@oslokommune/punkt-elements 13.15.2 → 13.15.4

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 (78) hide show
  1. package/CHANGELOG.md +35 -0
  2. package/dist/{calendar-DtJh7UYD.js → calendar-Bz27nuTP.js} +161 -158
  3. package/dist/calendar-Dz1Cnzx5.cjs +115 -0
  4. package/dist/{checkbox-_5LbXU7N.js → checkbox-CCFBIf44.js} +21 -21
  5. package/dist/checkbox-UT6D1Wi0.cjs +31 -0
  6. package/dist/{combobox-BX1YbDHV.cjs → combobox-6WP1urZS.cjs} +1 -1
  7. package/dist/{combobox-BdDZU1bk.js → combobox-CtHgl1n2.js} +3 -3
  8. package/dist/{datepicker-C4joeEiQ.cjs → datepicker-DEO1C69C.cjs} +47 -47
  9. package/dist/{datepicker-lnxklOi4.js → datepicker-q9haFM81.js} +178 -203
  10. package/dist/{helptext-DuvVSH7d.js → helptext-Cs3QHeEy.js} +1 -1
  11. package/dist/helptext-EPTR9AIl.cjs +24 -0
  12. package/dist/{input-element-BcFmygSF.js → input-element-Dqu8udwd.js} +1 -1
  13. package/dist/input-element-KUsQQ-1d.cjs +1 -0
  14. package/dist/{input-wrapper-D9kFsTCN.cjs → input-wrapper-B-Qseywc.cjs} +2 -2
  15. package/dist/{input-wrapper-CiqUL7my.js → input-wrapper-Wu3Yv-bn.js} +2 -2
  16. package/dist/{listbox-CsGiqzD0.cjs → listbox-DnoqOo5u.cjs} +1 -1
  17. package/dist/{listbox-DlJevu8O.js → listbox-mvKKzH-v.js} +1 -1
  18. package/dist/pkt-calendar.cjs +1 -1
  19. package/dist/pkt-calendar.js +1 -1
  20. package/dist/pkt-checkbox.cjs +1 -1
  21. package/dist/pkt-checkbox.js +1 -1
  22. package/dist/pkt-combobox.cjs +1 -1
  23. package/dist/pkt-combobox.js +1 -1
  24. package/dist/pkt-datepicker.cjs +1 -1
  25. package/dist/pkt-datepicker.js +2 -2
  26. package/dist/pkt-helptext.cjs +1 -1
  27. package/dist/pkt-helptext.js +1 -1
  28. package/dist/pkt-index.cjs +1 -1
  29. package/dist/pkt-index.js +12 -12
  30. package/dist/pkt-input-wrapper.cjs +1 -1
  31. package/dist/pkt-input-wrapper.js +1 -1
  32. package/dist/pkt-listbox.cjs +1 -1
  33. package/dist/pkt-listbox.js +1 -1
  34. package/dist/pkt-progressbar.cjs +1 -1
  35. package/dist/pkt-progressbar.js +2 -2
  36. package/dist/pkt-radiobutton.cjs +1 -1
  37. package/dist/pkt-radiobutton.js +1 -1
  38. package/dist/pkt-select.cjs +1 -1
  39. package/dist/pkt-select.js +1 -1
  40. package/dist/pkt-textarea.cjs +1 -1
  41. package/dist/pkt-textarea.js +1 -1
  42. package/dist/pkt-textinput.cjs +1 -1
  43. package/dist/pkt-textinput.js +1 -1
  44. package/dist/{progressbar-CazcIzVT.cjs → progressbar-8gzOtJyh.cjs} +1 -1
  45. package/dist/{progressbar-BbVei20_.js → progressbar-kxcBEspG.js} +1 -1
  46. package/dist/{radiobutton-DODROIBF.js → radiobutton-DuAo3CdN.js} +1 -1
  47. package/dist/{radiobutton-D1fihs8R.cjs → radiobutton-FwxpKELo.cjs} +1 -1
  48. package/dist/{select-D7Ne5gv0.cjs → select-BbmLn1qh.cjs} +1 -1
  49. package/dist/{select-_KoHkDbx.js → select-wak-jukY.js} +2 -2
  50. package/dist/{textarea-DuOBX5is.js → textarea-CIb4VWtN.js} +2 -2
  51. package/dist/{textarea-CYHYvdCf.cjs → textarea-CzN0E0TV.cjs} +1 -1
  52. package/dist/{textinput-CrcXv_is.js → textinput-D5_RTkRY.js} +2 -2
  53. package/dist/{textinput-DYVtoRMy.cjs → textinput-D8v6D6ie.cjs} +1 -1
  54. package/dist/utils-DznhwRXm.js +8 -0
  55. package/dist/utils-byXsEz1u.cjs +1 -0
  56. package/package.json +2 -4
  57. package/src/components/calendar/calendar.constraints.test.ts +1 -1
  58. package/src/components/calendar/calendar.core.test.ts +1 -1
  59. package/src/components/calendar/calendar.selection.test.ts +1 -1
  60. package/src/components/calendar/calendar.ts +1 -1
  61. package/src/components/checkbox/checkbox.ts +5 -0
  62. package/src/components/datepicker/date-tags.ts +4 -4
  63. package/src/components/datepicker/datepicker-multiple.ts +3 -2
  64. package/src/components/datepicker/datepicker-range.ts +4 -3
  65. package/src/components/datepicker/datepicker-single.ts +3 -2
  66. package/src/components/datepicker/datepicker-utils.ts +7 -69
  67. package/src/components/datepicker/datepicker.core.test.ts +1 -1
  68. package/src/components/datepicker/datepicker.ts +11 -10
  69. package/src/components/helptext/helptext.ts +1 -1
  70. package/src/components/input-wrapper/input-wrapper.ts +1 -1
  71. package/src/components/listbox/listbox.ts +1 -1
  72. package/src/components/progressbar/progressbar.ts +1 -1
  73. package/dist/calendar-BaMrdMDZ.cjs +0 -115
  74. package/dist/checkbox-CTxc8wQe.cjs +0 -31
  75. package/dist/helptext-CVQP3pis.cjs +0 -24
  76. package/dist/input-element-j9znzLWz.cjs +0 -1
  77. package/dist/stringutils-CkVRq4jP.cjs +0 -1
  78. package/dist/stringutils-DJjRa8dG.js +0 -7
@@ -1,6 +1,6 @@
1
1
  import '@testing-library/jest-dom'
2
2
  import { fireEvent } from '@testing-library/dom'
3
- import { parseISODateString } from '@/utils/dateutils'
3
+ import { parseISODateString } from 'shared-utils/date-utils'
4
4
 
5
5
  import './calendar'
6
6
  import { PktCalendar } from './calendar'
@@ -9,7 +9,7 @@ import {
9
9
  todayInTz,
10
10
  isDateSelectable,
11
11
  newDateFromDate,
12
- } from '@/utils/dateutils'
12
+ } from 'shared-utils/date-utils'
13
13
  import { getWeek, eachDayOfInterval, getISODay, addDays } from 'date-fns'
14
14
  import { html, nothing, PropertyValues } from 'lit'
15
15
  import { PktElement } from '@/base-elements/element'
@@ -50,6 +50,7 @@ export class PktCheckbox extends PktInputElement<Props> {
50
50
  }
51
51
  if (name === 'checked') {
52
52
  this.checked = this.checked === '' || this.checked === 'true' || this.checked === true
53
+ if (this.inputRef.value) this.inputRef.value.checked = this.checked as boolean
53
54
  }
54
55
  super.attributeChangedCallback(name, _old, value)
55
56
  }
@@ -65,6 +66,10 @@ export class PktCheckbox extends PktInputElement<Props> {
65
66
  if (changedProperties.has('defaultChecked') && !this.checked) {
66
67
  this.checked = this.defaultChecked
67
68
  }
69
+ if (changedProperties.has('checked') && this.inputRef.value) {
70
+ this.inputRef.value.checked =
71
+ this.checked === '' || this.checked === 'true' || this.checked === true
72
+ }
68
73
  super.updated(changedProperties)
69
74
  }
70
75
 
@@ -5,9 +5,9 @@ import { classMap } from 'lit/directives/class-map.js'
5
5
  import { repeat } from 'lit/directives/repeat.js'
6
6
 
7
7
  import '@/components/tag'
8
- import { fromISOtoLocal } from '@/utils/dateutils'
9
- import { valueUtils } from './datepicker-utils'
10
- import { uuidish } from '@/utils/stringutils'
8
+ import { fromISOtoLocal } from 'shared-utils/date-utils'
9
+ import { uuidish } from 'shared-utils/utils'
10
+ import { sortDateStrings } from 'shared-utils/date-utils'
11
11
 
12
12
  type TYear = `${number}${number}${number}${number}`
13
13
  type TMonth = `${number}${number}`
