swal_rails 0.3.1.beta1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. checksums.yaml +7 -0
  2. data/Appraisals +43 -0
  3. data/CHANGELOG.md +73 -0
  4. data/LICENSE.txt +21 -0
  5. data/README.md +973 -0
  6. data/Rakefile +12 -0
  7. data/app/assets/javascripts/swal_rails/chain.js +38 -0
  8. data/app/assets/javascripts/swal_rails/confirm.js +93 -0
  9. data/app/assets/javascripts/swal_rails/controllers/swal_controller.js +54 -0
  10. data/app/assets/javascripts/swal_rails/flash.js +24 -0
  11. data/app/assets/javascripts/swal_rails/index.js +62 -0
  12. data/app/assets/stylesheets/swal_rails/index.css +5 -0
  13. data/config/importmap.rb +9 -0
  14. data/config/locales/swal_rails.en.yml +19 -0
  15. data/config/locales/swal_rails.fr.yml +19 -0
  16. data/gemfiles/rails_7_2.gemfile +25 -0
  17. data/gemfiles/rails_8_0.gemfile +25 -0
  18. data/gemfiles/rails_8_1.gemfile +25 -0
  19. data/gemfiles/rails_8_1_sprockets.gemfile +25 -0
  20. data/lib/generators/swal_rails/install/install_generator.rb +138 -0
  21. data/lib/generators/swal_rails/install/templates/initializer.rb +33 -0
  22. data/lib/generators/swal_rails/locales/locales_generator.rb +19 -0
  23. data/lib/swal_rails/configuration.rb +88 -0
  24. data/lib/swal_rails/engine.rb +55 -0
  25. data/lib/swal_rails/helpers.rb +96 -0
  26. data/lib/swal_rails/version.rb +6 -0
  27. data/lib/swal_rails.rb +25 -0
  28. data/vendor/javascript/sweetalert2/LICENSE +22 -0
  29. data/vendor/javascript/sweetalert2/sweetalert2.all.js +4814 -0
  30. data/vendor/javascript/sweetalert2/sweetalert2.all.min.js +6 -0
  31. data/vendor/javascript/sweetalert2/sweetalert2.esm.all.js +4805 -0
  32. data/vendor/javascript/sweetalert2/sweetalert2.esm.all.min.js +6 -0
  33. data/vendor/javascript/sweetalert2/sweetalert2.esm.js +4804 -0
  34. data/vendor/javascript/sweetalert2/sweetalert2.esm.min.js +5 -0
  35. data/vendor/javascript/sweetalert2/sweetalert2.js +4813 -0
  36. data/vendor/javascript/sweetalert2/sweetalert2.min.js +5 -0
  37. data/vendor/stylesheets/sweetalert2/LICENSE +22 -0
  38. data/vendor/stylesheets/sweetalert2/sweetalert2.css +1233 -0
  39. data/vendor/stylesheets/sweetalert2/sweetalert2.min.css +1 -0
  40. data/vendor/stylesheets/sweetalert2/themes/bootstrap-4.css +167 -0
  41. data/vendor/stylesheets/sweetalert2/themes/bootstrap-5.css +173 -0
  42. data/vendor/stylesheets/sweetalert2/themes/borderless.css +46 -0
  43. data/vendor/stylesheets/sweetalert2/themes/bulma.css +94 -0
  44. data/vendor/stylesheets/sweetalert2/themes/material-ui.css +183 -0
  45. data/vendor/stylesheets/sweetalert2/themes/minimal.css +40 -0
  46. metadata +124 -0
