monobill-mintui 0.6.650 → 0.6.652

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 (122) hide show
  1. package/bin/component-dependencies.json +13 -1
  2. package/dist/components/chunks/ScrollFade-D1FPF6ZS.js +82 -0
  3. package/dist/components/chunks/ScrollFade-DT2Br2g7.js +1 -0
  4. package/dist/components/chunks/date-picker-BQsCoKaK.js +1282 -0
  5. package/dist/components/chunks/date-picker-tm5Oc92c.js +1 -0
  6. package/dist/components/chunks/{input-CYv5hraJ.js → input-DcglGwsR.js} +13 -6
  7. package/dist/components/chunks/input-awdYlp-G.js +1 -0
  8. package/dist/components/chunks/{popover-DB1OaYVe.js → popover-FdMS4yAD.js} +54 -14
  9. package/dist/components/chunks/popover-wGdggZ-a.js +1 -0
  10. package/dist/components/chunks/{table-DRdsVUJL.js → table-B9e-cnAC.js} +7 -6
  11. package/dist/components/chunks/table-vjF3q3J5.js +1 -0
  12. package/dist/components/chunks/time-picker-Cq3qzkDb.js +1 -0
  13. package/dist/components/chunks/time-picker-S0bc0BPU.js +360 -0
  14. package/dist/components/date-picker/DatePicker.d.ts +5 -0
  15. package/dist/components/date-picker/DatePicker.d.ts.map +1 -1
  16. package/dist/components/date-picker/browser.js +2 -1270
  17. package/dist/components/date-picker/index.cjs +1 -1
  18. package/dist/components/date-picker/index.js +2 -1270
  19. package/dist/components/datetime-picker/DateTimePicker.d.ts +44 -0
  20. package/dist/components/datetime-picker/DateTimePicker.d.ts.map +1 -0
  21. package/dist/components/datetime-picker/browser.js +255 -0
  22. package/dist/components/datetime-picker/index.cjs +1 -0
  23. package/dist/components/datetime-picker/index.d.ts +4 -0
  24. package/dist/components/datetime-picker/index.d.ts.map +1 -0
  25. package/dist/components/datetime-picker/index.js +243 -0
  26. package/dist/components/form/Form.d.ts.map +1 -1
  27. package/dist/components/form/browser.js +9 -8
  28. package/dist/components/form/index.cjs +1 -1
  29. package/dist/components/form/index.js +9 -8
  30. package/dist/components/input/browser.js +1 -1
  31. package/dist/components/input/index.cjs +1 -1
  32. package/dist/components/input/index.js +1 -1
  33. package/dist/components/link/browser.js +1 -1
  34. package/dist/components/link/index.cjs +1 -1
  35. package/dist/components/link/index.js +1 -1
  36. package/dist/components/navigation/browser.js +2 -2
  37. package/dist/components/navigation/index.cjs +1 -1
  38. package/dist/components/navigation/index.js +2 -2
  39. package/dist/components/popover/Popover.d.ts.map +1 -1
  40. package/dist/components/popover/browser.js +1 -1
  41. package/dist/components/popover/index.cjs +1 -1
  42. package/dist/components/popover/index.js +1 -1
  43. package/dist/components/resource-table/ResourceTable.d.ts +1 -0
  44. package/dist/components/resource-table/ResourceTable.d.ts.map +1 -1
  45. package/dist/components/resource-table/browser.js +22 -22
  46. package/dist/components/resource-table/index.cjs +2 -2
  47. package/dist/components/resource-table/index.js +22 -22
  48. package/dist/components/scroll-fade/ScrollFade.d.ts +15 -0
  49. package/dist/components/scroll-fade/ScrollFade.d.ts.map +1 -0
  50. package/dist/components/scroll-fade/browser.js +16 -0
  51. package/dist/components/scroll-fade/index.cjs +1 -0
  52. package/dist/components/scroll-fade/index.d.ts +6 -0
  53. package/dist/components/scroll-fade/index.d.ts.map +1 -0
  54. package/dist/components/scroll-fade/index.js +4 -0
  55. package/dist/components/search/Search.d.ts.map +1 -1
  56. package/dist/components/search/browser.js +3 -3
  57. package/dist/components/search/index.cjs +1 -1
  58. package/dist/components/search/index.js +3 -3
  59. package/dist/components/select/NativeSelect.d.ts +38 -0
  60. package/dist/components/select/NativeSelect.d.ts.map +1 -0
  61. package/dist/components/select/Select.d.ts +36 -29
  62. package/dist/components/select/Select.d.ts.map +1 -1
  63. package/dist/components/select/browser.js +313 -19
  64. package/dist/components/select/index.cjs +1 -1
  65. package/dist/components/select/index.d.ts +3 -2
  66. package/dist/components/select/index.d.ts.map +1 -1
  67. package/dist/components/select/index.js +313 -19
  68. package/dist/components/side-navigation/SideNavigation.d.ts +1 -0
  69. package/dist/components/side-navigation/SideNavigation.d.ts.map +1 -1
  70. package/dist/components/side-navigation/browser.js +24 -23
  71. package/dist/components/side-navigation/index.cjs +1 -1
  72. package/dist/components/side-navigation/index.js +24 -23
  73. package/dist/components/sortable/browser.js +1 -1
  74. package/dist/components/sortable/index.cjs +1 -1
  75. package/dist/components/sortable/index.js +1 -1
  76. package/dist/components/table/Table.d.ts +1 -0
  77. package/dist/components/table/Table.d.ts.map +1 -1
  78. package/dist/components/table/browser.js +1 -1
  79. package/dist/components/table/index.cjs +1 -1
  80. package/dist/components/table/index.js +1 -1
  81. package/dist/components/tags/browser.js +1 -1
  82. package/dist/components/tags/index.cjs +1 -1
  83. package/dist/components/tags/index.js +1 -1
  84. package/dist/components/time-picker/TimePicker.d.ts +1 -0
  85. package/dist/components/time-picker/TimePicker.d.ts.map +1 -1
  86. package/dist/components/time-picker/browser.js +2 -347
  87. package/dist/components/time-picker/index.cjs +1 -1
  88. package/dist/components/time-picker/index.js +2 -347
  89. package/dist/components/tree/Tree.d.ts +2 -0
  90. package/dist/components/tree/Tree.d.ts.map +1 -1
  91. package/dist/components/tree/browser.js +15 -7
  92. package/dist/components/tree/index.cjs +1 -1
  93. package/dist/components/tree/index.js +15 -7
  94. package/dist/datetime-picker.css +3 -0
  95. package/dist/index.cjs +4 -4
  96. package/dist/index.css +22 -9
  97. package/dist/index.d.ts +3 -1
  98. package/dist/index.js +1413 -739
  99. package/dist/modal.css +1 -1
  100. package/dist/navigation-search.json +15 -1
  101. package/dist/navigation.css +1 -1
  102. package/dist/off-canvas.css +1 -1
  103. package/dist/popover.css +1 -1
  104. package/dist/scroll-fade.css +3 -0
  105. package/dist/select.css +1 -1
  106. package/dist/side-navigation.css +1 -1
  107. package/dist/theme.css +7 -2
  108. package/dist/time-picker.css +1 -1
  109. package/package.json +19 -1
  110. package/dist/components/chunks/caret-up-DzrY-bTy.js +0 -1
  111. package/dist/components/chunks/caret-up-ZK3v_oWQ.js +0 -9
  112. package/dist/components/chunks/input-Du8C2LW8.js +0 -1
  113. package/dist/components/chunks/popover-CNZ5u-MA.js +0 -1
  114. package/dist/components/chunks/table-2-0iNQJy.js +0 -1
  115. /package/dist/components/chunks/{caret-right-BzeJ0Fw3.js → caret-right-BcZ9bOhS.js} +0 -0
  116. /package/dist/components/chunks/{caret-right-Bh7uMg-Y.js → caret-right-CgIVfus7.js} +0 -0
  117. /package/dist/components/chunks/{link-BsC3zT_I.js → link-BjbBJpI6.js} +0 -0
  118. /package/dist/components/chunks/{link-dTjSvr4E.js → link-CU-gTgir.js} +0 -0
  119. /package/dist/components/chunks/{search-v06eZL4m.js → search--bcFMYMP.js} +0 -0
  120. /package/dist/components/chunks/{search-CTAGy5ab.js → search-Cixhf7hA.js} +0 -0
  121. /package/dist/components/chunks/{sortable-B1nMJBah.js → sortable-CNlF0_gv.js} +0 -0
  122. /package/dist/components/chunks/{sortable-CXM-7eyL.js → sortable-CVK48xj1.js} +0 -0
