1/** 2 * Skipped minification because the original files appears to be already minified. 3 * Original file: /npm/[email protected]/air-datepicker.js 4 * 5 * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files 6 */ 7!(function (e, t) { 8 "object" == typeof exports && "object" == typeof module 9 ? (module.exports = t()) 10 : "function" == typeof define && define.amd 11 ? define([], t) 12 : "object" == typeof exports 13 ? (exports.AirDatepicker = t()) 14 : (e.AirDatepicker = t()); 15})(this, function () { 16 return (function () { 17 "use strict"; 18 var e = { 19 d: function (t, i) { 20 for (var s in i) 21 e.o(i, s) && 22 !e.o(t, s) && 23 Object.defineProperty(t, s, { enumerable: !0, get: i[s] }); 24 }, 25 o: function (e, t) { 26 return Object.prototype.hasOwnProperty.call(e, t); 27 }, 28 }, 29 t = {}; 30 e.d(t, { 31 default: function () { 32 return K; 33 }, 34 }); 35 var i = { 36 days: "days", 37 months: "months", 38 years: "years", 39 day: "day", 40 month: "month", 41 year: "year", 42 eventChangeViewDate: "changeViewDate", 43 eventChangeCurrentView: "changeCurrentView", 44 eventChangeFocusDate: "changeFocusDate", 45 eventChangeSelectedDate: "changeSelectedDate", 46 eventChangeTime: "changeTime", 47 eventChangeLastSelectedDate: "changeLastSelectedDate", 48 actionSelectDate: "selectDate", 49 actionUnselectDate: "unselectDate", 50 cssClassWeekend: "-weekend-", 51 }, 52 s = { 53 classes: "", 54 inline: !1, 55 locale: { 56 days: [ 57 "ÐоÑкÑеÑенÑе", 58 "ÐонеделÑник", 59 "ÐÑоÑник", 60 "СÑеда", 61 "ЧеÑвеÑг", 62 "ÐÑÑниÑа", 63 "СÑббоÑа", 64 ], 65 daysShort: ["ÐоÑ", "Ðон", "ÐÑо", "СÑе", "ЧеÑ", "ÐÑÑ", "СÑб"], 66 daysMin: ["ÐÑ", "Ðн", "ÐÑ", "СÑ", "ЧÑ", "ÐÑ", "Сб"], 67 months: [ 68 "ЯнваÑÑ", 69 "ФевÑалÑ", 70 "ÐаÑÑ", 71 "ÐпÑелÑ", 72 "Ðай", 73 "ÐÑнÑ", 74 "ÐÑлÑ", 75 "ÐвгÑÑÑ", 76 "СенÑÑбÑÑ", 77 "ÐкÑÑбÑÑ", 78 "ÐоÑбÑÑ", 79 "ÐекабÑÑ", 80 ], 81 monthsShort: [ 82 "Янв", 83 "Фев", 84 "ÐаÑ", 85 "ÐпÑ", 86 "Ðай", 87 "ÐÑн", 88 "ÐÑл", 89 "Ðвг", 90 "Сен", 91 "ÐкÑ", 92 "ÐоÑ", 93 "Ðек", 94 ], 95 today: "СегоднÑ", 96 clear: "ÐÑиÑÑиÑÑ", 97 dateFormat: "dd.MM.yyyy", 98 timeFormat: "HH:mm", 99 firstDay: 1, 100 }, 101 startDate: new Date(), 102 firstDay: "", 103 weekends: [6, 0], 104 dateFormat: "", 105 altField: "", 106 altFieldDateFormat: "T", 107 toggleSelected: !0, 108 keyboardNav: !0, 109 selectedDates: !1, 110 container: "", 111 isMobile: !1, 112 visible: !1, 113 position: "bottom left", 114 offset: 12, 115 view: i.days, 116 minView: i.days, 117 showOtherMonths: !0, 118 selectOtherMonths: !0, 119 moveToOtherMonthsOnSelect: !0, 120 showOtherYears: !0, 121 selectOtherYears: !0, 122 moveToOtherYearsOnSelect: !0, 123 minDate: "", 124 maxDate: "", 125 disableNavWhenOutOfRange: !0, 126 multipleDates: !1, 127 multipleDatesSeparator: ", ", 128 range: !1, 129 dynamicRange: !0, 130 buttons: !1, 131 monthsField: "monthsShort", 132 showEvent: "focus", 133 autoClose: !1, 134 prevHtml: `<svg width="32" height="32" viewBox="0 0 32 32" fill="none" xmlns="http://www.w3.org/2000/svg"> 135 <rect width="32" height="32" rx="4" fill="white"/> 136 <path fill-rule="evenodd" clip-rule="evenodd" d="M20.1917 8.05862C20.2499 8.11667 20.296 8.18564 20.3276 8.26158C20.3591 8.33751 20.3753 8.41891 20.3753 8.50112C20.3753 8.58333 20.3591 8.66473 20.3276 8.74066C20.296 8.81659 20.2499 8.88556 20.1917 8.94362L13.1329 16.0011L20.1917 23.0586C20.309 23.176 20.375 23.3351 20.375 23.5011C20.375 23.6671 20.309 23.8263 20.1917 23.9436C20.0743 24.061 19.9151 24.1269 19.7492 24.1269C19.5832 24.1269 19.424 24.061 19.3067 23.9436L11.8067 16.4436C11.7485 16.3856 11.7023 16.3166 11.6708 16.2407C11.6393 16.1647 11.623 16.0833 11.623 16.0011C11.623 15.9189 11.6393 15.8375 11.6708 15.7616C11.7023 15.6856 11.7485 15.6167 11.8067 15.5586L19.3067 8.05862C19.3647 8.00041 19.4337 7.95423 19.5096 7.92273C19.5856 7.89122 19.667 7.875 19.7492 7.875C19.8314 7.875 19.9128 7.89122 19.9887 7.92273C20.0646 7.95423 20.1336 8.00041 20.1917 8.05862
136V8.05862Z" fill="#074C31"/> 137 <rect x="0.5" y="0.5" width="31" height="31" rx="3.5" stroke="black" stroke-opacity="0.1"/> 138 </svg> 139 `, 140 nextHtml: `<svg width="32" height="32" viewBox="0 0 32 32" fill="none" xmlns="http://www.w3.org/2000/svg"> 141 <rect width="32" height="32" rx="4" fill="white"/> 142 <path fill-rule="evenodd" clip-rule="evenodd" d="M11.8067 8.05862C11.8647 8.00041 11.9337 7.95423 12.0096 7.92273C12.0856 7.89122 12.167 7.875 12.2492 7.875C12.3314 7.875 12.4128 7.89122 12.4887 7.92273C12.5646 7.95423 12.6336 8.00041 12.6917 8.05862L20.1917 15.5586C20.2499 15.6167 20.296 15.6856 20.3276 15.7616C20.3591 15.8375 20.3753 15.9189 20.3753 16.0011C20.3753 16.0833 20.3591 16.1647 20.3276 16.2407C20.296 16.3166 20.2499 16.3856 20.1917 16.4436L12.6917 23.9436C12.5743 24.061 12.4151 24.1269 12.2492 24.1269C12.0832 24.1269 11.924 24.061 11.8067 23.9436C11.6893 23.8263 11.6234 23.6671 11.6234 23.5011C11.6234 23.3351 11.6893 23.176 11.8067 23.0586L18.8654 16.0011L11.8067 8.94362C11.7485 8.88556 11.7023 8.81659 11.6708 8.74066C11.6393 8.66473 11.623 8.58333 11.623 8.50112C11.623 8.41891 11.6393 8.33751 11.6708 8.26158C11.7023 8.18564 11.7485 8.11667 11.8067 8.05862V8.05862Z" fill="#074C31"/> 143 <rect x="0.5" y="0.5" width="31" height="31" rx="3.5" stroke="black" stroke-opacity="0.1"/> 144 </svg> 145 `, 146 navTitles: { 147 days: "MMMM, <i>yyyy</i>", 148 months: "yyyy", 149 years: "yyyy1 - yyyy2", 150 }, 151 timepicker: !1, 152 onlyTimepicker: !1, 153 dateTimeSeparator: " ", 154 timeFormat: "", 155 minHours: 0, 156 maxHours: 24, 157 minMinutes: 0, 158 maxMinutes: 59, 159 hoursStep: 1, 160 minutesStep: 1, 161 onSelect: !1, 162 onChangeViewDate: !1, 163 onChangeView: !1, 164 onRenderCell: !1, 165 onShow: !1, 166 onHide: !1, 167 onClickDayName: !1, 168 }; 169 function a(e) { 170 let t = 171 arguments.length > 1 && void 0 !== arguments[1] 172 ? arguments[1] 173 : document; 174 return "string" == typeof e ? t.querySelector(e) : e; 175 } 176 function n() { 177 let { 178 tagName: e = "div", 179 className: t = "", 180 innerHtml: i = "", 181 id: s = "", 182 attrs: a = {}, 183 } = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : {}, 184 n = document.createElement(e); 185 return ( 186 t && n.classList.add(...t.split(" ")), 187 s && (n.id = s), 188 i && (n.innerHTML = i), 189 a && r(n, a), 190 n 191 ); 192 } 193 function r(e, t) { 194 for (let [i, s] of Object.entries(t)) 195 void 0 !== s && e.setAttribute(i, s); 196 return e; 197 } 198 function h(e) { 199 return new Date(e.getFullYear(), e.getMonth() + 1, 0).getDate(); 200 } 201 function o(e) { 202 let t = e.getHours(), 203 { hours: i, dayPeriod: s } = l(t); 204 return { 205 year: e.getFullYear(), 206 month: e.getMonth(), 207 fullMonth: 208 e.getMonth() + 1 < 10 ? "0" + (e.getMonth() + 1) : e.getMonth() + 1, 209 date: e.getDate(), 210 fullDate: e.getDate() < 10 ? "0" + e.getDate() : e.getDate(), 211 day: e.getDay(), 212 hours: t, 213 fullHours: d(t), 214 hours12: i, 215 dayPeriod: s, 216 fullHours12: d(i), 217 minutes: e.getMinutes(), 218 fullMinutes: 219 e.getMinutes() < 10 ? "0" + e.getMinutes() : e.getMinutes(), 220 }; 221 } 222 function l(e) { 223 return { 224 dayPeriod: e > 11 ? "pm" : "am", 225 hours: e % 12 == 0 ? 12 : e % 12, 226 }; 227 } 228 function d(e) { 229 return e < 10 ? "0" + e : e; 230 } 231 function c(e) { 232 let t = 10 * Math.floor(e.getFullYear() / 10); 233 return [t, t + 9]; 234 } 235 function u() { 236 let e = []; 237 for (var t = arguments.length, i = new Array(t), s = 0; s < t; s++) 238 i[s] = arguments[s]; 239 return ( 240 i.forEach((t) => { 241 if ("object" == typeof t) for (let i in t) t[i] && e.push(i); 242 else t && e.push(t); 243 }), 244 e.join(" ") 245 ); 246 } 247 function p(e, t) { 248 let s = 249 arguments.length > 2 && void 0 !== arguments[2] ? arguments[2] : i.days; 250 if (!e || !t) return !1; 251 let a = o(e), 252 n = o(t), 253 r = { 254 [i.days]: 255 a.date === n.date && a.month === n.month && a.year === n.year, 256 [i.months]: a.month === n.month && a.year === n.year, 257 [i.years]: a.year === n.year, 258 }; 259 return r[s]; 260 } 261 function m(e, t, i) { 262 let s = g(e, !1).getTime(), 263 a = g(t, !1).getTime(); 264 return i ? s >
264= a : s > a; 265 } 266 function v(e, t) { 267 return !m(e, t, !0); 268 } 269 function g(e) { 270 let t = 271 !(arguments.length > 1 && void 0 !== arguments[1]) || arguments[1], 272 i = new Date(e.getTime()); 273 return "boolean" != typeof t || t || D(i), i; 274 } 275 function D(e) { 276 return e.setHours(0, 0, 0, 0), e; 277 } 278 function y(e, t, i) { 279 e.length 280 ? e.forEach((e) => { 281 e.addEventListener(t, i); 282 }) 283 : e.addEventListener(t, i); 284 } 285 function f(e, t) { 286 return ( 287 !(!e || e === document || e instanceof DocumentFragment) && 288 (e.matches(t) ? e : f(e.parentNode, t)) 289 ); 290 } 291 function w(e, t, i) { 292 return e > i ? i : e < t ? t : e; 293 } 294 function b(e) { 295 for ( 296 var t = arguments.length, i = new Array(t > 1 ? t - 1 : 0), s = 1; 297 s < t; 298 s++ 299 ) 300 i[s - 1] = arguments[s]; 301 return ( 302 i 303 .filter((e) => e) 304 .forEach((t) => { 305 for (let [i, s] of Object.entries(t)) 306 if (void 0 !== s && "[object Object]" === s.toString()) { 307 let t = void 0 !== e[i] ? e[i].toString() : void 0, 308 a = s.toString(), 309 n = Array.isArray(s) ? [] : {}; 310 (e[i] = e[i] ? (t !== a ? n : e[i]) : n), b(e[i], s); 311 } else e[i] = s; 312 }), 313 e 314 ); 315 } 316 function k(e) { 317 let t = e; 318 return ( 319 e instanceof Date || (t = new Date(e)), 320 isNaN(t.getTime()) && 321 (console.log(`Unable to convert value "${e}" to Date object`), 322 (t = !1)), 323 t 324 ); 325 } 326 function C(e) { 327 let t = "\\s|\\.|-|/|\\\\|,|\\$|\\!|\\?|:|;"; 328 return new RegExp("(^|>|" + t + ")(" + e + ")($|<|" + t + ")", "g"); 329 } 330 function $(e, t, i) { 331 return ( 332 (t = (function (e) { 333 var t = (function (e, t) { 334 if ("object" != typeof e || null === e) return e; 335 var i = e[Symbol.toPrimitive]; 336 if (void 0 !== i) { 337 var s = i.call(e, t); 338 if ("object" != typeof s) return s; 339 throw new TypeError( 340 "@@toPrimitive must return a primitive value." 341 ); 342 } 343 return String(e); 344 })(e, "string"); 345 return "symbol" == typeof t ? t : String(t); 346 })(t)) in e 347 ? Object.defineProperty(e, t, { 348 value: i, 349 enumerable: !0, 350 configurable: !0, 351 writable: !0, 352 }) 353 : (e[t] = i), 354 e 355 ); 356 } 357 class _ { 358 constructor() { 359 let { 360 type: e, 361 date: t, 362 dp: i, 363 opts: s, 364 body: a, 365 } = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : {}; 366 $(this, "focus", () => { 367 this.$cell.classList.add("-focus-"), (this.focused = !0); 368 }), 369 $(this, "removeFocus", () => { 370 this.$cell.classList.remove("-focus-"), (this.focused = !1); 371 }), 372 $(this, "select", () => { 373 this.$cell.classList.add("-selected-"), (this.selected = !0);
374 }), 375 $(this, "removeSelect", () => { 376 this.$cell.classList.remove( 377 "-selected-", 378 "-range-from-", 379 "-range-to-" 380 ), 381 (this.selected = !1); 382 }), 383 $(this, "onChangeSelectedDate", () => { 384 this.isDisabled || 385 (this._handleSelectedStatus(), 386 this.opts.range && this._handleRangeStatus()); 387 }), 388 $(this, "onChangeFocusDate", (e) => { 389 if (!e) return void (this.focused && this.removeFocus()); 390 let t = p(e, this.date, this.type); 391 t ? this.focus() : !t && this.focused && this.removeFocus(), 392 this.opts.range && this._handleRangeStatus(); 393 }), 394 $( 395 this, 396 "render", 397 () => ( 398 (this.$cell.innerHTML = this._getHtml()), 399 (this.$cell.adpCell = this), 400 this.$cell 401 ) 402 ), 403 (this.type = e), 404 (this.singleType = this.type.slice(0, -1)), 405 (this.date = t), 406 (this.dp = i), 407 (this.opts = s), 408 (this.body = a), 409 (this.customData = !1), 410 this.init(); 411 } 412 init() { 413 let { range: e, onRenderCell: t } = this.opts; 414 t && 415 (this.customData = t({ 416 date: this.date, 417 cellType: this.singleType, 418 datepicker: this.dp, 419 })), 420 this._createElement(), 421 this._bindDatepickerEvents(), 422 this._handleInitialFocusStatus(), 423 this.dp.hasSelectedDates && 424 (this._handleSelectedStatus(), e && this._handleRangeStatus()); 425 } 426 _bindDatepickerEvents() { 427 this.dp.on(i.eventChangeSelectedDate, this.onChangeSelectedDate), 428 this.dp.on(i.eventChangeFocusDate, this.onChangeFocusDate); 429 } 430 unbindDatepickerEvents() { 431 this.dp.off(i.eventChangeSelectedDate, this.onChangeSelectedDate), 432 this.dp.off(i.eventChangeFocusDate, this.onChangeFocusDate); 433 } 434 _createElement() { 435 var e; 436 let { year: t, month: i, date: s } = o(this.date), 437 a = 438 (null === (e = this.customData) || void 0 === e 439 ? void 0 440 : e.attrs) || {}; 441 this.$cell = n({ 442 className: this._getClassName(), 443 attrs: { "data-year": t, "data-month": i, "data-date": s, ...a }, 444 }); 445 } 446 _getClassName() { 447 var e, t; 448 let s = new Date(), 449 { selectOtherMonths: a, selectOtherYears: n } = this.opts, 450 { minDate: r, maxDate: h } = this.dp, 451 { day: l } = o(this.date), 452 d = this._isOutOfMinMaxRange(), 453 c = 454 null === (e = this.customData) || void 0 === e 455 ? void 0 456 : e.disabled, 457 m = u("air-datepicker-cell", `-${this.singleType}-`, { 458 "-current-": p(s, this.date, this.type), 459 "-min-date-": r && p(r, this.date, this.type), 460 "-max-date-": h && p(h, this.date, this.type), 461 }), 462 v = ""; 463 switch (this.type) { 464 case i.days: 465 v = u({ 466 "-weekend-": this.dp.isWeekend(l), 467 "-other-month-": this.isOtherMonth, 468 "-disabled-": (this.isOtherMonth && !a) || d || c, 469 }); 470 break; 471 case i.months: 472 v = u({ "-disabled-": d || c }); 473 break; 474 case i.years: 475 v = u({ 476 "-other-decade-": this.isOtherDecade, 477 "-disabled-": d || (this.isOtherDecade && !n) || c, 478 }); 479 } 480 return u( 481 m, 482 v, 483 null === (t = this.customData) || void 0 === t ? void 0 : t.classes 484 ); 485 } 486 _getHtml() { 487 var e; 488 let { year: t, month: s, date: a } = o(this.date), 489 { showOtherMonths: n, showOtherYears: r } = this.opts; 490 if (null !== (e = this.customData) && void 0 !== e && e.html) 491 return this.customData.html; 492 switch (this.type) { 493 case i.days: 494 return !n && this.isOtherMonth ? "" : a; 495 case i.months: 496 return this.dp.locale[this.opts.monthsField][s]; 497 case i.years: 498 return !r && this.isOtherDecade ? "" : t; 499 } 500 } 501 _isOutOfMinMaxRange() { 502 let { minDate: e, maxDate: t } = this.dp, 503 { type: s, date: a } = this, 504 { month: n, year: r, date: h } = o(a), 505 l = s === i.days, 506 d = s === i.years, 507 c = !!e && new Date(r, d ? e.getMonth() : n, l ? h : e.getDate()), 508 u = !!t && new Date(r, d ? t.getMonth() : n, l ? h : t.getDate()); 509 return e && t ? v(c, e) || m(u, t) : e ? v(c, e) : t ? m(u, t) : void 0; 510 } 511 destroy() { 512 this.unbindDatepickerEvents(); 513 } 514 _handleRangeStatus() { 515 let { rangeDateFrom: e, rangeDateTo: t } = this.dp, 516 i = u({ 517 "-in-range-": 518 e && t && ((s = this.date), (a = e), (n = t), m(s, a) && v(s, n)), 519 "-range-from-": e && p(this.date, e, this.type), 520 "-range-to-": t && p(this.date, t, this.type), 521 });
522 var s, a, n; 523 this.$cell.classList.remove("-range-from-", "-range-to-", "-in-range-"), 524 i && this.$cell.classList.add(...i.split(" ")); 525 } 526 _handleSelectedStatus() { 527 let e = this.dp._checkIfDateIsSelected(this.date, this.type); 528 e ? this.select() : !e && this.selected && this.removeSelect(); 529 } 530 _handleInitialFocusStatus() { 531 p(this.dp.focusDate, this.date, this.type) && this.focus(); 532 } 533 get isDisabled() { 534 return this.$cell.matches(".-disabled-"); 535 } 536 get isOtherMonth() { 537 return this.dp.isOtherMonth(this.date); 538 } 539 get isOtherDecade() { 540 return this.dp.isOtherDecade(this.date); 541 } 542 } 543 function M(e, t, i) { 544 return ( 545 (t = (function (e) { 546 var t = (function (e, t) { 547 if ("object" != typeof e || null === e) return e; 548 var i = e[Symbol.toPrimitive]; 549 if (void 0 !== i) { 550 var s = i.call(e, t); 551 if ("object" != typeof s) return s; 552 throw new TypeError( 553 "@@toPrimitive must return a primitive value." 554 ); 555 } 556 return String(e); 557 })(e, "string"); 558 return "symbol" == typeof t ? t : String(t); 559 })(t)) in e 560 ? Object.defineProperty(e, t, { 561 value: i, 562 enumerable: !0, 563 configurable: !0, 564 writable: !0, 565 }) 566 : (e[t] = i), 567 e 568 ); 569 } 570 let S = { 571 [i.days]: `<div class="air-datepicker-body--day-names"></div><div class="air-datepicker-body--cells -${i.days}-"></div>`, 572 [i.months]: `<div class="air-datepicker-body--cells -${i.months}-"></div>`, 573 [i.years]: `<div class="air-datepicker-body--cells -${i.years}-"></div>`, 574 }; 575 const T = ".air-datepicker-cell"; 576 class F { 577 constructor(e) { 578 let { dp: t, type: s, opts: a } = e; 579 M(this, "handleClick", (e) => { 580 let t = e.target.closest(T).adpCell; 581 if (t.isDisabled) return; 582 if (!this.dp.isMinViewReached) return void this.dp.down(); 583 let i = this.dp._checkIfDateIsSelected(t.date, t.type); 584 i 585 ? this.dp._handleAlreadySelectedDates(i, t.date) 586 : this.dp.selectDate(t.date); 587 }), 588 M(this, "handleDayNameClick", (e) => { 589 let t = e.target.getAttribute("data-day-index"); 590 this.opts.onClickDayName({ 591 dayIndex: Number(t), 592 datepicker: this.dp, 593 }); 594 }), 595 M(this, "onChangeCurrentView", (e) => { 596 e !== this.type ? this.hide() : (this.show(), this.render()); 597 }), 598 M(this, "onMouseOverCell", (e) => { 599 let t = f(e.target, T); 600 this.dp.setFocusDate(!!t && t.adpCell.date); 601 }), 602 M(this, "onMouseOutCell", () => { 603 this.dp.setFocusDate(!1); 604 }), 605 M(this, "onClickBody", (e) => { 606 let { onClickDayName: t } = this.opts, 607 i = e.target; 608 i.closest(T) && this.handleClick(e), 609 t && 610 i.closest(".air-datepicker-body--day-name") && 611 this.handleDayNameClick(e); 612 }), 613 M(this, "onMouseDown", (e) => { 614 this.pressed = !0; 615 let t = f(e.target, T), 616 i = t && t.adpCell; 617 p(i.date, this.dp.rangeDateFrom) && (this.rangeFromFocused = !0), 618 p(i.date, this.dp.rangeDateTo) && (this.rangeToFocused = !0); 619 }), 620 M(this, "onMouseMove", (e) => { 621 if (!this.pressed || !this.dp.isMinViewReached) return; 622 e.preventDefault(); 623 let t = f(e.target, T), 624 i = t && t.adpCell, 625 { selectedDates: s, rangeDateTo: a, rangeDateFrom: n } = this.dp; 626 if (!i || i.isDisabled) return; 627 let { date: r } = i; 628 if (2 === s.length) { 629 if (this.rangeFromFocused && !m(r, a)) { 630 let { hours: e, minutes: t } = o(n); 631 r.setHours(e), 632 r.setMinutes(t), 633 (this.dp.rangeDateFrom = r), 634 this.dp.replaceDate(n, r); 635 } 636 if (this.rangeToFocused && !v(r, n)) { 637 let { hours: e, minutes: t } = o(a); 638 r.setHours(e), 639 r.setMinutes(t), 640 (this.dp.rangeDateTo = r), 641 this.dp.replaceDate(a, r); 642 } 643 } 644 }), 645 M(this, "onMouseUp", () => { 646 (this.pressed = !1), 647 (this.rangeFromFocused = !1), 648 (this.rangeToFocused = !1); 649 }),
650 M(this, "onChangeViewDate", (e, t) => { 651 if (!this.isVisible) return; 652 let s = c(e), 653 a = c(t); 654 switch (this.dp.currentView) { 655 case i.days: 656 if (p(e, t, i.months)) return; 657 break; 658 case i.months: 659 if (p(e, t, i.years)) return; 660 break; 661 case i.years: 662 if (s[0] === a[0] && s[1] === a[1]) return; 663 } 664 this.render(); 665 }), 666 M(this, "render", () => { 667 this.destroyCells(), 668 this._generateCells(), 669 this.cells.forEach((e) => { 670 this.$cells.appendChild(e.render()); 671 }); 672 }), 673 (this.dp = t), 674 (this.type = s), 675 (this.opts = a), 676 (this.cells = []), 677 (this.$el = ""), 678 (this.pressed = !1), 679 (this.isVisible = !0), 680 this.init(); 681 } 682 init() { 683 this._buildBaseHtml(), 684 this.type === i.days && this.renderDayNames(), 685 this.render(), 686 this._bindEvents(), 687 this._bindDatepickerEvents(); 688 } 689 _bindEvents() { 690 let { range: e, dynamicRange: t } = this.opts; 691 y(this.$el, "mouseover", this.onMouseOverCell), 692 y(this.$el, "mouseout", this.onMouseOutCell), 693 y(this.$el, "click", this.onClickBody), 694 e && 695 t && 696 (y(this.$el, "mousedown", this.onMouseDown), 697 y(this.$el, "mousemove", this.onMouseMove), 698 y(window.document, "mouseup", this.onMouseUp)); 699 } 700 _bindDatepickerEvents() { 701 this.dp.on(i.eventChangeViewDate, this.onChangeViewDate), 702 this.dp.on(i.eventChangeCurrentView, this.onChangeCurrentView); 703 } 704 _buildBaseHtml() { 705 (this.$el = n({ 706 className: `air-datepicker-body -${this.type}-`, 707 innerHtml: S[this.type], 708 })), 709 (this.$names = a(".air-datepicker-body--day-names", this.$el)), 710 (this.$cells = a(".air-datepicker-body--cells", this.$el)); 711 } 712 _getDayNamesHtml() { 713 let e = 714 arguments.length > 0 && void 0 !== arguments[0] 715 ? arguments[0] 716 : this.dp.locale.firstDay, 717 t = "", 718 s = this.dp.isWeekend, 719 { onClickDayName: a } = this.opts, 720 n = e, 721 r = 0; 722 for (; r < 7; ) { 723 let e = n % 7; 724 (t += `<div class="${u("air-datepicker-body--day-name", { 725 [i.cssClassWeekend]: s(e), 726 "-clickable-": !!a, 727 })}" data-day-index='${e}'>${this.dp.locale.daysMin[e]}</div>`), 728 r++, 729 n++; 730 } 731 return t; 732 } 733 _getDaysCells() { 734 let { 735 viewDate: e, 736 locale: { firstDay: t }, 737 } = this.dp, 738 i = h(e), 739 { year: s, month: a } = o(e), 740 n = new Date(s, a, 1), 741 r = new Date(s, a, i), 742 l = n.getDay() - t, 743 d = 6 - r.getDay() + t; 744 (l = l < 0 ? l + 7 : l), (d = d > 6 ? d - 7 : d); 745 let c = (function (e, t) { 746 let { year: i, month: s, date: a } = o(e); 747 return new Date(i, s, a - t); 748 })(n, l), 749 u = i + l + d, 750 p = c.getDate(), 751 { year: m, month: v } = o(c), 752 g = 0; 753 for (; g < u; ) { 754 let e = new Date(m, v, p + g); 755 this._generateCell(e), g++; 756 } 757 } 758 _generateCell(e) { 759 let { type: t, dp: i, opts: s } = this, 760 a = new _({ type: t, dp: i, opts: s, date: e, body: this }); 761 return this.cells.push(a), a; 762 } 763 _generateDayCells() { 764 this._getDaysCells(); 765 } 766 _generateMonthCells() { 767 let { year: e } = this.dp.parsedViewDate, 768 t = 0; 769 for (; t < 12; ) 770 this.cells.push(this._generateCell(new Date(e, t))), t++; 771 } 772 _generateYearCells() { 773 let e = c(this.dp.viewDate), 774 t = e[0] - 1, 775 i = e[1] + 1, 776 s = t; 777 for (; s <= i; ) 778 this.cells.push(this._generateCell(new Date(s, 0))), s++; 779 } 780 renderDayNames() { 781 this.$names.innerHTML = this._getDayNamesHtml(); 782 } 783 _generateCells() { 784 switch (this.type) { 785 case i.days: 786 this._generateDayCells(); 787 break; 788 case i.months: 789 this._generateMonthCells(); 790 break; 791 case i.years: 792 this._generateYearCells(); 793 } 794 } 795 show() { 796 (this.isVisible = !0), this.$el.classList.remove("-hidden-"); 797 } 798 hide() { 799 (this.isVisible = !1), this.$el.classList.add("-hidden-"); 800 } 801 destroyCells() {
802 this.cells.forEach((e) => e.destroy()), 803 (this.cells = []), 804 (this.$cells.innerHTML = ""); 805 } 806 destroy() { 807 this.destroyCells(), 808 this.dp.off(i.eventChangeViewDate, this.onChangeViewDate), 809 this.dp.off(i.eventChangeCurrentView, this.onChangeCurrentView); 810 } 811 } 812 function V(e, t, i) { 813 return ( 814 (t = (function (e) { 815 var t = (function (e, t) { 816 if ("object" != typeof e || null === e) return e; 817 var i = e[Symbol.toPrimitive]; 818 if (void 0 !== i) { 819 var s = i.call(e, t); 820 if ("object" != typeof s) return s; 821 throw new TypeError( 822 "@@toPrimitive must return a primitive value." 823 ); 824 } 825 return String(e); 826 })(e, "string"); 827 return "symbol" == typeof t ? t : String(t); 828 })(t)) in e 829 ? Object.defineProperty(e, t, { 830 value: i, 831 enumerable: !0, 832 configurable: !0, 833 writable: !0, 834 }) 835 : (e[t] = i), 836 e 837 ); 838 } 839 class x { 840 constructor(e) { 841 let { dp: t, opts: i } = e; 842 V(this, "onClickNav", (e) => { 843 let t = f(e.target, ".air-datepicker-nav--action"); 844 if (!t) return; 845 let i = t.dataset.action; 846 this.dp[i] && this.dp[i](); 847 }), 848 V(this, "onChangeViewDate", () => { 849 this.render(), this._resetNavStatus(), this.handleNavStatus(); 850 }), 851 V(this, "onChangeCurrentView", () => { 852 this.render(), this._resetNavStatus(), this.handleNavStatus(); 853 }), 854 V(this, "onClickNavTitle", () => { 855 this.dp.isFinalView || this.dp.up(); 856 }), 857 V(this, "update", () => { 858 let { prevHtml: e, nextHtml: t } = this.opts; 859 (this.$prev.innerHTML = e), 860 (this.$next.innerHTML = t), 861 this._resetNavStatus(), 862 this.render(), 863 this.handleNavStatus(); 864 }), 865 V(this, "renderDelay", () => { 866 setTimeout(this.render); 867 }), 868 V(this, "render", () => { 869 (this.$title.innerHTML = this._getTitle()), 870 (function (e, t) { 871 for (let i in t) 872 t[i] ? e.classList.add(i) : e.classList.remove(i); 873 })(this.$title, { "-disabled-": this.dp.isFinalView }); 874 }), 875 (this.dp = t), 876 (this.opts = i), 877 this.init(); 878 } 879 init() { 880 this._createElement(), 881 this._buildBaseHtml(), 882 this._defineDOM(), 883 this.render(), 884 this.handleNavStatus(), 885 this._bindEvents(), 886 this._bindDatepickerEvents(); 887 } 888 _defineDOM() { 889 (this.$title = a(".air-datepicker-nav--title", this.$el)), 890 (this.$prev = a('[data-action="prev"]', this.$el)), 891 (this.$next = a('[data-action="next"]', this.$el)); 892 } 893 _bindEvents() { 894 this.$el.addEventListener("click", this.onClickNav), 895 this.$title.addEventListener("click", this.onClickNavTitle); 896 } 897 _bindDatepickerEvents() { 898 this.dp.on(i.eventChangeViewDate, this.onChangeViewDate), 899 this.dp.on(i.eventChangeCurrentView, this.onChangeCurrentView), 900 this.isNavIsFunction && 901 (this.dp.on(i.eventChangeSelectedDate, this.renderDelay), 902 this.dp.opts.timepicker && 903 this.dp.on(i.eventChangeTime, this.render)); 904 } 905 destroy() { 906 this.dp.off(i.eventChangeViewDate, this.onChangeViewDate), 907 this.dp.off(i.eventChangeCurrentView, this.onChangeCurrentView), 908 this.isNavIsFunction && 909 (this.dp.off(i.eventChangeSelectedDate, this.renderDelay), 910 this.dp.opts.timepicker && 911 this.dp.off(i.eventChangeTime, this.render)); 912 } 913 _createElement() { 914 this.$el = n({ tagName: "nav", className: "air-datepicker-nav" }); 915 } 916 _getTitle() { 917 let { dp: e, opts: t } = this, 918 i = t.navTitles[e.currentView]; 919 return "function" == typeof i ? i(e) : e.formatDate(e.viewDate, i); 920 } 921 handleNavStatus() { 922 let { disableNavWhenOutOfRange: e } = this.opts, 923 { minDate: t, maxDate: s } = this.dp; 924 if ((!t && !s) || !e) return; 925 let { year: a, month: n } = this.dp.parsedViewDate, 926 r = !!t && o(t), 927 h = !!s && o(s); 928 switch (this.dp.currentView) { 929 case i.days: 930 t && r.month >= n && r.year >= a && this._disableNav("prev"), 931 s && h.month <= n && h.year <= a && this._disableNav("next"); 932 break; 933 case i.months: 934 t && r.year >= a && this._disableNav("prev"), 935 s && h.year <= a && this._disableNav("next"); 936 break; 937 case i.years: { 938 let e = c(this.dp.viewDate); 939 t && r.year >= e[0] && this._disableNav("prev"), 940 s && h.year <= e[1] && this._disableNav("next"); 941 break; 942 } 943 } 944 } 945 _disableNav(e) { 946 a('[data-action="' + e + '"]', this.$el).classList.add("-disabled-"); 947 } 948 _resetNavStatus() { 949 !(function (e) { 950 for ( 951 var t = arguments.length, i = new Array(t > 1 ? t - 1 : 0), s = 1; 952 s < t; 953 s++ 954 ) 955 i[s - 1] = arguments[s]; 956 e.length 957 ? e.forEach((e) => { 958 e.classList.remove(...i); 959 }) 960 : e.classList.remove(...i); 961 })( 962 this.$el.querySelectorAll(".air-datepicker-nav--action"), 963 "-disabled-" 964 ); 965 } 966 _buildBaseHtml() { 967 let { prevHtml: e, nextHtml: t } = this.opts; 968 const customPrevYearSVG = `<svg width="32" height="32" viewBox="0 0 32 32" fill="none" xmlns="http://www.w3.org/2000/svg"> 969 <rect width="32" height="32" rx="4" fill="white"/> 970 <path fill-rule="evenodd" clip-rule="evenodd" d="M16.4417 8.05862C16.4999 8.11667 16.546 8.18564 16.5776 8.26158C16.6091 8.33751 16.6253 8.41891 16.6253 8.50112C16.6253 8.58333 16.6091 8.66473 16.5776 8.74066C16.546 8.81659 16.4999 8.88556 16.4417 8.94362L9.38291 16.0011L16.4417 23.0586C16.559 23.176 16.625 23.3351 16.625 23.5011C16.625 23.6671 16.559 23.8263 16.4417 23.9436C16.3243 24.061 16.1651 24.1269 15.9992 24.1269C15.8332 24.1269 15.674 24.061 15.5567 23.9436L8.05666 16.4436C7.99846 16.3856 7.95228 16.3166 7.92077 16.2407C7.88927 16.1647 7.87305 16.0833 7.87305 16.0011C7.87305 15.9189 7.88927 15.8375 7.92077 15.7616C7.95228 15.6856 7.99846 15.6167 8.05666 15.5586L15.5567 8.05862C15.6147 8.00041 15.6837 7.95423 15.7596 7.92273C15.8356 7.89122 15.917 7.875 15.9992 7.875C16.0814 7.875 16.1628 7.89122 16.2387 7.92273C16.3146 7.95423 16.3836 8.00041 16.4417 8.05862
970V8.05862Z" fill="#074C31"/> 971 <path fill-rule="evenodd" clip-rule="evenodd" d="M21.4417 8.05862C21.4999 8.11667 21.546 8.18564 21.5776 8.26158C21.6091 8.33751 21.6253 8.41891 21.6253 8.50112C21.6253 8.58333 21.6091 8.66473 21.5776 8.74066C21.546 8.81659 21.4999 8.88556 21.4417 8.94362L14.3829 16.0011L21.4417 23.0586C21.4998 23.1167 21.5459 23.1857 21.5773 23.2616C21.6088 23.3376 21.625 23.4189 21.625 23.5011C21.625 23.5833 21.6088 23.6647 21.5773 23.7406C21.5459 23.8165 21.4998 23.8855 21.4417 23.9436C21.3836 24.0017 21.3146 24.0478 21.2386 24.0793C21.1627 24.1107 21.0813 24.1269 20.9992 24.1269C20.917 24.1269 20.8356 24.1107 20.7597 24.0793C20.6838 24.0478 20.6148 24.0017 20.5567 23.9436L13.0567 16.4436C12.9985 16.3856 12.9523 16.3166 12.9208 16.2407C12.8893 16.1647 12.873 16.0833 12.873 16.0011C12.873 15.9189 12.8893 15.8375 12.9208 15.7616C12.9523 15.6856 12.9985 15.6167 13.0567 15.5586L20.5567 8.05862C20.6147 8.00041 20.6837 7.95423 20.7596 7.92273C20.8356 7.89122 20.917 7.875 20.9992 7.875C21.0814 7.875 21.1628 7.89122 21.2387 7.92273C21.3146 7.95423 21.3836 8.00041 21.4417 8.05862V8.05862Z" fill="#074C31"/> 972 <rect x="0.5" y="0.5" width="31" height="31" rx="3.5" stroke="black" stroke-opacity="0.1"/> 973 </svg>` 974 const customNextYearSVG = `<svg width="32" height="32" viewBox="0 0 32 32" fill="none" xmlns="http://www.w3.org/2000/svg"> 975 <rect width="32" height="32" rx="4" fill="white"/> 976 <path fill-rule="evenodd" clip-rule="evenodd" d="M10.5567 8.05862C10.6147 8.00041 10.6837 7.95423 10.7596 7.92273C10.8356 7.89122 10.917 7.875 10.9992 7.875C11.0814 7.875 11.1628 7.89122 11.2387 7.92273C11.3146 7.95423 11.3836 8.00041 11.4417 8.05862L18.9417 15.5586C18.9999 15.6167 19.046 15.6856 19.0776 15.7616C19.1091 15.8375 19.1253 15.9189 19.1253 16.0011C19.1253 16.0833 19.1091 16.1647 19.0776 16.2407C19.046 16.3166 18.9999 16.3856 18.9417 16.4436L11.4417 23.9436C11.3243 24.061 11.1651 24.1269 10.9992 24.1269C10.8332 24.1269 10.674 24.061 10.5567 23.9436C10.4393 23.8263 10.3734 23.6671 10.3734 23.5011C10.3734 23.3351 10.4393 23.176 10.5567 23.0586L17.6154 16.0011L10.5567 8.94362C10.4985 8.88556 10.4523 8.81659 10.4208 8.74066C10.3893 8.66473 10.373 8.58333 10.373 8.50112C10.373 8.41891 10.3893 8.33751 10.4208 8.26158C10.4523 8.18564 10.4985 8.11667 10.5567 8.05862Z" fill="#074C31"/> 977 <path fill-rule="evenodd" clip-rule="evenodd" d="M15.5567 8.05862C15.6147 8.00041 15.6837 7.95423 15.7596 7.92273C15.8356 7.89122 15.917 7.875 15.9992 7.875C16.0814 7.875 16.1628 7.89122 16.2387 7.92273C16.3146 7.95423 16.3836 8.00041 16.4417 8.05862L23.9417 15.5586C23.9999 15.6167 24.046 15.6856 24.0776 15.7616C24.1091 15.8375 24.1253 15.9189 24.1253 16.0011C24.1253 16.0833 24.1091 16.1647 24.0776 16.2407C24.046 16.3166 23.9999 16.3856 23.9417 16.4436L16.4417 23.9436C16.3243 24.061 16.1651 24.1269 15.9992 24.1269C15.8332 24.1269 15.674 24.061 15.5567 23.9436C15.4393 23.8263 15.3734 23.6671 15.3734 23.5011C15.3734 23.3351 15.4393 23.176 15.5567 23.0586L22.6154 16.0011L15.5567 8.94362C15.4985 8.88556 15.4523 8.81659 15.4208 8.74066C15.3893 8.66473 15.373 8.58333 15.373 8.50112C15.373 8.41891 15.3893 8.33751 15.4208 8.26158C15.4523 8.18564 15.4985 8.11667 15.5567 8.05862Z" fill="#074C31"/> 978 <rect x="0.5" y="0.5" width="31" height="31" rx="3.5" stroke="black" stroke-opacity="0.1"/> 979 </svg>` 980 this.$el.innerHTML = `<div class="custom-nav-action-datepicker d-flex"><div class="air-datepicker-nav--action prev-year">${customPrevYearSVG}</div><div class="air-datepicker-nav--action" data-action="prev">${e}</div></div><div class="air-datepicker-nav--title"></div><div class="custom-nav-action-datepicker d-flex"><div class="air-datepicker-nav--action" data-action="next">${t}</div><div class="air-datepicker-nav--action next-year">${customNextYearSVG}</div></div>`; 981 } 982 get isNavIsFunction() { 983 let { navTitles: e } = this.opts; 984 return Object.keys(e).find((t) => "function" == typeof e[t]); 985 } 986 } 987 var H = { 988 today: { 989 content: (e) => e.locale.today, 990 onClick: (e) => e.setViewDate(new Date()), 991 }, 992 clear: { content: (e) => e.locale.clear, onClick: (e) => e.clear() }, 993 }; 994 class E { 995 constructor(e) { 996 let { dp: t, opts: i } = e; 997 (this.dp = t), (this.opts = i), this.init(); 998 } 999 init() { 1000 this.createElement(), this.render(); 1001 } 1002 createElement() { 1003 this.$el = n({ className: "air-datepicker-buttons" }); 1004 } 1005 destroy() { 1006 this.$el.parentNode.removeChild(this.$el); 1007 } 1008 clearHtml() { 1009 return (this.$el.innerHTML = ""), this; 1010 } 1011 generateButtons() { 1012 let { buttons: e } = this.opts; 1013 Array.isArray(e) || (e = [e]), 1014 e.forEach((e) => { 1015 let t = e; 1016 "string" == typeof e && H[e] && (t = H[e]); 1017 let i = this.createButton(t); 1018 t.onClick && this.attachEventToButton(i, t.onClick), 1019 this.$el.appendChild(i); 1020 });
1021 } 1022 attachEventToButton(e, t) { 1023 e.addEventListener("click", () => { 1024 t(this.dp); 1025 }); 1026 } 1027 createButton(e) { 1028 let { 1029 content: t, 1030 className: i, 1031 tagName: s = "button", 1032 attrs: a = {}, 1033 } = e; 1034 return n({ 1035 tagName: s, 1036 innerHtml: `<span tabindex='-1'>${ 1037 "function" == typeof t ? t(this.dp) : t 1038 }</span>`, 1039 className: u("air-datepicker-button", i), 1040 attrs: a, 1041 }); 1042 } 1043 render() { 1044 this.generateButtons(); 1045 } 1046 } 1047 function L(e, t, i) { 1048 return ( 1049 (t = (function (e) { 1050 var t = (function (e, t) { 1051 if ("object" != typeof e || null === e) return e; 1052 var i = e[Symbol.toPrimitive]; 1053 if (void 0 !== i) { 1054 var s = i.call(e, t); 1055 if ("object" != typeof s) return s; 1056 throw new TypeError( 1057 "@@toPrimitive must return a primitive value." 1058 ); 1059 } 1060 return String(e); 1061 })(e, "string"); 1062 return "symbol" == typeof t ? t : String(t); 1063 })(t)) in e 1064 ? Object.defineProperty(e, t, { 1065 value: i, 1066 enumerable: !0, 1067 configurable: !0, 1068 writable: !0, 1069 }) 1070 : (e[t] = i), 1071 e 1072 ); 1073 } 1074 class O { 1075 constructor() { 1076 let { opts: e, dp: t } = 1077 arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : {}; 1078 L(this, "toggleTimepickerIsActive", (e) => { 1079 this.dp.timepickerIsActive = e; 1080 }), 1081 L(this, "onChangeSelectedDate", (e) => { 1082 let { date: t, updateTime: i = !1 } = e; 1083 t && 1084 (this.setMinMaxTime(t), 1085 this.setCurrentTime(!!i && t), 1086 this.addTimeToDate(t)); 1087 }), 1088 L(this, "onChangeLastSelectedDate", (e) => { 1089 e && (this.setTime(e), this.render()); 1090 }), 1091 L(this, "onChangeInputRange", (e) => { 1092 let t = e.target; 1093 (this[t.getAttribute("name")] = t.value), 1094 this.updateText(), 1095 this.dp.trigger(i.eventChangeTime, { 1096 hours: this.hours, 1097 minutes: this.minutes, 1098 }); 1099 }), 1100 L(this, "onMouseEnterLeave", (e) => { 1101 let t = e.target.getAttribute("name"), 1102 i = this.$minutesText; 1103 "hours" === t && (i = this.$hoursText), 1104 i.classList.toggle("-focus-"); 1105 }), 1106 L(this, "onFocus", () => { 1107 this.toggleTimepickerIsActive(!0); 1108 }), 1109 L(this, "onBlur", () => { 1110 this.toggleTimepickerIsActive(!1); 1111 }), 1112 (this.opts = e), 1113 (this.dp = t); 1114 let { timeFormat: s } = this.dp.locale; 1115 s && (s.match(C("h")) || s.match(C("hh"))) && (this.ampm = !0), 1116 this.init(); 1117 } 1118 init() { 1119 this.setTime(this.dp.lastSelectedDate || this.dp.viewDate), 1120 this.createElement(), 1121 this.buildHtml(), 1122 this.defineDOM(), 1123 this.render(), 1124 this.bindDatepickerEvents(), 1125 this.bindDOMEvents(); 1126 } 1127 bindDatepickerEvents() { 1128 this.dp.on(i.eventChangeSelectedDate, this.onChangeSelectedDate), 1129 this.dp.on( 1130 i.eventChangeLastSelectedDate, 1131 this.onChangeLastSelectedDate 1132 ); 1133 } 1134 bindDOMEvents() { 1135 let e = "input"; 1136 navigator.userAgent.match(/trident/gi) && (e = "change"), 1137 y(this.$ranges, e, this.onChangeInputRange), 1138 y(this.$ranges, "mouseenter", this.onMouseEnterLeave), 1139 y(this.$ranges, "mouseleave", this.onMouseEnterLeave), 1140 y(this.$ranges, "focus", this.onFocus), 1141 y(this.$ranges, "mousedown", this.onFocus), 1142 y(this.$ranges, "blur", this.onBlur); 1143 } 1144 createElement() { 1145 this.$el = n({ 1146 className: u("air-datepicker-time", { "-am-pm-": this.dp.ampm }), 1147 }); 1148 } 1149 destroy() { 1150 this.dp.off(i.eventChangeSelectedDate, this.onChangeSelectedDate), 1151 this.dp.off( 1152 i.eventChangeLastSelectedDate, 1153 this.onChangeLastSelectedDate 1154 ), 1155 this.$el.parentNode.removeChild(this.$el); 1156 } 1157 buildHtml() { 1158 let { 1159 ampm: e, 1160 hours: t, 1161 displayHours: i, 1162 minutes: s, 1163 minHours: a, 1164 minMinutes: n, 1165 maxHours: r, 1166 maxMinutes: h, 1167 dayPeriod: o, 1168 opts: { hoursStep: l, minutesStep: c }, 1169 } = this; 1170 this.$el.innerHTML = 1171 `<div class="air-datepicker-time--current"> <span class="air-datepicker-time--current-hours">${d( 1172 i 1173 )}</span> <span class="air-datepicker-time--current-colon">:</span> <span class="air-datepicker-time--current-minutes">${d( 1174 s 1175 )}</span> ` + 1176 (e 1177 ? `<span class='air-datepicker-time--current-ampm'>${o}</span>` 1178 : "") + 1179 '</div><div class="air-datepicker-time--sliders"> <div class="air-datepicker-time--row">' + 1180 ` <input type="range" name="hours" value="${t}" min="${a}" max="${r}" step="${l}"/> </div> <div class="air-datepicker-time--row">` + 1181 ` <input type="range" name="minutes" value="${s}" min="${n}" max="${h}" step="${c}"/> </div></div>`; 1182 } 1183 defineDOM() { 1184 let e = (e) => a(e, this.$el); 1185 (this.$ranges = this.$el.querySelectorAll('[type="range"]')), 1186 (this.$hours = e('[name="hours"]')), 1187 (this.$minutes = e('[name="minutes"]')), 1188 (this.$hoursText = e(".air-datepicker-time--current-hours")), 1189 (this.$minutesText = e(".air-datepicker-time--current-minutes")), 1190 (this.$ampm = e(".air-datepicker-time--current-ampm")); 1191 } 1192 setTime(e) { 1193 this.setMinMaxTime(e), this.setCurrentTime(e); 1194 } 1195 addTimeToDate(e) { 1196 e && (e.setHours(this.hours), e.setMinutes(this.minutes)); 1197 } 1198 setMinMaxTime(e) { 1199 if ((this.setMinMaxTimeFromOptions(), e)) { 1200 let { minDate: t, maxDate: i } = this.dp; 1201 t && p(e, t) && this.setMinTimeFromMinDate(t),
1202 i && p(e, i) && this.setMaxTimeFromMaxDate(i); 1203 } 1204 } 1205 setCurrentTime(e) { 1206 let { hours: t, minutes: i } = e ? o(e) : this; 1207 (this.hours = w(t, this.minHours, this.maxHours)), 1208 (this.minutes = w(i, this.minMinutes, this.maxMinutes)); 1209 } 1210 setMinMaxTimeFromOptions() { 1211 let { 1212 minHours: e, 1213 minMinutes: t, 1214 maxHours: i, 1215 maxMinutes: s, 1216 } = this.opts; 1217 (this.minHours = w(e, 0, 23)), 1218 (this.minMinutes = w(t, 0, 59)), 1219 (this.maxHours = w(i, 0, 23)), 1220 (this.maxMinutes = w(s, 0, 59)); 1221 } 1222 setMinTimeFromMinDate(e) { 1223 let { lastSelectedDate: t } = this.dp; 1224 (this.minHours = e.getHours()), 1225 t && t.getHours() > e.getHours() 1226 ? (this.minMinutes = this.opts.minMinutes) 1227 : (this.minMinutes = e.getMinutes()); 1228 } 1229 setMaxTimeFromMaxDate(e) { 1230 let { lastSelectedDate: t } = this.dp; 1231 (this.maxHours = e.getHours()), 1232 t && t.getHours() < e.getHours() 1233 ? (this.maxMinutes = this.opts.maxMinutes) 1234 : (this.maxMinutes = e.getMinutes()); 1235 } 1236 updateSliders() { 1237 (r(this.$hours, { min: this.minHours, max: this.maxHours }).value = 1238 this.hours), 1239 (r(this.$minutes, { 1240 min: this.minMinutes, 1241 max: this.maxMinutes, 1242 }).value = this.minutes); 1243 } 1244 updateText() { 1245 (this.$hoursText.innerHTML = d(this.displayHours)), 1246 (this.$minutesText.innerHTML = d(this.minutes)), 1247 this.ampm && (this.$ampm.innerHTML = this.dayPeriod); 1248 } 1249 set hours(e) { 1250 this._hours = e; 1251 let { hours: t, dayPeriod: i } = l(e); 1252 (this.displayHours = this.ampm ? t : e), (this.dayPeriod = i); 1253 } 1254 get hours() { 1255 return this._hours; 1256 } 1257 render() { 1258 this.updateSliders(), this.updateText(); 1259 } 1260 } 1261 function A(e, t, i) { 1262 return ( 1263 (t = (function (e) { 1264 var t = (function (e, t) { 1265 if ("object" != typeof e || null === e) return e; 1266 var i = e[Symbol.toPrimitive]; 1267 if (void 0 !== i) { 1268 var s = i.call(e, t); 1269 if ("object" != typeof s) return s; 1270 throw new TypeError( 1271 "@@toPrimitive must return a primitive value." 1272 ); 1273 } 1274 return String(e); 1275 })(e, "string"); 1276 return "symbol" == typeof t ? t : String(t); 1277 })(t)) in e 1278 ? Object.defineProperty(e, t, { 1279 value: i, 1280 enumerable: !0, 1281 configurable: !0, 1282 writable: !0, 1283 }) 1284 : (e[t] = i), 1285 e 1286 ); 1287 } 1288 class N { 1289 constructor(e) { 1290 let { dp: t, opts: i } = e; 1291 A(this, "pressedKeys", new Set()), 1292 A( 1293 this, 1294 "hotKeys", 1295 new Map([ 1296 [ 1297 [ 1298 ["Control", "ArrowRight"], 1299 ["Control", "ArrowUp"], 1300 ], 1301 (e) => e.month++, 1302 ], 1303 [ 1304 [ 1305 ["Control", "ArrowLeft"], 1306 ["Control", "ArrowDown"], 1307 ], 1308 (e) => e.month--, 1309 ], 1310 [ 1311 [ 1312 ["Shift", "ArrowRight"], 1313 ["Shift", "ArrowUp"], 1314 ], 1315 (e) => e.year++, 1316 ], 1317 [ 1318 [ 1319 ["Shift", "ArrowLeft"], 1320 ["Shift", "ArrowDown"], 1321 ], 1322 (e) => e.year--, 1323 ], 1324 [ 1325 [ 1326 ["Alt", "ArrowRight"], 1327 ["Alt", "ArrowUp"], 1328 ], 1329 (e) => (e.year += 10), 1330 ], 1331 [ 1332 [ 1333 ["Alt", "ArrowLeft"], 1334 ["Alt", "ArrowDown"], 1335 ], 1336 (e) => (e.year -= 10), 1337 ], 1338 [["Control", "Shift", "ArrowUp"], (e, t) => t.up()], 1339 ]) 1340 ), 1341 A(this, "handleHotKey", (e) => { 1342 let t = this.hotKeys.get(e), 1343 i = o(this.getInitialFocusDate()); 1344 t(i, this.dp); 1345 let { year: s, month: a, date: n } = i, 1346 r = h(new Date(s, a)); 1347 r < n && (n = r); 1348 let l = this.dp.getClampedDate(new Date(s, a, n)); 1349 this.dp.setFocusDate(l, { viewDateTransition: !0 }); 1350 }), 1351 A(this, "isHotKeyPressed", () => { 1352 let e = !1, 1353 t = this.pressedKeys.size, 1354 i = (e) => this.pressedKeys.has(e); 1355 for (let [s] of this.hotKeys) { 1356 if (e) break; 1357 if (Array.isArray(s[0]))
1358 s.forEach((a) => { 1359 e || t !== a.length || (e = a.every(i) && s); 1360 }); 1361 else { 1362 if (t !== s.length) continue; 1363 e = s.every(i) && s; 1364 } 1365 } 1366 return e; 1367 }), 1368 A(this, "isArrow", (e) => e >= 37 && e <= 40), 1369 A(this, "onKeyDown", (e) => { 1370 let { key: t, which: i } = e, 1371 { 1372 dp: s, 1373 dp: { focusDate: a }, 1374 opts: n, 1375 } = this; 1376 this.registerKey(t); 1377 let r = this.isHotKeyPressed(); 1378 if (r) return e.preventDefault(), void this.handleHotKey(r); 1379 if (this.isArrow(i)) 1380 return e.preventDefault(), void this.focusNextCell(t); 1381 if ("Enter" === t) { 1382 if (s.currentView !== n.minView) return void s.down(); 1383 if (a) { 1384 let e = s._checkIfDateIsSelected(a); 1385 return void (e 1386 ? s._handleAlreadySelectedDates(e, a) 1387 : s.selectDate(a)); 1388 } 1389 } 1390 "Escape" === t && this.dp.hide(); 1391 }), 1392 A(this, "onKeyUp", (e) => { 1393 this.removeKey(e.key); 1394 }), 1395 (this.dp = t), 1396 (this.opts = i), 1397 this.init(); 1398 } 1399 init() { 1400 this.bindKeyboardEvents(); 1401 } 1402 bindKeyboardEvents() { 1403 let { $el: e } = this.dp; 1404 e.addEventListener("keydown", this.onKeyDown), 1405 e.addEventListener("keyup", this.onKeyUp); 1406 } 1407 destroy() { 1408 let { $el: e } = this.dp; 1409 e.removeEventListener("keydown", this.onKeyDown), 1410 e.removeEventListener("keyup", this.onKeyUp), 1411 (this.hotKeys = null), 1412 (this.pressedKeys = null); 1413 } 1414 getInitialFocusDate() { 1415 let { 1416 focusDate: e, 1417 currentView: t, 1418 selectedDates: s, 1419 parsedViewDate: { year: a, month: n }, 1420 } = this.dp, 1421 r = e || s[s.length - 1]; 1422 if (!r) 1423 switch (t) { 1424 case i.days: 1425 r = new Date(a, n, new Date().getDate()); 1426 break; 1427 case i.months: 1428 r = new Date(a, n, 1); 1429 break; 1430 case i.years: 1431 r = new Date(a, 0, 1); 1432 } 1433 return r; 1434 } 1435 focusNextCell(e) { 1436 let t = this.getInitialFocusDate(), 1437 { currentView: s } = this.dp, 1438 { days: a, months: n, years: r } = i, 1439 h = o(t), 1440 l = h.year, 1441 d = h.month, 1442 c = h.date; 1443 switch (e) { 1444 case "ArrowLeft": 1445 s === a && (c -= 1), s === n && (d -= 1), s === r && (l -= 1); 1446 break; 1447 case "ArrowUp": 1448 s === a && (c -= 7), s === n && (d -= 3), s === r && (l -= 4); 1449 break; 1450 case "ArrowRight": 1451 s === a && (c += 1), s === n && (d += 1), s === r && (l += 1); 1452 break; 1453 case "ArrowDown": 1454 s === a && (c += 7), s === n && (d += 3), s === r && (l += 4); 1455 } 1456 let u = this.dp.getClampedDate(new Date(l, d, c)); 1457 this.dp.setFocusDate(u, { viewDateTransition: !0 }); 1458 } 1459 registerKey(e) { 1460 this.pressedKeys.add(e); 1461 } 1462 removeKey(e) { 1463 this.pressedKeys.delete(e); 1464 } 1465 } 1466 let I = { 1467 on(e, t) { 1468 this.__events || (this.__events = {}), 1469 this.__events[e] 1470 ? this.__events[e].push(t) 1471 : (this.__events[e] = [t]); 1472 }, 1473 off(e, t) { 1474 this.__events && 1475 this.__events[e] && 1476 (this.__events[e] = this.__events[e].filter((e) => e !== t)); 1477 }, 1478 removeAllEvents() { 1479 this.__events = {}; 1480 }, 1481 trigger(e) { 1482 for ( 1483 var t = arguments.length, i = new Array(t > 1 ? t - 1 : 0), s = 1; 1484 s < t; 1485 s++ 1486 ) 1487 i[s - 1] = arguments[s]; 1488 this.__events && 1489 this.__events[e] && 1490 this.__events[e].forEach((e) => { 1491 e(...i); 1492 }); 1493 }, 1494 }; 1495 function P(e, t, i) { 1496 return ( 1497 (t = (function (e) { 1498 var t = (function (e, t) { 1499 if ("object" != typeof e || null === e) return e; 1500 var i = e[Symbol.toPrimitive]; 1501 if (void 0 !== i) { 1502 var s = i.call(e, t); 1503 if ("object" != typeof s) return s; 1504 throw new TypeError( 1505 "@@toPrimitive must return a primitive value." 1506 ); 1507 } 1508 return String(e); 1509 })(e, "string"); 1510 return "symbol" == typeof t ? t : String(t); 1511 })(t)) in e 1512 ? Object.defineProperty(e, t, { 1513 value: i, 1514 enumerable: !0, 1515 configurable: !0, 1516 writable: !0, 1517 }) 1518 : (e[t] = i), 1519 e 1520 ); 1521 } 1522 let j = "", 1523 R = "", 1524 B = !1; 1525 class K { 1526 static buildGlobalContainer(e) { 1527 (B = !0), (j = n({ className: e, id: e })), a("body").appendChild(j); 1528 } 1529 constructor(e, t) { 1530 var r = this; 1531 if ( 1532 (P(this, "viewIndexes", [i.days, i.months, i.years]), 1533 P(this, "next", () => { 1534 let { year: e, month: t } = this.parsedViewDate; 1535 switch (this.currentView) { 1536 case i.days: 1537 this.setViewDate(new Date(e, t + 1, 1)); 1538 break; 1539 case i.months: 1540 this.setViewDate(new Date(e + 1, t, 1)); 1541 break; 1542 case i.years: 1543 this.setViewDate(new Date(e + 10, 0, 1)); 1544 } 1545 }), 1546 P(this, "prev", () => { 1547 let { year: e, month: t } = this.parsedViewDate; 1548 switch (this.currentView) { 1549 case i.days: 1550 this.setViewDate(new Date(e, t - 1, 1)); 1551 break; 1552 case i.months: 1553 this.setViewDate(new Date(e - 1, t, 1)); 1554 break; 1555 case i.years: 1556 this.setViewDate(new Date(e - 10, 0, 1)); 1557 } 1558 }), 1559 P(this, "_finishHide", () => { 1560 (this.hideAnimation = !1), 1561 this._destroyComponents(), 1562 this.$container.removeChild(this.$datepicker); 1563 }), 1564 P(this, "setPosition", function (e) { 1565 let t = 1566 arguments.length > 1 && void 0 !== arguments[1] && arguments[1]; 1567 if ("function" == typeof (e = e || r.opts.position)) 1568 return void (r.customHide = e({ 1569 $datepicker: r.$datepicker, 1570 $target: r.$el, 1571 $pointer: r.$pointer, 1572 isViewChange: t, 1573 done: r._finishHide, 1574 })); 1575 let i, 1576 s, 1577 { isMobile: a } = r.opts, 1578 n = r.$el.getBoundingClientRect(), 1579 h = r.$el.getBoundingClientRect(), 1580 o = r.$datepicker.offsetParent, 1581 l = r.$el.offsetParent, 1582 d = r.$datepicker.getBoundingClientRect(), 1583 c = e.split(" "), 1584 u = window.scrollY, 1585 p = window.scrollX, 1586 m = r.opts.offset, 1587 v = c[0], 1588 g = c[1]; 1589 if (a) r.$datepicker.style.cssText = "left: 50%; top: 50%"; 1590 else { 1591 if ( 1592 (o === l && 1593 o !== document.body && 1594 ((h = { 1595 top: r.$el.offsetTop, 1596 left: r.$el.offsetLeft, 1597 width: n.width, 1598 height: r.$el.offsetHeight, 1599 }), 1600 (u = 0), 1601 (p = 0)), 1602 o !== l && o !== document.body) 1603 ) { 1604 let e = o.getBoundingClientRect(); 1605 (h = { 1606 top: n.top - e.top, 1607 left: n.left - e.left, 1608 width: n.width, 1609 height: n.height, 1610 }), 1611 (u = 0), 1612 (p = 0); 1613 } 1614 switch (v) { 1615 case "top": 1616 i = h.top - d.height - m; 1617 break; 1618 case "right": 1619 s = h.left + h.width + m; 1620 break; 1621 case "bottom": 1622 i = h.top + h.height + m; 1623 break;
1624 case "left": 1625 s = h.left - d.width - m; 1626 } 1627 switch (g) { 1628 case "top": 1629 i = h.top; 1630 break; 1631 case "right": 1632 s = h.left + h.width - d.width; 1633 break; 1634 case "bottom": 1635 i = h.top + h.height - d.height; 1636 break; 1637 case "left": 1638 s = h.left; 1639 break; 1640 case "center": 1641 /left|right/.test(v) 1642 ? (i = h.top + h.height / 2 - d.height / 2) 1643 : (s = h.left + h.width / 2 - d.width / 2); 1644 } 1645 r.$datepicker.style.cssText = `left: ${s + p}px; top: ${i + u}px`; 1646 } 1647 }), 1648 P(this, "_setInputValue", () => { 1649 let { 1650 opts: e, 1651 $altField: t, 1652 locale: { dateFormat: i }, 1653 } = this, 1654 { altFieldDateFormat: s, altField: a } = e; 1655 a && t && (t.value = this._getInputValue(s)), 1656 (this.$el.value = this._getInputValue(i)); 1657 }), 1658 P(this, "_getInputValue", (e) => { 1659 let { selectedDates: t, opts: i } = this, 1660 { multipleDates: s, multipleDatesSeparator: a } = i; 1661 if (!t.length) return ""; 1662 let n = "function" == typeof e, 1663 r = n ? e(s ? t : t[0]) : t.map((t) => this.formatDate(t, e)); 1664 return (r = n ? r : r.join(a)), r; 1665 }), 1666 P(this, "_checkIfDateIsSelected", function (e) { 1667 let t = 1668 arguments.length > 1 && void 0 !== arguments[1] 1669 ? arguments[1] 1670 : i.days, 1671 s = !1; 1672 return ( 1673 r.selectedDates.some((i) => { 1674 let a = p(e, i, t); 1675 return (s = a && i), a; 1676 }), 1677 s 1678 ); 1679 }), 1680 P(this, "_scheduleCallAfterTransition", (e) => { 1681 this._cancelScheduledCall(), 1682 e && e(!1), 1683 (this._onTransitionEnd = () => { 1684 e && e(!0); 1685 }), 1686 this.$datepicker.addEventListener( 1687 "transitionend", 1688 this._onTransitionEnd, 1689 { once: !0 } 1690 ); 1691 }), 1692 P(this, "_cancelScheduledCall", () => { 1693 this.$datepicker.removeEventListener( 1694 "transitionend", 1695 this._onTransitionEnd 1696 ); 1697 }), 1698 P(this, "setViewDate", (e) => { 1699 if (!((e = k(e)) instanceof Date)) return; 1700 if (p(e, this.viewDate)) return; 1701 let t = this.viewDate; 1702 this.viewDate = e; 1703 let { onChangeViewDate: s } = this.opts; 1704 if (s) { 1705 let { month: e, year: t } = this.parsedViewDate; 1706 s({ month: e, year: t, decade: this.curDecade }); 1707 } 1708 this.trigger(i.eventChangeViewDate, e, t); 1709 }), 1710 P(this, "setFocusDate", function (e) { 1711 let t = 1712 arguments.length > 1 && void 0 !== arguments[1] 1713 ? arguments[1] 1714 : {}; 1715 (!e || (e = k(e)) instanceof Date) && 1716 ((r.focusDate = e), 1717 r.opts.range && e && r._handleRangeOnFocus(), 1718 r.trigger(i.eventChangeFocusDate, e, t)); 1719 }), 1720 P(this, "setCurrentView", (e) => { 1721 if (this.viewIndexes.includes(e)) { 1722 if ( 1723 ((this.currentView = e), 1724 this.elIsInput && this.visible && this.setPosition(void 0, !0), 1725 this.trigger(i.eventChangeCurrentView, e), 1726 !this.views[e]) 1727 ) { 1728 let t = (this.views[e] = new F({ 1729 dp: this, 1730 opts: this.opts, 1731 type: e, 1732 })); 1733 this.shouldUpdateDOM && this.$content.appendChild(t.$el); 1734 } 1735 this.opts.onChangeView && this.opts.onChangeView(e); 1736 } 1737 }), 1738 P(this, "_updateLastSelectedDate", (e) => { 1739 (this.lastSelectedDate = e), 1740 this.trigger(i.eventChangeLastSelectedDate, e); 1741 }), 1742 P(this, "destroy", () => { 1743 let { showEvent: e, isMobile: t } = this.opts, 1744 i = this.$datepicker.parentNode; 1745 i && i.removeChild(this.$datepicker), 1746 this.$el.removeEventListener(e, this._onFocus), 1747 this.$el.removeEventListener("blur", this._onBlur), 1748 window.removeEventListener("resize", this._onResize), 1749 t && this._removeMobileAttributes(), 1750 this.keyboardNav && this.keyboardNav.destroy(), 1751 (this.views = null), 1752 (this.nav = null), 1753 (this.$datepicker = null), 1754 (this.opts = null), 1755 (this.$customContainer = null), 1756 (this.viewDate = null), 1757 (this.focusDate = null), 1758 (this.selectedDates = null), 1759 (this.rangeDateFrom = null), 1760 (this.rangeDateTo = null); 1761 }), 1762 P(this, "update", (e) => { 1763 let t = b({}, this.opts); 1764 b(this.opts, e); 1765 let { 1766 timepicker: s, 1767 buttons: a, 1768 range: n, 1769 selectedDates: r, 1770 isMobile: h, 1771 } = this.opts, 1772 o = this.visible || this.treatAsInline; 1773 this._createMinMaxDates(), 1774 this._limitViewDateByMaxMinDates(), 1775 this._handleLocale(), 1776 !t.selectedDates && r && this.selectDate(r), 1777 e.view && this.setCurrentView(e.view), 1778 this._setInputValue(), 1779 t.range && !n 1780 ? ((this.rangeDateTo = !1), (this.rangeDateFrom = !1)) 1781 : !t.range && 1782 n && 1783 this.selectedDates.length && 1784 ((this.rangeDateFrom = this.selectedDates[0]), 1785 (this.rangeDateTo = this.selectedDates[1])), 1786 t.timepicker && !s
1787 ? (o && this.timepicker.destroy(), 1788 (this.timepicker = !1), 1789 this.$timepicker.parentNode.removeChild(this.$timepicker)) 1790 : !t.timepicker && s && this._addTimepicker(), 1791 !t.buttons && a 1792 ? this._addButtons() 1793 : t.buttons && !a 1794 ? (this.buttons.destroy(), 1795 this.$buttons.parentNode.removeChild(this.$buttons)) 1796 : o && t.buttons && a && this.buttons.clearHtml().render(), 1797 !t.isMobile && h 1798 ? (this.treatAsInline || R || this._createMobileOverlay(), 1799 this._addMobileAttributes(), 1800 this.visible && this._showMobileOverlay()) 1801 : t.isMobile && 1802 !h && 1803 (this._removeMobileAttributes(), 1804 this.visible && 1805 (R.classList.remove("-active-"), 1806 "function" != typeof this.opts.position && 1807 this.setPosition())), 1808 o && 1809 (this.nav.update(), 1810 this.views[this.currentView].render(), 1811 this.currentView === i.days && 1812 this.views[this.currentView].renderDayNames()); 1813 }), 1814 P(this, "isOtherMonth", (e) => { 1815 let { month: t } = o(e); 1816 return t !== this.parsedViewDate.month; 1817 }), 1818 P(this, "isOtherYear", (e) => { 1819 let { year: t } = o(e); 1820 return t !== this.parsedViewDate.year; 1821 }), 1822 P(this, "isOtherDecade", (e) => { 1823 let { year: t } = o(e), 1824 [i, s] = c(this.viewDate); 1825 return t < i || t > s; 1826 }), 1827 P(this, "_onChangeSelectedDate", (e) => { 1828 let { silent: t } = e; 1829 setTimeout(() => { 1830 this._setInputValue(), 1831 this.opts.onSelect && !t && this._triggerOnSelect(); 1832 }); 1833 }), 1834 P(this, "_onChangeFocusedDate", function (e) { 1835 let { viewDateTransition: t } = 1836 arguments.length > 1 && void 0 !== arguments[1] 1837 ? arguments[1] 1838 : {}; 1839 if (!e) return; 1840 let i = !1; 1841 t && 1842 (i = r.isOtherMonth(e) || r.isOtherYear(e) || r.isOtherDecade(e)), 1843 i && r.setViewDate(e); 1844 }), 1845 P(this, "_onChangeTime", (e) => { 1846 let { hours: t, minutes: i } = e, 1847 s = new Date(), 1848 { 1849 lastSelectedDate: a, 1850 opts: { onSelect: n }, 1851 } = this, 1852 r = a; 1853 a || (r = s); 1854 let h = this.getCell(r, this.currentViewSingular), 1855 o = h && h.adpCell; 1856 (o && o.isDisabled) || 1857 (r.setHours(t), 1858 r.setMinutes(i), 1859 a 1860 ? (this._setInputValue(), n && this._triggerOnSelect()) 1861 : this.selectDate(r)); 1862 }), 1863 P(this, "_onFocus", (e) => { 1864 this.visible || this.show(); 1865 }), 1866 P(this, "_onBlur", (e) => { 1867 this.inFocus || !this.visible || this.opts.isMobile || this.hide(); 1868 }), 1869 P(this, "_onMouseDown", (e) => { 1870 this.inFocus = !0; 1871 }), 1872 P(this, "_onMouseUp", (e) => { 1873 (this.inFocus = !1), this.$el.focus(); 1874 }), 1875 P(this, "_onResize", () => { 1876 this.visible && 1877 "function" != typeof this.opts.position && 1878 this.setPosition(); 1879 }), 1880 P(this, "_onClickOverlay", () => { 1881 this.visible && this.hide(); 1882 }), 1883 P(this, "isWeekend", (e) => this.opts.weekends.includes(e)), 1884 P(this, "getClampedDate", (e) => { 1885 let { minDate: t, maxDate: i } = this, 1886 s = e; 1887 return i && m(e, i) ? (s = i) : t && v(e, t) && (s = t), s; 1888 }), 1889 (this.$el = a(e)), 1890 !this.$el) 1891 ) 1892 return; 1893 (this.$datepicker = n({ className: "air-datepicker" })), 1894 (this.opts = b({}, s, t)), 1895 (this.$customContainer = 1896 !!this.opts.container && a(this.opts.container)), 1897 (this.$altField = a(this.opts.altField || !1)); 1898 let { view: h, startDate: l } = this.opts; 1899 l || (this.opts.startDate = new Date()), 1900 "INPUT" === this.$el.nodeName && (this.elIsInput = !0), 1901 (this.inited = !1), 1902 (this.visible = !1), 1903 (this.viewDate = k(this.opts.startDate)), 1904 (this.focusDate = !1), 1905 (this.initialReadonly = this.$el.getAttribute("readonly")), 1906 (this.customHide = !1), 1907 (this.currentView = h), 1908 (this.selectedDates = []), 1909 (this.views = {}), 1910 (this.keys = []), 1911 (this.rangeDateFrom = ""), 1912 (this.rangeDateTo = ""), 1913 (this.timepickerIsActive = !1), 1914 (this.treatAsInline = this.opts.inline || !this.elIsInput), 1915 this.init(); 1916 } 1917 init() { 1918 let { 1919 opts: e, 1920 treatAsInline: t, 1921 opts: { 1922 inline: i, 1923 isMobile: s, 1924 selectedDates: n, 1925 keyboardNav: r, 1926 onlyTimepicker: h, 1927 }, 1928 } = this, 1929 o = a("body"); 1930 (!B || (B && j && !o.contains(j))) && 1931 !i && 1932 this.elIsInput && 1933 !this.$customContainer && 1934 K.buildGlobalContainer(K.defaultGlobalContainerId), 1935 !s || R || t || this._createMobileOverlay(), 1936 this._handleLocale(), 1937 this._bindSubEvents(), 1938 this._createMinMaxDates(), 1939 this._limitViewDateByMaxMinDates(), 1940 this.elIsInput && 1941 (i || this._bindEvents(), 1942 r && !h && (this.keyboardNav = new N({ dp: this, opts: e }))), 1943 n && this.selectDate(n, { silent: !0 }), 1944 this.opts.visible && !t && this.show(),
1945 s && !t && this.$el.setAttribute("readonly", !0), 1946 t && this._createComponents(); 1947 } 1948 _createMobileOverlay() { 1949 (R = n({ className: "air-datepicker-overlay" })), j.appendChild(R); 1950 } 1951 _createComponents() { 1952 let { 1953 opts: e, 1954 treatAsInline: t, 1955 opts: { 1956 inline: i, 1957 buttons: s, 1958 timepicker: a, 1959 position: n, 1960 classes: r, 1961 onlyTimepicker: h, 1962 isMobile: o, 1963 }, 1964 } = this; 1965 this._buildBaseHtml(), 1966 this.elIsInput && (i || this._setPositionClasses(n)), 1967 (!i && this.elIsInput) || this.$datepicker.classList.add("-inline-"), 1968 r && this.$datepicker.classList.add(...r.split(" ")), 1969 h && this.$datepicker.classList.add("-only-timepicker-"), 1970 o && !t && this._addMobileAttributes(), 1971 (this.views[this.currentView] = new F({ 1972 dp: this, 1973 type: this.currentView, 1974 opts: e, 1975 })), 1976 (this.nav = new x({ dp: this, opts: e })), 1977 a && this._addTimepicker(), 1978 s && this._addButtons(), 1979 this.$content.appendChild(this.views[this.currentView].$el), 1980 this.$nav.appendChild(this.nav.$el); 1981 } 1982 _destroyComponents() { 1983 for (let e in this.views) this.views[e].destroy(); 1984 (this.views = {}), 1985 this.nav.destroy(), 1986 this.timepicker && this.timepicker.destroy(); 1987 } 1988 _addMobileAttributes() { 1989 R.addEventListener("click", this._onClickOverlay), 1990 this.$datepicker.classList.add("-is-mobile-"), 1991 this.$el.setAttribute("readonly", !0); 1992 } 1993 _removeMobileAttributes() { 1994 R.removeEventListener("click", this._onClickOverlay), 1995 this.$datepicker.classList.remove("-is-mobile-"), 1996 this.initialReadonly || 1997 "" === this.initialReadonly || 1998 this.$el.removeAttribute("readonly"); 1999 } 2000 _createMinMaxDates() { 2001 let { minDate: e, maxDate: t } = this.opts; 2002 (this.minDate = !!e && k(e)), (this.maxDate = !!t && k(t)); 2003 } 2004 _addTimepicker() { 2005 (this.$timepicker = n({ className: "air-datepicker--time" })), 2006 this.$datepicker.appendChild(this.$timepicker), 2007 (this.timepicker = new O({ dp: this, opts: this.opts })), 2008 this.$timepicker.appendChild(this.timepicker.$el); 2009 } 2010 _addButtons() { 2011 (this.$buttons = n({ className: "air-datepicker--buttons" })), 2012 this.$datepicker.appendChild(this.$buttons), 2013 (this.buttons = new E({ dp: this, opts: this.opts })), 2014 this.$buttons.appendChild(this.buttons.$el); 2015 } 2016 _bindSubEvents() { 2017 this.on(i.eventChangeSelectedDate, this._onChangeSelectedDate), 2018 this.on(i.eventChangeFocusDate, this._onChangeFocusedDate), 2019 this.on(i.eventChangeTime, this._onChangeTime); 2020 } 2021 _buildBaseHtml() { 2022 let { inline: e } = this.opts; 2023 var t, i; 2024 this.elIsInput 2025 ? e 2026 ? ((t = this.$datepicker), 2027 (i = this.$el).parentNode.insertBefore(t, i.nextSibling)) 2028 : this.$container.appendChild(this.$datepicker) 2029 : this.$el.appendChild(this.$datepicker), 2030 (this.$datepicker.innerHTML = 2031 '<i class="air-datepicker--pointer"></i><div class="air-datepicker--navigation"></div><div class="air-datepicker--content"></div>'), 2032 (this.$content = a(".air-datepicker--content", this.$datepicker)), 2033 (this.$pointer = a(".air-datepicker--pointer", this.$datepicker)), 2034 (this.$nav = a(".air-datepicker--navigation", this.$datepicker)); 2035 } 2036 _handleLocale() { 2037 let { 2038 locale: e, 2039 dateFormat: t, 2040 firstDay: i, 2041 timepicker: s, 2042 onlyTimepicker: a, 2043 timeFormat: n, 2044 dateTimeSeparator: r, 2045 } = this.opts; 2046 var h; 2047 (this.locale = ((h = e), JSON.parse(JSON.stringify(h)))), 2048 t && (this.locale.dateFormat = t), 2049 void 0 !== n && "" !== n && (this.locale.timeFormat = n); 2050 let { timeFormat: o } = this.locale; 2051 if ( 2052 ("" !== i && (this.locale.firstDay = i), s && "function" != typeof t) 2053 ) { 2054 let e = o ? r : ""; 2055 this.locale.dateFormat = [this.locale.dateFormat, o || ""].join(e); 2056 } 2057 a && 2058 "function" != typeof t && 2059 (this.locale.dateFormat = this.locale.timeFormat); 2060 } 2061 _setPositionClasses(e) { 2062 if ("function" == typeof e) 2063 return void this.$datepicker.classList.add("-custom-position-"); 2064 let t = (e = e.split(" "))[0], 2065 i = `air-datepicker -${t}-${e[1]}- -from-${t}-`; 2066 this.$datepicker.classList.add(...i.split(" ")); 2067 } 2068 _bindEvents() { 2069 this.$el.addEventListener(this.opts.showEvent, this._onFocus), 2070 this.$el.addEventListener("blur", this._onBlur), 2071 this.$datepicker.addEventListener("mousedown", this._onMouseDown), 2072 this.$datepicker.addEventListener("mouseup", this._onMouseUp), 2073 window.addEventListener("resize", this._onResize); 2074 } 2075 _limitViewDateByMaxMinDates() { 2076 let { viewDate: e, minDate: t, maxDate: i } = this; 2077 i && m(e, i) && this.setViewDate(i), 2078 t && v(e, t) && this.setViewDate(t); 2079 } 2080 formatDate() { 2081 let e = 2082 arguments.length > 0 && void 0 !== arguments[0] 2083 ? arguments[0] 2084 : this.viewDate, 2085 t = arguments.length > 1 ? arguments[1] : void 0; 2086 if (((e = k(e)), !(e instanceof Date))) return; 2087 let i = t, 2088 s = this.locale, 2089 a = o(e), 2090 n = a.dayPeriod, 2091 r = c(e), 2092 h = K.replacer, 2093 l = { 2094 T: e.getTime(), 2095 m: a.minutes, 2096 mm: a.fullMinutes, 2097 h: a.hours12, 2098 hh: a.fullHours12, 2099 H: a.hours, 2100 HH: a.fullHours, 2101 aa: n, 2102 AA: n.toUpperCase(), 2103 E: s.daysShort[a.day], 2104 EEEE: s.days[a.day], 2105 d: a.date, 2106 dd: a.fullDate, 2107 M: a.month + 1, 2108 MM: a.fullMonth, 2109 MMM: s.monthsShort[a.month], 2110 MMMM: s.months[a.month], 2111 yy: a.year.toString().slice(-2), 2112 yyyy: a.year, 2113 yyyy1: r[0], 2114 yyyy2: r[1], 2115 }; 2116 for (let [e, t] of Object.entries(l)) i = h(i, C(e), t); 2117 return i; 2118 } 2119 down(e) { 2120 this._handleUpDownActions(e, "down"); 2121 } 2122 up(e) { 2123 this._handleUpDownActions(e, "up"); 2124 } 2125 selectDate(e) { 2126 let t, 2127 s = 2128 arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : {}, 2129 { currentView: a, parsedViewDate: n, selectedDates: r } = this, 2130 { updateTime: h } = s, 2131 { 2132 moveToOtherMonthsOnSelect: o, 2133 moveToOtherYearsOnSelect: l, 2134 multipleDates: d, 2135 range: c, 2136 autoClose: u, 2137 } = this.opts, 2138 p = r.length; 2139 if (Array.isArray(e)) 2140 return ( 2141 e.forEach((e) => { 2142 this.selectDate(e, s); 2143 }), 2144 new Promise((e) => { 2145 setTimeout(e); 2146 }) 2147 ); 2148 if ((e = k(e)) instanceof Date) { 2149 if ( 2150 (a === i.days && 2151 e.getMonth() !== n.month && 2152 o && 2153 (t = new Date(e.getFullYear(), e.getMonth(), 1)), 2154 a === i.years && 2155 e.getFullYear() !== n.year && 2156 l && 2157 (t = new Date(e.getFullYear(), 0, 1)), 2158 t && this.setViewDate(t), 2159 d && !c) 2160 ) { 2161 if (p === d) return; 2162 this._checkIfDateIsSelected(e) || r.push(e); 2163 } else if (c) 2164 switch (p) { 2165 case 1: 2166 r.push(e), 2167 this.rangeDateTo || (this.rangeDateTo = e), 2168 m(this.rangeDateFrom, this.rangeDateTo) && 2169 ((this.rangeDateTo = this.rangeDateFrom), 2170 (this.rangeDateFrom = e)), 2171 (this.selectedDates = [this.rangeDateFrom, this.rangeDateTo]); 2172 break; 2173 case 2: 2174 (this.selectedDates = [e]), 2175 (this.rangeDateFrom = e), 2176 (this.rangeDateTo = ""); 2177 break; 2178 default: 2179 (this.selectedDates = [e]), (this.rangeDateFrom = e); 2180 } 2181 else this.selectedDates = [e]; 2182 return ( 2183 this.trigger(i.eventChangeSelectedDate, { 2184 action: i.actionSelectDate, 2185 silent: null == s ? void 0 : s.silent, 2186 date: e, 2187 updateTime: h, 2188 }), 2189 this._updateLastSelectedDate(e), 2190 u && 2191 !this.timepickerIsActive && 2192 this.visible && 2193 (d || c ? c && 1 === p && this.hide() : this.hide()), 2194 new Promise((e) => { 2195 setTimeout(e); 2196 }) 2197 ); 2198 } 2199 } 2200 unselectDate(e) { 2201 let t = this.selectedDates, 2202 s = this; 2203 if ((e = k(e)) instanceof Date) 2204 return t.some((a, n) => { 2205 if (p(a, e)) 2206 return ( 2207 t.splice(n, 1), 2208 s.selectedDates.length 2209 ? s._updateLastSelectedDate( 2210 s.selectedDates[s.selectedDates.length - 1] 2211 ) 2212 : ((s.rangeDateFrom = ""), 2213 (s.rangeDateTo = ""), 2214 s._updateLastSelectedDate(!1)), 2215 this.trigger(i.eventChangeSelectedDate, { 2216 action: i.actionUnselectDate, 2217 date: e, 2218 }), 2219 !0 2220 ); 2221 });
2222 } 2223 replaceDate(e, t) { 2224 let s = this.selectedDates.find((t) => p(t, e, this.currentView)), 2225 a = this.selectedDates.indexOf(s); 2226 a < 0 || 2227 p(this.selectedDates[a], t, this.currentView) || 2228 ((this.selectedDates[a] = t), 2229 this.trigger(i.eventChangeSelectedDate, { 2230 action: i.actionSelectDate, 2231 date: t, 2232 updateTime: !0, 2233 }), 2234 this._updateLastSelectedDate(t)); 2235 } 2236 clear() { 2237 let e = 2238 arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : {}; 2239 return ( 2240 (this.selectedDates = []), 2241 (this.rangeDateFrom = !1), 2242 (this.rangeDateTo = !1), 2243 this.trigger(i.eventChangeSelectedDate, { 2244 action: i.actionUnselectDate, 2245 silent: e.silent, 2246 }), 2247 new Promise((e) => { 2248 setTimeout(e); 2249 }) 2250 ); 2251 } 2252 show() { 2253 let { onShow: e, isMobile: t } = this.opts; 2254 this._cancelScheduledCall(), 2255 this.visible || this.hideAnimation || this._createComponents(), 2256 this.setPosition(this.opts.position), 2257 this.$datepicker.classList.add("-active-"), 2258 (this.visible = !0), 2259 e && this._scheduleCallAfterTransition(e), 2260 t && this._showMobileOverlay(); 2261 } 2262 hide() { 2263 let { onHide: e, isMobile: t } = this.opts, 2264 i = this._hasTransition(); 2265 (this.visible = !1), 2266 (this.hideAnimation = !0), 2267 this.$datepicker.classList.remove("-active-"), 2268 this.customHide && this.customHide(), 2269 this.elIsInput && this.$el.blur(), 2270 this._scheduleCallAfterTransition((t) => { 2271 !this.customHide && ((t && i) || (!t && !i)) && this._finishHide(), 2272 e && e(t); 2273 }), 2274 t && R.classList.remove("-active-"); 2275 } 2276 _triggerOnSelect() { 2277 let e = [], 2278 t = [], 2279 { 2280 selectedDates: i, 2281 locale: s, 2282 opts: { onSelect: a, multipleDates: n, range: r }, 2283 } = this, 2284 h = n || r, 2285 o = "function" == typeof s.dateFormat; 2286 i.length && 2287 ((e = i.map(g)), 2288 (t = o 2289 ? n 2290 ? s.dateFormat(e) 2291 : e.map((e) => s.dateFormat(e)) 2292 : e.map((e) => this.formatDate(e, s.dateFormat)))), 2293 a({ 2294 date: h ? e : e[0], 2295 formattedDate: h ? t : t[0], 2296 datepicker: this, 2297 }); 2298 } 2299 _handleAlreadySelectedDates(e, t) { 2300 let { range: i, toggleSelected: s } = this.opts; 2301 i 2302 ? s 2303 ? this.unselectDate(t) 2304 : 2 !== this.selectedDates.length && this.selectDate(t) 2305 : s && this.unselectDate(t), 2306 s || this._updateLastSelectedDate(e); 2307 } 2308 _handleUpDownActions(e, t) { 2309 if (!((e = k(e || this.focusDate || this.viewDate)) instanceof Date)) 2310 return; 2311 let i = "up" === t ? this.viewIndex + 1 : this.viewIndex - 1; 2312 i > 2 && (i = 2), 2313 i < 0 && (i = 0), 2314 this.setViewDate(new Date(e.getFullYear(), e.getMonth(), 1)), 2315 this.setCurrentView(this.viewIndexes[i]); 2316 } 2317 _handleRangeOnFocus() { 2318 1 === this.selectedDates.length && 2319 (m(this.selectedDates[0], this.focusDate) 2320 ? ((this.rangeDateTo = this.selectedDates[0]), 2321 (this.rangeDateFrom = this.focusDate)) 2322 : ((this.rangeDateTo = this.focusDate), 2323 (this.rangeDateFrom = this.selectedDates[0]))); 2324 } 2325 getCell(e) { 2326 let t = 2327 arguments.length > 1 && void 0 !== arguments[1] 2328 ? arguments[1] 2329 : i.day; 2330 if (!((e = k(e)) instanceof Date)) return; 2331 let { year: s, month: a, date: n } = o(e), 2332 r = `[data-year="${s}"]`, 2333 h = `[data-month="${a}"]`, 2334 l = { 2335 [i.day]: `${r}${h}[data-date="${n}"]`, 2336 [i.month]: `${r}${h}`, 2337 [i.year]: `${r}`, 2338 }; 2339 return this.views[this.currentView].$el.querySelector(l[t]); 2340 } 2341 _showMobileOverlay() { 2342 R.classList.add("-active-"); 2343 } 2344 _hasTransition() { 2345 return ( 2346 window 2347 .getComputedStyle(this.$datepicker) 2348 .getPropertyValue("transition-duration") 2349 .split(", ") 2350 .reduce((e, t) => parseFloat(t) + e, 0) > 0 2351 ); 2352 } 2353 get shouldUpdateDOM() { 2354 return this.visible || this.treatAsInline; 2355 } 2356 get parsedViewDate() { 2357 return o(this.viewDate); 2358 } 2359 get currentViewSingular() { 2360 return this.currentView.slice(0, -1); 2361 } 2362 get curDecade() { 2363 return c(this.viewDate); 2364 } 2365 get viewIndex() { 2366 return this.viewIndexes.indexOf(this.currentView); 2367 } 2368 get isFinalView() { 2369 return this.currentView === i.years; 2370 } 2371 get hasSelectedDates() { 2372 return this.selectedDates.length > 0;
2373 } 2374 get isMinViewReached() { 2375 return ( 2376 this.currentView === this.opts.minView || this.currentView === i.days 2377 ); 2378 } 2379 get $container() { 2380 return this.$customContainer || j; 2381 } 2382 static replacer(e, t, i) { 2383 return e.replace(t, function (e, t, s, a) { 2384 return t + i + a; 2385 }); 2386 } 2387 } 2388 var U; 2389 return ( 2390 P(K, "defaults", s), 2391 P(K, "version", "3.3.5"), 2392 P(K, "defaultGlobalContainerId", "air-datepicker-global-container"), 2393 (U = K.prototype), 2394 Object.assign(U, I), 2395 t.default 2396 ); 2397 })(); 2398});
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.