PluginProbe
LearnPress – WordPress LMS Plugin for Create and Sell Online Courses / 4.4.4
LearnPress – WordPress LMS Plugin for Create and Sell Online Courses v4.4.4
4.4.9 4.4.8 4.4.7 4.4.6 4.4.5 4.4.4 4.4.3 4.4.2 4.4.1 4.4.0 4.3.9.1 4.3.9 4.3.8 4.3.7 4.1.6.9 4.1.6.9.1 4.1.6.9.2 4.1.6.9.3 4.1.6.9.4 4.1.7 4.1.7.1 4.1.7.2 4.1.7.3 4.1.7.3.1 4.1.7.3.2 All 140 releases
learnpress / assets / dist / js / admin / admin-courses.js

admin-courses.js in LearnPress – WordPress LMS Plugin for Create and Sell Online Courses 4.4.4, at assets/dist/js/admin/admin-courses.js

6,998 lines 250.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 /******/ (() => { // webpackBootstrap
2 /******/ var __webpack_modules__ = ({
3
4 /***/ "./assets/src/js/admin/courses/generate-with-ai.js"
5 /*!*********************************************************!*\
6 !*** ./assets/src/js/admin/courses/generate-with-ai.js ***!
7 \*********************************************************/
8 (__unused_webpack_module, __webpack_exports__, __webpack_require__) {
9
10 "use strict";
11 __webpack_require__.r(__webpack_exports__);
12 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
13 /* harmony export */ CreateCourseViaAI: () => (/* binding */ CreateCourseViaAI)
14 /* harmony export */ });
15 /* harmony import */ var lpAssetsJsPath_utils_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! lpAssetsJsPath/utils.js */ "./assets/src/js/utils.js");
16 /* harmony import */ var sweetalert2__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! sweetalert2 */ "./node_modules/sweetalert2/dist/sweetalert2.all.js");
17 /* harmony import */ var sweetalert2__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(sweetalert2__WEBPACK_IMPORTED_MODULE_1__);
18 /* harmony import */ var lpAssetsJsPath_lpToastify_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! lpAssetsJsPath/lpToastify.js */ "./assets/src/js/lpToastify.js");
19 /**
20 * Create course with AI
21 */
22
23
24
25
26 let lp_structure_course;
27 let lp_is_generating_course_data = false;
28 const lp_course_ai_setting = JSON.parse(localStorage.getItem('lp_course_ai_setting')) || {};
29 class CreateCourseViaAI {
30 constructor(options = {}) {
31 this.options = {
32 autoInsertButton: true,
33 isCourseBuilder: false,
34 redirectDelayMs: 2000,
35 ...options
36 };
37 this.init();
38 }
39 static selectors = {
40 elGenerateDataAiWrap: '.lp-generate-data-ai-wrap'
41 };
42 init() {
43 if (this.options.autoInsertButton) {
44 if (!lpData?.enable_open_ai) {
45 lpAssetsJsPath_utils_js__WEBPACK_IMPORTED_MODULE_0__.lpOnElementReady('.page-title-action', el => {
46 el.insertAdjacentHTML('afterend', `<button type="button" class="lp-btn-warning-enable-ai lp-btn-ai-style">
47 <i class="lp-ico-ai"></i>
48 <span>${lpData.i18n.generate_with_ai}</span>
49 </button>`);
50 });
51 } else {
52 lpAssetsJsPath_utils_js__WEBPACK_IMPORTED_MODULE_0__.lpOnElementReady('.page-title-action', el => {
53 el.insertAdjacentHTML('afterend', `<button type="button" class="lp-btn-generate-course-with-ai lp-btn-ai-style">
54 <i class="lp-ico-ai"></i>
55 <span>${lpData.i18n.generate_with_ai}</span>
56 </button>`);
57 });
58 }
59 }
60 this.events();
61 }
62 events() {
63 if (CreateCourseViaAI._loadedEvents) {
64 return;
65 }
66 CreateCourseViaAI._loadedEvents = true;
67 lpAssetsJsPath_utils_js__WEBPACK_IMPORTED_MODULE_0__.eventHandlers('click', [{
68 selector: '.lp-btn-warning-enable-ai',
69 class: this,
70 callBack: this.showPopupEnableAI.name
71 }, {
72 selector: '.lp-btn-generate-course-with-ai',
73 class: this,
74 callBack: this.showPopupCreateFullCourse.name
75 }, {
76 selector: '.lp-btn-step',
77 class: this,
78 callBack: this.showStep.name
79 }, {
80 selector: '.lp-btn-generate-prompt',
81 class: this,
82 callBack: this.generatePrompt.name
83 }, {
84 selector: '.lp-btn-call-open-ai',
85 class: this,
86 callBack: this.generateDataCourse.name
87 }, {
88 selector: '.lp-btn-create-course',
89 class: this,
90 callBack: this.createCourse.name
91 }, {
92 selector: '.lp-btn-close-ai-popup',
93 //class: this,
94 callBack: args => {
95 const {
96 e,
97 target
98 } = args;
99 const message = lpData?.i18n?.confirm_close_ai || 'Are you sure you want to close? Generate data will stop.';
100 if (!lp_is_generating_course_data) {
101 sweetalert2__WEBPACK_IMPORTED_MODULE_1___default().close();
102 } else if (confirm(message)) {
103 sweetalert2__WEBPACK_IMPORTED_MODULE_1___default().close();
104 }
105
106 // Testing custom confirm box
107 /*if ( confirm( message ) ) {
108 SweetAlert.close();
109 }*/
110 }
111 }]);
112 }
113
114 // Show popup warning enable AI before using.
115 showPopupEnableAI() {
116 const modalTemplate = document.querySelector('#lp-tmpl-must-enable-ai');
117 if (!modalTemplate) {
118 console.error('Enable OpenAI Modal Template not found!');
119 return;
120 }
121 sweetalert2__WEBPACK_IMPORTED_MODULE_1___default().fire({
122 html: modalTemplate.innerHTML,
123 width: '420px',
124 showCloseButton: false,
125 showConfirmButton: false
126 });
127 }
128 showPopupCreateFullCourse() {
129 const modalTemplate = document.querySelector('#lp-tmpl-create-course-ai');
130 if (!modalTemplate) {
131 console.error('AI Create Full Course Modal Template not found!');
132 return;
133 }
134 sweetalert2__WEBPACK_IMPORTED_MODULE_1___default().fire({
135 html: modalTemplate.innerHTML,
136 width: '60%',
137 showCloseButton: false,
138 showConfirmButton: false,
139 allowOutsideClick: false,
140 allowEscapeKey: false,
141 didOpen: () => {
142 const popup = sweetalert2__WEBPACK_IMPORTED_MODULE_1___default().getPopup();
143 popup.click();
144 const targetAudience = popup.querySelector('select[name="target_audience"]');
145 if (targetAudience && lp_course_ai_setting?.target_audience) {
146 targetAudience.tomselect.setValue(lp_course_ai_setting.target_audience);
147 }
148 const tone = popup.querySelector('select[name="tone"]');
149 if (tone && lp_course_ai_setting?.tone) {
150 tone.tomselect.setValue(lp_course_ai_setting.tone);
151 }
152 const language = popup.querySelector('select[name="language"]');
153 if (language && lp_course_ai_setting?.language) {
154 language.tomselect.setValue(lp_course_ai_setting.language);
155 }
156 targetAudience.addEventListener('change', event => {
157 lp_course_ai_setting.target_audience = targetAudience.tomselect.getValue();
158 localStorage.setItem('lp_course_ai_setting', JSON.stringify(lp_course_ai_setting));
159 });
160 tone.addEventListener('change', event => {
161 lp_course_ai_setting.tone = tone.tomselect.getValue();
162 localStorage.setItem('lp_course_ai_setting', JSON.stringify(lp_course_ai_setting));
163 });
164 language.addEventListener('change', event => {
165 const value = language.tomselect.getValue();
166 lp_course_ai_setting.language = value ? [value] : [];
167 localStorage.setItem('lp_course_ai_setting', JSON.stringify(lp_course_ai_setting));
168 });
169 }
170 }).then(result => {
171 if (result.isDismissed) {
172 if (lp_is_generating_course_data) {
173 lp_is_generating_course_data = false;
174 }
175 }
176 });
177 }
178 showStep(args) {
179 const {
180 e,
181 target
182 } = args;
183 e.preventDefault();
184 const elBtnActions = target.closest('.button-actions');
185 const elCreateCourseAIWrap = elBtnActions.closest(CreateCourseViaAI.selectors.elGenerateDataAiWrap);
186 let step = parseInt(elBtnActions.dataset.step);
187 const stepAction = target.dataset.action;
188 if (stepAction === 'next') {
189 step++;
190 } else if (stepAction === 'prev') {
191 step--;
192 }
193 elBtnActions.dataset.step = step;
194 const elForm = target.closest('form');
195 const elContentStep = elForm.querySelector(`.step-content[data-step="${step}"]`);
196 const elItemStep = elCreateCourseAIWrap.querySelector(`.step-item[data-step="${step}"]`);
197 elForm.querySelectorAll('.step-content').forEach(el => el.classList.remove('active'));
198 elContentStep.classList.add('active');
199 elCreateCourseAIWrap.querySelectorAll('.step-item').forEach(el => el.classList.remove('active'));
200 elItemStep.classList.add('active');
201
202 // Get all buttons step to show/hide
203 const form = target.closest('form');
204 const elBtnSteps = form.querySelectorAll('button[data-step-show]');
205 elBtnSteps.forEach(el => {
206 const stepsShow = el.dataset.stepShow.split(',').map(s => parseInt(s.trim()));
207 if (stepsShow.includes(step)) {
208 lpAssetsJsPath_utils_js__WEBPACK_IMPORTED_MODULE_0__.lpShowHideEl(el, 1);
209 } else {
210 lpAssetsJsPath_utils_js__WEBPACK_IMPORTED_MODULE_0__.lpShowHideEl(el, 0);
211 }
212 });
213 }
214
215 /**
216 * Create prompt from data config
217 * @param args
218 */
219 generatePrompt(args) {
220 const {
221 e,
222 target
223 } = args;
224 e.preventDefault();
225 lpAssetsJsPath_utils_js__WEBPACK_IMPORTED_MODULE_0__.lpSetLoadingEl(target, true);
226
227 // Get dataSend
228 const form = target.closest('form');
229 let dataSend = JSON.parse(target.dataset.send);
230 dataSend = lpAssetsJsPath_utils_js__WEBPACK_IMPORTED_MODULE_0__.mergeDataWithDatForm(form, dataSend);
231
232 // Ajax to generate prompt
233 const callBack = {
234 success: response => {
235 const {
236 message,
237 status,
238 data
239 } = response;
240 lpAssetsJsPath_lpToastify_js__WEBPACK_IMPORTED_MODULE_2__.show(message, status);
241 if (status === 'success') {
242 const elBtnNext = form.querySelector('.lp-btn-step[data-action=next]');
243 elBtnNext.click();
244 const elPromptTextarea = form.querySelector('textarea[name=lp-openai-prompt-generated-field]');
245 elPromptTextarea.value = data;
246 }
247 },
248 error: error => {
249 lpAssetsJsPath_lpToastify_js__WEBPACK_IMPORTED_MODULE_2__.show(error, 'error');
250 },
251 completed: () => {
252 lpAssetsJsPath_utils_js__WEBPACK_IMPORTED_MODULE_0__.lpSetLoadingEl(target, false);
253 }
254 };
255 window.lpAJAXG.fetchAJAX(dataSend, callBack);
256 }
257
258 /**
259 * Submit prompt to OpenAI to generate course data
260 * @param args
261 */
262 generateDataCourse(args) {
263 const {
264 e,
265 target
266 } = args;
267 e.preventDefault();
268 lpAssetsJsPath_utils_js__WEBPACK_IMPORTED_MODULE_0__.lpSetLoadingEl(target, true);
269
270 // Get dataSend
271 const form = target.closest('form');
272 let dataSend = JSON.parse(target.dataset.send);
273 dataSend = lpAssetsJsPath_utils_js__WEBPACK_IMPORTED_MODULE_0__.mergeDataWithDatForm(form, dataSend);
274 const btnPrev = form.querySelector('.lp-btn-step[data-action=prev]');
275 lpAssetsJsPath_utils_js__WEBPACK_IMPORTED_MODULE_0__.lpShowHideEl(btnPrev, 0);
276
277 // Ajax to generate prompt
278 const callBack = {
279 success: response => {
280 const {
281 message,
282 status,
283 data
284 } = response;
285 if (lp_is_generating_course_data) {
286 lpAssetsJsPath_lpToastify_js__WEBPACK_IMPORTED_MODULE_2__.show(message, status);
287 }
288 if (status === 'success') {
289 // Save structure data
290 lp_structure_course = data.lp_structure_course;
291
292 // Set preview HTML
293 const elResults = form.querySelector('.lp-ai-generated-results');
294 elResults.innerHTML = data.lp_html_preview;
295 const elBtnNext = form.querySelector('.lp-btn-step[data-action=next]');
296 elBtnNext.click();
297 }
298 },
299 error: error => {
300 lpAssetsJsPath_lpToastify_js__WEBPACK_IMPORTED_MODULE_2__.show(error, 'error');
301 },
302 completed: () => {
303 lpAssetsJsPath_utils_js__WEBPACK_IMPORTED_MODULE_0__.lpSetLoadingEl(target, false);
304 lpAssetsJsPath_utils_js__WEBPACK_IMPORTED_MODULE_0__.lpShowHideEl(btnPrev, 1);
305 lp_is_generating_course_data = false;
306 }
307 };
308 lp_is_generating_course_data = true;
309 window.lpAJAXG.fetchAJAX(dataSend, callBack);
310 }
311
312 /**
313 * Create course with data of OpenAI
314 * @param args
315 */
316 createCourse(args) {
317 const {
318 e,
319 target
320 } = args;
321 e.preventDefault();
322 lpAssetsJsPath_utils_js__WEBPACK_IMPORTED_MODULE_0__.lpSetLoadingEl(target, true);
323
324 // Get dataSend
325 const dataSend = JSON.parse(target.dataset.send);
326 dataSend.lp_structure_course = lp_structure_course;
327 if (this.options.isCourseBuilder) {
328 dataSend.is_course_builder = 1;
329 }
330 const form = target.closest('form');
331 const elBtnPrev = form.querySelector('.lp-btn-step[data-action=prev]');
332 lpAssetsJsPath_utils_js__WEBPACK_IMPORTED_MODULE_0__.lpShowHideEl(elBtnPrev, 0);
333 const windowWidth = window.outerWidth;
334 let alertWidth;
335 if (windowWidth < 768) {
336 alertWidth = '90%';
337 } else {
338 alertWidth = '30%';
339 }
340 const creatingCourseAiModal = document.querySelector('#lp-tmpl-creating-course-ai');
341 sweetalert2__WEBPACK_IMPORTED_MODULE_1___default().fire({
342 html: creatingCourseAiModal.innerHTML,
343 showCloseButton: false,
344 showConfirmButton: false,
345 allowOutsideClick: false,
346 width: alertWidth
347 });
348
349 // Ajax to generate prompt
350 const callBack = {
351 success: response => {
352 const {
353 message,
354 status,
355 data
356 } = response;
357 sweetalert2__WEBPACK_IMPORTED_MODULE_1___default().close();
358 lpAssetsJsPath_lpToastify_js__WEBPACK_IMPORTED_MODULE_2__.show(message, status);
359 if (status === 'success') {
360 setTimeout(() => {
361 window.location.href = data.edit_course_url;
362 }, this.options.redirectDelayMs);
363 } else {
364 lpAssetsJsPath_utils_js__WEBPACK_IMPORTED_MODULE_0__.lpShowHideEl(elBtnPrev, 1);
365 }
366 },
367 error: error => {
368 lpAssetsJsPath_lpToastify_js__WEBPACK_IMPORTED_MODULE_2__.show(error, 'error');
369 lpAssetsJsPath_utils_js__WEBPACK_IMPORTED_MODULE_0__.lpShowHideEl(elBtnPrev, 1);
370 },
371 completed: () => {
372 lpAssetsJsPath_utils_js__WEBPACK_IMPORTED_MODULE_0__.lpSetLoadingEl(target, false);
373 }
374 };
375 window.lpAJAXG.fetchAJAX(dataSend, callBack);
376 }
377 }
378
379 /***/ },
380
381 /***/ "./assets/src/js/admin/courses/view-students-modal.js"
382 /*!************************************************************!*\
383 !*** ./assets/src/js/admin/courses/view-students-modal.js ***!
384 \************************************************************/
385 (__unused_webpack_module, __webpack_exports__, __webpack_require__) {
386
387 "use strict";
388 __webpack_require__.r(__webpack_exports__);
389 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
390 /* harmony export */ ViewStudentsModal: () => (/* binding */ ViewStudentsModal)
391 /* harmony export */ });
392 /* harmony import */ var sweetalert2__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! sweetalert2 */ "./node_modules/sweetalert2/dist/sweetalert2.all.js");
393 /* harmony import */ var sweetalert2__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(sweetalert2__WEBPACK_IMPORTED_MODULE_0__);
394 /* harmony import */ var lpAssetsJsPath_utils_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! lpAssetsJsPath/utils.js */ "./assets/src/js/utils.js");
395
396
397 class ViewStudentsModal {
398 constructor() {
399 this.isRequesting = false;
400 this.activeCourseId = 0;
401 this.init();
402 }
403 static selectors = {
404 wrap: '#lp-modal-enrolled-wrap',
405 form: '#lp-modal-enrolled-form',
406 toolbarTemplate: '#lp-tmpl-enrolled-students-toolbar-modal',
407 targetTemplate: '#lp-tmpl-enrolled-students-target-modal',
408 toolbar: '.lp-enrolled-students-table-toolbar--modal',
409 courseTrigger: '.lp-btn-view-students',
410 searchInput: '#lp-modal-enrolled-search-input',
411 startDateInput: '#lp-modal-enrolled-filter-start-date',
412 endDateInput: '#lp-modal-enrolled-filter-end-date',
413 searchBtn: '.lp-enrolled-btn-search-modal',
414 clearBtn: '.lp-enrolled-btn-clear-modal',
415 modalSearchFields: '#lp-modal-enrolled-search-input, #lp-modal-enrolled-filter-start-date, #lp-modal-enrolled-filter-end-date'
416 };
417 setButtonLoadingState(btn, isLoading) {
418 if (!btn) {
419 return;
420 }
421 lpAssetsJsPath_utils_js__WEBPACK_IMPORTED_MODULE_1__.lpSetLoadingEl(btn, isLoading ? 1 : 0);
422 btn.disabled = !!isLoading;
423 }
424 init() {
425 if (ViewStudentsModal._loadedEvents) {
426 return;
427 }
428 ViewStudentsModal._loadedEvents = true;
429 lpAssetsJsPath_utils_js__WEBPACK_IMPORTED_MODULE_1__.eventHandlers('click', [{
430 selector: ViewStudentsModal.selectors.courseTrigger,
431 class: this,
432 callBack: this.handleOpenModal.name
433 }, {
434 selector: ViewStudentsModal.selectors.searchBtn,
435 class: this,
436 callBack: this.handleModalSearch.name
437 }, {
438 selector: ViewStudentsModal.selectors.clearBtn,
439 class: this,
440 callBack: this.handleModalClear.name
441 }]);
442 lpAssetsJsPath_utils_js__WEBPACK_IMPORTED_MODULE_1__.eventHandlers('keydown', [{
443 selector: ViewStudentsModal.selectors.modalSearchFields,
444 class: this,
445 callBack: this.handleModalSearchOnEnter.name,
446 checkIsEventEnter: true
447 }]);
448 lpAssetsJsPath_utils_js__WEBPACK_IMPORTED_MODULE_1__.eventHandlers('change', [{
449 selector: ViewStudentsModal.selectors.startDateInput,
450 class: this,
451 callBack: this.checkDatesRange.name
452 }, {
453 selector: ViewStudentsModal.selectors.endDateInput,
454 class: this,
455 callBack: this.checkDatesRange.name
456 }]);
457 }
458 handleOpenModal(args) {
459 const btn = args?.target?.closest(ViewStudentsModal.selectors.courseTrigger);
460 if (!btn || this.isRequesting || btn.classList.contains('loading') || btn.disabled) {
461 return;
462 }
463 const courseId = parseInt(btn.dataset.courseId, 10) || 0;
464 if (!courseId) {
465 return;
466 }
467 const courseTitle = btn.dataset.courseTitle || '';
468 this.activeCourseId = courseId;
469 this.setButtonLoadingState(btn, true);
470 this.openModal(courseId, courseTitle, btn);
471 }
472 handleModalSearch(args) {
473 const btn = args?.target?.closest(ViewStudentsModal.selectors.searchBtn);
474 if (!btn || !this.activeCourseId) {
475 return;
476 }
477 if (args?.e) {
478 args.e.preventDefault();
479 }
480 if (this.isRequesting || btn.classList.contains('loading') || btn.disabled) {
481 return;
482 }
483 this.setButtonLoadingState(btn, true);
484 this.loadEnrolledStudents(this.activeCourseId, 1, btn);
485 }
486 handleModalSearchOnEnter(args) {
487 if (args?.e) {
488 args.e.preventDefault();
489 }
490 const form = this.getModalForm();
491 if (!form) {
492 return;
493 }
494 const btn = form.querySelector(ViewStudentsModal.selectors.searchBtn);
495 if (!btn) {
496 return;
497 }
498 this.handleModalSearch({
499 ...args,
500 target: btn
501 });
502 }
503 handleModalClear(args) {
504 const btn = args?.target?.closest(ViewStudentsModal.selectors.clearBtn);
505 const form = this.getModalForm();
506 if (!btn || !form || !this.activeCourseId) {
507 return;
508 }
509 if (args?.e) {
510 args.e.preventDefault();
511 }
512 if (this.isRequesting || btn.classList.contains('loading') || btn.disabled) {
513 return;
514 }
515 form.reset();
516 this.setButtonLoadingState(btn, true);
517 this.loadEnrolledStudents(this.activeCourseId, 1, btn);
518 }
519 getModalPopup() {
520 return (sweetalert2__WEBPACK_IMPORTED_MODULE_0___default().getPopup) ? sweetalert2__WEBPACK_IMPORTED_MODULE_0___default().getPopup() : null;
521 }
522 getModalToolbarHtml() {
523 const template = document.querySelector(ViewStudentsModal.selectors.toolbarTemplate);
524 return template ? template.innerHTML : '';
525 }
526 getModalTargetHtml() {
527 const template = document.querySelector(ViewStudentsModal.selectors.targetTemplate);
528 return template ? template.innerHTML : '';
529 }
530 getAjaxHandle() {
531 const ajaxHandle = window.lpAJAXG;
532 if (!ajaxHandle || typeof ajaxHandle.getDataSetCurrent !== 'function' || typeof ajaxHandle.setDataSetCurrent !== 'function' || typeof ajaxHandle.showHideLoading !== 'function' || typeof ajaxHandle.fetchAJAX !== 'function') {
533 return null;
534 }
535 return ajaxHandle;
536 }
537 getModalForm() {
538 const popup = this.getModalPopup();
539 if (!popup) {
540 return null;
541 }
542 return popup.querySelector(ViewStudentsModal.selectors.form);
543 }
544 getModalFilterArgs(dataArgs = {}) {
545 const form = this.getModalForm();
546 if (!form) {
547 return dataArgs;
548 }
549 return lpAssetsJsPath_utils_js__WEBPACK_IMPORTED_MODULE_1__.mergeDataWithDatForm(form, dataArgs);
550 }
551 loadEnrolledStudents(courseId, paged, elLoading = null) {
552 const wrap = document.querySelector(ViewStudentsModal.selectors.wrap);
553 const elTarget = wrap?.querySelector('.lp-target');
554 const ajaxHandle = this.getAjaxHandle();
555 if (!wrap || !elTarget || !ajaxHandle || this.isRequesting) {
556 return;
557 }
558 this.isRequesting = true;
559 if (elLoading) {
560 this.setButtonLoadingState(elLoading, true);
561 }
562 const dataSend = ajaxHandle.getDataSetCurrent(elTarget);
563 dataSend.args = this.getModalFilterArgs(dataSend.args || {});
564 dataSend.args.course_id = parseInt(courseId, 10) || 0;
565 dataSend.args.paged = paged;
566 ajaxHandle.setDataSetCurrent(elTarget, dataSend);
567 ajaxHandle.showHideLoading(elTarget, 1);
568 const callBack = {
569 success: response => {
570 elTarget.innerHTML = response.data.content;
571 },
572 error: err => {
573 console.error(err);
574 },
575 completed: () => {
576 this.isRequesting = false;
577 ajaxHandle.showHideLoading(elTarget, 0);
578 if (elLoading) {
579 this.setButtonLoadingState(elLoading, false);
580 }
581 }
582 };
583 ajaxHandle.fetchAJAX(dataSend, callBack);
584 }
585 openModal(courseId, courseTitle, elTrigger = null) {
586 const modalToolbarHtml = this.getModalToolbarHtml();
587 const modalTargetHtml = this.getModalTargetHtml();
588 if (!modalToolbarHtml || !modalTargetHtml) {
589 if (elTrigger) {
590 this.setButtonLoadingState(elTrigger, false);
591 }
592 return;
593 }
594 this.activeCourseId = parseInt(courseId, 10) || 0;
595 sweetalert2__WEBPACK_IMPORTED_MODULE_0___default().fire({
596 title: `${courseTitle}`,
597 html: modalToolbarHtml + modalTargetHtml,
598 width: '80%',
599 showConfirmButton: false,
600 showCloseButton: true,
601 didOpen: () => {
602 this.loadEnrolledStudents(this.activeCourseId, 1, elTrigger);
603 },
604 didClose: () => {
605 this.activeCourseId = 0;
606 if (elTrigger) {
607 this.setButtonLoadingState(elTrigger, false);
608 }
609 }
610 });
611 }
612
613 // Ensure start date is not after end date and vice versa. If invalid, adjust the other date to match.
614 checkDatesRange(args) {
615 const {
616 e
617 } = args;
618 const elInput = e?.target;
619 if (!elInput) {
620 return;
621 }
622 const elForm = elInput.closest(ViewStudentsModal.selectors.form);
623 if (!elForm) {
624 return;
625 }
626 const startDateInput = elForm.querySelector(ViewStudentsModal.selectors.startDateInput);
627 const endDateInput = elForm.querySelector(ViewStudentsModal.selectors.endDateInput);
628 if (elInput === startDateInput) {
629 if (startDateInput.value) {
630 endDateInput.min = startDateInput.value;
631 if (endDateInput.value && endDateInput.value < startDateInput.value) {
632 endDateInput.value = startDateInput.value;
633 }
634 } else {
635 endDateInput.min = '';
636 }
637 } else if (elInput === endDateInput) {
638 if (endDateInput.value) {
639 startDateInput.max = endDateInput.value;
640 if (startDateInput.value && startDateInput.value > endDateInput.value) {
641 startDateInput.value = endDateInput.value;
642 }
643 } else {
644 startDateInput.max = '';
645 }
646 }
647 }
648 }
649
650 /***/ },
651
652 /***/ "./assets/src/js/lpToastify.js"
653 /*!*************************************!*\
654 !*** ./assets/src/js/lpToastify.js ***!
655 \*************************************/
656 (__unused_webpack_module, __webpack_exports__, __webpack_require__) {
657
658 "use strict";
659 __webpack_require__.r(__webpack_exports__);
660 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
661 /* harmony export */ show: () => (/* binding */ show)
662 /* harmony export */ });
663 /* harmony import */ var toastify_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! toastify-js */ "./node_modules/toastify-js/src/toastify.js");
664 /* harmony import */ var toastify_js__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(toastify_js__WEBPACK_IMPORTED_MODULE_0__);
665 /* harmony import */ var toastify_js_src_toastify_css__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! toastify-js/src/toastify.css */ "./node_modules/toastify-js/src/toastify.css");
666 /**
667 * Utils functions
668 *
669 * @param url
670 * @param data
671 * @param functions
672 * @since 4.3.0
673 * @version 1.0.0
674 */
675
676
677 const argsToastify = {
678 text: '',
679 gravity: lpData.toast.gravity,
680 // `top` or `bottom`
681 position: lpData.toast.position,
682 // `left`, `center` or `right`
683 className: `${lpData.toast.classPrefix}`,
684 close: lpData.toast.close == 1,
685 stopOnFocus: lpData.toast.stopOnFocus == 1,
686 duration: lpData.toast.duration
687 };
688 const show = (message, status = 'success', argsCustom) => {
689 let args = argsToastify;
690 if (argsCustom) {
691 args = {
692 ...args,
693 ...argsCustom
694 };
695 }
696 const toastify = new (toastify_js__WEBPACK_IMPORTED_MODULE_0___default())({
697 ...args,
698 text: message,
699 className: `${lpData.toast.classPrefix} ${status}`
700 });
701 toastify.showToast();
702 };
703
704 /***/ },
705
706 /***/ "./assets/src/js/utils.js"
707 /*!********************************!*\
708 !*** ./assets/src/js/utils.js ***!
709 \********************************/
710 (__unused_webpack_module, __webpack_exports__, __webpack_require__) {
711
712 "use strict";
713 __webpack_require__.r(__webpack_exports__);
714 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
715 /* harmony export */ debounce: () => (/* binding */ debounce),
716 /* harmony export */ eventHandlers: () => (/* binding */ eventHandlers),
717 /* harmony export */ getDataOfForm: () => (/* binding */ getDataOfForm),
718 /* harmony export */ getFieldKeysOfForm: () => (/* binding */ getFieldKeysOfForm),
719 /* harmony export */ listenElementCreated: () => (/* binding */ listenElementCreated),
720 /* harmony export */ listenElementViewed: () => (/* binding */ listenElementViewed),
721 /* harmony export */ lpAddQueryArgs: () => (/* binding */ lpAddQueryArgs),
722 /* harmony export */ lpAjaxParseJsonOld: () => (/* binding */ lpAjaxParseJsonOld),
723 /* harmony export */ lpClassName: () => (/* binding */ lpClassName),
724 /* harmony export */ lpFetchAPI: () => (/* binding */ lpFetchAPI),
725 /* harmony export */ lpGetCurrentURLNoParam: () => (/* binding */ lpGetCurrentURLNoParam),
726 /* harmony export */ lpOnElementReady: () => (/* binding */ lpOnElementReady),
727 /* harmony export */ lpSetLoadingEl: () => (/* binding */ lpSetLoadingEl),
728 /* harmony export */ lpShowHideEl: () => (/* binding */ lpShowHideEl),
729 /* harmony export */ mergeDataWithDatForm: () => (/* binding */ mergeDataWithDatForm),
730 /* harmony export */ toggleCollapse: () => (/* binding */ toggleCollapse)
731 /* harmony export */ });
732 /**
733 * Utils functions
734 *
735 * @param url
736 * @param data
737 * @param functions
738 * @since 4.2.5.1
739 * @version 1.0.6
740 */
741 const lpClassName = {
742 hidden: 'lp-hidden',
743 loading: 'loading',
744 elCollapse: 'lp-collapse',
745 elSectionToggle: '.lp-section-toggle',
746 elTriggerToggle: '.lp-trigger-toggle'
747 };
748 const lpFetchAPI = (url, data = {}, functions = {}) => {
749 if ('function' === typeof functions.before) {
750 functions.before();
751 }
752 fetch(url, {
753 method: 'GET',
754 ...data
755 }).then(response => response.json()).then(response => {
756 if ('function' === typeof functions.success) {
757 functions.success(response);
758 }
759 }).catch(err => {
760 if ('function' === typeof functions.error) {
761 functions.error(err);
762 }
763 }).finally(() => {
764 if ('function' === typeof functions.completed) {
765 functions.completed();
766 }
767 });
768 };
769
770 /**
771 * Get current URL without params.
772 *
773 * @since 4.2.5.1
774 */
775 const lpGetCurrentURLNoParam = () => {
776 let currentUrl = window.location.href;
777 const hasParams = currentUrl.includes('?');
778 if (hasParams) {
779 currentUrl = currentUrl.split('?')[0];
780 }
781 return currentUrl;
782 };
783 const lpAddQueryArgs = (endpoint, args) => {
784 const url = new URL(endpoint);
785 Object.keys(args).forEach(arg => {
786 url.searchParams.set(arg, args[arg]);
787 });
788 return url;
789 };
790
791 /**
792 * Listen element viewed.
793 *
794 * @param el
795 * @param callback
796 * @since 4.2.5.8
797 */
798 const listenElementViewed = (el, callback) => {
799 const observerSeeItem = new IntersectionObserver(function (entries) {
800 for (const entry of entries) {
801 if (entry.isIntersecting) {
802 callback(entry);
803 }
804 }
805 });
806 observerSeeItem.observe(el);
807 };
808
809 /**
810 * Listen element created.
811 *
812 * @param callback
813 * @since 4.2.5.8
814 */
815 const listenElementCreated = callback => {
816 const observerCreateItem = new MutationObserver(function (mutations) {
817 mutations.forEach(function (mutation) {
818 if (mutation.addedNodes) {
819 mutation.addedNodes.forEach(function (node) {
820 if (node.nodeType === 1) {
821 callback(node);
822 }
823 });
824 }
825 });
826 });
827 observerCreateItem.observe(document, {
828 childList: true,
829 subtree: true
830 });
831 // End.
832 };
833
834 /**
835 * Listen element created.
836 *
837 * @param selector
838 * @param callback
839 * @since 4.2.7.1
840 */
841 const lpOnElementReady = (selector, callback) => {
842 const element = document.querySelector(selector);
843 if (element) {
844 callback(element);
845 return;
846 }
847 const observer = new MutationObserver((mutations, obs) => {
848 const element = document.querySelector(selector);
849 if (element) {
850 obs.disconnect();
851 callback(element);
852 }
853 });
854 observer.observe(document.documentElement, {
855 childList: true,
856 subtree: true
857 });
858 };
859
860 // Parse JSON from string with content include LP_AJAX_START.
861 const lpAjaxParseJsonOld = data => {
862 if (typeof data !== 'string') {
863 return data;
864 }
865 const m = String.raw({
866 raw: data
867 }).match(/<-- LP_AJAX_START -->(.*)<-- LP_AJAX_END -->/s);
868 try {
869 if (m) {
870 data = JSON.parse(m[1].replace(/(?:\r\n|\r|\n)/g, ''));
871 } else {
872 data = JSON.parse(data);
873 }
874 } catch (e) {
875 data = {};
876 }
877 return data;
878 };
879
880 // status 0: hide, 1: show
881 const lpShowHideEl = (el, status = 0) => {
882 if (!el) {
883 return;
884 }
885 if (!status) {
886 el.classList.add(lpClassName.hidden);
887 } else {
888 el.classList.remove(lpClassName.hidden);
889 }
890 };
891
892 // status 0: hide, 1: show
893 const lpSetLoadingEl = (el, status) => {
894 if (!el) {
895 return;
896 }
897 if (!status) {
898 el.classList.remove(lpClassName.loading);
899 } else {
900 el.classList.add(lpClassName.loading);
901 }
902 };
903
904 // Toggle collapse section
905 const toggleCollapse = (e, target, elTriggerClassName = '', elsExclude = [], callback) => {
906 if (!elTriggerClassName) {
907 elTriggerClassName = lpClassName.elTriggerToggle;
908 }
909
910 // Exclude elements, which should not trigger the collapse toggle
911 if (elsExclude && elsExclude.length > 0) {
912 for (const elExclude of elsExclude) {
913 if (target.closest(elExclude)) {
914 return;
915 }
916 }
917 }
918 const elTrigger = target.closest(elTriggerClassName);
919 if (!elTrigger) {
920 return;
921 }
922
923 //console.log( 'elTrigger', elTrigger );
924
925 const elSectionToggle = elTrigger.closest(`${lpClassName.elSectionToggle}`);
926 if (!elSectionToggle) {
927 return;
928 }
929 elSectionToggle.classList.toggle(`${lpClassName.elCollapse}`);
930 if ('function' === typeof callback) {
931 callback(elSectionToggle);
932 }
933 };
934
935 // Get data of form
936 const getDataOfForm = form => {
937 const dataSend = {};
938 const formData = new FormData(form);
939 for (const pair of formData.entries()) {
940 const key = pair[0];
941 const value = formData.getAll(key);
942 if (!dataSend.hasOwnProperty(key)) {
943 // Convert value array to string.
944 dataSend[key] = value.join(',');
945 }
946 }
947 return dataSend;
948 };
949
950 // Get field keys of form
951 const getFieldKeysOfForm = form => {
952 const keys = [];
953 const elements = form.elements;
954 for (let i = 0; i < elements.length; i++) {
955 const name = elements[i].name;
956 if (name && !keys.includes(name)) {
957 keys.push(name);
958 }
959 }
960 return keys;
961 };
962
963 // Merge data handle with data form.
964 const mergeDataWithDatForm = (elForm, dataHandle) => {
965 const dataForm = getDataOfForm(elForm);
966 const keys = getFieldKeysOfForm(elForm);
967 keys.forEach(key => {
968 if (!dataForm.hasOwnProperty(key)) {
969 delete dataHandle[key];
970 } else if (dataForm[key][0] === '') {
971 delete dataForm[key];
972 delete dataHandle[key];
973 }
974 });
975 dataHandle = {
976 ...dataHandle,
977 ...dataForm
978 };
979 return dataHandle;
980 };
981
982 /**
983 * Event trigger
984 * For each list of event handlers, listen event on document.
985 *
986 * eventName: 'click', 'change', ...
987 * eventHandlers = [ { selector: '.lp-button', callBack: function(){}, class: object } ]
988 *
989 * @param eventName
990 * @param eventHandlers
991 */
992 const eventHandlers = (eventName, eventHandlers) => {
993 document.addEventListener(eventName, e => {
994 const target = e.target;
995 let args = {
996 e,
997 target
998 };
999 eventHandlers.forEach(eventHandler => {
1000 args = {
1001 ...args,
1002 ...eventHandler
1003 };
1004
1005 //console.log( args );
1006
1007 // Check condition before call back
1008 if (eventHandler.conditionBeforeCallBack) {
1009 if (eventHandler.conditionBeforeCallBack(args) !== true) {
1010 return;
1011 }
1012 }
1013
1014 // Special check for keydown event with checkIsEventEnter = true
1015 if (eventName === 'keydown' && eventHandler.checkIsEventEnter) {
1016 if (e.key !== 'Enter') {
1017 return;
1018 }
1019 }
1020 if (target.closest(eventHandler.selector)) {
1021 if (eventHandler.class) {
1022 // Call method of class, function callBack will understand exactly {this} is class object.
1023 eventHandler.class[eventHandler.callBack](args);
1024 } else {
1025 // For send args is objected, {this} is eventHandler object, not class object.
1026 eventHandler.callBack(args);
1027 }
1028 }
1029 });
1030 });
1031 };
1032
1033 /**
1034 * Debounce - delays function execution until after `wait` ms of inactivity.
1035 *
1036 * Each call resets the timer. Only the last call in a burst executes.
1037 *
1038 * USE CASES:
1039 * - Search inputs, form validation, window resize
1040 * - Multiple elements need independent timers
1041 * - When you need to call with different arguments
1042 *
1043 * EXAMPLES:
1044 * const debouncedSearch = debounce( (query) => fetchResults(query), 300 );
1045 * searchInput.addEventListener('input', (e) => debouncedSearch(e.target.value));
1046 *
1047 * const debouncedResize = debounce( recalculateLayout, 250 );
1048 * window.addEventListener('resize', debouncedResize);
1049 *
1050 * ⚠️ Create ONCE outside event handlers, not inside.
1051 *
1052 * @param {Function} func - Function to debounce (can be anonymous)
1053 * @param {number} wait - Milliseconds to wait (default: 500)
1054 * @return {Function} Debounced wrapper function
1055 * @since 4.3.7
1056 * @version 1.0.0
1057 */
1058 const debounce = (func, wait = 500) => {
1059 let timer;
1060 return args => {
1061 clearTimeout(timer);
1062 timer = setTimeout(() => func(args), wait);
1063 };
1064 };
1065
1066 /***/ },
1067
1068 /***/ "./node_modules/css-loader/dist/cjs.js!./node_modules/toastify-js/src/toastify.css"
1069 /*!*****************************************************************************************!*\
1070 !*** ./node_modules/css-loader/dist/cjs.js!./node_modules/toastify-js/src/toastify.css ***!
1071 \*****************************************************************************************/
1072 (module, __webpack_exports__, __webpack_require__) {
1073
1074 "use strict";
1075 __webpack_require__.r(__webpack_exports__);
1076 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
1077 /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
1078 /* harmony export */ });
1079 /* harmony import */ var _css_loader_dist_runtime_sourceMaps_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../css-loader/dist/runtime/sourceMaps.js */ "./node_modules/css-loader/dist/runtime/sourceMaps.js");
1080 /* harmony import */ var _css_loader_dist_runtime_sourceMaps_js__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_css_loader_dist_runtime_sourceMaps_js__WEBPACK_IMPORTED_MODULE_0__);
1081 /* harmony import */ var _css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../css-loader/dist/runtime/api.js */ "./node_modules/css-loader/dist/runtime/api.js");
1082 /* harmony import */ var _css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1__);
1083 // Imports
1084
1085
1086 var ___CSS_LOADER_EXPORT___ = _css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1___default()((_css_loader_dist_runtime_sourceMaps_js__WEBPACK_IMPORTED_MODULE_0___default()));
1087 // Module
1088 ___CSS_LOADER_EXPORT___.push([module.id, `/*!
1089 * Toastify js 1.12.0
1090 * https://github.com/apvarun/toastify-js
1091 * @license MIT licensed
1092 *
1093 * Copyright (C) 2018 Varun A P
1094 */
1095
1096 .toastify {
1097 padding: 12px 20px;
1098 color: #ffffff;
1099 display: inline-block;
1100 box-shadow: 0 3px 6px -1px rgba(0, 0, 0, 0.12), 0 10px 36px -4px rgba(77, 96, 232, 0.3);
1101 background: -webkit-linear-gradient(315deg, #73a5ff, #5477f5);
1102 background: linear-gradient(135deg, #73a5ff, #5477f5);
1103 position: fixed;
1104 opacity: 0;
1105 transition: all 0.4s cubic-bezier(0.215, 0.61, 0.355, 1);
1106 border-radius: 2px;
1107 cursor: pointer;
1108 text-decoration: none;
1109 max-width: calc(50% - 20px);
1110 z-index: 2147483647;
1111 }
1112
1113 .toastify.on {
1114 opacity: 1;
1115 }
1116
1117 .toast-close {
1118 background: transparent;
1119 border: 0;
1120 color: white;
1121 cursor: pointer;
1122 font-family: inherit;
1123 font-size: 1em;
1124 opacity: 0.4;
1125 padding: 0 5px;
1126 }
1127
1128 .toastify-right {
1129 right: 15px;
1130 }
1131
1132 .toastify-left {
1133 left: 15px;
1134 }
1135
1136 .toastify-top {
1137 top: -150px;
1138 }
1139
1140 .toastify-bottom {
1141 bottom: -150px;
1142 }
1143
1144 .toastify-rounded {
1145 border-radius: 25px;
1146 }
1147
1148 .toastify-avatar {
1149 width: 1.5em;
1150 height: 1.5em;
1151 margin: -7px 5px;
1152 border-radius: 2px;
1153 }
1154
1155 .toastify-center {
1156 margin-left: auto;
1157 margin-right: auto;
1158 left: 0;
1159 right: 0;
1160 max-width: fit-content;
1161 max-width: -moz-fit-content;
1162 }
1163
1164 @media only screen and (max-width: 360px) {
1165 .toastify-right, .toastify-left {
1166 margin-left: auto;
1167 margin-right: auto;
1168 left: 0;
1169 right: 0;
1170 max-width: fit-content;
1171 }
1172 }
1173 `, "",{"version":3,"sources":["webpack://./node_modules/toastify-js/src/toastify.css"],"names":[],"mappings":"AAAA;;;;;;EAME;;AAEF;IACI,kBAAkB;IAClB,cAAc;IACd,qBAAqB;IACrB,uFAAuF;IACvF,6DAA6D;IAC7D,qDAAqD;IACrD,eAAe;IACf,UAAU;IACV,wDAAwD;IACxD,kBAAkB;IAClB,eAAe;IACf,qBAAqB;IACrB,2BAA2B;IAC3B,mBAAmB;AACvB;;AAEA;IACI,UAAU;AACd;;AAEA;IACI,uBAAuB;IACvB,SAAS;IACT,YAAY;IACZ,eAAe;IACf,oBAAoB;IACpB,cAAc;IACd,YAAY;IACZ,cAAc;AAClB;;AAEA;IACI,WAAW;AACf;;AAEA;IACI,UAAU;AACd;;AAEA;IACI,WAAW;AACf;;AAEA;IACI,cAAc;AAClB;;AAEA;IACI,mBAAmB;AACvB;;AAEA;IACI,YAAY;IACZ,aAAa;IACb,gBAAgB;IAChB,kBAAkB;AACtB;;AAEA;IACI,iBAAiB;IACjB,kBAAkB;IAClB,OAAO;IACP,QAAQ;IACR,sBAAsB;IACtB,2BAA2B;AAC/B;;AAEA;IACI;QACI,iBAAiB;QACjB,kBAAkB;QAClB,OAAO;QACP,QAAQ;QACR,sBAAsB;IAC1B;AACJ","sourcesContent":["/*!\n * Toastify js 1.12.0\n * https://github.com/apvarun/toastify-js\n * @license MIT licensed\n *\n * Copyright (C) 2018 Varun A P\n */\n\n.toastify {\n padding: 12px 20px;\n color: #ffffff;\n display: inline-block;\n box-shadow: 0 3px 6px -1px rgba(0, 0, 0, 0.12), 0 10px 36px -4px rgba(77, 96, 232, 0.3);\n background: -webkit-linear-gradient(315deg, #73a5ff, #5477f5);\n background: linear-gradient(135deg, #73a5ff, #5477f5);\n position: fixed;\n opacity: 0;\n transition: all 0.4s cubic-bezier(0.215, 0.61, 0.355, 1);\n border-radius: 2px;\n cursor: pointer;\n text-decoration: none;\n max-width: calc(50% - 20px);\n z-index: 2147483647;\n}\n\n.toastify.on {\n opacity: 1;\n}\n\n.toast-close {\n background: transparent;\n border: 0;\n color: white;\n cursor: pointer;\n font-family: inherit;\n font-size: 1em;\n opacity: 0.4;\n padding: 0 5px;\n}\n\n.toastify-right {\n right: 15px;\n}\n\n.toastify-left {\n left: 15px;\n}\n\n.toastify-top {\n top: -150px;\n}\n\n.toastify-bottom {\n bottom: -150px;\n}\n\n.toastify-rounded {\n border-radius: 25px;\n}\n\n.toastify-avatar {\n width: 1.5em;\n height: 1.5em;\n margin: -7px 5px;\n border-radius: 2px;\n}\n\n.toastify-center {\n margin-left: auto;\n margin-right: auto;\n left: 0;\n right: 0;\n max-width: fit-content;\n max-width: -moz-fit-content;\n}\n\n@media only screen and (max-width: 360px) {\n .toastify-right, .toastify-left {\n margin-left: auto;\n margin-right: auto;\n left: 0;\n right: 0;\n max-width: fit-content;\n }\n}\n"],"sourceRoot":""}]);
1174 // Exports
1175 /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (___CSS_LOADER_EXPORT___);
1176
1177
1178 /***/ },
1179
1180 /***/ "./node_modules/css-loader/dist/runtime/api.js"
1181 /*!*****************************************************!*\
1182 !*** ./node_modules/css-loader/dist/runtime/api.js ***!
1183 \*****************************************************/
1184 (module) {
1185
1186 "use strict";
1187
1188
1189 /*
1190 MIT License http://www.opensource.org/licenses/mit-license.php
1191 Author Tobias Koppers @sokra
1192 */
1193 module.exports = function (cssWithMappingToString) {
1194 var list = [];
1195
1196 // return the list of modules as css string
1197 list.toString = function toString() {
1198 return this.map(function (item) {
1199 var content = "";
1200 var needLayer = typeof item[5] !== "undefined";
1201 if (item[4]) {
1202 content += "@supports (".concat(item[4], ") {");
1203 }
1204 if (item[2]) {
1205 content += "@media ".concat(item[2], " {");
1206 }
1207 if (needLayer) {
1208 content += "@layer".concat(item[5].length > 0 ? " ".concat(item[5]) : "", " {");
1209 }
1210 content += cssWithMappingToString(item);
1211 if (needLayer) {
1212 content += "}";
1213 }
1214 if (item[2]) {
1215 content += "}";
1216 }
1217 if (item[4]) {
1218 content += "}";
1219 }
1220 return content;
1221 }).join("");
1222 };
1223
1224 // import a list of modules into the list
1225 list.i = function i(modules, media, dedupe, supports, layer) {
1226 if (typeof modules === "string") {
1227 modules = [[null, modules, undefined]];
1228 }
1229 var alreadyImportedModules = {};
1230 if (dedupe) {
1231 for (var k = 0; k < this.length; k++) {
1232 var id = this[k][0];
1233 if (id != null) {
1234 alreadyImportedModules[id] = true;
1235 }
1236 }
1237 }
1238 for (var _k = 0; _k < modules.length; _k++) {
1239 var item = [].concat(modules[_k]);
1240 if (dedupe && alreadyImportedModules[item[0]]) {
1241 continue;
1242 }
1243 if (typeof layer !== "undefined") {
1244 if (typeof item[5] === "undefined") {
1245 item[5] = layer;
1246 } else {
1247 item[1] = "@layer".concat(item[5].length > 0 ? " ".concat(item[5]) : "", " {").concat(item[1], "}");
1248 item[5] = layer;
1249 }
1250 }
1251 if (media) {
1252 if (!item[2]) {
1253 item[2] = media;
1254 } else {
1255 item[1] = "@media ".concat(item[2], " {").concat(item[1], "}");
1256 item[2] = media;
1257 }
1258 }
1259 if (supports) {
1260 if (!item[4]) {
1261 item[4] = "".concat(supports);
1262 } else {
1263 item[1] = "@supports (".concat(item[4], ") {").concat(item[1], "}");
1264 item[4] = supports;
1265 }
1266 }
1267 list.push(item);
1268 }
1269 };
1270 return list;
1271 };
1272
1273 /***/ },
1274
1275 /***/ "./node_modules/css-loader/dist/runtime/sourceMaps.js"
1276 /*!************************************************************!*\
1277 !*** ./node_modules/css-loader/dist/runtime/sourceMaps.js ***!
1278 \************************************************************/
1279 (module) {
1280
1281 "use strict";
1282
1283
1284 module.exports = function (item) {
1285 var content = item[1];
1286 var cssMapping = item[3];
1287 if (!cssMapping) {
1288 return content;
1289 }
1290 if (typeof btoa === "function") {
1291 var base64 = btoa(unescape(encodeURIComponent(JSON.stringify(cssMapping))));
1292 var data = "sourceMappingURL=data:application/json;charset=utf-8;base64,".concat(base64);
1293 var sourceMapping = "/*# ".concat(data, " */");
1294 return [content].concat([sourceMapping]).join("\n");
1295 }
1296 return [content].join("\n");
1297 };
1298
1299 /***/ },
1300
1301 /***/ "./node_modules/toastify-js/src/toastify.css"
1302 /*!***************************************************!*\
1303 !*** ./node_modules/toastify-js/src/toastify.css ***!
1304 \***************************************************/
1305 (__unused_webpack_module, __webpack_exports__, __webpack_require__) {
1306
1307 "use strict";
1308 __webpack_require__.r(__webpack_exports__);
1309 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
1310 /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
1311 /* harmony export */ });
1312 /* harmony import */ var _style_loader_dist_runtime_injectStylesIntoStyleTag_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! !../../style-loader/dist/runtime/injectStylesIntoStyleTag.js */ "./node_modules/style-loader/dist/runtime/injectStylesIntoStyleTag.js");
1313 /* harmony import */ var _style_loader_dist_runtime_injectStylesIntoStyleTag_js__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_style_loader_dist_runtime_injectStylesIntoStyleTag_js__WEBPACK_IMPORTED_MODULE_0__);
1314 /* harmony import */ var _style_loader_dist_runtime_styleDomAPI_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! !../../style-loader/dist/runtime/styleDomAPI.js */ "./node_modules/style-loader/dist/runtime/styleDomAPI.js");
1315 /* harmony import */ var _style_loader_dist_runtime_styleDomAPI_js__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_style_loader_dist_runtime_styleDomAPI_js__WEBPACK_IMPORTED_MODULE_1__);
1316 /* harmony import */ var _style_loader_dist_runtime_insertBySelector_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! !../../style-loader/dist/runtime/insertBySelector.js */ "./node_modules/style-loader/dist/runtime/insertBySelector.js");
1317 /* harmony import */ var _style_loader_dist_runtime_insertBySelector_js__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_style_loader_dist_runtime_insertBySelector_js__WEBPACK_IMPORTED_MODULE_2__);
1318 /* harmony import */ var _style_loader_dist_runtime_setAttributesWithoutAttributes_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! !../../style-loader/dist/runtime/setAttributesWithoutAttributes.js */ "./node_modules/style-loader/dist/runtime/setAttributesWithoutAttributes.js");
1319 /* harmony import */ var _style_loader_dist_runtime_setAttributesWithoutAttributes_js__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(_style_loader_dist_runtime_setAttributesWithoutAttributes_js__WEBPACK_IMPORTED_MODULE_3__);
1320 /* harmony import */ var _style_loader_dist_runtime_insertStyleElement_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! !../../style-loader/dist/runtime/insertStyleElement.js */ "./node_modules/style-loader/dist/runtime/insertStyleElement.js");
1321 /* harmony import */ var _style_loader_dist_runtime_insertStyleElement_js__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(_style_loader_dist_runtime_insertStyleElement_js__WEBPACK_IMPORTED_MODULE_4__);
1322 /* harmony import */ var _style_loader_dist_runtime_styleTagTransform_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! !../../style-loader/dist/runtime/styleTagTransform.js */ "./node_modules/style-loader/dist/runtime/styleTagTransform.js");
1323 /* harmony import */ var _style_loader_dist_runtime_styleTagTransform_js__WEBPACK_IMPORTED_MODULE_5___default = /*#__PURE__*/__webpack_require__.n(_style_loader_dist_runtime_styleTagTransform_js__WEBPACK_IMPORTED_MODULE_5__);
1324 /* harmony import */ var _css_loader_dist_cjs_js_toastify_css__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! !!../../css-loader/dist/cjs.js!./toastify.css */ "./node_modules/css-loader/dist/cjs.js!./node_modules/toastify-js/src/toastify.css");
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336 var options = {};
1337
1338 options.styleTagTransform = (_style_loader_dist_runtime_styleTagTransform_js__WEBPACK_IMPORTED_MODULE_5___default());
1339 options.setAttributes = (_style_loader_dist_runtime_setAttributesWithoutAttributes_js__WEBPACK_IMPORTED_MODULE_3___default());
1340
1341 options.insert = _style_loader_dist_runtime_insertBySelector_js__WEBPACK_IMPORTED_MODULE_2___default().bind(null, "head");
1342
1343 options.domAPI = (_style_loader_dist_runtime_styleDomAPI_js__WEBPACK_IMPORTED_MODULE_1___default());
1344 options.insertStyleElement = (_style_loader_dist_runtime_insertStyleElement_js__WEBPACK_IMPORTED_MODULE_4___default());
1345
1346 var update = _style_loader_dist_runtime_injectStylesIntoStyleTag_js__WEBPACK_IMPORTED_MODULE_0___default()(_css_loader_dist_cjs_js_toastify_css__WEBPACK_IMPORTED_MODULE_6__["default"], options);
1347
1348
1349
1350
1351 /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (_css_loader_dist_cjs_js_toastify_css__WEBPACK_IMPORTED_MODULE_6__["default"] && _css_loader_dist_cjs_js_toastify_css__WEBPACK_IMPORTED_MODULE_6__["default"].locals ? _css_loader_dist_cjs_js_toastify_css__WEBPACK_IMPORTED_MODULE_6__["default"].locals : undefined);
1352
1353
1354 /***/ },
1355
1356 /***/ "./node_modules/style-loader/dist/runtime/injectStylesIntoStyleTag.js"
1357 /*!****************************************************************************!*\
1358 !*** ./node_modules/style-loader/dist/runtime/injectStylesIntoStyleTag.js ***!
1359 \****************************************************************************/
1360 (module) {
1361
1362 "use strict";
1363
1364
1365 var stylesInDOM = [];
1366 function getIndexByIdentifier(identifier) {
1367 var result = -1;
1368 for (var i = 0; i < stylesInDOM.length; i++) {
1369 if (stylesInDOM[i].identifier === identifier) {
1370 result = i;
1371 break;
1372 }
1373 }
1374 return result;
1375 }
1376 function modulesToDom(list, options) {
1377 var idCountMap = {};
1378 var identifiers = [];
1379 for (var i = 0; i < list.length; i++) {
1380 var item = list[i];
1381 var id = options.base ? item[0] + options.base : item[0];
1382 var count = idCountMap[id] || 0;
1383 var identifier = "".concat(id, " ").concat(count);
1384 idCountMap[id] = count + 1;
1385 var indexByIdentifier = getIndexByIdentifier(identifier);
1386 var obj = {
1387 css: item[1],
1388 media: item[2],
1389 sourceMap: item[3],
1390 supports: item[4],
1391 layer: item[5]
1392 };
1393 if (indexByIdentifier !== -1) {
1394 stylesInDOM[indexByIdentifier].references++;
1395 stylesInDOM[indexByIdentifier].updater(obj);
1396 } else {
1397 var updater = addElementStyle(obj, options);
1398 options.byIndex = i;
1399 stylesInDOM.splice(i, 0, {
1400 identifier: identifier,
1401 updater: updater,
1402 references: 1
1403 });
1404 }
1405 identifiers.push(identifier);
1406 }
1407 return identifiers;
1408 }
1409 function addElementStyle(obj, options) {
1410 var api = options.domAPI(options);
1411 api.update(obj);
1412 var updater = function updater(newObj) {
1413 if (newObj) {
1414 if (newObj.css === obj.css && newObj.media === obj.media && newObj.sourceMap === obj.sourceMap && newObj.supports === obj.supports && newObj.layer === obj.layer) {
1415 return;
1416 }
1417 api.update(obj = newObj);
1418 } else {
1419 api.remove();
1420 }
1421 };
1422 return updater;
1423 }
1424 module.exports = function (list, options) {
1425 options = options || {};
1426 list = list || [];
1427 var lastIdentifiers = modulesToDom(list, options);
1428 return function update(newList) {
1429 newList = newList || [];
1430 for (var i = 0; i < lastIdentifiers.length; i++) {
1431 var identifier = lastIdentifiers[i];
1432 var index = getIndexByIdentifier(identifier);
1433 stylesInDOM[index].references--;
1434 }
1435 var newLastIdentifiers = modulesToDom(newList, options);
1436 for (var _i = 0; _i < lastIdentifiers.length; _i++) {
1437 var _identifier = lastIdentifiers[_i];
1438 var _index = getIndexByIdentifier(_identifier);
1439 if (stylesInDOM[_index].references === 0) {
1440 stylesInDOM[_index].updater();
1441 stylesInDOM.splice(_index, 1);
1442 }
1443 }
1444 lastIdentifiers = newLastIdentifiers;
1445 };
1446 };
1447
1448 /***/ },
1449
1450 /***/ "./node_modules/style-loader/dist/runtime/insertBySelector.js"
1451 /*!********************************************************************!*\
1452 !*** ./node_modules/style-loader/dist/runtime/insertBySelector.js ***!
1453 \********************************************************************/
1454 (module) {
1455
1456 "use strict";
1457
1458
1459 var memo = {};
1460
1461 /* istanbul ignore next */
1462 function getTarget(target) {
1463 if (typeof memo[target] === "undefined") {
1464 var styleTarget = document.querySelector(target);
1465
1466 // Special case to return head of iframe instead of iframe itself
1467 if (window.HTMLIFrameElement && styleTarget instanceof window.HTMLIFrameElement) {
1468 try {
1469 // This will throw an exception if access to iframe is blocked
1470 // due to cross-origin restrictions
1471 styleTarget = styleTarget.contentDocument.head;
1472 } catch (e) {
1473 // istanbul ignore next
1474 styleTarget = null;
1475 }
1476 }
1477 memo[target] = styleTarget;
1478 }
1479 return memo[target];
1480 }
1481
1482 /* istanbul ignore next */
1483 function insertBySelector(insert, style) {
1484 var target = getTarget(insert);
1485 if (!target) {
1486 throw new Error("Couldn't find a style target. This probably means that the value for the 'insert' parameter is invalid.");
1487 }
1488 target.appendChild(style);
1489 }
1490 module.exports = insertBySelector;
1491
1492 /***/ },
1493
1494 /***/ "./node_modules/style-loader/dist/runtime/insertStyleElement.js"
1495 /*!**********************************************************************!*\
1496 !*** ./node_modules/style-loader/dist/runtime/insertStyleElement.js ***!
1497 \**********************************************************************/
1498 (module) {
1499
1500 "use strict";
1501
1502
1503 /* istanbul ignore next */
1504 function insertStyleElement(options) {
1505 var element = document.createElement("style");
1506 options.setAttributes(element, options.attributes);
1507 options.insert(element, options.options);
1508 return element;
1509 }
1510 module.exports = insertStyleElement;
1511
1512 /***/ },
1513
1514 /***/ "./node_modules/style-loader/dist/runtime/setAttributesWithoutAttributes.js"
1515 /*!**********************************************************************************!*\
1516 !*** ./node_modules/style-loader/dist/runtime/setAttributesWithoutAttributes.js ***!
1517 \**********************************************************************************/
1518 (module, __unused_webpack_exports, __webpack_require__) {
1519
1520 "use strict";
1521
1522
1523 /* istanbul ignore next */
1524 function setAttributesWithoutAttributes(styleElement) {
1525 var nonce = true ? __webpack_require__.nc : 0;
1526 if (nonce) {
1527 styleElement.setAttribute("nonce", nonce);
1528 }
1529 }
1530 module.exports = setAttributesWithoutAttributes;
1531
1532 /***/ },
1533
1534 /***/ "./node_modules/style-loader/dist/runtime/styleDomAPI.js"
1535 /*!***************************************************************!*\
1536 !*** ./node_modules/style-loader/dist/runtime/styleDomAPI.js ***!
1537 \***************************************************************/
1538 (module) {
1539
1540 "use strict";
1541
1542
1543 /* istanbul ignore next */
1544 function apply(styleElement, options, obj) {
1545 var css = "";
1546 if (obj.supports) {
1547 css += "@supports (".concat(obj.supports, ") {");
1548 }
1549 if (obj.media) {
1550 css += "@media ".concat(obj.media, " {");
1551 }
1552 var needLayer = typeof obj.layer !== "undefined";
1553 if (needLayer) {
1554 css += "@layer".concat(obj.layer.length > 0 ? " ".concat(obj.layer) : "", " {");
1555 }
1556 css += obj.css;
1557 if (needLayer) {
1558 css += "}";
1559 }
1560 if (obj.media) {
1561 css += "}";
1562 }
1563 if (obj.supports) {
1564 css += "}";
1565 }
1566 var sourceMap = obj.sourceMap;
1567 if (sourceMap && typeof btoa !== "undefined") {
1568 css += "\n/*# sourceMappingURL=data:application/json;base64,".concat(btoa(unescape(encodeURIComponent(JSON.stringify(sourceMap)))), " */");
1569 }
1570
1571 // For old IE
1572 /* istanbul ignore if */
1573 options.styleTagTransform(css, styleElement, options.options);
1574 }
1575 function removeStyleElement(styleElement) {
1576 // istanbul ignore if
1577 if (styleElement.parentNode === null) {
1578 return false;
1579 }
1580 styleElement.parentNode.removeChild(styleElement);
1581 }
1582
1583 /* istanbul ignore next */
1584 function domAPI(options) {
1585 if (typeof document === "undefined") {
1586 return {
1587 update: function update() {},
1588 remove: function remove() {}
1589 };
1590 }
1591 var styleElement = options.insertStyleElement(options);
1592 return {
1593 update: function update(obj) {
1594 apply(styleElement, options, obj);
1595 },
1596 remove: function remove() {
1597 removeStyleElement(styleElement);
1598 }
1599 };
1600 }
1601 module.exports = domAPI;
1602
1603 /***/ },
1604
1605 /***/ "./node_modules/style-loader/dist/runtime/styleTagTransform.js"
1606 /*!*********************************************************************!*\
1607 !*** ./node_modules/style-loader/dist/runtime/styleTagTransform.js ***!
1608 \*********************************************************************/
1609 (module) {
1610
1611 "use strict";
1612
1613
1614 /* istanbul ignore next */
1615 function styleTagTransform(css, styleElement) {
1616 if (styleElement.styleSheet) {
1617 styleElement.styleSheet.cssText = css;
1618 } else {
1619 while (styleElement.firstChild) {
1620 styleElement.removeChild(styleElement.firstChild);
1621 }
1622 styleElement.appendChild(document.createTextNode(css));
1623 }
1624 }
1625 module.exports = styleTagTransform;
1626
1627 /***/ },
1628
1629 /***/ "./node_modules/sweetalert2/dist/sweetalert2.all.js"
1630 /*!**********************************************************!*\
1631 !*** ./node_modules/sweetalert2/dist/sweetalert2.all.js ***!
1632 \**********************************************************/
1633 (module) {
1634
1635 /*!
1636 * sweetalert2 v11.26.25
1637 * Released under the MIT License.
1638 */
1639 (function (global, factory) {
1640 true ? module.exports = factory() :
1641 0;
1642 })(this, (function () { 'use strict';
1643
1644 function _assertClassBrand(e, t, n) {
1645 if ("function" == typeof e ? e === t : e.has(t)) return arguments.length < 3 ? t : n;
1646 throw new TypeError("Private element is not present on this object");
1647 }
1648 function _checkPrivateRedeclaration(e, t) {
1649 if (t.has(e)) throw new TypeError("Cannot initialize the same private elements twice on an object");
1650 }
1651 function _classPrivateFieldGet2(s, a) {
1652 return s.get(_assertClassBrand(s, a));
1653 }
1654 function _classPrivateFieldInitSpec(e, t, a) {
1655 _checkPrivateRedeclaration(e, t), t.set(e, a);
1656 }
1657 function _classPrivateFieldSet2(s, a, r) {
1658 return s.set(_assertClassBrand(s, a), r), r;
1659 }
1660
1661 const RESTORE_FOCUS_TIMEOUT = 100;
1662
1663 /** @type {GlobalState} */
1664 const globalState = {};
1665 const focusPreviousActiveElement = () => {
1666 if (globalState.previousActiveElement instanceof HTMLElement) {
1667 globalState.previousActiveElement.focus();
1668 globalState.previousActiveElement = null;
1669 } else if (document.body) {
1670 document.body.focus();
1671 }
1672 };
1673
1674 /**
1675 * Restore previous active (focused) element
1676 *
1677 * @param {boolean} returnFocus
1678 * @returns {Promise<void>}
1679 */
1680 const restoreActiveElement = returnFocus => {
1681 return new Promise(resolve => {
1682 if (!returnFocus) {
1683 return resolve();
1684 }
1685 const x = window.scrollX;
1686 const y = window.scrollY;
1687 globalState.restoreFocusTimeout = setTimeout(() => {
1688 focusPreviousActiveElement();
1689 resolve();
1690 }, RESTORE_FOCUS_TIMEOUT); // issues/900
1691
1692 window.scrollTo(x, y);
1693 });
1694 };
1695
1696 const swalPrefix = 'swal2-';
1697
1698 /**
1699 * @typedef {Record<SwalClass, string>} SwalClasses
1700 */
1701
1702 /**
1703 * @typedef {'success' | 'warning' | 'info' | 'question' | 'error'} SwalIcon
1704 * @typedef {Record<SwalIcon, string>} SwalIcons
1705 */
1706
1707 /** @type {SwalClass[]} */
1708 const classNames = ['container', 'shown', 'height-auto', 'iosfix', 'popup', 'modal', 'no-backdrop', 'no-transition', 'toast', 'toast-shown', 'show', 'hide', 'close', 'title', 'html-container', 'actions', 'confirm', 'deny', 'cancel', 'footer', 'icon', 'icon-content', 'image', 'input', 'file', 'range', 'select', 'radio', 'checkbox', 'label', 'textarea', 'inputerror', 'input-label', 'validation-message', 'progress-steps', 'active-progress-step', 'progress-step', 'progress-step-line', 'loader', 'loading', 'styled', 'top', 'top-start', 'top-end', 'top-left', 'top-right', 'center', 'center-start', 'center-end', 'center-left', 'center-right', 'bottom', 'bottom-start', 'bottom-end', 'bottom-left', 'bottom-right', 'grow-row', 'grow-column', 'grow-fullscreen', 'rtl', 'timer-progress-bar', 'timer-progress-bar-container', 'scrollbar-measure', 'icon-success', 'icon-warning', 'icon-info', 'icon-question', 'icon-error', 'draggable', 'dragging'];
1709 const swalClasses = classNames.reduce((acc, className) => {
1710 acc[className] = swalPrefix + className;
1711 return acc;
1712 }, /** @type {SwalClasses} */{});
1713
1714 /** @type {SwalIcon[]} */
1715 const icons = ['success', 'warning', 'info', 'question', 'error'];
1716 const iconTypes = icons.reduce((acc, icon) => {
1717 acc[icon] = swalPrefix + icon;
1718 return acc;
1719 }, /** @type {SwalIcons} */{});
1720
1721 const consolePrefix = 'SweetAlert2:';
1722
1723 /**
1724 * Capitalize the first letter of a string
1725 *
1726 * @param {string} str
1727 * @returns {string}
1728 */
1729 const capitalizeFirstLetter = str => str.charAt(0).toUpperCase() + str.slice(1);
1730
1731 /**
1732 * Standardize console warnings
1733 *
1734 * @param {string | string[]} message
1735 */
1736 const warn = message => {
1737 console.warn(`${consolePrefix} ${typeof message === 'object' ? message.join(' ') : message}`);
1738 };
1739
1740 /**
1741 * Standardize console errors
1742 *
1743 * @param {string} message
1744 */
1745 const error = message => {
1746 console.error(`${consolePrefix} ${message}`);
1747 };
1748
1749 /**
1750 * Private global state for `warnOnce`
1751 *
1752 * @type {string[]}
1753 * @private
1754 */
1755 const previousWarnOnceMessages = [];
1756
1757 /**
1758 * Show a console warning, but only if it hasn't already been shown
1759 *
1760 * @param {string} message
1761 */
1762 const warnOnce = message => {
1763 if (!previousWarnOnceMessages.includes(message)) {
1764 previousWarnOnceMessages.push(message);
1765 warn(message);
1766 }
1767 };
1768
1769 /**
1770 * Show a one-time console warning about deprecated params/methods
1771 *
1772 * @param {string} deprecatedParam
1773 * @param {string?} useInstead
1774 */
1775 const warnAboutDeprecation = (deprecatedParam, useInstead = null) => {
1776 warnOnce(`"${deprecatedParam}" is deprecated and will be removed in the next major release.${useInstead ? ` Use "${useInstead}" instead.` : ''}`);
1777 };
1778
1779 /**
1780 * If `arg` is a function, call it (with no arguments or context) and return the result.
1781 * Otherwise, just pass the value through
1782 *
1783 * @param {(() => *) | *} arg
1784 * @returns {*}
1785 */
1786 const callIfFunction = arg => typeof arg === 'function' ? arg() : arg;
1787
1788 /**
1789 * @param {*} arg
1790 * @returns {boolean}
1791 */
1792 const hasToPromiseFn = arg => arg && typeof arg.toPromise === 'function';
1793
1794 /**
1795 * @param {*} arg
1796 * @returns {Promise<*>}
1797 */
1798 const asPromise = arg => hasToPromiseFn(arg) ? arg.toPromise() : Promise.resolve(arg);
1799
1800 /**
1801 * @param {*} arg
1802 * @returns {boolean}
1803 */
1804 const isPromise = arg => arg && Promise.resolve(arg) === arg;
1805
1806 /**
1807 * @returns {boolean}
1808 */
1809 const isFirefox = () => navigator.userAgent.includes('Firefox');
1810
1811 /**
1812 * Gets the popup container which contains the backdrop and the popup itself.
1813 *
1814 * @returns {HTMLElement | null}
1815 */
1816 const getContainer = () => document.body.querySelector(`.${swalClasses.container}`);
1817
1818 /**
1819 * @param {string} selectorString
1820 * @returns {HTMLElement | null}
1821 */
1822 const elementBySelector = selectorString => {
1823 const container = getContainer();
1824 return container ? container.querySelector(selectorString) : null;
1825 };
1826
1827 /**
1828 * @param {string} className
1829 * @returns {HTMLElement | null}
1830 */
1831 const elementByClass = className => {
1832 return elementBySelector(`.${className}`);
1833 };
1834
1835 /**
1836 * @returns {HTMLElement | null}
1837 */
1838 const getPopup = () => elementByClass(swalClasses.popup);
1839
1840 /**
1841 * @returns {HTMLElement | null}
1842 */
1843 const getIcon = () => elementByClass(swalClasses.icon);
1844
1845 /**
1846 * @returns {HTMLElement | null}
1847 */
1848 const getIconContent = () => elementByClass(swalClasses['icon-content']);
1849
1850 /**
1851 * @returns {HTMLElement | null}
1852 */
1853 const getTitle = () => elementByClass(swalClasses.title);
1854
1855 /**
1856 * @returns {HTMLElement | null}
1857 */
1858 const getHtmlContainer = () => elementByClass(swalClasses['html-container']);
1859
1860 /**
1861 * @returns {HTMLElement | null}
1862 */
1863 const getImage = () => elementByClass(swalClasses.image);
1864
1865 /**
1866 * @returns {HTMLElement | null}
1867 */
1868 const getProgressSteps = () => elementByClass(swalClasses['progress-steps']);
1869
1870 /**
1871 * @returns {HTMLElement | null}
1872 */
1873 const getValidationMessage = () => elementByClass(swalClasses['validation-message']);
1874
1875 /**
1876 * @returns {HTMLButtonElement | null}
1877 */
1878 const getConfirmButton = () => (/** @type {HTMLButtonElement} */elementBySelector(`.${swalClasses.actions} .${swalClasses.confirm}`));
1879
1880 /**
1881 * @returns {HTMLButtonElement | null}
1882 */
1883 const getCancelButton = () => (/** @type {HTMLButtonElement} */elementBySelector(`.${swalClasses.actions} .${swalClasses.cancel}`));
1884
1885 /**
1886 * @returns {HTMLButtonElement | null}
1887 */
1888 const getDenyButton = () => (/** @type {HTMLButtonElement} */elementBySelector(`.${swalClasses.actions} .${swalClasses.deny}`));
1889
1890 /**
1891 * @returns {HTMLElement | null}
1892 */
1893 const getInputLabel = () => elementByClass(swalClasses['input-label']);
1894
1895 /**
1896 * @returns {HTMLElement | null}
1897 */
1898 const getLoader = () => elementBySelector(`.${swalClasses.loader}`);
1899
1900 /**
1901 * @returns {HTMLElement | null}
1902 */
1903 const getActions = () => elementByClass(swalClasses.actions);
1904
1905 /**
1906 * @returns {HTMLElement | null}
1907 */
1908 const getFooter = () => elementByClass(swalClasses.footer);
1909
1910 /**
1911 * @returns {HTMLElement | null}
1912 */
1913 const getTimerProgressBar = () => elementByClass(swalClasses['timer-progress-bar']);
1914
1915 /**
1916 * @returns {HTMLElement | null}
1917 */
1918 const getCloseButton = () => elementByClass(swalClasses.close);
1919
1920 // https://github.com/jkup/focusable/blob/master/index.js
1921 const focusable = `
1922 a[href],
1923 area[href],
1924 input:not([disabled]),
1925 select:not([disabled]),
1926 textarea:not([disabled]),
1927 button:not([disabled]),
1928 iframe,
1929 object,
1930 embed,
1931 [tabindex="0"],
1932 [contenteditable],
1933 audio[controls],
1934 video[controls],
1935 summary
1936 `;
1937 /**
1938 * @returns {HTMLElement[]}
1939 */
1940 const getFocusableElements = () => {
1941 const popup = getPopup();
1942 if (!popup) {
1943 return [];
1944 }
1945 /** @type {NodeListOf<HTMLElement>} */
1946 const focusableElementsWithTabindex = popup.querySelectorAll('[tabindex]:not([tabindex="-1"]):not([tabindex="0"])');
1947 const focusableElementsWithTabindexSorted = Array.from(focusableElementsWithTabindex)
1948 // sort according to tabindex
1949 .sort((a, b) => {
1950 const tabindexA = parseInt(a.getAttribute('tabindex') || '0');
1951 const tabindexB = parseInt(b.getAttribute('tabindex') || '0');
1952 if (tabindexA > tabindexB) {
1953 return 1;
1954 } else if (tabindexA < tabindexB) {
1955 return -1;
1956 }
1957 return 0;
1958 });
1959
1960 /** @type {NodeListOf<HTMLElement>} */
1961 const otherFocusableElements = popup.querySelectorAll(focusable);
1962 const otherFocusableElementsFiltered = Array.from(otherFocusableElements).filter(el => el.getAttribute('tabindex') !== '-1');
1963 return [...new Set(focusableElementsWithTabindexSorted.concat(otherFocusableElementsFiltered))].filter(el => isVisible$1(el));
1964 };
1965
1966 /**
1967 * @returns {boolean}
1968 */
1969 const isModal = () => {
1970 return hasClass(document.body, swalClasses.shown) && !hasClass(document.body, swalClasses['toast-shown']) && !hasClass(document.body, swalClasses['no-backdrop']);
1971 };
1972
1973 /**
1974 * @returns {boolean}
1975 */
1976 const isToast = () => {
1977 const popup = getPopup();
1978 if (!popup) {
1979 return false;
1980 }
1981 return hasClass(popup, swalClasses.toast);
1982 };
1983
1984 /**
1985 * @returns {boolean}
1986 */
1987 const isLoading = () => {
1988 const popup = getPopup();
1989 if (!popup) {
1990 return false;
1991 }
1992 return popup.hasAttribute('data-loading');
1993 };
1994
1995 /**
1996 * Securely set innerHTML of an element
1997 * https://github.com/sweetalert2/sweetalert2/issues/1926
1998 *
1999 * @param {HTMLElement} elem
2000 * @param {string} html
2001 */
2002 const setInnerHtml = (elem, html) => {
2003 elem.textContent = '';
2004 if (html) {
2005 const parser = new DOMParser();
2006 const parsed = parser.parseFromString(html, `text/html`);
2007 const head = parsed.querySelector('head');
2008 if (head) {
2009 Array.from(head.childNodes).forEach(child => {
2010 elem.appendChild(child);
2011 });
2012 }
2013 const body = parsed.querySelector('body');
2014 if (body) {
2015 Array.from(body.childNodes).forEach(child => {
2016 if (child instanceof HTMLVideoElement || child instanceof HTMLAudioElement) {
2017 elem.appendChild(child.cloneNode(true)); // https://github.com/sweetalert2/sweetalert2/issues/2507
2018 } else {
2019 elem.appendChild(child);
2020 }
2021 });
2022 }
2023 }
2024 };
2025
2026 /**
2027 * @param {HTMLElement} elem
2028 * @param {string} className
2029 * @returns {boolean}
2030 */
2031 const hasClass = (elem, className) => {
2032 if (!className) {
2033 return false;
2034 }
2035 return className.split(/\s+/).every(cls => elem.classList.contains(cls));
2036 };
2037
2038 /**
2039 * @param {HTMLElement} elem
2040 * @param {SweetAlertOptions} params
2041 */
2042 const removeCustomClasses = (elem, params) => {
2043 Array.from(elem.classList).forEach(className => {
2044 if (!Object.values(swalClasses).includes(className) && !Object.values(iconTypes).includes(className) && !Object.values(params.showClass || {}).includes(className)) {
2045 elem.classList.remove(className);
2046 }
2047 });
2048 };
2049
2050 /**
2051 * @param {HTMLElement} elem
2052 * @param {SweetAlertOptions} params
2053 * @param {string} className
2054 */
2055 const applyCustomClass = (elem, params, className) => {
2056 removeCustomClasses(elem, params);
2057 if (!params.customClass) {
2058 return;
2059 }
2060 const customClass = params.customClass[(/** @type {keyof SweetAlertCustomClass} */className)];
2061 if (!customClass) {
2062 return;
2063 }
2064 if (typeof customClass !== 'string' && !customClass.forEach) {
2065 warn(`Invalid type of customClass.${className}! Expected string or iterable object, got "${typeof customClass}"`);
2066 return;
2067 }
2068 addClass(elem, customClass);
2069 };
2070
2071 /**
2072 * @param {HTMLElement} popup
2073 * @param {import('./renderers/renderInput').InputClass | SweetAlertInput} inputClass
2074 * @returns {HTMLInputElement | null}
2075 */
2076 const getInput$1 = (popup, inputClass) => {
2077 if (!inputClass) {
2078 return null;
2079 }
2080 switch (inputClass) {
2081 case 'select':
2082 case 'textarea':
2083 case 'file':
2084 return popup.querySelector(`.${swalClasses.popup} > .${swalClasses[inputClass]}`);
2085 case 'checkbox':
2086 return popup.querySelector(`.${swalClasses.popup} > .${swalClasses.checkbox} input`);
2087 case 'radio':
2088 return popup.querySelector(`.${swalClasses.popup} > .${swalClasses.radio} input:checked`) || popup.querySelector(`.${swalClasses.popup} > .${swalClasses.radio} input:first-child`);
2089 case 'range':
2090 return popup.querySelector(`.${swalClasses.popup} > .${swalClasses.range} input`);
2091 default:
2092 return popup.querySelector(`.${swalClasses.popup} > .${swalClasses.input}`);
2093 }
2094 };
2095
2096 /**
2097 * @param {HTMLInputElement | HTMLTextAreaElement | HTMLSelectElement} input
2098 */
2099 const focusInput = input => {
2100 input.focus();
2101
2102 // place cursor at end of text in text input
2103 if (input.type !== 'file') {
2104 // http://stackoverflow.com/a/2345915
2105 const val = input.value;
2106 input.value = '';
2107 input.value = val;
2108 }
2109 };
2110
2111 /**
2112 * @param {HTMLElement | HTMLElement[] | null} target
2113 * @param {string | string[] | readonly string[] | undefined} classList
2114 * @param {boolean} condition
2115 */
2116 const toggleClass = (target, classList, condition) => {
2117 if (!target || !classList) {
2118 return;
2119 }
2120 const classes = typeof classList === 'string' ? classList.split(/\s+/).filter(Boolean) : classList;
2121 const targets = Array.isArray(target) ? target : [target];
2122 targets.forEach(elem => {
2123 classes.forEach(className => {
2124 if (condition) {
2125 elem.classList.add(className);
2126 } else {
2127 elem.classList.remove(className);
2128 }
2129 });
2130 });
2131 };
2132
2133 /**
2134 * @param {HTMLElement | HTMLElement[] | null} target
2135 * @param {string | string[] | readonly string[] | undefined} classList
2136 */
2137 const addClass = (target, classList) => {
2138 toggleClass(target, classList, true);
2139 };
2140
2141 /**
2142 * @param {HTMLElement | HTMLElement[] | null} target
2143 * @param {string | string[] | readonly string[] | undefined} classList
2144 */
2145 const removeClass = (target, classList) => {
2146 toggleClass(target, classList, false);
2147 };
2148
2149 /**
2150 * Get direct child of an element by class name
2151 *
2152 * @param {HTMLElement} elem
2153 * @param {string} className
2154 * @returns {HTMLElement | undefined}
2155 */
2156 const getDirectChildByClass = (elem, className) => (/** @type {HTMLElement | undefined} */
2157 Array.from(elem.children).find(child => child instanceof HTMLElement && hasClass(child, className)));
2158
2159 /**
2160 * @param {HTMLElement} elem
2161 * @param {string} property
2162 * @param {string | number | null | undefined} value
2163 */
2164 const applyNumericalStyle = (elem, property, value) => {
2165 if (value === `${parseInt(`${value}`)}`) {
2166 value = parseInt(value);
2167 }
2168 if (value || value === 0) {
2169 elem.style.setProperty(property, typeof value === 'number' ? `${value}px` : (/** @type {string} */value));
2170 } else {
2171 elem.style.removeProperty(property);
2172 }
2173 };
2174
2175 /**
2176 * @param {HTMLElement | null} elem
2177 * @param {string} display
2178 */
2179 const show = (elem, display = 'flex') => {
2180 if (!elem) {
2181 return;
2182 }
2183 elem.style.display = display;
2184 };
2185
2186 /**
2187 * @param {HTMLElement | null} elem
2188 */
2189 const hide = elem => {
2190 if (!elem) {
2191 return;
2192 }
2193 elem.style.display = 'none';
2194 };
2195
2196 /**
2197 * @param {HTMLElement | null} elem
2198 * @param {string} display
2199 */
2200 const showWhenInnerHtmlPresent = (elem, display = 'block') => {
2201 if (!elem) {
2202 return;
2203 }
2204 new MutationObserver(() => {
2205 toggle(elem, elem.innerHTML, display);
2206 }).observe(elem, {
2207 childList: true,
2208 subtree: true
2209 });
2210 };
2211
2212 /**
2213 * @param {HTMLElement} parent
2214 * @param {string} selector
2215 * @param {string} property
2216 * @param {string} value
2217 */
2218 const setStyle = (parent, selector, property, value) => {
2219 /** @type {HTMLElement | null} */
2220 const el = parent.querySelector(selector);
2221 if (el) {
2222 el.style.setProperty(property, value);
2223 }
2224 };
2225
2226 /**
2227 * @param {HTMLElement} elem
2228 * @param {boolean | string | null | undefined} condition
2229 * @param {string} display
2230 */
2231 const toggle = (elem, condition, display = 'flex') => {
2232 if (condition) {
2233 show(elem, display);
2234 } else {
2235 hide(elem);
2236 }
2237 };
2238
2239 /**
2240 * borrowed from jquery $(elem).is(':visible') implementation
2241 *
2242 * @param {HTMLElement | null} elem
2243 * @returns {boolean}
2244 */
2245 const isVisible$1 = elem => Boolean(elem && (elem.offsetWidth || elem.offsetHeight || elem.getClientRects().length));
2246
2247 /**
2248 * @returns {boolean}
2249 */
2250 const allButtonsAreHidden = () => !isVisible$1(getConfirmButton()) && !isVisible$1(getDenyButton()) && !isVisible$1(getCancelButton());
2251
2252 /**
2253 * @param {HTMLElement} elem
2254 * @returns {boolean}
2255 */
2256 const isScrollable = elem => Boolean(elem.scrollHeight > elem.clientHeight);
2257
2258 /**
2259 * @param {HTMLElement} element
2260 * @param {HTMLElement} stopElement
2261 * @returns {boolean}
2262 */
2263 const selfOrParentIsScrollable = (element, stopElement) => {
2264 let parent = /** @type {HTMLElement | null} */element;
2265 while (parent && parent !== stopElement) {
2266 if (isScrollable(parent)) {
2267 return true;
2268 }
2269 parent = parent.parentElement;
2270 }
2271 return false;
2272 };
2273
2274 /**
2275 * borrowed from https://stackoverflow.com/a/46352119
2276 *
2277 * @param {HTMLElement} elem
2278 * @returns {boolean}
2279 */
2280 const hasCssAnimation = elem => {
2281 const style = window.getComputedStyle(elem);
2282 const animDuration = parseFloat(style.getPropertyValue('animation-duration') || '0');
2283 const transDuration = parseFloat(style.getPropertyValue('transition-duration') || '0');
2284 return animDuration > 0 || transDuration > 0;
2285 };
2286
2287 /**
2288 * @param {number} timer
2289 * @param {boolean} reset
2290 */
2291 const animateTimerProgressBar = (timer, reset = false) => {
2292 const timerProgressBar = getTimerProgressBar();
2293 if (!timerProgressBar) {
2294 return;
2295 }
2296 if (isVisible$1(timerProgressBar)) {
2297 if (reset) {
2298 timerProgressBar.style.transition = 'none';
2299 timerProgressBar.style.width = '100%';
2300 }
2301 setTimeout(() => {
2302 timerProgressBar.style.transition = `width ${timer / 1000}s linear`;
2303 timerProgressBar.style.width = '0%';
2304 }, 10);
2305 }
2306 };
2307 const stopTimerProgressBar = () => {
2308 const timerProgressBar = getTimerProgressBar();
2309 if (!timerProgressBar) {
2310 return;
2311 }
2312 const timerProgressBarWidth = parseInt(window.getComputedStyle(timerProgressBar).width);
2313 timerProgressBar.style.removeProperty('transition');
2314 timerProgressBar.style.width = '100%';
2315 const timerProgressBarFullWidth = parseInt(window.getComputedStyle(timerProgressBar).width);
2316 const timerProgressBarPercent = timerProgressBarWidth / timerProgressBarFullWidth * 100;
2317 timerProgressBar.style.width = `${timerProgressBarPercent}%`;
2318 };
2319
2320 /**
2321 * Detect Node env
2322 *
2323 * @returns {boolean}
2324 */
2325 const isNodeEnv = () => typeof window === 'undefined' || typeof document === 'undefined';
2326
2327 const sweetHTML = `
2328 <div aria-labelledby="${swalClasses.title}" aria-describedby="${swalClasses['html-container']}" class="${swalClasses.popup}" tabindex="-1">
2329 <button type="button" class="${swalClasses.close}"></button>
2330 <ul class="${swalClasses['progress-steps']}"></ul>
2331 <div class="${swalClasses.icon}"></div>
2332 <img class="${swalClasses.image}" />
2333 <h2 class="${swalClasses.title}" id="${swalClasses.title}"></h2>
2334 <div class="${swalClasses['html-container']}" id="${swalClasses['html-container']}"></div>
2335 <input class="${swalClasses.input}" id="${swalClasses.input}" />
2336 <input type="file" class="${swalClasses.file}" />
2337 <div class="${swalClasses.range}">
2338 <input type="range" />
2339 <output></output>
2340 </div>
2341 <select class="${swalClasses.select}" id="${swalClasses.select}"></select>
2342 <div class="${swalClasses.radio}"></div>
2343 <label class="${swalClasses.checkbox}">
2344 <input type="checkbox" id="${swalClasses.checkbox}" />
2345 <span class="${swalClasses.label}"></span>
2346 </label>
2347 <textarea class="${swalClasses.textarea}" id="${swalClasses.textarea}"></textarea>
2348 <div class="${swalClasses['validation-message']}" id="${swalClasses['validation-message']}"></div>
2349 <div class="${swalClasses.actions}">
2350 <div class="${swalClasses.loader}"></div>
2351 <button type="button" class="${swalClasses.confirm}"></button>
2352 <button type="button" class="${swalClasses.deny}"></button>
2353 <button type="button" class="${swalClasses.cancel}"></button>
2354 </div>
2355 <div class="${swalClasses.footer}"></div>
2356 <div class="${swalClasses['timer-progress-bar-container']}">
2357 <div class="${swalClasses['timer-progress-bar']}"></div>
2358 </div>
2359 </div>
2360 `.replace(/(^|\n)\s*/g, '');
2361
2362 /**
2363 * @returns {boolean}
2364 */
2365 const resetOldContainer = () => {
2366 const oldContainer = getContainer();
2367 if (!oldContainer) {
2368 return false;
2369 }
2370 oldContainer.remove();
2371 removeClass([document.documentElement, document.body], [swalClasses['no-backdrop'], swalClasses['toast-shown'],
2372 // @ts-ignore: 'has-column' is not defined in swalClasses but may be set dynamically
2373 swalClasses['has-column']]);
2374 return true;
2375 };
2376 const resetValidationMessage$1 = () => {
2377 if (globalState.currentInstance) {
2378 globalState.currentInstance.resetValidationMessage();
2379 }
2380 };
2381 const addInputChangeListeners = () => {
2382 const popup = getPopup();
2383 if (!popup) {
2384 return;
2385 }
2386 const input = getDirectChildByClass(popup, swalClasses.input);
2387 const file = getDirectChildByClass(popup, swalClasses.file);
2388 /** @type {HTMLInputElement | null} */
2389 const range = popup.querySelector(`.${swalClasses.range} input`);
2390 /** @type {HTMLOutputElement | null} */
2391 const rangeOutput = popup.querySelector(`.${swalClasses.range} output`);
2392 const select = getDirectChildByClass(popup, swalClasses.select);
2393 /** @type {HTMLInputElement | null} */
2394 const checkbox = popup.querySelector(`.${swalClasses.checkbox} input`);
2395 const textarea = getDirectChildByClass(popup, swalClasses.textarea);
2396 if (input) {
2397 input.oninput = resetValidationMessage$1;
2398 }
2399 if (file) {
2400 file.onchange = resetValidationMessage$1;
2401 }
2402 if (select) {
2403 select.onchange = resetValidationMessage$1;
2404 }
2405 if (checkbox) {
2406 checkbox.onchange = resetValidationMessage$1;
2407 }
2408 if (textarea) {
2409 textarea.oninput = resetValidationMessage$1;
2410 }
2411 if (range && rangeOutput) {
2412 range.oninput = () => {
2413 resetValidationMessage$1();
2414 rangeOutput.value = range.value;
2415 };
2416 range.onchange = () => {
2417 resetValidationMessage$1();
2418 rangeOutput.value = range.value;
2419 };
2420 }
2421 };
2422
2423 /**
2424 * @param {string | HTMLElement} target
2425 * @returns {HTMLElement}
2426 */
2427 const getTarget = target => {
2428 if (typeof target === 'string') {
2429 const element = document.querySelector(target);
2430 if (!element) {
2431 throw new Error(`Target element "${target}" not found`);
2432 }
2433 return /** @type {HTMLElement} */element;
2434 }
2435 return target;
2436 };
2437
2438 /**
2439 * @param {SweetAlertOptions} params
2440 */
2441 const setupAccessibility = params => {
2442 const popup = getPopup();
2443 if (!popup) {
2444 return;
2445 }
2446 popup.setAttribute('role', params.toast ? 'alert' : 'dialog');
2447 popup.setAttribute('aria-live', params.toast ? 'polite' : 'assertive');
2448 if (!params.toast) {
2449 popup.setAttribute('aria-modal', 'true');
2450 }
2451 };
2452
2453 /**
2454 * @param {HTMLElement} targetElement
2455 */
2456 const setupRTL = targetElement => {
2457 if (window.getComputedStyle(targetElement).direction === 'rtl') {
2458 addClass(getContainer(), swalClasses.rtl);
2459 globalState.isRTL = true;
2460 }
2461 };
2462
2463 /**
2464 * Add modal + backdrop to DOM
2465 *
2466 * @param {SweetAlertOptions} params
2467 */
2468 const init = params => {
2469 // Clean up the old popup container if it exists
2470 const oldContainerExisted = resetOldContainer();
2471 if (isNodeEnv()) {
2472 error('SweetAlert2 requires document to initialize');
2473 return;
2474 }
2475 const container = document.createElement('div');
2476 container.className = swalClasses.container;
2477 if (oldContainerExisted) {
2478 addClass(container, swalClasses['no-transition']);
2479 }
2480 setInnerHtml(container, sweetHTML);
2481 container.dataset['swal2Theme'] = params.theme;
2482 const targetElement = getTarget(params.target || 'body');
2483 targetElement.appendChild(container);
2484 if (params.topLayer) {
2485 container.setAttribute('popover', '');
2486 container.showPopover();
2487 }
2488 setupAccessibility(params);
2489 setupRTL(targetElement);
2490 addInputChangeListeners();
2491 };
2492
2493 /**
2494 * @param {HTMLElement | object | string} param
2495 * @param {HTMLElement} target
2496 */
2497 const parseHtmlToContainer = (param, target) => {
2498 // DOM element
2499 if (param instanceof HTMLElement) {
2500 target.appendChild(param);
2501 }
2502
2503 // Object
2504 else if (typeof param === 'object') {
2505 handleObject(param, target);
2506 }
2507
2508 // Plain string
2509 else if (param) {
2510 setInnerHtml(target, param);
2511 }
2512 };
2513
2514 /**
2515 * @param {object} param
2516 * @param {HTMLElement} target
2517 */
2518 const handleObject = (param, target) => {
2519 // JQuery element(s)
2520 if ('jquery' in param) {
2521 handleJqueryElem(target, param);
2522 }
2523
2524 // For other objects use their string representation
2525 else {
2526 setInnerHtml(target, param.toString());
2527 }
2528 };
2529
2530 /**
2531 * @param {HTMLElement} target
2532 * @param {any} elem
2533 */
2534 const handleJqueryElem = (target, elem) => {
2535 target.textContent = '';
2536 if (0 in elem) {
2537 for (let i = 0; i in elem; i++) {
2538 target.appendChild(elem[i].cloneNode(true));
2539 }
2540 } else {
2541 target.appendChild(elem.cloneNode(true));
2542 }
2543 };
2544
2545 /**
2546 * @param {SweetAlert} instance
2547 * @param {SweetAlertOptions} params
2548 */
2549 const renderActions = (instance, params) => {
2550 const actions = getActions();
2551 const loader = getLoader();
2552 if (!actions || !loader) {
2553 return;
2554 }
2555
2556 // Actions (buttons) wrapper
2557 if (!params.showConfirmButton && !params.showDenyButton && !params.showCancelButton) {
2558 hide(actions);
2559 } else {
2560 show(actions);
2561 }
2562
2563 // Custom class
2564 applyCustomClass(actions, params, 'actions');
2565
2566 // Render all the buttons
2567 renderButtons(actions, loader, params);
2568
2569 // Loader
2570 setInnerHtml(loader, params.loaderHtml || '');
2571 applyCustomClass(loader, params, 'loader');
2572 };
2573
2574 /**
2575 * @param {HTMLElement} actions
2576 * @param {HTMLElement} loader
2577 * @param {SweetAlertOptions} params
2578 */
2579 function renderButtons(actions, loader, params) {
2580 const confirmButton = getConfirmButton();
2581 const denyButton = getDenyButton();
2582 const cancelButton = getCancelButton();
2583 if (!confirmButton || !denyButton || !cancelButton) {
2584 return;
2585 }
2586
2587 // Render buttons
2588 renderButton(confirmButton, 'confirm', params);
2589 renderButton(denyButton, 'deny', params);
2590 renderButton(cancelButton, 'cancel', params);
2591 handleButtonsStyling(confirmButton, denyButton, cancelButton, params);
2592 if (params.reverseButtons) {
2593 if (params.toast) {
2594 actions.insertBefore(cancelButton, confirmButton);
2595 actions.insertBefore(denyButton, confirmButton);
2596 } else {
2597 actions.insertBefore(cancelButton, loader);
2598 actions.insertBefore(denyButton, loader);
2599 actions.insertBefore(confirmButton, loader);
2600 }
2601 }
2602 }
2603
2604 /**
2605 * @param {HTMLElement} confirmButton
2606 * @param {HTMLElement} denyButton
2607 * @param {HTMLElement} cancelButton
2608 * @param {SweetAlertOptions} params
2609 */
2610 function handleButtonsStyling(confirmButton, denyButton, cancelButton, params) {
2611 if (!params.buttonsStyling) {
2612 removeClass([confirmButton, denyButton, cancelButton], swalClasses.styled);
2613 return;
2614 }
2615 addClass([confirmButton, denyButton, cancelButton], swalClasses.styled);
2616
2617 // Apply custom background colors and outline colors to action buttons
2618 /** @type {[HTMLElement, string, string | undefined][]} */
2619 const buttons = [[confirmButton, 'confirm', params.confirmButtonColor], [denyButton, 'deny', params.denyButtonColor], [cancelButton, 'cancel', params.cancelButtonColor]];
2620 buttons.forEach(([button, type, color]) => {
2621 if (color) {
2622 button.style.setProperty(`--swal2-${type}-button-background-color`, color);
2623 }
2624 applyOutlineColor(button);
2625 });
2626 }
2627
2628 /**
2629 * @param {HTMLElement} button
2630 */
2631 function applyOutlineColor(button) {
2632 const buttonStyle = window.getComputedStyle(button);
2633 if (buttonStyle.getPropertyValue('--swal2-action-button-focus-box-shadow')) {
2634 // If the button already has a custom outline color, no need to change it
2635 return;
2636 }
2637 const outlineColor = buttonStyle.backgroundColor.replace(/rgba?\((\d+), (\d+), (\d+).*/, 'rgba($1, $2, $3, 0.5)');
2638 button.style.setProperty('--swal2-action-button-focus-box-shadow', buttonStyle.getPropertyValue('--swal2-outline').replace(/ rgba\(.*/, ` ${outlineColor}`));
2639 }
2640
2641 /**
2642 * @param {HTMLElement} button
2643 * @param {'confirm' | 'deny' | 'cancel'} buttonType
2644 * @param {SweetAlertOptions} params
2645 */
2646 function renderButton(button, buttonType, params) {
2647 const buttonName = /** @type {'Confirm' | 'Deny' | 'Cancel'} */capitalizeFirstLetter(buttonType);
2648 toggle(button, params[`show${buttonName}Button`], 'inline-block');
2649 setInnerHtml(button, params[`${buttonType}ButtonText`] || ''); // Set caption text
2650 button.setAttribute('aria-label', params[`${buttonType}ButtonAriaLabel`] || ''); // ARIA label
2651
2652 // Add buttons custom classes
2653 button.className = swalClasses[buttonType];
2654 applyCustomClass(button, params, `${buttonType}Button`);
2655 }
2656
2657 /**
2658 * @param {SweetAlert} instance
2659 * @param {SweetAlertOptions} params
2660 */
2661 const renderCloseButton = (instance, params) => {
2662 const closeButton = getCloseButton();
2663 if (!closeButton) {
2664 return;
2665 }
2666 setInnerHtml(closeButton, params.closeButtonHtml || '');
2667
2668 // Custom class
2669 applyCustomClass(closeButton, params, 'closeButton');
2670 toggle(closeButton, params.showCloseButton);
2671 closeButton.setAttribute('aria-label', params.closeButtonAriaLabel || '');
2672 };
2673
2674 /**
2675 * @param {SweetAlert} instance
2676 * @param {SweetAlertOptions} params
2677 */
2678 const renderContainer = (instance, params) => {
2679 const container = getContainer();
2680 if (!container) {
2681 return;
2682 }
2683 handleBackdropParam(container, params.backdrop);
2684 handlePositionParam(container, params.position);
2685 handleGrowParam(container, params.grow);
2686
2687 // Custom class
2688 applyCustomClass(container, params, 'container');
2689 };
2690
2691 /**
2692 * @param {HTMLElement} container
2693 * @param {SweetAlertOptions['backdrop']} backdrop
2694 */
2695 function handleBackdropParam(container, backdrop) {
2696 if (typeof backdrop === 'string') {
2697 container.style.background = backdrop;
2698 } else if (!backdrop) {
2699 addClass([document.documentElement, document.body], swalClasses['no-backdrop']);
2700 }
2701 }
2702
2703 /**
2704 * @param {HTMLElement} container
2705 * @param {SweetAlertOptions['position']} position
2706 */
2707 function handlePositionParam(container, position) {
2708 if (!position) {
2709 return;
2710 }
2711 if (position in swalClasses) {
2712 addClass(container, swalClasses[position]);
2713 } else {
2714 warn('The "position" parameter is not valid, defaulting to "center"');
2715 addClass(container, swalClasses.center);
2716 }
2717 }
2718
2719 /**
2720 * @param {HTMLElement} container
2721 * @param {SweetAlertOptions['grow']} grow
2722 */
2723 function handleGrowParam(container, grow) {
2724 if (!grow) {
2725 return;
2726 }
2727 addClass(container, swalClasses[`grow-${grow}`]);
2728 }
2729
2730 /**
2731 * This module contains `WeakMap`s for each effectively-"private property" that a `Swal` has.
2732 * For example, to set the private property "foo" of `this` to "bar", you can `privateProps.foo.set(this, 'bar')`
2733 * This is the approach that Babel will probably take to implement private methods/fields
2734 * https://github.com/tc39/proposal-private-methods
2735 * https://github.com/babel/babel/pull/7555
2736 * Once we have the changes from that PR in Babel, and our core class fits reasonable in *one module*
2737 * then we can use that language feature.
2738 */
2739
2740 var privateProps = {
2741 innerParams: new WeakMap(),
2742 domCache: new WeakMap(),
2743 focusedElement: new WeakMap()
2744 };
2745
2746 /// <reference path="../../../../sweetalert2.d.ts"/>
2747
2748
2749 /** @type {InputClass[]} */
2750 const inputClasses = ['input', 'file', 'range', 'select', 'radio', 'checkbox', 'textarea'];
2751
2752 /**
2753 * @param {SweetAlert} instance
2754 * @param {SweetAlertOptions} params
2755 */
2756 const renderInput = (instance, params) => {
2757 const popup = getPopup();
2758 if (!popup) {
2759 return;
2760 }
2761 const innerParams = privateProps.innerParams.get(instance);
2762 const rerender = !innerParams || params.input !== innerParams.input;
2763 inputClasses.forEach(inputClass => {
2764 const inputContainer = getDirectChildByClass(popup, swalClasses[inputClass]);
2765 if (!inputContainer) {
2766 return;
2767 }
2768
2769 // set attributes
2770 setAttributes(inputClass, params.inputAttributes);
2771
2772 // set class
2773 inputContainer.className = swalClasses[inputClass];
2774 if (rerender) {
2775 hide(inputContainer);
2776 }
2777 });
2778 if (params.input) {
2779 if (rerender) {
2780 showInput(params);
2781 }
2782 // set custom class
2783 setCustomClass(params);
2784 }
2785 };
2786
2787 /**
2788 * @param {SweetAlertOptions} params
2789 */
2790 const showInput = params => {
2791 if (!params.input) {
2792 return;
2793 }
2794 if (!renderInputType[params.input]) {
2795 error(`Unexpected type of input! Expected ${Object.keys(renderInputType).join(' | ')}, got "${params.input}"`);
2796 return;
2797 }
2798 const inputContainer = getInputContainer(params.input);
2799 if (!inputContainer) {
2800 return;
2801 }
2802 const input = renderInputType[params.input](inputContainer, params);
2803 show(inputContainer);
2804
2805 // input autofocus
2806 if (params.inputAutoFocus) {
2807 setTimeout(() => {
2808 focusInput(input);
2809 });
2810 }
2811 };
2812
2813 /**
2814 * @param {HTMLInputElement} input
2815 */
2816 const removeAttributes = input => {
2817 for (const {
2818 name
2819 } of Array.from(input.attributes)) {
2820 if (!['id', 'type', 'value', 'style'].includes(name)) {
2821 input.removeAttribute(name);
2822 }
2823 }
2824 };
2825
2826 /**
2827 * @param {InputClass} inputClass
2828 * @param {SweetAlertOptions['inputAttributes']} inputAttributes
2829 */
2830 const setAttributes = (inputClass, inputAttributes) => {
2831 const popup = getPopup();
2832 if (!popup) {
2833 return;
2834 }
2835 const input = getInput$1(popup, inputClass);
2836 if (!input) {
2837 return;
2838 }
2839 removeAttributes(input);
2840 for (const attr in inputAttributes) {
2841 input.setAttribute(attr, inputAttributes[attr]);
2842 }
2843 };
2844
2845 /**
2846 * @param {SweetAlertOptions} params
2847 */
2848 const setCustomClass = params => {
2849 if (!params.input) {
2850 return;
2851 }
2852 const inputContainer = getInputContainer(params.input);
2853 if (inputContainer) {
2854 applyCustomClass(inputContainer, params, 'input');
2855 }
2856 };
2857
2858 /**
2859 * @param {HTMLInputElement | HTMLTextAreaElement} input
2860 * @param {SweetAlertOptions} params
2861 */
2862 const setInputPlaceholder = (input, params) => {
2863 if (!input.placeholder && params.inputPlaceholder) {
2864 input.placeholder = params.inputPlaceholder;
2865 }
2866 };
2867
2868 /**
2869 * @param {Input} input
2870 * @param {Input} prependTo
2871 * @param {SweetAlertOptions} params
2872 */
2873 const setInputLabel = (input, prependTo, params) => {
2874 if (params.inputLabel) {
2875 const label = document.createElement('label');
2876 const labelClass = swalClasses['input-label'];
2877 label.setAttribute('for', input.id);
2878 label.className = labelClass;
2879 if (typeof params.customClass === 'object') {
2880 addClass(label, params.customClass.inputLabel);
2881 }
2882 label.innerText = params.inputLabel;
2883 prependTo.insertAdjacentElement('beforebegin', label);
2884 }
2885 };
2886
2887 /**
2888 * @param {SweetAlertInput} inputType
2889 * @returns {HTMLElement | undefined}
2890 */
2891 const getInputContainer = inputType => {
2892 const popup = getPopup();
2893 if (!popup) {
2894 return;
2895 }
2896 return getDirectChildByClass(popup, swalClasses[(/** @type {SwalClass} */inputType)] || swalClasses.input);
2897 };
2898
2899 /**
2900 * @param {HTMLInputElement | HTMLOutputElement | HTMLTextAreaElement} input
2901 * @param {SweetAlertOptions['inputValue']} inputValue
2902 */
2903 const checkAndSetInputValue = (input, inputValue) => {
2904 if (['string', 'number'].includes(typeof inputValue)) {
2905 input.value = `${inputValue}`;
2906 } else if (!isPromise(inputValue)) {
2907 warn(`Unexpected type of inputValue! Expected "string", "number" or "Promise", got "${typeof inputValue}"`);
2908 }
2909 };
2910
2911 /** @type {Record<SweetAlertInput, (input: Input | HTMLElement, params: SweetAlertOptions) => Input>} */
2912 const renderInputType = {};
2913
2914 /**
2915 * @param {Input | HTMLElement} input
2916 * @param {SweetAlertOptions} params
2917 * @returns {Input}
2918 */
2919 renderInputType.text = renderInputType.email = renderInputType.password = renderInputType.number = renderInputType.tel = renderInputType.url = renderInputType.search = renderInputType.date = renderInputType['datetime-local'] = renderInputType.time = renderInputType.week = renderInputType.month = /** @type {(input: Input | HTMLElement, params: SweetAlertOptions) => Input} */
2920 (input, params) => {
2921 // oxfmt-ignore
2922 const inputElement = /** @type {HTMLInputElement} */input;
2923 checkAndSetInputValue(inputElement, params.inputValue);
2924 setInputLabel(inputElement, inputElement, params);
2925 setInputPlaceholder(inputElement, params);
2926 // oxfmt-ignore
2927 inputElement.type = /** @type {string} */params.input;
2928 return inputElement;
2929 };
2930
2931 /**
2932 * @param {Input | HTMLElement} input
2933 * @param {SweetAlertOptions} params
2934 * @returns {Input}
2935 */
2936 renderInputType.file = (input, params) => {
2937 const inputElement = /** @type {HTMLInputElement} */input;
2938 setInputLabel(inputElement, inputElement, params);
2939 setInputPlaceholder(inputElement, params);
2940 return inputElement;
2941 };
2942
2943 /**
2944 * @param {Input | HTMLElement} range
2945 * @param {SweetAlertOptions} params
2946 * @returns {Input}
2947 */
2948 renderInputType.range = (range, params) => {
2949 const rangeContainer = /** @type {HTMLElement} */range;
2950 const rangeInput = rangeContainer.querySelector('input');
2951 const rangeOutput = rangeContainer.querySelector('output');
2952 if (rangeInput) {
2953 checkAndSetInputValue(rangeInput, params.inputValue);
2954 rangeInput.type = /** @type {string} */params.input;
2955 setInputLabel(rangeInput, /** @type {Input} */range, params);
2956 }
2957 if (rangeOutput) {
2958 checkAndSetInputValue(rangeOutput, params.inputValue);
2959 }
2960 return /** @type {Input} */range;
2961 };
2962
2963 /**
2964 * @param {Input | HTMLElement} select
2965 * @param {SweetAlertOptions} params
2966 * @returns {Input}
2967 */
2968 renderInputType.select = (select, params) => {
2969 const selectElement = /** @type {HTMLSelectElement} */select;
2970 selectElement.textContent = '';
2971 if (params.inputPlaceholder) {
2972 const placeholder = document.createElement('option');
2973 setInnerHtml(placeholder, params.inputPlaceholder);
2974 placeholder.value = '';
2975 placeholder.disabled = true;
2976 placeholder.selected = true;
2977 selectElement.appendChild(placeholder);
2978 }
2979 setInputLabel(selectElement, selectElement, params);
2980 return selectElement;
2981 };
2982
2983 /**
2984 * @param {Input | HTMLElement} radio
2985 * @returns {Input}
2986 */
2987 renderInputType.radio = radio => {
2988 const radioElement = /** @type {HTMLElement} */radio;
2989 radioElement.textContent = '';
2990 return /** @type {Input} */radio;
2991 };
2992
2993 /**
2994 * @param {Input | HTMLElement} checkboxContainer
2995 * @param {SweetAlertOptions} params
2996 * @returns {Input}
2997 */
2998 renderInputType.checkbox = (checkboxContainer, params) => {
2999 const popup = getPopup();
3000 if (!popup) {
3001 throw new Error('Popup not found');
3002 }
3003 const checkbox = getInput$1(popup, 'checkbox');
3004 if (!checkbox) {
3005 throw new Error('Checkbox input not found');
3006 }
3007 checkbox.value = '1';
3008 checkbox.checked = Boolean(params.inputValue);
3009 const containerElement = /** @type {HTMLElement} */checkboxContainer;
3010 const label = containerElement.querySelector('span');
3011 if (label) {
3012 const placeholderOrLabel = params.inputPlaceholder || params.inputLabel;
3013 if (placeholderOrLabel) {
3014 setInnerHtml(label, placeholderOrLabel);
3015 }
3016 }
3017 return checkbox;
3018 };
3019
3020 /**
3021 * @param {Input | HTMLElement} textarea
3022 * @param {SweetAlertOptions} params
3023 * @returns {Input}
3024 */
3025 renderInputType.textarea = (textarea, params) => {
3026 const textareaElement = /** @type {HTMLTextAreaElement} */textarea;
3027 checkAndSetInputValue(textareaElement, params.inputValue);
3028 setInputPlaceholder(textareaElement, params);
3029 setInputLabel(textareaElement, textareaElement, params);
3030
3031 /**
3032 * @param {HTMLElement} el
3033 * @returns {number}
3034 */
3035 const getMargin = el => parseInt(window.getComputedStyle(el).marginLeft) + parseInt(window.getComputedStyle(el).marginRight);
3036
3037 // https://github.com/sweetalert2/sweetalert2/issues/2291
3038 setTimeout(() => {
3039 // https://github.com/sweetalert2/sweetalert2/issues/1699
3040 if ('MutationObserver' in window) {
3041 const popup = getPopup();
3042 if (!popup) {
3043 return;
3044 }
3045 const initialPopupWidth = parseInt(window.getComputedStyle(popup).width);
3046 const textareaResizeHandler = () => {
3047 // check if texarea is still in document (i.e. popup wasn't closed in the meantime)
3048 if (!document.body.contains(textareaElement)) {
3049 return;
3050 }
3051 const textareaWidth = textareaElement.offsetWidth + getMargin(textareaElement);
3052 const popupElement = getPopup();
3053 if (popupElement) {
3054 if (textareaWidth > initialPopupWidth) {
3055 popupElement.style.width = `${textareaWidth}px`;
3056 } else {
3057 applyNumericalStyle(popupElement, 'width', params.width);
3058 }
3059 }
3060 };
3061 new MutationObserver(textareaResizeHandler).observe(textareaElement, {
3062 attributes: true,
3063 attributeFilter: ['style']
3064 });
3065 }
3066 });
3067 return textareaElement;
3068 };
3069
3070 /**
3071 * @param {SweetAlert} instance
3072 * @param {SweetAlertOptions} params
3073 */
3074 const renderContent = (instance, params) => {
3075 const htmlContainer = getHtmlContainer();
3076 if (!htmlContainer) {
3077 return;
3078 }
3079 showWhenInnerHtmlPresent(htmlContainer);
3080 applyCustomClass(htmlContainer, params, 'htmlContainer');
3081
3082 // Content as HTML
3083 if (params.html) {
3084 parseHtmlToContainer(params.html, htmlContainer);
3085 show(htmlContainer, 'block');
3086 }
3087
3088 // Content as plain text
3089 else if (params.text) {
3090 htmlContainer.textContent = params.text;
3091 show(htmlContainer, 'block');
3092 }
3093
3094 // No content
3095 else {
3096 hide(htmlContainer);
3097 }
3098 renderInput(instance, params);
3099 };
3100
3101 /**
3102 * @param {SweetAlert} instance
3103 * @param {SweetAlertOptions} params
3104 */
3105 const renderFooter = (instance, params) => {
3106 const footer = getFooter();
3107 if (!footer) {
3108 return;
3109 }
3110 showWhenInnerHtmlPresent(footer);
3111 toggle(footer, Boolean(params.footer), 'block');
3112 if (params.footer) {
3113 parseHtmlToContainer(params.footer, footer);
3114 }
3115
3116 // Custom class
3117 applyCustomClass(footer, params, 'footer');
3118 };
3119
3120 /**
3121 * @param {SweetAlert} instance
3122 * @param {SweetAlertOptions} params
3123 */
3124 const renderIcon = (instance, params) => {
3125 const innerParams = privateProps.innerParams.get(instance);
3126 const icon = getIcon();
3127 if (!icon) {
3128 return;
3129 }
3130
3131 // if the given icon already rendered, apply the styling without re-rendering the icon
3132 if (innerParams && params.icon === innerParams.icon) {
3133 // Custom or default content
3134 setContent(icon, params);
3135 applyStyles(icon, params);
3136 return;
3137 }
3138 if (!params.icon && !params.iconHtml) {
3139 hide(icon);
3140 return;
3141 }
3142 if (params.icon && Object.keys(iconTypes).indexOf(params.icon) === -1) {
3143 error(`Unknown icon! Expected "success", "error", "warning", "info" or "question", got "${params.icon}"`);
3144 hide(icon);
3145 return;
3146 }
3147 show(icon);
3148
3149 // Custom or default content
3150 setContent(icon, params);
3151 applyStyles(icon, params);
3152
3153 // Animate icon
3154 addClass(icon, params.showClass && params.showClass.icon);
3155
3156 // Re-adjust the success icon on system theme change
3157 const colorSchemeQueryList = window.matchMedia('(prefers-color-scheme: dark)');
3158 colorSchemeQueryList.addEventListener('change', adjustSuccessIconBackgroundColor);
3159 };
3160
3161 /**
3162 * @param {HTMLElement} icon
3163 * @param {SweetAlertOptions} params
3164 */
3165 const applyStyles = (icon, params) => {
3166 for (const [iconType, iconClassName] of Object.entries(iconTypes)) {
3167 if (params.icon !== iconType) {
3168 removeClass(icon, iconClassName);
3169 }
3170 }
3171 addClass(icon, params.icon && iconTypes[params.icon]);
3172
3173 // Icon color
3174 setColor(icon, params);
3175
3176 // Success icon background color
3177 adjustSuccessIconBackgroundColor();
3178
3179 // Custom class
3180 applyCustomClass(icon, params, 'icon');
3181 };
3182
3183 // Adjust success icon background color to match the popup background color
3184 const adjustSuccessIconBackgroundColor = () => {
3185 const popup = getPopup();
3186 if (!popup) {
3187 return;
3188 }
3189 const popupBackgroundColor = window.getComputedStyle(popup).getPropertyValue('background-color');
3190 /** @type {NodeListOf<HTMLElement>} */
3191 const successIconParts = popup.querySelectorAll('[class^=swal2-success-circular-line], .swal2-success-fix');
3192 successIconParts.forEach(part => {
3193 part.style.backgroundColor = popupBackgroundColor;
3194 });
3195 };
3196
3197 /**
3198 *
3199 * @param {SweetAlertOptions} params
3200 * @returns {string}
3201 */
3202 const successIconHtml = params => `
3203 ${params.animation ? '<div class="swal2-success-circular-line-left"></div>' : ''}
3204 <span class="swal2-success-line-tip"></span> <span class="swal2-success-line-long"></span>
3205 <div class="swal2-success-ring"></div>
3206 ${params.animation ? '<div class="swal2-success-fix"></div>' : ''}
3207 ${params.animation ? '<div class="swal2-success-circular-line-right"></div>' : ''}
3208 `;
3209 const errorIconHtml = `
3210 <span class="swal2-x-mark">
3211 <span class="swal2-x-mark-line-left"></span>
3212 <span class="swal2-x-mark-line-right"></span>
3213 </span>
3214 `;
3215
3216 /**
3217 * @param {HTMLElement} icon
3218 * @param {SweetAlertOptions} params
3219 */
3220 const setContent = (icon, params) => {
3221 if (!params.icon && !params.iconHtml) {
3222 return;
3223 }
3224 let oldContent = icon.innerHTML;
3225 let newContent = '';
3226 if (params.iconHtml) {
3227 newContent = iconContent(params.iconHtml);
3228 } else if (params.icon === 'success') {
3229 newContent = successIconHtml(params);
3230 oldContent = oldContent.replace(/ style=".*?"/g, ''); // undo adjustSuccessIconBackgroundColor()
3231 } else if (params.icon === 'error') {
3232 newContent = errorIconHtml;
3233 } else if (params.icon) {
3234 const defaultIconHtml = {
3235 question: '?',
3236 warning: '!',
3237 info: 'i'
3238 };
3239 newContent = iconContent(defaultIconHtml[params.icon]);
3240 }
3241 if (oldContent.trim() !== newContent.trim()) {
3242 setInnerHtml(icon, newContent);
3243 }
3244 };
3245
3246 /**
3247 * @param {HTMLElement} icon
3248 * @param {SweetAlertOptions} params
3249 */
3250 const setColor = (icon, params) => {
3251 if (!params.iconColor) {
3252 return;
3253 }
3254 icon.style.color = params.iconColor;
3255 icon.style.borderColor = params.iconColor;
3256 for (const sel of ['.swal2-success-line-tip', '.swal2-success-line-long', '.swal2-x-mark-line-left', '.swal2-x-mark-line-right']) {
3257 setStyle(icon, sel, 'background-color', params.iconColor);
3258 }
3259 setStyle(icon, '.swal2-success-ring', 'border-color', params.iconColor);
3260 };
3261
3262 /**
3263 * @param {string} content
3264 * @returns {string}
3265 */
3266 const iconContent = content => `<div class="${swalClasses['icon-content']}">${content}</div>`;
3267
3268 /**
3269 * @param {SweetAlert} instance
3270 * @param {SweetAlertOptions} params
3271 */
3272 const renderImage = (instance, params) => {
3273 const image = getImage();
3274 if (!image) {
3275 return;
3276 }
3277 if (!params.imageUrl) {
3278 hide(image);
3279 return;
3280 }
3281 show(image, '');
3282
3283 // Src, alt
3284 image.setAttribute('src', params.imageUrl);
3285 image.setAttribute('alt', params.imageAlt || '');
3286
3287 // Width, height
3288 applyNumericalStyle(image, 'width', params.imageWidth);
3289 applyNumericalStyle(image, 'height', params.imageHeight);
3290
3291 // Class
3292 image.className = swalClasses.image;
3293 applyCustomClass(image, params, 'image');
3294 };
3295
3296 let dragging = false;
3297 let mousedownX = 0;
3298 let mousedownY = 0;
3299 let initialX = 0;
3300 let initialY = 0;
3301
3302 /**
3303 * @param {HTMLElement} popup
3304 */
3305 const addDraggableListeners = popup => {
3306 popup.addEventListener('mousedown', down);
3307 document.body.addEventListener('mousemove', move);
3308 popup.addEventListener('mouseup', up);
3309 popup.addEventListener('touchstart', down);
3310 document.body.addEventListener('touchmove', move);
3311 popup.addEventListener('touchend', up);
3312 };
3313
3314 /**
3315 * @param {HTMLElement} popup
3316 */
3317 const removeDraggableListeners = popup => {
3318 popup.removeEventListener('mousedown', down);
3319 document.body.removeEventListener('mousemove', move);
3320 popup.removeEventListener('mouseup', up);
3321 popup.removeEventListener('touchstart', down);
3322 document.body.removeEventListener('touchmove', move);
3323 popup.removeEventListener('touchend', up);
3324 };
3325
3326 /**
3327 * @param {MouseEvent | TouchEvent} event
3328 */
3329 const down = event => {
3330 const popup = getPopup();
3331 if (!popup) {
3332 return;
3333 }
3334 const icon = getIcon();
3335 if (event.target === popup || icon && icon.contains(/** @type {HTMLElement} */event.target)) {
3336 dragging = true;
3337 const clientXY = getClientXY(event);
3338 mousedownX = clientXY.clientX;
3339 mousedownY = clientXY.clientY;
3340 initialX = parseInt(popup.style.insetInlineStart) || 0;
3341 initialY = parseInt(popup.style.insetBlockStart) || 0;
3342 addClass(popup, 'swal2-dragging');
3343 }
3344 };
3345
3346 /**
3347 * @param {MouseEvent | TouchEvent} event
3348 */
3349 const move = event => {
3350 const popup = getPopup();
3351 if (!popup) {
3352 return;
3353 }
3354 if (dragging) {
3355 let {
3356 clientX,
3357 clientY
3358 } = getClientXY(event);
3359 const deltaX = clientX - mousedownX;
3360 // In RTL mode, negate the horizontal delta since insetInlineStart refers to the right edge
3361 popup.style.insetInlineStart = `${initialX + (globalState.isRTL ? -deltaX : deltaX)}px`;
3362 popup.style.insetBlockStart = `${initialY + (clientY - mousedownY)}px`;
3363 }
3364 };
3365 const up = () => {
3366 const popup = getPopup();
3367 dragging = false;
3368 removeClass(popup, 'swal2-dragging');
3369 };
3370
3371 /**
3372 * @param {MouseEvent | TouchEvent} event
3373 * @returns {{ clientX: number, clientY: number }}
3374 */
3375 const getClientXY = event => {
3376 const source = event.type.startsWith('touch') ? /** @type {TouchEvent} */event.touches[0] : (/** @type {MouseEvent} */event);
3377 return {
3378 clientX: source.clientX,
3379 clientY: source.clientY
3380 };
3381 };
3382
3383 /**
3384 * @param {SweetAlert} instance
3385 * @param {SweetAlertOptions} params
3386 */
3387 const renderPopup = (instance, params) => {
3388 const container = getContainer();
3389 const popup = getPopup();
3390 if (!container || !popup) {
3391 return;
3392 }
3393
3394 // Width
3395 // https://github.com/sweetalert2/sweetalert2/issues/2170
3396 if (params.toast) {
3397 applyNumericalStyle(container, 'width', params.width);
3398 popup.style.width = '100%';
3399 const loader = getLoader();
3400 if (loader) {
3401 popup.insertBefore(loader, getIcon());
3402 }
3403 } else {
3404 applyNumericalStyle(popup, 'width', params.width);
3405 }
3406
3407 // Padding
3408 applyNumericalStyle(popup, 'padding', params.padding);
3409
3410 // Color
3411 if (params.color) {
3412 popup.style.color = params.color;
3413 }
3414
3415 // Background
3416 if (params.background) {
3417 popup.style.background = params.background;
3418 }
3419 hide(getValidationMessage());
3420
3421 // Classes
3422 addClasses$1(popup, params);
3423 if (params.draggable && !params.toast) {
3424 addClass(popup, swalClasses.draggable);
3425 addDraggableListeners(popup);
3426 } else {
3427 removeClass(popup, swalClasses.draggable);
3428 removeDraggableListeners(popup);
3429 }
3430 };
3431
3432 /**
3433 * @param {HTMLElement} popup
3434 * @param {SweetAlertOptions} params
3435 */
3436 const addClasses$1 = (popup, params) => {
3437 const showClass = params.showClass || {};
3438 // Default Class + showClass when updating Swal.update({})
3439 popup.className = `${swalClasses.popup} ${isVisible$1(popup) ? showClass.popup : ''}`;
3440 if (params.toast) {
3441 addClass([document.documentElement, document.body], swalClasses['toast-shown']);
3442 addClass(popup, swalClasses.toast);
3443 } else {
3444 addClass(popup, swalClasses.modal);
3445 }
3446
3447 // Custom class
3448 applyCustomClass(popup, params, 'popup');
3449 // TODO: remove in the next major
3450 if (typeof params.customClass === 'string') {
3451 addClass(popup, params.customClass);
3452 }
3453
3454 // Icon class (#1842)
3455 if (params.icon) {
3456 addClass(popup, swalClasses[`icon-${params.icon}`]);
3457 }
3458 };
3459
3460 /**
3461 * @param {SweetAlert} instance
3462 * @param {SweetAlertOptions} params
3463 */
3464 const renderProgressSteps = (instance, params) => {
3465 const progressStepsContainer = getProgressSteps();
3466 if (!progressStepsContainer) {
3467 return;
3468 }
3469 const {
3470 progressSteps,
3471 currentProgressStep
3472 } = params;
3473 if (!progressSteps || progressSteps.length === 0 || currentProgressStep === undefined) {
3474 hide(progressStepsContainer);
3475 return;
3476 }
3477 show(progressStepsContainer);
3478 progressStepsContainer.textContent = '';
3479 if (currentProgressStep >= progressSteps.length) {
3480 warn('Invalid currentProgressStep parameter, it should be less than progressSteps.length ' + '(currentProgressStep like JS arrays starts from 0)');
3481 }
3482 progressSteps.forEach((step, index) => {
3483 const stepEl = createStepElement(step);
3484 progressStepsContainer.appendChild(stepEl);
3485 if (index === currentProgressStep) {
3486 addClass(stepEl, swalClasses['active-progress-step']);
3487 }
3488 if (index !== progressSteps.length - 1) {
3489 const lineEl = createLineElement(params);
3490 progressStepsContainer.appendChild(lineEl);
3491 }
3492 });
3493 };
3494
3495 /**
3496 * @param {string} step
3497 * @returns {HTMLLIElement}
3498 */
3499 const createStepElement = step => {
3500 const stepEl = document.createElement('li');
3501 addClass(stepEl, swalClasses['progress-step']);
3502 setInnerHtml(stepEl, step);
3503 return stepEl;
3504 };
3505
3506 /**
3507 * @param {SweetAlertOptions} params
3508 * @returns {HTMLLIElement}
3509 */
3510 const createLineElement = params => {
3511 const lineEl = document.createElement('li');
3512 addClass(lineEl, swalClasses['progress-step-line']);
3513 if (params.progressStepsDistance) {
3514 applyNumericalStyle(lineEl, 'width', params.progressStepsDistance);
3515 }
3516 return lineEl;
3517 };
3518
3519 /**
3520 * @param {SweetAlert} instance
3521 * @param {SweetAlertOptions} params
3522 */
3523 const renderTitle = (instance, params) => {
3524 const title = getTitle();
3525 if (!title) {
3526 return;
3527 }
3528 showWhenInnerHtmlPresent(title);
3529 toggle(title, Boolean(params.title || params.titleText), 'block');
3530 if (params.title) {
3531 parseHtmlToContainer(params.title, title);
3532 }
3533 if (params.titleText) {
3534 title.innerText = params.titleText;
3535 }
3536
3537 // Custom class
3538 applyCustomClass(title, params, 'title');
3539 };
3540
3541 /**
3542 * @param {SweetAlert} instance
3543 * @param {SweetAlertOptions} params
3544 */
3545 const render = (instance, params) => {
3546 var _globalState$eventEmi;
3547 renderPopup(instance, params);
3548 renderContainer(instance, params);
3549 renderProgressSteps(instance, params);
3550 renderIcon(instance, params);
3551 renderImage(instance, params);
3552 renderTitle(instance, params);
3553 renderCloseButton(instance, params);
3554 renderContent(instance, params);
3555 renderActions(instance, params);
3556 renderFooter(instance, params);
3557 const popup = getPopup();
3558 if (typeof params.didRender === 'function' && popup) {
3559 params.didRender(popup);
3560 }
3561 (_globalState$eventEmi = globalState.eventEmitter) === null || _globalState$eventEmi === void 0 || _globalState$eventEmi.emit('didRender', popup);
3562 };
3563
3564 /*
3565 * Global function to determine if SweetAlert2 popup is shown
3566 */
3567 const isVisible = () => {
3568 return isVisible$1(getPopup());
3569 };
3570
3571 /*
3572 * Global function to click 'Confirm' button
3573 */
3574 const clickConfirm = () => {
3575 var _dom$getConfirmButton;
3576 return (_dom$getConfirmButton = getConfirmButton()) === null || _dom$getConfirmButton === void 0 ? void 0 : _dom$getConfirmButton.click();
3577 };
3578
3579 /*
3580 * Global function to click 'Deny' button
3581 */
3582 const clickDeny = () => {
3583 var _dom$getDenyButton;
3584 return (_dom$getDenyButton = getDenyButton()) === null || _dom$getDenyButton === void 0 ? void 0 : _dom$getDenyButton.click();
3585 };
3586
3587 /*
3588 * Global function to click 'Cancel' button
3589 */
3590 const clickCancel = () => {
3591 var _dom$getCancelButton;
3592 return (_dom$getCancelButton = getCancelButton()) === null || _dom$getCancelButton === void 0 ? void 0 : _dom$getCancelButton.click();
3593 };
3594
3595 /** @type {Record<DismissReason, DismissReason>} */
3596 const DismissReason = Object.freeze({
3597 cancel: 'cancel',
3598 backdrop: 'backdrop',
3599 close: 'close',
3600 esc: 'esc',
3601 timer: 'timer'
3602 });
3603
3604 /**
3605 * @param {GlobalState} globalState
3606 */
3607 const removeKeydownHandler = globalState => {
3608 if (globalState.keydownTarget && globalState.keydownHandlerAdded && globalState.keydownHandler) {
3609 const handler = /** @type {EventListenerOrEventListenerObject} */
3610 /** @type {unknown} */globalState.keydownHandler;
3611 globalState.keydownTarget.removeEventListener('keydown', handler, {
3612 capture: globalState.keydownListenerCapture
3613 });
3614 globalState.keydownHandlerAdded = false;
3615 }
3616 };
3617
3618 /**
3619 * @param {GlobalState} globalState
3620 * @param {SweetAlertOptions} innerParams
3621 * @param {(dismiss: DismissReason) => void} dismissWith
3622 */
3623 const addKeydownHandler = (globalState, innerParams, dismissWith) => {
3624 removeKeydownHandler(globalState);
3625 if (!innerParams.toast) {
3626 /** @type {(this: HTMLElement, event: KeyboardEvent) => void} */
3627 const handler = e => keydownHandler(innerParams, e, dismissWith);
3628 globalState.keydownHandler = handler;
3629 const target = innerParams.keydownListenerCapture ? window : getPopup();
3630 if (target) {
3631 globalState.keydownTarget = target;
3632 globalState.keydownListenerCapture = innerParams.keydownListenerCapture;
3633 const eventHandler = /** @type {EventListenerOrEventListenerObject} */ /** @type {unknown} */handler;
3634 globalState.keydownTarget.addEventListener('keydown', eventHandler, {
3635 capture: globalState.keydownListenerCapture
3636 });
3637 globalState.keydownHandlerAdded = true;
3638 }
3639 }
3640 };
3641
3642 /**
3643 * @param {number} index
3644 * @param {number} increment
3645 * @returns {boolean} shouldPreventDefault
3646 */
3647 const setFocus = (index, increment) => {
3648 var _dom$getPopup;
3649 const focusableElements = getFocusableElements();
3650 // search for visible elements and select the next possible match
3651 if (focusableElements.length) {
3652 index = index + increment;
3653
3654 // shift + tab when .swal2-popup is focused
3655 if (index === -2) {
3656 index = focusableElements.length - 1;
3657 }
3658
3659 // rollover to first item
3660 if (index === focusableElements.length) {
3661 index = 0;
3662
3663 // go to last item
3664 } else if (index === -1) {
3665 index = focusableElements.length - 1;
3666 }
3667 focusableElements[index].focus();
3668
3669 // don't prevent default for iframes (Firefox fix)
3670 // https://github.com/sweetalert2/sweetalert2/issues/2931
3671 if (isFirefox() && focusableElements[index] instanceof HTMLIFrameElement) {
3672 return false;
3673 }
3674 return true;
3675 }
3676 // no visible focusable elements, focus the popup
3677 (_dom$getPopup = getPopup()) === null || _dom$getPopup === void 0 || _dom$getPopup.focus();
3678 return true;
3679 };
3680 const arrowKeysNextButton = ['ArrowRight', 'ArrowDown'];
3681 const arrowKeysPreviousButton = ['ArrowLeft', 'ArrowUp'];
3682
3683 /**
3684 * @param {SweetAlertOptions} innerParams
3685 * @param {KeyboardEvent} event
3686 * @param {(dismiss: DismissReason) => void} dismissWith
3687 */
3688 const keydownHandler = (innerParams, event, dismissWith) => {
3689 if (!innerParams) {
3690 return; // This instance has already been destroyed
3691 }
3692
3693 // Ignore keydown during IME composition
3694 // https://developer.mozilla.org/en-US/docs/Web/API/Document/keydown_event#ignoring_keydown_during_ime_composition
3695 // https://github.com/sweetalert2/sweetalert2/issues/720
3696 // https://github.com/sweetalert2/sweetalert2/issues/2406
3697 if (event.isComposing || event.keyCode === 229) {
3698 return;
3699 }
3700 if (innerParams.stopKeydownPropagation) {
3701 event.stopPropagation();
3702 }
3703
3704 // ENTER
3705 if (event.key === 'Enter') {
3706 handleEnter(event, innerParams);
3707 }
3708
3709 // TAB
3710 else if (event.key === 'Tab') {
3711 handleTab(event);
3712 }
3713
3714 // ARROWS - switch focus between buttons
3715 else if ([...arrowKeysNextButton, ...arrowKeysPreviousButton].includes(event.key)) {
3716 handleArrows(event.key);
3717 }
3718
3719 // ESC
3720 else if (event.key === 'Escape') {
3721 handleEsc(event, innerParams, dismissWith);
3722 }
3723 };
3724
3725 /**
3726 * @param {KeyboardEvent} event
3727 * @param {SweetAlertOptions} innerParams
3728 */
3729 const handleEnter = (event, innerParams) => {
3730 // https://github.com/sweetalert2/sweetalert2/issues/2386
3731 if (!callIfFunction(innerParams.allowEnterKey)) {
3732 return;
3733 }
3734 const popup = getPopup();
3735 if (!popup || !innerParams.input) {
3736 return;
3737 }
3738 const input = getInput$1(popup, innerParams.input);
3739 if (event.target && input && event.target instanceof HTMLElement && event.target.outerHTML === input.outerHTML) {
3740 if (['textarea', 'file'].includes(innerParams.input)) {
3741 return; // do not submit
3742 }
3743 clickConfirm();
3744 event.preventDefault();
3745 }
3746 };
3747
3748 /**
3749 * @param {KeyboardEvent} event
3750 */
3751 const handleTab = event => {
3752 const targetElement = event.target;
3753 const focusableElements = getFocusableElements();
3754 const btnIndex = focusableElements.findIndex(el => el === targetElement);
3755
3756 // don't prevent default for iframes (Firefox fix)
3757 // https://github.com/sweetalert2/sweetalert2/issues/2931
3758 let shouldPreventDefault = true;
3759
3760 // Cycle to the next button
3761 if (!event.shiftKey) {
3762 shouldPreventDefault = setFocus(btnIndex, 1);
3763 }
3764
3765 // Cycle to the prev button
3766 else {
3767 shouldPreventDefault = setFocus(btnIndex, -1);
3768 }
3769 event.stopPropagation();
3770 if (shouldPreventDefault) {
3771 event.preventDefault();
3772 }
3773 };
3774
3775 /**
3776 * @param {string} key
3777 */
3778 const handleArrows = key => {
3779 const actions = getActions();
3780 const confirmButton = getConfirmButton();
3781 const denyButton = getDenyButton();
3782 const cancelButton = getCancelButton();
3783 if (!actions || !confirmButton || !denyButton || !cancelButton) {
3784 return;
3785 }
3786 /** @type HTMLElement[] */
3787 const buttons = [confirmButton, denyButton, cancelButton];
3788 if (document.activeElement instanceof HTMLElement && !buttons.includes(document.activeElement)) {
3789 return;
3790 }
3791 const sibling = arrowKeysNextButton.includes(key) ? 'nextElementSibling' : 'previousElementSibling';
3792 let buttonToFocus = document.activeElement;
3793 if (!buttonToFocus) {
3794 return;
3795 }
3796 for (let i = 0; i < actions.children.length; i++) {
3797 buttonToFocus = buttonToFocus[sibling];
3798 if (!buttonToFocus) {
3799 return;
3800 }
3801 if (buttonToFocus instanceof HTMLButtonElement && isVisible$1(buttonToFocus)) {
3802 break;
3803 }
3804 }
3805 if (buttonToFocus instanceof HTMLButtonElement) {
3806 buttonToFocus.focus();
3807 }
3808 };
3809
3810 /**
3811 * @param {KeyboardEvent} event
3812 * @param {SweetAlertOptions} innerParams
3813 * @param {(dismiss: DismissReason) => void} dismissWith
3814 */
3815 const handleEsc = (event, innerParams, dismissWith) => {
3816 event.preventDefault();
3817 if (callIfFunction(innerParams.allowEscapeKey)) {
3818 dismissWith(DismissReason.esc);
3819 }
3820 };
3821
3822 /**
3823 * This module contains `WeakMap`s for each effectively-"private property" that a `Swal` has.
3824 * For example, to set the private property "foo" of `this` to "bar", you can `privateProps.foo.set(this, 'bar')`
3825 * This is the approach that Babel will probably take to implement private methods/fields
3826 * https://github.com/tc39/proposal-private-methods
3827 * https://github.com/babel/babel/pull/7555
3828 * Once we have the changes from that PR in Babel, and our core class fits reasonable in *one module*
3829 * then we can use that language feature.
3830 */
3831
3832 var privateMethods = {
3833 swalPromiseResolve: new WeakMap(),
3834 swalPromiseReject: new WeakMap()
3835 };
3836
3837 // From https://developer.paciellogroup.com/blog/2018/06/the-current-state-of-modal-dialog-accessibility/
3838 // Adding aria-hidden="true" to elements outside of the active modal dialog ensures that
3839 // elements not within the active modal dialog will not be surfaced if a user opens a screen
3840 // reader’s list of elements (headings, form controls, landmarks, etc.) in the document.
3841
3842 const setAriaHidden = () => {
3843 const container = getContainer();
3844 const bodyChildren = Array.from(document.body.children);
3845 bodyChildren.forEach(el => {
3846 if (el.contains(container)) {
3847 return;
3848 }
3849 if (el.hasAttribute('aria-hidden')) {
3850 el.setAttribute('data-previous-aria-hidden', el.getAttribute('aria-hidden') || '');
3851 }
3852 el.setAttribute('aria-hidden', 'true');
3853 });
3854 };
3855 const unsetAriaHidden = () => {
3856 const bodyChildren = Array.from(document.body.children);
3857 bodyChildren.forEach(el => {
3858 if (el.hasAttribute('data-previous-aria-hidden')) {
3859 el.setAttribute('aria-hidden', el.getAttribute('data-previous-aria-hidden') || '');
3860 el.removeAttribute('data-previous-aria-hidden');
3861 } else {
3862 el.removeAttribute('aria-hidden');
3863 }
3864 });
3865 };
3866
3867 // @ts-ignore
3868 const isSafariOrIOS = typeof window !== 'undefined' && Boolean(window.GestureEvent); // true for Safari desktop + all iOS browsers https://stackoverflow.com/a/70585394
3869
3870 // @ts-ignore
3871 const isIOS = isSafariOrIOS && /iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream;
3872
3873 /**
3874 * Fix iOS scrolling
3875 * http://stackoverflow.com/q/39626302
3876 */
3877 const iOSfix = () => {
3878 if (isSafariOrIOS && !hasClass(document.body, swalClasses.iosfix)) {
3879 const offset = document.body.scrollTop;
3880 document.body.style.top = `${offset * -1}px`;
3881 addClass(document.body, swalClasses.iosfix);
3882 lockBodyScroll();
3883 }
3884 };
3885
3886 /**
3887 * https://github.com/sweetalert2/sweetalert2/issues/1246
3888 */
3889 const lockBodyScroll = () => {
3890 const container = getContainer();
3891 if (!container) {
3892 return;
3893 }
3894 /** @type {boolean} */
3895 let preventTouchMove;
3896 /**
3897 * @param {TouchEvent} event
3898 */
3899 container.ontouchstart = event => {
3900 preventTouchMove = shouldPreventTouchMove(event);
3901 };
3902 /**
3903 * @param {TouchEvent} event
3904 */
3905 container.ontouchmove = event => {
3906 if (preventTouchMove) {
3907 event.preventDefault();
3908 event.stopPropagation();
3909 }
3910 };
3911 };
3912
3913 /**
3914 * @param {TouchEvent} event
3915 * @returns {boolean}
3916 */
3917 const shouldPreventTouchMove = event => {
3918 const target = event.target;
3919 const container = getContainer();
3920 const htmlContainer = getHtmlContainer();
3921 if (!container || !htmlContainer) {
3922 return false;
3923 }
3924 if (isStylus(event) || isZoom(event)) {
3925 return false;
3926 }
3927 if (target === container) {
3928 return true;
3929 }
3930 if (!isScrollable(container) && target instanceof HTMLElement && !selfOrParentIsScrollable(target, htmlContainer) &&
3931 // #2823
3932 target.tagName !== 'INPUT' &&
3933 // #1603
3934 target.tagName !== 'TEXTAREA' &&
3935 // #2266
3936 !(isScrollable(htmlContainer) &&
3937 // #1944
3938 htmlContainer.contains(target))) {
3939 return true;
3940 }
3941 return false;
3942 };
3943
3944 /**
3945 * https://github.com/sweetalert2/sweetalert2/issues/1786
3946 *
3947 * @param {TouchEvent} event
3948 * @returns {boolean}
3949 */
3950 const isStylus = event => {
3951 return Boolean(event.touches && event.touches.length &&
3952 // @ts-ignore - touchType is not a standard property
3953 event.touches[0].touchType === 'stylus');
3954 };
3955
3956 /**
3957 * https://github.com/sweetalert2/sweetalert2/issues/1891
3958 *
3959 * @param {TouchEvent} event
3960 * @returns {boolean}
3961 */
3962 const isZoom = event => {
3963 return event.touches && event.touches.length > 1;
3964 };
3965 const undoIOSfix = () => {
3966 if (hasClass(document.body, swalClasses.iosfix)) {
3967 const offset = parseInt(document.body.style.top, 10);
3968 removeClass(document.body, swalClasses.iosfix);
3969 document.body.style.top = '';
3970 document.body.scrollTop = offset * -1;
3971 }
3972 };
3973
3974 /**
3975 * Measure scrollbar width for padding body during modal show/hide
3976 * https://github.com/twbs/bootstrap/blob/master/js/src/modal.js
3977 *
3978 * @returns {number}
3979 */
3980 const measureScrollbar = () => {
3981 const scrollDiv = document.createElement('div');
3982 scrollDiv.className = swalClasses['scrollbar-measure'];
3983 document.body.appendChild(scrollDiv);
3984 const scrollbarWidth = scrollDiv.getBoundingClientRect().width - scrollDiv.clientWidth;
3985 document.body.removeChild(scrollDiv);
3986 return scrollbarWidth;
3987 };
3988
3989 /**
3990 * Remember state in cases where opening and handling a modal will fiddle with it.
3991 * @type {number | null}
3992 */
3993 let previousBodyPadding = null;
3994
3995 /**
3996 * @param {string} initialBodyOverflow
3997 */
3998 const replaceScrollbarWithPadding = initialBodyOverflow => {
3999 // for queues, do not do this more than once
4000 if (previousBodyPadding !== null) {
4001 return;
4002 }
4003 // if the body has overflow
4004 if (document.body.scrollHeight > window.innerHeight || initialBodyOverflow === 'scroll' // https://github.com/sweetalert2/sweetalert2/issues/2663
4005 ) {
4006 // add padding so the content doesn't shift after removal of scrollbar
4007 previousBodyPadding = parseInt(window.getComputedStyle(document.body).getPropertyValue('padding-right'));
4008 document.body.style.paddingRight = `${previousBodyPadding + measureScrollbar()}px`;
4009 }
4010 };
4011 const undoReplaceScrollbarWithPadding = () => {
4012 if (previousBodyPadding !== null) {
4013 document.body.style.paddingRight = `${previousBodyPadding}px`;
4014 previousBodyPadding = null;
4015 }
4016 };
4017
4018 /**
4019 * @param {SweetAlert} instance
4020 * @param {HTMLElement} container
4021 * @param {boolean} returnFocus
4022 * @param {(() => void) | undefined} didClose
4023 */
4024 function removePopupAndResetState(instance, container, returnFocus, didClose) {
4025 if (isToast()) {
4026 triggerDidCloseAndDispose(instance, didClose);
4027 } else {
4028 restoreActiveElement(returnFocus).then(() => triggerDidCloseAndDispose(instance, didClose));
4029 removeKeydownHandler(globalState);
4030 }
4031
4032 // workaround for https://github.com/sweetalert2/sweetalert2/issues/2088
4033 // for some reason removing the container in Safari will scroll the document to bottom
4034 if (isSafariOrIOS) {
4035 container.setAttribute('style', 'display:none !important');
4036 container.removeAttribute('class');
4037 container.innerHTML = '';
4038 } else {
4039 container.remove();
4040 }
4041 if (isModal()) {
4042 undoReplaceScrollbarWithPadding();
4043 undoIOSfix();
4044 unsetAriaHidden();
4045 }
4046 removeBodyClasses();
4047 }
4048
4049 /**
4050 * Remove SweetAlert2 classes from body
4051 */
4052 function removeBodyClasses() {
4053 removeClass([document.documentElement, document.body], [swalClasses.shown, swalClasses['height-auto'], swalClasses['no-backdrop'], swalClasses['toast-shown']]);
4054 }
4055
4056 /**
4057 * Instance method to close sweetAlert
4058 *
4059 * @param {SweetAlertResult | undefined} resolveValue
4060 * @this {SweetAlert}
4061 */
4062 function close(resolveValue) {
4063 resolveValue = prepareResolveValue(resolveValue);
4064 const swalPromiseResolve = privateMethods.swalPromiseResolve.get(this);
4065 const didClose = triggerClosePopup(this);
4066 if (this.isAwaitingPromise) {
4067 // A swal awaiting for a promise (after a click on Confirm or Deny) cannot be dismissed anymore #2335
4068 if (!resolveValue.isDismissed) {
4069 handleAwaitingPromise(this);
4070 swalPromiseResolve(resolveValue);
4071 }
4072 } else if (didClose) {
4073 // Resolve Swal promise
4074 swalPromiseResolve(resolveValue);
4075 }
4076 }
4077
4078 /**
4079 * @param {SweetAlert} instance
4080 * @returns {boolean}
4081 */
4082 const triggerClosePopup = instance => {
4083 const popup = getPopup();
4084 if (!popup) {
4085 return false;
4086 }
4087 const innerParams = privateProps.innerParams.get(instance);
4088 if (!innerParams || hasClass(popup, innerParams.hideClass.popup)) {
4089 return false;
4090 }
4091 removeClass(popup, innerParams.showClass.popup);
4092 addClass(popup, innerParams.hideClass.popup);
4093 const backdrop = getContainer();
4094 removeClass(backdrop, innerParams.showClass.backdrop);
4095 addClass(backdrop, innerParams.hideClass.backdrop);
4096 handlePopupAnimation(instance, popup, innerParams);
4097 return true;
4098 };
4099
4100 /**
4101 * @param {Error | string} error
4102 * @this {SweetAlert}
4103 */
4104 function rejectPromise(error) {
4105 const rejectPromise = privateMethods.swalPromiseReject.get(this);
4106 handleAwaitingPromise(this);
4107 if (rejectPromise) {
4108 // Reject Swal promise
4109 rejectPromise(error);
4110 }
4111 }
4112
4113 /**
4114 * @param {SweetAlert} instance
4115 */
4116 const handleAwaitingPromise = instance => {
4117 if (instance.isAwaitingPromise) {
4118 // @ts-ignore
4119 delete instance.isAwaitingPromise;
4120 // The instance might have been previously partly destroyed, we must resume the destroy process in this case #2335
4121 if (!privateProps.innerParams.get(instance)) {
4122 instance._destroy();
4123 }
4124 }
4125 };
4126
4127 /**
4128 * @param {SweetAlertResult | undefined} resolveValue
4129 * @returns {SweetAlertResult}
4130 */
4131 const prepareResolveValue = resolveValue => {
4132 // When user calls Swal.close()
4133 if (typeof resolveValue === 'undefined') {
4134 return {
4135 isConfirmed: false,
4136 isDenied: false,
4137 isDismissed: true
4138 };
4139 }
4140 return Object.assign({
4141 isConfirmed: false,
4142 isDenied: false,
4143 isDismissed: false
4144 }, resolveValue);
4145 };
4146
4147 /**
4148 * @param {SweetAlert} instance
4149 * @param {HTMLElement} popup
4150 * @param {SweetAlertOptions} innerParams
4151 */
4152 const handlePopupAnimation = (instance, popup, innerParams) => {
4153 var _globalState$eventEmi;
4154 const container = getContainer();
4155 // If animation is supported, animate
4156 const animationIsSupported = hasCssAnimation(popup);
4157 if (typeof innerParams.willClose === 'function') {
4158 innerParams.willClose(popup);
4159 }
4160 (_globalState$eventEmi = globalState.eventEmitter) === null || _globalState$eventEmi === void 0 || _globalState$eventEmi.emit('willClose', popup);
4161 if (animationIsSupported && container) {
4162 animatePopup(instance, popup, container, Boolean(innerParams.returnFocus), innerParams.didClose);
4163 } else if (container) {
4164 // Otherwise, remove immediately
4165 removePopupAndResetState(instance, container, Boolean(innerParams.returnFocus), innerParams.didClose);
4166 }
4167 };
4168
4169 /**
4170 * @param {SweetAlert} instance
4171 * @param {HTMLElement} popup
4172 * @param {HTMLElement} container
4173 * @param {boolean} returnFocus
4174 * @param {(() => void) | undefined} didClose
4175 */
4176 const animatePopup = (instance, popup, container, returnFocus, didClose) => {
4177 globalState.swalCloseEventFinishedCallback = removePopupAndResetState.bind(null, instance, container, returnFocus, didClose);
4178 /**
4179 * @param {AnimationEvent | TransitionEvent} e
4180 */
4181 const swalCloseAnimationFinished = function (e) {
4182 if (e.target === popup) {
4183 var _globalState$swalClos;
4184 (_globalState$swalClos = globalState.swalCloseEventFinishedCallback) === null || _globalState$swalClos === void 0 || _globalState$swalClos.call(globalState);
4185 delete globalState.swalCloseEventFinishedCallback;
4186 popup.removeEventListener('animationend', swalCloseAnimationFinished);
4187 popup.removeEventListener('transitionend', swalCloseAnimationFinished);
4188 }
4189 };
4190 popup.addEventListener('animationend', swalCloseAnimationFinished);
4191 popup.addEventListener('transitionend', swalCloseAnimationFinished);
4192 };
4193
4194 /**
4195 * @param {SweetAlert} instance
4196 * @param {(() => void) | undefined} didClose
4197 */
4198 const triggerDidCloseAndDispose = (instance, didClose) => {
4199 setTimeout(() => {
4200 var _globalState$eventEmi2;
4201 if (typeof didClose === 'function') {
4202 didClose.bind(instance.params)();
4203 }
4204 (_globalState$eventEmi2 = globalState.eventEmitter) === null || _globalState$eventEmi2 === void 0 || _globalState$eventEmi2.emit('didClose');
4205 // instance might have been destroyed already
4206 if (instance._destroy) {
4207 instance._destroy();
4208 }
4209 });
4210 };
4211
4212 /**
4213 * Shows loader (spinner), this is useful with AJAX requests.
4214 * By default the loader be shown instead of the "Confirm" button.
4215 *
4216 * @param {HTMLButtonElement | null} [buttonToReplace]
4217 */
4218 const showLoading = buttonToReplace => {
4219 let popup = getPopup();
4220 if (!popup) {
4221 new Swal();
4222 }
4223 popup = getPopup();
4224 if (!popup) {
4225 return;
4226 }
4227 const loader = getLoader();
4228 if (isToast()) {
4229 hide(getIcon());
4230 } else {
4231 replaceButton(popup, buttonToReplace);
4232 }
4233 show(loader);
4234 popup.setAttribute('data-loading', 'true');
4235 popup.setAttribute('aria-busy', 'true');
4236 popup.focus();
4237 };
4238
4239 /**
4240 * @param {HTMLElement} popup
4241 * @param {HTMLButtonElement | null} [buttonToReplace]
4242 */
4243 const replaceButton = (popup, buttonToReplace) => {
4244 const actions = getActions();
4245 const loader = getLoader();
4246 if (!actions || !loader) {
4247 return;
4248 }
4249 if (!buttonToReplace && isVisible$1(getConfirmButton())) {
4250 buttonToReplace = getConfirmButton();
4251 }
4252 show(actions);
4253 if (buttonToReplace) {
4254 hide(buttonToReplace);
4255 loader.setAttribute('data-button-to-replace', buttonToReplace.className);
4256 actions.insertBefore(loader, buttonToReplace);
4257 }
4258 addClass([popup, actions], swalClasses.loading);
4259 };
4260
4261 /**
4262 * @param {SweetAlert} instance
4263 * @param {SweetAlertOptions} params
4264 */
4265 const handleInputOptionsAndValue = (instance, params) => {
4266 if (params.input === 'select' || params.input === 'radio') {
4267 handleInputOptions(instance, params);
4268 } else if (['text', 'email', 'number', 'tel', 'textarea'].some(i => i === params.input) && (hasToPromiseFn(params.inputValue) || isPromise(params.inputValue))) {
4269 showLoading(getConfirmButton());
4270 handleInputValue(instance, params);
4271 }
4272 };
4273
4274 /**
4275 * @param {SweetAlert} instance
4276 * @param {SweetAlertOptions} innerParams
4277 * @returns {SweetAlertInputValue}
4278 */
4279 const getInputValue = (instance, innerParams) => {
4280 const input = instance.getInput();
4281 if (!input) {
4282 return null;
4283 }
4284 switch (innerParams.input) {
4285 case 'checkbox':
4286 return getCheckboxValue(input);
4287 case 'radio':
4288 return getRadioValue(input);
4289 case 'file':
4290 return getFileValue(input);
4291 default:
4292 return innerParams.inputAutoTrim ? input.value.trim() : input.value;
4293 }
4294 };
4295
4296 /**
4297 * @param {HTMLInputElement} input
4298 * @returns {number}
4299 */
4300 const getCheckboxValue = input => input.checked ? 1 : 0;
4301
4302 /**
4303 * @param {HTMLInputElement} input
4304 * @returns {string | null}
4305 */
4306 const getRadioValue = input => input.checked ? input.value : null;
4307
4308 /**
4309 * @param {HTMLInputElement} input
4310 * @returns {FileList | File | null}
4311 */
4312 const getFileValue = input => input.files && input.files.length ? input.getAttribute('multiple') !== null ? input.files : input.files[0] : null;
4313
4314 /**
4315 * @param {SweetAlert} instance
4316 * @param {SweetAlertOptions} params
4317 */
4318 const handleInputOptions = (instance, params) => {
4319 const popup = getPopup();
4320 if (!popup) {
4321 return;
4322 }
4323 /**
4324 * @param {*} inputOptions
4325 */
4326 const processInputOptions = inputOptions => {
4327 if (params.input === 'select') {
4328 populateSelectOptions(popup, formatInputOptions(inputOptions), params);
4329 } else if (params.input === 'radio') {
4330 populateRadioOptions(popup, formatInputOptions(inputOptions), params);
4331 }
4332 };
4333 if (hasToPromiseFn(params.inputOptions) || isPromise(params.inputOptions)) {
4334 showLoading(getConfirmButton());
4335 asPromise(params.inputOptions).then(inputOptions => {
4336 instance.hideLoading();
4337 processInputOptions(inputOptions);
4338 });
4339 } else if (typeof params.inputOptions === 'object') {
4340 processInputOptions(params.inputOptions);
4341 } else {
4342 error(`Unexpected type of inputOptions! Expected object, Map or Promise, got ${typeof params.inputOptions}`);
4343 }
4344 };
4345
4346 /**
4347 * @param {SweetAlert} instance
4348 * @param {SweetAlertOptions} params
4349 */
4350 const handleInputValue = (instance, params) => {
4351 const input = instance.getInput();
4352 if (!input) {
4353 return;
4354 }
4355 hide(input);
4356 asPromise(params.inputValue).then(inputValue => {
4357 input.value = params.input === 'number' ? `${parseFloat(inputValue) || 0}` : `${inputValue}`;
4358 show(input);
4359 input.focus();
4360 instance.hideLoading();
4361 }).catch(err => {
4362 error(`Error in inputValue promise: ${err}`);
4363 input.value = '';
4364 show(input);
4365 input.focus();
4366 instance.hideLoading();
4367 });
4368 };
4369
4370 /**
4371 * @param {HTMLElement} popup
4372 * @param {InputOptionFlattened[]} inputOptions
4373 * @param {SweetAlertOptions} params
4374 */
4375 function populateSelectOptions(popup, inputOptions, params) {
4376 const select = getDirectChildByClass(popup, swalClasses.select);
4377 if (!select) {
4378 return;
4379 }
4380 /**
4381 * @param {HTMLElement} parent
4382 * @param {string} optionLabel
4383 * @param {string} optionValue
4384 */
4385 const renderOption = (parent, optionLabel, optionValue) => {
4386 const option = document.createElement('option');
4387 option.value = optionValue;
4388 setInnerHtml(option, optionLabel);
4389 option.selected = isSelected(optionValue, params.inputValue);
4390 parent.appendChild(option);
4391 };
4392 inputOptions.forEach(inputOption => {
4393 const optionValue = inputOption[0];
4394 const optionLabel = inputOption[1];
4395 // <optgroup> spec:
4396 // https://www.w3.org/TR/html401/interact/forms.html#h-17.6
4397 // "...all OPTGROUP elements must be specified directly within a SELECT element (i.e., groups may not be nested)..."
4398 // check whether this is a <optgroup>
4399 if (Array.isArray(optionLabel)) {
4400 // if it is an array, then it is an <optgroup>
4401 const optgroup = document.createElement('optgroup');
4402 optgroup.label = optionValue;
4403 optgroup.disabled = false; // not configurable for now
4404 select.appendChild(optgroup);
4405 optionLabel.forEach(o => renderOption(optgroup, o[1], o[0]));
4406 } else {
4407 // case of <option>
4408 renderOption(select, optionLabel, optionValue);
4409 }
4410 });
4411 select.focus();
4412 }
4413
4414 /**
4415 * @param {HTMLElement} popup
4416 * @param {InputOptionFlattened[]} inputOptions
4417 * @param {SweetAlertOptions} params
4418 */
4419 function populateRadioOptions(popup, inputOptions, params) {
4420 const radio = getDirectChildByClass(popup, swalClasses.radio);
4421 if (!radio) {
4422 return;
4423 }
4424 inputOptions.forEach(inputOption => {
4425 const radioValue = inputOption[0];
4426 const radioLabel = inputOption[1];
4427 const radioInput = document.createElement('input');
4428 const radioLabelElement = document.createElement('label');
4429 radioInput.type = 'radio';
4430 radioInput.name = swalClasses.radio;
4431 radioInput.value = radioValue;
4432 if (isSelected(radioValue, params.inputValue)) {
4433 radioInput.checked = true;
4434 }
4435 const label = document.createElement('span');
4436 setInnerHtml(label, radioLabel);
4437 label.className = swalClasses.label;
4438 radioLabelElement.appendChild(radioInput);
4439 radioLabelElement.appendChild(label);
4440 radio.appendChild(radioLabelElement);
4441 });
4442 const radios = radio.querySelectorAll('input');
4443 if (radios.length) {
4444 radios[0].focus();
4445 }
4446 }
4447
4448 /**
4449 * Converts `inputOptions` into an array of `[value, label]`s
4450 *
4451 * @param {*} inputOptions
4452 * @typedef {string[]} InputOptionFlattened
4453 * @returns {InputOptionFlattened[]}
4454 */
4455 const formatInputOptions = inputOptions => {
4456 const entries = inputOptions instanceof Map ? Array.from(inputOptions) : Object.entries(inputOptions);
4457 return entries.map(([key, value]) => [key, typeof value === 'object' ? formatInputOptions(value) : value]); // case of <optgroup>
4458 };
4459
4460 /**
4461 * @param {string} optionValue
4462 * @param {SweetAlertInputValue} inputValue
4463 * @returns {boolean}
4464 */
4465 const isSelected = (optionValue, inputValue) => Boolean(inputValue) && inputValue != null && inputValue.toString() === optionValue.toString();
4466
4467 /**
4468 * @param {SweetAlert} instance
4469 */
4470 const handleConfirmButtonClick = instance => {
4471 const innerParams = privateProps.innerParams.get(instance);
4472 instance.disableButtons();
4473 if (innerParams.input) {
4474 handleConfirmOrDenyWithInput(instance, 'confirm');
4475 } else {
4476 confirm(instance, true);
4477 }
4478 };
4479
4480 /**
4481 * @param {SweetAlert} instance
4482 */
4483 const handleDenyButtonClick = instance => {
4484 const innerParams = privateProps.innerParams.get(instance);
4485 instance.disableButtons();
4486 if (innerParams.returnInputValueOnDeny) {
4487 handleConfirmOrDenyWithInput(instance, 'deny');
4488 } else {
4489 deny(instance, false);
4490 }
4491 };
4492
4493 /**
4494 * @param {SweetAlert} instance
4495 * @param {(dismiss: DismissReason) => void} dismissWith
4496 */
4497 const handleCancelButtonClick = (instance, dismissWith) => {
4498 instance.disableButtons();
4499 dismissWith(DismissReason.cancel);
4500 };
4501
4502 /**
4503 * @param {SweetAlert} instance
4504 * @param {'confirm' | 'deny'} type
4505 */
4506 const handleConfirmOrDenyWithInput = (instance, type) => {
4507 const innerParams = privateProps.innerParams.get(instance);
4508 if (!innerParams.input) {
4509 error(`The "input" parameter is needed to be set when using returnInputValueOn${capitalizeFirstLetter(type)}`);
4510 return;
4511 }
4512 const input = instance.getInput();
4513 const inputValue = getInputValue(instance, innerParams);
4514 if (innerParams.inputValidator) {
4515 handleInputValidator(instance, inputValue, type);
4516 } else if (input && !input.checkValidity()) {
4517 instance.enableButtons();
4518 instance.showValidationMessage(innerParams.validationMessage || input.validationMessage);
4519 } else if (type === 'deny') {
4520 deny(instance, inputValue);
4521 } else {
4522 confirm(instance, inputValue);
4523 }
4524 };
4525
4526 /**
4527 * @param {SweetAlert} instance
4528 * @param {SweetAlertInputValue} inputValue
4529 * @param {'confirm' | 'deny'} type
4530 */
4531 const handleInputValidator = (instance, inputValue, type) => {
4532 const innerParams = privateProps.innerParams.get(instance);
4533 instance.disableInput();
4534 const validationPromise = Promise.resolve().then(() => asPromise(innerParams.inputValidator(inputValue, innerParams.validationMessage)));
4535 validationPromise.then(validationMessage => {
4536 instance.enableButtons();
4537 instance.enableInput();
4538 if (validationMessage) {
4539 instance.showValidationMessage(validationMessage);
4540 } else if (type === 'deny') {
4541 deny(instance, inputValue);
4542 } else {
4543 confirm(instance, inputValue);
4544 }
4545 });
4546 };
4547
4548 /**
4549 * @param {SweetAlert} instance
4550 * @param {*} value
4551 */
4552 const deny = (instance, value) => {
4553 const innerParams = privateProps.innerParams.get(instance);
4554 if (innerParams.showLoaderOnDeny) {
4555 showLoading(getDenyButton());
4556 }
4557 if (innerParams.preDeny) {
4558 instance.isAwaitingPromise = true; // Flagging the instance as awaiting a promise so it's own promise's reject/resolve methods doesn't get destroyed until the result from this preDeny's promise is received
4559 const preDenyPromise = Promise.resolve().then(() => asPromise(innerParams.preDeny(value, innerParams.validationMessage)));
4560 preDenyPromise.then(preDenyValue => {
4561 if (preDenyValue === false) {
4562 instance.hideLoading();
4563 handleAwaitingPromise(instance);
4564 } else {
4565 instance.close(/** @type SweetAlertResult */{
4566 isDenied: true,
4567 value: typeof preDenyValue === 'undefined' ? value : preDenyValue
4568 });
4569 }
4570 }).catch(error => rejectWith(instance, error));
4571 } else {
4572 instance.close(/** @type SweetAlertResult */{
4573 isDenied: true,
4574 value
4575 });
4576 }
4577 };
4578
4579 /**
4580 * @param {SweetAlert} instance
4581 * @param {*} value
4582 */
4583 const succeedWith = (instance, value) => {
4584 instance.close(/** @type SweetAlertResult */{
4585 isConfirmed: true,
4586 value
4587 });
4588 };
4589
4590 /**
4591 *
4592 * @param {SweetAlert} instance
4593 * @param {string} error
4594 */
4595 const rejectWith = (instance, error) => {
4596 instance.rejectPromise(error);
4597 };
4598
4599 /**
4600 *
4601 * @param {SweetAlert} instance
4602 * @param {*} value
4603 */
4604 const confirm = (instance, value) => {
4605 const innerParams = privateProps.innerParams.get(instance);
4606 if (innerParams.showLoaderOnConfirm) {
4607 showLoading();
4608 }
4609 if (innerParams.preConfirm) {
4610 instance.resetValidationMessage();
4611 instance.isAwaitingPromise = true; // Flagging the instance as awaiting a promise so it's own promise's reject/resolve methods doesn't get destroyed until the result from this preConfirm's promise is received
4612 const preConfirmPromise = Promise.resolve().then(() => asPromise(innerParams.preConfirm(value, innerParams.validationMessage)));
4613 preConfirmPromise.then(preConfirmValue => {
4614 if (isVisible$1(getValidationMessage()) || preConfirmValue === false) {
4615 instance.hideLoading();
4616 handleAwaitingPromise(instance);
4617 } else {
4618 succeedWith(instance, typeof preConfirmValue === 'undefined' ? value : preConfirmValue);
4619 }
4620 }).catch(error => rejectWith(instance, error));
4621 } else {
4622 succeedWith(instance, value);
4623 }
4624 };
4625
4626 /**
4627 * Hides loader and shows back the button which was hidden by .showLoading()
4628 * @this {SweetAlert}
4629 */
4630 function hideLoading() {
4631 // do nothing if popup is closed
4632 const innerParams = privateProps.innerParams.get(this);
4633 if (!innerParams) {
4634 return;
4635 }
4636 const domCache = privateProps.domCache.get(this);
4637 hide(domCache.loader);
4638 if (isToast()) {
4639 if (innerParams.icon) {
4640 show(getIcon());
4641 }
4642 } else {
4643 showRelatedButton(domCache);
4644 }
4645 removeClass([domCache.popup, domCache.actions], swalClasses.loading);
4646 domCache.popup.removeAttribute('aria-busy');
4647 domCache.popup.removeAttribute('data-loading');
4648 this.enableButtons();
4649 }
4650
4651 /**
4652 * @param {DomCache} domCache
4653 */
4654 const showRelatedButton = domCache => {
4655 const dataButtonToReplace = domCache.loader.getAttribute('data-button-to-replace');
4656 const buttonToReplace = dataButtonToReplace ? domCache.popup.getElementsByClassName(dataButtonToReplace) : [];
4657 if (buttonToReplace.length) {
4658 show(/** @type {HTMLElement} */buttonToReplace[0], 'inline-block');
4659 } else if (allButtonsAreHidden()) {
4660 hide(domCache.actions);
4661 }
4662 };
4663
4664 /**
4665 * Gets the input DOM node, this method works with input parameter.
4666 *
4667 * @returns {HTMLInputElement | null}
4668 * @this {SweetAlert}
4669 */
4670 function getInput() {
4671 const innerParams = privateProps.innerParams.get(this);
4672 const domCache = privateProps.domCache.get(this);
4673 if (!domCache) {
4674 return null;
4675 }
4676 return getInput$1(domCache.popup, innerParams.input);
4677 }
4678
4679 /**
4680 * @param {SweetAlert} instance
4681 * @param {string[]} buttons
4682 * @param {boolean} disabled
4683 */
4684 function setButtonsDisabled(instance, buttons, disabled) {
4685 const domCache = privateProps.domCache.get(instance);
4686 buttons.forEach(button => {
4687 domCache[button].disabled = disabled;
4688 });
4689 }
4690
4691 /**
4692 * @param {HTMLInputElement | null} input
4693 * @param {boolean} disabled
4694 */
4695 function setInputDisabled(input, disabled) {
4696 const popup = getPopup();
4697 if (!popup || !input) {
4698 return;
4699 }
4700 if (input.type === 'radio') {
4701 /** @type {NodeListOf<HTMLInputElement>} */
4702 const radios = popup.querySelectorAll(`[name="${swalClasses.radio}"]`);
4703 radios.forEach(radio => {
4704 radio.disabled = disabled;
4705 });
4706 } else {
4707 input.disabled = disabled;
4708 }
4709 }
4710
4711 /**
4712 * Enable all the buttons
4713 * @this {SweetAlert}
4714 */
4715 function enableButtons() {
4716 setButtonsDisabled(this, ['confirmButton', 'denyButton', 'cancelButton'], false);
4717 const focusedElement = privateProps.focusedElement.get(this);
4718 if (focusedElement instanceof HTMLElement && document.activeElement === document.body) {
4719 focusedElement.focus();
4720 }
4721 privateProps.focusedElement.delete(this);
4722 }
4723
4724 /**
4725 * Disable all the buttons
4726 * @this {SweetAlert}
4727 */
4728 function disableButtons() {
4729 privateProps.focusedElement.set(this, document.activeElement);
4730 setButtonsDisabled(this, ['confirmButton', 'denyButton', 'cancelButton'], true);
4731 }
4732
4733 /**
4734 * Enable the input field
4735 * @this {SweetAlert}
4736 */
4737 function enableInput() {
4738 setInputDisabled(this.getInput(), false);
4739 }
4740
4741 /**
4742 * Disable the input field
4743 * @this {SweetAlert}
4744 */
4745 function disableInput() {
4746 setInputDisabled(this.getInput(), true);
4747 }
4748
4749 /**
4750 * Show block with validation message
4751 *
4752 * @param {string} error
4753 * @this {SweetAlert}
4754 */
4755 function showValidationMessage(error) {
4756 const domCache = privateProps.domCache.get(this);
4757 const params = privateProps.innerParams.get(this);
4758 setInnerHtml(domCache.validationMessage, error);
4759 domCache.validationMessage.className = swalClasses['validation-message'];
4760 if (params.customClass && params.customClass.validationMessage) {
4761 addClass(domCache.validationMessage, params.customClass.validationMessage);
4762 }
4763 show(domCache.validationMessage);
4764 const input = this.getInput();
4765 if (input) {
4766 input.setAttribute('aria-invalid', 'true');
4767 input.setAttribute('aria-describedby', swalClasses['validation-message']);
4768 focusInput(input);
4769 addClass(input, swalClasses.inputerror);
4770 }
4771 }
4772
4773 /**
4774 * Hide block with validation message
4775 *
4776 * @this {SweetAlert}
4777 */
4778 function resetValidationMessage() {
4779 const domCache = privateProps.domCache.get(this);
4780 if (domCache.validationMessage) {
4781 hide(domCache.validationMessage);
4782 }
4783 const input = this.getInput();
4784 if (input) {
4785 input.removeAttribute('aria-invalid');
4786 input.removeAttribute('aria-describedby');
4787 removeClass(input, swalClasses.inputerror);
4788 }
4789 }
4790
4791 const defaultParams = {
4792 title: '',
4793 titleText: '',
4794 text: '',
4795 html: '',
4796 footer: '',
4797 icon: undefined,
4798 iconColor: undefined,
4799 iconHtml: undefined,
4800 template: undefined,
4801 toast: false,
4802 draggable: false,
4803 animation: true,
4804 theme: 'light',
4805 showClass: {
4806 popup: 'swal2-show',
4807 backdrop: 'swal2-backdrop-show',
4808 icon: 'swal2-icon-show'
4809 },
4810 hideClass: {
4811 popup: 'swal2-hide',
4812 backdrop: 'swal2-backdrop-hide',
4813 icon: 'swal2-icon-hide'
4814 },
4815 customClass: {},
4816 target: 'body',
4817 color: undefined,
4818 backdrop: true,
4819 heightAuto: true,
4820 allowOutsideClick: true,
4821 allowEscapeKey: true,
4822 allowEnterKey: true,
4823 stopKeydownPropagation: true,
4824 keydownListenerCapture: false,
4825 showConfirmButton: true,
4826 showDenyButton: false,
4827 showCancelButton: false,
4828 preConfirm: undefined,
4829 preDeny: undefined,
4830 confirmButtonText: 'OK',
4831 confirmButtonAriaLabel: '',
4832 confirmButtonColor: undefined,
4833 denyButtonText: 'No',
4834 denyButtonAriaLabel: '',
4835 denyButtonColor: undefined,
4836 cancelButtonText: 'Cancel',
4837 cancelButtonAriaLabel: '',
4838 cancelButtonColor: undefined,
4839 buttonsStyling: true,
4840 reverseButtons: false,
4841 focusConfirm: true,
4842 focusDeny: false,
4843 focusCancel: false,
4844 returnFocus: true,
4845 showCloseButton: false,
4846 closeButtonHtml: '&times;',
4847 closeButtonAriaLabel: 'Close this dialog',
4848 loaderHtml: '',
4849 showLoaderOnConfirm: false,
4850 showLoaderOnDeny: false,
4851 imageUrl: undefined,
4852 imageWidth: undefined,
4853 imageHeight: undefined,
4854 imageAlt: '',
4855 timer: undefined,
4856 timerProgressBar: false,
4857 width: undefined,
4858 padding: undefined,
4859 background: undefined,
4860 input: undefined,
4861 inputPlaceholder: '',
4862 inputLabel: '',
4863 inputValue: '',
4864 inputOptions: {},
4865 inputAutoFocus: true,
4866 inputAutoTrim: true,
4867 inputAttributes: {},
4868 inputValidator: undefined,
4869 returnInputValueOnDeny: false,
4870 validationMessage: undefined,
4871 grow: false,
4872 position: 'center',
4873 progressSteps: [],
4874 currentProgressStep: undefined,
4875 progressStepsDistance: undefined,
4876 willOpen: undefined,
4877 didOpen: undefined,
4878 didRender: undefined,
4879 willClose: undefined,
4880 didClose: undefined,
4881 didDestroy: undefined,
4882 scrollbarPadding: true,
4883 topLayer: false
4884 };
4885 const updatableParams = ['allowEscapeKey', 'allowOutsideClick', 'background', 'buttonsStyling', 'cancelButtonAriaLabel', 'cancelButtonColor', 'cancelButtonText', 'closeButtonAriaLabel', 'closeButtonHtml', 'color', 'confirmButtonAriaLabel', 'confirmButtonColor', 'confirmButtonText', 'currentProgressStep', 'customClass', 'denyButtonAriaLabel', 'denyButtonColor', 'denyButtonText', 'didClose', 'didDestroy', 'draggable', 'footer', 'hideClass', 'html', 'icon', 'iconColor', 'iconHtml', 'imageAlt', 'imageHeight', 'imageUrl', 'imageWidth', 'preConfirm', 'preDeny', 'progressSteps', 'returnFocus', 'reverseButtons', 'showCancelButton', 'showCloseButton', 'showConfirmButton', 'showDenyButton', 'text', 'title', 'titleText', 'theme', 'willClose'];
4886
4887 /** @type {Record<string, string | undefined>} */
4888 const deprecatedParams = {
4889 allowEnterKey: undefined
4890 };
4891 const toastIncompatibleParams = ['allowOutsideClick', 'allowEnterKey', 'backdrop', 'draggable', 'focusConfirm', 'focusDeny', 'focusCancel', 'returnFocus', 'heightAuto', 'keydownListenerCapture'];
4892
4893 /**
4894 * Is valid parameter
4895 *
4896 * @param {string} paramName
4897 * @returns {boolean}
4898 */
4899 const isValidParameter = paramName => {
4900 return Object.prototype.hasOwnProperty.call(defaultParams, paramName);
4901 };
4902
4903 /**
4904 * Is valid parameter for Swal.update() method
4905 *
4906 * @param {string} paramName
4907 * @returns {boolean}
4908 */
4909 const isUpdatableParameter = paramName => {
4910 return updatableParams.indexOf(paramName) !== -1;
4911 };
4912
4913 /**
4914 * Is deprecated parameter
4915 *
4916 * @param {string} paramName
4917 * @returns {string | undefined}
4918 */
4919 const isDeprecatedParameter = paramName => {
4920 return deprecatedParams[paramName];
4921 };
4922
4923 /**
4924 * @param {string} param
4925 */
4926 const checkIfParamIsValid = param => {
4927 if (!isValidParameter(param)) {
4928 warn(`Unknown parameter "${param}"`);
4929 }
4930 };
4931
4932 /**
4933 * @param {string} param
4934 */
4935 const checkIfToastParamIsValid = param => {
4936 if (toastIncompatibleParams.includes(param)) {
4937 warn(`The parameter "${param}" is incompatible with toasts`);
4938 }
4939 };
4940
4941 /**
4942 * @param {string} param
4943 */
4944 const checkIfParamIsDeprecated = param => {
4945 const isDeprecated = isDeprecatedParameter(param);
4946 if (isDeprecated) {
4947 warnAboutDeprecation(param, isDeprecated);
4948 }
4949 };
4950
4951 /**
4952 * Show relevant warnings for given params
4953 *
4954 * @param {SweetAlertOptions} params
4955 */
4956 const showWarningsForParams = params => {
4957 if (params.backdrop === false && params.allowOutsideClick) {
4958 warn('"allowOutsideClick" parameter requires `backdrop` parameter to be set to `true`');
4959 }
4960 if (params.theme && !['light', 'dark', 'auto', 'minimal', 'borderless', 'bootstrap-4', 'bootstrap-4-light', 'bootstrap-4-dark', 'bootstrap-5', 'bootstrap-5-light', 'bootstrap-5-dark', 'material-ui', 'material-ui-light', 'material-ui-dark', 'embed-iframe', 'bulma', 'bulma-light', 'bulma-dark'].includes(params.theme)) {
4961 warn(`Invalid theme "${params.theme}"`);
4962 }
4963 for (const param in params) {
4964 checkIfParamIsValid(param);
4965 if (params.toast) {
4966 checkIfToastParamIsValid(param);
4967 }
4968 checkIfParamIsDeprecated(param);
4969 }
4970 };
4971
4972 /**
4973 * Updates popup parameters.
4974 *
4975 * @this {any}
4976 * @param {SweetAlertOptions} params
4977 */
4978 function update(params) {
4979 const container = getContainer();
4980 const popup = getPopup();
4981 const innerParams = privateProps.innerParams.get(this);
4982 if (!popup || hasClass(popup, innerParams.hideClass.popup)) {
4983 warn(`You're trying to update the closed or closing popup, that won't work. Use the update() method in preConfirm parameter or show a new popup.`);
4984 return;
4985 }
4986 const validUpdatableParams = filterValidParams(params);
4987 const updatedParams = Object.assign({}, innerParams, validUpdatableParams);
4988 showWarningsForParams(updatedParams);
4989 if (container) {
4990 container.dataset['swal2Theme'] = updatedParams.theme;
4991 }
4992 render(this, updatedParams);
4993 privateProps.innerParams.set(this, updatedParams);
4994 Object.defineProperties(this, {
4995 params: {
4996 value: Object.assign({}, this.params, params),
4997 writable: false,
4998 enumerable: true
4999 }
5000 });
5001 }
5002
5003 /**
5004 * @param {SweetAlertOptions} params
5005 * @returns {SweetAlertOptions}
5006 */
5007 const filterValidParams = params => {
5008 /** @type {Record<string, any>} */
5009 const validUpdatableParams = {};
5010 Object.keys(params).forEach(param => {
5011 if (isUpdatableParameter(param)) {
5012 const typedParams = /** @type {Record<string, any>} */params;
5013 validUpdatableParams[param] = typedParams[param];
5014 } else {
5015 warn(`Invalid parameter to update: ${param}`);
5016 }
5017 });
5018 return validUpdatableParams;
5019 };
5020
5021 /**
5022 * Dispose the current SweetAlert2 instance
5023 * @this {SweetAlert}
5024 */
5025 function _destroy() {
5026 var _globalState$eventEmi;
5027 const domCache = privateProps.domCache.get(this);
5028 const innerParams = privateProps.innerParams.get(this);
5029 if (!innerParams) {
5030 disposeWeakMaps(this); // The WeakMaps might have been partly destroyed, we must recall it to dispose any remaining WeakMaps #2335
5031 return; // This instance has already been destroyed
5032 }
5033
5034 // Check if there is another Swal closing
5035 if (domCache.popup && globalState.swalCloseEventFinishedCallback) {
5036 globalState.swalCloseEventFinishedCallback();
5037 delete globalState.swalCloseEventFinishedCallback;
5038 }
5039 if (typeof innerParams.didDestroy === 'function') {
5040 innerParams.didDestroy();
5041 }
5042 (_globalState$eventEmi = globalState.eventEmitter) === null || _globalState$eventEmi === void 0 || _globalState$eventEmi.emit('didDestroy');
5043 disposeSwal(this);
5044 }
5045
5046 /**
5047 * @param {SweetAlert} instance
5048 */
5049 const disposeSwal = instance => {
5050 disposeWeakMaps(instance);
5051 // Unset this.params so GC will dispose it (#1569)
5052 // @ts-ignore
5053 delete instance.params;
5054 // Unset globalState props so GC will dispose globalState (#1569)
5055 delete globalState.keydownHandler;
5056 delete globalState.keydownTarget;
5057 // Unset currentInstance
5058 delete globalState.currentInstance;
5059 };
5060
5061 /**
5062 * @param {SweetAlert} instance
5063 */
5064 const disposeWeakMaps = instance => {
5065 // If the current instance is awaiting a promise result, we keep the privateMethods to call them once the promise result is retrieved #2335
5066 if (instance.isAwaitingPromise) {
5067 unsetWeakMaps(privateProps, instance);
5068 instance.isAwaitingPromise = true;
5069 } else {
5070 unsetWeakMaps(privateMethods, instance);
5071 unsetWeakMaps(privateProps, instance);
5072
5073 // @ts-ignore
5074 delete instance.isAwaitingPromise;
5075 // Unset instance methods
5076 // @ts-ignore
5077 delete instance.disableButtons;
5078 // @ts-ignore
5079 delete instance.enableButtons;
5080 // @ts-ignore
5081 delete instance.getInput;
5082 // @ts-ignore
5083 delete instance.disableInput;
5084 // @ts-ignore
5085 delete instance.enableInput;
5086 // @ts-ignore
5087 delete instance.hideLoading;
5088 // @ts-ignore
5089 delete instance.disableLoading;
5090 // @ts-ignore
5091 delete instance.showValidationMessage;
5092 // @ts-ignore
5093 delete instance.resetValidationMessage;
5094 // @ts-ignore
5095 delete instance.close;
5096 // @ts-ignore
5097 delete instance.closePopup;
5098 // @ts-ignore
5099 delete instance.closeModal;
5100 // @ts-ignore
5101 delete instance.closeToast;
5102 // @ts-ignore
5103 delete instance.rejectPromise;
5104 // @ts-ignore
5105 delete instance.update;
5106 // @ts-ignore
5107 delete instance._destroy;
5108 }
5109 };
5110
5111 /**
5112 * @param {Record<string, WeakMap<any, any>>} obj
5113 * @param {SweetAlert} instance
5114 */
5115 const unsetWeakMaps = (obj, instance) => {
5116 for (const i in obj) {
5117 obj[i].delete(instance);
5118 }
5119 };
5120
5121 var instanceMethods = /*#__PURE__*/Object.freeze({
5122 __proto__: null,
5123 _destroy: _destroy,
5124 close: close,
5125 closeModal: close,
5126 closePopup: close,
5127 closeToast: close,
5128 disableButtons: disableButtons,
5129 disableInput: disableInput,
5130 disableLoading: hideLoading,
5131 enableButtons: enableButtons,
5132 enableInput: enableInput,
5133 getInput: getInput,
5134 handleAwaitingPromise: handleAwaitingPromise,
5135 hideLoading: hideLoading,
5136 rejectPromise: rejectPromise,
5137 resetValidationMessage: resetValidationMessage,
5138 showValidationMessage: showValidationMessage,
5139 update: update
5140 });
5141
5142 /**
5143 * @param {SweetAlertOptions} innerParams
5144 * @param {DomCache} domCache
5145 * @param {(dismiss: DismissReason) => void} dismissWith
5146 */
5147 const handlePopupClick = (innerParams, domCache, dismissWith) => {
5148 if (innerParams.toast) {
5149 handleToastClick(innerParams, domCache, dismissWith);
5150 } else {
5151 // Ignore click events that had mousedown on the popup but mouseup on the container
5152 // This can happen when the user drags a slider
5153 handleModalMousedown(domCache);
5154
5155 // Ignore click events that had mousedown on the container but mouseup on the popup
5156 handleContainerMousedown(domCache);
5157 handleModalClick(innerParams, domCache, dismissWith);
5158 }
5159 };
5160
5161 /**
5162 * @param {SweetAlertOptions} innerParams
5163 * @param {DomCache} domCache
5164 * @param {(dismiss: DismissReason) => void} dismissWith
5165 */
5166 const handleToastClick = (innerParams, domCache, dismissWith) => {
5167 // Closing toast by internal click
5168 domCache.popup.onclick = () => {
5169 if (innerParams && (isAnyButtonShown(innerParams) || innerParams.timer || innerParams.input)) {
5170 return;
5171 }
5172 dismissWith(DismissReason.close);
5173 };
5174 };
5175
5176 /**
5177 * @param {SweetAlertOptions} innerParams
5178 * @returns {boolean}
5179 */
5180 const isAnyButtonShown = innerParams => {
5181 return Boolean(innerParams.showConfirmButton || innerParams.showDenyButton || innerParams.showCancelButton || innerParams.showCloseButton);
5182 };
5183 let ignoreOutsideClick = false;
5184
5185 /**
5186 * @param {DomCache} domCache
5187 */
5188 const handleModalMousedown = domCache => {
5189 domCache.popup.onmousedown = () => {
5190 domCache.container.onmouseup = function (e) {
5191 domCache.container.onmouseup = () => {};
5192 // We only check if the mouseup target is the container because usually it doesn't
5193 // have any other direct children aside of the popup
5194 if (e.target === domCache.container) {
5195 ignoreOutsideClick = true;
5196 }
5197 };
5198 };
5199 };
5200
5201 /**
5202 * @param {DomCache} domCache
5203 */
5204 const handleContainerMousedown = domCache => {
5205 domCache.container.onmousedown = e => {
5206 // prevent the modal text from being selected on double click on the container (allowOutsideClick: false)
5207 if (e.target === domCache.container) {
5208 e.preventDefault();
5209 }
5210 domCache.popup.onmouseup = function (e) {
5211 domCache.popup.onmouseup = () => {};
5212 // We also need to check if the mouseup target is a child of the popup
5213 if (e.target === domCache.popup || e.target instanceof HTMLElement && domCache.popup.contains(e.target)) {
5214 ignoreOutsideClick = true;
5215 }
5216 };
5217 };
5218 };
5219
5220 /**
5221 * @param {SweetAlertOptions} innerParams
5222 * @param {DomCache} domCache
5223 * @param {(dismiss: DismissReason) => void} dismissWith
5224 */
5225 const handleModalClick = (innerParams, domCache, dismissWith) => {
5226 domCache.container.onclick = e => {
5227 if (ignoreOutsideClick) {
5228 ignoreOutsideClick = false;
5229 return;
5230 }
5231 if (e.target === domCache.container && callIfFunction(innerParams.allowOutsideClick)) {
5232 dismissWith(DismissReason.backdrop);
5233 }
5234 };
5235 };
5236
5237 /**
5238 * @param {unknown} elem
5239 * @returns {boolean}
5240 */
5241 const isJqueryElement = elem => typeof elem === 'object' && elem !== null && 'jquery' in elem;
5242
5243 /**
5244 * @param {unknown} elem
5245 * @returns {boolean}
5246 */
5247 const isElement = elem => elem instanceof Element || isJqueryElement(elem);
5248
5249 /**
5250 * @param {ReadonlyArray<unknown>} args
5251 * @returns {SweetAlertOptions}
5252 */
5253 const argsToParams = args => {
5254 /** @type {Record<string, unknown>} */
5255 const params = {};
5256 if (typeof args[0] === 'object' && !isElement(args[0])) {
5257 Object.assign(params, args[0]);
5258 } else {
5259 ['title', 'html', 'icon'].forEach((name, index) => {
5260 const arg = args[index];
5261 if (typeof arg === 'string' || isElement(arg)) {
5262 params[name] = arg;
5263 } else if (arg !== undefined) {
5264 error(`Unexpected type of ${name}! Expected "string" or "Element", got ${typeof arg}`);
5265 }
5266 });
5267 }
5268 return /** @type {SweetAlertOptions} */params;
5269 };
5270
5271 /**
5272 * Main method to create a new SweetAlert2 popup
5273 *
5274 * @this {new (...args: any[]) => any}
5275 * @param {...SweetAlertOptions} args
5276 * @returns {Promise<SweetAlertResult>}
5277 */
5278 function fire(...args) {
5279 return new this(...args);
5280 }
5281
5282 /**
5283 * Returns an extended version of `Swal` containing `params` as defaults.
5284 * Useful for reusing Swal configuration.
5285 *
5286 * For example:
5287 *
5288 * Before:
5289 * const textPromptOptions = { input: 'text', showCancelButton: true }
5290 * const {value: firstName} = await Swal.fire({ ...textPromptOptions, title: 'What is your first name?' })
5291 * const {value: lastName} = await Swal.fire({ ...textPromptOptions, title: 'What is your last name?' })
5292 *
5293 * After:
5294 * const TextPrompt = Swal.mixin({ input: 'text', showCancelButton: true })
5295 * const {value: firstName} = await TextPrompt('What is your first name?')
5296 * const {value: lastName} = await TextPrompt('What is your last name?')
5297 *
5298 * @param {SweetAlertOptions} mixinParams
5299 * @returns {SweetAlert}
5300 * @this {typeof import('../SweetAlert.js').SweetAlert}
5301 */
5302 function mixin(mixinParams) {
5303 // @ts-ignore: 'this' refers to the SweetAlert constructor
5304 class MixinSwal extends this {
5305 /**
5306 * @param {any} params
5307 * @param {any} priorityMixinParams
5308 */
5309 _main(params, priorityMixinParams) {
5310 return super._main(params, Object.assign({}, mixinParams, priorityMixinParams));
5311 }
5312 }
5313 // @ts-ignore
5314 return MixinSwal;
5315 }
5316
5317 /**
5318 * If `timer` parameter is set, returns number of milliseconds of timer remained.
5319 * Otherwise, returns undefined.
5320 *
5321 * @returns {number | undefined}
5322 */
5323 const getTimerLeft = () => {
5324 return globalState.timeout && globalState.timeout.getTimerLeft();
5325 };
5326
5327 /**
5328 * Stop timer. Returns number of milliseconds of timer remained.
5329 * If `timer` parameter isn't set, returns undefined.
5330 *
5331 * @returns {number | undefined}
5332 */
5333 const stopTimer = () => {
5334 if (globalState.timeout) {
5335 stopTimerProgressBar();
5336 return globalState.timeout.stop();
5337 }
5338 };
5339
5340 /**
5341 * Resume timer. Returns number of milliseconds of timer remained.
5342 * If `timer` parameter isn't set, returns undefined.
5343 *
5344 * @returns {number | undefined}
5345 */
5346 const resumeTimer = () => {
5347 if (globalState.timeout) {
5348 const remaining = globalState.timeout.start();
5349 animateTimerProgressBar(remaining);
5350 return remaining;
5351 }
5352 };
5353
5354 /**
5355 * Resume timer. Returns number of milliseconds of timer remained.
5356 * If `timer` parameter isn't set, returns undefined.
5357 *
5358 * @returns {number | undefined}
5359 */
5360 const toggleTimer = () => {
5361 const timer = globalState.timeout;
5362 return timer && (timer.running ? stopTimer() : resumeTimer());
5363 };
5364
5365 /**
5366 * Increase timer. Returns number of milliseconds of an updated timer.
5367 * If `timer` parameter isn't set, returns undefined.
5368 *
5369 * @param {number} ms
5370 * @returns {number | undefined}
5371 */
5372 const increaseTimer = ms => {
5373 if (globalState.timeout) {
5374 const remaining = globalState.timeout.increase(ms);
5375 animateTimerProgressBar(remaining, true);
5376 return remaining;
5377 }
5378 };
5379
5380 /**
5381 * Check if timer is running. Returns true if timer is running
5382 * or false if timer is paused or stopped.
5383 * If `timer` parameter isn't set, returns undefined
5384 *
5385 * @returns {boolean}
5386 */
5387 const isTimerRunning = () => {
5388 return Boolean(globalState.timeout && globalState.timeout.isRunning());
5389 };
5390
5391 let bodyClickListenerAdded = false;
5392 /** @type {Record<string, any>} */
5393 const clickHandlers = {};
5394
5395 /**
5396 * @this {any}
5397 * @param {string} attr
5398 */
5399 function bindClickHandler(attr = 'data-swal-template') {
5400 clickHandlers[attr] = this;
5401 if (!bodyClickListenerAdded) {
5402 document.body.addEventListener('click', bodyClickListener);
5403 bodyClickListenerAdded = true;
5404 }
5405 }
5406
5407 /**
5408 * @param {MouseEvent} event
5409 */
5410 const bodyClickListener = event => {
5411 for (let el = /** @type {any} */event.target; el && el !== document; el = el.parentNode) {
5412 for (const attr in clickHandlers) {
5413 const template = el.getAttribute && el.getAttribute(attr);
5414 if (template) {
5415 clickHandlers[attr].fire({
5416 template
5417 });
5418 return;
5419 }
5420 }
5421 }
5422 };
5423
5424 // Source: https://gist.github.com/mudge/5830382?permalink_comment_id=2691957#gistcomment-2691957
5425
5426 class EventEmitter {
5427 constructor() {
5428 /** @type {Events} */
5429 this.events = {};
5430 }
5431
5432 /**
5433 * @param {string} eventName
5434 * @returns {EventHandlers}
5435 */
5436 _getHandlersByEventName(eventName) {
5437 if (typeof this.events[eventName] === 'undefined') {
5438 // not Set because we need to keep the FIFO order
5439 // https://github.com/sweetalert2/sweetalert2/pull/2763#discussion_r1748990334
5440 this.events[eventName] = [];
5441 }
5442 return this.events[eventName];
5443 }
5444
5445 /**
5446 * @param {string} eventName
5447 * @param {EventHandler} eventHandler
5448 */
5449 on(eventName, eventHandler) {
5450 const currentHandlers = this._getHandlersByEventName(eventName);
5451 if (!currentHandlers.includes(eventHandler)) {
5452 currentHandlers.push(eventHandler);
5453 }
5454 }
5455
5456 /**
5457 * @param {string} eventName
5458 * @param {EventHandler} eventHandler
5459 */
5460 once(eventName, eventHandler) {
5461 /**
5462 * @param {...any} args
5463 */
5464 const onceFn = (...args) => {
5465 this.removeListener(eventName, onceFn);
5466 // @ts-ignore
5467 eventHandler.apply(this, args);
5468 };
5469 this.on(eventName, onceFn);
5470 }
5471
5472 /**
5473 * @param {string} eventName
5474 * @param {...any} args
5475 */
5476 emit(eventName, ...args) {
5477 this._getHandlersByEventName(eventName).forEach(
5478 /**
5479 * @param {EventHandler} eventHandler
5480 */
5481 eventHandler => {
5482 try {
5483 // @ts-ignore
5484 eventHandler.apply(this, args);
5485 } catch (error) {
5486 console.error(error);
5487 }
5488 });
5489 }
5490
5491 /**
5492 * @param {string} eventName
5493 * @param {EventHandler} eventHandler
5494 */
5495 removeListener(eventName, eventHandler) {
5496 const currentHandlers = this._getHandlersByEventName(eventName);
5497 const index = currentHandlers.indexOf(eventHandler);
5498 if (index > -1) {
5499 currentHandlers.splice(index, 1);
5500 }
5501 }
5502
5503 /**
5504 * @param {string} eventName
5505 */
5506 removeAllListeners(eventName) {
5507 if (this.events[eventName] !== undefined) {
5508 // https://github.com/sweetalert2/sweetalert2/pull/2763#discussion_r1749239222
5509 this.events[eventName].length = 0;
5510 }
5511 }
5512 reset() {
5513 this.events = {};
5514 }
5515 }
5516
5517 globalState.eventEmitter = new EventEmitter();
5518
5519 /**
5520 * @param {string} eventName
5521 * @param {EventHandler} eventHandler
5522 */
5523 const on = (eventName, eventHandler) => {
5524 if (globalState.eventEmitter) {
5525 globalState.eventEmitter.on(eventName, eventHandler);
5526 }
5527 };
5528
5529 /**
5530 * @param {string} eventName
5531 * @param {EventHandler} eventHandler
5532 */
5533 const once = (eventName, eventHandler) => {
5534 if (globalState.eventEmitter) {
5535 globalState.eventEmitter.once(eventName, eventHandler);
5536 }
5537 };
5538
5539 /**
5540 * @param {string} [eventName]
5541 * @param {EventHandler} [eventHandler]
5542 */
5543 const off = (eventName, eventHandler) => {
5544 if (!globalState.eventEmitter) {
5545 return;
5546 }
5547
5548 // Remove all handlers for all events
5549 if (!eventName) {
5550 globalState.eventEmitter.reset();
5551 return;
5552 }
5553 if (eventHandler) {
5554 // Remove a specific handler
5555 globalState.eventEmitter.removeListener(eventName, eventHandler);
5556 } else {
5557 // Remove all handlers for a specific event
5558 globalState.eventEmitter.removeAllListeners(eventName);
5559 }
5560 };
5561
5562 var staticMethods = /*#__PURE__*/Object.freeze({
5563 __proto__: null,
5564 argsToParams: argsToParams,
5565 bindClickHandler: bindClickHandler,
5566 clickCancel: clickCancel,
5567 clickConfirm: clickConfirm,
5568 clickDeny: clickDeny,
5569 enableLoading: showLoading,
5570 fire: fire,
5571 getActions: getActions,
5572 getCancelButton: getCancelButton,
5573 getCloseButton: getCloseButton,
5574 getConfirmButton: getConfirmButton,
5575 getContainer: getContainer,
5576 getDenyButton: getDenyButton,
5577 getFocusableElements: getFocusableElements,
5578 getFooter: getFooter,
5579 getHtmlContainer: getHtmlContainer,
5580 getIcon: getIcon,
5581 getIconContent: getIconContent,
5582 getImage: getImage,
5583 getInputLabel: getInputLabel,
5584 getLoader: getLoader,
5585 getPopup: getPopup,
5586 getProgressSteps: getProgressSteps,
5587 getTimerLeft: getTimerLeft,
5588 getTimerProgressBar: getTimerProgressBar,
5589 getTitle: getTitle,
5590 getValidationMessage: getValidationMessage,
5591 increaseTimer: increaseTimer,
5592 isDeprecatedParameter: isDeprecatedParameter,
5593 isLoading: isLoading,
5594 isTimerRunning: isTimerRunning,
5595 isUpdatableParameter: isUpdatableParameter,
5596 isValidParameter: isValidParameter,
5597 isVisible: isVisible,
5598 mixin: mixin,
5599 off: off,
5600 on: on,
5601 once: once,
5602 resumeTimer: resumeTimer,
5603 showLoading: showLoading,
5604 stopTimer: stopTimer,
5605 toggleTimer: toggleTimer
5606 });
5607
5608 class Timer {
5609 /**
5610 * @param {() => void} callback
5611 * @param {number} delay
5612 */
5613 constructor(callback, delay) {
5614 this.callback = callback;
5615 this.remaining = delay;
5616 this.running = false;
5617 this.start();
5618 }
5619
5620 /**
5621 * @returns {number}
5622 */
5623 start() {
5624 if (!this.running) {
5625 this.running = true;
5626 this.started = new Date();
5627 this.id = setTimeout(this.callback, this.remaining);
5628 }
5629 return this.remaining;
5630 }
5631
5632 /**
5633 * @returns {number}
5634 */
5635 stop() {
5636 if (this.started && this.running) {
5637 this.running = false;
5638 clearTimeout(this.id);
5639 this.remaining -= new Date().getTime() - this.started.getTime();
5640 }
5641 return this.remaining;
5642 }
5643
5644 /**
5645 * @param {number} n
5646 * @returns {number}
5647 */
5648 increase(n) {
5649 const running = this.running;
5650 if (running) {
5651 this.stop();
5652 }
5653 this.remaining += n;
5654 if (running) {
5655 this.start();
5656 }
5657 return this.remaining;
5658 }
5659
5660 /**
5661 * @returns {number}
5662 */
5663 getTimerLeft() {
5664 if (this.running) {
5665 this.stop();
5666 this.start();
5667 }
5668 return this.remaining;
5669 }
5670
5671 /**
5672 * @returns {boolean}
5673 */
5674 isRunning() {
5675 return this.running;
5676 }
5677 }
5678
5679 const swalStringParams = ['swal-title', 'swal-html', 'swal-footer'];
5680
5681 /**
5682 * @param {SweetAlertOptions} params
5683 * @returns {SweetAlertOptions}
5684 */
5685 const getTemplateParams = params => {
5686 const template = typeof params.template === 'string' ? (/** @type {HTMLTemplateElement} */document.querySelector(params.template)) : params.template;
5687 if (!template) {
5688 return {};
5689 }
5690 /** @type {DocumentFragment} */
5691 const templateContent = template.content;
5692 showWarningsForElements(templateContent);
5693 const result = Object.assign(getSwalParams(templateContent), getSwalFunctionParams(templateContent), getSwalButtons(templateContent), getSwalImage(templateContent), getSwalIcon(templateContent), getSwalInput(templateContent), getSwalStringParams(templateContent, swalStringParams));
5694 return result;
5695 };
5696
5697 /**
5698 * @param {DocumentFragment} templateContent
5699 * @returns {Record<string, string | boolean | number>}
5700 */
5701 const getSwalParams = templateContent => {
5702 /** @type {Record<string, string | boolean | number>} */
5703 const result = {};
5704 /** @type {HTMLElement[]} */
5705 const swalParams = Array.from(templateContent.querySelectorAll('swal-param'));
5706 swalParams.forEach(param => {
5707 showWarningsForAttributes(param, ['name', 'value']);
5708 const paramName = /** @type {keyof SweetAlertOptions} */param.getAttribute('name');
5709 const value = param.getAttribute('value');
5710 if (!paramName || !value) {
5711 return;
5712 }
5713 if (paramName in defaultParams && typeof defaultParams[(/** @type {keyof typeof defaultParams} */paramName)] === 'boolean') {
5714 result[paramName] = value !== 'false';
5715 } else if (paramName in defaultParams && typeof defaultParams[(/** @type {keyof typeof defaultParams} */paramName)] === 'object') {
5716 result[paramName] = JSON.parse(value);
5717 } else {
5718 result[paramName] = value;
5719 }
5720 });
5721 return result;
5722 };
5723
5724 /**
5725 * @param {DocumentFragment} templateContent
5726 * @returns {Record<string, () => void>}
5727 */
5728 const getSwalFunctionParams = templateContent => {
5729 /** @type {Record<string, () => void>} */
5730 const result = {};
5731 /** @type {HTMLElement[]} */
5732 const swalFunctions = Array.from(templateContent.querySelectorAll('swal-function-param'));
5733 swalFunctions.forEach(param => {
5734 const paramName = /** @type {keyof SweetAlertOptions} */param.getAttribute('name');
5735 const value = param.getAttribute('value');
5736 if (!paramName || !value) {
5737 return;
5738 }
5739 result[paramName] = new Function(`return ${value}`)();
5740 });
5741 return result;
5742 };
5743
5744 /**
5745 * @param {DocumentFragment} templateContent
5746 * @returns {Record<string, string | boolean>}
5747 */
5748 const getSwalButtons = templateContent => {
5749 /** @type {Record<string, string | boolean>} */
5750 const result = {};
5751 /** @type {HTMLElement[]} */
5752 const swalButtons = Array.from(templateContent.querySelectorAll('swal-button'));
5753 swalButtons.forEach(button => {
5754 showWarningsForAttributes(button, ['type', 'color', 'aria-label']);
5755 const type = button.getAttribute('type');
5756 if (!type || !['confirm', 'cancel', 'deny'].includes(type)) {
5757 return;
5758 }
5759 result[`${type}ButtonText`] = button.innerHTML;
5760 result[`show${capitalizeFirstLetter(type)}Button`] = true;
5761 const color = button.getAttribute('color');
5762 if (color !== null) {
5763 result[`${type}ButtonColor`] = color;
5764 }
5765 const ariaLabel = button.getAttribute('aria-label');
5766 if (ariaLabel !== null) {
5767 result[`${type}ButtonAriaLabel`] = ariaLabel;
5768 }
5769 });
5770 return result;
5771 };
5772
5773 /**
5774 * @param {DocumentFragment} templateContent
5775 * @returns {Pick<SweetAlertOptions, 'imageUrl' | 'imageWidth' | 'imageHeight' | 'imageAlt'>}
5776 */
5777 const getSwalImage = templateContent => {
5778 const result = {};
5779 /** @type {HTMLElement | null} */
5780 const image = templateContent.querySelector('swal-image');
5781 if (image) {
5782 showWarningsForAttributes(image, ['src', 'width', 'height', 'alt']);
5783 // getAttribute returns null if attribute is absent; `|| undefined` converts empty string to undefined
5784 const src = image.getAttribute('src');
5785 if (src !== null) result.imageUrl = src || undefined;
5786 const width = image.getAttribute('width');
5787 if (width !== null) result.imageWidth = width || undefined;
5788 const height = image.getAttribute('height');
5789 if (height !== null) result.imageHeight = height || undefined;
5790 const alt = image.getAttribute('alt');
5791 if (alt !== null) result.imageAlt = alt || undefined;
5792 }
5793 return result;
5794 };
5795
5796 /**
5797 * @param {DocumentFragment} templateContent
5798 * @returns {object}
5799 */
5800 const getSwalIcon = templateContent => {
5801 const result = {};
5802 /** @type {HTMLElement | null} */
5803 const icon = templateContent.querySelector('swal-icon');
5804 if (icon) {
5805 showWarningsForAttributes(icon, ['type', 'color']);
5806 if (icon.hasAttribute('type')) {
5807 result.icon = icon.getAttribute('type');
5808 }
5809 if (icon.hasAttribute('color')) {
5810 result.iconColor = icon.getAttribute('color');
5811 }
5812 result.iconHtml = icon.innerHTML;
5813 }
5814 return result;
5815 };
5816
5817 /**
5818 * @param {DocumentFragment} templateContent
5819 * @returns {object}
5820 */
5821 const getSwalInput = templateContent => {
5822 /** @type {Record<string, any>} */
5823 const result = {};
5824 /** @type {HTMLElement | null} */
5825 const input = templateContent.querySelector('swal-input');
5826 if (input) {
5827 showWarningsForAttributes(input, ['type', 'label', 'placeholder', 'value']);
5828 result.input = input.getAttribute('type') || 'text';
5829 if (input.hasAttribute('label')) {
5830 result.inputLabel = input.getAttribute('label');
5831 }
5832 if (input.hasAttribute('placeholder')) {
5833 result.inputPlaceholder = input.getAttribute('placeholder');
5834 }
5835 if (input.hasAttribute('value')) {
5836 result.inputValue = input.getAttribute('value');
5837 }
5838 }
5839 /** @type {HTMLElement[]} */
5840 const inputOptions = Array.from(templateContent.querySelectorAll('swal-input-option'));
5841 if (inputOptions.length) {
5842 result.inputOptions = {};
5843 inputOptions.forEach(option => {
5844 showWarningsForAttributes(option, ['value']);
5845 const optionValue = option.getAttribute('value');
5846 if (!optionValue) {
5847 return;
5848 }
5849 const optionName = option.innerHTML;
5850 result.inputOptions[optionValue] = optionName;
5851 });
5852 }
5853 return result;
5854 };
5855
5856 /**
5857 * @param {DocumentFragment} templateContent
5858 * @param {string[]} paramNames
5859 * @returns {Record<string, string>}
5860 */
5861 const getSwalStringParams = (templateContent, paramNames) => {
5862 /** @type {Record<string, string>} */
5863 const result = {};
5864 for (const i in paramNames) {
5865 const paramName = paramNames[i];
5866 /** @type {HTMLElement | null} */
5867 const tag = templateContent.querySelector(paramName);
5868 if (tag) {
5869 showWarningsForAttributes(tag, []);
5870 result[paramName.replace(/^swal-/, '')] = tag.innerHTML.trim();
5871 }
5872 }
5873 return result;
5874 };
5875
5876 /**
5877 * @param {DocumentFragment} templateContent
5878 */
5879 const showWarningsForElements = templateContent => {
5880 const allowedElements = swalStringParams.concat(['swal-param', 'swal-function-param', 'swal-button', 'swal-image', 'swal-icon', 'swal-input', 'swal-input-option']);
5881 Array.from(templateContent.children).forEach(el => {
5882 const tagName = el.tagName.toLowerCase();
5883 if (!allowedElements.includes(tagName)) {
5884 warn(`Unrecognized element <${tagName}>`);
5885 }
5886 });
5887 };
5888
5889 /**
5890 * @param {HTMLElement} el
5891 * @param {string[]} allowedAttributes
5892 */
5893 const showWarningsForAttributes = (el, allowedAttributes) => {
5894 Array.from(el.attributes).forEach(attribute => {
5895 if (allowedAttributes.indexOf(attribute.name) === -1) {
5896 warn([`Unrecognized attribute "${attribute.name}" on <${el.tagName.toLowerCase()}>.`, `${allowedAttributes.length ? `Allowed attributes are: ${allowedAttributes.join(', ')}` : 'To set the value, use HTML within the element.'}`]);
5897 }
5898 });
5899 };
5900
5901 const SHOW_CLASS_TIMEOUT = 10;
5902
5903 /**
5904 * Open popup, add necessary classes and styles, fix scrollbar
5905 *
5906 * @param {SweetAlertOptions} params
5907 */
5908 const openPopup = params => {
5909 var _globalState$eventEmi, _globalState$eventEmi2;
5910 const container = getContainer();
5911 const popup = getPopup();
5912 if (!container || !popup) {
5913 return;
5914 }
5915 if (typeof params.willOpen === 'function') {
5916 params.willOpen(popup);
5917 }
5918 (_globalState$eventEmi = globalState.eventEmitter) === null || _globalState$eventEmi === void 0 || _globalState$eventEmi.emit('willOpen', popup);
5919 const bodyStyles = window.getComputedStyle(document.body);
5920 const initialBodyOverflow = bodyStyles.overflowY;
5921 addClasses(container, popup, params);
5922
5923 // scrolling is 'hidden' until animation is done, after that 'auto'
5924 setTimeout(() => {
5925 setScrollingVisibility(container, popup);
5926 }, SHOW_CLASS_TIMEOUT);
5927 if (isModal()) {
5928 fixScrollContainer(container, params.scrollbarPadding !== undefined ? params.scrollbarPadding : false, initialBodyOverflow);
5929 setAriaHidden();
5930 }
5931
5932 // https://github.com/sweetalert2/sweetalert2/issues/2923
5933 if (isIOS && params.backdrop === false && popup.scrollHeight > container.clientHeight) {
5934 // remove pointer-events: none from container, it breaks scrolling tall popups in iOS
5935 container.style.pointerEvents = 'auto';
5936 }
5937 if (!isToast() && !globalState.previousActiveElement) {
5938 globalState.previousActiveElement = document.activeElement;
5939 }
5940 if (typeof params.didOpen === 'function') {
5941 const didOpen = params.didOpen;
5942 setTimeout(() => didOpen(popup));
5943 }
5944 (_globalState$eventEmi2 = globalState.eventEmitter) === null || _globalState$eventEmi2 === void 0 || _globalState$eventEmi2.emit('didOpen', popup);
5945 };
5946
5947 /**
5948 * @param {Event} event
5949 */
5950 const swalOpenAnimationFinished = event => {
5951 const popup = getPopup();
5952 if (!popup || event.target !== popup) {
5953 return;
5954 }
5955 const container = getContainer();
5956 if (!container) {
5957 return;
5958 }
5959 popup.removeEventListener('animationend', swalOpenAnimationFinished);
5960 popup.removeEventListener('transitionend', swalOpenAnimationFinished);
5961 container.style.overflowY = 'auto';
5962
5963 // no-transition is added in init() in case one swal is opened right after another
5964 removeClass(container, swalClasses['no-transition']);
5965 };
5966
5967 /**
5968 * @param {HTMLElement} container
5969 * @param {HTMLElement} popup
5970 */
5971 const setScrollingVisibility = (container, popup) => {
5972 if (hasCssAnimation(popup)) {
5973 container.style.overflowY = 'hidden';
5974 popup.addEventListener('animationend', swalOpenAnimationFinished);
5975 popup.addEventListener('transitionend', swalOpenAnimationFinished);
5976 } else {
5977 container.style.overflowY = 'auto';
5978 }
5979 };
5980
5981 /**
5982 * @param {HTMLElement} container
5983 * @param {boolean} scrollbarPadding
5984 * @param {string} initialBodyOverflow
5985 */
5986 const fixScrollContainer = (container, scrollbarPadding, initialBodyOverflow) => {
5987 iOSfix();
5988 if (scrollbarPadding && initialBodyOverflow !== 'hidden') {
5989 replaceScrollbarWithPadding(initialBodyOverflow);
5990 }
5991
5992 // sweetalert2/issues/1247
5993 setTimeout(() => {
5994 container.scrollTop = 0;
5995 });
5996 };
5997
5998 /**
5999 * @param {HTMLElement} container
6000 * @param {HTMLElement} popup
6001 * @param {SweetAlertOptions} params
6002 */
6003 const addClasses = (container, popup, params) => {
6004 var _params$showClass;
6005 if ((_params$showClass = params.showClass) !== null && _params$showClass !== void 0 && _params$showClass.backdrop) {
6006 addClass(container, params.showClass.backdrop);
6007 }
6008 if (params.animation) {
6009 // this workaround with opacity is needed for https://github.com/sweetalert2/sweetalert2/issues/2059
6010 popup.style.setProperty('opacity', '0', 'important');
6011 show(popup, 'grid');
6012 setTimeout(() => {
6013 var _params$showClass2;
6014 // Animate popup right after showing it
6015 if ((_params$showClass2 = params.showClass) !== null && _params$showClass2 !== void 0 && _params$showClass2.popup) {
6016 addClass(popup, params.showClass.popup);
6017 }
6018 // and remove the opacity workaround
6019 popup.style.removeProperty('opacity');
6020 }, SHOW_CLASS_TIMEOUT); // 10ms in order to fix #2062
6021 } else {
6022 show(popup, 'grid');
6023 }
6024 addClass([document.documentElement, document.body], swalClasses.shown);
6025 if (params.heightAuto && params.backdrop && !params.toast) {
6026 addClass([document.documentElement, document.body], swalClasses['height-auto']);
6027 }
6028 };
6029
6030 var defaultInputValidators = {
6031 /**
6032 * @param {string} string
6033 * @param {string} [validationMessage]
6034 * @returns {Promise<string | void>}
6035 */
6036 email: (string, validationMessage) => {
6037 return /^[a-zA-Z0-9.+_'-]+@[a-zA-Z0-9.-]+\.[a-zA-Z0-9-]+$/.test(string) ? Promise.resolve() : Promise.resolve(validationMessage || 'Invalid email address');
6038 },
6039 /**
6040 * @param {string} string
6041 * @param {string} [validationMessage]
6042 * @returns {Promise<string | void>}
6043 */
6044 url: (string, validationMessage) => {
6045 // taken from https://stackoverflow.com/a/3809435 with a small change from #1306 and #2013
6046 return /^https?:\/\/(www\.)?[-a-zA-Z0-9@:%._+~#=]{1,256}\.[a-z]{2,63}\b([-a-zA-Z0-9@:%_+.~#?&/=]*)$/.test(string) ? Promise.resolve() : Promise.resolve(validationMessage || 'Invalid URL');
6047 }
6048 };
6049
6050 /**
6051 * @param {SweetAlertOptions} params
6052 */
6053 function setDefaultInputValidators(params) {
6054 // Use default `inputValidator` for supported input types if not provided
6055 if (params.inputValidator) {
6056 return;
6057 }
6058 if (params.input === 'email') {
6059 params.inputValidator = defaultInputValidators['email'];
6060 }
6061 if (params.input === 'url') {
6062 params.inputValidator = defaultInputValidators['url'];
6063 }
6064 }
6065
6066 /**
6067 * @param {SweetAlertOptions} params
6068 */
6069 function validateCustomTargetElement(params) {
6070 // Determine if the custom target element is valid
6071 if (!params.target || typeof params.target === 'string' && !document.querySelector(params.target) || typeof params.target !== 'string' && !params.target.appendChild) {
6072 warn('Target parameter is not valid, defaulting to "body"');
6073 params.target = 'body';
6074 }
6075 }
6076
6077 /**
6078 * Set type, text and actions on popup
6079 *
6080 * @param {SweetAlertOptions} params
6081 */
6082 function setParameters(params) {
6083 setDefaultInputValidators(params);
6084
6085 // showLoaderOnConfirm && preConfirm
6086 if (params.showLoaderOnConfirm && !params.preConfirm) {
6087 warn('showLoaderOnConfirm is set to true, but preConfirm is not defined.\n' + 'showLoaderOnConfirm should be used together with preConfirm, see usage example:\n' + 'https://sweetalert2.github.io/#ajax-request');
6088 }
6089 validateCustomTargetElement(params);
6090
6091 // Replace newlines with <br> in title
6092 if (typeof params.title === 'string') {
6093 params.title = params.title.split('\n').join('<br />');
6094 }
6095 init(params);
6096 }
6097
6098 /** @type {SweetAlert} */
6099 let currentInstance;
6100 var _promise = /*#__PURE__*/new WeakMap();
6101 class SweetAlert {
6102 /**
6103 * @param {...(SweetAlertOptions | string)} args
6104 * @this {SweetAlert}
6105 */
6106 constructor(...args) {
6107 /**
6108 * @type {Promise<SweetAlertResult>}
6109 */
6110 _classPrivateFieldInitSpec(this, _promise, /** @type {Promise<SweetAlertResult>} */
6111 Promise.resolve({
6112 isConfirmed: false,
6113 isDenied: false,
6114 isDismissed: true
6115 }));
6116 // Prevent run in Node env
6117 if (typeof window === 'undefined') {
6118 return;
6119 }
6120 currentInstance = this;
6121
6122 // @ts-ignore
6123 const outerParams = Object.freeze(this.constructor.argsToParams(args));
6124
6125 /** @type {Readonly<SweetAlertOptions>} */
6126 this.params = outerParams;
6127
6128 /** @type {boolean} */
6129 this.isAwaitingPromise = false;
6130 _classPrivateFieldSet2(_promise, this, this._main(currentInstance.params));
6131 }
6132
6133 /**
6134 * @param {any} userParams
6135 * @param {any} mixinParams
6136 */
6137 _main(userParams, mixinParams = {}) {
6138 showWarningsForParams(Object.assign({}, mixinParams, userParams));
6139 if (globalState.currentInstance) {
6140 const swalPromiseResolve = privateMethods.swalPromiseResolve.get(globalState.currentInstance);
6141 const {
6142 isAwaitingPromise
6143 } = globalState.currentInstance;
6144 globalState.currentInstance._destroy();
6145 if (!isAwaitingPromise) {
6146 swalPromiseResolve({
6147 isDismissed: true
6148 });
6149 }
6150 if (isModal()) {
6151 unsetAriaHidden();
6152 }
6153 }
6154 globalState.currentInstance = currentInstance;
6155 const innerParams = prepareParams(userParams, mixinParams);
6156 setParameters(innerParams);
6157 Object.freeze(innerParams);
6158
6159 // clear the previous timer
6160 if (globalState.timeout) {
6161 globalState.timeout.stop();
6162 delete globalState.timeout;
6163 }
6164
6165 // clear the restore focus timeout
6166 clearTimeout(globalState.restoreFocusTimeout);
6167 const domCache = populateDomCache(currentInstance);
6168 render(currentInstance, innerParams);
6169 privateProps.innerParams.set(currentInstance, innerParams);
6170 return swalPromise(currentInstance, domCache, innerParams);
6171 }
6172
6173 // `catch` cannot be the name of a module export, so we define our thenable methods here instead
6174 /**
6175 * @param {any} onFulfilled
6176 */
6177 // oxlint-disable-next-line unicorn/no-thenable
6178 then(onFulfilled) {
6179 return _classPrivateFieldGet2(_promise, this).then(onFulfilled);
6180 }
6181
6182 /**
6183 * @param {any} onFinally
6184 */
6185 finally(onFinally) {
6186 return _classPrivateFieldGet2(_promise, this).finally(onFinally);
6187 }
6188 }
6189
6190 /**
6191 * @param {SweetAlert} instance
6192 * @param {DomCache} domCache
6193 * @param {SweetAlertOptions} innerParams
6194 * @returns {Promise<SweetAlertResult>}
6195 */
6196 const swalPromise = (instance, domCache, innerParams) => {
6197 return new Promise((resolve, reject) => {
6198 // functions to handle all closings/dismissals
6199 /**
6200 * @param {DismissReason} dismiss
6201 */
6202 const dismissWith = dismiss => {
6203 instance.close({
6204 isDismissed: true,
6205 dismiss,
6206 isConfirmed: false,
6207 isDenied: false
6208 });
6209 };
6210 privateMethods.swalPromiseResolve.set(instance, resolve);
6211 privateMethods.swalPromiseReject.set(instance, reject);
6212 domCache.confirmButton.onclick = () => {
6213 handleConfirmButtonClick(instance);
6214 };
6215 domCache.denyButton.onclick = () => {
6216 handleDenyButtonClick(instance);
6217 };
6218 domCache.cancelButton.onclick = () => {
6219 handleCancelButtonClick(instance, dismissWith);
6220 };
6221 domCache.closeButton.onclick = () => {
6222 dismissWith(DismissReason.close);
6223 };
6224 handlePopupClick(innerParams, domCache, dismissWith);
6225 addKeydownHandler(globalState, innerParams, dismissWith);
6226 handleInputOptionsAndValue(instance, innerParams);
6227 openPopup(innerParams);
6228 setupTimer(globalState, innerParams, dismissWith);
6229 initFocus(domCache, innerParams);
6230
6231 // Scroll container to top on open (#1247, #1946)
6232 setTimeout(() => {
6233 domCache.container.scrollTop = 0;
6234 });
6235 });
6236 };
6237
6238 /**
6239 * @param {SweetAlertOptions} userParams
6240 * @param {SweetAlertOptions} mixinParams
6241 * @returns {SweetAlertOptions}
6242 */
6243 const prepareParams = (userParams, mixinParams) => {
6244 const templateParams = getTemplateParams(userParams);
6245 const params = Object.assign({}, defaultParams, mixinParams, templateParams, userParams); // precedence is described in #2131
6246 params.showClass = Object.assign({}, defaultParams.showClass, params.showClass);
6247 params.hideClass = Object.assign({}, defaultParams.hideClass, params.hideClass);
6248 if (params.animation === false) {
6249 params.showClass = {
6250 backdrop: 'swal2-noanimation'
6251 };
6252 params.hideClass = {};
6253 }
6254 return params;
6255 };
6256
6257 /**
6258 * @param {SweetAlert} instance
6259 * @returns {DomCache}
6260 */
6261 const populateDomCache = instance => {
6262 const domCache = /** @type {DomCache} */{
6263 popup: (/** @type {HTMLElement} */getPopup()),
6264 container: (/** @type {HTMLElement} */getContainer()),
6265 actions: (/** @type {HTMLElement} */getActions()),
6266 confirmButton: (/** @type {HTMLElement} */getConfirmButton()),
6267 denyButton: (/** @type {HTMLElement} */getDenyButton()),
6268 cancelButton: (/** @type {HTMLElement} */getCancelButton()),
6269 loader: (/** @type {HTMLElement} */getLoader()),
6270 closeButton: (/** @type {HTMLElement} */getCloseButton()),
6271 validationMessage: (/** @type {HTMLElement} */getValidationMessage()),
6272 progressSteps: (/** @type {HTMLElement} */getProgressSteps())
6273 };
6274 privateProps.domCache.set(instance, domCache);
6275 return domCache;
6276 };
6277
6278 /**
6279 * @param {GlobalState} globalState
6280 * @param {SweetAlertOptions} innerParams
6281 * @param {(dismiss: DismissReason) => void} dismissWith
6282 */
6283 const setupTimer = (globalState, innerParams, dismissWith) => {
6284 const timerProgressBar = getTimerProgressBar();
6285 hide(timerProgressBar);
6286 if (innerParams.timer) {
6287 globalState.timeout = new Timer(() => {
6288 dismissWith('timer');
6289 delete globalState.timeout;
6290 }, innerParams.timer);
6291 if (innerParams.timerProgressBar && timerProgressBar) {
6292 show(timerProgressBar);
6293 applyCustomClass(timerProgressBar, innerParams, 'timerProgressBar');
6294 setTimeout(() => {
6295 if (globalState.timeout && globalState.timeout.running) {
6296 // timer can be already stopped or unset at this point
6297 animateTimerProgressBar(/** @type {number} */innerParams.timer);
6298 }
6299 });
6300 }
6301 }
6302 };
6303
6304 /**
6305 * Initialize focus in the popup:
6306 *
6307 * 1. If `toast` is `true`, don't steal focus from the document.
6308 * 2. Else if there is an [autofocus] element, focus it.
6309 * 3. Else if `focusConfirm` is `true` and confirm button is visible, focus it.
6310 * 4. Else if `focusDeny` is `true` and deny button is visible, focus it.
6311 * 5. Else if `focusCancel` is `true` and cancel button is visible, focus it.
6312 * 6. Else focus the first focusable element in a popup (if any).
6313 *
6314 * @param {DomCache} domCache
6315 * @param {SweetAlertOptions} innerParams
6316 */
6317 const initFocus = (domCache, innerParams) => {
6318 if (innerParams.toast) {
6319 return;
6320 }
6321 // TODO: this is dumb, remove `allowEnterKey` param in the next major version
6322 if (!callIfFunction(innerParams.allowEnterKey)) {
6323 warnAboutDeprecation('allowEnterKey', 'preConfirm: () => false');
6324 domCache.popup.focus();
6325 return;
6326 }
6327 if (focusAutofocus(domCache)) {
6328 return;
6329 }
6330 if (focusButton(domCache, innerParams)) {
6331 return;
6332 }
6333 setFocus(-1, 1);
6334 };
6335
6336 /**
6337 * @param {DomCache} domCache
6338 * @returns {boolean}
6339 */
6340 const focusAutofocus = domCache => {
6341 const autofocusElements = Array.from(domCache.popup.querySelectorAll('[autofocus]'));
6342 for (const autofocusElement of autofocusElements) {
6343 if (autofocusElement instanceof HTMLElement && isVisible$1(autofocusElement)) {
6344 autofocusElement.focus();
6345 return true;
6346 }
6347 }
6348 return false;
6349 };
6350
6351 /**
6352 * @param {DomCache} domCache
6353 * @param {SweetAlertOptions} innerParams
6354 * @returns {boolean}
6355 */
6356 const focusButton = (domCache, innerParams) => {
6357 if (innerParams.focusDeny && isVisible$1(domCache.denyButton)) {
6358 domCache.denyButton.focus();
6359 return true;
6360 }
6361 if (innerParams.focusCancel && isVisible$1(domCache.cancelButton)) {
6362 domCache.cancelButton.focus();
6363 return true;
6364 }
6365 if (innerParams.focusConfirm && isVisible$1(domCache.confirmButton)) {
6366 domCache.confirmButton.focus();
6367 return true;
6368 }
6369 return false;
6370 };
6371
6372 // Assign instance methods from src/instanceMethods/*.js to prototype
6373 SweetAlert.prototype.disableButtons = disableButtons;
6374 SweetAlert.prototype.enableButtons = enableButtons;
6375 SweetAlert.prototype.getInput = getInput;
6376 SweetAlert.prototype.disableInput = disableInput;
6377 SweetAlert.prototype.enableInput = enableInput;
6378 SweetAlert.prototype.hideLoading = hideLoading;
6379 SweetAlert.prototype.disableLoading = hideLoading;
6380 SweetAlert.prototype.showValidationMessage = showValidationMessage;
6381 SweetAlert.prototype.resetValidationMessage = resetValidationMessage;
6382 SweetAlert.prototype.close = close;
6383 SweetAlert.prototype.closePopup = close;
6384 SweetAlert.prototype.closeModal = close;
6385 SweetAlert.prototype.closeToast = close;
6386 SweetAlert.prototype.rejectPromise = rejectPromise;
6387 SweetAlert.prototype.update = update;
6388 SweetAlert.prototype._destroy = _destroy;
6389
6390 // Assign static methods from src/staticMethods/*.js to constructor
6391 Object.assign(SweetAlert, staticMethods);
6392
6393 // Proxy to instance methods to constructor, for now, for backwards compatibility
6394 Object.keys(instanceMethods).forEach(key => {
6395 /**
6396 * @param {...(SweetAlertOptions | string | undefined)} args
6397 * @returns {SweetAlertResult | Promise<SweetAlertResult> | undefined}
6398 */
6399 // @ts-ignore: Dynamic property assignment for backwards compatibility
6400 SweetAlert[key] = function (...args) {
6401 // @ts-ignore
6402 if (currentInstance && currentInstance[key]) {
6403 // @ts-ignore
6404 return currentInstance[key](...args);
6405 }
6406 return undefined;
6407 };
6408 });
6409 SweetAlert.DismissReason = DismissReason;
6410 SweetAlert.version = '11.26.25';
6411
6412 const Swal = SweetAlert;
6413 // @ts-ignore
6414 Swal.default = Swal;
6415
6416 return Swal;
6417
6418 }));
6419 if (typeof this !== 'undefined' && this.Sweetalert2){this.swal = this.sweetAlert = this.Swal = this.SweetAlert = this.Sweetalert2}
6420 "undefined"!=typeof document&&function(e,t){var n=e.createElement("style");if(e.getElementsByTagName("head")[0].appendChild(n),n.styleSheet)n.styleSheet.disabled||(n.styleSheet.cssText=t);else try{n.innerHTML=t}catch(e){n.innerText=t}}(document,":root{--swal2-outline: 0 0 0 3px rgba(100, 150, 200, 0.5);--swal2-container-padding: 0.625em;--swal2-backdrop: rgba(0, 0, 0, 0.4);--swal2-backdrop-transition: background-color 0.15s;--swal2-width: 32em;--swal2-padding: 0 0 1.25em;--swal2-border: none;--swal2-border-radius: 0.3125rem;--swal2-background: white;--swal2-color: #545454;--swal2-show-animation: swal2-show 0.3s;--swal2-hide-animation: swal2-hide 0.15s forwards;--swal2-icon-zoom: 1;--swal2-title-padding: 0.8em 1em 0;--swal2-html-container-padding: 1em 1.6em 0.3em;--swal2-input-border: 1px solid #d9d9d9;--swal2-input-border-radius: 0.1875em;--swal2-input-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.06), 0 0 0 3px transparent;--swal2-input-background: transparent;--swal2-input-transition: border-color 0.2s, box-shadow 0.2s;--swal2-input-hover-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.06), 0 0 0 3px transparent;--swal2-input-focus-border: 1px solid #b4dbed;--swal2-input-focus-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.06), 0 0 0 3px rgba(100, 150, 200, 0.5);--swal2-progress-step-background: #add8e6;--swal2-validation-message-background: #f0f0f0;--swal2-validation-message-color: #666;--swal2-footer-border-color: #eee;--swal2-footer-background: transparent;--swal2-footer-color: inherit;--swal2-timer-progress-bar-background: rgba(0, 0, 0, 0.3);--swal2-close-button-position: initial;--swal2-close-button-inset: auto;--swal2-close-button-font-size: 2.5em;--swal2-close-button-color: #ccc;--swal2-close-button-transition: color 0.2s, box-shadow 0.2s;--swal2-close-button-outline: initial;--swal2-close-button-box-shadow: inset 0 0 0 3px transparent;--swal2-close-button-focus-box-shadow: inset var(--swal2-outline);--swal2-close-button-hover-transform: none;--swal2-actions-justify-content: center;--swal2-actions-width: auto;--swal2-actions-margin: 1.25em auto 0;--swal2-actions-padding: 0;--swal2-actions-border-radius: 0;--swal2-actions-background: transparent;--swal2-action-button-transition: background-color 0.2s, box-shadow 0.2s;--swal2-action-button-hover: black 10%;--swal2-action-button-active: black 10%;--swal2-confirm-button-box-shadow: none;--swal2-confirm-button-border-radius: 0.25em;--swal2-confirm-button-background-color: #7066e0;--swal2-confirm-button-color: #fff;--swal2-deny-button-box-shadow: none;--swal2-deny-button-border-radius: 0.25em;--swal2-deny-button-background-color: #dc3741;--swal2-deny-button-color: #fff;--swal2-cancel-button-box-shadow: none;--swal2-cancel-button-border-radius: 0.25em;--swal2-cancel-button-background-color: #6e7881;--swal2-cancel-button-color: #fff;--swal2-toast-show-animation: swal2-toast-show 0.5s;--swal2-toast-hide-animation: swal2-toast-hide 0.1s forwards;--swal2-toast-border: none;--swal2-toast-box-shadow: 0 0 1px hsl(0deg 0% 0% / 0.075), 0 1px 2px hsl(0deg 0% 0% / 0.075), 1px 2px 4px hsl(0deg 0% 0% / 0.075), 1px 3px 8px hsl(0deg 0% 0% / 0.075), 2px 4px 16px hsl(0deg 0% 0% / 0.075)}[data-swal2-theme=dark]{--swal2-dark-theme-black: #19191a;--swal2-dark-theme-white: #e1e1e1;--swal2-background: var(--swal2-dark-theme-black);--swal2-color: var(--swal2-dark-theme-white);--swal2-footer-border-color: #555;--swal2-input-background: color-mix(in srgb, var(--swal2-dark-theme-black), var(--swal2-dark-theme-white) 10%);--swal2-validation-message-background: color-mix( in srgb, var(--swal2-dark-theme-black), var(--swal2-dark-theme-white) 10% );--swal2-validation-message-color: var(--swal2-dark-theme-white);--swal2-timer-progress-bar-background: rgba(255, 255, 255, 0.7)}@media(prefers-color-scheme: dark){[data-swal2-theme=auto]{--swal2-dark-theme-black: #19191a;--swal2-dark-theme-white: #e1e1e1;--swal2-background: var(--swal2-dark-theme-black);--swal2-color: var(--swal2-dark-theme-white);--swal2-footer-border-color: #555;--swal2-input-background: color-mix(in srgb, var(--swal2-dark-theme-black), var(--swal2-dark-theme-white) 10%);--swal2-validation-message-background: color-mix( in srgb, var(--swal2-dark-theme-black), var(--swal2-dark-theme-white) 10% );--swal2-validation-message-color: var(--swal2-dark-theme-white);--swal2-timer-progress-bar-background: rgba(255, 255, 255, 0.7)}}body.swal2-shown:not(.swal2-no-backdrop,.swal2-toast-shown){overflow:hidden}body.swal2-height-auto{height:auto !important}body.swal2-no-backdrop .swal2-container{background-color:rgba(0,0,0,0) !important;pointer-events:none}body.swal2-no-backdrop .swal2-container .swal2-popup{pointer-events:auto}body.swal2-no-backdrop .swal2-container .swal2-modal{box-shadow:0 0 10px var(--swal2-backdrop)}body.swal2-toast-shown .swal2-container{box-sizing:border-box;width:360px;max-width:100%;background-color:rgba(0,0,0,0);pointer-events:none}body.swal2-toast-shown .swal2-container.swal2-top{inset:0 auto auto 50%;transform:translateX(-50%)}body.swal2-toast-shown .swal2-container.swal2-top-end,body.swal2-toast-shown .swal2-container.swal2-top-right{inset:0 0 auto auto}body.swal2-toast-shown .swal2-container.swal2-top-start,body.swal2-toast-shown .swal2-container.swal2-top-left{inset:0 auto auto 0}body.swal2-toast-shown .swal2-container.swal2-center-start,body.swal2-toast-shown .swal2-container.swal2-center-left{inset:50% auto auto 0;transform:translateY(-50%)}body.swal2-toast-shown .swal2-container.swal2-center{inset:50% auto auto 50%;transform:translate(-50%, -50%)}body.swal2-toast-shown .swal2-container.swal2-center-end,body.swal2-toast-shown .swal2-container.swal2-center-right{inset:50% 0 auto auto;transform:translateY(-50%)}body.swal2-toast-shown .swal2-container.swal2-bottom-start,body.swal2-toast-shown .swal2-container.swal2-bottom-left{inset:auto auto 0 0}body.swal2-toast-shown .swal2-container.swal2-bottom{inset:auto auto 0 50%;transform:translateX(-50%)}body.swal2-toast-shown .swal2-container.swal2-bottom-end,body.swal2-toast-shown .swal2-container.swal2-bottom-right{inset:auto 0 0 auto}@media print{body.swal2-shown:not(.swal2-no-backdrop,.swal2-toast-shown){overflow-y:scroll !important}body.swal2-shown:not(.swal2-no-backdrop,.swal2-toast-shown)>[aria-hidden=true]{display:none}body.swal2-shown:not(.swal2-no-backdrop,.swal2-toast-shown) .swal2-container{position:static !important}}div:where(.swal2-container){display:grid;position:fixed;z-index:1060;inset:0;box-sizing:border-box;grid-template-areas:\"top-start top top-end\" \"center-start center center-end\" \"bottom-start bottom-center bottom-end\";grid-template-rows:minmax(min-content, auto) minmax(min-content, auto) minmax(min-content, auto);height:100%;padding:var(--swal2-container-padding);overflow-x:hidden;transition:var(--swal2-backdrop-transition);-webkit-overflow-scrolling:touch}div:where(.swal2-container).swal2-backdrop-show,div:where(.swal2-container).swal2-noanimation{background:var(--swal2-backdrop)}div:where(.swal2-container).swal2-backdrop-hide{background:rgba(0,0,0,0) !important}div:where(.swal2-container).swal2-top-start,div:where(.swal2-container).swal2-center-start,div:where(.swal2-container).swal2-bottom-start{grid-template-columns:minmax(0, 1fr) auto auto}div:where(.swal2-container).swal2-top,div:where(.swal2-container).swal2-center,div:where(.swal2-container).swal2-bottom{grid-template-columns:auto minmax(0, 1fr) auto}div:where(.swal2-container).swal2-top-end,div:where(.swal2-container).swal2-center-end,div:where(.swal2-container).swal2-bottom-end{grid-template-columns:auto auto minmax(0, 1fr)}div:where(.swal2-container).swal2-top-start>.swal2-popup{align-self:start}div:where(.swal2-container).swal2-top>.swal2-popup{grid-column:2;place-self:start center}div:where(.swal2-container).swal2-top-end>.swal2-popup,div:where(.swal2-container).swal2-top-right>.swal2-popup{grid-column:3;place-self:start end}div:where(.swal2-container).swal2-center-start>.swal2-popup,div:where(.swal2-container).swal2-center-left>.swal2-popup{grid-row:2;align-self:center}div:where(.swal2-container).swal2-center>.swal2-popup{grid-column:2;grid-row:2;place-self:center center}div:where(.swal2-container).swal2-center-end>.swal2-popup,div:where(.swal2-container).swal2-center-right>.swal2-popup{grid-column:3;grid-row:2;place-self:center end}div:where(.swal2-container).swal2-bottom-start>.swal2-popup,div:where(.swal2-container).swal2-bottom-left>.swal2-popup{grid-column:1;grid-row:3;align-self:end}div:where(.swal2-container).swal2-bottom>.swal2-popup{grid-column:2;grid-row:3;place-self:end center}div:where(.swal2-container).swal2-bottom-end>.swal2-popup,div:where(.swal2-container).swal2-bottom-right>.swal2-popup{grid-column:3;grid-row:3;place-self:end end}div:where(.swal2-container).swal2-grow-row>.swal2-popup,div:where(.swal2-container).swal2-grow-fullscreen>.swal2-popup{grid-column:1/4;width:100%}div:where(.swal2-container).swal2-grow-column>.swal2-popup,div:where(.swal2-container).swal2-grow-fullscreen>.swal2-popup{grid-row:1/4;align-self:stretch}div:where(.swal2-container).swal2-no-transition{transition:none !important}div:where(.swal2-container)[popover]{width:auto;border:0}div:where(.swal2-container) div:where(.swal2-popup){display:none;position:relative;box-sizing:border-box;grid-template-columns:minmax(0, 100%);width:var(--swal2-width);max-width:100%;padding:var(--swal2-padding);border:var(--swal2-border);border-radius:var(--swal2-border-radius);background:var(--swal2-background);color:var(--swal2-color);font-family:inherit;font-size:1rem}div:where(.swal2-container) div:where(.swal2-popup):focus{outline:none}div:where(.swal2-container) div:where(.swal2-popup).swal2-loading{overflow-y:hidden}div:where(.swal2-container) div:where(.swal2-popup).swal2-draggable{cursor:grab}div:where(.swal2-container) div:where(.swal2-popup).swal2-draggable div:where(.swal2-icon){cursor:grab}div:where(.swal2-container) div:where(.swal2-popup).swal2-dragging{cursor:grabbing}div:where(.swal2-container) div:where(.swal2-popup).swal2-dragging div:where(.swal2-icon){cursor:grabbing}div:where(.swal2-container) h2:where(.swal2-title){position:relative;max-width:100%;margin:0;padding:var(--swal2-title-padding);color:inherit;font-size:1.875em;font-weight:600;text-align:center;text-transform:none;overflow-wrap:break-word;cursor:initial}div:where(.swal2-container) div:where(.swal2-actions){display:flex;z-index:1;box-sizing:border-box;flex-wrap:wrap;align-items:center;justify-content:var(--swal2-actions-justify-content);width:var(--swal2-actions-width);margin:var(--swal2-actions-margin);padding:var(--swal2-actions-padding);border-radius:var(--swal2-actions-border-radius);background:var(--swal2-actions-background)}div:where(.swal2-container) div:where(.swal2-loader){display:none;align-items:center;justify-content:center;width:2.2em;height:2.2em;margin:0 1.875em;animation:swal2-rotate-loading 1.5s linear 0s infinite normal;border-width:.25em;border-style:solid;border-radius:100%;border-color:#2778c4 rgba(0,0,0,0) #2778c4 rgba(0,0,0,0)}div:where(.swal2-container) button:where(.swal2-styled){margin:.3125em;padding:.625em 1.1em;transition:var(--swal2-action-button-transition);border:none;box-shadow:0 0 0 3px rgba(0,0,0,0);font-weight:500}div:where(.swal2-container) button:where(.swal2-styled):not([disabled]){cursor:pointer}div:where(.swal2-container) button:where(.swal2-styled):where(.swal2-confirm){border-radius:var(--swal2-confirm-button-border-radius);background:initial;background-color:var(--swal2-confirm-button-background-color);box-shadow:var(--swal2-confirm-button-box-shadow);color:var(--swal2-confirm-button-color);font-size:1em}div:where(.swal2-container) button:where(.swal2-styled):where(.swal2-confirm):hover{background-color:color-mix(in srgb, var(--swal2-confirm-button-background-color), var(--swal2-action-button-hover))}div:where(.swal2-container) button:where(.swal2-styled):where(.swal2-confirm):active{background-color:color-mix(in srgb, var(--swal2-confirm-button-background-color), var(--swal2-action-button-active))}div:where(.swal2-container) button:where(.swal2-styled):where(.swal2-deny){border-radius:var(--swal2-deny-button-border-radius);background:initial;background-color:var(--swal2-deny-button-background-color);box-shadow:var(--swal2-deny-button-box-shadow);color:var(--swal2-deny-button-color);font-size:1em}div:where(.swal2-container) button:where(.swal2-styled):where(.swal2-deny):hover{background-color:color-mix(in srgb, var(--swal2-deny-button-background-color), var(--swal2-action-button-hover))}div:where(.swal2-container) button:where(.swal2-styled):where(.swal2-deny):active{background-color:color-mix(in srgb, var(--swal2-deny-button-background-color), var(--swal2-action-button-active))}div:where(.swal2-container) button:where(.swal2-styled):where(.swal2-cancel){border-radius:var(--swal2-cancel-button-border-radius);background:initial;background-color:var(--swal2-cancel-button-background-color);box-shadow:var(--swal2-cancel-button-box-shadow);color:var(--swal2-cancel-button-color);font-size:1em}div:where(.swal2-container) button:where(.swal2-styled):where(.swal2-cancel):hover{background-color:color-mix(in srgb, var(--swal2-cancel-button-background-color), var(--swal2-action-button-hover))}div:where(.swal2-container) button:where(.swal2-styled):where(.swal2-cancel):active{background-color:color-mix(in srgb, var(--swal2-cancel-button-background-color), var(--swal2-action-button-active))}div:where(.swal2-container) button:where(.swal2-styled):focus-visible{outline:none;box-shadow:var(--swal2-action-button-focus-box-shadow)}div:where(.swal2-container) button:where(.swal2-styled)[disabled]:not(.swal2-loading){opacity:.4}div:where(.swal2-container) button:where(.swal2-styled)::-moz-focus-inner{border:0}div:where(.swal2-container) div:where(.swal2-footer){margin:1em 0 0;padding:1em 1em 0;border-top:1px solid var(--swal2-footer-border-color);background:var(--swal2-footer-background);color:var(--swal2-footer-color);font-size:1em;text-align:center;cursor:initial}div:where(.swal2-container) .swal2-timer-progress-bar-container{position:absolute;right:0;bottom:0;left:0;grid-column:auto !important;overflow:hidden;border-bottom-right-radius:var(--swal2-border-radius);border-bottom-left-radius:var(--swal2-border-radius)}div:where(.swal2-container) div:where(.swal2-timer-progress-bar){width:100%;height:.25em;background:var(--swal2-timer-progress-bar-background)}div:where(.swal2-container) img:where(.swal2-image){max-width:100%;margin:2em auto 1em;cursor:initial}div:where(.swal2-container) button:where(.swal2-close){position:var(--swal2-close-button-position);inset:var(--swal2-close-button-inset);z-index:2;align-items:center;justify-content:center;width:1.2em;height:1.2em;margin-top:0;margin-right:0;margin-bottom:-1.2em;padding:0;overflow:hidden;transition:var(--swal2-close-button-transition);border:none;border-radius:var(--swal2-border-radius);outline:var(--swal2-close-button-outline);background:rgba(0,0,0,0);color:var(--swal2-close-button-color);font-family:monospace;font-size:var(--swal2-close-button-font-size);cursor:pointer;justify-self:end}div:where(.swal2-container) button:where(.swal2-close):hover{transform:var(--swal2-close-button-hover-transform);background:rgba(0,0,0,0);color:#f27474}div:where(.swal2-container) button:where(.swal2-close):focus-visible{outline:none;box-shadow:var(--swal2-close-button-focus-box-shadow)}div:where(.swal2-container) button:where(.swal2-close)::-moz-focus-inner{border:0}div:where(.swal2-container) div:where(.swal2-html-container){z-index:1;justify-content:center;margin:0;padding:var(--swal2-html-container-padding);overflow:auto;color:inherit;font-size:1.125em;font-weight:normal;line-height:normal;text-align:center;overflow-wrap:break-word;word-break:break-word;cursor:initial}div:where(.swal2-container) input:where(.swal2-input),div:where(.swal2-container) input:where(.swal2-file),div:where(.swal2-container) textarea:where(.swal2-textarea),div:where(.swal2-container) select:where(.swal2-select),div:where(.swal2-container) div:where(.swal2-radio),div:where(.swal2-container) label:where(.swal2-checkbox){margin:1em 2em 3px}div:where(.swal2-container) input:where(.swal2-input),div:where(.swal2-container) input:where(.swal2-file),div:where(.swal2-container) textarea:where(.swal2-textarea){box-sizing:border-box;width:auto;transition:var(--swal2-input-transition);border:var(--swal2-input-border);border-radius:var(--swal2-input-border-radius);background:var(--swal2-input-background);box-shadow:var(--swal2-input-box-shadow);color:inherit;font-size:1.125em}div:where(.swal2-container) input:where(.swal2-input).swal2-inputerror,div:where(.swal2-container) input:where(.swal2-file).swal2-inputerror,div:where(.swal2-container) textarea:where(.swal2-textarea).swal2-inputerror{border-color:#f27474 !important;box-shadow:0 0 2px #f27474 !important}div:where(.swal2-container) input:where(.swal2-input):hover,div:where(.swal2-container) input:where(.swal2-file):hover,div:where(.swal2-container) textarea:where(.swal2-textarea):hover{box-shadow:var(--swal2-input-hover-box-shadow)}div:where(.swal2-container) input:where(.swal2-input):focus,div:where(.swal2-container) input:where(.swal2-file):focus,div:where(.swal2-container) textarea:where(.swal2-textarea):focus{border:var(--swal2-input-focus-border);outline:none;box-shadow:var(--swal2-input-focus-box-shadow)}div:where(.swal2-container) input:where(.swal2-input)::placeholder,div:where(.swal2-container) input:where(.swal2-file)::placeholder,div:where(.swal2-container) textarea:where(.swal2-textarea)::placeholder{color:#ccc}div:where(.swal2-container) .swal2-range{margin:1em 2em 3px;background:var(--swal2-background)}div:where(.swal2-container) .swal2-range input{width:80%}div:where(.swal2-container) .swal2-range output{width:20%;color:inherit;font-weight:600;text-align:center}div:where(.swal2-container) .swal2-range input,div:where(.swal2-container) .swal2-range output{height:2.625em;padding:0;font-size:1.125em;line-height:2.625em}div:where(.swal2-container) .swal2-input{height:2.625em;padding:0 .75em}div:where(.swal2-container) .swal2-file{width:75%;margin-right:auto;margin-left:auto;background:var(--swal2-input-background);font-size:1.125em}div:where(.swal2-container) .swal2-textarea{height:6.75em;padding:.75em}div:where(.swal2-container) .swal2-select{min-width:50%;max-width:100%;padding:.375em .625em;background:var(--swal2-input-background);color:inherit;font-size:1.125em}div:where(.swal2-container) .swal2-radio,div:where(.swal2-container) .swal2-checkbox{align-items:center;justify-content:center;background:var(--swal2-background);color:inherit}div:where(.swal2-container) .swal2-radio label,div:where(.swal2-container) .swal2-checkbox label{margin:0 .6em;font-size:1.125em}div:where(.swal2-container) .swal2-radio input,div:where(.swal2-container) .swal2-checkbox input{flex-shrink:0;margin:0 .4em}div:where(.swal2-container) label:where(.swal2-input-label){display:flex;justify-content:center;margin:1em auto 0}div:where(.swal2-container) div:where(.swal2-validation-message){align-items:center;justify-content:center;margin:1em 0 0;padding:.625em;overflow:hidden;background:var(--swal2-validation-message-background);color:var(--swal2-validation-message-color);font-size:1em;font-weight:300}div:where(.swal2-container) div:where(.swal2-validation-message)::before{content:\"!\";display:inline-block;width:1.5em;min-width:1.5em;height:1.5em;margin:0 .625em;border-radius:50%;background-color:#f27474;color:#fff;font-weight:600;line-height:1.5em;text-align:center}div:where(.swal2-container) .swal2-progress-steps{flex-wrap:wrap;align-items:center;max-width:100%;margin:1.25em auto;padding:0;background:rgba(0,0,0,0);font-weight:600}div:where(.swal2-container) .swal2-progress-steps li{display:inline-block;position:relative}div:where(.swal2-container) .swal2-progress-steps .swal2-progress-step{z-index:20;flex-shrink:0;width:2em;height:2em;border-radius:2em;background:#2778c4;color:#fff;line-height:2em;text-align:center}div:where(.swal2-container) .swal2-progress-steps .swal2-progress-step.swal2-active-progress-step{background:#2778c4}div:where(.swal2-container) .swal2-progress-steps .swal2-progress-step.swal2-active-progress-step~.swal2-progress-step{background:var(--swal2-progress-step-background);color:#fff}div:where(.swal2-container) .swal2-progress-steps .swal2-progress-step.swal2-active-progress-step~.swal2-progress-step-line{background:var(--swal2-progress-step-background)}div:where(.swal2-container) .swal2-progress-steps .swal2-progress-step-line{z-index:10;flex-shrink:0;width:2.5em;height:.4em;margin:0 -1px;background:#2778c4}div:where(.swal2-icon){position:relative;box-sizing:content-box;justify-content:center;width:5em;height:5em;margin:2.5em auto .6em;zoom:var(--swal2-icon-zoom);border:.25em solid rgba(0,0,0,0);border-radius:50%;border-color:#000;font-family:inherit;line-height:5em;cursor:default;user-select:none}div:where(.swal2-icon) .swal2-icon-content{display:flex;align-items:center;font-size:3.75em}div:where(.swal2-icon).swal2-error{border-color:#f27474;color:#f27474}div:where(.swal2-icon).swal2-error .swal2-x-mark{position:relative;flex-grow:1}div:where(.swal2-icon).swal2-error [class^=swal2-x-mark-line]{display:block;position:absolute;top:2.3125em;width:2.9375em;height:.3125em;border-radius:.125em;background-color:#f27474}div:where(.swal2-icon).swal2-error [class^=swal2-x-mark-line][class$=left]{left:1.0625em;transform:rotate(45deg)}div:where(.swal2-icon).swal2-error [class^=swal2-x-mark-line][class$=right]{right:1em;transform:rotate(-45deg)}div:where(.swal2-icon).swal2-error.swal2-icon-show{animation:swal2-animate-error-icon .5s}div:where(.swal2-icon).swal2-error.swal2-icon-show .swal2-x-mark{animation:swal2-animate-error-x-mark .5s}div:where(.swal2-icon).swal2-warning{border-color:#f8bb86;color:#f8bb86}div:where(.swal2-icon).swal2-warning.swal2-icon-show{animation:swal2-animate-error-icon .5s}div:where(.swal2-icon).swal2-warning.swal2-icon-show .swal2-icon-content{animation:swal2-animate-i-mark .5s}div:where(.swal2-icon).swal2-info{border-color:#3fc3ee;color:#3fc3ee}div:where(.swal2-icon).swal2-info.swal2-icon-show{animation:swal2-animate-error-icon .5s}div:where(.swal2-icon).swal2-info.swal2-icon-show .swal2-icon-content{animation:swal2-animate-i-mark .8s}div:where(.swal2-icon).swal2-question{border-color:#87adbd;color:#87adbd}div:where(.swal2-icon).swal2-question.swal2-icon-show{animation:swal2-animate-error-icon .5s}div:where(.swal2-icon).swal2-question.swal2-icon-show .swal2-icon-content{animation:swal2-animate-question-mark .8s}div:where(.swal2-icon).swal2-success{border-color:#a5dc86;color:#a5dc86}div:where(.swal2-icon).swal2-success [class^=swal2-success-circular-line]{position:absolute;width:3.75em;height:7.5em;border-radius:50%}div:where(.swal2-icon).swal2-success [class^=swal2-success-circular-line][class$=left]{top:-0.4375em;left:-2.0635em;transform:rotate(-45deg);transform-origin:3.75em 3.75em;border-radius:7.5em 0 0 7.5em}div:where(.swal2-icon).swal2-success [class^=swal2-success-circular-line][class$=right]{top:-0.6875em;left:1.875em;transform:rotate(-45deg);transform-origin:0 3.75em;border-radius:0 7.5em 7.5em 0}div:where(.swal2-icon).swal2-success .swal2-success-ring{position:absolute;z-index:2;top:-0.25em;left:-0.25em;box-sizing:content-box;width:100%;height:100%;border:.25em solid rgba(165,220,134,.3);border-radius:50%}div:where(.swal2-icon).swal2-success .swal2-success-fix{position:absolute;z-index:1;top:.5em;left:1.625em;width:.4375em;height:5.625em;transform:rotate(-45deg)}div:where(.swal2-icon).swal2-success [class^=swal2-success-line]{display:block;position:absolute;z-index:2;height:.3125em;border-radius:.125em;background-color:#a5dc86}div:where(.swal2-icon).swal2-success [class^=swal2-success-line][class$=tip]{top:2.875em;left:.8125em;width:1.5625em;transform:rotate(45deg)}div:where(.swal2-icon).swal2-success [class^=swal2-success-line][class$=long]{top:2.375em;right:.5em;width:2.9375em;transform:rotate(-45deg)}div:where(.swal2-icon).swal2-success.swal2-icon-show .swal2-success-line-tip{animation:swal2-animate-success-line-tip .75s}div:where(.swal2-icon).swal2-success.swal2-icon-show .swal2-success-line-long{animation:swal2-animate-success-line-long .75s}div:where(.swal2-icon).swal2-success.swal2-icon-show .swal2-success-circular-line-right{animation:swal2-rotate-success-circular-line 4.25s ease-in}[class^=swal2]{-webkit-tap-highlight-color:rgba(0,0,0,0)}.swal2-show{animation:var(--swal2-show-animation)}.swal2-hide{animation:var(--swal2-hide-animation)}.swal2-noanimation{transition:none}.swal2-scrollbar-measure{position:absolute;top:-9999px;width:50px;height:50px;overflow:scroll}.swal2-rtl .swal2-close{margin-right:initial;margin-left:0}.swal2-rtl .swal2-timer-progress-bar{right:0;left:auto}.swal2-toast{box-sizing:border-box;grid-column:1/4 !important;grid-row:1/4 !important;grid-template-columns:min-content auto min-content;padding:1em;overflow-y:hidden;border:var(--swal2-toast-border);background:var(--swal2-background);box-shadow:var(--swal2-toast-box-shadow);pointer-events:auto}.swal2-toast>*{grid-column:2}.swal2-toast h2:where(.swal2-title){margin:.5em 1em;padding:0;font-size:1em;text-align:initial}.swal2-toast .swal2-loading{justify-content:center}.swal2-toast input:where(.swal2-input){height:2em;margin:.5em;font-size:1em}.swal2-toast .swal2-validation-message{font-size:1em}.swal2-toast div:where(.swal2-footer){margin:.5em 0 0;padding:.5em 0 0;font-size:.8em}.swal2-toast button:where(.swal2-close){grid-column:3/3;grid-row:1/99;align-self:center;width:.8em;height:.8em;margin:0;font-size:2em}.swal2-toast div:where(.swal2-html-container){margin:.5em 1em;padding:0;overflow:initial;font-size:1em;text-align:initial}.swal2-toast div:where(.swal2-html-container):empty{padding:0}.swal2-toast .swal2-loader{grid-column:1;grid-row:1/99;align-self:center;width:2em;height:2em;margin:.25em}.swal2-toast .swal2-icon{grid-column:1;grid-row:1/99;align-self:center;width:2em;min-width:2em;height:2em;margin:0 .5em 0 0}.swal2-toast .swal2-icon .swal2-icon-content{display:flex;align-items:center;font-size:1.8em;font-weight:bold}.swal2-toast .swal2-icon.swal2-success .swal2-success-ring{width:2em;height:2em}.swal2-toast .swal2-icon.swal2-error [class^=swal2-x-mark-line]{top:.875em;width:1.375em}.swal2-toast .swal2-icon.swal2-error [class^=swal2-x-mark-line][class$=left]{left:.3125em}.swal2-toast .swal2-icon.swal2-error [class^=swal2-x-mark-line][class$=right]{right:.3125em}.swal2-toast div:where(.swal2-actions){justify-content:flex-start;height:auto;margin:0;margin-top:.5em;padding:0 .5em}.swal2-toast button:where(.swal2-styled){margin:.25em .5em;padding:.4em .6em;font-size:1em}.swal2-toast .swal2-success{border-color:#a5dc86}.swal2-toast .swal2-success [class^=swal2-success-circular-line]{position:absolute;width:1.6em;height:3em;border-radius:50%}.swal2-toast .swal2-success [class^=swal2-success-circular-line][class$=left]{top:-0.8em;left:-0.5em;transform:rotate(-45deg);transform-origin:2em 2em;border-radius:4em 0 0 4em}.swal2-toast .swal2-success [class^=swal2-success-circular-line][class$=right]{top:-0.25em;left:.9375em;transform-origin:0 1.5em;border-radius:0 4em 4em 0}.swal2-toast .swal2-success .swal2-success-ring{width:2em;height:2em}.swal2-toast .swal2-success .swal2-success-fix{top:0;left:.4375em;width:.4375em;height:2.6875em}.swal2-toast .swal2-success [class^=swal2-success-line]{height:.3125em}.swal2-toast .swal2-success [class^=swal2-success-line][class$=tip]{top:1.125em;left:.1875em;width:.75em}.swal2-toast .swal2-success [class^=swal2-success-line][class$=long]{top:.9375em;right:.1875em;width:1.375em}.swal2-toast .swal2-success.swal2-icon-show .swal2-success-line-tip{animation:swal2-toast-animate-success-line-tip .75s}.swal2-toast .swal2-success.swal2-icon-show .swal2-success-line-long{animation:swal2-toast-animate-success-line-long .75s}.swal2-toast.swal2-show{animation:var(--swal2-toast-show-animation)}.swal2-toast.swal2-hide{animation:var(--swal2-toast-hide-animation)}@keyframes swal2-show{0%{transform:translate3d(0, -50px, 0) scale(0.9);opacity:0}100%{transform:translate3d(0, 0, 0) scale(1);opacity:1}}@keyframes swal2-hide{0%{transform:translate3d(0, 0, 0) scale(1);opacity:1}100%{transform:translate3d(0, -50px, 0) scale(0.9);opacity:0}}@keyframes swal2-animate-success-line-tip{0%{top:1.1875em;left:.0625em;width:0}54%{top:1.0625em;left:.125em;width:0}70%{top:2.1875em;left:-0.375em;width:3.125em}84%{top:3em;left:1.3125em;width:1.0625em}100%{top:2.8125em;left:.8125em;width:1.5625em}}@keyframes swal2-animate-success-line-long{0%{top:3.375em;right:2.875em;width:0}65%{top:3.375em;right:2.875em;width:0}84%{top:2.1875em;right:0;width:3.4375em}100%{top:2.375em;right:.5em;width:2.9375em}}@keyframes swal2-rotate-success-circular-line{0%{transform:rotate(-45deg)}5%{transform:rotate(-45deg)}12%{transform:rotate(-405deg)}100%{transform:rotate(-405deg)}}@keyframes swal2-animate-error-x-mark{0%{margin-top:1.625em;transform:scale(0.4);opacity:0}50%{margin-top:1.625em;transform:scale(0.4);opacity:0}80%{margin-top:-0.375em;transform:scale(1.15)}100%{margin-top:0;transform:scale(1);opacity:1}}@keyframes swal2-animate-error-icon{0%{transform:rotateX(100deg);opacity:0}100%{transform:rotateX(0deg);opacity:1}}@keyframes swal2-rotate-loading{0%{transform:rotate(0deg)}100%{transform:rotate(360deg)}}@keyframes swal2-animate-question-mark{0%{transform:rotateY(-360deg)}100%{transform:rotateY(0)}}@keyframes swal2-animate-i-mark{0%{transform:rotateZ(45deg);opacity:0}25%{transform:rotateZ(-25deg);opacity:.4}50%{transform:rotateZ(15deg);opacity:.8}75%{transform:rotateZ(-5deg);opacity:1}100%{transform:rotateX(0);opacity:1}}@keyframes swal2-toast-show{0%{transform:translateY(-0.625em) rotateZ(2deg)}33%{transform:translateY(0) rotateZ(-2deg)}66%{transform:translateY(0.3125em) rotateZ(2deg)}100%{transform:translateY(0) rotateZ(0deg)}}@keyframes swal2-toast-hide{100%{transform:rotateZ(1deg);opacity:0}}@keyframes swal2-toast-animate-success-line-tip{0%{top:.5625em;left:.0625em;width:0}54%{top:.125em;left:.125em;width:0}70%{top:.625em;left:-0.25em;width:1.625em}84%{top:1.0625em;left:.75em;width:.5em}100%{top:1.125em;left:.1875em;width:.75em}}@keyframes swal2-toast-animate-success-line-long{0%{top:1.625em;right:1.375em;width:0}65%{top:1.25em;right:.9375em;width:0}84%{top:.9375em;right:0;width:1.125em}100%{top:.9375em;right:.1875em;width:1.375em}}");
6421
6422 /***/ },
6423
6424 /***/ "./node_modules/toastify-js/src/toastify.js"
6425 /*!**************************************************!*\
6426 !*** ./node_modules/toastify-js/src/toastify.js ***!
6427 \**************************************************/
6428 (module) {
6429
6430 /*!
6431 * Toastify js 1.12.0
6432 * https://github.com/apvarun/toastify-js
6433 * @license MIT licensed
6434 *
6435 * Copyright (C) 2018 Varun A P
6436 */
6437 (function(root, factory) {
6438 if ( true && module.exports) {
6439 module.exports = factory();
6440 } else {
6441 root.Toastify = factory();
6442 }
6443 })(this, function(global) {
6444 // Object initialization
6445 var Toastify = function(options) {
6446 // Returning a new init object
6447 return new Toastify.lib.init(options);
6448 },
6449 // Library version
6450 version = "1.12.0";
6451
6452 // Set the default global options
6453 Toastify.defaults = {
6454 oldestFirst: true,
6455 text: "Toastify is awesome!",
6456 node: undefined,
6457 duration: 3000,
6458 selector: undefined,
6459 callback: function () {
6460 },
6461 destination: undefined,
6462 newWindow: false,
6463 close: false,
6464 gravity: "toastify-top",
6465 positionLeft: false,
6466 position: '',
6467 backgroundColor: '',
6468 avatar: "",
6469 className: "",
6470 stopOnFocus: true,
6471 onClick: function () {
6472 },
6473 offset: {x: 0, y: 0},
6474 escapeMarkup: true,
6475 ariaLive: 'polite',
6476 style: {background: ''}
6477 };
6478
6479 // Defining the prototype of the object
6480 Toastify.lib = Toastify.prototype = {
6481 toastify: version,
6482
6483 constructor: Toastify,
6484
6485 // Initializing the object with required parameters
6486 init: function(options) {
6487 // Verifying and validating the input object
6488 if (!options) {
6489 options = {};
6490 }
6491
6492 // Creating the options object
6493 this.options = {};
6494
6495 this.toastElement = null;
6496
6497 // Validating the options
6498 this.options.text = options.text || Toastify.defaults.text; // Display message
6499 this.options.node = options.node || Toastify.defaults.node; // Display content as node
6500 this.options.duration = options.duration === 0 ? 0 : options.duration || Toastify.defaults.duration; // Display duration
6501 this.options.selector = options.selector || Toastify.defaults.selector; // Parent selector
6502 this.options.callback = options.callback || Toastify.defaults.callback; // Callback after display
6503 this.options.destination = options.destination || Toastify.defaults.destination; // On-click destination
6504 this.options.newWindow = options.newWindow || Toastify.defaults.newWindow; // Open destination in new window
6505 this.options.close = options.close || Toastify.defaults.close; // Show toast close icon
6506 this.options.gravity = options.gravity === "bottom" ? "toastify-bottom" : Toastify.defaults.gravity; // toast position - top or bottom
6507 this.options.positionLeft = options.positionLeft || Toastify.defaults.positionLeft; // toast position - left or right
6508 this.options.position = options.position || Toastify.defaults.position; // toast position - left or right
6509 this.options.backgroundColor = options.backgroundColor || Toastify.defaults.backgroundColor; // toast background color
6510 this.options.avatar = options.avatar || Toastify.defaults.avatar; // img element src - url or a path
6511 this.options.className = options.className || Toastify.defaults.className; // additional class names for the toast
6512 this.options.stopOnFocus = options.stopOnFocus === undefined ? Toastify.defaults.stopOnFocus : options.stopOnFocus; // stop timeout on focus
6513 this.options.onClick = options.onClick || Toastify.defaults.onClick; // Callback after click
6514 this.options.offset = options.offset || Toastify.defaults.offset; // toast offset
6515 this.options.escapeMarkup = options.escapeMarkup !== undefined ? options.escapeMarkup : Toastify.defaults.escapeMarkup;
6516 this.options.ariaLive = options.ariaLive || Toastify.defaults.ariaLive;
6517 this.options.style = options.style || Toastify.defaults.style;
6518 if(options.backgroundColor) {
6519 this.options.style.background = options.backgroundColor;
6520 }
6521
6522 // Returning the current object for chaining functions
6523 return this;
6524 },
6525
6526 // Building the DOM element
6527 buildToast: function() {
6528 // Validating if the options are defined
6529 if (!this.options) {
6530 throw "Toastify is not initialized";
6531 }
6532
6533 // Creating the DOM object
6534 var divElement = document.createElement("div");
6535 divElement.className = "toastify on " + this.options.className;
6536
6537 // Positioning toast to left or right or center
6538 if (!!this.options.position) {
6539 divElement.className += " toastify-" + this.options.position;
6540 } else {
6541 // To be depreciated in further versions
6542 if (this.options.positionLeft === true) {
6543 divElement.className += " toastify-left";
6544 console.warn('Property `positionLeft` will be depreciated in further versions. Please use `position` instead.')
6545 } else {
6546 // Default position
6547 divElement.className += " toastify-right";
6548 }
6549 }
6550
6551 // Assigning gravity of element
6552 divElement.className += " " + this.options.gravity;
6553
6554 if (this.options.backgroundColor) {
6555 // This is being deprecated in favor of using the style HTML DOM property
6556 console.warn('DEPRECATION NOTICE: "backgroundColor" is being deprecated. Please use the "style.background" property.');
6557 }
6558
6559 // Loop through our style object and apply styles to divElement
6560 for (var property in this.options.style) {
6561 divElement.style[property] = this.options.style[property];
6562 }
6563
6564 // Announce the toast to screen readers
6565 if (this.options.ariaLive) {
6566 divElement.setAttribute('aria-live', this.options.ariaLive)
6567 }
6568
6569 // Adding the toast message/node
6570 if (this.options.node && this.options.node.nodeType === Node.ELEMENT_NODE) {
6571 // If we have a valid node, we insert it
6572 divElement.appendChild(this.options.node)
6573 } else {
6574 if (this.options.escapeMarkup) {
6575 divElement.innerText = this.options.text;
6576 } else {
6577 divElement.innerHTML = this.options.text;
6578 }
6579
6580 if (this.options.avatar !== "") {
6581 var avatarElement = document.createElement("img");
6582 avatarElement.src = this.options.avatar;
6583
6584 avatarElement.className = "toastify-avatar";
6585
6586 if (this.options.position == "left" || this.options.positionLeft === true) {
6587 // Adding close icon on the left of content
6588 divElement.appendChild(avatarElement);
6589 } else {
6590 // Adding close icon on the right of content
6591 divElement.insertAdjacentElement("afterbegin", avatarElement);
6592 }
6593 }
6594 }
6595
6596 // Adding a close icon to the toast
6597 if (this.options.close === true) {
6598 // Create a span for close element
6599 var closeElement = document.createElement("button");
6600 closeElement.type = "button";
6601 closeElement.setAttribute("aria-label", "Close");
6602 closeElement.className = "toast-close";
6603 closeElement.innerHTML = "&#10006;";
6604
6605 // Triggering the removal of toast from DOM on close click
6606 closeElement.addEventListener(
6607 "click",
6608 function(event) {
6609 event.stopPropagation();
6610 this.removeElement(this.toastElement);
6611 window.clearTimeout(this.toastElement.timeOutValue);
6612 }.bind(this)
6613 );
6614
6615 //Calculating screen width
6616 var width = window.innerWidth > 0 ? window.innerWidth : screen.width;
6617
6618 // Adding the close icon to the toast element
6619 // Display on the right if screen width is less than or equal to 360px
6620 if ((this.options.position == "left" || this.options.positionLeft === true) && width > 360) {
6621 // Adding close icon on the left of content
6622 divElement.insertAdjacentElement("afterbegin", closeElement);
6623 } else {
6624 // Adding close icon on the right of content
6625 divElement.appendChild(closeElement);
6626 }
6627 }
6628
6629 // Clear timeout while toast is focused
6630 if (this.options.stopOnFocus && this.options.duration > 0) {
6631 var self = this;
6632 // stop countdown
6633 divElement.addEventListener(
6634 "mouseover",
6635 function(event) {
6636 window.clearTimeout(divElement.timeOutValue);
6637 }
6638 )
6639 // add back the timeout
6640 divElement.addEventListener(
6641 "mouseleave",
6642 function() {
6643 divElement.timeOutValue = window.setTimeout(
6644 function() {
6645 // Remove the toast from DOM
6646 self.removeElement(divElement);
6647 },
6648 self.options.duration
6649 )
6650 }
6651 )
6652 }
6653
6654 // Adding an on-click destination path
6655 if (typeof this.options.destination !== "undefined") {
6656 divElement.addEventListener(
6657 "click",
6658 function(event) {
6659 event.stopPropagation();
6660 if (this.options.newWindow === true) {
6661 window.open(this.options.destination, "_blank");
6662 } else {
6663 window.location = this.options.destination;
6664 }
6665 }.bind(this)
6666 );
6667 }
6668
6669 if (typeof this.options.onClick === "function" && typeof this.options.destination === "undefined") {
6670 divElement.addEventListener(
6671 "click",
6672 function(event) {
6673 event.stopPropagation();
6674 this.options.onClick();
6675 }.bind(this)
6676 );
6677 }
6678
6679 // Adding offset
6680 if(typeof this.options.offset === "object") {
6681
6682 var x = getAxisOffsetAValue("x", this.options);
6683 var y = getAxisOffsetAValue("y", this.options);
6684
6685 var xOffset = this.options.position == "left" ? x : "-" + x;
6686 var yOffset = this.options.gravity == "toastify-top" ? y : "-" + y;
6687
6688 divElement.style.transform = "translate(" + xOffset + "," + yOffset + ")";
6689
6690 }
6691
6692 // Returning the generated element
6693 return divElement;
6694 },
6695
6696 // Displaying the toast
6697 showToast: function() {
6698 // Creating the DOM object for the toast
6699 this.toastElement = this.buildToast();
6700
6701 // Getting the root element to with the toast needs to be added
6702 var rootElement;
6703 if (typeof this.options.selector === "string") {
6704 rootElement = document.getElementById(this.options.selector);
6705 } else if (this.options.selector instanceof HTMLElement || (typeof ShadowRoot !== 'undefined' && this.options.selector instanceof ShadowRoot)) {
6706 rootElement = this.options.selector;
6707 } else {
6708 rootElement = document.body;
6709 }
6710
6711 // Validating if root element is present in DOM
6712 if (!rootElement) {
6713 throw "Root element is not defined";
6714 }
6715
6716 // Adding the DOM element
6717 var elementToInsert = Toastify.defaults.oldestFirst ? rootElement.firstChild : rootElement.lastChild;
6718 rootElement.insertBefore(this.toastElement, elementToInsert);
6719
6720 // Repositioning the toasts in case multiple toasts are present
6721 Toastify.reposition();
6722
6723 if (this.options.duration > 0) {
6724 this.toastElement.timeOutValue = window.setTimeout(
6725 function() {
6726 // Remove the toast from DOM
6727 this.removeElement(this.toastElement);
6728 }.bind(this),
6729 this.options.duration
6730 ); // Binding `this` for function invocation
6731 }
6732
6733 // Supporting function chaining
6734 return this;
6735 },
6736
6737 hideToast: function() {
6738 if (this.toastElement.timeOutValue) {
6739 clearTimeout(this.toastElement.timeOutValue);
6740 }
6741 this.removeElement(this.toastElement);
6742 },
6743
6744 // Removing the element from the DOM
6745 removeElement: function(toastElement) {
6746 // Hiding the element
6747 // toastElement.classList.remove("on");
6748 toastElement.className = toastElement.className.replace(" on", "");
6749
6750 // Removing the element from DOM after transition end
6751 window.setTimeout(
6752 function() {
6753 // remove options node if any
6754 if (this.options.node && this.options.node.parentNode) {
6755 this.options.node.parentNode.removeChild(this.options.node);
6756 }
6757
6758 // Remove the element from the DOM, only when the parent node was not removed before.
6759 if (toastElement.parentNode) {
6760 toastElement.parentNode.removeChild(toastElement);
6761 }
6762
6763 // Calling the callback function
6764 this.options.callback.call(toastElement);
6765
6766 // Repositioning the toasts again
6767 Toastify.reposition();
6768 }.bind(this),
6769 400
6770 ); // Binding `this` for function invocation
6771 },
6772 };
6773
6774 // Positioning the toasts on the DOM
6775 Toastify.reposition = function() {
6776
6777 // Top margins with gravity
6778 var topLeftOffsetSize = {
6779 top: 15,
6780 bottom: 15,
6781 };
6782 var topRightOffsetSize = {
6783 top: 15,
6784 bottom: 15,
6785 };
6786 var offsetSize = {
6787 top: 15,
6788 bottom: 15,
6789 };
6790
6791 // Get all toast messages on the DOM
6792 var allToasts = document.getElementsByClassName("toastify");
6793
6794 var classUsed;
6795
6796 // Modifying the position of each toast element
6797 for (var i = 0; i < allToasts.length; i++) {
6798 // Getting the applied gravity
6799 if (containsClass(allToasts[i], "toastify-top") === true) {
6800 classUsed = "toastify-top";
6801 } else {
6802 classUsed = "toastify-bottom";
6803 }
6804
6805 var height = allToasts[i].offsetHeight;
6806 classUsed = classUsed.substr(9, classUsed.length-1)
6807 // Spacing between toasts
6808 var offset = 15;
6809
6810 var width = window.innerWidth > 0 ? window.innerWidth : screen.width;
6811
6812 // Show toast in center if screen with less than or equal to 360px
6813 if (width <= 360) {
6814 // Setting the position
6815 allToasts[i].style[classUsed] = offsetSize[classUsed] + "px";
6816
6817 offsetSize[classUsed] += height + offset;
6818 } else {
6819 if (containsClass(allToasts[i], "toastify-left") === true) {
6820 // Setting the position
6821 allToasts[i].style[classUsed] = topLeftOffsetSize[classUsed] + "px";
6822
6823 topLeftOffsetSize[classUsed] += height + offset;
6824 } else {
6825 // Setting the position
6826 allToasts[i].style[classUsed] = topRightOffsetSize[classUsed] + "px";
6827
6828 topRightOffsetSize[classUsed] += height + offset;
6829 }
6830 }
6831 }
6832
6833 // Supporting function chaining
6834 return this;
6835 };
6836
6837 // Helper function to get offset.
6838 function getAxisOffsetAValue(axis, options) {
6839
6840 if(options.offset[axis]) {
6841 if(isNaN(options.offset[axis])) {
6842 return options.offset[axis];
6843 }
6844 else {
6845 return options.offset[axis] + 'px';
6846 }
6847 }
6848
6849 return '0px';
6850
6851 }
6852
6853 function containsClass(elem, yourClass) {
6854 if (!elem || typeof yourClass !== "string") {
6855 return false;
6856 } else if (
6857 elem.className &&
6858 elem.className
6859 .trim()
6860 .split(/\s+/gi)
6861 .indexOf(yourClass) > -1
6862 ) {
6863 return true;
6864 } else {
6865 return false;
6866 }
6867 }
6868
6869 // Setting up the prototype for the init object
6870 Toastify.lib.init.prototype = Toastify.lib;
6871
6872 // Returning the Toastify function to be assigned to the window object/module
6873 return Toastify;
6874 });
6875
6876
6877 /***/ }
6878
6879 /******/ });
6880 /************************************************************************/
6881 /******/ // The module cache
6882 /******/ const __webpack_module_cache__ = {};
6883 /******/
6884 /******/ // The require function
6885 /******/ function __webpack_require__(moduleId) {
6886 /******/ // Check if module is in cache
6887 /******/ const cachedModule = __webpack_module_cache__[moduleId];
6888 /******/ if (cachedModule !== undefined) {
6889 /******/ return cachedModule.exports;
6890 /******/ }
6891 /******/ // Create a new module (and put it into the cache)
6892 /******/ const module = __webpack_module_cache__[moduleId] = {
6893 /******/ id: moduleId,
6894 /******/ // no module.loaded needed
6895 /******/ exports: {}
6896 /******/ };
6897 /******/
6898 /******/ // Execute the module function
6899 /******/ if (!(moduleId in __webpack_modules__)) {
6900 /******/ delete __webpack_module_cache__[moduleId];
6901 /******/ const e = new Error("Cannot find module '" + moduleId + "'");
6902 /******/ e.code = 'MODULE_NOT_FOUND';
6903 /******/ throw e;
6904 /******/ }
6905 /******/ __webpack_modules__[moduleId].call(module.exports, module, module.exports, __webpack_require__);
6906 /******/
6907 /******/ // Return the exports of the module
6908 /******/ return module.exports;
6909 /******/ }
6910 /******/
6911 /************************************************************************/
6912 /******/ /* webpack/runtime/compat get default export */
6913 /******/ (() => {
6914 /******/ // getDefaultExport function for compatibility with non-harmony modules
6915 /******/ __webpack_require__.n = (module) => {
6916 /******/ const getter = module && module.__esModule ?
6917 /******/ () => (module['default']) :
6918 /******/ () => (module);
6919 /******/ __webpack_require__.d(getter, { a: getter });
6920 /******/ return getter;
6921 /******/ };
6922 /******/ })();
6923 /******/
6924 /******/ /* webpack/runtime/define property getters */
6925 /******/ (() => {
6926 /******/ // define getter/value functions for harmony exports
6927 /******/ __webpack_require__.d = (exports, definition) => {
6928 /******/ if(Array.isArray(definition)) {
6929 /******/ var i = 0;
6930 /******/ while(i < definition.length) {
6931 /******/ var key = definition[i++];
6932 /******/ var binding = definition[i++];
6933 /******/ if(!__webpack_require__.o(exports, key)) {
6934 /******/ if(binding === 0) {
6935 /******/ Object.defineProperty(exports, key, { enumerable: true, value: definition[i++] });
6936 /******/ } else {
6937 /******/ Object.defineProperty(exports, key, { enumerable: true, get: binding });
6938 /******/ }
6939 /******/ } else if(binding === 0) { i++; }
6940 /******/ }
6941 /******/ } else {
6942 /******/ for(var key in definition) {
6943 /******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
6944 /******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
6945 /******/ }
6946 /******/ }
6947 /******/ }
6948 /******/ };
6949 /******/ })();
6950 /******/
6951 /******/ /* webpack/runtime/hasOwnProperty shorthand */
6952 /******/ (() => {
6953 /******/ __webpack_require__.o = (obj, prop) => (Object.hasOwn(obj, prop))
6954 /******/ })();
6955 /******/
6956 /******/ /* webpack/runtime/make namespace object */
6957 /******/ (() => {
6958 /******/ // define __esModule on exports
6959 /******/ __webpack_require__.r = (exports) => {
6960 /******/ if(Symbol.toStringTag) {
6961 /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
6962 /******/ }
6963 /******/ Object.defineProperty(exports, '__esModule', { value: true });
6964 /******/ };
6965 /******/ })();
6966 /******/
6967 /******/ /* webpack/runtime/nonce */
6968 /******/ (() => {
6969 /******/ __webpack_require__.nc = undefined;
6970 /******/ })();
6971 /******/
6972 /************************************************************************/
6973 let __webpack_exports__ = {};
6974 // This entry needs to be wrapped in an IIFE because it needs to be in strict mode.
6975 (() => {
6976 "use strict";
6977 /*!**********************************************!*\
6978 !*** ./assets/src/js/admin/admin-courses.js ***!
6979 \**********************************************/
6980 __webpack_require__.r(__webpack_exports__);
6981 /* harmony import */ var _courses_generate_with_ai_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./courses/generate-with-ai.js */ "./assets/src/js/admin/courses/generate-with-ai.js");
6982 /* harmony import */ var _courses_view_students_modal_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./courses/view-students-modal.js */ "./assets/src/js/admin/courses/view-students-modal.js");
6983 /**
6984 * Admin Courses JS
6985 *
6986 * @since 4.3.0
6987 * @version 1.0.1
6988 */
6989
6990
6991
6992 new _courses_generate_with_ai_js__WEBPACK_IMPORTED_MODULE_0__.CreateCourseViaAI();
6993 new _courses_view_students_modal_js__WEBPACK_IMPORTED_MODULE_1__.ViewStudentsModal();
6994 })();
6995
6996 /******/ })()
6997 ;
6998 //# sourceMappingURL=admin-courses.js.map