@@ -0,0 +1,4814 @@
1
+ /*!
2
+ * sweetalert2 v11.26.24
3
+ * Released under the MIT License.
4
+ */
5
+ (function (global, factory) {
6
+ typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
7
+ typeof define === 'function' && define.amd ? define(factory) :
8
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.Sweetalert2 = factory());
9
+ })(this, (function () { 'use strict';
10
+
11
+ function _assertClassBrand(e, t, n) {
12
+ if ("function" == typeof e ? e === t : e.has(t)) return arguments.length < 3 ? t : n;
13
+ throw new TypeError("Private element is not present on this object");
14
+ }
15
+ function _checkPrivateRedeclaration(e, t) {
16
+ if (t.has(e)) throw new TypeError("Cannot initialize the same private elements twice on an object");
17
+ }
18
+ function _classPrivateFieldGet2(s, a) {
19
+ return s.get(_assertClassBrand(s, a));
20
+ }
21
+ function _classPrivateFieldInitSpec(e, t, a) {
22
+ _checkPrivateRedeclaration(e, t), t.set(e, a);
23
+ }
24
+ function _classPrivateFieldSet2(s, a, r) {
25
+ return s.set(_assertClassBrand(s, a), r), r;
26
+ }
27
+
28
+ const RESTORE_FOCUS_TIMEOUT = 100;
29
+
30
+ /** @type {GlobalState} */
31
+ const globalState = {};
32
+ const focusPreviousActiveElement = () => {
33
+ if (globalState.previousActiveElement instanceof HTMLElement) {
34
+ globalState.previousActiveElement.focus();
35
+ globalState.previousActiveElement = null;
36
+ } else if (document.body) {
37
+ document.body.focus();
38
+ }
39
+ };
40
+
41
+ /**
42
+ * Restore previous active (focused) element
43
+ *
44
+ * @param {boolean} returnFocus
45
+ * @returns {Promise<void>}
46
+ */
47
+ const restoreActiveElement = returnFocus => {
48
+ return new Promise(resolve => {
49
+ if (!returnFocus) {
50
+ return resolve();
51
+ }
52
+ const x = window.scrollX;
53
+ const y = window.scrollY;
54
+ globalState.restoreFocusTimeout = setTimeout(() => {
55
+ focusPreviousActiveElement();
56
+ resolve();
57
+ }, RESTORE_FOCUS_TIMEOUT); // issues/900
58
+
59
+ window.scrollTo(x, y);
60
+ });
61
+ };
62
+
63
+ const swalPrefix = 'swal2-';
64
+
65
+ /**
66
+ * @typedef {Record<SwalClass, string>} SwalClasses
67
+ */
68
+
69
+ /**
70
+ * @typedef {'success' | 'warning' | 'info' | 'question' | 'error'} SwalIcon
71
+ * @typedef {Record<SwalIcon, string>} SwalIcons
72
+ */
73
+
74
+ /** @type {SwalClass[]} */
75
+ 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'];
76
+ const swalClasses = classNames.reduce((acc, className) => {
77
+ acc[className] = swalPrefix + className;
78
+ return acc;
79
+ }, /** @type {SwalClasses} */{});
80
+
81
+ /** @type {SwalIcon[]} */
82
+ const icons = ['success', 'warning', 'info', 'question', 'error'];
83
+ const iconTypes = icons.reduce((acc, icon) => {
84
+ acc[icon] = swalPrefix + icon;
85
+ return acc;
86
+ }, /** @type {SwalIcons} */{});
87
+
88
+ const consolePrefix = 'SweetAlert2:';
89
+
90
+ /**
91
+ * Capitalize the first letter of a string
92
+ *
93
+ * @param {string} str
94
+ * @returns {string}
95
+ */
96
+ const capitalizeFirstLetter = str => str.charAt(0).toUpperCase() + str.slice(1);
97
+
98
+ /**
99
+ * Standardize console warnings
100
+ *
101
+ * @param {string | string[]} message
102
+ */
103
+ const warn = message => {
104
+ console.warn(`${consolePrefix} ${typeof message === 'object' ? message.join(' ') : message}`);
105
+ };
106
+
107
+ /**
108
+ * Standardize console errors
109
+ *
110
+ * @param {string} message
111
+ */
112
+ const error = message => {
113
+ console.error(`${consolePrefix} ${message}`);
114
+ };
115
+
116
+ /**
117
+ * Private global state for `warnOnce`
118
+ *
119
+ * @type {string[]}
120
+ * @private
121
+ */
122
+ const previousWarnOnceMessages = [];
123
+
124
+ /**
125
+ * Show a console warning, but only if it hasn't already been shown
126
+ *
127
+ * @param {string} message
128
+ */
129
+ const warnOnce = message => {
130
+ if (!previousWarnOnceMessages.includes(message)) {
131
+ previousWarnOnceMessages.push(message);
132
+ warn(message);
133
+ }
134
+ };
135
+
136
+ /**
137
+ * Show a one-time console warning about deprecated params/methods
138
+ *
139
+ * @param {string} deprecatedParam
140
+ * @param {string?} useInstead
141
+ */
142
+ const warnAboutDeprecation = (deprecatedParam, useInstead = null) => {
143
+ warnOnce(`"${deprecatedParam}" is deprecated and will be removed in the next major release.${useInstead ? ` Use "${useInstead}" instead.` : ''}`);
144
+ };
145
+
146
+ /**
147
+ * If `arg` is a function, call it (with no arguments or context) and return the result.
148
+ * Otherwise, just pass the value through
149
+ *
150
+ * @param {(() => *) | *} arg
151
+ * @returns {*}
152
+ */
153
+ const callIfFunction = arg => typeof arg === 'function' ? arg() : arg;
154
+
155
+ /**
156
+ * @param {*} arg
157
+ * @returns {boolean}
158
+ */
159
+ const hasToPromiseFn = arg => arg && typeof arg.toPromise === 'function';
160
+
161
+ /**
162
+ * @param {*} arg
163
+ * @returns {Promise<*>}
164
+ */
165
+ const asPromise = arg => hasToPromiseFn(arg) ? arg.toPromise() : Promise.resolve(arg);
166
+
167
+ /**
168
+ * @param {*} arg
169
+ * @returns {boolean}
170
+ */
171
+ const isPromise = arg => arg && Promise.resolve(arg) === arg;
172
+
173
+ /**
174
+ * @returns {boolean}
175
+ */
176
+ const isFirefox = () => navigator.userAgent.includes('Firefox');
177
+
178
+ /**
179
+ * Gets the popup container which contains the backdrop and the popup itself.
180
+ *
181
+ * @returns {HTMLElement | null}
182
+ */
183
+ const getContainer = () => document.body.querySelector(`.${swalClasses.container}`);
184
+
185
+ /**
186
+ * @param {string} selectorString
187
+ * @returns {HTMLElement | null}
188
+ */
189
+ const elementBySelector = selectorString => {
190
+ const container = getContainer();
191
+ return container ? container.querySelector(selectorString) : null;
192
+ };
193
+
194
+ /**
195
+ * @param {string} className
196
+ * @returns {HTMLElement | null}
197
+ */
198
+ const elementByClass = className => {
199
+ return elementBySelector(`.${className}`);
200
+ };
201
+
202
+ /**
203
+ * @returns {HTMLElement | null}
204
+ */
205
+ const getPopup = () => elementByClass(swalClasses.popup);
206
+
207
+ /**
208
+ * @returns {HTMLElement | null}
209
+ */
210
+ const getIcon = () => elementByClass(swalClasses.icon);
211
+
212
+ /**
213
+ * @returns {HTMLElement | null}
214
+ */
215
+ const getIconContent = () => elementByClass(swalClasses['icon-content']);
216
+
217
+ /**
218
+ * @returns {HTMLElement | null}
219
+ */
220
+ const getTitle = () => elementByClass(swalClasses.title);
221
+
222
+ /**
223
+ * @returns {HTMLElement | null}
224
+ */
225
+ const getHtmlContainer = () => elementByClass(swalClasses['html-container']);
226
+
227
+ /**
228
+ * @returns {HTMLElement | null}
229
+ */
230
+ const getImage = () => elementByClass(swalClasses.image);
231
+
232
+ /**
233
+ * @returns {HTMLElement | null}
234
+ */
235
+ const getProgressSteps = () => elementByClass(swalClasses['progress-steps']);
236
+
237
+ /**
238
+ * @returns {HTMLElement | null}
239
+ */
240
+ const getValidationMessage = () => elementByClass(swalClasses['validation-message']);
241
+
242
+ /**
243
+ * @returns {HTMLButtonElement | null}
244
+ */
245
+ const getConfirmButton = () => (/** @type {HTMLButtonElement} */elementBySelector(`.${swalClasses.actions} .${swalClasses.confirm}`));
246
+
247
+ /**
248
+ * @returns {HTMLButtonElement | null}
249
+ */
250
+ const getCancelButton = () => (/** @type {HTMLButtonElement} */elementBySelector(`.${swalClasses.actions} .${swalClasses.cancel}`));
251
+
252
+ /**
253
+ * @returns {HTMLButtonElement | null}
254
+ */
255
+ const getDenyButton = () => (/** @type {HTMLButtonElement} */elementBySelector(`.${swalClasses.actions} .${swalClasses.deny}`));
256
+
257
+ /**
258
+ * @returns {HTMLElement | null}
259
+ */
260
+ const getInputLabel = () => elementByClass(swalClasses['input-label']);
261
+
262
+ /**
263
+ * @returns {HTMLElement | null}
264
+ */
265
+ const getLoader = () => elementBySelector(`.${swalClasses.loader}`);
266
+
267
+ /**
268
+ * @returns {HTMLElement | null}
269
+ */
270
+ const getActions = () => elementByClass(swalClasses.actions);
271
+
272
+ /**
273
+ * @returns {HTMLElement | null}
274
+ */
275
+ const getFooter = () => elementByClass(swalClasses.footer);
276
+
277
+ /**
278
+ * @returns {HTMLElement | null}
279
+ */
280
+ const getTimerProgressBar = () => elementByClass(swalClasses['timer-progress-bar']);
281
+
282
+ /**
283
+ * @returns {HTMLElement | null}
284
+ */
285
+ const getCloseButton = () => elementByClass(swalClasses.close);
286
+
287
+ // https://github.com/jkup/focusable/blob/master/index.js
288
+ const focusable = `
289
+ a[href],
290
+ area[href],
291
+ input:not([disabled]),
292
+ select:not([disabled]),
293
+ textarea:not([disabled]),
294
+ button:not([disabled]),
295
+ iframe,
296
+ object,
297
+ embed,
298
+ [tabindex="0"],
299
+ [contenteditable],
300
+ audio[controls],
301
+ video[controls],
302
+ summary
303
+ `;
304
+ /**
305
+ * @returns {HTMLElement[]}
306
+ */
307
+ const getFocusableElements = () => {
308
+ const popup = getPopup();
309
+ if (!popup) {
310
+ return [];
311
+ }
312
+ /** @type {NodeListOf<HTMLElement>} */
313
+ const focusableElementsWithTabindex = popup.querySelectorAll('[tabindex]:not([tabindex="-1"]):not([tabindex="0"])');
314
+ const focusableElementsWithTabindexSorted = Array.from(focusableElementsWithTabindex)
315
+ // sort according to tabindex
316
+ .sort((a, b) => {
317
+ const tabindexA = parseInt(a.getAttribute('tabindex') || '0');
318
+ const tabindexB = parseInt(b.getAttribute('tabindex') || '0');
319
+ if (tabindexA > tabindexB) {
320
+ return 1;
321
+ } else if (tabindexA < tabindexB) {
322
+ return -1;
323
+ }
324
+ return 0;
325
+ });
326
+
327
+ /** @type {NodeListOf<HTMLElement>} */
328
+ const otherFocusableElements = popup.querySelectorAll(focusable);
329
+ const otherFocusableElementsFiltered = Array.from(otherFocusableElements).filter(el => el.getAttribute('tabindex') !== '-1');
330
+ return [...new Set(focusableElementsWithTabindexSorted.concat(otherFocusableElementsFiltered))].filter(el => isVisible$1(el));
331
+ };
332
+
333
+ /**
334
+ * @returns {boolean}
335
+ */
336
+ const isModal = () => {
337
+ return hasClass(document.body, swalClasses.shown) && !hasClass(document.body, swalClasses['toast-shown']) && !hasClass(document.body, swalClasses['no-backdrop']);
338
+ };
339
+
340
+ /**
341
+ * @returns {boolean}
342
+ */
343
+ const isToast = () => {
344
+ const popup = getPopup();
345
+ if (!popup) {
346
+ return false;
347
+ }
348
+ return hasClass(popup, swalClasses.toast);
349
+ };
350
+
351
+ /**
352
+ * @returns {boolean}
353
+ */
354
+ const isLoading = () => {
355
+ const popup = getPopup();
356
+ if (!popup) {
357
+ return false;
358
+ }
359
+ return popup.hasAttribute('data-loading');
360
+ };
361
+
362
+ /**
363
+ * Securely set innerHTML of an element
364
+ * https://github.com/sweetalert2/sweetalert2/issues/1926
365
+ *
366
+ * @param {HTMLElement} elem
367
+ * @param {string} html
368
+ */
369
+ const setInnerHtml = (elem, html) => {
370
+ elem.textContent = '';
371
+ if (html) {
372
+ const parser = new DOMParser();
373
+ const parsed = parser.parseFromString(html, `text/html`);
374
+ const head = parsed.querySelector('head');
375
+ if (head) {
376
+ Array.from(head.childNodes).forEach(child => {
377
+ elem.appendChild(child);
378
+ });
379
+ }
380
+ const body = parsed.querySelector('body');
381
+ if (body) {
382
+ Array.from(body.childNodes).forEach(child => {
383
+ if (child instanceof HTMLVideoElement || child instanceof HTMLAudioElement) {
384
+ elem.appendChild(child.cloneNode(true)); // https://github.com/sweetalert2/sweetalert2/issues/2507
385
+ } else {
386
+ elem.appendChild(child);
387
+ }
388
+ });
389
+ }
390
+ }
391
+ };
392
+
393
+ /**
394
+ * @param {HTMLElement} elem
395
+ * @param {string} className
396
+ * @returns {boolean}
397
+ */
398
+ const hasClass = (elem, className) => {
399
+ if (!className) {
400
+ return false;
401
+ }
402
+ const classList = className.split(/\s+/);
403
+ for (let i = 0; i < classList.length; i++) {
404
+ if (!elem.classList.contains(classList[i])) {
405
+ return false;
406
+ }
407
+ }
408
+ return true;
409
+ };
410
+
411
+ /**
412
+ * @param {HTMLElement} elem
413
+ * @param {SweetAlertOptions} params
414
+ */
415
+ const removeCustomClasses = (elem, params) => {
416
+ Array.from(elem.classList).forEach(className => {
417
+ if (!Object.values(swalClasses).includes(className) && !Object.values(iconTypes).includes(className) && !Object.values(params.showClass || {}).includes(className)) {
418
+ elem.classList.remove(className);
419
+ }
420
+ });
421
+ };
422
+
423
+ /**
424
+ * @param {HTMLElement} elem
425
+ * @param {SweetAlertOptions} params
426
+ * @param {string} className
427
+ */
428
+ const applyCustomClass = (elem, params, className) => {
429
+ removeCustomClasses(elem, params);
430
+ if (!params.customClass) {
431
+ return;
432
+ }
433
+ const customClass = params.customClass[(/** @type {keyof SweetAlertCustomClass} */className)];
434
+ if (!customClass) {
435
+ return;
436
+ }
437
+ if (typeof customClass !== 'string' && !customClass.forEach) {
438
+ warn(`Invalid type of customClass.${className}! Expected string or iterable object, got "${typeof customClass}"`);
439
+ return;
440
+ }
441
+ addClass(elem, customClass);
442
+ };
443
+
444
+ /**
445
+ * @param {HTMLElement} popup
446
+ * @param {import('./renderers/renderInput').InputClass | SweetAlertInput} inputClass
447
+ * @returns {HTMLInputElement | null}
448
+ */
449
+ const getInput$1 = (popup, inputClass) => {
450
+ if (!inputClass) {
451
+ return null;
452
+ }
453
+ switch (inputClass) {
454
+ case 'select':
455
+ case 'textarea':
456
+ case 'file':
457
+ return popup.querySelector(`.${swalClasses.popup} > .${swalClasses[inputClass]}`);
458
+ case 'checkbox':
459
+ return popup.querySelector(`.${swalClasses.popup} > .${swalClasses.checkbox} input`);
460
+ case 'radio':
461
+ return popup.querySelector(`.${swalClasses.popup} > .${swalClasses.radio} input:checked`) || popup.querySelector(`.${swalClasses.popup} > .${swalClasses.radio} input:first-child`);
462
+ case 'range':
463
+ return popup.querySelector(`.${swalClasses.popup} > .${swalClasses.range} input`);
464
+ default:
465
+ return popup.querySelector(`.${swalClasses.popup} > .${swalClasses.input}`);
466
+ }
467
+ };
468
+
469
+ /**
470
+ * @param {HTMLInputElement | HTMLTextAreaElement | HTMLSelectElement} input
471
+ */
472
+ const focusInput = input => {
473
+ input.focus();
474
+
475
+ // place cursor at end of text in text input
476
+ if (input.type !== 'file') {
477
+ // http://stackoverflow.com/a/2345915
478
+ const val = input.value;
479
+ input.value = '';
480
+ input.value = val;
481
+ }
482
+ };
483
+
484
+ /**
485
+ * @param {HTMLElement | HTMLElement[] | null} target
486
+ * @param {string | string[] | readonly string[] | undefined} classList
487
+ * @param {boolean} condition
488
+ */
489
+ const toggleClass = (target, classList, condition) => {
490
+ if (!target || !classList) {
491
+ return;
492
+ }
493
+ const classes = typeof classList === 'string' ? classList.split(/\s+/).filter(Boolean) : classList;
494
+ const targets = Array.isArray(target) ? target : [target];
495
+ targets.forEach(elem => {
496
+ classes.forEach(className => {
497
+ if (condition) {
498
+ elem.classList.add(className);
499
+ } else {
500
+ elem.classList.remove(className);
501
+ }
502
+ });
503
+ });
504
+ };
505
+
506
+ /**
507
+ * @param {HTMLElement | HTMLElement[] | null} target
508
+ * @param {string | string[] | readonly string[] | undefined} classList
509
+ */
510
+ const addClass = (target, classList) => {
511
+ toggleClass(target, classList, true);
512
+ };
513
+
514
+ /**
515
+ * @param {HTMLElement | HTMLElement[] | null} target
516
+ * @param {string | string[] | readonly string[] | undefined} classList
517
+ */
518
+ const removeClass = (target, classList) => {
519
+ toggleClass(target, classList, false);
520
+ };
521
+
522
+ /**
523
+ * Get direct child of an element by class name
524
+ *
525
+ * @param {HTMLElement} elem
526
+ * @param {string} className
527
+ * @returns {HTMLElement | undefined}
528
+ */
529
+ const getDirectChildByClass = (elem, className) => {
530
+ const children = Array.from(elem.children);
531
+ for (let i = 0; i < children.length; i++) {
532
+ const child = children[i];
533
+ if (child instanceof HTMLElement && hasClass(child, className)) {
534
+ return child;
535
+ }
536
+ }
537
+ };
538
+
539
+ /**
540
+ * @param {HTMLElement} elem
541
+ * @param {string} property
542
+ * @param {string | number | null | undefined} value
543
+ */
544
+ const applyNumericalStyle = (elem, property, value) => {
545
+ if (value === `${parseInt(`${value}`)}`) {
546
+ value = parseInt(value);
547
+ }
548
+ if (value || value === 0) {
549
+ elem.style.setProperty(property, typeof value === 'number' ? `${value}px` : (/** @type {string} */value));
550
+ } else {
551
+ elem.style.removeProperty(property);
552
+ }
553
+ };
554
+
555
+ /**
556
+ * @param {HTMLElement | null} elem
557
+ * @param {string} display
558
+ */
559
+ const show = (elem, display = 'flex') => {
560
+ if (!elem) {
561
+ return;
562
+ }
563
+ elem.style.display = display;
564
+ };
565
+
566
+ /**
567
+ * @param {HTMLElement | null} elem
568
+ */
569
+ const hide = elem => {
570
+ if (!elem) {
571
+ return;
572
+ }
573
+ elem.style.display = 'none';
574
+ };
575
+
576
+ /**
577
+ * @param {HTMLElement | null} elem
578
+ * @param {string} display
579
+ */
580
+ const showWhenInnerHtmlPresent = (elem, display = 'block') => {
581
+ if (!elem) {
582
+ return;
583
+ }
584
+ new MutationObserver(() => {
585
+ toggle(elem, elem.innerHTML, display);
586
+ }).observe(elem, {
587
+ childList: true,
588
+ subtree: true
589
+ });
590
+ };
591
+
592
+ /**
593
+ * @param {HTMLElement} parent
594
+ * @param {string} selector
595
+ * @param {string} property
596
+ * @param {string} value
597
+ */
598
+ const setStyle = (parent, selector, property, value) => {
599
+ /** @type {HTMLElement | null} */
600
+ const el = parent.querySelector(selector);
601
+ if (el) {
602
+ el.style.setProperty(property, value);
603
+ }
604
+ };
605
+
606
+ /**
607
+ * @param {HTMLElement} elem
608
+ * @param {boolean | string | null | undefined} condition
609
+ * @param {string} display
610
+ */
611
+ const toggle = (elem, condition, display = 'flex') => {
612
+ if (condition) {
613
+ show(elem, display);
614
+ } else {
615
+ hide(elem);
616
+ }
617
+ };
618
+
619
+ /**
620
+ * borrowed from jquery $(elem).is(':visible') implementation
621
+ *
622
+ * @param {HTMLElement | null} elem
623
+ * @returns {boolean}
624
+ */
625
+ const isVisible$1 = elem => Boolean(elem && (elem.offsetWidth || elem.offsetHeight || elem.getClientRects().length));
626
+
627
+ /**
628
+ * @returns {boolean}
629
+ */
630
+ const allButtonsAreHidden = () => !isVisible$1(getConfirmButton()) && !isVisible$1(getDenyButton()) && !isVisible$1(getCancelButton());
631
+
632
+ /**
633
+ * @param {HTMLElement} elem
634
+ * @returns {boolean}
635
+ */
636
+ const isScrollable = elem => Boolean(elem.scrollHeight > elem.clientHeight);
637
+
638
+ /**
639
+ * @param {HTMLElement} element
640
+ * @param {HTMLElement} stopElement
641
+ * @returns {boolean}
642
+ */
643
+ const selfOrParentIsScrollable = (element, stopElement) => {
644
+ let parent = /** @type {HTMLElement | null} */element;
645
+ while (parent && parent !== stopElement) {
646
+ if (isScrollable(parent)) {
647
+ return true;
648
+ }
649
+ parent = parent.parentElement;
650
+ }
651
+ return false;
652
+ };
653
+
654
+ /**
655
+ * borrowed from https://stackoverflow.com/a/46352119
656
+ *
657
+ * @param {HTMLElement} elem
658
+ * @returns {boolean}
659
+ */
660
+ const hasCssAnimation = elem => {
661
+ const style = window.getComputedStyle(elem);
662
+ const animDuration = parseFloat(style.getPropertyValue('animation-duration') || '0');
663
+ const transDuration = parseFloat(style.getPropertyValue('transition-duration') || '0');
664
+ return animDuration > 0 || transDuration > 0;
665
+ };
666
+
667
+ /**
668
+ * @param {number} timer
669
+ * @param {boolean} reset
670
+ */
671
+ const animateTimerProgressBar = (timer, reset = false) => {
672
+ const timerProgressBar = getTimerProgressBar();
673
+ if (!timerProgressBar) {
674
+ return;
675
+ }
676
+ if (isVisible$1(timerProgressBar)) {
677
+ if (reset) {
678
+ timerProgressBar.style.transition = 'none';
679
+ timerProgressBar.style.width = '100%';
680
+ }
681
+ setTimeout(() => {
682
+ timerProgressBar.style.transition = `width ${timer / 1000}s linear`;
683
+ timerProgressBar.style.width = '0%';
684
+ }, 10);
685
+ }
686
+ };
687
+ const stopTimerProgressBar = () => {
688
+ const timerProgressBar = getTimerProgressBar();
689
+ if (!timerProgressBar) {
690
+ return;
691
+ }
692
+ const timerProgressBarWidth = parseInt(window.getComputedStyle(timerProgressBar).width);
693
+ timerProgressBar.style.removeProperty('transition');
694
+ timerProgressBar.style.width = '100%';
695
+ const timerProgressBarFullWidth = parseInt(window.getComputedStyle(timerProgressBar).width);
696
+ const timerProgressBarPercent = timerProgressBarWidth / timerProgressBarFullWidth * 100;
697
+ timerProgressBar.style.width = `${timerProgressBarPercent}%`;
698
+ };
699
+
700
+ /**
701
+ * Detect Node env
702
+ *
703
+ * @returns {boolean}
704
+ */
705
+ const isNodeEnv = () => typeof window === 'undefined' || typeof document === 'undefined';
706
+
707
+ const sweetHTML = `
708
+ <div aria-labelledby="${swalClasses.title}" aria-describedby="${swalClasses['html-container']}" class="${swalClasses.popup}" tabindex="-1">
709
+ <button type="button" class="${swalClasses.close}"></button>
710
+ <ul class="${swalClasses['progress-steps']}"></ul>
711
+ <div class="${swalClasses.icon}"></div>
712
+ <img class="${swalClasses.image}" />
713
+ <h2 class="${swalClasses.title}" id="${swalClasses.title}"></h2>
714
+ <div class="${swalClasses['html-container']}" id="${swalClasses['html-container']}"></div>
715
+ <input class="${swalClasses.input}" id="${swalClasses.input}" />
716
+ <input type="file" class="${swalClasses.file}" />
717
+ <div class="${swalClasses.range}">
718
+ <input type="range" />
719
+ <output></output>
720
+ </div>
721
+ <select class="${swalClasses.select}" id="${swalClasses.select}"></select>
722
+ <div class="${swalClasses.radio}"></div>
723
+ <label class="${swalClasses.checkbox}">
724
+ <input type="checkbox" id="${swalClasses.checkbox}" />
725
+ <span class="${swalClasses.label}"></span>
726
+ </label>
727
+ <textarea class="${swalClasses.textarea}" id="${swalClasses.textarea}"></textarea>
728
+ <div class="${swalClasses['validation-message']}" id="${swalClasses['validation-message']}"></div>
729
+ <div class="${swalClasses.actions}">
730
+ <div class="${swalClasses.loader}"></div>
731
+ <button type="button" class="${swalClasses.confirm}"></button>
732
+ <button type="button" class="${swalClasses.deny}"></button>
733
+ <button type="button" class="${swalClasses.cancel}"></button>
734
+ </div>
735
+ <div class="${swalClasses.footer}"></div>
736
+ <div class="${swalClasses['timer-progress-bar-container']}">
737
+ <div class="${swalClasses['timer-progress-bar']}"></div>
738
+ </div>
739
+ </div>
740
+ `.replace(/(^|\n)\s*/g, '');
741
+
742
+ /**
743
+ * @returns {boolean}
744
+ */
745
+ const resetOldContainer = () => {
746
+ const oldContainer = getContainer();
747
+ if (!oldContainer) {
748
+ return false;
749
+ }
750
+ oldContainer.remove();
751
+ removeClass([document.documentElement, document.body], [swalClasses['no-backdrop'], swalClasses['toast-shown'],
752
+ // @ts-ignore: 'has-column' is not defined in swalClasses but may be set dynamically
753
+ swalClasses['has-column']]);
754
+ return true;
755
+ };
756
+ const resetValidationMessage$1 = () => {
757
+ if (globalState.currentInstance) {
758
+ globalState.currentInstance.resetValidationMessage();
759
+ }
760
+ };
761
+ const addInputChangeListeners = () => {
762
+ const popup = getPopup();
763
+ if (!popup) {
764
+ return;
765
+ }
766
+ const input = getDirectChildByClass(popup, swalClasses.input);
767
+ const file = getDirectChildByClass(popup, swalClasses.file);
768
+ /** @type {HTMLInputElement | null} */
769
+ const range = popup.querySelector(`.${swalClasses.range} input`);
770
+ /** @type {HTMLOutputElement | null} */
771
+ const rangeOutput = popup.querySelector(`.${swalClasses.range} output`);
772
+ const select = getDirectChildByClass(popup, swalClasses.select);
773
+ /** @type {HTMLInputElement | null} */
774
+ const checkbox = popup.querySelector(`.${swalClasses.checkbox} input`);
775
+ const textarea = getDirectChildByClass(popup, swalClasses.textarea);
776
+ if (input) {
777
+ input.oninput = resetValidationMessage$1;
778
+ }
779
+ if (file) {
780
+ file.onchange = resetValidationMessage$1;
781
+ }
782
+ if (select) {
783
+ select.onchange = resetValidationMessage$1;
784
+ }
785
+ if (checkbox) {
786
+ checkbox.onchange = resetValidationMessage$1;
787
+ }
788
+ if (textarea) {
789
+ textarea.oninput = resetValidationMessage$1;
790
+ }
791
+ if (range && rangeOutput) {
792
+ range.oninput = () => {
793
+ resetValidationMessage$1();
794
+ rangeOutput.value = range.value;
795
+ };
796
+ range.onchange = () => {
797
+ resetValidationMessage$1();
798
+ rangeOutput.value = range.value;
799
+ };
800
+ }
801
+ };
802
+
803
+ /**
804
+ * @param {string | HTMLElement} target
805
+ * @returns {HTMLElement}
806
+ */
807
+ const getTarget = target => {
808
+ if (typeof target === 'string') {
809
+ const element = document.querySelector(target);
810
+ if (!element) {
811
+ throw new Error(`Target element "${target}" not found`);
812
+ }
813
+ return /** @type {HTMLElement} */element;
814
+ }
815
+ return target;
816
+ };
817
+
818
+ /**
819
+ * @param {SweetAlertOptions} params
820
+ */
821
+ const setupAccessibility = params => {
822
+ const popup = getPopup();
823
+ if (!popup) {
824
+ return;
825
+ }
826
+ popup.setAttribute('role', params.toast ? 'alert' : 'dialog');
827
+ popup.setAttribute('aria-live', params.toast ? 'polite' : 'assertive');
828
+ if (!params.toast) {
829
+ popup.setAttribute('aria-modal', 'true');
830
+ }
831
+ };
832
+
833
+ /**
834
+ * @param {HTMLElement} targetElement
835
+ */
836
+ const setupRTL = targetElement => {
837
+ if (window.getComputedStyle(targetElement).direction === 'rtl') {
838
+ addClass(getContainer(), swalClasses.rtl);
839
+ globalState.isRTL = true;
840
+ }
841
+ };
842
+
843
+ /**
844
+ * Add modal + backdrop to DOM
845
+ *
846
+ * @param {SweetAlertOptions} params
847
+ */
848
+ const init = params => {
849
+ // Clean up the old popup container if it exists
850
+ const oldContainerExisted = resetOldContainer();
851
+ if (isNodeEnv()) {
852
+ error('SweetAlert2 requires document to initialize');
853
+ return;
854
+ }
855
+ const container = document.createElement('div');
856
+ container.className = swalClasses.container;
857
+ if (oldContainerExisted) {
858
+ addClass(container, swalClasses['no-transition']);
859
+ }
860
+ setInnerHtml(container, sweetHTML);
861
+ container.dataset['swal2Theme'] = params.theme;
862
+ const targetElement = getTarget(params.target || 'body');
863
+ targetElement.appendChild(container);
864
+ if (params.topLayer) {
865
+ container.setAttribute('popover', '');
866
+ container.showPopover();
867
+ }
868
+ setupAccessibility(params);
869
+ setupRTL(targetElement);
870
+ addInputChangeListeners();
871
+ };
872
+
873
+ /**
874
+ * @param {HTMLElement | object | string} param
875
+ * @param {HTMLElement} target
876
+ */
877
+ const parseHtmlToContainer = (param, target) => {
878
+ // DOM element
879
+ if (param instanceof HTMLElement) {
880
+ target.appendChild(param);
881
+ }
882
+
883
+ // Object
884
+ else if (typeof param === 'object') {
885
+ handleObject(param, target);
886
+ }
887
+
888
+ // Plain string
889
+ else if (param) {
890
+ setInnerHtml(target, param);
891
+ }
892
+ };
893
+
894
+ /**
895
+ * @param {object} param
896
+ * @param {HTMLElement} target
897
+ */
898
+ const handleObject = (param, target) => {
899
+ // JQuery element(s)
900
+ if ('jquery' in param) {
901
+ handleJqueryElem(target, param);
902
+ }
903
+
904
+ // For other objects use their string representation
905
+ else {
906
+ setInnerHtml(target, param.toString());
907
+ }
908
+ };
909
+
910
+ /**
911
+ * @param {HTMLElement} target
912
+ * @param {any} elem
913
+ */
914
+ const handleJqueryElem = (target, elem) => {
915
+ target.textContent = '';
916
+ if (0 in elem) {
917
+ for (let i = 0; i in elem; i++) {
918
+ target.appendChild(elem[i].cloneNode(true));
919
+ }
920
+ } else {
921
+ target.appendChild(elem.cloneNode(true));
922
+ }
923
+ };
924
+
925
+ /**
926
+ * @param {SweetAlert} instance
927
+ * @param {SweetAlertOptions} params
928
+ */
929
+ const renderActions = (instance, params) => {
930
+ const actions = getActions();
931
+ const loader = getLoader();
932
+ if (!actions || !loader) {
933
+ return;
934
+ }
935
+
936
+ // Actions (buttons) wrapper
937
+ if (!params.showConfirmButton && !params.showDenyButton && !params.showCancelButton) {
938
+ hide(actions);
939
+ } else {
940
+ show(actions);
941
+ }
942
+
943
+ // Custom class
944
+ applyCustomClass(actions, params, 'actions');
945
+
946
+ // Render all the buttons
947
+ renderButtons(actions, loader, params);
948
+
949
+ // Loader
950
+ setInnerHtml(loader, params.loaderHtml || '');
951
+ applyCustomClass(loader, params, 'loader');
952
+ };
953
+
954
+ /**
955
+ * @param {HTMLElement} actions
956
+ * @param {HTMLElement} loader
957
+ * @param {SweetAlertOptions} params
958
+ */
959
+ function renderButtons(actions, loader, params) {
960
+ const confirmButton = getConfirmButton();
961
+ const denyButton = getDenyButton();
962
+ const cancelButton = getCancelButton();
963
+ if (!confirmButton || !denyButton || !cancelButton) {
964
+ return;
965
+ }
966
+
967
+ // Render buttons
968
+ renderButton(confirmButton, 'confirm', params);
969
+ renderButton(denyButton, 'deny', params);
970
+ renderButton(cancelButton, 'cancel', params);
971
+ handleButtonsStyling(confirmButton, denyButton, cancelButton, params);
972
+ if (params.reverseButtons) {
973
+ if (params.toast) {
974
+ actions.insertBefore(cancelButton, confirmButton);
975
+ actions.insertBefore(denyButton, confirmButton);
976
+ } else {
977
+ actions.insertBefore(cancelButton, loader);
978
+ actions.insertBefore(denyButton, loader);
979
+ actions.insertBefore(confirmButton, loader);
980
+ }
981
+ }
982
+ }
983
+
984
+ /**
985
+ * @param {HTMLElement} confirmButton
986
+ * @param {HTMLElement} denyButton
987
+ * @param {HTMLElement} cancelButton
988
+ * @param {SweetAlertOptions} params
989
+ */
990
+ function handleButtonsStyling(confirmButton, denyButton, cancelButton, params) {
991
+ if (!params.buttonsStyling) {
992
+ removeClass([confirmButton, denyButton, cancelButton], swalClasses.styled);
993
+ return;
994
+ }
995
+ addClass([confirmButton, denyButton, cancelButton], swalClasses.styled);
996
+
997
+ // Apply custom background colors and outline colors to action buttons
998
+ /** @type {[HTMLElement, string, string | undefined][]} */
999
+ const buttons = [[confirmButton, 'confirm', params.confirmButtonColor], [denyButton, 'deny', params.denyButtonColor], [cancelButton, 'cancel', params.cancelButtonColor]];
1000
+ buttons.forEach(([button, type, color]) => {
1001
+ if (color) {
1002
+ button.style.setProperty(`--swal2-${type}-button-background-color`, color);
1003
+ }
1004
+ applyOutlineColor(button);
1005
+ });
1006
+ }
1007
+
1008
+ /**
1009
+ * @param {HTMLElement} button
1010
+ */
1011
+ function applyOutlineColor(button) {
1012
+ const buttonStyle = window.getComputedStyle(button);
1013
+ if (buttonStyle.getPropertyValue('--swal2-action-button-focus-box-shadow')) {
1014
+ // If the button already has a custom outline color, no need to change it
1015
+ return;
1016
+ }
1017
+ const outlineColor = buttonStyle.backgroundColor.replace(/rgba?\((\d+), (\d+), (\d+).*/, 'rgba($1, $2, $3, 0.5)');
1018
+ button.style.setProperty('--swal2-action-button-focus-box-shadow', buttonStyle.getPropertyValue('--swal2-outline').replace(/ rgba\(.*/, ` ${outlineColor}`));
1019
+ }
1020
+
1021
+ /**
1022
+ * @param {HTMLElement} button
1023
+ * @param {'confirm' | 'deny' | 'cancel'} buttonType
1024
+ * @param {SweetAlertOptions} params
1025
+ */
1026
+ function renderButton(button, buttonType, params) {
1027
+ const buttonName = /** @type {'Confirm' | 'Deny' | 'Cancel'} */capitalizeFirstLetter(buttonType);
1028
+ toggle(button, params[`show${buttonName}Button`], 'inline-block');
1029
+ setInnerHtml(button, params[`${buttonType}ButtonText`] || ''); // Set caption text
1030
+ button.setAttribute('aria-label', params[`${buttonType}ButtonAriaLabel`] || ''); // ARIA label
1031
+
1032
+ // Add buttons custom classes
1033
+ button.className = swalClasses[buttonType];
1034
+ applyCustomClass(button, params, `${buttonType}Button`);
1035
+ }
1036
+
1037
+ /**
1038
+ * @param {SweetAlert} instance
1039
+ * @param {SweetAlertOptions} params
1040
+ */
1041
+ const renderCloseButton = (instance, params) => {
1042
+ const closeButton = getCloseButton();
1043
+ if (!closeButton) {
1044
+ return;
1045
+ }
1046
+ setInnerHtml(closeButton, params.closeButtonHtml || '');
1047
+
1048
+ // Custom class
1049
+ applyCustomClass(closeButton, params, 'closeButton');
1050
+ toggle(closeButton, params.showCloseButton);
1051
+ closeButton.setAttribute('aria-label', params.closeButtonAriaLabel || '');
1052
+ };
1053
+
1054
+ /**
1055
+ * @param {SweetAlert} instance
1056
+ * @param {SweetAlertOptions} params
1057
+ */
1058
+ const renderContainer = (instance, params) => {
1059
+ const container = getContainer();
1060
+ if (!container) {
1061
+ return;
1062
+ }
1063
+ handleBackdropParam(container, params.backdrop);
1064
+ handlePositionParam(container, params.position);
1065
+ handleGrowParam(container, params.grow);
1066
+
1067
+ // Custom class
1068
+ applyCustomClass(container, params, 'container');
1069
+ };
1070
+
1071
+ /**
1072
+ * @param {HTMLElement} container
1073
+ * @param {SweetAlertOptions['backdrop']} backdrop
1074
+ */
1075
+ function handleBackdropParam(container, backdrop) {
1076
+ if (typeof backdrop === 'string') {
1077
+ container.style.background = backdrop;
1078
+ } else if (!backdrop) {
1079
+ addClass([document.documentElement, document.body], swalClasses['no-backdrop']);
1080
+ }
1081
+ }
1082
+
1083
+ /**
1084
+ * @param {HTMLElement} container
1085
+ * @param {SweetAlertOptions['position']} position
1086
+ */
1087
+ function handlePositionParam(container, position) {
1088
+ if (!position) {
1089
+ return;
1090
+ }
1091
+ if (position in swalClasses) {
1092
+ addClass(container, swalClasses[position]);
1093
+ } else {
1094
+ warn('The "position" parameter is not valid, defaulting to "center"');
1095
+ addClass(container, swalClasses.center);
1096
+ }
1097
+ }
1098
+
1099
+ /**
1100
+ * @param {HTMLElement} container
1101
+ * @param {SweetAlertOptions['grow']} grow
1102
+ */
1103
+ function handleGrowParam(container, grow) {
1104
+ if (!grow) {
1105
+ return;
1106
+ }
1107
+ addClass(container, swalClasses[`grow-${grow}`]);
1108
+ }
1109
+
1110
+ /**
1111
+ * This module contains `WeakMap`s for each effectively-"private property" that a `Swal` has.
1112
+ * For example, to set the private property "foo" of `this` to "bar", you can `privateProps.foo.set(this, 'bar')`
1113
+ * This is the approach that Babel will probably take to implement private methods/fields
1114
+ * https://github.com/tc39/proposal-private-methods
1115
+ * https://github.com/babel/babel/pull/7555
1116
+ * Once we have the changes from that PR in Babel, and our core class fits reasonable in *one module*
1117
+ * then we can use that language feature.
1118
+ */
1119
+
1120
+ var privateProps = {
1121
+ innerParams: new WeakMap(),
1122
+ domCache: new WeakMap(),
1123
+ focusedElement: new WeakMap()
1124
+ };
1125
+
1126
+ /// <reference path="../../../../sweetalert2.d.ts"/>
1127
+
1128
+
1129
+ /** @type {InputClass[]} */
1130
+ const inputClasses = ['input', 'file', 'range', 'select', 'radio', 'checkbox', 'textarea'];
1131
+
1132
+ /**
1133
+ * @param {SweetAlert} instance
1134
+ * @param {SweetAlertOptions} params
1135
+ */
1136
+ const renderInput = (instance, params) => {
1137
+ const popup = getPopup();
1138
+ if (!popup) {
1139
+ return;
1140
+ }
1141
+ const innerParams = privateProps.innerParams.get(instance);
1142
+ const rerender = !innerParams || params.input !== innerParams.input;
1143
+ inputClasses.forEach(inputClass => {
1144
+ const inputContainer = getDirectChildByClass(popup, swalClasses[inputClass]);
1145
+ if (!inputContainer) {
1146
+ return;
1147
+ }
1148
+
1149
+ // set attributes
1150
+ setAttributes(inputClass, params.inputAttributes);
1151
+
1152
+ // set class
1153
+ inputContainer.className = swalClasses[inputClass];
1154
+ if (rerender) {
1155
+ hide(inputContainer);
1156
+ }
1157
+ });
1158
+ if (params.input) {
1159
+ if (rerender) {
1160
+ showInput(params);
1161
+ }
1162
+ // set custom class
1163
+ setCustomClass(params);
1164
+ }
1165
+ };
1166
+
1167
+ /**
1168
+ * @param {SweetAlertOptions} params
1169
+ */
1170
+ const showInput = params => {
1171
+ if (!params.input) {
1172
+ return;
1173
+ }
1174
+ if (!renderInputType[params.input]) {
1175
+ error(`Unexpected type of input! Expected ${Object.keys(renderInputType).join(' | ')}, got "${params.input}"`);
1176
+ return;
1177
+ }
1178
+ const inputContainer = getInputContainer(params.input);
1179
+ if (!inputContainer) {
1180
+ return;
1181
+ }
1182
+ const input = renderInputType[params.input](inputContainer, params);
1183
+ show(inputContainer);
1184
+
1185
+ // input autofocus
1186
+ if (params.inputAutoFocus) {
1187
+ setTimeout(() => {
1188
+ focusInput(input);
1189
+ });
1190
+ }
1191
+ };
1192
+
1193
+ /**
1194
+ * @param {HTMLInputElement} input
1195
+ */
1196
+ const removeAttributes = input => {
1197
+ for (let i = 0; i < input.attributes.length; i++) {
1198
+ const attrName = input.attributes[i].name;
1199
+ if (!['id', 'type', 'value', 'style'].includes(attrName)) {
1200
+ input.removeAttribute(attrName);
1201
+ }
1202
+ }
1203
+ };
1204
+
1205
+ /**
1206
+ * @param {InputClass} inputClass
1207
+ * @param {SweetAlertOptions['inputAttributes']} inputAttributes
1208
+ */
1209
+ const setAttributes = (inputClass, inputAttributes) => {
1210
+ const popup = getPopup();
1211
+ if (!popup) {
1212
+ return;
1213
+ }
1214
+ const input = getInput$1(popup, inputClass);
1215
+ if (!input) {
1216
+ return;
1217
+ }
1218
+ removeAttributes(input);
1219
+ for (const attr in inputAttributes) {
1220
+ input.setAttribute(attr, inputAttributes[attr]);
1221
+ }
1222
+ };
1223
+
1224
+ /**
1225
+ * @param {SweetAlertOptions} params
1226
+ */
1227
+ const setCustomClass = params => {
1228
+ if (!params.input) {
1229
+ return;
1230
+ }
1231
+ const inputContainer = getInputContainer(params.input);
1232
+ if (inputContainer) {
1233
+ applyCustomClass(inputContainer, params, 'input');
1234
+ }
1235
+ };
1236
+
1237
+ /**
1238
+ * @param {HTMLInputElement | HTMLTextAreaElement} input
1239
+ * @param {SweetAlertOptions} params
1240
+ */
1241
+ const setInputPlaceholder = (input, params) => {
1242
+ if (!input.placeholder && params.inputPlaceholder) {
1243
+ input.placeholder = params.inputPlaceholder;
1244
+ }
1245
+ };
1246
+
1247
+ /**
1248
+ * @param {Input} input
1249
+ * @param {Input} prependTo
1250
+ * @param {SweetAlertOptions} params
1251
+ */
1252
+ const setInputLabel = (input, prependTo, params) => {
1253
+ if (params.inputLabel) {
1254
+ const label = document.createElement('label');
1255
+ const labelClass = swalClasses['input-label'];
1256
+ label.setAttribute('for', input.id);
1257
+ label.className = labelClass;
1258
+ if (typeof params.customClass === 'object') {
1259
+ addClass(label, params.customClass.inputLabel);
1260
+ }
1261
+ label.innerText = params.inputLabel;
1262
+ prependTo.insertAdjacentElement('beforebegin', label);
1263
+ }
1264
+ };
1265
+
1266
+ /**
1267
+ * @param {SweetAlertInput} inputType
1268
+ * @returns {HTMLElement | undefined}
1269
+ */
1270
+ const getInputContainer = inputType => {
1271
+ const popup = getPopup();
1272
+ if (!popup) {
1273
+ return;
1274
+ }
1275
+ return getDirectChildByClass(popup, swalClasses[(/** @type {SwalClass} */inputType)] || swalClasses.input);
1276
+ };
1277
+
1278
+ /**
1279
+ * @param {HTMLInputElement | HTMLOutputElement | HTMLTextAreaElement} input
1280
+ * @param {SweetAlertOptions['inputValue']} inputValue
1281
+ */
1282
+ const checkAndSetInputValue = (input, inputValue) => {
1283
+ if (['string', 'number'].includes(typeof inputValue)) {
1284
+ input.value = `${inputValue}`;
1285
+ } else if (!isPromise(inputValue)) {
1286
+ warn(`Unexpected type of inputValue! Expected "string", "number" or "Promise", got "${typeof inputValue}"`);
1287
+ }
1288
+ };
1289
+
1290
+ /** @type {Record<SweetAlertInput, (input: Input | HTMLElement, params: SweetAlertOptions) => Input>} */
1291
+ const renderInputType = {};
1292
+
1293
+ /**
1294
+ * @param {Input | HTMLElement} input
1295
+ * @param {SweetAlertOptions} params
1296
+ * @returns {Input}
1297
+ */
1298
+ 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} */
1299
+ (input, params) => {
1300
+ // oxfmt-ignore
1301
+ const inputElement = /** @type {HTMLInputElement} */input;
1302
+ checkAndSetInputValue(inputElement, params.inputValue);
1303
+ setInputLabel(inputElement, inputElement, params);
1304
+ setInputPlaceholder(inputElement, params);
1305
+ // oxfmt-ignore
1306
+ inputElement.type = /** @type {string} */params.input;
1307
+ return inputElement;
1308
+ };
1309
+
1310
+ /**
1311
+ * @param {Input | HTMLElement} input
1312
+ * @param {SweetAlertOptions} params
1313
+ * @returns {Input}
1314
+ */
1315
+ renderInputType.file = (input, params) => {
1316
+ const inputElement = /** @type {HTMLInputElement} */input;
1317
+ setInputLabel(inputElement, inputElement, params);
1318
+ setInputPlaceholder(inputElement, params);
1319
+ return inputElement;
1320
+ };
1321
+
1322
+ /**
1323
+ * @param {Input | HTMLElement} range
1324
+ * @param {SweetAlertOptions} params
1325
+ * @returns {Input}
1326
+ */
1327
+ renderInputType.range = (range, params) => {
1328
+ const rangeContainer = /** @type {HTMLElement} */range;
1329
+ const rangeInput = rangeContainer.querySelector('input');
1330
+ const rangeOutput = rangeContainer.querySelector('output');
1331
+ if (rangeInput) {
1332
+ checkAndSetInputValue(rangeInput, params.inputValue);
1333
+ rangeInput.type = /** @type {string} */params.input;
1334
+ setInputLabel(rangeInput, /** @type {Input} */range, params);
1335
+ }
1336
+ if (rangeOutput) {
1337
+ checkAndSetInputValue(rangeOutput, params.inputValue);
1338
+ }
1339
+ return /** @type {Input} */range;
1340
+ };
1341
+
1342
+ /**
1343
+ * @param {Input | HTMLElement} select
1344
+ * @param {SweetAlertOptions} params
1345
+ * @returns {Input}
1346
+ */
1347
+ renderInputType.select = (select, params) => {
1348
+ const selectElement = /** @type {HTMLSelectElement} */select;
1349
+ selectElement.textContent = '';
1350
+ if (params.inputPlaceholder) {
1351
+ const placeholder = document.createElement('option');
1352
+ setInnerHtml(placeholder, params.inputPlaceholder);
1353
+ placeholder.value = '';
1354
+ placeholder.disabled = true;
1355
+ placeholder.selected = true;
1356
+ selectElement.appendChild(placeholder);
1357
+ }
1358
+ setInputLabel(selectElement, selectElement, params);
1359
+ return selectElement;
1360
+ };
1361
+
1362
+ /**
1363
+ * @param {Input | HTMLElement} radio
1364
+ * @returns {Input}
1365
+ */
1366
+ renderInputType.radio = radio => {
1367
+ const radioElement = /** @type {HTMLElement} */radio;
1368
+ radioElement.textContent = '';
1369
+ return /** @type {Input} */radio;
1370
+ };
1371
+
1372
+ /**
1373
+ * @param {Input | HTMLElement} checkboxContainer
1374
+ * @param {SweetAlertOptions} params
1375
+ * @returns {Input}
1376
+ */
1377
+ renderInputType.checkbox = (checkboxContainer, params) => {
1378
+ const popup = getPopup();
1379
+ if (!popup) {
1380
+ throw new Error('Popup not found');
1381
+ }
1382
+ const checkbox = getInput$1(popup, 'checkbox');
1383
+ if (!checkbox) {
1384
+ throw new Error('Checkbox input not found');
1385
+ }
1386
+ checkbox.value = '1';
1387
+ checkbox.checked = Boolean(params.inputValue);
1388
+ const containerElement = /** @type {HTMLElement} */checkboxContainer;
1389
+ const label = containerElement.querySelector('span');
1390
+ if (label) {
1391
+ const placeholderOrLabel = params.inputPlaceholder || params.inputLabel;
1392
+ if (placeholderOrLabel) {
1393
+ setInnerHtml(label, placeholderOrLabel);
1394
+ }
1395
+ }
1396
+ return checkbox;
1397
+ };
1398
+
1399
+ /**
1400
+ * @param {Input | HTMLElement} textarea
1401
+ * @param {SweetAlertOptions} params
1402
+ * @returns {Input}
1403
+ */
1404
+ renderInputType.textarea = (textarea, params) => {
1405
+ const textareaElement = /** @type {HTMLTextAreaElement} */textarea;
1406
+ checkAndSetInputValue(textareaElement, params.inputValue);
1407
+ setInputPlaceholder(textareaElement, params);
1408
+ setInputLabel(textareaElement, textareaElement, params);
1409
+
1410
+ /**
1411
+ * @param {HTMLElement} el
1412
+ * @returns {number}
1413
+ */
1414
+ const getMargin = el => parseInt(window.getComputedStyle(el).marginLeft) + parseInt(window.getComputedStyle(el).marginRight);
1415
+
1416
+ // https://github.com/sweetalert2/sweetalert2/issues/2291
1417
+ setTimeout(() => {
1418
+ // https://github.com/sweetalert2/sweetalert2/issues/1699
1419
+ if ('MutationObserver' in window) {
1420
+ const popup = getPopup();
1421
+ if (!popup) {
1422
+ return;
1423
+ }
1424
+ const initialPopupWidth = parseInt(window.getComputedStyle(popup).width);
1425
+ const textareaResizeHandler = () => {
1426
+ // check if texarea is still in document (i.e. popup wasn't closed in the meantime)
1427
+ if (!document.body.contains(textareaElement)) {
1428
+ return;
1429
+ }
1430
+ const textareaWidth = textareaElement.offsetWidth + getMargin(textareaElement);
1431
+ const popupElement = getPopup();
1432
+ if (popupElement) {
1433
+ if (textareaWidth > initialPopupWidth) {
1434
+ popupElement.style.width = `${textareaWidth}px`;
1435
+ } else {
1436
+ applyNumericalStyle(popupElement, 'width', params.width);
1437
+ }
1438
+ }
1439
+ };
1440
+ new MutationObserver(textareaResizeHandler).observe(textareaElement, {
1441
+ attributes: true,
1442
+ attributeFilter: ['style']
1443
+ });
1444
+ }
1445
+ });
1446
+ return textareaElement;
1447
+ };
1448
+
1449
+ /**
1450
+ * @param {SweetAlert} instance
1451
+ * @param {SweetAlertOptions} params
1452
+ */
1453
+ const renderContent = (instance, params) => {
1454
+ const htmlContainer = getHtmlContainer();
1455
+ if (!htmlContainer) {
1456
+ return;
1457
+ }
1458
+ showWhenInnerHtmlPresent(htmlContainer);
1459
+ applyCustomClass(htmlContainer, params, 'htmlContainer');
1460
+
1461
+ // Content as HTML
1462
+ if (params.html) {
1463
+ parseHtmlToContainer(params.html, htmlContainer);
1464
+ show(htmlContainer, 'block');
1465
+ }
1466
+
1467
+ // Content as plain text
1468
+ else if (params.text) {
1469
+ htmlContainer.textContent = params.text;
1470
+ show(htmlContainer, 'block');
1471
+ }
1472
+
1473
+ // No content
1474
+ else {
1475
+ hide(htmlContainer);
1476
+ }
1477
+ renderInput(instance, params);
1478
+ };
1479
+
1480
+ /**
1481
+ * @param {SweetAlert} instance
1482
+ * @param {SweetAlertOptions} params
1483
+ */
1484
+ const renderFooter = (instance, params) => {
1485
+ const footer = getFooter();
1486
+ if (!footer) {
1487
+ return;
1488
+ }
1489
+ showWhenInnerHtmlPresent(footer);
1490
+ toggle(footer, Boolean(params.footer), 'block');
1491
+ if (params.footer) {
1492
+ parseHtmlToContainer(params.footer, footer);
1493
+ }
1494
+
1495
+ // Custom class
1496
+ applyCustomClass(footer, params, 'footer');
1497
+ };
1498
+
1499
+ /**
1500
+ * @param {SweetAlert} instance
1501
+ * @param {SweetAlertOptions} params
1502
+ */
1503
+ const renderIcon = (instance, params) => {
1504
+ const innerParams = privateProps.innerParams.get(instance);
1505
+ const icon = getIcon();
1506
+ if (!icon) {
1507
+ return;
1508
+ }
1509
+
1510
+ // if the given icon already rendered, apply the styling without re-rendering the icon
1511
+ if (innerParams && params.icon === innerParams.icon) {
1512
+ // Custom or default content
1513
+ setContent(icon, params);
1514
+ applyStyles(icon, params);
1515
+ return;
1516
+ }
1517
+ if (!params.icon && !params.iconHtml) {
1518
+ hide(icon);
1519
+ return;
1520
+ }
1521
+ if (params.icon && Object.keys(iconTypes).indexOf(params.icon) === -1) {
1522
+ error(`Unknown icon! Expected "success", "error", "warning", "info" or "question", got "${params.icon}"`);
1523
+ hide(icon);
1524
+ return;
1525
+ }
1526
+ show(icon);
1527
+
1528
+ // Custom or default content
1529
+ setContent(icon, params);
1530
+ applyStyles(icon, params);
1531
+
1532
+ // Animate icon
1533
+ addClass(icon, params.showClass && params.showClass.icon);
1534
+
1535
+ // Re-adjust the success icon on system theme change
1536
+ const colorSchemeQueryList = window.matchMedia('(prefers-color-scheme: dark)');
1537
+ colorSchemeQueryList.addEventListener('change', adjustSuccessIconBackgroundColor);
1538
+ };
1539
+
1540
+ /**
1541
+ * @param {HTMLElement} icon
1542
+ * @param {SweetAlertOptions} params
1543
+ */
1544
+ const applyStyles = (icon, params) => {
1545
+ for (const [iconType, iconClassName] of Object.entries(iconTypes)) {
1546
+ if (params.icon !== iconType) {
1547
+ removeClass(icon, iconClassName);
1548
+ }
1549
+ }
1550
+ addClass(icon, params.icon && iconTypes[params.icon]);
1551
+
1552
+ // Icon color
1553
+ setColor(icon, params);
1554
+
1555
+ // Success icon background color
1556
+ adjustSuccessIconBackgroundColor();
1557
+
1558
+ // Custom class
1559
+ applyCustomClass(icon, params, 'icon');
1560
+ };
1561
+
1562
+ // Adjust success icon background color to match the popup background color
1563
+ const adjustSuccessIconBackgroundColor = () => {
1564
+ const popup = getPopup();
1565
+ if (!popup) {
1566
+ return;
1567
+ }
1568
+ const popupBackgroundColor = window.getComputedStyle(popup).getPropertyValue('background-color');
1569
+ /** @type {NodeListOf<HTMLElement>} */
1570
+ const successIconParts = popup.querySelectorAll('[class^=swal2-success-circular-line], .swal2-success-fix');
1571
+ for (let i = 0; i < successIconParts.length; i++) {
1572
+ successIconParts[i].style.backgroundColor = popupBackgroundColor;
1573
+ }
1574
+ };
1575
+
1576
+ /**
1577
+ *
1578
+ * @param {SweetAlertOptions} params
1579
+ * @returns {string}
1580
+ */
1581
+ const successIconHtml = params => `
1582
+ ${params.animation ? '<div class="swal2-success-circular-line-left"></div>' : ''}
1583
+ <span class="swal2-success-line-tip"></span> <span class="swal2-success-line-long"></span>
1584
+ <div class="swal2-success-ring"></div>
1585
+ ${params.animation ? '<div class="swal2-success-fix"></div>' : ''}
1586
+ ${params.animation ? '<div class="swal2-success-circular-line-right"></div>' : ''}
1587
+ `;
1588
+ const errorIconHtml = `
1589
+ <span class="swal2-x-mark">
1590
+ <span class="swal2-x-mark-line-left"></span>
1591
+ <span class="swal2-x-mark-line-right"></span>
1592
+ </span>
1593
+ `;
1594
+
1595
+ /**
1596
+ * @param {HTMLElement} icon
1597
+ * @param {SweetAlertOptions} params
1598
+ */
1599
+ const setContent = (icon, params) => {
1600
+ if (!params.icon && !params.iconHtml) {
1601
+ return;
1602
+ }
1603
+ let oldContent = icon.innerHTML;
1604
+ let newContent = '';
1605
+ if (params.iconHtml) {
1606
+ newContent = iconContent(params.iconHtml);
1607
+ } else if (params.icon === 'success') {
1608
+ newContent = successIconHtml(params);
1609
+ oldContent = oldContent.replace(/ style=".*?"/g, ''); // undo adjustSuccessIconBackgroundColor()
1610
+ } else if (params.icon === 'error') {
1611
+ newContent = errorIconHtml;
1612
+ } else if (params.icon) {
1613
+ const defaultIconHtml = {
1614
+ question: '?',
1615
+ warning: '!',
1616
+ info: 'i'
1617
+ };
1618
+ newContent = iconContent(defaultIconHtml[params.icon]);
1619
+ }
1620
+ if (oldContent.trim() !== newContent.trim()) {
1621
+ setInnerHtml(icon, newContent);
1622
+ }
1623
+ };
1624
+
1625
+ /**
1626
+ * @param {HTMLElement} icon
1627
+ * @param {SweetAlertOptions} params
1628
+ */
1629
+ const setColor = (icon, params) => {
1630
+ if (!params.iconColor) {
1631
+ return;
1632
+ }
1633
+ icon.style.color = params.iconColor;
1634
+ icon.style.borderColor = params.iconColor;
1635
+ for (const sel of ['.swal2-success-line-tip', '.swal2-success-line-long', '.swal2-x-mark-line-left', '.swal2-x-mark-line-right']) {
1636
+ setStyle(icon, sel, 'background-color', params.iconColor);
1637
+ }
1638
+ setStyle(icon, '.swal2-success-ring', 'border-color', params.iconColor);
1639
+ };
1640
+
1641
+ /**
1642
+ * @param {string} content
1643
+ * @returns {string}
1644
+ */
1645
+ const iconContent = content => `<div class="${swalClasses['icon-content']}">${content}</div>`;
1646
+
1647
+ /**
1648
+ * @param {SweetAlert} instance
1649
+ * @param {SweetAlertOptions} params
1650
+ */
1651
+ const renderImage = (instance, params) => {
1652
+ const image = getImage();
1653
+ if (!image) {
1654
+ return;
1655
+ }
1656
+ if (!params.imageUrl) {
1657
+ hide(image);
1658
+ return;
1659
+ }
1660
+ show(image, '');
1661
+
1662
+ // Src, alt
1663
+ image.setAttribute('src', params.imageUrl);
1664
+ image.setAttribute('alt', params.imageAlt || '');
1665
+
1666
+ // Width, height
1667
+ applyNumericalStyle(image, 'width', params.imageWidth);
1668
+ applyNumericalStyle(image, 'height', params.imageHeight);
1669
+
1670
+ // Class
1671
+ image.className = swalClasses.image;
1672
+ applyCustomClass(image, params, 'image');
1673
+ };
1674
+
1675
+ let dragging = false;
1676
+ let mousedownX = 0;
1677
+ let mousedownY = 0;
1678
+ let initialX = 0;
1679
+ let initialY = 0;
1680
+
1681
+ /**
1682
+ * @param {HTMLElement} popup
1683
+ */
1684
+ const addDraggableListeners = popup => {
1685
+ popup.addEventListener('mousedown', down);
1686
+ document.body.addEventListener('mousemove', move);
1687
+ popup.addEventListener('mouseup', up);
1688
+ popup.addEventListener('touchstart', down);
1689
+ document.body.addEventListener('touchmove', move);
1690
+ popup.addEventListener('touchend', up);
1691
+ };
1692
+
1693
+ /**
1694
+ * @param {HTMLElement} popup
1695
+ */
1696
+ const removeDraggableListeners = popup => {
1697
+ popup.removeEventListener('mousedown', down);
1698
+ document.body.removeEventListener('mousemove', move);
1699
+ popup.removeEventListener('mouseup', up);
1700
+ popup.removeEventListener('touchstart', down);
1701
+ document.body.removeEventListener('touchmove', move);
1702
+ popup.removeEventListener('touchend', up);
1703
+ };
1704
+
1705
+ /**
1706
+ * @param {MouseEvent | TouchEvent} event
1707
+ */
1708
+ const down = event => {
1709
+ const popup = getPopup();
1710
+ if (!popup) {
1711
+ return;
1712
+ }
1713
+ const icon = getIcon();
1714
+ if (event.target === popup || icon && icon.contains(/** @type {HTMLElement} */event.target)) {
1715
+ dragging = true;
1716
+ const clientXY = getClientXY(event);
1717
+ mousedownX = clientXY.clientX;
1718
+ mousedownY = clientXY.clientY;
1719
+ initialX = parseInt(popup.style.insetInlineStart) || 0;
1720
+ initialY = parseInt(popup.style.insetBlockStart) || 0;
1721
+ addClass(popup, 'swal2-dragging');
1722
+ }
1723
+ };
1724
+
1725
+ /**
1726
+ * @param {MouseEvent | TouchEvent} event
1727
+ */
1728
+ const move = event => {
1729
+ const popup = getPopup();
1730
+ if (!popup) {
1731
+ return;
1732
+ }
1733
+ if (dragging) {
1734
+ let {
1735
+ clientX,
1736
+ clientY
1737
+ } = getClientXY(event);
1738
+ const deltaX = clientX - mousedownX;
1739
+ // In RTL mode, negate the horizontal delta since insetInlineStart refers to the right edge
1740
+ popup.style.insetInlineStart = `${initialX + (globalState.isRTL ? -deltaX : deltaX)}px`;
1741
+ popup.style.insetBlockStart = `${initialY + (clientY - mousedownY)}px`;
1742
+ }
1743
+ };
1744
+ const up = () => {
1745
+ const popup = getPopup();
1746
+ dragging = false;
1747
+ removeClass(popup, 'swal2-dragging');
1748
+ };
1749
+
1750
+ /**
1751
+ * @param {MouseEvent | TouchEvent} event
1752
+ * @returns {{ clientX: number, clientY: number }}
1753
+ */
1754
+ const getClientXY = event => {
1755
+ const source = event.type.startsWith('touch') ? /** @type {TouchEvent} */event.touches[0] : (/** @type {MouseEvent} */event);
1756
+ return {
1757
+ clientX: source.clientX,
1758
+ clientY: source.clientY
1759
+ };
1760
+ };
1761
+
1762
+ /**
1763
+ * @param {SweetAlert} instance
1764
+ * @param {SweetAlertOptions} params
1765
+ */
1766
+ const renderPopup = (instance, params) => {
1767
+ const container = getContainer();
1768
+ const popup = getPopup();
1769
+ if (!container || !popup) {
1770
+ return;
1771
+ }
1772
+
1773
+ // Width
1774
+ // https://github.com/sweetalert2/sweetalert2/issues/2170
1775
+ if (params.toast) {
1776
+ applyNumericalStyle(container, 'width', params.width);
1777
+ popup.style.width = '100%';
1778
+ const loader = getLoader();
1779
+ if (loader) {
1780
+ popup.insertBefore(loader, getIcon());
1781
+ }
1782
+ } else {
1783
+ applyNumericalStyle(popup, 'width', params.width);
1784
+ }
1785
+
1786
+ // Padding
1787
+ applyNumericalStyle(popup, 'padding', params.padding);
1788
+
1789
+ // Color
1790
+ if (params.color) {
1791
+ popup.style.color = params.color;
1792
+ }
1793
+
1794
+ // Background
1795
+ if (params.background) {
1796
+ popup.style.background = params.background;
1797
+ }
1798
+ hide(getValidationMessage());
1799
+
1800
+ // Classes
1801
+ addClasses$1(popup, params);
1802
+ if (params.draggable && !params.toast) {
1803
+ addClass(popup, swalClasses.draggable);
1804
+ addDraggableListeners(popup);
1805
+ } else {
1806
+ removeClass(popup, swalClasses.draggable);
1807
+ removeDraggableListeners(popup);
1808
+ }
1809
+ };
1810
+
1811
+ /**
1812
+ * @param {HTMLElement} popup
1813
+ * @param {SweetAlertOptions} params
1814
+ */
1815
+ const addClasses$1 = (popup, params) => {
1816
+ const showClass = params.showClass || {};
1817
+ // Default Class + showClass when updating Swal.update({})
1818
+ popup.className = `${swalClasses.popup} ${isVisible$1(popup) ? showClass.popup : ''}`;
1819
+ if (params.toast) {
1820
+ addClass([document.documentElement, document.body], swalClasses['toast-shown']);
1821
+ addClass(popup, swalClasses.toast);
1822
+ } else {
1823
+ addClass(popup, swalClasses.modal);
1824
+ }
1825
+
1826
+ // Custom class
1827
+ applyCustomClass(popup, params, 'popup');
1828
+ // TODO: remove in the next major
1829
+ if (typeof params.customClass === 'string') {
1830
+ addClass(popup, params.customClass);
1831
+ }
1832
+
1833
+ // Icon class (#1842)
1834
+ if (params.icon) {
1835
+ addClass(popup, swalClasses[`icon-${params.icon}`]);
1836
+ }
1837
+ };
1838
+
1839
+ /**
1840
+ * @param {SweetAlert} instance
1841
+ * @param {SweetAlertOptions} params
1842
+ */
1843
+ const renderProgressSteps = (instance, params) => {
1844
+ const progressStepsContainer = getProgressSteps();
1845
+ if (!progressStepsContainer) {
1846
+ return;
1847
+ }
1848
+ const {
1849
+ progressSteps,
1850
+ currentProgressStep
1851
+ } = params;
1852
+ if (!progressSteps || progressSteps.length === 0 || currentProgressStep === undefined) {
1853
+ hide(progressStepsContainer);
1854
+ return;
1855
+ }
1856
+ show(progressStepsContainer);
1857
+ progressStepsContainer.textContent = '';
1858
+ if (currentProgressStep >= progressSteps.length) {
1859
+ warn('Invalid currentProgressStep parameter, it should be less than progressSteps.length ' + '(currentProgressStep like JS arrays starts from 0)');
1860
+ }
1861
+ progressSteps.forEach((step, index) => {
1862
+ const stepEl = createStepElement(step);
1863
+ progressStepsContainer.appendChild(stepEl);
1864
+ if (index === currentProgressStep) {
1865
+ addClass(stepEl, swalClasses['active-progress-step']);
1866
+ }
1867
+ if (index !== progressSteps.length - 1) {
1868
+ const lineEl = createLineElement(params);
1869
+ progressStepsContainer.appendChild(lineEl);
1870
+ }
1871
+ });
1872
+ };
1873
+
1874
+ /**
1875
+ * @param {string} step
1876
+ * @returns {HTMLLIElement}
1877
+ */
1878
+ const createStepElement = step => {
1879
+ const stepEl = document.createElement('li');
1880
+ addClass(stepEl, swalClasses['progress-step']);
1881
+ setInnerHtml(stepEl, step);
1882
+ return stepEl;
1883
+ };
1884
+
1885
+ /**
1886
+ * @param {SweetAlertOptions} params
1887
+ * @returns {HTMLLIElement}
1888
+ */
1889
+ const createLineElement = params => {
1890
+ const lineEl = document.createElement('li');
1891
+ addClass(lineEl, swalClasses['progress-step-line']);
1892
+ if (params.progressStepsDistance) {
1893
+ applyNumericalStyle(lineEl, 'width', params.progressStepsDistance);
1894
+ }
1895
+ return lineEl;
1896
+ };
1897
+
1898
+ /**
1899
+ * @param {SweetAlert} instance
1900
+ * @param {SweetAlertOptions} params
1901
+ */
1902
+ const renderTitle = (instance, params) => {
1903
+ const title = getTitle();
1904
+ if (!title) {
1905
+ return;
1906
+ }
1907
+ showWhenInnerHtmlPresent(title);
1908
+ toggle(title, Boolean(params.title || params.titleText), 'block');
1909
+ if (params.title) {
1910
+ parseHtmlToContainer(params.title, title);
1911
+ }
1912
+ if (params.titleText) {
1913
+ title.innerText = params.titleText;
1914
+ }
1915
+
1916
+ // Custom class
1917
+ applyCustomClass(title, params, 'title');
1918
+ };
1919
+
1920
+ /**
1921
+ * @param {SweetAlert} instance
1922
+ * @param {SweetAlertOptions} params
1923
+ */
1924
+ const render = (instance, params) => {
1925
+ var _globalState$eventEmi;
1926
+ renderPopup(instance, params);
1927
+ renderContainer(instance, params);
1928
+ renderProgressSteps(instance, params);
1929
+ renderIcon(instance, params);
1930
+ renderImage(instance, params);
1931
+ renderTitle(instance, params);
1932
+ renderCloseButton(instance, params);
1933
+ renderContent(instance, params);
1934
+ renderActions(instance, params);
1935
+ renderFooter(instance, params);
1936
+ const popup = getPopup();
1937
+ if (typeof params.didRender === 'function' && popup) {
1938
+ params.didRender(popup);
1939
+ }
1940
+ (_globalState$eventEmi = globalState.eventEmitter) === null || _globalState$eventEmi === void 0 || _globalState$eventEmi.emit('didRender', popup);
1941
+ };
1942
+
1943
+ /*
1944
+ * Global function to determine if SweetAlert2 popup is shown
1945
+ */
1946
+ const isVisible = () => {
1947
+ return isVisible$1(getPopup());
1948
+ };
1949
+
1950
+ /*
1951
+ * Global function to click 'Confirm' button
1952
+ */
1953
+ const clickConfirm = () => {
1954
+ var _dom$getConfirmButton;
1955
+ return (_dom$getConfirmButton = getConfirmButton()) === null || _dom$getConfirmButton === void 0 ? void 0 : _dom$getConfirmButton.click();
1956
+ };
1957
+
1958
+ /*
1959
+ * Global function to click 'Deny' button
1960
+ */
1961
+ const clickDeny = () => {
1962
+ var _dom$getDenyButton;
1963
+ return (_dom$getDenyButton = getDenyButton()) === null || _dom$getDenyButton === void 0 ? void 0 : _dom$getDenyButton.click();
1964
+ };
1965
+
1966
+ /*
1967
+ * Global function to click 'Cancel' button
1968
+ */
1969
+ const clickCancel = () => {
1970
+ var _dom$getCancelButton;
1971
+ return (_dom$getCancelButton = getCancelButton()) === null || _dom$getCancelButton === void 0 ? void 0 : _dom$getCancelButton.click();
1972
+ };
1973
+
1974
+ /** @type {Record<DismissReason, DismissReason>} */
1975
+ const DismissReason = Object.freeze({
1976
+ cancel: 'cancel',
1977
+ backdrop: 'backdrop',
1978
+ close: 'close',
1979
+ esc: 'esc',
1980
+ timer: 'timer'
1981
+ });
1982
+
1983
+ /**
1984
+ * @param {GlobalState} globalState
1985
+ */
1986
+ const removeKeydownHandler = globalState => {
1987
+ if (globalState.keydownTarget && globalState.keydownHandlerAdded && globalState.keydownHandler) {
1988
+ const handler = /** @type {EventListenerOrEventListenerObject} */
1989
+ /** @type {unknown} */globalState.keydownHandler;
1990
+ globalState.keydownTarget.removeEventListener('keydown', handler, {
1991
+ capture: globalState.keydownListenerCapture
1992
+ });
1993
+ globalState.keydownHandlerAdded = false;
1994
+ }
1995
+ };
1996
+
1997
+ /**
1998
+ * @param {GlobalState} globalState
1999
+ * @param {SweetAlertOptions} innerParams
2000
+ * @param {(dismiss: DismissReason) => void} dismissWith
2001
+ */
2002
+ const addKeydownHandler = (globalState, innerParams, dismissWith) => {
2003
+ removeKeydownHandler(globalState);
2004
+ if (!innerParams.toast) {
2005
+ /** @type {(this: HTMLElement, event: KeyboardEvent) => void} */
2006
+ const handler = e => keydownHandler(innerParams, e, dismissWith);
2007
+ globalState.keydownHandler = handler;
2008
+ const target = innerParams.keydownListenerCapture ? window : getPopup();
2009
+ if (target) {
2010
+ globalState.keydownTarget = target;
2011
+ globalState.keydownListenerCapture = innerParams.keydownListenerCapture;
2012
+ const eventHandler = /** @type {EventListenerOrEventListenerObject} */ /** @type {unknown} */handler;
2013
+ globalState.keydownTarget.addEventListener('keydown', eventHandler, {
2014
+ capture: globalState.keydownListenerCapture
2015
+ });
2016
+ globalState.keydownHandlerAdded = true;
2017
+ }
2018
+ }
2019
+ };
2020
+
2021
+ /**
2022
+ * @param {number} index
2023
+ * @param {number} increment
2024
+ * @returns {boolean} shouldPreventDefault
2025
+ */
2026
+ const setFocus = (index, increment) => {
2027
+ var _dom$getPopup;
2028
+ const focusableElements = getFocusableElements();
2029
+ // search for visible elements and select the next possible match
2030
+ if (focusableElements.length) {
2031
+ index = index + increment;
2032
+
2033
+ // shift + tab when .swal2-popup is focused
2034
+ if (index === -2) {
2035
+ index = focusableElements.length - 1;
2036
+ }
2037
+
2038
+ // rollover to first item
2039
+ if (index === focusableElements.length) {
2040
+ index = 0;
2041
+
2042
+ // go to last item
2043
+ } else if (index === -1) {
2044
+ index = focusableElements.length - 1;
2045
+ }
2046
+ focusableElements[index].focus();
2047
+
2048
+ // don't prevent default for iframes (Firefox fix)
2049
+ // https://github.com/sweetalert2/sweetalert2/issues/2931
2050
+ if (isFirefox() && focusableElements[index] instanceof HTMLIFrameElement) {
2051
+ return false;
2052
+ }
2053
+ return true;
2054
+ }
2055
+ // no visible focusable elements, focus the popup
2056
+ (_dom$getPopup = getPopup()) === null || _dom$getPopup === void 0 || _dom$getPopup.focus();
2057
+ return true;
2058
+ };
2059
+ const arrowKeysNextButton = ['ArrowRight', 'ArrowDown'];
2060
+ const arrowKeysPreviousButton = ['ArrowLeft', 'ArrowUp'];
2061
+
2062
+ /**
2063
+ * @param {SweetAlertOptions} innerParams
2064
+ * @param {KeyboardEvent} event
2065
+ * @param {(dismiss: DismissReason) => void} dismissWith
2066
+ */
2067
+ const keydownHandler = (innerParams, event, dismissWith) => {
2068
+ if (!innerParams) {
2069
+ return; // This instance has already been destroyed
2070
+ }
2071
+
2072
+ // Ignore keydown during IME composition
2073
+ // https://developer.mozilla.org/en-US/docs/Web/API/Document/keydown_event#ignoring_keydown_during_ime_composition
2074
+ // https://github.com/sweetalert2/sweetalert2/issues/720
2075
+ // https://github.com/sweetalert2/sweetalert2/issues/2406
2076
+ if (event.isComposing || event.keyCode === 229) {
2077
+ return;
2078
+ }
2079
+ if (innerParams.stopKeydownPropagation) {
2080
+ event.stopPropagation();
2081
+ }
2082
+
2083
+ // ENTER
2084
+ if (event.key === 'Enter') {
2085
+ handleEnter(event, innerParams);
2086
+ }
2087
+
2088
+ // TAB
2089
+ else if (event.key === 'Tab') {
2090
+ handleTab(event);
2091
+ }
2092
+
2093
+ // ARROWS - switch focus between buttons
2094
+ else if ([...arrowKeysNextButton, ...arrowKeysPreviousButton].includes(event.key)) {
2095
+ handleArrows(event.key);
2096
+ }
2097
+
2098
+ // ESC
2099
+ else if (event.key === 'Escape') {
2100
+ handleEsc(event, innerParams, dismissWith);
2101
+ }
2102
+ };
2103
+
2104
+ /**
2105
+ * @param {KeyboardEvent} event
2106
+ * @param {SweetAlertOptions} innerParams
2107
+ */
2108
+ const handleEnter = (event, innerParams) => {
2109
+ // https://github.com/sweetalert2/sweetalert2/issues/2386
2110
+ if (!callIfFunction(innerParams.allowEnterKey)) {
2111
+ return;
2112
+ }
2113
+ const popup = getPopup();
2114
+ if (!popup || !innerParams.input) {
2115
+ return;
2116
+ }
2117
+ const input = getInput$1(popup, innerParams.input);
2118
+ if (event.target && input && event.target instanceof HTMLElement && event.target.outerHTML === input.outerHTML) {
2119
+ if (['textarea', 'file'].includes(innerParams.input)) {
2120
+ return; // do not submit
2121
+ }
2122
+ clickConfirm();
2123
+ event.preventDefault();
2124
+ }
2125
+ };
2126
+
2127
+ /**
2128
+ * @param {KeyboardEvent} event
2129
+ */
2130
+ const handleTab = event => {
2131
+ const targetElement = event.target;
2132
+ const focusableElements = getFocusableElements();
2133
+ let btnIndex = -1;
2134
+ for (let i = 0; i < focusableElements.length; i++) {
2135
+ if (targetElement === focusableElements[i]) {
2136
+ btnIndex = i;
2137
+ break;
2138
+ }
2139
+ }
2140
+
2141
+ // don't prevent default for iframes (Firefox fix)
2142
+ // https://github.com/sweetalert2/sweetalert2/issues/2931
2143
+ let shouldPreventDefault = true;
2144
+
2145
+ // Cycle to the next button
2146
+ if (!event.shiftKey) {
2147
+ shouldPreventDefault = setFocus(btnIndex, 1);
2148
+ }
2149
+
2150
+ // Cycle to the prev button
2151
+ else {
2152
+ shouldPreventDefault = setFocus(btnIndex, -1);
2153
+ }
2154
+ event.stopPropagation();
2155
+ if (shouldPreventDefault) {
2156
+ event.preventDefault();
2157
+ }
2158
+ };
2159
+
2160
+ /**
2161
+ * @param {string} key
2162
+ */
2163
+ const handleArrows = key => {
2164
+ const actions = getActions();
2165
+ const confirmButton = getConfirmButton();
2166
+ const denyButton = getDenyButton();
2167
+ const cancelButton = getCancelButton();
2168
+ if (!actions || !confirmButton || !denyButton || !cancelButton) {
2169
+ return;
2170
+ }
2171
+ /** @type HTMLElement[] */
2172
+ const buttons = [confirmButton, denyButton, cancelButton];
2173
+ if (document.activeElement instanceof HTMLElement && !buttons.includes(document.activeElement)) {
2174
+ return;
2175
+ }
2176
+ const sibling = arrowKeysNextButton.includes(key) ? 'nextElementSibling' : 'previousElementSibling';
2177
+ let buttonToFocus = document.activeElement;
2178
+ if (!buttonToFocus) {
2179
+ return;
2180
+ }
2181
+ for (let i = 0; i < actions.children.length; i++) {
2182
+ buttonToFocus = buttonToFocus[sibling];
2183
+ if (!buttonToFocus) {
2184
+ return;
2185
+ }
2186
+ if (buttonToFocus instanceof HTMLButtonElement && isVisible$1(buttonToFocus)) {
2187
+ break;
2188
+ }
2189
+ }
2190
+ if (buttonToFocus instanceof HTMLButtonElement) {
2191
+ buttonToFocus.focus();
2192
+ }
2193
+ };
2194
+
2195
+ /**
2196
+ * @param {KeyboardEvent} event
2197
+ * @param {SweetAlertOptions} innerParams
2198
+ * @param {(dismiss: DismissReason) => void} dismissWith
2199
+ */
2200
+ const handleEsc = (event, innerParams, dismissWith) => {
2201
+ event.preventDefault();
2202
+ if (callIfFunction(innerParams.allowEscapeKey)) {
2203
+ dismissWith(DismissReason.esc);
2204
+ }
2205
+ };
2206
+
2207
+ /**
2208
+ * This module contains `WeakMap`s for each effectively-"private property" that a `Swal` has.
2209
+ * For example, to set the private property "foo" of `this` to "bar", you can `privateProps.foo.set(this, 'bar')`
2210
+ * This is the approach that Babel will probably take to implement private methods/fields
2211
+ * https://github.com/tc39/proposal-private-methods
2212
+ * https://github.com/babel/babel/pull/7555
2213
+ * Once we have the changes from that PR in Babel, and our core class fits reasonable in *one module*
2214
+ * then we can use that language feature.
2215
+ */
2216
+
2217
+ var privateMethods = {
2218
+ swalPromiseResolve: new WeakMap(),
2219
+ swalPromiseReject: new WeakMap()
2220
+ };
2221
+
2222
+ // From https://developer.paciellogroup.com/blog/2018/06/the-current-state-of-modal-dialog-accessibility/
2223
+ // Adding aria-hidden="true" to elements outside of the active modal dialog ensures that
2224
+ // elements not within the active modal dialog will not be surfaced if a user opens a screen
2225
+ // reader’s list of elements (headings, form controls, landmarks, etc.) in the document.
2226
+
2227
+ const setAriaHidden = () => {
2228
+ const container = getContainer();
2229
+ const bodyChildren = Array.from(document.body.children);
2230
+ bodyChildren.forEach(el => {
2231
+ if (el.contains(container)) {
2232
+ return;
2233
+ }
2234
+ if (el.hasAttribute('aria-hidden')) {
2235
+ el.setAttribute('data-previous-aria-hidden', el.getAttribute('aria-hidden') || '');
2236
+ }
2237
+ el.setAttribute('aria-hidden', 'true');
2238
+ });
2239
+ };
2240
+ const unsetAriaHidden = () => {
2241
+ const bodyChildren = Array.from(document.body.children);
2242
+ bodyChildren.forEach(el => {
2243
+ if (el.hasAttribute('data-previous-aria-hidden')) {
2244
+ el.setAttribute('aria-hidden', el.getAttribute('data-previous-aria-hidden') || '');
2245
+ el.removeAttribute('data-previous-aria-hidden');
2246
+ } else {
2247
+ el.removeAttribute('aria-hidden');
2248
+ }
2249
+ });
2250
+ };
2251
+
2252
+ // @ts-ignore
2253
+ const isSafariOrIOS = typeof window !== 'undefined' && Boolean(window.GestureEvent); // true for Safari desktop + all iOS browsers https://stackoverflow.com/a/70585394
2254
+
2255
+ // @ts-ignore
2256
+ const isIOS = isSafariOrIOS && /iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream;
2257
+
2258
+ /**
2259
+ * Fix iOS scrolling
2260
+ * http://stackoverflow.com/q/39626302
2261
+ */
2262
+ const iOSfix = () => {
2263
+ if (isSafariOrIOS && !hasClass(document.body, swalClasses.iosfix)) {
2264
+ const offset = document.body.scrollTop;
2265
+ document.body.style.top = `${offset * -1}px`;
2266
+ addClass(document.body, swalClasses.iosfix);
2267
+ lockBodyScroll();
2268
+ }
2269
+ };
2270
+
2271
+ /**
2272
+ * https://github.com/sweetalert2/sweetalert2/issues/1246
2273
+ */
2274
+ const lockBodyScroll = () => {
2275
+ const container = getContainer();
2276
+ if (!container) {
2277
+ return;
2278
+ }
2279
+ /** @type {boolean} */
2280
+ let preventTouchMove;
2281
+ /**
2282
+ * @param {TouchEvent} event
2283
+ */
2284
+ container.ontouchstart = event => {
2285
+ preventTouchMove = shouldPreventTouchMove(event);
2286
+ };
2287
+ /**
2288
+ * @param {TouchEvent} event
2289
+ */
2290
+ container.ontouchmove = event => {
2291
+ if (preventTouchMove) {
2292
+ event.preventDefault();
2293
+ event.stopPropagation();
2294
+ }
2295
+ };
2296
+ };
2297
+
2298
+ /**
2299
+ * @param {TouchEvent} event
2300
+ * @returns {boolean}
2301
+ */
2302
+ const shouldPreventTouchMove = event => {
2303
+ const target = event.target;
2304
+ const container = getContainer();
2305
+ const htmlContainer = getHtmlContainer();
2306
+ if (!container || !htmlContainer) {
2307
+ return false;
2308
+ }
2309
+ if (isStylus(event) || isZoom(event)) {
2310
+ return false;
2311
+ }
2312
+ if (target === container) {
2313
+ return true;
2314
+ }
2315
+ if (!isScrollable(container) && target instanceof HTMLElement && !selfOrParentIsScrollable(target, htmlContainer) &&
2316
+ // #2823
2317
+ target.tagName !== 'INPUT' &&
2318
+ // #1603
2319
+ target.tagName !== 'TEXTAREA' &&
2320
+ // #2266
2321
+ !(isScrollable(htmlContainer) &&
2322
+ // #1944
2323
+ htmlContainer.contains(target))) {
2324
+ return true;
2325
+ }
2326
+ return false;
2327
+ };
2328
+
2329
+ /**
2330
+ * https://github.com/sweetalert2/sweetalert2/issues/1786
2331
+ *
2332
+ * @param {TouchEvent} event
2333
+ * @returns {boolean}
2334
+ */
2335
+ const isStylus = event => {
2336
+ return Boolean(event.touches && event.touches.length &&
2337
+ // @ts-ignore - touchType is not a standard property
2338
+ event.touches[0].touchType === 'stylus');
2339
+ };
2340
+
2341
+ /**
2342
+ * https://github.com/sweetalert2/sweetalert2/issues/1891
2343
+ *
2344
+ * @param {TouchEvent} event
2345
+ * @returns {boolean}
2346
+ */
2347
+ const isZoom = event => {
2348
+ return event.touches && event.touches.length > 1;
2349
+ };
2350
+ const undoIOSfix = () => {
2351
+ if (hasClass(document.body, swalClasses.iosfix)) {
2352
+ const offset = parseInt(document.body.style.top, 10);
2353
+ removeClass(document.body, swalClasses.iosfix);
2354
+ document.body.style.top = '';
2355
+ document.body.scrollTop = offset * -1;
2356
+ }
2357
+ };
2358
+
2359
+ /**
2360
+ * Measure scrollbar width for padding body during modal show/hide
2361
+ * https://github.com/twbs/bootstrap/blob/master/js/src/modal.js
2362
+ *
2363
+ * @returns {number}
2364
+ */
2365
+ const measureScrollbar = () => {
2366
+ const scrollDiv = document.createElement('div');
2367
+ scrollDiv.className = swalClasses['scrollbar-measure'];
2368
+ document.body.appendChild(scrollDiv);
2369
+ const scrollbarWidth = scrollDiv.getBoundingClientRect().width - scrollDiv.clientWidth;
2370
+ document.body.removeChild(scrollDiv);
2371
+ return scrollbarWidth;
2372
+ };
2373
+
2374
+ /**
2375
+ * Remember state in cases where opening and handling a modal will fiddle with it.
2376
+ * @type {number | null}
2377
+ */
2378
+ let previousBodyPadding = null;
2379
+
2380
+ /**
2381
+ * @param {string} initialBodyOverflow
2382
+ */
2383
+ const replaceScrollbarWithPadding = initialBodyOverflow => {
2384
+ // for queues, do not do this more than once
2385
+ if (previousBodyPadding !== null) {
2386
+ return;
2387
+ }
2388
+ // if the body has overflow
2389
+ if (document.body.scrollHeight > window.innerHeight || initialBodyOverflow === 'scroll' // https://github.com/sweetalert2/sweetalert2/issues/2663
2390
+ ) {
2391
+ // add padding so the content doesn't shift after removal of scrollbar
2392
+ previousBodyPadding = parseInt(window.getComputedStyle(document.body).getPropertyValue('padding-right'));
2393
+ document.body.style.paddingRight = `${previousBodyPadding + measureScrollbar()}px`;
2394
+ }
2395
+ };
2396
+ const undoReplaceScrollbarWithPadding = () => {
2397
+ if (previousBodyPadding !== null) {
2398
+ document.body.style.paddingRight = `${previousBodyPadding}px`;
2399
+ previousBodyPadding = null;
2400
+ }
2401
+ };
2402
+
2403
+ /**
2404
+ * @param {SweetAlert} instance
2405
+ * @param {HTMLElement} container
2406
+ * @param {boolean} returnFocus
2407
+ * @param {(() => void) | undefined} didClose
2408
+ */
2409
+ function removePopupAndResetState(instance, container, returnFocus, didClose) {
2410
+ if (isToast()) {
2411
+ triggerDidCloseAndDispose(instance, didClose);
2412
+ } else {
2413
+ restoreActiveElement(returnFocus).then(() => triggerDidCloseAndDispose(instance, didClose));
2414
+ removeKeydownHandler(globalState);
2415
+ }
2416
+
2417
+ // workaround for https://github.com/sweetalert2/sweetalert2/issues/2088
2418
+ // for some reason removing the container in Safari will scroll the document to bottom
2419
+ if (isSafariOrIOS) {
2420
+ container.setAttribute('style', 'display:none !important');
2421
+ container.removeAttribute('class');
2422
+ container.innerHTML = '';
2423
+ } else {
2424
+ container.remove();
2425
+ }
2426
+ if (isModal()) {
2427
+ undoReplaceScrollbarWithPadding();
2428
+ undoIOSfix();
2429
+ unsetAriaHidden();
2430
+ }
2431
+ removeBodyClasses();
2432
+ }
2433
+
2434
+ /**
2435
+ * Remove SweetAlert2 classes from body
2436
+ */
2437
+ function removeBodyClasses() {
2438
+ removeClass([document.documentElement, document.body], [swalClasses.shown, swalClasses['height-auto'], swalClasses['no-backdrop'], swalClasses['toast-shown']]);
2439
+ }
2440
+
2441
+ /**
2442
+ * Instance method to close sweetAlert
2443
+ *
2444
+ * @param {SweetAlertResult | undefined} resolveValue
2445
+ * @this {SweetAlert}
2446
+ */
2447
+ function close(resolveValue) {
2448
+ resolveValue = prepareResolveValue(resolveValue);
2449
+ const swalPromiseResolve = privateMethods.swalPromiseResolve.get(this);
2450
+ const didClose = triggerClosePopup(this);
2451
+ if (this.isAwaitingPromise) {
2452
+ // A swal awaiting for a promise (after a click on Confirm or Deny) cannot be dismissed anymore #2335
2453
+ if (!resolveValue.isDismissed) {
2454
+ handleAwaitingPromise(this);
2455
+ swalPromiseResolve(resolveValue);
2456
+ }
2457
+ } else if (didClose) {
2458
+ // Resolve Swal promise
2459
+ swalPromiseResolve(resolveValue);
2460
+ }
2461
+ }
2462
+
2463
+ /**
2464
+ * @param {SweetAlert} instance
2465
+ * @returns {boolean}
2466
+ */
2467
+ const triggerClosePopup = instance => {
2468
+ const popup = getPopup();
2469
+ if (!popup) {
2470
+ return false;
2471
+ }
2472
+ const innerParams = privateProps.innerParams.get(instance);
2473
+ if (!innerParams || hasClass(popup, innerParams.hideClass.popup)) {
2474
+ return false;
2475
+ }
2476
+ removeClass(popup, innerParams.showClass.popup);
2477
+ addClass(popup, innerParams.hideClass.popup);
2478
+ const backdrop = getContainer();
2479
+ removeClass(backdrop, innerParams.showClass.backdrop);
2480
+ addClass(backdrop, innerParams.hideClass.backdrop);
2481
+ handlePopupAnimation(instance, popup, innerParams);
2482
+ return true;
2483
+ };
2484
+
2485
+ /**
2486
+ * @param {Error | string} error
2487
+ * @this {SweetAlert}
2488
+ */
2489
+ function rejectPromise(error) {
2490
+ const rejectPromise = privateMethods.swalPromiseReject.get(this);
2491
+ handleAwaitingPromise(this);
2492
+ if (rejectPromise) {
2493
+ // Reject Swal promise
2494
+ rejectPromise(error);
2495
+ }
2496
+ }
2497
+
2498
+ /**
2499
+ * @param {SweetAlert} instance
2500
+ */
2501
+ const handleAwaitingPromise = instance => {
2502
+ if (instance.isAwaitingPromise) {
2503
+ // @ts-ignore
2504
+ delete instance.isAwaitingPromise;
2505
+ // The instance might have been previously partly destroyed, we must resume the destroy process in this case #2335
2506
+ if (!privateProps.innerParams.get(instance)) {
2507
+ instance._destroy();
2508
+ }
2509
+ }
2510
+ };
2511
+
2512
+ /**
2513
+ * @param {SweetAlertResult | undefined} resolveValue
2514
+ * @returns {SweetAlertResult}
2515
+ */
2516
+ const prepareResolveValue = resolveValue => {
2517
+ // When user calls Swal.close()
2518
+ if (typeof resolveValue === 'undefined') {
2519
+ return {
2520
+ isConfirmed: false,
2521
+ isDenied: false,
2522
+ isDismissed: true
2523
+ };
2524
+ }
2525
+ return Object.assign({
2526
+ isConfirmed: false,
2527
+ isDenied: false,
2528
+ isDismissed: false
2529
+ }, resolveValue);
2530
+ };
2531
+
2532
+ /**
2533
+ * @param {SweetAlert} instance
2534
+ * @param {HTMLElement} popup
2535
+ * @param {SweetAlertOptions} innerParams
2536
+ */
2537
+ const handlePopupAnimation = (instance, popup, innerParams) => {
2538
+ var _globalState$eventEmi;
2539
+ const container = getContainer();
2540
+ // If animation is supported, animate
2541
+ const animationIsSupported = hasCssAnimation(popup);
2542
+ if (typeof innerParams.willClose === 'function') {
2543
+ innerParams.willClose(popup);
2544
+ }
2545
+ (_globalState$eventEmi = globalState.eventEmitter) === null || _globalState$eventEmi === void 0 || _globalState$eventEmi.emit('willClose', popup);
2546
+ if (animationIsSupported && container) {
2547
+ animatePopup(instance, popup, container, Boolean(innerParams.returnFocus), innerParams.didClose);
2548
+ } else if (container) {
2549
+ // Otherwise, remove immediately
2550
+ removePopupAndResetState(instance, container, Boolean(innerParams.returnFocus), innerParams.didClose);
2551
+ }
2552
+ };
2553
+
2554
+ /**
2555
+ * @param {SweetAlert} instance
2556
+ * @param {HTMLElement} popup
2557
+ * @param {HTMLElement} container
2558
+ * @param {boolean} returnFocus
2559
+ * @param {(() => void) | undefined} didClose
2560
+ */
2561
+ const animatePopup = (instance, popup, container, returnFocus, didClose) => {
2562
+ globalState.swalCloseEventFinishedCallback = removePopupAndResetState.bind(null, instance, container, returnFocus, didClose);
2563
+ /**
2564
+ * @param {AnimationEvent | TransitionEvent} e
2565
+ */
2566
+ const swalCloseAnimationFinished = function (e) {
2567
+ if (e.target === popup) {
2568
+ var _globalState$swalClos;
2569
+ (_globalState$swalClos = globalState.swalCloseEventFinishedCallback) === null || _globalState$swalClos === void 0 || _globalState$swalClos.call(globalState);
2570
+ delete globalState.swalCloseEventFinishedCallback;
2571
+ popup.removeEventListener('animationend', swalCloseAnimationFinished);
2572
+ popup.removeEventListener('transitionend', swalCloseAnimationFinished);
2573
+ }
2574
+ };
2575
+ popup.addEventListener('animationend', swalCloseAnimationFinished);
2576
+ popup.addEventListener('transitionend', swalCloseAnimationFinished);
2577
+ };
2578
+
2579
+ /**
2580
+ * @param {SweetAlert} instance
2581
+ * @param {(() => void) | undefined} didClose
2582
+ */
2583
+ const triggerDidCloseAndDispose = (instance, didClose) => {
2584
+ setTimeout(() => {
2585
+ var _globalState$eventEmi2;
2586
+ if (typeof didClose === 'function') {
2587
+ didClose.bind(instance.params)();
2588
+ }
2589
+ (_globalState$eventEmi2 = globalState.eventEmitter) === null || _globalState$eventEmi2 === void 0 || _globalState$eventEmi2.emit('didClose');
2590
+ // instance might have been destroyed already
2591
+ if (instance._destroy) {
2592
+ instance._destroy();
2593
+ }
2594
+ });
2595
+ };
2596
+
2597
+ /**
2598
+ * Shows loader (spinner), this is useful with AJAX requests.
2599
+ * By default the loader be shown instead of the "Confirm" button.
2600
+ *
2601
+ * @param {HTMLButtonElement | null} [buttonToReplace]
2602
+ */
2603
+ const showLoading = buttonToReplace => {
2604
+ let popup = getPopup();
2605
+ if (!popup) {
2606
+ new Swal();
2607
+ }
2608
+ popup = getPopup();
2609
+ if (!popup) {
2610
+ return;
2611
+ }
2612
+ const loader = getLoader();
2613
+ if (isToast()) {
2614
+ hide(getIcon());
2615
+ } else {
2616
+ replaceButton(popup, buttonToReplace);
2617
+ }
2618
+ show(loader);
2619
+ popup.setAttribute('data-loading', 'true');
2620
+ popup.setAttribute('aria-busy', 'true');
2621
+ popup.focus();
2622
+ };
2623
+
2624
+ /**
2625
+ * @param {HTMLElement} popup
2626
+ * @param {HTMLButtonElement | null} [buttonToReplace]
2627
+ */
2628
+ const replaceButton = (popup, buttonToReplace) => {
2629
+ const actions = getActions();
2630
+ const loader = getLoader();
2631
+ if (!actions || !loader) {
2632
+ return;
2633
+ }
2634
+ if (!buttonToReplace && isVisible$1(getConfirmButton())) {
2635
+ buttonToReplace = getConfirmButton();
2636
+ }
2637
+ show(actions);
2638
+ if (buttonToReplace) {
2639
+ hide(buttonToReplace);
2640
+ loader.setAttribute('data-button-to-replace', buttonToReplace.className);
2641
+ actions.insertBefore(loader, buttonToReplace);
2642
+ }
2643
+ addClass([popup, actions], swalClasses.loading);
2644
+ };
2645
+
2646
+ /**
2647
+ * @param {SweetAlert} instance
2648
+ * @param {SweetAlertOptions} params
2649
+ */
2650
+ const handleInputOptionsAndValue = (instance, params) => {
2651
+ if (params.input === 'select' || params.input === 'radio') {
2652
+ handleInputOptions(instance, params);
2653
+ } else if (['text', 'email', 'number', 'tel', 'textarea'].some(i => i === params.input) && (hasToPromiseFn(params.inputValue) || isPromise(params.inputValue))) {
2654
+ showLoading(getConfirmButton());
2655
+ handleInputValue(instance, params);
2656
+ }
2657
+ };
2658
+
2659
+ /**
2660
+ * @param {SweetAlert} instance
2661
+ * @param {SweetAlertOptions} innerParams
2662
+ * @returns {SweetAlertInputValue}
2663
+ */
2664
+ const getInputValue = (instance, innerParams) => {
2665
+ const input = instance.getInput();
2666
+ if (!input) {
2667
+ return null;
2668
+ }
2669
+ switch (innerParams.input) {
2670
+ case 'checkbox':
2671
+ return getCheckboxValue(input);
2672
+ case 'radio':
2673
+ return getRadioValue(input);
2674
+ case 'file':
2675
+ return getFileValue(input);
2676
+ default:
2677
+ return innerParams.inputAutoTrim ? input.value.trim() : input.value;
2678
+ }
2679
+ };
2680
+
2681
+ /**
2682
+ * @param {HTMLInputElement} input
2683
+ * @returns {number}
2684
+ */
2685
+ const getCheckboxValue = input => input.checked ? 1 : 0;
2686
+
2687
+ /**
2688
+ * @param {HTMLInputElement} input
2689
+ * @returns {string | null}
2690
+ */
2691
+ const getRadioValue = input => input.checked ? input.value : null;
2692
+
2693
+ /**
2694
+ * @param {HTMLInputElement} input
2695
+ * @returns {FileList | File | null}
2696
+ */
2697
+ const getFileValue = input => input.files && input.files.length ? input.getAttribute('multiple') !== null ? input.files : input.files[0] : null;
2698
+
2699
+ /**
2700
+ * @param {SweetAlert} instance
2701
+ * @param {SweetAlertOptions} params
2702
+ */
2703
+ const handleInputOptions = (instance, params) => {
2704
+ const popup = getPopup();
2705
+ if (!popup) {
2706
+ return;
2707
+ }
2708
+ /**
2709
+ * @param {*} inputOptions
2710
+ */
2711
+ const processInputOptions = inputOptions => {
2712
+ if (params.input === 'select') {
2713
+ populateSelectOptions(popup, formatInputOptions(inputOptions), params);
2714
+ } else if (params.input === 'radio') {
2715
+ populateRadioOptions(popup, formatInputOptions(inputOptions), params);
2716
+ }
2717
+ };
2718
+ if (hasToPromiseFn(params.inputOptions) || isPromise(params.inputOptions)) {
2719
+ showLoading(getConfirmButton());
2720
+ asPromise(params.inputOptions).then(inputOptions => {
2721
+ instance.hideLoading();
2722
+ processInputOptions(inputOptions);
2723
+ });
2724
+ } else if (typeof params.inputOptions === 'object') {
2725
+ processInputOptions(params.inputOptions);
2726
+ } else {
2727
+ error(`Unexpected type of inputOptions! Expected object, Map or Promise, got ${typeof params.inputOptions}`);
2728
+ }
2729
+ };
2730
+
2731
+ /**
2732
+ * @param {SweetAlert} instance
2733
+ * @param {SweetAlertOptions} params
2734
+ */
2735
+ const handleInputValue = (instance, params) => {
2736
+ const input = instance.getInput();
2737
+ if (!input) {
2738
+ return;
2739
+ }
2740
+ hide(input);
2741
+ asPromise(params.inputValue).then(inputValue => {
2742
+ input.value = params.input === 'number' ? `${parseFloat(inputValue) || 0}` : `${inputValue}`;
2743
+ show(input);
2744
+ input.focus();
2745
+ instance.hideLoading();
2746
+ }).catch(err => {
2747
+ error(`Error in inputValue promise: ${err}`);
2748
+ input.value = '';
2749
+ show(input);
2750
+ input.focus();
2751
+ instance.hideLoading();
2752
+ });
2753
+ };
2754
+
2755
+ /**
2756
+ * @param {HTMLElement} popup
2757
+ * @param {InputOptionFlattened[]} inputOptions
2758
+ * @param {SweetAlertOptions} params
2759
+ */
2760
+ function populateSelectOptions(popup, inputOptions, params) {
2761
+ const select = getDirectChildByClass(popup, swalClasses.select);
2762
+ if (!select) {
2763
+ return;
2764
+ }
2765
+ /**
2766
+ * @param {HTMLElement} parent
2767
+ * @param {string} optionLabel
2768
+ * @param {string} optionValue
2769
+ */
2770
+ const renderOption = (parent, optionLabel, optionValue) => {
2771
+ const option = document.createElement('option');
2772
+ option.value = optionValue;
2773
+ setInnerHtml(option, optionLabel);
2774
+ option.selected = isSelected(optionValue, params.inputValue);
2775
+ parent.appendChild(option);
2776
+ };
2777
+ inputOptions.forEach(inputOption => {
2778
+ const optionValue = inputOption[0];
2779
+ const optionLabel = inputOption[1];
2780
+ // <optgroup> spec:
2781
+ // https://www.w3.org/TR/html401/interact/forms.html#h-17.6
2782
+ // "...all OPTGROUP elements must be specified directly within a SELECT element (i.e., groups may not be nested)..."
2783
+ // check whether this is a <optgroup>
2784
+ if (Array.isArray(optionLabel)) {
2785
+ // if it is an array, then it is an <optgroup>
2786
+ const optgroup = document.createElement('optgroup');
2787
+ optgroup.label = optionValue;
2788
+ optgroup.disabled = false; // not configurable for now
2789
+ select.appendChild(optgroup);
2790
+ optionLabel.forEach(o => renderOption(optgroup, o[1], o[0]));
2791
+ } else {
2792
+ // case of <option>
2793
+ renderOption(select, optionLabel, optionValue);
2794
+ }
2795
+ });
2796
+ select.focus();
2797
+ }
2798
+
2799
+ /**
2800
+ * @param {HTMLElement} popup
2801
+ * @param {InputOptionFlattened[]} inputOptions
2802
+ * @param {SweetAlertOptions} params
2803
+ */
2804
+ function populateRadioOptions(popup, inputOptions, params) {
2805
+ const radio = getDirectChildByClass(popup, swalClasses.radio);
2806
+ if (!radio) {
2807
+ return;
2808
+ }
2809
+ inputOptions.forEach(inputOption => {
2810
+ const radioValue = inputOption[0];
2811
+ const radioLabel = inputOption[1];
2812
+ const radioInput = document.createElement('input');
2813
+ const radioLabelElement = document.createElement('label');
2814
+ radioInput.type = 'radio';
2815
+ radioInput.name = swalClasses.radio;
2816
+ radioInput.value = radioValue;
2817
+ if (isSelected(radioValue, params.inputValue)) {
2818
+ radioInput.checked = true;
2819
+ }
2820
+ const label = document.createElement('span');
2821
+ setInnerHtml(label, radioLabel);
2822
+ label.className = swalClasses.label;
2823
+ radioLabelElement.appendChild(radioInput);
2824
+ radioLabelElement.appendChild(label);
2825
+ radio.appendChild(radioLabelElement);
2826
+ });
2827
+ const radios = radio.querySelectorAll('input');
2828
+ if (radios.length) {
2829
+ radios[0].focus();
2830
+ }
2831
+ }
2832
+
2833
+ /**
2834
+ * Converts `inputOptions` into an array of `[value, label]`s
2835
+ *
2836
+ * @param {*} inputOptions
2837
+ * @typedef {string[]} InputOptionFlattened
2838
+ * @returns {InputOptionFlattened[]}
2839
+ */
2840
+ const formatInputOptions = inputOptions => {
2841
+ const entries = inputOptions instanceof Map ? Array.from(inputOptions) : Object.entries(inputOptions);
2842
+ return entries.map(([key, value]) => [key, typeof value === 'object' ? formatInputOptions(value) : value]); // case of <optgroup>
2843
+ };
2844
+
2845
+ /**
2846
+ * @param {string} optionValue
2847
+ * @param {SweetAlertInputValue} inputValue
2848
+ * @returns {boolean}
2849
+ */
2850
+ const isSelected = (optionValue, inputValue) => {
2851
+ return Boolean(inputValue) && inputValue !== null && inputValue !== undefined && inputValue.toString() === optionValue.toString();
2852
+ };
2853
+
2854
+ /**
2855
+ * @param {SweetAlert} instance
2856
+ */
2857
+ const handleConfirmButtonClick = instance => {
2858
+ const innerParams = privateProps.innerParams.get(instance);
2859
+ instance.disableButtons();
2860
+ if (innerParams.input) {
2861
+ handleConfirmOrDenyWithInput(instance, 'confirm');
2862
+ } else {
2863
+ confirm(instance, true);
2864
+ }
2865
+ };
2866
+
2867
+ /**
2868
+ * @param {SweetAlert} instance
2869
+ */
2870
+ const handleDenyButtonClick = instance => {
2871
+ const innerParams = privateProps.innerParams.get(instance);
2872
+ instance.disableButtons();
2873
+ if (innerParams.returnInputValueOnDeny) {
2874
+ handleConfirmOrDenyWithInput(instance, 'deny');
2875
+ } else {
2876
+ deny(instance, false);
2877
+ }
2878
+ };
2879
+
2880
+ /**
2881
+ * @param {SweetAlert} instance
2882
+ * @param {(dismiss: DismissReason) => void} dismissWith
2883
+ */
2884
+ const handleCancelButtonClick = (instance, dismissWith) => {
2885
+ instance.disableButtons();
2886
+ dismissWith(DismissReason.cancel);
2887
+ };
2888
+
2889
+ /**
2890
+ * @param {SweetAlert} instance
2891
+ * @param {'confirm' | 'deny'} type
2892
+ */
2893
+ const handleConfirmOrDenyWithInput = (instance, type) => {
2894
+ const innerParams = privateProps.innerParams.get(instance);
2895
+ if (!innerParams.input) {
2896
+ error(`The "input" parameter is needed to be set when using returnInputValueOn${capitalizeFirstLetter(type)}`);
2897
+ return;
2898
+ }
2899
+ const input = instance.getInput();
2900
+ const inputValue = getInputValue(instance, innerParams);
2901
+ if (innerParams.inputValidator) {
2902
+ handleInputValidator(instance, inputValue, type);
2903
+ } else if (input && !input.checkValidity()) {
2904
+ instance.enableButtons();
2905
+ instance.showValidationMessage(innerParams.validationMessage || input.validationMessage);
2906
+ } else if (type === 'deny') {
2907
+ deny(instance, inputValue);
2908
+ } else {
2909
+ confirm(instance, inputValue);
2910
+ }
2911
+ };
2912
+
2913
+ /**
2914
+ * @param {SweetAlert} instance
2915
+ * @param {SweetAlertInputValue} inputValue
2916
+ * @param {'confirm' | 'deny'} type
2917
+ */
2918
+ const handleInputValidator = (instance, inputValue, type) => {
2919
+ const innerParams = privateProps.innerParams.get(instance);
2920
+ instance.disableInput();
2921
+ const validationPromise = Promise.resolve().then(() => asPromise(innerParams.inputValidator(inputValue, innerParams.validationMessage)));
2922
+ validationPromise.then(validationMessage => {
2923
+ instance.enableButtons();
2924
+ instance.enableInput();
2925
+ if (validationMessage) {
2926
+ instance.showValidationMessage(validationMessage);
2927
+ } else if (type === 'deny') {
2928
+ deny(instance, inputValue);
2929
+ } else {
2930
+ confirm(instance, inputValue);
2931
+ }
2932
+ });
2933
+ };
2934
+
2935
+ /**
2936
+ * @param {SweetAlert} instance
2937
+ * @param {*} value
2938
+ */
2939
+ const deny = (instance, value) => {
2940
+ const innerParams = privateProps.innerParams.get(instance);
2941
+ if (innerParams.showLoaderOnDeny) {
2942
+ showLoading(getDenyButton());
2943
+ }
2944
+ if (innerParams.preDeny) {
2945
+ 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
2946
+ const preDenyPromise = Promise.resolve().then(() => asPromise(innerParams.preDeny(value, innerParams.validationMessage)));
2947
+ preDenyPromise.then(preDenyValue => {
2948
+ if (preDenyValue === false) {
2949
+ instance.hideLoading();
2950
+ handleAwaitingPromise(instance);
2951
+ } else {
2952
+ instance.close(/** @type SweetAlertResult */{
2953
+ isDenied: true,
2954
+ value: typeof preDenyValue === 'undefined' ? value : preDenyValue
2955
+ });
2956
+ }
2957
+ }).catch(error => rejectWith(instance, error));
2958
+ } else {
2959
+ instance.close(/** @type SweetAlertResult */{
2960
+ isDenied: true,
2961
+ value
2962
+ });
2963
+ }
2964
+ };
2965
+
2966
+ /**
2967
+ * @param {SweetAlert} instance
2968
+ * @param {*} value
2969
+ */
2970
+ const succeedWith = (instance, value) => {
2971
+ instance.close(/** @type SweetAlertResult */{
2972
+ isConfirmed: true,
2973
+ value
2974
+ });
2975
+ };
2976
+
2977
+ /**
2978
+ *
2979
+ * @param {SweetAlert} instance
2980
+ * @param {string} error
2981
+ */
2982
+ const rejectWith = (instance, error) => {
2983
+ instance.rejectPromise(error);
2984
+ };
2985
+
2986
+ /**
2987
+ *
2988
+ * @param {SweetAlert} instance
2989
+ * @param {*} value
2990
+ */
2991
+ const confirm = (instance, value) => {
2992
+ const innerParams = privateProps.innerParams.get(instance);
2993
+ if (innerParams.showLoaderOnConfirm) {
2994
+ showLoading();
2995
+ }
2996
+ if (innerParams.preConfirm) {
2997
+ instance.resetValidationMessage();
2998
+ 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
2999
+ const preConfirmPromise = Promise.resolve().then(() => asPromise(innerParams.preConfirm(value, innerParams.validationMessage)));
3000
+ preConfirmPromise.then(preConfirmValue => {
3001
+ if (isVisible$1(getValidationMessage()) || preConfirmValue === false) {
3002
+ instance.hideLoading();
3003
+ handleAwaitingPromise(instance);
3004
+ } else {
3005
+ succeedWith(instance, typeof preConfirmValue === 'undefined' ? value : preConfirmValue);
3006
+ }
3007
+ }).catch(error => rejectWith(instance, error));
3008
+ } else {
3009
+ succeedWith(instance, value);
3010
+ }
3011
+ };
3012
+
3013
+ /**
3014
+ * Hides loader and shows back the button which was hidden by .showLoading()
3015
+ * @this {SweetAlert}
3016
+ */
3017
+ function hideLoading() {
3018
+ // do nothing if popup is closed
3019
+ const innerParams = privateProps.innerParams.get(this);
3020
+ if (!innerParams) {
3021
+ return;
3022
+ }
3023
+ const domCache = privateProps.domCache.get(this);
3024
+ hide(domCache.loader);
3025
+ if (isToast()) {
3026
+ if (innerParams.icon) {
3027
+ show(getIcon());
3028
+ }
3029
+ } else {
3030
+ showRelatedButton(domCache);
3031
+ }
3032
+ removeClass([domCache.popup, domCache.actions], swalClasses.loading);
3033
+ domCache.popup.removeAttribute('aria-busy');
3034
+ domCache.popup.removeAttribute('data-loading');
3035
+ domCache.confirmButton.disabled = false;
3036
+ domCache.denyButton.disabled = false;
3037
+ domCache.cancelButton.disabled = false;
3038
+ const focusedElement = privateProps.focusedElement.get(this);
3039
+ if (focusedElement instanceof HTMLElement && document.activeElement === document.body) {
3040
+ focusedElement.focus();
3041
+ }
3042
+ privateProps.focusedElement.delete(this);
3043
+ }
3044
+
3045
+ /**
3046
+ * @param {DomCache} domCache
3047
+ */
3048
+ const showRelatedButton = domCache => {
3049
+ const dataButtonToReplace = domCache.loader.getAttribute('data-button-to-replace');
3050
+ const buttonToReplace = dataButtonToReplace ? domCache.popup.getElementsByClassName(dataButtonToReplace) : [];
3051
+ if (buttonToReplace.length) {
3052
+ show(/** @type {HTMLElement} */buttonToReplace[0], 'inline-block');
3053
+ } else if (allButtonsAreHidden()) {
3054
+ hide(domCache.actions);
3055
+ }
3056
+ };
3057
+
3058
+ /**
3059
+ * Gets the input DOM node, this method works with input parameter.
3060
+ *
3061
+ * @returns {HTMLInputElement | null}
3062
+ * @this {SweetAlert}
3063
+ */
3064
+ function getInput() {
3065
+ const innerParams = privateProps.innerParams.get(this);
3066
+ const domCache = privateProps.domCache.get(this);
3067
+ if (!domCache) {
3068
+ return null;
3069
+ }
3070
+ return getInput$1(domCache.popup, innerParams.input);
3071
+ }
3072
+
3073
+ /**
3074
+ * @param {SweetAlert} instance
3075
+ * @param {string[]} buttons
3076
+ * @param {boolean} disabled
3077
+ */
3078
+ function setButtonsDisabled(instance, buttons, disabled) {
3079
+ const domCache = privateProps.domCache.get(instance);
3080
+ buttons.forEach(button => {
3081
+ domCache[button].disabled = disabled;
3082
+ });
3083
+ }
3084
+
3085
+ /**
3086
+ * @param {HTMLInputElement | null} input
3087
+ * @param {boolean} disabled
3088
+ */
3089
+ function setInputDisabled(input, disabled) {
3090
+ const popup = getPopup();
3091
+ if (!popup || !input) {
3092
+ return;
3093
+ }
3094
+ if (input.type === 'radio') {
3095
+ /** @type {NodeListOf<HTMLInputElement>} */
3096
+ const radios = popup.querySelectorAll(`[name="${swalClasses.radio}"]`);
3097
+ for (let i = 0; i < radios.length; i++) {
3098
+ radios[i].disabled = disabled;
3099
+ }
3100
+ } else {
3101
+ input.disabled = disabled;
3102
+ }
3103
+ }
3104
+
3105
+ /**
3106
+ * Enable all the buttons
3107
+ * @this {SweetAlert}
3108
+ */
3109
+ function enableButtons() {
3110
+ setButtonsDisabled(this, ['confirmButton', 'denyButton', 'cancelButton'], false);
3111
+ const focusedElement = privateProps.focusedElement.get(this);
3112
+ if (focusedElement instanceof HTMLElement && document.activeElement === document.body) {
3113
+ focusedElement.focus();
3114
+ }
3115
+ privateProps.focusedElement.delete(this);
3116
+ }
3117
+
3118
+ /**
3119
+ * Disable all the buttons
3120
+ * @this {SweetAlert}
3121
+ */
3122
+ function disableButtons() {
3123
+ privateProps.focusedElement.set(this, document.activeElement);
3124
+ setButtonsDisabled(this, ['confirmButton', 'denyButton', 'cancelButton'], true);
3125
+ }
3126
+
3127
+ /**
3128
+ * Enable the input field
3129
+ * @this {SweetAlert}
3130
+ */
3131
+ function enableInput() {
3132
+ setInputDisabled(this.getInput(), false);
3133
+ }
3134
+
3135
+ /**
3136
+ * Disable the input field
3137
+ * @this {SweetAlert}
3138
+ */
3139
+ function disableInput() {
3140
+ setInputDisabled(this.getInput(), true);
3141
+ }
3142
+
3143
+ /**
3144
+ * Show block with validation message
3145
+ *
3146
+ * @param {string} error
3147
+ * @this {SweetAlert}
3148
+ */
3149
+ function showValidationMessage(error) {
3150
+ const domCache = privateProps.domCache.get(this);
3151
+ const params = privateProps.innerParams.get(this);
3152
+ setInnerHtml(domCache.validationMessage, error);
3153
+ domCache.validationMessage.className = swalClasses['validation-message'];
3154
+ if (params.customClass && params.customClass.validationMessage) {
3155
+ addClass(domCache.validationMessage, params.customClass.validationMessage);
3156
+ }
3157
+ show(domCache.validationMessage);
3158
+ const input = this.getInput();
3159
+ if (input) {
3160
+ input.setAttribute('aria-invalid', 'true');
3161
+ input.setAttribute('aria-describedby', swalClasses['validation-message']);
3162
+ focusInput(input);
3163
+ addClass(input, swalClasses.inputerror);
3164
+ }
3165
+ }
3166
+
3167
+ /**
3168
+ * Hide block with validation message
3169
+ *
3170
+ * @this {SweetAlert}
3171
+ */
3172
+ function resetValidationMessage() {
3173
+ const domCache = privateProps.domCache.get(this);
3174
+ if (domCache.validationMessage) {
3175
+ hide(domCache.validationMessage);
3176
+ }
3177
+ const input = this.getInput();
3178
+ if (input) {
3179
+ input.removeAttribute('aria-invalid');
3180
+ input.removeAttribute('aria-describedby');
3181
+ removeClass(input, swalClasses.inputerror);
3182
+ }
3183
+ }
3184
+
3185
+ const defaultParams = {
3186
+ title: '',
3187
+ titleText: '',
3188
+ text: '',
3189
+ html: '',
3190
+ footer: '',
3191
+ icon: undefined,
3192
+ iconColor: undefined,
3193
+ iconHtml: undefined,
3194
+ template: undefined,
3195
+ toast: false,
3196
+ draggable: false,
3197
+ animation: true,
3198
+ theme: 'light',
3199
+ showClass: {
3200
+ popup: 'swal2-show',
3201
+ backdrop: 'swal2-backdrop-show',
3202
+ icon: 'swal2-icon-show'
3203
+ },
3204
+ hideClass: {
3205
+ popup: 'swal2-hide',
3206
+ backdrop: 'swal2-backdrop-hide',
3207
+ icon: 'swal2-icon-hide'
3208
+ },
3209
+ customClass: {},
3210
+ target: 'body',
3211
+ color: undefined,
3212
+ backdrop: true,
3213
+ heightAuto: true,
3214
+ allowOutsideClick: true,
3215
+ allowEscapeKey: true,
3216
+ allowEnterKey: true,
3217
+ stopKeydownPropagation: true,
3218
+ keydownListenerCapture: false,
3219
+ showConfirmButton: true,
3220
+ showDenyButton: false,
3221
+ showCancelButton: false,
3222
+ preConfirm: undefined,
3223
+ preDeny: undefined,
3224
+ confirmButtonText: 'OK',
3225
+ confirmButtonAriaLabel: '',
3226
+ confirmButtonColor: undefined,
3227
+ denyButtonText: 'No',
3228
+ denyButtonAriaLabel: '',
3229
+ denyButtonColor: undefined,
3230
+ cancelButtonText: 'Cancel',
3231
+ cancelButtonAriaLabel: '',
3232
+ cancelButtonColor: undefined,
3233
+ buttonsStyling: true,
3234
+ reverseButtons: false,
3235
+ focusConfirm: true,
3236
+ focusDeny: false,
3237
+ focusCancel: false,
3238
+ returnFocus: true,
3239
+ showCloseButton: false,
3240
+ closeButtonHtml: '&times;',
3241
+ closeButtonAriaLabel: 'Close this dialog',
3242
+ loaderHtml: '',
3243
+ showLoaderOnConfirm: false,
3244
+ showLoaderOnDeny: false,
3245
+ imageUrl: undefined,
3246
+ imageWidth: undefined,
3247
+ imageHeight: undefined,
3248
+ imageAlt: '',
3249
+ timer: undefined,
3250
+ timerProgressBar: false,
3251
+ width: undefined,
3252
+ padding: undefined,
3253
+ background: undefined,
3254
+ input: undefined,
3255
+ inputPlaceholder: '',
3256
+ inputLabel: '',
3257
+ inputValue: '',
3258
+ inputOptions: {},
3259
+ inputAutoFocus: true,
3260
+ inputAutoTrim: true,
3261
+ inputAttributes: {},
3262
+ inputValidator: undefined,
3263
+ returnInputValueOnDeny: false,
3264
+ validationMessage: undefined,
3265
+ grow: false,
3266
+ position: 'center',
3267
+ progressSteps: [],
3268
+ currentProgressStep: undefined,
3269
+ progressStepsDistance: undefined,
3270
+ willOpen: undefined,
3271
+ didOpen: undefined,
3272
+ didRender: undefined,
3273
+ willClose: undefined,
3274
+ didClose: undefined,
3275
+ didDestroy: undefined,
3276
+ scrollbarPadding: true,
3277
+ topLayer: false
3278
+ };
3279
+ 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'];
3280
+
3281
+ /** @type {Record<string, string | undefined>} */
3282
+ const deprecatedParams = {
3283
+ allowEnterKey: undefined
3284
+ };
3285
+ const toastIncompatibleParams = ['allowOutsideClick', 'allowEnterKey', 'backdrop', 'draggable', 'focusConfirm', 'focusDeny', 'focusCancel', 'returnFocus', 'heightAuto', 'keydownListenerCapture'];
3286
+
3287
+ /**
3288
+ * Is valid parameter
3289
+ *
3290
+ * @param {string} paramName
3291
+ * @returns {boolean}
3292
+ */
3293
+ const isValidParameter = paramName => {
3294
+ return Object.prototype.hasOwnProperty.call(defaultParams, paramName);
3295
+ };
3296
+
3297
+ /**
3298
+ * Is valid parameter for Swal.update() method
3299
+ *
3300
+ * @param {string} paramName
3301
+ * @returns {boolean}
3302
+ */
3303
+ const isUpdatableParameter = paramName => {
3304
+ return updatableParams.indexOf(paramName) !== -1;
3305
+ };
3306
+
3307
+ /**
3308
+ * Is deprecated parameter
3309
+ *
3310
+ * @param {string} paramName
3311
+ * @returns {string | undefined}
3312
+ */
3313
+ const isDeprecatedParameter = paramName => {
3314
+ return deprecatedParams[paramName];
3315
+ };
3316
+
3317
+ /**
3318
+ * @param {string} param
3319
+ */
3320
+ const checkIfParamIsValid = param => {
3321
+ if (!isValidParameter(param)) {
3322
+ warn(`Unknown parameter "${param}"`);
3323
+ }
3324
+ };
3325
+
3326
+ /**
3327
+ * @param {string} param
3328
+ */
3329
+ const checkIfToastParamIsValid = param => {
3330
+ if (toastIncompatibleParams.includes(param)) {
3331
+ warn(`The parameter "${param}" is incompatible with toasts`);
3332
+ }
3333
+ };
3334
+
3335
+ /**
3336
+ * @param {string} param
3337
+ */
3338
+ const checkIfParamIsDeprecated = param => {
3339
+ const isDeprecated = isDeprecatedParameter(param);
3340
+ if (isDeprecated) {
3341
+ warnAboutDeprecation(param, isDeprecated);
3342
+ }
3343
+ };
3344
+
3345
+ /**
3346
+ * Show relevant warnings for given params
3347
+ *
3348
+ * @param {SweetAlertOptions} params
3349
+ */
3350
+ const showWarningsForParams = params => {
3351
+ if (params.backdrop === false && params.allowOutsideClick) {
3352
+ warn('"allowOutsideClick" parameter requires `backdrop` parameter to be set to `true`');
3353
+ }
3354
+ 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)) {
3355
+ warn(`Invalid theme "${params.theme}"`);
3356
+ }
3357
+ for (const param in params) {
3358
+ checkIfParamIsValid(param);
3359
+ if (params.toast) {
3360
+ checkIfToastParamIsValid(param);
3361
+ }
3362
+ checkIfParamIsDeprecated(param);
3363
+ }
3364
+ };
3365
+
3366
+ /**
3367
+ * Updates popup parameters.
3368
+ *
3369
+ * @this {any}
3370
+ * @param {SweetAlertOptions} params
3371
+ */
3372
+ function update(params) {
3373
+ const container = getContainer();
3374
+ const popup = getPopup();
3375
+ const innerParams = privateProps.innerParams.get(this);
3376
+ if (!popup || hasClass(popup, innerParams.hideClass.popup)) {
3377
+ 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.`);
3378
+ return;
3379
+ }
3380
+ const validUpdatableParams = filterValidParams(params);
3381
+ const updatedParams = Object.assign({}, innerParams, validUpdatableParams);
3382
+ showWarningsForParams(updatedParams);
3383
+ if (container) {
3384
+ container.dataset['swal2Theme'] = updatedParams.theme;
3385
+ }
3386
+ render(this, updatedParams);
3387
+ privateProps.innerParams.set(this, updatedParams);
3388
+ Object.defineProperties(this, {
3389
+ params: {
3390
+ value: Object.assign({}, this.params, params),
3391
+ writable: false,
3392
+ enumerable: true
3393
+ }
3394
+ });
3395
+ }
3396
+
3397
+ /**
3398
+ * @param {SweetAlertOptions} params
3399
+ * @returns {SweetAlertOptions}
3400
+ */
3401
+ const filterValidParams = params => {
3402
+ /** @type {Record<string, any>} */
3403
+ const validUpdatableParams = {};
3404
+ Object.keys(params).forEach(param => {
3405
+ if (isUpdatableParameter(param)) {
3406
+ const typedParams = /** @type {Record<string, any>} */params;
3407
+ validUpdatableParams[param] = typedParams[param];
3408
+ } else {
3409
+ warn(`Invalid parameter to update: ${param}`);
3410
+ }
3411
+ });
3412
+ return validUpdatableParams;
3413
+ };
3414
+
3415
+ /**
3416
+ * Dispose the current SweetAlert2 instance
3417
+ * @this {SweetAlert}
3418
+ */
3419
+ function _destroy() {
3420
+ var _globalState$eventEmi;
3421
+ const domCache = privateProps.domCache.get(this);
3422
+ const innerParams = privateProps.innerParams.get(this);
3423
+ if (!innerParams) {
3424
+ disposeWeakMaps(this); // The WeakMaps might have been partly destroyed, we must recall it to dispose any remaining WeakMaps #2335
3425
+ return; // This instance has already been destroyed
3426
+ }
3427
+
3428
+ // Check if there is another Swal closing
3429
+ if (domCache.popup && globalState.swalCloseEventFinishedCallback) {
3430
+ globalState.swalCloseEventFinishedCallback();
3431
+ delete globalState.swalCloseEventFinishedCallback;
3432
+ }
3433
+ if (typeof innerParams.didDestroy === 'function') {
3434
+ innerParams.didDestroy();
3435
+ }
3436
+ (_globalState$eventEmi = globalState.eventEmitter) === null || _globalState$eventEmi === void 0 || _globalState$eventEmi.emit('didDestroy');
3437
+ disposeSwal(this);
3438
+ }
3439
+
3440
+ /**
3441
+ * @param {SweetAlert} instance
3442
+ */
3443
+ const disposeSwal = instance => {
3444
+ disposeWeakMaps(instance);
3445
+ // Unset this.params so GC will dispose it (#1569)
3446
+ // @ts-ignore
3447
+ delete instance.params;
3448
+ // Unset globalState props so GC will dispose globalState (#1569)
3449
+ delete globalState.keydownHandler;
3450
+ delete globalState.keydownTarget;
3451
+ // Unset currentInstance
3452
+ delete globalState.currentInstance;
3453
+ };
3454
+
3455
+ /**
3456
+ * @param {SweetAlert} instance
3457
+ */
3458
+ const disposeWeakMaps = instance => {
3459
+ // If the current instance is awaiting a promise result, we keep the privateMethods to call them once the promise result is retrieved #2335
3460
+ if (instance.isAwaitingPromise) {
3461
+ unsetWeakMaps(privateProps, instance);
3462
+ instance.isAwaitingPromise = true;
3463
+ } else {
3464
+ unsetWeakMaps(privateMethods, instance);
3465
+ unsetWeakMaps(privateProps, instance);
3466
+
3467
+ // @ts-ignore
3468
+ delete instance.isAwaitingPromise;
3469
+ // Unset instance methods
3470
+ // @ts-ignore
3471
+ delete instance.disableButtons;
3472
+ // @ts-ignore
3473
+ delete instance.enableButtons;
3474
+ // @ts-ignore
3475
+ delete instance.getInput;
3476
+ // @ts-ignore
3477
+ delete instance.disableInput;
3478
+ // @ts-ignore
3479
+ delete instance.enableInput;
3480
+ // @ts-ignore
3481
+ delete instance.hideLoading;
3482
+ // @ts-ignore
3483
+ delete instance.disableLoading;
3484
+ // @ts-ignore
3485
+ delete instance.showValidationMessage;
3486
+ // @ts-ignore
3487
+ delete instance.resetValidationMessage;
3488
+ // @ts-ignore
3489
+ delete instance.close;
3490
+ // @ts-ignore
3491
+ delete instance.closePopup;
3492
+ // @ts-ignore
3493
+ delete instance.closeModal;
3494
+ // @ts-ignore
3495
+ delete instance.closeToast;
3496
+ // @ts-ignore
3497
+ delete instance.rejectPromise;
3498
+ // @ts-ignore
3499
+ delete instance.update;
3500
+ // @ts-ignore
3501
+ delete instance._destroy;
3502
+ }
3503
+ };
3504
+
3505
+ /**
3506
+ * @param {Record<string, WeakMap<any, any>>} obj
3507
+ * @param {SweetAlert} instance
3508
+ */
3509
+ const unsetWeakMaps = (obj, instance) => {
3510
+ for (const i in obj) {
3511
+ obj[i].delete(instance);
3512
+ }
3513
+ };
3514
+
3515
+ var instanceMethods = /*#__PURE__*/Object.freeze({
3516
+ __proto__: null,
3517
+ _destroy: _destroy,
3518
+ close: close,
3519
+ closeModal: close,
3520
+ closePopup: close,
3521
+ closeToast: close,
3522
+ disableButtons: disableButtons,
3523
+ disableInput: disableInput,
3524
+ disableLoading: hideLoading,
3525
+ enableButtons: enableButtons,
3526
+ enableInput: enableInput,
3527
+ getInput: getInput,
3528
+ handleAwaitingPromise: handleAwaitingPromise,
3529
+ hideLoading: hideLoading,
3530
+ rejectPromise: rejectPromise,
3531
+ resetValidationMessage: resetValidationMessage,
3532
+ showValidationMessage: showValidationMessage,
3533
+ update: update
3534
+ });
3535
+
3536
+ /**
3537
+ * @param {SweetAlertOptions} innerParams
3538
+ * @param {DomCache} domCache
3539
+ * @param {(dismiss: DismissReason) => void} dismissWith
3540
+ */
3541
+ const handlePopupClick = (innerParams, domCache, dismissWith) => {
3542
+ if (innerParams.toast) {
3543
+ handleToastClick(innerParams, domCache, dismissWith);
3544
+ } else {
3545
+ // Ignore click events that had mousedown on the popup but mouseup on the container
3546
+ // This can happen when the user drags a slider
3547
+ handleModalMousedown(domCache);
3548
+
3549
+ // Ignore click events that had mousedown on the container but mouseup on the popup
3550
+ handleContainerMousedown(domCache);
3551
+ handleModalClick(innerParams, domCache, dismissWith);
3552
+ }
3553
+ };
3554
+
3555
+ /**
3556
+ * @param {SweetAlertOptions} innerParams
3557
+ * @param {DomCache} domCache
3558
+ * @param {(dismiss: DismissReason) => void} dismissWith
3559
+ */
3560
+ const handleToastClick = (innerParams, domCache, dismissWith) => {
3561
+ // Closing toast by internal click
3562
+ domCache.popup.onclick = () => {
3563
+ if (innerParams && (isAnyButtonShown(innerParams) || innerParams.timer || innerParams.input)) {
3564
+ return;
3565
+ }
3566
+ dismissWith(DismissReason.close);
3567
+ };
3568
+ };
3569
+
3570
+ /**
3571
+ * @param {SweetAlertOptions} innerParams
3572
+ * @returns {boolean}
3573
+ */
3574
+ const isAnyButtonShown = innerParams => {
3575
+ return Boolean(innerParams.showConfirmButton || innerParams.showDenyButton || innerParams.showCancelButton || innerParams.showCloseButton);
3576
+ };
3577
+ let ignoreOutsideClick = false;
3578
+
3579
+ /**
3580
+ * @param {DomCache} domCache
3581
+ */
3582
+ const handleModalMousedown = domCache => {
3583
+ domCache.popup.onmousedown = () => {
3584
+ domCache.container.onmouseup = function (e) {
3585
+ domCache.container.onmouseup = () => {};
3586
+ // We only check if the mouseup target is the container because usually it doesn't
3587
+ // have any other direct children aside of the popup
3588
+ if (e.target === domCache.container) {
3589
+ ignoreOutsideClick = true;
3590
+ }
3591
+ };
3592
+ };
3593
+ };
3594
+
3595
+ /**
3596
+ * @param {DomCache} domCache
3597
+ */
3598
+ const handleContainerMousedown = domCache => {
3599
+ domCache.container.onmousedown = e => {
3600
+ // prevent the modal text from being selected on double click on the container (allowOutsideClick: false)
3601
+ if (e.target === domCache.container) {
3602
+ e.preventDefault();
3603
+ }
3604
+ domCache.popup.onmouseup = function (e) {
3605
+ domCache.popup.onmouseup = () => {};
3606
+ // We also need to check if the mouseup target is a child of the popup
3607
+ if (e.target === domCache.popup || e.target instanceof HTMLElement && domCache.popup.contains(e.target)) {
3608
+ ignoreOutsideClick = true;
3609
+ }
3610
+ };
3611
+ };
3612
+ };
3613
+
3614
+ /**
3615
+ * @param {SweetAlertOptions} innerParams
3616
+ * @param {DomCache} domCache
3617
+ * @param {(dismiss: DismissReason) => void} dismissWith
3618
+ */
3619
+ const handleModalClick = (innerParams, domCache, dismissWith) => {
3620
+ domCache.container.onclick = e => {
3621
+ if (ignoreOutsideClick) {
3622
+ ignoreOutsideClick = false;
3623
+ return;
3624
+ }
3625
+ if (e.target === domCache.container && callIfFunction(innerParams.allowOutsideClick)) {
3626
+ dismissWith(DismissReason.backdrop);
3627
+ }
3628
+ };
3629
+ };
3630
+
3631
+ /**
3632
+ * @param {unknown} elem
3633
+ * @returns {boolean}
3634
+ */
3635
+ const isJqueryElement = elem => typeof elem === 'object' && elem !== null && 'jquery' in elem;
3636
+
3637
+ /**
3638
+ * @param {unknown} elem
3639
+ * @returns {boolean}
3640
+ */
3641
+ const isElement = elem => elem instanceof Element || isJqueryElement(elem);
3642
+
3643
+ /**
3644
+ * @param {ReadonlyArray<unknown>} args
3645
+ * @returns {SweetAlertOptions}
3646
+ */
3647
+ const argsToParams = args => {
3648
+ /** @type {Record<string, unknown>} */
3649
+ const params = {};
3650
+ if (typeof args[0] === 'object' && !isElement(args[0])) {
3651
+ Object.assign(params, args[0]);
3652
+ } else {
3653
+ ['title', 'html', 'icon'].forEach((name, index) => {
3654
+ const arg = args[index];
3655
+ if (typeof arg === 'string' || isElement(arg)) {
3656
+ params[name] = arg;
3657
+ } else if (arg !== undefined) {
3658
+ error(`Unexpected type of ${name}! Expected "string" or "Element", got ${typeof arg}`);
3659
+ }
3660
+ });
3661
+ }
3662
+ return /** @type {SweetAlertOptions} */params;
3663
+ };
3664
+
3665
+ /**
3666
+ * Main method to create a new SweetAlert2 popup
3667
+ *
3668
+ * @this {new (...args: any[]) => any}
3669
+ * @param {...SweetAlertOptions} args
3670
+ * @returns {Promise<SweetAlertResult>}
3671
+ */
3672
+ function fire(...args) {
3673
+ return new this(...args);
3674
+ }
3675
+
3676
+ /**
3677
+ * Returns an extended version of `Swal` containing `params` as defaults.
3678
+ * Useful for reusing Swal configuration.
3679
+ *
3680
+ * For example:
3681
+ *
3682
+ * Before:
3683
+ * const textPromptOptions = { input: 'text', showCancelButton: true }
3684
+ * const {value: firstName} = await Swal.fire({ ...textPromptOptions, title: 'What is your first name?' })
3685
+ * const {value: lastName} = await Swal.fire({ ...textPromptOptions, title: 'What is your last name?' })
3686
+ *
3687
+ * After:
3688
+ * const TextPrompt = Swal.mixin({ input: 'text', showCancelButton: true })
3689
+ * const {value: firstName} = await TextPrompt('What is your first name?')
3690
+ * const {value: lastName} = await TextPrompt('What is your last name?')
3691
+ *
3692
+ * @param {SweetAlertOptions} mixinParams
3693
+ * @returns {SweetAlert}
3694
+ * @this {typeof import('../SweetAlert.js').SweetAlert}
3695
+ */
3696
+ function mixin(mixinParams) {
3697
+ // @ts-ignore: 'this' refers to the SweetAlert constructor
3698
+ class MixinSwal extends this {
3699
+ /**
3700
+ * @param {any} params
3701
+ * @param {any} priorityMixinParams
3702
+ */
3703
+ _main(params, priorityMixinParams) {
3704
+ return super._main(params, Object.assign({}, mixinParams, priorityMixinParams));
3705
+ }
3706
+ }
3707
+ // @ts-ignore
3708
+ return MixinSwal;
3709
+ }
3710
+
3711
+ /**
3712
+ * If `timer` parameter is set, returns number of milliseconds of timer remained.
3713
+ * Otherwise, returns undefined.
3714
+ *
3715
+ * @returns {number | undefined}
3716
+ */
3717
+ const getTimerLeft = () => {
3718
+ return globalState.timeout && globalState.timeout.getTimerLeft();
3719
+ };
3720
+
3721
+ /**
3722
+ * Stop timer. Returns number of milliseconds of timer remained.
3723
+ * If `timer` parameter isn't set, returns undefined.
3724
+ *
3725
+ * @returns {number | undefined}
3726
+ */
3727
+ const stopTimer = () => {
3728
+ if (globalState.timeout) {
3729
+ stopTimerProgressBar();
3730
+ return globalState.timeout.stop();
3731
+ }
3732
+ };
3733
+
3734
+ /**
3735
+ * Resume timer. Returns number of milliseconds of timer remained.
3736
+ * If `timer` parameter isn't set, returns undefined.
3737
+ *
3738
+ * @returns {number | undefined}
3739
+ */
3740
+ const resumeTimer = () => {
3741
+ if (globalState.timeout) {
3742
+ const remaining = globalState.timeout.start();
3743
+ animateTimerProgressBar(remaining);
3744
+ return remaining;
3745
+ }
3746
+ };
3747
+
3748
+ /**
3749
+ * Resume timer. Returns number of milliseconds of timer remained.
3750
+ * If `timer` parameter isn't set, returns undefined.
3751
+ *
3752
+ * @returns {number | undefined}
3753
+ */
3754
+ const toggleTimer = () => {
3755
+ const timer = globalState.timeout;
3756
+ return timer && (timer.running ? stopTimer() : resumeTimer());
3757
+ };
3758
+
3759
+ /**
3760
+ * Increase timer. Returns number of milliseconds of an updated timer.
3761
+ * If `timer` parameter isn't set, returns undefined.
3762
+ *
3763
+ * @param {number} ms
3764
+ * @returns {number | undefined}
3765
+ */
3766
+ const increaseTimer = ms => {
3767
+ if (globalState.timeout) {
3768
+ const remaining = globalState.timeout.increase(ms);
3769
+ animateTimerProgressBar(remaining, true);
3770
+ return remaining;
3771
+ }
3772
+ };
3773
+
3774
+ /**
3775
+ * Check if timer is running. Returns true if timer is running
3776
+ * or false if timer is paused or stopped.
3777
+ * If `timer` parameter isn't set, returns undefined
3778
+ *
3779
+ * @returns {boolean}
3780
+ */
3781
+ const isTimerRunning = () => {
3782
+ return Boolean(globalState.timeout && globalState.timeout.isRunning());
3783
+ };
3784
+
3785
+ let bodyClickListenerAdded = false;
3786
+ /** @type {Record<string, any>} */
3787
+ const clickHandlers = {};
3788
+
3789
+ /**
3790
+ * @this {any}
3791
+ * @param {string} attr
3792
+ */
3793
+ function bindClickHandler(attr = 'data-swal-template') {
3794
+ clickHandlers[attr] = this;
3795
+ if (!bodyClickListenerAdded) {
3796
+ document.body.addEventListener('click', bodyClickListener);
3797
+ bodyClickListenerAdded = true;
3798
+ }
3799
+ }
3800
+
3801
+ /**
3802
+ * @param {MouseEvent} event
3803
+ */
3804
+ const bodyClickListener = event => {
3805
+ for (let el = /** @type {any} */event.target; el && el !== document; el = el.parentNode) {
3806
+ for (const attr in clickHandlers) {
3807
+ const template = el.getAttribute && el.getAttribute(attr);
3808
+ if (template) {
3809
+ clickHandlers[attr].fire({
3810
+ template
3811
+ });
3812
+ return;
3813
+ }
3814
+ }
3815
+ }
3816
+ };
3817
+
3818
+ // Source: https://gist.github.com/mudge/5830382?permalink_comment_id=2691957#gistcomment-2691957
3819
+
3820
+ class EventEmitter {
3821
+ constructor() {
3822
+ /** @type {Events} */
3823
+ this.events = {};
3824
+ }
3825
+
3826
+ /**
3827
+ * @param {string} eventName
3828
+ * @returns {EventHandlers}
3829
+ */
3830
+ _getHandlersByEventName(eventName) {
3831
+ if (typeof this.events[eventName] === 'undefined') {
3832
+ // not Set because we need to keep the FIFO order
3833
+ // https://github.com/sweetalert2/sweetalert2/pull/2763#discussion_r1748990334
3834
+ this.events[eventName] = [];
3835
+ }
3836
+ return this.events[eventName];
3837
+ }
3838
+
3839
+ /**
3840
+ * @param {string} eventName
3841
+ * @param {EventHandler} eventHandler
3842
+ */
3843
+ on(eventName, eventHandler) {
3844
+ const currentHandlers = this._getHandlersByEventName(eventName);
3845
+ if (!currentHandlers.includes(eventHandler)) {
3846
+ currentHandlers.push(eventHandler);
3847
+ }
3848
+ }
3849
+
3850
+ /**
3851
+ * @param {string} eventName
3852
+ * @param {EventHandler} eventHandler
3853
+ */
3854
+ once(eventName, eventHandler) {
3855
+ /**
3856
+ * @param {...any} args
3857
+ */
3858
+ const onceFn = (...args) => {
3859
+ this.removeListener(eventName, onceFn);
3860
+ // @ts-ignore
3861
+ eventHandler.apply(this, args);
3862
+ };
3863
+ this.on(eventName, onceFn);
3864
+ }
3865
+
3866
+ /**
3867
+ * @param {string} eventName
3868
+ * @param {...any} args
3869
+ */
3870
+ emit(eventName, ...args) {
3871
+ this._getHandlersByEventName(eventName).forEach(
3872
+ /**
3873
+ * @param {EventHandler} eventHandler
3874
+ */
3875
+ eventHandler => {
3876
+ try {
3877
+ // @ts-ignore
3878
+ eventHandler.apply(this, args);
3879
+ } catch (error) {
3880
+ console.error(error);
3881
+ }
3882
+ });
3883
+ }
3884
+
3885
+ /**
3886
+ * @param {string} eventName
3887
+ * @param {EventHandler} eventHandler
3888
+ */
3889
+ removeListener(eventName, eventHandler) {
3890
+ const currentHandlers = this._getHandlersByEventName(eventName);
3891
+ const index = currentHandlers.indexOf(eventHandler);
3892
+ if (index > -1) {
3893
+ currentHandlers.splice(index, 1);
3894
+ }
3895
+ }
3896
+
3897
+ /**
3898
+ * @param {string} eventName
3899
+ */
3900
+ removeAllListeners(eventName) {
3901
+ if (this.events[eventName] !== undefined) {
3902
+ // https://github.com/sweetalert2/sweetalert2/pull/2763#discussion_r1749239222
3903
+ this.events[eventName].length = 0;
3904
+ }
3905
+ }
3906
+ reset() {
3907
+ this.events = {};
3908
+ }
3909
+ }
3910
+
3911
+ globalState.eventEmitter = new EventEmitter();
3912
+
3913
+ /**
3914
+ * @param {string} eventName
3915
+ * @param {EventHandler} eventHandler
3916
+ */
3917
+ const on = (eventName, eventHandler) => {
3918
+ if (globalState.eventEmitter) {
3919
+ globalState.eventEmitter.on(eventName, eventHandler);
3920
+ }
3921
+ };
3922
+
3923
+ /**
3924
+ * @param {string} eventName
3925
+ * @param {EventHandler} eventHandler
3926
+ */
3927
+ const once = (eventName, eventHandler) => {
3928
+ if (globalState.eventEmitter) {
3929
+ globalState.eventEmitter.once(eventName, eventHandler);
3930
+ }
3931
+ };
3932
+
3933
+ /**
3934
+ * @param {string} [eventName]
3935
+ * @param {EventHandler} [eventHandler]
3936
+ */
3937
+ const off = (eventName, eventHandler) => {
3938
+ if (!globalState.eventEmitter) {
3939
+ return;
3940
+ }
3941
+
3942
+ // Remove all handlers for all events
3943
+ if (!eventName) {
3944
+ globalState.eventEmitter.reset();
3945
+ return;
3946
+ }
3947
+ if (eventHandler) {
3948
+ // Remove a specific handler
3949
+ globalState.eventEmitter.removeListener(eventName, eventHandler);
3950
+ } else {
3951
+ // Remove all handlers for a specific event
3952
+ globalState.eventEmitter.removeAllListeners(eventName);
3953
+ }
3954
+ };
3955
+
3956
+ var staticMethods = /*#__PURE__*/Object.freeze({
3957
+ __proto__: null,
3958
+ argsToParams: argsToParams,
3959
+ bindClickHandler: bindClickHandler,
3960
+ clickCancel: clickCancel,
3961
+ clickConfirm: clickConfirm,
3962
+ clickDeny: clickDeny,
3963
+ enableLoading: showLoading,
3964
+ fire: fire,
3965
+ getActions: getActions,
3966
+ getCancelButton: getCancelButton,
3967
+ getCloseButton: getCloseButton,
3968
+ getConfirmButton: getConfirmButton,
3969
+ getContainer: getContainer,
3970
+ getDenyButton: getDenyButton,
3971
+ getFocusableElements: getFocusableElements,
3972
+ getFooter: getFooter,
3973
+ getHtmlContainer: getHtmlContainer,
3974
+ getIcon: getIcon,
3975
+ getIconContent: getIconContent,
3976
+ getImage: getImage,
3977
+ getInputLabel: getInputLabel,
3978
+ getLoader: getLoader,
3979
+ getPopup: getPopup,
3980
+ getProgressSteps: getProgressSteps,
3981
+ getTimerLeft: getTimerLeft,
3982
+ getTimerProgressBar: getTimerProgressBar,
3983
+ getTitle: getTitle,
3984
+ getValidationMessage: getValidationMessage,
3985
+ increaseTimer: increaseTimer,
3986
+ isDeprecatedParameter: isDeprecatedParameter,
3987
+ isLoading: isLoading,
3988
+ isTimerRunning: isTimerRunning,
3989
+ isUpdatableParameter: isUpdatableParameter,
3990
+ isValidParameter: isValidParameter,
3991
+ isVisible: isVisible,
3992
+ mixin: mixin,
3993
+ off: off,
3994
+ on: on,
3995
+ once: once,
3996
+ resumeTimer: resumeTimer,
3997
+ showLoading: showLoading,
3998
+ stopTimer: stopTimer,
3999
+ toggleTimer: toggleTimer
4000
+ });
4001
+
4002
+ class Timer {
4003
+ /**
4004
+ * @param {() => void} callback
4005
+ * @param {number} delay
4006
+ */
4007
+ constructor(callback, delay) {
4008
+ this.callback = callback;
4009
+ this.remaining = delay;
4010
+ this.running = false;
4011
+ this.start();
4012
+ }
4013
+
4014
+ /**
4015
+ * @returns {number}
4016
+ */
4017
+ start() {
4018
+ if (!this.running) {
4019
+ this.running = true;
4020
+ this.started = new Date();
4021
+ this.id = setTimeout(this.callback, this.remaining);
4022
+ }
4023
+ return this.remaining;
4024
+ }
4025
+
4026
+ /**
4027
+ * @returns {number}
4028
+ */
4029
+ stop() {
4030
+ if (this.started && this.running) {
4031
+ this.running = false;
4032
+ clearTimeout(this.id);
4033
+ this.remaining -= new Date().getTime() - this.started.getTime();
4034
+ }
4035
+ return this.remaining;
4036
+ }
4037
+
4038
+ /**
4039
+ * @param {number} n
4040
+ * @returns {number}
4041
+ */
4042
+ increase(n) {
4043
+ const running = this.running;
4044
+ if (running) {
4045
+ this.stop();
4046
+ }
4047
+ this.remaining += n;
4048
+ if (running) {
4049
+ this.start();
4050
+ }
4051
+ return this.remaining;
4052
+ }
4053
+
4054
+ /**
4055
+ * @returns {number}
4056
+ */
4057
+ getTimerLeft() {
4058
+ if (this.running) {
4059
+ this.stop();
4060
+ this.start();
4061
+ }
4062
+ return this.remaining;
4063
+ }
4064
+
4065
+ /**
4066
+ * @returns {boolean}
4067
+ */
4068
+ isRunning() {
4069
+ return this.running;
4070
+ }
4071
+ }
4072
+
4073
+ const swalStringParams = ['swal-title', 'swal-html', 'swal-footer'];
4074
+
4075
+ /**
4076
+ * @param {SweetAlertOptions} params
4077
+ * @returns {SweetAlertOptions}
4078
+ */
4079
+ const getTemplateParams = params => {
4080
+ const template = typeof params.template === 'string' ? (/** @type {HTMLTemplateElement} */document.querySelector(params.template)) : params.template;
4081
+ if (!template) {
4082
+ return {};
4083
+ }
4084
+ /** @type {DocumentFragment} */
4085
+ const templateContent = template.content;
4086
+ showWarningsForElements(templateContent);
4087
+ const result = Object.assign(getSwalParams(templateContent), getSwalFunctionParams(templateContent), getSwalButtons(templateContent), getSwalImage(templateContent), getSwalIcon(templateContent), getSwalInput(templateContent), getSwalStringParams(templateContent, swalStringParams));
4088
+ return result;
4089
+ };
4090
+
4091
+ /**
4092
+ * @param {DocumentFragment} templateContent
4093
+ * @returns {Record<string, string | boolean | number>}
4094
+ */
4095
+ const getSwalParams = templateContent => {
4096
+ /** @type {Record<string, string | boolean | number>} */
4097
+ const result = {};
4098
+ /** @type {HTMLElement[]} */
4099
+ const swalParams = Array.from(templateContent.querySelectorAll('swal-param'));
4100
+ swalParams.forEach(param => {
4101
+ showWarningsForAttributes(param, ['name', 'value']);
4102
+ const paramName = /** @type {keyof SweetAlertOptions} */param.getAttribute('name');
4103
+ const value = param.getAttribute('value');
4104
+ if (!paramName || !value) {
4105
+ return;
4106
+ }
4107
+ if (paramName in defaultParams && typeof defaultParams[(/** @type {keyof typeof defaultParams} */paramName)] === 'boolean') {
4108
+ result[paramName] = value !== 'false';
4109
+ } else if (paramName in defaultParams && typeof defaultParams[(/** @type {keyof typeof defaultParams} */paramName)] === 'object') {
4110
+ result[paramName] = JSON.parse(value);
4111
+ } else {
4112
+ result[paramName] = value;
4113
+ }
4114
+ });
4115
+ return result;
4116
+ };
4117
+
4118
+ /**
4119
+ * @param {DocumentFragment} templateContent
4120
+ * @returns {Record<string, () => void>}
4121
+ */
4122
+ const getSwalFunctionParams = templateContent => {
4123
+ /** @type {Record<string, () => void>} */
4124
+ const result = {};
4125
+ /** @type {HTMLElement[]} */
4126
+ const swalFunctions = Array.from(templateContent.querySelectorAll('swal-function-param'));
4127
+ swalFunctions.forEach(param => {
4128
+ const paramName = /** @type {keyof SweetAlertOptions} */param.getAttribute('name');
4129
+ const value = param.getAttribute('value');
4130
+ if (!paramName || !value) {
4131
+ return;
4132
+ }
4133
+ result[paramName] = new Function(`return ${value}`)();
4134
+ });
4135
+ return result;
4136
+ };
4137
+
4138
+ /**
4139
+ * @param {DocumentFragment} templateContent
4140
+ * @returns {Record<string, string | boolean>}
4141
+ */
4142
+ const getSwalButtons = templateContent => {
4143
+ /** @type {Record<string, string | boolean>} */
4144
+ const result = {};
4145
+ /** @type {HTMLElement[]} */
4146
+ const swalButtons = Array.from(templateContent.querySelectorAll('swal-button'));
4147
+ swalButtons.forEach(button => {
4148
+ showWarningsForAttributes(button, ['type', 'color', 'aria-label']);
4149
+ const type = button.getAttribute('type');
4150
+ if (!type || !['confirm', 'cancel', 'deny'].includes(type)) {
4151
+ return;
4152
+ }
4153
+ result[`${type}ButtonText`] = button.innerHTML;
4154
+ result[`show${capitalizeFirstLetter(type)}Button`] = true;
4155
+ const color = button.getAttribute('color');
4156
+ if (color !== null) {
4157
+ result[`${type}ButtonColor`] = color;
4158
+ }
4159
+ const ariaLabel = button.getAttribute('aria-label');
4160
+ if (ariaLabel !== null) {
4161
+ result[`${type}ButtonAriaLabel`] = ariaLabel;
4162
+ }
4163
+ });
4164
+ return result;
4165
+ };
4166
+
4167
+ /**
4168
+ * @param {DocumentFragment} templateContent
4169
+ * @returns {Pick<SweetAlertOptions, 'imageUrl' | 'imageWidth' | 'imageHeight' | 'imageAlt'>}
4170
+ */
4171
+ const getSwalImage = templateContent => {
4172
+ const result = {};
4173
+ /** @type {HTMLElement | null} */
4174
+ const image = templateContent.querySelector('swal-image');
4175
+ if (image) {
4176
+ showWarningsForAttributes(image, ['src', 'width', 'height', 'alt']);
4177
+ // getAttribute returns null if attribute is absent; `|| undefined` converts empty string to undefined
4178
+ const src = image.getAttribute('src');
4179
+ if (src !== null) result.imageUrl = src || undefined;
4180
+ const width = image.getAttribute('width');
4181
+ if (width !== null) result.imageWidth = width || undefined;
4182
+ const height = image.getAttribute('height');
4183
+ if (height !== null) result.imageHeight = height || undefined;
4184
+ const alt = image.getAttribute('alt');
4185
+ if (alt !== null) result.imageAlt = alt || undefined;
4186
+ }
4187
+ return result;
4188
+ };
4189
+
4190
+ /**
4191
+ * @param {DocumentFragment} templateContent
4192
+ * @returns {object}
4193
+ */
4194
+ const getSwalIcon = templateContent => {
4195
+ const result = {};
4196
+ /** @type {HTMLElement | null} */
4197
+ const icon = templateContent.querySelector('swal-icon');
4198
+ if (icon) {
4199
+ showWarningsForAttributes(icon, ['type', 'color']);
4200
+ if (icon.hasAttribute('type')) {
4201
+ result.icon = icon.getAttribute('type');
4202
+ }
4203
+ if (icon.hasAttribute('color')) {
4204
+ result.iconColor = icon.getAttribute('color');
4205
+ }
4206
+ result.iconHtml = icon.innerHTML;
4207
+ }
4208
+ return result;
4209
+ };
4210
+
4211
+ /**
4212
+ * @param {DocumentFragment} templateContent
4213
+ * @returns {object}
4214
+ */
4215
+ const getSwalInput = templateContent => {
4216
+ /** @type {Record<string, any>} */
4217
+ const result = {};
4218
+ /** @type {HTMLElement | null} */
4219
+ const input = templateContent.querySelector('swal-input');
4220
+ if (input) {
4221
+ showWarningsForAttributes(input, ['type', 'label', 'placeholder', 'value']);
4222
+ result.input = input.getAttribute('type') || 'text';
4223
+ if (input.hasAttribute('label')) {
4224
+ result.inputLabel = input.getAttribute('label');
4225
+ }
4226
+ if (input.hasAttribute('placeholder')) {
4227
+ result.inputPlaceholder = input.getAttribute('placeholder');
4228
+ }
4229
+ if (input.hasAttribute('value')) {
4230
+ result.inputValue = input.getAttribute('value');
4231
+ }
4232
+ }
4233
+ /** @type {HTMLElement[]} */
4234
+ const inputOptions = Array.from(templateContent.querySelectorAll('swal-input-option'));
4235
+ if (inputOptions.length) {
4236
+ result.inputOptions = {};
4237
+ inputOptions.forEach(option => {
4238
+ showWarningsForAttributes(option, ['value']);
4239
+ const optionValue = option.getAttribute('value');
4240
+ if (!optionValue) {
4241
+ return;
4242
+ }
4243
+ const optionName = option.innerHTML;
4244
+ result.inputOptions[optionValue] = optionName;
4245
+ });
4246
+ }
4247
+ return result;
4248
+ };
4249
+
4250
+ /**
4251
+ * @param {DocumentFragment} templateContent
4252
+ * @param {string[]} paramNames
4253
+ * @returns {Record<string, string>}
4254
+ */
4255
+ const getSwalStringParams = (templateContent, paramNames) => {
4256
+ /** @type {Record<string, string>} */
4257
+ const result = {};
4258
+ for (const i in paramNames) {
4259
+ const paramName = paramNames[i];
4260
+ /** @type {HTMLElement | null} */
4261
+ const tag = templateContent.querySelector(paramName);
4262
+ if (tag) {
4263
+ showWarningsForAttributes(tag, []);
4264
+ result[paramName.replace(/^swal-/, '')] = tag.innerHTML.trim();
4265
+ }
4266
+ }
4267
+ return result;
4268
+ };
4269
+
4270
+ /**
4271
+ * @param {DocumentFragment} templateContent
4272
+ */
4273
+ const showWarningsForElements = templateContent => {
4274
+ const allowedElements = swalStringParams.concat(['swal-param', 'swal-function-param', 'swal-button', 'swal-image', 'swal-icon', 'swal-input', 'swal-input-option']);
4275
+ Array.from(templateContent.children).forEach(el => {
4276
+ const tagName = el.tagName.toLowerCase();
4277
+ if (!allowedElements.includes(tagName)) {
4278
+ warn(`Unrecognized element <${tagName}>`);
4279
+ }
4280
+ });
4281
+ };
4282
+
4283
+ /**
4284
+ * @param {HTMLElement} el
4285
+ * @param {string[]} allowedAttributes
4286
+ */
4287
+ const showWarningsForAttributes = (el, allowedAttributes) => {
4288
+ Array.from(el.attributes).forEach(attribute => {
4289
+ if (allowedAttributes.indexOf(attribute.name) === -1) {
4290
+ 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.'}`]);
4291
+ }
4292
+ });
4293
+ };
4294
+
4295
+ const SHOW_CLASS_TIMEOUT = 10;
4296
+
4297
+ /**
4298
+ * Open popup, add necessary classes and styles, fix scrollbar
4299
+ *
4300
+ * @param {SweetAlertOptions} params
4301
+ */
4302
+ const openPopup = params => {
4303
+ var _globalState$eventEmi, _globalState$eventEmi2;
4304
+ const container = getContainer();
4305
+ const popup = getPopup();
4306
+ if (!container || !popup) {
4307
+ return;
4308
+ }
4309
+ if (typeof params.willOpen === 'function') {
4310
+ params.willOpen(popup);
4311
+ }
4312
+ (_globalState$eventEmi = globalState.eventEmitter) === null || _globalState$eventEmi === void 0 || _globalState$eventEmi.emit('willOpen', popup);
4313
+ const bodyStyles = window.getComputedStyle(document.body);
4314
+ const initialBodyOverflow = bodyStyles.overflowY;
4315
+ addClasses(container, popup, params);
4316
+
4317
+ // scrolling is 'hidden' until animation is done, after that 'auto'
4318
+ setTimeout(() => {
4319
+ setScrollingVisibility(container, popup);
4320
+ }, SHOW_CLASS_TIMEOUT);
4321
+ if (isModal()) {
4322
+ fixScrollContainer(container, params.scrollbarPadding !== undefined ? params.scrollbarPadding : false, initialBodyOverflow);
4323
+ setAriaHidden();
4324
+ }
4325
+
4326
+ // https://github.com/sweetalert2/sweetalert2/issues/2923
4327
+ if (isIOS && params.backdrop === false && popup.scrollHeight > container.clientHeight) {
4328
+ // remove pointer-events: none from container, it breaks scrolling tall popups in iOS
4329
+ container.style.pointerEvents = 'auto';
4330
+ }
4331
+ if (!isToast() && !globalState.previousActiveElement) {
4332
+ globalState.previousActiveElement = document.activeElement;
4333
+ }
4334
+ if (typeof params.didOpen === 'function') {
4335
+ const didOpen = params.didOpen;
4336
+ setTimeout(() => didOpen(popup));
4337
+ }
4338
+ (_globalState$eventEmi2 = globalState.eventEmitter) === null || _globalState$eventEmi2 === void 0 || _globalState$eventEmi2.emit('didOpen', popup);
4339
+ };
4340
+
4341
+ /**
4342
+ * @param {Event} event
4343
+ */
4344
+ const swalOpenAnimationFinished = event => {
4345
+ const popup = getPopup();
4346
+ if (!popup || event.target !== popup) {
4347
+ return;
4348
+ }
4349
+ const container = getContainer();
4350
+ if (!container) {
4351
+ return;
4352
+ }
4353
+ popup.removeEventListener('animationend', swalOpenAnimationFinished);
4354
+ popup.removeEventListener('transitionend', swalOpenAnimationFinished);
4355
+ container.style.overflowY = 'auto';
4356
+
4357
+ // no-transition is added in init() in case one swal is opened right after another
4358
+ removeClass(container, swalClasses['no-transition']);
4359
+ };
4360
+
4361
+ /**
4362
+ * @param {HTMLElement} container
4363
+ * @param {HTMLElement} popup
4364
+ */
4365
+ const setScrollingVisibility = (container, popup) => {
4366
+ if (hasCssAnimation(popup)) {
4367
+ container.style.overflowY = 'hidden';
4368
+ popup.addEventListener('animationend', swalOpenAnimationFinished);
4369
+ popup.addEventListener('transitionend', swalOpenAnimationFinished);
4370
+ } else {
4371
+ container.style.overflowY = 'auto';
4372
+ }
4373
+ };
4374
+
4375
+ /**
4376
+ * @param {HTMLElement} container
4377
+ * @param {boolean} scrollbarPadding
4378
+ * @param {string} initialBodyOverflow
4379
+ */
4380
+ const fixScrollContainer = (container, scrollbarPadding, initialBodyOverflow) => {
4381
+ iOSfix();
4382
+ if (scrollbarPadding && initialBodyOverflow !== 'hidden') {
4383
+ replaceScrollbarWithPadding(initialBodyOverflow);
4384
+ }
4385
+
4386
+ // sweetalert2/issues/1247
4387
+ setTimeout(() => {
4388
+ container.scrollTop = 0;
4389
+ });
4390
+ };
4391
+
4392
+ /**
4393
+ * @param {HTMLElement} container
4394
+ * @param {HTMLElement} popup
4395
+ * @param {SweetAlertOptions} params
4396
+ */
4397
+ const addClasses = (container, popup, params) => {
4398
+ var _params$showClass;
4399
+ if ((_params$showClass = params.showClass) !== null && _params$showClass !== void 0 && _params$showClass.backdrop) {
4400
+ addClass(container, params.showClass.backdrop);
4401
+ }
4402
+ if (params.animation) {
4403
+ // this workaround with opacity is needed for https://github.com/sweetalert2/sweetalert2/issues/2059
4404
+ popup.style.setProperty('opacity', '0', 'important');
4405
+ show(popup, 'grid');
4406
+ setTimeout(() => {
4407
+ var _params$showClass2;
4408
+ // Animate popup right after showing it
4409
+ if ((_params$showClass2 = params.showClass) !== null && _params$showClass2 !== void 0 && _params$showClass2.popup) {
4410
+ addClass(popup, params.showClass.popup);
4411
+ }
4412
+ // and remove the opacity workaround
4413
+ popup.style.removeProperty('opacity');
4414
+ }, SHOW_CLASS_TIMEOUT); // 10ms in order to fix #2062
4415
+ } else {
4416
+ show(popup, 'grid');
4417
+ }
4418
+ addClass([document.documentElement, document.body], swalClasses.shown);
4419
+ if (params.heightAuto && params.backdrop && !params.toast) {
4420
+ addClass([document.documentElement, document.body], swalClasses['height-auto']);
4421
+ }
4422
+ };
4423
+
4424
+ var defaultInputValidators = {
4425
+ /**
4426
+ * @param {string} string
4427
+ * @param {string} [validationMessage]
4428
+ * @returns {Promise<string | void>}
4429
+ */
4430
+ email: (string, validationMessage) => {
4431
+ return /^[a-zA-Z0-9.+_'-]+@[a-zA-Z0-9.-]+\.[a-zA-Z0-9-]+$/.test(string) ? Promise.resolve() : Promise.resolve(validationMessage || 'Invalid email address');
4432
+ },
4433
+ /**
4434
+ * @param {string} string
4435
+ * @param {string} [validationMessage]
4436
+ * @returns {Promise<string | void>}
4437
+ */
4438
+ url: (string, validationMessage) => {
4439
+ // taken from https://stackoverflow.com/a/3809435 with a small change from #1306 and #2013
4440
+ 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');
4441
+ }
4442
+ };
4443
+
4444
+ /**
4445
+ * @param {SweetAlertOptions} params
4446
+ */
4447
+ function setDefaultInputValidators(params) {
4448
+ // Use default `inputValidator` for supported input types if not provided
4449
+ if (params.inputValidator) {
4450
+ return;
4451
+ }
4452
+ if (params.input === 'email') {
4453
+ params.inputValidator = defaultInputValidators['email'];
4454
+ }
4455
+ if (params.input === 'url') {
4456
+ params.inputValidator = defaultInputValidators['url'];
4457
+ }
4458
+ }
4459
+
4460
+ /**
4461
+ * @param {SweetAlertOptions} params
4462
+ */
4463
+ function validateCustomTargetElement(params) {
4464
+ // Determine if the custom target element is valid
4465
+ if (!params.target || typeof params.target === 'string' && !document.querySelector(params.target) || typeof params.target !== 'string' && !params.target.appendChild) {
4466
+ warn('Target parameter is not valid, defaulting to "body"');
4467
+ params.target = 'body';
4468
+ }
4469
+ }
4470
+
4471
+ /**
4472
+ * Set type, text and actions on popup
4473
+ *
4474
+ * @param {SweetAlertOptions} params
4475
+ */
4476
+ function setParameters(params) {
4477
+ setDefaultInputValidators(params);
4478
+
4479
+ // showLoaderOnConfirm && preConfirm
4480
+ if (params.showLoaderOnConfirm && !params.preConfirm) {
4481
+ 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');
4482
+ }
4483
+ validateCustomTargetElement(params);
4484
+
4485
+ // Replace newlines with <br> in title
4486
+ if (typeof params.title === 'string') {
4487
+ params.title = params.title.split('\n').join('<br />');
4488
+ }
4489
+ init(params);
4490
+ }
4491
+
4492
+ /** @type {SweetAlert} */
4493
+ let currentInstance;
4494
+ var _promise = /*#__PURE__*/new WeakMap();
4495
+ class SweetAlert {
4496
+ /**
4497
+ * @param {...(SweetAlertOptions | string)} args
4498
+ * @this {SweetAlert}
4499
+ */
4500
+ constructor(...args) {
4501
+ /**
4502
+ * @type {Promise<SweetAlertResult>}
4503
+ */
4504
+ _classPrivateFieldInitSpec(this, _promise, /** @type {Promise<SweetAlertResult>} */
4505
+ Promise.resolve({
4506
+ isConfirmed: false,
4507
+ isDenied: false,
4508
+ isDismissed: true
4509
+ }));
4510
+ // Prevent run in Node env
4511
+ if (typeof window === 'undefined') {
4512
+ return;
4513
+ }
4514
+ currentInstance = this;
4515
+
4516
+ // @ts-ignore
4517
+ const outerParams = Object.freeze(this.constructor.argsToParams(args));
4518
+
4519
+ /** @type {Readonly<SweetAlertOptions>} */
4520
+ this.params = outerParams;
4521
+
4522
+ /** @type {boolean} */
4523
+ this.isAwaitingPromise = false;
4524
+ _classPrivateFieldSet2(_promise, this, this._main(currentInstance.params));
4525
+ }
4526
+
4527
+ /**
4528
+ * @param {any} userParams
4529
+ * @param {any} mixinParams
4530
+ */
4531
+ _main(userParams, mixinParams = {}) {
4532
+ showWarningsForParams(Object.assign({}, mixinParams, userParams));
4533
+ if (globalState.currentInstance) {
4534
+ const swalPromiseResolve = privateMethods.swalPromiseResolve.get(globalState.currentInstance);
4535
+ const {
4536
+ isAwaitingPromise
4537
+ } = globalState.currentInstance;
4538
+ globalState.currentInstance._destroy();
4539
+ if (!isAwaitingPromise) {
4540
+ swalPromiseResolve({
4541
+ isDismissed: true
4542
+ });
4543
+ }
4544
+ if (isModal()) {
4545
+ unsetAriaHidden();
4546
+ }
4547
+ }
4548
+ globalState.currentInstance = currentInstance;
4549
+ const innerParams = prepareParams(userParams, mixinParams);
4550
+ setParameters(innerParams);
4551
+ Object.freeze(innerParams);
4552
+
4553
+ // clear the previous timer
4554
+ if (globalState.timeout) {
4555
+ globalState.timeout.stop();
4556
+ delete globalState.timeout;
4557
+ }
4558
+
4559
+ // clear the restore focus timeout
4560
+ clearTimeout(globalState.restoreFocusTimeout);
4561
+ const domCache = populateDomCache(currentInstance);
4562
+ render(currentInstance, innerParams);
4563
+ privateProps.innerParams.set(currentInstance, innerParams);
4564
+ return swalPromise(currentInstance, domCache, innerParams);
4565
+ }
4566
+
4567
+ // `catch` cannot be the name of a module export, so we define our thenable methods here instead
4568
+ /**
4569
+ * @param {any} onFulfilled
4570
+ */
4571
+ // oxlint-disable-next-line unicorn/no-thenable
4572
+ then(onFulfilled) {
4573
+ return _classPrivateFieldGet2(_promise, this).then(onFulfilled);
4574
+ }
4575
+
4576
+ /**
4577
+ * @param {any} onFinally
4578
+ */
4579
+ finally(onFinally) {
4580
+ return _classPrivateFieldGet2(_promise, this).finally(onFinally);
4581
+ }
4582
+ }
4583
+
4584
+ /**
4585
+ * @param {SweetAlert} instance
4586
+ * @param {DomCache} domCache
4587
+ * @param {SweetAlertOptions} innerParams
4588
+ * @returns {Promise<SweetAlertResult>}
4589
+ */
4590
+ const swalPromise = (instance, domCache, innerParams) => {
4591
+ return new Promise((resolve, reject) => {
4592
+ // functions to handle all closings/dismissals
4593
+ /**
4594
+ * @param {DismissReason} dismiss
4595
+ */
4596
+ const dismissWith = dismiss => {
4597
+ instance.close({
4598
+ isDismissed: true,
4599
+ dismiss,
4600
+ isConfirmed: false,
4601
+ isDenied: false
4602
+ });
4603
+ };
4604
+ privateMethods.swalPromiseResolve.set(instance, resolve);
4605
+ privateMethods.swalPromiseReject.set(instance, reject);
4606
+ domCache.confirmButton.onclick = () => {
4607
+ handleConfirmButtonClick(instance);
4608
+ };
4609
+ domCache.denyButton.onclick = () => {
4610
+ handleDenyButtonClick(instance);
4611
+ };
4612
+ domCache.cancelButton.onclick = () => {
4613
+ handleCancelButtonClick(instance, dismissWith);
4614
+ };
4615
+ domCache.closeButton.onclick = () => {
4616
+ dismissWith(DismissReason.close);
4617
+ };
4618
+ handlePopupClick(innerParams, domCache, dismissWith);
4619
+ addKeydownHandler(globalState, innerParams, dismissWith);
4620
+ handleInputOptionsAndValue(instance, innerParams);
4621
+ openPopup(innerParams);
4622
+ setupTimer(globalState, innerParams, dismissWith);
4623
+ initFocus(domCache, innerParams);
4624
+
4625
+ // Scroll container to top on open (#1247, #1946)
4626
+ setTimeout(() => {
4627
+ domCache.container.scrollTop = 0;
4628
+ });
4629
+ });
4630
+ };
4631
+
4632
+ /**
4633
+ * @param {SweetAlertOptions} userParams
4634
+ * @param {SweetAlertOptions} mixinParams
4635
+ * @returns {SweetAlertOptions}
4636
+ */
4637
+ const prepareParams = (userParams, mixinParams) => {
4638
+ const templateParams = getTemplateParams(userParams);
4639
+ const params = Object.assign({}, defaultParams, mixinParams, templateParams, userParams); // precedence is described in #2131
4640
+ params.showClass = Object.assign({}, defaultParams.showClass, params.showClass);
4641
+ params.hideClass = Object.assign({}, defaultParams.hideClass, params.hideClass);
4642
+ if (params.animation === false) {
4643
+ params.showClass = {
4644
+ backdrop: 'swal2-noanimation'
4645
+ };
4646
+ params.hideClass = {};
4647
+ }
4648
+ return params;
4649
+ };
4650
+
4651
+ /**
4652
+ * @param {SweetAlert} instance
4653
+ * @returns {DomCache}
4654
+ */
4655
+ const populateDomCache = instance => {
4656
+ const domCache = /** @type {DomCache} */{
4657
+ popup: (/** @type {HTMLElement} */getPopup()),
4658
+ container: (/** @type {HTMLElement} */getContainer()),
4659
+ actions: (/** @type {HTMLElement} */getActions()),
4660
+ confirmButton: (/** @type {HTMLElement} */getConfirmButton()),
4661
+ denyButton: (/** @type {HTMLElement} */getDenyButton()),
4662
+ cancelButton: (/** @type {HTMLElement} */getCancelButton()),
4663
+ loader: (/** @type {HTMLElement} */getLoader()),
4664
+ closeButton: (/** @type {HTMLElement} */getCloseButton()),
4665
+ validationMessage: (/** @type {HTMLElement} */getValidationMessage()),
4666
+ progressSteps: (/** @type {HTMLElement} */getProgressSteps())
4667
+ };
4668
+ privateProps.domCache.set(instance, domCache);
4669
+ return domCache;
4670
+ };
4671
+
4672
+ /**
4673
+ * @param {GlobalState} globalState
4674
+ * @param {SweetAlertOptions} innerParams
4675
+ * @param {(dismiss: DismissReason) => void} dismissWith
4676
+ */
4677
+ const setupTimer = (globalState, innerParams, dismissWith) => {
4678
+ const timerProgressBar = getTimerProgressBar();
4679
+ hide(timerProgressBar);
4680
+ if (innerParams.timer) {
4681
+ globalState.timeout = new Timer(() => {
4682
+ dismissWith('timer');
4683
+ delete globalState.timeout;
4684
+ }, innerParams.timer);
4685
+ if (innerParams.timerProgressBar && timerProgressBar) {
4686
+ show(timerProgressBar);
4687
+ applyCustomClass(timerProgressBar, innerParams, 'timerProgressBar');
4688
+ setTimeout(() => {
4689
+ if (globalState.timeout && globalState.timeout.running) {
4690
+ // timer can be already stopped or unset at this point
4691
+ animateTimerProgressBar(/** @type {number} */innerParams.timer);
4692
+ }
4693
+ });
4694
+ }
4695
+ }
4696
+ };
4697
+
4698
+ /**
4699
+ * Initialize focus in the popup:
4700
+ *
4701
+ * 1. If `toast` is `true`, don't steal focus from the document.
4702
+ * 2. Else if there is an [autofocus] element, focus it.
4703
+ * 3. Else if `focusConfirm` is `true` and confirm button is visible, focus it.
4704
+ * 4. Else if `focusDeny` is `true` and deny button is visible, focus it.
4705
+ * 5. Else if `focusCancel` is `true` and cancel button is visible, focus it.
4706
+ * 6. Else focus the first focusable element in a popup (if any).
4707
+ *
4708
+ * @param {DomCache} domCache
4709
+ * @param {SweetAlertOptions} innerParams
4710
+ */
4711
+ const initFocus = (domCache, innerParams) => {
4712
+ if (innerParams.toast) {
4713
+ return;
4714
+ }
4715
+ // TODO: this is dumb, remove `allowEnterKey` param in the next major version
4716
+ if (!callIfFunction(innerParams.allowEnterKey)) {
4717
+ warnAboutDeprecation('allowEnterKey', 'preConfirm: () => false');
4718
+ domCache.popup.focus();
4719
+ return;
4720
+ }
4721
+ if (focusAutofocus(domCache)) {
4722
+ return;
4723
+ }
4724
+ if (focusButton(domCache, innerParams)) {
4725
+ return;
4726
+ }
4727
+ setFocus(-1, 1);
4728
+ };
4729
+
4730
+ /**
4731
+ * @param {DomCache} domCache
4732
+ * @returns {boolean}
4733
+ */
4734
+ const focusAutofocus = domCache => {
4735
+ const autofocusElements = Array.from(domCache.popup.querySelectorAll('[autofocus]'));
4736
+ for (const autofocusElement of autofocusElements) {
4737
+ if (autofocusElement instanceof HTMLElement && isVisible$1(autofocusElement)) {
4738
+ autofocusElement.focus();
4739
+ return true;
4740
+ }
4741
+ }
4742
+ return false;
4743
+ };
4744
+
4745
+ /**
4746
+ * @param {DomCache} domCache
4747
+ * @param {SweetAlertOptions} innerParams
4748
+ * @returns {boolean}
4749
+ */
4750
+ const focusButton = (domCache, innerParams) => {
4751
+ if (innerParams.focusDeny && isVisible$1(domCache.denyButton)) {
4752
+ domCache.denyButton.focus();
4753
+ return true;
4754
+ }
4755
+ if (innerParams.focusCancel && isVisible$1(domCache.cancelButton)) {
4756
+ domCache.cancelButton.focus();
4757
+ return true;
4758
+ }
4759
+ if (innerParams.focusConfirm && isVisible$1(domCache.confirmButton)) {
4760
+ domCache.confirmButton.focus();
4761
+ return true;
4762
+ }
4763
+ return false;
4764
+ };
4765
+
4766
+ // Assign instance methods from src/instanceMethods/*.js to prototype
4767
+ SweetAlert.prototype.disableButtons = disableButtons;
4768
+ SweetAlert.prototype.enableButtons = enableButtons;
4769
+ SweetAlert.prototype.getInput = getInput;
4770
+ SweetAlert.prototype.disableInput = disableInput;
4771
+ SweetAlert.prototype.enableInput = enableInput;
4772
+ SweetAlert.prototype.hideLoading = hideLoading;
4773
+ SweetAlert.prototype.disableLoading = hideLoading;
4774
+ SweetAlert.prototype.showValidationMessage = showValidationMessage;
4775
+ SweetAlert.prototype.resetValidationMessage = resetValidationMessage;
4776
+ SweetAlert.prototype.close = close;
4777
+ SweetAlert.prototype.closePopup = close;
4778
+ SweetAlert.prototype.closeModal = close;
4779
+ SweetAlert.prototype.closeToast = close;
4780
+ SweetAlert.prototype.rejectPromise = rejectPromise;
4781
+ SweetAlert.prototype.update = update;
4782
+ SweetAlert.prototype._destroy = _destroy;
4783
+
4784
+ // Assign static methods from src/staticMethods/*.js to constructor
4785
+ Object.assign(SweetAlert, staticMethods);
4786
+
4787
+ // Proxy to instance methods to constructor, for now, for backwards compatibility
4788
+ Object.keys(instanceMethods).forEach(key => {
4789
+ /**
4790
+ * @param {...(SweetAlertOptions | string | undefined)} args
4791
+ * @returns {SweetAlertResult | Promise<SweetAlertResult> | undefined}
4792
+ */
4793
+ // @ts-ignore: Dynamic property assignment for backwards compatibility
4794
+ SweetAlert[key] = function (...args) {
4795
+ // @ts-ignore
4796
+ if (currentInstance && currentInstance[key]) {
4797
+ // @ts-ignore
4798
+ return currentInstance[key](...args);
4799
+ }
4800
+ return undefined;
4801
+ };
4802
+ });
4803
+ SweetAlert.DismissReason = DismissReason;
4804
+ SweetAlert.version = '11.26.24';
4805
+
4806
+ const Swal = SweetAlert;
4807
+ // @ts-ignore
4808
+ Swal.default = Swal;
4809
+
4810
+ return Swal;
4811
+
4812
+ }));
4813
+ if (typeof this !== 'undefined' && this.Sweetalert2){this.swal = this.sweetAlert = this.Swal = this.SweetAlert = this.Sweetalert2}
4814
+ "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-icon-animations: true;--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;container-name:swal2-popup}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)}@container swal2-popup style(--swal2-icon-animations:true){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}@container swal2-popup style(--swal2-icon-animations:true){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}@container swal2-popup style(--swal2-icon-animations:true){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}@container swal2-popup style(--swal2-icon-animations:true){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)}@container swal2-popup style(--swal2-icon-animations:true){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}@container swal2-popup style(--swal2-icon-animations:true){.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}}");