@arc-ui/components 11.16.0 → 11.17.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (230) hide show
  1. package/dist/Calendar/Calendar.cjs.js +21 -0
  2. package/dist/Calendar/Calendar.esm.js +13 -0
  3. package/dist/Calendar/package.json +7 -0
  4. package/dist/Checkbox/Checkbox.cjs.js +3 -2
  5. package/dist/Checkbox/Checkbox.esm.js +3 -2
  6. package/dist/DatePicker/DatePicker.cjs.js +565 -0
  7. package/dist/DatePicker/DatePicker.esm.js +552 -0
  8. package/dist/DatePicker/package.json +7 -0
  9. package/dist/FormControl/FormControl.cjs.js +2 -1
  10. package/dist/FormControl/FormControl.esm.js +2 -1
  11. package/dist/InformationCard/InformationCard.cjs.js +10 -9
  12. package/dist/InformationCard/InformationCard.esm.js +8 -7
  13. package/dist/MediaCard/MediaCard.cjs.js +56 -0
  14. package/dist/MediaCard/MediaCard.esm.js +48 -0
  15. package/dist/MediaCard/package.json +7 -0
  16. package/dist/Modal/Modal.cjs.js +13 -286
  17. package/dist/Modal/Modal.esm.js +6 -279
  18. package/dist/RadioGroup/RadioGroup.cjs.js +3 -2
  19. package/dist/RadioGroup/RadioGroup.esm.js +3 -2
  20. package/dist/Select/Select.cjs.js +31 -2705
  21. package/dist/Select/Select.esm.js +13 -2668
  22. package/dist/SiteFooter/SiteFooter.cjs.js +2 -2
  23. package/dist/SiteFooter/SiteFooter.esm.js +3 -3
  24. package/dist/SiteHeader/SiteHeader.cjs.js +2 -2
  25. package/dist/SiteHeader/SiteHeader.esm.js +2 -2
  26. package/dist/SiteHeaderV2/SiteHeaderV2.cjs.js +23 -0
  27. package/dist/SiteHeaderV2/SiteHeaderV2.esm.js +15 -0
  28. package/dist/SiteHeaderV2/package.json +7 -0
  29. package/dist/Switch/Switch.cjs.js +4 -3
  30. package/dist/Switch/Switch.esm.js +4 -3
  31. package/dist/Tabs/Tabs.cjs.js +5 -5
  32. package/dist/Tabs/Tabs.esm.js +5 -5
  33. package/dist/TextArea/TextArea.cjs.js +20 -20
  34. package/dist/TextArea/TextArea.esm.js +20 -20
  35. package/dist/TextInput/TextInput.cjs.js +3 -2
  36. package/dist/TextInput/TextInput.esm.js +3 -2
  37. package/dist/Toast/Toast.cjs.js +6 -7
  38. package/dist/Toast/Toast.esm.js +6 -7
  39. package/dist/TypographyCard/TypographyCard.cjs.js +13 -70
  40. package/dist/TypographyCard/TypographyCard.esm.js +14 -71
  41. package/dist/_shared/cjs/Calendar-18e255f8.js +4106 -0
  42. package/dist/_shared/cjs/CardFooter-43c32239.js +80 -0
  43. package/dist/_shared/cjs/CardLabel-768abf20.js +54 -0
  44. package/dist/_shared/cjs/{Checkbox-904ad028.js → Checkbox-4d4b432f.js} +1 -1
  45. package/dist/_shared/cjs/{index-3d69ea00.js → Combination-9974f2e2.js} +662 -145
  46. package/dist/_shared/cjs/{FormControl-166e0957.js → FormControl-b26ad353.js} +8 -5
  47. package/dist/_shared/cjs/{RadioGroup-1eddf86f.js → RadioGroup-23c964ae.js} +1 -1
  48. package/dist/_shared/cjs/{SiteFooter-97c27b29.js → SiteFooter-65b6360c.js} +2 -2
  49. package/dist/_shared/cjs/{SiteHeader.rehydrator-af3dddef.js → SiteHeader.rehydrator-df053a52.js} +8 -8
  50. package/dist/_shared/cjs/SiteHeaderV2-8ce6d4fc.js +610 -0
  51. package/dist/_shared/cjs/{Tabs-cc77dabb.js → Tabs-34db6bc1.js} +4 -4
  52. package/dist/_shared/cjs/{TextInput-fd9c756f.js → TextInput-d0370fa8.js} +19 -6
  53. package/dist/_shared/cjs/{Toast-91e96744.js → Toast-392b1d60.js} +292 -34
  54. package/dist/_shared/cjs/{index-84e6a68f.js → index-6eb396a3.js} +1 -1
  55. package/dist/_shared/cjs/{index-6542b467.js → index-74004a9c.js} +1 -1
  56. package/dist/_shared/cjs/index-77ab5c6a.js +2180 -0
  57. package/dist/_shared/cjs/{index-d31f2b65.js → index-9f99d686.js} +1 -1
  58. package/dist/_shared/cjs/{index-1641d0b4.js → index-a31e64a9.js} +1 -1
  59. package/dist/_shared/cjs/{index-49c72a87.js → index-d38f1bd0.js} +1 -1
  60. package/dist/_shared/esm/Calendar-4033fa48.js +4093 -0
  61. package/dist/_shared/esm/CardFooter-dd8d4000.js +74 -0
  62. package/dist/_shared/esm/CardLabel-d6d71407.js +46 -0
  63. package/dist/_shared/esm/{Checkbox-8a5bb9a1.js → Checkbox-720b074d.js} +1 -1
  64. package/dist/_shared/esm/{index-3e2bc99d.js → Combination-e9f7e64e.js} +643 -132
  65. package/dist/_shared/esm/{FormControl-9d4ddfec.js → FormControl-f0b8fe91.js} +8 -5
  66. package/dist/_shared/esm/{RadioGroup-238db88d.js → RadioGroup-37fdb06b.js} +1 -1
  67. package/dist/_shared/esm/{SiteFooter-94316b8b.js → SiteFooter-38ee1536.js} +1 -1
  68. package/dist/_shared/esm/{SiteHeader.rehydrator-1b507253.js → SiteHeader.rehydrator-32bdcd88.js} +2 -2
  69. package/dist/_shared/esm/SiteHeaderV2-f8377627.js +604 -0
  70. package/dist/_shared/esm/{Tabs-8719d952.js → Tabs-df9965dd.js} +4 -4
  71. package/dist/_shared/esm/{TextInput-c1e2a1dd.js → TextInput-abbab56b.js} +19 -6
  72. package/dist/_shared/esm/{Toast-7cb1e544.js → Toast-5d66e13f.js} +264 -7
  73. package/dist/_shared/esm/{index-39019a9b.js → index-044da8d0.js} +1 -1
  74. package/dist/_shared/esm/{index-6b7b075c.js → index-25a5b393.js} +1 -1
  75. package/dist/_shared/esm/{index-246b4f18.js → index-2cfab9f2.js} +1 -1
  76. package/dist/_shared/esm/{index-12f3a407.js → index-7b531fa7.js} +68 -68
  77. package/dist/_shared/esm/index-b84a20c6.js +2155 -0
  78. package/dist/_shared/esm/{index-db47e95a.js → index-ca72c9d5.js} +1 -1
  79. package/dist/_shared/esm/{index-936b5179.js → index-efa9be1a.js} +1 -1
  80. package/dist/_shared/esm/{index.es-c552c0ea.js → use-media-query-4c807227.js} +9 -9
  81. package/dist/index.es.js +1135 -791
  82. package/dist/index.es.js.map +1 -1
  83. package/dist/index.js +1136 -791
  84. package/dist/index.js.map +1 -1
  85. package/dist/styles.css +4 -4
  86. package/dist/types/components/Calendar/Calendar.d.ts +49 -0
  87. package/dist/types/components/Calendar/Calendar.provider.d.ts +21 -0
  88. package/dist/types/components/Calendar/components/CalendarDateSelect/CalendarDateSelect.d.ts +15 -0
  89. package/dist/types/components/Calendar/components/CalendarDateSelect/index.d.ts +1 -0
  90. package/dist/types/components/Calendar/components/CalendarDayGrid/CalendarDayGrid.d.ts +6 -0
  91. package/dist/types/components/Calendar/components/CalendarDayGrid/index.d.ts +1 -0
  92. package/dist/types/components/Calendar/components/CalendarDayNumber/CalendarDayNumber.d.ts +8 -0
  93. package/dist/types/components/Calendar/components/CalendarDayNumber/index.d.ts +1 -0
  94. package/dist/types/components/Calendar/components/CalendarDoubleMonthView/CalendarDoubleMonthView.d.ts +9 -0
  95. package/dist/types/components/Calendar/components/CalendarDoubleMonthView/index.d.ts +1 -0
  96. package/dist/types/components/Calendar/components/CalendarFooter/CalendarFooter.d.ts +6 -0
  97. package/dist/types/components/Calendar/components/CalendarFooter/index.d.ts +1 -0
  98. package/dist/types/components/Calendar/components/CalendarMonthView/CalendarMonthView.d.ts +9 -0
  99. package/dist/types/components/Calendar/components/CalendarMonthView/index.d.ts +1 -0
  100. package/dist/types/components/Calendar/components/CalendarMonthYearView/CalendarMonthYearView.d.ts +11 -0
  101. package/dist/types/components/Calendar/components/CalendarMonthYearView/index.d.ts +1 -0
  102. package/dist/types/components/Calendar/components/CalendarNavButton/CalendarNavButton.d.ts +10 -0
  103. package/dist/types/components/Calendar/components/CalendarNavButton/index.d.ts +1 -0
  104. package/dist/types/components/Calendar/components/CalendarWrapper/CalendarWrapper.d.ts +5 -0
  105. package/dist/types/components/Calendar/components/CalendarWrapper/index.d.ts +1 -0
  106. package/dist/types/components/Calendar/components/index.d.ts +6 -0
  107. package/dist/types/components/Calendar/constants/day-names.d.ts +5 -0
  108. package/dist/types/components/Calendar/constants/index.d.ts +1 -0
  109. package/dist/types/components/Calendar/helpers/contains-date.d.ts +1 -0
  110. package/dist/types/components/Calendar/helpers/contains-date.test.d.ts +1 -0
  111. package/dist/types/components/Calendar/helpers/date-without-time.d.ts +1 -0
  112. package/dist/types/components/Calendar/helpers/date-without-time.test.d.ts +1 -0
  113. package/dist/types/components/Calendar/helpers/get-calendar-type.d.ts +2 -0
  114. package/dist/types/components/Calendar/helpers/get-calendar-type.test.d.ts +1 -0
  115. package/dist/types/components/Calendar/helpers/get-dates-in-month.d.ts +1 -0
  116. package/dist/types/components/Calendar/helpers/get-dates-in-month.test.d.ts +1 -0
  117. package/dist/types/components/Calendar/helpers/get-double-month-display-range.d.ts +1 -0
  118. package/dist/types/components/Calendar/helpers/get-double-month-display-range.test.d.ts +1 -0
  119. package/dist/types/components/Calendar/helpers/get-focus-date.d.ts +5 -0
  120. package/dist/types/components/Calendar/helpers/get-focus-date.test.d.ts +1 -0
  121. package/dist/types/components/Calendar/helpers/get-highlighted-range.d.ts +6 -0
  122. package/dist/types/components/Calendar/helpers/get-highlighted-range.test.d.ts +1 -0
  123. package/dist/types/components/Calendar/helpers/get-keydown-date.d.ts +6 -0
  124. package/dist/types/components/Calendar/helpers/get-keydown-date.test.d.ts +1 -0
  125. package/dist/types/components/Calendar/helpers/index.d.ts +13 -0
  126. package/dist/types/components/Calendar/helpers/is-day.d.ts +2 -0
  127. package/dist/types/components/Calendar/helpers/is-day.test.d.ts +1 -0
  128. package/dist/types/components/Calendar/helpers/is-disabled-date.d.ts +1 -0
  129. package/dist/types/components/Calendar/helpers/is-disabled-date.test.d.ts +1 -0
  130. package/dist/types/components/Calendar/helpers/is-month-after-max-date.d.ts +1 -0
  131. package/dist/types/components/Calendar/helpers/is-month-after-max-date.test.d.ts +1 -0
  132. package/dist/types/components/Calendar/helpers/is-month-before-min-date.d.ts +1 -0
  133. package/dist/types/components/Calendar/helpers/is-month-before-min-date.test.d.ts +1 -0
  134. package/dist/types/components/Calendar/helpers/process-selected-range.d.ts +9 -0
  135. package/dist/types/components/Calendar/helpers/process-selected-range.test.d.ts +1 -0
  136. package/dist/types/components/Calendar/index.d.ts +2 -0
  137. package/dist/types/components/Calendar/state/handlers/calendar-keydown-handler.d.ts +3 -0
  138. package/dist/types/components/Calendar/state/handlers/day-grid-leave-handler.d.ts +3 -0
  139. package/dist/types/components/Calendar/state/handlers/day-number-select-handler.d.ts +3 -0
  140. package/dist/types/components/Calendar/state/handlers/default-handler.d.ts +2 -0
  141. package/dist/types/components/Calendar/state/handlers/dropdown-change-month-handler.d.ts +3 -0
  142. package/dist/types/components/Calendar/state/handlers/dropdown-change-year-handler.d.ts +3 -0
  143. package/dist/types/components/Calendar/state/handlers/highlight-range-handler.d.ts +3 -0
  144. package/dist/types/components/Calendar/state/handlers/index.d.ts +12 -0
  145. package/dist/types/components/Calendar/state/handlers/range-select-handler.d.ts +3 -0
  146. package/dist/types/components/Calendar/state/handlers/show-next-double-month-handler.d.ts +3 -0
  147. package/dist/types/components/Calendar/state/handlers/show-next-month-handler.d.ts +3 -0
  148. package/dist/types/components/Calendar/state/handlers/show-previous-double-month-handler.d.ts +3 -0
  149. package/dist/types/components/Calendar/state/handlers/show-previous-month-handler.d.ts +3 -0
  150. package/dist/types/components/Calendar/state/index.d.ts +2 -0
  151. package/dist/types/components/Calendar/state/reducer.d.ts +3 -0
  152. package/dist/types/components/Calendar/state/reducer.test.d.ts +1 -0
  153. package/dist/types/components/Calendar/state/types/actions.d.ts +81 -0
  154. package/dist/types/components/Calendar/state/types/state-handler.d.ts +3 -0
  155. package/dist/types/components/Calendar/state/types/state.d.ts +5 -0
  156. package/dist/types/components/Calendar/types/calendar-type.d.ts +1 -0
  157. package/dist/types/components/Calendar/types/date-select-value.d.ts +2 -0
  158. package/dist/types/components/Calendar/types/index.d.ts +6 -0
  159. package/dist/types/components/Calendar/types/key-names.d.ts +13 -0
  160. package/dist/types/components/Calendar/types/range-selection.d.ts +10 -0
  161. package/dist/types/components/Calendar/types/selection-type.d.ts +1 -0
  162. package/dist/types/components/Calendar/types/week-days.d.ts +18 -0
  163. package/dist/types/components/DatePicker/DatePicker.d.ts +17 -0
  164. package/dist/types/components/DatePicker/constants/date-format.d.ts +1 -0
  165. package/dist/types/components/DatePicker/constants/index.d.ts +1 -0
  166. package/dist/types/components/DatePicker/helpers/convert-date-string-to-date.d.ts +1 -0
  167. package/dist/types/components/DatePicker/helpers/convert-date-string-to-date.test.d.ts +1 -0
  168. package/dist/types/components/DatePicker/helpers/convert-range-string-to-dates.d.ts +1 -0
  169. package/dist/types/components/DatePicker/helpers/convert-range-string-to-dates.test.d.ts +1 -0
  170. package/dist/types/components/DatePicker/helpers/format-date.d.ts +1 -0
  171. package/dist/types/components/DatePicker/helpers/format-date.test.d.ts +1 -0
  172. package/dist/types/components/DatePicker/helpers/index.d.ts +8 -0
  173. package/dist/types/components/DatePicker/helpers/is-date-valid.d.ts +1 -0
  174. package/dist/types/components/DatePicker/helpers/is-date-valid.test.d.ts +1 -0
  175. package/dist/types/components/DatePicker/helpers/is-disabled-date.d.ts +1 -0
  176. package/dist/types/components/DatePicker/helpers/is-disabled-date.test.d.ts +1 -0
  177. package/dist/types/components/DatePicker/helpers/is-range-valid.d.ts +1 -0
  178. package/dist/types/components/DatePicker/helpers/is-range-valid.test.d.ts +1 -0
  179. package/dist/types/components/DatePicker/helpers/parse-date-string.d.ts +5 -0
  180. package/dist/types/components/DatePicker/helpers/parse-date-string.test.d.ts +1 -0
  181. package/dist/types/components/DatePicker/helpers/parse-range-string.d.ts +14 -0
  182. package/dist/types/components/DatePicker/helpers/parse-range-string.test.d.ts +1 -0
  183. package/dist/types/components/DatePicker/index.d.ts +6 -0
  184. package/dist/types/components/FormControl/FormControl.d.ts +4 -0
  185. package/dist/types/components/RadioGroup/RadioGroup.d.ts +1 -1
  186. package/dist/types/components/SiteHeaderV2/SiteHeaderV2.d.ts +77 -0
  187. package/dist/types/components/SiteHeaderV2/components/BackButton/BackButton.d.ts +5 -0
  188. package/dist/types/components/SiteHeaderV2/components/BackButton/index.d.ts +1 -0
  189. package/dist/types/components/SiteHeaderV2/components/Column/Column.d.ts +8 -0
  190. package/dist/types/components/SiteHeaderV2/components/Column/index.d.ts +1 -0
  191. package/dist/types/components/SiteHeaderV2/components/HorizontalPanel/HorizontalPanel.d.ts +13 -0
  192. package/dist/types/components/SiteHeaderV2/components/HorizontalPanel/index.d.ts +1 -0
  193. package/dist/types/components/SiteHeaderV2/components/Item/Item.d.ts +20 -0
  194. package/dist/types/components/SiteHeaderV2/components/Item/index.d.ts +1 -0
  195. package/dist/types/components/SiteHeaderV2/components/ItemGroup/ItemGroup.d.ts +27 -0
  196. package/dist/types/components/SiteHeaderV2/components/ItemGroup/index.d.ts +1 -0
  197. package/dist/types/components/SiteHeaderV2/components/MenuButton/MenuButton.d.ts +6 -0
  198. package/dist/types/components/SiteHeaderV2/components/MenuButton/index.d.ts +1 -0
  199. package/dist/types/components/SiteHeaderV2/components/NavItem/NavItem.d.ts +40 -0
  200. package/dist/types/components/SiteHeaderV2/components/NavItem/NavItemWithSubNav.d.ts +55 -0
  201. package/dist/types/components/SiteHeaderV2/components/NavItem/index.d.ts +2 -0
  202. package/dist/types/components/SiteHeaderV2/components/NodeItem/NodeItem.d.ts +8 -0
  203. package/dist/types/components/SiteHeaderV2/components/Panel/Panel.d.ts +26 -0
  204. package/dist/types/components/SiteHeaderV2/components/Panel/index.d.ts +1 -0
  205. package/dist/types/components/SiteHeaderV2/components/SubNavItem/SubNavItem.d.ts +45 -0
  206. package/dist/types/components/SiteHeaderV2/components/SubNavItem/index.d.ts +1 -0
  207. package/dist/types/components/SiteHeaderV2/components/VerticalDivider/VerticalDivider.d.ts +1 -0
  208. package/dist/types/components/SiteHeaderV2/components/VerticalDivider/index.d.ts +1 -0
  209. package/dist/types/components/SiteHeaderV2/index.d.ts +1 -0
  210. package/dist/types/components/TextArea/TextArea.d.ts +4 -0
  211. package/dist/types/components/TextInput/TextInput.d.ts +22 -3
  212. package/dist/types/components/index.d.ts +1 -0
  213. package/dist/types/private-components/CardFooter/CardFooter.d.ts +11 -0
  214. package/dist/types/private-components/CardFooter/index.d.ts +1 -0
  215. package/dist/types/private-components/CardHeading/CardHeading.d.ts +19 -0
  216. package/dist/types/private-components/CardHeading/index.d.ts +1 -0
  217. package/dist/types/private-components/CardLabel/CardLabel.d.ts +10 -0
  218. package/dist/types/private-components/CardLabel/index.d.ts +1 -0
  219. package/dist/types/private-components/index.d.ts +4 -0
  220. package/dist/types/styles.d.ts +6 -0
  221. package/package.json +4 -2
  222. package/dist/_shared/cjs/BtIconArrowRight.esm-8e8ac316.js +0 -30
  223. package/dist/_shared/cjs/index-4ecad2dd.js +0 -273
  224. package/dist/_shared/esm/BtIconArrowRight.esm-267916a4.js +0 -24
  225. package/dist/_shared/esm/index-d0307140.js +0 -264
  226. package/dist/types/internal-components/index.d.ts +0 -1
  227. package/dist/_shared/cjs/{index-56a040f4.js → index-dd1d18ea.js} +66 -66
  228. package/dist/_shared/cjs/{index.es-26dd8c5d.js → use-media-query-e61881d8.js} +8 -8
  229. /package/dist/types/{internal-components → private-components}/ConditionalWrapper/ConditionalWrapper.d.ts +0 -0
  230. /package/dist/types/{internal-components → private-components}/ConditionalWrapper/index.d.ts +0 -0
