@lekoala/date-picker 0.3.0 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +281 -263
- package/custom-elements.json +30 -0
- package/dist/date-picker.css +51 -46
- package/dist/date-picker.js +685 -204
- package/dist/date-picker.min.css +1 -1
- package/dist/date-picker.min.js +13 -13
- package/dist/date-picker.standalone.min.js +65 -60
- package/dist/types/control-classes.d.ts +30 -0
- package/dist/types/control-classes.d.ts.map +1 -0
- package/dist/types/date-calendar.d.ts +49 -3
- package/dist/types/date-calendar.d.ts.map +1 -1
- package/dist/types/date-field.d.ts +12 -4
- package/dist/types/date-field.d.ts.map +1 -1
- package/dist/types/date-picker.d.ts +106 -9
- package/dist/types/date-picker.d.ts.map +1 -1
- package/dist/types/date-range.d.ts +102 -20
- package/dist/types/date-range.d.ts.map +1 -1
- package/dist/types/date.d.ts +14 -2
- package/dist/types/date.d.ts.map +1 -1
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/intl.d.ts.map +1 -1
- package/dist/types/source.d.ts +1 -0
- package/dist/types/source.d.ts.map +1 -1
- package/docs/ACCESSIBILITY.md +6 -2
- package/docs/API.md +430 -358
- package/docs/DECISIONS.md +68 -49
- package/docs/MIGRATION-FLATPICKR.md +1 -1
- package/docs/TESTING.md +1 -1
- package/docs/USE_CASES.md +156 -141
- package/package.json +8 -8
- package/src/control-classes.js +50 -0
- package/src/date-calendar.js +188 -54
- package/src/date-field.js +9 -5
- package/src/date-picker.css +51 -46
- package/src/date-picker.js +392 -83
- package/src/date-range.js +184 -30
- package/src/date.js +57 -3
- package/src/index.js +1 -0
- package/src/intl.js +52 -17
- package/src/source.js +14 -4
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
/*** @lekoala/date-picker v0.
|
|
2
|
-
(()=>{var
|
|
1
|
+
/*** @lekoala/date-picker v0.5.0 - https://github.com/lekoala/date-picker ***/
|
|
2
|
+
(()=>{var Ce=`:where(date-calendar, date-picker) {
|
|
3
3
|
--dp-bg: #ffffff;
|
|
4
4
|
--dp-fg: #1f2328;
|
|
5
5
|
--dp-muted: color-mix(in srgb, var(--dp-fg) 58%, var(--dp-bg));
|
|
@@ -7,6 +7,8 @@
|
|
|
7
7
|
--dp-hover: color-mix(in srgb, var(--dp-fg) 5%, var(--dp-bg));
|
|
8
8
|
--dp-accent: #2563eb;
|
|
9
9
|
--dp-accent-fg: #fff;
|
|
10
|
+
--dp-focus: var(--dp-accent);
|
|
11
|
+
--dp-focus-width: 2px;
|
|
10
12
|
--dp-radius: 0.5rem;
|
|
11
13
|
--dp-day-size: 2.75rem;
|
|
12
14
|
--dp-gap: 0.375rem;
|
|
@@ -45,7 +47,7 @@ date-calendar {
|
|
|
45
47
|
|
|
46
48
|
.dp-calendar-header {
|
|
47
49
|
display: grid;
|
|
48
|
-
grid-template-columns: minmax(0, 1fr)
|
|
50
|
+
grid-template-columns: minmax(0, 1fr) var(--dp-year-inline-size) auto auto;
|
|
49
51
|
/* Stretch (not center): once a UA natural height exceeds
|
|
50
52
|
--dp-header-control-size, the row grows to the tallest control and the
|
|
51
53
|
others stretch to match, so month/year/nav stay equal. */
|
|
@@ -61,12 +63,16 @@ date-calendar {
|
|
|
61
63
|
track stays under the month select so the fixed-width year input never
|
|
62
64
|
stretches. Visual mirroring itself is left to the inherited \`dir\`. */
|
|
63
65
|
date-calendar[data-year-first] .dp-calendar-header {
|
|
64
|
-
grid-template-columns:
|
|
66
|
+
grid-template-columns: var(--dp-year-inline-size) minmax(0, 1fr) auto auto;
|
|
65
67
|
}
|
|
66
68
|
|
|
67
69
|
.dp-calendar-header :where(button, select, input) {
|
|
68
|
-
min-block-size: var(--dp-header-control-size);
|
|
69
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);
|
|
70
76
|
/* Shared vertical metrics: UA default padding/line-height differ per control
|
|
71
77
|
(up to ~13px apart), which only shows once --dp-header-control-size drops
|
|
72
78
|
below content size. */
|
|
@@ -79,8 +85,7 @@ date-calendar[data-year-first] .dp-calendar-header {
|
|
|
79
85
|
line-height: 1.2;
|
|
80
86
|
}
|
|
81
87
|
|
|
82
|
-
.dp-calendar-header input {
|
|
83
|
-
min-inline-size: 0;
|
|
88
|
+
.dp-calendar-header input.dp-skin {
|
|
84
89
|
padding-inline: 0.45rem;
|
|
85
90
|
}
|
|
86
91
|
|
|
@@ -90,11 +95,13 @@ date-calendar[data-year-first] .dp-calendar-header {
|
|
|
90
95
|
control and the others stretch to match. */
|
|
91
96
|
.dp-month-select {
|
|
92
97
|
inline-size: 100%;
|
|
93
|
-
min-inline-size: 0;
|
|
94
98
|
/* Long month names in a narrow track (compact consumers, long locales)
|
|
95
99
|
would paint under the caret: truncate with an ellipsis instead. */
|
|
96
100
|
overflow: hidden;
|
|
97
101
|
text-overflow: ellipsis;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
.dp-month-select.dp-skin {
|
|
98
105
|
appearance: none;
|
|
99
106
|
padding-inline: 0.45rem 2rem;
|
|
100
107
|
background-image:
|
|
@@ -110,18 +117,18 @@ date-calendar[data-year-first] .dp-calendar-header {
|
|
|
110
117
|
/* Inherited RTL mirrors the header layout via the grid. The logical
|
|
111
118
|
\`padding-inline\` already flips, so only the physically-positioned caret has
|
|
112
119
|
to follow it to the other side. */
|
|
113
|
-
[dir="rtl"] .dp-month-select,
|
|
114
|
-
html[dir="rtl"] .dp-month-select {
|
|
120
|
+
[dir="rtl"] .dp-month-select.dp-skin,
|
|
121
|
+
html[dir="rtl"] .dp-month-select.dp-skin {
|
|
115
122
|
background-position:
|
|
116
123
|
0.9rem 50%,
|
|
117
124
|
0.65rem 50%;
|
|
118
125
|
}
|
|
119
126
|
|
|
120
127
|
.dp-year-input {
|
|
121
|
-
inline-size:
|
|
128
|
+
inline-size: 100%;
|
|
122
129
|
}
|
|
123
130
|
|
|
124
|
-
.dp-nav {
|
|
131
|
+
.dp-nav.dp-skin {
|
|
125
132
|
display: grid;
|
|
126
133
|
place-items: center;
|
|
127
134
|
inline-size: var(--dp-header-control-size);
|
|
@@ -138,30 +145,23 @@ html[dir="rtl"] .dp-month-select {
|
|
|
138
145
|
pointer-events: none;
|
|
139
146
|
}
|
|
140
147
|
|
|
141
|
-
|
|
142
|
-
so previous/next keep their visual sense. Actions stay chronological: no
|
|
143
|
-
button swap, no keyboard remapping. */
|
|
144
|
-
[dir="rtl"] .dp-nav svg,
|
|
145
|
-
html[dir="rtl"] .dp-nav svg {
|
|
146
|
-
transform: scaleX(-1);
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
.dp-calendar-header :where(button, select, input):disabled,
|
|
148
|
+
.dp-calendar-header .dp-skin:disabled,
|
|
150
149
|
.dp-picker-button:disabled {
|
|
151
150
|
cursor: not-allowed;
|
|
152
151
|
opacity: 0.45;
|
|
153
152
|
}
|
|
154
153
|
|
|
155
|
-
.dp-nav:hover:not(:disabled) {
|
|
154
|
+
.dp-nav.dp-skin:hover:not(:disabled) {
|
|
156
155
|
background: var(--dp-hover);
|
|
157
156
|
}
|
|
158
157
|
|
|
159
|
-
/*
|
|
160
|
-
|
|
161
|
-
.dp-calendar-header :
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
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
165
|
}
|
|
166
166
|
|
|
167
167
|
.dp-day:hover:not([data-disabled="true"]):not([data-selected="true"]):not([data-range-start="true"]):not(
|
|
@@ -206,15 +206,6 @@ html[dir="rtl"] .dp-nav svg {
|
|
|
206
206
|
font-size: 0.875rem;
|
|
207
207
|
}
|
|
208
208
|
|
|
209
|
-
/* Inner ring: keyboard focus stays inside the cell instead of reading as a
|
|
210
|
-
second selected state or bleeding onto a neighbouring range band. It is an
|
|
211
|
-
\`outline\` (not an inset box-shadow) because forced colors computes
|
|
212
|
-
box-shadow to \`none\`, which would erase the keyboard indicator entirely. */
|
|
213
|
-
.dp-day:focus-visible {
|
|
214
|
-
outline: 2px solid var(--dp-accent);
|
|
215
|
-
outline-offset: -2px;
|
|
216
|
-
}
|
|
217
|
-
|
|
218
209
|
/* On an accent-filled cell the ring inverts so it stays readable. */
|
|
219
210
|
.dp-day:is([data-selected="true"], [data-range-start="true"], [data-range-end="true"]):focus-visible {
|
|
220
211
|
outline-color: var(--dp-accent-fg);
|
|
@@ -276,6 +267,28 @@ html[dir="rtl"] .dp-nav svg {
|
|
|
276
267
|
border-end-end-radius: var(--dp-day-radius);
|
|
277
268
|
}
|
|
278
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
|
+
|
|
279
292
|
.dp-day-number {
|
|
280
293
|
display: block;
|
|
281
294
|
font-variant-numeric: tabular-nums;
|
|
@@ -321,14 +334,6 @@ date-picker {
|
|
|
321
334
|
max-inline-size: 100%;
|
|
322
335
|
}
|
|
323
336
|
|
|
324
|
-
/* Visible focus is normalized to --dp-accent so the component holds together
|
|
325
|
-
without a consumer stylesheet; the field's own look stays consumer-owned. */
|
|
326
|
-
date-picker > input:not([type="hidden"]):focus-visible {
|
|
327
|
-
border-color: var(--dp-accent);
|
|
328
|
-
outline: none;
|
|
329
|
-
box-shadow: 0 0 0 3px color-mix(in srgb, var(--dp-accent) 20%, transparent);
|
|
330
|
-
}
|
|
331
|
-
|
|
332
337
|
/* Every authored control is a grid item. */
|
|
333
338
|
date-picker > input:not([type="hidden"]) {
|
|
334
339
|
min-inline-size: 0;
|
|
@@ -369,7 +374,7 @@ date-picker > input:not([type="hidden"]):not([type="time"]) {
|
|
|
369
374
|
field already shows its own ring through :focus-visible). Same radius as
|
|
370
375
|
everywhere else: no bespoke shape. */
|
|
371
376
|
.dp-picker-button:focus-visible {
|
|
372
|
-
outline:
|
|
377
|
+
outline: var(--dp-focus-width) solid var(--dp-focus);
|
|
373
378
|
outline-offset: -5px;
|
|
374
379
|
border-radius: var(--dp-radius);
|
|
375
380
|
}
|
|
@@ -447,8 +452,8 @@ date-picker[range] > .dp-picker-button[data-endpoint="end"] {
|
|
|
447
452
|
@media (forced-colors: active) {
|
|
448
453
|
/* The author-drawn caret is a gradient and disappears here: hand the
|
|
449
454
|
control back to the browser instead of trying to rebuild it. */
|
|
450
|
-
.dp-month-select,
|
|
451
|
-
[dir="rtl"] .dp-month-select {
|
|
455
|
+
.dp-month-select.dp-skin,
|
|
456
|
+
[dir="rtl"] .dp-month-select.dp-skin {
|
|
452
457
|
appearance: auto;
|
|
453
458
|
background-image: none;
|
|
454
459
|
padding-inline: 0.45rem;
|
|
@@ -487,19 +492,19 @@ date-picker[range] > .dp-picker-button[data-endpoint="end"] {
|
|
|
487
492
|
forced-color-adjust: none;
|
|
488
493
|
}
|
|
489
494
|
}
|
|
490
|
-
`;var Ue=/^(\d{4})-(\d{2})-(\d{2})$/,Ye=/^(\d{4})-(\d{2})$/;function We(e){return e%4===0&&(e%100!==0||e%400===0)}function ee(e,t){if(t===2)return We(e)?29:28;return[4,6,9,11].includes(t)?30:31}function I(e){let t=Ue.exec(String(e||""));if(!t)return null;let i=Number(t[1]),s=Number(t[2]),n=Number(t[3]);if(i<1||i>9999||s<1||s>12)return null;if(n<1||n>ee(i,s))return null;return{year:i,month:s,day:n}}function c(e){return I(e)!==null}function f(e){let t=String(e||""),i=Ye.exec(t);if(i){let n=Number(i[2]);if(n>=1&&n<=12)return`${i[1]}-${String(n).padStart(2,"0")}`}let s=I(t);if(!s)throw TypeError(`Invalid civil date/month: ${e}`);return`${String(s.year).padStart(4,"0")}-${String(s.month).padStart(2,"0")}`}function U(e,t,i){let s=`${String(e).padStart(4,"0")}-${String(t).padStart(2,"0")}-${String(i).padStart(2,"0")}`;if(!c(s))throw TypeError(`Invalid civil date: ${s}`);return s}function te(e){let t=new Date(0);return t.setUTCHours(12,0,0,0),t.setUTCFullYear(e.year,e.month-1,e.day),t}function qe(e){return U(e.getUTCFullYear(),e.getUTCMonth()+1,e.getUTCDate())}function B(e){let t=I(e);if(!t)throw TypeError(`Invalid civil date: ${e}`);return te(t)}function w(e,t){if(!c(e)||!c(t))throw TypeError("compareDates() expects YYYY-MM-DD values");return e===t?0:e<t?-1:1}function L(e,t){let i=I(e);if(!i||!Number.isInteger(t))throw TypeError("addDays() expects a date and integer amount");let s=te(i);return s.setUTCDate(s.getUTCDate()+t),qe(s)}function ie(e,t){let i=I(e);if(!i||!Number.isInteger(t))throw TypeError("addMonths() expects a date and integer amount");let s=i.year*12+(i.month-1)+t,n=Math.floor(s/12),a=(s%12+12)%12+1,o=Math.min(i.day,ee(n,a));return U(n,a,o)}function _e(e,t){let i=I(e);if(!i||!Number.isInteger(t))throw TypeError("addYears() expects a date and integer amount");let s=i.year+t,n=Math.min(i.day,ee(s,i.month));return U(s,i.month,n)}function P(e,t){let i=`${f(e)}-01`;return f(ie(i,t))}function Ke(e){return`${f(e)}-01`}function je(e){let t=I(`${f(e)}-01`);if(!t)throw TypeError(`Invalid month: ${e}`);return U(t.year,t.month,ee(t.year,t.month))}function Ge(e){let t=I(e);if(!t)throw TypeError(`Invalid civil date: ${e}`);return te(t).getUTCDay()}function j(e){if(e===7)return 0;if(!Number.isInteger(e)||e<0||e>6)throw RangeError("firstDay must be 0..6 (Sunday=0, 7 accepted as Sunday alias)");return e}function se(e,t=1){let i=(Ge(e)-j(t)+7)%7;return L(e,-i)}function re(e,t=1){return L(se(e,t),6)}function ye(e,t={}){let i=t.firstDay??1,s=se(Ke(e),i),n=re(je(e),i),r=[],a=s;while(w(a,n)<=0){let o=[];for(let l=0;l<7;l++)o.push(L(a,l));r.push(o),a=L(a,7)}return r}function be(e,t="",i=""){if(!c(e))throw TypeError(`Invalid civil date: ${e}`);if(t&&w(e,t)<0)return t;if(i&&w(e,i)>0)return i;return e}function O(){let e=new Date;return U(e.getFullYear(),e.getMonth()+1,e.getDate())}function ve(e){let t=I(e);if(!t)throw TypeError(`Invalid civil date: ${e}`);let i=te(t),s=i.getUTCDay()||7;i.setUTCDate(i.getUTCDate()+4-s);let n=new Date(0);return n.setUTCHours(12,0,0,0),n.setUTCFullYear(i.getUTCFullYear(),0,1),Math.ceil(((i.getTime()-n.getTime())/86400000+1)/7)}class ae{constructor(e={}){let t=O();this.firstDay=j(e.firstDay??1),this.value=e.value&&c(e.value)?e.value:"",this.focused=e.focused&&c(e.focused)?e.focused:this.value||t,this.display=e.display?f(e.display):f(this.focused)}setValue(e){if(e&&!c(e))throw TypeError(`Invalid value: ${e}`);return this.value=e||"",this.value}setDisplay(e){let t=f(e),i=Number(this.focused.slice(8,10))||1,s=ie(`${t}-01`,0),n=L(s,Math.max(0,i-1));return this.focused=f(n)===t?n:L(`${P(t,1)}-01`,-1),this.display=t,this.display}setFocused(e,t={}){if(!c(e))throw TypeError(`Invalid focused date: ${e}`);if(this.focused=e,t.follow!==!1)this.display=f(e);return this.focused}moveFocusDays(e){return this.setFocused(L(this.focused,e))}moveFocusMonths(e){return this.setFocused(ie(this.focused,e))}moveFocusYears(e){return this.setFocused(_e(this.focused,e))}focusWeekStart(){return this.setFocused(se(this.focused,this.firstDay))}focusWeekEnd(){return this.setFocused(re(this.focused,this.firstDay))}navigateMonth(e){let t=P(this.display,e);return this.setDisplay(t),this.display}}function ne(e){if(e==null)return{start:"",end:""};if(typeof e!=="object")throw TypeError("highlightedRange expects { start, end }");let{start:t="",end:i=""}=e;if(t&&!c(t))throw TypeError(`Invalid range start: ${t}`);if(i&&!c(i))throw TypeError(`Invalid range end: ${i}`);if(!t&&i)throw TypeError("highlightedRange cannot define an end without a start");if(t&&i&&w(i,t)<0)throw TypeError("highlightedRange must be ordered; start must be on or before end");return{start:t,end:i}}function we(e,t){if(!t||!c(e))return"";let{start:i,end:s}=t;if(!i||!c(i))return"";if(i===e)return s?s===e?"single":"start":"start";if(s&&s===e)return"end";if(s&&w(e,i)>=0&&w(e,s)<=0)return"in";return""}class oe{constructor(){this.activeEndpoint="",this.start="",this.end=""}get range(){return{start:this.start,end:this.end}}get complete(){return Boolean(this.start&&this.end&&w(this.end,this.start)>=0)}focus(e){this.activeEndpoint=e}activate(e,t=()=>!0){if(!c(e))throw TypeError(`Invalid range activation: ${e}`);if(this.complete&&(w(e,this.start)<0||w(e,this.end)>0)){let i=w(e,this.start)<0?"start":"end";if(!t(i))return{status:"refused",endpoint:i};return this[i]=e,this.activeEndpoint=i,{status:"complete",endpoint:i}}if(this.activeEndpoint==="end"){if(this.start&&w(e,this.start)<0)return{status:"refused",endpoint:"end"};if(!t("end"))return{status:"refused",endpoint:"end"};return this.end=e,{status:this.start?"complete":"pending",endpoint:"end"}}if(!t("start"))return{status:"refused",endpoint:"start"};if(this.start=e,!t("end"))return{status:"pending",endpoint:"start",close:!0};return this.activeEndpoint="end",{status:"pending",endpoint:"start"}}}var De=/[\u200e\u200f\u061c\u202a-\u202e\u2066-\u2069]/g;function R(e=""){if(e)return e;if(typeof document<"u"&&document.documentElement.lang)return document.documentElement.lang;if(typeof navigator<"u"&&navigator.language)return navigator.language;return"en-US"}function Xe(e){let t=new Intl.NumberFormat(e,{useGrouping:!1}),i=new Map;for(let s=0;s<=9;s++)i.set(t.format(s),String(s));return i}function xe(e,t){let i=String(e||"").replace(De,"").trim();for(let[s,n]of Xe(t))i=i.split(s).join(n);return i}function G(e,t=""){let i=R(t);return new Intl.DateTimeFormat(i,{calendar:"gregory",weekday:"long",year:"numeric",month:"long",day:"numeric",timeZone:"UTC"}).format(B(e))}function ke(e,t=""){let i=R(t);return new Intl.DateTimeFormat(i,{calendar:"gregory",year:"numeric",month:"long",timeZone:"UTC"}).format(B(`${e.slice(0,7)}-15`))}function Ee(e=""){let t=R(e);try{let i=new Intl.DateTimeFormat(t,{calendar:"gregory",year:"numeric",month:"long",timeZone:"UTC"}).formatToParts(B("2026-09-15")),s=-1,n=-1;if(i.forEach((r,a)=>{let o=r.type;if(o==="month"){if(s<0)s=a}else if(o==="year"||o==="relatedYear"||o==="yearName"){if(n<0)n=a}}),s>=0&&n>=0)return n<s?["year","month"]:["month","year"]}catch{}return["month","year"]}function Te(e="",t="long"){let i=R(e),s=new Intl.DateTimeFormat(i,{calendar:"gregory",month:t,timeZone:"UTC"});return Array.from({length:12},(n,r)=>s.format(B(`2026-${String(r+1).padStart(2,"0")}-15`)))}function de(e="",t=1,i="short"){let s=R(e),n=new Intl.DateTimeFormat(s,{calendar:"gregory",weekday:i,timeZone:"UTC"}),r=j(t),a=B("2026-01-04");return Array.from({length:7},(o,l)=>{let d=new Date(a);return d.setUTCDate(a.getUTCDate()+(r+l)%7),n.format(d)})}function Ze(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function X(e=""){let t=R(e),i=new Intl.DateTimeFormat(t,{calendar:"gregory",year:"numeric",month:"2-digit",day:"2-digit",timeZone:"UTC"}),s=B("2006-11-22"),n=i.formatToParts(s).filter((d)=>d.type!=="literal"||d.value),r=n.filter((d)=>["day","month","year"].includes(d.type)).map((d)=>d.type),a=n.map((d)=>{if(d.type==="day")return"DD";if(d.type==="month")return"MM";if(d.type==="year")return"YYYY";return d.value.replace(De,"")}).join(""),o=n.map((d)=>{if(d.type==="day"||d.type==="month")return"(\\d{1,2})";if(d.type==="year")return"(\\d{4})";let u=xe(d.value,t).replace(/\s+/g," ");return Ze(u).replace(/\\ /g,"\\s*")}).join(""),l=new RegExp(`^\\s*${o}\\s*$`);return{locale:t,placeholder:a,format(d){if(!c(d))return"";return i.format(B(d))},parse(d){let u=xe(d,t);if(c(u))return u;let C=l.exec(u);if(!C)return"";let m={};if(r.forEach((b,E)=>{m[b]=Number(C[E+1])}),!m.year||!m.month||!m.day)return"";try{return U(m.year,m.month,m.day)}catch{return""}}}}var Je={chooseDate:"Choose date",changeDate:"Change date",previousMonth:"Previous month",nextMonth:"Next month",month:"Month",year:"Year",calendar:"Choose a date",unavailable:"Unavailable",invalidDate:"Enter a valid date",unavailableDate:"This date is unavailable",formatHint:"Format",week:"Week",rangeStart:"Range start",rangeInRange:"Inside range",rangeEnd:"Range end",rangeSingle:"Range of one day",rangeOrderStart:"Start must be on or before end",rangeOrderEnd:"End must be on or after start"},Qe={...Je};function W(){return{...Qe}}function Ce(e){let t=e&&typeof e==="object"&&!Array.isArray(e)&&"dates"in e?e.dates:e,i=new Map;if(Array.isArray(t)){for(let s of t){if(!s||typeof s!=="object"||!("date"in s))continue;let{date:n,...r}=s;i.set(String(n),r)}return i}if(t&&typeof t==="object")for(let[s,n]of Object.entries(t))i.set(s,n&&typeof n==="object"?n:{});return i}var et=0;function A(e){return String(e).replaceAll("&","&").replaceAll("<","<").replaceAll(">",">").replaceAll('"',""").replaceAll("'","'")}function tt(e){let t=Number(e);if(t===7)return 0;return Number.isInteger(t)&&t>=0&&t<=6?t:1}function it(e){return Number(e.slice(0,4))}function st(e){switch(e){case"single":return' data-range-start="true" data-range-end="true"';case"start":return' data-range-start="true"';case"end":return' data-range-end="true"';case"in":return' data-in-range="true"';default:return""}}function nt(e){if(e==="single")return"rangeSingle";if(e==="start")return"rangeStart";if(e==="end")return"rangeEnd";if(e==="in")return"rangeInRange";return""}class Z extends HTMLElement{static observedAttributes=["value","display","min","max","first-day","locale","fixed-weeks","show-week-numbers","selection","month-format"];constructor(){super();this._id=`date-calendar-${++et}`,this._model=new ae,this._connected=!1,this._rendering=!1,this._source=null,this._sourceStates=new Map,this._loadedRanges=new Set,this._loadController=null,this._loadingKey="",this._loadingPromise=null,this._dateState=null,this._renderDay=null,this._isDateDisabled=null,this._highlightedRange={start:"",end:""},this._messages=W(),this._onClick=this._onClick.bind(this),this._onChange=this._onChange.bind(this),this._onKeyDown=this._onKeyDown.bind(this),this._onFocusIn=this._onFocusIn.bind(this)}connectedCallback(){if(this._connected)return;this._connected=!0,this.addEventListener("click",this._onClick),this.addEventListener("change",this._onChange),this.addEventListener("keydown",this._onKeyDown),this.addEventListener("focusin",this._onFocusIn),this._syncModel(),this.render()}disconnectedCallback(){this._connected=!1,this._loadController?.abort(),this._loadController=null,this._loadingKey="",this._loadingPromise=null,this.removeEventListener("click",this._onClick),this.removeEventListener("change",this._onChange),this.removeEventListener("keydown",this._onKeyDown),this.removeEventListener("focusin",this._onFocusIn)}attributeChangedCallback(){if(!this._connected||this._rendering)return;this._syncModel(),this.render()}get locale(){return R(this.getAttribute("locale")||"")}set locale(e){if(e)this.setAttribute("locale",e);else this.removeAttribute("locale")}get value(){return this._model.value}set value(e){let t=e||"";if(t&&!c(t))throw TypeError(`Invalid calendar value: ${t}`);if(t===this._model.value)return;if(this._model.setValue(t),this._reflect("value",t),this._connected)this.render()}get display(){return this._model.display}set display(e){this._setDisplay(e,{emit:!1})}get focusedDate(){return this._model.focused}set focusedDate(e){let t=e||"";if(t===this._model.focused)return;this.focusDate(t,{moveFocus:!1})}get min(){let e=this.getAttribute("min")||"";return c(e)?e:""}set min(e){if(e)this.setAttribute("min",e);else this.removeAttribute("min")}get max(){let e=this.getAttribute("max")||"";return c(e)?e:""}set max(e){if(e)this.setAttribute("max",e);else this.removeAttribute("max")}get firstDay(){return tt(this.getAttribute("first-day")||"1")}set firstDay(e){this.setAttribute("first-day",String(e))}get selection(){return this.getAttribute("selection")==="none"?"none":"single"}set selection(e){this.setAttribute("selection",e==="none"?"none":"single")}get monthFormat(){return this.getAttribute("month-format")==="short"?"short":"long"}set monthFormat(e){if(e==="short")this.setAttribute("month-format","short");else this.removeAttribute("month-format")}get highlightedRange(){return{...this._highlightedRange}}set highlightedRange(e){let t=ne(e);if(t.start===this._highlightedRange.start&&t.end===this._highlightedRange.end)return;if(this._highlightedRange=t,this._connected)this.render()}get fixedWeeks(){return this.hasAttribute("fixed-weeks")}set fixedWeeks(e){this.toggleAttribute("fixed-weeks",Boolean(e))}get showWeekNumbers(){return this.hasAttribute("show-week-numbers")}set showWeekNumbers(e){this.toggleAttribute("show-week-numbers",Boolean(e))}get messages(){return this._messages}set messages(e){if(this._messages={...W(),...e||{}},this._connected)this.render()}get source(){return this._source}set source(e){this._source=e||null,this.refreshSource()}get dateState(){return this._dateState}set dateState(e){if(this._dateState=typeof e==="function"?e:null,this._connected)this.render()}get renderDay(){return this._renderDay}set renderDay(e){if(this._renderDay=typeof e==="function"?e:null,this._connected)this.render()}get isDateDisabled(){return this._isDateDisabled}set isDateDisabled(e){if(this._isDateDisabled=typeof e==="function"?e:null,this._connected)this.render()}_syncModel(){let e=this.firstDay;this._model.firstDay=e;let t=this.getAttribute("value")||"";if(!t||c(t))this._model.value=t;let i=this.getAttribute("display")||"";if(i)try{this._model.setDisplay(i)}catch{}else if(this._model.value)this._model.display=f(this._model.value),this._model.focused=this._model.value;if(this._model.focused=this._clamp(this._model.focused),!this.getAttribute("display"))this._model.display=f(this._model.focused)}_reflect(e,t){if(this._rendering=!0,t){if(this.getAttribute(e)!==t)this.setAttribute(e,t)}else if(this.hasAttribute(e))this.removeAttribute(e);this._rendering=!1}_clamp(e){return be(e,this.min,this.max)}_weeks(e=this.display){let t=ye(e,{firstDay:this.firstDay});if(!this.fixedWeeks||t.length>=6)return t;let i=t[t.length-1]?.[6]||"";while(t.length<6&&i){let s=[];for(let n=1;n<=7;n++)s.push(L(i,n));t.push(s),i=s[6]}return t}_focusTargetKey(e){if(e.matches(".dp-month-select, .dp-year-input")&&e.id)return`#${CSS.escape(e.id)}`;if(e.matches(".dp-nav[data-calendar-action]"))return`.dp-nav[data-calendar-action="${CSS.escape(e.dataset.calendarAction||"")}"]`;if(e.matches(".dp-day[data-date]")){let t=e.getAttribute("data-date")||"";if(c(t))return`.dp-day[data-date="${t}"]`}return""}_range(e=this.display){let t=this._weeks(e),i=t[0],s=t[t.length-1];if(!i||!s)throw Error("Calendar month produced no weeks");return{start:i[0],end:s[6]}}getDateState(e){let t=this._sourceStates.get(e)||{},i=this._dateState?.(e,{...t})||{},s={...t,...i},n=this.min&&w(e,this.min)<0||this.max&&w(e,this.max)>0,a=s.enabled===!0?!1:Boolean(this._isDateDisabled?.(e)),o=Boolean(n)||Boolean(s.disabled)||a;return{...s,disabled:o}}async refreshSource(){if(this._loadController?.abort(),this._loadController=null,this._loadingKey="",this._loadingPromise=null,this._loadedRanges.clear(),this._sourceStates.clear(),this._connected)this.render(),await this._loadDisplay(this.display)}async ensureDate(e){if(!c(e)||!this._source)return!0;return await this._loadDisplay(f(e),!1)==="loaded"}async _loadDisplay(e,t=!0){if(!this._source)return"loaded";let i=this._range(e),s=`${i.start}/${i.end}`;if(this._loadedRanges.has(s))return"loaded";if(s===this._loadingKey&&this._loadingPromise)return this._loadingPromise;this._loadController?.abort();let n=new AbortController;this._loadController=n,this._loadingKey=s;let r=this._source,a=(async()=>{this.toggleAttribute("data-loading",!0),this.dispatchEvent(new CustomEvent("dateloadstart",{detail:i,bubbles:!0}));try{let o=typeof r==="function"?r:r?.load?.bind(r);if(!o)throw TypeError("Date source must be a function or expose load(range, { signal })");let l=await o(i,{signal:n.signal});if(n.signal.aborted)return"cancelled";for(let[d,u]of Ce(l))this._sourceStates.set(d,u);if(this._loadedRanges.add(s),this.dispatchEvent(new CustomEvent("dateloadend",{detail:i,bubbles:!0})),t&&this._connected&&f(this.display)===f(e))this.render(!1);return"loaded"}catch(o){if(n.signal.aborted)return"cancelled";return this.dispatchEvent(new CustomEvent("dateloaderror",{detail:{...i,error:o},bubbles:!0})),"failed"}finally{if(this._loadController===n)this._loadController=null,this.removeAttribute("data-loading");if(this._loadingKey===s)this._loadingKey="",this._loadingPromise=null}})();return this._loadingPromise=a,a}_setDisplay(e,t={}){let i=this._model.display;if(this._model.setDisplay(e),this._model.focused=this._clamp(this._model.focused),this._model.display=f(this._model.focused),this._reflect("display",this._model.display),this._connected)this.render();if(t.emit!==!1&&i!==this._model.display)this._emitDisplayChange();return this._model.display}_emitDisplayChange(){let e=this._range();this.dispatchEvent(new CustomEvent("displaychange",{detail:{display:this.display,...e},bubbles:!0}))}previousMonth(){return this._setDisplay(P(this.display,-1))}nextMonth(){return this._setDisplay(P(this.display,1))}focusDate(e,t={}){if(!c(e))throw TypeError(`Invalid date: ${e}`);let i=this._clamp(e),s=this.display,n=this._model.focused,r=t.moveFocus!==!1;if(this._model.setFocused(i),this._reflect("display",this._model.display),s!==this.display){if(this._connected)this.render();this._emitDisplayChange()}else if(this._connected&&n!==this._model.focused)this._moveFocusDom(n,this._model.focused,r);if(r)queueMicrotask(()=>this.focusGrid())}_moveFocusDom(e,t,i=!0){let s=e?this.querySelector(`.dp-day[data-date="${CSS.escape(e)}"]`):null,n=this.querySelector(`.dp-day[data-date="${CSS.escape(t)}"]`);if(s instanceof HTMLElement)s.tabIndex=-1;if(n instanceof HTMLElement){if(n.tabIndex=0,i)n.focus()}else if(i)this.focusGrid()}_moveSelectionDom(e,t){if(e){let i=this.querySelector(`.dp-day[data-date="${CSS.escape(e)}"]`);if(i instanceof HTMLElement)i.removeAttribute("data-selected"),i.removeAttribute("aria-selected")}if(t){let i=this.querySelector(`.dp-day[data-date="${CSS.escape(t)}"]`);if(i instanceof HTMLElement)return i.setAttribute("data-selected","true"),i.setAttribute("aria-selected","true"),!0}return!1}focusGrid(){let e=this.querySelector(`.dp-day[data-date="${CSS.escape(this.focusedDate)}"]`);if(e instanceof HTMLElement)e.focus()}async _activate(e){let t=await this.ensureDate(e),i=this.getDateState(e);if(!t||i.disabled)return this.dispatchEvent(new CustomEvent("dateinvalid",{detail:{date:e,state:i},bubbles:!0})),!1;if(!this.dispatchEvent(new CustomEvent("dateactivate",{detail:{date:e,state:i},bubbles:!0,cancelable:!0})))return!1;if(this.selection==="single"){let n=this._model.value;if(this._model.setValue(e),this._reflect("value",e),this.dispatchEvent(new CustomEvent("datechange",{detail:{value:e},bubbles:!0})),this.dispatchEvent(new Event("change",{bubbles:!0})),this._connected)if(f(e)===this.display)this._moveSelectionDom(n,e);else this.render()}else if(this._connected){if(f(e)!==this.display)this.render()}return!0}_onClick(e){let t=e.target;if(!(t instanceof Element))return;let i=t.closest("[data-calendar-action]");if(i instanceof HTMLButtonElement){let a=i.dataset.calendarAction;if(a==="previous")this.previousMonth();if(a==="next")this.nextMonth();return}let s=t.closest(".dp-day[data-date]");if(!(s instanceof HTMLTableCellElement))return;let n=s.dataset.date||"";if(!c(n))return;let r=this.display;if(this._model.setFocused(this._clamp(n)),this._reflect("display",this._model.display),r!==this.display)this._emitDisplayChange();this._activate(n)}_onChange(e){let t=e.target;if(t instanceof HTMLSelectElement&&t.matches(".dp-month-select")){this._setDisplay(`${this.display.slice(0,4)}-${t.value}`);return}if(t instanceof HTMLInputElement&&t.matches(".dp-year-input")){let i=Number(t.value);if(!Number.isInteger(i)||i<1||i>9999){if(this._connected)this.render(!1);return}this._setDisplay(`${String(i).padStart(4,"0")}-${this.display.slice(5,7)}`)}}_onFocusIn(e){let t=e.target;if(!(t instanceof HTMLTableCellElement)||!t.matches(".dp-day[data-date]"))return;let i=t.dataset.date||"";if(c(i))this._model.focused=i}_onKeyDown(e){let t=e.target;if(!(t instanceof HTMLTableCellElement)||!t.matches(".dp-day[data-date]"))return;let i=t.dataset.date||this.focusedDate;if(e.key==="Enter"||e.key===" "){e.preventDefault(),this._activate(i);return}let s=this._model.focused,n=this._model.display;if(this._model.firstDay=this.firstDay,this._model.setFocused(i,{follow:!1}),e.key==="ArrowLeft")this._model.moveFocusDays(-1);else if(e.key==="ArrowRight")this._model.moveFocusDays(1);else if(e.key==="ArrowUp")this._model.moveFocusDays(-7);else if(e.key==="ArrowDown")this._model.moveFocusDays(7);else if(e.key==="Home")this._model.focusWeekStart();else if(e.key==="End")this._model.focusWeekEnd();else if(e.key==="PageUp")e.shiftKey?this._model.moveFocusYears(-1):this._model.moveFocusMonths(-1);else if(e.key==="PageDown")e.shiftKey?this._model.moveFocusYears(1):this._model.moveFocusMonths(1);else return;let r=this._model.focused;if(this._model.focused=s,this._model.display=n,!r)return;e.preventDefault(),this.focusDate(this._clamp(r))}render(e=!0){if(!this._connected)return;let t=this.locale,i=this.display,s=it(i),n=Number(i.slice(5,7)),r=Te(t,this.monthFormat),a=de(t,this.firstDay,"short"),o=de(t,this.firstDay,"long"),l=this._weeks(),d=O(),u=`${this._id}-heading`,C=`${this._id}-grid`,m=this.min?f(this.min):"",b=this.max?f(this.max):"",E=Boolean(m&&P(i,-1)<m),S=Boolean(b&&P(i,1)>b),x=this.min?` min="${Number(this.min.slice(0,4))}"`:"",_=this.max?` max="${Number(this.max.slice(0,4))}"`:"",g=this.showWeekNumbers&&this.firstDay===1,T=g?`<th scope="col" class="dp-week-heading" abbr="${A(this._messages.week)}">#</th>`:"",v=r.map((D,k)=>{let p=k+1,h=`${String(s).padStart(4,"0")}-${String(p).padStart(2,"0")}`,y=m&&h<m||b&&h>b;return`<option value="${String(p).padStart(2,"0")}"${p===n?" selected":""}${y?" disabled":""}>${A(D)}</option>`}).join(""),H=a.map((D,k)=>`<th scope="col" abbr="${A(o[k])}">${A(D.replace(".",""))}</th>`).join(""),Y=l.map((D)=>{let k=g?`<th scope="row" class="dp-week-number">${ve(D[0])}</th>`:"",p=D.map((h)=>{let y=this.getDateState(h),M=f(h)!==i,F=this.value===h,K=this.focusedDate===h,fe=h===d,pe=we(h,this._highlightedRange),me=nt(pe),Be=typeof y.description==="string"?y.description:"",Pe=[G(h,t),Be,me?this._messages[me]:"",y.disabled?this._messages.unavailable:""].filter(Boolean).join(". ");return`<td class="dp-day" data-date="${h}"${M?' data-outside-month="true"':""}${fe?' data-today="true" aria-current="date"':""}${F?' data-selected="true" aria-selected="true"':""}${st(pe)}${y.disabled?' data-disabled="true" aria-disabled="true"':""} tabindex="${K?"0":"-1"}" aria-label="${A(Pe)}"><span class="dp-day-number" aria-hidden="true">${Number(h.slice(8,10))}</span><span class="dp-day-extra" aria-hidden="true"></span></td>`}).join("");return`<tr>${k}${p}</tr>`}).join(""),z=document.activeElement,V=z instanceof HTMLElement&&this.contains(z)?this._focusTargetKey(z):"",q=Ee(t)[0]==="year";this.toggleAttribute("data-year-first",q);let N=`<label class="dp-visually-hidden" for="${this._id}-month">${A(this._messages.month)}</label>
|
|
491
|
-
<select id="${this._id}-month" class="dp-month-select" aria-label="${A(this._messages.month)}">${
|
|
492
|
-
<input id="${this._id}-year" class="dp-year-input" type="number" inputmode="numeric" value="${
|
|
495
|
+
`;var rt=/^(\d{4})-(\d{2})-(\d{2})$/,at=/^(\d{4})-(\d{2})$/;function ot(e){return e%4===0&&(e%100!==0||e%400===0)}function Q(e,t){if(t===2)return ot(e)?29:28;return[4,6,9,11].includes(t)?30:31}function L(e){let t=rt.exec(String(e||""));if(!t)return null;let i=Number(t[1]),n=Number(t[2]),s=Number(t[3]);if(i<1||i>9999||n<1||n>12)return null;if(s<1||s>Q(i,n))return null;return{year:i,month:n,day:s}}function d(e){return L(e)!==null}function f(e){let t=String(e||""),i=at.exec(t);if(i){let s=Number(i[2]);if(s>=1&&s<=12)return`${i[1]}-${String(s).padStart(2,"0")}`}let n=L(t);if(!n)throw TypeError(`Invalid civil date/month: ${e}`);return`${String(n.year).padStart(4,"0")}-${String(n.month).padStart(2,"0")}`}function B(e,t,i){let n=`${String(e).padStart(4,"0")}-${String(t).padStart(2,"0")}-${String(i).padStart(2,"0")}`;if(!d(n))throw TypeError(`Invalid civil date: ${n}`);return n}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 dt(e){return B(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 i=L(e);if(!i||!Number.isInteger(t))throw TypeError("addDays() expects a date and integer amount");let n=H(i);return n.setUTCDate(n.getUTCDate()+t),dt(n)}function oe(e,t){let i=L(e);if(!i||!Number.isInteger(t))throw TypeError("addMonths() expects a date and integer amount");let n=i.year*12+(i.month-1)+t,s=Math.floor(n/12),a=(n%12+12)%12+1,o=Math.min(i.day,Q(s,a));return B(s,a,o)}function Te(e,t){let i=L(e);if(!i||!Number.isInteger(t))throw TypeError("addYears() expects a date and integer amount");let n=i.year+t,s=Math.min(i.day,Q(n,i.month));return B(n,i.month,s)}function J(e,t){let i=`${f(e)}-01`;return f(oe(i,t))}function lt(e){return`${f(e)}-01`}function ge(e){let t=L(`${f(e)}-01`);if(!t)throw TypeError(`Invalid month: ${e}`);return B(t.year,t.month,Q(t.year,t.month))}function ct(e){let t=L(e);if(!t)throw TypeError(`Invalid civil date: ${e}`);return H(t).getUTCDay()}function j(e){if(e===7)return 0;if(!Number.isInteger(e)||e<0||e>6)throw RangeError("firstDay must be 0..6 (Sunday=0, 7 accepted as Sunday alias)");return e}function de(e,t=1){let i=(ct(e)-j(t)+7)%7;return F(e,-i)}function _e(e,t=1){return F(de(e,t),6)}function Se(e,t={}){let i=t.firstDay??1,n=de(lt(e),i),s=_e(ge(e),i),r=[],a=n;for(;;){let o=[];for(let c=0;c<7;c++)o.push(F(a,c));if(r.push(o),g(o[6],s)>=0){if(!t.fixedWeeks||r.length>=6||g(o[6],F("9999-12-31",-7))>0)break}a=F(a,7)}return r}function Ae(e,t,i){let n=H({year:1,month:1,day:1});return Math.round((H({year:e,month:t,day:i}).getTime()-n.getTime())/86400000)}function ee(e,t=1){let i=j(t),n=Ae(9999,12,31),s=f(e);for(;;){let r=L(`${s}-01`);if(!r)throw TypeError(`Invalid civil date/month: ${e}`);let a=Ae(r.year,r.month,1),o=(H(r).getUTCDay()-i+7)%7;if(a-o<0){s=J(s,1);continue}let c=Q(r.year,r.month),l={year:r.year,month:r.month,day:c},h=a+c-1,b=(H(l).getUTCDay()-i+7)%7;if(h-b+6>n){s=J(s,-1);continue}return s}}function Me(e,t="",i=""){if(!d(e))throw TypeError(`Invalid civil date: ${e}`);if(t&&g(e,t)<0)return t;if(i&&g(e,i)>0)return i;return e}function R(){let e=new Date;return B(e.getFullYear(),e.getMonth()+1,e.getDate())}function $e(e){let t=L(e);if(!t)throw TypeError(`Invalid civil date: ${e}`);let i=H(t),n=i.getUTCDay()||7;i.setUTCDate(i.getUTCDate()+4-n);let s=new Date(0);return s.setUTCHours(12,0,0,0),s.setUTCFullYear(i.getUTCFullYear(),0,1),Math.ceil(((i.getTime()-s.getTime())/86400000+1)/7)}class ye{constructor(e={}){let t=R();this.firstDay=j(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),i=Number(this.focused.slice(8,10))||1,n=oe(`${t}-01`,0),s=F(n,Math.max(0,i-1));return this.focused=f(s)===t?s:F(`${J(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(oe(this.focused,e))}moveFocusYears(e){return this.setFocused(Te(this.focused,e))}focusWeekStart(){return this.setFocused(de(this.focused,this.firstDay))}focusWeekEnd(){return this.setFocused(_e(this.focused,this.firstDay))}navigateMonth(e){let t=J(this.display,e);return this.setDisplay(t),this.display}}function ht(e){if(typeof e!=="string")return"";return[...new Set(e.split(/\s+/).filter((t)=>t&&!t.startsWith("dp-")&&![...t].some((i)=>i.charCodeAt(0)<32||i.charCodeAt(0)===127)))].join(" ")}function le(e,t){return e.month===t.month&&e.year===t.year&&e.nav===t.nav}var ut={month:"",year:"",nav:""};function te(){return{...ut}}function ce(e){let t=te();for(let i of["month","year","nav"])if(e&&Object.hasOwn(e,i))t[i]=ht(e[i]);return t}function he(e){if(e==null)return{start:"",end:""};if(typeof e!=="object")throw TypeError("highlightedRange expects { start, end }");let{start:t="",end:i=""}=e;if(t&&!d(t))throw TypeError(`Invalid range start: ${t}`);if(i&&!d(i))throw TypeError(`Invalid range end: ${i}`);if(!t&&i)throw TypeError("highlightedRange cannot define an end without a start");if(t&&i&&g(i,t)<0)throw TypeError("highlightedRange must be ordered; start must be on or before end");return{start:t,end:i}}function ue(e,t){if(!t||!d(e))return"";let{start:i,end:n}=t;if(!i||!d(i))return"";if(i===e)return n?n===e?"single":"start":"start";if(n&&n===e)return"end";if(n&&g(e,i)>=0&&g(e,n)<=0)return"in";return""}class be{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:i,end:n}=this;if(this.complete&&(g(e,i)<0||g(e,n)>0)){let r=g(e,i)<0?"start":"end";if(!t(r))return this._refuse(r);return{status:"complete",endpoint:r,changedEndpoints:[r],range:r==="start"?{start:e,end:n}:{start:i,end:e},activeEndpoint:r}}if(this.activeEndpoint==="end"){if(i&&!n&&g(e,i)<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:i},activeEndpoint:"end"}}if(i&&g(e,i)<0)return this._refuse("end");if(!t("end"))return this._refuse("end");return{status:i?"complete":"pending",endpoint:"end",changedEndpoints:["end"],range:{start:i,end:e},activeEndpoint:"end"}}if(n&&!i&&g(e,n)>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:n,end:e},activeEndpoint:"start"}}if(!t("start"))return this._refuse("start");let s=t("end");return{status:"pending",endpoint:"start",changedEndpoints:["start"],range:{start:e,end:n},activeEndpoint:s?"end":this.activeEndpoint,...s?{}:{close:!0}}}projectEndpoint(e,t,i=()=>!0){if(!d(e))throw TypeError(`Invalid range activation: ${e}`);if(!this.complete||!i(t))return this._refuse(t);let{start:n,end:s}=this,r=t==="start"?n:s,a=t==="start"?pt(e,s):ft(e,n);return{status:"complete",endpoint:t,changedEndpoints:a===r?[]:[t],range:t==="start"?{start:a,end:s}:{start:n,end:a},activeEndpoint:t}}previewRange(e,t="",i=()=>!0){if(!d(e))return null;if(!t&&Boolean(this.start)===Boolean(this.end))return null;let n=t?this.projectEndpoint(e,t,i):this.project(e,i);if(n.status==="refused")return null;let{start:s,end:r}=n.range;if(!s||r&&g(r,s)<0)return null;return{start:s,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,i=()=>!0){return this._apply(this.projectEndpoint(e,t,i))}}function ft(e,t){if(!e)return t;if(!t)return e;return g(e,t)>=0?e:t}function pt(e,t){if(!e)return t;if(!t)return e;return g(e,t)<=0?e:t}var Le=/[\u200e\u200f\u061c\u202a-\u202e\u2066-\u2069]/g,mt=new Map,gt=new Map;function Ie(e,t,i){let n=e.get(t);if(n!==void 0)return n;let s=i(),r=e.keys().next().value;if(e.size>=64&&r!==void 0)e.delete(r);return e.set(t,s),s}function Y(e,t){let i=JSON.stringify([e,t]);return Ie(mt,i,()=>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 _t(e){return Ie(gt,e,()=>{let t=new Intl.NumberFormat(e,{useGrouping:!1}),i=new Map;for(let n=0;n<=9;n++)i.set(t.format(n),String(n));return i})}function Fe(e,t,i={}){let n=String(e||"").replace(Le,"");if(i.trim!==!1)n=n.trim();for(let[s,r]of _t(t))n=n.split(s).join(r);return n}function ie(e,t=""){let i=P(t);return Y(i,{calendar:"gregory",weekday:"long",year:"numeric",month:"long",day:"numeric",timeZone:"UTC"}).format(V(e))}function Oe(e,t=""){let i=P(t);return Y(i,{calendar:"gregory",year:"numeric",month:"long",timeZone:"UTC"}).format(V(`${e.slice(0,7)}-15`))}function Re(e=""){let t=P(e);try{let i=Y(t,{calendar:"gregory",year:"numeric",month:"long",timeZone:"UTC"}).formatToParts(V("2026-09-15")),n=-1,s=-1;if(i.forEach((r,a)=>{let o=r.type;if(o==="month"){if(n<0)n=a}else if(o==="year"||o==="relatedYear"||o==="yearName"){if(s<0)s=a}}),n>=0&&s>=0)return s<n?["year","month"]:["month","year"]}catch{}return["month","year"]}function Pe(e="",t="long"){let i=P(e),n=Y(i,{calendar:"gregory",month:t,timeZone:"UTC"});return Array.from({length:12},(s,r)=>n.format(V(`2026-${String(r+1).padStart(2,"0")}-15`)))}function ve(e="",t=1,i="short"){let n=P(e),s=Y(n,{calendar:"gregory",weekday:i,timeZone:"UTC"}),r=j(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),s.format(l)})}function yt(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function ne(e=""){let t=P(e),i=Y(t,{calendar:"gregory",year:"numeric",month:"2-digit",day:"2-digit",timeZone:"UTC"}),n=V("2006-11-22"),s=i.formatToParts(n).filter((l)=>l.type!=="literal"||l.value),r=s.filter((l)=>["day","month","year"].includes(l.type)).map((l)=>l.type),a=s.map((l)=>{if(l.type==="day")return"DD";if(l.type==="month")return"MM";if(l.type==="year")return"YYYY";return l.value.replace(Le,"")}).join(""),o=s.map((l)=>{if(l.type==="day"||l.type==="month")return"(\\d{1,2})";if(l.type==="year")return"(\\d{4})";let h=Fe(l.value,t,{trim:!1});return yt(h).replace(/\s+/g,"\\s*")}).join(""),c=new RegExp(`^\\s*${o}\\s*$`);return{locale:t,placeholder:a,format(l){if(!d(l))return"";return i.format(V(l))},parse(l){let h=Fe(l,t);if(d(h))return h;let b=c.exec(h);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 B(D.year,D.month,D.day)}catch{return""}}}}var bt={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"},vt={...bt};function G(){return{...vt}}function ze(e){let t=e&&typeof e==="object"&&!Array.isArray(e)&&"dates"in e?e.dates:e,i=new Map;if(Array.isArray(t)){for(let n of t){if(!n||typeof n!=="object"||!("date"in n))continue;let{date:s,...r}=n;i.set(String(s),r)}return i}if(t&&typeof t==="object")for(let[n,s]of Object.entries(t))i.set(n,s&&typeof s==="object"?s:{});return i}var wt=0;function A(e){return String(e).replaceAll("&","&").replaceAll("<","<").replaceAll(">",">").replaceAll('"',""").replaceAll("'","'")}function Dt(e){let t=Number(e);if(t===7)return 0;return Number.isInteger(t)&&t>=0&&t<=6?t:1}function xt(e){return Number(e.slice(0,4))}function fe(e,t){let[i,n]=e.split("-").map(Number),s=i*12+(n-1)+t,r=Math.floor(s/12),a=(s%12+12)%12+1;if(r<1||r>9999)return null;return`${String(r).padStart(4,"0")}-${String(a).padStart(2,"0")}`}function He(e){return{"data-range-start":e==="start"||e==="single","data-range-end":e==="end"||e==="single","data-in-range":e==="in"}}function Et(e){return Object.entries(He(e)).filter(([,t])=>t).map(([t])=>` ${t}="true"`).join("")}function kt(e){if(e==="single")return"rangeSingle";if(e==="start")return"rangeStart";if(e==="end")return"rangeEnd";if(e==="in")return"rangeInRange";return""}class se extends HTMLElement{static observedAttributes=["value","display","min","max","first-day","locale","fixed-weeks","show-week-numbers","selection","month-format"];constructor(){super();this._id=`date-calendar-${++wt}`,this._model=new ye,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=G(),this._controlClasses=te(),this._onClick=this._onClick.bind(this),this._onChange=this._onChange.bind(this),this._onKeyDown=this._onKeyDown.bind(this),this._onFocusIn=this._onFocusIn.bind(this)}connectedCallback(){if(this._connected)return;this._connected=!0,this.addEventListener("click",this._onClick),this.addEventListener("change",this._onChange),this.addEventListener("keydown",this._onKeyDown),this.addEventListener("focusin",this._onFocusIn),this._syncModel(),this.render()}disconnectedCallback(){this._connected=!1,this._loadController?.abort(),this._loadController=null,this._loadingKey="",this._loadingPromise=null,this.removeEventListener("click",this._onClick),this.removeEventListener("change",this._onChange),this.removeEventListener("keydown",this._onKeyDown),this.removeEventListener("focusin",this._onFocusIn)}attributeChangedCallback(){if(!this._connected||this._rendering)return;this._syncModel(),this.render()}get locale(){return 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 Dt(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=he(e),i=this.hasAttribute("data-range-preview");if(t.start===this._paintedRange.start&&t.end===this._paintedRange.end&&i===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{...this._controlClasses}}set controlClasses(e){let t=ce(e);if(le(t,this._controlClasses))return;if(this._controlClasses=t,this._connected)this.render()}get messages(){return this._messages}set messages(e){if(this._messages={...G(),...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 i=this.getAttribute("display")||"";if(i)try{this._model.setDisplay(ee(i,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=Me(e,this.min,this.max),i=f(t),n=ee(i,this.firstDay);if(n===i)return t;let s=Number(t.slice(8,10))||1,r=F(`${n}-01`,s-1),a=ge(n);return g(r,a)>0?a:r}_weeks(e=this.display){return Se(ee(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),i=t[0],n=t[t.length-1];if(!i||!n)throw Error("Calendar month produced no weeks");return{start:i[0],end:n[6]}}getDateState(e){let t=this._sourceStates.get(e)||{},i=this._dateState?.(e,{...t})||{},n={...t,...i},s=this.min&&g(e,this.min)<0||this.max&&g(e,this.max)>0,a=n.enabled===!0?!1:Boolean(this._isDateDisabled?.(e)),o=Boolean(s)||Boolean(n.disabled)||a;return{...n,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 i=this._range(e),n=`${i.start}/${i.end}`;if(this._loadedRanges.has(n))return"loaded";if(n===this._loadingKey&&this._loadingPromise)return this._loadingPromise;this._loadController?.abort();let s=new AbortController;this._loadController=s,this._loadingKey=n;let r=this._source,a=(async()=>{this.toggleAttribute("data-loading",!0),this.dispatchEvent(new CustomEvent("dateloadstart",{detail:i,bubbles:!0}));try{let o=typeof r==="function"?r:r?.load?.bind(r);if(!o)throw TypeError("Date source must be a function or expose load(range, { signal })");let c=await o(i,{signal:s.signal});if(s.signal.aborted)return"cancelled";for(let[l,h]of ze(c))this._sourceStates.set(l,h);if(this._loadedRanges.add(n),this.dispatchEvent(new CustomEvent("dateloadend",{detail:i,bubbles:!0})),t&&this._connected&&f(this.display)===f(e))this.render(!1);return"loaded"}catch(o){if(s.signal.aborted)return"cancelled";return this.dispatchEvent(new CustomEvent("dateloaderror",{detail:{...i,error:o},bubbles:!0})),"failed"}finally{if(this._loadController===s)this._loadController=null,this.removeAttribute("data-loading");if(this._loadingKey===n)this._loadingKey="",this._loadingPromise=null}})();return this._loadingPromise=a,a}_setDisplay(e,t={}){let i=this._model.display;if(this._model.setDisplay(ee(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&&i!==this._model.display)this._emitDisplayChange();return this._model.display}_emitDisplayChange(){let e=this._range();this.dispatchEvent(new CustomEvent("displaychange",{detail:{display:this.display,...e},bubbles:!0}))}previousMonth(){return this._setDisplay(fe(this.display,-1)??this.display)}nextMonth(){return this._setDisplay(fe(this.display,1)??this.display)}focusDate(e,t={}){if(!d(e))throw TypeError(`Invalid date: ${e}`);let i=this._clamp(e),n=this.display,s=this._model.focused,r=t.moveFocus!==!1;if(this._model.setFocused(i),this._reflect("display",this._model.display),n!==this.display){if(this._connected)this.render();this._emitDisplayChange()}else if(this._connected&&s!==this._model.focused)this._moveFocusDom(s,this._model.focused,r);if(r)queueMicrotask(()=>this.focusGrid())}_moveFocusDom(e,t,i=!0){let n=e?this.querySelector(`.dp-day[data-date="${CSS.escape(e)}"]`):null,s=this.querySelector(`.dp-day[data-date="${CSS.escape(t)}"]`);if(n instanceof HTMLElement)n.tabIndex=-1;if(s instanceof HTMLElement){if(s.tabIndex=0,i)s.focus()}else if(i)this.focusGrid()}_moveSelectionDom(e,t){if(e){let i=this.querySelector(`.dp-day[data-date="${CSS.escape(e)}"]`);if(i instanceof HTMLElement)i.removeAttribute("data-selected"),i.removeAttribute("aria-selected")}if(t){let i=this.querySelector(`.dp-day[data-date="${CSS.escape(t)}"]`);if(i instanceof HTMLElement)return i.setAttribute("data-selected","true"),i.setAttribute("aria-selected","true"),!0}return!1}_dayLabel(e,t,i){let n=this.hasAttribute("data-range-preview")?"":kt(i),s=typeof t.description==="string"?t.description:"";return[ie(e,this.locale),s,n?this._messages[n]:"",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 i of this.querySelectorAll(".dp-day[data-date]")){if(!(i instanceof HTMLTableCellElement))continue;let n=i.dataset.date||"",s=ue(n,this._highlightedRange);if(s===ue(n,e)&&t===this._paintedPreview)continue;for(let[r,a]of Object.entries(He(s)))if(a)i.setAttribute(r,"true");else i.removeAttribute(r);if(!t||!this._paintedPreview){let r=this._renderedStates.get(n)||{},a=this._dayLabel(n,r,s);if(i.getAttribute("aria-label")!==a)i.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),i=this.getDateState(e);if(!t||i.disabled)return this.dispatchEvent(new CustomEvent("dateinvalid",{detail:{date:e,state:i},bubbles:!0})),!1;if(!this.dispatchEvent(new CustomEvent("dateactivate",{detail:{date:e,state:i},bubbles:!0,cancelable:!0})))return!1;if(this.selection==="single"){let s=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(s,e);else this.render()}else if(this._connected){if(f(e)!==this.display)this.render()}return!0}_onClick(e){let t=e.target;if(!(t instanceof Element))return;let i=t.closest("[data-calendar-action]");if(i instanceof HTMLButtonElement){let a=i.dataset.calendarAction;if(a==="previous")this.previousMonth();if(a==="next")this.nextMonth();return}let n=t.closest(".dp-day[data-date]");if(!(n instanceof HTMLTableCellElement))return;let s=n.dataset.date||"";if(!d(s))return;let r=this.display;if(this._model.setFocused(this._clamp(s)),this._reflect("display",this._model.display),r!==this.display)this._emitDisplayChange();this.activateDate(s)}_onChange(e){let t=e.target;if(t instanceof HTMLSelectElement&&t.matches(".dp-month-select")){this._setDisplay(`${this.display.slice(0,4)}-${t.value}`);return}if(t instanceof HTMLInputElement&&t.matches(".dp-year-input")){let i=Number(t.value);if(!Number.isInteger(i)||i<1||i>9998){if(this._connected)this.render(!1);return}this._setDisplay(`${String(i).padStart(4,"0")}-${this.display.slice(5,7)}`)}}_onFocusIn(e){let t=e.target;if(!(t instanceof HTMLTableCellElement)||!t.matches(".dp-day[data-date]"))return;let i=t.dataset.date||"";if(!d(i))return;this._model.focused=i,this.dispatchEvent(new CustomEvent("datefocus",{detail:{date:i,state:this.getDateState(i)},bubbles:!0}))}_onKeyDown(e){let t=e.target;if(!(t instanceof HTMLTableCellElement)||!t.matches(".dp-day[data-date]"))return;let i=t.dataset.date||this.focusedDate;if(e.key==="Enter"||e.key===" "){e.preventDefault(),this.activateDate(i);return}let n=this._model.focused,s=this._model.display;if(this._model.firstDay=this.firstDay,this._model.setFocused(i,{follow:!1}),e.key==="ArrowLeft")this._model.moveFocusDays(-1);else if(e.key==="ArrowRight")this._model.moveFocusDays(1);else if(e.key==="ArrowUp")this._model.moveFocusDays(-7);else if(e.key==="ArrowDown")this._model.moveFocusDays(7);else if(e.key==="Home")this._model.focusWeekStart();else if(e.key==="End")this._model.focusWeekEnd();else if(e.key==="PageUp")e.shiftKey?this._model.moveFocusYears(-1):this._model.moveFocusMonths(-1);else if(e.key==="PageDown")e.shiftKey?this._model.moveFocusYears(1):this._model.moveFocusMonths(1);else return;let r=this._model.focused;if(this._model.focused=n,this._model.display=s,!r)return;e.preventDefault(),this.focusDate(this._clamp(r))}render(e=!0){if(!this._connected)return;let t=this.locale,i=this.display,n=xt(i),s=Number(i.slice(5,7)),r=Pe(t,this.monthFormat),a=ve(t,this.firstDay,"short"),o=ve(t,this.firstDay,"long"),c=this._weeks(),l=R(),h=`${this._id}-heading`,b=`${this._id}-grid`,D=this.min?f(this.min):"",x=this.max?f(this.max):"",T=fe(i,-1),S=fe(i,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((u,m)=>{let w=m+1,p=`${String(n).padStart(4,"0")}-${String(w).padStart(2,"0")}`,Z=D&&p<D||x&&p>x;return`<option value="${String(w).padStart(2,"0")}"${w===s?" selected":""}${Z?" disabled":""}>${A(u)}</option>`}).join(""),I=a.map((u,m)=>`<th scope="col" abbr="${A(o[m])}">${A(u.replace(".",""))}</th>`).join("");this._renderedStates.clear();let N=c.map((u)=>{let m=C?`<th scope="row" class="dp-week-number">${$e(u[0])}</th>`:"",w=u.map((p)=>{let Z=this.getDateState(p);this._renderedStates.set(p,Z);let Qe=f(p)!==i,et=this.value===p,tt=this.focusedDate===p,it=p===l,ke=ue(p,this._highlightedRange),nt=this._dayLabel(p,Z,ke);return`<td class="dp-day" data-date="${p}"${Qe?' data-outside-month="true"':""}${it?' data-today="true" aria-current="date"':""}${et?' data-selected="true" aria-selected="true"':""}${Et(ke)}${Z.disabled?' data-disabled="true" aria-disabled="true"':""} tabindex="${tt?"0":"-1"}" aria-label="${A(nt)}"><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(""),W=document.activeElement,K=W instanceof HTMLElement&&this.contains(W)?this._focusTargetKey(W):"",O=Re(t)[0]==="year";this.toggleAttribute("data-year-first",O);let q=this._controlClasses,U=A(q.month||"dp-skin"),me=A(q.year||"dp-skin"),ae=A(q.nav||"dp-skin"),X=`<label class="dp-visually-hidden" for="${this._id}-month">${A(this._messages.month)}</label>
|
|
496
|
+
<select id="${this._id}-month" class="dp-month-select ${U}" 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 ${me}" type="number" inputmode="numeric" value="${n}"${v}${E} aria-label="${A(this._messages.year)}">`;if(this._rendering=!0,this.innerHTML=`
|
|
493
498
|
<div class="dp-calendar-shell">
|
|
494
499
|
<div class="dp-calendar-header">
|
|
495
|
-
${
|
|
496
|
-
${
|
|
497
|
-
<button type="button" class="dp-nav dp-prev" data-calendar-action="previous" aria-label="${A(this._messages.previousMonth)}"${
|
|
498
|
-
<button type="button" class="dp-nav dp-next" data-calendar-action="next" aria-label="${A(this._messages.nextMonth)}"${
|
|
500
|
+
${O?_:X}
|
|
501
|
+
${O?X:_}
|
|
502
|
+
<button type="button" class="dp-nav dp-prev ${ae}" 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>
|
|
503
|
+
<button type="button" class="dp-nav dp-next ${ae}" 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>
|
|
499
504
|
</div>
|
|
500
|
-
<h2 id="${
|
|
501
|
-
<table id="${
|
|
502
|
-
<thead><tr>${
|
|
503
|
-
<tbody>${
|
|
505
|
+
<h2 id="${h}" class="dp-calendar-heading dp-visually-hidden" aria-live="polite">${A(Oe(`${i}-15`,t))}</h2>
|
|
506
|
+
<table id="${b}" class="dp-grid" role="grid" aria-labelledby="${h}">
|
|
507
|
+
<thead><tr>${k}${I}</tr></thead>
|
|
508
|
+
<tbody>${N}</tbody>
|
|
504
509
|
</table>
|
|
505
|
-
</div>`,this._rendering=!1,V)queueMicrotask(()=>{let D=V;if(D.startsWith(".dp-day[data-date="))D=`.dp-day[data-date="${CSS.escape(this._model.focused)}"]`;let k=this.querySelector(D);if(k instanceof HTMLElement)k.focus()});if(this._renderDay)for(let D of this.querySelectorAll(".dp-day[data-date]")){if(!(D instanceof HTMLTableCellElement))continue;let k=D.dataset.date||"",p=D.querySelector(".dp-day-extra");if(!(p instanceof HTMLElement))continue;let h=this._renderDay(k,this.getDateState(k));if(h instanceof Node)p.append(h);else if(h!==void 0&&h!==null)p.textContent=String(h)}if(e)this._loadDisplay(i)}}function Le(e){return e==="top"||e==="bottom"?"x":"y"}function rt(e){let[t,i=null]=e.split("-");return{side:t,align:i,crossAxis:Le(t)}}function at(e){return{top:"bottom",bottom:"top",left:"right",right:"left"}[e]||e}function ot(e,t,i,s,n,r){let a=Le(i),o=e.x+e.width/2-t.width/2,l=e.y+e.height/2-t.height/2,d=e[a==="x"?"width":"height"]/2-t[a==="x"?"width":"height"]/2,u;switch(i){case"top":u={x:o,y:e.y-t.height-r};break;case"bottom":u={x:o,y:e.y+e.height+r};break;case"right":u={x:e.x+e.width+r,y:l};break;case"left":u={x:e.x-t.width-r,y:l};break;default:u={x:e.x,y:e.y}}if(s==="start"||s==="end"){let C=(n&&a==="x"?-1:1)*(s==="end"?1:-1);u[a]+=d*C}return u}function dt(e,t,i,s){return Math.max(i-e,0)+Math.max(e+t-s,0)}function lt(e){let t="dir"in e?e.dir:"";if(t==="rtl")return!0;if(t==="ltr")return!1;let i=e.ownerDocument?.defaultView;if(i?.CSS?.supports?.("selector(:dir(rtl))")&&typeof e.matches==="function")return e.matches(":dir(rtl)");return Boolean(i?.Element&&e instanceof i.Element&&i.getComputedStyle(e).direction==="rtl")}var ct=25;function ut(e){let t=e.defaultView;if(!t)return null;let i=e.documentElement,s=t.visualViewport,n=s?.offsetLeft||0,r=s?.offsetTop||0,a=s?.width||i.clientWidth||t.innerWidth,o=s?.height||i.clientHeight||t.innerHeight,l=e.compatMode==="BackCompat"?a-i.clientWidth:i.clientWidth-i.getBoundingClientRect().width;if(l>0&&l<=ct){let d=t.getComputedStyle?.(i).scrollbarGutter;if(d&&d!=="auto")a-=l}return{x:n,y:r,width:a,height:o,right:n+a,bottom:r+o}}function ht(e,t){return t.scope?t.scope.getBoundingClientRect():ut(e.ownerDocument)}function Ae(e,t,i,s,n){let r=i+n,a=s-t-n,o=a>=r,l=o?r:i,d=o?a:s-t;return Math.max(l,Math.min(e,d))}function Se(e,t,i){if(!i)return 50;let s=(e-t)/i*100;return Math.round(Math.min(100,Math.max(0,s))*1000)/1000}function ft(e,t){return e.right<t.x||e.left>t.right||e.bottom<t.y||e.top>t.bottom}function pt(e,t,i,s,n){if(t==="top")return Math.max(0,e.top-i.y-s-n);if(t==="bottom")return Math.max(0,i.bottom-e.bottom-s-n);return Math.max(0,i.height-n*2)}function mt(e){if(e.hidden)return!1;if(typeof e.checkVisibility==="function")return e.checkVisibility();return e.getClientRects().length>0}function Ie(e){let{offsetWidth:t,offsetHeight:i}=e;if(t&&i)return{width:t,height:i};let s=e.getBoundingClientRect();return{width:t||s.width,height:i||s.height}}var Me=new WeakMap,Fe={scroll:0,resize:1,"element-resize":2};function gt(e){let t=e.defaultView;if(!t)throw TypeError("floating must belong to a document with a browsing context");let i=new Set,s=new Map,n=t.ResizeObserver,r=!1,a=!1,o=t.visualViewport;function l(x,_){let g=s.get(x);if(g===void 0||Fe[_]>Fe[g])s.set(x,_)}function d(){if(r)return;r=!0,t.requestAnimationFrame(()=>{let x=[...s];s.clear(),r=!1;for(let[_,g]of x){if(!i.has(_)||!_.floating.isConnected)continue;_.callback({type:g})}})}function u(x){for(let _ of i)l(_,x);d()}function C(x){if(!n)return null;let _=new Set,g=new n((H)=>{let Y=!1;for(let z of H)if(_.has(z.target))Y=!0;else _.add(z.target);if(!Y)return;l(x,"element-resize"),d()}),{reference:T,floating:v}=x;if(T)g.observe(T);if(v!==T)g.observe(v);return g}let m=()=>u("scroll"),b=()=>u("resize");function E(){if(a)return;e.addEventListener("scroll",m,{passive:!0,capture:!0}),t.addEventListener("resize",b,{passive:!0}),o?.addEventListener("scroll",m,{passive:!0}),o?.addEventListener("resize",b,{passive:!0}),a=!0}function S(){if(!a)return;e.removeEventListener("scroll",m,{capture:!0}),t.removeEventListener("resize",b),o?.removeEventListener("scroll",m),o?.removeEventListener("resize",b),a=!1}return{add(x,_,g){let T={reference:x,floating:_,callback:g};i.add(T),E();let v=C(T),H=!1;return()=>{if(H)return;if(H=!0,i.delete(T),s.delete(T),v?.disconnect(),i.size===0)S()}}}}function _t(e){let t=e.ownerDocument,i=Me.get(t);if(!i)i=gt(t),Me.set(t,i);return i}function Oe(e,t,i){if(!t?.ownerDocument)throw TypeError("autoUpdate() expects a floating HTMLElement");if(e&&e.ownerDocument!==t.ownerDocument)throw TypeError("reference and floating must belong to the same document");if(typeof i!=="function")throw TypeError("callback must be a function");return _t(t).add(e,t,i)}function $e(e,t,i){if(!mt(t))return null;let s=i.placement||"bottom-start",n=i.distance||0,r=i.flip!==!1,a=i.shift!==!1,o=i.shiftPadding??4,{side:l,align:d,crossAxis:u}=rt(s),C=d?lt(e):!1,m=e.getClientRects(),b=l==="bottom"?m[m.length-1]:m[0];if(!b)return null;let E=ht(e,i);if(!E||ft(b,E))return null;let S=Ie(t),x={x:{size:S.width,start:E.x,end:E.right},y:{size:S.height,start:E.y,end:E.bottom}},_=(p,h)=>ot(b,S,p,h,C,n),g=(p,h)=>{let{size:y,start:M,end:F}=x[h];return dt(p,y,M+o,F-o)},T=(p,h)=>{let{size:y,start:M,end:F}=x[h];return g(a?Ae(p,y,M,F,o):p,h)},v=_(l,d);if(r){let p=u==="x"?"y":"x",h=g(v[p],p);if(h>0){let y=at(l),M=_(y,d),F=g(M[p],p);if(F<h)l=y,v=M,h=F}if(p==="x"&&h>0){let y=_("top",d),M=_("bottom",d),F=g(M.y,"y")<g(y.y,"y"),K=F?M:y;if(g(K.y,"y")+T(K.x,"x")<h+T(v.y,"y"))l=F?"bottom":"top",u="x",v=K}}if(u==="x"&&a&&d){let p=g(v.x,"x");if(p>0){let h=d==="end"?"start":"end",y=_(l,h);if(g(y.x,"x")<p)d=h,v=y}}if(a){let{size:p,start:h,end:y}=x[u];v[u]=Ae(v[u],p,h,y,o)}let H=Se(b.x+b.width/2,v.x,S.width),Y=Se(b.y+b.height/2,v.y,S.height),z=`${pt(b,l,E,n,o)}px`,{style:V}=t,q=V.getPropertyValue("--available-height")!==z,N=i.coordinateSpace==="document"?e.ownerDocument.defaultView:null,Q=N?N.scrollX:0,D=N?N.scrollY:0;V.left=`${v.x+Q}px`,V.top=`${v.y+D}px`,V.setProperty("--arrow-x",`${H}%`),V.setProperty("--arrow-y",`${Y}%`),V.setProperty("--available-height",z);let k=d?`${l}-${d}`:l;return t.dataset.placement=k,{width:S.width,height:S.height,roomChanged:q,placement:k}}function Re(e,t,i={}){let s=$e(e,t,i);if(!s)return!1;if(s.roomChanged){let n=Ie(t);if(n.width!==s.width||n.height!==s.height)$e(e,t,{...i,placement:s.placement,flip:!1})}return!0}class J{constructor(e,t={}){this.input=e,this.messages=t.messages||{},this.adapter=X(t.locale||""),this.hidden=null,this.canonical="",this._dirty=!1,this._commitId=0,this._originalName=e.getAttribute("name")||"",this._attributeObserver=null,this.onAttributesChanged=null,this.confirm=null}setLocale(e){this.adapter=X(e||"")}setMessages(e){this.messages=e||{}}format(e){return this.adapter.format(e)}parse(e){return this.adapter.parse(e)}get placeholder(){return this.adapter.placeholder}get isDisabled(){return this.input.disabled}get isReadOnly(){return this.input.readOnly}setupFormValue(){let e=this.input;this._originalName=e.getAttribute("name")||"",this._attributeObserver=new MutationObserver(()=>this.onAttributesChanged?.()),this._attributeObserver.observe(e,{attributes:!0,attributeFilter:["disabled","readonly","name","form"]}),this.syncInputState()}syncInputState(){let e=this.input,t=e.getAttribute("name")||"";if(t){if(!this.hidden){let i=document.createElement("input");i.type="hidden",i.value=this.canonical,e.insertAdjacentElement("afterend",i),this.hidden=i}if(this.hidden)this.hidden.name=t;e.removeAttribute("name")}if(this.hidden){if(e.hasAttribute("form"))this.hidden.setAttribute("form",e.getAttribute("form")||"");else this.hidden.removeAttribute("form");this.hidden.disabled=e.disabled}}dirty(){this._commitId++}get isDirty(){return this._dirty}handleInput(){let e=this.input,t=e.value.trim(),i=this.canonical?this.adapter.format(this.canonical):"";if(this.dirty(),t===i){if(this._dirty=!1,this.hidden)this.hidden.value=this.canonical;e.setCustomValidity("");return}if(this._dirty=!0,this.hidden)this.hidden.value="";if(!t){e.setCustomValidity("");return}e.setCustomValidity(t===i?"":this.messages.invalidDate)}async commit(){let e=this.input,t=++this._commitId,i=e.value.trim();if(!i){if(t!==this._commitId)return{status:"stale"};return e.setCustomValidity(""),{status:"clear",value:""}}let s=this.adapter.parse(i);if(!s){if(t!==this._commitId)return{status:"stale"};if(this.hidden)this.hidden.value="";return e.setCustomValidity(this.messages.invalidDate),{status:"invalid"}}if(this.confirm){let n=await this.confirm(s);if(t!==this._commitId)return{status:"stale"};if(!n?.ok){if(this.hidden)this.hidden.value="";return e.setCustomValidity(n?.message||this.messages.unavailableDate),{status:"invalid"}}}return{status:"ok",value:s}}setCanonical(e,t={}){let i=e||"";if(i&&!c(i))throw TypeError(`Invalid date-picker value: ${i}`);if(this.dirty(),this.canonical=i,this._dirty=!1,this.hidden)this.hidden.value=i;if(t.format!==!1)this.input.value=i?this.adapter.format(i):"";this.input.setCustomValidity("")}restoreDefault(){let e=String(this.input.defaultValue??"").trim(),t=c(e)?e:this.adapter.parse(e);return t&&c(t)?t:""}teardown(){this._attributeObserver?.disconnect(),this._attributeObserver=null;let e=this.hidden?.getAttribute("name")||this._originalName;if(e)this.input.setAttribute("name",e);this.hidden?.remove(),this.hidden=null}}var yt=/^(\d{2}):(\d{2})(?::(\d{2})(?:\.(\d{1,3}))?)?$/;function le(e){let t=yt.exec(String(e||""));if(!t)return null;let i=Number(t[1]),s=Number(t[2]),n=t[3]===void 0?0:Number(t[3]),r=t[4]===void 0?0:Number(t[4].padEnd(3,"0"));if(i>23||s>59||n>59||r>999)return null;return{hour:i,minute:s,second:n,millisecond:r}}function ce(e){return le(e)!==null}function ze(e){return((e.hour*60+e.minute)*60+e.second)*1000+e.millisecond}function Ve(e,t){let i=le(e),s=le(t);if(!i||!s)throw TypeError("compareTimes() expects HH:MM values");let n=ze(i)-ze(s);return n===0?0:n<0?-1:1}var bt=0;class ue extends HTMLElement{static observedAttributes=["value","locale","min","max","open-on-focus","month-format"];constructor(){super();this._id=`date-picker-${++bt}`,this._connected=!1,this._reflecting=!1,this._value="",this._input=null,this._field=null,this._fields=null,this._range=null,this._orderTags=new Set,this._timeFields=[null,null],this._timeOrderOwned=new Set,this._lastFocusEndpoint="",this._rangeCommitId=0,this._pendingIntents=new Map,this._buttons=[],this._returnFocus=null,this._panel=null,this._calendar=null,this._originalDescribedBy="",this._rangeOriginalDescribedBy=["",""],this._formatHint=null,this._generatedPlaceholder=!1,this._controller=null,this._stopTracking=null,this._open=!1,this._suppressFocusOpen=!1,this._messages=W(),this._source=null,this._dateState=null,this._renderDay=null,this._isDateDisabled=null,this._coordinateSpace="viewport"}_rangeMode(){return this.hasAttribute("range")&&Boolean(this._range)}connectedCallback(){if(this._connected)return;if(this.hasAttribute("range")){this._connectRange();return}this._connectSingle()}_connectSingle(){let e=this.querySelector(":scope > input:not([type=hidden]):not([type=time]):not([data-time-start]):not([data-time-end])");if(!(e instanceof HTMLInputElement)){console.warn("<date-picker> expects a direct child text input");return}this._connected=!0,this._input=e,this._discoverTimeFields(),this._field=new J(e,{messages:this._messages,locale:this.locale}),this._field.onAttributesChanged=()=>this._syncInputState(),this._field.confirm=(s)=>this._confirmDate(s),this._setupFormValue(),this._build(),this._syncInputState(),this._bind(),this._syncCalendarOptions();let t=this._adapter(),i=this.getAttribute("value")||(c(e.value)?e.value:t.parse(e.value));if(i&&c(i))this._setValue(i,{emit:!1,format:!0});else if(!e.value)this._setValue("",{emit:!1,format:!1});else e.setCustomValidity(this._messages.invalidDate);if(this._field.hidden)this._field.hidden.defaultValue=this._value;if(e.getAttribute("value")==null&&e.defaultValue==="")e.defaultValue=e.value}_discoverTimeFields(){this._timeFields=[null,null];let e=["data-time-start","data-time-end"];for(let[t,i]of e.entries()){let s=this.querySelectorAll(`:scope > input[${i}]`);if(s.length>1)console.warn(`<date-picker> expects at most one direct child input[${i}]; ignoring extras`);let n=s[0];if(n==null)continue;if(!(n instanceof HTMLInputElement)||n.type!=="time"){console.warn(`<date-picker> input[${i}] must be an <input type="time">; ignoring it`);continue}this._timeFields[t]=n}if(this.querySelector(":scope > input[type=time]:not([data-time-start]):not([data-time-end])"))console.warn("<date-picker> time inputs need [data-time-start] or [data-time-end]; ignoring it")}_connectRange(){if(this.querySelector(":scope > input[data-time-start], :scope > input[data-time-end]"))console.warn("<date-picker range> time companions are not supported yet; leaving them native");let e=this.querySelector(":scope > input[data-range-start]"),t=this.querySelector(":scope > input[data-range-end]");if(!(e instanceof HTMLInputElement)||!(t instanceof HTMLInputElement)){console.warn("<date-picker range> expects direct child inputs marked [data-range-start] and [data-range-end]");return}this._connected=!0,this._input=null,this._fields=[new J(e,{messages:this._messages,locale:this.locale}),new J(t,{messages:this._messages,locale:this.locale})],this._range=new oe,this._rangeOriginalDescribedBy=[e.getAttribute("aria-describedby")||"",t.getAttribute("aria-describedby")||""];for(let r of this._fields)r.onAttributesChanged=()=>this._syncRangeFields(),r.confirm=(a)=>this._confirmDate(a),r.setupFormValue();this._build(),this._setRangeAria(),this._syncRangeFields(),this._bindRange(),this._syncCalendarOptions();let i=this._adapter(),s=c(e.value)?e.value:i.parse(e.value),n=c(t.value)?t.value:i.parse(t.value);if(this._setRange(s||"",n||"",{emit:!1}),e.value.trim()&&!c(s))e.setCustomValidity(this._messages.invalidDate);if(t.value.trim()&&!c(n))t.setCustomValidity(this._messages.invalidDate);if(this._fields[0].hidden)this._fields[0].hidden.defaultValue=this._range.start;if(this._fields[1].hidden)this._fields[1].hidden.defaultValue=this._range.end;if(e.getAttribute("value")==null&&e.defaultValue==="")e.defaultValue=e.value;if(t.getAttribute("value")==null&&t.defaultValue==="")t.defaultValue=t.value}disconnectedCallback(){if(this._connected=!1,this.hide(!1),this._controller?.abort(),this._controller=null,this._clearTimeOrderValidity(),this._timeFields=[null,null],this._rangeMode()){for(let e of this._fields||[])this._teardownField(e);this._fields=null,this._range=null}else this._teardownField(this._field);this._field=null;for(let{button:e}of this._buttons)e.remove();this._buttons=[],this._returnFocus=null,this._panel?.remove(),this._formatHint?.remove(),this._panel=null,this._calendar=null,this._formatHint=null}_teardownField(e){if(!e)return;let t=e.input,i=this._fields?.includes(e)?this._rangeOriginalDescribedBy[this._fields?.indexOf(e)??0]||"":this._originalDescribedBy;if(e.teardown(),i)t.setAttribute("aria-describedby",i);else t.removeAttribute("aria-describedby");t.removeAttribute("role"),t.removeAttribute("aria-haspopup"),t.removeAttribute("aria-expanded"),t.removeAttribute("aria-controls")}attributeChangedCallback(e,t,i){if(!this._connected||this._reflecting||t===i)return;if(e==="value"){if(this._rangeMode())return;if(!i||c(i))this._setValue(i||"",{emit:!1,format:!0,reflect:!1});return}if(e==="locale")this._refreshLocale();if(e==="open-on-focus")return;this._syncCalendarOptions(),this.validate()}get input(){return this._rangeMode()?void 0:this._input}get calendar(){return this._calendar}get value(){return this._rangeMode()?void 0:this._value}set value(e){if(this._rangeMode())throw TypeError("value is not available in range mode; use range");if(e&&!c(e))throw TypeError(`Invalid date-picker value: ${e}`);this._setValue(e||"",{emit:!1,format:!0})}get range(){return this._rangeMode()&&this._range?{...this._range.range}:void 0}set range(e){if(!this._rangeMode())throw TypeError("range is only available on <date-picker range>");let{start:t,end:i}=ne(e);this._setRange(t,i)}get locale(){return R(this.getAttribute("locale")||"")}set locale(e){if(e)this.setAttribute("locale",e);else this.removeAttribute("locale")}get monthFormat(){return this.getAttribute("month-format")==="short"?"short":"long"}set monthFormat(e){if(e==="short")this.setAttribute("month-format","short");else this.removeAttribute("month-format")}get min(){let e=this.getAttribute("min")||"";return c(e)?e:""}set min(e){if(e)this.setAttribute("min",e);else this.removeAttribute("min")}get max(){let e=this.getAttribute("max")||"";return c(e)?e:""}set max(e){if(e)this.setAttribute("max",e);else this.removeAttribute("max")}get openOnFocus(){return this.getAttribute("open-on-focus")!=="false"}set openOnFocus(e){if(e===!1)this.setAttribute("open-on-focus","false");else this.removeAttribute("open-on-focus")}get open(){return this._open}get messages(){return this._messages}set messages(e){if(this._messages={...W(),...e||{}},this._calendar)this._calendar.messages=this._messages;for(let t of this._fields||[])t.setMessages(this._messages);this._field?.setMessages(this._messages),this._refreshButtonLabel(),this.validate()}get source(){return this._source}set source(e){if(this._source=e||null,this._calendar)this._calendar.source=this._source;if(this._connected)this.validate()}get dateState(){return this._dateState}set dateState(e){if(this._dateState=typeof e==="function"?e:null,this._calendar)this._calendar.dateState=this._dateState;if(this._connected)this.validate()}get renderDay(){return this._renderDay}set renderDay(e){if(this._renderDay=typeof e==="function"?e:null,this._calendar)this._calendar.renderDay=this._renderDay}get isDateDisabled(){return this._isDateDisabled}set isDateDisabled(e){if(this._isDateDisabled=typeof e==="function"?e:null,this._calendar)this._calendar.isDateDisabled=this._isDateDisabled;if(this._connected)this.validate()}get coordinateSpace(){return this._coordinateSpace}set coordinateSpace(e){this._coordinateSpace=e==="document"?"document":"viewport"}_adapter(){return this._field?.adapter??this._fields?.[0]?.adapter??X(this.locale)}_setupFormValue(){this._field?.setupFormValue()}_syncInputState(){let e=this._input;if(!e)return;this._field?.syncInputState();let t=this._buttons[0]?.button;if(t)t.disabled=e.disabled||e.readOnly;if(this._open&&(e.disabled||e.readOnly))this.hide(!1)}_syncRangeFields(){if(!this._fields)return;for(let t of this._fields)t.syncInputState();for(let{button:t,endpoint:i}of this._buttons){let s=i==="end"?1:0,n=this._fields[s];t.disabled=Boolean(n?.input.disabled||n?.input.readOnly)}let e=this._range?.activeEndpoint==="end"?1:0;if(this._open&&(this._fields[e]?.input.disabled||this._fields[e]?.input.readOnly))this.hide(!1)}_setRangeAria(){if(!this._fields||!this._panel||!this._formatHint)return;for(let e of this._fields){let t=e.input,i=[this._rangeOriginalDescribedBy[this._fields.indexOf(e)],this._formatHint.id].filter(Boolean).join(" ");t.setAttribute("aria-describedby",i),t.setAttribute("role","combobox"),t.setAttribute("aria-haspopup","dialog"),t.setAttribute("aria-expanded","false"),t.setAttribute("aria-controls",this._panel.id)}}_createTrigger(e){let t=document.createElement("button");if(t.type="button",t.className="dp-picker-button",t.setAttribute("aria-haspopup","dialog"),t.setAttribute("aria-expanded","false"),t.setAttribute("aria-controls",`${this._id}-panel`),e)t.dataset.endpoint=e;return t.innerHTML='<span aria-hidden="true"><svg viewBox="0 0 16 16" width="1em" height="1em" fill="none" stroke="currentColor" stroke-width="1.4" stroke-linecap="round"><rect x="1.75" y="3" width="12.5" height="11" rx="1.75"/><path d="M1.75 6.75h12.5"/><path d="M5.25 1.75v2.5M10.75 1.75v2.5"/></svg></span>',t}_build(){let e=this._rangeMode(),t=[];if(e)for(let[o,l]of(this._fields||[]).entries())t.push([l.input,o===1?"end":"start"]);else if(this._input)t.push([this._input,""]);if(!t.length)return;let i=`${this._id}-panel`,s=`${this._id}-format`;this._buttons=t.map(([o,l])=>{let d=this._createTrigger(l);return o.insertAdjacentElement("afterend",d),{button:d,endpoint:l}});let n=document.createElement("div");n.id=i,n.className="dp-picker-panel",n.setAttribute("popover","manual"),n.setAttribute("role","dialog"),n.setAttribute("aria-label",this._messages.calendar);let r=new Z;r.selection="none",r.fixedWeeks=!0,n.append(r);let a=document.createElement("span");if(a.id=s,a.className="dp-visually-hidden",this.append(n,a),this._panel=n,this._calendar=r,this._formatHint=a,!e&&this._input){this._originalDescribedBy=this._input.getAttribute("aria-describedby")||"";let o=[this._originalDescribedBy,s].filter(Boolean).join(" ");this._input.setAttribute("aria-describedby",o),this._input.setAttribute("role","combobox"),this._input.setAttribute("aria-haspopup","dialog"),this._input.setAttribute("aria-expanded","false"),this._input.setAttribute("aria-controls",i)}this._refreshLocale(),this._refreshButtonLabel()}_bind(){let e=this._input,t=this._buttons[0]?.button,i=this._calendar;if(!e||!t||!i)return;let s=new AbortController;this._controller=s;let{signal:n}=s;e.addEventListener("input",()=>{this._field?.handleInput()},{signal:n}),e.addEventListener("change",()=>void this._commitText(!1),{signal:n}),e.addEventListener("blur",()=>void this._commitText(!1),{signal:n}),e.addEventListener("focus",(r)=>{if(!this.openOnFocus||this._suppressFocusOpen)return;let a=r.relatedTarget;if(a instanceof Node&&this.contains(a))return;if(!this._open)this.show({moveFocus:!1})},{signal:n}),e.addEventListener("keydown",(r)=>{this._onFieldKeyDown("",r)},{signal:n});for(let[r,a]of this._timeFields.entries()){if(!a)continue;let o=r===1?"end":"start";a.addEventListener("input",()=>this._revalidateTimeOrder(o),{signal:n}),a.addEventListener("change",()=>this._revalidateTimeOrder(o),{signal:n})}t.addEventListener("click",(r)=>{if(this._open){if(r.detail===0){setTimeout(()=>this._calendar?.focusGrid(),0);return}this.hide(!1);return}this.show({returnFocus:t})},{signal:n}),t.addEventListener("keydown",(r)=>this._onTriggerKeyDown("",r),{signal:n}),i.addEventListener("dateactivate",(r)=>{let a=r,o=a.detail?.date;if(!c(o))return;queueMicrotask(()=>{if(a.defaultPrevented||!this._connected)return;if(this._input?.disabled||this._input?.readOnly)return;this._field?.dirty(),this._setValue(o,{emit:!0,format:!0}),this.hide(!1),this._restoreFocus()})},{signal:n}),i.addEventListener("dateloadend",()=>void this.validate(),{signal:n}),this.ownerDocument.addEventListener("pointerdown",(r)=>{if(!this._open||r.composedPath().includes(this))return;this.hide(!1)},{capture:!0,signal:n}),this.ownerDocument.addEventListener("reset",(r)=>{let a=r.target;if(a instanceof HTMLFormElement&&this._input&&a===this._input.form)this.hide(!1),queueMicrotask(()=>{if(!r.defaultPrevented)this._restoreDefault()})},{capture:!0,signal:n}),this.addEventListener("keydown",(r)=>this._onEscape(r),{signal:n})}_bindRange(){let e=this._calendar;if(!this._fields||!this._buttons.length||!e)return;let t=new AbortController;this._controller=t;let{signal:i}=t;for(let[s,n]of this._fields.entries()){let r=s===1?"end":"start";n.input.addEventListener("input",()=>n.handleInput(),{signal:i}),n.input.addEventListener("change",()=>void this._commitFieldText(r),{signal:i}),n.input.addEventListener("blur",()=>void this._commitFieldText(r),{signal:i}),n.input.addEventListener("focus",(a)=>this._onFieldFocus(r,a),{signal:i}),n.input.addEventListener("keydown",(a)=>this._onFieldKeyDown(r,a),{signal:i})}for(let s of this._buttons){let n=s.endpoint;if(n==="")continue;s.button.addEventListener("click",(r)=>this._onRangeTriggerClick(n,r),{signal:i}),s.button.addEventListener("keydown",(r)=>this._onTriggerKeyDown(n,r),{signal:i})}e.addEventListener("click",(s)=>this._captureGridIntent(s),{capture:!0,signal:i}),e.addEventListener("keydown",(s)=>this._captureGridIntent(s),{capture:!0,signal:i}),e.addEventListener("dateactivate",(s)=>{let n=s,r=n.detail?.date;if(!c(r))return;queueMicrotask(()=>{if(n.defaultPrevented||!this._connected||!this._range)return;let a=this._pendingIntents.get(r);if(a===void 0||a!==this._rangeCommitId)return;this._pendingIntents.delete(r);let o=this._range.activate(r,(l)=>{let d=l==="end"?1:0,u=this._fields?.[d];return u!=null&&!u.input.disabled&&!u.input.readOnly});if(o.status==="refused"){this._calendar?.dispatchEvent(new CustomEvent("dateinvalid",{detail:{date:r,state:this._calendar.getDateState(r)},bubbles:!0}));return}if(this._setBound(o.endpoint,r,{emit:!0,user:!0}),o.close||o.status==="complete")this.hide(!1),this._focusField(o.endpoint)})},{signal:i}),e.addEventListener("dateloadend",()=>void this.validate(),{signal:i}),this.ownerDocument.addEventListener("pointerdown",(s)=>{if(!this._open||s.composedPath().includes(this))return;this.hide(!1)},{capture:!0,signal:i}),this.ownerDocument.addEventListener("reset",(s)=>{let n=s.target;if(n instanceof HTMLFormElement&&this._fields&&n===this._fields[0].input.form)this.hide(!1),queueMicrotask(()=>{if(!s.defaultPrevented)this._restoreRangeDefault()})},{capture:!0,signal:i}),this.addEventListener("keydown",(s)=>this._onEscape(s),{signal:i})}_activateRangeEndpoint(e){let t=this._calendar;if(!this._range||!t)return;this._range.focus(e),this._rangeCommitId++,this._pendingIntents.clear(),this._lastFocusEndpoint=e;let i=this._boundCanonical(e)||O();t.display=f(i),t.focusedDate=i}_onRangeTriggerClick(e,t){if(!this._open){this.show({endpoint:e});return}if(t.detail===0){this._activateRangeEndpoint(e),setTimeout(()=>this._calendar?.focusGrid(),0);return}if(e!==this._range?.activeEndpoint){this._activateRangeEndpoint(e);return}this.hide(!1)}_onTriggerKeyDown(e,t){if(t.key!=="ArrowDown")return;if(t.preventDefault(),this._open){if(this._rangeMode()&&e)this._activateRangeEndpoint(e);setTimeout(()=>this._calendar?.focusGrid(),0);return}if(this._rangeMode())this.show({endpoint:e||void 0});else this.show({returnFocus:this._buttons[0]?.button})}_onFieldKeyDown(e,t){if(t.key==="ArrowDown"){if(t.preventDefault(),this._rangeMode()&&e)this._lastFocusEndpoint=e,this._range?.focus(e);if(this._open)setTimeout(()=>this._calendar?.focusGrid(),0);else this.show()}else if(t.key==="Escape"&&this._open)t.preventDefault(),this.hide(!1)}_onFieldFocus(e,t){if(!this._rangeMode()||!e)return;let i=e!==this._range?.activeEndpoint;if(this._lastFocusEndpoint=e,this._range?.focus(e),i)this._rangeCommitId++,this._pendingIntents.clear();if(!this.openOnFocus||this._suppressFocusOpen)return;let s=t.relatedTarget;if(s instanceof Node&&this.contains(s))return;if(!this._open)this.show({moveFocus:!1})}_captureGridIntent(e){if(!this._rangeMode()||!this._range)return;if(e.type==="keydown"){let s=e.key;if(s!=="Enter"&&s!==" ")return}if(!(e.target instanceof Element))return;let i=e.target.closest(".dp-day[data-date]")?.getAttribute("data-date")||"";if(!c(i))return;this._pendingIntents.clear(),this._pendingIntents.set(i,++this._rangeCommitId)}_onEscape(e){if(e.key==="Escape"&&this._open)e.preventDefault(),e.stopPropagation(),this.hide(!0)}_syncCalendarOptions(){let e=this._calendar,t=this._panel;if(!e)return;if(e.locale=this.locale,e.min=this.min,e.max=this.max,e.monthFormat=this.monthFormat,e.messages=this._messages,e.source=this._source,e.dateState=this._dateState,e.renderDay=this._renderDay,e.isDateDisabled=this._isDateDisabled,!this._rangeMode()&&this._value)e.value=this._value;if(t)t.setAttribute("aria-label",this._messages.calendar)}_refreshLocale(){let e=this._formatHint;if(!e)return;if(this._rangeMode()&&this._fields){this._fields[0].setLocale(this.locale),this._fields[1].setLocale(this.locale),e.textContent=`${this._messages.formatHint}: ${this._fields[0].placeholder}`;for(let[i,s]of this._fields.entries()){if(!s.input.hasAttribute("placeholder")||this._generatedPlaceholder)s.input.placeholder=s.placeholder,this._generatedPlaceholder=!0;let n=i===1?this._range?.end||"":this._range?.start||"";if(n)s.input.value=s.format(n)}this._refreshButtonLabel();return}let t=this._field;if(!t)return;if(t.setLocale(this.locale),e.textContent=`${this._messages.formatHint}: ${t.placeholder}`,!t.input.hasAttribute("placeholder")||this._generatedPlaceholder)t.input.placeholder=t.placeholder,this._generatedPlaceholder=!0;if(this._value)t.input.value=t.format(this._value);this._refreshButtonLabel()}_refreshButtonLabel(){let e=this._buttons[0]?.button;if(!e)return;if(this._rangeMode()){this._refreshRangeButtonLabel();return}let t=this._value?this._messages.changeDate:this._messages.chooseDate,i=this._value?`, ${G(this._value,this.locale)}`:"";e.setAttribute("aria-label",`${t}${i}`)}_refreshRangeButtonLabel(){if(!this._range)return;let{start:e,end:t}=this._range;for(let{button:i,endpoint:s}of this._buttons){let n=s==="end"?t:e,r=n?this._messages.changeDate:this._messages.chooseDate,a=n?`, ${G(n,this.locale)}`:"",o=s==="end"?this._messages.rangeEnd:this._messages.rangeStart;i.setAttribute("aria-label",`${r}${a}, ${o}`)}}_reflectValue(e){if(this._reflecting=!0,e)this.setAttribute("value",e);else this.removeAttribute("value");this._reflecting=!1}_setValue(e,t={}){if(e&&!c(e))throw TypeError(`Invalid date-picker value: ${e}`);let i=this._value;if(this._value=e||"",t.reflect!==!1)this._reflectValue(this._value);if(this._field?.setCanonical(this._value,{format:t.format!==!1}),this._calendar){if(this._calendar.value=this._value,this._value)this._calendar.focusedDate=this._value}if(this._refreshButtonLabel(),i!==this._value){if(this.dispatchEvent(new CustomEvent("valuechange",{detail:{value:this._value},bubbles:!0})),t.emit&&this._field){let s=this._field.input;s.dispatchEvent(new Event("input",{bubbles:!0})),s.dispatchEvent(new Event("change",{bubbles:!0}))}}}async _confirmDate(e){let t=this._calendar;if(!t)return{ok:!0};let i=f(e);if(t.display!==i)t.display=i;let s=await t.ensureDate(e),n=t.getDateState(e);if(!s||n.disabled)return{ok:!1,message:this._messages.unavailableDate};return{ok:!0}}async _commitText(e,t={}){let i=this._field;if(!i)return!1;if(!t.force&&!i.isDirty)return!1;let s=await i.commit();if(s.status==="stale"||s.status==="invalid")return!1;return this._setValue(s.value||"",{emit:e,format:s.status==="ok"}),!0}async _commitFieldText(e){let t=this._fields;if(!t)return!1;let i=e==="end"?1:0,s=t[i];if(!s?.isDirty)return!1;let n=await s.commit();if(n.status==="stale")return!1;if(n.status==="invalid")return this._orderTags.delete(i),!1;return this._setBound(e,n.value||"",{emit:!1,user:!0,format:n.status==="ok"}),!0}_setBound(e,t,i={}){if(!this._range)return!1;let s=this._fields;if(!s)return!1;let r=s[e==="end"?1:0];if(!r)return!1;if(i.user===!0&&(r.input.disabled||r.input.readOnly))return!1;let a=t||"",o=r.canonical;if(r.setCanonical(a,{format:i.format!==!1}),e==="end")this._range.end=a;else this._range.start=a;let l=o!==a;if(l){if(this._syncHighlight(),this._refreshRangeButtonLabel(),this._emitRangeChange(),i.emit)r.input.dispatchEvent(new Event("input",{bubbles:!0})),r.input.dispatchEvent(new Event("change",{bubbles:!0}))}return this._revalidateRange(e),l}_setRange(e,t,i={}){if(!this._range||!this._fields)return;if(this._range.start=e||"",this._range.end=t||"",this._fields[0].setCanonical(e||"",{format:i.format!==!1}),this._fields[1].setCanonical(t||"",{format:i.format!==!1}),this._syncHighlight(),this._refreshRangeButtonLabel(),this._revalidateRange("start"),this._revalidateRange("end"),i.emit!==!1)this._emitRangeChange()}_boundCanonical(e){return this._range?e==="end"?this._range.end:this._range.start:""}_emitRangeChange(){if(!this._range)return;this.dispatchEvent(new CustomEvent("rangechange",{detail:{...this._range.range},bubbles:!0}))}_syncHighlight(){if(!this._calendar||!this._range)return;let{start:e,end:t}=this._range;if(!e){this._calendar.highlightedRange={start:"",end:""};return}if(t&&w(t,e)<0)this._calendar.highlightedRange={start:e,end:""};else this._calendar.highlightedRange={start:e,end:t}}_revalidateRange(e){if(!this._fields||!this._range)return;let{start:t,end:i}=this._range,s=Boolean(t&&i&&w(i,t)<0),n=["start","end"];for(let r of n){let a=r==="end"?1:0,o=this._fields[a].input,l=r==="end"?this._messages.rangeOrderEnd:this._messages.rangeOrderStart;if(s&&r===e)o.setCustomValidity(l),this._orderTags.add(a);else if(this._orderTags.has(a))o.setCustomValidity(""),this._orderTags.delete(a)}}_revalidateTimeOrder(e){let[t,i]=this._timeFields,s=["start","end"],n=[t,i],r=t&&!t.disabled?t.value.trim():"",a=i&&!i.disabled?i.value.trim():"",o=Boolean(t&&i&&r&&a)&&ce(r)&&ce(a)&&Ve(a,r)<0;for(let[l,d]of s.entries()){let u=n[l];if(!u)continue;let C=d==="end"?this._messages.rangeOrderEnd:this._messages.rangeOrderStart;if(o&&d===e)u.setCustomValidity(C),this._timeOrderOwned.add(u);else if(this._timeOrderOwned.has(u))u.setCustomValidity(""),this._timeOrderOwned.delete(u)}}_clearTimeOrderValidity(){for(let e of this._timeOrderOwned)e.setCustomValidity("");this._timeOrderOwned.clear()}_restoreDefault(){let e=this._field;if(!e)return;let t=e.restoreDefault();if(this._setValue(t,{emit:!1,format:!0}),this._calendar)if(this._value)this._calendar.display=f(this._value),this._calendar.focusedDate=this._value;else this._calendar.display=f(O()),this._calendar.focusedDate=O();this.validate()}_restoreRangeDefault(){if(!this._fields)return;let e=this._fields[0].restoreDefault(),t=this._fields[1].restoreDefault();if(this._setRange(e,t),this._calendar){let i=this._range?.start||O();this._calendar.display=f(i),this._calendar.focusedDate=i}this.validate()}_focusField(e){let t=e==="end"?1:0,i=this._fields?.[t]?.input;if(!i)return;this._suppressFocusOpen=!0,setTimeout(()=>{i.focus(),this._suppressFocusOpen=!1},0)}_restoreFocus(){let e=this._returnFocus;if(this._returnFocus=null,!(e instanceof HTMLElement)||!e.isConnected||e.matches(":disabled"))return;this._suppressFocusOpen=!0,setTimeout(()=>{e.focus(),this._suppressFocusOpen=!1},0)}_resolveRangeEndpoint(){if(!this._fields)return"";let e=this._lastFocusEndpoint||"start",t=e==="end"?1:0;if(!this._fields[t].input.disabled&&!this._fields[t].input.readOnly)return e;let i=e==="end"?"start":"end",s=i==="end"?1:0;if(!this._fields[s].input.disabled&&!this._fields[s].input.readOnly)return i;return""}async validate(){if(this._rangeMode()){let i=this._fields;if(!i)return!0;for(let[s,n]of i.entries()){let r=await n.commit();if(r.status==="ok"||r.status==="clear"){let a=s===1?"end":"start";this._setBound(a,r.value||"",{format:r.status==="ok"})}}return this._revalidateRange("start"),this._revalidateRange("end"),i.every((s)=>s.input.checkValidity())}let e=this._field?.input;if(!e)return!0;if(!e.value.trim())e.setCustomValidity("");else await this._commitText(!1,{force:!0});this._revalidateTimeOrder("start"),this._revalidateTimeOrder("end");let t=this._timeFields.every((i)=>i?.checkValidity()??!0);return e.checkValidity()&&t}show(e={}){let t=this._panel,i=this._calendar;if(!t||!i||!this._buttons.length||this._open)return;if(this._rangeMode()){let r=e.endpoint||this._resolveRangeEndpoint();if(!r)return;this._activateRangeEndpoint(r)}else{let r=this._input;if(!r||r.disabled||r.readOnly)return;let a=this._value||this._adapter().parse(r.value)||O();i.display=f(a),i.focusedDate=a,this._returnFocus=e.returnFocus instanceof HTMLElement?e.returnFocus:r}t.showPopover(),this._open=!0,this._setExpanded(!0);let s=this.coordinateSpace;t.style.position=s==="document"?"absolute":"fixed";let n=()=>Re(this,t,{placement:"bottom-start",distance:4,shiftPadding:8,coordinateSpace:s});if(n(),this._stopTracking=Oe(this,t,n),e.moveFocus!==!1)queueMicrotask(()=>i.focusGrid());this.dispatchEvent(new Event("open",{bubbles:!0}))}_setExpanded(e){let t=e?"true":"false";this._input?.setAttribute("aria-expanded",t);for(let{button:i}of this._buttons)i.setAttribute("aria-expanded",t);for(let i of this._fields||[])i.input.setAttribute("aria-expanded",t)}hide(e=!1){if(!this._panel||!this._open)return;this._stopTracking?.(),this._stopTracking=null;try{this._panel.hidePopover()}catch{}if(this._open=!1,this._setExpanded(!1),this._rangeCommitId++,this._pendingIntents.clear(),e)if(this._rangeMode()){let t=this._restoreFocusEndpoint();if(t)this._focusField(t)}else this._restoreFocus();this.dispatchEvent(new Event("close",{bubbles:!0}))}_restoreFocusEndpoint(){let e=this._range?.activeEndpoint||"";if(e){let t=e==="end"?1:0,i=this._fields?.[t];if(i&&!i.input.disabled&&!i.input.readOnly)return e}return this._resolveRangeEndpoint()}}function he(){if(!customElements.get("date-calendar"))customElements.define("date-calendar",Z);if(!customElements.get("date-picker"))customElements.define("date-picker",ue)}he();var He="lekoala-date-picker-styles";if(!document.getElementById(He)){let e=document.createElement("style");e.id=He,e.textContent=ge,document.head.append(e)}he();})();
|
|
510
|
+
</div>`,this._rendering=!1,this._paintedRange={...this._highlightedRange},this._paintedPreview=this.hasAttribute("data-range-preview"),K)queueMicrotask(()=>{let u=K;if(u.startsWith(".dp-day[data-date="))u=`.dp-day[data-date="${CSS.escape(this._model.focused)}"]`;let m=this.querySelector(u);if(m instanceof HTMLElement)m.focus()});if(this._renderDay)for(let u of this.querySelectorAll(".dp-day[data-date]")){if(!(u instanceof HTMLTableCellElement))continue;let m=u.dataset.date||"",w=u.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(i)}}function pe(e){return e==="top"||e==="bottom"?"x":"y"}var Ye={top:"bottom",bottom:"top",left:"right",right:"left"},Ct=new Set(Object.keys(Ye).flatMap((e)=>[e,`${e}-start`,`${e}-end`])),At=new Set(["viewport","document"]);function Tt(e){if(!Ct.has(e))throw TypeError(`Unknown placement: ${e}`);let[t,i=null]=e.split("-");return{side:t,align:i,crossAxis:pe(t)}}function St(e,t,i,n,s,r){let a=pe(i),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,h;switch(i){case"top":h={x:o,y:e.y-t.height-r};break;case"bottom":h={x:o,y:e.y+e.height+r};break;case"right":h={x:e.x+e.width+r,y:c};break;case"left":h={x:e.x-t.width-r,y:c};break;default:h={x:e.x,y:e.y}}if(n==="start"||n==="end"){let b=(s&&a==="x"?-1:1)*(n==="end"?1:-1);h[a]+=l*b}return h}function Mt(e,t,i,n){return Math.max(i-e,0)+Math.max(e+t-n,0)}function $t(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 Ft=25;function Lt(e){let t=e.defaultView;if(!t)return null;let i=e.documentElement,n=t.visualViewport,s=n?.offsetLeft||0,r=n?.offsetTop||0,a=n?.width||i.clientWidth||t.innerWidth,o=n?.height||i.clientHeight||t.innerHeight,c=e.compatMode==="BackCompat"?a-i.clientWidth:i.clientWidth-i.getBoundingClientRect().width;if(c>0&&c<=Ft){let l=t.getComputedStyle?.(i).scrollbarGutter;if(l&&l!=="auto")a-=c}return{x:s,y:r,width:a,height:o,right:s+a,bottom:r+o}}function It(e,t){return t.scope?t.scope.getBoundingClientRect():Lt(e.ownerDocument)}function Ve(e,t,i,n,s){let r=i+s,a=n-t-s,o=a>=r,c=o?r:i,l=o?a:n-t;return Math.max(c,Math.min(e,l))}function Be(e,t,i){if(!i)return 50;let n=(e-t)/i*100;return Math.round(Math.min(100,Math.max(0,n))*1000)/1000}function Ot(e,t){for(let i=0;i<e.length;i++){let n=e[i];if(n.right>=t.x&&n.left<=t.right&&n.bottom>=t.y&&n.top<=t.bottom)return!1}return!0}function Rt(e,t,i,n,s){if(t==="top")return Math.max(0,e.top-i.y-n-s);if(t==="bottom")return Math.max(0,i.bottom-e.bottom-n-s);return Math.max(0,i.height-s*2)}function Pt(e){if(e.hidden)return!1;if(typeof e.checkVisibility==="function")return e.checkVisibility();return e.getClientRects().length>0}function Ge(e){let{offsetWidth:t,offsetHeight:i}=e;if(t&&i)return{width:t,height:i};let n=e.getBoundingClientRect();return{width:t||n.width,height:i||n.height}}var Ne=new WeakMap,Ue={scroll:0,resize:1,"element-resize":2};function zt(e){let t=e.defaultView;if(!t)throw TypeError("floating must belong to a document with a browsing context");let i=new Set,n=new Map,s=t.ResizeObserver,r=!1,a=!1,o=t.visualViewport;function c(y,v){let E=n.get(y);if(E===void 0||Ue[v]>Ue[E])n.set(y,v)}function l(){if(r)return;r=!0,t.requestAnimationFrame(()=>{let y=[...n];n.clear(),r=!1;for(let[v,E]of y){if(!i.has(v)||!v.floating.isConnected)continue;try{v.callback({type:E})}catch(C){h(C)}}})}function h(y){if(typeof t.reportError==="function")t.reportError(y);else t.setTimeout(()=>{throw y})}function b(y){for(let v of i)c(v,y);l()}function D(y){if(!s)return null;let v=new Set,E=new s((z)=>{let I=!1;for(let N of z)if(v.has(N.target))I=!0;else v.add(N.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};i.add(C),S();let k=D(C),z=!1;return()=>{if(z)return;if(z=!0,i.delete(C),n.delete(C),k?.disconnect(),i.size===0)M()}}}}function Ht(e){let t=e.ownerDocument,i=Ne.get(t);if(!i)i=zt(t),Ne.set(t,i);return i}function We(e,t,i){if(!t?.ownerDocument)throw TypeError("autoUpdate() expects a floating HTMLElement");if(e&&e.ownerDocument!==t.ownerDocument)throw TypeError("reference and floating must belong to the same document");if(typeof i!=="function")throw TypeError("callback must be a function");return Ht(t).add(e,t,i)}function je(e,t,i){let n=i.placement===void 0?"bottom-start":i.placement,{side:s,align:r,crossAxis:a}=Tt(n),o=i.coordinateSpace===void 0?"viewport":i.coordinateSpace;if(!At.has(o))throw TypeError(`Unknown coordinateSpace: ${o}`);if(!Pt(t))return null;let c=i.distance||0,l=i.flip!==!1,h=i.shift!==!1,b=i.shiftPadding??4,D=r?$t(e):!1,x=e.getClientRects();if(!x.length)return null;let T=(_)=>_==="bottom"?x[x.length-1]:x[0],S=It(e,i);if(!S||Ot(x,S))return null;let M=Ge(t),y={x:{size:M.width,start:S.x,end:S.right},y:{size:M.height,start:S.y,end:S.bottom}},v=(_,u)=>St(T(_),M,_,u,D,c),E=(_,u)=>{let{size:m,start:w,end:p}=y[u];return Mt(_,m,w+b,p-b)},C=(_,u)=>{let{size:m,start:w,end:p}=y[u];return E(h?Ve(_,m,w,p,b):_,u)},k=v(s,r),z=(_,u)=>{let m=pe(_),w=m==="x"?"y":"x",p=E(u[w],w);return{main:p,total:p+C(u[m],m)}};if(l){let _=z(s,k),u=(m)=>{let w=v(m,r),p=z(m,w);if(p.total<_.total)s=m,k=w,_=p};if(_.main>0)u(Ye[s]);if(a==="y"&&_.main>0)u("top"),u("bottom");a=pe(s)}if(a==="x"&&h&&r){let _=E(k.x,"x");if(_>0){let u=r==="end"?"start":"end",m=v(s,u);if(E(m.x,"x")<_)r=u,k=m}}if(h){let{size:_,start:u,end:m}=y[a];k[a]=Ve(k[a],_,u,m,b)}let I=T(s),N=Be(I.x+I.width/2,k.x,M.width),W=Be(I.y+I.height/2,k.y,M.height),K=`${Rt(I,s,S,c,b)}px`,{style:O}=t,q=O.getPropertyValue("--available-height")!==K,U=o==="document"?e.ownerDocument.defaultView:null,me=U?U.scrollX:0,ae=U?U.scrollY:0;O.left=`${k.x+me}px`,O.top=`${k.y+ae}px`,O.setProperty("--arrow-x",`${N}%`),O.setProperty("--arrow-y",`${W}%`),O.setProperty("--available-height",K);let X=r?`${s}-${r}`:s;return t.dataset.placement=X,{width:M.width,height:M.height,roomChanged:q,placement:X}}function Ke(e,t,i={}){let n=je(e,t,i);if(!n)return!1;if(n.roomChanged){let s=Ge(t);if(s.width!==n.width||s.height!==n.height)je(e,t,{...i,placement:n.placement,flip:!1})}return!0}class re{constructor(e,t={}){this.input=e,this.messages=t.messages||{},this.adapter=ne(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=ne(e||"")}setMessages(e){this.messages=e||{}}format(e){return this.adapter.format(e)}parse(e){return this.adapter.parse(e)}get placeholder(){return this.adapter.placeholder}get isDisabled(){return this.input.disabled}get isReadOnly(){return this.input.readOnly}setupFormValue(){let e=this.input;this._originalName=e.getAttribute("name")||"",this._attributeObserver=new MutationObserver(()=>this.onAttributesChanged?.()),this._attributeObserver.observe(e,{attributes:!0,attributeFilter:["disabled","readonly","name","form"]}),this.syncInputState()}syncInputState(){let e=this.input,t=e.getAttribute("name")||"";if(t){if(!this.hidden){let i=document.createElement("input");i.type="hidden",i.value=this.canonical,e.insertAdjacentElement("afterend",i),this.hidden=i}if(this.hidden)this.hidden.name=t;e.removeAttribute("name")}if(this.hidden){if(e.hasAttribute("form"))this.hidden.setAttribute("form",e.getAttribute("form")||"");else this.hidden.removeAttribute("form");this.hidden.disabled=e.disabled}}dirty(){this._commitId++}get isDirty(){return this._dirty}handleInput(){let e=this.input,t=e.value.trim(),i=this.canonical?this.adapter.format(this.canonical):"";if(this.dirty(),t===i){if(this._dirty=!1,this.hidden)this.hidden.value=this.canonical;e.setCustomValidity("");return}if(this._dirty=!0,this.hidden)this.hidden.value="";if(!t){e.setCustomValidity("");return}e.setCustomValidity(this.messages.invalidDate)}async commit(e={}){let t=this.input,i=++this._commitId,n=t.value.trim();if(!n){if(i!==this._commitId)return{status:"stale"};return t.setCustomValidity(""),{status:"clear",value:""}}let s=this.adapter.parse(n);if(!s){if(i!==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(s,e);if(i!==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:s}}setCanonical(e,t={}){let i=e||"";if(i&&!d(i))throw TypeError(`Invalid date-picker value: ${i}`);if(this.dirty(),this.canonical=i,this._dirty=!1,this.hidden)this.hidden.value=i;if(t.format!==!1)this.input.value=i?this.adapter.format(i):"";this.input.setCustomValidity("")}restoreDefault(){let e=String(this.input.defaultValue??"").trim(),t=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 Vt=/^(\d{2}):(\d{2})(?::(\d{2})(?:\.(\d{1,3}))?)?$/;function we(e){let t=Vt.exec(String(e||""));if(!t)return null;let i=Number(t[1]),n=Number(t[2]),s=t[3]===void 0?0:Number(t[3]),r=t[4]===void 0?0:Number(t[4].padEnd(3,"0"));if(i>23||n>59||s>59||r>999)return null;return{hour:i,minute:n,second:s,millisecond:r}}function De(e){return we(e)!==null}function qe(e){return((e.hour*60+e.minute)*60+e.second)*1000+e.millisecond}function Xe(e,t){let i=we(e),n=we(t);if(!i||!n)throw TypeError("compareTimes() expects HH:MM values");let s=qe(i)-qe(n);return s===0?0:s<0?-1:1}var Bt=0,Ze=4;class xe extends HTMLElement{static observedAttributes=["value","locale","min","max","open-on-focus","month-format"];constructor(){super();this._id=`date-picker-${++Bt}`,this._connected=!1,this._reflecting=!1,this._value="",this._input=null,this._field=null,this._fields=null,this._range=null,this._orderTags=new Set,this._timeFields=[null,null],this._timeOrderOwned=new Set,this._lastFocusEndpoint="",this._rangeCommitId=0,this._pendingIntents=new Map,this._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=G(),this._controlClasses=te(),this._source=null,this._dateState=null,this._renderDay=null,this._isDateDisabled=null,this._coordinateSpace="viewport"}_rangeMode(){return this.hasAttribute("range")&&Boolean(this._range)}connectedCallback(){if(this._connected)return;if(this.hasAttribute("range")){this._connectRange();return}this._connectSingle()}_connectSingle(){let e=this.querySelector(":scope > input:not([type=hidden]):not([type=time]):not([data-time-start]):not([data-time-end])");if(!(e instanceof HTMLInputElement)){console.warn("<date-picker> expects a direct child text input");return}this._connected=!0,this._input=e,this._discoverTimeFields(),this._field=new re(e,{messages:this._messages,locale:this.locale}),this._field.onAttributesChanged=()=>this._syncInputState(),this._field.confirm=(n,s)=>this._confirmDate(n,s),this._setupFormValue(),this._build(),this._syncInputState(),this._bind(),this._syncCalendarOptions();let t=this._adapter(),i=this.getAttribute("value")||(d(e.value)?e.value:t.parse(e.value));if(i&&d(i))this._setValue(i,{emit:!1,format:!0});else if(!e.value)this._setValue("",{emit:!1,format:!1});else e.setCustomValidity(this._messages.invalidDate);if(this._field.hidden)this._field.hidden.defaultValue=this._value;if(e.getAttribute("value")==null&&e.defaultValue==="")e.defaultValue=e.value}_discoverTimeFields(){this._timeFields=[null,null];let e=["data-time-start","data-time-end"];for(let[t,i]of e.entries()){let n=this.querySelectorAll(`:scope > input[${i}]`);if(n.length>1)console.warn(`<date-picker> expects at most one direct child input[${i}]; ignoring extras`);let s=n[0];if(s==null)continue;if(!(s instanceof HTMLInputElement)||s.type!=="time"){console.warn(`<date-picker> input[${i}] must be an <input type="time">; ignoring it`);continue}this._timeFields[t]=s}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 re(e,{messages:this._messages,locale:this.locale}),new re(t,{messages:this._messages,locale:this.locale})],this._range=new be,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 i=this._adapter(),n=d(e.value)?e.value:i.parse(e.value),s=d(t.value)?t.value:i.parse(t.value);if(this._setRange(n||"",s||"",{emit:!1}),e.value.trim()&&!d(n))e.setCustomValidity(this._messages.invalidDate);if(t.value.trim()&&!d(s))t.setCustomValidity(this._messages.invalidDate);if(this._fields[0].hidden)this._fields[0].hidden.defaultValue=this._range.start;if(this._fields[1].hidden)this._fields[1].hidden.defaultValue=this._range.end;if(e.getAttribute("value")==null&&e.defaultValue==="")e.defaultValue=e.value;if(t.getAttribute("value")==null&&t.defaultValue==="")t.defaultValue=t.value}disconnectedCallback(){if(this._connected=!1,this.hide(!1),this._controller?.abort(),this._controller=null,this._clearTimeOrderValidity(),this._timeFields=[null,null],this._rangeMode()){for(let e of this._fields||[])this._teardownField(e);this._fields=null,this._range=null}else this._teardownField(this._field);this._field=null;for(let{button:e}of this._buttons)e.remove();this._buttons=[],this._returnFocus=null,this._panel?.remove(),this._formatHint?.remove(),this._panel=null,this._calendar=null,this._formatHint=null}_teardownField(e){if(!e)return;let t=e.input,i=this._fields?.includes(e)?this._rangeOriginalDescribedBy[this._fields?.indexOf(e)??0]||"":this._originalDescribedBy;if(e.teardown(),i)t.setAttribute("aria-describedby",i);else t.removeAttribute("aria-describedby");t.removeAttribute("role"),t.removeAttribute("aria-haspopup"),t.removeAttribute("aria-expanded"),t.removeAttribute("aria-controls")}attributeChangedCallback(e,t,i){if(!this._connected||this._reflecting||t===i)return;if(e==="value"){if(this._rangeMode())return;if(!i||d(i))this._setValue(i||"",{emit:!1,format:!0,reflect:!1});return}if(e==="locale")this._refreshLocale();if(e==="open-on-focus")return;this._syncCalendarOptions(),this.validate()}get input(){return this._rangeMode()?void 0:this._input}get calendar(){return this._calendar}get value(){return this._rangeMode()?void 0:this._value}set value(e){if(this._rangeMode())throw TypeError("value is not available in range mode; use range");if(e&&!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:i}=he(e);this._setRange(t,i)}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{...this._controlClasses}}set controlClasses(e){let t=ce(e);if(le(t,this._controlClasses))return;if(this._controlClasses=t,this._calendar)this._calendar.controlClasses=this._controlClasses}get messages(){return this._messages}set messages(e){if(this._messages={...G(),...e||{}},this._calendar)this._calendar.messages=this._messages;for(let t of this._fields||[])t.setMessages(this._messages);this._field?.setMessages(this._messages),this._refreshButtonLabel(),this.validate()}get source(){return this._source}set source(e){if(this._source=e||null,this._calendar)this._calendar.source=this._source;if(this._connected)this.validate()}get dateState(){return this._dateState}set dateState(e){if(this._dateState=typeof e==="function"?e:null,this._calendar)this._calendar.dateState=this._dateState;if(this._connected)this.validate()}get renderDay(){return this._renderDay}set renderDay(e){if(this._renderDay=typeof e==="function"?e:null,this._calendar)this._calendar.renderDay=this._renderDay}get isDateDisabled(){return this._isDateDisabled}set isDateDisabled(e){if(this._isDateDisabled=typeof e==="function"?e:null,this._calendar)this._calendar.isDateDisabled=this._isDateDisabled;if(this._connected)this.validate()}get coordinateSpace(){return this._coordinateSpace}set coordinateSpace(e){this._coordinateSpace=e==="document"?"document":"viewport"}_adapter(){return this._field?.adapter??this._fields?.[0]?.adapter??ne(this.locale)}_setupFormValue(){this._field?.setupFormValue()}_syncInputState(){let e=this._input;if(!e)return;this._field?.syncInputState();let t=this._buttons[0]?.button;if(t)t.disabled=e.disabled||e.readOnly;if(this._open&&(e.disabled||e.readOnly))this.hide(!1)}_syncRangeFields(){if(!this._fields)return;for(let t of this._fields)t.syncInputState();for(let{button:t,endpoint:i}of this._buttons){let n=i==="end"?1:0,s=this._fields[n];t.disabled=Boolean(s?.input.disabled||s?.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,i=[this._rangeOriginalDescribedBy[this._fields.indexOf(e)],this._formatHint.id].filter(Boolean).join(" ");t.setAttribute("aria-describedby",i),t.setAttribute("role","combobox"),t.setAttribute("aria-haspopup","dialog"),t.setAttribute("aria-expanded","false"),t.setAttribute("aria-controls",this._panel.id)}}_createTrigger(e){let t=document.createElement("button");if(t.type="button",t.className="dp-picker-button",t.setAttribute("aria-haspopup","dialog"),t.setAttribute("aria-expanded","false"),t.setAttribute("aria-controls",`${this._id}-panel`),e)t.dataset.endpoint=e;return t.innerHTML='<span aria-hidden="true"><svg viewBox="0 0 16 16" width="1em" height="1em" fill="none" stroke="currentColor" stroke-width="1.4" stroke-linecap="round"><rect x="1.75" y="3" width="12.5" height="11" rx="1.75"/><path d="M1.75 6.75h12.5"/><path d="M5.25 1.75v2.5M10.75 1.75v2.5"/></svg></span>',t}_build(){let e=this._rangeMode(),t=[];if(e)for(let[o,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 i=`${this._id}-panel`,n=`${this._id}-format`;this._buttons=t.map(([o,c])=>{let l=this._createTrigger(c);return o.insertAdjacentElement("afterend",l),{button:l,endpoint:c}});let s=document.createElement("div");s.id=i,s.className="dp-picker-panel",s.setAttribute("popover","manual"),s.setAttribute("role","dialog"),s.setAttribute("aria-label",this._messages.calendar);let r=new se;r.selection="none",r.fixedWeeks=!0,s.append(r);let a=document.createElement("span");if(a.id=n,a.className="dp-visually-hidden",this.append(s,a),this._panel=s,this._calendar=r,this._formatHint=a,!e&&this._input){this._originalDescribedBy=this._input.getAttribute("aria-describedby")||"";let o=[this._originalDescribedBy,n].filter(Boolean).join(" ");this._input.setAttribute("aria-describedby",o),this._input.setAttribute("role","combobox"),this._input.setAttribute("aria-haspopup","dialog"),this._input.setAttribute("aria-expanded","false"),this._input.setAttribute("aria-controls",i)}this._refreshLocale(),this._refreshButtonLabel()}_bindPopup(e,t,i){this.ownerDocument.addEventListener("pointerdown",(n)=>{if(!this._open||n.composedPath().includes(this))return;this.hide(!1)},{capture:!0,signal:e}),this.ownerDocument.addEventListener("reset",(n)=>{if(!(n.target instanceof HTMLFormElement)||!t||n.target!==t.form)return;this.hide(!1),queueMicrotask(()=>{if(!n.defaultPrevented)i()})},{capture:!0,signal:e}),this.addEventListener("keydown",(n)=>this._onEscape(n),{signal:e})}_bind(){let e=this._input,t=this._buttons[0]?.button,i=this._calendar;if(!e||!t||!i)return;let n=new AbortController;this._controller=n;let{signal:s}=n;e.addEventListener("input",()=>{this._field?.handleInput()},{signal:s}),e.addEventListener("change",()=>void this._commitText(!1),{signal:s}),e.addEventListener("blur",()=>void this._commitText(!1),{signal:s}),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:s}),e.addEventListener("keydown",(r)=>{this._onFieldKeyDown("",r)},{signal:s});for(let[r,a]of this._timeFields.entries()){if(!a)continue;let o=r===1?"end":"start";a.addEventListener("input",()=>this._revalidateTimeOrder(o),{signal:s}),a.addEventListener("change",()=>this._revalidateTimeOrder(o),{signal:s})}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:s}),t.addEventListener("keydown",(r)=>this._onTriggerKeyDown("",r),{signal:s}),i.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:s}),i.addEventListener("dateloadend",()=>void this.validate(),{signal:s}),this._bindPopup(s,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:i}=t;for(let[n,s]of this._fields.entries()){let r=n===1?"end":"start";s.input.addEventListener("input",()=>s.handleInput(),{signal:i}),s.input.addEventListener("change",()=>void this._commitFieldText(r),{signal:i}),s.input.addEventListener("blur",()=>void this._commitFieldText(r),{signal:i}),s.input.addEventListener("focus",(a)=>this._onFieldFocus(r,a),{signal:i}),s.input.addEventListener("keydown",(a)=>this._onFieldKeyDown(r,a),{signal:i})}for(let n of this._buttons){let s=n.endpoint;if(s==="")continue;n.button.addEventListener("click",(r)=>this._onRangeTriggerClick(s,r),{signal:i}),n.button.addEventListener("keydown",(r)=>this._onTriggerKeyDown(s,r),{signal:i})}e.addEventListener("click",(n)=>{if(this._suppressGridClick){this._suppressGridClick=!1,n.preventDefault(),n.stopImmediatePropagation();return}this._captureGridIntent(n)},{capture:!0,signal:i}),e.addEventListener("keydown",(n)=>this._captureGridIntent(n),{capture:!0,signal:i}),e.addEventListener("dateactivate",(n)=>{let s=n,r=s.detail?.date;if(!d(r))return;queueMicrotask(()=>{if(s.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:i}),e.addEventListener("datefocus",(n)=>this._onGridDateFocus(n),{signal:i}),e.addEventListener("pointerover",(n)=>this._onGridPointerOver(n),{signal:i}),e.addEventListener("pointerleave",()=>this._onGridPointerLeave(),{signal:i}),e.addEventListener("pointerdown",(n)=>this._onGridPointerDown(n),{signal:i}),e.addEventListener("pointermove",(n)=>this._onGridPointerMove(n),{signal:i}),e.addEventListener("pointerup",(n)=>this._onGridPointerUp(n),{signal:i}),e.addEventListener("pointercancel",(n)=>this._onGridPointerCancel(n),{signal:i}),e.addEventListener("lostpointercapture",(n)=>this._onGridPointerCancel(n),{signal:i}),e.addEventListener("dateloadend",()=>void this.validate(),{signal:i}),this._bindPopup(i,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 i=this._boundCanonical(e)||R();t.display=f(i),t.focusedDate=i,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 i=e!==this._range?.activeEndpoint;if(this._lastFocusEndpoint=e,this._range?.focus(e),i)this._rangeCommitId++,this._pendingIntents.clear();if(!this.openOnFocus||this._suppressFocusOpen)return;let n=t.relatedTarget;if(n instanceof Node&&this.contains(n))return;if(!this._open)this.show({moveFocus:!1})}_captureGridIntent(e){if(!this._rangeMode()||!this._range)return;if(e.type==="keydown"){let n=e.key;if(n!=="Enter"&&n!==" ")return}if(!(e.target instanceof Element))return;let i=e.target.closest(".dp-day[data-date]")?.getAttribute("data-date")||"";if(!d(i))return;this._pendingIntents.clear(),this._pendingIntents.set(i,{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 i=[];for(let n of e.changedEndpoints){let s=t[n==="end"?1:0],r=n==="end"?e.range.end:e.range.start;if(!s||s.canonical===r)continue;s.setCanonical(r,{format:!0}),i.push(s)}if(this._syncHighlight(),this._refreshRangeButtonLabel(),this._revalidateRange(e.endpoint),!i.length)return;this._emitRangeChange();for(let n of i)n.input.dispatchEvent(new Event("input",{bubbles:!0})),n.input.dispatchEvent(new Event("change",{bubbles:!0}))}_setPreview(e,t=""){let i=this._calendar;if(!i||!this._range||!this._open)return;let n=d(e)&&!i.getDateState(e).disabled?e:"",s=n?this._range.previewRange(n,t,(r)=>this._boundEditable(r)):null;if(!s){this._clearPreview();return}this._previewDate=n,i.toggleAttribute("data-range-preview",!0),i.highlightedRange=s}_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 i=(e instanceof Element?e.closest(".dp-day[data-date]"):null)?.getAttribute("data-date")||"";return d(i)?i:""}_dateAtPoint(e,t){let i=this.ownerDocument.elementFromPoint(e,t);if(!(i instanceof Element)||!this._calendar?.contains(i))return"";return this._cellDate(i)}_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 i=t.target instanceof Element?t.target.closest(".dp-day[data-date]"):null;if(!(i instanceof HTMLElement))return;let n=i.hasAttribute("data-range-start"),s=i.hasAttribute("data-range-end");if(n===s)return;let r=n?"start":"end",a=this._cellDate(i);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,i=this._drag;if(!i||t.pointerId!==i.pointerId)return;if(!i.active){if(!(Math.abs(t.clientX-i.x)>Ze||Math.abs(t.clientY-i.y)>Ze))return;i.active=!0;try{this._calendar?.setPointerCapture(i.pointerId)}catch{}this._syncDragAffordance()}let n=this._dateAtPoint(t.clientX,t.clientY);if(!n||this._calendar?.getDateState(n).disabled)return;i.date=n,this._setPreview(n,i.endpoint)}_onGridPointerUp(e){let t=e,i=this._drag;if(!i||t.pointerId!==i.pointerId)return;if(this._drag=null,this._releaseDragCapture(i.pointerId),!i.active){this._syncDragAffordance();return}this._suppressGridClick=!0;let n=this._range?.projectEndpoint(i.date,i.endpoint,(r)=>this._boundEditable(r));if(!n||n.status==="refused"||!n.changedEndpoints.length){this._syncHighlight();return}let s=i.endpoint==="start"?n.range.start:n.range.end;this._pendingIntents.clear(),this._pendingIntents.set(s,{id:++this._rangeCommitId,endpoint:i.endpoint}),this._calendar?.activateDate(s)}_onGridPointerCancel(e){let t=e,i=this._drag;if(!i||t.pointerId!==i.pointerId)return;this._drag=null,this._releaseDragCapture(i.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:i}=this._range;if(this._range.complete&&t!==i&&(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[i,n]of this._fields.entries()){if(!n.input.hasAttribute("placeholder")||this._generatedPlaceholder)n.input.placeholder=n.placeholder,this._generatedPlaceholder=!0;let s=i===1?this._range?.end||"":this._range?.start||"";if(s)n.input.value=n.format(s)}this._refreshButtonLabel();return}let t=this._field;if(!t)return;if(t.setLocale(this.locale),e.textContent=`${this._messages.formatHint}: ${t.placeholder}`,!t.input.hasAttribute("placeholder")||this._generatedPlaceholder)t.input.placeholder=t.placeholder,this._generatedPlaceholder=!0;if(this._value)t.input.value=t.format(this._value);this._refreshButtonLabel()}_refreshButtonLabel(){let e=this._buttons[0]?.button;if(!e)return;if(this._rangeMode()){this._refreshRangeButtonLabel();return}let t=this._value?this._messages.changeDate:this._messages.chooseDate,i=this._value?`, ${ie(this._value,this.locale)}`:"";e.setAttribute("aria-label",`${t}${i}`)}_refreshRangeButtonLabel(){if(!this._range)return;let{start:e,end:t}=this._range;for(let{button:i,endpoint:n}of this._buttons){let s=n==="end"?t:e,r=s?this._messages.changeDate:this._messages.chooseDate,a=s?`, ${ie(s,this.locale)}`:"",o=n==="end"?this._messages.rangeEnd:this._messages.rangeStart;i.setAttribute("aria-label",`${r}${a}, ${o}`)}}_reflectValue(e){if(this._reflecting=!0,e)this.setAttribute("value",e);else this.removeAttribute("value");this._reflecting=!1}_setValue(e,t={}){if(e&&!d(e))throw TypeError(`Invalid date-picker value: ${e}`);let i=this._value;if(this._value=e||"",t.reflect!==!1)this._reflectValue(this._value);if(this._field?.setCanonical(this._value,{format:t.format!==!1}),this._calendar){if(this._calendar.value=this._value,this._value&&t.moveDisplay!==!1)this._calendar.focusedDate=this._value}if(this._refreshButtonLabel(),i!==this._value){if(this.dispatchEvent(new CustomEvent("valuechange",{detail:{value:this._value},bubbles:!0})),t.emit&&this._field){let n=this._field.input;n.dispatchEvent(new Event("input",{bubbles:!0})),n.dispatchEvent(new Event("change",{bubbles:!0}))}}}async _confirmDate(e,t={}){let i=this._calendar;if(!i)return{ok:!0};if(t.moveDisplay!==!1){let r=f(e);if(i.display!==r)i.display=r}let n=await i.ensureDate(e),s=i.getDateState(e);if(!n||s.disabled)return{ok:!1,message:this._messages.unavailableDate};return{ok:!0}}async _commitText(e,t={}){let i=this._field;if(!i)return!1;if(!t.force&&!i.isDirty)return!1;let n=await i.commit(t);if(n.status==="stale"||n.status==="invalid")return!1;return this._setValue(n.value||"",{emit:e,format:n.status==="ok",moveDisplay:t.moveDisplay}),!0}async _commitFieldText(e){let t=this._fields;if(!t)return!1;let i=e==="end"?1:0,n=t[i];if(!n?.isDirty)return!1;let s=await n.commit();if(s.status==="stale")return!1;if(s.status==="invalid")return this._orderTags.delete(i),!1;return this._setBound(e,s.value||"",{emit:!1,user:!0,format:s.status==="ok"}),!0}_setBound(e,t,i={}){if(!this._range)return!1;let n=this._fields;if(!n)return!1;let r=n[e==="end"?1:0];if(!r)return!1;if(i.user===!0&&(r.input.disabled||r.input.readOnly))return!1;let a=t||"",o=r.canonical;if(r.setCanonical(a,{format:i.format!==!1}),e==="end")this._range.end=a;else this._range.start=a;let c=o!==a;if(c){if(this._syncHighlight(),this._refreshRangeButtonLabel(),this._emitRangeChange(),i.emit)r.input.dispatchEvent(new Event("input",{bubbles:!0})),r.input.dispatchEvent(new Event("change",{bubbles:!0}))}return this._revalidateRange(e),c}_setRange(e,t,i={}){if(!this._range||!this._fields)return;if(this._range.start=e||"",this._range.end=t||"",this._fields[0].setCanonical(e||"",{format:i.format!==!1}),this._fields[1].setCanonical(t||"",{format:i.format!==!1}),this._syncHighlight(),this._refreshRangeButtonLabel(),this._revalidateRange("start"),this._revalidateRange("end"),i.emit!==!1)this._emitRangeChange()}_boundCanonical(e){return this._range?e==="end"?this._range.end:this._range.start:""}_emitRangeChange(){if(!this._range)return;this.dispatchEvent(new CustomEvent("rangechange",{detail:{...this._range.range},bubbles:!0}))}_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:i}=this._range,n=Boolean(t&&i&&g(i,t)<0),s=["start","end"];for(let r of s){let a=r==="end"?1:0,o=this._fields[a].input,c=r==="end"?this._messages.rangeOrderEnd:this._messages.rangeOrderStart;if(n&&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,i]=this._timeFields,n=["start","end"],s=[t,i],r=t&&!t.disabled?t.value.trim():"",a=i&&!i.disabled?i.value.trim():"",o=Boolean(t&&i&&r&&a)&&De(r)&&De(a)&&Xe(a,r)<0;for(let[c,l]of n.entries()){let h=s[c];if(!h)continue;let b=l==="end"?this._messages.rangeOrderEnd:this._messages.rangeOrderStart;if(o&&l===e)h.setCustomValidity(b),this._timeOrderOwned.add(h);else if(this._timeOrderOwned.has(h))h.setCustomValidity(""),this._timeOrderOwned.delete(h)}}_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 i=this._range?.start||R();this._calendar.display=f(i),this._calendar.focusedDate=i}this.validate()}_focusField(e){let t=e==="end"?1:0,i=this._fields?.[t]?.input;if(!i)return;this._suppressFocusOpen=!0,setTimeout(()=>{i.focus(),this._suppressFocusOpen=!1},0)}_restoreFocus(){let e=this._returnFocus;if(this._returnFocus=null,!(e instanceof HTMLElement)||!e.isConnected||e.matches(":disabled"))return;this._suppressFocusOpen=!0,setTimeout(()=>{e.focus(),this._suppressFocusOpen=!1},0)}_resolveRangeEndpoint(){if(!this._fields)return"";let e=this._lastFocusEndpoint||"start",t=e==="end"?1:0;if(!this._fields[t].input.disabled&&!this._fields[t].input.readOnly)return e;let i=e==="end"?"start":"end",n=i==="end"?1:0;if(!this._fields[n].input.disabled&&!this._fields[n].input.readOnly)return i;return""}async validate(){if(this._rangeMode()){let i=this._fields;if(!i)return!0;for(let[n,s]of i.entries()){let r=await s.commit({moveDisplay:!1});if(r.status==="ok"||r.status==="clear"){let a=n===1?"end":"start";this._setBound(a,r.value||"",{format:r.status==="ok"})}}return this._revalidateRange("start"),this._revalidateRange("end"),i.every((n)=>n.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((i)=>i?.checkValidity()??!0);return e.checkValidity()&&t}show(e={}){let t=this._panel,i=this._calendar;if(!t||!i||!this._buttons.length||this._open)return;if(this._rangeMode()){let r=e.endpoint||this._resolveRangeEndpoint();if(!r)return;this._activateRangeEndpoint(r)}else{let r=this._input;if(!r||r.disabled||r.readOnly)return;let a=this._value||this._adapter().parse(r.value)||R();i.display=f(a),i.focusedDate=a,this._returnFocus=e.returnFocus instanceof HTMLElement?e.returnFocus:r}t.showPopover(),this._open=!0,this._setExpanded(!0);let n=this.coordinateSpace;t.style.position=n==="document"?"absolute":"fixed";let s=()=>Ke(this,t,{placement:"bottom-start",distance:4,shiftPadding:8,coordinateSpace:n});if(s(),this._stopTracking=We(this,t,s),e.moveFocus!==!1)queueMicrotask(()=>i.focusGrid());this.dispatchEvent(new Event("open",{bubbles:!0}))}_setExpanded(e){let t=e?"true":"false";this._input?.setAttribute("aria-expanded",t);for(let{button:i}of this._buttons)i.setAttribute("aria-expanded",t);for(let i of this._fields||[])i.input.setAttribute("aria-expanded",t)}hide(e=!1){if(!this._panel||!this._open)return;this._stopTracking?.(),this._stopTracking=null;try{this._panel.hidePopover()}catch{}if(this._open=!1,this._setExpanded(!1),this._rangeCommitId++,this._pendingIntents.clear(),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,i=this._fields?.[t];if(i&&!i.input.disabled&&!i.input.readOnly)return e}return this._resolveRangeEndpoint()}}function Ee(){if(!customElements.get("date-calendar"))customElements.define("date-calendar",se);if(!customElements.get("date-picker"))customElements.define("date-picker",xe)}Ee();var Je="lekoala-date-picker-styles";if(!document.getElementById(Je)){let e=document.createElement("style");e.id=Je,e.textContent=Ce,document.head.append(e)}Ee();})();
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/** @typedef {{ month: string, year: string, nav: string }} ControlClasses */
|
|
2
|
+
export type ControlClasses = {
|
|
3
|
+
month: string;
|
|
4
|
+
year: string;
|
|
5
|
+
nav: string;
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* Normalize author class tokens. The dp-* namespace belongs to the component.
|
|
9
|
+
* @param {unknown} value
|
|
10
|
+
*/
|
|
11
|
+
export declare function normalizeControlClass(value: unknown): string;
|
|
12
|
+
/** @param {ControlClasses} a @param {ControlClasses} b */
|
|
13
|
+
export declare function sameControlClasses(a: ControlClasses, b: ControlClasses): boolean;
|
|
14
|
+
export declare function getDefaultControlClasses(): {
|
|
15
|
+
month: string;
|
|
16
|
+
year: string;
|
|
17
|
+
nav: string;
|
|
18
|
+
};
|
|
19
|
+
/** @param {Partial<ControlClasses> | null} classes */
|
|
20
|
+
export declare function resolveControlClasses(classes: Partial<ControlClasses> | null): {
|
|
21
|
+
month: string;
|
|
22
|
+
year: string;
|
|
23
|
+
nav: string;
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* Set defaults for subsequently created elements (existing elements are unchanged).
|
|
27
|
+
* @param {Partial<ControlClasses>} classes
|
|
28
|
+
*/
|
|
29
|
+
export declare function setDefaultControlClasses(classes: Partial<ControlClasses>): void;
|
|
30
|
+
//# sourceMappingURL=control-classes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"control-classes.d.ts","sourceRoot":"","sources":["../../src/control-classes.js"],"names":[],"mappings":"AAAA,6EAA6E;AAAzE,YAAwD,cAAc,GAA5D;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,CAAgB;AAE1E;;;GAGG;AACH,wBAAgB,qBAAqB,CAAC,KAAK,EAFhC,OAEgC,UAc1C;AAED,0DAA0D;AAC1D,wBAAgB,kBAAkB,CAAC,CAAC,EADxB,cACwB,EAAE,CAAC,EADD,cACC,WAEtC;AAKD,wBAAgB,wBAAwB;WA9BjB,MAAM;UAAQ,MAAM;SAAO,MAAM;EAgCvD;AAED,sDAAsD;AACtD,wBAAgB,qBAAqB,CAAC,OAAO,EADjC,OAAO,CAAC,cAAc,CAAC,GAAG,IACO;WAnCtB,MAAM;UAAQ,MAAM;SAAO,MAAM;EAyCvD;AAED;;;GAGG;AACH,wBAAgB,wBAAwB,CAAC,OAAO,EAFrC,OAAO,CAAC,cAAc,CAEe,QAE/C"}
|