@salla.sa/twilight-components 1.6.3 → 1.6.5

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 (103) hide show
  1. package/dist/cjs/loader.cjs.js +1 -1
  2. package/dist/cjs/salla-button_27.cjs.entry.js +27877 -0
  3. package/dist/cjs/salla-loyalty-prize-item.cjs.entry.js +26 -0
  4. package/dist/cjs/salla-scopes.cjs.entry.js +9 -6
  5. package/dist/cjs/salla-select.cjs.entry.js +159 -0
  6. package/dist/cjs/twilight-components.cjs.js +1 -1
  7. package/dist/collection/assets/svg/caret-down.svg +0 -1
  8. package/dist/collection/assets/svg/images.svg +0 -1
  9. package/dist/collection/collection-manifest.json +5 -0
  10. package/dist/collection/components/salla-datetime-picker/interfaces.js +4 -0
  11. package/dist/collection/components/salla-datetime-picker/salla-datetime-picker.css +13 -0
  12. package/dist/collection/components/salla-datetime-picker/salla-datetime-picker.js +1374 -0
  13. package/dist/collection/components/salla-file-upload/interfaces.js +42 -0
  14. package/dist/collection/components/salla-file-upload/salla-file-upload.css +219 -0
  15. package/dist/collection/components/salla-file-upload/salla-file-upload.js +1435 -0
  16. package/dist/collection/components/salla-gifting/gift-schema.js +4 -0
  17. package/dist/collection/components/salla-gifting/intefaces.js +4 -0
  18. package/dist/collection/components/salla-gifting/salla-gifting.css +20 -0
  19. package/dist/collection/components/salla-gifting/salla-gifting.js +564 -0
  20. package/dist/collection/components/salla-localization-modal/salla-localization-modal.js +23 -13
  21. package/dist/collection/components/salla-login-modal/salla-login-modal.js +48 -29
  22. package/dist/collection/components/salla-loyalty/salla-loyalty-prize-item.css +3 -0
  23. package/dist/collection/components/salla-loyalty/salla-loyalty-prize-item.js +69 -0
  24. package/dist/collection/components/salla-loyalty/salla-loyalty.css +0 -4
  25. package/dist/collection/components/salla-loyalty/salla-loyalty.js +29 -16
  26. package/dist/collection/components/salla-modal/salla-modal.css +6 -1
  27. package/dist/collection/components/salla-offer-modal/salla-offer-modal.js +37 -13
  28. package/dist/collection/components/salla-product-size-guide/salla-product-size-guide.js +23 -8
  29. package/dist/collection/components/salla-rating-modal/salla-rating-modal.js +87 -64
  30. package/dist/collection/components/salla-scopes/salla-scopes.js +11 -7
  31. package/dist/collection/components/salla-search/salla-search.js +1 -1
  32. package/dist/collection/components/salla-select/salla-select.css +86 -0
  33. package/dist/collection/components/salla-select/salla-select.js +610 -0
  34. package/dist/collection/components/salla-social-share/salla-social-share.js +1 -3
  35. package/dist/collection/components/salla-tel-input/interfaces.js +4 -0
  36. package/dist/collection/components/salla-tel-input/salla-tel-input.css +1 -2
  37. package/dist/collection/components/salla-tel-input/salla-tel-input.js +32 -3
  38. package/dist/collection/components/salla-verify/salla-verify.js +1 -1
  39. package/dist/collection/global/app.js +15 -12
  40. package/dist/components/_commonjsHelpers.js +24 -0
  41. package/dist/components/anime.es.js +1312 -0
  42. package/dist/components/index.d.ts +5 -0
  43. package/dist/components/index.js +5 -0
  44. package/dist/components/salla-datetime-picker.d.ts +11 -0
  45. package/dist/components/salla-datetime-picker.js +9 -0
  46. package/dist/components/salla-datetime-picker2.js +2876 -0
  47. package/dist/components/salla-file-upload.d.ts +11 -0
  48. package/dist/components/salla-file-upload.js +9 -0
  49. package/dist/components/salla-file-upload2.js +14623 -0
  50. package/dist/components/salla-gifting.d.ts +11 -0
  51. package/dist/components/salla-gifting.js +499 -0
  52. package/dist/components/salla-localization-modal.js +31 -16
  53. package/dist/components/salla-login-modal.js +37 -20
  54. package/dist/components/salla-loyalty-prize-item.d.ts +11 -0
  55. package/dist/components/salla-loyalty-prize-item.js +42 -0
  56. package/dist/components/salla-loyalty.js +28 -17
  57. package/dist/components/salla-modal2.js +1 -1
  58. package/dist/components/salla-offer-modal.js +42 -12
  59. package/dist/components/salla-product-size-guide.js +21 -6
  60. package/dist/components/salla-rating-modal.js +47 -19
  61. package/dist/components/salla-scopes.js +10 -6
  62. package/dist/components/salla-search.js +1 -1
  63. package/dist/components/salla-select.d.ts +11 -0
  64. package/dist/components/salla-select.js +199 -0
  65. package/dist/components/salla-social-share.js +2 -1311
  66. package/dist/components/salla-swiper2.js +9 -9
  67. package/dist/components/salla-tel-input2.js +15 -18
  68. package/dist/components/salla-verify2.js +1 -1
  69. package/dist/esm/loader.js +1 -1
  70. package/dist/esm/salla-button_27.entry.js +27847 -0
  71. package/dist/esm/salla-loyalty-prize-item.entry.js +22 -0
  72. package/dist/esm/salla-scopes.entry.js +9 -6
  73. package/dist/esm/salla-select.entry.js +155 -0
  74. package/dist/esm/twilight-components.js +1 -1
  75. package/dist/twilight-components/p-49125b6a.entry.js +4 -0
  76. package/dist/twilight-components/p-6087187d.entry.js +22 -0
  77. package/dist/twilight-components/p-9a25753c.entry.js +4 -0
  78. package/dist/twilight-components/p-df1eb1e5.entry.js +4 -0
  79. package/dist/twilight-components/twilight-components.esm.js +1 -1
  80. package/dist/types/components/salla-datetime-picker/interfaces.d.ts +8 -0
  81. package/dist/types/components/salla-datetime-picker/salla-datetime-picker.d.ts +250 -0
  82. package/dist/types/components/salla-file-upload/interfaces.d.ts +766 -0
  83. package/dist/types/components/salla-file-upload/salla-file-upload.d.ts +267 -0
  84. package/dist/types/components/salla-gifting/gift-schema.d.ts +20 -0
  85. package/dist/types/components/salla-gifting/intefaces.d.ts +18 -0
  86. package/dist/types/components/salla-gifting/salla-gifting.d.ts +98 -0
  87. package/dist/types/components/salla-localization-modal/salla-localization-modal.d.ts +3 -2
  88. package/dist/types/components/salla-login-modal/salla-login-modal.d.ts +13 -3
  89. package/dist/types/components/salla-loyalty/salla-loyalty-prize-item.d.ts +8 -0
  90. package/dist/types/components/salla-loyalty/salla-loyalty.d.ts +2 -0
  91. package/dist/types/components/salla-offer-modal/salla-offer-modal.d.ts +3 -1
  92. package/dist/types/components/salla-product-size-guide/salla-product-size-guide.d.ts +4 -0
  93. package/dist/types/components/salla-rating-modal/salla-rating-modal.d.ts +3 -2
  94. package/dist/types/components/salla-scopes/salla-scopes.d.ts +1 -0
  95. package/dist/types/components/salla-select/salla-select.d.ts +110 -0
  96. package/dist/types/components/salla-tel-input/interfaces.d.ts +4 -0
  97. package/dist/types/components/salla-tel-input/salla-tel-input.d.ts +3 -0
  98. package/dist/types/components.d.ts +1253 -10
  99. package/package.json +3 -3
  100. package/dist/cjs/salla-button_24.cjs.entry.js +0 -10087
  101. package/dist/esm/salla-button_24.entry.js +0 -10060
  102. package/dist/twilight-components/p-30b2c5b0.entry.js +0 -4
  103. package/dist/twilight-components/p-5fb32395.entry.js +0 -4