@@ -0,0 +1,4093 @@
1
+ import React__default, { createContext, forwardRef, useContext, useCallback, useRef, useState, useReducer, useEffect } from 'react';
2
+ import { u as useMediaQuery, A as ArcBreakpointM } from './use-media-query-4c807227.js';
3
+ import { b as __spreadArray, a as __assign } from './filter-data-attrs-ea8f4ed4.js';
4
+ import { c as classNames } from './index-2e73c2e9.js';
5
+ import { T as Text } from './Text-14f586ac.js';
6
+ import { V as VisuallyHidden } from './VisuallyHidden-b9eebf71.js';
7
+ import { S as Surface } from './Surface-0ca6817d.js';
8
+ import { H as Heading } from './Heading-d16e0e53.js';
9
+ import { B as BtIconChevronLeftMid } from './BtIconChevronLeftMid.esm-1ed8330b.js';
10
+ import { B as BtIconChevronRightMid } from './BtIconChevronRightMid.esm-32268f1a.js';
11
+ import { I as Icon } from './Icon-abd0d990.js';
12
+
13
+ function toInteger(dirtyNumber) {
14
+ if (dirtyNumber === null || dirtyNumber === true || dirtyNumber === false) {
15
+ return NaN;
16
+ }
17
+ var number = Number(dirtyNumber);
18
+ if (isNaN(number)) {
19
+ return number;
20
+ }
21
+ return number < 0 ? Math.ceil(number) : Math.floor(number);
22
+ }
23
+
24
+ function _typeof(o) {
25
+ "@babel/helpers - typeof";
26
+
27
+ return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) {
28
+ return typeof o;
29
+ } : function (o) {
30
+ return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
31
+ }, _typeof(o);
32
+ }
33
+
34
+ function requiredArgs(required, args) {
35
+ if (args.length < required) {
36
+ throw new TypeError(required + ' argument' + (required > 1 ? 's' : '') + ' required, but only ' + args.length + ' present');
37
+ }
38
+ }
39
+
40
+ /**
41
+ * @name toDate
42
+ * @category Common Helpers
43
+ * @summary Convert the given argument to an instance of Date.
44
+ *
45
+ * @description
46
+ * Convert the given argument to an instance of Date.
47
+ *
48
+ * If the argument is an instance of Date, the function returns its clone.
49
+ *
50
+ * If the argument is a number, it is treated as a timestamp.
51
+ *
52
+ * If the argument is none of the above, the function returns Invalid Date.
53
+ *
54
+ * **Note**: *all* Date arguments passed to any *date-fns* function is processed by `toDate`.
55
+ *
56
+ * @param {Date|Number} argument - the value to convert
57
+ * @returns {Date} the parsed date in the local time zone
58
+ * @throws {TypeError} 1 argument required
59
+ *
60
+ * @example
61
+ * // Clone the date:
62
+ * const result = toDate(new Date(2014, 1, 11, 11, 30, 30))
63
+ * //=> Tue Feb 11 2014 11:30:30
64
+ *
65
+ * @example
66
+ * // Convert the timestamp to date:
67
+ * const result = toDate(1392098430000)
68
+ * //=> Tue Feb 11 2014 11:30:30
69
+ */
70
+ function toDate(argument) {
71
+ requiredArgs(1, arguments);
72
+ var argStr = Object.prototype.toString.call(argument);
73
+
74
+ // Clone the date
75
+ if (argument instanceof Date || _typeof(argument) === 'object' && argStr === '[object Date]') {
76
+ // Prevent the date to lose the milliseconds when passed to new Date() in IE10
77
+ return new Date(argument.getTime());
78
+ } else if (typeof argument === 'number' || argStr === '[object Number]') {
79
+ return new Date(argument);
80
+ } else {
81
+ if ((typeof argument === 'string' || argStr === '[object String]') && typeof console !== 'undefined') {
82
+ // eslint-disable-next-line no-console
83
+ 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");
84
+ // eslint-disable-next-line no-console
85
+ console.warn(new Error().stack);
86
+ }
87
+ return new Date(NaN);
88
+ }
89
+ }
90
+
91
+ /**
92
+ * @name addMonths
93
+ * @category Month Helpers
94
+ * @summary Add the specified number of months to the given date.
95
+ *
96
+ * @description
97
+ * Add the specified number of months to the given date.
98
+ *
99
+ * @param {Date|Number} date - the date to be changed
100
+ * @param {Number} amount - the amount of months to be added. Positive decimals will be rounded using `Math.floor`, decimals less than zero will be rounded using `Math.ceil`.
101
+ * @returns {Date} the new date with the months added
102
+ * @throws {TypeError} 2 arguments required
103
+ *
104
+ * @example
105
+ * // Add 5 months to 1 September 2014:
106
+ * const result = addMonths(new Date(2014, 8, 1), 5)
107
+ * //=> Sun Feb 01 2015 00:00:00
108
+ */
109
+ function addMonths(dirtyDate, dirtyAmount) {
110
+ requiredArgs(2, arguments);
111
+ var date = toDate(dirtyDate);
112
+ var amount = toInteger(dirtyAmount);
113
+ if (isNaN(amount)) {
114
+ return new Date(NaN);
115
+ }
116
+ if (!amount) {
117
+ // If 0 months, no-op to avoid changing times in the hour before end of DST
118
+ return date;
119
+ }
120
+ var dayOfMonth = date.getDate();
121
+
122
+ // The JS Date object supports date math by accepting out-of-bounds values for
123
+ // month, day, etc. For example, new Date(2020, 0, 0) returns 31 Dec 2019 and
124
+ // new Date(2020, 13, 1) returns 1 Feb 2021. This is *almost* the behavior we
125
+ // want except that dates will wrap around the end of a month, meaning that
126
+ // new Date(2020, 13, 31) will return 3 Mar 2021 not 28 Feb 2021 as desired. So
127
+ // we'll default to the end of the desired month by adding 1 to the desired
128
+ // month and using a date of 0 to back up one day to the end of the desired
129
+ // month.
130
+ var endOfDesiredMonth = new Date(date.getTime());
131
+ endOfDesiredMonth.setMonth(date.getMonth() + amount + 1, 0);
132
+ var daysInMonth = endOfDesiredMonth.getDate();
133
+ if (dayOfMonth >= daysInMonth) {
134
+ // If we're already at the end of the month, then this is the correct date
135
+ // and we're done.
136
+ return endOfDesiredMonth;
137
+ } else {
138
+ // Otherwise, we now know that setting the original day-of-month value won't
139
+ // cause an overflow, so set the desired day-of-month. Note that we can't
140
+ // just set the date of `endOfDesiredMonth` because that object may have had
141
+ // its time changed in the unusual case where where a DST transition was on
142
+ // the last day of the month and its local time was in the hour skipped or
143
+ // repeated next to a DST transition. So we use `date` instead which is
144
+ // guaranteed to still have the original time.
145
+ date.setFullYear(endOfDesiredMonth.getFullYear(), endOfDesiredMonth.getMonth(), dayOfMonth);
146
+ return date;
147
+ }
148
+ }
149
+
150
+ /**
151
+ * @name subMonths
152
+ * @category Month Helpers
153
+ * @summary Subtract the specified number of months from the given date.
154
+ *
155
+ * @description
156
+ * Subtract the specified number of months from the given date.
157
+ *
158
+ * @param {Date|Number} date - the date to be changed
159
+ * @param {Number} amount - the amount of months to be subtracted. Positive decimals will be rounded using `Math.floor`, decimals less than zero will be rounded using `Math.ceil`.
160
+ * @returns {Date} the new date with the months subtracted
161
+ * @throws {TypeError} 2 arguments required
162
+ *
163
+ * @example
164
+ * // Subtract 5 months from 1 February 2015:
165
+ * const result = subMonths(new Date(2015, 1, 1), 5)
166
+ * //=> Mon Sep 01 2014 00:00:00
167
+ */
168
+ function subMonths(dirtyDate, dirtyAmount) {
169
+ requiredArgs(2, arguments);
170
+ var amount = toInteger(dirtyAmount);
171
+ return addMonths(dirtyDate, -amount);
172
+ }
173
+
174
+ /**
175
+ * @name startOfMonth
176
+ * @category Month Helpers
177
+ * @summary Return the start of a month for the given date.
178
+ *
179
+ * @description
180
+ * Return the start of a month for the given date.
181
+ * The result will be in the local timezone.
182
+ *
183
+ * @param {Date|Number} date - the original date
184
+ * @returns {Date} the start of a month
185
+ * @throws {TypeError} 1 argument required
186
+ *
187
+ * @example
188
+ * // The start of a month for 2 September 2014 11:55:00:
189
+ * const result = startOfMonth(new Date(2014, 8, 2, 11, 55, 0))
190
+ * //=> Mon Sep 01 2014 00:00:00
191
+ */
192
+ function startOfMonth(dirtyDate) {
193
+ requiredArgs(1, arguments);
194
+ var date = toDate(dirtyDate);
195
+ date.setDate(1);
196
+ date.setHours(0, 0, 0, 0);
197
+ return date;
198
+ }
199
+
200
+ var containsDate = function (dates, compareDate) {
201
+ return dates.map(function (date) { return date.getTime(); }).includes(compareDate.getTime());
202
+ };
203
+
204
+ /**
205
+ * @name getMonth
206
+ * @category Month Helpers
207
+ * @summary Get the month of the given date.
208
+ *
209
+ * @description
210
+ * Get the month of the given date.
211
+ *
212
+ * @param {Date|Number} date - the given date
213
+ * @returns {Number} the month
214
+ * @throws {TypeError} 1 argument required
215
+ *
216
+ * @example
217
+ * // Which month is 29 February 2012?
218
+ * const result = getMonth(new Date(2012, 1, 29))
219
+ * //=> 1
220
+ */
221
+ function getMonth(dirtyDate) {
222
+ requiredArgs(1, arguments);
223
+ var date = toDate(dirtyDate);
224
+ var month = date.getMonth();
225
+ return month;
226
+ }
227
+
228
+ /**
229
+ * @name getYear
230
+ * @category Year Helpers
231
+ * @summary Get the year of the given date.
232
+ *
233
+ * @description
234
+ * Get the year of the given date.
235
+ *
236
+ * @param {Date|Number} date - the given date
237
+ * @returns {Number} the year
238
+ * @throws {TypeError} 1 argument required
239
+ *
240
+ * @example
241
+ * // Which year is 2 July 2014?
242
+ * const result = getYear(new Date(2014, 6, 2))
243
+ * //=> 2014
244
+ */
245
+ function getYear(dirtyDate) {
246
+ requiredArgs(1, arguments);
247
+ return toDate(dirtyDate).getFullYear();
248
+ }
249
+
250
+ /**
251
+ * @name getDaysInMonth
252
+ * @category Month Helpers
253
+ * @summary Get the number of days in a month of the given date.
254
+ *
255
+ * @description
256
+ * Get the number of days in a month of the given date.
257
+ *
258
+ * @param {Date|Number} date - the given date
259
+ * @returns {Number} the number of days in a month
260
+ * @throws {TypeError} 1 argument required
261
+ *
262
+ * @example
263
+ * // How many days are in February 2000?
264
+ * const result = getDaysInMonth(new Date(2000, 1))
265
+ * //=> 29
266
+ */
267
+ function getDaysInMonth(dirtyDate) {
268
+ requiredArgs(1, arguments);
269
+ var date = toDate(dirtyDate);
270
+ var year = date.getFullYear();
271
+ var monthIndex = date.getMonth();
272
+ var lastDayOfMonth = new Date(0);
273
+ lastDayOfMonth.setFullYear(year, monthIndex + 1, 0);
274
+ lastDayOfMonth.setHours(0, 0, 0, 0);
275
+ return lastDayOfMonth.getDate();
276
+ }
277
+
278
+ /**
279
+ * @name setMonth
280
+ * @category Month Helpers
281
+ * @summary Set the month to the given date.
282
+ *
283
+ * @description
284
+ * Set the month to the given date.
285
+ *
286
+ * @param {Date|Number} date - the date to be changed
287
+ * @param {Number} month - the month of the new date
288
+ * @returns {Date} the new date with the month set
289
+ * @throws {TypeError} 2 arguments required
290
+ *
291
+ * @example
292
+ * // Set February to 1 September 2014:
293
+ * const result = setMonth(new Date(2014, 8, 1), 1)
294
+ * //=> Sat Feb 01 2014 00:00:00
295
+ */
296
+ function setMonth(dirtyDate, dirtyMonth) {
297
+ requiredArgs(2, arguments);
298
+ var date = toDate(dirtyDate);
299
+ var month = toInteger(dirtyMonth);
300
+ var year = date.getFullYear();
301
+ var day = date.getDate();
302
+ var dateWithDesiredMonth = new Date(0);
303
+ dateWithDesiredMonth.setFullYear(year, month, 15);
304
+ dateWithDesiredMonth.setHours(0, 0, 0, 0);
305
+ var daysInMonth = getDaysInMonth(dateWithDesiredMonth);
306
+ // Set the last day of the new month
307
+ // if the original date was the last day of the longer month
308
+ date.setMonth(month, Math.min(day, daysInMonth));
309
+ return date;
310
+ }
311
+
312
+ /**
313
+ * @name set
314
+ * @category Common Helpers
315
+ * @summary Set date values to a given date.
316
+ *
317
+ * @description
318
+ * Set date values to a given date.
319
+ *
320
+ * Sets time values to date from object `values`.
321
+ * A value is not set if it is undefined or null or doesn't exist in `values`.
322
+ *
323
+ * Note about bundle size: `set` does not internally use `setX` functions from date-fns but instead opts
324
+ * to use native `Date#setX` methods. If you use this function, you may not want to include the
325
+ * other `setX` functions that date-fns provides if you are concerned about the bundle size.
326
+ *
327
+ * @param {Date|Number} date - the date to be changed
328
+ * @param {Object} values - an object with options
329
+ * @param {Number} [values.year] - the number of years to be set
330
+ * @param {Number} [values.month] - the number of months to be set
331
+ * @param {Number} [values.date] - the number of days to be set
332
+ * @param {Number} [values.hours] - the number of hours to be set
333
+ * @param {Number} [values.minutes] - the number of minutes to be set
334
+ * @param {Number} [values.seconds] - the number of seconds to be set
335
+ * @param {Number} [values.milliseconds] - the number of milliseconds to be set
336
+ * @returns {Date} the new date with options set
337
+ * @throws {TypeError} 2 arguments required
338
+ * @throws {RangeError} `values` must be an object
339
+ *
340
+ * @example
341
+ * // Transform 1 September 2014 into 20 October 2015 in a single line:
342
+ * const result = set(new Date(2014, 8, 20), { year: 2015, month: 9, date: 20 })
343
+ * //=> Tue Oct 20 2015 00:00:00
344
+ *
345
+ * @example
346
+ * // Set 12 PM to 1 September 2014 01:23:45 to 1 September 2014 12:00:00:
347
+ * const result = set(new Date(2014, 8, 1, 1, 23, 45), { hours: 12 })
348
+ * //=> Mon Sep 01 2014 12:23:45
349
+ */
350
+ function set(dirtyDate, values) {
351
+ requiredArgs(2, arguments);
352
+ if (_typeof(values) !== 'object' || values === null) {
353
+ throw new RangeError('values parameter must be an object');
354
+ }
355
+ var date = toDate(dirtyDate);
356
+
357
+ // Check if date is Invalid Date because Date.prototype.setFullYear ignores the value of Invalid Date
358
+ if (isNaN(date.getTime())) {
359
+ return new Date(NaN);
360
+ }
361
+ if (values.year != null) {
362
+ date.setFullYear(values.year);
363
+ }
364
+ if (values.month != null) {
365
+ date = setMonth(date, values.month);
366
+ }
367
+ if (values.date != null) {
368
+ date.setDate(toInteger(values.date));
369
+ }
370
+ if (values.hours != null) {
371
+ date.setHours(toInteger(values.hours));
372
+ }
373
+ if (values.minutes != null) {
374
+ date.setMinutes(toInteger(values.minutes));
375
+ }
376
+ if (values.seconds != null) {
377
+ date.setSeconds(toInteger(values.seconds));
378
+ }
379
+ if (values.milliseconds != null) {
380
+ date.setMilliseconds(toInteger(values.milliseconds));
381
+ }
382
+ return date;
383
+ }
384
+
385
+ var dateWithoutTime = function (date) {
386
+ return set(new Date(date), {
387
+ hours: 0,
388
+ minutes: 0,
389
+ milliseconds: 0,
390
+ seconds: 0
391
+ });
392
+ };
393
+
394
+ var getDatesInMonth = function (date) {
395
+ var dateYear = getYear(date);
396
+ var dateMonth = getMonth(date);
397
+ return Array.from({ length: getDaysInMonth(date) }, function (_, i) {
398
+ return dateWithoutTime(new Date(dateYear, dateMonth, i + 1));
399
+ });
400
+ };
401
+
402
+ /**
403
+ * @name getDay
404
+ * @category Weekday Helpers
405
+ * @summary Get the day of the week of the given date.
406
+ *
407
+ * @description
408
+ * Get the day of the week of the given date.
409
+ *
410
+ * @param {Date|Number} date - the given date
411
+ * @returns {0|1|2|3|4|5|6} the day of week, 0 represents Sunday
412
+ * @throws {TypeError} 1 argument required
413
+ *
414
+ * @example
415
+ * // Which day of the week is 29 February 2012?
416
+ * const result = getDay(new Date(2012, 1, 29))
417
+ * //=> 3
418
+ */
419
+ function getDay(dirtyDate) {
420
+ requiredArgs(1, arguments);
421
+ var date = toDate(dirtyDate);
422
+ var day = date.getDay();
423
+ return day;
424
+ }
425
+
426
+ var WeekDaysAbbr;
427
+ (function (WeekDaysAbbr) {
428
+ WeekDaysAbbr["MON"] = "Mon";
429
+ WeekDaysAbbr["TUE"] = "Tue";
430
+ WeekDaysAbbr["WED"] = "Wed";
431
+ WeekDaysAbbr["THUR"] = "Thur";
432
+ WeekDaysAbbr["FRI"] = "Fri";
433
+ WeekDaysAbbr["SAT"] = "Sat";
434
+ WeekDaysAbbr["SUN"] = "Sun";
435
+ })(WeekDaysAbbr || (WeekDaysAbbr = {}));
436
+ var WeekDays;
437
+ (function (WeekDays) {
438
+ WeekDays["MONDAY"] = "Monday";
439
+ WeekDays["TUESDAY"] = "Tuesday";
440
+ WeekDays["WEDNESDAY"] = "Wednesday";
441
+ WeekDays["THURSDAY"] = "Thursday";
442
+ WeekDays["FRIDAY"] = "Friday";
443
+ WeekDays["SATURDAY"] = "Saturday";
444
+ WeekDays["SUNDAY"] = "Sunday";
445
+ })(WeekDays || (WeekDays = {}));
446
+
447
+ var isDay = function (date, day) {
448
+ var _a;
449
+ var dayMap = (_a = {},
450
+ _a[WeekDays.MONDAY] = 1,
451
+ _a[WeekDays.TUESDAY] = 2,
452
+ _a[WeekDays.WEDNESDAY] = 3,
453
+ _a[WeekDays.THURSDAY] = 4,
454
+ _a[WeekDays.FRIDAY] = 5,
455
+ _a[WeekDays.SATURDAY] = 6,
456
+ _a[WeekDays.SUNDAY] = 0,
457
+ _a);
458
+ return getDay(date) === dayMap[day];
459
+ };
460
+
461
+ /**
462
+ * @name isBefore
463
+ * @category Common Helpers
464
+ * @summary Is the first date before the second one?
465
+ *
466
+ * @description
467
+ * Is the first date before the second one?
468
+ *
469
+ * @param {Date|Number} date - the date that should be before the other one to return true
470
+ * @param {Date|Number} dateToCompare - the date to compare with
471
+ * @returns {Boolean} the first date is before the second date
472
+ * @throws {TypeError} 2 arguments required
473
+ *
474
+ * @example
475
+ * // Is 10 July 1989 before 11 February 1987?
476
+ * const result = isBefore(new Date(1989, 6, 10), new Date(1987, 1, 11))
477
+ * //=> false
478
+ */
479
+ function isBefore(dirtyDate, dirtyDateToCompare) {
480
+ requiredArgs(2, arguments);
481
+ var date = toDate(dirtyDate);
482
+ var dateToCompare = toDate(dirtyDateToCompare);
483
+ return date.getTime() < dateToCompare.getTime();
484
+ }
485
+
486
+ /**
487
+ * @name isAfter
488
+ * @category Common Helpers
489
+ * @summary Is the first date after the second one?
490
+ *
491
+ * @description
492
+ * Is the first date after the second one?
493
+ *
494
+ * @param {Date|Number} date - the date that should be after the other one to return true
495
+ * @param {Date|Number} dateToCompare - the date to compare with
496
+ * @returns {Boolean} the first date is after the second date
497
+ * @throws {TypeError} 2 arguments required
498
+ *
499
+ * @example
500
+ * // Is 10 July 1989 after 11 February 1987?
501
+ * const result = isAfter(new Date(1989, 6, 10), new Date(1987, 1, 11))
502
+ * //=> true
503
+ */
504
+ function isAfter(dirtyDate, dirtyDateToCompare) {
505
+ requiredArgs(2, arguments);
506
+ var date = toDate(dirtyDate);
507
+ var dateToCompare = toDate(dirtyDateToCompare);
508
+ return date.getTime() > dateToCompare.getTime();
509
+ }
510
+
511
+ var isDisabledDate = function (date, disabledDates, minDate, maxDate) {
512
+ return ((minDate && isBefore(date, minDate)) ||
513
+ (maxDate && isAfter(date, maxDate)) ||
514
+ (disabledDates && containsDate(disabledDates, date)));
515
+ };
516
+
517
+ var isMonthBeforeMinDate = function (month, minDate) {
518
+ return getDatesInMonth(month).every(function (date) {
519
+ return isBefore(date, minDate);
520
+ });
521
+ };
522
+
523
+ var isMonthAfterMaxDate = function (date, maxDate) {
524
+ return getDatesInMonth(date).every(function (date) {
525
+ return isAfter(date, maxDate);
526
+ });
527
+ };
528
+
529
+ /**
530
+ * @name compareAsc
531
+ * @category Common Helpers
532
+ * @summary Compare the two dates and return -1, 0 or 1.
533
+ *
534
+ * @description
535
+ * Compare the two dates and return 1 if the first date is after the second,
536
+ * -1 if the first date is before the second or 0 if dates are equal.
537
+ *
538
+ * @param {Date|Number} dateLeft - the first date to compare
539
+ * @param {Date|Number} dateRight - the second date to compare
540
+ * @returns {Number} the result of the comparison
541
+ * @throws {TypeError} 2 arguments required
542
+ *
543
+ * @example
544
+ * // Compare 11 February 1987 and 10 July 1989:
545
+ * const result = compareAsc(new Date(1987, 1, 11), new Date(1989, 6, 10))
546
+ * //=> -1
547
+ *
548
+ * @example
549
+ * // Sort the array of dates:
550
+ * const result = [
551
+ * new Date(1995, 6, 2),
552
+ * new Date(1987, 1, 11),
553
+ * new Date(1989, 6, 10)
554
+ * ].sort(compareAsc)
555
+ * //=> [
556
+ * // Wed Feb 11 1987 00:00:00,
557
+ * // Mon Jul 10 1989 00:00:00,
558
+ * // Sun Jul 02 1995 00:00:00
559
+ * // ]
560
+ */
561
+ function compareAsc(dirtyDateLeft, dirtyDateRight) {
562
+ requiredArgs(2, arguments);
563
+ var dateLeft = toDate(dirtyDateLeft);
564
+ var dateRight = toDate(dirtyDateRight);
565
+ var diff = dateLeft.getTime() - dateRight.getTime();
566
+ if (diff < 0) {
567
+ return -1;
568
+ } else if (diff > 0) {
569
+ return 1;
570
+ // Return 0 if diff is 0; return NaN if diff is NaN
571
+ } else {
572
+ return diff;
573
+ }
574
+ }
575
+
576
+ /**
577
+ * @name eachDayOfInterval
578
+ * @category Interval Helpers
579
+ * @summary Return the array of dates within the specified time interval.
580
+ *
581
+ * @description
582
+ * Return the array of dates within the specified time interval.
583
+ *
584
+ * @param {Interval} interval - the interval. See [Interval]{@link https://date-fns.org/docs/Interval}
585
+ * @param {Object} [options] - an object with options.
586
+ * @param {Number} [options.step=1] - the step to increment by. The value should be more than 1.
587
+ * @returns {Date[]} the array with starts of days from the day of the interval start to the day of the interval end
588
+ * @throws {TypeError} 1 argument required
589
+ * @throws {RangeError} `options.step` must be a number greater than 1
590
+ * @throws {RangeError} The start of an interval cannot be after its end
591
+ * @throws {RangeError} Date in interval cannot be `Invalid Date`
592
+ *
593
+ * @example
594
+ * // Each day between 6 October 2014 and 10 October 2014:
595
+ * const result = eachDayOfInterval({
596
+ * start: new Date(2014, 9, 6),
597
+ * end: new Date(2014, 9, 10)
598
+ * })
599
+ * //=> [
600
+ * // Mon Oct 06 2014 00:00:00,
601
+ * // Tue Oct 07 2014 00:00:00,
602
+ * // Wed Oct 08 2014 00:00:00,
603
+ * // Thu Oct 09 2014 00:00:00,
604
+ * // Fri Oct 10 2014 00:00:00
605
+ * // ]
606
+ */
607
+ function eachDayOfInterval(dirtyInterval, options) {
608
+ var _options$step;
609
+ requiredArgs(1, arguments);
610
+ var interval = dirtyInterval || {};
611
+ var startDate = toDate(interval.start);
612
+ var endDate = toDate(interval.end);
613
+ var endTime = endDate.getTime();
614
+
615
+ // Throw an exception if start date is after end date or if any date is `Invalid Date`
616
+ if (!(startDate.getTime() <= endTime)) {
617
+ throw new RangeError('Invalid interval');
618
+ }
619
+ var dates = [];
620
+ var currentDate = startDate;
621
+ currentDate.setHours(0, 0, 0, 0);
622
+ var step = Number((_options$step = options === null || options === void 0 ? void 0 : options.step) !== null && _options$step !== void 0 ? _options$step : 1);
623
+ if (step < 1 || isNaN(step)) throw new RangeError('`options.step` must be a number greater than 1');
624
+ while (currentDate.getTime() <= endTime) {
625
+ dates.push(toDate(currentDate));
626
+ currentDate.setDate(currentDate.getDate() + step);
627
+ currentDate.setHours(0, 0, 0, 0);
628
+ }
629
+ return dates;
630
+ }
631
+
632
+ var processSelectedRange = function (_a) {
633
+ var range = _a.range, value = _a.value, disabledDates = _a.disabledDates;
634
+ var exisitingRange = range.filter(function (date) { return Boolean(date); });
635
+ var newRange = __spreadArray(__spreadArray([], (exisitingRange.length === 2 ? [] : exisitingRange), true), [
636
+ value,
637
+ ], false).sort(compareAsc);
638
+ var isSelectionComplete = newRange.length === 2;
639
+ var allDaysInRange = isSelectionComplete
640
+ ? eachDayOfInterval({
641
+ start: newRange[0],
642
+ end: newRange[1]
643
+ })
644
+ : [];
645
+ var rangeOnChangeValue = {
646
+ dates: allDaysInRange.map(function (date) { return ({
647
+ value: date,
648
+ disabled: disabledDates ? containsDate(disabledDates, date) : false
649
+ }); }),
650
+ selectedDate: value,
651
+ start: newRange[0],
652
+ end: newRange[1],
653
+ isSelectionComplete: isSelectionComplete
654
+ };
655
+ return {
656
+ rangeValue: newRange,
657
+ rangeOnChangeValue: rangeOnChangeValue
658
+ };
659
+ };
660
+
661
+ var getCalendarType = function (type, isDesktop) {
662
+ if (type === "double" && !isDesktop) {
663
+ return "month";
664
+ }
665
+ if (type === "double" && isDesktop) {
666
+ return "double";
667
+ }
668
+ return type;
669
+ };
670
+
671
+ var getDoubleMonthDisplayRange = function (date) {
672
+ var firstMonth = getMonth(date) % 2 !== 0 ? subMonths(date, 1) : date;
673
+ var secondMonth = addMonths(firstMonth, 1);
674
+ return [firstMonth, secondMonth];
675
+ };
676
+
677
+ var getFocusDate = function (_a) {
678
+ var minDate = _a.minDate, maxDate = _a.maxDate, date = _a.date;
679
+ var isFocusDateBeforeMinDate = minDate && isBefore(date, minDate);
680
+ var isFocusDateAfterMaxDate = maxDate && isAfter(date, maxDate);
681
+ if (isFocusDateBeforeMinDate) {
682
+ return minDate;
683
+ }
684
+ if (isFocusDateAfterMaxDate) {
685
+ return maxDate;
686
+ }
687
+ return date;
688
+ };
689
+
690
+ var getHighlightRange = function (_a) {
691
+ var date = _a.date, minDate = _a.minDate, maxDate = _a.maxDate, range = _a.range;
692
+ var existingRange = range.filter(function (date) { return Boolean(date); });
693
+ if (existingRange.filter(function (date) { return Boolean(date); }).length === 1) {
694
+ var isDateBeforeMinDate = minDate && isBefore(date, minDate);
695
+ var isDateAfterMaxDate = maxDate && isAfter(date, maxDate);
696
+ if (isDateBeforeMinDate) {
697
+ return [minDate, existingRange[0]].sort(compareAsc);
698
+ }
699
+ if (isDateAfterMaxDate) {
700
+ return [maxDate, existingRange[0]].sort(compareAsc);
701
+ }
702
+ return [date, existingRange[0]].sort(compareAsc);
703
+ }
704
+ return existingRange;
705
+ };
706
+
707
+ /**
708
+ * @name addDays
709
+ * @category Day Helpers
710
+ * @summary Add the specified number of days to the given date.
711
+ *
712
+ * @description
713
+ * Add the specified number of days to the given date.
714
+ *
715
+ * @param {Date|Number} date - the date to be changed
716
+ * @param {Number} amount - the amount of days to be added. Positive decimals will be rounded using `Math.floor`, decimals less than zero will be rounded using `Math.ceil`.
717
+ * @returns {Date} - the new date with the days added
718
+ * @throws {TypeError} - 2 arguments required
719
+ *
720
+ * @example
721
+ * // Add 10 days to 1 September 2014:
722
+ * const result = addDays(new Date(2014, 8, 1), 10)
723
+ * //=> Thu Sep 11 2014 00:00:00
724
+ */
725
+ function addDays(dirtyDate, dirtyAmount) {
726
+ requiredArgs(2, arguments);
727
+ var date = toDate(dirtyDate);
728
+ var amount = toInteger(dirtyAmount);
729
+ if (isNaN(amount)) {
730
+ return new Date(NaN);
731
+ }
732
+ if (!amount) {
733
+ // If 0 days, no-op to avoid changing times in the hour before end of DST
734
+ return date;
735
+ }
736
+ date.setDate(date.getDate() + amount);
737
+ return date;
738
+ }
739
+
740
+ /**
741
+ * @name addWeeks
742
+ * @category Week Helpers
743
+ * @summary Add the specified number of weeks to the given date.
744
+ *
745
+ * @description
746
+ * Add the specified number of week to the given date.
747
+ *
748
+ * @param {Date|Number} date - the date to be changed
749
+ * @param {Number} amount - the amount of weeks to be added. Positive decimals will be rounded using `Math.floor`, decimals less than zero will be rounded using `Math.ceil`.
750
+ * @returns {Date} the new date with the weeks added
751
+ * @throws {TypeError} 2 arguments required
752
+ *
753
+ * @example
754
+ * // Add 4 weeks to 1 September 2014:
755
+ * const result = addWeeks(new Date(2014, 8, 1), 4)
756
+ * //=> Mon Sep 29 2014 00:00:00
757
+ */
758
+ function addWeeks(dirtyDate, dirtyAmount) {
759
+ requiredArgs(2, arguments);
760
+ var amount = toInteger(dirtyAmount);
761
+ var days = amount * 7;
762
+ return addDays(dirtyDate, days);
763
+ }
764
+
765
+ /**
766
+ * @name subDays
767
+ * @category Day Helpers
768
+ * @summary Subtract the specified number of days from the given date.
769
+ *
770
+ * @description
771
+ * Subtract the specified number of days from the given date.
772
+ *
773
+ * @param {Date|Number} date - the date to be changed
774
+ * @param {Number} amount - the amount of days to be subtracted. Positive decimals will be rounded using `Math.floor`, decimals less than zero will be rounded using `Math.ceil`.
775
+ * @returns {Date} the new date with the days subtracted
776
+ * @throws {TypeError} 2 arguments required
777
+ *
778
+ * @example
779
+ * // Subtract 10 days from 1 September 2014:
780
+ * const result = subDays(new Date(2014, 8, 1), 10)
781
+ * //=> Fri Aug 22 2014 00:00:00
782
+ */
783
+ function subDays(dirtyDate, dirtyAmount) {
784
+ requiredArgs(2, arguments);
785
+ var amount = toInteger(dirtyAmount);
786
+ return addDays(dirtyDate, -amount);
787
+ }
788
+
789
+ var defaultOptions = {};
790
+ function getDefaultOptions() {
791
+ return defaultOptions;
792
+ }
793
+
794
+ /**
795
+ * @name startOfWeek
796
+ * @category Week Helpers
797
+ * @summary Return the start of a week for the given date.
798
+ *
799
+ * @description
800
+ * Return the start of a week for the given date.
801
+ * The result will be in the local timezone.
802
+ *
803
+ * @param {Date|Number} date - the original date
804
+ * @param {Object} [options] - an object with options.
805
+ * @param {Locale} [options.locale=defaultLocale] - the locale object. See [Locale]{@link https://date-fns.org/docs/Locale}
806
+ * @param {0|1|2|3|4|5|6} [options.weekStartsOn=0] - the index of the first day of the week (0 - Sunday)
807
+ * @returns {Date} the start of a week
808
+ * @throws {TypeError} 1 argument required
809
+ * @throws {RangeError} `options.weekStartsOn` must be between 0 and 6
810
+ *
811
+ * @example
812
+ * // The start of a week for 2 September 2014 11:55:00:
813
+ * const result = startOfWeek(new Date(2014, 8, 2, 11, 55, 0))
814
+ * //=> Sun Aug 31 2014 00:00:00
815
+ *
816
+ * @example
817
+ * // If the week starts on Monday, the start of the week for 2 September 2014 11:55:00:
818
+ * const result = startOfWeek(new Date(2014, 8, 2, 11, 55, 0), { weekStartsOn: 1 })
819
+ * //=> Mon Sep 01 2014 00:00:00
820
+ */
821
+ function startOfWeek(dirtyDate, options) {
822
+ var _ref, _ref2, _ref3, _options$weekStartsOn, _options$locale, _options$locale$optio, _defaultOptions$local, _defaultOptions$local2;
823
+ requiredArgs(1, arguments);
824
+ var defaultOptions = getDefaultOptions();
825
+ 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);
826
+
827
+ // Test if weekStartsOn is between 0 and 6 _and_ is not NaN
828
+ if (!(weekStartsOn >= 0 && weekStartsOn <= 6)) {
829
+ throw new RangeError('weekStartsOn must be between 0 and 6 inclusively');
830
+ }
831
+ var date = toDate(dirtyDate);
832
+ var day = date.getDay();
833
+ var diff = (day < weekStartsOn ? 7 : 0) + day - weekStartsOn;
834
+ date.setDate(date.getDate() - diff);
835
+ date.setHours(0, 0, 0, 0);
836
+ return date;
837
+ }
838
+
839
+ /**
840
+ * @name endOfWeek
841
+ * @category Week Helpers
842
+ * @summary Return the end of a week for the given date.
843
+ *
844
+ * @description
845
+ * Return the end of a week for the given date.
846
+ * The result will be in the local timezone.
847
+ *
848
+ * @param {Date|Number} date - the original date
849
+ * @param {Object} [options] - an object with options.
850
+ * @param {Locale} [options.locale=defaultLocale] - the locale object. See [Locale]{@link https://date-fns.org/docs/Locale}
851
+ * @param {0|1|2|3|4|5|6} [options.weekStartsOn=0] - the index of the first day of the week (0 - Sunday)
852
+ * @returns {Date} the end of a week
853
+ * @throws {TypeError} 1 argument required
854
+ * @throws {RangeError} `options.weekStartsOn` must be between 0 and 6
855
+ *
856
+ * @example
857
+ * // The end of a week for 2 September 2014 11:55:00:
858
+ * const result = endOfWeek(new Date(2014, 8, 2, 11, 55, 0))
859
+ * //=> Sat Sep 06 2014 23:59:59.999
860
+ *
861
+ * @example
862
+ * // If the week starts on Monday, the end of the week for 2 September 2014 11:55:00:
863
+ * const result = endOfWeek(new Date(2014, 8, 2, 11, 55, 0), { weekStartsOn: 1 })
864
+ * //=> Sun Sep 07 2014 23:59:59.999
865
+ */
866
+ function endOfWeek(dirtyDate, options) {
867
+ var _ref, _ref2, _ref3, _options$weekStartsOn, _options$locale, _options$locale$optio, _defaultOptions$local, _defaultOptions$local2;
868
+ requiredArgs(1, arguments);
869
+ var defaultOptions = getDefaultOptions();
870
+ 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);
871
+
872
+ // Test if weekStartsOn is between 0 and 6 _and_ is not NaN
873
+ if (!(weekStartsOn >= 0 && weekStartsOn <= 6)) {
874
+ throw new RangeError('weekStartsOn must be between 0 and 6 inclusively');
875
+ }
876
+ var date = toDate(dirtyDate);
877
+ var day = date.getDay();
878
+ var diff = (day < weekStartsOn ? -7 : 0) + 6 - (day - weekStartsOn);
879
+ date.setDate(date.getDate() + diff);
880
+ date.setHours(23, 59, 59, 999);
881
+ return date;
882
+ }
883
+
884
+ /**
885
+ * @name subWeeks
886
+ * @category Week Helpers
887
+ * @summary Subtract the specified number of weeks from the given date.
888
+ *
889
+ * @description
890
+ * Subtract the specified number of weeks from the given date.
891
+ *
892
+ * @param {Date|Number} date - the date to be changed
893
+ * @param {Number} amount - the amount of weeks to be subtracted. Positive decimals will be rounded using `Math.floor`, decimals less than zero will be rounded using `Math.ceil`.
894
+ * @returns {Date} the new date with the weeks subtracted
895
+ * @throws {TypeError} 2 arguments required
896
+ *
897
+ * @example
898
+ * // Subtract 4 weeks from 1 September 2014:
899
+ * const result = subWeeks(new Date(2014, 8, 1), 4)
900
+ * //=> Mon Aug 04 2014 00:00:00
901
+ */
902
+ function subWeeks(dirtyDate, dirtyAmount) {
903
+ requiredArgs(2, arguments);
904
+ var amount = toInteger(dirtyAmount);
905
+ return addWeeks(dirtyDate, -amount);
906
+ }
907
+
908
+ /**
909
+ * @name addYears
910
+ * @category Year Helpers
911
+ * @summary Add the specified number of years to the given date.
912
+ *
913
+ * @description
914
+ * Add the specified number of years to the given date.
915
+ *
916
+ * @param {Date|Number} date - the date to be changed
917
+ * @param {Number} amount - the amount of years to be added. Positive decimals will be rounded using `Math.floor`, decimals less than zero will be rounded using `Math.ceil`.
918
+ * @returns {Date} the new date with the years added
919
+ * @throws {TypeError} 2 arguments required
920
+ *
921
+ * @example
922
+ * // Add 5 years to 1 September 2014:
923
+ * const result = addYears(new Date(2014, 8, 1), 5)
924
+ * //=> Sun Sep 01 2019 00:00:00
925
+ */
926
+ function addYears(dirtyDate, dirtyAmount) {
927
+ requiredArgs(2, arguments);
928
+ var amount = toInteger(dirtyAmount);
929
+ return addMonths(dirtyDate, amount * 12);
930
+ }
931
+
932
+ /**
933
+ * @name subYears
934
+ * @category Year Helpers
935
+ * @summary Subtract the specified number of years from the given date.
936
+ *
937
+ * @description
938
+ * Subtract the specified number of years from the given date.
939
+ *
940
+ * @param {Date|Number} date - the date to be changed
941
+ * @param {Number} amount - the amount of years to be subtracted. Positive decimals will be rounded using `Math.floor`, decimals less than zero will be rounded using `Math.ceil`.
942
+ * @returns {Date} the new date with the years subtracted
943
+ * @throws {TypeError} 2 arguments required
944
+ *
945
+ * @example
946
+ * // Subtract 5 years from 1 September 2014:
947
+ * const result = subYears(new Date(2014, 8, 1), 5)
948
+ * //=> Tue Sep 01 2009 00:00:00
949
+ */
950
+ function subYears(dirtyDate, dirtyAmount) {
951
+ requiredArgs(2, arguments);
952
+ var amount = toInteger(dirtyAmount);
953
+ return addYears(dirtyDate, -amount);
954
+ }
955
+
956
+ var KeyNames;
957
+ (function (KeyNames) {
958
+ KeyNames["ArrowUp"] = "ArrowUp";
959
+ KeyNames["ArrowDown"] = "ArrowDown";
960
+ KeyNames["ArrowLeft"] = "ArrowLeft";
961
+ KeyNames["ArrowRight"] = "ArrowRight";
962
+ KeyNames["Home"] = "Home";
963
+ KeyNames["End"] = "End";
964
+ KeyNames["PageUp"] = "PageUp";
965
+ KeyNames["PageDown"] = "PageDown";
966
+ KeyNames["Tab"] = "Tab";
967
+ KeyNames["Enter"] = "Enter";
968
+ KeyNames["Space"] = " ";
969
+ })(KeyNames || (KeyNames = {}));
970
+
971
+ var getKeyDownDate = function (_a) {
972
+ var key = _a.key, shiftKey = _a.shiftKey, focusDate = _a.focusDate;
973
+ switch (key) {
974
+ case KeyNames.ArrowDown:
975
+ return addWeeks(focusDate, 1);
976
+ case KeyNames.ArrowLeft:
977
+ return subDays(focusDate, 1);
978
+ case KeyNames.ArrowRight:
979
+ return addDays(focusDate, 1);
980
+ case KeyNames.ArrowUp:
981
+ return subWeeks(focusDate, 1);
982
+ case KeyNames.Home:
983
+ return dateWithoutTime(startOfWeek(focusDate, { weekStartsOn: 1 }));
984
+ case KeyNames.End:
985
+ return dateWithoutTime(endOfWeek(focusDate, { weekStartsOn: 1 }));
986
+ case KeyNames.PageUp:
987
+ return shiftKey ? subYears(focusDate, 1) : subMonths(focusDate, 1);
988
+ case KeyNames.PageDown:
989
+ return shiftKey ? addYears(focusDate, 1) : addMonths(focusDate, 1);
990
+ default:
991
+ return focusDate;
992
+ }
993
+ };
994
+
995
+ /**
996
+ * @name endOfDay
997
+ * @category Day Helpers
998
+ * @summary Return the end of a day for the given date.
999
+ *
1000
+ * @description
1001
+ * Return the end of a day for the given date.
1002
+ * The result will be in the local timezone.
1003
+ *
1004
+ * @param {Date|Number} date - the original date
1005
+ * @returns {Date} the end of a day
1006
+ * @throws {TypeError} 1 argument required
1007
+ *
1008
+ * @example
1009
+ * // The end of a day for 2 September 2014 11:55:00:
1010
+ * const result = endOfDay(new Date(2014, 8, 2, 11, 55, 0))
1011
+ * //=> Tue Sep 02 2014 23:59:59.999
1012
+ */
1013
+ function endOfDay(dirtyDate) {
1014
+ requiredArgs(1, arguments);
1015
+ var date = toDate(dirtyDate);
1016
+ date.setHours(23, 59, 59, 999);
1017
+ return date;
1018
+ }
1019
+
1020
+ /**
1021
+ * @name endOfMonth
1022
+ * @category Month Helpers
1023
+ * @summary Return the end of a month for the given date.
1024
+ *
1025
+ * @description
1026
+ * Return the end of a month for the given date.
1027
+ * The result will be in the local timezone.
1028
+ *
1029
+ * @param {Date|Number} date - the original date
1030
+ * @returns {Date} the end of a month
1031
+ * @throws {TypeError} 1 argument required
1032
+ *
1033
+ * @example
1034
+ * // The end of a month for 2 September 2014 11:55:00:
1035
+ * const result = endOfMonth(new Date(2014, 8, 2, 11, 55, 0))
1036
+ * //=> Tue Sep 30 2014 23:59:59.999
1037
+ */
1038
+ function endOfMonth(dirtyDate) {
1039
+ requiredArgs(1, arguments);
1040
+ var date = toDate(dirtyDate);
1041
+ var month = date.getMonth();
1042
+ date.setFullYear(date.getFullYear(), month + 1, 0);
1043
+ date.setHours(23, 59, 59, 999);
1044
+ return date;
1045
+ }
1046
+
1047
+ /**
1048
+ * @name isLastDayOfMonth
1049
+ * @category Month Helpers
1050
+ * @summary Is the given date the last day of a month?
1051
+ *
1052
+ * @description
1053
+ * Is the given date the last day of a month?
1054
+ *
1055
+ * @param {Date|Number} date - the date to check
1056
+ * @returns {Boolean} the date is the last day of a month
1057
+ * @throws {TypeError} 1 argument required
1058
+ *
1059
+ * @example
1060
+ * // Is 28 February 2014 the last day of a month?
1061
+ * const result = isLastDayOfMonth(new Date(2014, 1, 28))
1062
+ * //=> true
1063
+ */
1064
+ function isLastDayOfMonth(dirtyDate) {
1065
+ requiredArgs(1, arguments);
1066
+ var date = toDate(dirtyDate);
1067
+ return endOfDay(date).getTime() === endOfMonth(date).getTime();
1068
+ }
1069
+
1070
+ /**
1071
+ * @name isFirstDayOfMonth
1072
+ * @category Month Helpers
1073
+ * @summary Is the given date the first day of a month?
1074
+ *
1075
+ * @description
1076
+ * Is the given date the first day of a month?
1077
+ *
1078
+ * @param {Date|Number} date - the date to check
1079
+ * @returns {Boolean} the date is the first day of a month
1080
+ * @throws {TypeError} 1 argument required
1081
+ *
1082
+ * @example
1083
+ * // Is 1 September 2014 the first day of a month?
1084
+ * const result = isFirstDayOfMonth(new Date(2014, 8, 1))
1085
+ * //=> true
1086
+ */
1087
+ function isFirstDayOfMonth(dirtyDate) {
1088
+ requiredArgs(1, arguments);
1089
+ return toDate(dirtyDate).getDate() === 1;
1090
+ }
1091
+
1092
+ /**
1093
+ * @name getDate
1094
+ * @category Day Helpers
1095
+ * @summary Get the day of the month of the given date.
1096
+ *
1097
+ * @description
1098
+ * Get the day of the month of the given date.
1099
+ *
1100
+ * @param {Date|Number} date - the given date
1101
+ * @returns {Number} the day of month
1102
+ * @throws {TypeError} 1 argument required
1103
+ *
1104
+ * @example
1105
+ * // Which day of the month is 29 February 2012?
1106
+ * const result = getDate(new Date(2012, 1, 29))
1107
+ * //=> 29
1108
+ */
1109
+ function getDate(dirtyDate) {
1110
+ requiredArgs(1, arguments);
1111
+ var date = toDate(dirtyDate);
1112
+ var dayOfMonth = date.getDate();
1113
+ return dayOfMonth;
1114
+ }
1115
+
1116
+ /**
1117
+ * @name isEqual
1118
+ * @category Common Helpers
1119
+ * @summary Are the given dates equal?
1120
+ *
1121
+ * @description
1122
+ * Are the given dates equal?
1123
+ *
1124
+ * @param {Date|Number} dateLeft - the first date to compare
1125
+ * @param {Date|Number} dateRight - the second date to compare
1126
+ * @returns {Boolean} the dates are equal
1127
+ * @throws {TypeError} 2 arguments required
1128
+ *
1129
+ * @example
1130
+ * // Are 2 July 2014 06:30:45.000 and 2 July 2014 06:30:45.500 equal?
1131
+ * const result = isEqual(
1132
+ * new Date(2014, 6, 2, 6, 30, 45, 0),
1133
+ * new Date(2014, 6, 2, 6, 30, 45, 500)
1134
+ * )
1135
+ * //=> false
1136
+ */
1137
+ function isEqual(dirtyLeftDate, dirtyRightDate) {
1138
+ requiredArgs(2, arguments);
1139
+ var dateLeft = toDate(dirtyLeftDate);
1140
+ var dateRight = toDate(dirtyRightDate);
1141
+ return dateLeft.getTime() === dateRight.getTime();
1142
+ }
1143
+
1144
+ /**
1145
+ * @name isDate
1146
+ * @category Common Helpers
1147
+ * @summary Is the given value a date?
1148
+ *
1149
+ * @description
1150
+ * Returns true if the given value is an instance of Date. The function works for dates transferred across iframes.
1151
+ *
1152
+ * @param {*} value - the value to check
1153
+ * @returns {boolean} true if the given value is a date
1154
+ * @throws {TypeError} 1 arguments required
1155
+ *
1156
+ * @example
1157
+ * // For a valid date:
1158
+ * const result = isDate(new Date())
1159
+ * //=> true
1160
+ *
1161
+ * @example
1162
+ * // For an invalid date:
1163
+ * const result = isDate(new Date(NaN))
1164
+ * //=> true
1165
+ *
1166
+ * @example
1167
+ * // For some value:
1168
+ * const result = isDate('2014-02-31')
1169
+ * //=> false
1170
+ *
1171
+ * @example
1172
+ * // For an object:
1173
+ * const result = isDate({})
1174
+ * //=> false
1175
+ */
1176
+ function isDate(value) {
1177
+ requiredArgs(1, arguments);
1178
+ return value instanceof Date || _typeof(value) === 'object' && Object.prototype.toString.call(value) === '[object Date]';
1179
+ }
1180
+
1181
+ /**
1182
+ * @name isValid
1183
+ * @category Common Helpers
1184
+ * @summary Is the given date valid?
1185
+ *
1186
+ * @description
1187
+ * Returns false if argument is Invalid Date and true otherwise.
1188
+ * Argument is converted to Date using `toDate`. See [toDate]{@link https://date-fns.org/docs/toDate}
1189
+ * Invalid Date is a Date, whose time value is NaN.
1190
+ *
1191
+ * Time value of Date: http://es5.github.io/#x15.9.1.1
1192
+ *
1193
+ * @param {*} date - the date to check
1194
+ * @returns {Boolean} the date is valid
1195
+ * @throws {TypeError} 1 argument required
1196
+ *
1197
+ * @example
1198
+ * // For the valid date:
1199
+ * const result = isValid(new Date(2014, 1, 31))
1200
+ * //=> true
1201
+ *
1202
+ * @example
1203
+ * // For the value, convertable into a date:
1204
+ * const result = isValid(1393804800000)
1205
+ * //=> true
1206
+ *
1207
+ * @example
1208
+ * // For the invalid date:
1209
+ * const result = isValid(new Date(''))
1210
+ * //=> false
1211
+ */
1212
+ function isValid(dirtyDate) {
1213
+ requiredArgs(1, arguments);
1214
+ if (!isDate(dirtyDate) && typeof dirtyDate !== 'number') {
1215
+ return false;
1216
+ }
1217
+ var date = toDate(dirtyDate);
1218
+ return !isNaN(Number(date));
1219
+ }
1220
+
1221
+ /**
1222
+ * @name addMilliseconds
1223
+ * @category Millisecond Helpers
1224
+ * @summary Add the specified number of milliseconds to the given date.
1225
+ *
1226
+ * @description
1227
+ * Add the specified number of milliseconds to the given date.
1228
+ *
1229
+ * @param {Date|Number} date - the date to be changed
1230
+ * @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`.
1231
+ * @returns {Date} the new date with the milliseconds added
1232
+ * @throws {TypeError} 2 arguments required
1233
+ *
1234
+ * @example
1235
+ * // Add 750 milliseconds to 10 July 2014 12:45:30.000:
1236
+ * const result = addMilliseconds(new Date(2014, 6, 10, 12, 45, 30, 0), 750)
1237
+ * //=> Thu Jul 10 2014 12:45:30.750
1238
+ */
1239
+ function addMilliseconds(dirtyDate, dirtyAmount) {
1240
+ requiredArgs(2, arguments);
1241
+ var timestamp = toDate(dirtyDate).getTime();
1242
+ var amount = toInteger(dirtyAmount);
1243
+ return new Date(timestamp + amount);
1244
+ }
1245
+
1246
+ /**
1247
+ * @name subMilliseconds
1248
+ * @category Millisecond Helpers
1249
+ * @summary Subtract the specified number of milliseconds from the given date.
1250
+ *
1251
+ * @description
1252
+ * Subtract the specified number of milliseconds from the given date.
1253
+ *
1254
+ * @param {Date|Number} date - the date to be changed
1255
+ * @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`.
1256
+ * @returns {Date} the new date with the milliseconds subtracted
1257
+ * @throws {TypeError} 2 arguments required
1258
+ *
1259
+ * @example
1260
+ * // Subtract 750 milliseconds from 10 July 2014 12:45:30.000:
1261
+ * const result = subMilliseconds(new Date(2014, 6, 10, 12, 45, 30, 0), 750)
1262
+ * //=> Thu Jul 10 2014 12:45:29.250
1263
+ */
1264
+ function subMilliseconds(dirtyDate, dirtyAmount) {
1265
+ requiredArgs(2, arguments);
1266
+ var amount = toInteger(dirtyAmount);
1267
+ return addMilliseconds(dirtyDate, -amount);
1268
+ }
1269
+
1270
+ var MILLISECONDS_IN_DAY = 86400000;
1271
+ function getUTCDayOfYear(dirtyDate) {
1272
+ requiredArgs(1, arguments);
1273
+ var date = toDate(dirtyDate);
1274
+ var timestamp = date.getTime();
1275
+ date.setUTCMonth(0, 1);
1276
+ date.setUTCHours(0, 0, 0, 0);
1277
+ var startOfYearTimestamp = date.getTime();
1278
+ var difference = timestamp - startOfYearTimestamp;
1279
+ return Math.floor(difference / MILLISECONDS_IN_DAY) + 1;
1280
+ }
1281
+
1282
+ function startOfUTCISOWeek(dirtyDate) {
1283
+ requiredArgs(1, arguments);
1284
+ var weekStartsOn = 1;
1285
+ var date = toDate(dirtyDate);
1286
+ var day = date.getUTCDay();
1287
+ var diff = (day < weekStartsOn ? 7 : 0) + day - weekStartsOn;
1288
+ date.setUTCDate(date.getUTCDate() - diff);
1289
+ date.setUTCHours(0, 0, 0, 0);
1290
+ return date;
1291
+ }
1292
+
1293
+ function getUTCISOWeekYear(dirtyDate) {
1294
+ requiredArgs(1, arguments);
1295
+ var date = toDate(dirtyDate);
1296
+ var year = date.getUTCFullYear();
1297
+ var fourthOfJanuaryOfNextYear = new Date(0);
1298
+ fourthOfJanuaryOfNextYear.setUTCFullYear(year + 1, 0, 4);
1299
+ fourthOfJanuaryOfNextYear.setUTCHours(0, 0, 0, 0);
1300
+ var startOfNextYear = startOfUTCISOWeek(fourthOfJanuaryOfNextYear);
1301
+ var fourthOfJanuaryOfThisYear = new Date(0);
1302
+ fourthOfJanuaryOfThisYear.setUTCFullYear(year, 0, 4);
1303
+ fourthOfJanuaryOfThisYear.setUTCHours(0, 0, 0, 0);
1304
+ var startOfThisYear = startOfUTCISOWeek(fourthOfJanuaryOfThisYear);
1305
+ if (date.getTime() >= startOfNextYear.getTime()) {
1306
+ return year + 1;
1307
+ } else if (date.getTime() >= startOfThisYear.getTime()) {
1308
+ return year;
1309
+ } else {
1310
+ return year - 1;
1311
+ }
1312
+ }
1313
+
1314
+ function startOfUTCISOWeekYear(dirtyDate) {
1315
+ requiredArgs(1, arguments);
1316
+ var year = getUTCISOWeekYear(dirtyDate);
1317
+ var fourthOfJanuary = new Date(0);
1318
+ fourthOfJanuary.setUTCFullYear(year, 0, 4);
1319
+ fourthOfJanuary.setUTCHours(0, 0, 0, 0);
1320
+ var date = startOfUTCISOWeek(fourthOfJanuary);
1321
+ return date;
1322
+ }
1323
+
1324
+ var MILLISECONDS_IN_WEEK$1 = 604800000;
1325
+ function getUTCISOWeek(dirtyDate) {
1326
+ requiredArgs(1, arguments);
1327
+ var date = toDate(dirtyDate);
1328
+ var diff = startOfUTCISOWeek(date).getTime() - startOfUTCISOWeekYear(date).getTime();
1329
+
1330
+ // Round the number of days to the nearest integer
1331
+ // because the number of milliseconds in a week is not constant
1332
+ // (e.g. it's different in the week of the daylight saving time clock shift)
1333
+ return Math.round(diff / MILLISECONDS_IN_WEEK$1) + 1;
1334
+ }
1335
+
1336
+ function startOfUTCWeek(dirtyDate, options) {
1337
+ var _ref, _ref2, _ref3, _options$weekStartsOn, _options$locale, _options$locale$optio, _defaultOptions$local, _defaultOptions$local2;
1338
+ requiredArgs(1, arguments);
1339
+ var defaultOptions = getDefaultOptions();
1340
+ 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);
1341
+
1342
+ // Test if weekStartsOn is between 0 and 6 _and_ is not NaN
1343
+ if (!(weekStartsOn >= 0 && weekStartsOn <= 6)) {
1344
+ throw new RangeError('weekStartsOn must be between 0 and 6 inclusively');
1345
+ }
1346
+ var date = toDate(dirtyDate);
1347
+ var day = date.getUTCDay();
1348
+ var diff = (day < weekStartsOn ? 7 : 0) + day - weekStartsOn;
1349
+ date.setUTCDate(date.getUTCDate() - diff);
1350
+ date.setUTCHours(0, 0, 0, 0);
1351
+ return date;
1352
+ }
1353
+
1354
+ function getUTCWeekYear(dirtyDate, options) {
1355
+ var _ref, _ref2, _ref3, _options$firstWeekCon, _options$locale, _options$locale$optio, _defaultOptions$local, _defaultOptions$local2;
1356
+ requiredArgs(1, arguments);
1357
+ var date = toDate(dirtyDate);
1358
+ var year = date.getUTCFullYear();
1359
+ var defaultOptions = getDefaultOptions();
1360
+ 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);
1361
+
1362
+ // Test if weekStartsOn is between 1 and 7 _and_ is not NaN
1363
+ if (!(firstWeekContainsDate >= 1 && firstWeekContainsDate <= 7)) {
1364
+ throw new RangeError('firstWeekContainsDate must be between 1 and 7 inclusively');
1365
+ }
1366
+ var firstWeekOfNextYear = new Date(0);
1367
+ firstWeekOfNextYear.setUTCFullYear(year + 1, 0, firstWeekContainsDate);
1368
+ firstWeekOfNextYear.setUTCHours(0, 0, 0, 0);
1369
+ var startOfNextYear = startOfUTCWeek(firstWeekOfNextYear, options);
1370
+ var firstWeekOfThisYear = new Date(0);
1371
+ firstWeekOfThisYear.setUTCFullYear(year, 0, firstWeekContainsDate);
1372
+ firstWeekOfThisYear.setUTCHours(0, 0, 0, 0);
1373
+ var startOfThisYear = startOfUTCWeek(firstWeekOfThisYear, options);
1374
+ if (date.getTime() >= startOfNextYear.getTime()) {
1375
+ return year + 1;
1376
+ } else if (date.getTime() >= startOfThisYear.getTime()) {
1377
+ return year;
1378
+ } else {
1379
+ return year - 1;
1380
+ }
1381
+ }
1382
+
1383
+ function startOfUTCWeekYear(dirtyDate, options) {
1384
+ var _ref, _ref2, _ref3, _options$firstWeekCon, _options$locale, _options$locale$optio, _defaultOptions$local, _defaultOptions$local2;
1385
+ requiredArgs(1, arguments);
1386
+ var defaultOptions = getDefaultOptions();
1387
+ 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);
1388
+ var year = getUTCWeekYear(dirtyDate, options);
1389
+ var firstWeek = new Date(0);
1390
+ firstWeek.setUTCFullYear(year, 0, firstWeekContainsDate);
1391
+ firstWeek.setUTCHours(0, 0, 0, 0);
1392
+ var date = startOfUTCWeek(firstWeek, options);
1393
+ return date;
1394
+ }
1395
+
1396
+ var MILLISECONDS_IN_WEEK = 604800000;
1397
+ function getUTCWeek(dirtyDate, options) {
1398
+ requiredArgs(1, arguments);
1399
+ var date = toDate(dirtyDate);
1400
+ var diff = startOfUTCWeek(date, options).getTime() - startOfUTCWeekYear(date, options).getTime();
1401
+
1402
+ // Round the number of days to the nearest integer
1403
+ // because the number of milliseconds in a week is not constant
1404
+ // (e.g. it's different in the week of the daylight saving time clock shift)
1405
+ return Math.round(diff / MILLISECONDS_IN_WEEK) + 1;
1406
+ }
1407
+
1408
+ function addLeadingZeros(number, targetLength) {
1409
+ var sign = number < 0 ? '-' : '';
1410
+ var output = Math.abs(number).toString();
1411
+ while (output.length < targetLength) {
1412
+ output = '0' + output;
1413
+ }
1414
+ return sign + output;
1415
+ }
1416
+
1417
+ /*
1418
+ * | | Unit | | Unit |
1419
+ * |-----|--------------------------------|-----|--------------------------------|
1420
+ * | a | AM, PM | A* | |
1421
+ * | d | Day of month | D | |
1422
+ * | h | Hour [1-12] | H | Hour [0-23] |
1423
+ * | m | Minute | M | Month |
1424
+ * | s | Second | S | Fraction of second |
1425
+ * | y | Year (abs) | Y | |
1426
+ *
1427
+ * Letters marked by * are not implemented but reserved by Unicode standard.
1428
+ */
1429
+ var formatters$2 = {
1430
+ // Year
1431
+ y: function y(date, token) {
1432
+ // From http://www.unicode.org/reports/tr35/tr35-31/tr35-dates.html#Date_Format_tokens
1433
+ // | Year | y | yy | yyy | yyyy | yyyyy |
1434
+ // |----------|-------|----|-------|-------|-------|
1435
+ // | AD 1 | 1 | 01 | 001 | 0001 | 00001 |
1436
+ // | AD 12 | 12 | 12 | 012 | 0012 | 00012 |
1437
+ // | AD 123 | 123 | 23 | 123 | 0123 | 00123 |
1438
+ // | AD 1234 | 1234 | 34 | 1234 | 1234 | 01234 |
1439
+ // | AD 12345 | 12345 | 45 | 12345 | 12345 | 12345 |
1440
+
1441
+ var signedYear = date.getUTCFullYear();
1442
+ // Returns 1 for 1 BC (which is year 0 in JavaScript)
1443
+ var year = signedYear > 0 ? signedYear : 1 - signedYear;
1444
+ return addLeadingZeros(token === 'yy' ? year % 100 : year, token.length);
1445
+ },
1446
+ // Month
1447
+ M: function M(date, token) {
1448
+ var month = date.getUTCMonth();
1449
+ return token === 'M' ? String(month + 1) : addLeadingZeros(month + 1, 2);
1450
+ },
1451
+ // Day of the month
1452
+ d: function d(date, token) {
1453
+ return addLeadingZeros(date.getUTCDate(), token.length);
1454
+ },
1455
+ // AM or PM
1456
+ a: function a(date, token) {
1457
+ var dayPeriodEnumValue = date.getUTCHours() / 12 >= 1 ? 'pm' : 'am';
1458
+ switch (token) {
1459
+ case 'a':
1460
+ case 'aa':
1461
+ return dayPeriodEnumValue.toUpperCase();
1462
+ case 'aaa':
1463
+ return dayPeriodEnumValue;
1464
+ case 'aaaaa':
1465
+ return dayPeriodEnumValue[0];
1466
+ case 'aaaa':
1467
+ default:
1468
+ return dayPeriodEnumValue === 'am' ? 'a.m.' : 'p.m.';
1469
+ }
1470
+ },
1471
+ // Hour [1-12]
1472
+ h: function h(date, token) {
1473
+ return addLeadingZeros(date.getUTCHours() % 12 || 12, token.length);
1474
+ },
1475
+ // Hour [0-23]
1476
+ H: function H(date, token) {
1477
+ return addLeadingZeros(date.getUTCHours(), token.length);
1478
+ },
1479
+ // Minute
1480
+ m: function m(date, token) {
1481
+ return addLeadingZeros(date.getUTCMinutes(), token.length);
1482
+ },
1483
+ // Second
1484
+ s: function s(date, token) {
1485
+ return addLeadingZeros(date.getUTCSeconds(), token.length);
1486
+ },
1487
+ // Fraction of second
1488
+ S: function S(date, token) {
1489
+ var numberOfDigits = token.length;
1490
+ var milliseconds = date.getUTCMilliseconds();
1491
+ var fractionalSeconds = Math.floor(milliseconds * Math.pow(10, numberOfDigits - 3));
1492
+ return addLeadingZeros(fractionalSeconds, token.length);
1493
+ }
1494
+ };
1495
+ var formatters$3 = formatters$2;
1496
+
1497
+ var dayPeriodEnum = {
1498
+ am: 'am',
1499
+ pm: 'pm',
1500
+ midnight: 'midnight',
1501
+ noon: 'noon',
1502
+ morning: 'morning',
1503
+ afternoon: 'afternoon',
1504
+ evening: 'evening',
1505
+ night: 'night'
1506
+ };
1507
+ /*
1508
+ * | | Unit | | Unit |
1509
+ * |-----|--------------------------------|-----|--------------------------------|
1510
+ * | a | AM, PM | A* | Milliseconds in day |
1511
+ * | b | AM, PM, noon, midnight | B | Flexible day period |
1512
+ * | c | Stand-alone local day of week | C* | Localized hour w/ day period |
1513
+ * | d | Day of month | D | Day of year |
1514
+ * | e | Local day of week | E | Day of week |
1515
+ * | f | | F* | Day of week in month |
1516
+ * | g* | Modified Julian day | G | Era |
1517
+ * | h | Hour [1-12] | H | Hour [0-23] |
1518
+ * | i! | ISO day of week | I! | ISO week of year |
1519
+ * | j* | Localized hour w/ day period | J* | Localized hour w/o day period |
1520
+ * | k | Hour [1-24] | K | Hour [0-11] |
1521
+ * | l* | (deprecated) | L | Stand-alone month |
1522
+ * | m | Minute | M | Month |
1523
+ * | n | | N | |
1524
+ * | o! | Ordinal number modifier | O | Timezone (GMT) |
1525
+ * | p! | Long localized time | P! | Long localized date |
1526
+ * | q | Stand-alone quarter | Q | Quarter |
1527
+ * | r* | Related Gregorian year | R! | ISO week-numbering year |
1528
+ * | s | Second | S | Fraction of second |
1529
+ * | t! | Seconds timestamp | T! | Milliseconds timestamp |
1530
+ * | u | Extended year | U* | Cyclic year |
1531
+ * | v* | Timezone (generic non-locat.) | V* | Timezone (location) |
1532
+ * | w | Local week of year | W* | Week of month |
1533
+ * | x | Timezone (ISO-8601 w/o Z) | X | Timezone (ISO-8601) |
1534
+ * | y | Year (abs) | Y | Local week-numbering year |
1535
+ * | z | Timezone (specific non-locat.) | Z* | Timezone (aliases) |
1536
+ *
1537
+ * Letters marked by * are not implemented but reserved by Unicode standard.
1538
+ *
1539
+ * Letters marked by ! are non-standard, but implemented by date-fns:
1540
+ * - `o` modifies the previous token to turn it into an ordinal (see `format` docs)
1541
+ * - `i` is ISO day of week. For `i` and `ii` is returns numeric ISO week days,
1542
+ * i.e. 7 for Sunday, 1 for Monday, etc.
1543
+ * - `I` is ISO week of year, as opposed to `w` which is local week of year.
1544
+ * - `R` is ISO week-numbering year, as opposed to `Y` which is local week-numbering year.
1545
+ * `R` is supposed to be used in conjunction with `I` and `i`
1546
+ * for universal ISO week-numbering date, whereas
1547
+ * `Y` is supposed to be used in conjunction with `w` and `e`
1548
+ * for week-numbering date specific to the locale.
1549
+ * - `P` is long localized date format
1550
+ * - `p` is long localized time format
1551
+ */
1552
+
1553
+ var formatters = {
1554
+ // Era
1555
+ G: function G(date, token, localize) {
1556
+ var era = date.getUTCFullYear() > 0 ? 1 : 0;
1557
+ switch (token) {
1558
+ // AD, BC
1559
+ case 'G':
1560
+ case 'GG':
1561
+ case 'GGG':
1562
+ return localize.era(era, {
1563
+ width: 'abbreviated'
1564
+ });
1565
+ // A, B
1566
+ case 'GGGGG':
1567
+ return localize.era(era, {
1568
+ width: 'narrow'
1569
+ });
1570
+ // Anno Domini, Before Christ
1571
+ case 'GGGG':
1572
+ default:
1573
+ return localize.era(era, {
1574
+ width: 'wide'
1575
+ });
1576
+ }
1577
+ },
1578
+ // Year
1579
+ y: function y(date, token, localize) {
1580
+ // Ordinal number
1581
+ if (token === 'yo') {
1582
+ var signedYear = date.getUTCFullYear();
1583
+ // Returns 1 for 1 BC (which is year 0 in JavaScript)
1584
+ var year = signedYear > 0 ? signedYear : 1 - signedYear;
1585
+ return localize.ordinalNumber(year, {
1586
+ unit: 'year'
1587
+ });
1588
+ }
1589
+ return formatters$3.y(date, token);
1590
+ },
1591
+ // Local week-numbering year
1592
+ Y: function Y(date, token, localize, options) {
1593
+ var signedWeekYear = getUTCWeekYear(date, options);
1594
+ // Returns 1 for 1 BC (which is year 0 in JavaScript)
1595
+ var weekYear = signedWeekYear > 0 ? signedWeekYear : 1 - signedWeekYear;
1596
+
1597
+ // Two digit year
1598
+ if (token === 'YY') {
1599
+ var twoDigitYear = weekYear % 100;
1600
+ return addLeadingZeros(twoDigitYear, 2);
1601
+ }
1602
+
1603
+ // Ordinal number
1604
+ if (token === 'Yo') {
1605
+ return localize.ordinalNumber(weekYear, {
1606
+ unit: 'year'
1607
+ });
1608
+ }
1609
+
1610
+ // Padding
1611
+ return addLeadingZeros(weekYear, token.length);
1612
+ },
1613
+ // ISO week-numbering year
1614
+ R: function R(date, token) {
1615
+ var isoWeekYear = getUTCISOWeekYear(date);
1616
+
1617
+ // Padding
1618
+ return addLeadingZeros(isoWeekYear, token.length);
1619
+ },
1620
+ // Extended year. This is a single number designating the year of this calendar system.
1621
+ // The main difference between `y` and `u` localizers are B.C. years:
1622
+ // | Year | `y` | `u` |
1623
+ // |------|-----|-----|
1624
+ // | AC 1 | 1 | 1 |
1625
+ // | BC 1 | 1 | 0 |
1626
+ // | BC 2 | 2 | -1 |
1627
+ // Also `yy` always returns the last two digits of a year,
1628
+ // while `uu` pads single digit years to 2 characters and returns other years unchanged.
1629
+ u: function u(date, token) {
1630
+ var year = date.getUTCFullYear();
1631
+ return addLeadingZeros(year, token.length);
1632
+ },
1633
+ // Quarter
1634
+ Q: function Q(date, token, localize) {
1635
+ var quarter = Math.ceil((date.getUTCMonth() + 1) / 3);
1636
+ switch (token) {
1637
+ // 1, 2, 3, 4
1638
+ case 'Q':
1639
+ return String(quarter);
1640
+ // 01, 02, 03, 04
1641
+ case 'QQ':
1642
+ return addLeadingZeros(quarter, 2);
1643
+ // 1st, 2nd, 3rd, 4th
1644
+ case 'Qo':
1645
+ return localize.ordinalNumber(quarter, {
1646
+ unit: 'quarter'
1647
+ });
1648
+ // Q1, Q2, Q3, Q4
1649
+ case 'QQQ':
1650
+ return localize.quarter(quarter, {
1651
+ width: 'abbreviated',
1652
+ context: 'formatting'
1653
+ });
1654
+ // 1, 2, 3, 4 (narrow quarter; could be not numerical)
1655
+ case 'QQQQQ':
1656
+ return localize.quarter(quarter, {
1657
+ width: 'narrow',
1658
+ context: 'formatting'
1659
+ });
1660
+ // 1st quarter, 2nd quarter, ...
1661
+ case 'QQQQ':
1662
+ default:
1663
+ return localize.quarter(quarter, {
1664
+ width: 'wide',
1665
+ context: 'formatting'
1666
+ });
1667
+ }
1668
+ },
1669
+ // Stand-alone quarter
1670
+ q: function q(date, token, localize) {
1671
+ var quarter = Math.ceil((date.getUTCMonth() + 1) / 3);
1672
+ switch (token) {
1673
+ // 1, 2, 3, 4
1674
+ case 'q':
1675
+ return String(quarter);
1676
+ // 01, 02, 03, 04
1677
+ case 'qq':
1678
+ return addLeadingZeros(quarter, 2);
1679
+ // 1st, 2nd, 3rd, 4th
1680
+ case 'qo':
1681
+ return localize.ordinalNumber(quarter, {
1682
+ unit: 'quarter'
1683
+ });
1684
+ // Q1, Q2, Q3, Q4
1685
+ case 'qqq':
1686
+ return localize.quarter(quarter, {
1687
+ width: 'abbreviated',
1688
+ context: 'standalone'
1689
+ });
1690
+ // 1, 2, 3, 4 (narrow quarter; could be not numerical)
1691
+ case 'qqqqq':
1692
+ return localize.quarter(quarter, {
1693
+ width: 'narrow',
1694
+ context: 'standalone'
1695
+ });
1696
+ // 1st quarter, 2nd quarter, ...
1697
+ case 'qqqq':
1698
+ default:
1699
+ return localize.quarter(quarter, {
1700
+ width: 'wide',
1701
+ context: 'standalone'
1702
+ });
1703
+ }
1704
+ },
1705
+ // Month
1706
+ M: function M(date, token, localize) {
1707
+ var month = date.getUTCMonth();
1708
+ switch (token) {
1709
+ case 'M':
1710
+ case 'MM':
1711
+ return formatters$3.M(date, token);
1712
+ // 1st, 2nd, ..., 12th
1713
+ case 'Mo':
1714
+ return localize.ordinalNumber(month + 1, {
1715
+ unit: 'month'
1716
+ });
1717
+ // Jan, Feb, ..., Dec
1718
+ case 'MMM':
1719
+ return localize.month(month, {
1720
+ width: 'abbreviated',
1721
+ context: 'formatting'
1722
+ });
1723
+ // J, F, ..., D
1724
+ case 'MMMMM':
1725
+ return localize.month(month, {
1726
+ width: 'narrow',
1727
+ context: 'formatting'
1728
+ });
1729
+ // January, February, ..., December
1730
+ case 'MMMM':
1731
+ default:
1732
+ return localize.month(month, {
1733
+ width: 'wide',
1734
+ context: 'formatting'
1735
+ });
1736
+ }
1737
+ },
1738
+ // Stand-alone month
1739
+ L: function L(date, token, localize) {
1740
+ var month = date.getUTCMonth();
1741
+ switch (token) {
1742
+ // 1, 2, ..., 12
1743
+ case 'L':
1744
+ return String(month + 1);
1745
+ // 01, 02, ..., 12
1746
+ case 'LL':
1747
+ return addLeadingZeros(month + 1, 2);
1748
+ // 1st, 2nd, ..., 12th
1749
+ case 'Lo':
1750
+ return localize.ordinalNumber(month + 1, {
1751
+ unit: 'month'
1752
+ });
1753
+ // Jan, Feb, ..., Dec
1754
+ case 'LLL':
1755
+ return localize.month(month, {
1756
+ width: 'abbreviated',
1757
+ context: 'standalone'
1758
+ });
1759
+ // J, F, ..., D
1760
+ case 'LLLLL':
1761
+ return localize.month(month, {
1762
+ width: 'narrow',
1763
+ context: 'standalone'
1764
+ });
1765
+ // January, February, ..., December
1766
+ case 'LLLL':
1767
+ default:
1768
+ return localize.month(month, {
1769
+ width: 'wide',
1770
+ context: 'standalone'
1771
+ });
1772
+ }
1773
+ },
1774
+ // Local week of year
1775
+ w: function w(date, token, localize, options) {
1776
+ var week = getUTCWeek(date, options);
1777
+ if (token === 'wo') {
1778
+ return localize.ordinalNumber(week, {
1779
+ unit: 'week'
1780
+ });
1781
+ }
1782
+ return addLeadingZeros(week, token.length);
1783
+ },
1784
+ // ISO week of year
1785
+ I: function I(date, token, localize) {
1786
+ var isoWeek = getUTCISOWeek(date);
1787
+ if (token === 'Io') {
1788
+ return localize.ordinalNumber(isoWeek, {
1789
+ unit: 'week'
1790
+ });
1791
+ }
1792
+ return addLeadingZeros(isoWeek, token.length);
1793
+ },
1794
+ // Day of the month
1795
+ d: function d(date, token, localize) {
1796
+ if (token === 'do') {
1797
+ return localize.ordinalNumber(date.getUTCDate(), {
1798
+ unit: 'date'
1799
+ });
1800
+ }
1801
+ return formatters$3.d(date, token);
1802
+ },
1803
+ // Day of year
1804
+ D: function D(date, token, localize) {
1805
+ var dayOfYear = getUTCDayOfYear(date);
1806
+ if (token === 'Do') {
1807
+ return localize.ordinalNumber(dayOfYear, {
1808
+ unit: 'dayOfYear'
1809
+ });
1810
+ }
1811
+ return addLeadingZeros(dayOfYear, token.length);
1812
+ },
1813
+ // Day of week
1814
+ E: function E(date, token, localize) {
1815
+ var dayOfWeek = date.getUTCDay();
1816
+ switch (token) {
1817
+ // Tue
1818
+ case 'E':
1819
+ case 'EE':
1820
+ case 'EEE':
1821
+ return localize.day(dayOfWeek, {
1822
+ width: 'abbreviated',
1823
+ context: 'formatting'
1824
+ });
1825
+ // T
1826
+ case 'EEEEE':
1827
+ return localize.day(dayOfWeek, {
1828
+ width: 'narrow',
1829
+ context: 'formatting'
1830
+ });
1831
+ // Tu
1832
+ case 'EEEEEE':
1833
+ return localize.day(dayOfWeek, {
1834
+ width: 'short',
1835
+ context: 'formatting'
1836
+ });
1837
+ // Tuesday
1838
+ case 'EEEE':
1839
+ default:
1840
+ return localize.day(dayOfWeek, {
1841
+ width: 'wide',
1842
+ context: 'formatting'
1843
+ });
1844
+ }
1845
+ },
1846
+ // Local day of week
1847
+ e: function e(date, token, localize, options) {
1848
+ var dayOfWeek = date.getUTCDay();
1849
+ var localDayOfWeek = (dayOfWeek - options.weekStartsOn + 8) % 7 || 7;
1850
+ switch (token) {
1851
+ // Numerical value (Nth day of week with current locale or weekStartsOn)
1852
+ case 'e':
1853
+ return String(localDayOfWeek);
1854
+ // Padded numerical value
1855
+ case 'ee':
1856
+ return addLeadingZeros(localDayOfWeek, 2);
1857
+ // 1st, 2nd, ..., 7th
1858
+ case 'eo':
1859
+ return localize.ordinalNumber(localDayOfWeek, {
1860
+ unit: 'day'
1861
+ });
1862
+ case 'eee':
1863
+ return localize.day(dayOfWeek, {
1864
+ width: 'abbreviated',
1865
+ context: 'formatting'
1866
+ });
1867
+ // T
1868
+ case 'eeeee':
1869
+ return localize.day(dayOfWeek, {
1870
+ width: 'narrow',
1871
+ context: 'formatting'
1872
+ });
1873
+ // Tu
1874
+ case 'eeeeee':
1875
+ return localize.day(dayOfWeek, {
1876
+ width: 'short',
1877
+ context: 'formatting'
1878
+ });
1879
+ // Tuesday
1880
+ case 'eeee':
1881
+ default:
1882
+ return localize.day(dayOfWeek, {
1883
+ width: 'wide',
1884
+ context: 'formatting'
1885
+ });
1886
+ }
1887
+ },
1888
+ // Stand-alone local day of week
1889
+ c: function c(date, token, localize, options) {
1890
+ var dayOfWeek = date.getUTCDay();
1891
+ var localDayOfWeek = (dayOfWeek - options.weekStartsOn + 8) % 7 || 7;
1892
+ switch (token) {
1893
+ // Numerical value (same as in `e`)
1894
+ case 'c':
1895
+ return String(localDayOfWeek);
1896
+ // Padded numerical value
1897
+ case 'cc':
1898
+ return addLeadingZeros(localDayOfWeek, token.length);
1899
+ // 1st, 2nd, ..., 7th
1900
+ case 'co':
1901
+ return localize.ordinalNumber(localDayOfWeek, {
1902
+ unit: 'day'
1903
+ });
1904
+ case 'ccc':
1905
+ return localize.day(dayOfWeek, {
1906
+ width: 'abbreviated',
1907
+ context: 'standalone'
1908
+ });
1909
+ // T
1910
+ case 'ccccc':
1911
+ return localize.day(dayOfWeek, {
1912
+ width: 'narrow',
1913
+ context: 'standalone'
1914
+ });
1915
+ // Tu
1916
+ case 'cccccc':
1917
+ return localize.day(dayOfWeek, {
1918
+ width: 'short',
1919
+ context: 'standalone'
1920
+ });
1921
+ // Tuesday
1922
+ case 'cccc':
1923
+ default:
1924
+ return localize.day(dayOfWeek, {
1925
+ width: 'wide',
1926
+ context: 'standalone'
1927
+ });
1928
+ }
1929
+ },
1930
+ // ISO day of week
1931
+ i: function i(date, token, localize) {
1932
+ var dayOfWeek = date.getUTCDay();
1933
+ var isoDayOfWeek = dayOfWeek === 0 ? 7 : dayOfWeek;
1934
+ switch (token) {
1935
+ // 2
1936
+ case 'i':
1937
+ return String(isoDayOfWeek);
1938
+ // 02
1939
+ case 'ii':
1940
+ return addLeadingZeros(isoDayOfWeek, token.length);
1941
+ // 2nd
1942
+ case 'io':
1943
+ return localize.ordinalNumber(isoDayOfWeek, {
1944
+ unit: 'day'
1945
+ });
1946
+ // Tue
1947
+ case 'iii':
1948
+ return localize.day(dayOfWeek, {
1949
+ width: 'abbreviated',
1950
+ context: 'formatting'
1951
+ });
1952
+ // T
1953
+ case 'iiiii':
1954
+ return localize.day(dayOfWeek, {
1955
+ width: 'narrow',
1956
+ context: 'formatting'
1957
+ });
1958
+ // Tu
1959
+ case 'iiiiii':
1960
+ return localize.day(dayOfWeek, {
1961
+ width: 'short',
1962
+ context: 'formatting'
1963
+ });
1964
+ // Tuesday
1965
+ case 'iiii':
1966
+ default:
1967
+ return localize.day(dayOfWeek, {
1968
+ width: 'wide',
1969
+ context: 'formatting'
1970
+ });
1971
+ }
1972
+ },
1973
+ // AM or PM
1974
+ a: function a(date, token, localize) {
1975
+ var hours = date.getUTCHours();
1976
+ var dayPeriodEnumValue = hours / 12 >= 1 ? 'pm' : 'am';
1977
+ switch (token) {
1978
+ case 'a':
1979
+ case 'aa':
1980
+ return localize.dayPeriod(dayPeriodEnumValue, {
1981
+ width: 'abbreviated',
1982
+ context: 'formatting'
1983
+ });
1984
+ case 'aaa':
1985
+ return localize.dayPeriod(dayPeriodEnumValue, {
1986
+ width: 'abbreviated',
1987
+ context: 'formatting'
1988
+ }).toLowerCase();
1989
+ case 'aaaaa':
1990
+ return localize.dayPeriod(dayPeriodEnumValue, {
1991
+ width: 'narrow',
1992
+ context: 'formatting'
1993
+ });
1994
+ case 'aaaa':
1995
+ default:
1996
+ return localize.dayPeriod(dayPeriodEnumValue, {
1997
+ width: 'wide',
1998
+ context: 'formatting'
1999
+ });
2000
+ }
2001
+ },
2002
+ // AM, PM, midnight, noon
2003
+ b: function b(date, token, localize) {
2004
+ var hours = date.getUTCHours();
2005
+ var dayPeriodEnumValue;
2006
+ if (hours === 12) {
2007
+ dayPeriodEnumValue = dayPeriodEnum.noon;
2008
+ } else if (hours === 0) {
2009
+ dayPeriodEnumValue = dayPeriodEnum.midnight;
2010
+ } else {
2011
+ dayPeriodEnumValue = hours / 12 >= 1 ? 'pm' : 'am';
2012
+ }
2013
+ switch (token) {
2014
+ case 'b':
2015
+ case 'bb':
2016
+ return localize.dayPeriod(dayPeriodEnumValue, {
2017
+ width: 'abbreviated',
2018
+ context: 'formatting'
2019
+ });
2020
+ case 'bbb':
2021
+ return localize.dayPeriod(dayPeriodEnumValue, {
2022
+ width: 'abbreviated',
2023
+ context: 'formatting'
2024
+ }).toLowerCase();
2025
+ case 'bbbbb':
2026
+ return localize.dayPeriod(dayPeriodEnumValue, {
2027
+ width: 'narrow',
2028
+ context: 'formatting'
2029
+ });
2030
+ case 'bbbb':
2031
+ default:
2032
+ return localize.dayPeriod(dayPeriodEnumValue, {
2033
+ width: 'wide',
2034
+ context: 'formatting'
2035
+ });
2036
+ }
2037
+ },
2038
+ // in the morning, in the afternoon, in the evening, at night
2039
+ B: function B(date, token, localize) {
2040
+ var hours = date.getUTCHours();
2041
+ var dayPeriodEnumValue;
2042
+ if (hours >= 17) {
2043
+ dayPeriodEnumValue = dayPeriodEnum.evening;
2044
+ } else if (hours >= 12) {
2045
+ dayPeriodEnumValue = dayPeriodEnum.afternoon;
2046
+ } else if (hours >= 4) {
2047
+ dayPeriodEnumValue = dayPeriodEnum.morning;
2048
+ } else {
2049
+ dayPeriodEnumValue = dayPeriodEnum.night;
2050
+ }
2051
+ switch (token) {
2052
+ case 'B':
2053
+ case 'BB':
2054
+ case 'BBB':
2055
+ return localize.dayPeriod(dayPeriodEnumValue, {
2056
+ width: 'abbreviated',
2057
+ context: 'formatting'
2058
+ });
2059
+ case 'BBBBB':
2060
+ return localize.dayPeriod(dayPeriodEnumValue, {
2061
+ width: 'narrow',
2062
+ context: 'formatting'
2063
+ });
2064
+ case 'BBBB':
2065
+ default:
2066
+ return localize.dayPeriod(dayPeriodEnumValue, {
2067
+ width: 'wide',
2068
+ context: 'formatting'
2069
+ });
2070
+ }
2071
+ },
2072
+ // Hour [1-12]
2073
+ h: function h(date, token, localize) {
2074
+ if (token === 'ho') {
2075
+ var hours = date.getUTCHours() % 12;
2076
+ if (hours === 0) hours = 12;
2077
+ return localize.ordinalNumber(hours, {
2078
+ unit: 'hour'
2079
+ });
2080
+ }
2081
+ return formatters$3.h(date, token);
2082
+ },
2083
+ // Hour [0-23]
2084
+ H: function H(date, token, localize) {
2085
+ if (token === 'Ho') {
2086
+ return localize.ordinalNumber(date.getUTCHours(), {
2087
+ unit: 'hour'
2088
+ });
2089
+ }
2090
+ return formatters$3.H(date, token);
2091
+ },
2092
+ // Hour [0-11]
2093
+ K: function K(date, token, localize) {
2094
+ var hours = date.getUTCHours() % 12;
2095
+ if (token === 'Ko') {
2096
+ return localize.ordinalNumber(hours, {
2097
+ unit: 'hour'
2098
+ });
2099
+ }
2100
+ return addLeadingZeros(hours, token.length);
2101
+ },
2102
+ // Hour [1-24]
2103
+ k: function k(date, token, localize) {
2104
+ var hours = date.getUTCHours();
2105
+ if (hours === 0) hours = 24;
2106
+ if (token === 'ko') {
2107
+ return localize.ordinalNumber(hours, {
2108
+ unit: 'hour'
2109
+ });
2110
+ }
2111
+ return addLeadingZeros(hours, token.length);
2112
+ },
2113
+ // Minute
2114
+ m: function m(date, token, localize) {
2115
+ if (token === 'mo') {
2116
+ return localize.ordinalNumber(date.getUTCMinutes(), {
2117
+ unit: 'minute'
2118
+ });
2119
+ }
2120
+ return formatters$3.m(date, token);
2121
+ },
2122
+ // Second
2123
+ s: function s(date, token, localize) {
2124
+ if (token === 'so') {
2125
+ return localize.ordinalNumber(date.getUTCSeconds(), {
2126
+ unit: 'second'
2127
+ });
2128
+ }
2129
+ return formatters$3.s(date, token);
2130
+ },
2131
+ // Fraction of second
2132
+ S: function S(date, token) {
2133
+ return formatters$3.S(date, token);
2134
+ },
2135
+ // Timezone (ISO-8601. If offset is 0, output is always `'Z'`)
2136
+ X: function X(date, token, _localize, options) {
2137
+ var originalDate = options._originalDate || date;
2138
+ var timezoneOffset = originalDate.getTimezoneOffset();
2139
+ if (timezoneOffset === 0) {
2140
+ return 'Z';
2141
+ }
2142
+ switch (token) {
2143
+ // Hours and optional minutes
2144
+ case 'X':
2145
+ return formatTimezoneWithOptionalMinutes(timezoneOffset);
2146
+
2147
+ // Hours, minutes and optional seconds without `:` delimiter
2148
+ // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
2149
+ // so this token always has the same output as `XX`
2150
+ case 'XXXX':
2151
+ case 'XX':
2152
+ // Hours and minutes without `:` delimiter
2153
+ return formatTimezone(timezoneOffset);
2154
+
2155
+ // Hours, minutes and optional seconds with `:` delimiter
2156
+ // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
2157
+ // so this token always has the same output as `XXX`
2158
+ case 'XXXXX':
2159
+ case 'XXX': // Hours and minutes with `:` delimiter
2160
+ default:
2161
+ return formatTimezone(timezoneOffset, ':');
2162
+ }
2163
+ },
2164
+ // Timezone (ISO-8601. If offset is 0, output is `'+00:00'` or equivalent)
2165
+ x: function x(date, token, _localize, options) {
2166
+ var originalDate = options._originalDate || date;
2167
+ var timezoneOffset = originalDate.getTimezoneOffset();
2168
+ switch (token) {
2169
+ // Hours and optional minutes
2170
+ case 'x':
2171
+ return formatTimezoneWithOptionalMinutes(timezoneOffset);
2172
+
2173
+ // Hours, minutes and optional seconds without `:` delimiter
2174
+ // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
2175
+ // so this token always has the same output as `xx`
2176
+ case 'xxxx':
2177
+ case 'xx':
2178
+ // Hours and minutes without `:` delimiter
2179
+ return formatTimezone(timezoneOffset);
2180
+
2181
+ // Hours, minutes and optional seconds with `:` delimiter
2182
+ // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
2183
+ // so this token always has the same output as `xxx`
2184
+ case 'xxxxx':
2185
+ case 'xxx': // Hours and minutes with `:` delimiter
2186
+ default:
2187
+ return formatTimezone(timezoneOffset, ':');
2188
+ }
2189
+ },
2190
+ // Timezone (GMT)
2191
+ O: function O(date, token, _localize, options) {
2192
+ var originalDate = options._originalDate || date;
2193
+ var timezoneOffset = originalDate.getTimezoneOffset();
2194
+ switch (token) {
2195
+ // Short
2196
+ case 'O':
2197
+ case 'OO':
2198
+ case 'OOO':
2199
+ return 'GMT' + formatTimezoneShort(timezoneOffset, ':');
2200
+ // Long
2201
+ case 'OOOO':
2202
+ default:
2203
+ return 'GMT' + formatTimezone(timezoneOffset, ':');
2204
+ }
2205
+ },
2206
+ // Timezone (specific non-location)
2207
+ z: function z(date, token, _localize, options) {
2208
+ var originalDate = options._originalDate || date;
2209
+ var timezoneOffset = originalDate.getTimezoneOffset();
2210
+ switch (token) {
2211
+ // Short
2212
+ case 'z':
2213
+ case 'zz':
2214
+ case 'zzz':
2215
+ return 'GMT' + formatTimezoneShort(timezoneOffset, ':');
2216
+ // Long
2217
+ case 'zzzz':
2218
+ default:
2219
+ return 'GMT' + formatTimezone(timezoneOffset, ':');
2220
+ }
2221
+ },
2222
+ // Seconds timestamp
2223
+ t: function t(date, token, _localize, options) {
2224
+ var originalDate = options._originalDate || date;
2225
+ var timestamp = Math.floor(originalDate.getTime() / 1000);
2226
+ return addLeadingZeros(timestamp, token.length);
2227
+ },
2228
+ // Milliseconds timestamp
2229
+ T: function T(date, token, _localize, options) {
2230
+ var originalDate = options._originalDate || date;
2231
+ var timestamp = originalDate.getTime();
2232
+ return addLeadingZeros(timestamp, token.length);
2233
+ }
2234
+ };
2235
+ function formatTimezoneShort(offset, dirtyDelimiter) {
2236
+ var sign = offset > 0 ? '-' : '+';
2237
+ var absOffset = Math.abs(offset);
2238
+ var hours = Math.floor(absOffset / 60);
2239
+ var minutes = absOffset % 60;
2240
+ if (minutes === 0) {
2241
+ return sign + String(hours);
2242
+ }
2243
+ var delimiter = dirtyDelimiter || '';
2244
+ return sign + String(hours) + delimiter + addLeadingZeros(minutes, 2);
2245
+ }
2246
+ function formatTimezoneWithOptionalMinutes(offset, dirtyDelimiter) {
2247
+ if (offset % 60 === 0) {
2248
+ var sign = offset > 0 ? '-' : '+';
2249
+ return sign + addLeadingZeros(Math.abs(offset) / 60, 2);
2250
+ }
2251
+ return formatTimezone(offset, dirtyDelimiter);
2252
+ }
2253
+ function formatTimezone(offset, dirtyDelimiter) {
2254
+ var delimiter = dirtyDelimiter || '';
2255
+ var sign = offset > 0 ? '-' : '+';
2256
+ var absOffset = Math.abs(offset);
2257
+ var hours = addLeadingZeros(Math.floor(absOffset / 60), 2);
2258
+ var minutes = addLeadingZeros(absOffset % 60, 2);
2259
+ return sign + hours + delimiter + minutes;
2260
+ }
2261
+ var formatters$1 = formatters;
2262
+
2263
+ var dateLongFormatter = function dateLongFormatter(pattern, formatLong) {
2264
+ switch (pattern) {
2265
+ case 'P':
2266
+ return formatLong.date({
2267
+ width: 'short'
2268
+ });
2269
+ case 'PP':
2270
+ return formatLong.date({
2271
+ width: 'medium'
2272
+ });
2273
+ case 'PPP':
2274
+ return formatLong.date({
2275
+ width: 'long'
2276
+ });
2277
+ case 'PPPP':
2278
+ default:
2279
+ return formatLong.date({
2280
+ width: 'full'
2281
+ });
2282
+ }
2283
+ };
2284
+ var timeLongFormatter = function timeLongFormatter(pattern, formatLong) {
2285
+ switch (pattern) {
2286
+ case 'p':
2287
+ return formatLong.time({
2288
+ width: 'short'
2289
+ });
2290
+ case 'pp':
2291
+ return formatLong.time({
2292
+ width: 'medium'
2293
+ });
2294
+ case 'ppp':
2295
+ return formatLong.time({
2296
+ width: 'long'
2297
+ });
2298
+ case 'pppp':
2299
+ default:
2300
+ return formatLong.time({
2301
+ width: 'full'
2302
+ });
2303
+ }
2304
+ };
2305
+ var dateTimeLongFormatter = function dateTimeLongFormatter(pattern, formatLong) {
2306
+ var matchResult = pattern.match(/(P+)(p+)?/) || [];
2307
+ var datePattern = matchResult[1];
2308
+ var timePattern = matchResult[2];
2309
+ if (!timePattern) {
2310
+ return dateLongFormatter(pattern, formatLong);
2311
+ }
2312
+ var dateTimeFormat;
2313
+ switch (datePattern) {
2314
+ case 'P':
2315
+ dateTimeFormat = formatLong.dateTime({
2316
+ width: 'short'
2317
+ });
2318
+ break;
2319
+ case 'PP':
2320
+ dateTimeFormat = formatLong.dateTime({
2321
+ width: 'medium'
2322
+ });
2323
+ break;
2324
+ case 'PPP':
2325
+ dateTimeFormat = formatLong.dateTime({
2326
+ width: 'long'
2327
+ });
2328
+ break;
2329
+ case 'PPPP':
2330
+ default:
2331
+ dateTimeFormat = formatLong.dateTime({
2332
+ width: 'full'
2333
+ });
2334
+ break;
2335
+ }
2336
+ return dateTimeFormat.replace('{{date}}', dateLongFormatter(datePattern, formatLong)).replace('{{time}}', timeLongFormatter(timePattern, formatLong));
2337
+ };
2338
+ var longFormatters = {
2339
+ p: timeLongFormatter,
2340
+ P: dateTimeLongFormatter
2341
+ };
2342
+ var longFormatters$1 = longFormatters;
2343
+
2344
+ /**
2345
+ * Google Chrome as of 67.0.3396.87 introduced timezones with offset that includes seconds.
2346
+ * They usually appear for dates that denote time before the timezones were introduced
2347
+ * (e.g. for 'Europe/Prague' timezone the offset is GMT+00:57:44 before 1 October 1891
2348
+ * and GMT+01:00:00 after that date)
2349
+ *
2350
+ * Date#getTimezoneOffset returns the offset in minutes and would return 57 for the example above,
2351
+ * which would lead to incorrect calculations.
2352
+ *
2353
+ * This function returns the timezone offset in milliseconds that takes seconds in account.
2354
+ */
2355
+ function getTimezoneOffsetInMilliseconds(date) {
2356
+ var utcDate = new Date(Date.UTC(date.getFullYear(), date.getMonth(), date.getDate(), date.getHours(), date.getMinutes(), date.getSeconds(), date.getMilliseconds()));
2357
+ utcDate.setUTCFullYear(date.getFullYear());
2358
+ return date.getTime() - utcDate.getTime();
2359
+ }
2360
+
2361
+ var protectedDayOfYearTokens = ['D', 'DD'];
2362
+ var protectedWeekYearTokens = ['YY', 'YYYY'];
2363
+ function isProtectedDayOfYearToken(token) {
2364
+ return protectedDayOfYearTokens.indexOf(token) !== -1;
2365
+ }
2366
+ function isProtectedWeekYearToken(token) {
2367
+ return protectedWeekYearTokens.indexOf(token) !== -1;
2368
+ }
2369
+ function throwProtectedError(token, format, input) {
2370
+ if (token === 'YYYY') {
2371
+ 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"));
2372
+ } else if (token === 'YY') {
2373
+ 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"));
2374
+ } else if (token === 'D') {
2375
+ 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"));
2376
+ } else if (token === 'DD') {
2377
+ 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"));
2378
+ }
2379
+ }
2380
+
2381
+ var formatDistanceLocale = {
2382
+ lessThanXSeconds: {
2383
+ one: 'less than a second',
2384
+ other: 'less than {{count}} seconds'
2385
+ },
2386
+ xSeconds: {
2387
+ one: '1 second',
2388
+ other: '{{count}} seconds'
2389
+ },
2390
+ halfAMinute: 'half a minute',
2391
+ lessThanXMinutes: {
2392
+ one: 'less than a minute',
2393
+ other: 'less than {{count}} minutes'
2394
+ },
2395
+ xMinutes: {
2396
+ one: '1 minute',
2397
+ other: '{{count}} minutes'
2398
+ },
2399
+ aboutXHours: {
2400
+ one: 'about 1 hour',
2401
+ other: 'about {{count}} hours'
2402
+ },
2403
+ xHours: {
2404
+ one: '1 hour',
2405
+ other: '{{count}} hours'
2406
+ },
2407
+ xDays: {
2408
+ one: '1 day',
2409
+ other: '{{count}} days'
2410
+ },
2411
+ aboutXWeeks: {
2412
+ one: 'about 1 week',
2413
+ other: 'about {{count}} weeks'
2414
+ },
2415
+ xWeeks: {
2416
+ one: '1 week',
2417
+ other: '{{count}} weeks'
2418
+ },
2419
+ aboutXMonths: {
2420
+ one: 'about 1 month',
2421
+ other: 'about {{count}} months'
2422
+ },
2423
+ xMonths: {
2424
+ one: '1 month',
2425
+ other: '{{count}} months'
2426
+ },
2427
+ aboutXYears: {
2428
+ one: 'about 1 year',
2429
+ other: 'about {{count}} years'
2430
+ },
2431
+ xYears: {
2432
+ one: '1 year',
2433
+ other: '{{count}} years'
2434
+ },
2435
+ overXYears: {
2436
+ one: 'over 1 year',
2437
+ other: 'over {{count}} years'
2438
+ },
2439
+ almostXYears: {
2440
+ one: 'almost 1 year',
2441
+ other: 'almost {{count}} years'
2442
+ }
2443
+ };
2444
+ var formatDistance = function formatDistance(token, count, options) {
2445
+ var result;
2446
+ var tokenValue = formatDistanceLocale[token];
2447
+ if (typeof tokenValue === 'string') {
2448
+ result = tokenValue;
2449
+ } else if (count === 1) {
2450
+ result = tokenValue.one;
2451
+ } else {
2452
+ result = tokenValue.other.replace('{{count}}', count.toString());
2453
+ }
2454
+ if (options !== null && options !== void 0 && options.addSuffix) {
2455
+ if (options.comparison && options.comparison > 0) {
2456
+ return 'in ' + result;
2457
+ } else {
2458
+ return result + ' ago';
2459
+ }
2460
+ }
2461
+ return result;
2462
+ };
2463
+ var formatDistance$1 = formatDistance;
2464
+
2465
+ function buildFormatLongFn(args) {
2466
+ return function () {
2467
+ var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
2468
+ // TODO: Remove String()
2469
+ var width = options.width ? String(options.width) : args.defaultWidth;
2470
+ var format = args.formats[width] || args.formats[args.defaultWidth];
2471
+ return format;
2472
+ };
2473
+ }
2474
+
2475
+ var dateFormats = {
2476
+ full: 'EEEE, MMMM do, y',
2477
+ long: 'MMMM do, y',
2478
+ medium: 'MMM d, y',
2479
+ short: 'MM/dd/yyyy'
2480
+ };
2481
+ var timeFormats = {
2482
+ full: 'h:mm:ss a zzzz',
2483
+ long: 'h:mm:ss a z',
2484
+ medium: 'h:mm:ss a',
2485
+ short: 'h:mm a'
2486
+ };
2487
+ var dateTimeFormats = {
2488
+ full: "{{date}} 'at' {{time}}",
2489
+ long: "{{date}} 'at' {{time}}",
2490
+ medium: '{{date}}, {{time}}',
2491
+ short: '{{date}}, {{time}}'
2492
+ };
2493
+ var formatLong = {
2494
+ date: buildFormatLongFn({
2495
+ formats: dateFormats,
2496
+ defaultWidth: 'full'
2497
+ }),
2498
+ time: buildFormatLongFn({
2499
+ formats: timeFormats,
2500
+ defaultWidth: 'full'
2501
+ }),
2502
+ dateTime: buildFormatLongFn({
2503
+ formats: dateTimeFormats,
2504
+ defaultWidth: 'full'
2505
+ })
2506
+ };
2507
+ var formatLong$1 = formatLong;
2508
+
2509
+ var formatRelativeLocale = {
2510
+ lastWeek: "'last' eeee 'at' p",
2511
+ yesterday: "'yesterday at' p",
2512
+ today: "'today at' p",
2513
+ tomorrow: "'tomorrow at' p",
2514
+ nextWeek: "eeee 'at' p",
2515
+ other: 'P'
2516
+ };
2517
+ var formatRelative = function formatRelative(token, _date, _baseDate, _options) {
2518
+ return formatRelativeLocale[token];
2519
+ };
2520
+ var formatRelative$1 = formatRelative;
2521
+
2522
+ function buildLocalizeFn(args) {
2523
+ return function (dirtyIndex, options) {
2524
+ var context = options !== null && options !== void 0 && options.context ? String(options.context) : 'standalone';
2525
+ var valuesArray;
2526
+ if (context === 'formatting' && args.formattingValues) {
2527
+ var defaultWidth = args.defaultFormattingWidth || args.defaultWidth;
2528
+ var width = options !== null && options !== void 0 && options.width ? String(options.width) : defaultWidth;
2529
+ valuesArray = args.formattingValues[width] || args.formattingValues[defaultWidth];
2530
+ } else {
2531
+ var _defaultWidth = args.defaultWidth;
2532
+ var _width = options !== null && options !== void 0 && options.width ? String(options.width) : args.defaultWidth;
2533
+ valuesArray = args.values[_width] || args.values[_defaultWidth];
2534
+ }
2535
+ var index = args.argumentCallback ? args.argumentCallback(dirtyIndex) : dirtyIndex;
2536
+ // @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!
2537
+ return valuesArray[index];
2538
+ };
2539
+ }
2540
+
2541
+ var eraValues = {
2542
+ narrow: ['B', 'A'],
2543
+ abbreviated: ['BC', 'AD'],
2544
+ wide: ['Before Christ', 'Anno Domini']
2545
+ };
2546
+ var quarterValues = {
2547
+ narrow: ['1', '2', '3', '4'],
2548
+ abbreviated: ['Q1', 'Q2', 'Q3', 'Q4'],
2549
+ wide: ['1st quarter', '2nd quarter', '3rd quarter', '4th quarter']
2550
+ };
2551
+
2552
+ // Note: in English, the names of days of the week and months are capitalized.
2553
+ // If you are making a new locale based on this one, check if the same is true for the language you're working on.
2554
+ // Generally, formatted dates should look like they are in the middle of a sentence,
2555
+ // e.g. in Spanish language the weekdays and months should be in the lowercase.
2556
+ var monthValues = {
2557
+ narrow: ['J', 'F', 'M', 'A', 'M', 'J', 'J', 'A', 'S', 'O', 'N', 'D'],
2558
+ abbreviated: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'],
2559
+ wide: ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December']
2560
+ };
2561
+ var dayValues = {
2562
+ narrow: ['S', 'M', 'T', 'W', 'T', 'F', 'S'],
2563
+ short: ['Su', 'Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa'],
2564
+ abbreviated: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'],
2565
+ wide: ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday']
2566
+ };
2567
+ var dayPeriodValues = {
2568
+ narrow: {
2569
+ am: 'a',
2570
+ pm: 'p',
2571
+ midnight: 'mi',
2572
+ noon: 'n',
2573
+ morning: 'morning',
2574
+ afternoon: 'afternoon',
2575
+ evening: 'evening',
2576
+ night: 'night'
2577
+ },
2578
+ abbreviated: {
2579
+ am: 'AM',
2580
+ pm: 'PM',
2581
+ midnight: 'midnight',
2582
+ noon: 'noon',
2583
+ morning: 'morning',
2584
+ afternoon: 'afternoon',
2585
+ evening: 'evening',
2586
+ night: 'night'
2587
+ },
2588
+ wide: {
2589
+ am: 'a.m.',
2590
+ pm: 'p.m.',
2591
+ midnight: 'midnight',
2592
+ noon: 'noon',
2593
+ morning: 'morning',
2594
+ afternoon: 'afternoon',
2595
+ evening: 'evening',
2596
+ night: 'night'
2597
+ }
2598
+ };
2599
+ var formattingDayPeriodValues = {
2600
+ narrow: {
2601
+ am: 'a',
2602
+ pm: 'p',
2603
+ midnight: 'mi',
2604
+ noon: 'n',
2605
+ morning: 'in the morning',
2606
+ afternoon: 'in the afternoon',
2607
+ evening: 'in the evening',
2608
+ night: 'at night'
2609
+ },
2610
+ abbreviated: {
2611
+ am: 'AM',
2612
+ pm: 'PM',
2613
+ midnight: 'midnight',
2614
+ noon: 'noon',
2615
+ morning: 'in the morning',
2616
+ afternoon: 'in the afternoon',
2617
+ evening: 'in the evening',
2618
+ night: 'at night'
2619
+ },
2620
+ wide: {
2621
+ am: 'a.m.',
2622
+ pm: 'p.m.',
2623
+ midnight: 'midnight',
2624
+ noon: 'noon',
2625
+ morning: 'in the morning',
2626
+ afternoon: 'in the afternoon',
2627
+ evening: 'in the evening',
2628
+ night: 'at night'
2629
+ }
2630
+ };
2631
+ var ordinalNumber = function ordinalNumber(dirtyNumber, _options) {
2632
+ var number = Number(dirtyNumber);
2633
+
2634
+ // If ordinal numbers depend on context, for example,
2635
+ // if they are different for different grammatical genders,
2636
+ // use `options.unit`.
2637
+ //
2638
+ // `unit` can be 'year', 'quarter', 'month', 'week', 'date', 'dayOfYear',
2639
+ // 'day', 'hour', 'minute', 'second'.
2640
+
2641
+ var rem100 = number % 100;
2642
+ if (rem100 > 20 || rem100 < 10) {
2643
+ switch (rem100 % 10) {
2644
+ case 1:
2645
+ return number + 'st';
2646
+ case 2:
2647
+ return number + 'nd';
2648
+ case 3:
2649
+ return number + 'rd';
2650
+ }
2651
+ }
2652
+ return number + 'th';
2653
+ };
2654
+ var localize = {
2655
+ ordinalNumber: ordinalNumber,
2656
+ era: buildLocalizeFn({
2657
+ values: eraValues,
2658
+ defaultWidth: 'wide'
2659
+ }),
2660
+ quarter: buildLocalizeFn({
2661
+ values: quarterValues,
2662
+ defaultWidth: 'wide',
2663
+ argumentCallback: function argumentCallback(quarter) {
2664
+ return quarter - 1;
2665
+ }
2666
+ }),
2667
+ month: buildLocalizeFn({
2668
+ values: monthValues,
2669
+ defaultWidth: 'wide'
2670
+ }),
2671
+ day: buildLocalizeFn({
2672
+ values: dayValues,
2673
+ defaultWidth: 'wide'
2674
+ }),
2675
+ dayPeriod: buildLocalizeFn({
2676
+ values: dayPeriodValues,
2677
+ defaultWidth: 'wide',
2678
+ formattingValues: formattingDayPeriodValues,
2679
+ defaultFormattingWidth: 'wide'
2680
+ })
2681
+ };
2682
+ var localize$1 = localize;
2683
+
2684
+ function buildMatchFn(args) {
2685
+ return function (string) {
2686
+ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
2687
+ var width = options.width;
2688
+ var matchPattern = width && args.matchPatterns[width] || args.matchPatterns[args.defaultMatchWidth];
2689
+ var matchResult = string.match(matchPattern);
2690
+ if (!matchResult) {
2691
+ return null;
2692
+ }
2693
+ var matchedString = matchResult[0];
2694
+ var parsePatterns = width && args.parsePatterns[width] || args.parsePatterns[args.defaultParseWidth];
2695
+ var key = Array.isArray(parsePatterns) ? findIndex(parsePatterns, function (pattern) {
2696
+ return pattern.test(matchedString);
2697
+ }) : findKey(parsePatterns, function (pattern) {
2698
+ return pattern.test(matchedString);
2699
+ });
2700
+ var value;
2701
+ value = args.valueCallback ? args.valueCallback(key) : key;
2702
+ value = options.valueCallback ? options.valueCallback(value) : value;
2703
+ var rest = string.slice(matchedString.length);
2704
+ return {
2705
+ value: value,
2706
+ rest: rest
2707
+ };
2708
+ };
2709
+ }
2710
+ function findKey(object, predicate) {
2711
+ for (var key in object) {
2712
+ if (object.hasOwnProperty(key) && predicate(object[key])) {
2713
+ return key;
2714
+ }
2715
+ }
2716
+ return undefined;
2717
+ }
2718
+ function findIndex(array, predicate) {
2719
+ for (var key = 0; key < array.length; key++) {
2720
+ if (predicate(array[key])) {
2721
+ return key;
2722
+ }
2723
+ }
2724
+ return undefined;
2725
+ }
2726
+
2727
+ function buildMatchPatternFn(args) {
2728
+ return function (string) {
2729
+ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
2730
+ var matchResult = string.match(args.matchPattern);
2731
+ if (!matchResult) return null;
2732
+ var matchedString = matchResult[0];
2733
+ var parseResult = string.match(args.parsePattern);
2734
+ if (!parseResult) return null;
2735
+ var value = args.valueCallback ? args.valueCallback(parseResult[0]) : parseResult[0];
2736
+ value = options.valueCallback ? options.valueCallback(value) : value;
2737
+ var rest = string.slice(matchedString.length);
2738
+ return {
2739
+ value: value,
2740
+ rest: rest
2741
+ };
2742
+ };
2743
+ }
2744
+
2745
+ var matchOrdinalNumberPattern = /^(\d+)(th|st|nd|rd)?/i;
2746
+ var parseOrdinalNumberPattern = /\d+/i;
2747
+ var matchEraPatterns = {
2748
+ narrow: /^(b|a)/i,
2749
+ abbreviated: /^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,
2750
+ wide: /^(before christ|before common era|anno domini|common era)/i
2751
+ };
2752
+ var parseEraPatterns = {
2753
+ any: [/^b/i, /^(a|c)/i]
2754
+ };
2755
+ var matchQuarterPatterns = {
2756
+ narrow: /^[1234]/i,
2757
+ abbreviated: /^q[1234]/i,
2758
+ wide: /^[1234](th|st|nd|rd)? quarter/i
2759
+ };
2760
+ var parseQuarterPatterns = {
2761
+ any: [/1/i, /2/i, /3/i, /4/i]
2762
+ };
2763
+ var matchMonthPatterns = {
2764
+ narrow: /^[jfmasond]/i,
2765
+ abbreviated: /^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,
2766
+ wide: /^(january|february|march|april|may|june|july|august|september|october|november|december)/i
2767
+ };
2768
+ var parseMonthPatterns = {
2769
+ 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],
2770
+ 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]
2771
+ };
2772
+ var matchDayPatterns = {
2773
+ narrow: /^[smtwf]/i,
2774
+ short: /^(su|mo|tu|we|th|fr|sa)/i,
2775
+ abbreviated: /^(sun|mon|tue|wed|thu|fri|sat)/i,
2776
+ wide: /^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i
2777
+ };
2778
+ var parseDayPatterns = {
2779
+ narrow: [/^s/i, /^m/i, /^t/i, /^w/i, /^t/i, /^f/i, /^s/i],
2780
+ any: [/^su/i, /^m/i, /^tu/i, /^w/i, /^th/i, /^f/i, /^sa/i]
2781
+ };
2782
+ var matchDayPeriodPatterns = {
2783
+ narrow: /^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,
2784
+ any: /^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i
2785
+ };
2786
+ var parseDayPeriodPatterns = {
2787
+ any: {
2788
+ am: /^a/i,
2789
+ pm: /^p/i,
2790
+ midnight: /^mi/i,
2791
+ noon: /^no/i,
2792
+ morning: /morning/i,
2793
+ afternoon: /afternoon/i,
2794
+ evening: /evening/i,
2795
+ night: /night/i
2796
+ }
2797
+ };
2798
+ var match = {
2799
+ ordinalNumber: buildMatchPatternFn({
2800
+ matchPattern: matchOrdinalNumberPattern,
2801
+ parsePattern: parseOrdinalNumberPattern,
2802
+ valueCallback: function valueCallback(value) {
2803
+ return parseInt(value, 10);
2804
+ }
2805
+ }),
2806
+ era: buildMatchFn({
2807
+ matchPatterns: matchEraPatterns,
2808
+ defaultMatchWidth: 'wide',
2809
+ parsePatterns: parseEraPatterns,
2810
+ defaultParseWidth: 'any'
2811
+ }),
2812
+ quarter: buildMatchFn({
2813
+ matchPatterns: matchQuarterPatterns,
2814
+ defaultMatchWidth: 'wide',
2815
+ parsePatterns: parseQuarterPatterns,
2816
+ defaultParseWidth: 'any',
2817
+ valueCallback: function valueCallback(index) {
2818
+ return index + 1;
2819
+ }
2820
+ }),
2821
+ month: buildMatchFn({
2822
+ matchPatterns: matchMonthPatterns,
2823
+ defaultMatchWidth: 'wide',
2824
+ parsePatterns: parseMonthPatterns,
2825
+ defaultParseWidth: 'any'
2826
+ }),
2827
+ day: buildMatchFn({
2828
+ matchPatterns: matchDayPatterns,
2829
+ defaultMatchWidth: 'wide',
2830
+ parsePatterns: parseDayPatterns,
2831
+ defaultParseWidth: 'any'
2832
+ }),
2833
+ dayPeriod: buildMatchFn({
2834
+ matchPatterns: matchDayPeriodPatterns,
2835
+ defaultMatchWidth: 'any',
2836
+ parsePatterns: parseDayPeriodPatterns,
2837
+ defaultParseWidth: 'any'
2838
+ })
2839
+ };
2840
+ var match$1 = match;
2841
+
2842
+ /**
2843
+ * @type {Locale}
2844
+ * @category Locales
2845
+ * @summary English locale (United States).
2846
+ * @language English
2847
+ * @iso-639-2 eng
2848
+ * @author Sasha Koss [@kossnocorp]{@link https://github.com/kossnocorp}
2849
+ * @author Lesha Koss [@leshakoss]{@link https://github.com/leshakoss}
2850
+ */
2851
+ var locale = {
2852
+ code: 'en-US',
2853
+ formatDistance: formatDistance$1,
2854
+ formatLong: formatLong$1,
2855
+ formatRelative: formatRelative$1,
2856
+ localize: localize$1,
2857
+ match: match$1,
2858
+ options: {
2859
+ weekStartsOn: 0 /* Sunday */,
2860
+ firstWeekContainsDate: 1
2861
+ }
2862
+ };
2863
+ var defaultLocale = locale;
2864
+
2865
+ // - [yYQqMLwIdDecihHKkms]o matches any available ordinal number token
2866
+ // (one of the certain letters followed by `o`)
2867
+ // - (\w)\1* matches any sequences of the same letter
2868
+ // - '' matches two quote characters in a row
2869
+ // - '(''|[^'])+('|$) matches anything surrounded by two quote characters ('),
2870
+ // except a single quote symbol, which ends the sequence.
2871
+ // Two quote characters do not end the sequence.
2872
+ // If there is no matching single quote
2873
+ // then the sequence will continue until the end of the string.
2874
+ // - . matches any single character unmatched by previous parts of the RegExps
2875
+ var formattingTokensRegExp = /[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g;
2876
+
2877
+ // This RegExp catches symbols escaped by quotes, and also
2878
+ // sequences of symbols P, p, and the combinations like `PPPPPPPppppp`
2879
+ var longFormattingTokensRegExp = /P+p+|P+|p+|''|'(''|[^'])+('|$)|./g;
2880
+ var escapedStringRegExp = /^'([^]*?)'?$/;
2881
+ var doubleQuoteRegExp = /''/g;
2882
+ var unescapedLatinCharacterRegExp = /[a-zA-Z]/;
2883
+
2884
+ /**
2885
+ * @name format
2886
+ * @category Common Helpers
2887
+ * @summary Format the date.
2888
+ *
2889
+ * @description
2890
+ * Return the formatted date string in the given format. The result may vary by locale.
2891
+ *
2892
+ * > ⚠️ Please note that the `format` tokens differ from Moment.js and other libraries.
2893
+ * > See: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md
2894
+ *
2895
+ * The characters wrapped between two single quotes characters (') are escaped.
2896
+ * Two single quotes in a row, whether inside or outside a quoted sequence, represent a 'real' single quote.
2897
+ * (see the last example)
2898
+ *
2899
+ * Format of the string is based on Unicode Technical Standard #35:
2900
+ * https://www.unicode.org/reports/tr35/tr35-dates.html#Date_Field_Symbol_Table
2901
+ * with a few additions (see note 7 below the table).
2902
+ *
2903
+ * Accepted patterns:
2904
+ * | Unit | Pattern | Result examples | Notes |
2905
+ * |---------------------------------|---------|-----------------------------------|-------|
2906
+ * | Era | G..GGG | AD, BC | |
2907
+ * | | GGGG | Anno Domini, Before Christ | 2 |
2908
+ * | | GGGGG | A, B | |
2909
+ * | Calendar year | y | 44, 1, 1900, 2017 | 5 |
2910
+ * | | yo | 44th, 1st, 0th, 17th | 5,7 |
2911
+ * | | yy | 44, 01, 00, 17 | 5 |
2912
+ * | | yyy | 044, 001, 1900, 2017 | 5 |
2913
+ * | | yyyy | 0044, 0001, 1900, 2017 | 5 |
2914
+ * | | yyyyy | ... | 3,5 |
2915
+ * | Local week-numbering year | Y | 44, 1, 1900, 2017 | 5 |
2916
+ * | | Yo | 44th, 1st, 1900th, 2017th | 5,7 |
2917
+ * | | YY | 44, 01, 00, 17 | 5,8 |
2918
+ * | | YYY | 044, 001, 1900, 2017 | 5 |
2919
+ * | | YYYY | 0044, 0001, 1900, 2017 | 5,8 |
2920
+ * | | YYYYY | ... | 3,5 |
2921
+ * | ISO week-numbering year | R | -43, 0, 1, 1900, 2017 | 5,7 |
2922
+ * | | RR | -43, 00, 01, 1900, 2017 | 5,7 |
2923
+ * | | RRR | -043, 000, 001, 1900, 2017 | 5,7 |
2924
+ * | | RRRR | -0043, 0000, 0001, 1900, 2017 | 5,7 |
2925
+ * | | RRRRR | ... | 3,5,7 |
2926
+ * | Extended year | u | -43, 0, 1, 1900, 2017 | 5 |
2927
+ * | | uu | -43, 01, 1900, 2017 | 5 |
2928
+ * | | uuu | -043, 001, 1900, 2017 | 5 |
2929
+ * | | uuuu | -0043, 0001, 1900, 2017 | 5 |
2930
+ * | | uuuuu | ... | 3,5 |
2931
+ * | Quarter (formatting) | Q | 1, 2, 3, 4 | |
2932
+ * | | Qo | 1st, 2nd, 3rd, 4th | 7 |
2933
+ * | | QQ | 01, 02, 03, 04 | |
2934
+ * | | QQQ | Q1, Q2, Q3, Q4 | |
2935
+ * | | QQQQ | 1st quarter, 2nd quarter, ... | 2 |
2936
+ * | | QQQQQ | 1, 2, 3, 4 | 4 |
2937
+ * | Quarter (stand-alone) | q | 1, 2, 3, 4 | |
2938
+ * | | qo | 1st, 2nd, 3rd, 4th | 7 |
2939
+ * | | qq | 01, 02, 03, 04 | |
2940
+ * | | qqq | Q1, Q2, Q3, Q4 | |
2941
+ * | | qqqq | 1st quarter, 2nd quarter, ... | 2 |
2942
+ * | | qqqqq | 1, 2, 3, 4 | 4 |
2943
+ * | Month (formatting) | M | 1, 2, ..., 12 | |
2944
+ * | | Mo | 1st, 2nd, ..., 12th | 7 |
2945
+ * | | MM | 01, 02, ..., 12 | |
2946
+ * | | MMM | Jan, Feb, ..., Dec | |
2947
+ * | | MMMM | January, February, ..., December | 2 |
2948
+ * | | MMMMM | J, F, ..., D | |
2949
+ * | Month (stand-alone) | L | 1, 2, ..., 12 | |
2950
+ * | | Lo | 1st, 2nd, ..., 12th | 7 |
2951
+ * | | LL | 01, 02, ..., 12 | |
2952
+ * | | LLL | Jan, Feb, ..., Dec | |
2953
+ * | | LLLL | January, February, ..., December | 2 |
2954
+ * | | LLLLL | J, F, ..., D | |
2955
+ * | Local week of year | w | 1, 2, ..., 53 | |
2956
+ * | | wo | 1st, 2nd, ..., 53th | 7 |
2957
+ * | | ww | 01, 02, ..., 53 | |
2958
+ * | ISO week of year | I | 1, 2, ..., 53 | 7 |
2959
+ * | | Io | 1st, 2nd, ..., 53th | 7 |
2960
+ * | | II | 01, 02, ..., 53 | 7 |
2961
+ * | Day of month | d | 1, 2, ..., 31 | |
2962
+ * | | do | 1st, 2nd, ..., 31st | 7 |
2963
+ * | | dd | 01, 02, ..., 31 | |
2964
+ * | Day of year | D | 1, 2, ..., 365, 366 | 9 |
2965
+ * | | Do | 1st, 2nd, ..., 365th, 366th | 7 |
2966
+ * | | DD | 01, 02, ..., 365, 366 | 9 |
2967
+ * | | DDD | 001, 002, ..., 365, 366 | |
2968
+ * | | DDDD | ... | 3 |
2969
+ * | Day of week (formatting) | E..EEE | Mon, Tue, Wed, ..., Sun | |
2970
+ * | | EEEE | Monday, Tuesday, ..., Sunday | 2 |
2971
+ * | | EEEEE | M, T, W, T, F, S, S | |
2972
+ * | | EEEEEE | Mo, Tu, We, Th, Fr, Sa, Su | |
2973
+ * | ISO day of week (formatting) | i | 1, 2, 3, ..., 7 | 7 |
2974
+ * | | io | 1st, 2nd, ..., 7th | 7 |
2975
+ * | | ii | 01, 02, ..., 07 | 7 |
2976
+ * | | iii | Mon, Tue, Wed, ..., Sun | 7 |
2977
+ * | | iiii | Monday, Tuesday, ..., Sunday | 2,7 |
2978
+ * | | iiiii | M, T, W, T, F, S, S | 7 |
2979
+ * | | iiiiii | Mo, Tu, We, Th, Fr, Sa, Su | 7 |
2980
+ * | Local day of week (formatting) | e | 2, 3, 4, ..., 1 | |
2981
+ * | | eo | 2nd, 3rd, ..., 1st | 7 |
2982
+ * | | ee | 02, 03, ..., 01 | |
2983
+ * | | eee | Mon, Tue, Wed, ..., Sun | |
2984
+ * | | eeee | Monday, Tuesday, ..., Sunday | 2 |
2985
+ * | | eeeee | M, T, W, T, F, S, S | |
2986
+ * | | eeeeee | Mo, Tu, We, Th, Fr, Sa, Su | |
2987
+ * | Local day of week (stand-alone) | c | 2, 3, 4, ..., 1 | |
2988
+ * | | co | 2nd, 3rd, ..., 1st | 7 |
2989
+ * | | cc | 02, 03, ..., 01 | |
2990
+ * | | ccc | Mon, Tue, Wed, ..., Sun | |
2991
+ * | | cccc | Monday, Tuesday, ..., Sunday | 2 |
2992
+ * | | ccccc | M, T, W, T, F, S, S | |
2993
+ * | | cccccc | Mo, Tu, We, Th, Fr, Sa, Su | |
2994
+ * | AM, PM | a..aa | AM, PM | |
2995
+ * | | aaa | am, pm | |
2996
+ * | | aaaa | a.m., p.m. | 2 |
2997
+ * | | aaaaa | a, p | |
2998
+ * | AM, PM, noon, midnight | b..bb | AM, PM, noon, midnight | |
2999
+ * | | bbb | am, pm, noon, midnight | |
3000
+ * | | bbbb | a.m., p.m., noon, midnight | 2 |
3001
+ * | | bbbbb | a, p, n, mi | |
3002
+ * | Flexible day period | B..BBB | at night, in the morning, ... | |
3003
+ * | | BBBB | at night, in the morning, ... | 2 |
3004
+ * | | BBBBB | at night, in the morning, ... | |
3005
+ * | Hour [1-12] | h | 1, 2, ..., 11, 12 | |
3006
+ * | | ho | 1st, 2nd, ..., 11th, 12th | 7 |
3007
+ * | | hh | 01, 02, ..., 11, 12 | |
3008
+ * | Hour [0-23] | H | 0, 1, 2, ..., 23 | |
3009
+ * | | Ho | 0th, 1st, 2nd, ..., 23rd | 7 |
3010
+ * | | HH | 00, 01, 02, ..., 23 | |
3011
+ * | Hour [0-11] | K | 1, 2, ..., 11, 0 | |
3012
+ * | | Ko | 1st, 2nd, ..., 11th, 0th | 7 |
3013
+ * | | KK | 01, 02, ..., 11, 00 | |
3014
+ * | Hour [1-24] | k | 24, 1, 2, ..., 23 | |
3015
+ * | | ko | 24th, 1st, 2nd, ..., 23rd | 7 |
3016
+ * | | kk | 24, 01, 02, ..., 23 | |
3017
+ * | Minute | m | 0, 1, ..., 59 | |
3018
+ * | | mo | 0th, 1st, ..., 59th | 7 |
3019
+ * | | mm | 00, 01, ..., 59 | |
3020
+ * | Second | s | 0, 1, ..., 59 | |
3021
+ * | | so | 0th, 1st, ..., 59th | 7 |
3022
+ * | | ss | 00, 01, ..., 59 | |
3023
+ * | Fraction of second | S | 0, 1, ..., 9 | |
3024
+ * | | SS | 00, 01, ..., 99 | |
3025
+ * | | SSS | 000, 001, ..., 999 | |
3026
+ * | | SSSS | ... | 3 |
3027
+ * | Timezone (ISO-8601 w/ Z) | X | -08, +0530, Z | |
3028
+ * | | XX | -0800, +0530, Z | |
3029
+ * | | XXX | -08:00, +05:30, Z | |
3030
+ * | | XXXX | -0800, +0530, Z, +123456 | 2 |
3031
+ * | | XXXXX | -08:00, +05:30, Z, +12:34:56 | |
3032
+ * | Timezone (ISO-8601 w/o Z) | x | -08, +0530, +00 | |
3033
+ * | | xx | -0800, +0530, +0000 | |
3034
+ * | | xxx | -08:00, +05:30, +00:00 | 2 |
3035
+ * | | xxxx | -0800, +0530, +0000, +123456 | |
3036
+ * | | xxxxx | -08:00, +05:30, +00:00, +12:34:56 | |
3037
+ * | Timezone (GMT) | O...OOO | GMT-8, GMT+5:30, GMT+0 | |
3038
+ * | | OOOO | GMT-08:00, GMT+05:30, GMT+00:00 | 2 |
3039
+ * | Timezone (specific non-locat.) | z...zzz | GMT-8, GMT+5:30, GMT+0 | 6 |
3040
+ * | | zzzz | GMT-08:00, GMT+05:30, GMT+00:00 | 2,6 |
3041
+ * | Seconds timestamp | t | 512969520 | 7 |
3042
+ * | | tt | ... | 3,7 |
3043
+ * | Milliseconds timestamp | T | 512969520900 | 7 |
3044
+ * | | TT | ... | 3,7 |
3045
+ * | Long localized date | P | 04/29/1453 | 7 |
3046
+ * | | PP | Apr 29, 1453 | 7 |
3047
+ * | | PPP | April 29th, 1453 | 7 |
3048
+ * | | PPPP | Friday, April 29th, 1453 | 2,7 |
3049
+ * | Long localized time | p | 12:00 AM | 7 |
3050
+ * | | pp | 12:00:00 AM | 7 |
3051
+ * | | ppp | 12:00:00 AM GMT+2 | 7 |
3052
+ * | | pppp | 12:00:00 AM GMT+02:00 | 2,7 |
3053
+ * | Combination of date and time | Pp | 04/29/1453, 12:00 AM | 7 |
3054
+ * | | PPpp | Apr 29, 1453, 12:00:00 AM | 7 |
3055
+ * | | PPPppp | April 29th, 1453 at ... | 7 |
3056
+ * | | PPPPpppp| Friday, April 29th, 1453 at ... | 2,7 |
3057
+ * Notes:
3058
+ * 1. "Formatting" units (e.g. formatting quarter) in the default en-US locale
3059
+ * are the same as "stand-alone" units, but are different in some languages.
3060
+ * "Formatting" units are declined according to the rules of the language
3061
+ * in the context of a date. "Stand-alone" units are always nominative singular:
3062
+ *
3063
+ * `format(new Date(2017, 10, 6), 'do LLLL', {locale: cs}) //=> '6. listopad'`
3064
+ *
3065
+ * `format(new Date(2017, 10, 6), 'do MMMM', {locale: cs}) //=> '6. listopadu'`
3066
+ *
3067
+ * 2. Any sequence of the identical letters is a pattern, unless it is escaped by
3068
+ * the single quote characters (see below).
3069
+ * If the sequence is longer than listed in table (e.g. `EEEEEEEEEEE`)
3070
+ * the output will be the same as default pattern for this unit, usually
3071
+ * the longest one (in case of ISO weekdays, `EEEE`). Default patterns for units
3072
+ * are marked with "2" in the last column of the table.
3073
+ *
3074
+ * `format(new Date(2017, 10, 6), 'MMM') //=> 'Nov'`
3075
+ *
3076
+ * `format(new Date(2017, 10, 6), 'MMMM') //=> 'November'`
3077
+ *
3078
+ * `format(new Date(2017, 10, 6), 'MMMMM') //=> 'N'`
3079
+ *
3080
+ * `format(new Date(2017, 10, 6), 'MMMMMM') //=> 'November'`
3081
+ *
3082
+ * `format(new Date(2017, 10, 6), 'MMMMMMM') //=> 'November'`
3083
+ *
3084
+ * 3. Some patterns could be unlimited length (such as `yyyyyyyy`).
3085
+ * The output will be padded with zeros to match the length of the pattern.
3086
+ *
3087
+ * `format(new Date(2017, 10, 6), 'yyyyyyyy') //=> '00002017'`
3088
+ *
3089
+ * 4. `QQQQQ` and `qqqqq` could be not strictly numerical in some locales.
3090
+ * These tokens represent the shortest form of the quarter.
3091
+ *
3092
+ * 5. The main difference between `y` and `u` patterns are B.C. years:
3093
+ *
3094
+ * | Year | `y` | `u` |
3095
+ * |------|-----|-----|
3096
+ * | AC 1 | 1 | 1 |
3097
+ * | BC 1 | 1 | 0 |
3098
+ * | BC 2 | 2 | -1 |
3099
+ *
3100
+ * Also `yy` always returns the last two digits of a year,
3101
+ * while `uu` pads single digit years to 2 characters and returns other years unchanged:
3102
+ *
3103
+ * | Year | `yy` | `uu` |
3104
+ * |------|------|------|
3105
+ * | 1 | 01 | 01 |
3106
+ * | 14 | 14 | 14 |
3107
+ * | 376 | 76 | 376 |
3108
+ * | 1453 | 53 | 1453 |
3109
+ *
3110
+ * The same difference is true for local and ISO week-numbering years (`Y` and `R`),
3111
+ * except local week-numbering years are dependent on `options.weekStartsOn`
3112
+ * and `options.firstWeekContainsDate` (compare [getISOWeekYear]{@link https://date-fns.org/docs/getISOWeekYear}
3113
+ * and [getWeekYear]{@link https://date-fns.org/docs/getWeekYear}).
3114
+ *
3115
+ * 6. Specific non-location timezones are currently unavailable in `date-fns`,
3116
+ * so right now these tokens fall back to GMT timezones.
3117
+ *
3118
+ * 7. These patterns are not in the Unicode Technical Standard #35:
3119
+ * - `i`: ISO day of week
3120
+ * - `I`: ISO week of year
3121
+ * - `R`: ISO week-numbering year
3122
+ * - `t`: seconds timestamp
3123
+ * - `T`: milliseconds timestamp
3124
+ * - `o`: ordinal number modifier
3125
+ * - `P`: long localized date
3126
+ * - `p`: long localized time
3127
+ *
3128
+ * 8. `YY` and `YYYY` tokens represent week-numbering years but they are often confused with years.
3129
+ * You should enable `options.useAdditionalWeekYearTokens` to use them. See: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md
3130
+ *
3131
+ * 9. `D` and `DD` tokens represent days of the year but they are often confused with days of the month.
3132
+ * You should enable `options.useAdditionalDayOfYearTokens` to use them. See: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md
3133
+ *
3134
+ * @param {Date|Number} date - the original date
3135
+ * @param {String} format - the string of tokens
3136
+ * @param {Object} [options] - an object with options.
3137
+ * @param {Locale} [options.locale=defaultLocale] - the locale object. See [Locale]{@link https://date-fns.org/docs/Locale}
3138
+ * @param {0|1|2|3|4|5|6} [options.weekStartsOn=0] - the index of the first day of the week (0 - Sunday)
3139
+ * @param {Number} [options.firstWeekContainsDate=1] - the day of January, which is
3140
+ * @param {Boolean} [options.useAdditionalWeekYearTokens=false] - if true, allows usage of the week-numbering year tokens `YY` and `YYYY`;
3141
+ * see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md
3142
+ * @param {Boolean} [options.useAdditionalDayOfYearTokens=false] - if true, allows usage of the day of year tokens `D` and `DD`;
3143
+ * see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md
3144
+ * @returns {String} the formatted date string
3145
+ * @throws {TypeError} 2 arguments required
3146
+ * @throws {RangeError} `date` must not be Invalid Date
3147
+ * @throws {RangeError} `options.locale` must contain `localize` property
3148
+ * @throws {RangeError} `options.locale` must contain `formatLong` property
3149
+ * @throws {RangeError} `options.weekStartsOn` must be between 0 and 6
3150
+ * @throws {RangeError} `options.firstWeekContainsDate` must be between 1 and 7
3151
+ * @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
3152
+ * @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
3153
+ * @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
3154
+ * @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
3155
+ * @throws {RangeError} format string contains an unescaped latin alphabet character
3156
+ *
3157
+ * @example
3158
+ * // Represent 11 February 2014 in middle-endian format:
3159
+ * const result = format(new Date(2014, 1, 11), 'MM/dd/yyyy')
3160
+ * //=> '02/11/2014'
3161
+ *
3162
+ * @example
3163
+ * // Represent 2 July 2014 in Esperanto:
3164
+ * import { eoLocale } from 'date-fns/locale/eo'
3165
+ * const result = format(new Date(2014, 6, 2), "do 'de' MMMM yyyy", {
3166
+ * locale: eoLocale
3167
+ * })
3168
+ * //=> '2-a de julio 2014'
3169
+ *
3170
+ * @example
3171
+ * // Escape string by single quote characters:
3172
+ * const result = format(new Date(2014, 6, 2, 15), "h 'o''clock'")
3173
+ * //=> "3 o'clock"
3174
+ */
3175
+
3176
+ function format(dirtyDate, dirtyFormatStr, options) {
3177
+ 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;
3178
+ requiredArgs(2, arguments);
3179
+ var formatStr = String(dirtyFormatStr);
3180
+ var defaultOptions = getDefaultOptions();
3181
+ var locale = (_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 : defaultLocale;
3182
+ 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);
3183
+
3184
+ // Test if weekStartsOn is between 1 and 7 _and_ is not NaN
3185
+ if (!(firstWeekContainsDate >= 1 && firstWeekContainsDate <= 7)) {
3186
+ throw new RangeError('firstWeekContainsDate must be between 1 and 7 inclusively');
3187
+ }
3188
+ 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);
3189
+
3190
+ // Test if weekStartsOn is between 0 and 6 _and_ is not NaN
3191
+ if (!(weekStartsOn >= 0 && weekStartsOn <= 6)) {
3192
+ throw new RangeError('weekStartsOn must be between 0 and 6 inclusively');
3193
+ }
3194
+ if (!locale.localize) {
3195
+ throw new RangeError('locale must contain localize property');
3196
+ }
3197
+ if (!locale.formatLong) {
3198
+ throw new RangeError('locale must contain formatLong property');
3199
+ }
3200
+ var originalDate = toDate(dirtyDate);
3201
+ if (!isValid(originalDate)) {
3202
+ throw new RangeError('Invalid time value');
3203
+ }
3204
+
3205
+ // Convert the date in system timezone to the same date in UTC+00:00 timezone.
3206
+ // This ensures that when UTC functions will be implemented, locales will be compatible with them.
3207
+ // See an issue about UTC functions: https://github.com/date-fns/date-fns/issues/376
3208
+ var timezoneOffset = getTimezoneOffsetInMilliseconds(originalDate);
3209
+ var utcDate = subMilliseconds(originalDate, timezoneOffset);
3210
+ var formatterOptions = {
3211
+ firstWeekContainsDate: firstWeekContainsDate,
3212
+ weekStartsOn: weekStartsOn,
3213
+ locale: locale,
3214
+ _originalDate: originalDate
3215
+ };
3216
+ var result = formatStr.match(longFormattingTokensRegExp).map(function (substring) {
3217
+ var firstCharacter = substring[0];
3218
+ if (firstCharacter === 'p' || firstCharacter === 'P') {
3219
+ var longFormatter = longFormatters$1[firstCharacter];
3220
+ return longFormatter(substring, locale.formatLong);
3221
+ }
3222
+ return substring;
3223
+ }).join('').match(formattingTokensRegExp).map(function (substring) {
3224
+ // Replace two single quote characters with one single quote character
3225
+ if (substring === "''") {
3226
+ return "'";
3227
+ }
3228
+ var firstCharacter = substring[0];
3229
+ if (firstCharacter === "'") {
3230
+ return cleanEscapedString(substring);
3231
+ }
3232
+ var formatter = formatters$1[firstCharacter];
3233
+ if (formatter) {
3234
+ if (!(options !== null && options !== void 0 && options.useAdditionalWeekYearTokens) && isProtectedWeekYearToken(substring)) {
3235
+ throwProtectedError(substring, dirtyFormatStr, String(dirtyDate));
3236
+ }
3237
+ if (!(options !== null && options !== void 0 && options.useAdditionalDayOfYearTokens) && isProtectedDayOfYearToken(substring)) {
3238
+ throwProtectedError(substring, dirtyFormatStr, String(dirtyDate));
3239
+ }
3240
+ return formatter(utcDate, substring, locale.localize, formatterOptions);
3241
+ }
3242
+ if (firstCharacter.match(unescapedLatinCharacterRegExp)) {
3243
+ throw new RangeError('Format string contains an unescaped latin alphabet character `' + firstCharacter + '`');
3244
+ }
3245
+ return substring;
3246
+ }).join('');
3247
+ return result;
3248
+ }
3249
+ function cleanEscapedString(input) {
3250
+ var matched = input.match(escapedStringRegExp);
3251
+ if (!matched) {
3252
+ return input;
3253
+ }
3254
+ return matched[1].replace(doubleQuoteRegExp, "'");
3255
+ }
3256
+
3257
+ var ArcCalendarContext = createContext(null);
3258
+
3259
+ var CalendarDayNumber = forwardRef(function (_a, autoFocusRef) {
3260
+ var date = _a.date, shouldRender = _a.shouldRender, isFocusWithinDayGrid = _a.isFocusWithinDayGrid;
3261
+ var context = useContext(ArcCalendarContext);
3262
+ var isFocusDate = context && isEqual(date, context.focusDate);
3263
+ var tableCellRef = useCallback(function (el) {
3264
+ if (el && isFocusDate && isFocusWithinDayGrid) {
3265
+ el.focus();
3266
+ }
3267
+ }, [isFocusDate, isFocusWithinDayGrid]);
3268
+ if (!context) {
3269
+ return null;
3270
+ }
3271
+ var handleRefs = function (el) {
3272
+ tableCellRef(el);
3273
+ if (autoFocusRef && typeof autoFocusRef === "function") {
3274
+ autoFocusRef(el);
3275
+ }
3276
+ };
3277
+ var disabledDates = context.disabledDates, selectedDate = context.selectedDate, selectionType = context.selectionType, selectedRange = context.selectedRange, highlightedRange = context.highlightedRange, todayDate = context.todayDate, onDayNumberClick = context.onDayNumberClick, onDayNumberHover = context.onDayNumberHover, minDate = context.minDate, maxDate = context.maxDate;
3278
+ var highlightedRangeStart = highlightedRange[0];
3279
+ var highlightedRangeEnd = highlightedRange[1];
3280
+ var isSelectedDate = selectionType === "single"
3281
+ ? isEqual(date, selectedDate)
3282
+ : selectedRange.length &&
3283
+ containsDate(selectedRange.filter(function (date) { return Boolean(date); }), date);
3284
+ var isTodayDate = isEqual(date, todayDate);
3285
+ var dateIsWithinHighlightedRange = selectionType === "range" &&
3286
+ highlightedRange.length === 2 &&
3287
+ !isAfter(date, highlightedRangeEnd) &&
3288
+ !isBefore(date, highlightedRangeStart);
3289
+ var isRoundedLeft = selectionType === "range" &&
3290
+ (isDay(date, WeekDays.MONDAY) ||
3291
+ isFirstDayOfMonth(date) ||
3292
+ isEqual(date, highlightedRangeStart));
3293
+ var isRoundedRight = selectionType === "range" &&
3294
+ (isDay(date, WeekDays.SUNDAY) ||
3295
+ isLastDayOfMonth(date) ||
3296
+ isEqual(date, highlightedRangeEnd));
3297
+ var conditionalClasses = {
3298
+ "arc-CalendarDayNumber--selected": isSelectedDate,
3299
+ "arc-CalendarDayNumber--todayDate": isTodayDate,
3300
+ "arc-CalendarDayNumber--hightlightedRange": dateIsWithinHighlightedRange,
3301
+ "arc-CalendarDayNumber--hightlightedRangeRoundedLeft": isRoundedLeft,
3302
+ "arc-CalendarDayNumber--hightlightedRangeRoundedRight": isRoundedRight
3303
+ };
3304
+ var isAriaSelected = isSelectedDate ||
3305
+ (dateIsWithinHighlightedRange && selectedRange.length === 2);
3306
+ var tableCellProps = {
3307
+ className: classNames("arc-CalendarDayNumber", conditionalClasses),
3308
+ tabIndex: isFocusDate && shouldRender ? 0 : -1,
3309
+ "aria-current": isTodayDate ? "date" : undefined,
3310
+ "aria-selected": isAriaSelected,
3311
+ "aria-disabled": isDisabledDate(date, disabledDates, minDate, maxDate),
3312
+ onClick: onDayNumberClick(date),
3313
+ onMouseEnter: onDayNumberHover(date)
3314
+ };
3315
+ return (React__default.createElement("td", __assign({ ref: handleRefs, "data-date": date.getTime() }, (shouldRender ? tableCellProps : {})), shouldRender && (React__default.createElement(React__default.Fragment, null,
3316
+ React__default.createElement(VisuallyHidden, null, format(date, "MMMM do, yyyy")),
3317
+ React__default.createElement("div", { className: "arc-CalendarDayNumber-buttonOuter" },
3318
+ React__default.createElement("div", { className: "arc-CalendarDayNumber-buttonInner" },
3319
+ React__default.createElement(Text, { size: "s" },
3320
+ React__default.createElement("span", { "aria-hidden": true }, getDate(date)))))))));
3321
+ });
3322
+
3323
+ const BtIconChevronDownMid = (props) =>
3324
+ /*#__PURE__*/ React__default.createElement(
3325
+ "svg",
3326
+ Object.assign(
3327
+ {
3328
+ viewBox: "0 0 32 32",
3329
+ fill: "none",
3330
+ xmlns: "http://www.w3.org/2000/svg",
3331
+ },
3332
+ props,
3333
+ ),
3334
+ /*#__PURE__*/ React__default.createElement("path", {
3335
+ fillRule: "evenodd",
3336
+ clipRule: "evenodd",
3337
+ d: "M16.0001 18.0909L21.7041 12.3935C21.9566 12.1415 22.2987 12 22.6554 12C23.0121 12 23.3543 12.1415 23.6068 12.3935C23.7316 12.5181 23.8306 12.6661 23.8982 12.829C23.9657 12.9919 24.0005 13.1665 24.0005 13.3429C24.0005 13.5192 23.9657 13.6938 23.8982 13.8567C23.8306 14.0196 23.7316 14.1676 23.6068 14.2922L16.9508 20.9402C16.6983 21.1918 16.3565 21.3331 16.0001 21.3331C15.6437 21.3331 15.3018 21.1918 15.0494 20.9402L8.39342 14.2922C8.26861 14.1676 8.16959 14.0196 8.10202 13.8567C8.03446 13.6938 7.99969 13.5192 7.99969 13.3429C7.99969 13.1665 8.03446 12.9919 8.10202 12.829C8.16959 12.6661 8.26861 12.5181 8.39342 12.3935C8.6459 12.1415 8.98804 12 9.34475 12C9.70147 12 10.0436 12.1415 10.2961 12.3935L16.0001 18.0909Z",
3338
+ fill: "currentColor",
3339
+ }),
3340
+ );
3341
+
3342
+ var CalendarDateSelect = function (_a) {
3343
+ var ariaLabel = _a.ariaLabel, onChange = _a.onChange, name = _a.name, value = _a.value, displayValue = _a.displayValue, options = _a.options;
3344
+ return (React__default.createElement("div", { className: "arc-CalendarDateSelect-wrapper" },
3345
+ React__default.createElement("select", { "aria-label": ariaLabel, onChange: onChange, className: "arc-CalendarDateSelect", value: value, name: name }, options.map(function (_a) {
3346
+ var text = _a.text, value = _a.value;
3347
+ return (React__default.createElement("option", { className: "arc-CalendarDateSelect-option", key: "arc-calendar-year-select-".concat(value), value: value }, text));
3348
+ })),
3349
+ React__default.createElement("div", { "aria-hidden": true, className: "arc-CalendarDateSelect-label" },
3350
+ React__default.createElement(Heading, { size: "s" }, displayValue || value),
3351
+ React__default.createElement("div", { className: "arc-CalendarDateSelect-icon" },
3352
+ React__default.createElement(Icon, { size: 24, icon: BtIconChevronDownMid })))));
3353
+ };
3354
+
3355
+ /**
3356
+ * @name isSameMonth
3357
+ * @category Month Helpers
3358
+ * @summary Are the given dates in the same month (and year)?
3359
+ *
3360
+ * @description
3361
+ * Are the given dates in the same month (and year)?
3362
+ *
3363
+ * @param {Date|Number} dateLeft - the first date to check
3364
+ * @param {Date|Number} dateRight - the second date to check
3365
+ * @returns {Boolean} the dates are in the same month (and year)
3366
+ * @throws {TypeError} 2 arguments required
3367
+ *
3368
+ * @example
3369
+ * // Are 2 September 2014 and 25 September 2014 in the same month?
3370
+ * const result = isSameMonth(new Date(2014, 8, 2), new Date(2014, 8, 25))
3371
+ * //=> true
3372
+ *
3373
+ * @example
3374
+ * // Are 2 September 2014 and 25 September 2015 in the same month?
3375
+ * const result = isSameMonth(new Date(2014, 8, 2), new Date(2015, 8, 25))
3376
+ * //=> false
3377
+ */
3378
+ function isSameMonth(dirtyDateLeft, dirtyDateRight) {
3379
+ requiredArgs(2, arguments);
3380
+ var dateLeft = toDate(dirtyDateLeft);
3381
+ var dateRight = toDate(dirtyDateRight);
3382
+ return dateLeft.getFullYear() === dateRight.getFullYear() && dateLeft.getMonth() === dateRight.getMonth();
3383
+ }
3384
+
3385
+ /**
3386
+ * @name eachWeekOfInterval
3387
+ * @category Interval Helpers
3388
+ * @summary Return the array of weeks within the specified time interval.
3389
+ *
3390
+ * @description
3391
+ * Return the array of weeks within the specified time interval.
3392
+ *
3393
+ * @param {Interval} interval - the interval. See [Interval]{@link https://date-fns.org/docs/Interval}
3394
+ * @param {Object} [options] - an object with options.
3395
+ * @param {Locale} [options.locale=defaultLocale] - the locale object. See [Locale]{@link https://date-fns.org/docs/Locale}
3396
+ * @param {0|1|2|3|4|5|6} [options.weekStartsOn=0] - the index of the first day of the week (0 - Sunday)
3397
+ * @returns {Date[]} the array with starts of weeks from the week of the interval start to the week of the interval end
3398
+ * @throws {TypeError} 1 argument required
3399
+ * @throws {RangeError} `options.weekStartsOn` must be 0, 1, ..., 6
3400
+ * @throws {RangeError} The start of an interval cannot be after its end
3401
+ * @throws {RangeError} Date in interval cannot be `Invalid Date`
3402
+ *
3403
+ * @example
3404
+ * // Each week within interval 6 October 2014 - 23 November 2014:
3405
+ * const result = eachWeekOfInterval({
3406
+ * start: new Date(2014, 9, 6),
3407
+ * end: new Date(2014, 10, 23)
3408
+ * })
3409
+ * //=> [
3410
+ * // Sun Oct 05 2014 00:00:00,
3411
+ * // Sun Oct 12 2014 00:00:00,
3412
+ * // Sun Oct 19 2014 00:00:00,
3413
+ * // Sun Oct 26 2014 00:00:00,
3414
+ * // Sun Nov 02 2014 00:00:00,
3415
+ * // Sun Nov 09 2014 00:00:00,
3416
+ * // Sun Nov 16 2014 00:00:00,
3417
+ * // Sun Nov 23 2014 00:00:00
3418
+ * // ]
3419
+ */
3420
+ function eachWeekOfInterval(dirtyInterval, options) {
3421
+ requiredArgs(1, arguments);
3422
+ var interval = dirtyInterval || {};
3423
+ var startDate = toDate(interval.start);
3424
+ var endDate = toDate(interval.end);
3425
+ var endTime = endDate.getTime();
3426
+
3427
+ // Throw an exception if start date is after end date or if any date is `Invalid Date`
3428
+ if (!(startDate.getTime() <= endTime)) {
3429
+ throw new RangeError('Invalid interval');
3430
+ }
3431
+ var startDateWeek = startOfWeek(startDate, options);
3432
+ var endDateWeek = startOfWeek(endDate, options);
3433
+
3434
+ // Some timezones switch DST at midnight, making start of day unreliable in these timezones, 3pm is a safe bet
3435
+ startDateWeek.setHours(15);
3436
+ endDateWeek.setHours(15);
3437
+ endTime = endDateWeek.getTime();
3438
+ var weeks = [];
3439
+ var currentWeek = startDateWeek;
3440
+ while (currentWeek.getTime() <= endTime) {
3441
+ currentWeek.setHours(0);
3442
+ weeks.push(toDate(currentWeek));
3443
+ currentWeek = addWeeks(currentWeek, 1);
3444
+ currentWeek.setHours(15);
3445
+ }
3446
+ return weeks;
3447
+ }
3448
+
3449
+ var DAY_NAMES = [
3450
+ {
3451
+ value: WeekDays.MONDAY,
3452
+ displayValue: WeekDaysAbbr.MON
3453
+ },
3454
+ {
3455
+ value: WeekDays.TUESDAY,
3456
+ displayValue: WeekDaysAbbr.TUE
3457
+ },
3458
+ {
3459
+ value: WeekDays.WEDNESDAY,
3460
+ displayValue: WeekDaysAbbr.WED
3461
+ },
3462
+ {
3463
+ value: WeekDays.THURSDAY,
3464
+ displayValue: WeekDaysAbbr.THUR
3465
+ },
3466
+ {
3467
+ value: WeekDays.FRIDAY,
3468
+ displayValue: WeekDaysAbbr.FRI
3469
+ },
3470
+ {
3471
+ value: WeekDays.SATURDAY,
3472
+ displayValue: WeekDaysAbbr.SAT
3473
+ },
3474
+ {
3475
+ value: WeekDays.SUNDAY,
3476
+ displayValue: WeekDaysAbbr.SUN
3477
+ },
3478
+ ];
3479
+
3480
+ /**
3481
+ * @name isWithinInterval
3482
+ * @category Interval Helpers
3483
+ * @summary Is the given date within the interval?
3484
+ *
3485
+ * @description
3486
+ * Is the given date within the interval? (Including start and end.)
3487
+ *
3488
+ * @param {Date|Number} date - the date to check
3489
+ * @param {Interval} interval - the interval to check
3490
+ * @returns {Boolean} the date is within the interval
3491
+ * @throws {TypeError} 2 arguments required
3492
+ * @throws {RangeError} The start of an interval cannot be after its end
3493
+ * @throws {RangeError} Date in interval cannot be `Invalid Date`
3494
+ *
3495
+ * @example
3496
+ * // For the date within the interval:
3497
+ * isWithinInterval(new Date(2014, 0, 3), {
3498
+ * start: new Date(2014, 0, 1),
3499
+ * end: new Date(2014, 0, 7)
3500
+ * })
3501
+ * //=> true
3502
+ *
3503
+ * @example
3504
+ * // For the date outside of the interval:
3505
+ * isWithinInterval(new Date(2014, 0, 10), {
3506
+ * start: new Date(2014, 0, 1),
3507
+ * end: new Date(2014, 0, 7)
3508
+ * })
3509
+ * //=> false
3510
+ *
3511
+ * @example
3512
+ * // For date equal to interval start:
3513
+ * isWithinInterval(date, { start, end: date }) // => true
3514
+ *
3515
+ * @example
3516
+ * // For date equal to interval end:
3517
+ * isWithinInterval(date, { start: date, end }) // => true
3518
+ */
3519
+ function isWithinInterval(dirtyDate, interval) {
3520
+ requiredArgs(2, arguments);
3521
+ var time = toDate(dirtyDate).getTime();
3522
+ var startTime = toDate(interval.start).getTime();
3523
+ var endTime = toDate(interval.end).getTime();
3524
+
3525
+ // Throw an exception if start date is after end date or if any date is `Invalid Date`
3526
+ if (!(startTime <= endTime)) {
3527
+ throw new RangeError('Invalid interval');
3528
+ }
3529
+ return time >= startTime && time <= endTime;
3530
+ }
3531
+
3532
+ /**
3533
+ * @name setYear
3534
+ * @category Year Helpers
3535
+ * @summary Set the year to the given date.
3536
+ *
3537
+ * @description
3538
+ * Set the year to the given date.
3539
+ *
3540
+ * @param {Date|Number} date - the date to be changed
3541
+ * @param {Number} year - the year of the new date
3542
+ * @returns {Date} the new date with the year set
3543
+ * @throws {TypeError} 2 arguments required
3544
+ *
3545
+ * @example
3546
+ * // Set year 2013 to 1 September 2014:
3547
+ * const result = setYear(new Date(2014, 8, 1), 2013)
3548
+ * //=> Sun Sep 01 2013 00:00:00
3549
+ */
3550
+ function setYear(dirtyDate, dirtyYear) {
3551
+ requiredArgs(2, arguments);
3552
+ var date = toDate(dirtyDate);
3553
+ var year = toInteger(dirtyYear);
3554
+
3555
+ // Check if date is Invalid Date because Date.prototype.setFullYear ignores the value of Invalid Date
3556
+ if (isNaN(date.getTime())) {
3557
+ return new Date(NaN);
3558
+ }
3559
+ date.setFullYear(year);
3560
+ return date;
3561
+ }
3562
+
3563
+ var CalendarDayGrid = function (_a) {
3564
+ var displayRange = _a.displayRange;
3565
+ var hasAutoFocused = useRef(false);
3566
+ var dayNumberGridRef = useRef(null);
3567
+ var context = useContext(ArcCalendarContext);
3568
+ var autoFocusRef = useCallback(function (el) {
3569
+ if (el &&
3570
+ el.tabIndex === 0 &&
3571
+ (context === null || context === void 0 ? void 0 : context.autoFocusOnMount) &&
3572
+ !hasAutoFocused.current) {
3573
+ el.focus();
3574
+ }
3575
+ if (document.activeElement === el) {
3576
+ hasAutoFocused.current = true;
3577
+ }
3578
+ }, [context === null || context === void 0 ? void 0 : context.autoFocusOnMount]);
3579
+ if (!context) {
3580
+ return null;
3581
+ }
3582
+ var onKeyboardNavigate = context.onKeyboardNavigate, onDayNumberClick = context.onDayNumberClick, onDayGridLeave = context.onDayGridLeave;
3583
+ var isFocusWithinDayGrid = Boolean(dayNumberGridRef &&
3584
+ dayNumberGridRef.current &&
3585
+ dayNumberGridRef.current.contains(document.activeElement));
3586
+ var handleKeyDown = function (e) {
3587
+ var key = e.key;
3588
+ var newDate = e.target.getAttribute("data-date");
3589
+ if (key === KeyNames.Tab) {
3590
+ return;
3591
+ }
3592
+ if (Object.values(KeyNames).includes(key)) {
3593
+ e.preventDefault();
3594
+ }
3595
+ if ([KeyNames.Space, KeyNames.Enter].includes(key) && newDate) {
3596
+ onDayNumberClick(dateWithoutTime(new Date(parseInt(newDate))))();
3597
+ }
3598
+ else {
3599
+ onKeyboardNavigate(e.key, e.shiftKey);
3600
+ }
3601
+ };
3602
+ var getWeeksInMonth = function (month) {
3603
+ return eachWeekOfInterval({ start: startOfMonth(month), end: endOfMonth(month) }, { weekStartsOn: 1 }).map(function (week) { return eachDayOfInterval({ start: week, end: addDays(week, 6) }); });
3604
+ };
3605
+ return (React__default.createElement("div", { ref: dayNumberGridRef, onMouseLeave: onDayGridLeave, className: classNames("arc-CalendarDayGrid", {
3606
+ "arc-CalendarDayGrid--dual": displayRange.length > 1
3607
+ }) }, displayRange.map(function (month) { return (React__default.createElement("div", { key: month.getTime(), className: "arc-CalendarDayGrid-month" },
3608
+ React__default.createElement("table", { className: "arc-CalendarDayGrid-table" },
3609
+ React__default.createElement("thead", null,
3610
+ React__default.createElement("tr", null, DAY_NAMES.map(function (dayName) { return (React__default.createElement("th", { key: "".concat(month.getTime(), "-").concat(dayName.displayValue) },
3611
+ React__default.createElement(Text, { key: dayName.displayValue, size: "s" },
3612
+ React__default.createElement("b", { "aria-hidden": true }, dayName.displayValue)),
3613
+ React__default.createElement(VisuallyHidden, null, dayName.value))); }))),
3614
+ React__default.createElement("tbody", { onKeyDown: handleKeyDown }, getWeeksInMonth(month).map(function (week, i) { return (React__default.createElement("tr", { key: "".concat(month.getTime(), "-week-").concat(i) }, week.map(function (day) { return (React__default.createElement(CalendarDayNumber, { ref: autoFocusRef, shouldRender: isSameMonth(month, day), key: day.getTime(), date: day, isFocusWithinDayGrid: isFocusWithinDayGrid })); }))); }))))); })));
3615
+ };
3616
+
3617
+ var CalendarNavButton = function (_a) {
3618
+ var isDisabled = _a.isDisabled, onClick = _a.onClick, direction = _a.direction, ariaLabel = _a.ariaLabel;
3619
+ var icons = {
3620
+ previous: BtIconChevronLeftMid,
3621
+ next: BtIconChevronRightMid
3622
+ };
3623
+ return (React__default.createElement("button", { "aria-label": ariaLabel, disabled: isDisabled, onClick: onClick, className: classNames("arc-CalendarNavButton", {
3624
+ "arc-CalendarNavButton--previous": direction === "previous",
3625
+ "arc-CalendarNavButton--next": direction === "next"
3626
+ }) },
3627
+ React__default.createElement(Icon, { size: 32, icon: icons[direction] })));
3628
+ };
3629
+
3630
+ var CalendarDoubleMonthView = function (_a) {
3631
+ var isPreviousMonthDisabled = _a.isPreviousMonthDisabled, isNextMonthDisabled = _a.isNextMonthDisabled, onNextMonthClick = _a.onNextMonthClick, onPreviousMonthClick = _a.onPreviousMonthClick;
3632
+ var context = useContext(ArcCalendarContext);
3633
+ if (!context) {
3634
+ return null;
3635
+ }
3636
+ var displayDate = context.displayDate;
3637
+ var displayRange = getDoubleMonthDisplayRange(displayDate);
3638
+ var getAriaLabel = function (date) {
3639
+ var months = getDoubleMonthDisplayRange(date);
3640
+ return "show ".concat(format(months[0], "MMMM yyyy"), " to ").concat(format(months[1], "MMMM yyyy"));
3641
+ };
3642
+ return (React__default.createElement(React__default.Fragment, null,
3643
+ React__default.createElement(VisuallyHidden, null,
3644
+ React__default.createElement(Heading, { level: "2" },
3645
+ React__default.createElement("span", { "aria-live": "polite" },
3646
+ "showing ",
3647
+ format(displayRange[0], "MMMM yyyy"),
3648
+ " to",
3649
+ " ",
3650
+ format(displayRange[1], "MMMM yyyy")))),
3651
+ React__default.createElement("div", { className: "arc-CalendarDoubleMonthView-header" },
3652
+ React__default.createElement("div", { className: "arc-CalendarDoubleMonthView-headerMonth" },
3653
+ React__default.createElement("div", { className: "arc-CalendarDoubleMonthView-headerMonthItem" },
3654
+ React__default.createElement(CalendarNavButton, { ariaLabel: getAriaLabel(subMonths(displayDate, 2)), direction: "previous", isDisabled: isPreviousMonthDisabled, onClick: onPreviousMonthClick })),
3655
+ React__default.createElement("div", { "aria-hidden": true, className: "arc-CalendarDoubleMonthView-headerMonthItem" },
3656
+ React__default.createElement(Heading, { level: "2", size: "s" }, format(displayRange[0], "MMM yyyy")))),
3657
+ React__default.createElement("div", { className: "arc-CalendarDoubleMonthView-headerMonth" },
3658
+ React__default.createElement("div", { "aria-hidden": true, className: "arc-CalendarDoubleMonthView-headerMonthItem" },
3659
+ React__default.createElement(Heading, { level: "2", size: "s" }, format(displayRange[1], "MMM yyyy"))),
3660
+ React__default.createElement("div", { className: "arc-CalendarDoubleMonthView-headerMonthItem" },
3661
+ React__default.createElement(CalendarNavButton, { ariaLabel: getAriaLabel(addMonths(displayDate, 2)), direction: "next", isDisabled: isNextMonthDisabled, onClick: onNextMonthClick })))),
3662
+ React__default.createElement(CalendarDayGrid, { displayRange: displayRange })));
3663
+ };
3664
+
3665
+ var CalendarMonthView = function (_a) {
3666
+ var isPreviousMonthDisabled = _a.isPreviousMonthDisabled, isNextMonthDisabled = _a.isNextMonthDisabled, onNextMonthClick = _a.onNextMonthClick, onPreviousMonthClick = _a.onPreviousMonthClick;
3667
+ var context = useContext(ArcCalendarContext);
3668
+ if (!context) {
3669
+ return null;
3670
+ }
3671
+ var displayDate = context.displayDate;
3672
+ return (React__default.createElement(React__default.Fragment, null,
3673
+ React__default.createElement("div", { className: "arc-CalendarMonthView-header" },
3674
+ React__default.createElement(CalendarNavButton, { ariaLabel: "Show ".concat(format(subMonths(displayDate, 1), "MMMM yyyy")), direction: "previous", isDisabled: isPreviousMonthDisabled, onClick: onPreviousMonthClick }),
3675
+ React__default.createElement("div", { className: "arc-CalendarMonthView-headingContainer" },
3676
+ React__default.createElement(VisuallyHidden, null,
3677
+ React__default.createElement(Heading, { level: "2" },
3678
+ React__default.createElement("span", { "aria-live": "polite" },
3679
+ "showing ",
3680
+ format(displayDate, "MMMM yyyy")))),
3681
+ React__default.createElement("div", { "aria-hidden": true },
3682
+ React__default.createElement(Heading, { size: "s", level: "2" }, format(displayDate, "MMM yyyy")))),
3683
+ React__default.createElement(CalendarNavButton, { direction: "next", ariaLabel: "Show ".concat(format(addMonths(displayDate, 1), "MMMM yyyy")), isDisabled: isNextMonthDisabled, onClick: onNextMonthClick })),
3684
+ React__default.createElement(CalendarDayGrid, { displayRange: [displayDate] })));
3685
+ };
3686
+
3687
+ var CalendarMonthYearView = function (_a) {
3688
+ var isPreviousMonthDisabled = _a.isPreviousMonthDisabled, isNextMonthDisabled = _a.isNextMonthDisabled, onMonthChange = _a.onMonthChange, onYearChange = _a.onYearChange, onNextMonthClick = _a.onNextMonthClick, onPreviousMonthClick = _a.onPreviousMonthClick;
3689
+ var context = useContext(ArcCalendarContext);
3690
+ if (!context) {
3691
+ return null;
3692
+ }
3693
+ var displayDate = context.displayDate, minDate = context.minDate, maxDate = context.maxDate;
3694
+ var monthOptions = Array.from({ length: 12 })
3695
+ .map(function (_, i) { return ({
3696
+ value: i,
3697
+ text: format(new Date(2023, i, 1), "MMMM")
3698
+ }); })
3699
+ .filter(function (_a) {
3700
+ var value = _a.value;
3701
+ var currentDateYear = getYear(displayDate);
3702
+ var date = dateWithoutTime(new Date(currentDateYear, value, 1));
3703
+ return ((!minDate || !isMonthBeforeMinDate(date, minDate)) &&
3704
+ (!maxDate || !isMonthAfterMaxDate(date, maxDate)));
3705
+ });
3706
+ var yearOptions = Array.from({ length: 21 }, function (_, i) {
3707
+ var value = getYear(displayDate) - 10 + i;
3708
+ return {
3709
+ value: value,
3710
+ text: value
3711
+ };
3712
+ }).filter(function (_a) {
3713
+ var value = _a.value;
3714
+ return ((minDate ? value >= getYear(minDate) : true) &&
3715
+ (maxDate ? value <= getYear(maxDate) : true));
3716
+ });
3717
+ return (React__default.createElement(React__default.Fragment, null,
3718
+ React__default.createElement("div", { className: "arc-CalendarMonthYearView-header" },
3719
+ React__default.createElement(VisuallyHidden, null,
3720
+ React__default.createElement(Heading, { level: "2" },
3721
+ React__default.createElement("span", { "aria-live": "polite" },
3722
+ "showing ",
3723
+ format(displayDate, "MMMM yyyy")))),
3724
+ React__default.createElement("div", { className: "arc-CalendarMonthYearView-selectWrapper" },
3725
+ React__default.createElement("div", null,
3726
+ React__default.createElement(CalendarDateSelect, { options: monthOptions, ariaLabel: "month", onChange: function (e) { return onMonthChange(parseInt(e.target.value)); }, name: "arc-CalendarMonthYearView-monthSelect", displayValue: format(displayDate, "MMM"), value: "".concat(getMonth(displayDate)) })),
3727
+ React__default.createElement("div", { className: "arc-CalendarMonthYearView-yearSelectContainer" },
3728
+ React__default.createElement(CalendarDateSelect, { options: yearOptions, ariaLabel: "year", onChange: function (e) { return onYearChange(parseInt(e.target.value)); }, name: "arc-CalendarMonthYearView-yearSelect", value: getYear(displayDate) }))),
3729
+ React__default.createElement("div", { className: "arc-CalendarMonthYearView-navButtonContainer" },
3730
+ React__default.createElement(CalendarNavButton, { direction: "previous", ariaLabel: "Show ".concat(format(subMonths(displayDate, 1), "MMMM yyyy")), isDisabled: isPreviousMonthDisabled, onClick: onPreviousMonthClick }),
3731
+ React__default.createElement(CalendarNavButton, { direction: "next", ariaLabel: "Show ".concat(format(addMonths(displayDate, 1), "MMMM yyyy")), isDisabled: isNextMonthDisabled, onClick: onNextMonthClick }))),
3732
+ React__default.createElement(CalendarDayGrid, { displayRange: [displayDate] })));
3733
+ };
3734
+
3735
+ var showPreviousMonthHandler = function (payload, state) {
3736
+ return __assign(__assign({}, state), { focusDate: getFocusDate({
3737
+ date: subMonths(state.focusDate, 1),
3738
+ minDate: payload.minDate
3739
+ }), displayDate: subMonths(state.displayDate, 1) });
3740
+ };
3741
+
3742
+ var showNextMonthHandler = function (payload, state) {
3743
+ return __assign(__assign({}, state), { focusDate: getFocusDate({
3744
+ date: addMonths(state.focusDate, 1),
3745
+ maxDate: payload.maxDate
3746
+ }), displayDate: addMonths(state.displayDate, 1) });
3747
+ };
3748
+
3749
+ var showPreviousDoubleMonthHandler = function (payload, state) {
3750
+ return __assign(__assign({}, state), { focusDate: getFocusDate({
3751
+ date: subMonths(state.focusDate, 2),
3752
+ minDate: payload.minDate
3753
+ }), displayDate: subMonths(state.displayDate, 2) });
3754
+ };
3755
+
3756
+ var showNextDoubleMonthHandler = function (payload, state) {
3757
+ return __assign(__assign({}, state), { focusDate: getFocusDate({
3758
+ date: addMonths(state.focusDate, 2),
3759
+ maxDate: payload.maxDate
3760
+ }), displayDate: addMonths(state.displayDate, 2) });
3761
+ };
3762
+
3763
+ var rangeSelectHandler = function (payload, state) {
3764
+ return __assign(__assign({}, state), { focusDate: payload.date, highlightedRange: payload.range });
3765
+ };
3766
+
3767
+ var highlightRangeHandler = function (payload, state) {
3768
+ return __assign(__assign({}, state), { highlightedRange: getHighlightRange({
3769
+ date: payload.date,
3770
+ range: payload.range,
3771
+ minDate: payload.minDate,
3772
+ maxDate: payload.maxDate
3773
+ }) });
3774
+ };
3775
+
3776
+ var dayNumberSelectHandler = function (payload, state) {
3777
+ return __assign(__assign({}, state), { focusDate: payload });
3778
+ };
3779
+
3780
+ var dayGridLeaveHandler = function (payload, state) {
3781
+ if (payload.selectionType === "range" &&
3782
+ payload.range.filter(function (date) { return Boolean(date); }).length === 1) {
3783
+ return __assign(__assign({}, state), { highlightedRange: [] });
3784
+ }
3785
+ return __assign({}, state);
3786
+ };
3787
+
3788
+ var dropDownChangeYearHandler = function (payload, state) {
3789
+ var year = payload.year, minDate = payload.minDate, maxDate = payload.maxDate;
3790
+ var yearsToAdd = year - getYear(state.displayDate);
3791
+ var newDisplayDate = addYears(state.displayDate, yearsToAdd);
3792
+ var focusDate = getFocusDate({
3793
+ date: addYears(state.focusDate, yearsToAdd),
3794
+ minDate: payload.minDate,
3795
+ maxDate: payload.maxDate
3796
+ });
3797
+ if (minDate && isBefore(newDisplayDate, minDate)) {
3798
+ return __assign(__assign({}, state), { focusDate: focusDate, displayDate: minDate });
3799
+ }
3800
+ if (maxDate && isAfter(newDisplayDate, maxDate)) {
3801
+ return __assign(__assign({}, state), { focusDate: focusDate, displayDate: maxDate });
3802
+ }
3803
+ return __assign(__assign({}, state), { focusDate: focusDate, displayDate: newDisplayDate });
3804
+ };
3805
+
3806
+ var dropDownChangeMonthHandler = function (payload, state) {
3807
+ return __assign(__assign({}, state), { focusDate: getFocusDate({
3808
+ date: setMonth(state.focusDate, payload.month),
3809
+ minDate: payload.minDate,
3810
+ maxDate: payload.maxDate
3811
+ }), displayDate: setMonth(state.displayDate, payload.month) });
3812
+ };
3813
+
3814
+ var calendarKeydownHandler = function (payload, state) {
3815
+ var displayDate = state.displayDate, focusDate = state.focusDate, highlightedRange = state.highlightedRange;
3816
+ var minDate = payload.minDate, maxDate = payload.maxDate, calendarType = payload.calendarType, key = payload.key, shiftKey = payload.shiftKey, range = payload.range, selectionType = payload.selectionType;
3817
+ var isNavigatingByYear = shiftKey && [KeyNames.PageUp, KeyNames.PageDown].includes(key);
3818
+ var keyDownDate = getKeyDownDate({
3819
+ focusDate: focusDate,
3820
+ key: key,
3821
+ shiftKey: shiftKey
3822
+ });
3823
+ var newFocusDate = getFocusDate({
3824
+ minDate: minDate,
3825
+ maxDate: maxDate,
3826
+ date: keyDownDate
3827
+ });
3828
+ var newHighlightedRange = selectionType === "range"
3829
+ ? getHighlightRange({
3830
+ date: keyDownDate,
3831
+ range: range,
3832
+ minDate: minDate,
3833
+ maxDate: maxDate
3834
+ })
3835
+ : highlightedRange;
3836
+ var focusDateIsMinOrMax = (maxDate && isEqual(newFocusDate, maxDate)) ||
3837
+ (minDate && isEqual(newFocusDate, minDate));
3838
+ var _a = getDoubleMonthDisplayRange(displayDate), doubleMonthFirstMonth = _a[0], doubleMonthSecondMonth = _a[1];
3839
+ var doubleMonthVisibleRange = {
3840
+ start: startOfMonth(doubleMonthFirstMonth),
3841
+ end: endOfMonth(doubleMonthSecondMonth)
3842
+ };
3843
+ var singleMonthVisibleRange = {
3844
+ start: startOfMonth(displayDate),
3845
+ end: endOfMonth(displayDate)
3846
+ };
3847
+ var isNewFocusDateVisible = isWithinInterval(newFocusDate, calendarType === "double"
3848
+ ? doubleMonthVisibleRange
3849
+ : singleMonthVisibleRange);
3850
+ var commonState = __assign(__assign({}, state), { focusDate: newFocusDate, highlightedRange: newHighlightedRange });
3851
+ if (!isNewFocusDateVisible &&
3852
+ !focusDateIsMinOrMax &&
3853
+ isNavigatingByYear &&
3854
+ calendarType === "double") {
3855
+ return __assign(__assign({}, commonState), { displayDate: setYear(displayDate, getYear(newFocusDate)) });
3856
+ }
3857
+ if (!isNewFocusDateVisible) {
3858
+ return __assign(__assign({}, commonState), { displayDate: startOfMonth(newFocusDate) });
3859
+ }
3860
+ return commonState;
3861
+ };
3862
+
3863
+ var defaultHandler = function (state) {
3864
+ return __assign({}, state);
3865
+ };
3866
+
3867
+ var reducer = function (state, action) {
3868
+ switch (action.type) {
3869
+ case "DAY_NUMBER_SELECT":
3870
+ return dayNumberSelectHandler(action.payload, state);
3871
+ case "RANGE_SELECT":
3872
+ return rangeSelectHandler(action.payload, state);
3873
+ case "HIGHLIGHT_RANGE":
3874
+ return highlightRangeHandler(action.payload, state);
3875
+ case "DAY_GRID_LEAVE":
3876
+ return dayGridLeaveHandler(action.payload, state);
3877
+ case "SHOW_PREVIOUS_MONTH":
3878
+ return showPreviousMonthHandler(action.payload, state);
3879
+ case "SHOW_NEXT_MONTH":
3880
+ return showNextMonthHandler(action.payload, state);
3881
+ case "SHOW_PREVIOUS_DOUBLE_MONTH":
3882
+ return showPreviousDoubleMonthHandler(action.payload, state);
3883
+ case "SHOW_NEXT_DOUBLE_MONTH":
3884
+ return showNextDoubleMonthHandler(action.payload, state);
3885
+ case "DROPDOWN_CHANGE_YEAR":
3886
+ return dropDownChangeYearHandler(action.payload, state);
3887
+ case "DROPDOWN_CHANGE_MONTH":
3888
+ return dropDownChangeMonthHandler(action.payload, state);
3889
+ case "CALENDAR_KEYDOWN":
3890
+ return calendarKeydownHandler(action.payload, state);
3891
+ default:
3892
+ return defaultHandler(state);
3893
+ }
3894
+ };
3895
+
3896
+ var CalendarFooter = function (_a) {
3897
+ var onCancelClick = _a.onCancelClick;
3898
+ return (React__default.createElement("div", { className: "arc-CalendarFooter" },
3899
+ React__default.createElement("button", { className: "arc-CalendarFooter-button", onClick: onCancelClick }, "Cancel")));
3900
+ };
3901
+
3902
+ var CalendarWrapper = function (_a) {
3903
+ var children = _a.children;
3904
+ return (React__default.createElement("div", { className: "arc-CalendarWrapper" },
3905
+ React__default.createElement(Surface, { background: "white" },
3906
+ React__default.createElement("div", { className: "arc-CalendarWrapper-inner" }, children))));
3907
+ };
3908
+
3909
+ var Calendar = function (_a) {
3910
+ var _b = _a.type, type = _b === void 0 ? "month" : _b, _c = _a.selectionType, selectionType = _c === void 0 ? "single" : _c, _d = _a.autoFocusOnMount, autoFocusOnMount = _d === void 0 ? false : _d, _e = _a.selectedRange, rawSelectedRange = _e === void 0 ? [] : _e, _f = _a.selectedDate, rawSelectedDate = _f === void 0 ? new Date() : _f, rawDisabledDates = _a.disabledDates, rawMinDate = _a.minDate, rawMaxDate = _a.maxDate, onCancelClick = _a.onCancelClick, onDateSelect = _a.onDateSelect, onRangeSelect = _a.onRangeSelect;
3911
+ var todayDate = dateWithoutTime(new Date());
3912
+ var selectedDate = dateWithoutTime(rawSelectedDate);
3913
+ var selectedRange = rawSelectedRange
3914
+ .filter(function (rangeDate) { return Boolean(rangeDate); })
3915
+ .map(function (rangeDate) { return dateWithoutTime(rangeDate); });
3916
+ var _g = useState(false), isClientLoaded = _g[0], setIsClientLoaded = _g[1];
3917
+ var _h = useReducer(reducer, {
3918
+ displayDate: selectionType === "single"
3919
+ ? startOfMonth(selectedDate)
3920
+ : startOfMonth(selectedRange[0] || todayDate),
3921
+ focusDate: selectionType === "single"
3922
+ ? selectedDate
3923
+ : selectedRange[0] || todayDate,
3924
+ highlightedRange: selectedRange
3925
+ }), _j = _h[0], displayDate = _j.displayDate, focusDate = _j.focusDate, highlightedRange = _j.highlightedRange, dispatch = _h[1];
3926
+ var isMinWidthArcBreakpointM = useMediaQuery("(min-width: ".concat(ArcBreakpointM, "px)"));
3927
+ useEffect(function () {
3928
+ setIsClientLoaded(true);
3929
+ }, []);
3930
+ var disabledDates = rawDisabledDates === null || rawDisabledDates === void 0 ? void 0 : rawDisabledDates.map(function (date) { return dateWithoutTime(date); });
3931
+ var minDate = rawMinDate && dateWithoutTime(rawMinDate);
3932
+ var maxDate = rawMaxDate && dateWithoutTime(rawMaxDate);
3933
+ var calendarType = getCalendarType(type, isMinWidthArcBreakpointM);
3934
+ var doubleMonthDisplayRange = getDoubleMonthDisplayRange(displayDate);
3935
+ var isPreviousMonthDisabled = minDate
3936
+ ? isMonthBeforeMinDate(subMonths(displayDate, 1), minDate)
3937
+ : false;
3938
+ var isNextMonthDisabled = maxDate
3939
+ ? isMonthAfterMaxDate(addMonths(displayDate, 1), maxDate)
3940
+ : false;
3941
+ var isDoubleMonthPreviousDisabled = minDate
3942
+ ? isMonthBeforeMinDate(subMonths(doubleMonthDisplayRange[0], 1), minDate)
3943
+ : false;
3944
+ var isDoubleMonthNextDisabled = maxDate
3945
+ ? isMonthAfterMaxDate(addMonths(doubleMonthDisplayRange[1], 1), maxDate)
3946
+ : false;
3947
+ var setDateRange = function (value) {
3948
+ var _a = processSelectedRange({
3949
+ value: value,
3950
+ range: selectedRange,
3951
+ disabledDates: disabledDates
3952
+ }), rangeOnChangeValue = _a.rangeOnChangeValue, rangeValue = _a.rangeValue;
3953
+ dispatch({
3954
+ type: "RANGE_SELECT",
3955
+ payload: {
3956
+ date: value,
3957
+ range: rangeValue
3958
+ }
3959
+ });
3960
+ onRangeSelect && onRangeSelect(rangeOnChangeValue);
3961
+ };
3962
+ var setNewDate = function (value) {
3963
+ dispatch({
3964
+ type: "DAY_NUMBER_SELECT",
3965
+ payload: value
3966
+ });
3967
+ onDateSelect && onDateSelect(value);
3968
+ };
3969
+ var onDayNumberHover = function (date) { return function () {
3970
+ selectionType === "range" &&
3971
+ dispatch({
3972
+ type: "HIGHLIGHT_RANGE",
3973
+ payload: {
3974
+ date: date,
3975
+ minDate: minDate,
3976
+ maxDate: maxDate,
3977
+ range: selectedRange
3978
+ }
3979
+ });
3980
+ }; };
3981
+ var handleDateSelection = function (date) {
3982
+ var isDisabled = isDisabledDate(date, disabledDates, minDate, maxDate);
3983
+ if (isDisabled)
3984
+ return;
3985
+ selectionType === "single" ? setNewDate(date) : setDateRange(date);
3986
+ };
3987
+ var onDayNumberClick = function (date) { return function () {
3988
+ handleDateSelection(date);
3989
+ }; };
3990
+ var onCancelButtonClick = function () {
3991
+ onCancelClick && onCancelClick();
3992
+ };
3993
+ var onDayGridLeave = function () {
3994
+ dispatch({
3995
+ type: "DAY_GRID_LEAVE",
3996
+ payload: {
3997
+ selectionType: selectionType,
3998
+ range: selectedRange
3999
+ }
4000
+ });
4001
+ };
4002
+ var onPreviousMonthClick = function () {
4003
+ dispatch({
4004
+ type: "SHOW_PREVIOUS_MONTH",
4005
+ payload: {
4006
+ minDate: minDate
4007
+ }
4008
+ });
4009
+ };
4010
+ var onNextMonthClick = function () {
4011
+ dispatch({
4012
+ type: "SHOW_NEXT_MONTH",
4013
+ payload: {
4014
+ maxDate: maxDate
4015
+ }
4016
+ });
4017
+ };
4018
+ var onDoubleViewPreviousClick = function () {
4019
+ dispatch({
4020
+ type: "SHOW_PREVIOUS_DOUBLE_MONTH",
4021
+ payload: {
4022
+ minDate: minDate
4023
+ }
4024
+ });
4025
+ };
4026
+ var onDoubleViewNextClick = function () {
4027
+ dispatch({
4028
+ type: "SHOW_NEXT_DOUBLE_MONTH",
4029
+ payload: {
4030
+ maxDate: maxDate
4031
+ }
4032
+ });
4033
+ };
4034
+ var onYearChange = function (year) {
4035
+ dispatch({
4036
+ type: "DROPDOWN_CHANGE_YEAR",
4037
+ payload: {
4038
+ year: year,
4039
+ minDate: minDate,
4040
+ maxDate: maxDate
4041
+ }
4042
+ });
4043
+ };
4044
+ var onMonthChange = function (month) {
4045
+ dispatch({
4046
+ type: "DROPDOWN_CHANGE_MONTH",
4047
+ payload: {
4048
+ month: month,
4049
+ minDate: minDate,
4050
+ maxDate: maxDate
4051
+ }
4052
+ });
4053
+ };
4054
+ var onKeyboardNavigate = function (key, shiftKey) {
4055
+ dispatch({
4056
+ type: "CALENDAR_KEYDOWN",
4057
+ payload: {
4058
+ minDate: minDate,
4059
+ maxDate: maxDate,
4060
+ selectionType: selectionType,
4061
+ calendarType: calendarType,
4062
+ key: key,
4063
+ shiftKey: shiftKey,
4064
+ range: selectedRange
4065
+ }
4066
+ });
4067
+ };
4068
+ return (React__default.createElement(ArcCalendarContext.Provider, { value: {
4069
+ minDate: minDate,
4070
+ maxDate: maxDate,
4071
+ focusDate: focusDate,
4072
+ todayDate: todayDate,
4073
+ displayDate: displayDate,
4074
+ onDayGridLeave: onDayGridLeave,
4075
+ disabledDates: disabledDates,
4076
+ selectedDate: selectedDate,
4077
+ selectionType: selectionType,
4078
+ selectedRange: selectedRange,
4079
+ highlightedRange: highlightedRange,
4080
+ onDayNumberClick: onDayNumberClick,
4081
+ onDayNumberHover: onDayNumberHover,
4082
+ onKeyboardNavigate: onKeyboardNavigate,
4083
+ autoFocusOnMount: autoFocusOnMount
4084
+ } },
4085
+ React__default.createElement("div", { style: { display: isClientLoaded ? "block" : "none" } },
4086
+ React__default.createElement(CalendarWrapper, null,
4087
+ calendarType === "year" && (React__default.createElement(CalendarMonthYearView, { isPreviousMonthDisabled: isPreviousMonthDisabled, isNextMonthDisabled: isNextMonthDisabled, onPreviousMonthClick: onPreviousMonthClick, onNextMonthClick: onNextMonthClick, onMonthChange: onMonthChange, onYearChange: onYearChange })),
4088
+ calendarType === "month" && (React__default.createElement(CalendarMonthView, { isPreviousMonthDisabled: isPreviousMonthDisabled, isNextMonthDisabled: isNextMonthDisabled, onPreviousMonthClick: onPreviousMonthClick, onNextMonthClick: onNextMonthClick })),
4089
+ calendarType === "double" && (React__default.createElement(CalendarDoubleMonthView, { isPreviousMonthDisabled: isDoubleMonthPreviousDisabled, isNextMonthDisabled: isDoubleMonthNextDisabled, onPreviousMonthClick: onDoubleViewPreviousClick, onNextMonthClick: onDoubleViewNextClick })),
4090
+ onCancelClick && (React__default.createElement(CalendarFooter, { onCancelClick: onCancelButtonClick }))))));
4091
+ };
4092
+
4093
+ export { Calendar as C, isBefore as a, isAfter as b, compareAsc as c, format as f, isValid as i, requiredArgs as r, toDate as t };