@@ -0,0 +1,1282 @@
1
+ import { a as e } from "./icon-Cxv9k3CY.js";
2
+ import { t } from "./register-element-BFYmIynH.js";
3
+ import "./icon-DMa6Oo80.js";
4
+ import "./caret-right-CgIVfus7.js";
5
+ import "./input-DcglGwsR.js";
6
+ import "./popover-FdMS4yAD.js";
7
+ e({
8
+ name: "calendar",
9
+ viewBox: "0 0 24 24",
10
+ path: "M8 7V3m8 4V3M5 21h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v12a2 2 0 002 2zM6 11h12M6 14h12M6 17h12",
11
+ strokeLinecap: "round",
12
+ strokeLinejoin: "round"
13
+ }), e({
14
+ name: "caret-left",
15
+ viewBox: "0 0 24 24",
16
+ path: "M15 19l-7-7 7-7",
17
+ strokeLinecap: "round",
18
+ strokeLinejoin: "round"
19
+ });
20
+ //#endregion
21
+ //#region src/components/date-picker/DatePicker.ts
22
+ var n = class extends HTMLElement {
23
+ static get observedAttributes() {
24
+ return [
25
+ "value",
26
+ "label",
27
+ "info",
28
+ "disabled",
29
+ "id",
30
+ "name",
31
+ "required",
32
+ "readonly",
33
+ "format",
34
+ "min",
35
+ "max",
36
+ "range",
37
+ "shortcuts",
38
+ "display-format",
39
+ "error",
40
+ "error-message",
41
+ "loading",
42
+ "selection-mode",
43
+ "week-start-day",
44
+ "mode",
45
+ "disabled-dates"
46
+ ];
47
+ }
48
+ constructor() {
49
+ super(), this._input = null, this._textInput = null, this._popover = null, this._calendarContainer = null, this._iconButton = null, this._hiddenInput = null, this._startPartInputs = [], this._endPartInputs = [], this._displayEl = null, this._inputsWrapperEl = null, this._fieldsContainer = null, this._resetHandler = null, this._isInputMode = !1, this._currentMonth = (/* @__PURE__ */ new Date()).getMonth(), this._currentYear = (/* @__PURE__ */ new Date()).getFullYear(), this._viewMode = "calendar", this._selectedStartDate = null, this._selectedEndDate = null, this._isRange = !1, this._hoveredDate = null, this._isHandlingClick = !1, this._touchStartDate = null, this._touchStartElement = null, this._isTouchActive = !1, this._resizeObserver = null, this._popoverObserver = null, this._focusTrapHandler = null, this._escapeHandler = null, this._a11yId = `mint-date-picker-${Math.random().toString(36).slice(2, 10)}`;
50
+ }
51
+ connectedCallback() {
52
+ this.classList.add("mint-date-picker"), this.render(), this._setupPopoverWithRetry(), this._attachFormResetListener();
53
+ }
54
+ disconnectedCallback() {
55
+ if (this._popoverObserver &&= (this._popoverObserver.disconnect(), null), this._resizeObserver &&= (this._resizeObserver.disconnect(), null), this._removeFocusTrap(), this._resetHandler) {
56
+ let e = this.closest("form");
57
+ e && e.removeEventListener("reset", this._resetHandler), this._resetHandler = null;
58
+ }
59
+ }
60
+ isLoading() {
61
+ return this.getAttribute("loading") === "true";
62
+ }
63
+ attributeChangedCallback(e, t, n) {
64
+ if (t !== n) {
65
+ if (e === "error" || e === "error-message") {
66
+ let e = this.hasError(), t = this.getErrorMessage();
67
+ this._applyErrorVisuals(e, t, this.isDisabled());
68
+ return;
69
+ }
70
+ if (e === "loading") {
71
+ this.render();
72
+ return;
73
+ }
74
+ if (e === "mode" || e === "format") {
75
+ let e = this.getMode();
76
+ e === "month" ? this._viewMode = "month" : e === "year" ? this._viewMode = "year" : this._viewMode = "calendar", this._popover && this._calendarContainer && this._buildCalendar();
77
+ }
78
+ this.render(), this._input && this._setupPopoverWithRetry();
79
+ }
80
+ }
81
+ getValue() {
82
+ return this.getAttribute("value") || "";
83
+ }
84
+ getPopoverElement() {
85
+ return this._popover;
86
+ }
87
+ getPopoverContentElement() {
88
+ return this._popover?.querySelector(".popover-content") || null;
89
+ }
90
+ getDisplayElement() {
91
+ return this._displayEl;
92
+ }
93
+ refreshCalendar() {
94
+ this._buildCalendar();
95
+ }
96
+ setValue(e) {
97
+ e ? (this.setAttribute("value", e), this._textInput && (this._textInput.value = e), this._parseValue(e)) : (this.removeAttribute("value"), this._textInput && (this._textInput.value = ""), this._selectedStartDate = null, this._selectedEndDate = null), this._buildCalendar(), this._updateDisplayText();
98
+ }
99
+ get value() {
100
+ try {
101
+ return this.getValue() || "";
102
+ } catch {
103
+ return "";
104
+ }
105
+ }
106
+ set value(e) {
107
+ try {
108
+ this.setValue(e || "");
109
+ } catch {}
110
+ }
111
+ getFormat() {
112
+ return this.getAttribute("format") || "mm/dd/yyyy";
113
+ }
114
+ getLabel() {
115
+ return this.getAttribute("label") || "";
116
+ }
117
+ getInfo() {
118
+ return this.getAttribute("info") || "";
119
+ }
120
+ isDisabled() {
121
+ return this.getAttribute("disabled") === "true";
122
+ }
123
+ isReadonly() {
124
+ return this.getAttribute("readonly") === "true";
125
+ }
126
+ isRequired() {
127
+ return this.getAttribute("required") === "true";
128
+ }
129
+ hasError() {
130
+ return this.getAttribute("error") === "true";
131
+ }
132
+ getErrorMessage() {
133
+ return this.getAttribute("error-message") || "";
134
+ }
135
+ isRange() {
136
+ return this.getAttribute("range") === "true";
137
+ }
138
+ getId() {
139
+ return this.getAttribute("id") || "";
140
+ }
141
+ getName() {
142
+ return this.getAttribute("name") || "";
143
+ }
144
+ getMin() {
145
+ return this.getAttribute("min") || "";
146
+ }
147
+ getMax() {
148
+ return this.getAttribute("max") || "";
149
+ }
150
+ getDisabledDates() {
151
+ let e = this.getAttribute("disabled-dates");
152
+ if (!e) return [];
153
+ try {
154
+ let t = JSON.parse(e), n = this.getFormat();
155
+ return t.map((e) => this._parseDateString(e, n)).filter((e) => e !== null);
156
+ } catch {
157
+ return [];
158
+ }
159
+ }
160
+ getDisabledDateStrings() {
161
+ let e = this.getAttribute("disabled-dates");
162
+ if (!e) return [];
163
+ try {
164
+ return JSON.parse(e);
165
+ } catch {
166
+ return [];
167
+ }
168
+ }
169
+ disableDate(e) {
170
+ let t = this.getFormat(), n = this.getDisabledDateStrings(), r = Array.isArray(e) ? e : [e], i = [];
171
+ for (let e of r) {
172
+ let r = this._parseDateString(e, t);
173
+ if (r) {
174
+ let e = this._formatDate(r, t);
175
+ n.includes(e) || i.push(e);
176
+ }
177
+ }
178
+ if (i.length > 0) {
179
+ let e = [...n, ...i];
180
+ this.setAttribute("disabled-dates", JSON.stringify(e)), this._buildCalendar();
181
+ }
182
+ }
183
+ enableDate(e) {
184
+ let t = this.getFormat(), n = this.getDisabledDateStrings(), r = Array.isArray(e) ? e : [e], i = [];
185
+ for (let e of r) {
186
+ let n = this._parseDateString(e, t);
187
+ if (n) {
188
+ let e = this._formatDate(n, t);
189
+ i.push(e);
190
+ }
191
+ }
192
+ if (i.length > 0) {
193
+ let e = n.filter((e) => !i.includes(e));
194
+ e.length === 0 ? this.removeAttribute("disabled-dates") : this.setAttribute("disabled-dates", JSON.stringify(e)), this._buildCalendar();
195
+ }
196
+ }
197
+ getSelectionMode() {
198
+ let e = this.getAttribute("selection-mode");
199
+ return e === "week" || e === "month" ? e : "day";
200
+ }
201
+ getMode() {
202
+ let e = this.getAttribute("mode");
203
+ if (e === "month" || e === "year") return e;
204
+ let t = this.getFormat().toLowerCase(), n = t.includes("d"), r = t.includes("m");
205
+ return !n && !r ? "year" : !n && r ? "month" : "default";
206
+ }
207
+ getWeekStartDay() {
208
+ return {
209
+ sunday: 0,
210
+ monday: 1,
211
+ tuesday: 2,
212
+ wednesday: 3,
213
+ thursday: 4,
214
+ friday: 5,
215
+ saturday: 6
216
+ }[this.getAttribute("week-start-day")?.toLowerCase() || "sunday"] ?? 0;
217
+ }
218
+ getDisplayFormat() {
219
+ return this.getAttribute("display-format") || "F j, Y";
220
+ }
221
+ getShortcuts() {
222
+ let e = this.getAttribute("shortcuts");
223
+ if (!e) return [];
224
+ try {
225
+ let t = JSON.parse(e);
226
+ if (Array.isArray(t)) return t.map((e) => ({
227
+ label: e.label,
228
+ action: this._createShortcutAction(e.action)
229
+ }));
230
+ } catch {
231
+ let t = e.trim();
232
+ if (t && typeof window[t] == "function") {
233
+ let e = window[t]();
234
+ if (Array.isArray(e)) return e.map((e) => ({
235
+ label: e.label,
236
+ action: typeof e.action == "function" ? e.action : this._createShortcutAction(e.action)
237
+ }));
238
+ }
239
+ }
240
+ return [];
241
+ }
242
+ _createShortcutAction(e) {
243
+ return typeof e == "function" ? e : typeof e == "string" && typeof window[e] == "function" ? window[e] : () => null;
244
+ }
245
+ _getDefaultShortcuts() {
246
+ let e = [{
247
+ label: "Today",
248
+ action: () => /* @__PURE__ */ new Date()
249
+ }];
250
+ return this._isRange && e.push({
251
+ label: "This Week",
252
+ action: () => {
253
+ let e = /* @__PURE__ */ new Date(), t = e.getDay(), n = new Date(e);
254
+ n.setDate(e.getDate() - t), n.setHours(0, 0, 0, 0);
255
+ let r = new Date(n);
256
+ return r.setDate(n.getDate() + 6), r.setHours(23, 59, 59, 999), {
257
+ start: n,
258
+ end: r
259
+ };
260
+ }
261
+ }, {
262
+ label: "This Month",
263
+ action: () => {
264
+ let e = /* @__PURE__ */ new Date(), t = new Date(e.getFullYear(), e.getMonth(), 1), n = new Date(e.getFullYear(), e.getMonth() + 1, 0);
265
+ return n.setHours(23, 59, 59, 999), {
266
+ start: t,
267
+ end: n
268
+ };
269
+ }
270
+ }), e;
271
+ }
272
+ _getFormatTokens(e) {
273
+ let t = [], n = 0, r = e.toLowerCase();
274
+ for (; n < r.length;) {
275
+ let i = r[n];
276
+ if (i === "d" || i === "m" || i === "y") {
277
+ let e = 1, a = n + 1;
278
+ for (; a < r.length && r[a] === i;) e++, a++;
279
+ t.push({
280
+ type: "part",
281
+ part: i,
282
+ len: e
283
+ }), n = a;
284
+ } else t.push({
285
+ type: "sep",
286
+ value: e[n]
287
+ }), n++;
288
+ }
289
+ return t;
290
+ }
291
+ _createPartInput(e, t, n, r, i) {
292
+ let a = document.createElement("input");
293
+ return a.type = "text", a.inputMode = "numeric", a.pattern = "\\d*", a.maxLength = e, a.placeholder = t, a.className = "mint-date-picker-part-input", a.disabled = n || r, a.readOnly = r, a.required = i, e === 4 ? a.classList.add("is-year-part") : e === 2 && a.classList.add("is-short-part"), a;
294
+ }
295
+ _buildValueFromParts(e, t) {
296
+ let n = 0;
297
+ return t.map((t) => {
298
+ if (t.type === "sep") return t.value;
299
+ let r = e[n]?.value || "";
300
+ return n++, r;
301
+ }).join("");
302
+ }
303
+ _applyDateToParts(e, t, n, r) {
304
+ if (!t.length) return;
305
+ if (!e) {
306
+ t.forEach((e) => e.value = "");
307
+ return;
308
+ }
309
+ let i = this._formatDate(e, r), a = 0, o = 0;
310
+ n.forEach((e) => {
311
+ if (e.type === "sep") a += e.value.length;
312
+ else {
313
+ let n = i.substr(a, e.len);
314
+ t[o] && (t[o].value = n), o++, a += e.len;
315
+ }
316
+ });
317
+ }
318
+ _syncHiddenInput() {
319
+ if (!this._hiddenInput) return;
320
+ let e = this.getFormat(), t = this._getFormatTokens(e), n = this._buildValueFromParts(this._startPartInputs, t);
321
+ if (this._isRange) {
322
+ let e = this._buildValueFromParts(this._endPartInputs, t);
323
+ this._hiddenInput.value = e ? `${n} - ${e}` : n;
324
+ } else this._hiddenInput.value = n;
325
+ }
326
+ _focusNext(e, t) {
327
+ if (t + 1 < e.length) {
328
+ let n = e[t + 1];
329
+ n.focus(), n.setSelectionRange(0, n.value.length);
330
+ }
331
+ }
332
+ _focusPrev(e, t) {
333
+ if (t - 1 >= 0) {
334
+ let n = e[t - 1];
335
+ n.focus(), n.setSelectionRange(n.value.length, n.value.length);
336
+ }
337
+ }
338
+ _attachPartInputHandlers(e, t, n) {
339
+ e.forEach((t, n) => {
340
+ let r = t.maxLength || 2;
341
+ t.addEventListener("input", () => {
342
+ t.value = t.value.replace(/\D/g, "").slice(0, r), t.value.length >= r && this._focusNext(e, n), this._syncHiddenInput();
343
+ }), t.addEventListener("keydown", (r) => {
344
+ r.key === "Backspace" && t.selectionStart === 0 && t.selectionEnd === 0 && this._focusPrev(e, n), r.key === "ArrowLeft" && t.selectionStart === 0 && t.selectionEnd === 0 && (this._focusPrev(e, n), r.preventDefault()), r.key === "ArrowRight" && t.selectionStart === t.value.length && t.selectionEnd === t.value.length && (this._focusNext(e, n), r.preventDefault());
345
+ }), t.addEventListener("blur", (e) => {
346
+ this._syncHiddenInput();
347
+ let t = e.relatedTarget, n = t && (this._startPartInputs.includes(t) || this._endPartInputs.includes(t));
348
+ setTimeout(() => {
349
+ if (!(this._startPartInputs.some((e) => e === document.activeElement) || this._endPartInputs.some((e) => e === document.activeElement)) && (n || this._handleBlur(this._hiddenInput?.value || ""), this._exitInputMode(), !n && this._hiddenInput)) {
350
+ let t = new FocusEvent("blur", {
351
+ bubbles: !0,
352
+ cancelable: !0,
353
+ relatedTarget: e.relatedTarget
354
+ });
355
+ this._hiddenInput.dispatchEvent(t);
356
+ }
357
+ }, 0);
358
+ });
359
+ });
360
+ }
361
+ _splitRangeInput(e, t) {
362
+ let n = e.split(/\s*-\s*/);
363
+ return n.length >= 2 ? [n[0], n.slice(1).join("-")] : [e];
364
+ }
365
+ _parseValue(e) {
366
+ let t = this.getFormat(), n = this._getFormatTokens(t), r = this.getSelectionMode();
367
+ if (this._isRange || r === "week" || r === "month") {
368
+ let [r, i] = this._splitRangeInput(e, t), a = r ? this._parseDateString(r, t) : null, o = i ? this._parseDateString(i, t) : null;
369
+ if (a && o) {
370
+ let [e, t] = a <= o ? [a, o] : [o, a];
371
+ this._selectedStartDate = e, this._selectedEndDate = t, this._currentMonth = e.getMonth(), this._currentYear = e.getFullYear();
372
+ } else a && (this._selectedStartDate = a, this._selectedEndDate = null, this._currentMonth = a.getMonth(), this._currentYear = a.getFullYear());
373
+ this._applyDateToParts(this._selectedStartDate, this._startPartInputs, n, t), this._applyDateToParts(this._selectedEndDate, this._endPartInputs, n, t);
374
+ } else {
375
+ let r = this._parseDateString(e, t);
376
+ r && !isNaN(r.getTime()) ? (this._selectedStartDate = r, this._selectedEndDate = null, this._currentMonth = r.getMonth(), this._currentYear = r.getFullYear(), this._applyDateToParts(r, this._startPartInputs, n, t)) : this._applyDateToParts(null, this._startPartInputs, n, t);
377
+ }
378
+ this._syncHiddenInput(), this._updateDisplayText();
379
+ }
380
+ _parseDateString(e, t) {
381
+ let n = /[\/\-\.\s]+/;
382
+ if (n.test(e)) {
383
+ let r = e.split(n).filter((e) => e.length > 0), i = t.split(/[\/\-\.\s]+/).filter((e) => e.length > 0);
384
+ if (r.length === i.length) {
385
+ let e = 0, t = 0, n = 0;
386
+ for (let a = 0; a < i.length; a++) {
387
+ let o = i[a].toLowerCase(), s = r[a];
388
+ if (o.includes("d")) e = parseInt(s, 10);
389
+ else if (o.includes("m")) t = parseInt(s, 10) - 1;
390
+ else if (o.includes("y")) {
391
+ let e = parseInt(s, 10), t = o.length, r = s.length;
392
+ (r === 2 && t === 4 || r === 2 && t === 2) && (e = Math.floor((/* @__PURE__ */ new Date()).getFullYear() / 100) * 100 + e), n = e;
393
+ }
394
+ }
395
+ let a = i.some((e) => e.toLowerCase().includes("d")), o = i.some((e) => e.toLowerCase().includes("m"));
396
+ if (a || (e = 1), o || (t = 0), t >= 0 && t <= 11 && n) {
397
+ let r = new Date(n, t, e);
398
+ if (!isNaN(r.getTime())) return a && r.getDate() !== e || r.getMonth() !== t || r.getFullYear() !== n ? null : r;
399
+ }
400
+ }
401
+ }
402
+ let r = e.replace(/[\/\-\.]/g, ""), i = t.replace(/[\/\-\.]/g, "").toLowerCase(), a = i.indexOf("d"), o = i.indexOf("m"), s = i.indexOf("y"), c = [
403
+ {
404
+ char: "d",
405
+ index: a
406
+ },
407
+ {
408
+ char: "m",
409
+ index: o
410
+ },
411
+ {
412
+ char: "y",
413
+ index: s
414
+ }
415
+ ].sort((e, t) => e.index - t.index), l = 0, u = 0, d = 0, f = 0;
416
+ i.length, r.length;
417
+ for (let e of c) if (e.char === "d") {
418
+ let e = i.lastIndexOf("d") - i.indexOf("d") + 1, t = r.substr(f, e);
419
+ if (t.length === 0) return null;
420
+ l = parseInt(t, 10), f += t.length;
421
+ } else if (e.char === "m") {
422
+ let e = i.lastIndexOf("m") - i.indexOf("m") + 1, t = r.substr(f, e);
423
+ if (t.length === 0) return null;
424
+ u = parseInt(t, 10) - 1, f += t.length;
425
+ } else if (e.char === "y") {
426
+ let e = i.lastIndexOf("y") - i.indexOf("y") + 1, t = r.substr(f), n = Math.min(e, t.length), a = t.substr(0, n);
427
+ if (a.length === 0) return null;
428
+ let o = parseInt(a, 10);
429
+ (n === 2 && e === 4 || n === 2 && e === 2) && (o = Math.floor((/* @__PURE__ */ new Date()).getFullYear() / 100) * 100 + o), d = o, f += n;
430
+ }
431
+ let p = t.toLowerCase(), m = p.includes("d"), h = p.includes("m");
432
+ if (m || (l = 1), h || (u = 0), u < 0 || u > 11 || !d) return null;
433
+ let g = new Date(d, u, l);
434
+ return isNaN(g.getTime()) || m && g.getDate() !== l || g.getMonth() !== u || g.getFullYear() !== d ? null : g;
435
+ }
436
+ _formatDate(e, t) {
437
+ let n = e.getDate(), r = e.getMonth() + 1, i = e.getFullYear(), a = t.toLowerCase(), o = t;
438
+ return a.includes("dd") ? o = o.replace(/dd/gi, String(n).padStart(2, "0")) : a.includes("d") && (o = o.replace(/d/gi, String(n))), a.includes("mm") ? o = o.replace(/mm/gi, String(r).padStart(2, "0")) : a.includes("m") && (o = o.replace(/m/gi, String(r))), a.includes("yyyy") ? o = o.replace(/yyyy/gi, String(i)) : a.includes("yy") && (o = o.replace(/yy/gi, String(i).substr(2))), o;
439
+ }
440
+ _formatDatePhp(e, t) {
441
+ let n = e.getDate(), r = e.getMonth() + 1, i = e.getFullYear(), a = [
442
+ "Sunday",
443
+ "Monday",
444
+ "Tuesday",
445
+ "Wednesday",
446
+ "Thursday",
447
+ "Friday",
448
+ "Saturday"
449
+ ], o = [
450
+ "Sun",
451
+ "Mon",
452
+ "Tue",
453
+ "Wed",
454
+ "Thu",
455
+ "Fri",
456
+ "Sat"
457
+ ], s = [
458
+ "January",
459
+ "February",
460
+ "March",
461
+ "April",
462
+ "May",
463
+ "June",
464
+ "July",
465
+ "August",
466
+ "September",
467
+ "October",
468
+ "November",
469
+ "December"
470
+ ], c = [
471
+ "Jan",
472
+ "Feb",
473
+ "Mar",
474
+ "Apr",
475
+ "May",
476
+ "Jun",
477
+ "Jul",
478
+ "Aug",
479
+ "Sep",
480
+ "Oct",
481
+ "Nov",
482
+ "Dec"
483
+ ], l = (e, t = 2) => e.toString().padStart(t, "0"), u = (e) => {
484
+ let t = e % 10, n = e % 100;
485
+ return t === 1 && n !== 11 ? "st" : t === 2 && n !== 12 ? "nd" : t === 3 && n !== 13 ? "rd" : "th";
486
+ }, d = "";
487
+ for (let f = 0; f < t.length; f++) {
488
+ let p = t[f];
489
+ if (p === "\\" && f + 1 < t.length) {
490
+ d += t[f + 1], f++;
491
+ continue;
492
+ }
493
+ switch (p) {
494
+ case "Y":
495
+ d += i.toString();
496
+ break;
497
+ case "y":
498
+ d += i.toString().slice(-2);
499
+ break;
500
+ case "m":
501
+ d += l(r);
502
+ break;
503
+ case "n":
504
+ d += r.toString();
505
+ break;
506
+ case "M":
507
+ d += c[r - 1];
508
+ break;
509
+ case "F":
510
+ d += s[r - 1];
511
+ break;
512
+ case "d":
513
+ d += l(n);
514
+ break;
515
+ case "j":
516
+ d += n.toString();
517
+ break;
518
+ case "D":
519
+ d += o[e.getDay()];
520
+ break;
521
+ case "l":
522
+ d += a[e.getDay()];
523
+ break;
524
+ case "S":
525
+ d += u(n);
526
+ break;
527
+ default:
528
+ d += p;
529
+ break;
530
+ }
531
+ }
532
+ return d;
533
+ }
534
+ _validateDateString(e, t) {
535
+ let n = this._parseDateString(e, t);
536
+ return n !== null && !isNaN(n.getTime());
537
+ }
538
+ render() {
539
+ let e = this.isLoading(), t = this.getLabel(), n = this.getInfo(), r = this.getValue(), i = this.isDisabled(), a = this.isReadonly(), o = this.isRequired(), s = this.getId() || this._a11yId, c = this.getName(), l = this.getFormat(), u = this.hasError(), d = this.getErrorMessage(), f = this.getSelectionMode();
540
+ this._isRange = this.isRange() || f === "week" || f === "month", this._input || (this._input = document.createElement("div"), this._input.className = "mint-date-picker-field", this.appendChild(this._input));
541
+ let p = this.querySelector(".mint-date-picker-label-container");
542
+ if (t || n) {
543
+ p || (p = document.createElement("div"), p.className = "mint-date-picker-label-container", this.contains(this._input) ? this.insertBefore(p, this._input) : this.appendChild(p));
544
+ let e = p.querySelector(".mint-date-picker-label");
545
+ t ? (e || (e = document.createElement("label"), e.className = "mint-date-picker-label", p.insertBefore(e, p.firstChild)), e.textContent = t, s && this._textInput && e.setAttribute("for", s)) : e && e.remove();
546
+ let r = p.querySelector(".mint-date-picker-info");
547
+ n ? (r || (r = document.createElement("span"), r.className = "mint-date-picker-info", p.appendChild(r)), r.textContent = n) : r && r.remove();
548
+ } else p && p.remove();
549
+ this._hiddenInput || (this._hiddenInput = document.createElement("input"), this._hiddenInput.type = "hidden", this._hiddenInput.value = r || "", this._textInput = this._hiddenInput, this._input.appendChild(this._hiddenInput)), s && (this._hiddenInput.id = s), c && (this._hiddenInput.name = c), this._hiddenInput.value = r || "", this._hiddenInput.setAttribute("aria-invalid", u ? "true" : "false");
550
+ let m = this._input.querySelector(".mint-date-fields");
551
+ m || (m = document.createElement("div"), this._input.appendChild(m)), this._fieldsContainer = m, this._applyErrorVisuals(u, d, i), m.innerHTML = "", this._displayEl = document.createElement("div"), this._displayEl.className = `mint-date-picker-display${a ? " is-readonly" : ""}`, this._displayEl.tabIndex = i || a ? -1 : 0, this._displayEl.setAttribute("role", "button"), this._displayEl.setAttribute("aria-label", `${this.getLabel() || "Date"}: ${r || "Select date"}`), this._displayEl.addEventListener("click", () => {
552
+ i || a || this._enterInputMode();
553
+ }), this._displayEl.addEventListener("keydown", (e) => {
554
+ i || a || (e.key === "Enter" || e.key === " ") && (e.preventDefault(), this._enterInputMode());
555
+ }), this._inputsWrapperEl = document.createElement("div"), this._isRange, this._inputsWrapperEl.className = "mint-date-picker-inputs";
556
+ let h = this._getFormatTokens(l);
557
+ this._startPartInputs = [], this._endPartInputs = [];
558
+ let g = (e) => {
559
+ let t = document.createDocumentFragment();
560
+ return h.forEach((n) => {
561
+ if (n.type === "sep") {
562
+ let e = document.createElement("span");
563
+ e.textContent = n.value, e.className = "mint-date-picker-separator", t.appendChild(e);
564
+ } else {
565
+ let r = n.part === "d" ? "dd" : n.part === "m" ? "mm" : n.len === 2 ? "yy" : "yyyy", s = this._createPartInput(n.len, r, i, a, o), c = n.part === "d" ? "day" : n.part === "m" ? "month" : "year", l = this.getLabel() || "Date";
566
+ s.setAttribute("aria-label", `${e === "end" ? `End ${l.toLowerCase()}` : l} ${c}`), e === "start" ? this._startPartInputs.push(s) : this._endPartInputs.push(s), t.appendChild(s);
567
+ }
568
+ }), t;
569
+ };
570
+ if (this._isRange) {
571
+ let e = document.createElement("div");
572
+ e.className = "mint-date-picker-range-part", e.appendChild(g("start")), this._inputsWrapperEl.appendChild(e);
573
+ let t = document.createElement("span");
574
+ t.textContent = " - ", t.className = "mint-date-picker-range-dash", this._inputsWrapperEl.appendChild(t);
575
+ let n = document.createElement("div");
576
+ n.className = "mint-date-picker-range-part", n.appendChild(g("end")), this._inputsWrapperEl.appendChild(n);
577
+ } else this._inputsWrapperEl.appendChild(g("start"));
578
+ let _ = document.createElement("div");
579
+ if (_.className = "mint-date-picker-stacked", this.classList.toggle("is-input-mode", this._isInputMode), _.appendChild(this._displayEl), _.appendChild(this._inputsWrapperEl), m.appendChild(_), this._isRange && this._inputsWrapperEl && this._setupContainerObserver(), m.addEventListener("click", () => {
580
+ this._isInputMode || i || a || this._enterInputMode();
581
+ }), this._attachPartInputHandlers(this._startPartInputs, h, m), this._isRange && this._attachPartInputHandlers(this._endPartInputs, h, m), this._parseValue(r), this._syncHiddenInput(), this._updateDisplayText(), this._iconButton) this._iconButton.disabled = i || a, !i && !a ? this._iconButton.tabIndex = 0 : this._iconButton.tabIndex = -1;
582
+ else {
583
+ this._iconButton = document.createElement("button"), this._iconButton.type = "button", this._iconButton.tabIndex = 0, this._iconButton.className = "mint-date-picker-icon-button", this._iconButton.setAttribute("aria-label", "Open calendar"), this._iconButton.setAttribute("aria-haspopup", "dialog"), this._iconButton.setAttribute("aria-expanded", "false");
584
+ let e = `date-icon-${Math.random().toString(36).substr(2, 9)}`;
585
+ this._iconButton.id = e;
586
+ let t = document.createElement("mint-icon");
587
+ t.setAttribute("name", "calendar"), t.className = "mint-date-picker-icon", this._iconButton.appendChild(t), this._input.prepend(this._iconButton), this._iconButton.disabled = i || a;
588
+ }
589
+ this._renderErrorState(u, d), this._syncDateFieldDescriptions(), this._renderSkeleton(e);
590
+ }
591
+ _renderErrorState(e, t) {
592
+ let n = this.querySelector(".mint-date-picker-error");
593
+ e && t ? (n || (n = document.createElement("div"), n.className = "mint-date-picker-error", this.appendChild(n)), n.textContent = t) : n && n.remove();
594
+ }
595
+ _syncDateFieldDescriptions() {
596
+ let e = Array.from(this.querySelectorAll(".mint-date-fields input"));
597
+ if (!e.length) return;
598
+ let t = (this.getAttribute("aria-describedby") || "").split(/\s+/).filter(Boolean), n = this.querySelector(".mint-date-picker-info"), r = this.querySelector(".mint-date-picker-error"), i = this.getAttribute("id") || this._a11yId;
599
+ n && (n.id = `${i}-info`, t.push(n.id)), r && (r.id = `${i}-error`, t.push(r.id));
600
+ let a = Array.from(new Set(t)).join(" ");
601
+ e.forEach((e) => {
602
+ e.setAttribute("aria-invalid", String(this._hiddenInput?.getAttribute("aria-invalid") === "true")), a ? e.setAttribute("aria-describedby", a) : e.removeAttribute("aria-describedby");
603
+ });
604
+ }
605
+ _applyErrorVisuals(e, t, n) {
606
+ if (this._renderErrorState(e, t), this._fieldsContainer) {
607
+ let t = this._getFieldContainerClass(e, n);
608
+ this._fieldsContainer.className = t;
609
+ }
610
+ this._hiddenInput && this._hiddenInput.setAttribute("aria-invalid", e ? "true" : "false"), this._syncDateFieldDescriptions();
611
+ }
612
+ _attachFormResetListener() {
613
+ let e = this.closest("form");
614
+ !e || this._resetHandler || (this._resetHandler = () => {
615
+ this.setValue(""), this._clearPartInputs(this._startPartInputs), this._clearPartInputs(this._endPartInputs), this._isInputMode = !1, this._updateDisplayText(), this._applyErrorVisuals(!1, "", this.isDisabled());
616
+ }, e.addEventListener("reset", this._resetHandler));
617
+ }
618
+ _clearPartInputs(e) {
619
+ e.forEach((e) => {
620
+ e.value = "";
621
+ });
622
+ }
623
+ _getFieldContainerClass(e, t) {
624
+ return `mint-date-fields${e ? " has-error" : ""}${t ? " is-disabled" : ""}`;
625
+ }
626
+ _handleInputChange(e) {}
627
+ _cleanInputValue(e, t) {
628
+ return e;
629
+ }
630
+ _handleBlur(e) {
631
+ let t = this.getFormat(), n = this.getSelectionMode(), r = this._isRange || n === "week" || n === "month";
632
+ if (!e) {
633
+ this.setValue(""), this._updateDisplayText();
634
+ return;
635
+ }
636
+ if (r) {
637
+ let [n, r] = this._splitRangeInput(e, t), i = n ? this._parseDateString(n, t) : null, a = r ? this._parseDateString(r, t) : null;
638
+ if (i && a) {
639
+ let [e, n] = i <= a ? [i, a] : [a, i], r = `${this._formatDate(e, t)} - ${this._formatDate(n, t)}`;
640
+ this.setValue(r), this._applyDateToParts(e, this._startPartInputs, this._getFormatTokens(t), t), this._applyDateToParts(n, this._endPartInputs, this._getFormatTokens(t), t), this._selectedStartDate = e, this._selectedEndDate = n, this._currentMonth = e.getMonth(), this._currentYear = e.getFullYear();
641
+ } else if (i) {
642
+ let e = this._formatDate(i, t);
643
+ this.setValue(e), this._applyDateToParts(i, this._startPartInputs, this._getFormatTokens(t), t), this._applyDateToParts(null, this._endPartInputs, this._getFormatTokens(t), t), this._selectedStartDate = i, this._selectedEndDate = null, this._currentMonth = i.getMonth(), this._currentYear = i.getFullYear();
644
+ } else this.setValue(""), this._applyDateToParts(null, this._startPartInputs, this._getFormatTokens(t), t), this._applyDateToParts(null, this._endPartInputs, this._getFormatTokens(t), t), this._selectedStartDate = null, this._selectedEndDate = null;
645
+ } else if (this._validateDateString(e, t)) {
646
+ let n = this._parseDateString(e, t);
647
+ if (n) {
648
+ let e = this._formatDate(n, t);
649
+ this.setValue(e), this._applyDateToParts(n, this._startPartInputs, this._getFormatTokens(t), t), this._selectedStartDate = n, this._selectedEndDate = null, this._currentMonth = n.getMonth(), this._currentYear = n.getFullYear();
650
+ }
651
+ } else this.setValue(""), this._applyDateToParts(null, this._startPartInputs, this._getFormatTokens(t), t), this._selectedStartDate = null, this._selectedEndDate = null;
652
+ }
653
+ _setupPopoverWithRetry(e = 0) {
654
+ if (!this._iconButton) {
655
+ e < 10 && requestAnimationFrame(() => {
656
+ this._setupPopoverWithRetry(e + 1);
657
+ });
658
+ return;
659
+ }
660
+ let t = this._iconButton.id;
661
+ t && this._iconButton.isConnected && document.getElementById(t) ? this._createPopover(t) : e < 10 && requestAnimationFrame(() => {
662
+ this._setupPopoverWithRetry(e + 1);
663
+ });
664
+ }
665
+ _createPopover(e) {
666
+ if (e) {
667
+ if (!document.getElementById(e)) {
668
+ setTimeout(() => {
669
+ this._createPopover(e);
670
+ }, 50);
671
+ return;
672
+ }
673
+ if (this._popover) {
674
+ if (this._popover.getAttribute("trigger-id") !== e) {
675
+ this._popover.setAttribute("trigger-id", e);
676
+ let t = this._popover;
677
+ typeof t._setupTrigger == "function" && t._setupTrigger();
678
+ }
679
+ this._buildCalendar();
680
+ } else {
681
+ this._popover = document.createElement("mint-popover"), this._popover.classList.add("mint-date-picker-popover"), this._popover.setAttribute("direction", "down"), this._popover.setAttribute("padding", "0");
682
+ let t = this.closest("mint-modal"), n = this.closest("mint-off-canvas");
683
+ t || n ? document.body.appendChild(this._popover) : this.parentNode ? this.parentNode.insertBefore(this._popover, this.nextSibling) : document.body.appendChild(this._popover), requestAnimationFrame(() => {
684
+ requestAnimationFrame(() => {
685
+ this._popover && this._popover.isConnected && (this._popover.setAttribute("trigger-id", e), this._popoverObserver || (this._popoverObserver = new MutationObserver((e) => {
686
+ e.forEach((e) => {
687
+ if (e.type === "attributes" && e.attributeName === "open") if (this._popover?.hasAttribute("open")) requestAnimationFrame(() => {
688
+ this._buildCalendar();
689
+ let e = this._popover;
690
+ typeof e.render == "function" && e.render(), this._setupFocusTrap();
691
+ });
692
+ else {
693
+ if (this._removeFocusTrap(), this._iconButton && !this._iconButton.disabled && requestAnimationFrame(() => {
694
+ this._iconButton?.focus();
695
+ }), this._viewMode = "calendar", this._selectedStartDate) this._currentMonth = this._selectedStartDate.getMonth(), this._currentYear = this._selectedStartDate.getFullYear();
696
+ else {
697
+ let e = /* @__PURE__ */ new Date();
698
+ this._currentMonth = e.getMonth(), this._currentYear = e.getFullYear();
699
+ }
700
+ requestAnimationFrame(() => {
701
+ this._buildCalendar();
702
+ }), this._hiddenInput && (this._syncHiddenInput(), setTimeout(() => {
703
+ let e = new FocusEvent("blur", {
704
+ bubbles: !0,
705
+ cancelable: !0,
706
+ relatedTarget: null
707
+ });
708
+ this._hiddenInput?.dispatchEvent(e);
709
+ }, 0));
710
+ }
711
+ });
712
+ }), this._popoverObserver.observe(this._popover, {
713
+ attributes: !0,
714
+ attributeFilter: ["open"]
715
+ })), requestAnimationFrame(() => {
716
+ this._buildCalendar();
717
+ }));
718
+ });
719
+ });
720
+ }
721
+ }
722
+ }
723
+ _buildCalendar() {
724
+ if (!this._popover) return;
725
+ this._calendarContainer && this._calendarContainer.parentNode && this._calendarContainer.remove(), this._calendarContainer = document.createElement("div"), this._calendarContainer.className = "mint-date-calendar";
726
+ let e = this.getMode();
727
+ e === "month" && this._viewMode === "calendar" ? this._viewMode = "month" : e === "year" && this._viewMode === "calendar" ? this._viewMode = "year" : e === "default" && this._viewMode !== "month" && this._viewMode !== "year" && (this._viewMode = "calendar"), this._viewMode === "calendar" ? this._buildCalendarView() : this._viewMode === "month" ? this._buildMonthView() : this._viewMode === "year" && this._buildYearView(), this._popover.replaceChildren(this._calendarContainer);
728
+ }
729
+ _buildCalendarView() {
730
+ if (!this._calendarContainer) return;
731
+ let e = this._getDaysInMonth(this._currentMonth, this._currentYear), t = this._getFirstDayOfMonth(this._currentMonth, this._currentYear), n = [
732
+ "January",
733
+ "February",
734
+ "March",
735
+ "April",
736
+ "May",
737
+ "June",
738
+ "July",
739
+ "August",
740
+ "September",
741
+ "October",
742
+ "November",
743
+ "December"
744
+ ], r = this.getWeekStartDay(), i = [
745
+ "Sun",
746
+ "Mon",
747
+ "Tue",
748
+ "Wed",
749
+ "Thu",
750
+ "Fri",
751
+ "Sat"
752
+ ], a = [...i.slice(r), ...i.slice(0, r)], o = this.getShortcuts(), s = o.length > 0;
753
+ this._calendarContainer.className = `mint-date-calendar${s ? " has-shortcuts" : ""}`;
754
+ let c = document.createElement("div");
755
+ c.className = "mint-date-calendar-layout";
756
+ let l = document.createElement("div");
757
+ l.className = "mint-date-calendar-content";
758
+ let u = document.createElement("div");
759
+ u.className = "mint-date-calendar-header";
760
+ let d = document.createElement("button");
761
+ d.type = "button", d.tabIndex = 0, d.className = "mint-date-calendar-nav-button", d.setAttribute("aria-label", "Previous month"), d.setAttribute("data-keep-popover-open", "true");
762
+ let f = document.createElement("mint-icon");
763
+ f.setAttribute("name", "caret-left"), f.className = "mint-date-calendar-icon", d.appendChild(f), d.addEventListener("click", () => {
764
+ let e = this._currentMonth, t = this._currentYear;
765
+ this._currentMonth === 0 ? (this._currentMonth = 11, this._currentYear--) : this._currentMonth--, this._buildCalendar(), this._dispatchMonthChangeEvent(e, t, this._currentMonth, this._currentYear);
766
+ }), u.appendChild(d);
767
+ let p = document.createElement("div");
768
+ p.className = "mint-date-calendar-month-year";
769
+ let m = document.createElement("button");
770
+ m.type = "button", m.tabIndex = 0, m.className = "mint-date-calendar-title-button", m.setAttribute("data-keep-popover-open", "true"), m.textContent = n[this._currentMonth], m.setAttribute("aria-label", `Choose month, ${n[this._currentMonth]}`);
771
+ let h = () => {
772
+ let e = this.getMode();
773
+ e !== "month" && e !== "year" && (this._viewMode = "month", this._buildCalendar());
774
+ };
775
+ m.addEventListener("click", h), m.addEventListener("touchend", (e) => {
776
+ e.preventDefault(), h();
777
+ }, { passive: !1 }), p.appendChild(m);
778
+ let g = document.createElement("button");
779
+ g.type = "button", g.tabIndex = 0, g.className = "mint-date-calendar-title-button", g.setAttribute("data-keep-popover-open", "true"), g.textContent = String(this._currentYear), g.setAttribute("aria-label", `Choose year, ${this._currentYear}`), g.addEventListener("click", () => {
780
+ this.getMode() !== "year" && (this._viewMode = "year", this._buildCalendar());
781
+ }), p.appendChild(g), u.appendChild(p);
782
+ let _ = document.createElement("button");
783
+ _.type = "button", _.tabIndex = 0, _.className = "mint-date-calendar-nav-button", _.setAttribute("aria-label", "Next month"), _.setAttribute("data-keep-popover-open", "true");
784
+ let v = document.createElement("mint-icon");
785
+ v.setAttribute("name", "caret-right"), v.className = "mint-date-calendar-icon", _.appendChild(v);
786
+ let y = () => {
787
+ let e = this._currentMonth, t = this._currentYear;
788
+ this._currentMonth === 11 ? (this._currentMonth = 0, this._currentYear++) : this._currentMonth++, this._buildCalendar(), this._dispatchMonthChangeEvent(e, t, this._currentMonth, this._currentYear);
789
+ };
790
+ _.addEventListener("click", y), _.addEventListener("touchend", (e) => {
791
+ e.preventDefault(), y();
792
+ }, { passive: !1 }), u.appendChild(_);
793
+ let b = document.createElement("div");
794
+ b.className = "mint-date-calendar-day-names", a.forEach((e) => {
795
+ let t = document.createElement("div");
796
+ t.className = "mint-date-calendar-day-name", t.textContent = e, b.appendChild(t);
797
+ });
798
+ let x = document.createElement("div");
799
+ x.className = "mint-date-calendar-grid", x.setAttribute("role", "group"), x.setAttribute("aria-label", `${n[this._currentMonth]} ${this._currentYear}`);
800
+ let S = this.getMin() ? this._parseDateString(this.getMin(), this.getFormat()) : null, C = this.getMax() ? this._parseDateString(this.getMax(), this.getFormat()) : null;
801
+ this.getDisabledDates();
802
+ let w = this._currentMonth === 0 ? 11 : this._currentMonth - 1, T = this._currentMonth === 0 ? this._currentYear - 1 : this._currentYear, E = this._getDaysInMonth(w, T), D = this._currentMonth === 11 ? 0 : this._currentMonth + 1, O = this._currentMonth === 11 ? this._currentYear + 1 : this._currentYear, k = t + e, A = Math.ceil(k / 7) * 7 - k, j = (e, t, n) => {
803
+ let r = this._isToday(e), i = this._isDateSelected(e), a = this._isDateInRange(e), o = S && e < S || C && e > C || this._isDateDisabled(e), s = "is-fully-rounded", c = this._isRange && this._selectedStartDate && !this._selectedEndDate && this._hoveredDate, l = c && this._selectedStartDate && this._hoveredDate && this._selectedStartDate < this._hoveredDate ? this._selectedStartDate : c && this._hoveredDate ? this._hoveredDate : null, u = c && this._selectedStartDate && this._hoveredDate && this._selectedStartDate < this._hoveredDate ? this._hoveredDate : c && this._selectedStartDate ? this._selectedStartDate : null, d = l !== null && this._isSameDate(e, l), f = u !== null && this._isSameDate(e, u), p = this._hoveredDate !== null && this._isSameDate(e, this._hoveredDate), m = c && this._hoveredDate && this._selectedStartDate ? !this._rangeIncludesDisabledDates(this._selectedStartDate < this._hoveredDate ? this._selectedStartDate : this._hoveredDate, this._selectedStartDate < this._hoveredDate ? this._hoveredDate : this._selectedStartDate) : !1;
804
+ if (this._isRange && this._selectedStartDate && this._selectedEndDate) {
805
+ let t = this._isSameDate(e, this._selectedStartDate), n = this._isSameDate(e, this._selectedEndDate);
806
+ t && n ? s = "is-fully-rounded" : t ? s = "is-range-start" : n ? s = "is-range-end" : a && (s = "is-range-middle");
807
+ } else c && (d || f) && m ? d && f ? s = "is-fully-rounded" : d ? s = "is-range-start" : f && (s = "is-range-end") : i && !this._isRange || i && this._isRange && !this._selectedEndDate ? s = "is-fully-rounded" : a && c && m && (s = "is-range-middle");
808
+ let h = document.createElement("button");
809
+ h.type = "button", h.disabled = !!o, h.tabIndex = o ? -1 : 0;
810
+ let g = ["mint-date-picker-day", s], _ = i || c && p && m;
811
+ return n || g.push("is-outside-month"), _ && g.push("is-selected"), a && !_ && g.push("is-in-range"), r && !_ && g.push("is-today"), o && g.push("is-disabled"), h.className = g.join(" "), h.textContent = t.toString(), h.setAttribute("aria-label", e.toLocaleDateString(void 0, {
812
+ weekday: "long",
813
+ year: "numeric",
814
+ month: "long",
815
+ day: "numeric"
816
+ })), h.setAttribute("aria-pressed", String(i)), r && h.setAttribute("aria-current", "date"), o || (h.addEventListener("click", (t) => {
817
+ t.preventDefault(), t.stopPropagation(), this._handleDateClick(e);
818
+ }), h.addEventListener("touchstart", (t) => {
819
+ t.preventDefault(), t.stopPropagation(), this._isTouchActive = !0, this._touchStartDate = e, this._touchStartElement = h, h.classList.add("is-touch-active");
820
+ }, { passive: !1 }), h.addEventListener("touchend", (t) => {
821
+ t.preventDefault(), t.stopPropagation(), this._isTouchActive && this._touchStartDate && this._isSameDate(this._touchStartDate, e) && this._handleDateClick(e), this._touchStartElement && this._touchStartElement.classList.remove("is-touch-active"), this._isTouchActive = !1, this._touchStartDate = null, this._touchStartElement = null;
822
+ }, { passive: !1 }), h.addEventListener("touchcancel", () => {
823
+ this._touchStartElement && this._touchStartElement.classList.remove("is-touch-active"), this._isTouchActive = !1, this._touchStartDate = null, this._touchStartElement = null;
824
+ }), this._isRange && this._selectedStartDate && !this._selectedEndDate && !o && (h.addEventListener("mouseenter", () => {
825
+ this._isHandlingClick || this._isTouchActive || this._isDateDisabled(e) || (!this._hoveredDate || !this._isSameDate(this._hoveredDate, e)) && (this._hoveredDate = e, this._buildCalendar());
826
+ }), h.addEventListener("touchmove", (e) => {
827
+ if (!this._isTouchActive || !this._touchStartDate) return;
828
+ let t = e.touches[0], n = document.elementFromPoint(t.clientX, t.clientY);
829
+ for (; n && !n.classList.contains("mint-date-picker-day");) n = n.parentElement;
830
+ if (n && n !== h) {
831
+ let e = n.getAttribute("data-date");
832
+ if (e) {
833
+ let t = new Date(e);
834
+ this._isDateDisabled(t) || (!this._hoveredDate || !this._isSameDate(this._hoveredDate, t)) && (this._hoveredDate = t, this._buildCalendar());
835
+ }
836
+ }
837
+ }, { passive: !0 }))), h;
838
+ };
839
+ for (let e = t - 1; e >= 0; e--) {
840
+ let t = E - e, n = j(new Date(T, w, t), t, !1);
841
+ x.appendChild(n);
842
+ }
843
+ for (let t = 1; t <= e; t++) {
844
+ let e = j(new Date(this._currentYear, this._currentMonth, t), t, !0);
845
+ x.appendChild(e);
846
+ }
847
+ for (let e = 1; e <= A; e++) {
848
+ let t = j(new Date(O, D, e), e, !1);
849
+ x.appendChild(t);
850
+ }
851
+ if (this._isRange && this._selectedStartDate && !this._selectedEndDate && (x.addEventListener("mouseleave", () => {
852
+ this._isTouchActive || (this._hoveredDate = null, this._buildCalendar());
853
+ }), x.addEventListener("touchend", (e) => {
854
+ let t = e.changedTouches[0], n = document.elementFromPoint(t.clientX, t.clientY);
855
+ n && !x.contains(n) && (this._hoveredDate = null, this._buildCalendar());
856
+ }, { passive: !0 })), s) {
857
+ let e = document.createElement("div");
858
+ e.className = "mint-date-shortcuts";
859
+ let t = document.createElement("div");
860
+ t.className = "mint-date-shortcuts-wrapper";
861
+ let n = document.createElement("div");
862
+ n.className = "mint-date-shortcuts-row";
863
+ let r = document.createElement("div");
864
+ r.className = "mint-date-shortcuts-fade is-horizontal is-left", t.appendChild(r);
865
+ let i = document.createElement("div");
866
+ i.className = "mint-date-shortcuts-fade is-horizontal is-right is-visible", t.appendChild(i);
867
+ let a = document.createElement("div");
868
+ a.className = "mint-date-shortcuts-fade is-vertical is-top", t.appendChild(a);
869
+ let s = document.createElement("div");
870
+ s.className = "mint-date-shortcuts-fade is-vertical is-bottom is-visible", t.appendChild(s);
871
+ let l = () => {
872
+ if (window.innerWidth >= 768) {
873
+ let e = n.scrollTop, t = n.scrollHeight, o = n.clientHeight;
874
+ e > 0 ? a.classList.add("is-visible") : a.classList.remove("is-visible"), e + o < t - 1 ? s.classList.add("is-visible") : s.classList.remove("is-visible"), r.classList.remove("is-visible"), i.classList.remove("is-visible");
875
+ } else {
876
+ let e = n.scrollLeft, t = n.scrollWidth, o = n.clientWidth;
877
+ e > 0 ? r.classList.add("is-visible") : r.classList.remove("is-visible"), e + o < t - 1 ? i.classList.add("is-visible") : i.classList.remove("is-visible"), a.classList.remove("is-visible"), s.classList.remove("is-visible");
878
+ }
879
+ };
880
+ n.addEventListener("scroll", l), window.addEventListener("resize", l), setTimeout(l, 0), o.forEach((e) => {
881
+ let t = document.createElement("button");
882
+ t.type = "button", t.tabIndex = 0, t.className = "mint-date-shortcut-button", t.textContent = e.label;
883
+ let r = () => {
884
+ let t = e.action();
885
+ if (t) {
886
+ if (this._isRange && "start" in t && "end" in t) {
887
+ this._selectedStartDate = t.start, this._selectedEndDate = t.end;
888
+ let e = this.getFormat(), n = `${this._formatDate(t.start, e)} - ${this._formatDate(t.end, e)}`;
889
+ this.setValue(n), this._currentMonth = t.start.getMonth(), this._currentYear = t.start.getFullYear();
890
+ } else if (t instanceof Date) {
891
+ this._selectedStartDate = t, this._selectedEndDate = null;
892
+ let e = this.getFormat(), n = this._formatDate(t, e);
893
+ this.setValue(n), this._currentMonth = t.getMonth(), this._currentYear = t.getFullYear();
894
+ }
895
+ this._buildCalendar(), this._popover && typeof this._popover.close == "function" && this._popover.close(), this.dispatchEvent(new CustomEvent("input", {
896
+ detail: { value: this.getValue() },
897
+ bubbles: !0,
898
+ cancelable: !0
899
+ })), this.dispatchEvent(new CustomEvent("change", {
900
+ detail: { value: this.getValue() },
901
+ bubbles: !0,
902
+ cancelable: !0
903
+ }));
904
+ }
905
+ };
906
+ t.addEventListener("click", r), t.addEventListener("touchend", (e) => {
907
+ e.preventDefault(), r();
908
+ }, { passive: !1 }), n.appendChild(t);
909
+ }), t.appendChild(n), e.appendChild(t), c.appendChild(e);
910
+ }
911
+ l.appendChild(u), l.appendChild(b), l.appendChild(x), c.appendChild(l), this._calendarContainer.appendChild(c);
912
+ }
913
+ _buildMonthView() {
914
+ if (!this._calendarContainer) return;
915
+ let e = [
916
+ "January",
917
+ "February",
918
+ "March",
919
+ "April",
920
+ "May",
921
+ "June",
922
+ "July",
923
+ "August",
924
+ "September",
925
+ "October",
926
+ "November",
927
+ "December"
928
+ ], t = document.createElement("div");
929
+ t.className = "mint-date-calendar-header";
930
+ let n = document.createElement("button");
931
+ n.type = "button", n.tabIndex = 0, n.className = "mint-date-calendar-nav-button", n.setAttribute("data-keep-popover-open", "true");
932
+ let r = document.createElement("mint-icon");
933
+ r.setAttribute("name", "caret-left"), r.className = "mint-date-calendar-icon", n.appendChild(r);
934
+ let i = () => {
935
+ let e = this._currentMonth, t = this._currentYear;
936
+ this._currentYear--, this._buildCalendar(), this._dispatchMonthChangeEvent(e, t, this._currentMonth, this._currentYear);
937
+ };
938
+ n.addEventListener("click", i), n.addEventListener("touchend", (e) => {
939
+ e.preventDefault(), i();
940
+ }, { passive: !1 }), t.appendChild(n);
941
+ let a = document.createElement("button");
942
+ a.type = "button", a.tabIndex = 0, a.className = "mint-date-calendar-title-button", a.setAttribute("data-keep-popover-open", "true"), a.textContent = String(this._currentYear);
943
+ let o = () => {
944
+ this.getMode() !== "year" && (this._viewMode = "year", this._buildCalendar());
945
+ };
946
+ a.addEventListener("click", o), a.addEventListener("touchend", (e) => {
947
+ e.preventDefault(), o();
948
+ }, { passive: !1 }), t.appendChild(a);
949
+ let s = document.createElement("button");
950
+ s.type = "button", s.tabIndex = 0, s.className = "mint-date-calendar-nav-button", s.setAttribute("data-keep-popover-open", "true");
951
+ let c = document.createElement("mint-icon");
952
+ c.setAttribute("name", "caret-right"), c.className = "mint-date-calendar-icon", s.appendChild(c);
953
+ let l = () => {
954
+ let e = this._currentMonth, t = this._currentYear;
955
+ this._currentYear++, this._buildCalendar(), this._dispatchMonthChangeEvent(e, t, this._currentMonth, this._currentYear);
956
+ };
957
+ s.addEventListener("click", l), s.addEventListener("touchend", (e) => {
958
+ e.preventDefault(), l();
959
+ }, { passive: !1 }), t.appendChild(s);
960
+ let u = document.createElement("div");
961
+ u.className = "mint-date-calendar-option-grid", e.forEach((e, t) => {
962
+ let n = document.createElement("button");
963
+ n.type = "button", n.tabIndex = 0, this.getMode() !== "month" && n.setAttribute("data-keep-popover-open", "true"), n.className = `mint-date-calendar-option${this._currentMonth === t ? " is-selected" : ""}`, n.textContent = e;
964
+ let r = () => {
965
+ if (this.getMode() === "month") {
966
+ let e = new Date(this._currentYear, t, 1), n = this.getFormat(), r = this._formatDate(e, n);
967
+ this.setValue(r), this._selectedStartDate = e, this._selectedEndDate = null;
968
+ let i = this._currentMonth, a = this._currentYear;
969
+ this._currentMonth = t, this._dispatchMonthChangeEvent(i, a, this._currentMonth, this._currentYear), this.dispatchEvent(new CustomEvent("input", {
970
+ detail: { value: this.getValue() },
971
+ bubbles: !0,
972
+ cancelable: !0
973
+ })), this.dispatchEvent(new CustomEvent("change", {
974
+ detail: { value: this.getValue() },
975
+ bubbles: !0,
976
+ cancelable: !0
977
+ })), this._dispatchDateChangeEvent(), this._popover && typeof this._popover.close == "function" && this._popover.close();
978
+ } else {
979
+ let e = this._currentMonth, n = this._currentYear;
980
+ this._currentMonth = t, this._viewMode = "calendar", this._buildCalendar(), this._dispatchMonthChangeEvent(e, n, this._currentMonth, this._currentYear);
981
+ }
982
+ };
983
+ n.addEventListener("click", r), n.addEventListener("touchend", (e) => {
984
+ e.preventDefault(), r();
985
+ }, { passive: !1 }), u.appendChild(n);
986
+ }), this._calendarContainer.appendChild(t), this._calendarContainer.appendChild(u);
987
+ }
988
+ _buildYearView() {
989
+ if (!this._calendarContainer) return;
990
+ let e = this._currentYear - 6, t = this._currentYear + 6, n = document.createElement("div");
991
+ n.className = "mint-date-calendar-header";
992
+ let r = document.createElement("button");
993
+ r.type = "button", r.tabIndex = 0, r.className = "mint-date-calendar-nav-button", r.setAttribute("data-keep-popover-open", "true");
994
+ let i = document.createElement("mint-icon");
995
+ i.setAttribute("name", "caret-left"), i.className = "mint-date-calendar-icon", r.appendChild(i);
996
+ let a = () => {
997
+ let e = this._currentMonth, t = this._currentYear;
998
+ this._currentYear -= 12, this._buildCalendar(), this._dispatchMonthChangeEvent(e, t, this._currentMonth, this._currentYear);
999
+ };
1000
+ r.addEventListener("click", a), r.addEventListener("touchend", (e) => {
1001
+ e.preventDefault(), a();
1002
+ }, { passive: !1 }), n.appendChild(r);
1003
+ let o = document.createElement("div");
1004
+ o.className = "mint-date-calendar-title", o.textContent = `${e} - ${t}`, n.appendChild(o);
1005
+ let s = document.createElement("button");
1006
+ s.type = "button", s.tabIndex = 0, s.className = "mint-date-calendar-nav-button", s.setAttribute("data-keep-popover-open", "true");
1007
+ let c = document.createElement("mint-icon");
1008
+ c.setAttribute("name", "caret-right"), c.className = "mint-date-calendar-icon", s.appendChild(c);
1009
+ let l = () => {
1010
+ let e = this._currentMonth, t = this._currentYear;
1011
+ this._currentYear += 12, this._buildCalendar(), this._dispatchMonthChangeEvent(e, t, this._currentMonth, this._currentYear);
1012
+ };
1013
+ s.addEventListener("click", l), s.addEventListener("touchend", (e) => {
1014
+ e.preventDefault(), l();
1015
+ }, { passive: !1 }), n.appendChild(s);
1016
+ let u = document.createElement("div");
1017
+ u.className = "mint-date-calendar-option-grid";
1018
+ for (let n = e; n <= t; n++) {
1019
+ let e = document.createElement("button");
1020
+ e.type = "button", e.tabIndex = 0, this.getMode() !== "year" && e.setAttribute("data-keep-popover-open", "true"), e.className = `mint-date-calendar-option${this._currentYear === n ? " is-selected" : ""}`, e.textContent = String(n), e.addEventListener("click", () => {
1021
+ let e = this.getMode();
1022
+ if (e === "year") {
1023
+ let e = new Date(n, 0, 1), t = this.getFormat(), r = this._formatDate(e, t);
1024
+ this.setValue(r), this._selectedStartDate = e, this._selectedEndDate = null;
1025
+ let i = this._currentMonth, a = this._currentYear;
1026
+ this._currentYear = n, this._currentMonth = 0, this._dispatchMonthChangeEvent(i, a, this._currentMonth, this._currentYear), this.dispatchEvent(new CustomEvent("input", {
1027
+ detail: { value: this.getValue() },
1028
+ bubbles: !0,
1029
+ cancelable: !0
1030
+ })), this.dispatchEvent(new CustomEvent("change", {
1031
+ detail: { value: this.getValue() },
1032
+ bubbles: !0,
1033
+ cancelable: !0
1034
+ })), this._dispatchDateChangeEvent(), this._popover && typeof this._popover.close == "function" && this._popover.close();
1035
+ } else if (e === "month") {
1036
+ let e = this._currentMonth, t = this._currentYear;
1037
+ this._currentYear = n, this._viewMode = "month", this._buildCalendar(), this._dispatchMonthChangeEvent(e, t, this._currentMonth, this._currentYear);
1038
+ } else {
1039
+ let e = this._currentMonth, t = this._currentYear;
1040
+ this._currentYear = n, this._viewMode = "calendar", this._buildCalendar(), this._dispatchMonthChangeEvent(e, t, this._currentMonth, this._currentYear);
1041
+ }
1042
+ }), u.appendChild(e);
1043
+ }
1044
+ this._calendarContainer.appendChild(n), this._calendarContainer.appendChild(u);
1045
+ }
1046
+ _getDaysInMonth(e, t) {
1047
+ return new Date(t, e + 1, 0).getDate();
1048
+ }
1049
+ _getFirstDayOfMonth(e, t) {
1050
+ let n = this.getWeekStartDay(), r = new Date(t, e, 1).getDay();
1051
+ return r >= n ? r - n : 7 - (n - r);
1052
+ }
1053
+ _isToday(e) {
1054
+ let t = /* @__PURE__ */ new Date();
1055
+ return e.getDate() === t.getDate() && e.getMonth() === t.getMonth() && e.getFullYear() === t.getFullYear();
1056
+ }
1057
+ _isDateSelected(e) {
1058
+ let t = this.getSelectionMode();
1059
+ return this._isRange || t === "week" || t === "month" ? this._selectedStartDate && this._selectedEndDate ? this._isSameDate(e, this._selectedStartDate) || this._isSameDate(e, this._selectedEndDate) : this._isRange && this._selectedStartDate && !this._selectedEndDate ? this._isSameDate(e, this._selectedStartDate) : !1 : this._selectedStartDate !== null && this._isSameDate(e, this._selectedStartDate);
1060
+ }
1061
+ _isDateInRange(e) {
1062
+ let t = this.getSelectionMode();
1063
+ if ((this._isRange || t === "week" || t === "month") && this._selectedStartDate && this._selectedEndDate) return this._rangeIncludesDisabledDates(this._selectedStartDate, this._selectedEndDate) ? !1 : e >= this._selectedStartDate && e <= this._selectedEndDate;
1064
+ if (this._isRange && this._selectedStartDate && !this._selectedEndDate && this._hoveredDate) {
1065
+ let t = this._selectedStartDate < this._hoveredDate ? this._selectedStartDate : this._hoveredDate, n = this._selectedStartDate < this._hoveredDate ? this._hoveredDate : this._selectedStartDate;
1066
+ if (this._rangeIncludesDisabledDates(t, n)) {
1067
+ let r = this._findFirstDisabledDateInRange(t, n);
1068
+ return r ? this._selectedStartDate < this._hoveredDate ? e >= t && e < r && !this._isSameDate(e, t) : e > r && e <= n && !this._isSameDate(e, n) : !1;
1069
+ }
1070
+ return e >= t && e <= n && !this._isSameDate(e, t) && !this._isSameDate(e, n);
1071
+ }
1072
+ return !1;
1073
+ }
1074
+ _rangeIncludesDisabledDates(e, t) {
1075
+ let n = this.getDisabledDates(), r = new Date(e.getFullYear(), e.getMonth(), e.getDate()), i = new Date(t.getFullYear(), t.getMonth(), t.getDate());
1076
+ return n.some((e) => {
1077
+ let t = new Date(e.getFullYear(), e.getMonth(), e.getDate());
1078
+ return t >= r && t <= i;
1079
+ });
1080
+ }
1081
+ _findFirstDisabledDateInRange(e, t) {
1082
+ let n = this.getDisabledDates(), r = new Date(e.getFullYear(), e.getMonth(), e.getDate()), i = new Date(t.getFullYear(), t.getMonth(), t.getDate()), a = n.map((e) => new Date(e.getFullYear(), e.getMonth(), e.getDate())).filter((e) => e >= r && e <= i).sort((e, t) => e.getTime() - t.getTime());
1083
+ return a.length > 0 ? a[0] : null;
1084
+ }
1085
+ _hasIncompleteRange() {
1086
+ return this._isRange && this._selectedStartDate !== null && this._selectedEndDate === null;
1087
+ }
1088
+ _isSameDate(e, t) {
1089
+ return e.getDate() === t.getDate() && e.getMonth() === t.getMonth() && e.getFullYear() === t.getFullYear();
1090
+ }
1091
+ _isDateDisabled(e) {
1092
+ return this.getDisabledDates().some((t) => this._isSameDate(e, t));
1093
+ }
1094
+ _dispatchMonthChangeEvent(e, t, n, r) {
1095
+ (e !== n || t !== r) && this.dispatchEvent(new CustomEvent("month-change", {
1096
+ detail: {
1097
+ month: n,
1098
+ year: r,
1099
+ oldMonth: e,
1100
+ oldYear: t
1101
+ },
1102
+ bubbles: !0,
1103
+ cancelable: !0,
1104
+ composed: !0
1105
+ }));
1106
+ }
1107
+ _dispatchDateChangeEvent() {
1108
+ let e = this.getFormat(), t = { value: this.getValue() };
1109
+ this._selectedStartDate && (t.startDate = this._selectedStartDate, t.startDateFormatted = this._formatDate(this._selectedStartDate, e)), this._selectedEndDate && (t.endDate = this._selectedEndDate, t.endDateFormatted = this._formatDate(this._selectedEndDate, e)), this.dispatchEvent(new CustomEvent("date-change", {
1110
+ detail: t,
1111
+ bubbles: !0,
1112
+ cancelable: !0,
1113
+ composed: !0
1114
+ }));
1115
+ }
1116
+ _setupContainerObserver() {
1117
+ if (this._resizeObserver &&= (this._resizeObserver.disconnect(), null), !this._inputsWrapperEl) return;
1118
+ let e = (e) => {
1119
+ this._inputsWrapperEl && (e < 400 ? (this._inputsWrapperEl.classList.add("is-wrapping"), this._inputsWrapperEl.classList.remove("is-nowrap")) : (this._inputsWrapperEl.classList.remove("is-wrapping"), this._inputsWrapperEl.classList.add("is-nowrap")));
1120
+ };
1121
+ e(this._inputsWrapperEl.offsetWidth || this.offsetWidth), this._resizeObserver = new ResizeObserver((t) => {
1122
+ for (let n of t) {
1123
+ let t = n.contentRect.width;
1124
+ e(t);
1125
+ }
1126
+ }), this._resizeObserver.observe(this);
1127
+ }
1128
+ _getWeekStart(e) {
1129
+ let t = this.getWeekStartDay(), n = e.getDay(), r;
1130
+ r = n >= t ? n - t : 7 - (t - n);
1131
+ let i = new Date(e);
1132
+ return i.setDate(e.getDate() - r), i.setHours(0, 0, 0, 0), i;
1133
+ }
1134
+ _getWeekEnd(e) {
1135
+ let t = this._getWeekStart(e), n = new Date(t);
1136
+ return n.setDate(t.getDate() + 6), n.setHours(23, 59, 59, 999), n;
1137
+ }
1138
+ _getMonthStart(e) {
1139
+ let t = new Date(e.getFullYear(), e.getMonth(), 1);
1140
+ return t.setHours(0, 0, 0, 0), t;
1141
+ }
1142
+ _getMonthEnd(e) {
1143
+ let t = new Date(e.getFullYear(), e.getMonth() + 1, 0);
1144
+ return t.setHours(23, 59, 59, 999), t;
1145
+ }
1146
+ _handleDateClick(e) {
1147
+ this._isHandlingClick = !0;
1148
+ try {
1149
+ let t = this.getFormat(), n = this.getSelectionMode(), r, i;
1150
+ if (n === "week" ? (r = this._getWeekStart(e), i = this._getWeekEnd(e)) : n === "month" ? (r = this._getMonthStart(e), i = this._getMonthEnd(e)) : (r = e, i = e), this.isRange() || n === "week" || n === "month") if (n === "week" || n === "month") {
1151
+ if (this._rangeIncludesDisabledDates(r, i)) {
1152
+ this._buildCalendar();
1153
+ return;
1154
+ }
1155
+ this._selectedStartDate = r, this._selectedEndDate = i;
1156
+ let e = `${this._formatDate(this._selectedStartDate, t)} - ${this._formatDate(this._selectedEndDate, t)}`;
1157
+ this.setValue(e), this._textInput && (this._textInput.value = e), this._popover && typeof this._popover.close == "function" && this._popover.close();
1158
+ } else if (this._hoveredDate = null, this._selectedStartDate === null) {
1159
+ if (this._isDateDisabled(r)) {
1160
+ this._buildCalendar();
1161
+ return;
1162
+ }
1163
+ this._selectedStartDate = new Date(r.getFullYear(), r.getMonth(), r.getDate()), this._selectedEndDate = null, this._currentMonth = this._selectedStartDate.getMonth(), this._currentYear = this._selectedStartDate.getFullYear(), this._hoveredDate = null, this._buildCalendar();
1164
+ } else if (this._selectedEndDate === null) {
1165
+ let n = new Date(e.getFullYear(), e.getMonth(), e.getDate()), r = this._selectedStartDate ? new Date(this._selectedStartDate.getFullYear(), this._selectedStartDate.getMonth(), this._selectedStartDate.getDate()) : null, i, a;
1166
+ if (r && n < r ? (i = n, a = r) : (i = r, a = n), this._rangeIncludesDisabledDates(i, a)) {
1167
+ this._buildCalendar();
1168
+ return;
1169
+ }
1170
+ r && n < r ? (this._selectedEndDate = r, this._selectedStartDate = n) : (this._selectedEndDate = n, r && (this._selectedStartDate = r)), this._currentMonth = this._selectedStartDate.getMonth(), this._currentYear = this._selectedStartDate.getFullYear();
1171
+ let o = `${this._formatDate(this._selectedStartDate, t)} - ${this._formatDate(this._selectedEndDate, t)}`;
1172
+ this.setAttribute("value", o), this._textInput && (this._textInput.value = o), this._hiddenInput && (this._hiddenInput.value = o), this._updateDisplayText(), this._buildCalendar(), this._popover && typeof this._popover.close == "function" && this._popover.close();
1173
+ } else this._selectedStartDate = r, this._selectedEndDate = null;
1174
+ else {
1175
+ this._selectedStartDate = r, this._selectedEndDate = null;
1176
+ let e = this._formatDate(r, t);
1177
+ this.setValue(e), this._textInput && (this._textInput.value = e), !this.hasAttribute("keep-open-on-select") && this._popover && typeof this._popover.close == "function" && this._popover.close();
1178
+ }
1179
+ this._buildCalendar(), this._updateDisplayText(), this._exitInputMode();
1180
+ let a = new Event("input", {
1181
+ bubbles: !0,
1182
+ cancelable: !0,
1183
+ composed: !0
1184
+ });
1185
+ this.dispatchEvent(a), this.dispatchEvent(new CustomEvent("input", {
1186
+ detail: { value: this.getValue() },
1187
+ bubbles: !0,
1188
+ cancelable: !0,
1189
+ composed: !0
1190
+ })), this.dispatchEvent(new CustomEvent("change", {
1191
+ detail: { value: this.getValue() },
1192
+ bubbles: !0,
1193
+ cancelable: !0,
1194
+ composed: !0
1195
+ })), this._dispatchDateChangeEvent();
1196
+ } finally {
1197
+ this._isHandlingClick = !1;
1198
+ }
1199
+ }
1200
+ _updateDisplayText() {
1201
+ if (!this._displayEl) return;
1202
+ let e = this.getDisplayFormat(), t = this.getSelectionMode(), n = this._isRange || t === "week" || t === "month", r = "";
1203
+ n && this._selectedStartDate && this._selectedEndDate ? r = `${this._formatDatePhp(this._selectedStartDate, e)} - ${this._formatDatePhp(this._selectedEndDate, e)}` : this._selectedStartDate && (r = this._formatDatePhp(this._selectedStartDate, e)), r ? (this._displayEl.textContent = r, this._displayEl.classList.remove("is-empty")) : (this._displayEl.textContent = "Select date", this._displayEl.classList.add("is-empty")), this._displayEl && this._inputsWrapperEl && this.classList.toggle("is-input-mode", this._isInputMode);
1204
+ }
1205
+ _enterInputMode() {
1206
+ if (!this._isInputMode && !(this.isReadonly() || this.isDisabled()) && (this._isInputMode = !0, this._displayEl && this._inputsWrapperEl && this.classList.add("is-input-mode"), this._startPartInputs.length > 0)) {
1207
+ let e = this._startPartInputs[0];
1208
+ requestAnimationFrame(() => {
1209
+ e.focus();
1210
+ try {
1211
+ e.setSelectionRange(0, e.value.length);
1212
+ } catch {}
1213
+ });
1214
+ }
1215
+ }
1216
+ _exitInputMode() {
1217
+ this._isInputMode && (this._isInputMode = !1, this._displayEl && this._inputsWrapperEl && this.classList.remove("is-input-mode"), this._updateDisplayText());
1218
+ }
1219
+ _renderSkeleton(e) {
1220
+ let t = this.querySelector(".mint-date-picker-skeleton-container");
1221
+ this._fieldsContainer;
1222
+ let n = this._input;
1223
+ if (e) {
1224
+ t || (t = document.createElement("div"), t.className = "mint-date-picker-skeleton-container", n ? n.appendChild(t) : (this.classList.add("is-positioned"), this.appendChild(t)));
1225
+ let e = t.querySelector(".mint-date-picker-skeleton");
1226
+ e || (e = document.createElement("div"), e.className = "mint-date-picker-skeleton", t.appendChild(e)), this.classList.add("is-loading");
1227
+ } else t?.remove(), this.classList.remove("is-loading", "is-positioned");
1228
+ }
1229
+ _getFocusableElements() {
1230
+ if (!this._calendarContainer) return [];
1231
+ let e = [
1232
+ "button:not([disabled])",
1233
+ "a[href]",
1234
+ "input:not([disabled]):not([type=\"hidden\"])",
1235
+ "select:not([disabled])",
1236
+ "textarea:not([disabled])",
1237
+ "[tabindex]:not([tabindex=\"-1\"])"
1238
+ ].join(", ");
1239
+ return Array.from(this._calendarContainer.querySelectorAll(e)).filter((e) => {
1240
+ let t = window.getComputedStyle(e);
1241
+ return t.display !== "none" && t.visibility !== "hidden";
1242
+ });
1243
+ }
1244
+ _setupFocusTrap() {
1245
+ if (!this._popover || !this._popover.hasAttribute("open")) return;
1246
+ this._removeFocusTrap();
1247
+ let e = this;
1248
+ this._focusTrapHandler = function(t) {
1249
+ if (t.key !== "Tab") return;
1250
+ if (!e._popover || !e._popover.hasAttribute("open")) {
1251
+ e._removeFocusTrap();
1252
+ return;
1253
+ }
1254
+ let n = e._getFocusableElements();
1255
+ if (n.length === 0) return;
1256
+ let r = n[0], i = n[n.length - 1], a = document.activeElement;
1257
+ if (!e._calendarContainer?.contains(a)) {
1258
+ t.preventDefault(), r.focus();
1259
+ return;
1260
+ }
1261
+ if (t.shiftKey && a === r) {
1262
+ t.preventDefault(), i.focus();
1263
+ return;
1264
+ }
1265
+ if (!t.shiftKey && a === i) {
1266
+ t.preventDefault(), r.focus();
1267
+ return;
1268
+ }
1269
+ }, this._escapeHandler = function(t) {
1270
+ (t.key === "Escape" || t.key === "Esc") && e._popover && e._popover.hasAttribute("open") && (t.preventDefault(), t.stopPropagation(), typeof e._popover.close == "function" && e._popover.close());
1271
+ }, document.addEventListener("keydown", this._focusTrapHandler, !0), document.addEventListener("keydown", this._escapeHandler, !0), requestAnimationFrame(() => {
1272
+ let e = this._getFocusableElements();
1273
+ e.length > 0 && e[0].focus();
1274
+ });
1275
+ }
1276
+ _removeFocusTrap() {
1277
+ this._focusTrapHandler &&= (document.removeEventListener("keydown", this._focusTrapHandler, !0), null), this._escapeHandler &&= (document.removeEventListener("keydown", this._escapeHandler, !0), null);
1278
+ }
1279
+ };
1280
+ customElements.get("mint-date-picker") || t("mint-date-picker", n);
1281
+ //#endregion
1282
+ export { n as t };