@lekoala/date-picker 0.5.1 → 0.5.3
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 +296 -294
- package/custom-elements.json +3 -0
- package/dist/date-picker.js +256 -91
- package/dist/date-picker.min.css +1 -1
- package/dist/date-picker.min.js +11 -12
- package/dist/date-picker.standalone.min.js +12 -506
- package/dist/types/date-calendar.d.ts +5 -90
- package/dist/types/date-picker.d.ts +12 -314
- package/dist/types/date.d.ts.map +1 -1
- package/docs/API.md +444 -442
- package/docs/ARCHITECTURE.md +2 -0
- package/docs/DECISIONS.md +74 -74
- package/docs/USE_CASES.md +156 -156
- package/package.json +3 -3
- package/src/activation-intents.js +9 -0
- package/src/date-calendar.js +99 -18
- package/src/date-field.js +57 -10
- package/src/date-picker.js +187 -86
- package/src/date.js +4 -1
- package/dist/types/date-calendar.d.ts.map +0 -1
- package/dist/types/date-field.d.ts +0 -104
- package/dist/types/date-field.d.ts.map +0 -1
- package/dist/types/date-picker.d.ts.map +0 -1
- package/dist/types/time.d.ts +0 -8
- package/dist/types/time.d.ts.map +0 -1
- package/dist/types/upgrade-properties.d.ts +0 -8
- package/dist/types/upgrade-properties.d.ts.map +0 -1
|
@@ -1,510 +1,16 @@
|
|
|
1
|
-
/*** @lekoala/date-picker v0.5.
|
|
2
|
-
(()=>{var Oe=`:where(date-calendar, date-picker) {
|
|
3
|
-
|
|
4
|
-
|
|
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
|
-
--dp-focus: var(--dp-accent);
|
|
11
|
-
--dp-focus-width: 2px;
|
|
12
|
-
--dp-radius: 0.5rem;
|
|
13
|
-
--dp-day-size: 2.75rem;
|
|
14
|
-
--dp-gap: 0.375rem;
|
|
15
|
-
--dp-header-control-size: 2.25rem;
|
|
16
|
-
--dp-header-block-gap: 0.75rem;
|
|
17
|
-
--dp-row-gap: 0.375rem;
|
|
18
|
-
--dp-picker-button-size: 2.5rem;
|
|
19
|
-
--dp-year-inline-size: 5.5rem;
|
|
20
|
-
--dp-day-radius: calc(var(--dp-radius) * 0.75);
|
|
21
|
-
color: var(--dp-fg);
|
|
22
|
-
font: inherit;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
.dp-visually-hidden {
|
|
26
|
-
position: absolute !important;
|
|
27
|
-
inline-size: 1px !important;
|
|
28
|
-
block-size: 1px !important;
|
|
29
|
-
padding: 0 !important;
|
|
30
|
-
margin: -1px !important;
|
|
31
|
-
overflow: hidden !important;
|
|
32
|
-
clip: rect(0 0 0 0) !important;
|
|
33
|
-
white-space: nowrap !important;
|
|
34
|
-
border: 0 !important;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
date-calendar {
|
|
38
|
-
display: block;
|
|
39
|
-
inline-size: max-content;
|
|
40
|
-
max-inline-size: 100%;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
.dp-calendar-shell {
|
|
44
|
-
inline-size: max-content;
|
|
45
|
-
max-inline-size: 100%;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
.dp-calendar-header {
|
|
49
|
-
display: grid;
|
|
50
|
-
grid-template-columns: minmax(0, 1fr) var(--dp-year-inline-size) auto auto;
|
|
51
|
-
/* Stretch (not center): once a UA natural height exceeds
|
|
52
|
-
--dp-header-control-size, the row grows to the tallest control and the
|
|
53
|
-
others stretch to match, so month/year/nav stay equal. */
|
|
54
|
-
align-items: stretch;
|
|
55
|
-
/* Uniform horizontal rhythm: the four header controls are self-evident from
|
|
56
|
-
their kind and position, so no group gets an extra semantic gap. The air
|
|
57
|
-
belongs to the vertical zones (header -> weekdays -> dates). */
|
|
58
|
-
gap: var(--dp-gap);
|
|
59
|
-
margin-block-end: var(--dp-header-block-gap);
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
/* Locale year-first order (Intl-derived, direction-independent): the flexible
|
|
63
|
-
track stays under the month select so the fixed-width year input never
|
|
64
|
-
stretches. Visual mirroring itself is left to the inherited \`dir\`. */
|
|
65
|
-
date-calendar[data-year-first] .dp-calendar-header {
|
|
66
|
-
grid-template-columns: var(--dp-year-inline-size) minmax(0, 1fr) auto auto;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
.dp-calendar-header :where(button, select, input) {
|
|
70
|
-
box-sizing: border-box;
|
|
71
|
-
min-inline-size: 0;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
.dp-calendar-header .dp-skin {
|
|
75
|
-
min-block-size: var(--dp-header-control-size);
|
|
76
|
-
/* Shared vertical metrics: UA default padding/line-height differ per control
|
|
77
|
-
(up to ~13px apart), which only shows once --dp-header-control-size drops
|
|
78
|
-
below content size. */
|
|
79
|
-
padding-block: 0.15rem;
|
|
80
|
-
border: 1px solid var(--dp-border);
|
|
81
|
-
border-radius: calc(var(--dp-radius) * 0.75);
|
|
82
|
-
background: var(--dp-bg);
|
|
83
|
-
color: var(--dp-fg);
|
|
84
|
-
font: inherit;
|
|
85
|
-
line-height: 1.2;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
.dp-calendar-header input.dp-skin {
|
|
89
|
-
padding-inline: 0.45rem;
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
/* Author-drawn caret so the month select matches the nav controls without a
|
|
93
|
-
hardcoded SVG color (currentColor keeps theming). Equal outer heights come
|
|
94
|
-
from the header grid's stretch alignment: the row sizes to the tallest
|
|
95
|
-
control and the others stretch to match. */
|
|
96
|
-
.dp-month-select {
|
|
97
|
-
inline-size: 100%;
|
|
98
|
-
/* Long month names in a narrow track (compact consumers, long locales)
|
|
99
|
-
would paint under the caret: truncate with an ellipsis instead. */
|
|
100
|
-
overflow: hidden;
|
|
101
|
-
text-overflow: ellipsis;
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
.dp-month-select.dp-skin {
|
|
105
|
-
appearance: none;
|
|
106
|
-
padding-inline: 0.45rem 2rem;
|
|
107
|
-
background-image:
|
|
108
|
-
linear-gradient(45deg, transparent 50%, currentColor 50%),
|
|
109
|
-
linear-gradient(135deg, currentColor 50%, transparent 50%);
|
|
110
|
-
background-position:
|
|
111
|
-
calc(100% - 0.9rem) 50%,
|
|
112
|
-
calc(100% - 0.65rem) 50%;
|
|
113
|
-
background-size: 0.3rem 0.3rem;
|
|
114
|
-
background-repeat: no-repeat;
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
/* Inherited RTL mirrors the header layout via the grid. The logical
|
|
118
|
-
\`padding-inline\` already flips, so only the physically-positioned caret has
|
|
119
|
-
to follow it to the other side. */
|
|
120
|
-
[dir="rtl"] .dp-month-select.dp-skin,
|
|
121
|
-
html[dir="rtl"] .dp-month-select.dp-skin {
|
|
122
|
-
background-position:
|
|
123
|
-
0.9rem 50%,
|
|
124
|
-
0.65rem 50%;
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
.dp-year-input {
|
|
128
|
-
inline-size: 100%;
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
.dp-nav.dp-skin {
|
|
132
|
-
display: grid;
|
|
133
|
-
place-items: center;
|
|
134
|
-
inline-size: var(--dp-header-control-size);
|
|
135
|
-
padding: 0;
|
|
136
|
-
font-size: 1.35rem;
|
|
137
|
-
line-height: 1;
|
|
138
|
-
cursor: pointer;
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
.dp-nav svg {
|
|
142
|
-
display: block;
|
|
143
|
-
inline-size: 1rem;
|
|
144
|
-
block-size: 1rem;
|
|
145
|
-
pointer-events: none;
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
.dp-calendar-header .dp-skin:disabled,
|
|
149
|
-
.dp-picker-button:disabled {
|
|
150
|
-
cursor: not-allowed;
|
|
151
|
-
opacity: 0.45;
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
.dp-nav.dp-skin:hover:not(:disabled) {
|
|
155
|
-
background: var(--dp-hover);
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
/* Inner outlines survive forced colors and keep focus inside each control.
|
|
159
|
-
The picker trigger uses a tighter inset around its icon below. */
|
|
160
|
-
.dp-calendar-header .dp-skin:focus-visible,
|
|
161
|
-
date-picker > input:not([type="hidden"]):focus-visible,
|
|
162
|
-
.dp-day:focus-visible {
|
|
163
|
-
outline: var(--dp-focus-width) solid var(--dp-focus);
|
|
164
|
-
outline-offset: calc(var(--dp-focus-width) * -1);
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
.dp-day:hover:not([data-disabled="true"]):not([data-selected="true"]):not([data-range-start="true"]):not(
|
|
168
|
-
[data-range-end="true"]
|
|
169
|
-
) {
|
|
170
|
-
background: var(--dp-hover);
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
/* .dp-calendar-heading is always visually hidden: it names the grid via
|
|
174
|
-
aria-labelledby and stays the aria-live announcement channel while the
|
|
175
|
-
month/year selects render the same info visually. */
|
|
176
|
-
|
|
177
|
-
.dp-grid {
|
|
178
|
-
border-collapse: separate;
|
|
179
|
-
/* --dp-gap scopes to the header grid; vertical week rhythm is --dp-row-gap. */
|
|
180
|
-
border-spacing: 0 var(--dp-row-gap);
|
|
181
|
-
table-layout: fixed;
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
.dp-grid :where(th, td) {
|
|
185
|
-
box-sizing: border-box;
|
|
186
|
-
inline-size: var(--dp-day-size);
|
|
187
|
-
block-size: var(--dp-day-size);
|
|
188
|
-
padding: 0;
|
|
189
|
-
text-align: center;
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
.dp-grid thead th {
|
|
193
|
-
block-size: 1.5rem;
|
|
194
|
-
color: var(--dp-muted);
|
|
195
|
-
font-size: 0.72rem;
|
|
196
|
-
font-weight: 500;
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
.dp-day {
|
|
200
|
-
position: relative;
|
|
201
|
-
border: 1px solid transparent;
|
|
202
|
-
border-radius: var(--dp-day-radius);
|
|
203
|
-
cursor: pointer;
|
|
204
|
-
outline: none;
|
|
205
|
-
vertical-align: middle;
|
|
206
|
-
font-size: 0.875rem;
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
/* On an accent-filled cell the ring inverts so it stays readable. */
|
|
210
|
-
.dp-day:is([data-selected="true"], [data-range-start="true"], [data-range-end="true"]):focus-visible {
|
|
211
|
-
outline-color: var(--dp-accent-fg);
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
/* Base tint for days outside the displayed month. It stays before the
|
|
215
|
-
selection states so selected/range endpoints keep their accent-contrast
|
|
216
|
-
text on the accent fill (equal specificity, source order decides). */
|
|
217
|
-
.dp-day[data-outside-month="true"] {
|
|
218
|
-
color: var(--dp-muted);
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
.dp-day[data-selected="true"] {
|
|
222
|
-
background: var(--dp-accent);
|
|
223
|
-
color: var(--dp-accent-fg);
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
/* Today never competes with a stronger state: a selected day or a range
|
|
227
|
-
endpoint keeps its own treatment, in normal rendering and in
|
|
228
|
-
forced-colors alike. */
|
|
229
|
-
.dp-day[data-today="true"]:not([data-selected="true"], [data-range-start="true"], [data-range-end="true"]) {
|
|
230
|
-
border-color: var(--dp-accent);
|
|
231
|
-
}
|
|
232
|
-
|
|
233
|
-
.dp-day[data-disabled="true"] {
|
|
234
|
-
cursor: not-allowed;
|
|
235
|
-
opacity: 0.42;
|
|
236
|
-
}
|
|
237
|
-
|
|
238
|
-
.dp-day[data-range-start="true"],
|
|
239
|
-
.dp-day[data-range-end="true"] {
|
|
240
|
-
background: var(--dp-accent);
|
|
241
|
-
color: var(--dp-accent-fg);
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
.dp-day[data-in-range="true"] {
|
|
245
|
-
border-radius: 0;
|
|
246
|
-
background: color-mix(in srgb, var(--dp-accent) 18%, var(--dp-bg));
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
/* Join the band without gaps, including the corners beside each endpoint. */
|
|
250
|
-
.dp-day[data-range-start="true"]:has(+ [data-in-range="true"], + [data-range-end="true"]) {
|
|
251
|
-
border-start-end-radius: 0;
|
|
252
|
-
border-end-end-radius: 0;
|
|
253
|
-
}
|
|
254
|
-
|
|
255
|
-
.dp-day:is([data-in-range="true"], [data-range-start="true"]) + .dp-day[data-range-end="true"] {
|
|
256
|
-
border-start-start-radius: 0;
|
|
257
|
-
border-end-start-radius: 0;
|
|
258
|
-
}
|
|
259
|
-
|
|
260
|
-
.dp-day[data-in-range="true"]:first-of-type {
|
|
261
|
-
border-start-start-radius: var(--dp-day-radius);
|
|
262
|
-
border-end-start-radius: var(--dp-day-radius);
|
|
263
|
-
}
|
|
264
|
-
|
|
265
|
-
.dp-day[data-in-range="true"]:last-of-type {
|
|
266
|
-
border-start-end-radius: var(--dp-day-radius);
|
|
267
|
-
border-end-end-radius: var(--dp-day-radius);
|
|
268
|
-
}
|
|
269
|
-
|
|
270
|
-
/* Projected band: the range the next commit would produce. It reads as one
|
|
271
|
-
step short of the committed band, so a hovered, keyboard or dragged preview
|
|
272
|
-
is never mistaken for the selection itself. */
|
|
273
|
-
[data-range-preview] .dp-day:is([data-range-start="true"], [data-range-end="true"]) {
|
|
274
|
-
background: color-mix(in srgb, var(--dp-accent) 58%, var(--dp-bg));
|
|
275
|
-
}
|
|
276
|
-
|
|
277
|
-
[data-range-preview] .dp-day[data-in-range="true"] {
|
|
278
|
-
background: color-mix(in srgb, var(--dp-accent) 11%, var(--dp-bg));
|
|
279
|
-
}
|
|
280
|
-
|
|
281
|
-
/* Endpoint handles are draggable only while the committed range is complete
|
|
282
|
-
and its two ends sit on different days. */
|
|
283
|
-
[data-range-drag] .dp-day:is([data-range-start="true"], [data-range-end="true"]) {
|
|
284
|
-
cursor: grab;
|
|
285
|
-
}
|
|
286
|
-
|
|
287
|
-
[data-range-drag="active"],
|
|
288
|
-
[data-range-drag="active"] .dp-day {
|
|
289
|
-
cursor: grabbing;
|
|
290
|
-
}
|
|
291
|
-
|
|
292
|
-
.dp-day-number {
|
|
293
|
-
display: block;
|
|
294
|
-
font-variant-numeric: tabular-nums;
|
|
295
|
-
}
|
|
296
|
-
|
|
297
|
-
/* A focused disabled day stays discoverable by keyboard: restore full opacity
|
|
298
|
-
so the focus outline renders at full strength, and mark the number with the
|
|
299
|
-
muted tone (same language as outside-month days) instead of the wash-out. */
|
|
300
|
-
.dp-day[data-disabled="true"]:focus-visible {
|
|
301
|
-
opacity: 1;
|
|
302
|
-
}
|
|
303
|
-
|
|
304
|
-
.dp-day[data-disabled="true"]:focus-visible .dp-day-number {
|
|
305
|
-
color: var(--dp-muted);
|
|
306
|
-
}
|
|
307
|
-
|
|
308
|
-
.dp-day-extra {
|
|
309
|
-
position: absolute;
|
|
310
|
-
inset-inline: 2px;
|
|
311
|
-
inset-block-end: 1px;
|
|
312
|
-
display: flex;
|
|
313
|
-
justify-content: center;
|
|
314
|
-
gap: 2px;
|
|
315
|
-
min-block-size: 0.35rem;
|
|
316
|
-
font-size: 0.55rem;
|
|
317
|
-
line-height: 1;
|
|
318
|
-
pointer-events: none;
|
|
319
|
-
}
|
|
320
|
-
|
|
321
|
-
.dp-week-number,
|
|
322
|
-
.dp-week-heading {
|
|
323
|
-
inline-size: 1.6rem !important;
|
|
324
|
-
color: var(--dp-muted);
|
|
325
|
-
font-size: 0.65rem;
|
|
326
|
-
font-weight: 500;
|
|
327
|
-
}
|
|
328
|
-
|
|
329
|
-
date-picker {
|
|
330
|
-
position: relative;
|
|
331
|
-
display: inline-grid;
|
|
332
|
-
grid-template-columns: minmax(0, 1fr);
|
|
333
|
-
align-items: stretch;
|
|
334
|
-
max-inline-size: 100%;
|
|
335
|
-
}
|
|
336
|
-
|
|
337
|
-
/* Every authored control is a grid item. */
|
|
338
|
-
date-picker > input:not([type="hidden"]) {
|
|
339
|
-
min-inline-size: 0;
|
|
340
|
-
}
|
|
341
|
-
|
|
342
|
-
/* Date fields reserve room for the trigger, which is painted inside the
|
|
343
|
-
field's own box: the field is the real outer box, so its focus ring wraps
|
|
344
|
-
the affordance too. \`grid-row\` must stay explicit, otherwise the trigger
|
|
345
|
-
(placed with a definite row) claims the row and pushes the field down. */
|
|
346
|
-
date-picker > input:not([type="hidden"]):not([type="time"]) {
|
|
347
|
-
grid-column: 1;
|
|
348
|
-
grid-row: 1;
|
|
349
|
-
box-sizing: border-box;
|
|
350
|
-
inline-size: 100%;
|
|
351
|
-
padding-inline-end: calc(var(--dp-picker-button-size) + 0.5rem);
|
|
352
|
-
}
|
|
353
|
-
|
|
354
|
-
/* The trigger is a real button overlaid on the field's inline-end, like the
|
|
355
|
-
native \`input[type=time]\` indicator: no chrome of its own, transparent, so
|
|
356
|
-
the authored field background and border stay visible underneath. */
|
|
357
|
-
.dp-picker-button {
|
|
358
|
-
display: grid;
|
|
359
|
-
place-items: center;
|
|
360
|
-
grid-column: 1;
|
|
361
|
-
grid-row: 1;
|
|
362
|
-
justify-self: end;
|
|
363
|
-
align-self: stretch;
|
|
364
|
-
inline-size: var(--dp-picker-button-size);
|
|
365
|
-
min-inline-size: 0;
|
|
366
|
-
border: 0;
|
|
367
|
-
background: transparent;
|
|
368
|
-
color: var(--dp-fg);
|
|
369
|
-
font: inherit;
|
|
370
|
-
cursor: pointer;
|
|
371
|
-
}
|
|
372
|
-
|
|
373
|
-
/* Like the native time indicator: the ring wraps the icon, not the field (the
|
|
374
|
-
field already shows its own ring through :focus-visible). Same radius as
|
|
375
|
-
everywhere else: no bespoke shape. */
|
|
376
|
-
.dp-picker-button:focus-visible {
|
|
377
|
-
outline: var(--dp-focus-width) solid var(--dp-focus);
|
|
378
|
-
outline-offset: -5px;
|
|
379
|
-
border-radius: var(--dp-radius);
|
|
380
|
-
}
|
|
381
|
-
|
|
382
|
-
/* Optional native time companions share the date row; authored inputs stay
|
|
383
|
-
consumer-styled, the picker only reserves their grid cells. Time tracks are
|
|
384
|
-
flexible (never \`auto\`) so a wide UA time control cannot squeeze the date.
|
|
385
|
-
Each companion keeps its own box and its own gap: nothing is joined, so
|
|
386
|
-
focus rings never merge and no neighbour swallows another's focus. */
|
|
387
|
-
date-picker:has(> [data-time-start], > [data-time-end]) {
|
|
388
|
-
grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
|
|
389
|
-
column-gap: var(--dp-gap);
|
|
390
|
-
}
|
|
391
|
-
|
|
392
|
-
date-picker:has(> [data-time-start]):has(> [data-time-end]) {
|
|
393
|
-
grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1fr);
|
|
394
|
-
}
|
|
395
|
-
|
|
396
|
-
date-picker > input[data-time-start] {
|
|
397
|
-
grid-column: 2;
|
|
398
|
-
grid-row: 1;
|
|
399
|
-
min-inline-size: 0;
|
|
400
|
-
}
|
|
401
|
-
|
|
402
|
-
date-picker > input[data-time-end] {
|
|
403
|
-
grid-column: 3;
|
|
404
|
-
grid-row: 1;
|
|
405
|
-
min-inline-size: 0;
|
|
406
|
-
}
|
|
407
|
-
|
|
408
|
-
/* Range: two stacked fields, each owning its trigger, sharing one popup and
|
|
409
|
-
one calendar. No trigger spans both bounds, so each bound keeps a local
|
|
410
|
-
affordance and a local focus target. */
|
|
411
|
-
date-picker[range] {
|
|
412
|
-
row-gap: var(--dp-gap);
|
|
413
|
-
}
|
|
414
|
-
|
|
415
|
-
date-picker[range] > input[data-range-start] {
|
|
416
|
-
grid-row: 1;
|
|
417
|
-
}
|
|
418
|
-
|
|
419
|
-
date-picker[range] > input[data-range-end] {
|
|
420
|
-
grid-row: 2;
|
|
421
|
-
}
|
|
422
|
-
|
|
423
|
-
date-picker[range] > .dp-picker-button[data-endpoint="start"] {
|
|
424
|
-
grid-row: 1;
|
|
425
|
-
}
|
|
426
|
-
|
|
427
|
-
date-picker[range] > .dp-picker-button[data-endpoint="end"] {
|
|
428
|
-
grid-row: 2;
|
|
429
|
-
}
|
|
430
|
-
|
|
431
|
-
.dp-picker-panel[popover] {
|
|
432
|
-
/* Safe baseline. show() switches to absolute only when the consumer
|
|
433
|
-
* explicitly selects document coordinate space. */
|
|
434
|
-
position: fixed;
|
|
435
|
-
inset: auto;
|
|
436
|
-
margin: 0;
|
|
437
|
-
padding: 0.875rem 1rem;
|
|
438
|
-
border: 1px solid var(--dp-border);
|
|
439
|
-
border-radius: var(--dp-radius);
|
|
440
|
-
background: var(--dp-bg);
|
|
441
|
-
color: var(--dp-fg);
|
|
442
|
-
box-shadow: 0 0.5rem 1.5rem rgb(15 23 42 / 0.12);
|
|
443
|
-
max-block-size: var(--available-height, 90svh);
|
|
444
|
-
max-inline-size: calc(100vi - 1rem);
|
|
445
|
-
overflow: auto;
|
|
446
|
-
}
|
|
447
|
-
|
|
448
|
-
.dp-picker-panel:not(:popover-open) {
|
|
449
|
-
display: none;
|
|
450
|
-
}
|
|
451
|
-
|
|
452
|
-
@media (forced-colors: active) {
|
|
453
|
-
/* The author-drawn caret is a gradient and disappears here: hand the
|
|
454
|
-
control back to the browser instead of trying to rebuild it. */
|
|
455
|
-
.dp-month-select.dp-skin,
|
|
456
|
-
[dir="rtl"] .dp-month-select.dp-skin {
|
|
457
|
-
appearance: auto;
|
|
458
|
-
background-image: none;
|
|
459
|
-
padding-inline: 0.45rem;
|
|
460
|
-
}
|
|
461
|
-
|
|
462
|
-
/* Fills vanish here, so selection and endpoints fall back to a 2px
|
|
463
|
-
Highlight border. The in-range underline is the only band marker left:
|
|
464
|
-
the range fill is lost and the browser does not know the semantics. */
|
|
465
|
-
.dp-day:is([data-selected="true"], [data-range-start="true"], [data-range-end="true"]) {
|
|
466
|
-
border: 2px solid Highlight;
|
|
467
|
-
background-color: Canvas;
|
|
468
|
-
color: CanvasText;
|
|
469
|
-
}
|
|
470
|
-
|
|
471
|
-
.dp-day[data-in-range="true"] {
|
|
472
|
-
color: CanvasText;
|
|
473
|
-
}
|
|
474
|
-
|
|
475
|
-
.dp-day[data-in-range="true"]::after {
|
|
476
|
-
content: "";
|
|
477
|
-
position: absolute;
|
|
478
|
-
inset-inline: 3px;
|
|
479
|
-
inset-block-end: 4px;
|
|
480
|
-
block-size: 1px;
|
|
481
|
-
background-color: Highlight;
|
|
482
|
-
}
|
|
483
|
-
|
|
484
|
-
/* Pin the today marker: the deterministic accent is a non-system color
|
|
485
|
-
and would otherwise remap unpredictably here. */
|
|
486
|
-
.dp-day[data-today="true"] {
|
|
487
|
-
border-color: Highlight;
|
|
488
|
-
}
|
|
489
|
-
|
|
490
|
-
.dp-day-extra {
|
|
491
|
-
color: CanvasText;
|
|
492
|
-
forced-color-adjust: none;
|
|
493
|
-
}
|
|
494
|
-
}
|
|
495
|
-
`;var gt=/^(\d{4})-(\d{2})-(\d{2})$/,_t=/^(\d{4})-(\d{2})$/;function yt(e){return e%4===0&&(e%100!==0||e%400===0)}function ee(e,t){if(t===2)return yt(e)?29:28;return[4,6,9,11].includes(t)?30:31}function L(e){let t=gt.exec(String(e||""));if(!t)return null;let s=Number(t[1]),i=Number(t[2]),n=Number(t[3]);if(s<1||s>9999||i<1||i>12)return null;if(n<1||n>ee(s,i))return null;return{year:s,month:i,day:n}}function d(e){return L(e)!==null}function f(e){let t=String(e||""),s=_t.exec(t);if(s){let n=Number(s[2]);if(n>=1&&n<=12)return`${s[1]}-${String(n).padStart(2,"0")}`}let i=L(t);if(!i)throw TypeError(`Invalid civil date/month: ${e}`);return`${String(i.year).padStart(4,"0")}-${String(i.month).padStart(2,"0")}`}function N(e,t,s){let i=`${String(e).padStart(4,"0")}-${String(t).padStart(2,"0")}-${String(s).padStart(2,"0")}`;if(!d(i))throw TypeError(`Invalid civil date: ${i}`);return i}function H(e){let t=new Date(0);return t.setUTCHours(12,0,0,0),t.setUTCFullYear(e.year,e.month-1,e.day),t}function bt(e){return N(e.getUTCFullYear(),e.getUTCMonth()+1,e.getUTCDate())}function V(e){let t=L(e);if(!t)throw TypeError(`Invalid civil date: ${e}`);return H(t)}function g(e,t){if(!d(e)||!d(t))throw TypeError("compareDates() expects YYYY-MM-DD values");return e===t?0:e<t?-1:1}function F(e,t){let s=L(e);if(!s||!Number.isInteger(t))throw TypeError("addDays() expects a date and integer amount");let i=H(s);return i.setUTCDate(i.getUTCDate()+t),bt(i)}function ce(e,t){let s=L(e);if(!s||!Number.isInteger(t))throw TypeError("addMonths() expects a date and integer amount");let i=s.year*12+(s.month-1)+t,n=Math.floor(i/12),a=(i%12+12)%12+1,o=Math.min(s.day,ee(n,a));return N(n,a,o)}function Pe(e,t){let s=L(e);if(!s||!Number.isInteger(t))throw TypeError("addYears() expects a date and integer amount");let i=s.year+t,n=Math.min(s.day,ee(i,s.month));return N(i,s.month,n)}function Q(e,t){let s=`${f(e)}-01`;return f(ce(s,t))}function vt(e){return`${f(e)}-01`}function ve(e){let t=L(`${f(e)}-01`);if(!t)throw TypeError(`Invalid month: ${e}`);return N(t.year,t.month,ee(t.year,t.month))}function wt(e){let t=L(e);if(!t)throw TypeError(`Invalid civil date: ${e}`);return H(t).getUTCDay()}function Y(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 ue(e,t=1){let s=(wt(e)-Y(t)+7)%7;return F(e,-s)}function we(e,t=1){return F(ue(e,t),6)}function ze(e,t={}){let s=t.firstDay??1,i=ue(vt(e),s),n=we(ve(e),s),r=[],a=i;for(;;){let o=[];for(let c=0;c<7;c++)o.push(F(a,c));if(r.push(o),g(o[6],n)>=0){if(!t.fixedWeeks||r.length>=6||g(o[6],F("9999-12-31",-7))>0)break}a=F(a,7)}return r}function Re(e,t,s){let i=H({year:1,month:1,day:1});return Math.round((H({year:e,month:t,day:s}).getTime()-i.getTime())/86400000)}function te(e,t=1){let s=Y(t),i=Re(9999,12,31),n=f(e);for(;;){let r=L(`${n}-01`);if(!r)throw TypeError(`Invalid civil date/month: ${e}`);let a=Re(r.year,r.month,1),o=(H(r).getUTCDay()-s+7)%7;if(a-o<0){n=Q(n,1);continue}let c=ee(r.year,r.month),l={year:r.year,month:r.month,day:c},u=a+c-1,b=(H(l).getUTCDay()-s+7)%7;if(u-b+6>i){n=Q(n,-1);continue}return n}}function He(e,t="",s=""){if(!d(e))throw TypeError(`Invalid civil date: ${e}`);if(t&&g(e,t)<0)return t;if(s&&g(e,s)>0)return s;return e}function R(){let e=new Date;return N(e.getFullYear(),e.getMonth()+1,e.getDate())}function Ve(e){let t=L(e);if(!t)throw TypeError(`Invalid civil date: ${e}`);let s=H(t),i=s.getUTCDay()||7;s.setUTCDate(s.getUTCDate()+4-i);let n=new Date(0);return n.setUTCHours(12,0,0,0),n.setUTCFullYear(s.getUTCFullYear(),0,1),Math.ceil(((s.getTime()-n.getTime())/86400000+1)/7)}class De{constructor(e={}){let t=R();this.firstDay=Y(e.firstDay??1),this.value=e.value&&d(e.value)?e.value:"",this.focused=e.focused&&d(e.focused)?e.focused:this.value||t,this.display=e.display?f(e.display):f(this.focused)}setValue(e){if(e&&!d(e))throw TypeError(`Invalid value: ${e}`);return this.value=e||"",this.value}setDisplay(e){let t=f(e),s=Number(this.focused.slice(8,10))||1,i=ce(`${t}-01`,0),n=F(i,Math.max(0,s-1));return this.focused=f(n)===t?n:F(`${Q(t,1)}-01`,-1),this.display=t,this.display}setFocused(e,t={}){if(!d(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(ce(this.focused,e))}moveFocusYears(e){return this.setFocused(Pe(this.focused,e))}focusWeekStart(){return this.setFocused(ue(this.focused,this.firstDay))}focusWeekEnd(){return this.setFocused(we(this.focused,this.firstDay))}navigateMonth(e){let t=Q(this.display,e);return this.setDisplay(t),this.display}}function Dt(e){if(typeof e!=="string")return"";return[...new Set(e.split(/\s+/).filter((t)=>t&&!t.startsWith("dp-")&&![...t].some((s)=>s.charCodeAt(0)<32||s.charCodeAt(0)===127)))].join(" ")}function ke(e,t){return e.month===t.month&&e.year===t.year&&e.nav===t.nav}var xe={month:"",year:"",nav:""};function se(){return{...xe}}function ie(e){if(e==null)return null;let t={};for(let s of["month","year","nav"])if(Object.hasOwn(e,s))t[s]=Dt(e[s]);return t}function Be(e){return e==null||["month","year","nav"].some((t)=>!Object.hasOwn(e,t))}function ne(e){return{...se(),...ie(e)}}function he(e){let t=ne(e);if(ke(xe,t))return;xe=t;for(let s of Ee)s()}var Ee=new Set;function Ne(e){return Ee.add(e),()=>{Ee.delete(e)}}function fe(e){if(e==null)return{start:"",end:""};if(typeof e!=="object")throw TypeError("highlightedRange expects { start, end }");let{start:t="",end:s=""}=e;if(t&&!d(t))throw TypeError(`Invalid range start: ${t}`);if(s&&!d(s))throw TypeError(`Invalid range end: ${s}`);if(!t&&s)throw TypeError("highlightedRange cannot define an end without a start");if(t&&s&&g(s,t)<0)throw TypeError("highlightedRange must be ordered; start must be on or before end");return{start:t,end:s}}function pe(e,t){if(!t||!d(e))return"";let{start:s,end:i}=t;if(!s||!d(s))return"";if(s===e)return i?i===e?"single":"start":"start";if(i&&i===e)return"end";if(i&&g(e,s)>=0&&g(e,i)<=0)return"in";return""}class Ce{constructor(){this.activeEndpoint="",this.start="",this.end=""}get range(){return{start:this.start,end:this.end}}get complete(){return Boolean(this.start&&this.end&&g(this.end,this.start)>=0)}focus(e){this.activeEndpoint=e}_refuse(e){return{status:"refused",endpoint:e,changedEndpoints:[],range:this.range,activeEndpoint:this.activeEndpoint}}project(e,t=()=>!0){if(!d(e))throw TypeError(`Invalid range activation: ${e}`);let{start:s,end:i}=this;if(this.complete&&(g(e,s)<0||g(e,i)>0)){let r=g(e,s)<0?"start":"end";if(!t(r))return this._refuse(r);return{status:"complete",endpoint:r,changedEndpoints:[r],range:r==="start"?{start:e,end:i}:{start:s,end:e},activeEndpoint:r}}if(this.activeEndpoint==="end"){if(s&&!i&&g(e,s)<0){if(!t("start"))return this._refuse("start");if(!t("end"))return this._refuse("end");return{status:"complete",endpoint:"end",changedEndpoints:["start","end"],range:{start:e,end:s},activeEndpoint:"end"}}if(s&&g(e,s)<0)return this._refuse("end");if(!t("end"))return this._refuse("end");return{status:s?"complete":"pending",endpoint:"end",changedEndpoints:["end"],range:{start:s,end:e},activeEndpoint:"end"}}if(i&&!s&&g(e,i)>0){if(!t("start"))return this._refuse("start");if(!t("end"))return this._refuse("end");return{status:"complete",endpoint:"start",changedEndpoints:["start","end"],range:{start:i,end:e},activeEndpoint:"start"}}if(!t("start"))return this._refuse("start");let n=t("end");return{status:"pending",endpoint:"start",changedEndpoints:["start"],range:{start:e,end:i},activeEndpoint:n?"end":this.activeEndpoint,...n?{}:{close:!0}}}projectEndpoint(e,t,s=()=>!0){if(!d(e))throw TypeError(`Invalid range activation: ${e}`);if(!this.complete||!s(t))return this._refuse(t);let{start:i,end:n}=this,r=t==="start"?i:n,a=t==="start"?Et(e,n):xt(e,i);return{status:"complete",endpoint:t,changedEndpoints:a===r?[]:[t],range:t==="start"?{start:a,end:n}:{start:i,end:a},activeEndpoint:t}}previewRange(e,t="",s=()=>!0){if(!d(e))return null;if(!t&&Boolean(this.start)===Boolean(this.end))return null;let i=t?this.projectEndpoint(e,t,s):this.project(e,s);if(i.status==="refused")return null;let{start:n,end:r}=i.range;if(!n||r&&g(r,n)<0)return null;return{start:n,end:r}}_apply(e){if(e.status==="refused")return e;return this.start=e.range.start,this.end=e.range.end,this.activeEndpoint=e.activeEndpoint,e}activate(e,t=()=>!0){return this._apply(this.project(e,t))}moveEndpoint(e,t,s=()=>!0){return this._apply(this.projectEndpoint(e,t,s))}}function xt(e,t){if(!e)return t;if(!t)return e;return g(e,t)>=0?e:t}function Et(e,t){if(!e)return t;if(!t)return e;return g(e,t)<=0?e:t}var je=/[\u200e\u200f\u061c\u202a-\u202e\u2066-\u2069]/g,kt=new Map,Ct=new Map;function Ye(e,t,s){let i=e.get(t);if(i!==void 0)return i;let n=s(),r=e.keys().next().value;if(e.size>=64&&r!==void 0)e.delete(r);return e.set(t,n),n}function G(e,t){let s=JSON.stringify([e,t]);return Ye(kt,s,()=>new Intl.DateTimeFormat(e,t))}function P(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 At(e){return Ye(Ct,e,()=>{let t=new Intl.NumberFormat(e,{useGrouping:!1}),s=new Map;for(let i=0;i<=9;i++)s.set(t.format(i),String(i));return s})}function Ue(e,t,s={}){let i=String(e||"").replace(je,"");if(s.trim!==!1)i=i.trim();for(let[n,r]of At(t))i=i.split(n).join(r);return i}function re(e,t=""){let s=P(t);return G(s,{calendar:"gregory",weekday:"long",year:"numeric",month:"long",day:"numeric",timeZone:"UTC"}).format(V(e))}function Ge(e,t=""){let s=P(t);return G(s,{calendar:"gregory",year:"numeric",month:"long",timeZone:"UTC"}).format(V(`${e.slice(0,7)}-15`))}function We(e=""){let t=P(e);try{let s=G(t,{calendar:"gregory",year:"numeric",month:"long",timeZone:"UTC"}).formatToParts(V("2026-09-15")),i=-1,n=-1;if(s.forEach((r,a)=>{let o=r.type;if(o==="month"){if(i<0)i=a}else if(o==="year"||o==="relatedYear"||o==="yearName"){if(n<0)n=a}}),i>=0&&n>=0)return n<i?["year","month"]:["month","year"]}catch{}return["month","year"]}function Ke(e="",t="long"){let s=P(e),i=G(s,{calendar:"gregory",month:t,timeZone:"UTC"});return Array.from({length:12},(n,r)=>i.format(V(`2026-${String(r+1).padStart(2,"0")}-15`)))}function Ae(e="",t=1,s="short"){let i=P(e),n=G(i,{calendar:"gregory",weekday:s,timeZone:"UTC"}),r=Y(t),a=V("2026-01-04");return Array.from({length:7},(o,c)=>{let l=new Date(a);return l.setUTCDate(a.getUTCDate()+(r+c)%7),n.format(l)})}function Tt(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function ae(e=""){let t=P(e),s=G(t,{calendar:"gregory",year:"numeric",month:"2-digit",day:"2-digit",timeZone:"UTC"}),i=V("2006-11-22"),n=s.formatToParts(i).filter((l)=>l.type!=="literal"||l.value),r=n.filter((l)=>["day","month","year"].includes(l.type)).map((l)=>l.type),a=n.map((l)=>{if(l.type==="day")return"DD";if(l.type==="month")return"MM";if(l.type==="year")return"YYYY";return l.value.replace(je,"")}).join(""),o=n.map((l)=>{if(l.type==="day"||l.type==="month")return"(\\d{1,2})";if(l.type==="year")return"(\\d{4})";let u=Ue(l.value,t,{trim:!1});return Tt(u).replace(/\s+/g,"\\s*")}).join(""),c=new RegExp(`^\\s*${o}\\s*$`);return{locale:t,placeholder:a,format(l){if(!d(l))return"";return s.format(V(l))},parse(l){let u=Ue(l,t);if(d(u))return u;let b=c.exec(u);if(!b)return"";let D={};if(r.forEach((x,T)=>{D[x]=Number(b[T+1])}),!D.year||!D.month||!D.day)return"";try{return N(D.year,D.month,D.day)}catch{return""}}}}var St={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"},Te={...St};function B(){return{...Te}}function me(e){Te={...Te,...e};for(let t of Se)t()}var Se=new Set;function ge(e){return Se.add(e),()=>{Se.delete(e)}}function qe(e){let t=e&&typeof e==="object"&&!Array.isArray(e)&&"dates"in e?e.dates:e,s=new Map;if(Array.isArray(t)){for(let i of t){if(!i||typeof i!=="object"||!("date"in i))continue;let{date:n,...r}=i;s.set(String(n),r)}return s}if(t&&typeof t==="object")for(let[i,n]of Object.entries(t))s.set(i,n&&typeof n==="object"?n:{});return s}function W(e,t){for(let s of t){if(!Object.hasOwn(e,s))continue;let i=Reflect.get(e,s);Reflect.deleteProperty(e,s),Reflect.set(e,s,i)}}var Mt=0;function A(e){return String(e).replaceAll("&","&").replaceAll("<","<").replaceAll(">",">").replaceAll('"',""").replaceAll("'","'")}function $t(e){let t=Number(e);if(t===7)return 0;return Number.isInteger(t)&&t>=0&&t<=6?t:1}function Ft(e){return Number(e.slice(0,4))}function _e(e,t){let[s,i]=e.split("-").map(Number),n=s*12+(i-1)+t,r=Math.floor(n/12),a=(n%12+12)%12+1;if(r<1||r>9999)return null;return`${String(r).padStart(4,"0")}-${String(a).padStart(2,"0")}`}function Xe(e){return{"data-range-start":e==="start"||e==="single","data-range-end":e==="end"||e==="single","data-in-range":e==="in"}}function Lt(e){return Object.entries(Xe(e)).filter(([,t])=>t).map(([t])=>` ${t}="true"`).join("")}function It(e){if(e==="single")return"rangeSingle";if(e==="start")return"rangeStart";if(e==="end")return"rangeEnd";if(e==="in")return"rangeInRange";return""}class oe extends HTMLElement{static observedAttributes=["value","display","min","max","first-day","locale","fixed-weeks","show-week-numbers","selection","month-format"];static setDefaultControlClasses(e){he(e)}static getDefaultControlClasses(){return se()}static setDefaultMessages(e){me(e)}static getDefaultMessages(){return B()}constructor(){super();this._id=`date-calendar-${++Mt}`,this._model=new De,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._paintedRange={start:"",end:""},this._paintedPreview=!1,this._renderedStates=new Map,this._messages=null,this._controlClasses=null,this._stopDefaultMessages=null,this._stopDefaultControlClasses=null,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;W(this,["locale","min","max","firstDay","selection","monthFormat","fixedWeeks","showWeekNumbers","controlClasses","messages","source","dateState","renderDay","isDateDisabled","highlightedRange","value","display"]),this._syncModel(),W(this,["focusedDate"]),this._stopDefaultControlClasses=Ne(()=>{if(Be(this._controlClasses))this.render()}),this._stopDefaultMessages=ge(()=>{if(this._messages===null)this.render()}),this._connected=!0,this.addEventListener("click",this._onClick),this.addEventListener("change",this._onChange),this.addEventListener("keydown",this._onKeyDown),this.addEventListener("focusin",this._onFocusIn),this.render()}disconnectedCallback(){this._stopDefaultControlClasses?.(),this._stopDefaultControlClasses=null,this._stopDefaultMessages?.(),this._stopDefaultMessages=null,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 P(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&&!d(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 d(e)?e:""}set min(e){if(e)this.setAttribute("min",e);else this.removeAttribute("min")}get max(){let e=this.getAttribute("max")||"";return d(e)?e:""}set max(e){if(e)this.setAttribute("max",e);else this.removeAttribute("max")}get firstDay(){return $t(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=fe(e),s=this.hasAttribute("data-range-preview");if(t.start===this._paintedRange.start&&t.end===this._paintedRange.end&&s===this._paintedPreview)return;if(this._highlightedRange=t,this._connected)this._updateRangeDom()}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 controlClasses(){return ne(this._controlClasses)}set controlClasses(e){let t=this.controlClasses;if(this._controlClasses=ie(e),ke(t,this.controlClasses))return;if(this._connected)this.render()}get messages(){return this._messages??B()}set messages(e){if(this._messages=e==null?null:{...B(),...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||d(t))this._model.value=t;let s=this.getAttribute("display")||"";if(s)try{this._model.setDisplay(te(s,e))}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){let t=He(e,this.min,this.max),s=f(t),i=te(s,this.firstDay);if(i===s)return t;let n=Number(t.slice(8,10))||1,r=F(`${i}-01`,n-1),a=ve(i);return g(r,a)>0?a:r}_weeks(e=this.display){return ze(te(e,this.firstDay),{firstDay:this.firstDay,fixedWeeks:this.fixedWeeks})}_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(d(t))return`.dp-day[data-date="${t}"]`}return""}_range(e=this.display){let t=this._weeks(e),s=t[0],i=t[t.length-1];if(!s||!i)throw Error("Calendar month produced no weeks");return{start:s[0],end:i[6]}}getDateState(e){let t=this._sourceStates.get(e)||{},s=this._dateState?.(e,{...t})||{},i={...t,...s},n=this.min&&g(e,this.min)<0||this.max&&g(e,this.max)>0,a=i.enabled===!0?!1:Boolean(this._isDateDisabled?.(e)),o=Boolean(n)||Boolean(i.disabled)||a;return{...i,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(!d(e)||!this._source)return!0;return await this._loadDisplay(f(e),!1)==="loaded"}async _loadDisplay(e,t=!0){if(!this._source)return"loaded";let s=this._range(e),i=`${s.start}/${s.end}`;if(this._loadedRanges.has(i))return"loaded";if(i===this._loadingKey&&this._loadingPromise)return this._loadingPromise;this._loadController?.abort();let n=new AbortController;this._loadController=n,this._loadingKey=i;let r=this._source,a=(async()=>{this.toggleAttribute("data-loading",!0),this.dispatchEvent(new CustomEvent("dateloadstart",{detail:s,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 c=await o(s,{signal:n.signal});if(n.signal.aborted)return"cancelled";for(let[l,u]of qe(c))this._sourceStates.set(l,u);if(this._loadedRanges.add(i),this.dispatchEvent(new CustomEvent("dateloadend",{detail:s,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:{...s,error:o},bubbles:!0})),"failed"}finally{if(this._loadController===n)this._loadController=null,this.removeAttribute("data-loading");if(this._loadingKey===i)this._loadingKey="",this._loadingPromise=null}})();return this._loadingPromise=a,a}_setDisplay(e,t={}){let s=this._model.display;if(this._model.setDisplay(te(e,this.firstDay)),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&&s!==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(_e(this.display,-1)??this.display)}nextMonth(){return this._setDisplay(_e(this.display,1)??this.display)}focusDate(e,t={}){if(!d(e))throw TypeError(`Invalid date: ${e}`);let s=this._clamp(e),i=this.display,n=this._model.focused,r=t.moveFocus!==!1;if(this._model.setFocused(s),this._reflect("display",this._model.display),i!==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,s=!0){let i=e?this.querySelector(`.dp-day[data-date="${CSS.escape(e)}"]`):null,n=this.querySelector(`.dp-day[data-date="${CSS.escape(t)}"]`);if(i instanceof HTMLElement)i.tabIndex=-1;if(n instanceof HTMLElement){if(n.tabIndex=0,s)n.focus()}else if(s)this.focusGrid()}_moveSelectionDom(e,t){if(e){let s=this.querySelector(`.dp-day[data-date="${CSS.escape(e)}"]`);if(s instanceof HTMLElement)s.removeAttribute("data-selected"),s.removeAttribute("aria-selected")}if(t){let s=this.querySelector(`.dp-day[data-date="${CSS.escape(t)}"]`);if(s instanceof HTMLElement)return s.setAttribute("data-selected","true"),s.setAttribute("aria-selected","true"),!0}return!1}_dayLabel(e,t,s){let i=this.hasAttribute("data-range-preview")?"":It(s),n=typeof t.description==="string"?t.description:"";return[re(e,this.locale),n,i?this.messages[i]:"",t.disabled?this.messages.unavailable:""].filter(Boolean).join(". ")}_updateRangeDom(){let e=this._paintedRange,t=this._paintedPreview;this._paintedRange={...this._highlightedRange},this._paintedPreview=this.hasAttribute("data-range-preview");for(let s of this.querySelectorAll(".dp-day[data-date]")){if(!(s instanceof HTMLTableCellElement))continue;let i=s.dataset.date||"",n=pe(i,this._highlightedRange);if(n===pe(i,e)&&t===this._paintedPreview)continue;for(let[r,a]of Object.entries(Xe(n)))if(a)s.setAttribute(r,"true");else s.removeAttribute(r);if(!t||!this._paintedPreview){let r=this._renderedStates.get(i)||{},a=this._dayLabel(i,r,n);if(s.getAttribute("aria-label")!==a)s.setAttribute("aria-label",a)}}}focusGrid(){let e=this.querySelector(`.dp-day[data-date="${CSS.escape(this.focusedDate)}"]`);if(e instanceof HTMLElement)e.focus()}async activateDate(e){let t=await this.ensureDate(e),s=this.getDateState(e);if(!t||s.disabled)return this.dispatchEvent(new CustomEvent("dateinvalid",{detail:{date:e,state:s},bubbles:!0})),!1;if(!this.dispatchEvent(new CustomEvent("dateactivate",{detail:{date:e,state:s},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 s=t.closest("[data-calendar-action]");if(s instanceof HTMLButtonElement){let a=s.dataset.calendarAction;if(a==="previous")this.previousMonth();if(a==="next")this.nextMonth();return}let i=t.closest(".dp-day[data-date]");if(!(i instanceof HTMLTableCellElement))return;let n=i.dataset.date||"";if(!d(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.activateDate(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 s=Number(t.value);if(!Number.isInteger(s)||s<1||s>9998){if(this._connected)this.render(!1);return}this._setDisplay(`${String(s).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 s=t.dataset.date||"";if(!d(s))return;this._model.focused=s,this.dispatchEvent(new CustomEvent("datefocus",{detail:{date:s,state:this.getDateState(s)},bubbles:!0}))}_onKeyDown(e){let t=e.target;if(!(t instanceof HTMLTableCellElement)||!t.matches(".dp-day[data-date]"))return;let s=t.dataset.date||this.focusedDate;if(e.key==="Enter"||e.key===" "){e.preventDefault(),this.activateDate(s);return}let i=this._model.focused,n=this._model.display;if(this._model.firstDay=this.firstDay,this._model.setFocused(s,{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=i,this._model.display=n,!r)return;e.preventDefault(),this.focusDate(this._clamp(r))}render(e=!0){if(!this._connected)return;let t=this.locale,s=this.display,i=Ft(s),n=Number(s.slice(5,7)),r=Ke(t,this.monthFormat),a=Ae(t,this.firstDay,"short"),o=Ae(t,this.firstDay,"long"),c=this._weeks(),l=R(),u=`${this._id}-heading`,b=`${this._id}-grid`,D=this.min?f(this.min):"",x=this.max?f(this.max):"",T=_e(s,-1),S=_e(s,1),M=Boolean(D&&T!==null&&T<D),y=Boolean(x&&S!==null&&S>x),v=this.min?` min="${Number(this.min.slice(0,4))}"`:"",E=this.max?` max="${Number(this.max.slice(0,4))}"`:"",C=this.showWeekNumbers&&this.firstDay===1,k=C?`<th scope="col" class="dp-week-heading" abbr="${A(this.messages.week)}">#</th>`:"",z=r.map((h,m)=>{let w=m+1,p=`${String(i).padStart(4,"0")}-${String(w).padStart(2,"0")}`,J=D&&p<D||x&&p>x;return`<option value="${String(w).padStart(2,"0")}"${w===n?" selected":""}${J?" disabled":""}>${A(h)}</option>`}).join(""),I=a.map((h,m)=>`<th scope="col" abbr="${A(o[m])}">${A(h.replace(".",""))}</th>`).join("");this._renderedStates.clear();let U=c.map((h)=>{let m=C?`<th scope="row" class="dp-week-number">${Ve(h[0])}</th>`:"",w=h.map((p)=>{let J=this.getDateState(p);this._renderedStates.set(p,J);let ct=f(p)!==s,ut=this.value===p,ht=this.focusedDate===p,ft=p===l,Ie=pe(p,this._highlightedRange),pt=this._dayLabel(p,J,Ie);return`<td class="dp-day" data-date="${p}"${ct?' data-outside-month="true"':""}${ft?' data-today="true" aria-current="date"':""}${ut?' data-selected="true" aria-selected="true"':""}${Lt(Ie)}${J.disabled?' data-disabled="true" aria-disabled="true"':""} tabindex="${ht?"0":"-1"}" aria-label="${A(pt)}"><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}${w}</tr>`}).join(""),K=document.activeElement,q=K instanceof HTMLElement&&this.contains(K)?this._focusTargetKey(K):"",O=We(t)[0]==="year";this.toggleAttribute("data-year-first",O);let X=this.controlClasses,j=A(X.month||"dp-skin"),be=A(X.year||"dp-skin"),le=A(X.nav||"dp-skin"),Z=`<label class="dp-visually-hidden" for="${this._id}-month">${A(this.messages.month)}</label>
|
|
496
|
-
<select id="${this._id}-month" class="dp-month-select ${j}" aria-label="${A(this.messages.month)}">${z}</select>`,_=`<label class="dp-visually-hidden" for="${this._id}-year">${A(this.messages.year)}</label>
|
|
497
|
-
<input id="${this._id}-year" class="dp-year-input ${be}" type="number" inputmode="numeric" value="${i}"${v}${E} aria-label="${A(this.messages.year)}">`;if(this._rendering=!0,this.innerHTML=`
|
|
1
|
+
/*** @lekoala/date-picker v0.5.3 - https://github.com/lekoala/date-picker ***/
|
|
2
|
+
(()=>{var Pt=":where(date-calendar,date-picker){--dp-bg: #ffffff;--dp-fg: #1f2328;--dp-muted: color-mix(in srgb,var(--dp-fg) 58%,var(--dp-bg));--dp-border: color-mix(in srgb,var(--dp-fg) 16%,var(--dp-bg));--dp-hover: color-mix(in srgb,var(--dp-fg) 5%,var(--dp-bg));--dp-accent: #2563eb;--dp-accent-fg: #fff;--dp-focus: var(--dp-accent);--dp-focus-width: 2px;--dp-radius: 0.5rem;--dp-day-size: 2.75rem;--dp-gap: 0.375rem;--dp-header-control-size: 2.25rem;--dp-header-block-gap: 0.75rem;--dp-row-gap: 0.375rem;--dp-picker-button-size: 2.5rem;--dp-year-inline-size: 5.5rem;--dp-day-radius: calc(var(--dp-radius) * 0.75);color: var(--dp-fg);font: inherit}.dp-visually-hidden{position: absolute !important;inline-size: 1px !important;block-size: 1px !important;padding: 0 !important;margin: -1px !important;overflow: hidden !important;clip: rect(0 0 0 0) !important;white-space: nowrap !important;border: 0 !important}date-calendar{display: block;inline-size: max-content;max-inline-size: 100%}.dp-calendar-shell{inline-size: max-content;max-inline-size: 100%}.dp-calendar-header{display: grid;grid-template-columns: minmax(0,1fr) var(--dp-year-inline-size) auto auto;align-items: stretch;gap: var(--dp-gap);margin-block-end: var(--dp-header-block-gap)}date-calendar[data-year-first] .dp-calendar-header{grid-template-columns: var(--dp-year-inline-size) minmax(0,1fr) auto auto}.dp-calendar-header :where(button,select,input){box-sizing: border-box;min-inline-size: 0}.dp-calendar-header .dp-skin{min-block-size: var(--dp-header-control-size);padding-block: 0.15rem;border: 1px solid var(--dp-border);border-radius: calc(var(--dp-radius) * 0.75);background: var(--dp-bg);color: var(--dp-fg);font: inherit;line-height: 1.2}.dp-calendar-header input.dp-skin{padding-inline: 0.45rem}.dp-month-select{inline-size: 100%;overflow: hidden;text-overflow: ellipsis}.dp-month-select.dp-skin{appearance: none;padding-inline: 0.45rem 2rem;background-image: linear-gradient(45deg,transparent 50%,currentColor 50%),linear-gradient(135deg,currentColor 50%,transparent 50%);background-position: calc(100% - 0.9rem) 50%,calc(100% - 0.65rem) 50%;background-size: 0.3rem 0.3rem;background-repeat: no-repeat}[dir=\"rtl\"] .dp-month-select.dp-skin,html[dir=\"rtl\"] .dp-month-select.dp-skin{background-position: 0.9rem 50%,0.65rem 50%}.dp-year-input{inline-size: 100%}.dp-nav.dp-skin{display: grid;place-items: center;inline-size: var(--dp-header-control-size);padding: 0;font-size: 1.35rem;line-height: 1;cursor: pointer}.dp-nav svg{display: block;inline-size: 1rem;block-size: 1rem;pointer-events: none}.dp-calendar-header .dp-skin:disabled,.dp-picker-button:disabled{cursor: not-allowed;opacity: 0.45}.dp-nav.dp-skin:hover:not(:disabled){background: var(--dp-hover)}.dp-calendar-header .dp-skin:focus-visible,date-picker>input:not([type=\"hidden\"]):focus-visible,.dp-day:focus-visible{outline: var(--dp-focus-width) solid var(--dp-focus);outline-offset: calc(var(--dp-focus-width) * -1)}.dp-day:hover:not([data-disabled=\"true\"]):not([data-selected=\"true\"]):not([data-range-start=\"true\"]):not( [data-range-end=\"true\"] ){background: var(--dp-hover)}.dp-grid{border-collapse: separate;border-spacing: 0 var(--dp-row-gap);table-layout: fixed}.dp-grid :where(th,td){box-sizing: border-box;inline-size: var(--dp-day-size);block-size: var(--dp-day-size);padding: 0;text-align: center}.dp-grid thead th{block-size: 1.5rem;color: var(--dp-muted);font-size: 0.72rem;font-weight: 500}.dp-day{position: relative;border: 1px solid transparent;border-radius: var(--dp-day-radius);cursor: pointer;outline: none;vertical-align: middle;font-size: 0.875rem}.dp-day:is([data-selected=\"true\"],[data-range-start=\"true\"],[data-range-end=\"true\"]):focus-visible{outline-color: var(--dp-accent-fg)}.dp-day[data-outside-month=\"true\"]{color: var(--dp-muted)}.dp-day[data-selected=\"true\"]{background: var(--dp-accent);color: var(--dp-accent-fg)}.dp-day[data-today=\"true\"]:not([data-selected=\"true\"],[data-range-start=\"true\"],[data-range-end=\"true\"]){border-color: var(--dp-accent)}.dp-day[data-disabled=\"true\"]{cursor: not-allowed;opacity: 0.42}.dp-day[data-range-start=\"true\"],.dp-day[data-range-end=\"true\"]{background: var(--dp-accent);color: var(--dp-accent-fg)}.dp-day[data-in-range=\"true\"]{border-radius: 0;background: color-mix(in srgb,var(--dp-accent) 18%,var(--dp-bg))}.dp-day[data-range-start=\"true\"]:has(+ [data-in-range=\"true\"],+ [data-range-end=\"true\"]){border-start-end-radius: 0;border-end-end-radius: 0}.dp-day:is([data-in-range=\"true\"],[data-range-start=\"true\"]) + .dp-day[data-range-end=\"true\"]{border-start-start-radius: 0;border-end-start-radius: 0}.dp-day[data-in-range=\"true\"]:first-of-type{border-start-start-radius: var(--dp-day-radius);border-end-start-radius: var(--dp-day-radius)}.dp-day[data-in-range=\"true\"]:last-of-type{border-start-end-radius: var(--dp-day-radius);border-end-end-radius: var(--dp-day-radius)}[data-range-preview] .dp-day:is([data-range-start=\"true\"],[data-range-end=\"true\"]){background: color-mix(in srgb,var(--dp-accent) 58%,var(--dp-bg))}[data-range-preview] .dp-day[data-in-range=\"true\"]{background: color-mix(in srgb,var(--dp-accent) 11%,var(--dp-bg))}[data-range-drag] .dp-day:is([data-range-start=\"true\"],[data-range-end=\"true\"]){cursor: grab}[data-range-drag=\"active\"],[data-range-drag=\"active\"] .dp-day{cursor: grabbing}.dp-day-number{display: block;font-variant-numeric: tabular-nums}.dp-day[data-disabled=\"true\"]:focus-visible{opacity: 1}.dp-day[data-disabled=\"true\"]:focus-visible .dp-day-number{color: var(--dp-muted)}.dp-day-extra{position: absolute;inset-inline: 2px;inset-block-end: 1px;display: flex;justify-content: center;gap: 2px;min-block-size: 0.35rem;font-size: 0.55rem;line-height: 1;pointer-events: none}.dp-week-number,.dp-week-heading{inline-size: 1.6rem !important;color: var(--dp-muted);font-size: 0.65rem;font-weight: 500}date-picker{position: relative;display: inline-grid;grid-template-columns: minmax(0,1fr);align-items: stretch;max-inline-size: 100%}date-picker>input:not([type=\"hidden\"]){min-inline-size: 0}date-picker>input:not([type=\"hidden\"]):not([type=\"time\"]){grid-column: 1;grid-row: 1;box-sizing: border-box;inline-size: 100%;padding-inline-end: calc(var(--dp-picker-button-size) + 0.5rem)}.dp-picker-button{display: grid;place-items: center;grid-column: 1;grid-row: 1;justify-self: end;align-self: stretch;inline-size: var(--dp-picker-button-size);min-inline-size: 0;border: 0;background: transparent;color: var(--dp-fg);font: inherit;cursor: pointer}.dp-picker-button:focus-visible{outline: var(--dp-focus-width) solid var(--dp-focus);outline-offset: -5px;border-radius: var(--dp-radius)}date-picker:has(>[data-time-start],>[data-time-end]){grid-template-columns: minmax(0,1fr) minmax(0,1fr);column-gap: var(--dp-gap)}date-picker:has(>[data-time-start]):has(>[data-time-end]){grid-template-columns: minmax(0,1fr) minmax(0,1fr) minmax(0,1fr)}date-picker>input[data-time-start]{grid-column: 2;grid-row: 1;min-inline-size: 0}date-picker>input[data-time-end]{grid-column: 3;grid-row: 1;min-inline-size: 0}date-picker[range]{row-gap: var(--dp-gap)}date-picker[range]>input[data-range-start]{grid-row: 1}date-picker[range]>input[data-range-end]{grid-row: 2}date-picker[range]>.dp-picker-button[data-endpoint=\"start\"]{grid-row: 1}date-picker[range]>.dp-picker-button[data-endpoint=\"end\"]{grid-row: 2}.dp-picker-panel[popover]{position: fixed;inset: auto;margin: 0;padding: 0.875rem 1rem;border: 1px solid var(--dp-border);border-radius: var(--dp-radius);background: var(--dp-bg);color: var(--dp-fg);box-shadow: 0 0.5rem 1.5rem rgb(15 23 42 / 0.12);max-block-size: var(--available-height,90svh);max-inline-size: calc(100vi - 1rem);overflow: auto}.dp-picker-panel:not(:popover-open){display: none}@media (forced-colors: active){.dp-month-select.dp-skin,[dir=\"rtl\"] .dp-month-select.dp-skin{appearance: auto;background-image: none;padding-inline: 0.45rem}.dp-day:is([data-selected=\"true\"],[data-range-start=\"true\"],[data-range-end=\"true\"]){border: 2px solid Highlight;background-color: Canvas;color: CanvasText}.dp-day[data-in-range=\"true\"]{color: CanvasText}.dp-day[data-in-range=\"true\"]::after{content: \"\";position: absolute;inset-inline: 3px;inset-block-end: 4px;block-size: 1px;background-color: Highlight}.dp-day[data-today=\"true\"]{border-color: Highlight}.dp-day-extra{color: CanvasText;forced-color-adjust: none}}";var tt=new WeakMap;var _e=/^(\d{4})-(\d{2})-(\d{2})$/,ye=/^(\d{4})-(\d{2})$/;function be(t){return t%4===0&&(t%100!==0||t%400===0)}function st(t,e){if(e===2)return be(t)?29:28;return[4,6,9,11].includes(e)?30:31}function F(t){let e=_e.exec(String(t||""));if(!e)return null;let s=Number(e[1]),i=Number(e[2]),n=Number(e[3]);if(s<1||s>9999||i<1||i>12)return null;if(n<1||n>st(s,i))return null;return{year:s,month:i,day:n}}function c(t){return F(t)!==null}function p(t){let e=String(t||""),s=ye.exec(e);if(s){let n=Number(s[1]),r=Number(s[2]);if(n>=1&&n<=9999&&r>=1&&r<=12)return`${s[1]}-${String(r).padStart(2,"0")}`}let i=F(e);if(!i)throw TypeError(`Invalid civil date/month: ${t}`);return`${String(i.year).padStart(4,"0")}-${String(i.month).padStart(2,"0")}`}function U(t,e,s){let i=`${String(t).padStart(4,"0")}-${String(e).padStart(2,"0")}-${String(s).padStart(2,"0")}`;if(!c(i))throw TypeError(`Invalid civil date: ${i}`);return i}function B(t){let e=new Date(0);return e.setUTCHours(12,0,0,0),e.setUTCFullYear(t.year,t.month-1,t.day),e}function ve(t){return U(t.getUTCFullYear(),t.getUTCMonth()+1,t.getUTCDate())}function N(t){let e=F(t);if(!e)throw TypeError(`Invalid civil date: ${t}`);return B(e)}function g(t,e){if(!c(t)||!c(e))throw TypeError("compareDates() expects YYYY-MM-DD values");return t===e?0:t<e?-1:1}function I(t,e){let s=F(t);if(!s||!Number.isInteger(e))throw TypeError("addDays() expects a date and integer amount");let i=B(s);return i.setUTCDate(i.getUTCDate()+e),ve(i)}function ht(t,e){let s=F(t);if(!s||!Number.isInteger(e))throw TypeError("addMonths() expects a date and integer amount");let i=s.year*12+(s.month-1)+e,n=Math.floor(i/12),a=(i%12+12)%12+1,o=Math.min(s.day,st(n,a));return U(n,a,o)}function Ht(t,e){let s=F(t);if(!s||!Number.isInteger(e))throw TypeError("addYears() expects a date and integer amount");let i=s.year+e,n=Math.min(s.day,st(i,s.month));return U(i,s.month,n)}function et(t,e){let s=`${p(t)}-01`;return p(ht(s,e))}function we(t){return`${p(t)}-01`}function Dt(t){let e=F(`${p(t)}-01`);if(!e)throw TypeError(`Invalid month: ${t}`);return U(e.year,e.month,st(e.year,e.month))}function De(t){let e=F(t);if(!e)throw TypeError(`Invalid civil date: ${t}`);return B(e).getUTCDay()}function Y(t){if(t===7)return 0;if(!Number.isInteger(t)||t<0||t>6)throw RangeError("firstDay must be 0..6 (Sunday=0, 7 accepted as Sunday alias)");return t}function ft(t,e=1){let s=(De(t)-Y(e)+7)%7;return I(t,-s)}function xt(t,e=1){return I(ft(t,e),6)}function Bt(t,e={}){let s=e.firstDay??1,i=ft(we(t),s),n=xt(Dt(t),s),r=[],a=i;for(;;){let o=[];for(let d=0;d<7;d++)o.push(I(a,d));if(r.push(o),g(o[6],n)>=0){if(!e.fixedWeeks||r.length>=6||g(o[6],I("9999-12-31",-7))>0)break}a=I(a,7)}return r}function zt(t,e,s){let i=B({year:1,month:1,day:1});return Math.round((B({year:t,month:e,day:s}).getTime()-i.getTime())/86400000)}function it(t,e=1){let s=Y(e),i=zt(9999,12,31),n=p(t);for(;;){let r=F(`${n}-01`);if(!r)throw TypeError(`Invalid civil date/month: ${t}`);let a=zt(r.year,r.month,1),o=(B(r).getUTCDay()-s+7)%7;if(a-o<0){n=et(n,1);continue}let d=st(r.year,r.month),l={year:r.year,month:r.month,day:d},h=a+d-1,b=(B(l).getUTCDay()-s+7)%7;if(h-b+6>i){n=et(n,-1);continue}return n}}function Nt(t,e="",s=""){if(!c(t))throw TypeError(`Invalid civil date: ${t}`);if(e&&g(t,e)<0)return e;if(s&&g(t,s)>0)return s;return t}function O(){let t=new Date;return U(t.getFullYear(),t.getMonth()+1,t.getDate())}function Vt(t){let e=F(t);if(!e)throw TypeError(`Invalid civil date: ${t}`);let s=B(e),i=s.getUTCDay()||7;s.setUTCDate(s.getUTCDate()+4-i);let n=new Date(0);return n.setUTCHours(12,0,0,0),n.setUTCFullYear(s.getUTCFullYear(),0,1),Math.ceil(((s.getTime()-n.getTime())/86400000+1)/7)}class Et{constructor(t={}){let e=O();this.firstDay=Y(t.firstDay??1),this.value=t.value&&c(t.value)?t.value:"",this.focused=t.focused&&c(t.focused)?t.focused:this.value||e,this.display=t.display?p(t.display):p(this.focused)}setValue(t){if(t&&!c(t))throw TypeError(`Invalid value: ${t}`);return this.value=t||"",this.value}setDisplay(t){let e=p(t),s=Number(this.focused.slice(8,10))||1,i=ht(`${e}-01`,0),n=I(i,Math.max(0,s-1));return this.focused=p(n)===e?n:I(`${et(e,1)}-01`,-1),this.display=e,this.display}setFocused(t,e={}){if(!c(t))throw TypeError(`Invalid focused date: ${t}`);if(this.focused=t,e.follow!==!1)this.display=p(t);return this.focused}moveFocusDays(t){return this.setFocused(I(this.focused,t))}moveFocusMonths(t){return this.setFocused(ht(this.focused,t))}moveFocusYears(t){return this.setFocused(Ht(this.focused,t))}focusWeekStart(){return this.setFocused(ft(this.focused,this.firstDay))}focusWeekEnd(){return this.setFocused(xt(this.focused,this.firstDay))}navigateMonth(t){let e=et(this.display,t);return this.setDisplay(e),this.display}}function xe(t){if(typeof t!=="string")return"";return[...new Set(t.split(/\s+/).filter((e)=>e&&!e.startsWith("dp-")&&![...e].some((s)=>s.charCodeAt(0)<32||s.charCodeAt(0)===127)))].join(" ")}function At(t,e){return t.month===e.month&&t.year===e.year&&t.nav===e.nav}var Ct={month:"",year:"",nav:""};function nt(){return{...Ct}}function rt(t){if(t==null)return null;let e={};for(let s of["month","year","nav"])if(Object.hasOwn(t,s))e[s]=xe(t[s]);return e}function Ut(t){return t==null||["month","year","nav"].some((e)=>!Object.hasOwn(t,e))}function at(t){return{...nt(),...rt(t)}}function pt(t){let e=at(t);if(At(Ct,e))return;Ct=e;for(let s of kt)s()}var kt=new Set;function jt(t){return kt.add(t),()=>{kt.delete(t)}}function mt(t){if(t==null)return{start:"",end:""};if(typeof t!=="object")throw TypeError("highlightedRange expects { start, end }");let{start:e="",end:s=""}=t;if(e&&!c(e))throw TypeError(`Invalid range start: ${e}`);if(s&&!c(s))throw TypeError(`Invalid range end: ${s}`);if(!e&&s)throw TypeError("highlightedRange cannot define an end without a start");if(e&&s&&g(s,e)<0)throw TypeError("highlightedRange must be ordered; start must be on or before end");return{start:e,end:s}}function gt(t,e){if(!e||!c(t))return"";let{start:s,end:i}=e;if(!s||!c(s))return"";if(s===t)return i?i===t?"single":"start":"start";if(i&&i===t)return"end";if(i&&g(t,s)>=0&&g(t,i)<=0)return"in";return""}class St{constructor(){this.activeEndpoint="",this.start="",this.end=""}get range(){return{start:this.start,end:this.end}}get complete(){return Boolean(this.start&&this.end&&g(this.end,this.start)>=0)}focus(t){this.activeEndpoint=t}_refuse(t){return{status:"refused",endpoint:t,changedEndpoints:[],range:this.range,activeEndpoint:this.activeEndpoint}}project(t,e=()=>!0){if(!c(t))throw TypeError(`Invalid range activation: ${t}`);let{start:s,end:i}=this;if(this.complete&&(g(t,s)<0||g(t,i)>0)){let r=g(t,s)<0?"start":"end";if(!e(r))return this._refuse(r);return{status:"complete",endpoint:r,changedEndpoints:[r],range:r==="start"?{start:t,end:i}:{start:s,end:t},activeEndpoint:r}}if(this.activeEndpoint==="end"){if(s&&!i&&g(t,s)<0){if(!e("start"))return this._refuse("start");if(!e("end"))return this._refuse("end");return{status:"complete",endpoint:"end",changedEndpoints:["start","end"],range:{start:t,end:s},activeEndpoint:"end"}}if(s&&g(t,s)<0)return this._refuse("end");if(!e("end"))return this._refuse("end");return{status:s?"complete":"pending",endpoint:"end",changedEndpoints:["end"],range:{start:s,end:t},activeEndpoint:"end"}}if(i&&!s&&g(t,i)>0){if(!e("start"))return this._refuse("start");if(!e("end"))return this._refuse("end");return{status:"complete",endpoint:"start",changedEndpoints:["start","end"],range:{start:i,end:t},activeEndpoint:"start"}}if(!e("start"))return this._refuse("start");let n=e("end");return{status:"pending",endpoint:"start",changedEndpoints:["start"],range:{start:t,end:i},activeEndpoint:n?"end":this.activeEndpoint,...n?{}:{close:!0}}}projectEndpoint(t,e,s=()=>!0){if(!c(t))throw TypeError(`Invalid range activation: ${t}`);if(!this.complete||!s(e))return this._refuse(e);let{start:i,end:n}=this,r=e==="start"?i:n,a=e==="start"?Ce(t,n):Ee(t,i);return{status:"complete",endpoint:e,changedEndpoints:a===r?[]:[e],range:e==="start"?{start:a,end:n}:{start:i,end:a},activeEndpoint:e}}previewRange(t,e="",s=()=>!0){if(!c(t))return null;if(!e&&Boolean(this.start)===Boolean(this.end))return null;let i=e?this.projectEndpoint(t,e,s):this.project(t,s);if(i.status==="refused")return null;let{start:n,end:r}=i.range;if(!n||r&&g(r,n)<0)return null;return{start:n,end:r}}_apply(t){if(t.status==="refused")return t;return this.start=t.range.start,this.end=t.range.end,this.activeEndpoint=t.activeEndpoint,t}activate(t,e=()=>!0){return this._apply(this.project(t,e))}moveEndpoint(t,e,s=()=>!0){return this._apply(this.projectEndpoint(t,e,s))}}function Ee(t,e){if(!t)return e;if(!e)return t;return g(t,e)>=0?t:e}function Ce(t,e){if(!t)return e;if(!e)return t;return g(t,e)<=0?t:e}var Yt=/[\u200e\u200f\u061c\u202a-\u202e\u2066-\u2069]/g,ke=new Map,Ae=new Map;function Wt(t,e,s){let i=t.get(e);if(i!==void 0)return i;let n=s(),r=t.keys().next().value;if(t.size>=64&&r!==void 0)t.delete(r);return t.set(e,n),n}function W(t,e){let s=JSON.stringify([t,e]);return Wt(ke,s,()=>new Intl.DateTimeFormat(t,e))}function P(t=""){if(t)return t;if(typeof document<"u"&&document.documentElement.lang)return document.documentElement.lang;if(typeof navigator<"u"&&navigator.language)return navigator.language;return"en-US"}function Se(t){return Wt(Ae,t,()=>{let e=new Intl.NumberFormat(t,{useGrouping:!1}),s=new Map;for(let i=0;i<=9;i++)s.set(e.format(i),String(i));return s})}function Gt(t,e,s={}){let i=String(t||"").replace(Yt,"");if(s.trim!==!1)i=i.trim();for(let[n,r]of Se(e))i=i.split(n).join(r);return i}function ot(t,e=""){let s=P(e);return W(s,{calendar:"gregory",weekday:"long",year:"numeric",month:"long",day:"numeric",timeZone:"UTC"}).format(N(t))}function qt(t,e=""){let s=P(e);return W(s,{calendar:"gregory",year:"numeric",month:"long",timeZone:"UTC"}).format(N(`${t.slice(0,7)}-15`))}function Kt(t=""){let e=P(t);try{let s=W(e,{calendar:"gregory",year:"numeric",month:"long",timeZone:"UTC"}).formatToParts(N("2026-09-15")),i=-1,n=-1;if(s.forEach((r,a)=>{let o=r.type;if(o==="month"){if(i<0)i=a}else if(o==="year"||o==="relatedYear"||o==="yearName"){if(n<0)n=a}}),i>=0&&n>=0)return n<i?["year","month"]:["month","year"]}catch{}return["month","year"]}function Xt(t="",e="long"){let s=P(t),i=W(s,{calendar:"gregory",month:e,timeZone:"UTC"});return Array.from({length:12},(n,r)=>i.format(N(`2026-${String(r+1).padStart(2,"0")}-15`)))}function Tt(t="",e=1,s="short"){let i=P(t),n=W(i,{calendar:"gregory",weekday:s,timeZone:"UTC"}),r=Y(e),a=N("2026-01-04");return Array.from({length:7},(o,d)=>{let l=new Date(a);return l.setUTCDate(a.getUTCDate()+(r+d)%7),n.format(l)})}function Te(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function dt(t=""){let e=P(t),s=W(e,{calendar:"gregory",year:"numeric",month:"2-digit",day:"2-digit",timeZone:"UTC"}),i=N("2006-11-22"),n=s.formatToParts(i).filter((l)=>l.type!=="literal"||l.value),r=n.filter((l)=>["day","month","year"].includes(l.type)).map((l)=>l.type),a=n.map((l)=>{if(l.type==="day")return"DD";if(l.type==="month")return"MM";if(l.type==="year")return"YYYY";return l.value.replace(Yt,"")}).join(""),o=n.map((l)=>{if(l.type==="day"||l.type==="month")return"(\\d{1,2})";if(l.type==="year")return"(\\d{4})";let h=Gt(l.value,e,{trim:!1});return Te(h).replace(/\s+/g,"\\s*")}).join(""),d=new RegExp(`^\\s*${o}\\s*$`);return{locale:e,placeholder:a,format(l){if(!c(l))return"";return s.format(N(l))},parse(l){let h=Gt(l,e);if(c(h))return h;let b=d.exec(h);if(!b)return"";let D={};if(r.forEach((x,S)=>{D[x]=Number(b[S+1])}),!D.year||!D.month||!D.day)return"";try{return U(D.year,D.month,D.day)}catch{return""}}}}var Me={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"},Mt={...Me};function V(){return{...Mt}}function _t(t){Mt={...Mt,...t};for(let e of It)e()}var It=new Set;function yt(t){return It.add(t),()=>{It.delete(t)}}function Zt(t){let e=t&&typeof t==="object"&&!Array.isArray(t)&&"dates"in t?t.dates:t,s=new Map;if(Array.isArray(e)){for(let i of e){if(!i||typeof i!=="object"||!("date"in i))continue;let{date:n,...r}=i;s.set(String(n),r)}return s}if(e&&typeof e==="object")for(let[i,n]of Object.entries(e))s.set(i,n&&typeof n==="object"?n:{});return s}function q(t,e){for(let s of e){if(!Object.hasOwn(t,s))continue;let i=Reflect.get(t,s);Reflect.deleteProperty(t,s),Reflect.set(t,s,i)}}var Ie=0;function A(t){return String(t).replaceAll("&","&").replaceAll("<","<").replaceAll(">",">").replaceAll('"',""").replaceAll("'","'")}function $e(t){let e=Number(t);if(e===7)return 0;return Number.isInteger(e)&&e>=0&&e<=6?e:1}function Fe(t){return Number(t.slice(0,4))}function bt(t,e){let[s,i]=t.split("-").map(Number),n=s*12+(i-1)+e,r=Math.floor(n/12),a=(n%12+12)%12+1;if(r<1||r>9999)return null;return`${String(r).padStart(4,"0")}-${String(a).padStart(2,"0")}`}function Jt(t){return{"data-range-start":t==="start"||t==="single","data-range-end":t==="end"||t==="single","data-in-range":t==="in"}}function Le(t){return Object.entries(Jt(t)).filter(([,e])=>e).map(([e])=>` ${e}="true"`).join("")}function Re(t){if(t==="single")return"rangeSingle";if(t==="start")return"rangeStart";if(t==="end")return"rangeEnd";if(t==="in")return"rangeInRange";return""}class lt extends HTMLElement{static observedAttributes=["value","display","min","max","first-day","locale","fixed-weeks","show-week-numbers","selection","month-format"];static setDefaultControlClasses(t){pt(t)}static getDefaultControlClasses(){return nt()}static setDefaultMessages(t){_t(t)}static getDefaultMessages(){return V()}constructor(){super();this._id=`date-calendar-${++Ie}`,this._model=new Et,this._connected=!1,this._lifecycleId=0,this._rendering=!1,this._heading=null,this._renderRoot=null,this._source=null,this._hostIntent=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._paintedRange={start:"",end:""},this._paintedPreview=!1,this._renderedStates=new Map,this._messages=null,this._controlClasses=null,this._stopDefaultMessages=null,this._stopDefaultControlClasses=null,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._lifecycleId++,q(this,["locale","min","max","firstDay","selection","monthFormat","fixedWeeks","showWeekNumbers","controlClasses","messages","source","dateState","renderDay","isDateDisabled","highlightedRange","value","display"]),this._syncModel(),q(this,["focusedDate"]),this._stopDefaultControlClasses=jt(()=>{if(Ut(this._controlClasses))this.render()}),this._stopDefaultMessages=yt(()=>{if(this._messages===null)this.render()}),this._connected=!0,this.addEventListener("click",this._onClick),this.addEventListener("change",this._onChange),this.addEventListener("keydown",this._onKeyDown),this.addEventListener("focusin",this._onFocusIn),this.render()}disconnectedCallback(){this._stopDefaultControlClasses?.(),this._stopDefaultControlClasses=null,this._stopDefaultMessages?.(),this._stopDefaultMessages=null,this._connected=!1,this._lifecycleId++,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(t,e,s){if(this._rendering)return;if(t==="value"&&s&&!c(s)){this._reflect("value",this._model.value);return}if((t==="min"||t==="max")&&s&&!c(s)){if(this._reflect(t,""),this._connected)this._syncModel(),this.render();return}if(t==="display"&&s)try{if(p(s)!==s)throw TypeError("Non-canonical month")}catch{this._reflect("display",this._model.display);return}if(!this._connected)return;this._syncModel(),this.render()}_queueFocus(t){let e=this._lifecycleId;queueMicrotask(()=>{if(!this._connected||e!==this._lifecycleId)return;t()})}get locale(){return P(this.getAttribute("locale")||"")}set locale(t){if(t)this.setAttribute("locale",t);else this.removeAttribute("locale")}get value(){return this._model.value}set value(t){let e=t||"";if(e&&!c(e))throw TypeError(`Invalid calendar value: ${e}`);if(e===this._model.value)return;if(this._model.setValue(e),this._reflect("value",e),this._connected)this.render()}get display(){return this._model.display}set display(t){this._setDisplay(t,{emit:!1})}get focusedDate(){return this._model.focused}set focusedDate(t){let e=t||"";if(e===this._model.focused)return;this.focusDate(e,{moveFocus:!1})}get min(){let t=this.getAttribute("min")||"";return c(t)?t:""}set min(t){if(t)this.setAttribute("min",t);else this.removeAttribute("min")}get max(){let t=this.getAttribute("max")||"";return c(t)?t:""}set max(t){if(t)this.setAttribute("max",t);else this.removeAttribute("max")}get firstDay(){return $e(this.getAttribute("first-day")||"1")}set firstDay(t){this.setAttribute("first-day",String(t))}get selection(){return this.getAttribute("selection")==="none"?"none":"single"}set selection(t){this.setAttribute("selection",t==="none"?"none":"single")}get monthFormat(){return this.getAttribute("month-format")==="short"?"short":"long"}set monthFormat(t){if(t==="short")this.setAttribute("month-format","short");else this.removeAttribute("month-format")}get highlightedRange(){return{...this._highlightedRange}}set highlightedRange(t){let e=mt(t),s=this.hasAttribute("data-range-preview");if(e.start===this._paintedRange.start&&e.end===this._paintedRange.end&&s===this._paintedPreview)return;if(this._highlightedRange=e,this._connected)this._updateRangeDom()}get fixedWeeks(){return this.hasAttribute("fixed-weeks")}set fixedWeeks(t){this.toggleAttribute("fixed-weeks",Boolean(t))}get showWeekNumbers(){return this.hasAttribute("show-week-numbers")}set showWeekNumbers(t){this.toggleAttribute("show-week-numbers",Boolean(t))}get controlClasses(){return at(this._controlClasses)}set controlClasses(t){let e=this.controlClasses;if(this._controlClasses=rt(t),At(e,this.controlClasses))return;if(this._connected)this.render()}get messages(){return this._messages??V()}set messages(t){if(this._messages=t==null?null:{...V(),...t},this._connected)this.render()}get source(){return this._source}set source(t){this._source=t||null,this.refreshSource()}get dateState(){return this._dateState}set dateState(t){if(this._dateState=typeof t==="function"?t:null,this._connected)this.render()}get renderDay(){return this._renderDay}set renderDay(t){if(this._renderDay=typeof t==="function"?t:null,this._connected)this.render()}get isDateDisabled(){return this._isDateDisabled}set isDateDisabled(t){if(this._isDateDisabled=typeof t==="function"?t:null,this._connected)this.render()}_syncModel(){let t=this.firstDay;this._model.firstDay=t;let e=this.getAttribute("value")||"";if(!e||c(e))this._model.value=e;let s=this.getAttribute("display")||"";if(s)try{this._model.setDisplay(it(s,t))}catch{}else if(this._model.value)this._model.display=p(this._model.value),this._model.focused=this._model.value;if(this._model.focused=this._clamp(this._model.focused),!this.getAttribute("display"))this._model.display=p(this._model.focused)}_reflect(t,e){if(this._rendering=!0,e){if(this.getAttribute(t)!==e)this.setAttribute(t,e)}else if(this.hasAttribute(t))this.removeAttribute(t);this._rendering=!1}_clamp(t){let e=Nt(t,this.min,this.max),s=p(e),i=it(s,this.firstDay);if(i===s)return e;let n=Number(e.slice(8,10))||1,r=I(`${i}-01`,n-1),a=Dt(i);return g(r,a)>0?a:r}_weeks(t=this.display){return Bt(it(t,this.firstDay),{firstDay:this.firstDay,fixedWeeks:this.fixedWeeks})}_focusTargetKey(t){if(t.matches(".dp-month-select, .dp-year-input")&&t.id)return`#${CSS.escape(t.id)}`;if(t.matches(".dp-nav[data-calendar-action]"))return`.dp-nav[data-calendar-action="${CSS.escape(t.dataset.calendarAction||"")}"]`;if(t.matches(".dp-day[data-date]")){let e=t.getAttribute("data-date")||"";if(c(e))return`.dp-day[data-date="${e}"]`}return""}_range(t=this.display){let e=this._weeks(t),s=e[0],i=e[e.length-1];if(!s||!i)throw Error("Calendar month produced no weeks");return{start:s[0],end:i[6]}}getDateState(t){let e=this._sourceStates.get(t)||{},s=this._dateState?.(t,{...e})||{},i={...e,...s},n=this.min&&g(t,this.min)<0||this.max&&g(t,this.max)>0,a=i.enabled===!0?!1:Boolean(this._isDateDisabled?.(t)),o=Boolean(n)||Boolean(i.disabled)||a;return{...i,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(t){if(!c(t)||!this._source)return!0;return await this._loadDisplay(p(t),!1)==="loaded"}async _loadDisplay(t,e=!0){if(!this._source)return"loaded";let s=this._range(t),i=`${s.start}/${s.end}`;if(this._loadedRanges.has(i))return"loaded";if(i===this._loadingKey&&this._loadingPromise)return this._loadingPromise;this._loadController?.abort();let n=new AbortController;this._loadController=n,this._loadingKey=i;let r=this._source,a=(async()=>{this.toggleAttribute("data-loading",!0),this.dispatchEvent(new CustomEvent("dateloadstart",{detail:s,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 d=await o(s,{signal:n.signal});if(n.signal.aborted)return"cancelled";for(let[l,h]of Zt(d))this._sourceStates.set(l,h);if(this._loadedRanges.add(i),this.dispatchEvent(new CustomEvent("dateloadend",{detail:s,bubbles:!0})),e&&this._connected&&p(this.display)===p(t))this.render(!1);return"loaded"}catch(o){if(n.signal.aborted)return"cancelled";return this.dispatchEvent(new CustomEvent("dateloaderror",{detail:{...s,error:o},bubbles:!0})),"failed"}finally{if(this._loadController===n)this._loadController=null,this.removeAttribute("data-loading");if(this._loadingKey===i)this._loadingKey="",this._loadingPromise=null}})();return this._loadingPromise=a,a}_setDisplay(t,e={}){let s=this._model.display;if(this._model.setDisplay(it(t,this.firstDay)),this._model.focused=this._clamp(this._model.focused),this._model.display=p(this._model.focused),this._reflect("display",this._model.display),this._connected)this.render();if(e.emit!==!1&&s!==this._model.display)this._emitDisplayChange();return this._model.display}_emitDisplayChange(){let t=this._range();this.dispatchEvent(new CustomEvent("displaychange",{detail:{display:this.display,...t},bubbles:!0}))}previousMonth(){return this._setDisplay(bt(this.display,-1)??this.display)}nextMonth(){return this._setDisplay(bt(this.display,1)??this.display)}focusDate(t,e={}){if(!c(t))throw TypeError(`Invalid date: ${t}`);let s=this._clamp(t),i=this.display,n=this._model.focused,r=e.moveFocus!==!1;if(this._model.setFocused(s),this._reflect("display",this._model.display),i!==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)this._queueFocus(()=>this.focusGrid())}_moveFocusDom(t,e,s=!0){let i=t?this.querySelector(`.dp-day[data-date="${CSS.escape(t)}"]`):null,n=this.querySelector(`.dp-day[data-date="${CSS.escape(e)}"]`);if(i instanceof HTMLElement)i.tabIndex=-1;if(n instanceof HTMLElement){if(n.tabIndex=0,s)n.focus()}else if(s)this.focusGrid()}_syncRovingDom(t){for(let s of this.querySelectorAll('.dp-day[tabindex="0"]'))if(s instanceof HTMLElement&&s.dataset.date!==t)s.tabIndex=-1;let e=this.querySelector(`.dp-day[data-date="${CSS.escape(t)}"]`);if(e instanceof HTMLElement)e.tabIndex=0}_moveSelectionDom(t,e){if(t){let s=this.querySelector(`.dp-day[data-date="${CSS.escape(t)}"]`);if(s instanceof HTMLElement)s.removeAttribute("data-selected"),s.removeAttribute("aria-selected")}if(e){let s=this.querySelector(`.dp-day[data-date="${CSS.escape(e)}"]`);if(s instanceof HTMLElement)return s.setAttribute("data-selected","true"),s.setAttribute("aria-selected","true"),!0}return!1}_dayLabel(t,e,s){let i=this.hasAttribute("data-range-preview")?"":Re(s),n=typeof e.description==="string"?e.description:"";return[ot(t,this.locale),n,i?this.messages[i]:"",e.disabled?this.messages.unavailable:""].filter(Boolean).join(". ")}_updateRangeDom(){let t=this._paintedRange,e=this._paintedPreview;this._paintedRange={...this._highlightedRange},this._paintedPreview=this.hasAttribute("data-range-preview");for(let s of this.querySelectorAll(".dp-day[data-date]")){if(!(s instanceof HTMLTableCellElement))continue;let i=s.dataset.date||"",n=gt(i,this._highlightedRange);if(n===gt(i,t)&&e===this._paintedPreview)continue;for(let[r,a]of Object.entries(Jt(n)))if(a)s.setAttribute(r,"true");else s.removeAttribute(r);if(!e||!this._paintedPreview){let r=this._renderedStates.get(i)||{},a=this._dayLabel(i,r,n);if(s.getAttribute("aria-label")!==a)s.setAttribute("aria-label",a)}}}focusGrid(){let t=this.querySelector(`.dp-day[data-date="${CSS.escape(this.focusedDate)}"]`);if(t instanceof HTMLElement)t.focus()}async activateDate(t){if(!this._connected)return!1;let e=this._lifecycleId,s=this._hostIntent?.date===t?this._hostIntent.intent:void 0;this._hostIntent=null;let i=(o)=>{if(s!==void 0)tt.set(o,s);return o},n=await this.ensureDate(t);if(!this._connected||e!==this._lifecycleId)return!1;let r=this.getDateState(t);if(!n||r.disabled)return this.dispatchEvent(i(new CustomEvent("dateinvalid",{detail:{date:t,state:r},bubbles:!0}))),!1;if(!this.dispatchEvent(i(new CustomEvent("dateactivate",{detail:{date:t,state:r},bubbles:!0,cancelable:!0}))))return!1;if(this.selection==="single"){let o=this._model.value;if(this._model.setValue(t),this._reflect("value",t),this.dispatchEvent(new CustomEvent("datechange",{detail:{value:t},bubbles:!0})),this.dispatchEvent(new Event("change",{bubbles:!0})),this._connected)if(p(t)===this.display)this._moveSelectionDom(o,t);else this.render()}else if(this._connected){if(p(t)!==this.display)this.render()}return!0}_onClick(t){let e=t.target;if(!(e instanceof Element))return;let s=e.closest("[data-calendar-action]");if(s instanceof HTMLButtonElement){let a=s.dataset.calendarAction;if(a==="previous")this.previousMonth();if(a==="next")this.nextMonth();return}let i=e.closest(".dp-day[data-date]");if(!(i instanceof HTMLTableCellElement))return;let n=i.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();else this._syncRovingDom(this._model.focused);this.activateDate(n)}_onChange(t){let e=t.target;if(e instanceof HTMLSelectElement&&e.matches(".dp-month-select")){this._setDisplay(`${this.display.slice(0,4)}-${e.value}`);return}if(e instanceof HTMLInputElement&&e.matches(".dp-year-input")){let s=Number(e.value);if(!Number.isInteger(s)||s<1||s>9999){if(this._connected)this.render(!1);return}this._setDisplay(`${String(s).padStart(4,"0")}-${this.display.slice(5,7)}`)}}_onFocusIn(t){let e=t.target;if(!(e instanceof HTMLTableCellElement)||!e.matches(".dp-day[data-date]"))return;let s=e.dataset.date||"";if(!c(s))return;this._model.focused=s,this._syncRovingDom(s),this.dispatchEvent(new CustomEvent("datefocus",{detail:{date:s,state:this.getDateState(s)},bubbles:!0}))}_onKeyDown(t){let e=t.target;if(!(e instanceof HTMLTableCellElement)||!e.matches(".dp-day[data-date]"))return;let s=e.dataset.date||this.focusedDate;if(t.key==="Enter"||t.key===" "){t.preventDefault(),this.activateDate(s);return}let i=this._model.focused,n=this._model.display;if(this._model.firstDay=this.firstDay,this._model.setFocused(s,{follow:!1}),t.key==="ArrowLeft")this._model.moveFocusDays(-1);else if(t.key==="ArrowRight")this._model.moveFocusDays(1);else if(t.key==="ArrowUp")this._model.moveFocusDays(-7);else if(t.key==="ArrowDown")this._model.moveFocusDays(7);else if(t.key==="Home")this._model.focusWeekStart();else if(t.key==="End")this._model.focusWeekEnd();else if(t.key==="PageUp")t.shiftKey?this._model.moveFocusYears(-1):this._model.moveFocusMonths(-1);else if(t.key==="PageDown")t.shiftKey?this._model.moveFocusYears(1):this._model.moveFocusMonths(1);else return;let r=this._model.focused;if(this._model.focused=i,this._model.display=n,!r)return;t.preventDefault(),this.focusDate(this._clamp(r))}render(t=!0){if(!this._connected)return;let e=this.locale,s=this.display,i=Fe(s),n=Number(s.slice(5,7)),r=Xt(e,this.monthFormat),a=Tt(e,this.firstDay,"short"),o=Tt(e,this.firstDay,"long"),d=this._weeks(),l=O(),h=`${this._id}-heading`,b=`${this._id}-grid`,D=this.min?p(this.min):"",x=this.max?p(this.max):"",S=bt(s,-1),T=bt(s,1),M=Boolean(D&&S!==null&&S<D),y=Boolean(x&&T!==null&&T>x),v=` min="${this.min?Number(this.min.slice(0,4)):1}"`,E=` max="${this.max?Number(this.max.slice(0,4)):9999}"`,k=this.showWeekNumbers&&this.firstDay===1,C=k?`<th scope="col" class="dp-week-heading" abbr="${A(this.messages.week)}">#</th>`:"",H=r.map((u,f)=>{let w=f+1,m=`${String(i).padStart(4,"0")}-${String(w).padStart(2,"0")}`,Q=D&&m<D||x&&m>x;return`<option value="${String(w).padStart(2,"0")}"${w===n?" selected":""}${Q?" disabled":""}>${A(u)}</option>`}).join(""),L=a.map((u,f)=>`<th scope="col" abbr="${A(o[f])}">${A(u.replace(".",""))}</th>`).join("");this._renderedStates.clear();let j=d.map((u)=>{let f=k?`<th scope="row" class="dp-week-number">${Vt(u[0])}</th>`:"",w=u.map((m)=>{let Q=this.getDateState(m);this._renderedStates.set(m,Q);let he=p(m)!==s,fe=this.value===m,pe=this.focusedDate===m,me=m===l,Ot=gt(m,this._highlightedRange),ge=this._dayLabel(m,Q,Ot);return`<td class="dp-day" data-date="${m}"${he?' data-outside-month="true"':""}${me?' data-today="true" aria-current="date"':""}${fe?' data-selected="true" aria-selected="true"':""}${Le(Ot)}${Q.disabled?' data-disabled="true" aria-disabled="true"':""} tabindex="${pe?"0":"-1"}" aria-label="${A(ge)}"><span class="dp-day-number" aria-hidden="true">${Number(m.slice(8,10))}</span><span class="dp-day-extra" aria-hidden="true"></span></td>`}).join("");return`<tr>${f}${w}</tr>`}).join(""),K=document.activeElement,X=K instanceof HTMLElement&&this.contains(K)?this._focusTargetKey(K):"",R=Kt(e)[0]==="year";this.toggleAttribute("data-year-first",R);let Z=this.controlClasses,G=A(Z.month||"dp-skin"),wt=A(Z.year||"dp-skin"),ut=A(Z.nav||"dp-skin"),J=`<label class="dp-visually-hidden" for="${this._id}-month">${A(this.messages.month)}</label>
|
|
3
|
+
<select id="${this._id}-month" class="dp-month-select ${G}" aria-label="${A(this.messages.month)}">${H}</select>`,_=`<label class="dp-visually-hidden" for="${this._id}-year">${A(this.messages.year)}</label>
|
|
4
|
+
<input id="${this._id}-year" class="dp-year-input ${wt}" type="number" inputmode="numeric" value="${i}"${v}${E} aria-label="${A(this.messages.year)}">`;if(!this._heading?.isConnected||!this._renderRoot?.isConnected){this.replaceChildren();let u=document.createElement("h2");u.id=h,u.className="dp-calendar-heading dp-visually-hidden",u.setAttribute("aria-live","polite");let f=document.createElement("div");f.className="dp-calendar-render",this.append(u,f),this._heading=u,this._renderRoot=f}if(this._rendering=!0,this._renderRoot.innerHTML=`
|
|
498
5
|
<div class="dp-calendar-shell">
|
|
499
6
|
<div class="dp-calendar-header">
|
|
500
|
-
${
|
|
501
|
-
${
|
|
502
|
-
<button type="button" class="dp-nav dp-prev ${
|
|
503
|
-
<button type="button" class="dp-nav dp-next ${
|
|
7
|
+
${R?_:J}
|
|
8
|
+
${R?J:_}
|
|
9
|
+
<button type="button" class="dp-nav dp-prev ${ut}" data-calendar-action="previous" aria-label="${A(this.messages.previousMonth)}"${M?" 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="m4 10 4-4 4 4"/></svg></button>
|
|
10
|
+
<button type="button" class="dp-nav dp-next ${ut}" data-calendar-action="next" aria-label="${A(this.messages.nextMonth)}"${y?" 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="m4 6 4 4 4-4"/></svg></button>
|
|
504
11
|
</div>
|
|
505
|
-
<
|
|
506
|
-
|
|
507
|
-
<
|
|
508
|
-
<tbody>${U}</tbody>
|
|
12
|
+
<table id="${b}" class="dp-grid" role="grid" aria-labelledby="${h}">
|
|
13
|
+
<thead><tr>${C}${L}</tr></thead>
|
|
14
|
+
<tbody>${j}</tbody>
|
|
509
15
|
</table>
|
|
510
|
-
</div>`,this._rendering=!1,this._paintedRange={...this._highlightedRange},this._paintedPreview=this.hasAttribute("data-range-preview"),q)queueMicrotask(()=>{let h=q;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||"",w=h.querySelector(".dp-day-extra");if(!(w instanceof HTMLElement))continue;let p=this._renderDay(m,this._renderedStates.get(m)||{});if(p instanceof Node)w.append(p);else if(p!==void 0&&p!==null)w.textContent=String(p)}if(e)this._loadDisplay(s)}}function ye(e){return e==="top"||e==="bottom"?"x":"y"}var st={top:"bottom",bottom:"top",left:"right",right:"left"},Ot=new Set(Object.keys(st).flatMap((e)=>[e,`${e}-start`,`${e}-end`])),Rt=new Set(["viewport","document"]);function Pt(e){if(!Ot.has(e))throw TypeError(`Unknown placement: ${e}`);let[t,s=null]=e.split("-");return{side:t,align:s,crossAxis:ye(t)}}function zt(e,t,s,i,n,r){let a=ye(s),o=e.x+e.width/2-t.width/2,c=e.y+e.height/2-t.height/2,l=e[a==="x"?"width":"height"]/2-t[a==="x"?"width":"height"]/2,u;switch(s){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:c};break;case"left":u={x:e.x-t.width-r,y:c};break;default:u={x:e.x,y:e.y}}if(i==="start"||i==="end"){let b=(n&&a==="x"?-1:1)*(i==="end"?1:-1);u[a]+=l*b}return u}function Ht(e,t,s,i){return Math.max(s-e,0)+Math.max(e+t-i,0)}function Vt(e){let t=e.ownerDocument?.defaultView;if(t&&e instanceof t.Element)return t.getComputedStyle(e).direction==="rtl";return"dir"in e&&e.dir==="rtl"}var Bt=25;function Nt(e){let t=e.defaultView;if(!t)return null;let s=e.documentElement,i=t.visualViewport,n=i?.offsetLeft||0,r=i?.offsetTop||0,a=i?.width||s.clientWidth||t.innerWidth,o=i?.height||s.clientHeight||t.innerHeight,c=e.compatMode==="BackCompat"?a-s.clientWidth:s.clientWidth-s.getBoundingClientRect().width;if(c>0&&c<=Bt){let l=t.getComputedStyle?.(s).scrollbarGutter;if(l&&l!=="auto")a-=c}return{x:n,y:r,width:a,height:o,right:n+a,bottom:r+o}}function Ut(e,t){return t.scope?t.scope.getBoundingClientRect():Nt(e.ownerDocument)}function Ze(e,t,s,i,n){let r=s+n,a=i-t-n,o=a>=r,c=o?r:s,l=o?a:i-t;return Math.max(c,Math.min(e,l))}function Je(e,t,s){if(!s)return 50;let i=(e-t)/s*100;return Math.round(Math.min(100,Math.max(0,i))*1000)/1000}function jt(e,t){for(let s=0;s<e.length;s++){let i=e[s];if(i.right>=t.x&&i.left<=t.right&&i.bottom>=t.y&&i.top<=t.bottom)return!1}return!0}function Yt(e,t,s,i,n){if(t==="top")return Math.max(0,e.top-s.y-i-n);if(t==="bottom")return Math.max(0,s.bottom-e.bottom-i-n);return Math.max(0,s.height-n*2)}function Gt(e){if(e.hidden)return!1;if(typeof e.checkVisibility==="function")return e.checkVisibility();return e.getClientRects().length>0}function it(e){let{offsetWidth:t,offsetHeight:s}=e;if(t&&s)return{width:t,height:s};let i=e.getBoundingClientRect();return{width:t||i.width,height:s||i.height}}var Qe=new WeakMap,et={scroll:0,resize:1,"element-resize":2};function Wt(e){let t=e.defaultView;if(!t)throw TypeError("floating must belong to a document with a browsing context");let s=new Set,i=new Map,n=t.ResizeObserver,r=!1,a=!1,o=t.visualViewport;function c(y,v){let E=i.get(y);if(E===void 0||et[v]>et[E])i.set(y,v)}function l(){if(r)return;r=!0,t.requestAnimationFrame(()=>{let y=[...i];i.clear(),r=!1;for(let[v,E]of y){if(!s.has(v)||!v.floating.isConnected)continue;try{v.callback({type:E})}catch(C){u(C)}}})}function u(y){if(typeof t.reportError==="function")t.reportError(y);else t.setTimeout(()=>{throw y})}function b(y){for(let v of s)c(v,y);l()}function D(y){if(!n)return null;let v=new Set,E=new n((z)=>{let I=!1;for(let U of z)if(v.has(U.target))I=!0;else v.add(U.target);if(!I)return;c(y,"element-resize"),l()}),{reference:C,floating:k}=y;if(C)E.observe(C);if(k!==C)E.observe(k);return E}let x=()=>b("scroll"),T=()=>b("resize");function S(){if(a)return;e.addEventListener("scroll",x,{passive:!0,capture:!0}),t.addEventListener("resize",T,{passive:!0}),o?.addEventListener("scroll",x,{passive:!0}),o?.addEventListener("resize",T,{passive:!0}),a=!0}function M(){if(!a)return;e.removeEventListener("scroll",x,{capture:!0}),t.removeEventListener("resize",T),o?.removeEventListener("scroll",x),o?.removeEventListener("resize",T),a=!1}return{add(y,v,E){let C={reference:y,floating:v,callback:E};s.add(C),S();let k=D(C),z=!1;return()=>{if(z)return;if(z=!0,s.delete(C),i.delete(C),k?.disconnect(),s.size===0)M()}}}}function Kt(e){let t=e.ownerDocument,s=Qe.get(t);if(!s)s=Wt(t),Qe.set(t,s);return s}function nt(e,t,s){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 s!=="function")throw TypeError("callback must be a function");return Kt(t).add(e,t,s)}function tt(e,t,s){let i=s.placement===void 0?"bottom-start":s.placement,{side:n,align:r,crossAxis:a}=Pt(i),o=s.coordinateSpace===void 0?"viewport":s.coordinateSpace;if(!Rt.has(o))throw TypeError(`Unknown coordinateSpace: ${o}`);if(!Gt(t))return null;let c=s.distance||0,l=s.flip!==!1,u=s.shift!==!1,b=s.shiftPadding??4,D=r?Vt(e):!1,x=e.getClientRects();if(!x.length)return null;let T=(_)=>_==="bottom"?x[x.length-1]:x[0],S=Ut(e,s);if(!S||jt(x,S))return null;let M=it(t),y={x:{size:M.width,start:S.x,end:S.right},y:{size:M.height,start:S.y,end:S.bottom}},v=(_,h)=>zt(T(_),M,_,h,D,c),E=(_,h)=>{let{size:m,start:w,end:p}=y[h];return Ht(_,m,w+b,p-b)},C=(_,h)=>{let{size:m,start:w,end:p}=y[h];return E(u?Ze(_,m,w,p,b):_,h)},k=v(n,r),z=(_,h)=>{let m=ye(_),w=m==="x"?"y":"x",p=E(h[w],w);return{main:p,total:p+C(h[m],m)}};if(l){let _=z(n,k),h=(m)=>{let w=v(m,r),p=z(m,w);if(p.total<_.total)n=m,k=w,_=p};if(_.main>0)h(st[n]);if(a==="y"&&_.main>0)h("top"),h("bottom");a=ye(n)}if(a==="x"&&u&&r){let _=E(k.x,"x");if(_>0){let h=r==="end"?"start":"end",m=v(n,h);if(E(m.x,"x")<_)r=h,k=m}}if(u){let{size:_,start:h,end:m}=y[a];k[a]=Ze(k[a],_,h,m,b)}let I=T(n),U=Je(I.x+I.width/2,k.x,M.width),K=Je(I.y+I.height/2,k.y,M.height),q=`${Yt(I,n,S,c,b)}px`,{style:O}=t,X=O.getPropertyValue("--available-height")!==q,j=o==="document"?e.ownerDocument.defaultView:null,be=j?j.scrollX:0,le=j?j.scrollY:0;O.left=`${k.x+be}px`,O.top=`${k.y+le}px`,O.setProperty("--arrow-x",`${U}%`),O.setProperty("--arrow-y",`${K}%`),O.setProperty("--available-height",q);let Z=r?`${n}-${r}`:n;return t.dataset.placement=Z,{width:M.width,height:M.height,roomChanged:X,placement:Z}}function rt(e,t,s={}){let i=tt(e,t,s);if(!i)return!1;if(i.roomChanged){let n=it(t);if(n.width!==i.width||n.height!==i.height)tt(e,t,{...s,placement:i.placement,flip:!1})}return!0}class de{constructor(e,t={}){this.input=e,this.messages=t.messages||{},this.adapter=ae(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=ae(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 s=document.createElement("input");s.type="hidden",s.value=this.canonical,e.insertAdjacentElement("afterend",s),this.hidden=s}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(),s=this.canonical?this.adapter.format(this.canonical):"";if(this.dirty(),t===s){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(this.messages.invalidDate)}async commit(e={}){let t=this.input,s=++this._commitId,i=t.value.trim();if(!i){if(s!==this._commitId)return{status:"stale"};return t.setCustomValidity(""),{status:"clear",value:""}}let n=this.adapter.parse(i);if(!n){if(s!==this._commitId)return{status:"stale"};if(this.hidden)this.hidden.value="";return t.setCustomValidity(this.messages.invalidDate),{status:"invalid"}}if(this.confirm){let r=await this.confirm(n,e);if(s!==this._commitId)return{status:"stale"};if(!r?.ok){if(this.hidden)this.hidden.value="";return t.setCustomValidity(r?.message||this.messages.unavailableDate),{status:"invalid"}}}return{status:"ok",value:n}}setCanonical(e,t={}){let s=e||"";if(s&&!d(s))throw TypeError(`Invalid date-picker value: ${s}`);if(this.dirty(),this.canonical=s,this._dirty=!1,this.hidden)this.hidden.value=s;if(t.format!==!1)this.input.value=s?this.adapter.format(s):"";this.input.setCustomValidity("")}restoreDefault(){let e=String(this.input.defaultValue??"").trim(),t=d(e)?e:this.adapter.parse(e);return t&&d(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 qt=/^(\d{2}):(\d{2})(?::(\d{2})(?:\.(\d{1,3}))?)?$/;function Me(e){let t=qt.exec(String(e||""));if(!t)return null;let s=Number(t[1]),i=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(s>23||i>59||n>59||r>999)return null;return{hour:s,minute:i,second:n,millisecond:r}}function $e(e){return Me(e)!==null}function at(e){return((e.hour*60+e.minute)*60+e.second)*1000+e.millisecond}function ot(e,t){let s=Me(e),i=Me(t);if(!s||!i)throw TypeError("compareTimes() expects HH:MM values");let n=at(s)-at(i);return n===0?0:n<0?-1:1}var Xt=0,dt=4;class Fe extends HTMLElement{static observedAttributes=["value","locale","min","max","open-on-focus","month-format"];static setDefaultControlClasses(e){he(e)}static getDefaultControlClasses(){return se()}static setDefaultMessages(e){me(e)}static getDefaultMessages(){return B()}constructor(){super();this._id=`date-picker-${++Xt}`,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._previewDate="",this._drag=null,this._suppressGridClick=!1,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=null,this._controlClasses=null,this._stopDefaultMessages=null,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(W(this,["locale","min","max","monthFormat","openOnFocus","coordinateSpace","controlClasses","messages","source","dateState","renderDay","isDateDisabled"]),this.hasAttribute("range"))this._connectRange();else this._connectSingle();if(this._connected)W(this,["value","range"]),this._stopDefaultMessages=ge(()=>{if(this._messages===null)this._refreshMessages()})}_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 de(e,{messages:this.messages,locale:this.locale}),this._field.onAttributesChanged=()=>this._syncInputState(),this._field.confirm=(i,n)=>this._confirmDate(i,n),this._setupFormValue(),this._build(),this._syncInputState(),this._bind(),this._syncCalendarOptions();let t=this._adapter(),s=this.getAttribute("value")||(d(e.value)?e.value:t.parse(e.value));if(s&&d(s))this._setValue(s,{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,s]of e.entries()){let i=this.querySelectorAll(`:scope > input[${s}]`);if(i.length>1)console.warn(`<date-picker> expects at most one direct child input[${s}]; ignoring extras`);let n=i[0];if(n==null)continue;if(!(n instanceof HTMLInputElement)||n.type!=="time"){console.warn(`<date-picker> input[${s}] 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 de(e,{messages:this.messages,locale:this.locale}),new de(t,{messages:this.messages,locale:this.locale})],this._range=new Ce,this._rangeOriginalDescribedBy=[e.getAttribute("aria-describedby")||"",t.getAttribute("aria-describedby")||""];for(let r of this._fields)r.onAttributesChanged=()=>this._syncRangeFields(),r.confirm=(a,o)=>this._confirmDate(a,o),r.setupFormValue();this._build(),this._setRangeAria(),this._syncRangeFields(),this._bindRange(),this._syncCalendarOptions();let s=this._adapter(),i=d(e.value)?e.value:s.parse(e.value),n=d(t.value)?t.value:s.parse(t.value);if(this._setRange(i||"",n||"",{emit:!1}),e.value.trim()&&!d(i))e.setCustomValidity(this.messages.invalidDate);if(t.value.trim()&&!d(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._stopDefaultMessages?.(),this._stopDefaultMessages=null,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,s=this._fields?.includes(e)?this._rangeOriginalDescribedBy[this._fields?.indexOf(e)??0]||"":this._originalDescribedBy;if(e.teardown(),s)t.setAttribute("aria-describedby",s);else t.removeAttribute("aria-describedby");t.removeAttribute("role"),t.removeAttribute("aria-haspopup"),t.removeAttribute("aria-expanded"),t.removeAttribute("aria-controls")}attributeChangedCallback(e,t,s){if(!this._connected||this._reflecting||t===s)return;if(e==="value"){if(this._rangeMode())return;if(!s||d(s))this._setValue(s||"",{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&&!d(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:s}=fe(e);this._setRange(t,s)}get locale(){return P(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 d(e)?e:""}set min(e){if(e)this.setAttribute("min",e);else this.removeAttribute("min")}get max(){let e=this.getAttribute("max")||"";return d(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 controlClasses(){return ne(this._controlClasses)}set controlClasses(e){if(this._controlClasses=ie(e),this._calendar)this._calendar.controlClasses=this._controlClasses}get messages(){return this._messages??B()}set messages(e){if(this._messages=e==null?null:{...B(),...e},this._calendar)this._calendar.messages=this._messages;this._refreshMessages()}_refreshMessages(){let e=this.messages;for(let s of this._fields||[])s.setMessages(e);this._field?.setMessages(e),this._panel?.setAttribute("aria-label",e.calendar);let t=this._field??this._fields?.[0];if(this._formatHint&&t)this._formatHint.textContent=`${e.formatHint}: ${t.placeholder}`;if(this._refreshButtonLabel(),this._connected)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??ae(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:s}of this._buttons){let i=s==="end"?1:0,n=this._fields[i];t.disabled=Boolean(n?.input.disabled||n?.input.readOnly)}this._syncDragAffordance();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,s=[this._rangeOriginalDescribedBy[this._fields.indexOf(e)],this._formatHint.id].filter(Boolean).join(" ");t.setAttribute("aria-describedby",s),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,c]of(this._fields||[]).entries())t.push([c.input,o===1?"end":"start"]);else if(this._input)t.push([this._input,""]);if(!t.length)return;let s=`${this._id}-panel`,i=`${this._id}-format`;this._buttons=t.map(([o,c])=>{let l=this._createTrigger(c);return o.insertAdjacentElement("afterend",l),{button:l,endpoint:c}});let n=document.createElement("div");n.id=s,n.className="dp-picker-panel",n.setAttribute("popover","manual"),n.setAttribute("role","dialog"),n.setAttribute("aria-label",this.messages.calendar);let r=new oe;r.selection="none",r.fixedWeeks=!0,n.append(r);let a=document.createElement("span");if(a.id=i,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,i].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",s)}this._refreshLocale(),this._refreshButtonLabel()}_bindPopup(e,t,s){this.ownerDocument.addEventListener("pointerdown",(i)=>{if(!this._open||i.composedPath().includes(this))return;this.hide(!1)},{capture:!0,signal:e}),this.ownerDocument.addEventListener("reset",(i)=>{if(!(i.target instanceof HTMLFormElement)||!t||i.target!==t.form)return;this.hide(!1),queueMicrotask(()=>{if(!i.defaultPrevented)s()})},{capture:!0,signal:e}),this.addEventListener("keydown",(i)=>this._onEscape(i),{signal:e})}_bind(){let e=this._input,t=this._buttons[0]?.button,s=this._calendar;if(!e||!t||!s)return;let i=new AbortController;this._controller=i;let{signal:n}=i;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}),s.addEventListener("dateactivate",(r)=>{let a=r,o=a.detail?.date;if(!d(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}),s.addEventListener("dateloadend",()=>void this.validate(),{signal:n}),this._bindPopup(n,this._input,()=>this._restoreDefault())}_bindRange(){let e=this._calendar;if(!this._fields||!this._buttons.length||!e)return;let t=new AbortController;this._controller=t;let{signal:s}=t;for(let[i,n]of this._fields.entries()){let r=i===1?"end":"start";n.input.addEventListener("input",()=>n.handleInput(),{signal:s}),n.input.addEventListener("change",()=>void this._commitFieldText(r),{signal:s}),n.input.addEventListener("blur",()=>void this._commitFieldText(r),{signal:s}),n.input.addEventListener("focus",(a)=>this._onFieldFocus(r,a),{signal:s}),n.input.addEventListener("keydown",(a)=>this._onFieldKeyDown(r,a),{signal:s})}for(let i of this._buttons){let n=i.endpoint;if(n==="")continue;i.button.addEventListener("click",(r)=>this._onRangeTriggerClick(n,r),{signal:s}),i.button.addEventListener("keydown",(r)=>this._onTriggerKeyDown(n,r),{signal:s})}e.addEventListener("click",(i)=>{if(this._suppressGridClick){this._suppressGridClick=!1,i.preventDefault(),i.stopImmediatePropagation();return}this._captureGridIntent(i)},{capture:!0,signal:s}),e.addEventListener("keydown",(i)=>this._captureGridIntent(i),{capture:!0,signal:s}),e.addEventListener("dateactivate",(i)=>{let n=i,r=n.detail?.date;if(!d(r))return;queueMicrotask(()=>{if(n.defaultPrevented||!this._connected||!this._range)return;let a=this._pendingIntents.get(r);if(a===void 0||a.id!==this._rangeCommitId)return;this._pendingIntents.delete(r);let o=(l)=>this._boundEditable(l),c=a.endpoint?this._range.moveEndpoint(r,a.endpoint,o):this._range.activate(r,o);if(c.status==="refused"){this._calendar?.dispatchEvent(new CustomEvent("dateinvalid",{detail:{date:r,state:this._calendar.getDateState(r)},bubbles:!0}));return}if(this._applyRangeTransition(c),a.endpoint)return;if(c.close||c.status==="complete")this.hide(!1),this._focusField(c.endpoint)})},{signal:s}),e.addEventListener("datefocus",(i)=>this._onGridDateFocus(i),{signal:s}),e.addEventListener("pointerover",(i)=>this._onGridPointerOver(i),{signal:s}),e.addEventListener("pointerleave",()=>this._onGridPointerLeave(),{signal:s}),e.addEventListener("pointerdown",(i)=>this._onGridPointerDown(i),{signal:s}),e.addEventListener("pointermove",(i)=>this._onGridPointerMove(i),{signal:s}),e.addEventListener("pointerup",(i)=>this._onGridPointerUp(i),{signal:s}),e.addEventListener("pointercancel",(i)=>this._onGridPointerCancel(i),{signal:s}),e.addEventListener("lostpointercapture",(i)=>this._onGridPointerCancel(i),{signal:s}),e.addEventListener("dateloadend",()=>void this.validate(),{signal:s}),this._bindPopup(s,this._fields?.[0]?.input,()=>this._restoreRangeDefault())}_activateRangeEndpoint(e){let t=this._calendar;if(!this._range||!t)return;this._range.focus(e),this._rangeCommitId++,this._pendingIntents.clear(),this._lastFocusEndpoint=e;let s=this._boundCanonical(e)||R();t.display=f(s),t.focusedDate=s,this._clearPreview()}_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 s=e!==this._range?.activeEndpoint;if(this._lastFocusEndpoint=e,this._range?.focus(e),s)this._rangeCommitId++,this._pendingIntents.clear();if(!this.openOnFocus||this._suppressFocusOpen)return;let i=t.relatedTarget;if(i instanceof Node&&this.contains(i))return;if(!this._open)this.show({moveFocus:!1})}_captureGridIntent(e){if(!this._rangeMode()||!this._range)return;if(e.type==="keydown"){let i=e.key;if(i!=="Enter"&&i!==" ")return}if(!(e.target instanceof Element))return;let s=e.target.closest(".dp-day[data-date]")?.getAttribute("data-date")||"";if(!d(s))return;this._pendingIntents.clear(),this._pendingIntents.set(s,{id:++this._rangeCommitId,endpoint:""})}_boundEditable(e){let t=this._fields?.[e==="end"?1:0];return t!=null&&!t.input.disabled&&!t.input.readOnly}_applyRangeTransition(e){let t=this._fields;if(!t||!this._range||e.status==="refused")return;let s=[];for(let i of e.changedEndpoints){let n=t[i==="end"?1:0],r=i==="end"?e.range.end:e.range.start;if(!n||n.canonical===r)continue;n.setCanonical(r,{format:!0}),s.push(n)}if(this._syncHighlight(),this._refreshRangeButtonLabel(),this._revalidateRange(e.endpoint),!s.length)return;this._emitRangeChange();for(let i of s)i.input.dispatchEvent(new Event("input",{bubbles:!0})),i.input.dispatchEvent(new Event("change",{bubbles:!0}))}_setPreview(e,t=""){let s=this._calendar;if(!s||!this._range||!this._open)return;let i=d(e)&&!s.getDateState(e).disabled?e:"",n=i?this._range.previewRange(i,t,(r)=>this._boundEditable(r)):null;if(!n){this._clearPreview();return}this._previewDate=i,s.toggleAttribute("data-range-preview",!0),s.highlightedRange=n}_clearPreview(){if(!this._previewDate)return;this._syncHighlight()}_onGridDateFocus(e){if(this._drag)return;let t=e.detail?.date;if(d(t))this._setPreview(t)}_onGridPointerOver(e){let t=e;if(this._drag||t.pointerType==="touch")return;this._setPreview(this._cellDate(t.target))}_onGridPointerLeave(){if(this._drag?.active===!1)this._drag=null;if(this._drag)return;this._clearPreview()}_cellDate(e){let s=(e instanceof Element?e.closest(".dp-day[data-date]"):null)?.getAttribute("data-date")||"";return d(s)?s:""}_dateAtPoint(e,t){let s=this.ownerDocument.elementFromPoint(e,t);if(!(s instanceof Element)||!this._calendar?.contains(s))return"";return this._cellDate(s)}_onGridPointerDown(e){let t=e;if(this._suppressGridClick=!1,this._drag?.active===!1)this._drag=null;if(!this._open||!this._range||this._drag)return;if(!t.isPrimary||t.button!==0)return;if(t.pointerType!=="mouse"&&t.pointerType!=="pen")return;if(!this._range.complete)return;let s=t.target instanceof Element?t.target.closest(".dp-day[data-date]"):null;if(!(s instanceof HTMLElement))return;let i=s.hasAttribute("data-range-start"),n=s.hasAttribute("data-range-end");if(i===n)return;let r=i?"start":"end",a=this._cellDate(s);if(!a||!this._boundEditable(r))return;this._drag={pointerId:t.pointerId,endpoint:r,x:t.clientX,y:t.clientY,date:a,active:!1}}_onGridPointerMove(e){let t=e,s=this._drag;if(!s||t.pointerId!==s.pointerId)return;if(!s.active){if(!(Math.abs(t.clientX-s.x)>dt||Math.abs(t.clientY-s.y)>dt))return;s.active=!0;try{this._calendar?.setPointerCapture(s.pointerId)}catch{}this._syncDragAffordance()}let i=this._dateAtPoint(t.clientX,t.clientY);if(!i||this._calendar?.getDateState(i).disabled)return;s.date=i,this._setPreview(i,s.endpoint)}_onGridPointerUp(e){let t=e,s=this._drag;if(!s||t.pointerId!==s.pointerId)return;if(this._drag=null,this._releaseDragCapture(s.pointerId),!s.active){this._syncDragAffordance();return}this._suppressGridClick=!0;let i=this._range?.projectEndpoint(s.date,s.endpoint,(r)=>this._boundEditable(r));if(!i||i.status==="refused"||!i.changedEndpoints.length){this._syncHighlight();return}let n=s.endpoint==="start"?i.range.start:i.range.end;this._pendingIntents.clear(),this._pendingIntents.set(n,{id:++this._rangeCommitId,endpoint:s.endpoint}),this._calendar?.activateDate(n)}_onGridPointerCancel(e){let t=e,s=this._drag;if(!s||t.pointerId!==s.pointerId)return;this._drag=null,this._releaseDragCapture(s.pointerId),this._syncHighlight()}_releaseDragCapture(e){let t=this._calendar;if(t?.hasPointerCapture(e))t.releasePointerCapture(e)}_syncDragAffordance(){let e=this._calendar;if(!e||!this._range)return;if(this._drag?.active){e.setAttribute("data-range-drag","active");return}let{start:t,end:s}=this._range;if(this._range.complete&&t!==s&&(this._boundEditable("start")||this._boundEditable("end")))e.setAttribute("data-range-drag","ready");else e.removeAttribute("data-range-drag")}_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.controlClasses=this._controlClasses,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[s,i]of this._fields.entries()){if(!i.input.hasAttribute("placeholder")||this._generatedPlaceholder)i.input.placeholder=i.placeholder,this._generatedPlaceholder=!0;let n=s===1?this._range?.end||"":this._range?.start||"";if(n)i.input.value=i.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,s=this._value?`, ${re(this._value,this.locale)}`:"";e.setAttribute("aria-label",`${t}${s}`)}_refreshRangeButtonLabel(){if(!this._range)return;let{start:e,end:t}=this._range;for(let{button:s,endpoint:i}of this._buttons){let n=i==="end"?t:e,r=n?this.messages.changeDate:this.messages.chooseDate,a=n?`, ${re(n,this.locale)}`:"",o=i==="end"?this.messages.rangeEnd:this.messages.rangeStart;s.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&&!d(e))throw TypeError(`Invalid date-picker value: ${e}`);let s=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&&t.moveDisplay!==!1)this._calendar.focusedDate=this._value}if(this._refreshButtonLabel(),s!==this._value){if(this.dispatchEvent(new CustomEvent("valuechange",{detail:{value:this._value},bubbles:!0})),t.emit&&this._field){let i=this._field.input;i.dispatchEvent(new Event("input",{bubbles:!0})),i.dispatchEvent(new Event("change",{bubbles:!0}))}}}async _confirmDate(e,t={}){let s=this._calendar;if(!s)return{ok:!0};if(t.moveDisplay!==!1){let r=f(e);if(s.display!==r)s.display=r}let i=await s.ensureDate(e),n=s.getDateState(e);if(!i||n.disabled)return{ok:!1,message:this.messages.unavailableDate};return{ok:!0}}async _commitText(e,t={}){let s=this._field;if(!s)return!1;if(!t.force&&!s.isDirty)return!1;let i=await s.commit(t);if(i.status==="stale"||i.status==="invalid")return!1;return this._setValue(i.value||"",{emit:e,format:i.status==="ok",moveDisplay:t.moveDisplay}),!0}async _commitFieldText(e){let t=this._fields;if(!t)return!1;let s=e==="end"?1:0,i=t[s];if(!i?.isDirty)return!1;let n=await i.commit();if(n.status==="stale")return!1;if(n.status==="invalid")return this._orderTags.delete(s),!1;return this._setBound(e,n.value||"",{emit:!1,user:!0,format:n.status==="ok"}),!0}_setBound(e,t,s={}){if(!this._range)return!1;let i=this._fields;if(!i)return!1;let r=i[e==="end"?1:0];if(!r)return!1;if(s.user===!0&&(r.input.disabled||r.input.readOnly))return!1;let a=t||"",o=r.canonical;if(r.setCanonical(a,{format:s.format!==!1}),e==="end")this._range.end=a;else this._range.start=a;let c=o!==a;if(c){if(this._syncHighlight(),this._refreshRangeButtonLabel(),this._emitRangeChange(),s.emit)r.input.dispatchEvent(new Event("input",{bubbles:!0})),r.input.dispatchEvent(new Event("change",{bubbles:!0}))}return this._revalidateRange(e),c}_setRange(e,t,s={}){if(!this._range||!this._fields)return;if(this._range.start=e||"",this._range.end=t||"",this._fields[0].setCanonical(e||"",{format:s.format!==!1}),this._fields[1].setCanonical(t||"",{format:s.format!==!1}),this._syncHighlight(),this._refreshRangeButtonLabel(),this._revalidateRange("start"),this._revalidateRange("end"),s.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}))}_displayRange(){let{start:e,end:t}=this._range?.range??{start:"",end:""};if(!e)return{start:"",end:""};if(t&&g(t,e)<0)return{start:e,end:""};return{start:e,end:t}}_syncHighlight(){if(!this._calendar||!this._range)return;this._previewDate="",this._calendar.removeAttribute("data-range-preview"),this._calendar.highlightedRange=this._displayRange(),this._syncDragAffordance()}_revalidateRange(e){if(!this._fields||!this._range)return;let{start:t,end:s}=this._range,i=Boolean(t&&s&&g(s,t)<0),n=["start","end"];for(let r of n){let a=r==="end"?1:0,o=this._fields[a].input,c=r==="end"?this.messages.rangeOrderEnd:this.messages.rangeOrderStart;if(i&&r===e)o.setCustomValidity(c),this._orderTags.add(a);else if(this._orderTags.has(a))o.setCustomValidity(""),this._orderTags.delete(a)}}_revalidateTimeOrder(e){let[t,s]=this._timeFields,i=["start","end"],n=[t,s],r=t&&!t.disabled?t.value.trim():"",a=s&&!s.disabled?s.value.trim():"",o=Boolean(t&&s&&r&&a)&&$e(r)&&$e(a)&&ot(a,r)<0;for(let[c,l]of i.entries()){let u=n[c];if(!u)continue;let b=l==="end"?this.messages.rangeOrderEnd:this.messages.rangeOrderStart;if(o&&l===e)u.setCustomValidity(b),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(R()),this._calendar.focusedDate=R();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 s=this._range?.start||R();this._calendar.display=f(s),this._calendar.focusedDate=s}this.validate()}_focusField(e){let t=e==="end"?1:0,s=this._fields?.[t]?.input;if(!s)return;this._suppressFocusOpen=!0,setTimeout(()=>{s.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 s=e==="end"?"start":"end",i=s==="end"?1:0;if(!this._fields[i].input.disabled&&!this._fields[i].input.readOnly)return s;return""}async validate(){if(this._rangeMode()){let s=this._fields;if(!s)return!0;for(let[i,n]of s.entries()){let r=await n.commit({moveDisplay:!1});if(r.status==="ok"||r.status==="clear"){let a=i===1?"end":"start";this._setBound(a,r.value||"",{format:r.status==="ok"})}}return this._revalidateRange("start"),this._revalidateRange("end"),s.every((i)=>i.input.checkValidity())}let e=this._field?.input;if(!e)return!0;if(!e.value.trim())e.setCustomValidity("");else await this._commitText(!1,{force:!0,moveDisplay:!1});this._revalidateTimeOrder("start"),this._revalidateTimeOrder("end");let t=this._timeFields.every((s)=>s?.checkValidity()??!0);return e.checkValidity()&&t}show(e={}){let t=this._panel,s=this._calendar;if(!t||!s||!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)||R();s.display=f(a),s.focusedDate=a,this._returnFocus=e.returnFocus instanceof HTMLElement?e.returnFocus:r}t.showPopover(),this._open=!0,this._setExpanded(!0);let i=this.coordinateSpace;t.style.position=i==="document"?"absolute":"fixed";let n=()=>rt(this,t,{placement:"bottom-start",distance:4,shiftPadding:8,coordinateSpace:i});if(n(),this._stopTracking=nt(this,t,n),e.moveFocus!==!1)queueMicrotask(()=>s.focusGrid());this.dispatchEvent(new Event("open",{bubbles:!0}))}_setExpanded(e){let t=e?"true":"false";this._input?.setAttribute("aria-expanded",t);for(let{button:s}of this._buttons)s.setAttribute("aria-expanded",t);for(let s of this._fields||[])s.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(),this._suppressGridClick=!1,this._drag)this._releaseDragCapture(this._drag.pointerId),this._drag=null;if(this._syncHighlight(),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,s=this._fields?.[t];if(s&&!s.input.disabled&&!s.input.readOnly)return e}return this._resolveRangeEndpoint()}}function Le(){if(!customElements.get("date-calendar"))customElements.define("date-calendar",oe);if(!customElements.get("date-picker"))customElements.define("date-picker",Fe)}Le();var lt="lekoala-date-picker-styles";if(!document.getElementById(lt)){let e=document.createElement("style");e.id=lt,e.textContent=Oe,document.head.append(e)}Le();})();
|
|
16
|
+
</div>`,this._heading.textContent=qt(`${s}-15`,e),this._rendering=!1,this._paintedRange={...this._highlightedRange},this._paintedPreview=this.hasAttribute("data-range-preview"),X)this._queueFocus(()=>{let u=X;if(u.startsWith(".dp-day[data-date="))u=`.dp-day[data-date="${CSS.escape(this._model.focused)}"]`;let f=this.querySelector(u);if(f instanceof HTMLElement)f.focus()});if(this._renderDay)for(let u of this.querySelectorAll(".dp-day[data-date]")){if(!(u instanceof HTMLTableCellElement))continue;let f=u.dataset.date||"",w=u.querySelector(".dp-day-extra");if(!(w instanceof HTMLElement))continue;let m=this._renderDay(f,this._renderedStates.get(f)||{});if(m instanceof Node)w.append(m);else if(m!==void 0&&m!==null)w.textContent=String(m)}if(t)this._loadDisplay(s)}}function vt(t){return t==="top"||t==="bottom"?"x":"y"}var ne={top:"bottom",bottom:"top",left:"right",right:"left"},Oe=new Set(Object.keys(ne).flatMap((t)=>[t,`${t}-start`,`${t}-end`])),Pe=new Set(["viewport","document"]);function ze(t){if(!Oe.has(t))throw TypeError(`Unknown placement: ${t}`);let[e,s=null]=t.split("-");return{side:e,align:s,crossAxis:vt(e)}}function He(t,e,s,i,n,r){let a=vt(s),o=t.x+t.width/2-e.width/2,d=t.y+t.height/2-e.height/2,l=t[a==="x"?"width":"height"]/2-e[a==="x"?"width":"height"]/2,h;switch(s){case"top":h={x:o,y:t.y-e.height-r};break;case"bottom":h={x:o,y:t.y+t.height+r};break;case"right":h={x:t.x+t.width+r,y:d};break;case"left":h={x:t.x-e.width-r,y:d};break;default:h={x:t.x,y:t.y}}if(i==="start"||i==="end"){let b=(n&&a==="x"?-1:1)*(i==="end"?1:-1);h[a]+=l*b}return h}function Be(t,e,s,i){return Math.max(s-t,0)+Math.max(t+e-i,0)}function Ne(t){let e=t.ownerDocument?.defaultView;if(e&&t instanceof e.Element)return e.getComputedStyle(t).direction==="rtl";return"dir"in t&&t.dir==="rtl"}var Ve=25;function Ue(t){let e=t.defaultView;if(!e)return null;let s=t.documentElement,i=e.visualViewport,n=i?.offsetLeft||0,r=i?.offsetTop||0,a=i?.width||s.clientWidth||e.innerWidth,o=i?.height||s.clientHeight||e.innerHeight,d=t.compatMode==="BackCompat"?a-s.clientWidth:s.clientWidth-s.getBoundingClientRect().width;if(d>0&&d<=Ve){let l=e.getComputedStyle?.(s).scrollbarGutter;if(l&&l!=="auto")a-=d}return{x:n,y:r,width:a,height:o,right:n+a,bottom:r+o}}function je(t,e){return e.scope?e.scope.getBoundingClientRect():Ue(t.ownerDocument)}function Qt(t,e,s,i,n){let r=s+n,a=i-e-n,o=a>=r,d=o?r:s,l=o?a:i-e;return Math.max(d,Math.min(t,l))}function te(t,e,s){if(!s)return 50;let i=(t-e)/s*100;return Math.round(Math.min(100,Math.max(0,i))*1000)/1000}function Ge(t,e){for(let s=0;s<t.length;s++){let i=t[s];if(i.right>=e.x&&i.left<=e.right&&i.bottom>=e.y&&i.top<=e.bottom)return!1}return!0}function Ye(t,e,s,i,n){if(e==="top")return Math.max(0,t.top-s.y-i-n);if(e==="bottom")return Math.max(0,s.bottom-t.bottom-i-n);return Math.max(0,s.height-n*2)}function We(t){if(t.hidden)return!1;if(typeof t.checkVisibility==="function")return t.checkVisibility();return t.getClientRects().length>0}function re(t){let{offsetWidth:e,offsetHeight:s}=t;if(e&&s)return{width:e,height:s};let i=t.getBoundingClientRect();return{width:e||i.width,height:s||i.height}}var ee=new WeakMap,se={scroll:0,resize:1,"element-resize":2};function qe(t){let e=t.defaultView;if(!e)throw TypeError("floating must belong to a document with a browsing context");let s=new Set,i=new Map,n=e.ResizeObserver,r=!1,a=!1,o=e.visualViewport;function d(y,v){let E=i.get(y);if(E===void 0||se[v]>se[E])i.set(y,v)}function l(){if(r)return;r=!0,e.requestAnimationFrame(()=>{let y=[...i];i.clear(),r=!1;for(let[v,E]of y){if(!s.has(v)||!v.floating.isConnected)continue;try{v.callback({type:E})}catch(k){h(k)}}})}function h(y){if(typeof e.reportError==="function")e.reportError(y);else e.setTimeout(()=>{throw y})}function b(y){for(let v of s)d(v,y);l()}function D(y){if(!n)return null;let v=new Set,E=new n((H)=>{let L=!1;for(let j of H)if(v.has(j.target))L=!0;else v.add(j.target);if(!L)return;d(y,"element-resize"),l()}),{reference:k,floating:C}=y;if(k)E.observe(k);if(C!==k)E.observe(C);return E}let x=()=>b("scroll"),S=()=>b("resize");function T(){if(a)return;t.addEventListener("scroll",x,{passive:!0,capture:!0}),e.addEventListener("resize",S,{passive:!0}),o?.addEventListener("scroll",x,{passive:!0}),o?.addEventListener("resize",S,{passive:!0}),a=!0}function M(){if(!a)return;t.removeEventListener("scroll",x,{capture:!0}),e.removeEventListener("resize",S),o?.removeEventListener("scroll",x),o?.removeEventListener("resize",S),a=!1}return{add(y,v,E){let k={reference:y,floating:v,callback:E};s.add(k),T();let C=D(k),H=!1;return()=>{if(H)return;if(H=!0,s.delete(k),i.delete(k),C?.disconnect(),s.size===0)M()}}}}function Ke(t){let e=t.ownerDocument,s=ee.get(e);if(!s)s=qe(e),ee.set(e,s);return s}function ae(t,e,s){if(!e?.ownerDocument)throw TypeError("autoUpdate() expects a floating HTMLElement");if(t&&t.ownerDocument!==e.ownerDocument)throw TypeError("reference and floating must belong to the same document");if(typeof s!=="function")throw TypeError("callback must be a function");return Ke(e).add(t,e,s)}function ie(t,e,s){let i=s.placement===void 0?"bottom-start":s.placement,{side:n,align:r,crossAxis:a}=ze(i),o=s.coordinateSpace===void 0?"viewport":s.coordinateSpace;if(!Pe.has(o))throw TypeError(`Unknown coordinateSpace: ${o}`);if(!We(e))return null;let d=s.distance||0,l=s.flip!==!1,h=s.shift!==!1,b=s.shiftPadding??4,D=r?Ne(t):!1,x=t.getClientRects();if(!x.length)return null;let S=(_)=>_==="bottom"?x[x.length-1]:x[0],T=je(t,s);if(!T||Ge(x,T))return null;let M=re(e),y={x:{size:M.width,start:T.x,end:T.right},y:{size:M.height,start:T.y,end:T.bottom}},v=(_,u)=>He(S(_),M,_,u,D,d),E=(_,u)=>{let{size:f,start:w,end:m}=y[u];return Be(_,f,w+b,m-b)},k=(_,u)=>{let{size:f,start:w,end:m}=y[u];return E(h?Qt(_,f,w,m,b):_,u)},C=v(n,r),H=(_,u)=>{let f=vt(_),w=f==="x"?"y":"x",m=E(u[w],w);return{main:m,total:m+k(u[f],f)}};if(l){let _=H(n,C),u=(f)=>{let w=v(f,r),m=H(f,w);if(m.total<_.total)n=f,C=w,_=m};if(_.main>0)u(ne[n]);if(a==="y"&&_.main>0)u("top"),u("bottom");a=vt(n)}if(a==="x"&&h&&r){let _=E(C.x,"x");if(_>0){let u=r==="end"?"start":"end",f=v(n,u);if(E(f.x,"x")<_)r=u,C=f}}if(h){let{size:_,start:u,end:f}=y[a];C[a]=Qt(C[a],_,u,f,b)}let L=S(n),j=te(L.x+L.width/2,C.x,M.width),K=te(L.y+L.height/2,C.y,M.height),X=`${Ye(L,n,T,d,b)}px`,{style:R}=e,Z=R.getPropertyValue("--available-height")!==X,G=o==="document"?t.ownerDocument.defaultView:null,wt=G?G.scrollX:0,ut=G?G.scrollY:0;R.left=`${C.x+wt}px`,R.top=`${C.y+ut}px`,R.setProperty("--arrow-x",`${j}%`),R.setProperty("--arrow-y",`${K}%`),R.setProperty("--available-height",X);let J=r?`${n}-${r}`:n;return e.dataset.placement=J,{width:M.width,height:M.height,roomChanged:Z,placement:J}}function oe(t,e,s={}){let i=ie(t,e,s);if(!i)return!1;if(i.roomChanged){let n=re(e);if(n.width!==i.width||n.height!==i.height)ie(t,e,{...s,placement:i.placement,flip:!1})}return!0}function z(t){return!t.matches(":disabled")&&!t.readOnly}class ct{constructor(t,e={}){this.input=t,this.messages=e.messages||{},this.adapter=dt(e.locale||""),this.hidden=null,this.canonical="",this._dirty=!1,this._commitId=0,this._disposed=!1,this._originalName=t.getAttribute("name")||"",this._attributeObserver=null,this.onAttributesChanged=null,this.confirm=null,this._generatedDefault=null}setLocale(t){let e=this._generatedDefault,s=e?this.adapter.format(e):null;if(this.adapter=dt(t||""),e&&this.input.defaultValue===s)this.input.defaultValue=this.adapter.format(e)}adoptDefault(){let t=this.input;if(t.getAttribute("value")!=null||t.defaultValue!=="")return;t.defaultValue=t.value,this._generatedDefault=this.canonical&&t.value?this.canonical:null}setMessages(t){this.messages=t||{}}format(t){return this.adapter.format(t)}parse(t){return this.adapter.parse(t)}get placeholder(){return this.adapter.placeholder}get isDisabled(){return this.input.matches(":disabled")}get isReadOnly(){return this.input.readOnly}setupFormValue(){let t=this.input;this._originalName=t.getAttribute("name")||"",this._attributeObserver=new MutationObserver(()=>this.onAttributesChanged?.()),this._attributeObserver.observe(t,{attributes:!0,attributeFilter:["disabled","readonly","name","form"]}),this.syncInputState()}syncInputState(){let t=this.input,e=t.getAttribute("name")||"";if(e){if(!this.hidden){let s=document.createElement("input");s.type="hidden",s.value=this.canonical,t.insertAdjacentElement("afterend",s),this.hidden=s}if(this.hidden)this.hidden.name=e;t.removeAttribute("name")}if(this.hidden){if(t.hasAttribute("form"))this.hidden.setAttribute("form",t.getAttribute("form")||"");else this.hidden.removeAttribute("form");this.hidden.disabled=t.disabled}}dirty(){this._commitId++}get isDirty(){return this._dirty}handleInput(){let t=this.input,e=t.value.trim(),s=this.canonical?this.adapter.format(this.canonical):"";if(this.dirty(),e===s){if(this._dirty=!1,this.hidden)this.hidden.value=this.canonical;t.setCustomValidity("");return}if(this._dirty=!0,this.hidden)this.hidden.value="";if(!e){t.setCustomValidity("");return}t.setCustomValidity(this.messages.invalidDate)}async commit(t={}){let e=this.input,s=++this._commitId;if(this._disposed)return{status:"stale",commitId:s};let i=e.value.trim();if(!i){if(s!==this._commitId)return{status:"stale",commitId:s};return e.setCustomValidity(""),{status:"clear",value:"",commitId:s}}let n=this.adapter.parse(i);if(!n){if(s!==this._commitId)return{status:"stale",commitId:s};if(this.hidden)this.hidden.value="";return e.setCustomValidity(this.messages.invalidDate),{status:"invalid",commitId:s}}if(this.confirm){let r=await this.confirm(n,t);if(this._disposed||s!==this._commitId)return{status:"stale",commitId:s};if(!r?.ok){if(this.hidden)this.hidden.value="";return e.setCustomValidity(r?.message||this.messages.unavailableDate),{status:"invalid",commitId:s}}}return{status:"ok",value:n,commitId:s}}isCommitCurrent(t){return t===this._commitId}setCanonical(t,e={}){let s=t||"";if(s&&!c(s))throw TypeError(`Invalid date-picker value: ${s}`);if(this.dirty(),this.canonical=s,this._dirty=!1,this.hidden)this.hidden.value=s;if(e.format!==!1)this.input.value=s?this.adapter.format(s):"";this.input.setCustomValidity("")}restoreDefault(){let t=String(this.input.defaultValue??"").trim(),e=c(t)?t:this.adapter.parse(t);return e&&c(e)?e:""}teardown(){this.dirty(),this._disposed=!0,this._attributeObserver?.disconnect(),this._attributeObserver=null;let t=this.hidden?.getAttribute("name")||this._originalName;if(t)this.input.setAttribute("name",t);this.hidden?.remove(),this.hidden=null}}var Xe=/^(\d{2}):(\d{2})(?::(\d{2})(?:\.(\d{1,3}))?)?$/;function $t(t){let e=Xe.exec(String(t||""));if(!e)return null;let s=Number(e[1]),i=Number(e[2]),n=e[3]===void 0?0:Number(e[3]),r=e[4]===void 0?0:Number(e[4].padEnd(3,"0"));if(s>23||i>59||n>59||r>999)return null;return{hour:s,minute:i,second:n,millisecond:r}}function Ft(t){return $t(t)!==null}function de(t){return((t.hour*60+t.minute)*60+t.second)*1000+t.millisecond}function le(t,e){let s=$t(t),i=$t(e);if(!s||!i)throw TypeError("compareTimes() expects HH:MM values");let n=de(s)-de(i);return n===0?0:n<0?-1:1}var Ze=0,ce=4;class Lt extends HTMLElement{static observedAttributes=["value","locale","min","max","open-on-focus","month-format"];static setDefaultControlClasses(t){pt(t)}static getDefaultControlClasses(){return nt()}static setDefaultMessages(t){_t(t)}static getDefaultMessages(){return V()}constructor(){super();this._id=`date-picker-${++Ze}`,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._activationId=0,this._previewDate="",this._drag=null,this._suppressGridClick=!1,this._buttons=[],this._returnFocus=null,this._panel=null,this._calendar=null,this._originalDescribedBy="",this._rangeOriginalDescribedBy=["",""],this._formatHint=null,this._generatedPlaceholders=new WeakSet,this._controller=null,this._stopTracking=null,this._open=!1,this._suppressFocusOpen=!1,this._messages=null,this._controlClasses=null,this._stopDefaultMessages=null,this._source=null,this._dateState=null,this._renderDay=null,this._isDateDisabled=null,this._coordinateSpace="viewport"}_rangeMode(){return this.hasAttribute("range")&&Boolean(this._range)}_ownsField(t){return this._connected&&(t===this._field||Boolean(this._fields?.includes(t)))}connectedCallback(){if(this._connected)return;if(q(this,["locale","min","max","monthFormat","openOnFocus","coordinateSpace","controlClasses","messages","source","dateState","renderDay","isDateDisabled"]),this.hasAttribute("range"))this._connectRange();else this._connectSingle();if(this._connected)q(this,["value","range"]),this._stopDefaultMessages=yt(()=>{if(this._messages===null)this._refreshMessages()}),this.validate()}_connectSingle(){let t=this.querySelector(":scope > input:not([type=hidden]):not([type=time]):not([data-time-start]):not([data-time-end])");if(!(t instanceof HTMLInputElement)){console.warn("<date-picker> expects a direct child text input");return}this._connected=!0,this._input=t,this._discoverTimeFields(),this._field=new ct(t,{messages:this.messages,locale:this.locale}),this._field.onAttributesChanged=()=>this._syncInputState(),this._field.confirm=(i,n)=>this._confirmDate(i,n),this._setupFormValue(),this._build(),this._syncInputState(),this._bind(),this._syncCalendarOptions();let e=this._adapter(),s=this.getAttribute("value")||(c(t.value)?t.value:e.parse(t.value));if(s&&c(s))this._setValue(s,{emit:!1,format:!0});else if(!t.value)this._setValue("",{emit:!1,format:!1});else t.setCustomValidity(this.messages.invalidDate);if(this._field.hidden)this._field.hidden.defaultValue=this._value;this._field.adoptDefault()}_discoverTimeFields(){this._timeFields=[null,null];let t=["data-time-start","data-time-end"];for(let[e,s]of t.entries()){let i=this.querySelectorAll(`:scope > input[${s}]`);if(i.length>1)console.warn(`<date-picker> expects at most one direct child input[${s}]; ignoring extras`);let n=i[0];if(n==null)continue;if(!(n instanceof HTMLInputElement)||n.type!=="time"){console.warn(`<date-picker> input[${s}] must be an <input type="time">; ignoring it`);continue}this._timeFields[e]=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 t=this.querySelector(":scope > input[data-range-start]"),e=this.querySelector(":scope > input[data-range-end]");if(!(t instanceof HTMLInputElement)||!(e 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 ct(t,{messages:this.messages,locale:this.locale}),new ct(e,{messages:this.messages,locale:this.locale})],this._range=new St,this._rangeOriginalDescribedBy=[t.getAttribute("aria-describedby")||"",e.getAttribute("aria-describedby")||""];for(let o of this._fields)o.onAttributesChanged=()=>this._syncRangeFields(),o.confirm=(d,l)=>this._confirmDate(d,l),o.setupFormValue();this._build(),this._setRangeAria(),this._syncRangeFields(),this._bindRange(),this._syncCalendarOptions();let s=this._adapter(),i=c(t.value)?t.value:s.parse(t.value),n=c(e.value)?e.value:s.parse(e.value),r=t.value,a=e.value;this._setRange(i||"",n||"",{emit:!1});for(let[o,d,l]of[[t,r,i],[e,a,n]]){if(!d.trim()||c(l))continue;o.value=d,o.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;for(let o of this._fields)o.adoptDefault()}disconnectedCallback(){if(this._stopDefaultMessages?.(),this._stopDefaultMessages=null,this._connected=!1,this._suppressFocusOpen=!1,this.hide(!1),this._controller?.abort(),this._controller=null,this._clearTimeOrderValidity(),this._timeFields=[null,null],this._rangeMode()){for(let t of this._fields||[])this._teardownField(t);this._fields=null,this._range=null}else this._teardownField(this._field);this._field=null;for(let{button:t}of this._buttons)t.remove();this._buttons=[],this._returnFocus=null,this._panel?.remove(),this._formatHint?.remove(),this._panel=null,this._calendar=null,this._formatHint=null}_teardownField(t){if(!t)return;let e=t.input,s=this._fields?.includes(t)?this._rangeOriginalDescribedBy[this._fields?.indexOf(t)??0]||"":this._originalDescribedBy;if(t.teardown(),s)e.setAttribute("aria-describedby",s);else e.removeAttribute("aria-describedby");e.removeAttribute("role"),e.removeAttribute("aria-haspopup"),e.removeAttribute("aria-expanded"),e.removeAttribute("aria-controls")}attributeChangedCallback(t,e,s){if(this._reflecting||e===s)return;if(t==="value"&&s&&!c(s)){this._reflectValue(this._value);return}if((t==="min"||t==="max")&&s&&!c(s)){if(this.removeAttribute(t),this._connected)this._syncCalendarOptions(),this.validate();return}if(!this._connected)return;if(t==="value"){if(this._rangeMode())return;if(!s||c(s))this._supersedeActivations(),this._setValue(s||"",{emit:!1,format:!0,reflect:!1});return}if(t==="locale")this._refreshLocale();if(t==="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(t){if(this._rangeMode())throw TypeError("value is not available in range mode; use range");if(t&&!c(t))throw TypeError(`Invalid date-picker value: ${t}`);this._supersedeActivations(),this._setValue(t||"",{emit:!1,format:!0})}get range(){return this._rangeMode()&&this._range?{...this._range.range}:void 0}set range(t){if(!this._rangeMode())throw TypeError("range is only available on <date-picker range>");let{start:e,end:s}=mt(t);this._supersedeActivations(),this._setRange(e,s)}get locale(){return P(this.getAttribute("locale")||"")}set locale(t){if(t)this.setAttribute("locale",t);else this.removeAttribute("locale")}get monthFormat(){return this.getAttribute("month-format")==="short"?"short":"long"}set monthFormat(t){if(t==="short")this.setAttribute("month-format","short");else this.removeAttribute("month-format")}get min(){let t=this.getAttribute("min")||"";return c(t)?t:""}set min(t){if(t)this.setAttribute("min",t);else this.removeAttribute("min")}get max(){let t=this.getAttribute("max")||"";return c(t)?t:""}set max(t){if(t)this.setAttribute("max",t);else this.removeAttribute("max")}get openOnFocus(){return this.getAttribute("open-on-focus")!=="false"}set openOnFocus(t){if(t===!1)this.setAttribute("open-on-focus","false");else this.removeAttribute("open-on-focus")}get open(){return this._open}get controlClasses(){return at(this._controlClasses)}set controlClasses(t){if(this._controlClasses=rt(t),this._calendar)this._calendar.controlClasses=this._controlClasses}get messages(){return this._messages??V()}set messages(t){if(this._messages=t==null?null:{...V(),...t},this._calendar)this._calendar.messages=this._messages;this._refreshMessages()}_refreshMessages(){let t=this.messages;for(let s of this._fields||[])s.setMessages(t);this._field?.setMessages(t),this._panel?.setAttribute("aria-label",t.calendar);let e=this._field??this._fields?.[0];if(this._formatHint&&e)this._formatHint.textContent=`${t.formatHint}: ${e.placeholder}`;if(this._refreshButtonLabel(),this._connected)this.validate()}get source(){return this._source}set source(t){if(this._source=t||null,this._calendar)this._calendar.source=this._source;if(this._connected)this.validate()}get dateState(){return this._dateState}set dateState(t){if(this._dateState=typeof t==="function"?t:null,this._calendar)this._calendar.dateState=this._dateState;if(this._connected)this.validate()}get renderDay(){return this._renderDay}set renderDay(t){if(this._renderDay=typeof t==="function"?t:null,this._calendar)this._calendar.renderDay=this._renderDay}get isDateDisabled(){return this._isDateDisabled}set isDateDisabled(t){if(this._isDateDisabled=typeof t==="function"?t:null,this._calendar)this._calendar.isDateDisabled=this._isDateDisabled;if(this._connected)this.validate()}get coordinateSpace(){return this._coordinateSpace}set coordinateSpace(t){this._coordinateSpace=t==="document"?"document":"viewport"}_adapter(){return this._field?.adapter??this._fields?.[0]?.adapter??dt(this.locale)}_setupFormValue(){this._field?.setupFormValue()}_syncInputState(){let t=this._input;if(!t)return;this._field?.syncInputState();let e=this._buttons[0]?.button;if(e)e.disabled=t.disabled||t.readOnly;if(this._open&&!z(t))this.hide(!1)}_syncRangeFields(){if(!this._fields)return;for(let s of this._fields)s.syncInputState();for(let{button:s,endpoint:i}of this._buttons){let n=i==="end"?1:0,r=this._fields[n];s.disabled=Boolean(r?.input.disabled||r?.input.readOnly)}this._syncDragAffordance();let t=this._range?.activeEndpoint==="end"?1:0,e=this._fields[t]?.input;if(this._open&&e&&!z(e))this.hide(!1)}_setRangeAria(){if(!this._fields||!this._panel||!this._formatHint)return;for(let t of this._fields){let e=t.input,s=[this._rangeOriginalDescribedBy[this._fields.indexOf(t)],this._formatHint.id].filter(Boolean).join(" ");e.setAttribute("aria-describedby",s),e.setAttribute("role","combobox"),e.setAttribute("aria-haspopup","dialog"),e.setAttribute("aria-expanded","false"),e.setAttribute("aria-controls",this._panel.id)}}_createTrigger(t){let e=document.createElement("button");if(e.type="button",e.className="dp-picker-button",e.setAttribute("aria-haspopup","dialog"),e.setAttribute("aria-expanded","false"),e.setAttribute("aria-controls",`${this._id}-panel`),t)e.dataset.endpoint=t;return e.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>',e}_build(){let t=this._rangeMode(),e=[];if(t)for(let[o,d]of(this._fields||[]).entries())e.push([d.input,o===1?"end":"start"]);else if(this._input)e.push([this._input,""]);if(!e.length)return;let s=`${this._id}-panel`,i=`${this._id}-format`;this._buttons=e.map(([o,d])=>{let l=this._createTrigger(d);return o.insertAdjacentElement("afterend",l),{button:l,endpoint:d}});let n=document.createElement("div");n.id=s,n.className="dp-picker-panel",n.setAttribute("popover","manual"),n.setAttribute("role","dialog"),n.setAttribute("aria-label",this.messages.calendar);let r=new lt;r.selection="none",r.fixedWeeks=!0,n.append(r);let a=document.createElement("span");if(a.id=i,a.className="dp-visually-hidden",this.append(n,a),this._panel=n,this._calendar=r,this._formatHint=a,!t&&this._input){this._originalDescribedBy=this._input.getAttribute("aria-describedby")||"";let o=[this._originalDescribedBy,i].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",s)}this._refreshLocale(),this._refreshButtonLabel()}_bindPopup(t,e,s){this.ownerDocument.addEventListener("pointerdown",(i)=>{if(!this._open||i.composedPath().includes(this))return;this.hide(!1)},{capture:!0,signal:t}),this.ownerDocument.addEventListener("reset",(i)=>{if(!(i.target instanceof HTMLFormElement)||!e||i.target!==e.form)return;this.hide(!1),queueMicrotask(()=>{if(!t.aborted&&!i.defaultPrevented)s()})},{capture:!0,signal:t}),this.addEventListener("keydown",(i)=>this._onEscape(i),{signal:t})}_bind(){let t=this._input,e=this._buttons[0]?.button,s=this._calendar;if(!t||!e||!s)return;let i=new AbortController;this._controller=i;let{signal:n}=i;t.addEventListener("input",()=>{this._field?.handleInput()},{signal:n}),t.addEventListener("change",()=>void this._commitText(!1),{signal:n}),t.addEventListener("blur",()=>void this._commitText(!1),{signal:n}),t.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}),t.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})}e.addEventListener("click",(r)=>{if(this._open){if(r.detail===0){this._defer(()=>this._calendar?.focusGrid());return}this.hide(!1);return}this.show({returnFocus:e})},{signal:n}),e.addEventListener("keydown",(r)=>this._onTriggerKeyDown("",r),{signal:n}),s.addEventListener("click",(r)=>this._captureGridIntent(r),{capture:!0,signal:n}),s.addEventListener("keydown",(r)=>this._captureGridIntent(r),{capture:!0,signal:n}),s.addEventListener("dateactivate",(r)=>{let a=r,o=a.detail?.date;if(!c(o))return;let d=tt.get(a);queueMicrotask(()=>{if(n.aborted||a.defaultPrevented||!this._connected)return;if(d&&d.id!==this._activationId)return;if(!this._input||!z(this._input))return;this._field?.dirty(),this._setValue(o,{emit:!0,format:!0}),this.hide(!1),this._restoreFocus()})},{signal:n}),s.addEventListener("dateloadend",()=>void this.validate(),{signal:n}),this._bindPopup(n,this._input,()=>this._restoreDefault())}_bindRange(){let t=this._calendar;if(!this._fields||!this._buttons.length||!t)return;let e=new AbortController;this._controller=e;let{signal:s}=e;for(let[i,n]of this._fields.entries()){let r=i===1?"end":"start";n.input.addEventListener("input",()=>{if(n.handleInput(),this._orderTags.delete(i),!n.isDirty)this._revalidateRange(r)},{signal:s}),n.input.addEventListener("change",()=>void this._commitFieldText(r),{signal:s}),n.input.addEventListener("blur",()=>void this._commitFieldText(r),{signal:s}),n.input.addEventListener("focus",(a)=>this._onFieldFocus(r,a),{signal:s}),n.input.addEventListener("keydown",(a)=>this._onFieldKeyDown(r,a),{signal:s})}for(let i of this._buttons){let n=i.endpoint;if(n==="")continue;i.button.addEventListener("click",(r)=>this._onRangeTriggerClick(n,r),{signal:s}),i.button.addEventListener("keydown",(r)=>this._onTriggerKeyDown(n,r),{signal:s})}t.addEventListener("click",(i)=>{if(this._suppressGridClick){this._suppressGridClick=!1,i.preventDefault(),i.stopImmediatePropagation();return}this._captureGridIntent(i)},{capture:!0,signal:s}),t.addEventListener("keydown",(i)=>this._captureGridIntent(i),{capture:!0,signal:s}),t.addEventListener("dateactivate",(i)=>{let n=i,r=n.detail?.date;if(!c(r))return;queueMicrotask(()=>{if(s.aborted||n.defaultPrevented||!this._connected||!this._range)return;let a=tt.get(n);if(a===void 0||a.id!==this._activationId)return;let o=(l)=>this._boundEditable(l),d=a.endpoint?this._range.moveEndpoint(r,a.endpoint,o):this._range.activate(r,o);if(d.status==="refused"){this._calendar?.dispatchEvent(new CustomEvent("dateinvalid",{detail:{date:r,state:this._calendar.getDateState(r)},bubbles:!0}));return}if(this._applyRangeTransition(d),a.endpoint)return;if(d.close||d.status==="complete")this.hide(!1),this._focusField(d.endpoint)})},{signal:s}),t.addEventListener("datefocus",(i)=>this._onGridDateFocus(i),{signal:s}),t.addEventListener("pointerover",(i)=>this._onGridPointerOver(i),{signal:s}),t.addEventListener("pointerleave",()=>this._onGridPointerLeave(),{signal:s}),t.addEventListener("pointerdown",(i)=>this._onGridPointerDown(i),{signal:s}),t.addEventListener("pointermove",(i)=>this._onGridPointerMove(i),{signal:s}),t.addEventListener("pointerup",(i)=>this._onGridPointerUp(i),{signal:s}),t.addEventListener("pointercancel",(i)=>this._onGridPointerCancel(i),{signal:s}),t.addEventListener("lostpointercapture",(i)=>this._onGridPointerCancel(i),{signal:s}),t.addEventListener("dateloadend",()=>void this.validate(),{signal:s}),this._bindPopup(s,this._fields?.[0]?.input,()=>this._restoreRangeDefault())}_activateRangeEndpoint(t){let e=this._calendar;if(!this._range||!e)return;this._range.focus(t),this._activationId++,this._lastFocusEndpoint=t;let s=this._boundCanonical(t)||O();e.display=p(s),e.focusedDate=s,this._clearPreview()}_onRangeTriggerClick(t,e){if(!this._open){this.show({endpoint:t});return}if(e.detail===0){this._activateRangeEndpoint(t),this._defer(()=>this._calendar?.focusGrid());return}if(t!==this._range?.activeEndpoint){this._activateRangeEndpoint(t);return}this.hide(!1)}_onTriggerKeyDown(t,e){if(e.key!=="ArrowDown")return;if(e.preventDefault(),this._open){if(this._rangeMode()&&t)this._activateRangeEndpoint(t);this._defer(()=>this._calendar?.focusGrid());return}if(this._rangeMode())this.show({endpoint:t||void 0});else this.show({returnFocus:this._buttons[0]?.button})}_onFieldKeyDown(t,e){if(e.key==="ArrowDown"){if(e.preventDefault(),this._rangeMode()&&t)this._lastFocusEndpoint=t,this._range?.focus(t);if(this._open)this._defer(()=>this._calendar?.focusGrid());else this.show()}else if(e.key==="Escape"&&this._open)e.preventDefault(),this.hide(!1)}_onFieldFocus(t,e){if(!this._rangeMode()||!t)return;let s=t!==this._range?.activeEndpoint;if(this._lastFocusEndpoint=t,this._range?.focus(t),s)this._activationId++;if(!this.openOnFocus||this._suppressFocusOpen)return;let i=e.relatedTarget;if(i instanceof Node&&this.contains(i))return;if(!this._open)this.show({moveFocus:!1})}_captureGridIntent(t){if(this._rangeMode()?!this._range:!this._field)return;if(t.type==="keydown"){let i=t.key;if(i!=="Enter"&&i!==" ")return}if(t.type==="click"&&this._suppressGridClick)return;if(!(t.target instanceof Element))return;let s=t.target.closest(".dp-day[data-date]")?.getAttribute("data-date")||"";if(!c(s))return;this._attachIntent(s,"")}_attachIntent(t,e){if(!this._calendar)return;this._calendar._hostIntent={date:t,intent:{id:++this._activationId,endpoint:e}}}_supersedeActivations(){this._activationId++}_boundEditable(t){let e=this._fields?.[t==="end"?1:0];return e!=null&&z(e.input)}_applyRangeTransition(t){let e=this._fields;if(!e||!this._range||t.status==="refused")return;let s=[];for(let i of t.changedEndpoints){let n=e[i==="end"?1:0],r=i==="end"?t.range.end:t.range.start;if(!n||n.canonical===r)continue;n.setCanonical(r,{format:!0}),s.push(n)}if(this._syncHighlight(),this._refreshRangeButtonLabel(),this._revalidateRange(t.endpoint),!s.length)return;this._emitRangeChange();for(let i of s)i.input.dispatchEvent(new Event("input",{bubbles:!0})),i.input.dispatchEvent(new Event("change",{bubbles:!0}))}_setPreview(t,e=""){let s=this._calendar;if(!s||!this._range||!this._open)return;let i=c(t)&&!s.getDateState(t).disabled?t:"",n=i?this._range.previewRange(i,e,(r)=>this._boundEditable(r)):null;if(!n){this._clearPreview();return}this._previewDate=i,s.toggleAttribute("data-range-preview",!0),s.highlightedRange=n}_clearPreview(){if(!this._previewDate)return;this._syncHighlight()}_onGridDateFocus(t){if(this._drag)return;let e=t.detail?.date;if(c(e))this._setPreview(e)}_onGridPointerOver(t){let e=t;if(this._drag||e.pointerType==="touch")return;this._setPreview(this._cellDate(e.target))}_onGridPointerLeave(){if(this._drag?.active===!1)this._drag=null;if(this._drag)return;this._clearPreview()}_cellDate(t){let s=(t instanceof Element?t.closest(".dp-day[data-date]"):null)?.getAttribute("data-date")||"";return c(s)?s:""}_dateAtPoint(t,e){let s=this.ownerDocument.elementFromPoint(t,e);if(!(s instanceof Element)||!this._calendar?.contains(s))return"";return this._cellDate(s)}_onGridPointerDown(t){let e=t;if(this._suppressGridClick=!1,this._drag?.active===!1)this._drag=null;if(!this._open||!this._range||this._drag)return;if(!e.isPrimary||e.button!==0)return;if(e.pointerType!=="mouse"&&e.pointerType!=="pen")return;if(!this._range.complete)return;let s=e.target instanceof Element?e.target.closest(".dp-day[data-date]"):null;if(!(s instanceof HTMLElement))return;let i=s.hasAttribute("data-range-start"),n=s.hasAttribute("data-range-end");if(i===n)return;let r=i?"start":"end",a=this._cellDate(s);if(!a||!this._boundEditable(r))return;this._drag={pointerId:e.pointerId,endpoint:r,x:e.clientX,y:e.clientY,date:a,active:!1}}_onGridPointerMove(t){let e=t,s=this._drag;if(!s||e.pointerId!==s.pointerId)return;if(!s.active){if(!(Math.abs(e.clientX-s.x)>ce||Math.abs(e.clientY-s.y)>ce))return;s.active=!0;try{this._calendar?.setPointerCapture(s.pointerId)}catch{}this._syncDragAffordance()}let i=this._dateAtPoint(e.clientX,e.clientY);if(!i||this._calendar?.getDateState(i).disabled)return;s.date=i,this._setPreview(i,s.endpoint)}_onGridPointerUp(t){let e=t,s=this._drag;if(!s||e.pointerId!==s.pointerId)return;if(this._drag=null,this._releaseDragCapture(s.pointerId),!s.active){this._syncDragAffordance();return}this._suppressGridClick=!0;let i=this._range?.projectEndpoint(s.date,s.endpoint,(r)=>this._boundEditable(r));if(!i||i.status==="refused"||!i.changedEndpoints.length){this._syncHighlight();return}let n=s.endpoint==="start"?i.range.start:i.range.end;this._attachIntent(n,s.endpoint),this._calendar?.activateDate(n)}_onGridPointerCancel(t){let e=t,s=this._drag;if(!s||e.pointerId!==s.pointerId)return;this._drag=null,this._releaseDragCapture(s.pointerId),this._syncHighlight()}_releaseDragCapture(t){let e=this._calendar;if(e?.hasPointerCapture(t))e.releasePointerCapture(t)}_syncDragAffordance(){let t=this._calendar;if(!t||!this._range)return;if(this._drag?.active){t.setAttribute("data-range-drag","active");return}let{start:e,end:s}=this._range;if(this._range.complete&&e!==s&&(this._boundEditable("start")||this._boundEditable("end")))t.setAttribute("data-range-drag","ready");else t.removeAttribute("data-range-drag")}_onEscape(t){if(t.key==="Escape"&&this._open)t.preventDefault(),t.stopPropagation(),this.hide(!0)}_syncCalendarOptions(){let t=this._calendar,e=this._panel;if(!t)return;if(t.locale=this.locale,t.min=this.min,t.max=this.max,t.monthFormat=this.monthFormat,t.controlClasses=this._controlClasses,t.messages=this._messages,t.source=this._source,t.dateState=this._dateState,t.renderDay=this._renderDay,t.isDateDisabled=this._isDateDisabled,!this._rangeMode()&&this._value)t.value=this._value;if(e)e.setAttribute("aria-label",this.messages.calendar)}_refreshLocale(){let t=this._formatHint;if(!t)return;if(this._rangeMode()&&this._fields){this._fields[0].setLocale(this.locale),this._fields[1].setLocale(this.locale),t.textContent=`${this.messages.formatHint}: ${this._fields[0].placeholder}`;for(let[s,i]of this._fields.entries()){if(!i.input.hasAttribute("placeholder")||this._generatedPlaceholders.has(i.input))i.input.placeholder=i.placeholder,this._generatedPlaceholders.add(i.input);let n=s===1?this._range?.end||"":this._range?.start||"";if(n)i.input.value=i.format(n)}this._refreshButtonLabel();return}let e=this._field;if(!e)return;if(e.setLocale(this.locale),t.textContent=`${this.messages.formatHint}: ${e.placeholder}`,!e.input.hasAttribute("placeholder")||this._generatedPlaceholders.has(e.input))e.input.placeholder=e.placeholder,this._generatedPlaceholders.add(e.input);if(this._value)e.input.value=e.format(this._value);this._refreshButtonLabel()}_refreshButtonLabel(){let t=this._buttons[0]?.button;if(!t)return;if(this._rangeMode()){this._refreshRangeButtonLabel();return}let e=this._value?this.messages.changeDate:this.messages.chooseDate,s=this._value?`, ${ot(this._value,this.locale)}`:"";t.setAttribute("aria-label",`${e}${s}`)}_refreshRangeButtonLabel(){if(!this._range)return;let{start:t,end:e}=this._range;for(let{button:s,endpoint:i}of this._buttons){let n=i==="end"?e:t,r=n?this.messages.changeDate:this.messages.chooseDate,a=n?`, ${ot(n,this.locale)}`:"",o=i==="end"?this.messages.rangeEnd:this.messages.rangeStart;s.setAttribute("aria-label",`${r}${a}, ${o}`)}}_reflectValue(t){if(this._reflecting=!0,t)this.setAttribute("value",t);else this.removeAttribute("value");this._reflecting=!1}_setValue(t,e={}){if(t&&!c(t))throw TypeError(`Invalid date-picker value: ${t}`);let s=this._value;if(this._value=t||"",e.reflect!==!1)this._reflectValue(this._value);if(this._field?.setCanonical(this._value,{format:e.format!==!1}),this._calendar){if(this._calendar.value=this._value,this._value&&e.moveDisplay!==!1)this._calendar.focusedDate=this._value}if(this._refreshButtonLabel(),s!==this._value){if(this.dispatchEvent(new CustomEvent("valuechange",{detail:{value:this._value},bubbles:!0})),e.emit&&this._field){let i=this._field.input;i.dispatchEvent(new Event("input",{bubbles:!0})),i.dispatchEvent(new Event("change",{bubbles:!0}))}}}async _confirmDate(t,e={}){let s=this._calendar;if(!s)return{ok:!0};if(e.moveDisplay!==!1){let r=p(t);if(s.display!==r)s.display=r}let i=await s.ensureDate(t),n=s.getDateState(t);if(!i||n.disabled)return{ok:!1,message:this.messages.unavailableDate};return{ok:!0}}async _commitText(t,e={}){let s=this._field;if(!s)return!1;if(!e.force&&!s.isDirty)return!1;let i=await s.commit(e);if(!this._ownsField(s)||!s.isCommitCurrent(i.commitId))return!1;if(i.status==="stale"||i.status==="invalid")return!1;return this._setValue(i.value||"",{emit:t,format:i.status==="ok",moveDisplay:e.moveDisplay}),!0}async _commitFieldText(t){let e=this._fields;if(!e)return!1;let s=t==="end"?1:0,i=e[s];if(!i?.isDirty)return!1;let n=await i.commit();if(!this._ownsField(i)||!i.isCommitCurrent(n.commitId))return!1;if(n.status==="stale")return!1;if(n.status==="invalid")return this._orderTags.delete(s),!1;return this._setBound(t,n.value||"",{emit:!1,user:!0,format:n.status==="ok"}),!0}_setBound(t,e,s={}){if(!this._range)return!1;let i=this._fields;if(!i)return!1;let r=i[t==="end"?1:0];if(!r)return!1;if(s.user===!0&&!z(r.input))return!1;let a=e||"",o=r.canonical;if(r.setCanonical(a,{format:s.format!==!1}),t==="end")this._range.end=a;else this._range.start=a;let d=o!==a;if(d){if(this._syncHighlight(),this._refreshRangeButtonLabel(),this._emitRangeChange(),s.emit)r.input.dispatchEvent(new Event("input",{bubbles:!0})),r.input.dispatchEvent(new Event("change",{bubbles:!0}))}return this._revalidateRange(t),d}_setRange(t,e,s={}){if(!this._range||!this._fields)return;if(this._range.start=t||"",this._range.end=e||"",this._fields[0].setCanonical(t||"",{format:s.format!==!1}),this._fields[1].setCanonical(e||"",{format:s.format!==!1}),this._syncHighlight(),this._refreshRangeButtonLabel(),this._revalidateRange("start"),this._revalidateRange("end"),s.emit!==!1)this._emitRangeChange()}_boundCanonical(t){return this._range?t==="end"?this._range.end:this._range.start:""}_emitRangeChange(){if(!this._range)return;this.dispatchEvent(new CustomEvent("rangechange",{detail:{...this._range.range},bubbles:!0}))}_displayRange(){let{start:t,end:e}=this._range?.range??{start:"",end:""};if(!t)return{start:"",end:""};if(e&&g(e,t)<0)return{start:t,end:""};return{start:t,end:e}}_syncHighlight(){if(!this._calendar||!this._range)return;this._previewDate="",this._calendar.removeAttribute("data-range-preview"),this._calendar.highlightedRange=this._displayRange(),this._syncDragAffordance()}_revalidateRange(t){if(!this._fields||!this._range)return;let{start:e,end:s}=this._range,i=Boolean(e&&s&&g(s,e)<0),n=["start","end"];for(let r of n){let a=r==="end"?1:0,o=this._fields[a].input,d=r==="end"?this.messages.rangeOrderEnd:this.messages.rangeOrderStart;if(i&&r===t)o.setCustomValidity(d),this._orderTags.add(a);else if(this._orderTags.has(a))o.setCustomValidity(""),this._orderTags.delete(a)}}_revalidateTimeOrder(t){let[e,s]=this._timeFields,i=["start","end"],n=[e,s],r=e&&!e.matches(":disabled")?e.value.trim():"",a=s&&!s.matches(":disabled")?s.value.trim():"",o=Boolean(e&&s&&r&&a)&&Ft(r)&&Ft(a)&&le(a,r)<0;for(let[d,l]of i.entries()){let h=n[d];if(!h)continue;let b=l==="end"?this.messages.rangeOrderEnd:this.messages.rangeOrderStart;if(o&&l===t)h.setCustomValidity(b),this._timeOrderOwned.add(h);else if(this._timeOrderOwned.has(h))h.setCustomValidity(""),this._timeOrderOwned.delete(h)}}_clearTimeOrderValidity(){for(let t of this._timeOrderOwned)t.setCustomValidity("");this._timeOrderOwned.clear()}_defer(t){let e=this._controller;setTimeout(()=>{if(!this._connected||!e||e.signal.aborted||this._controller!==e)return;t()},0)}_restoreDefault(){let t=this._field;if(!t)return;let e=t.restoreDefault();if(this._setValue(e,{emit:!1,format:!0}),this._calendar)if(this._value)this._calendar.display=p(this._value),this._calendar.focusedDate=this._value;else this._calendar.display=p(O()),this._calendar.focusedDate=O();this.validate()}_restoreRangeDefault(){if(!this._fields)return;let t=this._fields[0].restoreDefault(),e=this._fields[1].restoreDefault();if(this._setRange(t,e),this._calendar){let s=this._range?.start||O();this._calendar.display=p(s),this._calendar.focusedDate=s}this.validate()}_focusField(t){let e=t==="end"?1:0,s=this._fields?.[e]?.input;if(!s)return;this._suppressFocusOpen=!0,this._defer(()=>{s.focus(),this._suppressFocusOpen=!1})}_restoreFocus(){let t=this._returnFocus;if(this._returnFocus=null,!(t instanceof HTMLElement)||!t.isConnected||t.matches(":disabled"))return;this._suppressFocusOpen=!0,this._defer(()=>{t.focus(),this._suppressFocusOpen=!1})}_resolveRangeEndpoint(){if(!this._fields)return"";let t=this._lastFocusEndpoint||"start",e=t==="end"?1:0;if(z(this._fields[e].input))return t;let s=t==="end"?"start":"end",i=s==="end"?1:0;if(z(this._fields[i].input))return s;return""}async validate(){if(this._rangeMode()){let s=this._fields;if(!s)return!0;for(let[i,n]of s.entries()){let r=await n.commit({moveDisplay:!1});if(!this._ownsField(n)||!n.isCommitCurrent(r.commitId))continue;if(r.status==="invalid")this._orderTags.delete(i);if(r.status==="ok"||r.status==="clear"){let a=i===1?"end":"start";this._setBound(a,r.value||"",{format:r.status==="ok"})}}return this._revalidateRange("start"),this._revalidateRange("end"),s.every((i)=>i.input.checkValidity())}let t=this._field?.input;if(!t){let s=this.hasAttribute("range")?this.querySelectorAll(":scope > input[data-range-start], :scope > input[data-range-end]"):this._input?[this._input]:[],i=this.querySelectorAll(":scope > input[type=time][data-time-start], :scope > input[type=time][data-time-end]");return[...s,...i].every((n)=>n instanceof HTMLInputElement&&n.checkValidity())}await this._commitText(!1,{force:!0,moveDisplay:!1}),this._revalidateTimeOrder("start"),this._revalidateTimeOrder("end");let e=this._timeFields.every((s)=>s?.checkValidity()??!0);return t.checkValidity()&&e}show(t={}){let e=this._panel,s=this._calendar;if(!e||!s||!this._buttons.length||this._open)return;if(this._rangeMode()){let r=t.endpoint||this._resolveRangeEndpoint();if(!r)return;this._activateRangeEndpoint(r)}else{let r=this._input;if(!r||!z(r))return;let a=this._value||this._adapter().parse(r.value)||O();s.display=p(a),s.focusedDate=a,this._returnFocus=t.returnFocus instanceof HTMLElement?t.returnFocus:r}e.showPopover(),this._open=!0,this._setExpanded(!0);let i=this.coordinateSpace;e.style.position=i==="document"?"absolute":"fixed";let n=()=>oe(this,e,{placement:"bottom-start",distance:4,shiftPadding:8,coordinateSpace:i});if(n(),this._stopTracking=ae(this,e,n),t.moveFocus!==!1){let r=this._controller;queueMicrotask(()=>{if(!this._connected||!r||r.signal.aborted||this._controller!==r)return;s.focusGrid()})}this.dispatchEvent(new Event("open",{bubbles:!0}))}_setExpanded(t){let e=t?"true":"false";this._input?.setAttribute("aria-expanded",e);for(let{button:s}of this._buttons)s.setAttribute("aria-expanded",e);for(let s of this._fields||[])s.input.setAttribute("aria-expanded",e)}hide(t=!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._supersedeActivations(),this._suppressGridClick=!1,this._drag)this._releaseDragCapture(this._drag.pointerId),this._drag=null;if(this._syncHighlight(),t)if(this._rangeMode()){let e=this._restoreFocusEndpoint();if(e)this._focusField(e)}else this._restoreFocus();this.dispatchEvent(new Event("close",{bubbles:!0}))}_restoreFocusEndpoint(){let t=this._range?.activeEndpoint||"";if(t){let e=t==="end"?1:0,s=this._fields?.[e];if(s&&z(s.input))return t}return this._resolveRangeEndpoint()}}function Rt(){if(!customElements.get("date-calendar"))customElements.define("date-calendar",lt);if(!customElements.get("date-picker"))customElements.define("date-picker",Lt)}Rt();var ue="lekoala-date-picker-styles";if(!document.getElementById(ue)){let t=document.createElement("style");t.id=ue,t.textContent=Pt;let e=document.currentScript?.nonce;if(e)t.nonce=e;document.head.append(t)}Rt();})();
|