@lekoala/date-picker 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (104) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +236 -0
  3. package/custom-elements.json +366 -0
  4. package/dist/date-picker.css +344 -0
  5. package/dist/date-picker.js +2693 -0
  6. package/dist/date-picker.min.css +1 -0
  7. package/dist/date-picker.min.js +17 -0
  8. package/dist/date-picker.standalone.min.js +361 -0
  9. package/dist/types/calendar-model.d.ts +34 -0
  10. package/dist/types/calendar-model.d.ts.map +1 -0
  11. package/dist/types/date-calendar.d.ts +228 -0
  12. package/dist/types/date-calendar.d.ts.map +1 -0
  13. package/dist/types/date-field.d.ts +94 -0
  14. package/dist/types/date-field.d.ts.map +1 -0
  15. package/dist/types/date-picker.d.ts +258 -0
  16. package/dist/types/date-picker.d.ts.map +1 -0
  17. package/dist/types/date-range.d.ts +89 -0
  18. package/dist/types/date-range.d.ts.map +1 -0
  19. package/dist/types/date.d.ts +61 -0
  20. package/dist/types/date.d.ts.map +1 -0
  21. package/dist/types/define.d.ts +2 -0
  22. package/dist/types/define.d.ts.map +1 -0
  23. package/dist/types/index.d.ts +9 -0
  24. package/dist/types/index.d.ts.map +1 -0
  25. package/dist/types/intl.d.ts +33 -0
  26. package/dist/types/intl.d.ts.map +1 -0
  27. package/dist/types/locales/ar.d.ts +22 -0
  28. package/dist/types/locales/ar.d.ts.map +1 -0
  29. package/dist/types/locales/de.d.ts +22 -0
  30. package/dist/types/locales/de.d.ts.map +1 -0
  31. package/dist/types/locales/en.d.ts +22 -0
  32. package/dist/types/locales/en.d.ts.map +1 -0
  33. package/dist/types/locales/es.d.ts +22 -0
  34. package/dist/types/locales/es.d.ts.map +1 -0
  35. package/dist/types/locales/fr.d.ts +22 -0
  36. package/dist/types/locales/fr.d.ts.map +1 -0
  37. package/dist/types/locales/hi.d.ts +22 -0
  38. package/dist/types/locales/hi.d.ts.map +1 -0
  39. package/dist/types/locales/id.d.ts +22 -0
  40. package/dist/types/locales/id.d.ts.map +1 -0
  41. package/dist/types/locales/it.d.ts +22 -0
  42. package/dist/types/locales/it.d.ts.map +1 -0
  43. package/dist/types/locales/ja.d.ts +22 -0
  44. package/dist/types/locales/ja.d.ts.map +1 -0
  45. package/dist/types/locales/ko.d.ts +22 -0
  46. package/dist/types/locales/ko.d.ts.map +1 -0
  47. package/dist/types/locales/nl.d.ts +22 -0
  48. package/dist/types/locales/nl.d.ts.map +1 -0
  49. package/dist/types/locales/pl.d.ts +22 -0
  50. package/dist/types/locales/pl.d.ts.map +1 -0
  51. package/dist/types/locales/pt-BR.d.ts +22 -0
  52. package/dist/types/locales/pt-BR.d.ts.map +1 -0
  53. package/dist/types/locales/pt-PT.d.ts +22 -0
  54. package/dist/types/locales/pt-PT.d.ts.map +1 -0
  55. package/dist/types/locales/ru.d.ts +22 -0
  56. package/dist/types/locales/ru.d.ts.map +1 -0
  57. package/dist/types/locales/tr.d.ts +22 -0
  58. package/dist/types/locales/tr.d.ts.map +1 -0
  59. package/dist/types/locales/zh-CN.d.ts +22 -0
  60. package/dist/types/locales/zh-CN.d.ts.map +1 -0
  61. package/dist/types/messages.d.ts +43 -0
  62. package/dist/types/messages.d.ts.map +1 -0
  63. package/dist/types/source.d.ts +28 -0
  64. package/dist/types/source.d.ts.map +1 -0
  65. package/docs/ACCESSIBILITY.md +128 -0
  66. package/docs/API.md +289 -0
  67. package/docs/ARCHITECTURE.md +183 -0
  68. package/docs/AT-CHECKLIST.md +63 -0
  69. package/docs/CALENDAR-INTEGRATION.md +70 -0
  70. package/docs/DECISIONS.md +40 -0
  71. package/docs/MIGRATION-FLATPICKR.md +92 -0
  72. package/docs/ROADMAP.md +105 -0
  73. package/docs/TESTING.md +73 -0
  74. package/docs/USE_CASES.md +128 -0
  75. package/package.json +174 -0
  76. package/src/calendar-model.js +80 -0
  77. package/src/date-calendar.js +800 -0
  78. package/src/date-field.js +203 -0
  79. package/src/date-picker.css +344 -0
  80. package/src/date-picker.js +1140 -0
  81. package/src/date-range.js +172 -0
  82. package/src/date.js +203 -0
  83. package/src/define.js +9 -0
  84. package/src/index.js +15 -0
  85. package/src/intl.js +155 -0
  86. package/src/locales/ar.js +20 -0
  87. package/src/locales/de.js +20 -0
  88. package/src/locales/en.js +20 -0
  89. package/src/locales/es.js +20 -0
  90. package/src/locales/fr.js +20 -0
  91. package/src/locales/hi.js +20 -0
  92. package/src/locales/id.js +20 -0
  93. package/src/locales/it.js +20 -0
  94. package/src/locales/ja.js +20 -0
  95. package/src/locales/ko.js +20 -0
  96. package/src/locales/nl.js +20 -0
  97. package/src/locales/pl.js +20 -0
  98. package/src/locales/pt-BR.js +20 -0
  99. package/src/locales/pt-PT.js +20 -0
  100. package/src/locales/ru.js +20 -0
  101. package/src/locales/tr.js +20 -0
  102. package/src/locales/zh-CN.js +20 -0
  103. package/src/messages.js +31 -0
  104. package/src/source.js +50 -0
