@lekoala/date-picker 0.2.0 → 0.3.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.
- package/README.md +6 -4
- package/custom-elements.json +12 -2
- package/dist/date-picker.css +153 -105
- package/dist/date-picker.js +166 -78
- package/dist/date-picker.min.css +1 -1
- package/dist/date-picker.min.js +13 -13
- package/dist/date-picker.standalone.min.js +167 -119
- package/dist/types/date-calendar.d.ts.map +1 -1
- package/dist/types/date-field.d.ts +3 -1
- package/dist/types/date-field.d.ts.map +1 -1
- package/dist/types/date-picker.d.ts +62 -5
- package/dist/types/date-picker.d.ts.map +1 -1
- package/docs/ACCESSIBILITY.md +17 -9
- package/docs/API.md +21 -2
- package/docs/ARCHITECTURE.md +16 -2
- package/docs/AT-CHECKLIST.md +1 -1
- package/docs/DECISIONS.md +2 -0
- package/docs/MIGRATION-FLATPICKR.md +1 -1
- package/package.json +4 -4
- package/src/date-calendar.js +3 -6
- package/src/date-field.js +12 -4
- package/src/date-picker.css +153 -105
- package/src/date-picker.js +206 -75
|
@@ -1,18 +1,19 @@
|
|
|
1
|
-
/*** @lekoala/date-picker v0.
|
|
2
|
-
(()=>{var
|
|
3
|
-
--dp-bg:
|
|
4
|
-
--dp-fg:
|
|
5
|
-
--dp-muted: color-mix(in srgb,
|
|
6
|
-
--dp-border: color-mix(in srgb,
|
|
7
|
-
--dp-hover: color-mix(in srgb,
|
|
8
|
-
--dp-accent:
|
|
9
|
-
--dp-accent-fg:
|
|
1
|
+
/*** @lekoala/date-picker v0.3.0 - https://github.com/lekoala/date-picker ***/
|
|
2
|
+
(()=>{var ge=`:where(date-calendar, date-picker) {
|
|
3
|
+
--dp-bg: #ffffff;
|
|
4
|
+
--dp-fg: #1f2328;
|
|
5
|
+
--dp-muted: color-mix(in srgb, var(--dp-fg) 58%, var(--dp-bg));
|
|
6
|
+
--dp-border: color-mix(in srgb, var(--dp-fg) 16%, var(--dp-bg));
|
|
7
|
+
--dp-hover: color-mix(in srgb, var(--dp-fg) 5%, var(--dp-bg));
|
|
8
|
+
--dp-accent: #2563eb;
|
|
9
|
+
--dp-accent-fg: #fff;
|
|
10
10
|
--dp-radius: 0.5rem;
|
|
11
11
|
--dp-day-size: 2.75rem;
|
|
12
|
-
--dp-gap: 0.
|
|
12
|
+
--dp-gap: 0.375rem;
|
|
13
13
|
--dp-header-control-size: 2.25rem;
|
|
14
|
-
--dp-header-block-gap: 0.
|
|
15
|
-
--dp-
|
|
14
|
+
--dp-header-block-gap: 0.75rem;
|
|
15
|
+
--dp-row-gap: 0.375rem;
|
|
16
|
+
--dp-picker-button-size: 2.5rem;
|
|
16
17
|
--dp-year-inline-size: 5.5rem;
|
|
17
18
|
--dp-day-radius: calc(var(--dp-radius) * 0.75);
|
|
18
19
|
color: var(--dp-fg);
|
|
@@ -49,6 +50,9 @@ date-calendar {
|
|
|
49
50
|
--dp-header-control-size, the row grows to the tallest control and the
|
|
50
51
|
others stretch to match, so month/year/nav stay equal. */
|
|
51
52
|
align-items: stretch;
|
|
53
|
+
/* Uniform horizontal rhythm: the four header controls are self-evident from
|
|
54
|
+
their kind and position, so no group gets an extra semantic gap. The air
|
|
55
|
+
belongs to the vertical zones (header -> weekdays -> dates). */
|
|
52
56
|
gap: var(--dp-gap);
|
|
53
57
|
margin-block-end: var(--dp-header-block-gap);
|
|
54
58
|
}
|
|
@@ -60,10 +64,6 @@ date-calendar[data-year-first] .dp-calendar-header {
|
|
|
60
64
|
grid-template-columns: auto minmax(0, 1fr) auto auto;
|
|
61
65
|
}
|
|
62
66
|
|
|
63
|
-
.dp-calendar-header .dp-prev {
|
|
64
|
-
margin-inline-start: var(--dp-nav-gap);
|
|
65
|
-
}
|
|
66
|
-
|
|
67
67
|
.dp-calendar-header :where(button, select, input) {
|
|
68
68
|
min-block-size: var(--dp-header-control-size);
|
|
69
69
|
box-sizing: border-box;
|
|
@@ -79,26 +79,42 @@ date-calendar[data-year-first] .dp-calendar-header {
|
|
|
79
79
|
line-height: 1.2;
|
|
80
80
|
}
|
|
81
81
|
|
|
82
|
-
/* The select menulist carries UA-internal leading that author padding only
|
|
83
|
-
adds to (and it ignores line-height), so it gets zero author padding.
|
|
84
|
-
Equal outer heights come from the header grid's stretch alignment: the row
|
|
85
|
-
sizes to the tallest control and the others stretch to match. */
|
|
86
|
-
.dp-calendar-header select {
|
|
87
|
-
padding-block: 0;
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
.dp-calendar-header select,
|
|
91
82
|
.dp-calendar-header input {
|
|
92
83
|
min-inline-size: 0;
|
|
93
84
|
padding-inline: 0.45rem;
|
|
94
85
|
}
|
|
95
86
|
|
|
87
|
+
/* Author-drawn caret so the month select matches the nav controls without a
|
|
88
|
+
hardcoded SVG color (currentColor keeps theming). Equal outer heights come
|
|
89
|
+
from the header grid's stretch alignment: the row sizes to the tallest
|
|
90
|
+
control and the others stretch to match. */
|
|
96
91
|
.dp-month-select {
|
|
97
92
|
inline-size: 100%;
|
|
93
|
+
min-inline-size: 0;
|
|
98
94
|
/* Long month names in a narrow track (compact consumers, long locales)
|
|
99
|
-
would paint under the
|
|
95
|
+
would paint under the caret: truncate with an ellipsis instead. */
|
|
100
96
|
overflow: hidden;
|
|
101
97
|
text-overflow: ellipsis;
|
|
98
|
+
appearance: none;
|
|
99
|
+
padding-inline: 0.45rem 2rem;
|
|
100
|
+
background-image:
|
|
101
|
+
linear-gradient(45deg, transparent 50%, currentColor 50%),
|
|
102
|
+
linear-gradient(135deg, currentColor 50%, transparent 50%);
|
|
103
|
+
background-position:
|
|
104
|
+
calc(100% - 0.9rem) 50%,
|
|
105
|
+
calc(100% - 0.65rem) 50%;
|
|
106
|
+
background-size: 0.3rem 0.3rem;
|
|
107
|
+
background-repeat: no-repeat;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/* Inherited RTL mirrors the header layout via the grid. The logical
|
|
111
|
+
\`padding-inline\` already flips, so only the physically-positioned caret has
|
|
112
|
+
to follow it to the other side. */
|
|
113
|
+
[dir="rtl"] .dp-month-select,
|
|
114
|
+
html[dir="rtl"] .dp-month-select {
|
|
115
|
+
background-position:
|
|
116
|
+
0.9rem 50%,
|
|
117
|
+
0.65rem 50%;
|
|
102
118
|
}
|
|
103
119
|
|
|
104
120
|
.dp-year-input {
|
|
@@ -140,6 +156,14 @@ html[dir="rtl"] .dp-nav svg {
|
|
|
140
156
|
background: var(--dp-hover);
|
|
141
157
|
}
|
|
142
158
|
|
|
159
|
+
/* Shared control focus: accent border + light halo. Day cells keep their
|
|
160
|
+
dedicated outline ring below; the picker trigger has its own inner ring. */
|
|
161
|
+
.dp-calendar-header :where(button, select, input):focus-visible {
|
|
162
|
+
outline: none;
|
|
163
|
+
border-color: var(--dp-accent);
|
|
164
|
+
box-shadow: 0 0 0 3px color-mix(in srgb, var(--dp-accent) 22%, transparent);
|
|
165
|
+
}
|
|
166
|
+
|
|
143
167
|
.dp-day:hover:not([data-disabled="true"]):not([data-selected="true"]):not([data-range-start="true"]):not(
|
|
144
168
|
[data-range-end="true"]
|
|
145
169
|
) {
|
|
@@ -152,8 +176,8 @@ html[dir="rtl"] .dp-nav svg {
|
|
|
152
176
|
|
|
153
177
|
.dp-grid {
|
|
154
178
|
border-collapse: separate;
|
|
155
|
-
/* --dp-gap scopes to the header grid;
|
|
156
|
-
border-spacing: 0
|
|
179
|
+
/* --dp-gap scopes to the header grid; vertical week rhythm is --dp-row-gap. */
|
|
180
|
+
border-spacing: 0 var(--dp-row-gap);
|
|
157
181
|
table-layout: fixed;
|
|
158
182
|
}
|
|
159
183
|
|
|
@@ -166,10 +190,10 @@ html[dir="rtl"] .dp-nav svg {
|
|
|
166
190
|
}
|
|
167
191
|
|
|
168
192
|
.dp-grid thead th {
|
|
169
|
-
block-size: 1.
|
|
193
|
+
block-size: 1.5rem;
|
|
170
194
|
color: var(--dp-muted);
|
|
171
195
|
font-size: 0.72rem;
|
|
172
|
-
font-weight:
|
|
196
|
+
font-weight: 500;
|
|
173
197
|
}
|
|
174
198
|
|
|
175
199
|
.dp-day {
|
|
@@ -182,14 +206,18 @@ html[dir="rtl"] .dp-nav svg {
|
|
|
182
206
|
font-size: 0.875rem;
|
|
183
207
|
}
|
|
184
208
|
|
|
209
|
+
/* Inner ring: keyboard focus stays inside the cell instead of reading as a
|
|
210
|
+
second selected state or bleeding onto a neighbouring range band. It is an
|
|
211
|
+
\`outline\` (not an inset box-shadow) because forced colors computes
|
|
212
|
+
box-shadow to \`none\`, which would erase the keyboard indicator entirely. */
|
|
185
213
|
.dp-day:focus-visible {
|
|
186
214
|
outline: 2px solid var(--dp-accent);
|
|
187
|
-
outline-offset: 2px;
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
215
|
+
outline-offset: -2px;
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
/* On an accent-filled cell the ring inverts so it stays readable. */
|
|
219
|
+
.dp-day:is([data-selected="true"], [data-range-start="true"], [data-range-end="true"]):focus-visible {
|
|
220
|
+
outline-color: var(--dp-accent-fg);
|
|
193
221
|
}
|
|
194
222
|
|
|
195
223
|
/* Base tint for days outside the displayed month. It stays before the
|
|
@@ -204,7 +232,10 @@ html[dir="rtl"] .dp-nav svg {
|
|
|
204
232
|
color: var(--dp-accent-fg);
|
|
205
233
|
}
|
|
206
234
|
|
|
207
|
-
|
|
235
|
+
/* Today never competes with a stronger state: a selected day or a range
|
|
236
|
+
endpoint keeps its own treatment, in normal rendering and in
|
|
237
|
+
forced-colors alike. */
|
|
238
|
+
.dp-day[data-today="true"]:not([data-selected="true"], [data-range-start="true"], [data-range-end="true"]) {
|
|
208
239
|
border-color: var(--dp-accent);
|
|
209
240
|
}
|
|
210
241
|
|
|
@@ -236,13 +267,13 @@ html[dir="rtl"] .dp-nav svg {
|
|
|
236
267
|
}
|
|
237
268
|
|
|
238
269
|
.dp-day[data-in-range="true"]:first-of-type {
|
|
239
|
-
border-start-start-radius: var(--dp-radius);
|
|
240
|
-
border-end-start-radius: var(--dp-radius);
|
|
270
|
+
border-start-start-radius: var(--dp-day-radius);
|
|
271
|
+
border-end-start-radius: var(--dp-day-radius);
|
|
241
272
|
}
|
|
242
273
|
|
|
243
274
|
.dp-day[data-in-range="true"]:last-of-type {
|
|
244
|
-
border-start-end-radius: var(--dp-radius);
|
|
245
|
-
border-end-end-radius: var(--dp-radius);
|
|
275
|
+
border-start-end-radius: var(--dp-day-radius);
|
|
276
|
+
border-end-end-radius: var(--dp-day-radius);
|
|
246
277
|
}
|
|
247
278
|
|
|
248
279
|
.dp-day-number {
|
|
@@ -285,97 +316,125 @@ html[dir="rtl"] .dp-nav svg {
|
|
|
285
316
|
date-picker {
|
|
286
317
|
position: relative;
|
|
287
318
|
display: inline-grid;
|
|
288
|
-
grid-template-columns: minmax(0, 1fr)
|
|
319
|
+
grid-template-columns: minmax(0, 1fr);
|
|
289
320
|
align-items: stretch;
|
|
290
321
|
max-inline-size: 100%;
|
|
291
322
|
}
|
|
292
323
|
|
|
324
|
+
/* Visible focus is normalized to --dp-accent so the component holds together
|
|
325
|
+
without a consumer stylesheet; the field's own look stays consumer-owned. */
|
|
326
|
+
date-picker > input:not([type="hidden"]):focus-visible {
|
|
327
|
+
border-color: var(--dp-accent);
|
|
328
|
+
outline: none;
|
|
329
|
+
box-shadow: 0 0 0 3px color-mix(in srgb, var(--dp-accent) 20%, transparent);
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
/* Every authored control is a grid item. */
|
|
293
333
|
date-picker > input:not([type="hidden"]) {
|
|
334
|
+
min-inline-size: 0;
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
/* Date fields reserve room for the trigger, which is painted inside the
|
|
338
|
+
field's own box: the field is the real outer box, so its focus ring wraps
|
|
339
|
+
the affordance too. \`grid-row\` must stay explicit, otherwise the trigger
|
|
340
|
+
(placed with a definite row) claims the row and pushes the field down. */
|
|
341
|
+
date-picker > input:not([type="hidden"]):not([type="time"]) {
|
|
342
|
+
grid-column: 1;
|
|
343
|
+
grid-row: 1;
|
|
344
|
+
box-sizing: border-box;
|
|
345
|
+
inline-size: 100%;
|
|
346
|
+
padding-inline-end: calc(var(--dp-picker-button-size) + 0.5rem);
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
/* The trigger is a real button overlaid on the field's inline-end, like the
|
|
350
|
+
native \`input[type=time]\` indicator: no chrome of its own, transparent, so
|
|
351
|
+
the authored field background and border stay visible underneath. */
|
|
352
|
+
.dp-picker-button {
|
|
353
|
+
display: grid;
|
|
354
|
+
place-items: center;
|
|
294
355
|
grid-column: 1;
|
|
356
|
+
grid-row: 1;
|
|
357
|
+
justify-self: end;
|
|
358
|
+
align-self: stretch;
|
|
359
|
+
inline-size: var(--dp-picker-button-size);
|
|
295
360
|
min-inline-size: 0;
|
|
361
|
+
border: 0;
|
|
362
|
+
background: transparent;
|
|
363
|
+
color: var(--dp-fg);
|
|
364
|
+
font: inherit;
|
|
365
|
+
cursor: pointer;
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
/* Like the native time indicator: the ring wraps the icon, not the field (the
|
|
369
|
+
field already shows its own ring through :focus-visible). Same radius as
|
|
370
|
+
everywhere else: no bespoke shape. */
|
|
371
|
+
.dp-picker-button:focus-visible {
|
|
372
|
+
outline: 2px solid var(--dp-accent);
|
|
373
|
+
outline-offset: -5px;
|
|
374
|
+
border-radius: var(--dp-radius);
|
|
296
375
|
}
|
|
297
376
|
|
|
298
377
|
/* Optional native time companions share the date row; authored inputs stay
|
|
299
378
|
consumer-styled, the picker only reserves their grid cells. Time tracks are
|
|
300
|
-
flexible (never \`auto\`) so a wide UA time control cannot squeeze the date.
|
|
379
|
+
flexible (never \`auto\`) so a wide UA time control cannot squeeze the date.
|
|
380
|
+
Each companion keeps its own box and its own gap: nothing is joined, so
|
|
381
|
+
focus rings never merge and no neighbour swallows another's focus. */
|
|
301
382
|
date-picker:has(> [data-time-start], > [data-time-end]) {
|
|
302
|
-
grid-template-columns: minmax(0, 1fr)
|
|
383
|
+
grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
|
|
384
|
+
column-gap: var(--dp-gap);
|
|
303
385
|
}
|
|
304
386
|
|
|
305
387
|
date-picker:has(> [data-time-start]):has(> [data-time-end]) {
|
|
306
|
-
grid-template-columns: minmax(0, 1fr)
|
|
388
|
+
grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1fr);
|
|
307
389
|
}
|
|
308
390
|
|
|
309
391
|
date-picker > input[data-time-start] {
|
|
310
|
-
grid-column:
|
|
392
|
+
grid-column: 2;
|
|
311
393
|
grid-row: 1;
|
|
312
394
|
min-inline-size: 0;
|
|
313
|
-
inline-size: 100%;
|
|
314
|
-
margin-inline-start: var(--dp-gap);
|
|
315
395
|
}
|
|
316
396
|
|
|
317
397
|
date-picker > input[data-time-end] {
|
|
318
|
-
grid-column:
|
|
398
|
+
grid-column: 3;
|
|
319
399
|
grid-row: 1;
|
|
320
400
|
min-inline-size: 0;
|
|
321
|
-
inline-size: 100%;
|
|
322
|
-
}
|
|
323
|
-
|
|
324
|
-
/* From/to read as one joined control: square the inner corners, but only
|
|
325
|
-
when both companions are present so a lone time keeps its own radius. */
|
|
326
|
-
date-picker:has(> [data-time-start]):has(> [data-time-end]) > input[data-time-start] {
|
|
327
|
-
border-start-end-radius: 0;
|
|
328
|
-
border-end-end-radius: 0;
|
|
329
401
|
}
|
|
330
402
|
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
date-picker[range] > input:not([type="hidden"]) {
|
|
337
|
-
grid-column: 1;
|
|
403
|
+
/* Range: two stacked fields, each owning its trigger, sharing one popup and
|
|
404
|
+
one calendar. No trigger spans both bounds, so each bound keeps a local
|
|
405
|
+
affordance and a local focus target. */
|
|
406
|
+
date-picker[range] {
|
|
407
|
+
row-gap: var(--dp-gap);
|
|
338
408
|
}
|
|
339
409
|
|
|
340
410
|
date-picker[range] > input[data-range-start] {
|
|
341
411
|
grid-row: 1;
|
|
342
|
-
border-end-start-radius: 0;
|
|
343
412
|
}
|
|
344
413
|
|
|
345
414
|
date-picker[range] > input[data-range-end] {
|
|
346
415
|
grid-row: 2;
|
|
347
|
-
border-start-start-radius: 0;
|
|
348
416
|
}
|
|
349
417
|
|
|
350
|
-
.dp-picker-button {
|
|
351
|
-
grid-
|
|
352
|
-
min-inline-size: 2.5rem;
|
|
353
|
-
border: 1px solid var(--dp-border);
|
|
354
|
-
border-inline-start: 0;
|
|
355
|
-
border-start-start-radius: 0;
|
|
356
|
-
border-end-start-radius: 0;
|
|
357
|
-
border-start-end-radius: var(--dp-radius);
|
|
358
|
-
border-end-end-radius: var(--dp-radius);
|
|
359
|
-
background: var(--dp-bg);
|
|
360
|
-
color: var(--dp-fg);
|
|
361
|
-
font: inherit;
|
|
362
|
-
cursor: pointer;
|
|
418
|
+
date-picker[range] > .dp-picker-button[data-endpoint="start"] {
|
|
419
|
+
grid-row: 1;
|
|
363
420
|
}
|
|
364
421
|
|
|
365
|
-
date-picker[range] > .dp-picker-button {
|
|
366
|
-
grid-row:
|
|
422
|
+
date-picker[range] > .dp-picker-button[data-endpoint="end"] {
|
|
423
|
+
grid-row: 2;
|
|
367
424
|
}
|
|
368
425
|
|
|
369
426
|
.dp-picker-panel[popover] {
|
|
427
|
+
/* Safe baseline. show() switches to absolute only when the consumer
|
|
428
|
+
* explicitly selects document coordinate space. */
|
|
370
429
|
position: fixed;
|
|
371
430
|
inset: auto;
|
|
372
431
|
margin: 0;
|
|
373
|
-
padding: 0.
|
|
432
|
+
padding: 0.875rem 1rem;
|
|
374
433
|
border: 1px solid var(--dp-border);
|
|
375
434
|
border-radius: var(--dp-radius);
|
|
376
435
|
background: var(--dp-bg);
|
|
377
436
|
color: var(--dp-fg);
|
|
378
|
-
box-shadow: 0 0.5rem 1.5rem rgb(
|
|
437
|
+
box-shadow: 0 0.5rem 1.5rem rgb(15 23 42 / 0.12);
|
|
379
438
|
max-block-size: var(--available-height, 90svh);
|
|
380
439
|
max-inline-size: calc(100vi - 1rem);
|
|
381
440
|
overflow: auto;
|
|
@@ -386,19 +445,22 @@ date-picker[range] > .dp-picker-button {
|
|
|
386
445
|
}
|
|
387
446
|
|
|
388
447
|
@media (forced-colors: active) {
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
448
|
+
/* The author-drawn caret is a gradient and disappears here: hand the
|
|
449
|
+
control back to the browser instead of trying to rebuild it. */
|
|
450
|
+
.dp-month-select,
|
|
451
|
+
[dir="rtl"] .dp-month-select {
|
|
452
|
+
appearance: auto;
|
|
453
|
+
background-image: none;
|
|
454
|
+
padding-inline: 0.45rem;
|
|
394
455
|
}
|
|
395
456
|
|
|
396
|
-
|
|
397
|
-
|
|
457
|
+
/* Fills vanish here, so selection and endpoints fall back to a 2px
|
|
458
|
+
Highlight border. The in-range underline is the only band marker left:
|
|
459
|
+
the range fill is lost and the browser does not know the semantics. */
|
|
460
|
+
.dp-day:is([data-selected="true"], [data-range-start="true"], [data-range-end="true"]) {
|
|
398
461
|
border: 2px solid Highlight;
|
|
399
462
|
background-color: Canvas;
|
|
400
463
|
color: CanvasText;
|
|
401
|
-
font-weight: 700;
|
|
402
464
|
}
|
|
403
465
|
|
|
404
466
|
.dp-day[data-in-range="true"] {
|
|
@@ -414,15 +476,8 @@ date-picker[range] > .dp-picker-button {
|
|
|
414
476
|
background-color: Highlight;
|
|
415
477
|
}
|
|
416
478
|
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
position: absolute;
|
|
420
|
-
inset: 3px;
|
|
421
|
-
border: 1px solid CanvasText;
|
|
422
|
-
border-radius: calc(var(--dp-radius) * 0.5);
|
|
423
|
-
pointer-events: none;
|
|
424
|
-
}
|
|
425
|
-
|
|
479
|
+
/* Pin the today marker: the deterministic accent is a non-system color
|
|
480
|
+
and would otherwise remap unpredictably here. */
|
|
426
481
|
.dp-day[data-today="true"] {
|
|
427
482
|
border-color: Highlight;
|
|
428
483
|
}
|
|
@@ -431,27 +486,20 @@ date-picker[range] > .dp-picker-button {
|
|
|
431
486
|
color: CanvasText;
|
|
432
487
|
forced-color-adjust: none;
|
|
433
488
|
}
|
|
434
|
-
|
|
435
|
-
.dp-day[data-disabled="true"],
|
|
436
|
-
.dp-calendar-header :where(button, select, input):disabled,
|
|
437
|
-
.dp-picker-button:disabled {
|
|
438
|
-
opacity: 1;
|
|
439
|
-
color: GrayText;
|
|
440
|
-
}
|
|
441
489
|
}
|
|
442
|
-
`;var Ue=/^(\d{4})-(\d{2})-(\d{2})$/,Ye=/^(\d{4})-(\d{2})$/;function We(e){return e%4===0&&(e%100!==0||e%400===0)}function X(e,t){if(t===2)return We(e)?29:28;return[4,6,9,11].includes(t)?30:31}function I(e){let t=Ue.exec(String(e||""));if(!t)return null;let i=Number(t[1]),s=Number(t[2]),n=Number(t[3]);if(i<1||i>9999||s<1||s>12)return null;if(n<1||n>X(i,s))return null;return{year:i,month:s,day:n}}function c(e){return I(e)!==null}function f(e){let t=String(e||""),i=Ye.exec(t);if(i){let n=Number(i[2]);if(n>=1&&n<=12)return`${i[1]}-${String(n).padStart(2,"0")}`}let s=I(t);if(!s)throw TypeError(`Invalid civil date/month: ${e}`);return`${String(s.year).padStart(4,"0")}-${String(s.month).padStart(2,"0")}`}function P(e,t,i){let s=`${String(e).padStart(4,"0")}-${String(t).padStart(2,"0")}-${String(i).padStart(2,"0")}`;if(!c(s))throw TypeError(`Invalid civil date: ${s}`);return s}function J(e){let t=new Date(0);return t.setUTCHours(12,0,0,0),t.setUTCFullYear(e.year,e.month-1,e.day),t}function qe(e){return P(e.getUTCFullYear(),e.getUTCMonth()+1,e.getUTCDate())}function V(e){let t=I(e);if(!t)throw TypeError(`Invalid civil date: ${e}`);return J(t)}function D(e,t){if(!c(e)||!c(t))throw TypeError("compareDates() expects YYYY-MM-DD values");return e===t?0:e<t?-1:1}function F(e,t){let i=I(e);if(!i||!Number.isInteger(t))throw TypeError("addDays() expects a date and integer amount");let s=J(i);return s.setUTCDate(s.getUTCDate()+t),qe(s)}function Q(e,t){let i=I(e);if(!i||!Number.isInteger(t))throw TypeError("addMonths() expects a date and integer amount");let s=i.year*12+(i.month-1)+t,n=Math.floor(s/12),a=(s%12+12)%12+1,o=Math.min(i.day,X(n,a));return P(n,a,o)}function pe(e,t){let i=I(e);if(!i||!Number.isInteger(t))throw TypeError("addYears() expects a date and integer amount");let s=i.year+t,n=Math.min(i.day,X(s,i.month));return P(s,i.month,n)}function B(e,t){let i=`${f(e)}-01`;return f(Q(i,t))}function je(e){return`${f(e)}-01`}function Ke(e){let t=I(`${f(e)}-01`);if(!t)throw TypeError(`Invalid month: ${e}`);return P(t.year,t.month,X(t.year,t.month))}function Ge(e){let t=I(e);if(!t)throw TypeError(`Invalid civil date: ${e}`);return J(t).getUTCDay()}function j(e){if(e===7)return 0;if(!Number.isInteger(e)||e<0||e>6)throw RangeError("firstDay must be 0..6 (Sunday=0, 7 accepted as Sunday alias)");return e}function ee(e,t=1){let i=(Ge(e)-j(t)+7)%7;return F(e,-i)}function ie(e,t=1){return F(ee(e,t),6)}function me(e,t={}){let i=t.firstDay??1,s=ee(je(e),i),n=ie(Ke(e),i),r=[],a=s;while(D(a,n)<=0){let o=[];for(let l=0;l<7;l++)o.push(F(a,l));r.push(o),a=F(a,7)}return r}function ge(e,t="",i=""){if(!c(e))throw TypeError(`Invalid civil date: ${e}`);if(t&&D(e,t)<0)return t;if(i&&D(e,i)>0)return i;return e}function L(){let e=new Date;return P(e.getFullYear(),e.getMonth()+1,e.getDate())}function _e(e){let t=I(e);if(!t)throw TypeError(`Invalid civil date: ${e}`);let i=J(t),s=i.getUTCDay()||7;i.setUTCDate(i.getUTCDate()+4-s);let n=new Date(0);return n.setUTCHours(12,0,0,0),n.setUTCFullYear(i.getUTCFullYear(),0,1),Math.ceil(((i.getTime()-n.getTime())/86400000+1)/7)}class se{constructor(e={}){let t=L();this.firstDay=j(e.firstDay??1),this.value=e.value&&c(e.value)?e.value:"",this.focused=e.focused&&c(e.focused)?e.focused:this.value||t,this.display=e.display?f(e.display):f(this.focused)}setValue(e){if(e&&!c(e))throw TypeError(`Invalid value: ${e}`);return this.value=e||"",this.value}setDisplay(e){let t=f(e),i=Number(this.focused.slice(8,10))||1,s=Q(`${t}-01`,0),n=F(s,Math.max(0,i-1));return this.focused=f(n)===t?n:F(`${B(t,1)}-01`,-1),this.display=t,this.display}setFocused(e,t={}){if(!c(e))throw TypeError(`Invalid focused date: ${e}`);if(this.focused=e,t.follow!==!1)this.display=f(e);return this.focused}moveFocusDays(e){return this.setFocused(F(this.focused,e))}moveFocusMonths(e){return this.setFocused(Q(this.focused,e))}moveFocusYears(e){return this.setFocused(pe(this.focused,e))}focusWeekStart(){return this.setFocused(ee(this.focused,this.firstDay))}focusWeekEnd(){return this.setFocused(ie(this.focused,this.firstDay))}navigateMonth(e){let t=B(this.display,e);return this.setDisplay(t),this.display}}function te(e){if(e==null)return{start:"",end:""};if(typeof e!=="object")throw TypeError("highlightedRange expects { start, end }");let{start:t="",end:i=""}=e;if(t&&!c(t))throw TypeError(`Invalid range start: ${t}`);if(i&&!c(i))throw TypeError(`Invalid range end: ${i}`);if(!t&&i)throw TypeError("highlightedRange cannot define an end without a start");if(t&&i&&D(i,t)<0)throw TypeError("highlightedRange must be ordered; start must be on or before end");return{start:t,end:i}}function ye(e,t){if(!t||!c(e))return"";let{start:i,end:s}=t;if(!i||!c(i))return"";if(i===e)return s?s===e?"single":"start":"start";if(s&&s===e)return"end";if(s&&D(e,i)>=0&&D(e,s)<=0)return"in";return""}class ne{constructor(){this.activeEndpoint="",this.start="",this.end=""}get range(){return{start:this.start,end:this.end}}get complete(){return Boolean(this.start&&this.end&&D(this.end,this.start)>=0)}focus(e){this.activeEndpoint=e}activate(e,t=()=>!0){if(!c(e))throw TypeError(`Invalid range activation: ${e}`);if(this.complete&&(D(e,this.start)<0||D(e,this.end)>0)){let i=D(e,this.start)<0?"start":"end";if(!t(i))return{status:"refused",endpoint:i};return this[i]=e,this.activeEndpoint=i,{status:"complete",endpoint:i}}if(this.activeEndpoint==="end"){if(this.start&&D(e,this.start)<0)return{status:"refused",endpoint:"end"};if(!t("end"))return{status:"refused",endpoint:"end"};return this.end=e,{status:this.start?"complete":"pending",endpoint:"end"}}if(!t("start"))return{status:"refused",endpoint:"start"};if(this.start=e,!t("end"))return{status:"pending",endpoint:"start",close:!0};return this.activeEndpoint="end",{status:"pending",endpoint:"start"}}}var ve=/[\u200e\u200f\u061c\u202a-\u202e\u2066-\u2069]/g;function O(e=""){if(e)return e;if(typeof document<"u"&&document.documentElement.lang)return document.documentElement.lang;if(typeof navigator<"u"&&navigator.language)return navigator.language;return"en-US"}function Ze(e){let t=new Intl.NumberFormat(e,{useGrouping:!1}),i=new Map;for(let s=0;s<=9;s++)i.set(t.format(s),String(s));return i}function be(e,t){let i=String(e||"").replace(ve,"").trim();for(let[s,n]of Ze(t))i=i.split(s).join(n);return i}function U(e,t=""){let i=O(t);return new Intl.DateTimeFormat(i,{calendar:"gregory",weekday:"long",year:"numeric",month:"long",day:"numeric",timeZone:"UTC"}).format(V(e))}function we(e,t=""){let i=O(t);return new Intl.DateTimeFormat(i,{calendar:"gregory",year:"numeric",month:"long",timeZone:"UTC"}).format(V(`${e.slice(0,7)}-15`))}function xe(e=""){let t=O(e);try{let i=new Intl.DateTimeFormat(t,{calendar:"gregory",year:"numeric",month:"long",timeZone:"UTC"}).formatToParts(V("2026-09-15")),s=-1,n=-1;if(i.forEach((r,a)=>{let o=r.type;if(o==="month"){if(s<0)s=a}else if(o==="year"||o==="relatedYear"||o==="yearName"){if(n<0)n=a}}),s>=0&&n>=0)return n<s?["year","month"]:["month","year"]}catch{}return["month","year"]}function De(e="",t="long"){let i=O(e),s=new Intl.DateTimeFormat(i,{calendar:"gregory",month:t,timeZone:"UTC"});return Array.from({length:12},(n,r)=>s.format(V(`2026-${String(r+1).padStart(2,"0")}-15`)))}function re(e="",t=1,i="short"){let s=O(e),n=new Intl.DateTimeFormat(s,{calendar:"gregory",weekday:i,timeZone:"UTC"}),r=j(t),a=V("2026-01-04");return Array.from({length:7},(o,l)=>{let d=new Date(a);return d.setUTCDate(a.getUTCDate()+(r+l)%7),n.format(d)})}function Xe(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function K(e=""){let t=O(e),i=new Intl.DateTimeFormat(t,{calendar:"gregory",year:"numeric",month:"2-digit",day:"2-digit",timeZone:"UTC"}),s=V("2006-11-22"),n=i.formatToParts(s).filter((d)=>d.type!=="literal"||d.value),r=n.filter((d)=>["day","month","year"].includes(d.type)).map((d)=>d.type),a=n.map((d)=>{if(d.type==="day")return"DD";if(d.type==="month")return"MM";if(d.type==="year")return"YYYY";return d.value.replace(ve,"")}).join(""),o=n.map((d)=>{if(d.type==="day"||d.type==="month")return"(\\d{1,2})";if(d.type==="year")return"(\\d{4})";let u=be(d.value,t).replace(/\s+/g," ");return Xe(u).replace(/\\ /g,"\\s*")}).join(""),l=new RegExp(`^\\s*${o}\\s*$`);return{locale:t,placeholder:a,format(d){if(!c(d))return"";return i.format(V(d))},parse(d){let u=be(d,t);if(c(u))return u;let k=l.exec(u);if(!k)return"";let g={};if(r.forEach((b,C)=>{g[b]=Number(k[C+1])}),!g.year||!g.month||!g.day)return"";try{return P(g.year,g.month,g.day)}catch{return""}}}}var Je={chooseDate:"Choose date",changeDate:"Change date",previousMonth:"Previous month",nextMonth:"Next month",month:"Month",year:"Year",calendar:"Choose a date",unavailable:"Unavailable",invalidDate:"Enter a valid date",unavailableDate:"This date is unavailable",formatHint:"Format",week:"Week",rangeStart:"Range start",rangeInRange:"Inside range",rangeEnd:"Range end",rangeSingle:"Range of one day",rangeOrderStart:"Start must be on or before end",rangeOrderEnd:"End must be on or after start"},Qe={...Je};function Y(){return{...Qe}}function Ee(e){let t=e&&typeof e==="object"&&!Array.isArray(e)&&"dates"in e?e.dates:e,i=new Map;if(Array.isArray(t)){for(let s of t){if(!s||typeof s!=="object"||!("date"in s))continue;let{date:n,...r}=s;i.set(String(n),r)}return i}if(t&&typeof t==="object")for(let[s,n]of Object.entries(t))i.set(s,n&&typeof n==="object"?n:{});return i}var et=0;function T(e){return String(e).replaceAll("&","&").replaceAll("<","<").replaceAll(">",">").replaceAll('"',""").replaceAll("'","'")}function tt(e){let t=Number(e);if(t===7)return 0;return Number.isInteger(t)&&t>=0&&t<=6?t:1}function it(e){return Number(e.slice(0,4))}function st(e){switch(e){case"single":return' data-range-start="true" data-range-end="true"';case"start":return' data-range-start="true"';case"end":return' data-range-end="true"';case"in":return' data-in-range="true"';default:return""}}function nt(e){if(e==="single")return"rangeSingle";if(e==="start")return"rangeStart";if(e==="end")return"rangeEnd";if(e==="in")return"rangeInRange";return""}class G extends HTMLElement{static observedAttributes=["value","display","min","max","first-day","locale","fixed-weeks","show-week-numbers","selection","month-format"];constructor(){super();this._id=`date-calendar-${++et}`,this._model=new se,this._connected=!1,this._rendering=!1,this._source=null,this._sourceStates=new Map,this._loadedRanges=new Set,this._loadController=null,this._loadingKey="",this._loadingPromise=null,this._dateState=null,this._renderDay=null,this._isDateDisabled=null,this._highlightedRange={start:"",end:""},this._messages=Y(),this._onClick=this._onClick.bind(this),this._onChange=this._onChange.bind(this),this._onKeyDown=this._onKeyDown.bind(this),this._onFocusIn=this._onFocusIn.bind(this)}connectedCallback(){if(this._connected)return;this._connected=!0,this.addEventListener("click",this._onClick),this.addEventListener("change",this._onChange),this.addEventListener("keydown",this._onKeyDown),this.addEventListener("focusin",this._onFocusIn),this._syncModel(),this.render()}disconnectedCallback(){this._connected=!1,this._loadController?.abort(),this._loadController=null,this._loadingKey="",this._loadingPromise=null,this.removeEventListener("click",this._onClick),this.removeEventListener("change",this._onChange),this.removeEventListener("keydown",this._onKeyDown),this.removeEventListener("focusin",this._onFocusIn)}attributeChangedCallback(){if(!this._connected||this._rendering)return;this._syncModel(),this.render()}get locale(){return O(this.getAttribute("locale")||"")}set locale(e){if(e)this.setAttribute("locale",e);else this.removeAttribute("locale")}get value(){return this._model.value}set value(e){let t=e||"";if(t&&!c(t))throw TypeError(`Invalid calendar value: ${t}`);if(t===this._model.value)return;if(this._model.setValue(t),this._reflect("value",t),this._connected)this.render()}get display(){return this._model.display}set display(e){this._setDisplay(e,{emit:!1})}get focusedDate(){return this._model.focused}set focusedDate(e){let t=e||"";if(t===this._model.focused)return;this.focusDate(t,{moveFocus:!1})}get min(){let e=this.getAttribute("min")||"";return c(e)?e:""}set min(e){if(e)this.setAttribute("min",e);else this.removeAttribute("min")}get max(){let e=this.getAttribute("max")||"";return c(e)?e:""}set max(e){if(e)this.setAttribute("max",e);else this.removeAttribute("max")}get firstDay(){return tt(this.getAttribute("first-day")||"1")}set firstDay(e){this.setAttribute("first-day",String(e))}get selection(){return this.getAttribute("selection")==="none"?"none":"single"}set selection(e){this.setAttribute("selection",e==="none"?"none":"single")}get monthFormat(){return this.getAttribute("month-format")==="short"?"short":"long"}set monthFormat(e){if(e==="short")this.setAttribute("month-format","short");else this.removeAttribute("month-format")}get highlightedRange(){return{...this._highlightedRange}}set highlightedRange(e){let t=te(e);if(t.start===this._highlightedRange.start&&t.end===this._highlightedRange.end)return;if(this._highlightedRange=t,this._connected)this.render()}get fixedWeeks(){return this.hasAttribute("fixed-weeks")}set fixedWeeks(e){this.toggleAttribute("fixed-weeks",Boolean(e))}get showWeekNumbers(){return this.hasAttribute("show-week-numbers")}set showWeekNumbers(e){this.toggleAttribute("show-week-numbers",Boolean(e))}get messages(){return this._messages}set messages(e){if(this._messages={...Y(),...e||{}},this._connected)this.render()}get source(){return this._source}set source(e){this._source=e||null,this.refreshSource()}get dateState(){return this._dateState}set dateState(e){if(this._dateState=typeof e==="function"?e:null,this._connected)this.render()}get renderDay(){return this._renderDay}set renderDay(e){if(this._renderDay=typeof e==="function"?e:null,this._connected)this.render()}get isDateDisabled(){return this._isDateDisabled}set isDateDisabled(e){if(this._isDateDisabled=typeof e==="function"?e:null,this._connected)this.render()}_syncModel(){let e=this.firstDay;this._model.firstDay=e;let t=this.getAttribute("value")||"";if(!t||c(t))this._model.value=t;let i=this.getAttribute("display")||"";if(i)try{this._model.setDisplay(i)}catch{}else if(this._model.value)this._model.display=f(this._model.value),this._model.focused=this._model.value;if(this._model.focused=this._clamp(this._model.focused),!this.getAttribute("display"))this._model.display=f(this._model.focused)}_reflect(e,t){if(this._rendering=!0,t){if(this.getAttribute(e)!==t)this.setAttribute(e,t)}else if(this.hasAttribute(e))this.removeAttribute(e);this._rendering=!1}_clamp(e){return ge(e,this.min,this.max)}_weeks(e=this.display){let t=me(e,{firstDay:this.firstDay});if(!this.fixedWeeks||t.length>=6)return t;let i=t[t.length-1]?.[6]||"";while(t.length<6&&i){let s=[];for(let n=1;n<=7;n++)s.push(F(i,n));t.push(s),i=s[6]}return t}_focusTargetKey(e){if(e.matches(".dp-month-select, .dp-year-select, .dp-year-input")&&e.id)return`#${CSS.escape(e.id)}`;if(e.matches(".dp-nav[data-calendar-action]"))return`.dp-nav[data-calendar-action="${CSS.escape(e.dataset.calendarAction||"")}"]`;if(e.matches(".dp-day[data-date]")){let t=e.getAttribute("data-date")||"";if(c(t))return`.dp-day[data-date="${t}"]`}return""}_range(e=this.display){let t=this._weeks(e),i=t[0],s=t[t.length-1];if(!i||!s)throw Error("Calendar month produced no weeks");return{start:i[0],end:s[6]}}getDateState(e){let t=this._sourceStates.get(e)||{},i=this._dateState?.(e,{...t})||{},s={...t,...i},n=this.min&&D(e,this.min)<0||this.max&&D(e,this.max)>0,a=s.enabled===!0?!1:Boolean(this._isDateDisabled?.(e)),o=Boolean(n)||Boolean(s.disabled)||a;return{...s,disabled:o}}async refreshSource(){if(this._loadController?.abort(),this._loadController=null,this._loadingKey="",this._loadingPromise=null,this._loadedRanges.clear(),this._sourceStates.clear(),this._connected)this.render(),await this._loadDisplay(this.display)}async ensureDate(e){if(!c(e)||!this._source)return!0;return await this._loadDisplay(f(e),!1)==="loaded"}async _loadDisplay(e,t=!0){if(!this._source)return"loaded";let i=this._range(e),s=`${i.start}/${i.end}`;if(this._loadedRanges.has(s))return"loaded";if(s===this._loadingKey&&this._loadingPromise)return this._loadingPromise;this._loadController?.abort();let n=new AbortController;this._loadController=n,this._loadingKey=s;let r=this._source,a=(async()=>{this.toggleAttribute("data-loading",!0),this.dispatchEvent(new CustomEvent("dateloadstart",{detail:i,bubbles:!0}));try{let o=typeof r==="function"?r:r?.load?.bind(r);if(!o)throw TypeError("Date source must be a function or expose load(range, { signal })");let l=await o(i,{signal:n.signal});if(n.signal.aborted)return"cancelled";for(let[d,u]of Ee(l))this._sourceStates.set(d,u);if(this._loadedRanges.add(s),this.dispatchEvent(new CustomEvent("dateloadend",{detail:i,bubbles:!0})),t&&this._connected&&f(this.display)===f(e))this.render(!1);return"loaded"}catch(o){if(n.signal.aborted)return"cancelled";return this.dispatchEvent(new CustomEvent("dateloaderror",{detail:{...i,error:o},bubbles:!0})),"failed"}finally{if(this._loadController===n)this._loadController=null,this.removeAttribute("data-loading");if(this._loadingKey===s)this._loadingKey="",this._loadingPromise=null}})();return this._loadingPromise=a,a}_setDisplay(e,t={}){let i=this._model.display;if(this._model.setDisplay(e),this._model.focused=this._clamp(this._model.focused),this._model.display=f(this._model.focused),this._reflect("display",this._model.display),this._connected)this.render();if(t.emit!==!1&&i!==this._model.display)this._emitDisplayChange();return this._model.display}_emitDisplayChange(){let e=this._range();this.dispatchEvent(new CustomEvent("displaychange",{detail:{display:this.display,...e},bubbles:!0}))}previousMonth(){return this._setDisplay(B(this.display,-1))}nextMonth(){return this._setDisplay(B(this.display,1))}focusDate(e,t={}){if(!c(e))throw TypeError(`Invalid date: ${e}`);let i=this._clamp(e),s=this.display,n=this._model.focused,r=t.moveFocus!==!1;if(this._model.setFocused(i),this._reflect("display",this._model.display),s!==this.display){if(this._connected)this.render();this._emitDisplayChange()}else if(this._connected&&n!==this._model.focused)this._moveFocusDom(n,this._model.focused,r);if(r)queueMicrotask(()=>this.focusGrid())}_moveFocusDom(e,t,i=!0){let s=e?this.querySelector(`.dp-day[data-date="${CSS.escape(e)}"]`):null,n=this.querySelector(`.dp-day[data-date="${CSS.escape(t)}"]`);if(s instanceof HTMLElement)s.tabIndex=-1;if(n instanceof HTMLElement){if(n.tabIndex=0,i)n.focus()}else if(i)this.focusGrid()}_moveSelectionDom(e,t){if(e){let i=this.querySelector(`.dp-day[data-date="${CSS.escape(e)}"]`);if(i instanceof HTMLElement)i.removeAttribute("data-selected"),i.removeAttribute("aria-selected")}if(t){let i=this.querySelector(`.dp-day[data-date="${CSS.escape(t)}"]`);if(i instanceof HTMLElement)return i.setAttribute("data-selected","true"),i.setAttribute("aria-selected","true"),!0}return!1}focusGrid(){let e=this.querySelector(`.dp-day[data-date="${CSS.escape(this.focusedDate)}"]`);if(e instanceof HTMLElement)e.focus()}async _activate(e){let t=await this.ensureDate(e),i=this.getDateState(e);if(!t||i.disabled)return this.dispatchEvent(new CustomEvent("dateinvalid",{detail:{date:e,state:i},bubbles:!0})),!1;if(!this.dispatchEvent(new CustomEvent("dateactivate",{detail:{date:e,state:i},bubbles:!0,cancelable:!0})))return!1;if(this.selection==="single"){let n=this._model.value;if(this._model.setValue(e),this._reflect("value",e),this.dispatchEvent(new CustomEvent("datechange",{detail:{value:e},bubbles:!0})),this.dispatchEvent(new Event("change",{bubbles:!0})),this._connected)if(f(e)===this.display)this._moveSelectionDom(n,e);else this.render()}else if(this._connected){if(f(e)!==this.display)this.render()}return!0}_onClick(e){let t=e.target;if(!(t instanceof Element))return;let i=t.closest("[data-calendar-action]");if(i instanceof HTMLButtonElement){let a=i.dataset.calendarAction;if(a==="previous")this.previousMonth();if(a==="next")this.nextMonth();return}let s=t.closest(".dp-day[data-date]");if(!(s instanceof HTMLTableCellElement))return;let n=s.dataset.date||"";if(!c(n))return;let r=this.display;if(this._model.setFocused(this._clamp(n)),this._reflect("display",this._model.display),r!==this.display)this._emitDisplayChange();this._activate(n)}_onChange(e){let t=e.target;if(t instanceof HTMLSelectElement&&t.matches(".dp-month-select")){this._setDisplay(`${this.display.slice(0,4)}-${t.value}`);return}if(t instanceof HTMLSelectElement&&t.matches(".dp-year-select")){this._setDisplay(`${t.value}-${this.display.slice(5,7)}`);return}if(t instanceof HTMLInputElement&&t.matches(".dp-year-input")){let i=Number(t.value);if(!Number.isInteger(i)||i<1||i>9999){if(this._connected)this.render(!1);return}this._setDisplay(`${String(i).padStart(4,"0")}-${this.display.slice(5,7)}`)}}_onFocusIn(e){let t=e.target;if(!(t instanceof HTMLTableCellElement)||!t.matches(".dp-day[data-date]"))return;let i=t.dataset.date||"";if(c(i))this._model.focused=i}_onKeyDown(e){let t=e.target;if(!(t instanceof HTMLTableCellElement)||!t.matches(".dp-day[data-date]"))return;let i=t.dataset.date||this.focusedDate;if(e.key==="Enter"||e.key===" "){e.preventDefault(),this._activate(i);return}let s=this._model.focused,n=this._model.display;if(this._model.firstDay=this.firstDay,this._model.setFocused(i,{follow:!1}),e.key==="ArrowLeft")this._model.moveFocusDays(-1);else if(e.key==="ArrowRight")this._model.moveFocusDays(1);else if(e.key==="ArrowUp")this._model.moveFocusDays(-7);else if(e.key==="ArrowDown")this._model.moveFocusDays(7);else if(e.key==="Home")this._model.focusWeekStart();else if(e.key==="End")this._model.focusWeekEnd();else if(e.key==="PageUp")e.shiftKey?this._model.moveFocusYears(-1):this._model.moveFocusMonths(-1);else if(e.key==="PageDown")e.shiftKey?this._model.moveFocusYears(1):this._model.moveFocusMonths(1);else return;let r=this._model.focused;if(this._model.focused=s,this._model.display=n,!r)return;e.preventDefault(),this.focusDate(this._clamp(r))}render(e=!0){if(!this._connected)return;let t=this.locale,i=this.display,s=it(i),n=Number(i.slice(5,7)),r=De(t,this.monthFormat),a=re(t,this.firstDay,"short"),o=re(t,this.firstDay,"long"),l=this._weeks(),d=L(),u=`${this._id}-heading`,k=`${this._id}-grid`,g=this.min?f(this.min):"",b=this.max?f(this.max):"",C=Boolean(g&&B(i,-1)<g),S=Boolean(b&&B(i,1)>b),E=this.min?` min="${Number(this.min.slice(0,4))}"`:"",y=this.max?` max="${Number(this.max.slice(0,4))}"`:"",_=this.showWeekNumbers&&this.firstDay===1,A=_?`<th scope="col" class="dp-week-heading" abbr="${T(this._messages.week)}">#</th>`:"",w=r.map((h,m)=>{let x=m+1,p=`${String(s).padStart(4,"0")}-${String(x).padStart(2,"0")}`,M=g&&p<g||b&&p>b;return`<option value="${String(x).padStart(2,"0")}"${x===n?" selected":""}${M?" disabled":""}>${T(h)}</option>`}).join(""),H=a.map((h,m)=>`<th scope="col" abbr="${T(o[m])}">${T(h.replace(".",""))}</th>`).join(""),N=l.map((h)=>{let m=_?`<th scope="row" class="dp-week-number">${_e(h[0])}</th>`:"",x=h.map((p)=>{let M=this.getDateState(p),ce=f(p)!==i,ze=this.value===p,He=this.focusedDate===p,Ve=p===d,ue=ye(p,this._highlightedRange),he=nt(ue),Be=typeof M.description==="string"?M.description:"",Pe=[U(p,t),Be,he?this._messages[he]:"",M.disabled?this._messages.unavailable:""].filter(Boolean).join(". ");return`<td class="dp-day" data-date="${p}"${ce?' data-outside-month="true"':""}${Ve?' data-today="true" aria-current="date"':""}${ze?' data-selected="true" aria-selected="true"':""}${st(ue)}${M.disabled?' data-disabled="true" aria-disabled="true"':""} tabindex="${He?"0":"-1"}" aria-label="${T(Pe)}"><span class="dp-day-number" aria-hidden="true">${Number(p.slice(8,10))}</span><span class="dp-day-extra" aria-hidden="true"></span></td>`}).join("");return`<tr>${m}${x}</tr>`}).join(""),R=document.activeElement,z=R instanceof HTMLElement&&this.contains(R)?this._focusTargetKey(R):"",W=xe(t)[0]==="year";this.toggleAttribute("data-year-first",W);let q=`<label class="dp-visually-hidden" for="${this._id}-month">${T(this._messages.month)}</label>
|
|
443
|
-
<select id="${this._id}-month" class="dp-month-select" aria-label="${
|
|
444
|
-
<input id="${this._id}-year" class="dp-year-input" type="number" inputmode="numeric" value="${s}"${
|
|
490
|
+
`;var Ue=/^(\d{4})-(\d{2})-(\d{2})$/,Ye=/^(\d{4})-(\d{2})$/;function We(e){return e%4===0&&(e%100!==0||e%400===0)}function ee(e,t){if(t===2)return We(e)?29:28;return[4,6,9,11].includes(t)?30:31}function I(e){let t=Ue.exec(String(e||""));if(!t)return null;let i=Number(t[1]),s=Number(t[2]),n=Number(t[3]);if(i<1||i>9999||s<1||s>12)return null;if(n<1||n>ee(i,s))return null;return{year:i,month:s,day:n}}function c(e){return I(e)!==null}function f(e){let t=String(e||""),i=Ye.exec(t);if(i){let n=Number(i[2]);if(n>=1&&n<=12)return`${i[1]}-${String(n).padStart(2,"0")}`}let s=I(t);if(!s)throw TypeError(`Invalid civil date/month: ${e}`);return`${String(s.year).padStart(4,"0")}-${String(s.month).padStart(2,"0")}`}function U(e,t,i){let s=`${String(e).padStart(4,"0")}-${String(t).padStart(2,"0")}-${String(i).padStart(2,"0")}`;if(!c(s))throw TypeError(`Invalid civil date: ${s}`);return s}function te(e){let t=new Date(0);return t.setUTCHours(12,0,0,0),t.setUTCFullYear(e.year,e.month-1,e.day),t}function qe(e){return U(e.getUTCFullYear(),e.getUTCMonth()+1,e.getUTCDate())}function B(e){let t=I(e);if(!t)throw TypeError(`Invalid civil date: ${e}`);return te(t)}function w(e,t){if(!c(e)||!c(t))throw TypeError("compareDates() expects YYYY-MM-DD values");return e===t?0:e<t?-1:1}function L(e,t){let i=I(e);if(!i||!Number.isInteger(t))throw TypeError("addDays() expects a date and integer amount");let s=te(i);return s.setUTCDate(s.getUTCDate()+t),qe(s)}function ie(e,t){let i=I(e);if(!i||!Number.isInteger(t))throw TypeError("addMonths() expects a date and integer amount");let s=i.year*12+(i.month-1)+t,n=Math.floor(s/12),a=(s%12+12)%12+1,o=Math.min(i.day,ee(n,a));return U(n,a,o)}function _e(e,t){let i=I(e);if(!i||!Number.isInteger(t))throw TypeError("addYears() expects a date and integer amount");let s=i.year+t,n=Math.min(i.day,ee(s,i.month));return U(s,i.month,n)}function P(e,t){let i=`${f(e)}-01`;return f(ie(i,t))}function Ke(e){return`${f(e)}-01`}function je(e){let t=I(`${f(e)}-01`);if(!t)throw TypeError(`Invalid month: ${e}`);return U(t.year,t.month,ee(t.year,t.month))}function Ge(e){let t=I(e);if(!t)throw TypeError(`Invalid civil date: ${e}`);return te(t).getUTCDay()}function j(e){if(e===7)return 0;if(!Number.isInteger(e)||e<0||e>6)throw RangeError("firstDay must be 0..6 (Sunday=0, 7 accepted as Sunday alias)");return e}function se(e,t=1){let i=(Ge(e)-j(t)+7)%7;return L(e,-i)}function re(e,t=1){return L(se(e,t),6)}function ye(e,t={}){let i=t.firstDay??1,s=se(Ke(e),i),n=re(je(e),i),r=[],a=s;while(w(a,n)<=0){let o=[];for(let l=0;l<7;l++)o.push(L(a,l));r.push(o),a=L(a,7)}return r}function be(e,t="",i=""){if(!c(e))throw TypeError(`Invalid civil date: ${e}`);if(t&&w(e,t)<0)return t;if(i&&w(e,i)>0)return i;return e}function O(){let e=new Date;return U(e.getFullYear(),e.getMonth()+1,e.getDate())}function ve(e){let t=I(e);if(!t)throw TypeError(`Invalid civil date: ${e}`);let i=te(t),s=i.getUTCDay()||7;i.setUTCDate(i.getUTCDate()+4-s);let n=new Date(0);return n.setUTCHours(12,0,0,0),n.setUTCFullYear(i.getUTCFullYear(),0,1),Math.ceil(((i.getTime()-n.getTime())/86400000+1)/7)}class ae{constructor(e={}){let t=O();this.firstDay=j(e.firstDay??1),this.value=e.value&&c(e.value)?e.value:"",this.focused=e.focused&&c(e.focused)?e.focused:this.value||t,this.display=e.display?f(e.display):f(this.focused)}setValue(e){if(e&&!c(e))throw TypeError(`Invalid value: ${e}`);return this.value=e||"",this.value}setDisplay(e){let t=f(e),i=Number(this.focused.slice(8,10))||1,s=ie(`${t}-01`,0),n=L(s,Math.max(0,i-1));return this.focused=f(n)===t?n:L(`${P(t,1)}-01`,-1),this.display=t,this.display}setFocused(e,t={}){if(!c(e))throw TypeError(`Invalid focused date: ${e}`);if(this.focused=e,t.follow!==!1)this.display=f(e);return this.focused}moveFocusDays(e){return this.setFocused(L(this.focused,e))}moveFocusMonths(e){return this.setFocused(ie(this.focused,e))}moveFocusYears(e){return this.setFocused(_e(this.focused,e))}focusWeekStart(){return this.setFocused(se(this.focused,this.firstDay))}focusWeekEnd(){return this.setFocused(re(this.focused,this.firstDay))}navigateMonth(e){let t=P(this.display,e);return this.setDisplay(t),this.display}}function ne(e){if(e==null)return{start:"",end:""};if(typeof e!=="object")throw TypeError("highlightedRange expects { start, end }");let{start:t="",end:i=""}=e;if(t&&!c(t))throw TypeError(`Invalid range start: ${t}`);if(i&&!c(i))throw TypeError(`Invalid range end: ${i}`);if(!t&&i)throw TypeError("highlightedRange cannot define an end without a start");if(t&&i&&w(i,t)<0)throw TypeError("highlightedRange must be ordered; start must be on or before end");return{start:t,end:i}}function we(e,t){if(!t||!c(e))return"";let{start:i,end:s}=t;if(!i||!c(i))return"";if(i===e)return s?s===e?"single":"start":"start";if(s&&s===e)return"end";if(s&&w(e,i)>=0&&w(e,s)<=0)return"in";return""}class oe{constructor(){this.activeEndpoint="",this.start="",this.end=""}get range(){return{start:this.start,end:this.end}}get complete(){return Boolean(this.start&&this.end&&w(this.end,this.start)>=0)}focus(e){this.activeEndpoint=e}activate(e,t=()=>!0){if(!c(e))throw TypeError(`Invalid range activation: ${e}`);if(this.complete&&(w(e,this.start)<0||w(e,this.end)>0)){let i=w(e,this.start)<0?"start":"end";if(!t(i))return{status:"refused",endpoint:i};return this[i]=e,this.activeEndpoint=i,{status:"complete",endpoint:i}}if(this.activeEndpoint==="end"){if(this.start&&w(e,this.start)<0)return{status:"refused",endpoint:"end"};if(!t("end"))return{status:"refused",endpoint:"end"};return this.end=e,{status:this.start?"complete":"pending",endpoint:"end"}}if(!t("start"))return{status:"refused",endpoint:"start"};if(this.start=e,!t("end"))return{status:"pending",endpoint:"start",close:!0};return this.activeEndpoint="end",{status:"pending",endpoint:"start"}}}var De=/[\u200e\u200f\u061c\u202a-\u202e\u2066-\u2069]/g;function R(e=""){if(e)return e;if(typeof document<"u"&&document.documentElement.lang)return document.documentElement.lang;if(typeof navigator<"u"&&navigator.language)return navigator.language;return"en-US"}function Xe(e){let t=new Intl.NumberFormat(e,{useGrouping:!1}),i=new Map;for(let s=0;s<=9;s++)i.set(t.format(s),String(s));return i}function xe(e,t){let i=String(e||"").replace(De,"").trim();for(let[s,n]of Xe(t))i=i.split(s).join(n);return i}function G(e,t=""){let i=R(t);return new Intl.DateTimeFormat(i,{calendar:"gregory",weekday:"long",year:"numeric",month:"long",day:"numeric",timeZone:"UTC"}).format(B(e))}function ke(e,t=""){let i=R(t);return new Intl.DateTimeFormat(i,{calendar:"gregory",year:"numeric",month:"long",timeZone:"UTC"}).format(B(`${e.slice(0,7)}-15`))}function Ee(e=""){let t=R(e);try{let i=new Intl.DateTimeFormat(t,{calendar:"gregory",year:"numeric",month:"long",timeZone:"UTC"}).formatToParts(B("2026-09-15")),s=-1,n=-1;if(i.forEach((r,a)=>{let o=r.type;if(o==="month"){if(s<0)s=a}else if(o==="year"||o==="relatedYear"||o==="yearName"){if(n<0)n=a}}),s>=0&&n>=0)return n<s?["year","month"]:["month","year"]}catch{}return["month","year"]}function Te(e="",t="long"){let i=R(e),s=new Intl.DateTimeFormat(i,{calendar:"gregory",month:t,timeZone:"UTC"});return Array.from({length:12},(n,r)=>s.format(B(`2026-${String(r+1).padStart(2,"0")}-15`)))}function de(e="",t=1,i="short"){let s=R(e),n=new Intl.DateTimeFormat(s,{calendar:"gregory",weekday:i,timeZone:"UTC"}),r=j(t),a=B("2026-01-04");return Array.from({length:7},(o,l)=>{let d=new Date(a);return d.setUTCDate(a.getUTCDate()+(r+l)%7),n.format(d)})}function Ze(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function X(e=""){let t=R(e),i=new Intl.DateTimeFormat(t,{calendar:"gregory",year:"numeric",month:"2-digit",day:"2-digit",timeZone:"UTC"}),s=B("2006-11-22"),n=i.formatToParts(s).filter((d)=>d.type!=="literal"||d.value),r=n.filter((d)=>["day","month","year"].includes(d.type)).map((d)=>d.type),a=n.map((d)=>{if(d.type==="day")return"DD";if(d.type==="month")return"MM";if(d.type==="year")return"YYYY";return d.value.replace(De,"")}).join(""),o=n.map((d)=>{if(d.type==="day"||d.type==="month")return"(\\d{1,2})";if(d.type==="year")return"(\\d{4})";let u=xe(d.value,t).replace(/\s+/g," ");return Ze(u).replace(/\\ /g,"\\s*")}).join(""),l=new RegExp(`^\\s*${o}\\s*$`);return{locale:t,placeholder:a,format(d){if(!c(d))return"";return i.format(B(d))},parse(d){let u=xe(d,t);if(c(u))return u;let C=l.exec(u);if(!C)return"";let m={};if(r.forEach((b,E)=>{m[b]=Number(C[E+1])}),!m.year||!m.month||!m.day)return"";try{return U(m.year,m.month,m.day)}catch{return""}}}}var Je={chooseDate:"Choose date",changeDate:"Change date",previousMonth:"Previous month",nextMonth:"Next month",month:"Month",year:"Year",calendar:"Choose a date",unavailable:"Unavailable",invalidDate:"Enter a valid date",unavailableDate:"This date is unavailable",formatHint:"Format",week:"Week",rangeStart:"Range start",rangeInRange:"Inside range",rangeEnd:"Range end",rangeSingle:"Range of one day",rangeOrderStart:"Start must be on or before end",rangeOrderEnd:"End must be on or after start"},Qe={...Je};function W(){return{...Qe}}function Ce(e){let t=e&&typeof e==="object"&&!Array.isArray(e)&&"dates"in e?e.dates:e,i=new Map;if(Array.isArray(t)){for(let s of t){if(!s||typeof s!=="object"||!("date"in s))continue;let{date:n,...r}=s;i.set(String(n),r)}return i}if(t&&typeof t==="object")for(let[s,n]of Object.entries(t))i.set(s,n&&typeof n==="object"?n:{});return i}var et=0;function A(e){return String(e).replaceAll("&","&").replaceAll("<","<").replaceAll(">",">").replaceAll('"',""").replaceAll("'","'")}function tt(e){let t=Number(e);if(t===7)return 0;return Number.isInteger(t)&&t>=0&&t<=6?t:1}function it(e){return Number(e.slice(0,4))}function st(e){switch(e){case"single":return' data-range-start="true" data-range-end="true"';case"start":return' data-range-start="true"';case"end":return' data-range-end="true"';case"in":return' data-in-range="true"';default:return""}}function nt(e){if(e==="single")return"rangeSingle";if(e==="start")return"rangeStart";if(e==="end")return"rangeEnd";if(e==="in")return"rangeInRange";return""}class Z extends HTMLElement{static observedAttributes=["value","display","min","max","first-day","locale","fixed-weeks","show-week-numbers","selection","month-format"];constructor(){super();this._id=`date-calendar-${++et}`,this._model=new ae,this._connected=!1,this._rendering=!1,this._source=null,this._sourceStates=new Map,this._loadedRanges=new Set,this._loadController=null,this._loadingKey="",this._loadingPromise=null,this._dateState=null,this._renderDay=null,this._isDateDisabled=null,this._highlightedRange={start:"",end:""},this._messages=W(),this._onClick=this._onClick.bind(this),this._onChange=this._onChange.bind(this),this._onKeyDown=this._onKeyDown.bind(this),this._onFocusIn=this._onFocusIn.bind(this)}connectedCallback(){if(this._connected)return;this._connected=!0,this.addEventListener("click",this._onClick),this.addEventListener("change",this._onChange),this.addEventListener("keydown",this._onKeyDown),this.addEventListener("focusin",this._onFocusIn),this._syncModel(),this.render()}disconnectedCallback(){this._connected=!1,this._loadController?.abort(),this._loadController=null,this._loadingKey="",this._loadingPromise=null,this.removeEventListener("click",this._onClick),this.removeEventListener("change",this._onChange),this.removeEventListener("keydown",this._onKeyDown),this.removeEventListener("focusin",this._onFocusIn)}attributeChangedCallback(){if(!this._connected||this._rendering)return;this._syncModel(),this.render()}get locale(){return R(this.getAttribute("locale")||"")}set locale(e){if(e)this.setAttribute("locale",e);else this.removeAttribute("locale")}get value(){return this._model.value}set value(e){let t=e||"";if(t&&!c(t))throw TypeError(`Invalid calendar value: ${t}`);if(t===this._model.value)return;if(this._model.setValue(t),this._reflect("value",t),this._connected)this.render()}get display(){return this._model.display}set display(e){this._setDisplay(e,{emit:!1})}get focusedDate(){return this._model.focused}set focusedDate(e){let t=e||"";if(t===this._model.focused)return;this.focusDate(t,{moveFocus:!1})}get min(){let e=this.getAttribute("min")||"";return c(e)?e:""}set min(e){if(e)this.setAttribute("min",e);else this.removeAttribute("min")}get max(){let e=this.getAttribute("max")||"";return c(e)?e:""}set max(e){if(e)this.setAttribute("max",e);else this.removeAttribute("max")}get firstDay(){return tt(this.getAttribute("first-day")||"1")}set firstDay(e){this.setAttribute("first-day",String(e))}get selection(){return this.getAttribute("selection")==="none"?"none":"single"}set selection(e){this.setAttribute("selection",e==="none"?"none":"single")}get monthFormat(){return this.getAttribute("month-format")==="short"?"short":"long"}set monthFormat(e){if(e==="short")this.setAttribute("month-format","short");else this.removeAttribute("month-format")}get highlightedRange(){return{...this._highlightedRange}}set highlightedRange(e){let t=ne(e);if(t.start===this._highlightedRange.start&&t.end===this._highlightedRange.end)return;if(this._highlightedRange=t,this._connected)this.render()}get fixedWeeks(){return this.hasAttribute("fixed-weeks")}set fixedWeeks(e){this.toggleAttribute("fixed-weeks",Boolean(e))}get showWeekNumbers(){return this.hasAttribute("show-week-numbers")}set showWeekNumbers(e){this.toggleAttribute("show-week-numbers",Boolean(e))}get messages(){return this._messages}set messages(e){if(this._messages={...W(),...e||{}},this._connected)this.render()}get source(){return this._source}set source(e){this._source=e||null,this.refreshSource()}get dateState(){return this._dateState}set dateState(e){if(this._dateState=typeof e==="function"?e:null,this._connected)this.render()}get renderDay(){return this._renderDay}set renderDay(e){if(this._renderDay=typeof e==="function"?e:null,this._connected)this.render()}get isDateDisabled(){return this._isDateDisabled}set isDateDisabled(e){if(this._isDateDisabled=typeof e==="function"?e:null,this._connected)this.render()}_syncModel(){let e=this.firstDay;this._model.firstDay=e;let t=this.getAttribute("value")||"";if(!t||c(t))this._model.value=t;let i=this.getAttribute("display")||"";if(i)try{this._model.setDisplay(i)}catch{}else if(this._model.value)this._model.display=f(this._model.value),this._model.focused=this._model.value;if(this._model.focused=this._clamp(this._model.focused),!this.getAttribute("display"))this._model.display=f(this._model.focused)}_reflect(e,t){if(this._rendering=!0,t){if(this.getAttribute(e)!==t)this.setAttribute(e,t)}else if(this.hasAttribute(e))this.removeAttribute(e);this._rendering=!1}_clamp(e){return be(e,this.min,this.max)}_weeks(e=this.display){let t=ye(e,{firstDay:this.firstDay});if(!this.fixedWeeks||t.length>=6)return t;let i=t[t.length-1]?.[6]||"";while(t.length<6&&i){let s=[];for(let n=1;n<=7;n++)s.push(L(i,n));t.push(s),i=s[6]}return t}_focusTargetKey(e){if(e.matches(".dp-month-select, .dp-year-input")&&e.id)return`#${CSS.escape(e.id)}`;if(e.matches(".dp-nav[data-calendar-action]"))return`.dp-nav[data-calendar-action="${CSS.escape(e.dataset.calendarAction||"")}"]`;if(e.matches(".dp-day[data-date]")){let t=e.getAttribute("data-date")||"";if(c(t))return`.dp-day[data-date="${t}"]`}return""}_range(e=this.display){let t=this._weeks(e),i=t[0],s=t[t.length-1];if(!i||!s)throw Error("Calendar month produced no weeks");return{start:i[0],end:s[6]}}getDateState(e){let t=this._sourceStates.get(e)||{},i=this._dateState?.(e,{...t})||{},s={...t,...i},n=this.min&&w(e,this.min)<0||this.max&&w(e,this.max)>0,a=s.enabled===!0?!1:Boolean(this._isDateDisabled?.(e)),o=Boolean(n)||Boolean(s.disabled)||a;return{...s,disabled:o}}async refreshSource(){if(this._loadController?.abort(),this._loadController=null,this._loadingKey="",this._loadingPromise=null,this._loadedRanges.clear(),this._sourceStates.clear(),this._connected)this.render(),await this._loadDisplay(this.display)}async ensureDate(e){if(!c(e)||!this._source)return!0;return await this._loadDisplay(f(e),!1)==="loaded"}async _loadDisplay(e,t=!0){if(!this._source)return"loaded";let i=this._range(e),s=`${i.start}/${i.end}`;if(this._loadedRanges.has(s))return"loaded";if(s===this._loadingKey&&this._loadingPromise)return this._loadingPromise;this._loadController?.abort();let n=new AbortController;this._loadController=n,this._loadingKey=s;let r=this._source,a=(async()=>{this.toggleAttribute("data-loading",!0),this.dispatchEvent(new CustomEvent("dateloadstart",{detail:i,bubbles:!0}));try{let o=typeof r==="function"?r:r?.load?.bind(r);if(!o)throw TypeError("Date source must be a function or expose load(range, { signal })");let l=await o(i,{signal:n.signal});if(n.signal.aborted)return"cancelled";for(let[d,u]of Ce(l))this._sourceStates.set(d,u);if(this._loadedRanges.add(s),this.dispatchEvent(new CustomEvent("dateloadend",{detail:i,bubbles:!0})),t&&this._connected&&f(this.display)===f(e))this.render(!1);return"loaded"}catch(o){if(n.signal.aborted)return"cancelled";return this.dispatchEvent(new CustomEvent("dateloaderror",{detail:{...i,error:o},bubbles:!0})),"failed"}finally{if(this._loadController===n)this._loadController=null,this.removeAttribute("data-loading");if(this._loadingKey===s)this._loadingKey="",this._loadingPromise=null}})();return this._loadingPromise=a,a}_setDisplay(e,t={}){let i=this._model.display;if(this._model.setDisplay(e),this._model.focused=this._clamp(this._model.focused),this._model.display=f(this._model.focused),this._reflect("display",this._model.display),this._connected)this.render();if(t.emit!==!1&&i!==this._model.display)this._emitDisplayChange();return this._model.display}_emitDisplayChange(){let e=this._range();this.dispatchEvent(new CustomEvent("displaychange",{detail:{display:this.display,...e},bubbles:!0}))}previousMonth(){return this._setDisplay(P(this.display,-1))}nextMonth(){return this._setDisplay(P(this.display,1))}focusDate(e,t={}){if(!c(e))throw TypeError(`Invalid date: ${e}`);let i=this._clamp(e),s=this.display,n=this._model.focused,r=t.moveFocus!==!1;if(this._model.setFocused(i),this._reflect("display",this._model.display),s!==this.display){if(this._connected)this.render();this._emitDisplayChange()}else if(this._connected&&n!==this._model.focused)this._moveFocusDom(n,this._model.focused,r);if(r)queueMicrotask(()=>this.focusGrid())}_moveFocusDom(e,t,i=!0){let s=e?this.querySelector(`.dp-day[data-date="${CSS.escape(e)}"]`):null,n=this.querySelector(`.dp-day[data-date="${CSS.escape(t)}"]`);if(s instanceof HTMLElement)s.tabIndex=-1;if(n instanceof HTMLElement){if(n.tabIndex=0,i)n.focus()}else if(i)this.focusGrid()}_moveSelectionDom(e,t){if(e){let i=this.querySelector(`.dp-day[data-date="${CSS.escape(e)}"]`);if(i instanceof HTMLElement)i.removeAttribute("data-selected"),i.removeAttribute("aria-selected")}if(t){let i=this.querySelector(`.dp-day[data-date="${CSS.escape(t)}"]`);if(i instanceof HTMLElement)return i.setAttribute("data-selected","true"),i.setAttribute("aria-selected","true"),!0}return!1}focusGrid(){let e=this.querySelector(`.dp-day[data-date="${CSS.escape(this.focusedDate)}"]`);if(e instanceof HTMLElement)e.focus()}async _activate(e){let t=await this.ensureDate(e),i=this.getDateState(e);if(!t||i.disabled)return this.dispatchEvent(new CustomEvent("dateinvalid",{detail:{date:e,state:i},bubbles:!0})),!1;if(!this.dispatchEvent(new CustomEvent("dateactivate",{detail:{date:e,state:i},bubbles:!0,cancelable:!0})))return!1;if(this.selection==="single"){let n=this._model.value;if(this._model.setValue(e),this._reflect("value",e),this.dispatchEvent(new CustomEvent("datechange",{detail:{value:e},bubbles:!0})),this.dispatchEvent(new Event("change",{bubbles:!0})),this._connected)if(f(e)===this.display)this._moveSelectionDom(n,e);else this.render()}else if(this._connected){if(f(e)!==this.display)this.render()}return!0}_onClick(e){let t=e.target;if(!(t instanceof Element))return;let i=t.closest("[data-calendar-action]");if(i instanceof HTMLButtonElement){let a=i.dataset.calendarAction;if(a==="previous")this.previousMonth();if(a==="next")this.nextMonth();return}let s=t.closest(".dp-day[data-date]");if(!(s instanceof HTMLTableCellElement))return;let n=s.dataset.date||"";if(!c(n))return;let r=this.display;if(this._model.setFocused(this._clamp(n)),this._reflect("display",this._model.display),r!==this.display)this._emitDisplayChange();this._activate(n)}_onChange(e){let t=e.target;if(t instanceof HTMLSelectElement&&t.matches(".dp-month-select")){this._setDisplay(`${this.display.slice(0,4)}-${t.value}`);return}if(t instanceof HTMLInputElement&&t.matches(".dp-year-input")){let i=Number(t.value);if(!Number.isInteger(i)||i<1||i>9999){if(this._connected)this.render(!1);return}this._setDisplay(`${String(i).padStart(4,"0")}-${this.display.slice(5,7)}`)}}_onFocusIn(e){let t=e.target;if(!(t instanceof HTMLTableCellElement)||!t.matches(".dp-day[data-date]"))return;let i=t.dataset.date||"";if(c(i))this._model.focused=i}_onKeyDown(e){let t=e.target;if(!(t instanceof HTMLTableCellElement)||!t.matches(".dp-day[data-date]"))return;let i=t.dataset.date||this.focusedDate;if(e.key==="Enter"||e.key===" "){e.preventDefault(),this._activate(i);return}let s=this._model.focused,n=this._model.display;if(this._model.firstDay=this.firstDay,this._model.setFocused(i,{follow:!1}),e.key==="ArrowLeft")this._model.moveFocusDays(-1);else if(e.key==="ArrowRight")this._model.moveFocusDays(1);else if(e.key==="ArrowUp")this._model.moveFocusDays(-7);else if(e.key==="ArrowDown")this._model.moveFocusDays(7);else if(e.key==="Home")this._model.focusWeekStart();else if(e.key==="End")this._model.focusWeekEnd();else if(e.key==="PageUp")e.shiftKey?this._model.moveFocusYears(-1):this._model.moveFocusMonths(-1);else if(e.key==="PageDown")e.shiftKey?this._model.moveFocusYears(1):this._model.moveFocusMonths(1);else return;let r=this._model.focused;if(this._model.focused=s,this._model.display=n,!r)return;e.preventDefault(),this.focusDate(this._clamp(r))}render(e=!0){if(!this._connected)return;let t=this.locale,i=this.display,s=it(i),n=Number(i.slice(5,7)),r=Te(t,this.monthFormat),a=de(t,this.firstDay,"short"),o=de(t,this.firstDay,"long"),l=this._weeks(),d=O(),u=`${this._id}-heading`,C=`${this._id}-grid`,m=this.min?f(this.min):"",b=this.max?f(this.max):"",E=Boolean(m&&P(i,-1)<m),S=Boolean(b&&P(i,1)>b),x=this.min?` min="${Number(this.min.slice(0,4))}"`:"",_=this.max?` max="${Number(this.max.slice(0,4))}"`:"",g=this.showWeekNumbers&&this.firstDay===1,T=g?`<th scope="col" class="dp-week-heading" abbr="${A(this._messages.week)}">#</th>`:"",v=r.map((D,k)=>{let p=k+1,h=`${String(s).padStart(4,"0")}-${String(p).padStart(2,"0")}`,y=m&&h<m||b&&h>b;return`<option value="${String(p).padStart(2,"0")}"${p===n?" selected":""}${y?" disabled":""}>${A(D)}</option>`}).join(""),H=a.map((D,k)=>`<th scope="col" abbr="${A(o[k])}">${A(D.replace(".",""))}</th>`).join(""),Y=l.map((D)=>{let k=g?`<th scope="row" class="dp-week-number">${ve(D[0])}</th>`:"",p=D.map((h)=>{let y=this.getDateState(h),M=f(h)!==i,F=this.value===h,K=this.focusedDate===h,fe=h===d,pe=we(h,this._highlightedRange),me=nt(pe),Be=typeof y.description==="string"?y.description:"",Pe=[G(h,t),Be,me?this._messages[me]:"",y.disabled?this._messages.unavailable:""].filter(Boolean).join(". ");return`<td class="dp-day" data-date="${h}"${M?' data-outside-month="true"':""}${fe?' data-today="true" aria-current="date"':""}${F?' data-selected="true" aria-selected="true"':""}${st(pe)}${y.disabled?' data-disabled="true" aria-disabled="true"':""} tabindex="${K?"0":"-1"}" aria-label="${A(Pe)}"><span class="dp-day-number" aria-hidden="true">${Number(h.slice(8,10))}</span><span class="dp-day-extra" aria-hidden="true"></span></td>`}).join("");return`<tr>${k}${p}</tr>`}).join(""),z=document.activeElement,V=z instanceof HTMLElement&&this.contains(z)?this._focusTargetKey(z):"",q=Ee(t)[0]==="year";this.toggleAttribute("data-year-first",q);let N=`<label class="dp-visually-hidden" for="${this._id}-month">${A(this._messages.month)}</label>
|
|
491
|
+
<select id="${this._id}-month" class="dp-month-select" aria-label="${A(this._messages.month)}">${v}</select>`,Q=`<label class="dp-visually-hidden" for="${this._id}-year">${A(this._messages.year)}</label>
|
|
492
|
+
<input id="${this._id}-year" class="dp-year-input" type="number" inputmode="numeric" value="${s}"${x}${_} aria-label="${A(this._messages.year)}">`;if(this._rendering=!0,this.innerHTML=`
|
|
445
493
|
<div class="dp-calendar-shell">
|
|
446
494
|
<div class="dp-calendar-header">
|
|
447
|
-
${
|
|
448
|
-
${
|
|
449
|
-
<button type="button" class="dp-nav dp-prev" data-calendar-action="previous" aria-label="${
|
|
450
|
-
<button type="button" class="dp-nav dp-next" data-calendar-action="next" aria-label="${
|
|
495
|
+
${q?Q:N}
|
|
496
|
+
${q?N:Q}
|
|
497
|
+
<button type="button" class="dp-nav dp-prev" data-calendar-action="previous" aria-label="${A(this._messages.previousMonth)}"${E?" disabled":""}><svg aria-hidden="true" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><path d="m10 4-4 4 4 4"/></svg></button>
|
|
498
|
+
<button type="button" class="dp-nav dp-next" data-calendar-action="next" aria-label="${A(this._messages.nextMonth)}"${S?" disabled":""}><svg aria-hidden="true" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><path d="m6 4 4 4-4 4"/></svg></button>
|
|
451
499
|
</div>
|
|
452
|
-
<h2 id="${u}" class="dp-calendar-heading dp-visually-hidden" aria-live="polite">${
|
|
453
|
-
<table id="${
|
|
454
|
-
<thead><tr>${
|
|
455
|
-
<tbody>${
|
|
500
|
+
<h2 id="${u}" class="dp-calendar-heading dp-visually-hidden" aria-live="polite">${A(ke(`${i}-15`,t))}</h2>
|
|
501
|
+
<table id="${C}" class="dp-grid" role="grid" aria-labelledby="${u}">
|
|
502
|
+
<thead><tr>${T}${H}</tr></thead>
|
|
503
|
+
<tbody>${Y}</tbody>
|
|
456
504
|
</table>
|
|
457
|
-
</div>`,this._rendering=!1,z)queueMicrotask(()=>{let h=z;if(h.startsWith(".dp-day[data-date="))h=`.dp-day[data-date="${CSS.escape(this._model.focused)}"]`;let m=this.querySelector(h);if(m instanceof HTMLElement)m.focus()});if(this._renderDay)for(let h of this.querySelectorAll(".dp-day[data-date]")){if(!(h instanceof HTMLTableCellElement))continue;let m=h.dataset.date||"",x=h.querySelector(".dp-day-extra");if(!(x instanceof HTMLElement))continue;let p=this._renderDay(m,this.getDateState(m));if(p instanceof Node)x.append(p);else if(p!==void 0&&p!==null)x.textContent=String(p)}if(e)this._loadDisplay(i)}}function Me(e){return e==="top"||e==="bottom"?"x":"y"}function rt(e){let[t,i=null]=e.split("-");return{side:t,align:i,crossAxis:Me(t)}}function at(e){return{top:"bottom",bottom:"top",left:"right",right:"left"}[e]||e}function ot(e,t,i,s,n,r){let a=Me(i),o=e.x+e.width/2-t.width/2,l=e.y+e.height/2-t.height/2,d=e[a==="x"?"width":"height"]/2-t[a==="x"?"width":"height"]/2,u;switch(i){case"top":u={x:o,y:e.y-t.height-r};break;case"bottom":u={x:o,y:e.y+e.height+r};break;case"right":u={x:e.x+e.width+r,y:l};break;case"left":u={x:e.x-t.width-r,y:l};break;default:u={x:e.x,y:e.y}}if(s==="start"||s==="end"){let k=(n&&a==="x"?-1:1)*(s==="end"?1:-1);u[a]+=d*k}return u}function dt(e,t,i,s){return Math.max(i-e,0)+Math.max(e+t-s,0)}function lt(e){let t="dir"in e?e.dir:"";if(t==="rtl")return!0;if(t==="ltr")return!1;let i=e.ownerDocument?.defaultView;if(i?.CSS?.supports?.("selector(:dir(rtl))")&&typeof e.matches==="function")return e.matches(":dir(rtl)");return Boolean(i?.Element&&e instanceof i.Element&&i.getComputedStyle(e).direction==="rtl")}var ct=25;function ut(e){let t=e.defaultView;if(!t)return null;let i=e.documentElement,s=t.visualViewport,n=s?.offsetLeft||0,r=s?.offsetTop||0,a=s?.width||i.clientWidth||t.innerWidth,o=s?.height||i.clientHeight||t.innerHeight,l=e.compatMode==="BackCompat"?a-i.clientWidth:i.clientWidth-i.getBoundingClientRect().width;if(l>0&&l<=ct){let d=t.getComputedStyle?.(i).scrollbarGutter;if(d&&d!=="auto")a-=l}return{x:n,y:r,width:a,height:o,right:n+a,bottom:r+o}}function ht(e,t){return t.scope?t.scope.getBoundingClientRect():ut(e.ownerDocument)}function ke(e,t,i,s,n){let r=i+n,a=s-t-n,o=a>=r,l=o?r:i,d=o?a:s-t;return Math.max(l,Math.min(e,d))}function Ce(e,t,i){if(!i)return 50;let s=(e-t)/i*100;return Math.round(Math.min(100,Math.max(0,s))*1000)/1000}function ft(e,t){return e.right<t.x||e.left>t.right||e.bottom<t.y||e.top>t.bottom}function pt(e,t,i,s,n){if(t==="top")return Math.max(0,e.top-i.y-s-n);if(t==="bottom")return Math.max(0,i.bottom-e.bottom-s-n);return Math.max(0,i.height-n*2)}function mt(e){if(e.hidden)return!1;if(typeof e.checkVisibility==="function")return e.checkVisibility();return e.getClientRects().length>0}function $e(e){let{offsetWidth:t,offsetHeight:i}=e;if(t&&i)return{width:t,height:i};let s=e.getBoundingClientRect();return{width:t||s.width,height:i||s.height}}var Ae=new WeakMap,Te={scroll:0,resize:1,"element-resize":2};function gt(e){let t=e.defaultView;if(!t)throw TypeError("floating must belong to a document with a browsing context");let i=new Set,s=new Map,n=t.ResizeObserver,r=!1,a=!1,o=t.visualViewport;function l(E,y){let _=s.get(E);if(_===void 0||Te[y]>Te[_])s.set(E,y)}function d(){if(r)return;r=!0,t.requestAnimationFrame(()=>{let E=[...s];s.clear(),r=!1;for(let[y,_]of E){if(!i.has(y)||!y.floating.isConnected)continue;y.callback({type:_})}})}function u(E){for(let y of i)l(y,E);d()}function k(E){if(!n)return null;let y=new Set,_=new n((H)=>{let N=!1;for(let R of H)if(y.has(R.target))N=!0;else y.add(R.target);if(!N)return;l(E,"element-resize"),d()}),{reference:A,floating:w}=E;if(A)_.observe(A);if(w!==A)_.observe(w);return _}let g=()=>u("scroll"),b=()=>u("resize");function C(){if(a)return;e.addEventListener("scroll",g,{passive:!0,capture:!0}),t.addEventListener("resize",b,{passive:!0}),o?.addEventListener("scroll",g,{passive:!0}),o?.addEventListener("resize",b,{passive:!0}),a=!0}function S(){if(!a)return;e.removeEventListener("scroll",g,{capture:!0}),t.removeEventListener("resize",b),o?.removeEventListener("scroll",g),o?.removeEventListener("resize",b),a=!1}return{add(E,y,_){let A={reference:E,floating:y,callback:_};i.add(A),C();let w=k(A),H=!1;return()=>{if(H)return;if(H=!0,i.delete(A),s.delete(A),w?.disconnect(),i.size===0)S()}}}}function _t(e){let t=e.ownerDocument,i=Ae.get(t);if(!i)i=gt(t),Ae.set(t,i);return i}function Fe(e,t,i){if(!t?.ownerDocument)throw TypeError("autoUpdate() expects a floating HTMLElement");if(e&&e.ownerDocument!==t.ownerDocument)throw TypeError("reference and floating must belong to the same document");if(typeof i!=="function")throw TypeError("callback must be a function");return _t(t).add(e,t,i)}function Se(e,t,i){if(!mt(t))return null;let s=i.placement||"bottom-start",n=i.distance||0,r=i.flip!==!1,a=i.shift!==!1,o=i.shiftPadding??4,{side:l,align:d,crossAxis:u}=rt(s),k=d?lt(e):!1,g=e.getClientRects(),b=l==="bottom"?g[g.length-1]:g[0];if(!b)return null;let C=ht(e,i);if(!C||ft(b,C))return null;let S=$e(t),E={x:{size:S.width,start:C.x,end:C.right},y:{size:S.height,start:C.y,end:C.bottom}},y=(v,h)=>ot(b,S,v,h,k,n),_=(v,h)=>{let{size:m,start:x,end:p}=E[h];return dt(v,m,x+o,p-o)},A=(v,h)=>{let{size:m,start:x,end:p}=E[h];return _(a?ke(v,m,x,p,o):v,h)},w=y(l,d);if(r){let v=u==="x"?"y":"x",h=_(w[v],v);if(h>0){let m=at(l),x=y(m,d),p=_(x[v],v);if(p<h)l=m,w=x,h=p}if(v==="x"&&h>0){let m=y("top",d),x=y("bottom",d),p=_(x.y,"y")<_(m.y,"y"),M=p?x:m;if(_(M.y,"y")+A(M.x,"x")<h+A(w.y,"y"))l=p?"bottom":"top",u="x",w=M}}if(u==="x"&&a&&d){let v=_(w.x,"x");if(v>0){let h=d==="end"?"start":"end",m=y(l,h);if(_(m.x,"x")<v)d=h,w=m}}if(a){let{size:v,start:h,end:m}=E[u];w[u]=ke(w[u],v,h,m,o)}let H=Ce(b.x+b.width/2,w.x,S.width),N=Ce(b.y+b.height/2,w.y,S.height),R=`${pt(b,l,C,n,o)}px`,{style:z}=t,W=z.getPropertyValue("--available-height")!==R;z.left=`${w.x}px`,z.top=`${w.y}px`,z.setProperty("--arrow-x",`${H}%`),z.setProperty("--arrow-y",`${N}%`),z.setProperty("--available-height",R);let q=d?`${l}-${d}`:l;return t.dataset.placement=q,{width:S.width,height:S.height,roomChanged:W,placement:q}}function Ie(e,t,i={}){let s=Se(e,t,i);if(!s)return!1;if(s.roomChanged){let n=$e(t);if(n.width!==s.width||n.height!==s.height)Se(e,t,{...i,placement:s.placement,flip:!1})}return!0}class Z{constructor(e,t={}){this.input=e,this.messages=t.messages||{},this.adapter=K(t.locale||""),this.hidden=null,this.canonical="",this._dirty=!1,this._commitId=0,this._originalName=e.getAttribute("name")||"",this._attributeObserver=null,this.onAttributesChanged=null,this.confirm=null}setLocale(e){this.adapter=K(e||"")}setMessages(e){this.messages=e||{}}format(e){return this.adapter.format(e)}parse(e){return this.adapter.parse(e)}get placeholder(){return this.adapter.placeholder}get isDisabled(){return this.input.disabled}get isReadOnly(){return this.input.readOnly}setupFormValue(){let e=this.input;this._originalName=e.getAttribute("name")||"",this._attributeObserver=new MutationObserver(()=>this.onAttributesChanged?.()),this._attributeObserver.observe(e,{attributes:!0,attributeFilter:["disabled","readonly","name","form"]}),this.syncInputState()}syncInputState(){let e=this.input,t=e.getAttribute("name")||"";if(t){if(!this.hidden){let i=document.createElement("input");i.type="hidden",i.value=this.canonical,e.insertAdjacentElement("afterend",i),this.hidden=i}if(this.hidden)this.hidden.name=t;e.removeAttribute("name")}if(this.hidden){if(e.hasAttribute("form"))this.hidden.setAttribute("form",e.getAttribute("form")||"");else this.hidden.removeAttribute("form");this.hidden.disabled=e.disabled}}dirty(){this._commitId++}get isDirty(){return this._dirty}handleInput(){let e=this.input;if(this._dirty=!0,this.dirty(),this.hidden)this.hidden.value="";let t=e.value.trim();if(!t){e.setCustomValidity("");return}let i=this.canonical?this.adapter.format(this.canonical):"";e.setCustomValidity(t===i?"":this.messages.invalidDate)}async commit(){let e=this.input,t=++this._commitId,i=e.value.trim();if(!i){if(t!==this._commitId)return{status:"stale"};return e.setCustomValidity(""),{status:"clear",value:""}}let s=this.adapter.parse(i);if(!s){if(t!==this._commitId)return{status:"stale"};if(this.hidden)this.hidden.value="";return e.setCustomValidity(this.messages.invalidDate),{status:"invalid"}}if(this.confirm){let n=await this.confirm(s);if(t!==this._commitId)return{status:"stale"};if(!n?.ok){if(this.hidden)this.hidden.value="";return e.setCustomValidity(n?.message||this.messages.unavailableDate),{status:"invalid"}}}return{status:"ok",value:s}}setCanonical(e,t={}){let i=e||"";if(i&&!c(i))throw TypeError(`Invalid date-picker value: ${i}`);if(this.dirty(),this.canonical=i,this._dirty=!1,this.hidden)this.hidden.value=i;if(t.format!==!1)this.input.value=i?this.adapter.format(i):"";this.input.setCustomValidity("")}restoreDefault(){let e=String(this.input.defaultValue??"").trim(),t=c(e)?e:this.adapter.parse(e);return t&&c(t)?t:""}teardown(){this._attributeObserver?.disconnect(),this._attributeObserver=null;let e=this.hidden?.getAttribute("name")||this._originalName;if(e)this.input.setAttribute("name",e);this.hidden?.remove(),this.hidden=null}}var yt=/^(\d{2}):(\d{2})(?::(\d{2})(?:\.(\d{1,3}))?)?$/;function ae(e){let t=yt.exec(String(e||""));if(!t)return null;let i=Number(t[1]),s=Number(t[2]),n=t[3]===void 0?0:Number(t[3]),r=t[4]===void 0?0:Number(t[4].padEnd(3,"0"));if(i>23||s>59||n>59||r>999)return null;return{hour:i,minute:s,second:n,millisecond:r}}function oe(e){return ae(e)!==null}function Le(e){return((e.hour*60+e.minute)*60+e.second)*1000+e.millisecond}function Oe(e,t){let i=ae(e),s=ae(t);if(!i||!s)throw TypeError("compareTimes() expects HH:MM values");let n=Le(i)-Le(s);return n===0?0:n<0?-1:1}var bt=0;class de extends HTMLElement{static observedAttributes=["value","locale","min","max","open-on-focus","month-format"];constructor(){super();this._id=`date-picker-${++bt}`,this._connected=!1,this._reflecting=!1,this._value="",this._input=null,this._field=null,this._fields=null,this._range=null,this._orderTags=new Set,this._timeFields=[null,null],this._timeOrderOwned=new Set,this._lastFocusEndpoint="",this._rangeCommitId=0,this._pendingIntents=new Map,this._button=null,this._panel=null,this._calendar=null,this._originalDescribedBy="",this._rangeOriginalDescribedBy=["",""],this._formatHint=null,this._generatedPlaceholder=!1,this._controller=null,this._stopTracking=null,this._open=!1,this._suppressFocusOpen=!1,this._messages=Y(),this._source=null,this._dateState=null,this._renderDay=null,this._isDateDisabled=null}_rangeMode(){return this.hasAttribute("range")&&Boolean(this._range)}connectedCallback(){if(this._connected)return;if(this.hasAttribute("range")){this._connectRange();return}this._connectSingle()}_connectSingle(){let e=this.querySelector(":scope > input:not([type=hidden]):not([type=time]):not([data-time-start]):not([data-time-end])");if(!(e instanceof HTMLInputElement)){console.warn("<date-picker> expects a direct child text input");return}this._connected=!0,this._input=e,this._discoverTimeFields(),this._field=new Z(e,{messages:this._messages,locale:this.locale}),this._field.onAttributesChanged=()=>this._syncInputState(),this._field.confirm=(s)=>this._confirmDate(s),this._setupFormValue(),this._build(),this._syncInputState(),this._bind(),this._syncCalendarOptions();let t=this._adapter(),i=this.getAttribute("value")||(c(e.value)?e.value:t.parse(e.value));if(i&&c(i))this._setValue(i,{emit:!1,format:!0});else if(!e.value)this._setValue("",{emit:!1,format:!1});else e.setCustomValidity(this._messages.invalidDate);if(this._field.hidden)this._field.hidden.defaultValue=this._value;if(e.getAttribute("value")==null&&e.defaultValue==="")e.defaultValue=e.value}_discoverTimeFields(){this._timeFields=[null,null];let e=["data-time-start","data-time-end"];for(let[t,i]of e.entries()){let s=this.querySelectorAll(`:scope > input[${i}]`);if(s.length>1)console.warn(`<date-picker> expects at most one direct child input[${i}]; ignoring extras`);let n=s[0];if(n==null)continue;if(!(n instanceof HTMLInputElement)||n.type!=="time"){console.warn(`<date-picker> input[${i}] must be an <input type="time">; ignoring it`);continue}this._timeFields[t]=n}if(this.querySelector(":scope > input[type=time]:not([data-time-start]):not([data-time-end])"))console.warn("<date-picker> time inputs need [data-time-start] or [data-time-end]; ignoring it")}_connectRange(){if(this.querySelector(":scope > input[data-time-start], :scope > input[data-time-end]"))console.warn("<date-picker range> time companions are not supported yet; leaving them native");let e=this.querySelector(":scope > input[data-range-start]"),t=this.querySelector(":scope > input[data-range-end]");if(!(e instanceof HTMLInputElement)||!(t instanceof HTMLInputElement)){console.warn("<date-picker range> expects direct child inputs marked [data-range-start] and [data-range-end]");return}this._connected=!0,this._input=null,this._fields=[new Z(e,{messages:this._messages,locale:this.locale}),new Z(t,{messages:this._messages,locale:this.locale})],this._range=new ne,this._rangeOriginalDescribedBy=[e.getAttribute("aria-describedby")||"",t.getAttribute("aria-describedby")||""];for(let r of this._fields)r.onAttributesChanged=()=>this._syncRangeFields(),r.confirm=(a)=>this._confirmDate(a),r.setupFormValue();this._build(t),this._setRangeAria(),this._syncRangeFields(),this._bindRange(),this._syncCalendarOptions();let i=this._adapter(),s=c(e.value)?e.value:i.parse(e.value),n=c(t.value)?t.value:i.parse(t.value);if(this._setRange(s||"",n||"",{emit:!1}),e.value.trim()&&!c(s))e.setCustomValidity(this._messages.invalidDate);if(t.value.trim()&&!c(n))t.setCustomValidity(this._messages.invalidDate);if(this._fields[0].hidden)this._fields[0].hidden.defaultValue=this._range.start;if(this._fields[1].hidden)this._fields[1].hidden.defaultValue=this._range.end;if(e.getAttribute("value")==null&&e.defaultValue==="")e.defaultValue=e.value;if(t.getAttribute("value")==null&&t.defaultValue==="")t.defaultValue=t.value}disconnectedCallback(){if(this._connected=!1,this.hide(!1),this._controller?.abort(),this._controller=null,this._clearTimeOrderValidity(),this._timeFields=[null,null],this._rangeMode()){for(let e of this._fields||[])this._teardownField(e);this._fields=null,this._range=null}else this._teardownField(this._field);this._field=null,this._button?.remove(),this._panel?.remove(),this._formatHint?.remove(),this._button=null,this._panel=null,this._calendar=null,this._formatHint=null}_teardownField(e){if(!e)return;let t=e.input,i=this._fields?.includes(e)?this._rangeOriginalDescribedBy[this._fields?.indexOf(e)??0]||"":this._originalDescribedBy;if(e.teardown(),i)t.setAttribute("aria-describedby",i);else t.removeAttribute("aria-describedby");t.removeAttribute("role"),t.removeAttribute("aria-haspopup"),t.removeAttribute("aria-expanded"),t.removeAttribute("aria-controls")}attributeChangedCallback(e,t,i){if(!this._connected||this._reflecting||t===i)return;if(e==="value"){if(this._rangeMode())return;if(!i||c(i))this._setValue(i||"",{emit:!1,format:!0,reflect:!1});return}if(e==="locale")this._refreshLocale();if(e==="open-on-focus")return;this._syncCalendarOptions(),this.validate()}get input(){return this._rangeMode()?void 0:this._input}get calendar(){return this._calendar}get value(){return this._rangeMode()?void 0:this._value}set value(e){if(this._rangeMode())throw TypeError("value is not available in range mode; use range");if(e&&!c(e))throw TypeError(`Invalid date-picker value: ${e}`);this._setValue(e||"",{emit:!1,format:!0})}get range(){return this._rangeMode()&&this._range?{...this._range.range}:void 0}set range(e){if(!this._rangeMode())throw TypeError("range is only available on <date-picker range>");let{start:t,end:i}=te(e);this._setRange(t,i)}get locale(){return O(this.getAttribute("locale")||"")}set locale(e){if(e)this.setAttribute("locale",e);else this.removeAttribute("locale")}get monthFormat(){return this.getAttribute("month-format")==="short"?"short":"long"}set monthFormat(e){if(e==="short")this.setAttribute("month-format","short");else this.removeAttribute("month-format")}get min(){let e=this.getAttribute("min")||"";return c(e)?e:""}set min(e){if(e)this.setAttribute("min",e);else this.removeAttribute("min")}get max(){let e=this.getAttribute("max")||"";return c(e)?e:""}set max(e){if(e)this.setAttribute("max",e);else this.removeAttribute("max")}get openOnFocus(){return this.getAttribute("open-on-focus")!=="false"}set openOnFocus(e){if(e===!1)this.setAttribute("open-on-focus","false");else this.removeAttribute("open-on-focus")}get open(){return this._open}get messages(){return this._messages}set messages(e){if(this._messages={...Y(),...e||{}},this._calendar)this._calendar.messages=this._messages;for(let t of this._fields||[])t.setMessages(this._messages);this._field?.setMessages(this._messages),this._refreshButtonLabel(),this.validate()}get source(){return this._source}set source(e){if(this._source=e||null,this._calendar)this._calendar.source=this._source;if(this._connected)this.validate()}get dateState(){return this._dateState}set dateState(e){if(this._dateState=typeof e==="function"?e:null,this._calendar)this._calendar.dateState=this._dateState;if(this._connected)this.validate()}get renderDay(){return this._renderDay}set renderDay(e){if(this._renderDay=typeof e==="function"?e:null,this._calendar)this._calendar.renderDay=this._renderDay}get isDateDisabled(){return this._isDateDisabled}set isDateDisabled(e){if(this._isDateDisabled=typeof e==="function"?e:null,this._calendar)this._calendar.isDateDisabled=this._isDateDisabled;if(this._connected)this.validate()}_adapter(){return this._field?.adapter??this._fields?.[0]?.adapter??K(this.locale)}_setupFormValue(){this._field?.setupFormValue()}_syncInputState(){let e=this._input;if(!e)return;if(this._field?.syncInputState(),this._button)this._button.disabled=e.disabled||e.readOnly;if(this._open&&(e.disabled||e.readOnly))this.hide(!1)}_syncRangeFields(){if(!this._fields)return;for(let i of this._fields)i.syncInputState();let e=this._range?.activeEndpoint==="end"?1:0,t=this._fields.every((i)=>i.input.disabled||i.input.readOnly);if(this._button)this._button.disabled=t;if(this._open&&(this._fields[e]?.input.disabled||this._fields[e]?.input.readOnly))this.hide(!1)}_setRangeAria(){if(!this._fields||!this._panel||!this._formatHint)return;for(let e of this._fields){let t=e.input,i=[this._rangeOriginalDescribedBy[this._fields.indexOf(e)],this._formatHint.id].filter(Boolean).join(" ");t.setAttribute("aria-describedby",i),t.setAttribute("role","combobox"),t.setAttribute("aria-haspopup","dialog"),t.setAttribute("aria-expanded","false"),t.setAttribute("aria-controls",this._panel.id)}}_build(e){let t=e||this._input;if(!t)return;let i=`${this._id}-panel`,s=`${this._id}-format`,n=document.createElement("button");n.type="button",n.className="dp-picker-button",n.setAttribute("aria-haspopup","dialog"),n.setAttribute("aria-expanded","false"),n.setAttribute("aria-controls",i),n.innerHTML='<span aria-hidden="true"><svg viewBox="0 0 16 16" width="1em" height="1em" fill="none" stroke="currentColor" stroke-width="1.4" stroke-linecap="round"><rect x="1.75" y="3" width="12.5" height="11" rx="1.75"/><path d="M1.75 6.75h12.5"/><path d="M5.25 1.75v2.5M10.75 1.75v2.5"/></svg></span>';let r=document.createElement("div");r.id=i,r.className="dp-picker-panel",r.setAttribute("popover","manual"),r.setAttribute("role","dialog"),r.setAttribute("aria-label",this._messages.calendar);let a=new G;a.selection="none",a.fixedWeeks=!0,r.append(a);let o=document.createElement("span");if(o.id=s,o.className="dp-visually-hidden",t.insertAdjacentElement("afterend",n),n.insertAdjacentElement("afterend",r),r.insertAdjacentElement("afterend",o),this._button=n,this._panel=r,this._calendar=a,this._formatHint=o,!this._rangeMode()){this._originalDescribedBy=t.getAttribute("aria-describedby")||"";let l=[this._originalDescribedBy,s].filter(Boolean).join(" ");t.setAttribute("aria-describedby",l),t.setAttribute("role","combobox"),t.setAttribute("aria-haspopup","dialog"),t.setAttribute("aria-expanded","false"),t.setAttribute("aria-controls",i)}this._refreshLocale(),this._refreshButtonLabel()}_bind(){let e=this._input,t=this._button,i=this._calendar;if(!e||!t||!i)return;let s=new AbortController;this._controller=s;let{signal:n}=s;e.addEventListener("input",()=>{this._field?.handleInput()},{signal:n}),e.addEventListener("change",()=>void this._commitText(!1),{signal:n}),e.addEventListener("blur",()=>void this._commitText(!1),{signal:n}),e.addEventListener("focus",(r)=>{if(!this.openOnFocus||this._suppressFocusOpen)return;let a=r.relatedTarget;if(a instanceof Node&&this.contains(a))return;if(!this._open)this.show({moveFocus:!1})},{signal:n}),e.addEventListener("keydown",(r)=>{this._onFieldKeyDown("",r)},{signal:n});for(let[r,a]of this._timeFields.entries()){if(!a)continue;let o=r===1?"end":"start";a.addEventListener("input",()=>this._revalidateTimeOrder(o),{signal:n}),a.addEventListener("change",()=>this._revalidateTimeOrder(o),{signal:n})}t.addEventListener("click",(r)=>{if(this._open){if(r.detail===0){setTimeout(()=>this._calendar?.focusGrid(),0);return}this.hide(!1);return}this.show()},{signal:n}),i.addEventListener("dateactivate",(r)=>{let a=r,o=a.detail?.date;if(!c(o))return;queueMicrotask(()=>{if(a.defaultPrevented||!this._connected)return;if(this._input?.disabled||this._input?.readOnly)return;this._field?.dirty(),this._setValue(o,{emit:!0,format:!0}),this.hide(!1),this._focusInput()})},{signal:n}),i.addEventListener("dateloadend",()=>void this.validate(),{signal:n}),this.ownerDocument.addEventListener("pointerdown",(r)=>{if(!this._open||r.composedPath().includes(this))return;this.hide(!1)},{capture:!0,signal:n}),this.ownerDocument.addEventListener("reset",(r)=>{let a=r.target;if(a instanceof HTMLFormElement&&this._input&&a===this._input.form)this.hide(!1),queueMicrotask(()=>{if(!r.defaultPrevented)this._restoreDefault()})},{capture:!0,signal:n}),this.addEventListener("keydown",(r)=>this._onEscape(r),{signal:n})}_bindRange(){let e=this._button,t=this._calendar;if(!this._fields||!e||!t)return;let i=new AbortController;this._controller=i;let{signal:s}=i;for(let[n,r]of this._fields.entries()){let a=n===1?"end":"start";r.input.addEventListener("input",()=>r.handleInput(),{signal:s}),r.input.addEventListener("change",()=>void this._commitFieldText(a),{signal:s}),r.input.addEventListener("blur",()=>void this._commitFieldText(a),{signal:s}),r.input.addEventListener("focus",(o)=>this._onFieldFocus(a,o),{signal:s}),r.input.addEventListener("keydown",(o)=>this._onFieldKeyDown(a,o),{signal:s})}e.addEventListener("click",(n)=>{if(this._open){if(n.detail===0){setTimeout(()=>this._calendar?.focusGrid(),0);return}this.hide(!1);return}this.show()},{signal:s}),t.addEventListener("click",(n)=>this._captureGridIntent(n),{capture:!0,signal:s}),t.addEventListener("keydown",(n)=>this._captureGridIntent(n),{capture:!0,signal:s}),t.addEventListener("dateactivate",(n)=>{let r=n,a=r.detail?.date;if(!c(a))return;queueMicrotask(()=>{if(r.defaultPrevented||!this._connected||!this._range)return;let o=this._pendingIntents.get(a);if(o===void 0||o!==this._rangeCommitId)return;this._pendingIntents.delete(a);let l=this._range.activate(a,(d)=>{let u=d==="end"?1:0,k=this._fields?.[u];return k!=null&&!k.input.disabled&&!k.input.readOnly});if(l.status==="refused"){this._calendar?.dispatchEvent(new CustomEvent("dateinvalid",{detail:{date:a,state:this._calendar.getDateState(a)},bubbles:!0}));return}if(this._setBound(l.endpoint,a,{emit:!0,user:!0}),l.close||l.status==="complete")this.hide(!1),this._focusField(l.endpoint)})},{signal:s}),t.addEventListener("dateloadend",()=>void this.validate(),{signal:s}),this.ownerDocument.addEventListener("pointerdown",(n)=>{if(!this._open||n.composedPath().includes(this))return;this.hide(!1)},{capture:!0,signal:s}),this.ownerDocument.addEventListener("reset",(n)=>{let r=n.target;if(r instanceof HTMLFormElement&&this._fields&&r===this._fields[0].input.form)this.hide(!1),queueMicrotask(()=>{if(!n.defaultPrevented)this._restoreRangeDefault()})},{capture:!0,signal:s}),this.addEventListener("keydown",(n)=>this._onEscape(n),{signal:s})}_onFieldKeyDown(e,t){if(t.key==="ArrowDown"||t.altKey&&t.key==="ArrowDown"){if(t.preventDefault(),this._rangeMode()&&e)this._lastFocusEndpoint=e,this._range?.focus(e);if(this._open)setTimeout(()=>this._calendar?.focusGrid(),0);else this.show()}else if(t.key==="Escape"&&this._open)t.preventDefault(),this.hide(!1)}_onFieldFocus(e,t){if(!this._rangeMode()||!e)return;let i=e!==this._range?.activeEndpoint;if(this._lastFocusEndpoint=e,this._range?.focus(e),i)this._rangeCommitId++,this._pendingIntents.clear();if(!this.openOnFocus||this._suppressFocusOpen)return;let s=t.relatedTarget;if(s instanceof Node&&this.contains(s))return;if(!this._open)this.show({moveFocus:!1})}_captureGridIntent(e){if(!this._rangeMode()||!this._range)return;if(e.type==="keydown"){let s=e.key;if(s!=="Enter"&&s!==" ")return}if(!(e.target instanceof Element))return;let i=e.target.closest(".dp-day[data-date]")?.getAttribute("data-date")||"";if(!c(i))return;this._pendingIntents.set(i,++this._rangeCommitId)}_onEscape(e){if(e.key==="Escape"&&this._open)e.preventDefault(),e.stopPropagation(),this.hide(!0)}_syncCalendarOptions(){let e=this._calendar,t=this._panel;if(!e)return;if(e.locale=this.locale,e.min=this.min,e.max=this.max,e.monthFormat=this.monthFormat,e.messages=this._messages,e.source=this._source,e.dateState=this._dateState,e.renderDay=this._renderDay,e.isDateDisabled=this._isDateDisabled,!this._rangeMode()&&this._value)e.value=this._value;if(t)t.setAttribute("aria-label",this._messages.calendar)}_refreshLocale(){let e=this._formatHint;if(!e)return;if(this._rangeMode()&&this._fields){this._fields[0].setLocale(this.locale),this._fields[1].setLocale(this.locale),e.textContent=`${this._messages.formatHint}: ${this._fields[0].placeholder}`;for(let[i,s]of this._fields.entries()){if(!s.input.hasAttribute("placeholder")||this._generatedPlaceholder)s.input.placeholder=s.placeholder,this._generatedPlaceholder=!0;let n=i===1?this._range?.end||"":this._range?.start||"";if(n)s.input.value=s.format(n)}this._refreshButtonLabel();return}let t=this._field;if(!t)return;if(t.setLocale(this.locale),e.textContent=`${this._messages.formatHint}: ${t.placeholder}`,!t.input.hasAttribute("placeholder")||this._generatedPlaceholder)t.input.placeholder=t.placeholder,this._generatedPlaceholder=!0;if(this._value)t.input.value=t.format(this._value);this._refreshButtonLabel()}_refreshButtonLabel(){if(!this._button)return;if(this._rangeMode()){this._refreshRangeButtonLabel();return}let e=this._value?this._messages.changeDate:this._messages.chooseDate,t=this._value?`, ${U(this._value,this.locale)}`:"";this._button.setAttribute("aria-label",`${e}${t}`)}_refreshRangeButtonLabel(){if(!this._button||!this._range)return;let{start:e,end:t}=this._range,i=Boolean(e&&t),s=i?this._messages.changeDate:this._messages.chooseDate,n=i?`, ${U(e,this.locale)} – ${U(t,this.locale)}`:"";this._button.setAttribute("aria-label",`${s}${n}`)}_reflectValue(e){if(this._reflecting=!0,e)this.setAttribute("value",e);else this.removeAttribute("value");this._reflecting=!1}_setValue(e,t={}){if(e&&!c(e))throw TypeError(`Invalid date-picker value: ${e}`);let i=this._value;if(this._value=e||"",t.reflect!==!1)this._reflectValue(this._value);if(this._field?.setCanonical(this._value,{format:t.format!==!1}),this._calendar){if(this._calendar.value=this._value,this._value)this._calendar.focusedDate=this._value}if(this._refreshButtonLabel(),i!==this._value){if(this.dispatchEvent(new CustomEvent("valuechange",{detail:{value:this._value},bubbles:!0})),t.emit&&this._field){let s=this._field.input;s.dispatchEvent(new Event("input",{bubbles:!0})),s.dispatchEvent(new Event("change",{bubbles:!0}))}}}async _confirmDate(e){let t=this._calendar;if(!t)return{ok:!0};let i=f(e);if(t.display!==i)t.display=i;let s=await t.ensureDate(e),n=t.getDateState(e);if(!s||n.disabled)return{ok:!1,message:this._messages.unavailableDate};return{ok:!0}}async _commitText(e,t={}){let i=this._field;if(!i)return!1;if(!t.force&&!i.isDirty)return!1;let s=await i.commit();if(s.status==="stale"||s.status==="invalid")return!1;return this._setValue(s.value||"",{emit:e,format:s.status==="ok"}),!0}async _commitFieldText(e){let t=this._fields;if(!t)return!1;let i=e==="end"?1:0,s=t[i];if(!s?.isDirty)return!1;let n=await s.commit();if(n.status==="stale")return!1;if(n.status==="invalid")return this._orderTags.delete(i),!1;return this._setBound(e,n.value||"",{emit:!0,user:!0,format:n.status==="ok"}),!0}_setBound(e,t,i={}){if(!this._range)return!1;let s=this._fields;if(!s)return!1;let r=s[e==="end"?1:0];if(!r)return!1;if(i.user===!0&&(r.input.disabled||r.input.readOnly))return!1;let a=t||"",o=r.canonical;if(r.setCanonical(a,{format:i.format!==!1}),e==="end")this._range.end=a;else this._range.start=a;let l=o!==a;if(l){if(this._syncHighlight(),this._refreshRangeButtonLabel(),this._emitRangeChange(),i.emit)r.input.dispatchEvent(new Event("input",{bubbles:!0})),r.input.dispatchEvent(new Event("change",{bubbles:!0}))}return this._revalidateRange(e),l}_setRange(e,t,i={}){if(!this._range||!this._fields)return;if(this._range.start=e||"",this._range.end=t||"",this._fields[0].setCanonical(e||"",{format:i.format!==!1}),this._fields[1].setCanonical(t||"",{format:i.format!==!1}),this._syncHighlight(),this._refreshRangeButtonLabel(),this._revalidateRange("start"),this._revalidateRange("end"),i.emit!==!1)this._emitRangeChange()}_boundCanonical(e){return this._range?e==="end"?this._range.end:this._range.start:""}_emitRangeChange(){if(!this._range)return;this.dispatchEvent(new CustomEvent("rangechange",{detail:{...this._range.range},bubbles:!0}))}_syncHighlight(){if(!this._calendar||!this._range)return;let{start:e,end:t}=this._range;if(!e){this._calendar.highlightedRange={start:"",end:""};return}if(t&&D(t,e)<0)this._calendar.highlightedRange={start:e,end:""};else this._calendar.highlightedRange={start:e,end:t}}_revalidateRange(e){if(!this._fields||!this._range)return;let{start:t,end:i}=this._range,s=Boolean(t&&i&&D(i,t)<0),n=["start","end"];for(let r of n){let a=r==="end"?1:0,o=this._fields[a].input,l=r==="end"?this._messages.rangeOrderEnd:this._messages.rangeOrderStart;if(s&&r===e)o.setCustomValidity(l),this._orderTags.add(a);else if(this._orderTags.has(a))o.setCustomValidity(""),this._orderTags.delete(a)}}_revalidateTimeOrder(e){let[t,i]=this._timeFields,s=["start","end"],n=[t,i],r=t&&!t.disabled?t.value.trim():"",a=i&&!i.disabled?i.value.trim():"",o=Boolean(t&&i&&r&&a)&&oe(r)&&oe(a)&&Oe(a,r)<0;for(let[l,d]of s.entries()){let u=n[l];if(!u)continue;let k=d==="end"?this._messages.rangeOrderEnd:this._messages.rangeOrderStart;if(o&&d===e)u.setCustomValidity(k),this._timeOrderOwned.add(u);else if(this._timeOrderOwned.has(u))u.setCustomValidity(""),this._timeOrderOwned.delete(u)}}_clearTimeOrderValidity(){for(let e of this._timeOrderOwned)e.setCustomValidity("");this._timeOrderOwned.clear()}_restoreDefault(){let e=this._field;if(!e)return;let t=e.restoreDefault();if(this._setValue(t,{emit:!1,format:!0}),this._calendar)if(this._value)this._calendar.display=f(this._value),this._calendar.focusedDate=this._value;else this._calendar.display=f(L()),this._calendar.focusedDate=L();this.validate()}_restoreRangeDefault(){if(!this._fields)return;let e=this._fields[0].restoreDefault(),t=this._fields[1].restoreDefault();if(this._setRange(e,t),this._calendar){let i=this._range?.start||L();this._calendar.display=f(i),this._calendar.focusedDate=i}this.validate()}_focusField(e){let t=e==="end"?1:0,i=this._fields?.[t]?.input;if(!i)return;this._suppressFocusOpen=!0,setTimeout(()=>{i.focus(),this._suppressFocusOpen=!1},0)}_focusInput(){this._suppressFocusOpen=!0,setTimeout(()=>{this._input?.focus(),this._suppressFocusOpen=!1},0)}_resolveRangeEndpoint(){if(!this._fields)return"";let e=this._lastFocusEndpoint||"start",t=e==="end"?1:0;if(!this._fields[t].input.disabled&&!this._fields[t].input.readOnly)return e;let i=e==="end"?"start":"end",s=i==="end"?1:0;if(!this._fields[s].input.disabled&&!this._fields[s].input.readOnly)return i;return""}async validate(){if(this._rangeMode()){let i=this._fields;if(!i)return!0;for(let[s,n]of i.entries()){let r=await n.commit();if(r.status==="ok"||r.status==="clear"){let a=s===1?"end":"start";this._setBound(a,r.value||"",{format:r.status==="ok"})}}return this._revalidateRange("start"),this._revalidateRange("end"),i.every((s)=>s.input.checkValidity())}let e=this._field?.input;if(!e)return!0;if(!e.value.trim())e.setCustomValidity("");else await this._commitText(!1,{force:!0});this._revalidateTimeOrder("start"),this._revalidateTimeOrder("end");let t=this._timeFields.every((i)=>i?.checkValidity()??!0);return e.checkValidity()&&t}show(e={}){let t=this._panel,i=this._calendar,s=this._button;if(!t||!i||!s||this._open)return;if(this._rangeMode()){let r=this._resolveRangeEndpoint();if(!r)return;this._range?.focus(r),this._rangeCommitId++,this._pendingIntents.clear();let a=this._boundCanonical(r)||L();i.display=f(a),i.focusedDate=a,this._lastFocusEndpoint=r}else{let r=this._input;if(!r||r.disabled||r.readOnly)return;let a=this._value||this._adapter().parse(r.value)||L();i.display=f(a),i.focusedDate=a}t.showPopover(),this._open=!0,this._setExpanded(!0);let n=()=>Ie(this,t,{placement:"bottom-start",distance:4,shiftPadding:8});if(n(),this._stopTracking=Fe(this,t,n),e.moveFocus!==!1)queueMicrotask(()=>i.focusGrid());this.dispatchEvent(new Event("open",{bubbles:!0}))}_setExpanded(e){let t=e?"true":"false";this._input?.setAttribute("aria-expanded",t),this._button?.setAttribute("aria-expanded",t);for(let i of this._fields||[])i.input.setAttribute("aria-expanded",t)}hide(e=!1){if(!this._panel||!this._open)return;this._stopTracking?.(),this._stopTracking=null;try{this._panel.hidePopover()}catch{}if(this._open=!1,this._setExpanded(!1),this._rangeCommitId++,this._pendingIntents.clear(),e)if(this._rangeMode()){let t=this._restoreFocusEndpoint();if(t)this._focusField(t)}else this._focusInput();this.dispatchEvent(new Event("close",{bubbles:!0}))}_restoreFocusEndpoint(){let e=this._range?.activeEndpoint||"";if(e){let t=e==="end"?1:0,i=this._fields?.[t];if(i&&!i.input.disabled&&!i.input.readOnly)return e}return this._resolveRangeEndpoint()}}function le(){if(!customElements.get("date-calendar"))customElements.define("date-calendar",G);if(!customElements.get("date-picker"))customElements.define("date-picker",de)}le();var Re="lekoala-date-picker-styles";if(!document.getElementById(Re)){let e=document.createElement("style");e.id=Re,e.textContent=fe,document.head.append(e)}le();})();
|
|
505
|
+
</div>`,this._rendering=!1,V)queueMicrotask(()=>{let D=V;if(D.startsWith(".dp-day[data-date="))D=`.dp-day[data-date="${CSS.escape(this._model.focused)}"]`;let k=this.querySelector(D);if(k instanceof HTMLElement)k.focus()});if(this._renderDay)for(let D of this.querySelectorAll(".dp-day[data-date]")){if(!(D instanceof HTMLTableCellElement))continue;let k=D.dataset.date||"",p=D.querySelector(".dp-day-extra");if(!(p instanceof HTMLElement))continue;let h=this._renderDay(k,this.getDateState(k));if(h instanceof Node)p.append(h);else if(h!==void 0&&h!==null)p.textContent=String(h)}if(e)this._loadDisplay(i)}}function Le(e){return e==="top"||e==="bottom"?"x":"y"}function rt(e){let[t,i=null]=e.split("-");return{side:t,align:i,crossAxis:Le(t)}}function at(e){return{top:"bottom",bottom:"top",left:"right",right:"left"}[e]||e}function ot(e,t,i,s,n,r){let a=Le(i),o=e.x+e.width/2-t.width/2,l=e.y+e.height/2-t.height/2,d=e[a==="x"?"width":"height"]/2-t[a==="x"?"width":"height"]/2,u;switch(i){case"top":u={x:o,y:e.y-t.height-r};break;case"bottom":u={x:o,y:e.y+e.height+r};break;case"right":u={x:e.x+e.width+r,y:l};break;case"left":u={x:e.x-t.width-r,y:l};break;default:u={x:e.x,y:e.y}}if(s==="start"||s==="end"){let C=(n&&a==="x"?-1:1)*(s==="end"?1:-1);u[a]+=d*C}return u}function dt(e,t,i,s){return Math.max(i-e,0)+Math.max(e+t-s,0)}function lt(e){let t="dir"in e?e.dir:"";if(t==="rtl")return!0;if(t==="ltr")return!1;let i=e.ownerDocument?.defaultView;if(i?.CSS?.supports?.("selector(:dir(rtl))")&&typeof e.matches==="function")return e.matches(":dir(rtl)");return Boolean(i?.Element&&e instanceof i.Element&&i.getComputedStyle(e).direction==="rtl")}var ct=25;function ut(e){let t=e.defaultView;if(!t)return null;let i=e.documentElement,s=t.visualViewport,n=s?.offsetLeft||0,r=s?.offsetTop||0,a=s?.width||i.clientWidth||t.innerWidth,o=s?.height||i.clientHeight||t.innerHeight,l=e.compatMode==="BackCompat"?a-i.clientWidth:i.clientWidth-i.getBoundingClientRect().width;if(l>0&&l<=ct){let d=t.getComputedStyle?.(i).scrollbarGutter;if(d&&d!=="auto")a-=l}return{x:n,y:r,width:a,height:o,right:n+a,bottom:r+o}}function ht(e,t){return t.scope?t.scope.getBoundingClientRect():ut(e.ownerDocument)}function Ae(e,t,i,s,n){let r=i+n,a=s-t-n,o=a>=r,l=o?r:i,d=o?a:s-t;return Math.max(l,Math.min(e,d))}function Se(e,t,i){if(!i)return 50;let s=(e-t)/i*100;return Math.round(Math.min(100,Math.max(0,s))*1000)/1000}function ft(e,t){return e.right<t.x||e.left>t.right||e.bottom<t.y||e.top>t.bottom}function pt(e,t,i,s,n){if(t==="top")return Math.max(0,e.top-i.y-s-n);if(t==="bottom")return Math.max(0,i.bottom-e.bottom-s-n);return Math.max(0,i.height-n*2)}function mt(e){if(e.hidden)return!1;if(typeof e.checkVisibility==="function")return e.checkVisibility();return e.getClientRects().length>0}function Ie(e){let{offsetWidth:t,offsetHeight:i}=e;if(t&&i)return{width:t,height:i};let s=e.getBoundingClientRect();return{width:t||s.width,height:i||s.height}}var Me=new WeakMap,Fe={scroll:0,resize:1,"element-resize":2};function gt(e){let t=e.defaultView;if(!t)throw TypeError("floating must belong to a document with a browsing context");let i=new Set,s=new Map,n=t.ResizeObserver,r=!1,a=!1,o=t.visualViewport;function l(x,_){let g=s.get(x);if(g===void 0||Fe[_]>Fe[g])s.set(x,_)}function d(){if(r)return;r=!0,t.requestAnimationFrame(()=>{let x=[...s];s.clear(),r=!1;for(let[_,g]of x){if(!i.has(_)||!_.floating.isConnected)continue;_.callback({type:g})}})}function u(x){for(let _ of i)l(_,x);d()}function C(x){if(!n)return null;let _=new Set,g=new n((H)=>{let Y=!1;for(let z of H)if(_.has(z.target))Y=!0;else _.add(z.target);if(!Y)return;l(x,"element-resize"),d()}),{reference:T,floating:v}=x;if(T)g.observe(T);if(v!==T)g.observe(v);return g}let m=()=>u("scroll"),b=()=>u("resize");function E(){if(a)return;e.addEventListener("scroll",m,{passive:!0,capture:!0}),t.addEventListener("resize",b,{passive:!0}),o?.addEventListener("scroll",m,{passive:!0}),o?.addEventListener("resize",b,{passive:!0}),a=!0}function S(){if(!a)return;e.removeEventListener("scroll",m,{capture:!0}),t.removeEventListener("resize",b),o?.removeEventListener("scroll",m),o?.removeEventListener("resize",b),a=!1}return{add(x,_,g){let T={reference:x,floating:_,callback:g};i.add(T),E();let v=C(T),H=!1;return()=>{if(H)return;if(H=!0,i.delete(T),s.delete(T),v?.disconnect(),i.size===0)S()}}}}function _t(e){let t=e.ownerDocument,i=Me.get(t);if(!i)i=gt(t),Me.set(t,i);return i}function Oe(e,t,i){if(!t?.ownerDocument)throw TypeError("autoUpdate() expects a floating HTMLElement");if(e&&e.ownerDocument!==t.ownerDocument)throw TypeError("reference and floating must belong to the same document");if(typeof i!=="function")throw TypeError("callback must be a function");return _t(t).add(e,t,i)}function $e(e,t,i){if(!mt(t))return null;let s=i.placement||"bottom-start",n=i.distance||0,r=i.flip!==!1,a=i.shift!==!1,o=i.shiftPadding??4,{side:l,align:d,crossAxis:u}=rt(s),C=d?lt(e):!1,m=e.getClientRects(),b=l==="bottom"?m[m.length-1]:m[0];if(!b)return null;let E=ht(e,i);if(!E||ft(b,E))return null;let S=Ie(t),x={x:{size:S.width,start:E.x,end:E.right},y:{size:S.height,start:E.y,end:E.bottom}},_=(p,h)=>ot(b,S,p,h,C,n),g=(p,h)=>{let{size:y,start:M,end:F}=x[h];return dt(p,y,M+o,F-o)},T=(p,h)=>{let{size:y,start:M,end:F}=x[h];return g(a?Ae(p,y,M,F,o):p,h)},v=_(l,d);if(r){let p=u==="x"?"y":"x",h=g(v[p],p);if(h>0){let y=at(l),M=_(y,d),F=g(M[p],p);if(F<h)l=y,v=M,h=F}if(p==="x"&&h>0){let y=_("top",d),M=_("bottom",d),F=g(M.y,"y")<g(y.y,"y"),K=F?M:y;if(g(K.y,"y")+T(K.x,"x")<h+T(v.y,"y"))l=F?"bottom":"top",u="x",v=K}}if(u==="x"&&a&&d){let p=g(v.x,"x");if(p>0){let h=d==="end"?"start":"end",y=_(l,h);if(g(y.x,"x")<p)d=h,v=y}}if(a){let{size:p,start:h,end:y}=x[u];v[u]=Ae(v[u],p,h,y,o)}let H=Se(b.x+b.width/2,v.x,S.width),Y=Se(b.y+b.height/2,v.y,S.height),z=`${pt(b,l,E,n,o)}px`,{style:V}=t,q=V.getPropertyValue("--available-height")!==z,N=i.coordinateSpace==="document"?e.ownerDocument.defaultView:null,Q=N?N.scrollX:0,D=N?N.scrollY:0;V.left=`${v.x+Q}px`,V.top=`${v.y+D}px`,V.setProperty("--arrow-x",`${H}%`),V.setProperty("--arrow-y",`${Y}%`),V.setProperty("--available-height",z);let k=d?`${l}-${d}`:l;return t.dataset.placement=k,{width:S.width,height:S.height,roomChanged:q,placement:k}}function Re(e,t,i={}){let s=$e(e,t,i);if(!s)return!1;if(s.roomChanged){let n=Ie(t);if(n.width!==s.width||n.height!==s.height)$e(e,t,{...i,placement:s.placement,flip:!1})}return!0}class J{constructor(e,t={}){this.input=e,this.messages=t.messages||{},this.adapter=X(t.locale||""),this.hidden=null,this.canonical="",this._dirty=!1,this._commitId=0,this._originalName=e.getAttribute("name")||"",this._attributeObserver=null,this.onAttributesChanged=null,this.confirm=null}setLocale(e){this.adapter=X(e||"")}setMessages(e){this.messages=e||{}}format(e){return this.adapter.format(e)}parse(e){return this.adapter.parse(e)}get placeholder(){return this.adapter.placeholder}get isDisabled(){return this.input.disabled}get isReadOnly(){return this.input.readOnly}setupFormValue(){let e=this.input;this._originalName=e.getAttribute("name")||"",this._attributeObserver=new MutationObserver(()=>this.onAttributesChanged?.()),this._attributeObserver.observe(e,{attributes:!0,attributeFilter:["disabled","readonly","name","form"]}),this.syncInputState()}syncInputState(){let e=this.input,t=e.getAttribute("name")||"";if(t){if(!this.hidden){let i=document.createElement("input");i.type="hidden",i.value=this.canonical,e.insertAdjacentElement("afterend",i),this.hidden=i}if(this.hidden)this.hidden.name=t;e.removeAttribute("name")}if(this.hidden){if(e.hasAttribute("form"))this.hidden.setAttribute("form",e.getAttribute("form")||"");else this.hidden.removeAttribute("form");this.hidden.disabled=e.disabled}}dirty(){this._commitId++}get isDirty(){return this._dirty}handleInput(){let e=this.input,t=e.value.trim(),i=this.canonical?this.adapter.format(this.canonical):"";if(this.dirty(),t===i){if(this._dirty=!1,this.hidden)this.hidden.value=this.canonical;e.setCustomValidity("");return}if(this._dirty=!0,this.hidden)this.hidden.value="";if(!t){e.setCustomValidity("");return}e.setCustomValidity(t===i?"":this.messages.invalidDate)}async commit(){let e=this.input,t=++this._commitId,i=e.value.trim();if(!i){if(t!==this._commitId)return{status:"stale"};return e.setCustomValidity(""),{status:"clear",value:""}}let s=this.adapter.parse(i);if(!s){if(t!==this._commitId)return{status:"stale"};if(this.hidden)this.hidden.value="";return e.setCustomValidity(this.messages.invalidDate),{status:"invalid"}}if(this.confirm){let n=await this.confirm(s);if(t!==this._commitId)return{status:"stale"};if(!n?.ok){if(this.hidden)this.hidden.value="";return e.setCustomValidity(n?.message||this.messages.unavailableDate),{status:"invalid"}}}return{status:"ok",value:s}}setCanonical(e,t={}){let i=e||"";if(i&&!c(i))throw TypeError(`Invalid date-picker value: ${i}`);if(this.dirty(),this.canonical=i,this._dirty=!1,this.hidden)this.hidden.value=i;if(t.format!==!1)this.input.value=i?this.adapter.format(i):"";this.input.setCustomValidity("")}restoreDefault(){let e=String(this.input.defaultValue??"").trim(),t=c(e)?e:this.adapter.parse(e);return t&&c(t)?t:""}teardown(){this._attributeObserver?.disconnect(),this._attributeObserver=null;let e=this.hidden?.getAttribute("name")||this._originalName;if(e)this.input.setAttribute("name",e);this.hidden?.remove(),this.hidden=null}}var yt=/^(\d{2}):(\d{2})(?::(\d{2})(?:\.(\d{1,3}))?)?$/;function le(e){let t=yt.exec(String(e||""));if(!t)return null;let i=Number(t[1]),s=Number(t[2]),n=t[3]===void 0?0:Number(t[3]),r=t[4]===void 0?0:Number(t[4].padEnd(3,"0"));if(i>23||s>59||n>59||r>999)return null;return{hour:i,minute:s,second:n,millisecond:r}}function ce(e){return le(e)!==null}function ze(e){return((e.hour*60+e.minute)*60+e.second)*1000+e.millisecond}function Ve(e,t){let i=le(e),s=le(t);if(!i||!s)throw TypeError("compareTimes() expects HH:MM values");let n=ze(i)-ze(s);return n===0?0:n<0?-1:1}var bt=0;class ue extends HTMLElement{static observedAttributes=["value","locale","min","max","open-on-focus","month-format"];constructor(){super();this._id=`date-picker-${++bt}`,this._connected=!1,this._reflecting=!1,this._value="",this._input=null,this._field=null,this._fields=null,this._range=null,this._orderTags=new Set,this._timeFields=[null,null],this._timeOrderOwned=new Set,this._lastFocusEndpoint="",this._rangeCommitId=0,this._pendingIntents=new Map,this._buttons=[],this._returnFocus=null,this._panel=null,this._calendar=null,this._originalDescribedBy="",this._rangeOriginalDescribedBy=["",""],this._formatHint=null,this._generatedPlaceholder=!1,this._controller=null,this._stopTracking=null,this._open=!1,this._suppressFocusOpen=!1,this._messages=W(),this._source=null,this._dateState=null,this._renderDay=null,this._isDateDisabled=null,this._coordinateSpace="viewport"}_rangeMode(){return this.hasAttribute("range")&&Boolean(this._range)}connectedCallback(){if(this._connected)return;if(this.hasAttribute("range")){this._connectRange();return}this._connectSingle()}_connectSingle(){let e=this.querySelector(":scope > input:not([type=hidden]):not([type=time]):not([data-time-start]):not([data-time-end])");if(!(e instanceof HTMLInputElement)){console.warn("<date-picker> expects a direct child text input");return}this._connected=!0,this._input=e,this._discoverTimeFields(),this._field=new J(e,{messages:this._messages,locale:this.locale}),this._field.onAttributesChanged=()=>this._syncInputState(),this._field.confirm=(s)=>this._confirmDate(s),this._setupFormValue(),this._build(),this._syncInputState(),this._bind(),this._syncCalendarOptions();let t=this._adapter(),i=this.getAttribute("value")||(c(e.value)?e.value:t.parse(e.value));if(i&&c(i))this._setValue(i,{emit:!1,format:!0});else if(!e.value)this._setValue("",{emit:!1,format:!1});else e.setCustomValidity(this._messages.invalidDate);if(this._field.hidden)this._field.hidden.defaultValue=this._value;if(e.getAttribute("value")==null&&e.defaultValue==="")e.defaultValue=e.value}_discoverTimeFields(){this._timeFields=[null,null];let e=["data-time-start","data-time-end"];for(let[t,i]of e.entries()){let s=this.querySelectorAll(`:scope > input[${i}]`);if(s.length>1)console.warn(`<date-picker> expects at most one direct child input[${i}]; ignoring extras`);let n=s[0];if(n==null)continue;if(!(n instanceof HTMLInputElement)||n.type!=="time"){console.warn(`<date-picker> input[${i}] must be an <input type="time">; ignoring it`);continue}this._timeFields[t]=n}if(this.querySelector(":scope > input[type=time]:not([data-time-start]):not([data-time-end])"))console.warn("<date-picker> time inputs need [data-time-start] or [data-time-end]; ignoring it")}_connectRange(){if(this.querySelector(":scope > input[data-time-start], :scope > input[data-time-end]"))console.warn("<date-picker range> time companions are not supported yet; leaving them native");let e=this.querySelector(":scope > input[data-range-start]"),t=this.querySelector(":scope > input[data-range-end]");if(!(e instanceof HTMLInputElement)||!(t instanceof HTMLInputElement)){console.warn("<date-picker range> expects direct child inputs marked [data-range-start] and [data-range-end]");return}this._connected=!0,this._input=null,this._fields=[new J(e,{messages:this._messages,locale:this.locale}),new J(t,{messages:this._messages,locale:this.locale})],this._range=new oe,this._rangeOriginalDescribedBy=[e.getAttribute("aria-describedby")||"",t.getAttribute("aria-describedby")||""];for(let r of this._fields)r.onAttributesChanged=()=>this._syncRangeFields(),r.confirm=(a)=>this._confirmDate(a),r.setupFormValue();this._build(),this._setRangeAria(),this._syncRangeFields(),this._bindRange(),this._syncCalendarOptions();let i=this._adapter(),s=c(e.value)?e.value:i.parse(e.value),n=c(t.value)?t.value:i.parse(t.value);if(this._setRange(s||"",n||"",{emit:!1}),e.value.trim()&&!c(s))e.setCustomValidity(this._messages.invalidDate);if(t.value.trim()&&!c(n))t.setCustomValidity(this._messages.invalidDate);if(this._fields[0].hidden)this._fields[0].hidden.defaultValue=this._range.start;if(this._fields[1].hidden)this._fields[1].hidden.defaultValue=this._range.end;if(e.getAttribute("value")==null&&e.defaultValue==="")e.defaultValue=e.value;if(t.getAttribute("value")==null&&t.defaultValue==="")t.defaultValue=t.value}disconnectedCallback(){if(this._connected=!1,this.hide(!1),this._controller?.abort(),this._controller=null,this._clearTimeOrderValidity(),this._timeFields=[null,null],this._rangeMode()){for(let e of this._fields||[])this._teardownField(e);this._fields=null,this._range=null}else this._teardownField(this._field);this._field=null;for(let{button:e}of this._buttons)e.remove();this._buttons=[],this._returnFocus=null,this._panel?.remove(),this._formatHint?.remove(),this._panel=null,this._calendar=null,this._formatHint=null}_teardownField(e){if(!e)return;let t=e.input,i=this._fields?.includes(e)?this._rangeOriginalDescribedBy[this._fields?.indexOf(e)??0]||"":this._originalDescribedBy;if(e.teardown(),i)t.setAttribute("aria-describedby",i);else t.removeAttribute("aria-describedby");t.removeAttribute("role"),t.removeAttribute("aria-haspopup"),t.removeAttribute("aria-expanded"),t.removeAttribute("aria-controls")}attributeChangedCallback(e,t,i){if(!this._connected||this._reflecting||t===i)return;if(e==="value"){if(this._rangeMode())return;if(!i||c(i))this._setValue(i||"",{emit:!1,format:!0,reflect:!1});return}if(e==="locale")this._refreshLocale();if(e==="open-on-focus")return;this._syncCalendarOptions(),this.validate()}get input(){return this._rangeMode()?void 0:this._input}get calendar(){return this._calendar}get value(){return this._rangeMode()?void 0:this._value}set value(e){if(this._rangeMode())throw TypeError("value is not available in range mode; use range");if(e&&!c(e))throw TypeError(`Invalid date-picker value: ${e}`);this._setValue(e||"",{emit:!1,format:!0})}get range(){return this._rangeMode()&&this._range?{...this._range.range}:void 0}set range(e){if(!this._rangeMode())throw TypeError("range is only available on <date-picker range>");let{start:t,end:i}=ne(e);this._setRange(t,i)}get locale(){return R(this.getAttribute("locale")||"")}set locale(e){if(e)this.setAttribute("locale",e);else this.removeAttribute("locale")}get monthFormat(){return this.getAttribute("month-format")==="short"?"short":"long"}set monthFormat(e){if(e==="short")this.setAttribute("month-format","short");else this.removeAttribute("month-format")}get min(){let e=this.getAttribute("min")||"";return c(e)?e:""}set min(e){if(e)this.setAttribute("min",e);else this.removeAttribute("min")}get max(){let e=this.getAttribute("max")||"";return c(e)?e:""}set max(e){if(e)this.setAttribute("max",e);else this.removeAttribute("max")}get openOnFocus(){return this.getAttribute("open-on-focus")!=="false"}set openOnFocus(e){if(e===!1)this.setAttribute("open-on-focus","false");else this.removeAttribute("open-on-focus")}get open(){return this._open}get messages(){return this._messages}set messages(e){if(this._messages={...W(),...e||{}},this._calendar)this._calendar.messages=this._messages;for(let t of this._fields||[])t.setMessages(this._messages);this._field?.setMessages(this._messages),this._refreshButtonLabel(),this.validate()}get source(){return this._source}set source(e){if(this._source=e||null,this._calendar)this._calendar.source=this._source;if(this._connected)this.validate()}get dateState(){return this._dateState}set dateState(e){if(this._dateState=typeof e==="function"?e:null,this._calendar)this._calendar.dateState=this._dateState;if(this._connected)this.validate()}get renderDay(){return this._renderDay}set renderDay(e){if(this._renderDay=typeof e==="function"?e:null,this._calendar)this._calendar.renderDay=this._renderDay}get isDateDisabled(){return this._isDateDisabled}set isDateDisabled(e){if(this._isDateDisabled=typeof e==="function"?e:null,this._calendar)this._calendar.isDateDisabled=this._isDateDisabled;if(this._connected)this.validate()}get coordinateSpace(){return this._coordinateSpace}set coordinateSpace(e){this._coordinateSpace=e==="document"?"document":"viewport"}_adapter(){return this._field?.adapter??this._fields?.[0]?.adapter??X(this.locale)}_setupFormValue(){this._field?.setupFormValue()}_syncInputState(){let e=this._input;if(!e)return;this._field?.syncInputState();let t=this._buttons[0]?.button;if(t)t.disabled=e.disabled||e.readOnly;if(this._open&&(e.disabled||e.readOnly))this.hide(!1)}_syncRangeFields(){if(!this._fields)return;for(let t of this._fields)t.syncInputState();for(let{button:t,endpoint:i}of this._buttons){let s=i==="end"?1:0,n=this._fields[s];t.disabled=Boolean(n?.input.disabled||n?.input.readOnly)}let e=this._range?.activeEndpoint==="end"?1:0;if(this._open&&(this._fields[e]?.input.disabled||this._fields[e]?.input.readOnly))this.hide(!1)}_setRangeAria(){if(!this._fields||!this._panel||!this._formatHint)return;for(let e of this._fields){let t=e.input,i=[this._rangeOriginalDescribedBy[this._fields.indexOf(e)],this._formatHint.id].filter(Boolean).join(" ");t.setAttribute("aria-describedby",i),t.setAttribute("role","combobox"),t.setAttribute("aria-haspopup","dialog"),t.setAttribute("aria-expanded","false"),t.setAttribute("aria-controls",this._panel.id)}}_createTrigger(e){let t=document.createElement("button");if(t.type="button",t.className="dp-picker-button",t.setAttribute("aria-haspopup","dialog"),t.setAttribute("aria-expanded","false"),t.setAttribute("aria-controls",`${this._id}-panel`),e)t.dataset.endpoint=e;return t.innerHTML='<span aria-hidden="true"><svg viewBox="0 0 16 16" width="1em" height="1em" fill="none" stroke="currentColor" stroke-width="1.4" stroke-linecap="round"><rect x="1.75" y="3" width="12.5" height="11" rx="1.75"/><path d="M1.75 6.75h12.5"/><path d="M5.25 1.75v2.5M10.75 1.75v2.5"/></svg></span>',t}_build(){let e=this._rangeMode(),t=[];if(e)for(let[o,l]of(this._fields||[]).entries())t.push([l.input,o===1?"end":"start"]);else if(this._input)t.push([this._input,""]);if(!t.length)return;let i=`${this._id}-panel`,s=`${this._id}-format`;this._buttons=t.map(([o,l])=>{let d=this._createTrigger(l);return o.insertAdjacentElement("afterend",d),{button:d,endpoint:l}});let n=document.createElement("div");n.id=i,n.className="dp-picker-panel",n.setAttribute("popover","manual"),n.setAttribute("role","dialog"),n.setAttribute("aria-label",this._messages.calendar);let r=new Z;r.selection="none",r.fixedWeeks=!0,n.append(r);let a=document.createElement("span");if(a.id=s,a.className="dp-visually-hidden",this.append(n,a),this._panel=n,this._calendar=r,this._formatHint=a,!e&&this._input){this._originalDescribedBy=this._input.getAttribute("aria-describedby")||"";let o=[this._originalDescribedBy,s].filter(Boolean).join(" ");this._input.setAttribute("aria-describedby",o),this._input.setAttribute("role","combobox"),this._input.setAttribute("aria-haspopup","dialog"),this._input.setAttribute("aria-expanded","false"),this._input.setAttribute("aria-controls",i)}this._refreshLocale(),this._refreshButtonLabel()}_bind(){let e=this._input,t=this._buttons[0]?.button,i=this._calendar;if(!e||!t||!i)return;let s=new AbortController;this._controller=s;let{signal:n}=s;e.addEventListener("input",()=>{this._field?.handleInput()},{signal:n}),e.addEventListener("change",()=>void this._commitText(!1),{signal:n}),e.addEventListener("blur",()=>void this._commitText(!1),{signal:n}),e.addEventListener("focus",(r)=>{if(!this.openOnFocus||this._suppressFocusOpen)return;let a=r.relatedTarget;if(a instanceof Node&&this.contains(a))return;if(!this._open)this.show({moveFocus:!1})},{signal:n}),e.addEventListener("keydown",(r)=>{this._onFieldKeyDown("",r)},{signal:n});for(let[r,a]of this._timeFields.entries()){if(!a)continue;let o=r===1?"end":"start";a.addEventListener("input",()=>this._revalidateTimeOrder(o),{signal:n}),a.addEventListener("change",()=>this._revalidateTimeOrder(o),{signal:n})}t.addEventListener("click",(r)=>{if(this._open){if(r.detail===0){setTimeout(()=>this._calendar?.focusGrid(),0);return}this.hide(!1);return}this.show({returnFocus:t})},{signal:n}),t.addEventListener("keydown",(r)=>this._onTriggerKeyDown("",r),{signal:n}),i.addEventListener("dateactivate",(r)=>{let a=r,o=a.detail?.date;if(!c(o))return;queueMicrotask(()=>{if(a.defaultPrevented||!this._connected)return;if(this._input?.disabled||this._input?.readOnly)return;this._field?.dirty(),this._setValue(o,{emit:!0,format:!0}),this.hide(!1),this._restoreFocus()})},{signal:n}),i.addEventListener("dateloadend",()=>void this.validate(),{signal:n}),this.ownerDocument.addEventListener("pointerdown",(r)=>{if(!this._open||r.composedPath().includes(this))return;this.hide(!1)},{capture:!0,signal:n}),this.ownerDocument.addEventListener("reset",(r)=>{let a=r.target;if(a instanceof HTMLFormElement&&this._input&&a===this._input.form)this.hide(!1),queueMicrotask(()=>{if(!r.defaultPrevented)this._restoreDefault()})},{capture:!0,signal:n}),this.addEventListener("keydown",(r)=>this._onEscape(r),{signal:n})}_bindRange(){let e=this._calendar;if(!this._fields||!this._buttons.length||!e)return;let t=new AbortController;this._controller=t;let{signal:i}=t;for(let[s,n]of this._fields.entries()){let r=s===1?"end":"start";n.input.addEventListener("input",()=>n.handleInput(),{signal:i}),n.input.addEventListener("change",()=>void this._commitFieldText(r),{signal:i}),n.input.addEventListener("blur",()=>void this._commitFieldText(r),{signal:i}),n.input.addEventListener("focus",(a)=>this._onFieldFocus(r,a),{signal:i}),n.input.addEventListener("keydown",(a)=>this._onFieldKeyDown(r,a),{signal:i})}for(let s of this._buttons){let n=s.endpoint;if(n==="")continue;s.button.addEventListener("click",(r)=>this._onRangeTriggerClick(n,r),{signal:i}),s.button.addEventListener("keydown",(r)=>this._onTriggerKeyDown(n,r),{signal:i})}e.addEventListener("click",(s)=>this._captureGridIntent(s),{capture:!0,signal:i}),e.addEventListener("keydown",(s)=>this._captureGridIntent(s),{capture:!0,signal:i}),e.addEventListener("dateactivate",(s)=>{let n=s,r=n.detail?.date;if(!c(r))return;queueMicrotask(()=>{if(n.defaultPrevented||!this._connected||!this._range)return;let a=this._pendingIntents.get(r);if(a===void 0||a!==this._rangeCommitId)return;this._pendingIntents.delete(r);let o=this._range.activate(r,(l)=>{let d=l==="end"?1:0,u=this._fields?.[d];return u!=null&&!u.input.disabled&&!u.input.readOnly});if(o.status==="refused"){this._calendar?.dispatchEvent(new CustomEvent("dateinvalid",{detail:{date:r,state:this._calendar.getDateState(r)},bubbles:!0}));return}if(this._setBound(o.endpoint,r,{emit:!0,user:!0}),o.close||o.status==="complete")this.hide(!1),this._focusField(o.endpoint)})},{signal:i}),e.addEventListener("dateloadend",()=>void this.validate(),{signal:i}),this.ownerDocument.addEventListener("pointerdown",(s)=>{if(!this._open||s.composedPath().includes(this))return;this.hide(!1)},{capture:!0,signal:i}),this.ownerDocument.addEventListener("reset",(s)=>{let n=s.target;if(n instanceof HTMLFormElement&&this._fields&&n===this._fields[0].input.form)this.hide(!1),queueMicrotask(()=>{if(!s.defaultPrevented)this._restoreRangeDefault()})},{capture:!0,signal:i}),this.addEventListener("keydown",(s)=>this._onEscape(s),{signal:i})}_activateRangeEndpoint(e){let t=this._calendar;if(!this._range||!t)return;this._range.focus(e),this._rangeCommitId++,this._pendingIntents.clear(),this._lastFocusEndpoint=e;let i=this._boundCanonical(e)||O();t.display=f(i),t.focusedDate=i}_onRangeTriggerClick(e,t){if(!this._open){this.show({endpoint:e});return}if(t.detail===0){this._activateRangeEndpoint(e),setTimeout(()=>this._calendar?.focusGrid(),0);return}if(e!==this._range?.activeEndpoint){this._activateRangeEndpoint(e);return}this.hide(!1)}_onTriggerKeyDown(e,t){if(t.key!=="ArrowDown")return;if(t.preventDefault(),this._open){if(this._rangeMode()&&e)this._activateRangeEndpoint(e);setTimeout(()=>this._calendar?.focusGrid(),0);return}if(this._rangeMode())this.show({endpoint:e||void 0});else this.show({returnFocus:this._buttons[0]?.button})}_onFieldKeyDown(e,t){if(t.key==="ArrowDown"){if(t.preventDefault(),this._rangeMode()&&e)this._lastFocusEndpoint=e,this._range?.focus(e);if(this._open)setTimeout(()=>this._calendar?.focusGrid(),0);else this.show()}else if(t.key==="Escape"&&this._open)t.preventDefault(),this.hide(!1)}_onFieldFocus(e,t){if(!this._rangeMode()||!e)return;let i=e!==this._range?.activeEndpoint;if(this._lastFocusEndpoint=e,this._range?.focus(e),i)this._rangeCommitId++,this._pendingIntents.clear();if(!this.openOnFocus||this._suppressFocusOpen)return;let s=t.relatedTarget;if(s instanceof Node&&this.contains(s))return;if(!this._open)this.show({moveFocus:!1})}_captureGridIntent(e){if(!this._rangeMode()||!this._range)return;if(e.type==="keydown"){let s=e.key;if(s!=="Enter"&&s!==" ")return}if(!(e.target instanceof Element))return;let i=e.target.closest(".dp-day[data-date]")?.getAttribute("data-date")||"";if(!c(i))return;this._pendingIntents.clear(),this._pendingIntents.set(i,++this._rangeCommitId)}_onEscape(e){if(e.key==="Escape"&&this._open)e.preventDefault(),e.stopPropagation(),this.hide(!0)}_syncCalendarOptions(){let e=this._calendar,t=this._panel;if(!e)return;if(e.locale=this.locale,e.min=this.min,e.max=this.max,e.monthFormat=this.monthFormat,e.messages=this._messages,e.source=this._source,e.dateState=this._dateState,e.renderDay=this._renderDay,e.isDateDisabled=this._isDateDisabled,!this._rangeMode()&&this._value)e.value=this._value;if(t)t.setAttribute("aria-label",this._messages.calendar)}_refreshLocale(){let e=this._formatHint;if(!e)return;if(this._rangeMode()&&this._fields){this._fields[0].setLocale(this.locale),this._fields[1].setLocale(this.locale),e.textContent=`${this._messages.formatHint}: ${this._fields[0].placeholder}`;for(let[i,s]of this._fields.entries()){if(!s.input.hasAttribute("placeholder")||this._generatedPlaceholder)s.input.placeholder=s.placeholder,this._generatedPlaceholder=!0;let n=i===1?this._range?.end||"":this._range?.start||"";if(n)s.input.value=s.format(n)}this._refreshButtonLabel();return}let t=this._field;if(!t)return;if(t.setLocale(this.locale),e.textContent=`${this._messages.formatHint}: ${t.placeholder}`,!t.input.hasAttribute("placeholder")||this._generatedPlaceholder)t.input.placeholder=t.placeholder,this._generatedPlaceholder=!0;if(this._value)t.input.value=t.format(this._value);this._refreshButtonLabel()}_refreshButtonLabel(){let e=this._buttons[0]?.button;if(!e)return;if(this._rangeMode()){this._refreshRangeButtonLabel();return}let t=this._value?this._messages.changeDate:this._messages.chooseDate,i=this._value?`, ${G(this._value,this.locale)}`:"";e.setAttribute("aria-label",`${t}${i}`)}_refreshRangeButtonLabel(){if(!this._range)return;let{start:e,end:t}=this._range;for(let{button:i,endpoint:s}of this._buttons){let n=s==="end"?t:e,r=n?this._messages.changeDate:this._messages.chooseDate,a=n?`, ${G(n,this.locale)}`:"",o=s==="end"?this._messages.rangeEnd:this._messages.rangeStart;i.setAttribute("aria-label",`${r}${a}, ${o}`)}}_reflectValue(e){if(this._reflecting=!0,e)this.setAttribute("value",e);else this.removeAttribute("value");this._reflecting=!1}_setValue(e,t={}){if(e&&!c(e))throw TypeError(`Invalid date-picker value: ${e}`);let i=this._value;if(this._value=e||"",t.reflect!==!1)this._reflectValue(this._value);if(this._field?.setCanonical(this._value,{format:t.format!==!1}),this._calendar){if(this._calendar.value=this._value,this._value)this._calendar.focusedDate=this._value}if(this._refreshButtonLabel(),i!==this._value){if(this.dispatchEvent(new CustomEvent("valuechange",{detail:{value:this._value},bubbles:!0})),t.emit&&this._field){let s=this._field.input;s.dispatchEvent(new Event("input",{bubbles:!0})),s.dispatchEvent(new Event("change",{bubbles:!0}))}}}async _confirmDate(e){let t=this._calendar;if(!t)return{ok:!0};let i=f(e);if(t.display!==i)t.display=i;let s=await t.ensureDate(e),n=t.getDateState(e);if(!s||n.disabled)return{ok:!1,message:this._messages.unavailableDate};return{ok:!0}}async _commitText(e,t={}){let i=this._field;if(!i)return!1;if(!t.force&&!i.isDirty)return!1;let s=await i.commit();if(s.status==="stale"||s.status==="invalid")return!1;return this._setValue(s.value||"",{emit:e,format:s.status==="ok"}),!0}async _commitFieldText(e){let t=this._fields;if(!t)return!1;let i=e==="end"?1:0,s=t[i];if(!s?.isDirty)return!1;let n=await s.commit();if(n.status==="stale")return!1;if(n.status==="invalid")return this._orderTags.delete(i),!1;return this._setBound(e,n.value||"",{emit:!1,user:!0,format:n.status==="ok"}),!0}_setBound(e,t,i={}){if(!this._range)return!1;let s=this._fields;if(!s)return!1;let r=s[e==="end"?1:0];if(!r)return!1;if(i.user===!0&&(r.input.disabled||r.input.readOnly))return!1;let a=t||"",o=r.canonical;if(r.setCanonical(a,{format:i.format!==!1}),e==="end")this._range.end=a;else this._range.start=a;let l=o!==a;if(l){if(this._syncHighlight(),this._refreshRangeButtonLabel(),this._emitRangeChange(),i.emit)r.input.dispatchEvent(new Event("input",{bubbles:!0})),r.input.dispatchEvent(new Event("change",{bubbles:!0}))}return this._revalidateRange(e),l}_setRange(e,t,i={}){if(!this._range||!this._fields)return;if(this._range.start=e||"",this._range.end=t||"",this._fields[0].setCanonical(e||"",{format:i.format!==!1}),this._fields[1].setCanonical(t||"",{format:i.format!==!1}),this._syncHighlight(),this._refreshRangeButtonLabel(),this._revalidateRange("start"),this._revalidateRange("end"),i.emit!==!1)this._emitRangeChange()}_boundCanonical(e){return this._range?e==="end"?this._range.end:this._range.start:""}_emitRangeChange(){if(!this._range)return;this.dispatchEvent(new CustomEvent("rangechange",{detail:{...this._range.range},bubbles:!0}))}_syncHighlight(){if(!this._calendar||!this._range)return;let{start:e,end:t}=this._range;if(!e){this._calendar.highlightedRange={start:"",end:""};return}if(t&&w(t,e)<0)this._calendar.highlightedRange={start:e,end:""};else this._calendar.highlightedRange={start:e,end:t}}_revalidateRange(e){if(!this._fields||!this._range)return;let{start:t,end:i}=this._range,s=Boolean(t&&i&&w(i,t)<0),n=["start","end"];for(let r of n){let a=r==="end"?1:0,o=this._fields[a].input,l=r==="end"?this._messages.rangeOrderEnd:this._messages.rangeOrderStart;if(s&&r===e)o.setCustomValidity(l),this._orderTags.add(a);else if(this._orderTags.has(a))o.setCustomValidity(""),this._orderTags.delete(a)}}_revalidateTimeOrder(e){let[t,i]=this._timeFields,s=["start","end"],n=[t,i],r=t&&!t.disabled?t.value.trim():"",a=i&&!i.disabled?i.value.trim():"",o=Boolean(t&&i&&r&&a)&&ce(r)&&ce(a)&&Ve(a,r)<0;for(let[l,d]of s.entries()){let u=n[l];if(!u)continue;let C=d==="end"?this._messages.rangeOrderEnd:this._messages.rangeOrderStart;if(o&&d===e)u.setCustomValidity(C),this._timeOrderOwned.add(u);else if(this._timeOrderOwned.has(u))u.setCustomValidity(""),this._timeOrderOwned.delete(u)}}_clearTimeOrderValidity(){for(let e of this._timeOrderOwned)e.setCustomValidity("");this._timeOrderOwned.clear()}_restoreDefault(){let e=this._field;if(!e)return;let t=e.restoreDefault();if(this._setValue(t,{emit:!1,format:!0}),this._calendar)if(this._value)this._calendar.display=f(this._value),this._calendar.focusedDate=this._value;else this._calendar.display=f(O()),this._calendar.focusedDate=O();this.validate()}_restoreRangeDefault(){if(!this._fields)return;let e=this._fields[0].restoreDefault(),t=this._fields[1].restoreDefault();if(this._setRange(e,t),this._calendar){let i=this._range?.start||O();this._calendar.display=f(i),this._calendar.focusedDate=i}this.validate()}_focusField(e){let t=e==="end"?1:0,i=this._fields?.[t]?.input;if(!i)return;this._suppressFocusOpen=!0,setTimeout(()=>{i.focus(),this._suppressFocusOpen=!1},0)}_restoreFocus(){let e=this._returnFocus;if(this._returnFocus=null,!(e instanceof HTMLElement)||!e.isConnected||e.matches(":disabled"))return;this._suppressFocusOpen=!0,setTimeout(()=>{e.focus(),this._suppressFocusOpen=!1},0)}_resolveRangeEndpoint(){if(!this._fields)return"";let e=this._lastFocusEndpoint||"start",t=e==="end"?1:0;if(!this._fields[t].input.disabled&&!this._fields[t].input.readOnly)return e;let i=e==="end"?"start":"end",s=i==="end"?1:0;if(!this._fields[s].input.disabled&&!this._fields[s].input.readOnly)return i;return""}async validate(){if(this._rangeMode()){let i=this._fields;if(!i)return!0;for(let[s,n]of i.entries()){let r=await n.commit();if(r.status==="ok"||r.status==="clear"){let a=s===1?"end":"start";this._setBound(a,r.value||"",{format:r.status==="ok"})}}return this._revalidateRange("start"),this._revalidateRange("end"),i.every((s)=>s.input.checkValidity())}let e=this._field?.input;if(!e)return!0;if(!e.value.trim())e.setCustomValidity("");else await this._commitText(!1,{force:!0});this._revalidateTimeOrder("start"),this._revalidateTimeOrder("end");let t=this._timeFields.every((i)=>i?.checkValidity()??!0);return e.checkValidity()&&t}show(e={}){let t=this._panel,i=this._calendar;if(!t||!i||!this._buttons.length||this._open)return;if(this._rangeMode()){let r=e.endpoint||this._resolveRangeEndpoint();if(!r)return;this._activateRangeEndpoint(r)}else{let r=this._input;if(!r||r.disabled||r.readOnly)return;let a=this._value||this._adapter().parse(r.value)||O();i.display=f(a),i.focusedDate=a,this._returnFocus=e.returnFocus instanceof HTMLElement?e.returnFocus:r}t.showPopover(),this._open=!0,this._setExpanded(!0);let s=this.coordinateSpace;t.style.position=s==="document"?"absolute":"fixed";let n=()=>Re(this,t,{placement:"bottom-start",distance:4,shiftPadding:8,coordinateSpace:s});if(n(),this._stopTracking=Oe(this,t,n),e.moveFocus!==!1)queueMicrotask(()=>i.focusGrid());this.dispatchEvent(new Event("open",{bubbles:!0}))}_setExpanded(e){let t=e?"true":"false";this._input?.setAttribute("aria-expanded",t);for(let{button:i}of this._buttons)i.setAttribute("aria-expanded",t);for(let i of this._fields||[])i.input.setAttribute("aria-expanded",t)}hide(e=!1){if(!this._panel||!this._open)return;this._stopTracking?.(),this._stopTracking=null;try{this._panel.hidePopover()}catch{}if(this._open=!1,this._setExpanded(!1),this._rangeCommitId++,this._pendingIntents.clear(),e)if(this._rangeMode()){let t=this._restoreFocusEndpoint();if(t)this._focusField(t)}else this._restoreFocus();this.dispatchEvent(new Event("close",{bubbles:!0}))}_restoreFocusEndpoint(){let e=this._range?.activeEndpoint||"";if(e){let t=e==="end"?1:0,i=this._fields?.[t];if(i&&!i.input.disabled&&!i.input.readOnly)return e}return this._resolveRangeEndpoint()}}function he(){if(!customElements.get("date-calendar"))customElements.define("date-calendar",Z);if(!customElements.get("date-picker"))customElements.define("date-picker",ue)}he();var He="lekoala-date-picker-styles";if(!document.getElementById(He)){let e=document.createElement("style");e.id=He,e.textContent=ge,document.head.append(e)}he();})();
|