@@ -0,0 +1,2876 @@
1
+ /*!
2
+ * Crafted with ❤ by Salla
3
+ */
4
+ import { proxyCustomElement, HTMLElement as HTMLElement$1, createEvent, h } from '@stencil/core/internal/client';
5
+
6
+ var HOOKS = [
7
+ "onChange",
8
+ "onClose",
9
+ "onDayCreate",
10
+ "onDestroy",
11
+ "onKeyDown",
12
+ "onMonthChange",
13
+ "onOpen",
14
+ "onParseConfig",
15
+ "onReady",
16
+ "onValueUpdate",
17
+ "onYearChange",
18
+ "onPreCalendarPosition",
19
+ ];
20
+ var defaults = {
21
+ _disable: [],
22
+ allowInput: false,
23
+ allowInvalidPreload: false,
24
+ altFormat: "F j, Y",
25
+ altInput: false,
26
+ altInputClass: "form-control input",
27
+ animate: typeof window === "object" &&
28
+ window.navigator.userAgent.indexOf("MSIE") === -1,
29
+ ariaDateFormat: "F j, Y",
30
+ autoFillDefaultTime: true,
31
+ clickOpens: true,
32
+ closeOnSelect: true,
33
+ conjunction: ", ",
34
+ dateFormat: "Y-m-d",
35
+ defaultHour: 12,
36
+ defaultMinute: 0,
37
+ defaultSeconds: 0,
38
+ disable: [],
39
+ disableMobile: false,
40
+ enableSeconds: false,
41
+ enableTime: false,
42
+ errorHandler: function (err) {
43
+ return typeof console !== "undefined" && console.warn(err);
44
+ },
45
+ getWeek: function (givenDate) {
46
+ var date = new Date(givenDate.getTime());
47
+ date.setHours(0, 0, 0, 0);
48
+ date.setDate(date.getDate() + 3 - ((date.getDay() + 6) % 7));
49
+ var week1 = new Date(date.getFullYear(), 0, 4);
50
+ return (1 +
51
+ Math.round(((date.getTime() - week1.getTime()) / 86400000 -
52
+ 3 +
53
+ ((week1.getDay() + 6) % 7)) /
54
+ 7));
55
+ },
56
+ hourIncrement: 1,
57
+ ignoredFocusElements: [],
58
+ inline: false,
59
+ locale: "default",
60
+ minuteIncrement: 5,
61
+ mode: "single",
62
+ monthSelectorType: "dropdown",
63
+ nextArrow: "<svg version='1.1' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' viewBox='0 0 17 17'><g></g><path d='M13.207 8.472l-7.854 7.854-0.707-0.707 7.146-7.146-7.146-7.148 0.707-0.707 7.854 7.854z' /></svg>",
64
+ noCalendar: false,
65
+ now: new Date(),
66
+ onChange: [],
67
+ onClose: [],
68
+ onDayCreate: [],
69
+ onDestroy: [],
70
+ onKeyDown: [],
71
+ onMonthChange: [],
72
+ onOpen: [],
73
+ onParseConfig: [],
74
+ onReady: [],
75
+ onValueUpdate: [],
76
+ onYearChange: [],
77
+ onPreCalendarPosition: [],
78
+ plugins: [],
79
+ position: "auto",
80
+ positionElement: undefined,
81
+ prevArrow: "<svg version='1.1' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' viewBox='0 0 17 17'><g></g><path d='M5.207 8.471l7.146 7.147-0.707 0.707-7.853-7.854 7.854-7.853 0.707 0.707-7.147 7.146z' /></svg>",
82
+ shorthandCurrentMonth: false,
83
+ showMonths: 1,
84
+ static: false,
85
+ time_24hr: false,
86
+ weekNumbers: false,
87
+ wrap: false,
88
+ };
89
+
90
+ var english = {
91
+ weekdays: {
92
+ shorthand: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"],
93
+ longhand: [
94
+ "Sunday",
95
+ "Monday",
96
+ "Tuesday",
97
+ "Wednesday",
98
+ "Thursday",
99
+ "Friday",
100
+ "Saturday",
101
+ ],
102
+ },
103
+ months: {
104
+ shorthand: [
105
+ "Jan",
106
+ "Feb",
107
+ "Mar",
108
+ "Apr",
109
+ "May",
110
+ "Jun",
111
+ "Jul",
112
+ "Aug",
113
+ "Sep",
114
+ "Oct",
115
+ "Nov",
116
+ "Dec",
117
+ ],
118
+ longhand: [
119
+ "January",
120
+ "February",
121
+ "March",
122
+ "April",
123
+ "May",
124
+ "June",
125
+ "July",
126
+ "August",
127
+ "September",
128
+ "October",
129
+ "November",
130
+ "December",
131
+ ],
132
+ },
133
+ daysInMonth: [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31],
134
+ firstDayOfWeek: 0,
135
+ ordinal: function (nth) {
136
+ var s = nth % 100;
137
+ if (s > 3 && s < 21)
138
+ return "th";
139
+ switch (s % 10) {
140
+ case 1:
141
+ return "st";
142
+ case 2:
143
+ return "nd";
144
+ case 3:
145
+ return "rd";
146
+ default:
147
+ return "th";
148
+ }
149
+ },
150
+ rangeSeparator: " to ",
151
+ weekAbbreviation: "Wk",
152
+ scrollTitle: "Scroll to increment",
153
+ toggleTitle: "Click to toggle",
154
+ amPM: ["AM", "PM"],
155
+ yearAriaLabel: "Year",
156
+ monthAriaLabel: "Month",
157
+ hourAriaLabel: "Hour",
158
+ minuteAriaLabel: "Minute",
159
+ time_24hr: false,
160
+ };
161
+
162
+ var pad = function (number, length) {
163
+ if (length === void 0) { length = 2; }
164
+ return ("000" + number).slice(length * -1);
165
+ };
166
+ var int = function (bool) { return (bool === true ? 1 : 0); };
167
+ function debounce(fn, wait) {
168
+ var t;
169
+ return function () {
170
+ var _this = this;
171
+ var args = arguments;
172
+ clearTimeout(t);
173
+ t = setTimeout(function () { return fn.apply(_this, args); }, wait);
174
+ };
175
+ }
176
+ var arrayify = function (obj) {
177
+ return obj instanceof Array ? obj : [obj];
178
+ };
179
+
180
+ function toggleClass(elem, className, bool) {
181
+ if (bool === true)
182
+ return elem.classList.add(className);
183
+ elem.classList.remove(className);
184
+ }
185
+ function createElement(tag, className, content) {
186
+ var e = window.document.createElement(tag);
187
+ className = className || "";
188
+ content = content || "";
189
+ e.className = className;
190
+ if (content !== undefined)
191
+ e.textContent = content;
192
+ return e;
193
+ }
194
+ function clearNode(node) {
195
+ while (node.firstChild)
196
+ node.removeChild(node.firstChild);
197
+ }
198
+ function findParent(node, condition) {
199
+ if (condition(node))
200
+ return node;
201
+ else if (node.parentNode)
202
+ return findParent(node.parentNode, condition);
203
+ return undefined;
204
+ }
205
+ function createNumberInput(inputClassName, opts) {
206
+ var wrapper = createElement("div", "numInputWrapper"), numInput = createElement("input", "numInput " + inputClassName), arrowUp = createElement("span", "arrowUp"), arrowDown = createElement("span", "arrowDown");
207
+ if (navigator.userAgent.indexOf("MSIE 9.0") === -1) {
208
+ numInput.type = "number";
209
+ }
210
+ else {
211
+ numInput.type = "text";
212
+ numInput.pattern = "\\d*";
213
+ }
214
+ if (opts !== undefined)
215
+ for (var key in opts)
216
+ numInput.setAttribute(key, opts[key]);
217
+ wrapper.appendChild(numInput);
218
+ wrapper.appendChild(arrowUp);
219
+ wrapper.appendChild(arrowDown);
220
+ return wrapper;
221
+ }
222
+ function getEventTarget(event) {
223
+ try {
224
+ if (typeof event.composedPath === "function") {
225
+ var path = event.composedPath();
226
+ return path[0];
227
+ }
228
+ return event.target;
229
+ }
230
+ catch (error) {
231
+ return event.target;
232
+ }
233
+ }
234
+
235
+ var doNothing = function () { return undefined; };
236
+ var monthToStr = function (monthNumber, shorthand, locale) { return locale.months[shorthand ? "shorthand" : "longhand"][monthNumber]; };
237
+ var revFormat = {
238
+ D: doNothing,
239
+ F: function (dateObj, monthName, locale) {
240
+ dateObj.setMonth(locale.months.longhand.indexOf(monthName));
241
+ },
242
+ G: function (dateObj, hour) {
243
+ dateObj.setHours((dateObj.getHours() >= 12 ? 12 : 0) + parseFloat(hour));
244
+ },
245
+ H: function (dateObj, hour) {
246
+ dateObj.setHours(parseFloat(hour));
247
+ },
248
+ J: function (dateObj, day) {
249
+ dateObj.setDate(parseFloat(day));
250
+ },
251
+ K: function (dateObj, amPM, locale) {
252
+ dateObj.setHours((dateObj.getHours() % 12) +
253
+ 12 * int(new RegExp(locale.amPM[1], "i").test(amPM)));
254
+ },
255
+ M: function (dateObj, shortMonth, locale) {
256
+ dateObj.setMonth(locale.months.shorthand.indexOf(shortMonth));
257
+ },
258
+ S: function (dateObj, seconds) {
259
+ dateObj.setSeconds(parseFloat(seconds));
260
+ },
261
+ U: function (_, unixSeconds) { return new Date(parseFloat(unixSeconds) * 1000); },
262
+ W: function (dateObj, weekNum, locale) {
263
+ var weekNumber = parseInt(weekNum);
264
+ var date = new Date(dateObj.getFullYear(), 0, 2 + (weekNumber - 1) * 7, 0, 0, 0, 0);
265
+ date.setDate(date.getDate() - date.getDay() + locale.firstDayOfWeek);
266
+ return date;
267
+ },
268
+ Y: function (dateObj, year) {
269
+ dateObj.setFullYear(parseFloat(year));
270
+ },
271
+ Z: function (_, ISODate) { return new Date(ISODate); },
272
+ d: function (dateObj, day) {
273
+ dateObj.setDate(parseFloat(day));
274
+ },
275
+ h: function (dateObj, hour) {
276
+ dateObj.setHours((dateObj.getHours() >= 12 ? 12 : 0) + parseFloat(hour));
277
+ },
278
+ i: function (dateObj, minutes) {
279
+ dateObj.setMinutes(parseFloat(minutes));
280
+ },
281
+ j: function (dateObj, day) {
282
+ dateObj.setDate(parseFloat(day));
283
+ },
284
+ l: doNothing,
285
+ m: function (dateObj, month) {
286
+ dateObj.setMonth(parseFloat(month) - 1);
287
+ },
288
+ n: function (dateObj, month) {
289
+ dateObj.setMonth(parseFloat(month) - 1);
290
+ },
291
+ s: function (dateObj, seconds) {
292
+ dateObj.setSeconds(parseFloat(seconds));
293
+ },
294
+ u: function (_, unixMillSeconds) {
295
+ return new Date(parseFloat(unixMillSeconds));
296
+ },
297
+ w: doNothing,
298
+ y: function (dateObj, year) {
299
+ dateObj.setFullYear(2000 + parseFloat(year));
300
+ },
301
+ };
302
+ var tokenRegex = {
303
+ D: "",
304
+ F: "",
305
+ G: "(\\d\\d|\\d)",
306
+ H: "(\\d\\d|\\d)",
307
+ J: "(\\d\\d|\\d)\\w+",
308
+ K: "",
309
+ M: "",
310
+ S: "(\\d\\d|\\d)",
311
+ U: "(.+)",
312
+ W: "(\\d\\d|\\d)",
313
+ Y: "(\\d{4})",
314
+ Z: "(.+)",
315
+ d: "(\\d\\d|\\d)",
316
+ h: "(\\d\\d|\\d)",
317
+ i: "(\\d\\d|\\d)",
318
+ j: "(\\d\\d|\\d)",
319
+ l: "",
320
+ m: "(\\d\\d|\\d)",
321
+ n: "(\\d\\d|\\d)",
322
+ s: "(\\d\\d|\\d)",
323
+ u: "(.+)",
324
+ w: "(\\d\\d|\\d)",
325
+ y: "(\\d{2})",
326
+ };
327
+ var formats = {
328
+ Z: function (date) { return date.toISOString(); },
329
+ D: function (date, locale, options) {
330
+ return locale.weekdays.shorthand[formats.w(date, locale, options)];
331
+ },
332
+ F: function (date, locale, options) {
333
+ return monthToStr(formats.n(date, locale, options) - 1, false, locale);
334
+ },
335
+ G: function (date, locale, options) {
336
+ return pad(formats.h(date, locale, options));
337
+ },
338
+ H: function (date) { return pad(date.getHours()); },
339
+ J: function (date, locale) {
340
+ return locale.ordinal !== undefined
341
+ ? date.getDate() + locale.ordinal(date.getDate())
342
+ : date.getDate();
343
+ },
344
+ K: function (date, locale) { return locale.amPM[int(date.getHours() > 11)]; },
345
+ M: function (date, locale) {
346
+ return monthToStr(date.getMonth(), true, locale);
347
+ },
348
+ S: function (date) { return pad(date.getSeconds()); },
349
+ U: function (date) { return date.getTime() / 1000; },
350
+ W: function (date, _, options) {
351
+ return options.getWeek(date);
352
+ },
353
+ Y: function (date) { return pad(date.getFullYear(), 4); },
354
+ d: function (date) { return pad(date.getDate()); },
355
+ h: function (date) { return (date.getHours() % 12 ? date.getHours() % 12 : 12); },
356
+ i: function (date) { return pad(date.getMinutes()); },
357
+ j: function (date) { return date.getDate(); },
358
+ l: function (date, locale) {
359
+ return locale.weekdays.longhand[date.getDay()];
360
+ },
361
+ m: function (date) { return pad(date.getMonth() + 1); },
362
+ n: function (date) { return date.getMonth() + 1; },
363
+ s: function (date) { return date.getSeconds(); },
364
+ u: function (date) { return date.getTime(); },
365
+ w: function (date) { return date.getDay(); },
366
+ y: function (date) { return String(date.getFullYear()).substring(2); },
367
+ };
368
+
369
+ var createDateFormatter = function (_a) {
370
+ var _b = _a.config, config = _b === void 0 ? defaults : _b, _c = _a.l10n, l10n = _c === void 0 ? english : _c, _d = _a.isMobile, isMobile = _d === void 0 ? false : _d;
371
+ return function (dateObj, frmt, overrideLocale) {
372
+ var locale = overrideLocale || l10n;
373
+ if (config.formatDate !== undefined && !isMobile) {
374
+ return config.formatDate(dateObj, frmt, locale);
375
+ }
376
+ return frmt
377
+ .split("")
378
+ .map(function (c, i, arr) {
379
+ return formats[c] && arr[i - 1] !== "\\"
380
+ ? formats[c](dateObj, locale, config)
381
+ : c !== "\\"
382
+ ? c
383
+ : "";
384
+ })
385
+ .join("");
386
+ };
387
+ };
388
+ var createDateParser = function (_a) {
389
+ var _b = _a.config, config = _b === void 0 ? defaults : _b, _c = _a.l10n, l10n = _c === void 0 ? english : _c;
390
+ return function (date, givenFormat, timeless, customLocale) {
391
+ if (date !== 0 && !date)
392
+ return undefined;
393
+ var locale = customLocale || l10n;
394
+ var parsedDate;
395
+ var dateOrig = date;
396
+ if (date instanceof Date)
397
+ parsedDate = new Date(date.getTime());
398
+ else if (typeof date !== "string" &&
399
+ date.toFixed !== undefined)
400
+ parsedDate = new Date(date);
401
+ else if (typeof date === "string") {
402
+ var format = givenFormat || (config || defaults).dateFormat;
403
+ var datestr = String(date).trim();
404
+ if (datestr === "today") {
405
+ parsedDate = new Date();
406
+ timeless = true;
407
+ }
408
+ else if (config && config.parseDate) {
409
+ parsedDate = config.parseDate(date, format);
410
+ }
411
+ else if (/Z$/.test(datestr) ||
412
+ /GMT$/.test(datestr)) {
413
+ parsedDate = new Date(date);
414
+ }
415
+ else {
416
+ var matched = void 0, ops = [];
417
+ for (var i = 0, matchIndex = 0, regexStr = ""; i < format.length; i++) {
418
+ var token = format[i];
419
+ var isBackSlash = token === "\\";
420
+ var escaped = format[i - 1] === "\\" || isBackSlash;
421
+ if (tokenRegex[token] && !escaped) {
422
+ regexStr += tokenRegex[token];
423
+ var match = new RegExp(regexStr).exec(date);
424
+ if (match && (matched = true)) {
425
+ ops[token !== "Y" ? "push" : "unshift"]({
426
+ fn: revFormat[token],
427
+ val: match[++matchIndex],
428
+ });
429
+ }
430
+ }
431
+ else if (!isBackSlash)
432
+ regexStr += ".";
433
+ }
434
+ parsedDate =
435
+ !config || !config.noCalendar
436
+ ? new Date(new Date().getFullYear(), 0, 1, 0, 0, 0, 0)
437
+ : new Date(new Date().setHours(0, 0, 0, 0));
438
+ ops.forEach(function (_a) {
439
+ var fn = _a.fn, val = _a.val;
440
+ return (parsedDate = fn(parsedDate, val, locale) || parsedDate);
441
+ });
442
+ parsedDate = matched ? parsedDate : undefined;
443
+ }
444
+ }
445
+ if (!(parsedDate instanceof Date && !isNaN(parsedDate.getTime()))) {
446
+ config.errorHandler(new Error("Invalid date provided: " + dateOrig));
447
+ return undefined;
448
+ }
449
+ if (timeless === true)
450
+ parsedDate.setHours(0, 0, 0, 0);
451
+ return parsedDate;
452
+ };
453
+ };
454
+ function compareDates(date1, date2, timeless) {
455
+ if (timeless === void 0) { timeless = true; }
456
+ if (timeless !== false) {
457
+ return (new Date(date1.getTime()).setHours(0, 0, 0, 0) -
458
+ new Date(date2.getTime()).setHours(0, 0, 0, 0));
459
+ }
460
+ return date1.getTime() - date2.getTime();
461
+ }
462
+ var isBetween = function (ts, ts1, ts2) {
463
+ return ts > Math.min(ts1, ts2) && ts < Math.max(ts1, ts2);
464
+ };
465
+ var calculateSecondsSinceMidnight = function (hours, minutes, seconds) {
466
+ return hours * 3600 + minutes * 60 + seconds;
467
+ };
468
+ var parseSeconds = function (secondsSinceMidnight) {
469
+ var hours = Math.floor(secondsSinceMidnight / 3600), minutes = (secondsSinceMidnight - hours * 3600) / 60;
470
+ return [hours, minutes, secondsSinceMidnight - hours * 3600 - minutes * 60];
471
+ };
472
+ var duration = {
473
+ DAY: 86400000,
474
+ };
475
+ function getDefaultHours(config) {
476
+ var hours = config.defaultHour;
477
+ var minutes = config.defaultMinute;
478
+ var seconds = config.defaultSeconds;
479
+ if (config.minDate !== undefined) {
480
+ var minHour = config.minDate.getHours();
481
+ var minMinutes = config.minDate.getMinutes();
482
+ var minSeconds = config.minDate.getSeconds();
483
+ if (hours < minHour) {
484
+ hours = minHour;
485
+ }
486
+ if (hours === minHour && minutes < minMinutes) {
487
+ minutes = minMinutes;
488
+ }
489
+ if (hours === minHour && minutes === minMinutes && seconds < minSeconds)
490
+ seconds = config.minDate.getSeconds();
491
+ }
492
+ if (config.maxDate !== undefined) {
493
+ var maxHr = config.maxDate.getHours();
494
+ var maxMinutes = config.maxDate.getMinutes();
495
+ hours = Math.min(hours, maxHr);
496
+ if (hours === maxHr)
497
+ minutes = Math.min(maxMinutes, minutes);
498
+ if (hours === maxHr && minutes === maxMinutes)
499
+ seconds = config.maxDate.getSeconds();
500
+ }
501
+ return { hours: hours, minutes: minutes, seconds: seconds };
502
+ }
503
+
504
+ if (typeof Object.assign !== "function") {
505
+ Object.assign = function (target) {
506
+ var args = [];
507
+ for (var _i = 1; _i < arguments.length; _i++) {
508
+ args[_i - 1] = arguments[_i];
509
+ }
510
+ if (!target) {
511
+ throw TypeError("Cannot convert undefined or null to object");
512
+ }
513
+ var _loop_1 = function (source) {
514
+ if (source) {
515
+ Object.keys(source).forEach(function (key) { return (target[key] = source[key]); });
516
+ }
517
+ };
518
+ for (var _a = 0, args_1 = args; _a < args_1.length; _a++) {
519
+ var source = args_1[_a];
520
+ _loop_1(source);
521
+ }
522
+ return target;
523
+ };
524
+ }
525
+
526
+ var __assign = (undefined && undefined.__assign) || function () {
527
+ __assign = Object.assign || function(t) {
528
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
529
+ s = arguments[i];
530
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
531
+ t[p] = s[p];
532
+ }
533
+ return t;
534
+ };
535
+ return __assign.apply(this, arguments);
536
+ };
537
+ var __spreadArrays = (undefined && undefined.__spreadArrays) || function () {
538
+ for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
539
+ for (var r = Array(s), k = 0, i = 0; i < il; i++)
540
+ for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
541
+ r[k] = a[j];
542
+ return r;
543
+ };
544
+ var DEBOUNCED_CHANGE_MS = 300;
545
+ function FlatpickrInstance(element, instanceConfig) {
546
+ var self = {
547
+ config: __assign(__assign({}, defaults), flatpickr.defaultConfig),
548
+ l10n: english,
549
+ };
550
+ self.parseDate = createDateParser({ config: self.config, l10n: self.l10n });
551
+ self._handlers = [];
552
+ self.pluginElements = [];
553
+ self.loadedPlugins = [];
554
+ self._bind = bind;
555
+ self._setHoursFromDate = setHoursFromDate;
556
+ self._positionCalendar = positionCalendar;
557
+ self.changeMonth = changeMonth;
558
+ self.changeYear = changeYear;
559
+ self.clear = clear;
560
+ self.close = close;
561
+ self.onMouseOver = onMouseOver;
562
+ self._createElement = createElement;
563
+ self.createDay = createDay;
564
+ self.destroy = destroy;
565
+ self.isEnabled = isEnabled;
566
+ self.jumpToDate = jumpToDate;
567
+ self.updateValue = updateValue;
568
+ self.open = open;
569
+ self.redraw = redraw;
570
+ self.set = set;
571
+ self.setDate = setDate;
572
+ self.toggle = toggle;
573
+ function setupHelperFunctions() {
574
+ self.utils = {
575
+ getDaysInMonth: function (month, yr) {
576
+ if (month === void 0) { month = self.currentMonth; }
577
+ if (yr === void 0) { yr = self.currentYear; }
578
+ if (month === 1 && ((yr % 4 === 0 && yr % 100 !== 0) || yr % 400 === 0))
579
+ return 29;
580
+ return self.l10n.daysInMonth[month];
581
+ },
582
+ };
583
+ }
584
+ function init() {
585
+ self.element = self.input = element;
586
+ self.isOpen = false;
587
+ parseConfig();
588
+ setupLocale();
589
+ setupInputs();
590
+ setupDates();
591
+ setupHelperFunctions();
592
+ if (!self.isMobile)
593
+ build();
594
+ bindEvents();
595
+ if (self.selectedDates.length || self.config.noCalendar) {
596
+ if (self.config.enableTime) {
597
+ setHoursFromDate(self.config.noCalendar ? self.latestSelectedDateObj : undefined);
598
+ }
599
+ updateValue(false);
600
+ }
601
+ setCalendarWidth();
602
+ var isSafari = /^((?!chrome|android).)*safari/i.test(navigator.userAgent);
603
+ if (!self.isMobile && isSafari) {
604
+ positionCalendar();
605
+ }
606
+ triggerEvent("onReady");
607
+ }
608
+ function getClosestActiveElement() {
609
+ var _a;
610
+ return (((_a = self.calendarContainer) === null || _a === void 0 ? void 0 : _a.getRootNode())
611
+ .activeElement || document.activeElement);
612
+ }
613
+ function bindToInstance(fn) {
614
+ return fn.bind(self);
615
+ }
616
+ function setCalendarWidth() {
617
+ var config = self.config;
618
+ if (config.weekNumbers === false && config.showMonths === 1) {
619
+ return;
620
+ }
621
+ else if (config.noCalendar !== true) {
622
+ window.requestAnimationFrame(function () {
623
+ if (self.calendarContainer !== undefined) {
624
+ self.calendarContainer.style.visibility = "hidden";
625
+ self.calendarContainer.style.display = "block";
626
+ }
627
+ if (self.daysContainer !== undefined) {
628
+ var daysWidth = (self.days.offsetWidth + 1) * config.showMonths;
629
+ self.daysContainer.style.width = daysWidth + "px";
630
+ self.calendarContainer.style.width =
631
+ daysWidth +
632
+ (self.weekWrapper !== undefined
633
+ ? self.weekWrapper.offsetWidth
634
+ : 0) +
635
+ "px";
636
+ self.calendarContainer.style.removeProperty("visibility");
637
+ self.calendarContainer.style.removeProperty("display");
638
+ }
639
+ });
640
+ }
641
+ }
642
+ function updateTime(e) {
643
+ if (self.selectedDates.length === 0) {
644
+ var defaultDate = self.config.minDate === undefined ||
645
+ compareDates(new Date(), self.config.minDate) >= 0
646
+ ? new Date()
647
+ : new Date(self.config.minDate.getTime());
648
+ var defaults = getDefaultHours(self.config);
649
+ defaultDate.setHours(defaults.hours, defaults.minutes, defaults.seconds, defaultDate.getMilliseconds());
650
+ self.selectedDates = [defaultDate];
651
+ self.latestSelectedDateObj = defaultDate;
652
+ }
653
+ if (e !== undefined && e.type !== "blur") {
654
+ timeWrapper(e);
655
+ }
656
+ var prevValue = self._input.value;
657
+ setHoursFromInputs();
658
+ updateValue();
659
+ if (self._input.value !== prevValue) {
660
+ self._debouncedChange();
661
+ }
662
+ }
663
+ function ampm2military(hour, amPM) {
664
+ return (hour % 12) + 12 * int(amPM === self.l10n.amPM[1]);
665
+ }
666
+ function military2ampm(hour) {
667
+ switch (hour % 24) {
668
+ case 0:
669
+ case 12:
670
+ return 12;
671
+ default:
672
+ return hour % 12;
673
+ }
674
+ }
675
+ function setHoursFromInputs() {
676
+ if (self.hourElement === undefined || self.minuteElement === undefined)
677
+ return;
678
+ var hours = (parseInt(self.hourElement.value.slice(-2), 10) || 0) % 24, minutes = (parseInt(self.minuteElement.value, 10) || 0) % 60, seconds = self.secondElement !== undefined
679
+ ? (parseInt(self.secondElement.value, 10) || 0) % 60
680
+ : 0;
681
+ if (self.amPM !== undefined) {
682
+ hours = ampm2military(hours, self.amPM.textContent);
683
+ }
684
+ var limitMinHours = self.config.minTime !== undefined ||
685
+ (self.config.minDate &&
686
+ self.minDateHasTime &&
687
+ self.latestSelectedDateObj &&
688
+ compareDates(self.latestSelectedDateObj, self.config.minDate, true) ===
689
+ 0);
690
+ var limitMaxHours = self.config.maxTime !== undefined ||
691
+ (self.config.maxDate &&
692
+ self.maxDateHasTime &&
693
+ self.latestSelectedDateObj &&
694
+ compareDates(self.latestSelectedDateObj, self.config.maxDate, true) ===
695
+ 0);
696
+ if (self.config.maxTime !== undefined &&
697
+ self.config.minTime !== undefined &&
698
+ self.config.minTime > self.config.maxTime) {
699
+ var minBound = calculateSecondsSinceMidnight(self.config.minTime.getHours(), self.config.minTime.getMinutes(), self.config.minTime.getSeconds());
700
+ var maxBound = calculateSecondsSinceMidnight(self.config.maxTime.getHours(), self.config.maxTime.getMinutes(), self.config.maxTime.getSeconds());
701
+ var currentTime = calculateSecondsSinceMidnight(hours, minutes, seconds);
702
+ if (currentTime > maxBound && currentTime < minBound) {
703
+ var result = parseSeconds(minBound);
704
+ hours = result[0];
705
+ minutes = result[1];
706
+ seconds = result[2];
707
+ }
708
+ }
709
+ else {
710
+ if (limitMaxHours) {
711
+ var maxTime = self.config.maxTime !== undefined
712
+ ? self.config.maxTime
713
+ : self.config.maxDate;
714
+ hours = Math.min(hours, maxTime.getHours());
715
+ if (hours === maxTime.getHours())
716
+ minutes = Math.min(minutes, maxTime.getMinutes());
717
+ if (minutes === maxTime.getMinutes())
718
+ seconds = Math.min(seconds, maxTime.getSeconds());
719
+ }
720
+ if (limitMinHours) {
721
+ var minTime = self.config.minTime !== undefined
722
+ ? self.config.minTime
723
+ : self.config.minDate;
724
+ hours = Math.max(hours, minTime.getHours());
725
+ if (hours === minTime.getHours() && minutes < minTime.getMinutes())
726
+ minutes = minTime.getMinutes();
727
+ if (minutes === minTime.getMinutes())
728
+ seconds = Math.max(seconds, minTime.getSeconds());
729
+ }
730
+ }
731
+ setHours(hours, minutes, seconds);
732
+ }
733
+ function setHoursFromDate(dateObj) {
734
+ var date = dateObj || self.latestSelectedDateObj;
735
+ if (date && date instanceof Date) {
736
+ setHours(date.getHours(), date.getMinutes(), date.getSeconds());
737
+ }
738
+ }
739
+ function setHours(hours, minutes, seconds) {
740
+ if (self.latestSelectedDateObj !== undefined) {
741
+ self.latestSelectedDateObj.setHours(hours % 24, minutes, seconds || 0, 0);
742
+ }
743
+ if (!self.hourElement || !self.minuteElement || self.isMobile)
744
+ return;
745
+ self.hourElement.value = pad(!self.config.time_24hr
746
+ ? ((12 + hours) % 12) + 12 * int(hours % 12 === 0)
747
+ : hours);
748
+ self.minuteElement.value = pad(minutes);
749
+ if (self.amPM !== undefined)
750
+ self.amPM.textContent = self.l10n.amPM[int(hours >= 12)];
751
+ if (self.secondElement !== undefined)
752
+ self.secondElement.value = pad(seconds);
753
+ }
754
+ function onYearInput(event) {
755
+ var eventTarget = getEventTarget(event);
756
+ var year = parseInt(eventTarget.value) + (event.delta || 0);
757
+ if (year / 1000 > 1 ||
758
+ (event.key === "Enter" && !/[^\d]/.test(year.toString()))) {
759
+ changeYear(year);
760
+ }
761
+ }
762
+ function bind(element, event, handler, options) {
763
+ if (event instanceof Array)
764
+ return event.forEach(function (ev) { return bind(element, ev, handler, options); });
765
+ if (element instanceof Array)
766
+ return element.forEach(function (el) { return bind(el, event, handler, options); });
767
+ element.addEventListener(event, handler, options);
768
+ self._handlers.push({
769
+ remove: function () { return element.removeEventListener(event, handler, options); },
770
+ });
771
+ }
772
+ function triggerChange() {
773
+ triggerEvent("onChange");
774
+ }
775
+ function bindEvents() {
776
+ if (self.config.wrap) {
777
+ ["open", "close", "toggle", "clear"].forEach(function (evt) {
778
+ Array.prototype.forEach.call(self.element.querySelectorAll("[data-" + evt + "]"), function (el) {
779
+ return bind(el, "click", self[evt]);
780
+ });
781
+ });
782
+ }
783
+ if (self.isMobile) {
784
+ setupMobile();
785
+ return;
786
+ }
787
+ var debouncedResize = debounce(onResize, 50);
788
+ self._debouncedChange = debounce(triggerChange, DEBOUNCED_CHANGE_MS);
789
+ if (self.daysContainer && !/iPhone|iPad|iPod/i.test(navigator.userAgent))
790
+ bind(self.daysContainer, "mouseover", function (e) {
791
+ if (self.config.mode === "range")
792
+ onMouseOver(getEventTarget(e));
793
+ });
794
+ bind(self._input, "keydown", onKeyDown);
795
+ if (self.calendarContainer !== undefined) {
796
+ bind(self.calendarContainer, "keydown", onKeyDown);
797
+ }
798
+ if (!self.config.inline && !self.config.static)
799
+ bind(window, "resize", debouncedResize);
800
+ if (window.ontouchstart !== undefined)
801
+ bind(window.document, "touchstart", documentClick);
802
+ else
803
+ bind(window.document, "mousedown", documentClick);
804
+ bind(window.document, "focus", documentClick, { capture: true });
805
+ if (self.config.clickOpens === true) {
806
+ bind(self._input, "focus", self.open);
807
+ bind(self._input, "click", self.open);
808
+ }
809
+ if (self.daysContainer !== undefined) {
810
+ bind(self.monthNav, "click", onMonthNavClick);
811
+ bind(self.monthNav, ["keyup", "increment"], onYearInput);
812
+ bind(self.daysContainer, "click", selectDate);
813
+ }
814
+ if (self.timeContainer !== undefined &&
815
+ self.minuteElement !== undefined &&
816
+ self.hourElement !== undefined) {
817
+ var selText = function (e) {
818
+ return getEventTarget(e).select();
819
+ };
820
+ bind(self.timeContainer, ["increment"], updateTime);
821
+ bind(self.timeContainer, "blur", updateTime, { capture: true });
822
+ bind(self.timeContainer, "click", timeIncrement);
823
+ bind([self.hourElement, self.minuteElement], ["focus", "click"], selText);
824
+ if (self.secondElement !== undefined)
825
+ bind(self.secondElement, "focus", function () { return self.secondElement && self.secondElement.select(); });
826
+ if (self.amPM !== undefined) {
827
+ bind(self.amPM, "click", function (e) {
828
+ updateTime(e);
829
+ });
830
+ }
831
+ }
832
+ if (self.config.allowInput) {
833
+ bind(self._input, "blur", onBlur);
834
+ }
835
+ }
836
+ function jumpToDate(jumpDate, triggerChange) {
837
+ var jumpTo = jumpDate !== undefined
838
+ ? self.parseDate(jumpDate)
839
+ : self.latestSelectedDateObj ||
840
+ (self.config.minDate && self.config.minDate > self.now
841
+ ? self.config.minDate
842
+ : self.config.maxDate && self.config.maxDate < self.now
843
+ ? self.config.maxDate
844
+ : self.now);
845
+ var oldYear = self.currentYear;
846
+ var oldMonth = self.currentMonth;
847
+ try {
848
+ if (jumpTo !== undefined) {
849
+ self.currentYear = jumpTo.getFullYear();
850
+ self.currentMonth = jumpTo.getMonth();
851
+ }
852
+ }
853
+ catch (e) {
854
+ e.message = "Invalid date supplied: " + jumpTo;
855
+ self.config.errorHandler(e);
856
+ }
857
+ if (triggerChange && self.currentYear !== oldYear) {
858
+ triggerEvent("onYearChange");
859
+ buildMonthSwitch();
860
+ }
861
+ if (triggerChange &&
862
+ (self.currentYear !== oldYear || self.currentMonth !== oldMonth)) {
863
+ triggerEvent("onMonthChange");
864
+ }
865
+ self.redraw();
866
+ }
867
+ function timeIncrement(e) {
868
+ var eventTarget = getEventTarget(e);
869
+ if (~eventTarget.className.indexOf("arrow"))
870
+ incrementNumInput(e, eventTarget.classList.contains("arrowUp") ? 1 : -1);
871
+ }
872
+ function incrementNumInput(e, delta, inputElem) {
873
+ var target = e && getEventTarget(e);
874
+ var input = inputElem ||
875
+ (target && target.parentNode && target.parentNode.firstChild);
876
+ var event = createEvent("increment");
877
+ event.delta = delta;
878
+ input && input.dispatchEvent(event);
879
+ }
880
+ function build() {
881
+ var fragment = window.document.createDocumentFragment();
882
+ self.calendarContainer = createElement("div", "flatpickr-calendar");
883
+ self.calendarContainer.tabIndex = -1;
884
+ if (!self.config.noCalendar) {
885
+ fragment.appendChild(buildMonthNav());
886
+ self.innerContainer = createElement("div", "flatpickr-innerContainer");
887
+ if (self.config.weekNumbers) {
888
+ var _a = buildWeeks(), weekWrapper = _a.weekWrapper, weekNumbers = _a.weekNumbers;
889
+ self.innerContainer.appendChild(weekWrapper);
890
+ self.weekNumbers = weekNumbers;
891
+ self.weekWrapper = weekWrapper;
892
+ }
893
+ self.rContainer = createElement("div", "flatpickr-rContainer");
894
+ self.rContainer.appendChild(buildWeekdays());
895
+ if (!self.daysContainer) {
896
+ self.daysContainer = createElement("div", "flatpickr-days");
897
+ self.daysContainer.tabIndex = -1;
898
+ }
899
+ buildDays();
900
+ self.rContainer.appendChild(self.daysContainer);
901
+ self.innerContainer.appendChild(self.rContainer);
902
+ fragment.appendChild(self.innerContainer);
903
+ }
904
+ if (self.config.enableTime) {
905
+ fragment.appendChild(buildTime());
906
+ }
907
+ toggleClass(self.calendarContainer, "rangeMode", self.config.mode === "range");
908
+ toggleClass(self.calendarContainer, "animate", self.config.animate === true);
909
+ toggleClass(self.calendarContainer, "multiMonth", self.config.showMonths > 1);
910
+ self.calendarContainer.appendChild(fragment);
911
+ var customAppend = self.config.appendTo !== undefined &&
912
+ self.config.appendTo.nodeType !== undefined;
913
+ if (self.config.inline || self.config.static) {
914
+ self.calendarContainer.classList.add(self.config.inline ? "inline" : "static");
915
+ if (self.config.inline) {
916
+ if (!customAppend && self.element.parentNode)
917
+ self.element.parentNode.insertBefore(self.calendarContainer, self._input.nextSibling);
918
+ else if (self.config.appendTo !== undefined)
919
+ self.config.appendTo.appendChild(self.calendarContainer);
920
+ }
921
+ if (self.config.static) {
922
+ var wrapper = createElement("div", "flatpickr-wrapper");
923
+ if (self.element.parentNode)
924
+ self.element.parentNode.insertBefore(wrapper, self.element);
925
+ wrapper.appendChild(self.element);
926
+ if (self.altInput)
927
+ wrapper.appendChild(self.altInput);
928
+ wrapper.appendChild(self.calendarContainer);
929
+ }
930
+ }
931
+ if (!self.config.static && !self.config.inline)
932
+ (self.config.appendTo !== undefined
933
+ ? self.config.appendTo
934
+ : window.document.body).appendChild(self.calendarContainer);
935
+ }
936
+ function createDay(className, date, _dayNumber, i) {
937
+ var dateIsEnabled = isEnabled(date, true), dayElement = createElement("span", className, date.getDate().toString());
938
+ dayElement.dateObj = date;
939
+ dayElement.$i = i;
940
+ dayElement.setAttribute("aria-label", self.formatDate(date, self.config.ariaDateFormat));
941
+ if (className.indexOf("hidden") === -1 &&
942
+ compareDates(date, self.now) === 0) {
943
+ self.todayDateElem = dayElement;
944
+ dayElement.classList.add("today");
945
+ dayElement.setAttribute("aria-current", "date");
946
+ }
947
+ if (dateIsEnabled) {
948
+ dayElement.tabIndex = -1;
949
+ if (isDateSelected(date)) {
950
+ dayElement.classList.add("selected");
951
+ self.selectedDateElem = dayElement;
952
+ if (self.config.mode === "range") {
953
+ toggleClass(dayElement, "startRange", self.selectedDates[0] &&
954
+ compareDates(date, self.selectedDates[0], true) === 0);
955
+ toggleClass(dayElement, "endRange", self.selectedDates[1] &&
956
+ compareDates(date, self.selectedDates[1], true) === 0);
957
+ if (className === "nextMonthDay")
958
+ dayElement.classList.add("inRange");
959
+ }
960
+ }
961
+ }
962
+ else {
963
+ dayElement.classList.add("flatpickr-disabled");
964
+ }
965
+ if (self.config.mode === "range") {
966
+ if (isDateInRange(date) && !isDateSelected(date))
967
+ dayElement.classList.add("inRange");
968
+ }
969
+ if (self.weekNumbers &&
970
+ self.config.showMonths === 1 &&
971
+ className !== "prevMonthDay" &&
972
+ i % 7 === 6) {
973
+ self.weekNumbers.insertAdjacentHTML("beforeend", "<span class='flatpickr-day'>" + self.config.getWeek(date) + "</span>");
974
+ }
975
+ triggerEvent("onDayCreate", dayElement);
976
+ return dayElement;
977
+ }
978
+ function focusOnDayElem(targetNode) {
979
+ targetNode.focus();
980
+ if (self.config.mode === "range")
981
+ onMouseOver(targetNode);
982
+ }
983
+ function getFirstAvailableDay(delta) {
984
+ var startMonth = delta > 0 ? 0 : self.config.showMonths - 1;
985
+ var endMonth = delta > 0 ? self.config.showMonths : -1;
986
+ for (var m = startMonth; m != endMonth; m += delta) {
987
+ var month = self.daysContainer.children[m];
988
+ var startIndex = delta > 0 ? 0 : month.children.length - 1;
989
+ var endIndex = delta > 0 ? month.children.length : -1;
990
+ for (var i = startIndex; i != endIndex; i += delta) {
991
+ var c = month.children[i];
992
+ if (c.className.indexOf("hidden") === -1 && isEnabled(c.dateObj))
993
+ return c;
994
+ }
995
+ }
996
+ return undefined;
997
+ }
998
+ function getNextAvailableDay(current, delta) {
999
+ var givenMonth = current.className.indexOf("Month") === -1
1000
+ ? current.dateObj.getMonth()
1001
+ : self.currentMonth;
1002
+ var endMonth = delta > 0 ? self.config.showMonths : -1;
1003
+ var loopDelta = delta > 0 ? 1 : -1;
1004
+ for (var m = givenMonth - self.currentMonth; m != endMonth; m += loopDelta) {
1005
+ var month = self.daysContainer.children[m];
1006
+ var startIndex = givenMonth - self.currentMonth === m
1007
+ ? current.$i + delta
1008
+ : delta < 0
1009
+ ? month.children.length - 1
1010
+ : 0;
1011
+ var numMonthDays = month.children.length;
1012
+ for (var i = startIndex; i >= 0 && i < numMonthDays && i != (delta > 0 ? numMonthDays : -1); i += loopDelta) {
1013
+ var c = month.children[i];
1014
+ if (c.className.indexOf("hidden") === -1 &&
1015
+ isEnabled(c.dateObj) &&
1016
+ Math.abs(current.$i - i) >= Math.abs(delta))
1017
+ return focusOnDayElem(c);
1018
+ }
1019
+ }
1020
+ self.changeMonth(loopDelta);
1021
+ focusOnDay(getFirstAvailableDay(loopDelta), 0);
1022
+ return undefined;
1023
+ }
1024
+ function focusOnDay(current, offset) {
1025
+ var activeElement = getClosestActiveElement();
1026
+ var dayFocused = isInView(activeElement || document.body);
1027
+ var startElem = current !== undefined
1028
+ ? current
1029
+ : dayFocused
1030
+ ? activeElement
1031
+ : self.selectedDateElem !== undefined && isInView(self.selectedDateElem)
1032
+ ? self.selectedDateElem
1033
+ : self.todayDateElem !== undefined && isInView(self.todayDateElem)
1034
+ ? self.todayDateElem
1035
+ : getFirstAvailableDay(offset > 0 ? 1 : -1);
1036
+ if (startElem === undefined) {
1037
+ self._input.focus();
1038
+ }
1039
+ else if (!dayFocused) {
1040
+ focusOnDayElem(startElem);
1041
+ }
1042
+ else {
1043
+ getNextAvailableDay(startElem, offset);
1044
+ }
1045
+ }
1046
+ function buildMonthDays(year, month) {
1047
+ var firstOfMonth = (new Date(year, month, 1).getDay() - self.l10n.firstDayOfWeek + 7) % 7;
1048
+ var prevMonthDays = self.utils.getDaysInMonth((month - 1 + 12) % 12, year);
1049
+ var daysInMonth = self.utils.getDaysInMonth(month, year), days = window.document.createDocumentFragment(), isMultiMonth = self.config.showMonths > 1, prevMonthDayClass = isMultiMonth ? "prevMonthDay hidden" : "prevMonthDay", nextMonthDayClass = isMultiMonth ? "nextMonthDay hidden" : "nextMonthDay";
1050
+ var dayNumber = prevMonthDays + 1 - firstOfMonth, dayIndex = 0;
1051
+ for (; dayNumber <= prevMonthDays; dayNumber++, dayIndex++) {
1052
+ days.appendChild(createDay("flatpickr-day " + prevMonthDayClass, new Date(year, month - 1, dayNumber), dayNumber, dayIndex));
1053
+ }
1054
+ for (dayNumber = 1; dayNumber <= daysInMonth; dayNumber++, dayIndex++) {
1055
+ days.appendChild(createDay("flatpickr-day", new Date(year, month, dayNumber), dayNumber, dayIndex));
1056
+ }
1057
+ for (var dayNum = daysInMonth + 1; dayNum <= 42 - firstOfMonth &&
1058
+ (self.config.showMonths === 1 || dayIndex % 7 !== 0); dayNum++, dayIndex++) {
1059
+ days.appendChild(createDay("flatpickr-day " + nextMonthDayClass, new Date(year, month + 1, dayNum % daysInMonth), dayNum, dayIndex));
1060
+ }
1061
+ var dayContainer = createElement("div", "dayContainer");
1062
+ dayContainer.appendChild(days);
1063
+ return dayContainer;
1064
+ }
1065
+ function buildDays() {
1066
+ if (self.daysContainer === undefined) {
1067
+ return;
1068
+ }
1069
+ clearNode(self.daysContainer);
1070
+ if (self.weekNumbers)
1071
+ clearNode(self.weekNumbers);
1072
+ var frag = document.createDocumentFragment();
1073
+ for (var i = 0; i < self.config.showMonths; i++) {
1074
+ var d = new Date(self.currentYear, self.currentMonth, 1);
1075
+ d.setMonth(self.currentMonth + i);
1076
+ frag.appendChild(buildMonthDays(d.getFullYear(), d.getMonth()));
1077
+ }
1078
+ self.daysContainer.appendChild(frag);
1079
+ self.days = self.daysContainer.firstChild;
1080
+ if (self.config.mode === "range" && self.selectedDates.length === 1) {
1081
+ onMouseOver();
1082
+ }
1083
+ }
1084
+ function buildMonthSwitch() {
1085
+ if (self.config.showMonths > 1 ||
1086
+ self.config.monthSelectorType !== "dropdown")
1087
+ return;
1088
+ var shouldBuildMonth = function (month) {
1089
+ if (self.config.minDate !== undefined &&
1090
+ self.currentYear === self.config.minDate.getFullYear() &&
1091
+ month < self.config.minDate.getMonth()) {
1092
+ return false;
1093
+ }
1094
+ return !(self.config.maxDate !== undefined &&
1095
+ self.currentYear === self.config.maxDate.getFullYear() &&
1096
+ month > self.config.maxDate.getMonth());
1097
+ };
1098
+ self.monthsDropdownContainer.tabIndex = -1;
1099
+ self.monthsDropdownContainer.innerHTML = "";
1100
+ for (var i = 0; i < 12; i++) {
1101
+ if (!shouldBuildMonth(i))
1102
+ continue;
1103
+ var month = createElement("option", "flatpickr-monthDropdown-month");
1104
+ month.value = new Date(self.currentYear, i).getMonth().toString();
1105
+ month.textContent = monthToStr(i, self.config.shorthandCurrentMonth, self.l10n);
1106
+ month.tabIndex = -1;
1107
+ if (self.currentMonth === i) {
1108
+ month.selected = true;
1109
+ }
1110
+ self.monthsDropdownContainer.appendChild(month);
1111
+ }
1112
+ }
1113
+ function buildMonth() {
1114
+ var container = createElement("div", "flatpickr-month");
1115
+ var monthNavFragment = window.document.createDocumentFragment();
1116
+ var monthElement;
1117
+ if (self.config.showMonths > 1 ||
1118
+ self.config.monthSelectorType === "static") {
1119
+ monthElement = createElement("span", "cur-month");
1120
+ }
1121
+ else {
1122
+ self.monthsDropdownContainer = createElement("select", "flatpickr-monthDropdown-months");
1123
+ self.monthsDropdownContainer.setAttribute("aria-label", self.l10n.monthAriaLabel);
1124
+ bind(self.monthsDropdownContainer, "change", function (e) {
1125
+ var target = getEventTarget(e);
1126
+ var selectedMonth = parseInt(target.value, 10);
1127
+ self.changeMonth(selectedMonth - self.currentMonth);
1128
+ triggerEvent("onMonthChange");
1129
+ });
1130
+ buildMonthSwitch();
1131
+ monthElement = self.monthsDropdownContainer;
1132
+ }
1133
+ var yearInput = createNumberInput("cur-year", { tabindex: "-1" });
1134
+ var yearElement = yearInput.getElementsByTagName("input")[0];
1135
+ yearElement.setAttribute("aria-label", self.l10n.yearAriaLabel);
1136
+ if (self.config.minDate) {
1137
+ yearElement.setAttribute("min", self.config.minDate.getFullYear().toString());
1138
+ }
1139
+ if (self.config.maxDate) {
1140
+ yearElement.setAttribute("max", self.config.maxDate.getFullYear().toString());
1141
+ yearElement.disabled =
1142
+ !!self.config.minDate &&
1143
+ self.config.minDate.getFullYear() === self.config.maxDate.getFullYear();
1144
+ }
1145
+ var currentMonth = createElement("div", "flatpickr-current-month");
1146
+ currentMonth.appendChild(monthElement);
1147
+ currentMonth.appendChild(yearInput);
1148
+ monthNavFragment.appendChild(currentMonth);
1149
+ container.appendChild(monthNavFragment);
1150
+ return {
1151
+ container: container,
1152
+ yearElement: yearElement,
1153
+ monthElement: monthElement,
1154
+ };
1155
+ }
1156
+ function buildMonths() {
1157
+ clearNode(self.monthNav);
1158
+ self.monthNav.appendChild(self.prevMonthNav);
1159
+ if (self.config.showMonths) {
1160
+ self.yearElements = [];
1161
+ self.monthElements = [];
1162
+ }
1163
+ for (var m = self.config.showMonths; m--;) {
1164
+ var month = buildMonth();
1165
+ self.yearElements.push(month.yearElement);
1166
+ self.monthElements.push(month.monthElement);
1167
+ self.monthNav.appendChild(month.container);
1168
+ }
1169
+ self.monthNav.appendChild(self.nextMonthNav);
1170
+ }
1171
+ function buildMonthNav() {
1172
+ self.monthNav = createElement("div", "flatpickr-months");
1173
+ self.yearElements = [];
1174
+ self.monthElements = [];
1175
+ self.prevMonthNav = createElement("span", "flatpickr-prev-month");
1176
+ self.prevMonthNav.innerHTML = self.config.prevArrow;
1177
+ self.nextMonthNav = createElement("span", "flatpickr-next-month");
1178
+ self.nextMonthNav.innerHTML = self.config.nextArrow;
1179
+ buildMonths();
1180
+ Object.defineProperty(self, "_hidePrevMonthArrow", {
1181
+ get: function () { return self.__hidePrevMonthArrow; },
1182
+ set: function (bool) {
1183
+ if (self.__hidePrevMonthArrow !== bool) {
1184
+ toggleClass(self.prevMonthNav, "flatpickr-disabled", bool);
1185
+ self.__hidePrevMonthArrow = bool;
1186
+ }
1187
+ },
1188
+ });
1189
+ Object.defineProperty(self, "_hideNextMonthArrow", {
1190
+ get: function () { return self.__hideNextMonthArrow; },
1191
+ set: function (bool) {
1192
+ if (self.__hideNextMonthArrow !== bool) {
1193
+ toggleClass(self.nextMonthNav, "flatpickr-disabled", bool);
1194
+ self.__hideNextMonthArrow = bool;
1195
+ }
1196
+ },
1197
+ });
1198
+ self.currentYearElement = self.yearElements[0];
1199
+ updateNavigationCurrentMonth();
1200
+ return self.monthNav;
1201
+ }
1202
+ function buildTime() {
1203
+ self.calendarContainer.classList.add("hasTime");
1204
+ if (self.config.noCalendar)
1205
+ self.calendarContainer.classList.add("noCalendar");
1206
+ var defaults = getDefaultHours(self.config);
1207
+ self.timeContainer = createElement("div", "flatpickr-time");
1208
+ self.timeContainer.tabIndex = -1;
1209
+ var separator = createElement("span", "flatpickr-time-separator", ":");
1210
+ var hourInput = createNumberInput("flatpickr-hour", {
1211
+ "aria-label": self.l10n.hourAriaLabel,
1212
+ });
1213
+ self.hourElement = hourInput.getElementsByTagName("input")[0];
1214
+ var minuteInput = createNumberInput("flatpickr-minute", {
1215
+ "aria-label": self.l10n.minuteAriaLabel,
1216
+ });
1217
+ self.minuteElement = minuteInput.getElementsByTagName("input")[0];
1218
+ self.hourElement.tabIndex = self.minuteElement.tabIndex = -1;
1219
+ self.hourElement.value = pad(self.latestSelectedDateObj
1220
+ ? self.latestSelectedDateObj.getHours()
1221
+ : self.config.time_24hr
1222
+ ? defaults.hours
1223
+ : military2ampm(defaults.hours));
1224
+ self.minuteElement.value = pad(self.latestSelectedDateObj
1225
+ ? self.latestSelectedDateObj.getMinutes()
1226
+ : defaults.minutes);
1227
+ self.hourElement.setAttribute("step", self.config.hourIncrement.toString());
1228
+ self.minuteElement.setAttribute("step", self.config.minuteIncrement.toString());
1229
+ self.hourElement.setAttribute("min", self.config.time_24hr ? "0" : "1");
1230
+ self.hourElement.setAttribute("max", self.config.time_24hr ? "23" : "12");
1231
+ self.hourElement.setAttribute("maxlength", "2");
1232
+ self.minuteElement.setAttribute("min", "0");
1233
+ self.minuteElement.setAttribute("max", "59");
1234
+ self.minuteElement.setAttribute("maxlength", "2");
1235
+ self.timeContainer.appendChild(hourInput);
1236
+ self.timeContainer.appendChild(separator);
1237
+ self.timeContainer.appendChild(minuteInput);
1238
+ if (self.config.time_24hr)
1239
+ self.timeContainer.classList.add("time24hr");
1240
+ if (self.config.enableSeconds) {
1241
+ self.timeContainer.classList.add("hasSeconds");
1242
+ var secondInput = createNumberInput("flatpickr-second");
1243
+ self.secondElement = secondInput.getElementsByTagName("input")[0];
1244
+ self.secondElement.value = pad(self.latestSelectedDateObj
1245
+ ? self.latestSelectedDateObj.getSeconds()
1246
+ : defaults.seconds);
1247
+ self.secondElement.setAttribute("step", self.minuteElement.getAttribute("step"));
1248
+ self.secondElement.setAttribute("min", "0");
1249
+ self.secondElement.setAttribute("max", "59");
1250
+ self.secondElement.setAttribute("maxlength", "2");
1251
+ self.timeContainer.appendChild(createElement("span", "flatpickr-time-separator", ":"));
1252
+ self.timeContainer.appendChild(secondInput);
1253
+ }
1254
+ if (!self.config.time_24hr) {
1255
+ self.amPM = createElement("span", "flatpickr-am-pm", self.l10n.amPM[int((self.latestSelectedDateObj
1256
+ ? self.hourElement.value
1257
+ : self.config.defaultHour) > 11)]);
1258
+ self.amPM.title = self.l10n.toggleTitle;
1259
+ self.amPM.tabIndex = -1;
1260
+ self.timeContainer.appendChild(self.amPM);
1261
+ }
1262
+ return self.timeContainer;
1263
+ }
1264
+ function buildWeekdays() {
1265
+ if (!self.weekdayContainer)
1266
+ self.weekdayContainer = createElement("div", "flatpickr-weekdays");
1267
+ else
1268
+ clearNode(self.weekdayContainer);
1269
+ for (var i = self.config.showMonths; i--;) {
1270
+ var container = createElement("div", "flatpickr-weekdaycontainer");
1271
+ self.weekdayContainer.appendChild(container);
1272
+ }
1273
+ updateWeekdays();
1274
+ return self.weekdayContainer;
1275
+ }
1276
+ function updateWeekdays() {
1277
+ if (!self.weekdayContainer) {
1278
+ return;
1279
+ }
1280
+ var firstDayOfWeek = self.l10n.firstDayOfWeek;
1281
+ var weekdays = __spreadArrays(self.l10n.weekdays.shorthand);
1282
+ if (firstDayOfWeek > 0 && firstDayOfWeek < weekdays.length) {
1283
+ weekdays = __spreadArrays(weekdays.splice(firstDayOfWeek, weekdays.length), weekdays.splice(0, firstDayOfWeek));
1284
+ }
1285
+ for (var i = self.config.showMonths; i--;) {
1286
+ self.weekdayContainer.children[i].innerHTML = "\n <span class='flatpickr-weekday'>\n " + weekdays.join("</span><span class='flatpickr-weekday'>") + "\n </span>\n ";
1287
+ }
1288
+ }
1289
+ function buildWeeks() {
1290
+ self.calendarContainer.classList.add("hasWeeks");
1291
+ var weekWrapper = createElement("div", "flatpickr-weekwrapper");
1292
+ weekWrapper.appendChild(createElement("span", "flatpickr-weekday", self.l10n.weekAbbreviation));
1293
+ var weekNumbers = createElement("div", "flatpickr-weeks");
1294
+ weekWrapper.appendChild(weekNumbers);
1295
+ return {
1296
+ weekWrapper: weekWrapper,
1297
+ weekNumbers: weekNumbers,
1298
+ };
1299
+ }
1300
+ function changeMonth(value, isOffset) {
1301
+ if (isOffset === void 0) { isOffset = true; }
1302
+ var delta = isOffset ? value : value - self.currentMonth;
1303
+ if ((delta < 0 && self._hidePrevMonthArrow === true) ||
1304
+ (delta > 0 && self._hideNextMonthArrow === true))
1305
+ return;
1306
+ self.currentMonth += delta;
1307
+ if (self.currentMonth < 0 || self.currentMonth > 11) {
1308
+ self.currentYear += self.currentMonth > 11 ? 1 : -1;
1309
+ self.currentMonth = (self.currentMonth + 12) % 12;
1310
+ triggerEvent("onYearChange");
1311
+ buildMonthSwitch();
1312
+ }
1313
+ buildDays();
1314
+ triggerEvent("onMonthChange");
1315
+ updateNavigationCurrentMonth();
1316
+ }
1317
+ function clear(triggerChangeEvent, toInitial) {
1318
+ if (triggerChangeEvent === void 0) { triggerChangeEvent = true; }
1319
+ if (toInitial === void 0) { toInitial = true; }
1320
+ self.input.value = "";
1321
+ if (self.altInput !== undefined)
1322
+ self.altInput.value = "";
1323
+ if (self.mobileInput !== undefined)
1324
+ self.mobileInput.value = "";
1325
+ self.selectedDates = [];
1326
+ self.latestSelectedDateObj = undefined;
1327
+ if (toInitial === true) {
1328
+ self.currentYear = self._initialDate.getFullYear();
1329
+ self.currentMonth = self._initialDate.getMonth();
1330
+ }
1331
+ if (self.config.enableTime === true) {
1332
+ var _a = getDefaultHours(self.config), hours = _a.hours, minutes = _a.minutes, seconds = _a.seconds;
1333
+ setHours(hours, minutes, seconds);
1334
+ }
1335
+ self.redraw();
1336
+ if (triggerChangeEvent)
1337
+ triggerEvent("onChange");
1338
+ }
1339
+ function close() {
1340
+ self.isOpen = false;
1341
+ if (!self.isMobile) {
1342
+ if (self.calendarContainer !== undefined) {
1343
+ self.calendarContainer.classList.remove("open");
1344
+ }
1345
+ if (self._input !== undefined) {
1346
+ self._input.classList.remove("active");
1347
+ }
1348
+ }
1349
+ triggerEvent("onClose");
1350
+ }
1351
+ function destroy() {
1352
+ if (self.config !== undefined)
1353
+ triggerEvent("onDestroy");
1354
+ for (var i = self._handlers.length; i--;) {
1355
+ self._handlers[i].remove();
1356
+ }
1357
+ self._handlers = [];
1358
+ if (self.mobileInput) {
1359
+ if (self.mobileInput.parentNode)
1360
+ self.mobileInput.parentNode.removeChild(self.mobileInput);
1361
+ self.mobileInput = undefined;
1362
+ }
1363
+ else if (self.calendarContainer && self.calendarContainer.parentNode) {
1364
+ if (self.config.static && self.calendarContainer.parentNode) {
1365
+ var wrapper = self.calendarContainer.parentNode;
1366
+ wrapper.lastChild && wrapper.removeChild(wrapper.lastChild);
1367
+ if (wrapper.parentNode) {
1368
+ while (wrapper.firstChild)
1369
+ wrapper.parentNode.insertBefore(wrapper.firstChild, wrapper);
1370
+ wrapper.parentNode.removeChild(wrapper);
1371
+ }
1372
+ }
1373
+ else
1374
+ self.calendarContainer.parentNode.removeChild(self.calendarContainer);
1375
+ }
1376
+ if (self.altInput) {
1377
+ self.input.type = "text";
1378
+ if (self.altInput.parentNode)
1379
+ self.altInput.parentNode.removeChild(self.altInput);
1380
+ delete self.altInput;
1381
+ }
1382
+ if (self.input) {
1383
+ self.input.type = self.input._type;
1384
+ self.input.classList.remove("flatpickr-input");
1385
+ self.input.removeAttribute("readonly");
1386
+ }
1387
+ [
1388
+ "_showTimeInput",
1389
+ "latestSelectedDateObj",
1390
+ "_hideNextMonthArrow",
1391
+ "_hidePrevMonthArrow",
1392
+ "__hideNextMonthArrow",
1393
+ "__hidePrevMonthArrow",
1394
+ "isMobile",
1395
+ "isOpen",
1396
+ "selectedDateElem",
1397
+ "minDateHasTime",
1398
+ "maxDateHasTime",
1399
+ "days",
1400
+ "daysContainer",
1401
+ "_input",
1402
+ "_positionElement",
1403
+ "innerContainer",
1404
+ "rContainer",
1405
+ "monthNav",
1406
+ "todayDateElem",
1407
+ "calendarContainer",
1408
+ "weekdayContainer",
1409
+ "prevMonthNav",
1410
+ "nextMonthNav",
1411
+ "monthsDropdownContainer",
1412
+ "currentMonthElement",
1413
+ "currentYearElement",
1414
+ "navigationCurrentMonth",
1415
+ "selectedDateElem",
1416
+ "config",
1417
+ ].forEach(function (k) {
1418
+ try {
1419
+ delete self[k];
1420
+ }
1421
+ catch (_) { }
1422
+ });
1423
+ }
1424
+ function isCalendarElem(elem) {
1425
+ return self.calendarContainer.contains(elem);
1426
+ }
1427
+ function documentClick(e) {
1428
+ if (self.isOpen && !self.config.inline) {
1429
+ var eventTarget_1 = getEventTarget(e);
1430
+ var isCalendarElement = isCalendarElem(eventTarget_1);
1431
+ var isInput = eventTarget_1 === self.input ||
1432
+ eventTarget_1 === self.altInput ||
1433
+ self.element.contains(eventTarget_1) ||
1434
+ (e.path &&
1435
+ e.path.indexOf &&
1436
+ (~e.path.indexOf(self.input) ||
1437
+ ~e.path.indexOf(self.altInput)));
1438
+ var lostFocus = !isInput &&
1439
+ !isCalendarElement &&
1440
+ !isCalendarElem(e.relatedTarget);
1441
+ var isIgnored = !self.config.ignoredFocusElements.some(function (elem) {
1442
+ return elem.contains(eventTarget_1);
1443
+ });
1444
+ if (lostFocus && isIgnored) {
1445
+ if (self.config.allowInput) {
1446
+ self.setDate(self._input.value, false, self.config.altInput
1447
+ ? self.config.altFormat
1448
+ : self.config.dateFormat);
1449
+ }
1450
+ if (self.timeContainer !== undefined &&
1451
+ self.minuteElement !== undefined &&
1452
+ self.hourElement !== undefined &&
1453
+ self.input.value !== "" &&
1454
+ self.input.value !== undefined) {
1455
+ updateTime();
1456
+ }
1457
+ self.close();
1458
+ if (self.config &&
1459
+ self.config.mode === "range" &&
1460
+ self.selectedDates.length === 1)
1461
+ self.clear(false);
1462
+ }
1463
+ }
1464
+ }
1465
+ function changeYear(newYear) {
1466
+ if (!newYear ||
1467
+ (self.config.minDate && newYear < self.config.minDate.getFullYear()) ||
1468
+ (self.config.maxDate && newYear > self.config.maxDate.getFullYear()))
1469
+ return;
1470
+ var newYearNum = newYear, isNewYear = self.currentYear !== newYearNum;
1471
+ self.currentYear = newYearNum || self.currentYear;
1472
+ if (self.config.maxDate &&
1473
+ self.currentYear === self.config.maxDate.getFullYear()) {
1474
+ self.currentMonth = Math.min(self.config.maxDate.getMonth(), self.currentMonth);
1475
+ }
1476
+ else if (self.config.minDate &&
1477
+ self.currentYear === self.config.minDate.getFullYear()) {
1478
+ self.currentMonth = Math.max(self.config.minDate.getMonth(), self.currentMonth);
1479
+ }
1480
+ if (isNewYear) {
1481
+ self.redraw();
1482
+ triggerEvent("onYearChange");
1483
+ buildMonthSwitch();
1484
+ }
1485
+ }
1486
+ function isEnabled(date, timeless) {
1487
+ var _a;
1488
+ if (timeless === void 0) { timeless = true; }
1489
+ var dateToCheck = self.parseDate(date, undefined, timeless);
1490
+ if ((self.config.minDate &&
1491
+ dateToCheck &&
1492
+ compareDates(dateToCheck, self.config.minDate, timeless !== undefined ? timeless : !self.minDateHasTime) < 0) ||
1493
+ (self.config.maxDate &&
1494
+ dateToCheck &&
1495
+ compareDates(dateToCheck, self.config.maxDate, timeless !== undefined ? timeless : !self.maxDateHasTime) > 0))
1496
+ return false;
1497
+ if (!self.config.enable && self.config.disable.length === 0)
1498
+ return true;
1499
+ if (dateToCheck === undefined)
1500
+ return false;
1501
+ var bool = !!self.config.enable, array = (_a = self.config.enable) !== null && _a !== void 0 ? _a : self.config.disable;
1502
+ for (var i = 0, d = void 0; i < array.length; i++) {
1503
+ d = array[i];
1504
+ if (typeof d === "function" &&
1505
+ d(dateToCheck))
1506
+ return bool;
1507
+ else if (d instanceof Date &&
1508
+ dateToCheck !== undefined &&
1509
+ d.getTime() === dateToCheck.getTime())
1510
+ return bool;
1511
+ else if (typeof d === "string") {
1512
+ var parsed = self.parseDate(d, undefined, true);
1513
+ return parsed && parsed.getTime() === dateToCheck.getTime()
1514
+ ? bool
1515
+ : !bool;
1516
+ }
1517
+ else if (typeof d === "object" &&
1518
+ dateToCheck !== undefined &&
1519
+ d.from &&
1520
+ d.to &&
1521
+ dateToCheck.getTime() >= d.from.getTime() &&
1522
+ dateToCheck.getTime() <= d.to.getTime())
1523
+ return bool;
1524
+ }
1525
+ return !bool;
1526
+ }
1527
+ function isInView(elem) {
1528
+ if (self.daysContainer !== undefined)
1529
+ return (elem.className.indexOf("hidden") === -1 &&
1530
+ elem.className.indexOf("flatpickr-disabled") === -1 &&
1531
+ self.daysContainer.contains(elem));
1532
+ return false;
1533
+ }
1534
+ function onBlur(e) {
1535
+ var isInput = e.target === self._input;
1536
+ var valueChanged = self._input.value.trimEnd() !== getDateStr();
1537
+ if (isInput &&
1538
+ valueChanged &&
1539
+ !(e.relatedTarget && isCalendarElem(e.relatedTarget))) {
1540
+ self.setDate(self._input.value, true, e.target === self.altInput
1541
+ ? self.config.altFormat
1542
+ : self.config.dateFormat);
1543
+ }
1544
+ }
1545
+ function onKeyDown(e) {
1546
+ var eventTarget = getEventTarget(e);
1547
+ var isInput = self.config.wrap
1548
+ ? element.contains(eventTarget)
1549
+ : eventTarget === self._input;
1550
+ var allowInput = self.config.allowInput;
1551
+ var allowKeydown = self.isOpen && (!allowInput || !isInput);
1552
+ var allowInlineKeydown = self.config.inline && isInput && !allowInput;
1553
+ if (e.keyCode === 13 && isInput) {
1554
+ if (allowInput) {
1555
+ self.setDate(self._input.value, true, eventTarget === self.altInput
1556
+ ? self.config.altFormat
1557
+ : self.config.dateFormat);
1558
+ self.close();
1559
+ return eventTarget.blur();
1560
+ }
1561
+ else {
1562
+ self.open();
1563
+ }
1564
+ }
1565
+ else if (isCalendarElem(eventTarget) ||
1566
+ allowKeydown ||
1567
+ allowInlineKeydown) {
1568
+ var isTimeObj = !!self.timeContainer &&
1569
+ self.timeContainer.contains(eventTarget);
1570
+ switch (e.keyCode) {
1571
+ case 13:
1572
+ if (isTimeObj) {
1573
+ e.preventDefault();
1574
+ updateTime();
1575
+ focusAndClose();
1576
+ }
1577
+ else
1578
+ selectDate(e);
1579
+ break;
1580
+ case 27:
1581
+ e.preventDefault();
1582
+ focusAndClose();
1583
+ break;
1584
+ case 8:
1585
+ case 46:
1586
+ if (isInput && !self.config.allowInput) {
1587
+ e.preventDefault();
1588
+ self.clear();
1589
+ }
1590
+ break;
1591
+ case 37:
1592
+ case 39:
1593
+ if (!isTimeObj && !isInput) {
1594
+ e.preventDefault();
1595
+ var activeElement = getClosestActiveElement();
1596
+ if (self.daysContainer !== undefined &&
1597
+ (allowInput === false ||
1598
+ (activeElement && isInView(activeElement)))) {
1599
+ var delta_1 = e.keyCode === 39 ? 1 : -1;
1600
+ if (!e.ctrlKey)
1601
+ focusOnDay(undefined, delta_1);
1602
+ else {
1603
+ e.stopPropagation();
1604
+ changeMonth(delta_1);
1605
+ focusOnDay(getFirstAvailableDay(1), 0);
1606
+ }
1607
+ }
1608
+ }
1609
+ else if (self.hourElement)
1610
+ self.hourElement.focus();
1611
+ break;
1612
+ case 38:
1613
+ case 40:
1614
+ e.preventDefault();
1615
+ var delta = e.keyCode === 40 ? 1 : -1;
1616
+ if ((self.daysContainer &&
1617
+ eventTarget.$i !== undefined) ||
1618
+ eventTarget === self.input ||
1619
+ eventTarget === self.altInput) {
1620
+ if (e.ctrlKey) {
1621
+ e.stopPropagation();
1622
+ changeYear(self.currentYear - delta);
1623
+ focusOnDay(getFirstAvailableDay(1), 0);
1624
+ }
1625
+ else if (!isTimeObj)
1626
+ focusOnDay(undefined, delta * 7);
1627
+ }
1628
+ else if (eventTarget === self.currentYearElement) {
1629
+ changeYear(self.currentYear - delta);
1630
+ }
1631
+ else if (self.config.enableTime) {
1632
+ if (!isTimeObj && self.hourElement)
1633
+ self.hourElement.focus();
1634
+ updateTime(e);
1635
+ self._debouncedChange();
1636
+ }
1637
+ break;
1638
+ case 9:
1639
+ if (isTimeObj) {
1640
+ var elems = [
1641
+ self.hourElement,
1642
+ self.minuteElement,
1643
+ self.secondElement,
1644
+ self.amPM,
1645
+ ]
1646
+ .concat(self.pluginElements)
1647
+ .filter(function (x) { return x; });
1648
+ var i = elems.indexOf(eventTarget);
1649
+ if (i !== -1) {
1650
+ var target = elems[i + (e.shiftKey ? -1 : 1)];
1651
+ e.preventDefault();
1652
+ (target || self._input).focus();
1653
+ }
1654
+ }
1655
+ else if (!self.config.noCalendar &&
1656
+ self.daysContainer &&
1657
+ self.daysContainer.contains(eventTarget) &&
1658
+ e.shiftKey) {
1659
+ e.preventDefault();
1660
+ self._input.focus();
1661
+ }
1662
+ break;
1663
+ }
1664
+ }
1665
+ if (self.amPM !== undefined && eventTarget === self.amPM) {
1666
+ switch (e.key) {
1667
+ case self.l10n.amPM[0].charAt(0):
1668
+ case self.l10n.amPM[0].charAt(0).toLowerCase():
1669
+ self.amPM.textContent = self.l10n.amPM[0];
1670
+ setHoursFromInputs();
1671
+ updateValue();
1672
+ break;
1673
+ case self.l10n.amPM[1].charAt(0):
1674
+ case self.l10n.amPM[1].charAt(0).toLowerCase():
1675
+ self.amPM.textContent = self.l10n.amPM[1];
1676
+ setHoursFromInputs();
1677
+ updateValue();
1678
+ break;
1679
+ }
1680
+ }
1681
+ if (isInput || isCalendarElem(eventTarget)) {
1682
+ triggerEvent("onKeyDown", e);
1683
+ }
1684
+ }
1685
+ function onMouseOver(elem, cellClass) {
1686
+ if (cellClass === void 0) { cellClass = "flatpickr-day"; }
1687
+ if (self.selectedDates.length !== 1 ||
1688
+ (elem &&
1689
+ (!elem.classList.contains(cellClass) ||
1690
+ elem.classList.contains("flatpickr-disabled"))))
1691
+ return;
1692
+ var hoverDate = elem
1693
+ ? elem.dateObj.getTime()
1694
+ : self.days.firstElementChild.dateObj.getTime(), initialDate = self.parseDate(self.selectedDates[0], undefined, true).getTime(), rangeStartDate = Math.min(hoverDate, self.selectedDates[0].getTime()), rangeEndDate = Math.max(hoverDate, self.selectedDates[0].getTime());
1695
+ var containsDisabled = false;
1696
+ var minRange = 0, maxRange = 0;
1697
+ for (var t = rangeStartDate; t < rangeEndDate; t += duration.DAY) {
1698
+ if (!isEnabled(new Date(t), true)) {
1699
+ containsDisabled =
1700
+ containsDisabled || (t > rangeStartDate && t < rangeEndDate);
1701
+ if (t < initialDate && (!minRange || t > minRange))
1702
+ minRange = t;
1703
+ else if (t > initialDate && (!maxRange || t < maxRange))
1704
+ maxRange = t;
1705
+ }
1706
+ }
1707
+ var hoverableCells = Array.from(self.rContainer.querySelectorAll("*:nth-child(-n+" + self.config.showMonths + ") > ." + cellClass));
1708
+ hoverableCells.forEach(function (dayElem) {
1709
+ var date = dayElem.dateObj;
1710
+ var timestamp = date.getTime();
1711
+ var outOfRange = (minRange > 0 && timestamp < minRange) ||
1712
+ (maxRange > 0 && timestamp > maxRange);
1713
+ if (outOfRange) {
1714
+ dayElem.classList.add("notAllowed");
1715
+ ["inRange", "startRange", "endRange"].forEach(function (c) {
1716
+ dayElem.classList.remove(c);
1717
+ });
1718
+ return;
1719
+ }
1720
+ else if (containsDisabled && !outOfRange)
1721
+ return;
1722
+ ["startRange", "inRange", "endRange", "notAllowed"].forEach(function (c) {
1723
+ dayElem.classList.remove(c);
1724
+ });
1725
+ if (elem !== undefined) {
1726
+ elem.classList.add(hoverDate <= self.selectedDates[0].getTime()
1727
+ ? "startRange"
1728
+ : "endRange");
1729
+ if (initialDate < hoverDate && timestamp === initialDate)
1730
+ dayElem.classList.add("startRange");
1731
+ else if (initialDate > hoverDate && timestamp === initialDate)
1732
+ dayElem.classList.add("endRange");
1733
+ if (timestamp >= minRange &&
1734
+ (maxRange === 0 || timestamp <= maxRange) &&
1735
+ isBetween(timestamp, initialDate, hoverDate))
1736
+ dayElem.classList.add("inRange");
1737
+ }
1738
+ });
1739
+ }
1740
+ function onResize() {
1741
+ if (self.isOpen && !self.config.static && !self.config.inline)
1742
+ positionCalendar();
1743
+ }
1744
+ function open(e, positionElement) {
1745
+ if (positionElement === void 0) { positionElement = self._positionElement; }
1746
+ if (self.isMobile === true) {
1747
+ if (e) {
1748
+ e.preventDefault();
1749
+ var eventTarget = getEventTarget(e);
1750
+ if (eventTarget) {
1751
+ eventTarget.blur();
1752
+ }
1753
+ }
1754
+ if (self.mobileInput !== undefined) {
1755
+ self.mobileInput.focus();
1756
+ self.mobileInput.click();
1757
+ }
1758
+ triggerEvent("onOpen");
1759
+ return;
1760
+ }
1761
+ else if (self._input.disabled || self.config.inline) {
1762
+ return;
1763
+ }
1764
+ var wasOpen = self.isOpen;
1765
+ self.isOpen = true;
1766
+ if (!wasOpen) {
1767
+ self.calendarContainer.classList.add("open");
1768
+ self._input.classList.add("active");
1769
+ triggerEvent("onOpen");
1770
+ positionCalendar(positionElement);
1771
+ }
1772
+ if (self.config.enableTime === true && self.config.noCalendar === true) {
1773
+ if (self.config.allowInput === false &&
1774
+ (e === undefined ||
1775
+ !self.timeContainer.contains(e.relatedTarget))) {
1776
+ setTimeout(function () { return self.hourElement.select(); }, 50);
1777
+ }
1778
+ }
1779
+ }
1780
+ function minMaxDateSetter(type) {
1781
+ return function (date) {
1782
+ var dateObj = (self.config["_" + type + "Date"] = self.parseDate(date, self.config.dateFormat));
1783
+ var inverseDateObj = self.config["_" + (type === "min" ? "max" : "min") + "Date"];
1784
+ if (dateObj !== undefined) {
1785
+ self[type === "min" ? "minDateHasTime" : "maxDateHasTime"] =
1786
+ dateObj.getHours() > 0 ||
1787
+ dateObj.getMinutes() > 0 ||
1788
+ dateObj.getSeconds() > 0;
1789
+ }
1790
+ if (self.selectedDates) {
1791
+ self.selectedDates = self.selectedDates.filter(function (d) { return isEnabled(d); });
1792
+ if (!self.selectedDates.length && type === "min")
1793
+ setHoursFromDate(dateObj);
1794
+ updateValue();
1795
+ }
1796
+ if (self.daysContainer) {
1797
+ redraw();
1798
+ if (dateObj !== undefined)
1799
+ self.currentYearElement[type] = dateObj.getFullYear().toString();
1800
+ else
1801
+ self.currentYearElement.removeAttribute(type);
1802
+ self.currentYearElement.disabled =
1803
+ !!inverseDateObj &&
1804
+ dateObj !== undefined &&
1805
+ inverseDateObj.getFullYear() === dateObj.getFullYear();
1806
+ }
1807
+ };
1808
+ }
1809
+ function parseConfig() {
1810
+ var boolOpts = [
1811
+ "wrap",
1812
+ "weekNumbers",
1813
+ "allowInput",
1814
+ "allowInvalidPreload",
1815
+ "clickOpens",
1816
+ "time_24hr",
1817
+ "enableTime",
1818
+ "noCalendar",
1819
+ "altInput",
1820
+ "shorthandCurrentMonth",
1821
+ "inline",
1822
+ "static",
1823
+ "enableSeconds",
1824
+ "disableMobile",
1825
+ ];
1826
+ var userConfig = __assign(__assign({}, JSON.parse(JSON.stringify(element.dataset || {}))), instanceConfig);
1827
+ var formats = {};
1828
+ self.config.parseDate = userConfig.parseDate;
1829
+ self.config.formatDate = userConfig.formatDate;
1830
+ Object.defineProperty(self.config, "enable", {
1831
+ get: function () { return self.config._enable; },
1832
+ set: function (dates) {
1833
+ self.config._enable = parseDateRules(dates);
1834
+ },
1835
+ });
1836
+ Object.defineProperty(self.config, "disable", {
1837
+ get: function () { return self.config._disable; },
1838
+ set: function (dates) {
1839
+ self.config._disable = parseDateRules(dates);
1840
+ },
1841
+ });
1842
+ var timeMode = userConfig.mode === "time";
1843
+ if (!userConfig.dateFormat && (userConfig.enableTime || timeMode)) {
1844
+ var defaultDateFormat = flatpickr.defaultConfig.dateFormat || defaults.dateFormat;
1845
+ formats.dateFormat =
1846
+ userConfig.noCalendar || timeMode
1847
+ ? "H:i" + (userConfig.enableSeconds ? ":S" : "")
1848
+ : defaultDateFormat + " H:i" + (userConfig.enableSeconds ? ":S" : "");
1849
+ }
1850
+ if (userConfig.altInput &&
1851
+ (userConfig.enableTime || timeMode) &&
1852
+ !userConfig.altFormat) {
1853
+ var defaultAltFormat = flatpickr.defaultConfig.altFormat || defaults.altFormat;
1854
+ formats.altFormat =
1855
+ userConfig.noCalendar || timeMode
1856
+ ? "h:i" + (userConfig.enableSeconds ? ":S K" : " K")
1857
+ : defaultAltFormat + (" h:i" + (userConfig.enableSeconds ? ":S" : "") + " K");
1858
+ }
1859
+ Object.defineProperty(self.config, "minDate", {
1860
+ get: function () { return self.config._minDate; },
1861
+ set: minMaxDateSetter("min"),
1862
+ });
1863
+ Object.defineProperty(self.config, "maxDate", {
1864
+ get: function () { return self.config._maxDate; },
1865
+ set: minMaxDateSetter("max"),
1866
+ });
1867
+ var minMaxTimeSetter = function (type) { return function (val) {
1868
+ self.config[type === "min" ? "_minTime" : "_maxTime"] = self.parseDate(val, "H:i:S");
1869
+ }; };
1870
+ Object.defineProperty(self.config, "minTime", {
1871
+ get: function () { return self.config._minTime; },
1872
+ set: minMaxTimeSetter("min"),
1873
+ });
1874
+ Object.defineProperty(self.config, "maxTime", {
1875
+ get: function () { return self.config._maxTime; },
1876
+ set: minMaxTimeSetter("max"),
1877
+ });
1878
+ if (userConfig.mode === "time") {
1879
+ self.config.noCalendar = true;
1880
+ self.config.enableTime = true;
1881
+ }
1882
+ Object.assign(self.config, formats, userConfig);
1883
+ for (var i = 0; i < boolOpts.length; i++)
1884
+ self.config[boolOpts[i]] =
1885
+ self.config[boolOpts[i]] === true ||
1886
+ self.config[boolOpts[i]] === "true";
1887
+ HOOKS.filter(function (hook) { return self.config[hook] !== undefined; }).forEach(function (hook) {
1888
+ self.config[hook] = arrayify(self.config[hook] || []).map(bindToInstance);
1889
+ });
1890
+ self.isMobile =
1891
+ !self.config.disableMobile &&
1892
+ !self.config.inline &&
1893
+ self.config.mode === "single" &&
1894
+ !self.config.disable.length &&
1895
+ !self.config.enable &&
1896
+ !self.config.weekNumbers &&
1897
+ /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);
1898
+ for (var i = 0; i < self.config.plugins.length; i++) {
1899
+ var pluginConf = self.config.plugins[i](self) || {};
1900
+ for (var key in pluginConf) {
1901
+ if (HOOKS.indexOf(key) > -1) {
1902
+ self.config[key] = arrayify(pluginConf[key])
1903
+ .map(bindToInstance)
1904
+ .concat(self.config[key]);
1905
+ }
1906
+ else if (typeof userConfig[key] === "undefined")
1907
+ self.config[key] = pluginConf[key];
1908
+ }
1909
+ }
1910
+ if (!userConfig.altInputClass) {
1911
+ self.config.altInputClass =
1912
+ getInputElem().className + " " + self.config.altInputClass;
1913
+ }
1914
+ triggerEvent("onParseConfig");
1915
+ }
1916
+ function getInputElem() {
1917
+ return self.config.wrap
1918
+ ? element.querySelector("[data-input]")
1919
+ : element;
1920
+ }
1921
+ function setupLocale() {
1922
+ if (typeof self.config.locale !== "object" &&
1923
+ typeof flatpickr.l10ns[self.config.locale] === "undefined")
1924
+ self.config.errorHandler(new Error("flatpickr: invalid locale " + self.config.locale));
1925
+ self.l10n = __assign(__assign({}, flatpickr.l10ns.default), (typeof self.config.locale === "object"
1926
+ ? self.config.locale
1927
+ : self.config.locale !== "default"
1928
+ ? flatpickr.l10ns[self.config.locale]
1929
+ : undefined));
1930
+ tokenRegex.D = "(" + self.l10n.weekdays.shorthand.join("|") + ")";
1931
+ tokenRegex.l = "(" + self.l10n.weekdays.longhand.join("|") + ")";
1932
+ tokenRegex.M = "(" + self.l10n.months.shorthand.join("|") + ")";
1933
+ tokenRegex.F = "(" + self.l10n.months.longhand.join("|") + ")";
1934
+ tokenRegex.K = "(" + self.l10n.amPM[0] + "|" + self.l10n.amPM[1] + "|" + self.l10n.amPM[0].toLowerCase() + "|" + self.l10n.amPM[1].toLowerCase() + ")";
1935
+ var userConfig = __assign(__assign({}, instanceConfig), JSON.parse(JSON.stringify(element.dataset || {})));
1936
+ if (userConfig.time_24hr === undefined &&
1937
+ flatpickr.defaultConfig.time_24hr === undefined) {
1938
+ self.config.time_24hr = self.l10n.time_24hr;
1939
+ }
1940
+ self.formatDate = createDateFormatter(self);
1941
+ self.parseDate = createDateParser({ config: self.config, l10n: self.l10n });
1942
+ }
1943
+ function positionCalendar(customPositionElement) {
1944
+ if (typeof self.config.position === "function") {
1945
+ return void self.config.position(self, customPositionElement);
1946
+ }
1947
+ if (self.calendarContainer === undefined)
1948
+ return;
1949
+ triggerEvent("onPreCalendarPosition");
1950
+ var positionElement = customPositionElement || self._positionElement;
1951
+ var calendarHeight = Array.prototype.reduce.call(self.calendarContainer.children, (function (acc, child) { return acc + child.offsetHeight; }), 0), calendarWidth = self.calendarContainer.offsetWidth, configPos = self.config.position.split(" "), configPosVertical = configPos[0], configPosHorizontal = configPos.length > 1 ? configPos[1] : null, inputBounds = positionElement.getBoundingClientRect(), distanceFromBottom = window.innerHeight - inputBounds.bottom, showOnTop = configPosVertical === "above" ||
1952
+ (configPosVertical !== "below" &&
1953
+ distanceFromBottom < calendarHeight &&
1954
+ inputBounds.top > calendarHeight);
1955
+ var top = window.pageYOffset +
1956
+ inputBounds.top +
1957
+ (!showOnTop ? positionElement.offsetHeight + 2 : -calendarHeight - 2);
1958
+ toggleClass(self.calendarContainer, "arrowTop", !showOnTop);
1959
+ toggleClass(self.calendarContainer, "arrowBottom", showOnTop);
1960
+ if (self.config.inline)
1961
+ return;
1962
+ var left = window.pageXOffset + inputBounds.left;
1963
+ var isCenter = false;
1964
+ var isRight = false;
1965
+ if (configPosHorizontal === "center") {
1966
+ left -= (calendarWidth - inputBounds.width) / 2;
1967
+ isCenter = true;
1968
+ }
1969
+ else if (configPosHorizontal === "right") {
1970
+ left -= calendarWidth - inputBounds.width;
1971
+ isRight = true;
1972
+ }
1973
+ toggleClass(self.calendarContainer, "arrowLeft", !isCenter && !isRight);
1974
+ toggleClass(self.calendarContainer, "arrowCenter", isCenter);
1975
+ toggleClass(self.calendarContainer, "arrowRight", isRight);
1976
+ var right = window.document.body.offsetWidth -
1977
+ (window.pageXOffset + inputBounds.right);
1978
+ var rightMost = left + calendarWidth > window.document.body.offsetWidth;
1979
+ var centerMost = right + calendarWidth > window.document.body.offsetWidth;
1980
+ toggleClass(self.calendarContainer, "rightMost", rightMost);
1981
+ if (self.config.static)
1982
+ return;
1983
+ self.calendarContainer.style.top = top + "px";
1984
+ if (!rightMost) {
1985
+ self.calendarContainer.style.left = left + "px";
1986
+ self.calendarContainer.style.right = "auto";
1987
+ }
1988
+ else if (!centerMost) {
1989
+ self.calendarContainer.style.left = "auto";
1990
+ self.calendarContainer.style.right = right + "px";
1991
+ }
1992
+ else {
1993
+ var doc = getDocumentStyleSheet();
1994
+ if (doc === undefined)
1995
+ return;
1996
+ var bodyWidth = window.document.body.offsetWidth;
1997
+ var centerLeft = Math.max(0, bodyWidth / 2 - calendarWidth / 2);
1998
+ var centerBefore = ".flatpickr-calendar.centerMost:before";
1999
+ var centerAfter = ".flatpickr-calendar.centerMost:after";
2000
+ var centerIndex = doc.cssRules.length;
2001
+ var centerStyle = "{left:" + inputBounds.left + "px;right:auto;}";
2002
+ toggleClass(self.calendarContainer, "rightMost", false);
2003
+ toggleClass(self.calendarContainer, "centerMost", true);
2004
+ doc.insertRule(centerBefore + "," + centerAfter + centerStyle, centerIndex);
2005
+ self.calendarContainer.style.left = centerLeft + "px";
2006
+ self.calendarContainer.style.right = "auto";
2007
+ }
2008
+ }
2009
+ function getDocumentStyleSheet() {
2010
+ var editableSheet = null;
2011
+ for (var i = 0; i < document.styleSheets.length; i++) {
2012
+ var sheet = document.styleSheets[i];
2013
+ if (!sheet.cssRules)
2014
+ continue;
2015
+ editableSheet = sheet;
2016
+ break;
2017
+ }
2018
+ return editableSheet != null ? editableSheet : createStyleSheet();
2019
+ }
2020
+ function createStyleSheet() {
2021
+ var style = document.createElement("style");
2022
+ document.head.appendChild(style);
2023
+ return style.sheet;
2024
+ }
2025
+ function redraw() {
2026
+ if (self.config.noCalendar || self.isMobile)
2027
+ return;
2028
+ buildMonthSwitch();
2029
+ updateNavigationCurrentMonth();
2030
+ buildDays();
2031
+ }
2032
+ function focusAndClose() {
2033
+ self._input.focus();
2034
+ if (window.navigator.userAgent.indexOf("MSIE") !== -1 ||
2035
+ navigator.msMaxTouchPoints !== undefined) {
2036
+ setTimeout(self.close, 0);
2037
+ }
2038
+ else {
2039
+ self.close();
2040
+ }
2041
+ }
2042
+ function selectDate(e) {
2043
+ e.preventDefault();
2044
+ e.stopPropagation();
2045
+ var isSelectable = function (day) {
2046
+ return day.classList &&
2047
+ day.classList.contains("flatpickr-day") &&
2048
+ !day.classList.contains("flatpickr-disabled") &&
2049
+ !day.classList.contains("notAllowed");
2050
+ };
2051
+ var t = findParent(getEventTarget(e), isSelectable);
2052
+ if (t === undefined)
2053
+ return;
2054
+ var target = t;
2055
+ var selectedDate = (self.latestSelectedDateObj = new Date(target.dateObj.getTime()));
2056
+ var shouldChangeMonth = (selectedDate.getMonth() < self.currentMonth ||
2057
+ selectedDate.getMonth() >
2058
+ self.currentMonth + self.config.showMonths - 1) &&
2059
+ self.config.mode !== "range";
2060
+ self.selectedDateElem = target;
2061
+ if (self.config.mode === "single")
2062
+ self.selectedDates = [selectedDate];
2063
+ else if (self.config.mode === "multiple") {
2064
+ var selectedIndex = isDateSelected(selectedDate);
2065
+ if (selectedIndex)
2066
+ self.selectedDates.splice(parseInt(selectedIndex), 1);
2067
+ else
2068
+ self.selectedDates.push(selectedDate);
2069
+ }
2070
+ else if (self.config.mode === "range") {
2071
+ if (self.selectedDates.length === 2) {
2072
+ self.clear(false, false);
2073
+ }
2074
+ self.latestSelectedDateObj = selectedDate;
2075
+ self.selectedDates.push(selectedDate);
2076
+ if (compareDates(selectedDate, self.selectedDates[0], true) !== 0)
2077
+ self.selectedDates.sort(function (a, b) { return a.getTime() - b.getTime(); });
2078
+ }
2079
+ setHoursFromInputs();
2080
+ if (shouldChangeMonth) {
2081
+ var isNewYear = self.currentYear !== selectedDate.getFullYear();
2082
+ self.currentYear = selectedDate.getFullYear();
2083
+ self.currentMonth = selectedDate.getMonth();
2084
+ if (isNewYear) {
2085
+ triggerEvent("onYearChange");
2086
+ buildMonthSwitch();
2087
+ }
2088
+ triggerEvent("onMonthChange");
2089
+ }
2090
+ updateNavigationCurrentMonth();
2091
+ buildDays();
2092
+ updateValue();
2093
+ if (!shouldChangeMonth &&
2094
+ self.config.mode !== "range" &&
2095
+ self.config.showMonths === 1)
2096
+ focusOnDayElem(target);
2097
+ else if (self.selectedDateElem !== undefined &&
2098
+ self.hourElement === undefined) {
2099
+ self.selectedDateElem && self.selectedDateElem.focus();
2100
+ }
2101
+ if (self.hourElement !== undefined)
2102
+ self.hourElement !== undefined && self.hourElement.focus();
2103
+ if (self.config.closeOnSelect) {
2104
+ var single = self.config.mode === "single" && !self.config.enableTime;
2105
+ var range = self.config.mode === "range" &&
2106
+ self.selectedDates.length === 2 &&
2107
+ !self.config.enableTime;
2108
+ if (single || range) {
2109
+ focusAndClose();
2110
+ }
2111
+ }
2112
+ triggerChange();
2113
+ }
2114
+ var CALLBACKS = {
2115
+ locale: [setupLocale, updateWeekdays],
2116
+ showMonths: [buildMonths, setCalendarWidth, buildWeekdays],
2117
+ minDate: [jumpToDate],
2118
+ maxDate: [jumpToDate],
2119
+ positionElement: [updatePositionElement],
2120
+ clickOpens: [
2121
+ function () {
2122
+ if (self.config.clickOpens === true) {
2123
+ bind(self._input, "focus", self.open);
2124
+ bind(self._input, "click", self.open);
2125
+ }
2126
+ else {
2127
+ self._input.removeEventListener("focus", self.open);
2128
+ self._input.removeEventListener("click", self.open);
2129
+ }
2130
+ },
2131
+ ],
2132
+ };
2133
+ function set(option, value) {
2134
+ if (option !== null && typeof option === "object") {
2135
+ Object.assign(self.config, option);
2136
+ for (var key in option) {
2137
+ if (CALLBACKS[key] !== undefined)
2138
+ CALLBACKS[key].forEach(function (x) { return x(); });
2139
+ }
2140
+ }
2141
+ else {
2142
+ self.config[option] = value;
2143
+ if (CALLBACKS[option] !== undefined)
2144
+ CALLBACKS[option].forEach(function (x) { return x(); });
2145
+ else if (HOOKS.indexOf(option) > -1)
2146
+ self.config[option] = arrayify(value);
2147
+ }
2148
+ self.redraw();
2149
+ updateValue(true);
2150
+ }
2151
+ function setSelectedDate(inputDate, format) {
2152
+ var dates = [];
2153
+ if (inputDate instanceof Array)
2154
+ dates = inputDate.map(function (d) { return self.parseDate(d, format); });
2155
+ else if (inputDate instanceof Date || typeof inputDate === "number")
2156
+ dates = [self.parseDate(inputDate, format)];
2157
+ else if (typeof inputDate === "string") {
2158
+ switch (self.config.mode) {
2159
+ case "single":
2160
+ case "time":
2161
+ dates = [self.parseDate(inputDate, format)];
2162
+ break;
2163
+ case "multiple":
2164
+ dates = inputDate
2165
+ .split(self.config.conjunction)
2166
+ .map(function (date) { return self.parseDate(date, format); });
2167
+ break;
2168
+ case "range":
2169
+ dates = inputDate
2170
+ .split(self.l10n.rangeSeparator)
2171
+ .map(function (date) { return self.parseDate(date, format); });
2172
+ break;
2173
+ }
2174
+ }
2175
+ else
2176
+ self.config.errorHandler(new Error("Invalid date supplied: " + JSON.stringify(inputDate)));
2177
+ self.selectedDates = (self.config.allowInvalidPreload
2178
+ ? dates
2179
+ : dates.filter(function (d) { return d instanceof Date && isEnabled(d, false); }));
2180
+ if (self.config.mode === "range")
2181
+ self.selectedDates.sort(function (a, b) { return a.getTime() - b.getTime(); });
2182
+ }
2183
+ function setDate(date, triggerChange, format) {
2184
+ if (triggerChange === void 0) { triggerChange = false; }
2185
+ if (format === void 0) { format = self.config.dateFormat; }
2186
+ if ((date !== 0 && !date) || (date instanceof Array && date.length === 0))
2187
+ return self.clear(triggerChange);
2188
+ setSelectedDate(date, format);
2189
+ self.latestSelectedDateObj =
2190
+ self.selectedDates[self.selectedDates.length - 1];
2191
+ self.redraw();
2192
+ jumpToDate(undefined, triggerChange);
2193
+ setHoursFromDate();
2194
+ if (self.selectedDates.length === 0) {
2195
+ self.clear(false);
2196
+ }
2197
+ updateValue(triggerChange);
2198
+ if (triggerChange)
2199
+ triggerEvent("onChange");
2200
+ }
2201
+ function parseDateRules(arr) {
2202
+ return arr
2203
+ .slice()
2204
+ .map(function (rule) {
2205
+ if (typeof rule === "string" ||
2206
+ typeof rule === "number" ||
2207
+ rule instanceof Date) {
2208
+ return self.parseDate(rule, undefined, true);
2209
+ }
2210
+ else if (rule &&
2211
+ typeof rule === "object" &&
2212
+ rule.from &&
2213
+ rule.to)
2214
+ return {
2215
+ from: self.parseDate(rule.from, undefined),
2216
+ to: self.parseDate(rule.to, undefined),
2217
+ };
2218
+ return rule;
2219
+ })
2220
+ .filter(function (x) { return x; });
2221
+ }
2222
+ function setupDates() {
2223
+ self.selectedDates = [];
2224
+ self.now = self.parseDate(self.config.now) || new Date();
2225
+ var preloadedDate = self.config.defaultDate ||
2226
+ ((self.input.nodeName === "INPUT" ||
2227
+ self.input.nodeName === "TEXTAREA") &&
2228
+ self.input.placeholder &&
2229
+ self.input.value === self.input.placeholder
2230
+ ? null
2231
+ : self.input.value);
2232
+ if (preloadedDate)
2233
+ setSelectedDate(preloadedDate, self.config.dateFormat);
2234
+ self._initialDate =
2235
+ self.selectedDates.length > 0
2236
+ ? self.selectedDates[0]
2237
+ : self.config.minDate &&
2238
+ self.config.minDate.getTime() > self.now.getTime()
2239
+ ? self.config.minDate
2240
+ : self.config.maxDate &&
2241
+ self.config.maxDate.getTime() < self.now.getTime()
2242
+ ? self.config.maxDate
2243
+ : self.now;
2244
+ self.currentYear = self._initialDate.getFullYear();
2245
+ self.currentMonth = self._initialDate.getMonth();
2246
+ if (self.selectedDates.length > 0)
2247
+ self.latestSelectedDateObj = self.selectedDates[0];
2248
+ if (self.config.minTime !== undefined)
2249
+ self.config.minTime = self.parseDate(self.config.minTime, "H:i");
2250
+ if (self.config.maxTime !== undefined)
2251
+ self.config.maxTime = self.parseDate(self.config.maxTime, "H:i");
2252
+ self.minDateHasTime =
2253
+ !!self.config.minDate &&
2254
+ (self.config.minDate.getHours() > 0 ||
2255
+ self.config.minDate.getMinutes() > 0 ||
2256
+ self.config.minDate.getSeconds() > 0);
2257
+ self.maxDateHasTime =
2258
+ !!self.config.maxDate &&
2259
+ (self.config.maxDate.getHours() > 0 ||
2260
+ self.config.maxDate.getMinutes() > 0 ||
2261
+ self.config.maxDate.getSeconds() > 0);
2262
+ }
2263
+ function setupInputs() {
2264
+ self.input = getInputElem();
2265
+ if (!self.input) {
2266
+ self.config.errorHandler(new Error("Invalid input element specified"));
2267
+ return;
2268
+ }
2269
+ self.input._type = self.input.type;
2270
+ self.input.type = "text";
2271
+ self.input.classList.add("flatpickr-input");
2272
+ self._input = self.input;
2273
+ if (self.config.altInput) {
2274
+ self.altInput = createElement(self.input.nodeName, self.config.altInputClass);
2275
+ self._input = self.altInput;
2276
+ self.altInput.placeholder = self.input.placeholder;
2277
+ self.altInput.disabled = self.input.disabled;
2278
+ self.altInput.required = self.input.required;
2279
+ self.altInput.tabIndex = self.input.tabIndex;
2280
+ self.altInput.type = "text";
2281
+ self.input.setAttribute("type", "hidden");
2282
+ if (!self.config.static && self.input.parentNode)
2283
+ self.input.parentNode.insertBefore(self.altInput, self.input.nextSibling);
2284
+ }
2285
+ if (!self.config.allowInput)
2286
+ self._input.setAttribute("readonly", "readonly");
2287
+ updatePositionElement();
2288
+ }
2289
+ function updatePositionElement() {
2290
+ self._positionElement = self.config.positionElement || self._input;
2291
+ }
2292
+ function setupMobile() {
2293
+ var inputType = self.config.enableTime
2294
+ ? self.config.noCalendar
2295
+ ? "time"
2296
+ : "datetime-local"
2297
+ : "date";
2298
+ self.mobileInput = createElement("input", self.input.className + " flatpickr-mobile");
2299
+ self.mobileInput.tabIndex = 1;
2300
+ self.mobileInput.type = inputType;
2301
+ self.mobileInput.disabled = self.input.disabled;
2302
+ self.mobileInput.required = self.input.required;
2303
+ self.mobileInput.placeholder = self.input.placeholder;
2304
+ self.mobileFormatStr =
2305
+ inputType === "datetime-local"
2306
+ ? "Y-m-d\\TH:i:S"
2307
+ : inputType === "date"
2308
+ ? "Y-m-d"
2309
+ : "H:i:S";
2310
+ if (self.selectedDates.length > 0) {
2311
+ self.mobileInput.defaultValue = self.mobileInput.value = self.formatDate(self.selectedDates[0], self.mobileFormatStr);
2312
+ }
2313
+ if (self.config.minDate)
2314
+ self.mobileInput.min = self.formatDate(self.config.minDate, "Y-m-d");
2315
+ if (self.config.maxDate)
2316
+ self.mobileInput.max = self.formatDate(self.config.maxDate, "Y-m-d");
2317
+ if (self.input.getAttribute("step"))
2318
+ self.mobileInput.step = String(self.input.getAttribute("step"));
2319
+ self.input.type = "hidden";
2320
+ if (self.altInput !== undefined)
2321
+ self.altInput.type = "hidden";
2322
+ try {
2323
+ if (self.input.parentNode)
2324
+ self.input.parentNode.insertBefore(self.mobileInput, self.input.nextSibling);
2325
+ }
2326
+ catch (_a) { }
2327
+ bind(self.mobileInput, "change", function (e) {
2328
+ self.setDate(getEventTarget(e).value, false, self.mobileFormatStr);
2329
+ triggerEvent("onChange");
2330
+ triggerEvent("onClose");
2331
+ });
2332
+ }
2333
+ function toggle(e) {
2334
+ if (self.isOpen === true)
2335
+ return self.close();
2336
+ self.open(e);
2337
+ }
2338
+ function triggerEvent(event, data) {
2339
+ if (self.config === undefined)
2340
+ return;
2341
+ var hooks = self.config[event];
2342
+ if (hooks !== undefined && hooks.length > 0) {
2343
+ for (var i = 0; hooks[i] && i < hooks.length; i++)
2344
+ hooks[i](self.selectedDates, self.input.value, self, data);
2345
+ }
2346
+ if (event === "onChange") {
2347
+ self.input.dispatchEvent(createEvent("change"));
2348
+ self.input.dispatchEvent(createEvent("input"));
2349
+ }
2350
+ }
2351
+ function createEvent(name) {
2352
+ var e = document.createEvent("Event");
2353
+ e.initEvent(name, true, true);
2354
+ return e;
2355
+ }
2356
+ function isDateSelected(date) {
2357
+ for (var i = 0; i < self.selectedDates.length; i++) {
2358
+ var selectedDate = self.selectedDates[i];
2359
+ if (selectedDate instanceof Date &&
2360
+ compareDates(selectedDate, date) === 0)
2361
+ return "" + i;
2362
+ }
2363
+ return false;
2364
+ }
2365
+ function isDateInRange(date) {
2366
+ if (self.config.mode !== "range" || self.selectedDates.length < 2)
2367
+ return false;
2368
+ return (compareDates(date, self.selectedDates[0]) >= 0 &&
2369
+ compareDates(date, self.selectedDates[1]) <= 0);
2370
+ }
2371
+ function updateNavigationCurrentMonth() {
2372
+ if (self.config.noCalendar || self.isMobile || !self.monthNav)
2373
+ return;
2374
+ self.yearElements.forEach(function (yearElement, i) {
2375
+ var d = new Date(self.currentYear, self.currentMonth, 1);
2376
+ d.setMonth(self.currentMonth + i);
2377
+ if (self.config.showMonths > 1 ||
2378
+ self.config.monthSelectorType === "static") {
2379
+ self.monthElements[i].textContent =
2380
+ monthToStr(d.getMonth(), self.config.shorthandCurrentMonth, self.l10n) + " ";
2381
+ }
2382
+ else {
2383
+ self.monthsDropdownContainer.value = d.getMonth().toString();
2384
+ }
2385
+ yearElement.value = d.getFullYear().toString();
2386
+ });
2387
+ self._hidePrevMonthArrow =
2388
+ self.config.minDate !== undefined &&
2389
+ (self.currentYear === self.config.minDate.getFullYear()
2390
+ ? self.currentMonth <= self.config.minDate.getMonth()
2391
+ : self.currentYear < self.config.minDate.getFullYear());
2392
+ self._hideNextMonthArrow =
2393
+ self.config.maxDate !== undefined &&
2394
+ (self.currentYear === self.config.maxDate.getFullYear()
2395
+ ? self.currentMonth + 1 > self.config.maxDate.getMonth()
2396
+ : self.currentYear > self.config.maxDate.getFullYear());
2397
+ }
2398
+ function getDateStr(specificFormat) {
2399
+ var format = specificFormat ||
2400
+ (self.config.altInput ? self.config.altFormat : self.config.dateFormat);
2401
+ return self.selectedDates
2402
+ .map(function (dObj) { return self.formatDate(dObj, format); })
2403
+ .filter(function (d, i, arr) {
2404
+ return self.config.mode !== "range" ||
2405
+ self.config.enableTime ||
2406
+ arr.indexOf(d) === i;
2407
+ })
2408
+ .join(self.config.mode !== "range"
2409
+ ? self.config.conjunction
2410
+ : self.l10n.rangeSeparator);
2411
+ }
2412
+ function updateValue(triggerChange) {
2413
+ if (triggerChange === void 0) { triggerChange = true; }
2414
+ if (self.mobileInput !== undefined && self.mobileFormatStr) {
2415
+ self.mobileInput.value =
2416
+ self.latestSelectedDateObj !== undefined
2417
+ ? self.formatDate(self.latestSelectedDateObj, self.mobileFormatStr)
2418
+ : "";
2419
+ }
2420
+ self.input.value = getDateStr(self.config.dateFormat);
2421
+ if (self.altInput !== undefined) {
2422
+ self.altInput.value = getDateStr(self.config.altFormat);
2423
+ }
2424
+ if (triggerChange !== false)
2425
+ triggerEvent("onValueUpdate");
2426
+ }
2427
+ function onMonthNavClick(e) {
2428
+ var eventTarget = getEventTarget(e);
2429
+ var isPrevMonth = self.prevMonthNav.contains(eventTarget);
2430
+ var isNextMonth = self.nextMonthNav.contains(eventTarget);
2431
+ if (isPrevMonth || isNextMonth) {
2432
+ changeMonth(isPrevMonth ? -1 : 1);
2433
+ }
2434
+ else if (self.yearElements.indexOf(eventTarget) >= 0) {
2435
+ eventTarget.select();
2436
+ }
2437
+ else if (eventTarget.classList.contains("arrowUp")) {
2438
+ self.changeYear(self.currentYear + 1);
2439
+ }
2440
+ else if (eventTarget.classList.contains("arrowDown")) {
2441
+ self.changeYear(self.currentYear - 1);
2442
+ }
2443
+ }
2444
+ function timeWrapper(e) {
2445
+ e.preventDefault();
2446
+ var isKeyDown = e.type === "keydown", eventTarget = getEventTarget(e), input = eventTarget;
2447
+ if (self.amPM !== undefined && eventTarget === self.amPM) {
2448
+ self.amPM.textContent =
2449
+ self.l10n.amPM[int(self.amPM.textContent === self.l10n.amPM[0])];
2450
+ }
2451
+ var min = parseFloat(input.getAttribute("min")), max = parseFloat(input.getAttribute("max")), step = parseFloat(input.getAttribute("step")), curValue = parseInt(input.value, 10), delta = e.delta ||
2452
+ (isKeyDown ? (e.which === 38 ? 1 : -1) : 0);
2453
+ var newValue = curValue + step * delta;
2454
+ if (typeof input.value !== "undefined" && input.value.length === 2) {
2455
+ var isHourElem = input === self.hourElement, isMinuteElem = input === self.minuteElement;
2456
+ if (newValue < min) {
2457
+ newValue =
2458
+ max +
2459
+ newValue +
2460
+ int(!isHourElem) +
2461
+ (int(isHourElem) && int(!self.amPM));
2462
+ if (isMinuteElem)
2463
+ incrementNumInput(undefined, -1, self.hourElement);
2464
+ }
2465
+ else if (newValue > max) {
2466
+ newValue =
2467
+ input === self.hourElement ? newValue - max - int(!self.amPM) : min;
2468
+ if (isMinuteElem)
2469
+ incrementNumInput(undefined, 1, self.hourElement);
2470
+ }
2471
+ if (self.amPM &&
2472
+ isHourElem &&
2473
+ (step === 1
2474
+ ? newValue + curValue === 23
2475
+ : Math.abs(newValue - curValue) > step)) {
2476
+ self.amPM.textContent =
2477
+ self.l10n.amPM[int(self.amPM.textContent === self.l10n.amPM[0])];
2478
+ }
2479
+ input.value = pad(newValue);
2480
+ }
2481
+ }
2482
+ init();
2483
+ return self;
2484
+ }
2485
+ function _flatpickr(nodeList, config) {
2486
+ var nodes = Array.prototype.slice
2487
+ .call(nodeList)
2488
+ .filter(function (x) { return x instanceof HTMLElement; });
2489
+ var instances = [];
2490
+ for (var i = 0; i < nodes.length; i++) {
2491
+ var node = nodes[i];
2492
+ try {
2493
+ if (node.getAttribute("data-fp-omit") !== null)
2494
+ continue;
2495
+ if (node._flatpickr !== undefined) {
2496
+ node._flatpickr.destroy();
2497
+ node._flatpickr = undefined;
2498
+ }
2499
+ node._flatpickr = FlatpickrInstance(node, config || {});
2500
+ instances.push(node._flatpickr);
2501
+ }
2502
+ catch (e) {
2503
+ console.error(e);
2504
+ }
2505
+ }
2506
+ return instances.length === 1 ? instances[0] : instances;
2507
+ }
2508
+ if (typeof HTMLElement !== "undefined" &&
2509
+ typeof HTMLCollection !== "undefined" &&
2510
+ typeof NodeList !== "undefined") {
2511
+ HTMLCollection.prototype.flatpickr = NodeList.prototype.flatpickr = function (config) {
2512
+ return _flatpickr(this, config);
2513
+ };
2514
+ HTMLElement.prototype.flatpickr = function (config) {
2515
+ return _flatpickr([this], config);
2516
+ };
2517
+ }
2518
+ var flatpickr = function (selector, config) {
2519
+ if (typeof selector === "string") {
2520
+ return _flatpickr(window.document.querySelectorAll(selector), config);
2521
+ }
2522
+ else if (selector instanceof Node) {
2523
+ return _flatpickr([selector], config);
2524
+ }
2525
+ else {
2526
+ return _flatpickr(selector, config);
2527
+ }
2528
+ };
2529
+ flatpickr.defaultConfig = {};
2530
+ flatpickr.l10ns = {
2531
+ en: __assign({}, english),
2532
+ default: __assign({}, english),
2533
+ };
2534
+ flatpickr.localize = function (l10n) {
2535
+ flatpickr.l10ns.default = __assign(__assign({}, flatpickr.l10ns.default), l10n);
2536
+ };
2537
+ flatpickr.setDefaults = function (config) {
2538
+ flatpickr.defaultConfig = __assign(__assign({}, flatpickr.defaultConfig), config);
2539
+ };
2540
+ flatpickr.parseDate = createDateParser({});
2541
+ flatpickr.formatDate = createDateFormatter({});
2542
+ flatpickr.compareDates = compareDates;
2543
+ if (typeof jQuery !== "undefined" && typeof jQuery.fn !== "undefined") {
2544
+ jQuery.fn.flatpickr = function (config) {
2545
+ return _flatpickr(this, config);
2546
+ };
2547
+ }
2548
+ Date.prototype.fp_incr = function (days) {
2549
+ return new Date(this.getFullYear(), this.getMonth(), this.getDate() + (typeof days === "string" ? parseInt(days, 10) : days));
2550
+ };
2551
+ if (typeof window !== "undefined") {
2552
+ window.flatpickr = flatpickr;
2553
+ }
2554
+
2555
+ const sallaDatetimePickerCss = ".flatpickr-calendar{background:transparent;opacity:0;display:none;text-align:center;visibility:hidden;padding:0;-webkit-animation:none;animation:none;direction:ltr;border:0;font-size:14px;line-height:24px;border-radius:5px;position:absolute;width:307.875px;-webkit-box-sizing:border-box;box-sizing:border-box;-ms-touch-action:manipulation;touch-action:manipulation;background:#fff;-webkit-box-shadow:1px 0 0 #e6e6e6,-1px 0 0 #e6e6e6,0 1px 0 #e6e6e6,0 -1px 0 #e6e6e6,0 3px 13px rgba(0,0,0,0.08);box-shadow:1px 0 0 #e6e6e6,-1px 0 0 #e6e6e6,0 1px 0 #e6e6e6,0 -1px 0 #e6e6e6,0 3px 13px rgba(0,0,0,0.08)}.flatpickr-calendar.open,.flatpickr-calendar.inline{opacity:1;max-height:640px;visibility:visible}.flatpickr-calendar.open{display:inline-block;z-index:99999}.flatpickr-calendar.animate.open{-webkit-animation:fpFadeInDown 300ms cubic-bezier(.23,1,.32,1);animation:fpFadeInDown 300ms cubic-bezier(.23,1,.32,1)}.flatpickr-calendar.inline{display:block;position:relative;top:2px}.flatpickr-calendar.static{position:absolute;top:calc(100% + 2px)}.flatpickr-calendar.static.open{z-index:999;display:block}.flatpickr-calendar.multiMonth .flatpickr-days .dayContainer:nth-child(n+1) .flatpickr-day.inRange:nth-child(7n+7){-webkit-box-shadow:none !important;box-shadow:none !important}.flatpickr-calendar.multiMonth .flatpickr-days .dayContainer:nth-child(n+2) .flatpickr-day.inRange:nth-child(7n+1){-webkit-box-shadow:-2px 0 0 #e6e6e6,5px 0 0 #e6e6e6;box-shadow:-2px 0 0 #e6e6e6,5px 0 0 #e6e6e6}.flatpickr-calendar .hasWeeks .dayContainer,.flatpickr-calendar .hasTime .dayContainer{border-bottom:0;border-bottom-right-radius:0;border-bottom-left-radius:0}.flatpickr-calendar .hasWeeks .dayContainer{border-left:0}.flatpickr-calendar.hasTime .flatpickr-time{height:40px;border-top:1px solid #e6e6e6}.flatpickr-calendar.noCalendar.hasTime .flatpickr-time{height:auto}.flatpickr-calendar:before,.flatpickr-calendar:after{position:absolute;display:block;pointer-events:none;border:solid transparent;content:'';height:0;width:0;left:22px}.flatpickr-calendar.rightMost:before,.flatpickr-calendar.arrowRight:before,.flatpickr-calendar.rightMost:after,.flatpickr-calendar.arrowRight:after{left:auto;right:22px}.flatpickr-calendar.arrowCenter:before,.flatpickr-calendar.arrowCenter:after{left:50%;right:50%}.flatpickr-calendar:before{border-width:5px;margin:0 -5px}.flatpickr-calendar:after{border-width:4px;margin:0 -4px}.flatpickr-calendar.arrowTop:before,.flatpickr-calendar.arrowTop:after{bottom:100%}.flatpickr-calendar.arrowTop:before{border-bottom-color:#e6e6e6}.flatpickr-calendar.arrowTop:after{border-bottom-color:#fff}.flatpickr-calendar.arrowBottom:before,.flatpickr-calendar.arrowBottom:after{top:100%}.flatpickr-calendar.arrowBottom:before{border-top-color:#e6e6e6}.flatpickr-calendar.arrowBottom:after{border-top-color:#fff}.flatpickr-calendar:focus{outline:0}.flatpickr-wrapper{position:relative;display:inline-block}.flatpickr-months{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex}.flatpickr-months .flatpickr-month{background:transparent;color:rgba(0,0,0,0.9);fill:rgba(0,0,0,0.9);height:34px;line-height:1;text-align:center;position:relative;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;overflow:hidden;-webkit-box-flex:1;-webkit-flex:1;-ms-flex:1;flex:1}.flatpickr-months .flatpickr-prev-month,.flatpickr-months .flatpickr-next-month{-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;text-decoration:none;cursor:pointer;position:absolute;top:0;height:34px;padding:10px;z-index:3;color:rgba(0,0,0,0.9);fill:rgba(0,0,0,0.9)}.flatpickr-months .flatpickr-prev-month.flatpickr-disabled,.flatpickr-months .flatpickr-next-month.flatpickr-disabled{display:none}.flatpickr-months .flatpickr-prev-month i,.flatpickr-months .flatpickr-next-month i{position:relative}.flatpickr-months .flatpickr-prev-month.flatpickr-prev-month,.flatpickr-months .flatpickr-next-month.flatpickr-prev-month{left:0}.flatpickr-months .flatpickr-prev-month.flatpickr-next-month,.flatpickr-months .flatpickr-next-month.flatpickr-next-month{right:0}.flatpickr-months .flatpickr-prev-month:hover,.flatpickr-months .flatpickr-next-month:hover{color:#959ea9}.flatpickr-months .flatpickr-prev-month:hover svg,.flatpickr-months .flatpickr-next-month:hover svg{fill:#f64747}.flatpickr-months .flatpickr-prev-month svg,.flatpickr-months .flatpickr-next-month svg{width:14px;height:14px}.flatpickr-months .flatpickr-prev-month svg path,.flatpickr-months .flatpickr-next-month svg path{-webkit-transition:fill .1s;transition:fill .1s;fill:inherit}.numInputWrapper{position:relative;height:auto}.numInputWrapper input,.numInputWrapper span{display:inline-block}.numInputWrapper input{width:100%}.numInputWrapper input::-ms-clear{display:none}.numInputWrapper input::-webkit-outer-spin-button,.numInputWrapper input::-webkit-inner-spin-button{margin:0;-webkit-appearance:none}.numInputWrapper span{position:absolute;right:0;width:14px;padding:0 4px 0 2px;height:50%;line-height:50%;opacity:0;cursor:pointer;border:1px solid rgba(57,57,57,0.15);-webkit-box-sizing:border-box;box-sizing:border-box}.numInputWrapper span:hover{background:rgba(0,0,0,0.1)}.numInputWrapper span:active{background:rgba(0,0,0,0.2)}.numInputWrapper span:after{display:block;content:\"\";position:absolute}.numInputWrapper span.arrowUp{top:0;border-bottom:0}.numInputWrapper span.arrowUp:after{border-left:4px solid transparent;border-right:4px solid transparent;border-bottom:4px solid rgba(57,57,57,0.6);top:26%}.numInputWrapper span.arrowDown{top:50%}.numInputWrapper span.arrowDown:after{border-left:4px solid transparent;border-right:4px solid transparent;border-top:4px solid rgba(57,57,57,0.6);top:40%}.numInputWrapper span svg{width:inherit;height:auto}.numInputWrapper span svg path{fill:rgba(0,0,0,0.5)}.numInputWrapper:hover{background:rgba(0,0,0,0.05)}.numInputWrapper:hover span{opacity:1}.flatpickr-current-month{font-size:135%;line-height:inherit;font-weight:300;color:inherit;position:absolute;width:75%;left:12.5%;padding:7.48px 0 0 0;line-height:1;height:34px;display:inline-block;text-align:center;-webkit-transform:translate3d(0,0,0);transform:translate3d(0,0,0)}.flatpickr-current-month span.cur-month{font-family:inherit;font-weight:700;color:inherit;display:inline-block;margin-left:.5ch;padding:0}.flatpickr-current-month span.cur-month:hover{background:rgba(0,0,0,0.05)}.flatpickr-current-month .numInputWrapper{width:6ch;width:7ch\\0;display:inline-block}.flatpickr-current-month .numInputWrapper span.arrowUp:after{border-bottom-color:rgba(0,0,0,0.9)}.flatpickr-current-month .numInputWrapper span.arrowDown:after{border-top-color:rgba(0,0,0,0.9)}.flatpickr-current-month input.cur-year{background:transparent;-webkit-box-sizing:border-box;box-sizing:border-box;color:inherit;cursor:text;padding:0 0 0 .5ch;margin:0;display:inline-block;font-size:inherit;font-family:inherit;font-weight:300;line-height:inherit;height:auto;border:0;border-radius:0;vertical-align:initial;-webkit-appearance:textfield;-moz-appearance:textfield;appearance:textfield}.flatpickr-current-month input.cur-year:focus{outline:0}.flatpickr-current-month input.cur-year[disabled],.flatpickr-current-month input.cur-year[disabled]:hover{font-size:100%;color:rgba(0,0,0,0.5);background:transparent;pointer-events:none}.flatpickr-current-month .flatpickr-monthDropdown-months{appearance:menulist;background:transparent;border:none;border-radius:0;box-sizing:border-box;color:inherit;cursor:pointer;font-size:inherit;font-family:inherit;font-weight:300;height:auto;line-height:inherit;margin:-1px 0 0 0;outline:none;padding:0 0 0 .5ch;position:relative;vertical-align:initial;-webkit-box-sizing:border-box;-webkit-appearance:menulist;-moz-appearance:menulist;width:auto}.flatpickr-current-month .flatpickr-monthDropdown-months:focus,.flatpickr-current-month .flatpickr-monthDropdown-months:active{outline:none}.flatpickr-current-month .flatpickr-monthDropdown-months:hover{background:rgba(0,0,0,0.05)}.flatpickr-current-month .flatpickr-monthDropdown-months .flatpickr-monthDropdown-month{background-color:transparent;outline:none;padding:0}.flatpickr-weekdays{background:transparent;text-align:center;overflow:hidden;width:100%;display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-box-align:center;-webkit-align-items:center;-ms-flex-align:center;align-items:center;height:28px}.flatpickr-weekdays .flatpickr-weekdaycontainer{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-box-flex:1;-webkit-flex:1;-ms-flex:1;flex:1}span.flatpickr-weekday{cursor:default;font-size:90%;background:transparent;color:rgba(0,0,0,0.54);line-height:1;margin:0;text-align:center;display:block;-webkit-box-flex:1;-webkit-flex:1;-ms-flex:1;flex:1;font-weight:bolder}.dayContainer,.flatpickr-weeks{padding:1px 0 0 0}.flatpickr-days{position:relative;overflow:hidden;display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-box-align:start;-webkit-align-items:flex-start;-ms-flex-align:start;align-items:flex-start;width:307.875px}.flatpickr-days:focus{outline:0}.dayContainer{padding:0;outline:0;text-align:left;width:307.875px;min-width:307.875px;max-width:307.875px;-webkit-box-sizing:border-box;box-sizing:border-box;display:inline-block;display:-ms-flexbox;display:-webkit-box;display:-webkit-flex;display:flex;-webkit-flex-wrap:wrap;flex-wrap:wrap;-ms-flex-wrap:wrap;-ms-flex-pack:justify;-webkit-justify-content:space-around;justify-content:space-around;-webkit-transform:translate3d(0,0,0);transform:translate3d(0,0,0);opacity:1}.dayContainer+.dayContainer{-webkit-box-shadow:-1px 0 0 #e6e6e6;box-shadow:-1px 0 0 #e6e6e6}.flatpickr-day{background:none;border:1px solid transparent;border-radius:150px;-webkit-box-sizing:border-box;box-sizing:border-box;color:#393939;cursor:pointer;font-weight:400;width:14.2857143%;-webkit-flex-basis:14.2857143%;-ms-flex-preferred-size:14.2857143%;flex-basis:14.2857143%;max-width:39px;height:39px;line-height:39px;margin:0;display:inline-block;position:relative;-webkit-box-pack:center;-webkit-justify-content:center;-ms-flex-pack:center;justify-content:center;text-align:center}.flatpickr-day.inRange,.flatpickr-day.prevMonthDay.inRange,.flatpickr-day.nextMonthDay.inRange,.flatpickr-day.today.inRange,.flatpickr-day.prevMonthDay.today.inRange,.flatpickr-day.nextMonthDay.today.inRange,.flatpickr-day:hover,.flatpickr-day.prevMonthDay:hover,.flatpickr-day.nextMonthDay:hover,.flatpickr-day:focus,.flatpickr-day.prevMonthDay:focus,.flatpickr-day.nextMonthDay:focus{cursor:pointer;outline:0;background:#e6e6e6;border-color:#e6e6e6}.flatpickr-day.today{border-color:#959ea9}.flatpickr-day.today:hover,.flatpickr-day.today:focus{border-color:#959ea9;background:#959ea9;color:#fff}.flatpickr-day.selected,.flatpickr-day.startRange,.flatpickr-day.endRange,.flatpickr-day.selected.inRange,.flatpickr-day.startRange.inRange,.flatpickr-day.endRange.inRange,.flatpickr-day.selected:focus,.flatpickr-day.startRange:focus,.flatpickr-day.endRange:focus,.flatpickr-day.selected:hover,.flatpickr-day.startRange:hover,.flatpickr-day.endRange:hover,.flatpickr-day.selected.prevMonthDay,.flatpickr-day.startRange.prevMonthDay,.flatpickr-day.endRange.prevMonthDay,.flatpickr-day.selected.nextMonthDay,.flatpickr-day.startRange.nextMonthDay,.flatpickr-day.endRange.nextMonthDay{background:#569ff7;-webkit-box-shadow:none;box-shadow:none;color:#fff;border-color:#569ff7}.flatpickr-day.selected.startRange,.flatpickr-day.startRange.startRange,.flatpickr-day.endRange.startRange{border-radius:50px 0 0 50px}.flatpickr-day.selected.endRange,.flatpickr-day.startRange.endRange,.flatpickr-day.endRange.endRange{border-radius:0 50px 50px 0}.flatpickr-day.selected.startRange+.endRange:not(:nth-child(7n+1)),.flatpickr-day.startRange.startRange+.endRange:not(:nth-child(7n+1)),.flatpickr-day.endRange.startRange+.endRange:not(:nth-child(7n+1)){-webkit-box-shadow:-10px 0 0 #569ff7;box-shadow:-10px 0 0 #569ff7}.flatpickr-day.selected.startRange.endRange,.flatpickr-day.startRange.startRange.endRange,.flatpickr-day.endRange.startRange.endRange{border-radius:50px}.flatpickr-day.inRange{border-radius:0;-webkit-box-shadow:-5px 0 0 #e6e6e6,5px 0 0 #e6e6e6;box-shadow:-5px 0 0 #e6e6e6,5px 0 0 #e6e6e6}.flatpickr-day.flatpickr-disabled,.flatpickr-day.flatpickr-disabled:hover,.flatpickr-day.prevMonthDay,.flatpickr-day.nextMonthDay,.flatpickr-day.notAllowed,.flatpickr-day.notAllowed.prevMonthDay,.flatpickr-day.notAllowed.nextMonthDay{color:rgba(57,57,57,0.3);background:transparent;border-color:transparent;cursor:default}.flatpickr-day.flatpickr-disabled,.flatpickr-day.flatpickr-disabled:hover{cursor:not-allowed;color:rgba(57,57,57,0.1)}.flatpickr-day.week.selected{border-radius:0;-webkit-box-shadow:-5px 0 0 #569ff7,5px 0 0 #569ff7;box-shadow:-5px 0 0 #569ff7,5px 0 0 #569ff7}.flatpickr-day.hidden{visibility:hidden}.rangeMode .flatpickr-day{margin-top:1px}.flatpickr-weekwrapper{float:left}.flatpickr-weekwrapper .flatpickr-weeks{padding:0 12px;-webkit-box-shadow:1px 0 0 #e6e6e6;box-shadow:1px 0 0 #e6e6e6}.flatpickr-weekwrapper .flatpickr-weekday{float:none;width:100%;line-height:28px}.flatpickr-weekwrapper span.flatpickr-day,.flatpickr-weekwrapper span.flatpickr-day:hover{display:block;width:100%;max-width:none;color:rgba(57,57,57,0.3);background:transparent;cursor:default;border:none}.flatpickr-innerContainer{display:block;display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-box-sizing:border-box;box-sizing:border-box;overflow:hidden}.flatpickr-rContainer{display:inline-block;padding:0;-webkit-box-sizing:border-box;box-sizing:border-box}.flatpickr-time{text-align:center;outline:0;display:block;height:0;line-height:40px;max-height:40px;-webkit-box-sizing:border-box;box-sizing:border-box;overflow:hidden;display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex}.flatpickr-time:after{content:\"\";display:table;clear:both}.flatpickr-time .numInputWrapper{-webkit-box-flex:1;-webkit-flex:1;-ms-flex:1;flex:1;width:40%;height:40px;float:left}.flatpickr-time .numInputWrapper span.arrowUp:after{border-bottom-color:#393939}.flatpickr-time .numInputWrapper span.arrowDown:after{border-top-color:#393939}.flatpickr-time.hasSeconds .numInputWrapper{width:26%}.flatpickr-time.time24hr .numInputWrapper{width:49%}.flatpickr-time input{background:transparent;-webkit-box-shadow:none;box-shadow:none;border:0;border-radius:0;text-align:center;margin:0;padding:0;height:inherit;line-height:inherit;color:#393939;font-size:14px;position:relative;-webkit-box-sizing:border-box;box-sizing:border-box;-webkit-appearance:textfield;-moz-appearance:textfield;appearance:textfield}.flatpickr-time input.flatpickr-hour{font-weight:bold}.flatpickr-time input.flatpickr-minute,.flatpickr-time input.flatpickr-second{font-weight:400}.flatpickr-time input:focus{outline:0;border:0}.flatpickr-time .flatpickr-time-separator,.flatpickr-time .flatpickr-am-pm{height:inherit;float:left;line-height:inherit;color:#393939;font-weight:bold;width:2%;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;-webkit-align-self:center;-ms-flex-item-align:center;align-self:center}.flatpickr-time .flatpickr-am-pm{outline:0;width:18%;cursor:pointer;text-align:center;font-weight:400}.flatpickr-time input:hover,.flatpickr-time .flatpickr-am-pm:hover,.flatpickr-time input:focus,.flatpickr-time .flatpickr-am-pm:focus{background:#eee}.flatpickr-input[readonly]{cursor:pointer}@-webkit-keyframes fpFadeInDown{from{opacity:0;-webkit-transform:translate3d(0,-20px,0);transform:translate3d(0,-20px,0)}to{opacity:1;-webkit-transform:translate3d(0,0,0);transform:translate3d(0,0,0)}}@keyframes fpFadeInDown{from{opacity:0;-webkit-transform:translate3d(0,-20px,0);transform:translate3d(0,-20px,0)}to{opacity:1;-webkit-transform:translate3d(0,0,0);transform:translate3d(0,0,0)}}";
2556
+
2557
+ const SallaDatetimePicker = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement$1 {
2558
+ constructor() {
2559
+ super();
2560
+ this.__registerHost();
2561
+ this.picked = createEvent(this, "picked", 7);
2562
+ /**
2563
+ * Two way data binding to retrieve the selected date[time] value
2564
+ */
2565
+ this.value = null;
2566
+ /**
2567
+ * Placeholder text to show on the input element
2568
+ */
2569
+ this.placeholder = salla.lang.get('blocks.buy_as_gift.select_send_date_and_time');
2570
+ /**
2571
+ * Allows the user to enter a date directly into the input field. By default, direct entry is disabled.
2572
+ */
2573
+ this.allowInput = false;
2574
+ /**
2575
+ * Allows the preloading of an invalid date. When disabled, the field will be cleared if the provided date is invalid
2576
+ */
2577
+ this.allowInvalidPreload = false;
2578
+ /**
2579
+ * Exactly the same as date format, but for the altInput field.
2580
+ */
2581
+ this.altFormat = "F j, Y";
2582
+ /**
2583
+ * Show the user a readable date (as per altFormat), but return something totally different to the server.
2584
+ */
2585
+ this.altInput = false;
2586
+ /**
2587
+ * Instead of body, appends the calendar to the specified node instead.
2588
+ */
2589
+ this.appendTo = undefined;
2590
+ /**
2591
+ * Defines how the date will be formatted in the aria-label for calendar days,
2592
+ * using the same tokens as dateFormat. If you change this, you should choose a
2593
+ * value that will make sense if a screen reader reads it out loud.
2594
+ */
2595
+ this.ariaDateFormat = "F j, Y";
2596
+ /**
2597
+ * Whether the default time should be auto-filled when the input is empty and gains or loses focus.
2598
+ */
2599
+ this.autoFillDefaultTime = true;
2600
+ /**
2601
+ * Whether clicking on the input should open the picker.
2602
+ * Set it to false if you only want to open the calendar programmatically with [open()]
2603
+ */
2604
+ this.clickOpens = true;
2605
+ /**
2606
+ * Whether calendar should close after date selection or not
2607
+ */
2608
+ this.closeOnSelect = true;
2609
+ /**
2610
+ * A string of characters which are used to define how the date will be displayed in the input box.
2611
+ * The supported characters are defined in the table below.
2612
+ */
2613
+ this.dateFormat = "Y-m-d";
2614
+ /**
2615
+ * Initial value of the hour element, when no date is selected
2616
+ */
2617
+ this.defaultHour = 12;
2618
+ /**
2619
+ * Initial value of the minute element, when no date is selected
2620
+ */
2621
+ this.defaultMinute = 0;
2622
+ /**
2623
+ * Initial value of the seconds element, when no date is selected
2624
+ */
2625
+ this.defaultSeconds = 0;
2626
+ /**
2627
+ * Disables certain dates, preventing them from being selected.
2628
+ * See https://chmln.github.io/flatpickr/examples/#disabling-specific-dates
2629
+ */
2630
+ this.disable = [];
2631
+ /**
2632
+ * Set this to true to always use the non-native picker on mobile devices.
2633
+ * By default, Flatpickr utilizes native datetime widgets unless certain options (e.g. disable) are used.
2634
+ */
2635
+ this.disableMobile = false;
2636
+ /**
2637
+ * Disables all dates except these specified. See https://chmln.github.io/flatpickr/examples/#disabling-all-dates-except-select-few
2638
+ */
2639
+ this.enable = [(_) => true];
2640
+ /**
2641
+ * Enables seconds selection in the time picker.
2642
+ */
2643
+ this.enableSeconds = false;
2644
+ /**
2645
+ * Enables the time picker
2646
+ */
2647
+ this.enableTime = false;
2648
+ /**
2649
+ * Adjusts the step for the hour input (incl. scrolling)
2650
+ */
2651
+ this.hourIncrement = 1;
2652
+ /**
2653
+ * Displays the calendar inline
2654
+ */
2655
+ this.inline = false;
2656
+ /**
2657
+ * The locale, either as a string (e.g. "ar", "en") or as an object.
2658
+ * See https://chmln.github.io/flatpickr/localization/
2659
+ */
2660
+ this.locale = "en";
2661
+ /**
2662
+ * The maximum date that a user can pick to (inclusive).
2663
+ */
2664
+ this.maxDate = null;
2665
+ /**
2666
+ * The minimum date that a user can start picking from (inclusive).
2667
+ */
2668
+ this.maxTime = null;
2669
+ /**
2670
+ * The minimum date that a user can start picking from (inclusive).
2671
+ */
2672
+ this.minDate = null;
2673
+ /**
2674
+ * The minimum time that a user can start picking from (inclusive).
2675
+ */
2676
+ this.minTime = null;
2677
+ /**
2678
+ * Adjusts the step for the minute input (incl. scrolling) Defaults to 5
2679
+ */
2680
+ this.minuteIncrement = 5;
2681
+ /**
2682
+ * Date selection mode, defaults to "single"
2683
+ */
2684
+ this.mode = "single";
2685
+ /**
2686
+ * How the month should be displayed in the header of the calendar.
2687
+ * If showMonths has a value greater than 1, the month is always shown as static.
2688
+ */
2689
+ this.monthSelectorType = "dropdown";
2690
+ /**
2691
+ * HTML for the arrow icon, used to switch months.
2692
+ */
2693
+ this.nextArrow = '<span class="sicon-keyboard_arrow_right"></span>';
2694
+ /**
2695
+ * Hides the day selection in calendar. Use it along with enableTime to create a time picker.
2696
+ */
2697
+ this.noCalendar = false;
2698
+ /**
2699
+ * How the calendar should be positioned with regards to the input. Defaults to "auto"
2700
+ */
2701
+ this.position = "auto";
2702
+ /**
2703
+ * HTML for the left arrow icon, used to switch months.
2704
+ */
2705
+ this.prevArrow = '<span class="sicon-keyboard_arrow_left"></span>';
2706
+ /**
2707
+ * Whether to display the current month name in shorthand mode, e.g. "Sep" instead "September"
2708
+ */
2709
+ this.shorthandCurrentMonth = false;
2710
+ /**
2711
+ * Position the calendar inside the wrapper and next to the input element*.
2712
+ */
2713
+ this.static = false;
2714
+ /**
2715
+ * The number of months to be shown at the same time when displaying the calendar.
2716
+ */
2717
+ this.showMonths = 1;
2718
+ /**
2719
+ * Displays time picker in 24 hour mode without AM/PM selection when enabled.
2720
+ */
2721
+ this.time_24hr = false;
2722
+ /**
2723
+ * Enables display of week numbers in calendar.
2724
+ */
2725
+ this.weekNumbers = false;
2726
+ /**
2727
+ * See https://chmln.github.io/flatpickr/examples/#flatpickr-external-elements
2728
+ */
2729
+ this.wrap = false;
2730
+ }
2731
+ onInputChange(event) {
2732
+ this.value = event.target.value;
2733
+ this.picked.emit(this.value);
2734
+ }
2735
+ componentDidLoad() {
2736
+ this.initPicker();
2737
+ }
2738
+ initPicker() {
2739
+ let options = {
2740
+ allowInput: this.allowInput,
2741
+ allowInvalidPreload: this.allowInvalidPreload,
2742
+ altFormat: this.altFormat,
2743
+ altInput: this.altInput,
2744
+ altInputClass: this.altInputClass,
2745
+ appendTo: this.appendTo,
2746
+ ariaDateFormat: this.ariaDateFormat,
2747
+ autoFillDefaultTime: this.autoFillDefaultTime,
2748
+ clickOpens: this.clickOpens,
2749
+ closeOnSelect: this.closeOnSelect,
2750
+ conjunction: this.conjunction,
2751
+ dateFormat: this.dateFormat,
2752
+ defaultDate: !!this.value ? Date.parse(this.value) : this.defaultDate,
2753
+ defaultHour: this.defaultHour,
2754
+ defaultMinute: this.defaultMinute,
2755
+ defaultSeconds: this.defaultSeconds,
2756
+ disable: this.disable,
2757
+ disableMobile: this.disableMobile,
2758
+ enable: this.enable,
2759
+ enableSeconds: this.enableSeconds,
2760
+ enableTime: this.enableTime,
2761
+ formatDate: this.formatDate,
2762
+ hourIncrement: this.hourIncrement,
2763
+ inline: this.inline,
2764
+ locale: this.locale,
2765
+ maxDate: this.maxDate,
2766
+ maxTime: this.maxTime,
2767
+ minDate: this.minDate,
2768
+ minTime: this.minTime,
2769
+ minuteIncrement: this.minuteIncrement,
2770
+ mode: this.mode,
2771
+ monthSelectorType: this.monthSelectorType,
2772
+ nextArrow: this.nextArrow,
2773
+ noCalendar: this.noCalendar,
2774
+ onChange: this.onChange,
2775
+ onClose: this.onClose,
2776
+ onDayCreate: this.onDayCreate,
2777
+ onDestroy: this.onDestroy,
2778
+ onKeyDown: this.onKeyDown,
2779
+ onMonthChange: this.onMonthChange,
2780
+ onOpen: this.onOpen,
2781
+ onParseConfig: this.onParseConfig,
2782
+ onReady: this.onReady,
2783
+ onValueUpdate: this.onValueUpdate,
2784
+ onYearChange: this.onYearChange,
2785
+ parseDate: this.dateParser,
2786
+ position: this.position,
2787
+ positionElement: this.positionElement,
2788
+ prevArrow: this.prevArrow,
2789
+ shorthandCurrentMonth: this.shorthandCurrentMonth,
2790
+ static: this.static,
2791
+ showMonths: this.showMonths,
2792
+ time_24hr: this.time_24hr,
2793
+ weekNumbers: this.weekNumbers,
2794
+ wrap: this.wrap,
2795
+ };
2796
+ flatpickr(this.dateInput, options);
2797
+ }
2798
+ render() {
2799
+ return (h("div", { class: "s-datetime-picker" }, h("input", { type: "datetime", class: "s-datetime-picker-input", ref: (el) => this.dateInput = el, value: this.value, placeholder: this.placeholder, onInput: this.onInputChange.bind(this) })));
2800
+ }
2801
+ static get style() { return sallaDatetimePickerCss; }
2802
+ }, [0, "salla-datetime-picker", {
2803
+ "value": [1025],
2804
+ "placeholder": [1],
2805
+ "allowInput": [4, "allow-input"],
2806
+ "allowInvalidPreload": [4, "allow-invalid-preload"],
2807
+ "altFormat": [1, "alt-format"],
2808
+ "altInput": [4, "alt-input"],
2809
+ "altInputClass": [1, "alt-input-class"],
2810
+ "appendTo": [16],
2811
+ "ariaDateFormat": [1, "aria-date-format"],
2812
+ "autoFillDefaultTime": [4, "auto-fill-default-time"],
2813
+ "clickOpens": [4, "click-opens"],
2814
+ "closeOnSelect": [4, "close-on-select"],
2815
+ "conjunction": [1],
2816
+ "dateFormat": [1, "date-format"],
2817
+ "defaultDate": [8, "default-date"],
2818
+ "defaultHour": [2, "default-hour"],
2819
+ "defaultMinute": [2, "default-minute"],
2820
+ "defaultSeconds": [2, "default-seconds"],
2821
+ "disable": [16],
2822
+ "disableMobile": [4, "disable-mobile"],
2823
+ "enable": [16],
2824
+ "enableSeconds": [4, "enable-seconds"],
2825
+ "enableTime": [4, "enable-time"],
2826
+ "formatDate": [16],
2827
+ "hourIncrement": [2, "hour-increment"],
2828
+ "inline": [4],
2829
+ "locale": [1],
2830
+ "maxDate": [8, "max-date"],
2831
+ "maxTime": [8, "max-time"],
2832
+ "minDate": [8, "min-date"],
2833
+ "minTime": [8, "min-time"],
2834
+ "minuteIncrement": [2, "minute-increment"],
2835
+ "mode": [1],
2836
+ "monthSelectorType": [1, "month-selector-type"],
2837
+ "nextArrow": [1, "next-arrow"],
2838
+ "noCalendar": [4, "no-calendar"],
2839
+ "onChange": [16],
2840
+ "onClose": [16],
2841
+ "onDayCreate": [16],
2842
+ "onDestroy": [16],
2843
+ "onKeyDown": [16],
2844
+ "onMonthChange": [16],
2845
+ "onOpen": [16],
2846
+ "onParseConfig": [16],
2847
+ "onReady": [16],
2848
+ "onValueUpdate": [16],
2849
+ "onYearChange": [16],
2850
+ "dateParser": [16],
2851
+ "position": [1],
2852
+ "positionElement": [16],
2853
+ "prevArrow": [1, "prev-arrow"],
2854
+ "shorthandCurrentMonth": [4, "shorthand-current-month"],
2855
+ "static": [4],
2856
+ "showMonths": [2, "show-months"],
2857
+ "time_24hr": [4, "time_-2-4hr"],
2858
+ "weekNumbers": [4, "week-numbers"],
2859
+ "wrap": [4]
2860
+ }]);
2861
+ function defineCustomElement() {
2862
+ if (typeof customElements === "undefined") {
2863
+ return;
2864
+ }
2865
+ const components = ["salla-datetime-picker"];
2866
+ components.forEach(tagName => { switch (tagName) {
2867
+ case "salla-datetime-picker":
2868
+ if (!customElements.get(tagName)) {
2869
+ customElements.define(tagName, SallaDatetimePicker);
2870
+ }
2871
+ break;
2872
+ } });
2873
+ }
2874
+ defineCustomElement();
2875
+
2876
+ export { SallaDatetimePicker as S, defineCustomElement as d };