@@ -0,0 +1,361 @@
1
+ /*** @lekoala/date-picker v0.1.0 - https://github.com/lekoala/date-picker ***/
2
+ (()=>{var ct=`:where(date-calendar, date-picker) {
3
+ --dp-bg: Canvas;
4
+ --dp-fg: CanvasText;
5
+ --dp-muted: color-mix(in srgb, CanvasText 58%, Canvas);
6
+ --dp-border: color-mix(in srgb, CanvasText 22%, Canvas);
7
+ --dp-hover: color-mix(in srgb, CanvasText 7%, Canvas);
8
+ --dp-accent: Highlight;
9
+ --dp-accent-fg: HighlightText;
10
+ --dp-radius: 0.5rem;
11
+ --dp-day-size: 2.75rem;
12
+ --dp-gap: 0.25rem;
13
+ color: var(--dp-fg);
14
+ font: inherit;
15
+ }
16
+
17
+ .dp-visually-hidden {
18
+ position: absolute !important;
19
+ inline-size: 1px !important;
20
+ block-size: 1px !important;
21
+ padding: 0 !important;
22
+ margin: -1px !important;
23
+ overflow: hidden !important;
24
+ clip: rect(0 0 0 0) !important;
25
+ white-space: nowrap !important;
26
+ border: 0 !important;
27
+ }
28
+
29
+ date-calendar {
30
+ display: block;
31
+ inline-size: max-content;
32
+ max-inline-size: 100%;
33
+ }
34
+
35
+ .dp-calendar-shell {
36
+ inline-size: max-content;
37
+ max-inline-size: 100%;
38
+ }
39
+
40
+ .dp-calendar-header {
41
+ display: grid;
42
+ grid-template-columns: minmax(0, 1fr) auto auto auto;
43
+ align-items: center;
44
+ gap: var(--dp-gap);
45
+ margin-block-end: 0.4rem;
46
+ }
47
+
48
+ .dp-calendar-header .dp-prev {
49
+ margin-inline-start: calc(var(--dp-gap) * 2.5);
50
+ }
51
+
52
+ .dp-calendar-header :where(button, select, input) {
53
+ min-block-size: 2.25rem;
54
+ border: 1px solid var(--dp-border);
55
+ border-radius: calc(var(--dp-radius) * 0.75);
56
+ background: var(--dp-bg);
57
+ color: var(--dp-fg);
58
+ font: inherit;
59
+ }
60
+
61
+ .dp-calendar-header select,
62
+ .dp-calendar-header input {
63
+ min-inline-size: 0;
64
+ padding-inline: 0.45rem;
65
+ }
66
+
67
+ .dp-month-select {
68
+ inline-size: 100%;
69
+ }
70
+
71
+ .dp-year-input {
72
+ inline-size: 5.5rem;
73
+ }
74
+
75
+ .dp-nav {
76
+ display: grid;
77
+ place-items: center;
78
+ inline-size: 2.25rem;
79
+ padding: 0;
80
+ font-size: 1.35rem;
81
+ line-height: 1;
82
+ cursor: pointer;
83
+ }
84
+
85
+ .dp-nav svg {
86
+ display: block;
87
+ inline-size: 1rem;
88
+ block-size: 1rem;
89
+ pointer-events: none;
90
+ }
91
+
92
+ .dp-calendar-header :where(button, select, input):disabled,
93
+ .dp-picker-button:disabled {
94
+ cursor: not-allowed;
95
+ opacity: 0.45;
96
+ }
97
+
98
+ .dp-nav:hover:not(:disabled) {
99
+ background: var(--dp-hover);
100
+ }
101
+
102
+ .dp-day:hover:not([data-disabled="true"]):not([data-selected="true"]):not([data-range-start="true"]):not(
103
+ [data-range-end="true"]
104
+ ) {
105
+ background: var(--dp-hover);
106
+ }
107
+
108
+ .dp-calendar-heading {
109
+ margin: 0 0 0.35rem;
110
+ font-size: 0.875rem;
111
+ font-weight: 600;
112
+ text-align: center;
113
+ }
114
+
115
+ .dp-grid {
116
+ border-collapse: separate;
117
+ /* --dp-gap scopes to the header grid; day-cell spacing stays fixed. */
118
+ border-spacing: 0 0.25rem;
119
+ table-layout: fixed;
120
+ }
121
+
122
+ .dp-grid :where(th, td) {
123
+ box-sizing: border-box;
124
+ inline-size: var(--dp-day-size);
125
+ block-size: var(--dp-day-size);
126
+ padding: 0;
127
+ text-align: center;
128
+ }
129
+
130
+ .dp-grid thead th {
131
+ block-size: 1.6rem;
132
+ color: var(--dp-muted);
133
+ font-size: 0.72rem;
134
+ font-weight: 600;
135
+ }
136
+
137
+ .dp-day {
138
+ position: relative;
139
+ border: 1px solid transparent;
140
+ border-radius: calc(var(--dp-radius) * 0.75);
141
+ cursor: pointer;
142
+ outline: none;
143
+ vertical-align: middle;
144
+ font-size: 0.875rem;
145
+ }
146
+
147
+ .dp-day:focus-visible {
148
+ outline: 2px solid var(--dp-accent);
149
+ outline-offset: 1px;
150
+ z-index: 1;
151
+ }
152
+
153
+ .dp-day[data-selected="true"] {
154
+ background: var(--dp-accent);
155
+ color: var(--dp-accent-fg);
156
+ }
157
+
158
+ .dp-day[data-today="true"]:not([data-selected="true"]) {
159
+ border-color: var(--dp-accent);
160
+ }
161
+
162
+ .dp-day[data-outside-month="true"] {
163
+ color: var(--dp-muted);
164
+ }
165
+
166
+ .dp-day[data-disabled="true"] {
167
+ cursor: not-allowed;
168
+ opacity: 0.42;
169
+ }
170
+
171
+ .dp-day[data-range-start="true"],
172
+ .dp-day[data-range-end="true"] {
173
+ background: var(--dp-accent);
174
+ color: var(--dp-accent-fg);
175
+ }
176
+
177
+ .dp-day[data-in-range="true"] {
178
+ border-radius: 0;
179
+ background: color-mix(in srgb, var(--dp-accent) 18%, var(--dp-bg));
180
+ }
181
+
182
+ /* Join the band without gaps, including the corners beside each endpoint. */
183
+ .dp-day[data-range-start="true"]:has(+ [data-in-range="true"], + [data-range-end="true"]) {
184
+ border-start-end-radius: 0;
185
+ border-end-end-radius: 0;
186
+ }
187
+
188
+ .dp-day:is([data-in-range="true"], [data-range-start="true"]) + .dp-day[data-range-end="true"] {
189
+ border-start-start-radius: 0;
190
+ border-end-start-radius: 0;
191
+ }
192
+
193
+ .dp-day[data-in-range="true"]:first-of-type {
194
+ border-start-start-radius: var(--dp-radius);
195
+ border-end-start-radius: var(--dp-radius);
196
+ }
197
+
198
+ .dp-day[data-in-range="true"]:last-of-type {
199
+ border-start-end-radius: var(--dp-radius);
200
+ border-end-end-radius: var(--dp-radius);
201
+ }
202
+
203
+ .dp-day-number {
204
+ display: block;
205
+ font-variant-numeric: tabular-nums;
206
+ }
207
+
208
+ .dp-day-extra {
209
+ position: absolute;
210
+ inset-inline: 2px;
211
+ inset-block-end: 1px;
212
+ display: flex;
213
+ justify-content: center;
214
+ gap: 2px;
215
+ min-block-size: 0.35rem;
216
+ font-size: 0.55rem;
217
+ line-height: 1;
218
+ pointer-events: none;
219
+ }
220
+
221
+ .dp-week-number,
222
+ .dp-week-heading {
223
+ inline-size: 1.6rem !important;
224
+ color: var(--dp-muted);
225
+ font-size: 0.65rem;
226
+ font-weight: 500;
227
+ }
228
+
229
+ date-picker {
230
+ position: relative;
231
+ display: inline-grid;
232
+ grid-template-columns: minmax(0, 1fr) auto;
233
+ align-items: stretch;
234
+ max-inline-size: 100%;
235
+ }
236
+
237
+ date-picker > input:not([type="hidden"]) {
238
+ grid-column: 1;
239
+ min-inline-size: 0;
240
+ }
241
+
242
+ date-picker[range] > input:not([type="hidden"]) {
243
+ grid-column: 1;
244
+ }
245
+
246
+ date-picker[range] > input[data-range-start] {
247
+ grid-row: 1;
248
+ }
249
+
250
+ date-picker[range] > input[data-range-end] {
251
+ grid-row: 2;
252
+ }
253
+
254
+ .dp-picker-button {
255
+ grid-column: 2;
256
+ min-inline-size: 2.5rem;
257
+ border: 1px solid var(--dp-border);
258
+ border-inline-start: 0;
259
+ border-start-start-radius: 0;
260
+ border-end-start-radius: 0;
261
+ border-start-end-radius: var(--dp-radius);
262
+ border-end-end-radius: var(--dp-radius);
263
+ background: var(--dp-bg);
264
+ color: var(--dp-fg);
265
+ font: inherit;
266
+ cursor: pointer;
267
+ }
268
+
269
+ date-picker[range] > .dp-picker-button {
270
+ grid-row: 1 / span 2;
271
+ }
272
+
273
+ .dp-picker-panel[popover] {
274
+ position: fixed;
275
+ inset: auto;
276
+ margin: 0;
277
+ padding: 0.65rem;
278
+ border: 1px solid var(--dp-border);
279
+ border-radius: var(--dp-radius);
280
+ background: var(--dp-bg);
281
+ color: var(--dp-fg);
282
+ box-shadow: 0 0.5rem 1.5rem rgb(0 0 0 / 0.16);
283
+ max-block-size: var(--available-height, 90svh);
284
+ max-inline-size: calc(100vi - 1rem);
285
+ overflow: auto;
286
+ }
287
+
288
+ .dp-picker-panel:not(:popover-open) {
289
+ display: none;
290
+ }
291
+
292
+ @media (forced-colors: active) {
293
+ .dp-day[data-selected="true"] {
294
+ border: 2px solid Highlight;
295
+ background-color: Canvas;
296
+ color: CanvasText;
297
+ font-weight: 700;
298
+ }
299
+
300
+ .dp-day[data-range-start="true"],
301
+ .dp-day[data-range-end="true"] {
302
+ border: 2px solid Highlight;
303
+ background-color: Canvas;
304
+ color: CanvasText;
305
+ font-weight: 700;
306
+ }
307
+
308
+ .dp-day[data-in-range="true"] {
309
+ color: CanvasText;
310
+ }
311
+
312
+ .dp-day[data-in-range="true"]::after {
313
+ content: "";
314
+ position: absolute;
315
+ inset-inline: 3px;
316
+ inset-block-end: 4px;
317
+ block-size: 1px;
318
+ background-color: Highlight;
319
+ }
320
+
321
+ .dp-day[data-selected="true"]::before {
322
+ content: "";
323
+ position: absolute;
324
+ inset: 3px;
325
+ border: 1px solid CanvasText;
326
+ border-radius: calc(var(--dp-radius) * 0.5);
327
+ pointer-events: none;
328
+ }
329
+
330
+ .dp-day[data-today="true"] {
331
+ border-color: Highlight;
332
+ }
333
+
334
+ .dp-day-extra {
335
+ color: CanvasText;
336
+ forced-color-adjust: none;
337
+ }
338
+
339
+ .dp-day[data-disabled="true"],
340
+ .dp-calendar-header :where(button, select, input):disabled,
341
+ .dp-picker-button:disabled {
342
+ opacity: 1;
343
+ color: GrayText;
344
+ }
345
+ }
346
+ `;var Ft=/^(\d{4})-(\d{2})-(\d{2})$/,Rt=/^(\d{4})-(\d{2})$/;function Ot(t){return t%4===0&&(t%100!==0||t%400===0)}function Z(t,e){if(e===2)return Ot(t)?29:28;return[4,6,9,11].includes(e)?30:31}function F(t){let e=Ft.exec(String(t||""));if(!e)return null;let i=Number(e[1]),s=Number(e[2]),n=Number(e[3]);if(i<1||i>9999||s<1||s>12)return null;if(n<1||n>Z(i,s))return null;return{year:i,month:s,day:n}}function c(t){return F(t)!==null}function f(t){let e=String(t||""),i=Rt.exec(e);if(i){let n=Number(i[2]);if(n>=1&&n<=12)return`${i[1]}-${String(n).padStart(2,"0")}`}let s=F(e);if(!s)throw TypeError(`Invalid civil date/month: ${t}`);return`${String(s.year).padStart(4,"0")}-${String(s.month).padStart(2,"0")}`}function P(t,e,i){let s=`${String(t).padStart(4,"0")}-${String(e).padStart(2,"0")}-${String(i).padStart(2,"0")}`;if(!c(s))throw TypeError(`Invalid civil date: ${s}`);return s}function X(t){let e=new Date(0);return e.setUTCHours(12,0,0,0),e.setUTCFullYear(t.year,t.month-1,t.day),e}function Ht(t){return P(t.getUTCFullYear(),t.getUTCMonth()+1,t.getUTCDate())}function N(t){let e=F(t);if(!e)throw TypeError(`Invalid civil date: ${t}`);return X(e)}function w(t,e){if(!c(t)||!c(e))throw TypeError("compareDates() expects YYYY-MM-DD values");return t===e?0:t<e?-1:1}function I(t,e){let i=F(t);if(!i||!Number.isInteger(e))throw TypeError("addDays() expects a date and integer amount");let s=X(i);return s.setUTCDate(s.getUTCDate()+e),Ht(s)}function J(t,e){let i=F(t);if(!i||!Number.isInteger(e))throw TypeError("addMonths() expects a date and integer amount");let s=i.year*12+(i.month-1)+e,n=Math.floor(s/12),a=(s%12+12)%12+1,o=Math.min(i.day,Z(n,a));return P(n,a,o)}function ut(t,e){let i=F(t);if(!i||!Number.isInteger(e))throw TypeError("addYears() expects a date and integer amount");let s=i.year+e,n=Math.min(i.day,Z(s,i.month));return P(s,i.month,n)}function V(t,e){let i=`${f(t)}-01`;return f(J(i,e))}function zt(t){return`${f(t)}-01`}function Bt(t){let e=F(`${f(t)}-01`);if(!e)throw TypeError(`Invalid month: ${t}`);return P(e.year,e.month,Z(e.year,e.month))}function Vt(t){let e=F(t);if(!e)throw TypeError(`Invalid civil date: ${t}`);return X(e).getUTCDay()}function Q(t,e=1){if(!Number.isInteger(e)||e<0||e>6)throw RangeError("firstDay must be 0..6");let i=(Vt(t)-e+7)%7;return I(t,-i)}function et(t,e=1){return I(Q(t,e),6)}function ht(t,e={}){let i=e.firstDay??1,s=Q(zt(t),i),n=et(Bt(t),i),r=[],a=s;while(w(a,n)<=0){let o=[];for(let l=0;l<7;l++)o.push(I(a,l));r.push(o),a=I(a,7)}return r}function ft(t,e="",i=""){if(!c(t))throw TypeError(`Invalid civil date: ${t}`);if(e&&w(t,e)<0)return e;if(i&&w(t,i)>0)return i;return t}function R(){let t=new Date;return P(t.getFullYear(),t.getMonth()+1,t.getDate())}function pt(t){let e=F(t);if(!e)throw TypeError(`Invalid civil date: ${t}`);let i=X(e),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 it{constructor(t={}){let e=R();this.firstDay=t.firstDay??1,this.value=t.value&&c(t.value)?t.value:"",this.focused=t.focused&&c(t.focused)?t.focused:this.value||e,this.display=t.display?f(t.display):f(this.focused)}setValue(t){if(t&&!c(t))throw TypeError(`Invalid value: ${t}`);return this.value=t||"",this.value}setDisplay(t){let e=f(t),i=Number(this.focused.slice(8,10))||1,s=J(`${e}-01`,0),n=I(s,Math.max(0,i-1));return this.focused=f(n)===e?n:I(`${V(e,1)}-01`,-1),this.display=e,this.display}setFocused(t,e={}){if(!c(t))throw TypeError(`Invalid focused date: ${t}`);if(this.focused=t,e.follow!==!1)this.display=f(t);return this.focused}moveFocusDays(t){return this.setFocused(I(this.focused,t))}moveFocusMonths(t){return this.setFocused(J(this.focused,t))}moveFocusYears(t){return this.setFocused(ut(this.focused,t))}focusWeekStart(){return this.setFocused(Q(this.focused,this.firstDay))}focusWeekEnd(){return this.setFocused(et(this.focused,this.firstDay))}navigateMonth(t){let e=V(this.display,t);return this.setDisplay(e),this.display}}function tt(t){if(t==null)return{start:"",end:""};if(typeof t!=="object")throw TypeError("highlightedRange expects { start, end }");let{start:e="",end:i=""}=t;if(e&&!c(e))throw TypeError(`Invalid range start: ${e}`);if(i&&!c(i))throw TypeError(`Invalid range end: ${i}`);if(!e&&i)throw TypeError("highlightedRange cannot define an end without a start");if(e&&i&&w(i,e)<0)throw TypeError("highlightedRange must be ordered; start must be on or before end");return{start:e,end:i}}function mt(t,e){if(!e||!c(t))return"";let{start:i,end:s}=e;if(!i||!c(i))return"";if(i===t)return s?s===t?"single":"start":"start";if(s&&s===t)return"end";if(s&&w(t,i)>=0&&w(t,s)<=0)return"in";return""}class st{constructor(){this.activeEndpoint="",this.start="",this.end=""}get range(){return{start:this.start,end:this.end}}get complete(){return Boolean(this.start&&this.end&&w(this.end,this.start)>=0)}focus(t){this.activeEndpoint=t}activate(t,e=()=>!0){if(!c(t))throw TypeError(`Invalid range activation: ${t}`);if(this.complete&&(w(t,this.start)<0||w(t,this.end)>0)){let i=w(t,this.start)<0?"start":"end";if(!e(i))return{status:"refused",endpoint:i};return this[i]=t,this.activeEndpoint=i,{status:"complete",endpoint:i}}if(this.activeEndpoint==="end"){if(this.start&&w(t,this.start)<0)return{status:"refused",endpoint:"end"};if(!e("end"))return{status:"refused",endpoint:"end"};return this.end=t,{status:this.start?"complete":"pending",endpoint:"end"}}if(!e("start"))return{status:"refused",endpoint:"start"};if(this.start=t,!e("end"))return{status:"pending",endpoint:"start",close:!0};return this.activeEndpoint="end",{status:"pending",endpoint:"start"}}}var _t=/[\u200e\u200f\u061c\u202a-\u202e\u2066-\u2069]/g;function z(t=""){if(t)return t;if(typeof document<"u"&&document.documentElement.lang)return document.documentElement.lang;if(typeof navigator<"u"&&navigator.language)return navigator.language;return"en-US"}function Pt(t){let e=new Intl.NumberFormat(t,{useGrouping:!1}),i=new Map;for(let s=0;s<=9;s++)i.set(e.format(s),String(s));return i}function gt(t,e){let i=String(t||"").replace(_t,"").trim();for(let[s,n]of Pt(e))i=i.split(s).join(n);return i}function Y(t,e=""){let i=z(e);return new Intl.DateTimeFormat(i,{calendar:"gregory",weekday:"long",year:"numeric",month:"long",day:"numeric",timeZone:"UTC"}).format(N(t))}function yt(t,e=""){let i=z(e);return new Intl.DateTimeFormat(i,{calendar:"gregory",year:"numeric",month:"long",timeZone:"UTC"}).format(N(`${t.slice(0,7)}-15`))}function bt(t="",e="long"){let i=z(t),s=new Intl.DateTimeFormat(i,{calendar:"gregory",month:e,timeZone:"UTC"});return Array.from({length:12},(n,r)=>s.format(N(`2026-${String(r+1).padStart(2,"0")}-15`)))}function nt(t="",e=1,i="short"){let s=z(t),n=new Intl.DateTimeFormat(s,{calendar:"gregory",weekday:i,timeZone:"UTC"}),r=N("2026-01-04");return Array.from({length:7},(a,o)=>{let l=new Date(r);return l.setUTCDate(r.getUTCDate()+(e+o)%7),n.format(l)})}function Nt(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function K(t=""){let e=z(t),i=new Intl.DateTimeFormat(e,{calendar:"gregory",year:"numeric",month:"2-digit",day:"2-digit",timeZone:"UTC"}),s=N("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(_t,"")}).join(""),o=n.map((d)=>{if(d.type==="day"||d.type==="month")return"(\\d{1,2})";if(d.type==="year")return"(\\d{4})";let h=gt(d.value,e).replace(/\s+/g," ");return Nt(h).replace(/\\ /g,"\\s*")}).join(""),l=new RegExp(`^\\s*${o}\\s*$`);return{locale:e,placeholder:a,format(d){if(!c(d))return"";return i.format(N(d))},parse(d){let h=gt(d,e);if(c(h))return h;let E=l.exec(h);if(!E)return"";let g={};if(r.forEach((b,k)=>{g[b]=Number(E[k+1])}),!g.year||!g.month||!g.day)return"";try{return P(g.year,g.month,g.day)}catch{return""}}}}var Ut={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"},Yt={...Ut};function W(){return{...Yt}}function vt(t){let e=t&&typeof t==="object"&&!Array.isArray(t)&&"dates"in t?t.dates:t,i=new Map;if(Array.isArray(e)){for(let s of e){if(!s||typeof s!=="object"||!("date"in s))continue;let{date:n,...r}=s;i.set(String(n),r)}return i}if(e&&typeof e==="object")for(let[s,n]of Object.entries(e))i.set(s,n&&typeof n==="object"?n:{});return i}var Wt=0;function A(t){return String(t).replaceAll("&","&amp;").replaceAll("<","&lt;").replaceAll(">","&gt;").replaceAll('"',"&quot;").replaceAll("'","&#039;")}function jt(t){let e=Number(t);return Number.isInteger(e)&&e>=0&&e<=6?e:1}function Kt(t){return Number(t.slice(0,4))}function qt(t){switch(t){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 Gt(t){if(t==="single")return"rangeSingle";if(t==="start")return"rangeStart";if(t==="end")return"rangeEnd";if(t==="in")return"rangeInRange";return""}class q extends HTMLElement{static observedAttributes=["value","display","min","max","first-day","locale","fixed-weeks","show-week-numbers","selection"];constructor(){super();this._id=`date-calendar-${++Wt}`,this._model=new it,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 z(this.getAttribute("locale")||"")}set locale(t){if(t)this.setAttribute("locale",t);else this.removeAttribute("locale")}get value(){return this._model.value}set value(t){let e=t||"";if(e&&!c(e))throw TypeError(`Invalid calendar value: ${e}`);if(e===this._model.value)return;if(this._model.setValue(e),this._reflect("value",e),this._connected)this.render()}get display(){return this._model.display}set display(t){this._setDisplay(t,{emit:!1})}get focusedDate(){return this._model.focused}set focusedDate(t){let e=t||"";if(e===this._model.focused)return;this.focusDate(e,{moveFocus:!1})}get min(){let t=this.getAttribute("min")||"";return c(t)?t:""}set min(t){if(t)this.setAttribute("min",t);else this.removeAttribute("min")}get max(){let t=this.getAttribute("max")||"";return c(t)?t:""}set max(t){if(t)this.setAttribute("max",t);else this.removeAttribute("max")}get firstDay(){return jt(this.getAttribute("first-day")||"1")}set firstDay(t){this.setAttribute("first-day",String(t))}get selection(){return this.getAttribute("selection")==="none"?"none":"single"}set selection(t){this.setAttribute("selection",t==="none"?"none":"single")}get highlightedRange(){return{...this._highlightedRange}}set highlightedRange(t){let e=tt(t);if(e.start===this._highlightedRange.start&&e.end===this._highlightedRange.end)return;if(this._highlightedRange=e,this._connected)this.render()}get fixedWeeks(){return this.hasAttribute("fixed-weeks")}set fixedWeeks(t){this.toggleAttribute("fixed-weeks",Boolean(t))}get showWeekNumbers(){return this.hasAttribute("show-week-numbers")}set showWeekNumbers(t){this.toggleAttribute("show-week-numbers",Boolean(t))}get messages(){return this._messages}set messages(t){if(this._messages={...W(),...t||{}},this._connected)this.render()}get source(){return this._source}set source(t){this._source=t||null,this.refreshSource()}get dateState(){return this._dateState}set dateState(t){if(this._dateState=typeof t==="function"?t:null,this._connected)this.render()}get renderDay(){return this._renderDay}set renderDay(t){if(this._renderDay=typeof t==="function"?t:null,this._connected)this.render()}get isDateDisabled(){return this._isDateDisabled}set isDateDisabled(t){if(this._isDateDisabled=typeof t==="function"?t:null,this._connected)this.render()}_syncModel(){let t=this.firstDay;this._model.firstDay=t;let e=this.getAttribute("value")||"";if(!e||c(e))this._model.value=e;let 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(t,e){if(this._rendering=!0,e){if(this.getAttribute(t)!==e)this.setAttribute(t,e)}else if(this.hasAttribute(t))this.removeAttribute(t);this._rendering=!1}_clamp(t){return ft(t,this.min,this.max)}_weeks(t=this.display){let e=ht(t,{firstDay:this.firstDay});if(!this.fixedWeeks||e.length>=6)return e;let i=e[e.length-1]?.[6]||"";while(e.length<6&&i){let s=[];for(let n=1;n<=7;n++)s.push(I(i,n));e.push(s),i=s[6]}return e}_focusTargetKey(t){if(t.matches(".dp-month-select, .dp-year-select, .dp-year-input")&&t.id)return`#${CSS.escape(t.id)}`;if(t.matches(".dp-nav[data-calendar-action]"))return`.dp-nav[data-calendar-action="${CSS.escape(t.dataset.calendarAction||"")}"]`;if(t.matches(".dp-day[data-date]")){let e=t.getAttribute("data-date")||"";if(c(e))return`.dp-day[data-date="${e}"]`}return""}_range(t=this.display){let e=this._weeks(t),i=e[0],s=e[e.length-1];if(!i||!s)throw Error("Calendar month produced no weeks");return{start:i[0],end:s[6]}}getDateState(t){let e=this._sourceStates.get(t)||{},i=this._dateState?.(t,{...e})||{},s={...e,...i},n=this.min&&w(t,this.min)<0||this.max&&w(t,this.max)>0,a=s.enabled===!0?!1:Boolean(this._isDateDisabled?.(t)),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(t){if(!c(t)||!this._source)return!0;return await this._loadDisplay(f(t),!1)==="loaded"}async _loadDisplay(t,e=!0){if(!this._source)return"loaded";let i=this._range(t),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,h]of vt(l))this._sourceStates.set(d,h);if(this._loadedRanges.add(s),this.dispatchEvent(new CustomEvent("dateloadend",{detail:i,bubbles:!0})),e&&this._connected&&f(this.display)===f(t))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(t,e={}){let i=this._model.display;if(this._model.setDisplay(t),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(e.emit!==!1&&i!==this._model.display)this._emitDisplayChange();return this._model.display}_emitDisplayChange(){let t=this._range();this.dispatchEvent(new CustomEvent("displaychange",{detail:{display:this.display,...t},bubbles:!0}))}previousMonth(){return this._setDisplay(V(this.display,-1))}nextMonth(){return this._setDisplay(V(this.display,1))}focusDate(t,e={}){if(!c(t))throw TypeError(`Invalid date: ${t}`);let i=this._clamp(t),s=this.display,n=this._model.focused,r=e.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(t,e,i=!0){let s=t?this.querySelector(`.dp-day[data-date="${CSS.escape(t)}"]`):null,n=this.querySelector(`.dp-day[data-date="${CSS.escape(e)}"]`);if(s instanceof HTMLElement)s.tabIndex=-1;if(n instanceof HTMLElement){if(n.tabIndex=0,i)n.focus()}else if(i)this.focusGrid()}_moveSelectionDom(t,e){if(t){let i=this.querySelector(`.dp-day[data-date="${CSS.escape(t)}"]`);if(i instanceof HTMLElement)i.removeAttribute("data-selected"),i.removeAttribute("aria-selected")}if(e){let i=this.querySelector(`.dp-day[data-date="${CSS.escape(e)}"]`);if(i instanceof HTMLElement)return i.setAttribute("data-selected","true"),i.setAttribute("aria-selected","true"),!0}return!1}focusGrid(){let t=this.querySelector(`.dp-day[data-date="${CSS.escape(this.focusedDate)}"]`);if(t instanceof HTMLElement)t.focus()}async _activate(t){let e=await this.ensureDate(t),i=this.getDateState(t);if(!e||i.disabled)return this.dispatchEvent(new CustomEvent("dateinvalid",{detail:{date:t,state:i},bubbles:!0})),!1;if(!this.dispatchEvent(new CustomEvent("dateactivate",{detail:{date:t,state:i},bubbles:!0,cancelable:!0})))return!1;if(this.selection==="single"){let n=this._model.value;if(this._model.setValue(t),this._reflect("value",t),this.dispatchEvent(new CustomEvent("datechange",{detail:{value:t},bubbles:!0})),this.dispatchEvent(new Event("change",{bubbles:!0})),this._connected)if(f(t)===this.display)this._moveSelectionDom(n,t);else this.render()}else if(this._connected){if(f(t)!==this.display)this.render()}return!0}_onClick(t){let e=t.target;if(!(e instanceof Element))return;let i=e.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=e.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(t){let e=t.target;if(e instanceof HTMLSelectElement&&e.matches(".dp-month-select")){this._setDisplay(`${this.display.slice(0,4)}-${e.value}`);return}if(e instanceof HTMLSelectElement&&e.matches(".dp-year-select")){this._setDisplay(`${e.value}-${this.display.slice(5,7)}`);return}if(e instanceof HTMLInputElement&&e.matches(".dp-year-input")){let i=Number(e.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(t){let e=t.target;if(!(e instanceof HTMLTableCellElement)||!e.matches(".dp-day[data-date]"))return;let i=e.dataset.date||"";if(c(i))this._model.focused=i}_onKeyDown(t){let e=t.target;if(!(e instanceof HTMLTableCellElement)||!e.matches(".dp-day[data-date]"))return;let i=e.dataset.date||this.focusedDate;if(t.key==="Enter"||t.key===" "){t.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}),t.key==="ArrowLeft")this._model.moveFocusDays(-1);else if(t.key==="ArrowRight")this._model.moveFocusDays(1);else if(t.key==="ArrowUp")this._model.moveFocusDays(-7);else if(t.key==="ArrowDown")this._model.moveFocusDays(7);else if(t.key==="Home")this._model.focusWeekStart();else if(t.key==="End")this._model.focusWeekEnd();else if(t.key==="PageUp")t.shiftKey?this._model.moveFocusYears(-1):this._model.moveFocusMonths(-1);else if(t.key==="PageDown")t.shiftKey?this._model.moveFocusYears(1):this._model.moveFocusMonths(1);else return;let r=this._model.focused;if(this._model.focused=s,this._model.display=n,!r)return;t.preventDefault(),this.focusDate(this._clamp(r))}render(t=!0){if(!this._connected)return;let e=this.locale,i=this.display,s=Kt(i),n=Number(i.slice(5,7)),r=bt(e,"long"),a=nt(e,this.firstDay,"short"),o=nt(e,this.firstDay,"long"),l=this._weeks(),d=R(),h=`${this._id}-heading`,E=`${this._id}-grid`,g=this.min?f(this.min):"",b=this.max?f(this.max):"",k=Boolean(g&&V(i,-1)<g),T=Boolean(b&&V(i,1)>b),x=this.min?` min="${Number(this.min.slice(0,4))}"`:"",_=this.max?` max="${Number(this.max.slice(0,4))}"`:"",m=this.showWeekNumbers&&this.firstDay===1,C=m?`<th scope="col" class="dp-week-heading" abbr="${A(this._messages.week)}">#</th>`:"",v=r.map((D,S)=>{let p=S+1,u=`${String(s).padStart(4,"0")}-${String(p).padStart(2,"0")}`,y=g&&u<g||b&&u>b;return`<option value="${String(p).padStart(2,"0")}"${p===n?" selected":""}${y?" disabled":""}>${A(D)}</option>`}).join(""),B=a.map((D,S)=>`<th scope="col" abbr="${A(o[S])}">${A(D.replace(".",""))}</th>`).join(""),U=l.map((D)=>{let S=m?`<th scope="row" class="dp-week-number">${pt(D[0])}</th>`:"",p=D.map((u)=>{let y=this.getDateState(u),M=f(u)!==i,L=this.value===u,j=this.focusedDate===u,ot=u===d,dt=mt(u,this._highlightedRange),lt=Gt(dt),$t=typeof y.description==="string"?y.description:"",Lt=[Y(u,e),$t,lt?this._messages[lt]:"",y.disabled?this._messages.unavailable:""].filter(Boolean).join(". ");return`<td class="dp-day" data-date="${u}"${M?' data-outside-month="true"':""}${ot?' data-today="true" aria-current="date"':""}${L?' data-selected="true" aria-selected="true"':""}${qt(dt)}${y.disabled?' data-disabled="true" aria-disabled="true"':""} tabindex="${j?"0":"-1"}" aria-label="${A(Lt)}"><span class="dp-day-number" aria-hidden="true">${Number(u.slice(8,10))}</span><span class="dp-day-extra" aria-hidden="true"></span></td>`}).join("");return`<tr>${S}${p}</tr>`}).join(""),O=document.activeElement,H=O instanceof HTMLElement&&this.contains(O)?this._focusTargetKey(O):"";if(this._rendering=!0,this.innerHTML=`
347
+ <div class="dp-calendar-shell">
348
+ <div class="dp-calendar-header">
349
+ <label class="dp-visually-hidden" for="${this._id}-month">${A(this._messages.month)}</label>
350
+ <select id="${this._id}-month" class="dp-month-select" aria-label="${A(this._messages.month)}">${v}</select>
351
+ <label class="dp-visually-hidden" for="${this._id}-year">${A(this._messages.year)}</label>
352
+ <input id="${this._id}-year" class="dp-year-input" type="number" inputmode="numeric" value="${s}"${x}${_} aria-label="${A(this._messages.year)}">
353
+ <button type="button" class="dp-nav dp-prev" data-calendar-action="previous" aria-label="${A(this._messages.previousMonth)}"${k?" disabled":""}><svg aria-hidden="true" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><path d="m10 4-4 4 4 4"/></svg></button>
354
+ <button type="button" class="dp-nav dp-next" data-calendar-action="next" aria-label="${A(this._messages.nextMonth)}"${T?" disabled":""}><svg aria-hidden="true" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><path d="m6 4 4 4-4 4"/></svg></button>
355
+ </div>
356
+ <h2 id="${h}" class="dp-calendar-heading" aria-live="polite">${A(yt(`${i}-15`,e))}</h2>
357
+ <table id="${E}" class="dp-grid" role="grid" aria-labelledby="${h}">
358
+ <thead><tr>${C}${B}</tr></thead>
359
+ <tbody>${U}</tbody>
360
+ </table>
361
+ </div>`,this._rendering=!1,H)queueMicrotask(()=>{let D=this.querySelector(H);if(D instanceof HTMLElement)D.focus()});if(this._renderDay)for(let D of this.querySelectorAll(".dp-day[data-date]")){if(!(D instanceof HTMLTableCellElement))continue;let S=D.dataset.date||"",p=D.querySelector(".dp-day-extra");if(!(p instanceof HTMLElement))continue;let u=this._renderDay(S,this.getDateState(S));if(u instanceof Node)p.append(u);else if(u!==void 0&&u!==null)p.textContent=String(u)}if(t)this._loadDisplay(i)}}function Ct(t){return t==="top"||t==="bottom"?"x":"y"}function Zt(t){let[e,i=null]=t.split("-");return{side:e,align:i,crossAxis:Ct(e)}}function Xt(t){return{top:"bottom",bottom:"top",left:"right",right:"left"}[t]||t}function Jt(t,e,i,s,n,r){let a=Ct(i),o=t.x+t.width/2-e.width/2,l=t.y+t.height/2-e.height/2,d=t[a==="x"?"width":"height"]/2-e[a==="x"?"width":"height"]/2,h;switch(i){case"top":h={x:o,y:t.y-e.height-r};break;case"bottom":h={x:o,y:t.y+t.height+r};break;case"right":h={x:t.x+t.width+r,y:l};break;case"left":h={x:t.x-e.width-r,y:l};break;default:h={x:t.x,y:t.y}}if(s==="start"||s==="end"){let E=(n&&a==="x"?-1:1)*(s==="end"?1:-1);h[a]+=d*E}return h}function Qt(t,e,i,s){return Math.max(i-t,0)+Math.max(t+e-s,0)}function te(t){let e="dir"in t?t.dir:"";if(e==="rtl")return!0;if(e==="ltr")return!1;let i=t.ownerDocument?.defaultView;if(i?.CSS?.supports?.("selector(:dir(rtl))")&&typeof t.matches==="function")return t.matches(":dir(rtl)");return Boolean(i?.Element&&t instanceof i.Element&&i.getComputedStyle(t).direction==="rtl")}var ee=25;function ie(t){let e=t.defaultView;if(!e)return null;let i=t.documentElement,s=e.visualViewport,n=s?.offsetLeft||0,r=s?.offsetTop||0,a=s?.width||i.clientWidth||e.innerWidth,o=s?.height||i.clientHeight||e.innerHeight,l=t.compatMode==="BackCompat"?a-i.clientWidth:i.clientWidth-i.getBoundingClientRect().width;if(l>0&&l<=ee){let d=e.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 se(t,e){return e.scope?e.scope.getBoundingClientRect():ie(t.ownerDocument)}function wt(t,e,i,s,n){let r=i+n,a=s-e-n,o=a>=r,l=o?r:i,d=o?a:s-e;return Math.max(l,Math.min(t,d))}function xt(t,e,i){if(!i)return 50;let s=(t-e)/i*100;return Math.round(Math.min(100,Math.max(0,s))*1000)/1000}function ne(t,e){return t.right<e.x||t.left>e.right||t.bottom<e.y||t.top>e.bottom}function re(t,e,i,s,n){if(e==="top")return Math.max(0,t.top-i.y-s-n);if(e==="bottom")return Math.max(0,i.bottom-t.bottom-s-n);return Math.max(0,i.height-n*2)}function ae(t){if(t.hidden)return!1;if(typeof t.checkVisibility==="function")return t.checkVisibility();return t.getClientRects().length>0}function At(t){let{offsetWidth:e,offsetHeight:i}=t;if(e&&i)return{width:e,height:i};let s=t.getBoundingClientRect();return{width:e||s.width,height:i||s.height}}var Dt=new WeakMap,Et={scroll:0,resize:1,"element-resize":2};function oe(t){let e=t.defaultView;if(!e)throw TypeError("floating must belong to a document with a browsing context");let i=new Set,s=new Map,n=e.ResizeObserver,r=!1,a=!1,o=e.visualViewport;function l(x,_){let m=s.get(x);if(m===void 0||Et[_]>Et[m])s.set(x,_)}function d(){if(r)return;r=!0,e.requestAnimationFrame(()=>{let x=[...s];s.clear(),r=!1;for(let[_,m]of x){if(!i.has(_)||!_.floating.isConnected)continue;_.callback({type:m})}})}function h(x){for(let _ of i)l(_,x);d()}function E(x){if(!n)return null;let _=new Set,m=new n((B)=>{let U=!1;for(let O of B)if(_.has(O.target))U=!0;else _.add(O.target);if(!U)return;l(x,"element-resize"),d()}),{reference:C,floating:v}=x;if(C)m.observe(C);if(v!==C)m.observe(v);return m}let g=()=>h("scroll"),b=()=>h("resize");function k(){if(a)return;t.addEventListener("scroll",g,{passive:!0,capture:!0}),e.addEventListener("resize",b,{passive:!0}),o?.addEventListener("scroll",g,{passive:!0}),o?.addEventListener("resize",b,{passive:!0}),a=!0}function T(){if(!a)return;t.removeEventListener("scroll",g,{capture:!0}),e.removeEventListener("resize",b),o?.removeEventListener("scroll",g),o?.removeEventListener("resize",b),a=!1}return{add(x,_,m){let C={reference:x,floating:_,callback:m};i.add(C),k();let v=E(C),B=!1;return()=>{if(B)return;if(B=!0,i.delete(C),s.delete(C),v?.disconnect(),i.size===0)T()}}}}function de(t){let e=t.ownerDocument,i=Dt.get(e);if(!i)i=oe(e),Dt.set(e,i);return i}function Tt(t,e,i){if(!e?.ownerDocument)throw TypeError("autoUpdate() expects a floating HTMLElement");if(t&&t.ownerDocument!==e.ownerDocument)throw TypeError("reference and floating must belong to the same document");if(typeof i!=="function")throw TypeError("callback must be a function");return de(e).add(t,e,i)}function kt(t,e,i){if(!ae(e))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:h}=Zt(s),E=d?te(t):!1,g=t.getClientRects(),b=l==="bottom"?g[g.length-1]:g[0];if(!b)return null;let k=se(t,i);if(!k||ne(b,k))return null;let T=At(e),x={x:{size:T.width,start:k.x,end:k.right},y:{size:T.height,start:k.y,end:k.bottom}},_=(p,u)=>Jt(b,T,p,u,E,n),m=(p,u)=>{let{size:y,start:M,end:L}=x[u];return Qt(p,y,M+o,L-o)},C=(p,u)=>{let{size:y,start:M,end:L}=x[u];return m(a?wt(p,y,M,L,o):p,u)},v=_(l,d);if(r){let p=h==="x"?"y":"x",u=m(v[p],p);if(u>0){let y=Xt(l),M=_(y,d),L=m(M[p],p);if(L<u)l=y,v=M,u=L}if(p==="x"&&u>0){let y=_("top",d),M=_("bottom",d),L=m(M.y,"y")<m(y.y,"y"),j=L?M:y;if(m(j.y,"y")+C(j.x,"x")<u+C(v.y,"y"))l=L?"bottom":"top",h="x",v=j}}if(h==="x"&&a&&d){let p=m(v.x,"x");if(p>0){let u=d==="end"?"start":"end",y=_(l,u);if(m(y.x,"x")<p)d=u,v=y}}if(a){let{size:p,start:u,end:y}=x[h];v[h]=wt(v[h],p,u,y,o)}let B=xt(b.x+b.width/2,v.x,T.width),U=xt(b.y+b.height/2,v.y,T.height),O=`${re(b,l,k,n,o)}px`,{style:H}=e,D=H.getPropertyValue("--available-height")!==O;H.left=`${v.x}px`,H.top=`${v.y}px`,H.setProperty("--arrow-x",`${B}%`),H.setProperty("--arrow-y",`${U}%`),H.setProperty("--available-height",O);let S=d?`${l}-${d}`:l;return e.dataset.placement=S,{width:T.width,height:T.height,roomChanged:D,placement:S}}function St(t,e,i={}){let s=kt(t,e,i);if(!s)return!1;if(s.roomChanged){let n=At(e);if(n.width!==s.width||n.height!==s.height)kt(t,e,{...i,placement:s.placement,flip:!1})}return!0}class G{constructor(t,e={}){this.input=t,this.messages=e.messages||{},this.adapter=K(e.locale||""),this.hidden=null,this.canonical="",this._dirty=!1,this._commitId=0,this._originalName=t.getAttribute("name")||"",this._attributeObserver=null,this.onAttributesChanged=null,this.confirm=null}setLocale(t){this.adapter=K(t||"")}setMessages(t){this.messages=t||{}}format(t){return this.adapter.format(t)}parse(t){return this.adapter.parse(t)}get placeholder(){return this.adapter.placeholder}get isDisabled(){return this.input.disabled}get isReadOnly(){return this.input.readOnly}setupFormValue(){let t=this.input;this._originalName=t.getAttribute("name")||"",this._attributeObserver=new MutationObserver(()=>this.onAttributesChanged?.()),this._attributeObserver.observe(t,{attributes:!0,attributeFilter:["disabled","readonly","name","form"]}),this.syncInputState()}syncInputState(){let t=this.input,e=t.getAttribute("name")||"";if(e){if(!this.hidden){let i=document.createElement("input");i.type="hidden",i.value=this.canonical,t.insertAdjacentElement("afterend",i),this.hidden=i}if(this.hidden)this.hidden.name=e;t.removeAttribute("name")}if(this.hidden){if(t.hasAttribute("form"))this.hidden.setAttribute("form",t.getAttribute("form")||"");else this.hidden.removeAttribute("form");this.hidden.disabled=t.disabled}}dirty(){this._commitId++}get isDirty(){return this._dirty}handleInput(){let t=this.input;if(this._dirty=!0,this.dirty(),this.hidden)this.hidden.value="";let e=t.value.trim();if(!e){t.setCustomValidity("");return}let i=this.canonical?this.adapter.format(this.canonical):"";t.setCustomValidity(e===i?"":this.messages.invalidDate)}async commit(){let t=this.input,e=++this._commitId,i=t.value.trim();if(!i){if(e!==this._commitId)return{status:"stale"};return t.setCustomValidity(""),{status:"clear",value:""}}let s=this.adapter.parse(i);if(!s){if(e!==this._commitId)return{status:"stale"};if(this.hidden)this.hidden.value="";return t.setCustomValidity(this.messages.invalidDate),{status:"invalid"}}if(this.confirm){let n=await this.confirm(s);if(e!==this._commitId)return{status:"stale"};if(!n?.ok){if(this.hidden)this.hidden.value="";return t.setCustomValidity(n?.message||this.messages.unavailableDate),{status:"invalid"}}}return{status:"ok",value:s}}setCanonical(t,e={}){let i=t||"";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(e.format!==!1)this.input.value=i?this.adapter.format(i):"";this.input.setCustomValidity("")}restoreDefault(){let t=String(this.input.defaultValue??"").trim(),e=c(t)?t:this.adapter.parse(t);return e&&c(e)?e:""}teardown(){this._attributeObserver?.disconnect(),this._attributeObserver=null;let t=this.hidden?.getAttribute("name")||this._originalName;if(t)this.input.setAttribute("name",t);this.hidden?.remove(),this.hidden=null}}var le=0;class rt extends HTMLElement{static observedAttributes=["value","locale","min","max","open-on-focus"];constructor(){super();this._id=`date-picker-${++le}`,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._lastFocusEndpoint="",this._rangeCommitId=0,this._pendingIntents=new Map,this._button=null,this._panel=null,this._calendar=null,this._originalDescribedBy="",this._rangeOriginalDescribedBy=["",""],this._formatHint=null,this._generatedPlaceholder=!1,this._controller=null,this._stopTracking=null,this._open=!1,this._suppressFocusOpen=!1,this._messages=W(),this._source=null,this._dateState=null,this._renderDay=null,this._isDateDisabled=null}_rangeMode(){return this.hasAttribute("range")&&Boolean(this._range)}connectedCallback(){if(this._connected)return;if(this.hasAttribute("range")){this._connectRange();return}this._connectSingle()}_connectSingle(){let t=this.querySelector(":scope > input:not([type=hidden])");if(!(t instanceof HTMLInputElement)){console.warn("<date-picker> expects a direct child text input");return}this._connected=!0,this._input=t,this._field=new G(t,{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 e=this._adapter(),i=this.getAttribute("value")||(c(t.value)?t.value:e.parse(t.value));if(i&&c(i))this._setValue(i,{emit:!1,format:!0});else if(!t.value)this._setValue("",{emit:!1,format:!1});else t.setCustomValidity(this._messages.invalidDate);if(this._field.hidden)this._field.hidden.defaultValue=this._value;if(t.getAttribute("value")==null&&t.defaultValue==="")t.defaultValue=t.value}_connectRange(){let t=this.querySelector(":scope > input[data-range-start]"),e=this.querySelector(":scope > input[data-range-end]");if(!(t instanceof HTMLInputElement)||!(e instanceof HTMLInputElement)){console.warn("<date-picker range> expects direct child inputs marked [data-range-start] and [data-range-end]");return}this._connected=!0,this._input=null,this._fields=[new G(t,{messages:this._messages,locale:this.locale}),new G(e,{messages:this._messages,locale:this.locale})],this._range=new st,this._rangeOriginalDescribedBy=[t.getAttribute("aria-describedby")||"",e.getAttribute("aria-describedby")||""];for(let r of this._fields)r.onAttributesChanged=()=>this._syncRangeFields(),r.confirm=(a)=>this._confirmDate(a),r.setupFormValue();this._build(e),this._setRangeAria(),this._syncRangeFields(),this._bindRange(),this._syncCalendarOptions();let i=this._adapter(),s=c(t.value)?t.value:i.parse(t.value),n=c(e.value)?e.value:i.parse(e.value);if(this._setRange(s||"",n||"",{emit:!1}),t.value.trim()&&!c(s))t.setCustomValidity(this._messages.invalidDate);if(e.value.trim()&&!c(n))e.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(t.getAttribute("value")==null&&t.defaultValue==="")t.defaultValue=t.value;if(e.getAttribute("value")==null&&e.defaultValue==="")e.defaultValue=e.value}disconnectedCallback(){if(this._connected=!1,this.hide(!1),this._controller?.abort(),this._controller=null,this._rangeMode()){for(let t of this._fields||[])this._teardownField(t);this._fields=null,this._range=null}else this._teardownField(this._field);this._field=null,this._button?.remove(),this._panel?.remove(),this._formatHint?.remove(),this._button=null,this._panel=null,this._calendar=null,this._formatHint=null}_teardownField(t){if(!t)return;let e=t.input,i=this._fields?.includes(t)?this._rangeOriginalDescribedBy[this._fields?.indexOf(t)??0]||"":this._originalDescribedBy;if(t.teardown(),i)e.setAttribute("aria-describedby",i);else e.removeAttribute("aria-describedby");e.removeAttribute("role"),e.removeAttribute("aria-haspopup"),e.removeAttribute("aria-expanded"),e.removeAttribute("aria-controls")}attributeChangedCallback(t,e,i){if(!this._connected||this._reflecting||e===i)return;if(t==="value"){if(this._rangeMode())return;if(!i||c(i))this._setValue(i||"",{emit:!1,format:!0,reflect:!1});return}if(t==="locale")this._refreshLocale();if(t==="open-on-focus")return;this._syncCalendarOptions(),this.validate()}get input(){return this._rangeMode()?void 0:this._input}get calendar(){return this._calendar}get value(){return this._rangeMode()?void 0:this._value}set value(t){if(this._rangeMode())throw TypeError("value is not available in range mode; use range");if(t&&!c(t))throw TypeError(`Invalid date-picker value: ${t}`);this._setValue(t||"",{emit:!1,format:!0})}get range(){return this._rangeMode()&&this._range?{...this._range.range}:void 0}set range(t){if(!this._rangeMode())throw TypeError("range is only available on <date-picker range>");let{start:e,end:i}=tt(t);this._setRange(e,i)}get locale(){return z(this.getAttribute("locale")||"")}set locale(t){if(t)this.setAttribute("locale",t);else this.removeAttribute("locale")}get min(){let t=this.getAttribute("min")||"";return c(t)?t:""}set min(t){if(t)this.setAttribute("min",t);else this.removeAttribute("min")}get max(){let t=this.getAttribute("max")||"";return c(t)?t:""}set max(t){if(t)this.setAttribute("max",t);else this.removeAttribute("max")}get openOnFocus(){return this.getAttribute("open-on-focus")!=="false"}set openOnFocus(t){if(t===!1)this.setAttribute("open-on-focus","false");else this.removeAttribute("open-on-focus")}get open(){return this._open}get messages(){return this._messages}set messages(t){if(this._messages={...W(),...t||{}},this._calendar)this._calendar.messages=this._messages;for(let e of this._fields||[])e.setMessages(this._messages);this._field?.setMessages(this._messages),this._refreshButtonLabel(),this.validate()}get source(){return this._source}set source(t){if(this._source=t||null,this._calendar)this._calendar.source=this._source;if(this._connected)this.validate()}get dateState(){return this._dateState}set dateState(t){if(this._dateState=typeof t==="function"?t:null,this._calendar)this._calendar.dateState=this._dateState;if(this._connected)this.validate()}get renderDay(){return this._renderDay}set renderDay(t){if(this._renderDay=typeof t==="function"?t:null,this._calendar)this._calendar.renderDay=this._renderDay}get isDateDisabled(){return this._isDateDisabled}set isDateDisabled(t){if(this._isDateDisabled=typeof t==="function"?t:null,this._calendar)this._calendar.isDateDisabled=this._isDateDisabled;if(this._connected)this.validate()}_adapter(){return this._field?.adapter??this._fields?.[0]?.adapter??K(this.locale)}_setupFormValue(){this._field?.setupFormValue()}_syncInputState(){let t=this._input;if(!t)return;if(this._field?.syncInputState(),this._button)this._button.disabled=t.disabled||t.readOnly;if(this._open&&(t.disabled||t.readOnly))this.hide(!1)}_syncRangeFields(){if(!this._fields)return;for(let i of this._fields)i.syncInputState();let t=this._range?.activeEndpoint==="end"?1:0,e=this._fields.every((i)=>i.input.disabled||i.input.readOnly);if(this._button)this._button.disabled=e;if(this._open&&(this._fields[t]?.input.disabled||this._fields[t]?.input.readOnly))this.hide(!1)}_setRangeAria(){if(!this._fields||!this._panel||!this._formatHint)return;for(let t of this._fields){let e=t.input,i=[this._rangeOriginalDescribedBy[this._fields.indexOf(t)],this._formatHint.id].filter(Boolean).join(" ");e.setAttribute("aria-describedby",i),e.setAttribute("role","combobox"),e.setAttribute("aria-haspopup","dialog"),e.setAttribute("aria-expanded","false"),e.setAttribute("aria-controls",this._panel.id)}}_build(t){let e=t||this._input;if(!e)return;let i=`${this._id}-panel`,s=`${this._id}-format`,n=document.createElement("button");n.type="button",n.className="dp-picker-button",n.setAttribute("aria-haspopup","dialog"),n.setAttribute("aria-expanded","false"),n.setAttribute("aria-controls",i),n.innerHTML='<span aria-hidden="true"><svg viewBox="0 0 16 16" width="1em" height="1em" fill="none" stroke="currentColor" stroke-width="1.4" stroke-linecap="round"><rect x="1.75" y="3" width="12.5" height="11" rx="1.75"/><path d="M1.75 6.75h12.5"/><path d="M5.25 1.75v2.5M10.75 1.75v2.5"/></svg></span>';let r=document.createElement("div");r.id=i,r.className="dp-picker-panel",r.setAttribute("popover","manual"),r.setAttribute("role","dialog"),r.setAttribute("aria-label",this._messages.calendar);let a=new q;a.selection="none",a.fixedWeeks=!0,r.append(a);let o=document.createElement("span");if(o.id=s,o.className="dp-visually-hidden",e.insertAdjacentElement("afterend",n),n.insertAdjacentElement("afterend",r),r.insertAdjacentElement("afterend",o),this._button=n,this._panel=r,this._calendar=a,this._formatHint=o,!this._rangeMode()){this._originalDescribedBy=e.getAttribute("aria-describedby")||"";let l=[this._originalDescribedBy,s].filter(Boolean).join(" ");e.setAttribute("aria-describedby",l),e.setAttribute("role","combobox"),e.setAttribute("aria-haspopup","dialog"),e.setAttribute("aria-expanded","false"),e.setAttribute("aria-controls",i)}this._refreshLocale(),this._refreshButtonLabel()}_bind(){let t=this._input,e=this._button,i=this._calendar;if(!t||!e||!i)return;let s=new AbortController;this._controller=s;let{signal:n}=s;t.addEventListener("input",()=>{this._field?.handleInput()},{signal:n}),t.addEventListener("change",()=>void this._commitText(!1),{signal:n}),t.addEventListener("blur",()=>void this._commitText(!1),{signal:n}),t.addEventListener("focus",(r)=>{if(!this.openOnFocus||this._suppressFocusOpen)return;let a=r.relatedTarget;if(a instanceof Node&&this.contains(a))return;if(!this._open)this.show({moveFocus:!1})},{signal:n}),t.addEventListener("keydown",(r)=>{this._onFieldKeyDown("",r)},{signal:n}),e.addEventListener("click",(r)=>{if(this._open){if(r.detail===0){setTimeout(()=>this._calendar?.focusGrid(),0);return}this.hide(!1);return}this.show()},{signal:n}),i.addEventListener("dateactivate",(r)=>{let a=r,o=a.detail?.date;if(!c(o))return;queueMicrotask(()=>{if(a.defaultPrevented||!this._connected)return;if(this._input?.disabled||this._input?.readOnly)return;this._field?.dirty(),this._setValue(o,{emit:!0,format:!0}),this.hide(!1),this._focusInput()})},{signal:n}),i.addEventListener("dateloadend",()=>void this.validate(),{signal:n}),this.ownerDocument.addEventListener("pointerdown",(r)=>{if(!this._open||r.composedPath().includes(this))return;this.hide(!1)},{capture:!0,signal:n}),this.ownerDocument.addEventListener("reset",(r)=>{let a=r.target;if(a instanceof HTMLFormElement&&this._input&&a===this._input.form)this.hide(!1),queueMicrotask(()=>{if(!r.defaultPrevented)this._restoreDefault()})},{capture:!0,signal:n}),this.addEventListener("keydown",(r)=>this._onEscape(r),{signal:n})}_bindRange(){let t=this._button,e=this._calendar;if(!this._fields||!t||!e)return;let i=new AbortController;this._controller=i;let{signal:s}=i;for(let[n,r]of this._fields.entries()){let a=n===1?"end":"start";r.input.addEventListener("input",()=>r.handleInput(),{signal:s}),r.input.addEventListener("change",()=>void this._commitFieldText(a),{signal:s}),r.input.addEventListener("blur",()=>void this._commitFieldText(a),{signal:s}),r.input.addEventListener("focus",(o)=>this._onFieldFocus(a,o),{signal:s}),r.input.addEventListener("keydown",(o)=>this._onFieldKeyDown(a,o),{signal:s})}t.addEventListener("click",(n)=>{if(this._open){if(n.detail===0){setTimeout(()=>this._calendar?.focusGrid(),0);return}this.hide(!1);return}this.show()},{signal:s}),e.addEventListener("click",(n)=>this._captureGridIntent(n),{capture:!0,signal:s}),e.addEventListener("keydown",(n)=>this._captureGridIntent(n),{capture:!0,signal:s}),e.addEventListener("dateactivate",(n)=>{let r=n,a=r.detail?.date;if(!c(a))return;queueMicrotask(()=>{if(r.defaultPrevented||!this._connected||!this._range)return;let o=this._pendingIntents.get(a);if(o===void 0||o!==this._rangeCommitId)return;this._pendingIntents.delete(a);let l=this._range.activate(a,(d)=>{let h=d==="end"?1:0,E=this._fields?.[h];return E!=null&&!E.input.disabled&&!E.input.readOnly});if(l.status==="refused"){this._calendar?.dispatchEvent(new CustomEvent("dateinvalid",{detail:{date:a,state:this._calendar.getDateState(a)},bubbles:!0}));return}if(this._setBound(l.endpoint,a,{emit:!0,user:!0}),l.close||l.status==="complete")this.hide(!1),this._focusField(l.endpoint)})},{signal:s}),e.addEventListener("dateloadend",()=>void this.validate(),{signal:s}),this.ownerDocument.addEventListener("pointerdown",(n)=>{if(!this._open||n.composedPath().includes(this))return;this.hide(!1)},{capture:!0,signal:s}),this.ownerDocument.addEventListener("reset",(n)=>{let r=n.target;if(r instanceof HTMLFormElement&&this._fields&&r===this._fields[0].input.form)this.hide(!1),queueMicrotask(()=>{if(!n.defaultPrevented)this._restoreRangeDefault()})},{capture:!0,signal:s}),this.addEventListener("keydown",(n)=>this._onEscape(n),{signal:s})}_onFieldKeyDown(t,e){if(e.key==="ArrowDown"||e.altKey&&e.key==="ArrowDown"){if(e.preventDefault(),this._rangeMode()&&t)this._lastFocusEndpoint=t,this._range?.focus(t);if(this._open)setTimeout(()=>this._calendar?.focusGrid(),0);else this.show()}else if(e.key==="Escape"&&this._open)e.preventDefault(),this.hide(!1)}_onFieldFocus(t,e){if(!this._rangeMode()||!t)return;let i=t!==this._range?.activeEndpoint;if(this._lastFocusEndpoint=t,this._range?.focus(t),i)this._rangeCommitId++,this._pendingIntents.clear();if(!this.openOnFocus||this._suppressFocusOpen)return;let s=e.relatedTarget;if(s instanceof Node&&this.contains(s))return;if(!this._open)this.show({moveFocus:!1})}_captureGridIntent(t){if(!this._rangeMode()||!this._range)return;if(t.type==="keydown"){let s=t.key;if(s!=="Enter"&&s!==" ")return}if(!(t.target instanceof Element))return;let i=t.target.closest(".dp-day[data-date]")?.getAttribute("data-date")||"";if(!c(i))return;this._pendingIntents.set(i,++this._rangeCommitId)}_onEscape(t){if(t.key==="Escape"&&this._open)t.preventDefault(),t.stopPropagation(),this.hide(!0)}_syncCalendarOptions(){let t=this._calendar,e=this._panel;if(!t)return;if(t.locale=this.locale,t.min=this.min,t.max=this.max,t.messages=this._messages,t.source=this._source,t.dateState=this._dateState,t.renderDay=this._renderDay,t.isDateDisabled=this._isDateDisabled,!this._rangeMode()&&this._value)t.value=this._value;if(e)e.setAttribute("aria-label",this._messages.calendar)}_refreshLocale(){let t=this._formatHint;if(!t)return;if(this._rangeMode()&&this._fields){this._fields[0].setLocale(this.locale),this._fields[1].setLocale(this.locale),t.textContent=`${this._messages.formatHint}: ${this._fields[0].placeholder}`;for(let[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 e=this._field;if(!e)return;if(e.setLocale(this.locale),t.textContent=`${this._messages.formatHint}: ${e.placeholder}`,!e.input.hasAttribute("placeholder")||this._generatedPlaceholder)e.input.placeholder=e.placeholder,this._generatedPlaceholder=!0;if(this._value)e.input.value=e.format(this._value);this._refreshButtonLabel()}_refreshButtonLabel(){if(!this._button)return;if(this._rangeMode()){this._refreshRangeButtonLabel();return}let t=this._value?this._messages.changeDate:this._messages.chooseDate,e=this._value?`, ${Y(this._value,this.locale)}`:"";this._button.setAttribute("aria-label",`${t}${e}`)}_refreshRangeButtonLabel(){if(!this._button||!this._range)return;let{start:t,end:e}=this._range,i=Boolean(t&&e),s=i?this._messages.changeDate:this._messages.chooseDate,n=i?`, ${Y(t,this.locale)} – ${Y(e,this.locale)}`:"";this._button.setAttribute("aria-label",`${s}${n}`)}_reflectValue(t){if(this._reflecting=!0,t)this.setAttribute("value",t);else this.removeAttribute("value");this._reflecting=!1}_setValue(t,e={}){if(t&&!c(t))throw TypeError(`Invalid date-picker value: ${t}`);let i=this._value;if(this._value=t||"",e.reflect!==!1)this._reflectValue(this._value);if(this._field?.setCanonical(this._value,{format:e.format!==!1}),this._calendar){if(this._calendar.value=this._value,this._value)this._calendar.focusedDate=this._value}if(this._refreshButtonLabel(),i!==this._value){if(this.dispatchEvent(new CustomEvent("valuechange",{detail:{value:this._value},bubbles:!0})),e.emit&&this._field){let s=this._field.input;s.dispatchEvent(new Event("input",{bubbles:!0})),s.dispatchEvent(new Event("change",{bubbles:!0}))}}}async _confirmDate(t){let e=this._calendar;if(!e)return{ok:!0};let i=f(t);if(e.display!==i)e.display=i;let s=await e.ensureDate(t),n=e.getDateState(t);if(!s||n.disabled)return{ok:!1,message:this._messages.unavailableDate};return{ok:!0}}async _commitText(t,e={}){let i=this._field;if(!i)return!1;if(!e.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:t,format:s.status==="ok"}),!0}async _commitFieldText(t){let e=this._fields;if(!e)return!1;let i=t==="end"?1:0,s=e[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(t,n.value||"",{emit:!0,user:!0,format:n.status==="ok"}),!0}_setBound(t,e,i={}){if(!this._range)return!1;let s=this._fields;if(!s)return!1;let r=s[t==="end"?1:0];if(!r)return!1;if(i.user===!0&&(r.input.disabled||r.input.readOnly))return!1;let a=e||"",o=r.canonical;if(r.setCanonical(a,{format:i.format!==!1}),t==="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(t),l}_setRange(t,e,i={}){if(!this._range||!this._fields)return;if(this._range.start=t||"",this._range.end=e||"",this._fields[0].setCanonical(t||"",{format:i.format!==!1}),this._fields[1].setCanonical(e||"",{format:i.format!==!1}),this._syncHighlight(),this._refreshRangeButtonLabel(),this._revalidateRange("start"),this._revalidateRange("end"),i.emit!==!1)this._emitRangeChange()}_boundCanonical(t){return this._range?t==="end"?this._range.end:this._range.start:""}_emitRangeChange(){if(!this._range)return;this.dispatchEvent(new CustomEvent("rangechange",{detail:{...this._range.range},bubbles:!0}))}_syncHighlight(){if(!this._calendar||!this._range)return;let{start:t,end:e}=this._range;if(!t){this._calendar.highlightedRange={start:"",end:""};return}if(e&&w(e,t)<0)this._calendar.highlightedRange={start:t,end:""};else this._calendar.highlightedRange={start:t,end:e}}_revalidateRange(t){if(!this._fields||!this._range)return;let{start:e,end:i}=this._range,s=Boolean(e&&i&&w(i,e)<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===t)o.setCustomValidity(l),this._orderTags.add(a);else if(this._orderTags.has(a))o.setCustomValidity(""),this._orderTags.delete(a)}}_restoreDefault(){let t=this._field;if(!t)return;let e=t.restoreDefault();if(this._setValue(e,{emit:!1,format:!0}),this._calendar)if(this._value)this._calendar.display=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 t=this._fields[0].restoreDefault(),e=this._fields[1].restoreDefault();if(this._setRange(t,e),this._calendar){let i=this._range?.start||R();this._calendar.display=f(i),this._calendar.focusedDate=i}this.validate()}_focusField(t){let e=t==="end"?1:0,i=this._fields?.[e]?.input;if(!i)return;this._suppressFocusOpen=!0,setTimeout(()=>{i.focus(),this._suppressFocusOpen=!1},0)}_focusInput(){this._suppressFocusOpen=!0,setTimeout(()=>{this._input?.focus(),this._suppressFocusOpen=!1},0)}_resolveRangeEndpoint(){if(!this._fields)return"";let t=this._lastFocusEndpoint||"start",e=t==="end"?1:0;if(!this._fields[e].input.disabled&&!this._fields[e].input.readOnly)return t;let i=t==="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 e=this._fields;if(!e)return!0;for(let[i,s]of e.entries()){let n=await s.commit();if(n.status==="ok"||n.status==="clear"){let r=i===1?"end":"start";this._setBound(r,n.value||"",{format:n.status==="ok"})}}return this._revalidateRange("start"),this._revalidateRange("end"),e.every((i)=>i.input.checkValidity())}let t=this._field?.input;if(!t)return!0;if(!t.value.trim())return t.setCustomValidity(""),t.checkValidity();return await this._commitText(!1,{force:!0}),t.checkValidity()}show(t={}){let e=this._panel,i=this._calendar,s=this._button;if(!e||!i||!s||this._open)return;if(this._rangeMode()){let r=this._resolveRangeEndpoint();if(!r)return;this._range?.focus(r),this._rangeCommitId++,this._pendingIntents.clear();let a=this._boundCanonical(r)||R();i.display=f(a),i.focusedDate=a,this._lastFocusEndpoint=r}else{let r=this._input;if(!r||r.disabled||r.readOnly)return;let a=this._value||this._adapter().parse(r.value)||R();i.display=f(a),i.focusedDate=a}e.showPopover(),this._open=!0,this._setExpanded(!0);let n=()=>St(this,e,{placement:"bottom-start",distance:4,shiftPadding:8});if(n(),this._stopTracking=Tt(this,e,n),t.moveFocus!==!1)queueMicrotask(()=>i.focusGrid());this.dispatchEvent(new Event("open",{bubbles:!0}))}_setExpanded(t){let e=t?"true":"false";this._input?.setAttribute("aria-expanded",e),this._button?.setAttribute("aria-expanded",e);for(let i of this._fields||[])i.input.setAttribute("aria-expanded",e)}hide(t=!1){if(!this._panel||!this._open)return;this._stopTracking?.(),this._stopTracking=null;try{this._panel.hidePopover()}catch{}if(this._open=!1,this._setExpanded(!1),this._rangeCommitId++,this._pendingIntents.clear(),t)if(this._rangeMode()){let e=this._restoreFocusEndpoint();if(e)this._focusField(e)}else this._focusInput();this.dispatchEvent(new Event("close",{bubbles:!0}))}_restoreFocusEndpoint(){let t=this._range?.activeEndpoint||"";if(t){let e=t==="end"?1:0,i=this._fields?.[e];if(i&&!i.input.disabled&&!i.input.readOnly)return t}return this._resolveRangeEndpoint()}}function at(){if(!customElements.get("date-calendar"))customElements.define("date-calendar",q);if(!customElements.get("date-picker"))customElements.define("date-picker",rt)}at();var Mt="lekoala-date-picker-styles";if(!document.getElementById(Mt)){let t=document.createElement("style");t.id=Mt,t.textContent=ct,document.head.append(t)}at();})();
@@ -0,0 +1,34 @@
1
+ export declare class CalendarModel {
2
+ firstDay: number;
3
+ value: string;
4
+ focused: string;
5
+ display: string;
6
+ /**
7
+ * @param {{value?:string, display?:string, focused?:string, firstDay?:number}} [options]
8
+ */
9
+ constructor(options?: {
10
+ value?: string;
11
+ display?: string;
12
+ focused?: string;
13
+ firstDay?: number;
14
+ });
15
+ /** @param {string} value */
16
+ setValue(value: string): string;
17
+ /** @param {string} value */
18
+ setDisplay(value: string): string;
19
+ /** @param {string} value @param {{follow?:boolean}} [options] */
20
+ setFocused(value: string, options?: {
21
+ follow?: boolean;
22
+ }): string;
23
+ /** @param {number} amount */
24
+ moveFocusDays(amount: number): string;
25
+ /** @param {number} amount */
26
+ moveFocusMonths(amount: number): string;
27
+ /** @param {number} amount */
28
+ moveFocusYears(amount: number): string;
29
+ focusWeekStart(): string;
30
+ focusWeekEnd(): string;
31
+ /** Header/month-select navigation. Value is intentionally untouched. @param {number} amount */
32
+ navigateMonth(amount: number): string;
33
+ }
34
+ //# sourceMappingURL=calendar-model.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"calendar-model.d.ts","sourceRoot":"","sources":["../../src/calendar-model.js"],"names":[],"mappings":"AAYA,qBAAa,aAAa;IAMjB,QAAQ;IACR,KAAK;IACL,OAAO;IACP,OAAO;IARd;;OAEG;IACH,YAAY,OAAO,AAFhB,CAAsF,EAA9E;QAAC,KAAK,CAAC,EAAC,MAAM,CAAC;QAAC,OAAO,CAAC,EAAC,MAAM,CAAC;QAAC,OAAO,CAAC,EAAC,MAAM,CAAC;QAAC,QAAQ,CAAC,EAAC,MAAM,CAAA;KAErD,EAMvB;IAED,4BAA4B;IAC5B,QAAQ,CAAC,KAAK,EADF,MACE,UAIb;IAED,4BAA4B;IAC5B,UAAU,CAAC,KAAK,EADJ,MACI,UAQf;IAED,iEAAiE;IACjE,UAAU,CAAC,KAAK,EADJ,MACI,EAAE,OAAO,AADC,CAAoC,EAA5B;QAAC,MAAM,CAAC,EAAC,OAAO,CAAA;KACpB,UAK7B;IAED,6BAA6B;IAC7B,aAAa,CAAC,MAAM,EADR,MACQ,UAEnB;IAED,6BAA6B;IAC7B,eAAe,CAAC,MAAM,EADV,MACU,UAErB;IAED,6BAA6B;IAC7B,cAAc,CAAC,MAAM,EADT,MACS,UAEpB;IAED,cAAc,WAEb;IAED,YAAY,WAEX;IAED,+FAA+F;IAC/F,aAAa,CAAC,MAAM,EAD0D,MAC1D,UAInB;CACF"}