@@ -39,7 +39,7 @@ export class PktDateTags extends PktElement {
39
39
  <div class=${classMap(this.classes)} aria-live="polite">
40
40
  ${Array.isArray(this.dates) && !!this.dates[0]
41
41
  ? repeat(
42
- valueUtils.sortDates((this.dates ?? []).filter(Boolean)),
42
+ sortDateStrings((this.dates ?? []).filter(Boolean)),
43
43
  (date) => date,
44
44
  (date) =>
45
45
  html` <pkt-tag
@@ -4,7 +4,8 @@ import { classMap } from 'lit/directives/class-map.js'
4
4
  import { ifDefined } from 'lit/directives/if-defined.js'
5
5
  import { Ref, createRef, ref } from 'lit/directives/ref.js'
6
6
  import { PktElement } from '@/base-elements/element'
7
- import { keyboardUtils, formUtils, deviceDetection, cssUtils } from './datepicker-utils'
7
+ import { keyboardUtils, formUtils, cssUtils } from './datepicker-utils'
8
+ import { isIOS } from 'shared-utils/device-utils'
8
9
  import '@/components/icon'
9
10
 
10
11
  @customElement('pkt-datepicker-multiple')
@@ -164,7 +165,7 @@ export class PktDatepickerMultiple extends PktElement {
164
165
  }}
165
166
  @focus=${() => {
166
167
  this.dispatchFocus()
167
- if (deviceDetection.isIOS()) {
168
+ if (isIOS()) {
168
169
  this.dispatchToggleCalendar(new Event('focus'))
169
170
  }
170
171
  }}
@@ -4,7 +4,8 @@ import { classMap } from 'lit/directives/class-map.js'
4
4
  import { ifDefined } from 'lit/directives/if-defined.js'
5
5
  import { Ref, createRef, ref } from 'lit/directives/ref.js'
6
6
  import { PktElement } from '@/base-elements/element'
7
- import { keyboardUtils, formUtils, deviceDetection, cssUtils } from './datepicker-utils'
7
+ import { keyboardUtils, formUtils, cssUtils } from './datepicker-utils'
8
+ import { isIOS } from 'shared-utils/device-utils'
8
9
  import '@/components/icon'
9
10
 
10
11
  @customElement('pkt-datepicker-range')
@@ -173,7 +174,7 @@ export class PktDatepickerRange extends PktElement {
173
174
  }}
174
175
  @focus=${() => {
175
176
  this.dispatchFocus()
176
- if (deviceDetection.isIOS()) {
177
+ if (isIOS()) {
177
178
  this.dispatchToggleCalendar(new Event('focus'))
178
179
  }
179
180
  }}
@@ -233,7 +234,7 @@ export class PktDatepickerRange extends PktElement {
233
234
  }}
234
235
  @focus=${() => {
235
236
  this.dispatchFocus()
236
- if (deviceDetection.isIOS()) {
237
+ if (isIOS()) {
237
238
  this.dispatchToggleCalendar(new Event('focus'))
238
239
  }
239
240
  }}
@@ -4,7 +4,8 @@ import { classMap } from 'lit/directives/class-map.js'
4
4
  import { ifDefined } from 'lit/directives/if-defined.js'
5
5
  import { Ref, createRef, ref } from 'lit/directives/ref.js'
6
6
  import { PktElement } from '@/base-elements/element'
7
- import { keyboardUtils, formUtils, deviceDetection, cssUtils } from './datepicker-utils'
7
+ import { keyboardUtils, formUtils, cssUtils } from './datepicker-utils'
8
+ import { isIOS } from 'shared-utils/device-utils'
8
9
  import '@/components/icon'
9
10
 
10
11
  @customElement('pkt-datepicker-single')
@@ -159,7 +160,7 @@ export class PktDatepickerSingle extends PktElement {
159
160
  }}
160
161
  @focus=${() => {
161
162
  this.dispatchFocus()
162
- if (deviceDetection.isIOS()) {
163
+ if (isIOS()) {
163
164
  this.dispatchToggleCalendar(new Event('focus'))
164
165
  }
165
166
  }}
@@ -4,7 +4,8 @@ import {
4
4
  isValidDateRange,
5
5
  sortDateStrings,
6
6
  filterSelectableDates,
7
- } from '@/utils/dateutils'
7
+ } from 'shared-utils/date-utils'
8
+ import { isIOS } from 'shared-utils/device-utils'
8
9
  import { Ref } from 'lit/directives/ref.js'
9
10
  import { PktCalendar } from '@/components/calendar/calendar'
10
11
 
@@ -12,63 +13,10 @@ import { PktCalendar } from '@/components/calendar/calendar'
12
13
  * Utility functions for PktDatepicker
13
14
  */
14
15
 
15
- /**
16
- * Sleep utility function for async delays
17
- */
18
- export const sleep = (ms: number): Promise<void> =>
19
- new Promise((resolve) => setTimeout(resolve, ms))
20
-
21
- /**
22
- * Device detection utilities
23
- */
24
- export const deviceDetection = {
25
- /**
26
- * Detects if the current device is iOS (iPhone, iPad, iPod)
27
- * Handles modern iPad Safari which uses desktop user agent since iOS 13
28
- */
29
- isIOS(): boolean {
30
- const ua = navigator.userAgent
31
-
32
- // Legacy iOS detection (iPhone, iPod, older iPads)
33
- if (/iP(hone|od|ad)/.test(ua)) {
34
- return true
35
- }
36
-
37
- // Modern iPad detection (iOS 13+ iPads identify as Mac)
38
- // Check for Mac + touch support
39
- if (/Macintosh/.test(ua) && 'ontouchend' in document) {
40
- return true
41
- }
42
-
43
- return false
44
- },
45
- }
46
-
47
16
  /**
48
17
  * Value parsing and validation utilities
49
18
  */
50
19
  export const valueUtils = {
51
- /**
52
- * Parses a value (string or string array) into an array of strings
53
- */
54
- parseValue(value: string | string[] | null | undefined): string[] {
55
- if (!value) return []
56
- if (Array.isArray(value)) {
57
- return value.filter(Boolean)
58
- }
59
- if (typeof value === 'string') {
60
- return value.split(',').filter(Boolean)
61
- }
62
- return String(value).split(',').filter(Boolean)
63
- },
64
-
65
- /**
66
- * Converts array of dates to comma-separated string
67
- */
68
- formatValue(values: string[]): string {
69
- return values.join(',')
70
- },
71
-
72
20
  /**
73
21
  * Ensures name attribute ends with [] for multiple/range inputs
74
22
  */
@@ -84,16 +32,6 @@ export const valueUtils = {
84
32
  return name
85
33
  },
86
34
 
87
- /**
88
- * Converts string arrays to proper arrays if they come as strings
89
- */
90
- normalizeStringArray(value: string | string[]): string[] {
91
- if (typeof value === 'string') {
92
- return value.split(',').filter(Boolean)
93
- }
94
- return Array.isArray(value) ? value : []
95
- },
96
-
97
35
  /**
98
36
  * Validates that a range has valid order (start <= end)
99
37
  */
@@ -132,7 +70,7 @@ export const inputTypeUtils = {
132
70
  * Mobile Safari does not play well with type="date" amd custom datepickers
133
71
  */
134
72
  getInputType(): string {
135
- return deviceDetection.isIOS() ? 'text' : 'date'
73
+ return isIOS() ? 'text' : 'date'
136
74
  },
137
75
  }
138
76
 
@@ -323,12 +261,12 @@ export const cssUtils = {
323
261
  * Generates input classes for datepicker
324
262
  */
325
263
  getInputClasses(
326
- fullwidth: boolean,
327
- showRangeLabels: boolean,
328
- multiple: boolean,
264
+ fullwidth: boolean,
265
+ showRangeLabels: boolean,
266
+ multiple: boolean,
329
267
  range: boolean,
330
268
  readonly?: boolean,
331
- inputType?: string
269
+ inputType?: string,
332
270
  ) {
333
271
  return {
334
272
  'pkt-input': true,
@@ -1,7 +1,7 @@
1
1
  import '@testing-library/jest-dom'
2
2
  import { toHaveNoViolations } from 'jest-axe'
3
3
  import { fireEvent } from '@testing-library/dom'
4
- import { parseISODateString } from '@/utils/dateutils'
4
+ import { parseISODateString } from 'shared-utils/date-utils'
5
5
 
6
6
  expect.extend(toHaveNoViolations)
7
7
 
@@ -1,5 +1,5 @@
1
1
  import { customElement, property, state } from 'lit/decorators.js'
2
- import { formatISODate, fromISOToDate, parseISODateString } from '@/utils/dateutils'
2
+ import { formatISODate, fromISOToDate, parseISODateString } from 'shared-utils/date-utils'
3
3
  import { html, nothing, PropertyValues } from 'lit'
4
4
  import { PktCalendar } from '@/components/calendar/calendar'
5
5
  import { PktInputElement } from '@/base-elements/input-element'
@@ -16,8 +16,6 @@ import './datepicker-range'
16
16
  import './datepicker-multiple'
17
17
  import { PktSlotController } from '@/controllers/pkt-slot-controller'
18
18
  import {
19
- sleep,
20
- deviceDetection,
21
19
  valueUtils,
22
20
  inputTypeUtils,
23
21
  calendarUtils,
@@ -25,6 +23,9 @@ import {
25
23
  dateProcessingUtils,
26
24
  formUtils,
27
25
  } from './datepicker-utils'
26
+ import { valueToArray, arrayToCsv } from 'shared-utils/value-utils'
27
+ import { sleep } from 'shared-utils/utils'
28
+ import { isIOS } from 'shared-utils/device-utils'
28
29
  import { PktDatepickerPopup } from './datepicker-popup'
29
30
  import { PktDatepickerSingle } from './datepicker-single'
30
31
  import { PktDatepickerRange } from './datepicker-range'
@@ -156,7 +157,7 @@ export class PktDatepicker extends PktInputElement<Props> {
156
157
  valueChanged(newValue: string | null, oldValue: string | null): void {
157
158
  if (newValue === oldValue) return
158
159
 
159
- const parsedValue = valueUtils.parseValue(newValue)
160
+ const parsedValue = valueToArray(newValue)
160
161
 
161
162
  // For multiple dates, filter out invalid ones to prevent accumulating bad dates
162
163
  // For single/range dates, preserve user input for validation feedback
@@ -180,7 +181,7 @@ export class PktDatepicker extends PktInputElement<Props> {
180
181
 
181
182
  this._value = filteredValue
182
183
 
183
- const parsedValueString = valueUtils.formatValue(filteredValue)
184
+ const parsedValueString = arrayToCsv(filteredValue)
184
185
  if (this._valueProperty !== parsedValueString) {
185
186
  this._valueProperty = parsedValueString
186
187
  }
@@ -194,11 +195,11 @@ export class PktDatepicker extends PktInputElement<Props> {
194
195
  }
195
196
 
196
197
  if (name === 'excludedates' && typeof this.excludedates === 'string') {
197
- this.excludedates = valueUtils.normalizeStringArray(value || '')
198
+ this.excludedates = valueToArray(value || '')
198
199
  }
199
200
 
200
201
  if (name === 'excludeweekdays' && typeof this.excludeweekdays === 'string') {
201
- this.excludeweekdays = valueUtils.normalizeStringArray(value || '')
202
+ this.excludeweekdays = valueToArray(value || '')
202
203
  }
203
204
  super.attributeChangedCallback(name, _old, value)
204
205
  }
@@ -216,7 +217,7 @@ export class PktDatepicker extends PktInputElement<Props> {
216
217
  }
217
218
  if (changedProperties.has('multiple')) {
218
219
  if (this.multiple && !Array.isArray(this._value)) {
219
- this._value = valueUtils.parseValue(this.value)
220
+ this._value = valueToArray(this.value)
220
221
  } else if (!this.multiple && Array.isArray(this._value)) {
221
222
  this._value = this._value.filter(Boolean)
222
223
  }
@@ -536,12 +537,12 @@ export class PktDatepicker extends PktInputElement<Props> {
536
537
  this.calendarOpen = true
537
538
  if (popup && typeof popup.show === 'function') {
538
539
  popup.show()
539
- if (deviceDetection.isIOS()) popup.focusOnCurrentDate()
540
+ if (isIOS()) popup.focusOnCurrentDate()
540
541
  return
541
542
  }
542
543
  await sleep(20)
543
544
  this.handleCalendarPosition()
544
- if (deviceDetection.isIOS()) {
545
+ if (isIOS()) {
545
546
  this.calRef.value?.focusOnCurrentDate()
546
547
  }
547
548
  }
@@ -4,7 +4,7 @@ import { createRef, ref, Ref } from 'lit/directives/ref.js'
4
4
  import { unsafeHTML } from 'lit/directives/unsafe-html.js'
5
5
  import { classMap } from 'lit/directives/class-map.js'
6
6
  import { customElement, property, state } from 'lit/decorators.js'
7
- import { uuidish } from '@/utils/stringutils'
7
+ import { uuidish } from 'shared-utils/utils'
8
8
  import specs from 'componentSpecs/input-wrapper.json'
9
9
  import '@/components/icon'
10
10
  import { PktSlotController } from '@/controllers/pkt-slot-controller'
@@ -7,7 +7,7 @@ import { unsafeHTML } from 'lit/directives/unsafe-html.js'
7
7
  import { classMap } from 'lit/directives/class-map.js'
8
8
  import { customElement, property } from 'lit/decorators.js'
9
9
  import { ElementProps } from '@/types/typeUtils'
10
- import { uuidish } from '@/utils/stringutils'
10
+ import { uuidish } from 'shared-utils/utils'
11
11
  import specs from 'componentSpecs/input-wrapper.json'
12
12
  import '@/components/helptext'
13
13
  import '@/components/icon'
@@ -6,7 +6,7 @@ import { PktElement } from '@/base-elements/element'
6
6
  import { repeat } from 'lit/directives/repeat.js'
7
7
  import { classMap } from 'lit/directives/class-map.js'
8
8
  import { IPktComboboxOption } from '@/components/combobox/combobox'
9
- import { uuidish } from '@/utils/stringutils'
9
+ import { uuidish } from 'shared-utils/utils'
10
10
 
11
11
  declare global {
12
12
  interface HTMLElementTagNameMap {
@@ -4,7 +4,7 @@ import { html, nothing } from 'lit'
4
4
  import { PktElement } from '@/base-elements/element'
5
5
  import { Ref, createRef, ref } from 'lit/directives/ref.js'
6
6
  import { styleMap } from 'lit/directives/style-map.js'
7
- import { uuidish } from '@/utils/stringutils'
7
+ import { uuidish } from 'shared-utils/utils'
8
8
 
9
9
  import '@/components/icon'
10
10
  import { TAriaLive } from '@/types/aria'
@@ -1,115 +0,0 @@
1
- "use strict";const J=require("./class-map-C_erArZz.cjs"),c=require("./element-CJ_QKaki.cjs"),I=require("./state-DSjcvzDN.cjs");require("./icon-BGuizDwk.cjs");const ot=6048e5,pt=864e5,K=Symbol.for("constructDateFrom");function S(e,t){return typeof e=="function"?e(t):e&&typeof e=="object"&&K in e?e[K](t):e instanceof Date?new e.constructor(t):new Date(t)}function k(e,t){return S(t||e,e)}function j(e,t,n){const r=k(e,n==null?void 0:n.in);return isNaN(t)?S(e,NaN):(t&&r.setDate(r.getDate()+t),r)}let wt={};function L(){return wt}function H(e,t){var l,o,u,d;const n=L(),r=(t==null?void 0:t.weekStartsOn)??((o=(l=t==null?void 0:t.locale)==null?void 0:l.options)==null?void 0:o.weekStartsOn)??n.weekStartsOn??((d=(u=n.locale)==null?void 0:u.options)==null?void 0:d.weekStartsOn)??0,a=k(e,t==null?void 0:t.in),s=a.getDay(),i=(s<r?7:0)+s-r;return a.setDate(a.getDate()-i),a.setHours(0,0,0,0),a}function R(e,t){return H(e,{...t,weekStartsOn:1})}function ct(e,t){const n=k(e,t==null?void 0:t.in),r=n.getFullYear(),a=S(n,0);a.setFullYear(r+1,0,4),a.setHours(0,0,0,0);const s=R(a),i=S(n,0);i.setFullYear(r,0,4),i.setHours(0,0,0,0);const l=R(i);return n.getTime()>=s.getTime()?r+1:n.getTime()>=l.getTime()?r:r-1}function Z(e){const t=k(e),n=new Date(Date.UTC(t.getFullYear(),t.getMonth(),t.getDate(),t.getHours(),t.getMinutes(),t.getSeconds(),t.getMilliseconds()));return n.setUTCFullYear(t.getFullYear()),+e-+n}function lt(e,...t){const n=S.bind(null,t.find(r=>typeof r=="object"));return t.map(n)}function tt(e,t){const n=k(e,t==null?void 0:t.in);return n.setHours(0,0,0,0),n}function bt(e,t,n){const[r,a]=lt(n==null?void 0:n.in,e,t),s=tt(r),i=tt(a),l=+s-Z(s),o=+i-Z(i);return Math.round((l-o)/pt)}function kt(e,t){const n=ct(e,t),r=S(e,0);return r.setFullYear(n,0,4),r.setHours(0,0,0,0),R(r)}function Dt(e){return e instanceof Date||typeof e=="object"&&Object.prototype.toString.call(e)==="[object Date]"}function St(e){return!(!Dt(e)&&typeof e!="number"||isNaN(+k(e)))}function Mt(e,t){const[n,r]=lt(e,t.start,t.end);return{start:n,end:r}}function z(e,t){const{start:n,end:r}=Mt(t==null?void 0:t.in,e);let a=+n>+r;const s=a?+n:+r,i=a?r:n;i.setHours(0,0,0,0);let l=1;const o=[];for(;+i<=s;)o.push(S(n,i)),i.setDate(i.getDate()+l),i.setHours(0,0,0,0);return a?o.reverse():o}function vt(e,t){const n=k(e,t==null?void 0:t.in);return n.setFullYear(n.getFullYear(),0,1),n.setHours(0,0,0,0),n}const Tt={lessThanXSeconds:{one:"less than a second",other:"less than {{count}} seconds"},xSeconds:{one:"1 second",other:"{{count}} seconds"},halfAMinute:"half a minute",lessThanXMinutes:{one:"less than a minute",other:"less than {{count}} minutes"},xMinutes:{one:"1 minute",other:"{{count}} minutes"},aboutXHours:{one:"about 1 hour",other:"about {{count}} hours"},xHours:{one:"1 hour",other:"{{count}} hours"},xDays:{one:"1 day",other:"{{count}} days"},aboutXWeeks:{one:"about 1 week",other:"about {{count}} weeks"},xWeeks:{one:"1 week",other:"{{count}} weeks"},aboutXMonths:{one:"about 1 month",other:"about {{count}} months"},xMonths:{one:"1 month",other:"{{count}} months"},aboutXYears:{one:"about 1 year",other:"about {{count}} years"},xYears:{one:"1 year",other:"{{count}} years"},overXYears:{one:"over 1 year",other:"over {{count}} years"},almostXYears:{one:"almost 1 year",other:"almost {{count}} years"}},xt=(e,t,n)=>{let r;const a=Tt[e];return typeof a=="string"?r=a:t===1?r=a.one:r=a.other.replace("{{count}}",t.toString()),n!=null&&n.addSuffix?n.comparison&&n.comparison>0?"in "+r:r+" ago":r};function Q(e){return(t={})=>{const n=t.width?String(t.width):e.defaultWidth;return e.formats[n]||e.formats[e.defaultWidth]}}const Ot={full:"EEEE, MMMM do, y",long:"MMMM do, y",medium:"MMM d, y",short:"MM/dd/yyyy"},Pt={full:"h:mm:ss a zzzz",long:"h:mm:ss a z",medium:"h:mm:ss a",short:"h:mm a"},Ct={full:"{{date}} 'at' {{time}}",long:"{{date}} 'at' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},Nt={date:Q({formats:Ot,defaultWidth:"full"}),time:Q({formats:Pt,defaultWidth:"full"}),dateTime:Q({formats:Ct,defaultWidth:"full"})},$t={lastWeek:"'last' eeee 'at' p",yesterday:"'yesterday at' p",today:"'today at' p",tomorrow:"'tomorrow at' p",nextWeek:"eeee 'at' p",other:"P"},_t=(e,t,n,r)=>$t[e];function W(e){return(t,n)=>{const r=n!=null&&n.context?String(n.context):"standalone";let a;if(r==="formatting"&&e.formattingValues){const i=e.defaultFormattingWidth||e.defaultWidth,l=n!=null&&n.width?String(n.width):i;a=e.formattingValues[l]||e.formattingValues[i]}else{const i=e.defaultWidth,l=n!=null&&n.width?String(n.width):e.defaultWidth;a=e.values[l]||e.values[i]}const s=e.argumentCallback?e.argumentCallback(t):t;return a[s]}}const Et={narrow:["B","A"],abbreviated:["BC","AD"],wide:["Before Christ","Anno Domini"]},Wt={narrow:["1","2","3","4"],abbreviated:["Q1","Q2","Q3","Q4"],wide:["1st quarter","2nd quarter","3rd quarter","4th quarter"]},Yt={narrow:["J","F","M","A","M","J","J","A","S","O","N","D"],abbreviated:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],wide:["January","February","March","April","May","June","July","August","September","October","November","December"]},At={narrow:["S","M","T","W","T","F","S"],short:["Su","Mo","Tu","We","Th","Fr","Sa"],abbreviated:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],wide:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]},Ft={narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"}},Ht={narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"}},It=(e,t)=>{const n=Number(e),r=n%100;if(r>20||r<10)switch(r%10){case 1:return n+"st";case 2:return n+"nd";case 3:return n+"rd"}return n+"th"},qt={ordinalNumber:It,era:W({values:Et,defaultWidth:"wide"}),quarter:W({values:Wt,defaultWidth:"wide",argumentCallback:e=>e-1}),month:W({values:Yt,defaultWidth:"wide"}),day:W({values:At,defaultWidth:"wide"}),dayPeriod:W({values:Ft,defaultWidth:"wide",formattingValues:Ht,defaultFormattingWidth:"wide"})};function Y(e){return(t,n={})=>{const r=n.width,a=r&&e.matchPatterns[r]||e.matchPatterns[e.defaultMatchWidth],s=t.match(a);if(!s)return null;const i=s[0],l=r&&e.parsePatterns[r]||e.parsePatterns[e.defaultParseWidth],o=Array.isArray(l)?Lt(l,m=>m.test(i)):Rt(l,m=>m.test(i));let u;u=e.valueCallback?e.valueCallback(o):o,u=n.valueCallback?n.valueCallback(u):u;const d=t.slice(i.length);return{value:u,rest:d}}}function Rt(e,t){for(const n in e)if(Object.prototype.hasOwnProperty.call(e,n)&&t(e[n]))return n}function Lt(e,t){for(let n=0;n<e.length;n++)if(t(e[n]))return n}function Ut(e){return(t,n={})=>{const r=t.match(e.matchPattern);if(!r)return null;const a=r[0],s=t.match(e.parsePattern);if(!s)return null;let i=e.valueCallback?e.valueCallback(s[0]):s[0];i=n.valueCallback?n.valueCallback(i):i;const l=t.slice(a.length);return{value:i,rest:l}}}const Bt=/^(\d+)(th|st|nd|rd)?/i,jt=/\d+/i,zt={narrow:/^(b|a)/i,abbreviated:/^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,wide:/^(before christ|before common era|anno domini|common era)/i},Qt={any:[/^b/i,/^(a|c)/i]},Xt={narrow:/^[1234]/i,abbreviated:/^q[1234]/i,wide:/^[1234](th|st|nd|rd)? quarter/i},Gt={any:[/1/i,/2/i,/3/i,/4/i]},Vt={narrow:/^[jfmasond]/i,abbreviated:/^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,wide:/^(january|february|march|april|may|june|july|august|september|october|november|december)/i},Jt={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],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]},Kt={narrow:/^[smtwf]/i,short:/^(su|mo|tu|we|th|fr|sa)/i,abbreviated:/^(sun|mon|tue|wed|thu|fri|sat)/i,wide:/^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i},Zt={narrow:[/^s/i,/^m/i,/^t/i,/^w/i,/^t/i,/^f/i,/^s/i],any:[/^su/i,/^m/i,/^tu/i,/^w/i,/^th/i,/^f/i,/^sa/i]},te={narrow:/^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,any:/^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i},ee={any:{am:/^a/i,pm:/^p/i,midnight:/^mi/i,noon:/^no/i,morning:/morning/i,afternoon:/afternoon/i,evening:/evening/i,night:/night/i}},ne={ordinalNumber:Ut({matchPattern:Bt,parsePattern:jt,valueCallback:e=>parseInt(e,10)}),era:Y({matchPatterns:zt,defaultMatchWidth:"wide",parsePatterns:Qt,defaultParseWidth:"any"}),quarter:Y({matchPatterns:Xt,defaultMatchWidth:"wide",parsePatterns:Gt,defaultParseWidth:"any",valueCallback:e=>e+1}),month:Y({matchPatterns:Vt,defaultMatchWidth:"wide",parsePatterns:Jt,defaultParseWidth:"any"}),day:Y({matchPatterns:Kt,defaultMatchWidth:"wide",parsePatterns:Zt,defaultParseWidth:"any"}),dayPeriod:Y({matchPatterns:te,defaultMatchWidth:"any",parsePatterns:ee,defaultParseWidth:"any"})},re={code:"en-US",formatDistance:xt,formatLong:Nt,formatRelative:_t,localize:qt,match:ne,options:{weekStartsOn:0,firstWeekContainsDate:1}};function ae(e,t){const n=k(e,t==null?void 0:t.in);return bt(n,vt(n))+1}function se(e,t){const n=k(e,t==null?void 0:t.in),r=+R(n)-+kt(n);return Math.round(r/ot)+1}function ut(e,t){var d,m,p,g;const n=k(e,t==null?void 0:t.in),r=n.getFullYear(),a=L(),s=(t==null?void 0:t.firstWeekContainsDate)??((m=(d=t==null?void 0:t.locale)==null?void 0:d.options)==null?void 0:m.firstWeekContainsDate)??a.firstWeekContainsDate??((g=(p=a.locale)==null?void 0:p.options)==null?void 0:g.firstWeekContainsDate)??1,i=S((t==null?void 0:t.in)||e,0);i.setFullYear(r+1,0,s),i.setHours(0,0,0,0);const l=H(i,t),o=S((t==null?void 0:t.in)||e,0);o.setFullYear(r,0,s),o.setHours(0,0,0,0);const u=H(o,t);return+n>=+l?r+1:+n>=+u?r:r-1}function ie(e,t){var l,o,u,d;const n=L(),r=(t==null?void 0:t.firstWeekContainsDate)??((o=(l=t==null?void 0:t.locale)==null?void 0:l.options)==null?void 0:o.firstWeekContainsDate)??n.firstWeekContainsDate??((d=(u=n.locale)==null?void 0:u.options)==null?void 0:d.firstWeekContainsDate)??1,a=ut(e,t),s=S((t==null?void 0:t.in)||e,0);return s.setFullYear(a,0,r),s.setHours(0,0,0,0),H(s,t)}function ht(e,t){const n=k(e,t==null?void 0:t.in),r=+H(n,t)-+ie(n,t);return Math.round(r/ot)+1}function h(e,t){const n=e<0?"-":"",r=Math.abs(e).toString().padStart(t,"0");return n+r}const M={y(e,t){const n=e.getFullYear(),r=n>0?n:1-n;return h(t==="yy"?r%100:r,t.length)},M(e,t){const n=e.getMonth();return t==="M"?String(n+1):h(n+1,2)},d(e,t){return h(e.getDate(),t.length)},a(e,t){const n=e.getHours()/12>=1?"pm":"am";switch(t){case"a":case"aa":return n.toUpperCase();case"aaa":return n;case"aaaaa":return n[0];case"aaaa":default:return n==="am"?"a.m.":"p.m."}},h(e,t){return h(e.getHours()%12||12,t.length)},H(e,t){return h(e.getHours(),t.length)},m(e,t){return h(e.getMinutes(),t.length)},s(e,t){return h(e.getSeconds(),t.length)},S(e,t){const n=t.length,r=e.getMilliseconds(),a=Math.trunc(r*Math.pow(10,n-3));return h(a,t.length)}},$={midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},et={G:function(e,t,n){const r=e.getFullYear()>0?1:0;switch(t){case"G":case"GG":case"GGG":return n.era(r,{width:"abbreviated"});case"GGGGG":return n.era(r,{width:"narrow"});case"GGGG":default:return n.era(r,{width:"wide"})}},y:function(e,t,n){if(t==="yo"){const r=e.getFullYear(),a=r>0?r:1-r;return n.ordinalNumber(a,{unit:"year"})}return M.y(e,t)},Y:function(e,t,n,r){const a=ut(e,r),s=a>0?a:1-a;if(t==="YY"){const i=s%100;return h(i,2)}return t==="Yo"?n.ordinalNumber(s,{unit:"year"}):h(s,t.length)},R:function(e,t){const n=ct(e);return h(n,t.length)},u:function(e,t){const n=e.getFullYear();return h(n,t.length)},Q:function(e,t,n){const r=Math.ceil((e.getMonth()+1)/3);switch(t){case"Q":return String(r);case"QQ":return h(r,2);case"Qo":return n.ordinalNumber(r,{unit:"quarter"});case"QQQ":return n.quarter(r,{width:"abbreviated",context:"formatting"});case"QQQQQ":return n.quarter(r,{width:"narrow",context:"formatting"});case"QQQQ":default:return n.quarter(r,{width:"wide",context:"formatting"})}},q:function(e,t,n){const r=Math.ceil((e.getMonth()+1)/3);switch(t){case"q":return String(r);case"qq":return h(r,2);case"qo":return n.ordinalNumber(r,{unit:"quarter"});case"qqq":return n.quarter(r,{width:"abbreviated",context:"standalone"});case"qqqqq":return n.quarter(r,{width:"narrow",context:"standalone"});case"qqqq":default:return n.quarter(r,{width:"wide",context:"standalone"})}},M:function(e,t,n){const r=e.getMonth();switch(t){case"M":case"MM":return M.M(e,t);case"Mo":return n.ordinalNumber(r+1,{unit:"month"});case"MMM":return n.month(r,{width:"abbreviated",context:"formatting"});case"MMMMM":return n.month(r,{width:"narrow",context:"formatting"});case"MMMM":default:return n.month(r,{width:"wide",context:"formatting"})}},L:function(e,t,n){const r=e.getMonth();switch(t){case"L":return String(r+1);case"LL":return h(r+1,2);case"Lo":return n.ordinalNumber(r+1,{unit:"month"});case"LLL":return n.month(r,{width:"abbreviated",context:"standalone"});case"LLLLL":return n.month(r,{width:"narrow",context:"standalone"});case"LLLL":default:return n.month(r,{width:"wide",context:"standalone"})}},w:function(e,t,n,r){const a=ht(e,r);return t==="wo"?n.ordinalNumber(a,{unit:"week"}):h(a,t.length)},I:function(e,t,n){const r=se(e);return t==="Io"?n.ordinalNumber(r,{unit:"week"}):h(r,t.length)},d:function(e,t,n){return t==="do"?n.ordinalNumber(e.getDate(),{unit:"date"}):M.d(e,t)},D:function(e,t,n){const r=ae(e);return t==="Do"?n.ordinalNumber(r,{unit:"dayOfYear"}):h(r,t.length)},E:function(e,t,n){const r=e.getDay();switch(t){case"E":case"EE":case"EEE":return n.day(r,{width:"abbreviated",context:"formatting"});case"EEEEE":return n.day(r,{width:"narrow",context:"formatting"});case"EEEEEE":return n.day(r,{width:"short",context:"formatting"});case"EEEE":default:return n.day(r,{width:"wide",context:"formatting"})}},e:function(e,t,n,r){const a=e.getDay(),s=(a-r.weekStartsOn+8)%7||7;switch(t){case"e":return String(s);case"ee":return h(s,2);case"eo":return n.ordinalNumber(s,{unit:"day"});case"eee":return n.day(a,{width:"abbreviated",context:"formatting"});case"eeeee":return n.day(a,{width:"narrow",context:"formatting"});case"eeeeee":return n.day(a,{width:"short",context:"formatting"});case"eeee":default:return n.day(a,{width:"wide",context:"formatting"})}},c:function(e,t,n,r){const a=e.getDay(),s=(a-r.weekStartsOn+8)%7||7;switch(t){case"c":return String(s);case"cc":return h(s,t.length);case"co":return n.ordinalNumber(s,{unit:"day"});case"ccc":return n.day(a,{width:"abbreviated",context:"standalone"});case"ccccc":return n.day(a,{width:"narrow",context:"standalone"});case"cccccc":return n.day(a,{width:"short",context:"standalone"});case"cccc":default:return n.day(a,{width:"wide",context:"standalone"})}},i:function(e,t,n){const r=e.getDay(),a=r===0?7:r;switch(t){case"i":return String(a);case"ii":return h(a,t.length);case"io":return n.ordinalNumber(a,{unit:"day"});case"iii":return n.day(r,{width:"abbreviated",context:"formatting"});case"iiiii":return n.day(r,{width:"narrow",context:"formatting"});case"iiiiii":return n.day(r,{width:"short",context:"formatting"});case"iiii":default:return n.day(r,{width:"wide",context:"formatting"})}},a:function(e,t,n){const a=e.getHours()/12>=1?"pm":"am";switch(t){case"a":case"aa":return n.dayPeriod(a,{width:"abbreviated",context:"formatting"});case"aaa":return n.dayPeriod(a,{width:"abbreviated",context:"formatting"}).toLowerCase();case"aaaaa":return n.dayPeriod(a,{width:"narrow",context:"formatting"});case"aaaa":default:return n.dayPeriod(a,{width:"wide",context:"formatting"})}},b:function(e,t,n){const r=e.getHours();let a;switch(r===12?a=$.noon:r===0?a=$.midnight:a=r/12>=1?"pm":"am",t){case"b":case"bb":return n.dayPeriod(a,{width:"abbreviated",context:"formatting"});case"bbb":return n.dayPeriod(a,{width:"abbreviated",context:"formatting"}).toLowerCase();case"bbbbb":return n.dayPeriod(a,{width:"narrow",context:"formatting"});case"bbbb":default:return n.dayPeriod(a,{width:"wide",context:"formatting"})}},B:function(e,t,n){const r=e.getHours();let a;switch(r>=17?a=$.evening:r>=12?a=$.afternoon:r>=4?a=$.morning:a=$.night,t){case"B":case"BB":case"BBB":return n.dayPeriod(a,{width:"abbreviated",context:"formatting"});case"BBBBB":return n.dayPeriod(a,{width:"narrow",context:"formatting"});case"BBBB":default:return n.dayPeriod(a,{width:"wide",context:"formatting"})}},h:function(e,t,n){if(t==="ho"){let r=e.getHours()%12;return r===0&&(r=12),n.ordinalNumber(r,{unit:"hour"})}return M.h(e,t)},H:function(e,t,n){return t==="Ho"?n.ordinalNumber(e.getHours(),{unit:"hour"}):M.H(e,t)},K:function(e,t,n){const r=e.getHours()%12;return t==="Ko"?n.ordinalNumber(r,{unit:"hour"}):h(r,t.length)},k:function(e,t,n){let r=e.getHours();return r===0&&(r=24),t==="ko"?n.ordinalNumber(r,{unit:"hour"}):h(r,t.length)},m:function(e,t,n){return t==="mo"?n.ordinalNumber(e.getMinutes(),{unit:"minute"}):M.m(e,t)},s:function(e,t,n){return t==="so"?n.ordinalNumber(e.getSeconds(),{unit:"second"}):M.s(e,t)},S:function(e,t){return M.S(e,t)},X:function(e,t,n){const r=e.getTimezoneOffset();if(r===0)return"Z";switch(t){case"X":return rt(r);case"XXXX":case"XX":return P(r);case"XXXXX":case"XXX":default:return P(r,":")}},x:function(e,t,n){const r=e.getTimezoneOffset();switch(t){case"x":return rt(r);case"xxxx":case"xx":return P(r);case"xxxxx":case"xxx":default:return P(r,":")}},O:function(e,t,n){const r=e.getTimezoneOffset();switch(t){case"O":case"OO":case"OOO":return"GMT"+nt(r,":");case"OOOO":default:return"GMT"+P(r,":")}},z:function(e,t,n){const r=e.getTimezoneOffset();switch(t){case"z":case"zz":case"zzz":return"GMT"+nt(r,":");case"zzzz":default:return"GMT"+P(r,":")}},t:function(e,t,n){const r=Math.trunc(+e/1e3);return h(r,t.length)},T:function(e,t,n){return h(+e,t.length)}};function nt(e,t=""){const n=e>0?"-":"+",r=Math.abs(e),a=Math.trunc(r/60),s=r%60;return s===0?n+String(a):n+String(a)+t+h(s,2)}function rt(e,t){return e%60===0?(e>0?"-":"+")+h(Math.abs(e)/60,2):P(e,t)}function P(e,t=""){const n=e>0?"-":"+",r=Math.abs(e),a=h(Math.trunc(r/60),2),s=h(r%60,2);return n+a+t+s}const at=(e,t)=>{switch(e){case"P":return t.date({width:"short"});case"PP":return t.date({width:"medium"});case"PPP":return t.date({width:"long"});case"PPPP":default:return t.date({width:"full"})}},dt=(e,t)=>{switch(e){case"p":return t.time({width:"short"});case"pp":return t.time({width:"medium"});case"ppp":return t.time({width:"long"});case"pppp":default:return t.time({width:"full"})}},oe=(e,t)=>{const n=e.match(/(P+)(p+)?/)||[],r=n[1],a=n[2];if(!a)return at(e,t);let s;switch(r){case"P":s=t.dateTime({width:"short"});break;case"PP":s=t.dateTime({width:"medium"});break;case"PPP":s=t.dateTime({width:"long"});break;case"PPPP":default:s=t.dateTime({width:"full"});break}return s.replace("{{date}}",at(r,t)).replace("{{time}}",dt(a,t))},ce={p:dt,P:oe},le=/^D+$/,ue=/^Y+$/,he=["D","DD","YY","YYYY"];function de(e){return le.test(e)}function fe(e){return ue.test(e)}function me(e,t,n){const r=ge(e,t,n);if(console.warn(r),he.includes(e))throw new RangeError(r)}function ge(e,t,n){const r=e[0]==="Y"?"years":"days of the month";return`Use \`${e.toLowerCase()}\` instead of \`${e}\` (in \`${t}\`) for formatting ${r} to the input \`${n}\`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md`}const ye=/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g,pe=/P+p+|P+|p+|''|'(''|[^'])+('|$)|./g,we=/^'([^]*?)'?$/,be=/''/g,ke=/[a-zA-Z]/;function De(e,t,n){var d,m,p,g;const r=L(),a=r.locale??re,s=r.firstWeekContainsDate??((m=(d=r.locale)==null?void 0:d.options)==null?void 0:m.firstWeekContainsDate)??1,i=r.weekStartsOn??((g=(p=r.locale)==null?void 0:p.options)==null?void 0:g.weekStartsOn)??0,l=k(e,n==null?void 0:n.in);if(!St(l))throw new RangeError("Invalid time value");let o=t.match(pe).map(w=>{const b=w[0];if(b==="p"||b==="P"){const E=ce[b];return E(w,a.formatLong)}return w}).join("").match(ye).map(w=>{if(w==="''")return{isToken:!1,value:"'"};const b=w[0];if(b==="'")return{isToken:!1,value:Se(w)};if(et[b])return{isToken:!0,value:w};if(b.match(ke))throw new RangeError("Format string contains an unescaped latin alphabet character `"+b+"`");return{isToken:!1,value:w}});a.localize.preprocessor&&(o=a.localize.preprocessor(l,o));const u={firstWeekContainsDate:s,weekStartsOn:i,locale:a};return o.map(w=>{if(!w.isToken)return w.value;const b=w.value;(fe(b)||de(b))&&me(b,t,String(e));const E=et[b[0]];return E(l,b,a.localize,u)}).join("")}function Se(e){const t=e.match(we);return t?t[1].replace(be,"'"):e}function Me(e,t){const n=k(e,t==null?void 0:t.in).getDay();return n===0?7:n}function ve(e,t,n="long"){return new Intl.DateTimeFormat("en-US",{hour:"numeric",timeZone:e,timeZoneName:n}).format(t).split(/\s/g).slice(2).join(" ")}const X={},F={};function C(e,t){try{const r=(X[e]||(X[e]=new Intl.DateTimeFormat("en-US",{timeZone:e,timeZoneName:"longOffset"}).format))(t).split("GMT")[1];return r in F?F[r]:st(r,r.split(":"))}catch{if(e in F)return F[e];const n=e==null?void 0:e.match(Te);return n?st(e,n.slice(1)):NaN}}const Te=/([+-]\d\d):?(\d\d)?/;function st(e,t){const n=+(t[0]||0),r=+(t[1]||0),a=+(t[2]||0)/60;return F[e]=n*60+r>0?n*60+r+a:n*60-r-a}class D extends Date{constructor(...t){super(),t.length>1&&typeof t[t.length-1]=="string"&&(this.timeZone=t.pop()),this.internal=new Date,isNaN(C(this.timeZone,this))?this.setTime(NaN):t.length?typeof t[0]=="number"&&(t.length===1||t.length===2&&typeof t[1]!="number")?this.setTime(t[0]):typeof t[0]=="string"?this.setTime(+new Date(t[0])):t[0]instanceof Date?this.setTime(+t[0]):(this.setTime(+new Date(...t)),ft(this),G(this)):this.setTime(Date.now())}static tz(t,...n){return n.length?new D(...n,t):new D(Date.now(),t)}withTimeZone(t){return new D(+this,t)}getTimezoneOffset(){const t=-C(this.timeZone,this);return t>0?Math.floor(t):Math.ceil(t)}setTime(t){return Date.prototype.setTime.apply(this,arguments),G(this),+this}[Symbol.for("constructDateFrom")](t){return new D(+new Date(t),this.timeZone)}}const it=/^(get|set)(?!UTC)/;Object.getOwnPropertyNames(Date.prototype).forEach(e=>{if(!it.test(e))return;const t=e.replace(it,"$1UTC");D.prototype[t]&&(e.startsWith("get")?D.prototype[e]=function(){return this.internal[t]()}:(D.prototype[e]=function(){return Date.prototype[t].apply(this.internal,arguments),xe(this),+this},D.prototype[t]=function(){return Date.prototype[t].apply(this,arguments),G(this),+this}))});function G(e){e.internal.setTime(+e),e.internal.setUTCSeconds(e.internal.getUTCSeconds()-Math.round(-C(e.timeZone,e)*60))}function xe(e){Date.prototype.setFullYear.call(e,e.internal.getUTCFullYear(),e.internal.getUTCMonth(),e.internal.getUTCDate()),Date.prototype.setHours.call(e,e.internal.getUTCHours(),e.internal.getUTCMinutes(),e.internal.getUTCSeconds(),e.internal.getUTCMilliseconds()),ft(e)}function ft(e){const t=C(e.timeZone,e),n=t>0?Math.floor(t):Math.ceil(t),r=new Date(+e);r.setUTCHours(r.getUTCHours()-1);const a=-new Date(+e).getTimezoneOffset(),s=-new Date(+r).getTimezoneOffset(),i=a-s,l=Date.prototype.getHours.apply(e)!==e.internal.getUTCHours();i&&l&&e.internal.setUTCMinutes(e.internal.getUTCMinutes()+i);const o=a-n;o&&Date.prototype.setUTCMinutes.call(e,Date.prototype.getUTCMinutes.call(e)+o);const u=new Date(+e);u.setUTCSeconds(0);const d=a>0?u.getSeconds():(u.getSeconds()-60)%60,m=Math.round(-(C(e.timeZone,e)*60))%60;(m||d)&&(e.internal.setUTCSeconds(e.internal.getUTCSeconds()+m),Date.prototype.setUTCSeconds.call(e,Date.prototype.getUTCSeconds.call(e)+m+d));const p=C(e.timeZone,e),g=p>0?Math.floor(p):Math.ceil(p),b=-new Date(+e).getTimezoneOffset()-g,E=g!==n,V=b-o;if(E&&V){Date.prototype.setUTCMinutes.call(e,Date.prototype.getUTCMinutes.call(e)+V);const U=C(e.timeZone,e),yt=U>0?Math.floor(U):Math.ceil(U),B=g-yt;B&&(e.internal.setUTCMinutes(e.internal.getUTCMinutes()+B),Date.prototype.setUTCMinutes.call(e,Date.prototype.getUTCMinutes.call(e)+B))}}class T extends D{static tz(t,...n){return n.length?new T(...n,t):new T(Date.now(),t)}toISOString(){const[t,n,r]=this.tzComponents(),a=`${t}${n}:${r}`;return this.internal.toISOString().slice(0,-1)+a}toString(){return`${this.toDateString()} ${this.toTimeString()}`}toDateString(){const[t,n,r,a]=this.internal.toUTCString().split(" ");return`${t==null?void 0:t.slice(0,-1)} ${r} ${n} ${a}`}toTimeString(){const t=this.internal.toUTCString().split(" ")[4],[n,r,a]=this.tzComponents();return`${t} GMT${n}${r}${a} (${ve(this.timeZone,this)})`}toLocaleString(t,n){return Date.prototype.toLocaleString.call(this,t,{...n,timeZone:(n==null?void 0:n.timeZone)||this.timeZone})}toLocaleDateString(t,n){return Date.prototype.toLocaleDateString.call(this,t,{...n,timeZone:(n==null?void 0:n.timeZone)||this.timeZone})}toLocaleTimeString(t,n){return Date.prototype.toLocaleTimeString.call(this,t,{...n,timeZone:(n==null?void 0:n.timeZone)||this.timeZone})}tzComponents(){const t=this.getTimezoneOffset(),n=t>0?"-":"+",r=String(Math.floor(Math.abs(t)/60)).padStart(2,"0"),a=String(Math.abs(t)%60).padStart(2,"0");return[n,r,a]}withTimeZone(t){return new T(+this,t)}[Symbol.for("constructDateFrom")](t){return new T(+new Date(t),this.timeZone)}}window.pktTz=window.pktTz===void 0?"Europe/Oslo":window.pktTz;const Oe=(e=window.pktTz)=>{const t=new T(new Date().toISOString(),e);return t.setHours(0,0,0,0),isNaN(t.getTime())?new Date:new Date(t.getFullYear(),t.getMonth(),t.getDate())};function x(e){if(!e||e==="")return new Date;if(/^\d{4}-\d{2}-\d{2}$/.test(e)){const[t,n,r]=e.split("-").map(Number);return new Date(t,n-1,r)}if(/^\d{4}-\d{2}$/.test(e)){const[t,n]=e.split("-").map(Number);return new Date(t,n-1,1)}return/^\d{4}$/.test(e)?new Date(Number(e),0,1):new Date(e)}const y=e=>{if(!e||isNaN(e.getTime()))return"";const t=e.getFullYear(),n=String(e.getMonth()+1).padStart(2,"0"),r=String(e.getDate()).padStart(2,"0");return`${t}-${n}-${r}`},_=e=>{if(!e)return null;const t=x(e);return isNaN(t.getTime())?null:t},Pe=(e,t)=>{const n=N(e);return isNaN(n.getTime())?"":De(n,t)},N=(e="",t)=>{const n=typeof e=="string"?x(e):e;return!n||isNaN(n.getTime())?new Date:n},v=(e,t,n=1)=>{if(typeof e!="number"||typeof t!="number"||typeof n!="number"||isNaN(e)||isNaN(t)||isNaN(n))return new Date;const r=new Date(e,t,n);return isNaN(r.getTime())?new Date:r},A=e=>{let t;return typeof e=="number"?t=new T(e,window.pktTz):t=new T(e,window.pktTz),t.setHours(12,0,0,0),t},Ce=e=>!e||isNaN(e.getTime())?"":new Intl.DateTimeFormat("no",{dateStyle:"full",timeZone:window.pktTz}).format(e),Ne=(e,t,n)=>{if(!e||isNaN(e.getTime()))return!1;const r=t?N(t):null,a=n?N(n):null;return!(r&&e<r||a&&e>a)},$e=(e,t)=>{if(!e||isNaN(e.getTime())||!Array.isArray(t))return!1;const n=y(e);return t.includes(n)},_e=(e,t)=>{if(!e||isNaN(e.getTime())||!Array.isArray(t))return!1;const n=e.getDay().toString();return t.includes(n)},mt=(e,t,n,r,a)=>!(!e||isNaN(e.getTime())||!Ne(e,t,n)||r&&$e(e,r)||a&&_e(e,a)),Ee=(e,t,n,r,a)=>e.filter(s=>{const i=_(s);return i&&mt(i,t,n,r,a)}),We=e=>e.slice().sort((t,n)=>{const r=_(t),a=_(n);return!r||!a?0:r.getTime()-a.getTime()}),Ye=(e,t)=>{const n=_(e),r=_(t);return!n||!r?!1:n<=r},gt=e=>{if(Array.isArray(e))return e;if(typeof e=="string")return e.split(",")},Ae=e=>e?x(e):null,Fe=e=>{if(typeof e=="string")return e.split(",").map(t=>x(t));if(Array.isArray(e))return e.map(t=>x(t))},q={csvToArray:gt,stringToDate:Ae,stringsToDate:Fe},He={earliest:{default:null},latest:{default:null},weeknumbers:{default:!1},withcontrols:{default:!1},multiple:{default:!1},maxMultiple:{default:4},range:{default:!1}},O={props:He};var Ie=Object.defineProperty,qe=Object.getOwnPropertyDescriptor,f=(e,t,n,r)=>{for(var a=r>1?void 0:r?qe(t,n):t,s=e.length-1,i;s>=0;s--)(i=e[s])&&(a=(r?i(t,n,a):i(a))||a);return r&&a&&Ie(t,n,a),a};exports.PktCalendar=class extends c.PktElement{constructor(){super(...arguments),this.multiple=O.props.multiple.default,this.maxMultiple=O.props.maxMultiple.default,this.range=O.props.range.default,this.weeknumbers=O.props.weeknumbers.default,this.withcontrols=O.props.withcontrols.default,this.selected=[],this.earliest=O.props.earliest.default,this.latest=O.props.latest.default,this.excludedates=[],this.excludeweekdays=[],this.currentmonth=null,this.dayStrings=this.strings.dates.daysShort,this.dayStringsLong=this.strings.dates.days,this.monthStrings=this.strings.dates.months,this.weekString=this.strings.dates.week,this.prevMonthString=this.strings.dates.prevMonth,this.nextMonthString=this.strings.dates.nextMonth,this._selected=[],this.year=0,this.month=0,this.week=0,this.rangeHovered=null,this.inRange={},this.focusedDate=null,this.selectableDates=[],this.currentmonthtouched=!1,this.tabIndexSet=0}connectedCallback(){super.connectedCallback()}disconnectedCallback(){this.removeEventListener("keydown",this.handleKeydown),super.disconnectedCallback()}attributeChangedCallback(t,n,r){t==="selected"&&r&&this.convertSelected(),super.attributeChangedCallback(t,n,r)}updated(t){super.updated(t),t.has("selected")&&this.convertSelected()}firstUpdated(t){this.addEventListener("keydown",this.handleKeydown)}convertSelected(){if(typeof this.selected=="string"&&(this.selected=this.selected.split(",")),this.selected.length===1&&this.selected[0]===""&&(this.selected=[]),this._selected=this.selected.map(t=>x(t)),this.range&&this.selected.length===2){const t=z({start:this._selected[0],end:this._selected[1]});if(this.inRange={},Array.isArray(t)&&t.length){const n={};for(let r=0;r<t.length;r++){const a=t[r],s=a>this._selected[0]&&a<this._selected[1];n[y(a)]=s}this.inRange=n}}this.setCurrentMonth()}setCurrentMonth(){if(this.currentmonth===null&&!this.currentmonthtouched&&(this.currentmonthtouched=!0),this.selected.length&&this.selected[0]!==""){const t=x(this.selected[this.selected.length-1]);this.currentmonth=isNaN(t.getTime())?A(new Date):t}else this.currentmonth===null&&(this.currentmonth=A(new Date));(!this.currentmonth||isNaN(this.currentmonth.getTime()))&&(this.currentmonth=A(new Date)),this.year=this.currentmonth.getFullYear(),this.month=this.currentmonth.getMonth()}handleKeydown(t){switch(t.key){case"ArrowLeft":this.handleArrowKey(t,-1);break;case"ArrowRight":this.handleArrowKey(t,1);break;case"ArrowUp":this.handleArrowKey(t,-7);break;case"ArrowDown":this.handleArrowKey(t,7);break}}handleArrowKey(t,n){var s,i,l,o,u;if(((s=t.target)==null?void 0:s.nodeName)==="INPUT"||((i=t.target)==null?void 0:i.nodeName)==="SELECT"||((l=t.target)==null?void 0:l.nodeName)==="BUTTON"&&!((u=(o=t.target)==null?void 0:o.dataset)!=null&&u.date))return;t.preventDefault(),this.focusedDate||this.focusOnCurrentDate();const r=this.focusedDate?N(this.focusedDate):v(this.year,this.month,1);let a=j(r,n);if(a){let d=this.querySelector(`button[data-date="${y(a)}"]`);if(d instanceof HTMLButtonElement){if(d.dataset.disabled){a=j(a,n);let m=this.querySelector(`button[data-date="${y(a)}"]`);for(;m&&m instanceof HTMLButtonElement&&m.dataset.disabled;)a=j(a,n),m=this.querySelector(`button[data-date="${y(a)}"]`);d=m}d instanceof HTMLButtonElement&&!d.dataset.disabled&&(this.focusedDate=y(a),d.focus())}}}render(){return c.x`
2
- <div
3
- class="pkt-calendar ${this.weeknumbers?"pkt-cal-weeknumbers":""}"
4
- @focusout=${this.closeEvent}
5
- @keydown=${t=>{t.key==="Escape"&&(t.preventDefault(),this.close())}}
6
- >
7
- <nav class="pkt-cal-month-nav">
8
- <div>
9
- <button
10
- type="button"
11
- aria-label="${this.prevMonthString}"
12
- @click=${()=>this.isPrevMonthAllowed()&&this.prevMonth()}
13
- @keydown=${t=>{(t.key==="Enter"||t.key===" ")&&(t.preventDefault(),this.isPrevMonthAllowed()&&this.prevMonth())}}
14
- class="pkt-btn pkt-btn--tertiary pkt-btn--small pkt-btn--icon-only pkt-calendar__prev-month ${this.isPrevMonthAllowed()?"":"pkt-hide"}"
15
- .data-disabled=${this.isPrevMonthAllowed()?c.E:"disabled"}
16
- ?aria-disabled=${!this.isPrevMonthAllowed()}
17
- tabindex=${this.isPrevMonthAllowed()?"0":"-1"}
18
- >
19
- <pkt-icon class="pkt-btn__icon" name="chevron-thin-left"></pkt-icon>
20
- <span class="pkt-btn__text">${this.prevMonthString}</span>
21
- </button>
22
- </div>
23
- ${this.renderMonthNav()}
24
- <div>
25
- <button
26
- type="button"
27
- aria-label="${this.nextMonthString}"
28
- @click=${()=>this.isNextMonthAllowed()&&this.nextMonth()}
29
- @keydown=${t=>{(t.key==="Enter"||t.key===" ")&&(t.preventDefault(),this.isNextMonthAllowed()&&this.nextMonth())}}
30
- class="pkt-btn pkt-btn--tertiary pkt-btn--small pkt-btn--icon-only pkt-calendar__next-month ${this.isNextMonthAllowed()?"":"pkt-hide"}"
31
- .data-disabled=${this.isNextMonthAllowed()?c.E:"disabled"}
32
- ?aria-disabled=${!this.isNextMonthAllowed()}
33
- tabindex=${this.isNextMonthAllowed()?"0":"-1"}
34
- >
35
- <pkt-icon class="pkt-btn__icon" name="chevron-thin-right"></pkt-icon>
36
- <span class="pkt-btn__text">${this.nextMonthString}</span>
37
- </button>
38
- </div>
39
- </nav>
40
- <table
41
- class="pkt-cal-days pkt-txt-12-medium pkt-calendar__body"
42
- role="grid"
43
- ?aria-multiselectable=${this.range||this.multiple}
44
- >
45
- <thead>
46
- ${this.renderDayNames()}
47
- </thead>
48
- <tbody>
49
- ${this.renderCalendarBody()}
50
- </tbody>
51
- </table>
52
- </div>
53
- `}renderDayNames(){const t=[];this.weeknumbers&&t.push(c.x`<th><div class="pkt-calendar__week-number">${this.weekString}</div></th>`);for(let n=0;n<this.dayStrings.length;n++)t.push(c.x`<th>
54
- <div class="pkt-calendar__day-name" aria-label="${this.dayStringsLong[n]}">
55
- ${this.dayStrings[n]}
56
- </div>
57
- </th>`);return c.x`<tr class="pkt-cal-week-row">
58
- ${t}
59
- </tr>`}renderMonthNav(){let t=[];return this.withcontrols?t.push(c.x`<div class="pkt-cal-month-picker">
60
- <label for="${this.id}-monthnav" class="pkt-hide">${this.strings.dates.month}</label>
61
- <select
62
- aria-label="${this.strings.dates.month}"
63
- class="pkt-input pkt-input-compact"
64
- id="${this.id}-monthnav"
65
- @change=${n=>{n.stopImmediatePropagation(),this.changeMonth(this.year,n.target.value)}}
66
- >
67
- ${this.monthStrings.map((n,r)=>c.x`<option value=${r} ?selected=${this.month===r}>${n}</option>`)}
68
- </select>
69
- <label for="${this.id}-yearnav" class="pkt-hide">${this.strings.dates.year}</label>
70
- <input
71
- aria-label="${this.strings.dates.year}"
72
- class="pkt-input pkt-cal-input-year pkt-input-compact"
73
- id="${this.id}-yearnav"
74
- type="number"
75
- size="4"
76
- placeholder="0000"
77
- @change=${n=>{n.stopImmediatePropagation(),this.changeMonth(n.target.value,this.month)}}
78
- .value=${this.year}
79
- />
80
- </div> `):t.push(c.x`<div class="pkt-txt-16-medium pkt-calendar__month-title" aria-live="polite">
81
- ${this.monthStrings[this.month]} ${this.year}
82
- </div>`),t}renderDayView(t,n){var p;const r=v(this.year,this.month,t),a=y(r),s=a===y(n),i=this.selected.includes(a),l=Ce(r),o=this.isExcluded(r)||!i&&this.multiple&&this.maxMultiple>0&&this.selected.length>=this.maxMultiple,u=this.focusedDate?this.focusedDate===a&&!o?"0":"-1":!o&&this.tabIndexSet===0||this.tabIndexSet===t?"0":"-1";u==="0"&&(this.tabIndexSet=t),this.selectableDates.push({currentDateISO:a,isDisabled:o,tabindex:u});const d={"pkt-cal-today":s,"pkt-cal-selected":i,"pkt-cal-in-range":this.inRange[a],"pkt-cal-excluded":this.isExcluded(r),"pkt-cal-in-range-first":this.range&&(this.selected.length===2||this.rangeHovered!==null)&&a===this.selected[0],"pkt-cal-in-range-last":this.range&&this.selected.length===2&&a===this.selected[1],"pkt-cal-range-hover":this.rangeHovered!==null&&a===y(this.rangeHovered)},m={"pkt-calendar__date":!0,"pkt-calendar__date--today":s,"pkt-calendar__date--selected":i,"pkt-calendar__date--disabled":o,"pkt-calendar__date--in-range":this.inRange[a],"pkt-calendar__date--in-range-hover":this.rangeHovered!==null&&a===y(this.rangeHovered),"pkt-calendar__date--range-start":this.range&&(this.selected.length===2||this.rangeHovered!==null)&&a===this.selected[0],"pkt-calendar__date--range-end":this.range&&this.selected.length===2&&a===this.selected[1]};return c.x`<td class=${J.e(d)}>
83
- <button
84
- type="button"
85
- aria-pressed=${i?"true":"false"}
86
- ?disabled=${o}
87
- class="pkt-btn pkt-btn--tertiary pkt-btn--small pkt-btn--label-only ${J.e(m)}"
88
- @mouseover=${()=>this.range&&!this.isExcluded(r)&&this.handleRangeHover(r)}
89
- @focus=${()=>{this.range&&!this.isExcluded(r)&&this.handleRangeHover(r),this.focusedDate=a}}
90
- aria-label="${l}"
91
- tabindex=${(p=this.selectableDates.find(g=>g.currentDateISO===a))==null?void 0:p.tabindex}
92
- data-disabled=${o?"disabled":c.E}
93
- data-date=${a}
94
- @keydown=${g=>{(g.key==="Enter"||g.key===" ")&&(g.preventDefault(),this.handleDateSelect(r))}}
95
- @click=${g=>{o||(g.preventDefault(),this.handleDateSelect(r))}}
96
- >
97
- <span class="pkt-btn__text pkt-txt-14-light">${t}</span>
98
- </button>
99
- </td>`}renderCalendarBody(){const t=Oe(),n=v(this.year,this.month,1),r=v(this.year,this.month+1,0),a=(n.getDay()+6)%7,s=r.getDate(),i=Math.ceil((s+a)/7),o=v(this.year,this.month,0).getDate();let u=1;this.week=ht(v(this.year,this.month,1));const d=[];for(let m=0;m<i;m++){const p=[];this.weeknumbers&&p.push(c.x`<td class="pkt-cal-week">${this.week}</td>`),this.week++;for(let g=1;g<8;g++)if(m===0&&g<a+1){const w=o-(a-g);p.push(c.x`<td class="pkt-cal-other">
100
- <div
101
- class="pkt-btn pkt-btn--tertiary pkt-btn--small pkt-btn--label-only"
102
- data-disabled="disabled"
103
- >
104
- <span class="pkt-btn__text pkt-txt-14-light">${w}</span>
105
- </div>
106
- </td>`)}else u>s?(p.push(c.x`<td class="pkt-cal-other">
107
- <div
108
- class="pkt-btn pkt-btn--tertiary pkt-btn--small pkt-btn--label-only"
109
- data-disabled="disabled"
110
- >
111
- <span class="pkt-btn__text pkt-txt-14-light">${u-s}</span>
112
- </div>
113
- </td>`),u++):(p.push(this.renderDayView(u,t)),u++);d.push(c.x`<tr class="pkt-cal-week-row" role="row">
114
- ${p}
115
- </tr>`)}return d}isExcluded(t){const n=this.excludedates.map(r=>typeof r=="string"?r:y(r));return!mt(t,this.earliest,this.latest,n,this.excludeweekdays)}isPrevMonthAllowed(){const t=v(this.year,this.month,0);return!(this.earliest&&N(this.earliest)>t)}prevMonth(){const t=this.month===0?11:this.month-1,n=this.month===0?this.year-1:this.year;this.changeMonth(n,t)}isNextMonthAllowed(){const t=v(this.month===11?this.year+1:this.year,this.month===11?0:this.month+1,1);return!(this.latest&&N(this.latest)<t)}nextMonth(){const t=this.month===11?0:this.month+1,n=this.month===11?this.year+1:this.year;this.changeMonth(n,t)}changeMonth(t,n){this.year=typeof t=="string"?parseInt(t):t,this.month=typeof n=="string"?parseInt(n):n,this.currentmonth=A(new Date(this.year,this.month,1)),this.tabIndexSet=0,this.focusedDate=null,this.selectableDates=[]}isRangeAllowed(t){let n=!0;if(this._selected.length===1){const r=z({start:this._selected[0],end:t});if(Array.isArray(r)&&r.length)for(let a=0;a<r.length;a++)this.excludedates.forEach(s=>{s>this._selected[0]&&s<t&&(n=!1)}),this.excludeweekdays.includes(Me(r[a]).toString())&&(n=!1)}return n}emptySelected(){this.selected=[],this._selected=[],this.inRange={}}addToSelected(t){this.selected.includes(y(t))||(this.selected=[...this.selected,y(t)],this._selected=[...this._selected,t],this.range&&this.selected.length===2&&(this.convertSelected(),this.close()))}removeFromSelected(t){if(this.selected.length===1)this.emptySelected();else{const n=this.selected.indexOf(y(t)),r=[...this.selected],a=[...this._selected];r.splice(n,1),a.splice(n,1),this.selected=r,this._selected=a}}toggleSelected(t){const n=y(t);this.selected.includes(n)?this.removeFromSelected(t):this.maxMultiple&&this.selected.length>=this.maxMultiple||this.addToSelected(t)}handleRangeSelect(t){const n=y(t);return this.selected.includes(n)?this.selected.indexOf(n)===0?this.emptySelected():this.removeFromSelected(t):this.selected.length>1?(this.emptySelected(),this.addToSelected(t)):(this.selected.length===1&&!this.isRangeAllowed(t)&&this.emptySelected(),this.selected.length===1&&this._selected[0]>t&&this.emptySelected(),this.addToSelected(t)),Promise.resolve()}handleRangeHover(t){if(this.range&&this._selected.length===1&&this.isRangeAllowed(t)&&this._selected[0]<t){this.rangeHovered=t,this.inRange={};const n=z({start:this._selected[0],end:t});if(Array.isArray(n)&&n.length)for(let r=0;r<n.length;r++){const a=n[r],s=a>this._selected[0]&&a<t;this.inRange[y(a)]=s}}else this.rangeHovered=null}handleDateSelect(t){if(t)return this.range?this.handleRangeSelect(t):this.multiple?this.toggleSelected(t):(this.selected.includes(y(t))?this.emptySelected():(this.emptySelected(),this.addToSelected(t)),this.close()),this.dispatchEvent(new CustomEvent("date-selected",{detail:this.selected,bubbles:!0,composed:!0})),Promise.resolve()}focusOnCurrentDate(){const t=y(A(new Date)),n=this.querySelector(`button[data-date="${t}"]`);if(n instanceof HTMLButtonElement)this.focusedDate=t,n.focus();else{const r=this.selectableDates.find(a=>!a.isDisabled);if(r){const a=this.querySelector(`button[data-date="${r.currentDateISO}"]`);a instanceof HTMLButtonElement&&(this.focusedDate=r.currentDateISO,a.focus())}}}closeEvent(t){!this.contains(t.relatedTarget)&&!t.target.classList.contains("pkt-hide")&&this.close()}close(){this.dispatchEvent(new CustomEvent("close",{detail:!0,bubbles:!0,composed:!0}))}};f([c.n({type:Boolean})],exports.PktCalendar.prototype,"multiple",2);f([c.n({type:Number})],exports.PktCalendar.prototype,"maxMultiple",2);f([c.n({type:Boolean})],exports.PktCalendar.prototype,"range",2);f([c.n({type:Boolean})],exports.PktCalendar.prototype,"weeknumbers",2);f([c.n({type:Boolean})],exports.PktCalendar.prototype,"withcontrols",2);f([c.n({converter:q.csvToArray})],exports.PktCalendar.prototype,"selected",2);f([c.n({type:String})],exports.PktCalendar.prototype,"earliest",2);f([c.n({type:String})],exports.PktCalendar.prototype,"latest",2);f([c.n({converter:q.stringsToDate})],exports.PktCalendar.prototype,"excludedates",2);f([c.n({converter:q.csvToArray})],exports.PktCalendar.prototype,"excludeweekdays",2);f([c.n({converter:q.stringToDate})],exports.PktCalendar.prototype,"currentmonth",2);f([c.n({type:Array})],exports.PktCalendar.prototype,"dayStrings",2);f([c.n({type:Array})],exports.PktCalendar.prototype,"dayStringsLong",2);f([c.n({type:Array})],exports.PktCalendar.prototype,"monthStrings",2);f([c.n({type:String})],exports.PktCalendar.prototype,"weekString",2);f([c.n({type:String})],exports.PktCalendar.prototype,"prevMonthString",2);f([c.n({type:String})],exports.PktCalendar.prototype,"nextMonthString",2);f([c.n({type:Array})],exports.PktCalendar.prototype,"_selected",2);f([c.n({type:Number})],exports.PktCalendar.prototype,"year",2);f([c.n({type:Number})],exports.PktCalendar.prototype,"month",2);f([c.n({type:Number})],exports.PktCalendar.prototype,"week",2);f([c.n({type:Date})],exports.PktCalendar.prototype,"rangeHovered",2);f([I.r()],exports.PktCalendar.prototype,"inRange",2);f([I.r()],exports.PktCalendar.prototype,"focusedDate",2);f([I.r()],exports.PktCalendar.prototype,"selectableDates",2);f([I.r()],exports.PktCalendar.prototype,"currentmonthtouched",2);f([I.r()],exports.PktCalendar.prototype,"tabIndexSet",2);exports.PktCalendar=f([c.t("pkt-calendar")],exports.PktCalendar);exports.converters=q;exports.csvToArray=gt;exports.filterSelectableDates=Ee;exports.formatISODate=y;exports.fromISOToDate=_;exports.fromISOtoLocal=Pe;exports.isValidDateRange=Ye;exports.newDate=N;exports.parseISODateString=x;exports.sortDateStrings=We;
@@ -1,31 +0,0 @@
1
- "use strict";const e=require("./element-CJ_QKaki.cjs"),r=require("./input-element-j9znzLWz.cjs"),o=require("./ref-BFa5Utho.cjs"),n=require("./class-map-C_erArZz.cjs");var k=Object.defineProperty,u=Object.getOwnPropertyDescriptor,i=(p,t,h,a)=>{for(var s=a>1?void 0:a?u(t,h):t,c=p.length-1,l;c>=0;c--)(l=p[c])&&(s=(a?l(t,h,s):l(s))||s);return a&&s&&k(t,h,s),s};exports.PktCheckbox=class extends r.PktInputElement{constructor(){super(...arguments),this.inputRef=o.e(),this.value="",this.checkHelptext=null,this.defaultChecked=!1,this.hasTile=!1,this.isSwitch=!1,this.labelPosition="right",this.hideLabel=!1,this.checked=null,this.type="checkbox",this.tagText=null,this.optionalTag=!1,this.optionalText="Valgfritt",this.requiredTag=!1,this.requiredText="Må fylles ut"}connectedCallback(){super.connectedCallback()}attributeChangedCallback(t,h,a){t==="defaultChecked"&&!this.checked&&(this.checked=this.defaultChecked),t==="checked"&&(this.checked=this.checked===""||this.checked==="true"||this.checked===!0),super.attributeChangedCallback(t,h,a)}firstUpdated(t){t.has("defaultChecked")&&!this.checked&&(this.checked=this.defaultChecked),super.firstUpdated(t)}updated(t){t.has("defaultChecked")&&!this.checked&&(this.checked=this.defaultChecked),super.updated(t)}render(){const t=n.e({"pkt-input-check__input":!0,"pkt-input-check__input--tile":this.hasTile,"pkt-input-check__input--tile-disabled":this.disabled&&this.hasTile}),h=n.e({"pkt-input-check__input-checkbox":!0,"pkt-input-check__input-checkbox--error":this.hasError}),a=n.e({"pkt-input-check__input-label":!0,"pkt-input-check__input-label--disabled":this.disabled,"pkt-input-check__input-label--left":this.labelPosition==="left","pkt-input-check__input-label--right":this.labelPosition==="right","pkt-sr-only":this.hideLabel}),s="pkt-tag pkt-tag--small pkt-tag--thin-text",c=()=>e.x`
2
- ${this.tagText?e.x`<span class=${s+" pkt-tag--gray"}>${this.tagText}</span>`:e.E}
3
- ${this.optionalTag?e.x`<span class=${s+" pkt-tag--blue-light"}>${this.optionalText}</span>`:e.E}
4
- ${this.requiredTag?e.x`<span class=${s+" pkt-tag--beige"}>${this.requiredText}</span>`:e.E}
5
- `,l=()=>e.x`
6
- <label class=${a} for=${this.id+"-internal"}>
7
- ${this.label} ${c()}
8
- ${this.checkHelptext?e.x`<div class="pkt-input-check__input-helptext">${this.checkHelptext}</div>`:e.E}
9
- </label>
10
- `;return e.x`
11
- <div class="pkt-input-check">
12
- <div class=${t}>
13
- ${this.labelPosition==="left"?l():e.E}
14
- <input
15
- id=${this.id+"-internal"}
16
- class=${h}
17
- type="checkbox"
18
- ?disabled=${this.disabled}
19
- name=${this.name+"-internal"}
20
- ${o.n(this.inputRef)}
21
- @change=${this.handleChange}
22
- @click=${this.handleClick}
23
- @blur=${this.onBlur}
24
- @focus=${this.onFocus}
25
- ?checked=${this.checked}
26
- role=${this.isSwitch?"switch":"checkbox"}
27
- />
28
- ${this.labelPosition==="right"?l():e.E}
29
- </div>
30
- </div>
31
- `}handleClick(t){if(this.disabled)return t.preventDefault(),t.stopImmediatePropagation(),!1}handleChange(t){if(this.disabled)return t.preventDefault(),t.stopImmediatePropagation(),!1;this.toggleChecked(t)}toggleChecked(t){if(this.disabled){t.preventDefault(),t.stopImmediatePropagation();return}const h=t.target;if(h&&h.disabled){t.preventDefault(),t.stopImmediatePropagation();return}t.stopImmediatePropagation(),this.touched=!0,this.inputRef.value&&(this.checked=this.inputRef.value.matches(":checked"),this.valueChecked(this.checked))}};i([e.n({type:String,reflect:!0})],exports.PktCheckbox.prototype,"value",2);i([e.n({type:String})],exports.PktCheckbox.prototype,"checkHelptext",2);i([e.n({type:Boolean})],exports.PktCheckbox.prototype,"defaultChecked",2);i([e.n({type:Boolean})],exports.PktCheckbox.prototype,"hasTile",2);i([e.n({type:Boolean})],exports.PktCheckbox.prototype,"isSwitch",2);i([e.n({type:String})],exports.PktCheckbox.prototype,"labelPosition",2);i([e.n({type:Boolean})],exports.PktCheckbox.prototype,"hideLabel",2);i([e.n({type:Boolean,reflect:!0})],exports.PktCheckbox.prototype,"checked",2);i([e.n({type:String,reflect:!0})],exports.PktCheckbox.prototype,"type",2);i([e.n({type:String})],exports.PktCheckbox.prototype,"tagText",2);i([e.n({type:Boolean})],exports.PktCheckbox.prototype,"optionalTag",2);i([e.n({type:String})],exports.PktCheckbox.prototype,"optionalText",2);i([e.n({type:Boolean})],exports.PktCheckbox.prototype,"requiredTag",2);i([e.n({type:String})],exports.PktCheckbox.prototype,"requiredText",2);exports.PktCheckbox=i([e.t("pkt-checkbox")],exports.PktCheckbox);