PageSourceSearch

https://truthtube.video/themes/youplay/js/lib/sweetalert2/dist/sweetalert2.js

js truthtube.video collected 2026-09-25 18:51:37 UTC 54,594 bytes, 1,812 lines download raw bytes

1/*!
2 * sweetalert2 v6.10.2
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.Sweetalert2 = factory());
9}(this, (function () { 'use strict';
10
11function __$styleInject(css, returnValue) {
12  if (typeof document === 'undefined') {
13    return returnValue;
14  }
15  css = css || '';
16  var head = document.head || document.getElementsByTagName('head')[0];
17  var style = document.createElement('style');
18  style.type = 'text/css';
19  head.appendChild(style);
20  
21  if (style.styleSheet){
22    style.styleSheet.cssText = css;
23  } else {
24    style.appendChild(document.createTextNode(css));
25  }
26  return returnValue;
27}
28
29var defaultParams = {
30  title: '',
31  titleText: '',
32  text: '',
33  html: '',
34  type: null,
35  customClass: '',
36  target: 'body',
37  animation: true,
38  allowOutsideClick: true,
39  allowEscapeKey: true,
40  allowEnterKey: true,
41  showConfirmButton: true,
42  showCancelButton: false,
43  preConfirm: null,
44  confirmButtonText: 'OK',
45  confirmButtonAriaLabel: '',
46  confirmButtonColor: '#3085d6',
47  confirmButtonClass: null,
48  cancelButtonText: 'Cancel',
49  cancelButtonAriaLabel: '',
50  cancelButtonColor: '#aaa',
51  cancelButtonClass: null,
52  buttonsStyling: true,
53  reverseButtons: false,
54  focusConfirm: true,
55  focusCancel: false,
56  showCloseButton: false,
57  closeButtonAriaLabel: 'Close this dialog',
58  showLoaderOnConfirm: false,
59  imageUrl: null,
60  imageWidth: null,
61  imageHeight: null,
62  imageAlt: '',
63  imageClass: null,
64  timer: null,
65  width: 500,
66  padding: 20,
67  background: '#fff',
68  input: null,
69  inputPlaceholder: '',
70  inputValue: '',
71  inputOptions: {},
72  inputAutoTrim: true,
73  inputClass: null,
74  inputAttributes: {},
75  inputValidator: null,
76  progressSteps: [],
77  currentProgressStep: null,
78  progressStepsDistance: '40px',
79  onOpen: null,
80  onClose: null,
81  useRejections: true,
82  closeOnConfirm:true
83};
84
85var swalPrefix = 'swal2-';
86
87var prefix = function prefix(items) {
88  var result = {};
89  for (var i in items) {
90    result[items[i]] = swalPrefix + items[i];
91  }
92  return result;
93};
94
95var swalClasses = prefix(['container', 'shown', 'iosfix', 'modal', 'overlay', 'fade', 'show', 'hide', 'noanimation', 'close', 'title', 'content', 'buttonswrapper', 'confirm', 'cancel', 'icon', 'image', 'input', 'file', 'range', 'select', 'radio', 'checkbox', 'textarea', 'inputerror', 'validationerror', 'progresssteps', 'activeprogressstep', 'progresscircle', 'progressline', 'loading', 'styled']);
96
97var iconTypes = prefix(['success', 'warning', 'info', 'question', 'error']);
98
99var consolePrefix = 'SweetAlert2:';
100
101/*
102 * Set hover, active and focus-states for buttons (source: http://www.sitepoint.com/javascript-generate-lighter-darker-color)
103 */
104var colorLuminance = function colorLuminance(hex, lum) {
105  // Validate hex string
106  hex = String(hex).replace(/[^0-9a-f]/gi, '');
107  if (hex.length < 6) {
108    hex = hex[0] + hex[0] + hex[1] + hex[1] + hex[2] + hex[2];
109  }
110  lum = lum || 0;
111
112  // Convert to decimal and change luminosity
113  var rgb = '#';
114  for (var i = 0; i < 3; i++) {
115    var c = parseInt(hex.substr(i * 2, 2), 16);
116    c = Math.round(Math.min(Math.max(0, c + c * lum), 255)).toString(16);
117    rgb += ('00' + c).substr(c.length);
118  }
119
120  return rgb;
121};
122
123var uniqueArray = function uniqueArray(arr) {
124  var result = [];
125  for (var i in arr) {
126    if (result.indexOf(arr[i]) === -1) {
127      result.push(arr[i]);
128    }
129  }
130  return result;
131};
132
133/**
134 * Standardise console warnings
135 * @param message
136 */
137var warn = function warn(message) {
138  console.warn(consolePrefix + ' ' + message);
139};
140
141/**
142 * Standardise console errors
143 * @param message
144 */
145var error = function error(message) {
146  console.error(consolePrefix + ' ' + message);
147};
148
149// Remember state in cases where opening and handling a modal will fiddle with it.
150var states = {
151  previousWindowKeyDown: null,
152  previousActiveElement: null,
153  previousBodyPadding: null
154
155  /*
156   * Add modal + overlay to DOM
157   */
158};var init = function init(params) {
159  // Clean up the old modal if it exists
160  var c = getContainer();
161  if (c) {
162    c.parentNode.removeChild(c);
163  }
164
165  if (typeof document === 'undefined') {
166    error('SweetAlert2 requires document to initialize');
167    return;
168  }
169
170  var container = document.createElement('div');
171  container.className = swalClasses.container;
172  container.innerHTML = sweetHTML;
173
174  var targetElement = typeof params.target === 'string' ? document.querySelector(params.target) : params.target;
175  targetElement.appendChild(container);
176
177  var modal = getModal();
178  var input = getChildByClass(modal, swalClasses.input);
179  var file = getChildByClass(modal, swalClasses.file);
180  var range = modal.querySelector('.' + swalClasses.range + ' input');
181  var rangeOutput = modal.querySelector('.' + swalClasses.range + ' output');
182  var select = getChildByClass(modal, swalClasses.select);
183  var checkbox = modal.querySelector('.' + swalClasses.checkbox + ' input');
184  var textarea = getChildByClass(modal, swalClasses.textarea);
185
186  input.oninput = function () {
187    sweetAlert.resetValidationError();
188  };
189
190  file.onchange = function () {
191    sweetAlert.resetValidationError();
192  };
193
194  range.oninput = function () {
195    sweetAlert.resetValidationError();
196    rangeOutput.value = range.value;
197  };
198
199  range.onchange = function () {
200    sweetAlert.resetValidationError();
201    range.previousSibling.value = range.value;
202  };
203
204  select.onchange = function () {
205    sweetAlert.resetValidationError();
206  };
207
208  checkbox.onchange = function () {
209    sweetAlert.resetValidationError();
210  };
211
212  textarea.oninput = function () {
213    sweetAlert.resetValidationError();
214  };
215
216  return modal;
217};
218
219/*
220 * Manipulate DOM
221 */
222
223var sweetHTML = ('\n <div role="dialog" aria-labelledby="' + swalClasses.title + '" aria-describedby="' + swalClasses.content + '" class="' + swalClasses.modal + '" tabindex="-1">\n   <ul class="' + swalClasses.progresssteps + '"></ul>\n   <div class="' + swalClasses.icon + ' ' + iconTypes.error + '">\n     <span class="swal2-x-mark"><span class="swal2-x-mark-line-left"></span><span class="swal2-x-mark-line-right"></span></span>\n   </div>\n   <div class="' + swalClasses.icon + ' ' + iconTypes.question + '">?</div>\n   <div class="' + swalClasses.icon + ' ' + iconTypes.warning + '">!</div>\n   <div class="' + swalClasses.icon + ' ' + iconTypes.info + '">i</div>\n   <div class="' + swalClasses.icon + ' ' + iconTypes.success + '">\n     <div class="swal2-success-circular-line-left"></div>\n     <span class="swal2-success-line-tip"></span> <span class="swal2-success-line-long"></span>\n     <div class="swal2-success-ring"></div> <div class="swal2-success-fix"></div>\n     <div class="swal2-success-circular-line-right"></div>\n   </div>\n   <img class="' + swalClasses.image + '" />\n   <h2 class="' + swalClasses.title + '" id="' + swalClasses.title + '"></h2>\n   <div id="' + swalClasses.content + '" class="' + swalClasses.content + '"></div>\n   <input class="' + swalClasses.input + '" />\n   <input type="file" class="' + swalClasses.file + '" />\n   <div class="' + swalClasses.range + '">\n     <output></output>\n     <input type="range" />\n   </div>\n   <select class="' + swalClasses.select + '"></select>\n   <div class="' + swalClasses.radio + '"></div>\n   <label for="' + swalClasses.checkbox + '" class="' + swalClasses.checkbox + '">\n     <input type="checkbox" />\n   </label>\n   <textarea class="' + swalClasses.textarea + '"></textarea>\n   <div class="' + swalClasses.validationerror + '" id="' + swalClasses.validationerror + '"></div>\n   <div class="' + swalClasses.buttonswrapper + '">\n     <button type="button" class="' + swalClasses.confirm + '">OK</button>\n     <button type="button" class="' + swalClasses.cancel + '">Cancel</button>\n   </div>\n   <button type="button" class="' + swalClasses.close + '">\xD7</button>\n </div>\n').replace(/(^|\n)\s*/g, '');
224
225var getContainer = function getContainer() {
226  return document.body.querySelector('.' + swalClasses.container);
227};
228
229var getModal = function getModal() {
230  return getContainer() ? getContainer().querySelector('.' + swalClasses.modal) : null;
231};
232
233var getIcons = function getIcons() {
234  var modal = getModal();
235  return modal.querySelectorAll('.' + swalClasses.icon);
236};
237
238var elementByClass = function elementByClass(className) {
239  return getContainer() ? getContainer().querySelector('.' + className) : null;
240};
241
242var getTitle = function getTitle() {
243  return elementByClass(swalClasses.title);
244};
245
246var getContent = function getContent() {
247  return elementByClass(swalClasses.content);
248};
249
250var getImage = function getImage() {
251  return elementByClass(swalClasses.image);
252};
253
254var getProgressSteps = function getProgressSteps() {
255  return elementByClass(swalClasses.progresssteps);
256};
257
258var getValidationError = function getValidationError() {
259  return elementByClass(swalClasses.validationerror);
260};
261
262var getConfirmButton = function getConfirmButton() {
263  return elementByClass(swalClasses.confirm);
264};
265
266var getCancelButton = function getCancelButton() {
267  return elementByClass(swalClasses.cancel);
268};
269
270var getButtonsWrapper = function getButtonsWrapper() {
271  return elementByClass(swalClasses.buttonswrapper);
272};
273
274var getCloseButton = function getCloseButton() {
275  return elementByClass(swalClasses.close);
276};
277
278var getFocusableElements = function getFocusableElements() {
279  var focusableElementsWithTabindex = Array.from(getModal().querySelectorAll('[tabindex]:not
279([tabindex="-1"]):not([tabindex="0"])'))
280  // sort according to tabindex
281  .sort(function (a, b) {
282    a = parseInt(a.getAttribute('tabindex'));
283    b = parseInt(b.getAttribute('tabindex'));
284    if (a > b) {
285      return 1;
286    } else if (a < b) {
287      return -1;
288    }
289    return 0;
290  });
291
292  var otherFocusableElements = Array.prototype.slice.call(getModal().querySelectorAll('button, input:not([type=hidden]), textarea, select, a, [tabindex="0"]'));
293
294  return uniqueArray(focusableElementsWithTabindex.concat(otherFocusableElements));
295};
296
297var hasClass = function hasClass(elem, className) {
298  if (elem.classList) {
299    return elem.classList.contains(className);
300  }
301  return false;
302};
303
304var focusInput = function focusInput(input) {
305  input.focus();
306
307  // place cursor at end of text in text input
308  if (input.type !== 'file') {
309    // http://stackoverflow.com/a/2345915/1331425
310    var val = input.value;
311    input.value = '';
312    input.value = val;
313  }
314};
315
316var addClass = function addClass(elem, className) {
317  if (!elem || !className) {
318    return;
319  }
320  var classes = className.split(/\s+/).filter(Boolean);
321  classes.forEach(function (className) {
322    elem.classList.add(className);
323  });
324};
325
326var removeClass = function removeClass(elem, className) {
327  if (!elem || !className) {
328    return;
329  }
330  var classes = className.split(/\s+/).filter(Boolean);
331  classes.forEach(function (className) {
332    elem.classList.remove(className);
333  });
334};
335
336var getChildByClass = function getChildByClass(elem, className) {
337  for (var i = 0; i < elem.childNodes.length; i++) {
338    if (hasClass(elem.childNodes[i], className)) {
339      return elem.childNodes[i];
340    }
341  }
342};
343
344var show = function show(elem, display) {
345  if (!display) {
346    display = 'block';
347  }
348  elem.style.opacity = '';
349  elem.style.display = display;
350};
351
352var hide = function hide(elem) {
353  elem.style.opacity = '';
354  elem.style.display = 'none';
355};
356
357var empty = function empty(elem) {
358  while (elem.firstChild) {
359    elem.removeChild(elem.firstChild);
360  }
361};
362
363// borrowed from jqeury $(elem).is(':visible') implementation
364var isVisible = function isVisible(elem) {
365  return elem.offsetWidth || elem.offsetHeight || elem.getClientRects().length;
366};
367
368var removeStyleProperty = function removeStyleProperty(elem, property) {
369  if (elem.style.removeProperty) {
370    elem.style.removeProperty(property);
371  } else {
372    elem.style.removeAttribute(property);
373  }
374};
375
376var animationEndEvent = function () {
377  var testEl = document.createElement('div');
378  var transEndEventNames = {
379    'WebkitAnimation': 'webkitAnimationEnd',
380    'OAnimation': 'oAnimationEnd oanimationend',
381    'animation': 'animationend'
382  };
383  for (var i in transEndEventNames) {
384    if (transEndEventNames.hasOwnProperty(i) && testEl.style[i] !== undefined) {
385      return transEndEventNames[i];
386    }
387  }
388
389  return false;
390}();
391
392// Reset previous window keydown handler and focued element
393var resetPrevState = function resetPrevState() {
394  window.onkeydown = states.previousWindowKeyDown;
395  if (states.previousActiveElement && states.previousActiveElement.focus) {
396    var x = window.scrollX;
397    var y = window.scrollY;
398    states.previousActiveElement.focus();
399    if (x && y) {
400      // IE has no scrollX/scrollY support
401      window.scrollTo(x, y);
402    }
403  }
404};
405
406// Measure width of scrollbar
407// https://github.com/twbs/bootstrap/blob/master/js/modal.js#L279-L286
408var measureScrollbar = function measureScrollbar() {
409  var supportsTouch = 'ontouchstart' in window || navigator.msMaxTouchPoints;
410  if (supportsTouch) {
411    return 0;
412  }
413  var scrollDiv = document.createElement('div');
414  scrollDiv.style.width = '50px';
415  scrollDiv.style.height = '50px';
416  scrollDiv.style.overflow = 'scroll';
417  document.body.appendChild(scrollDiv);
418  var scrollbarWidth = scrollDiv.offsetWidth - scrollDiv.clientWidth;
419  document.body.removeChild(scrollDiv);
420  return scrollbarWidth;
421};
422
423// JavaScript Debounce Function
424// Simplivied version of https://davidwalsh.name/javascript-debounce-function
425var debounce = function debounce(func, wait) {
426  var timeout = void 0;
427  return function () {
428    var later = function later() {
429      timeout = null;
430      func();
431    };
432    clearTimeout(timeout);
433    timeout = setTimeout(later, wait);
434  };
435};
436
437var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) {
438  return typeof obj;
439} : function (obj) {
440  return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
441};
442
443
444
445
446
447var asyncGenerator = function () {
448  function AwaitValue(value) {
449    this.value = value;
450  }
451
452  function AsyncGenerator(gen) {
453    var front, back;
454
455    function send(key, arg) {
456      return new Promise(function (resolve, reject) {
457        var request = {
458          key: key,
459          arg: arg,
460          resolve: resolve,
461          reject: reject,
462          next: null
463        };
464
465        if (back) {
466          back = back.next = request;
467        } else {
468          front = back = request;
469          resume(key, arg);
470        }
471      });
472    }
473
474    function resume(key, arg) {
475      try {
476        var result = gen[key](arg);
477        var value = result.value;
478
479        if (value instanceof AwaitValue) {
480          Promise.resolve(value.value).then(function (arg) {
481            resume("next", arg);
482          }, function (arg) {
483            resume("throw", arg);
484          });
485        } else {
486          settle(result.done ? "return" : "normal", result.value);
487        }
488      } catch (err) {
489        settle("throw", err);
490      }
491    }
492
493    function settle(type, value) {
494      switch (type) {
495        case "return":
496          front.resolve({
497            value: value,
498            done: true
499          });
500          break;
501
502        case "throw":
503          front.reject(value);
504          break;
505
506        default:
507          front.resolve({
508            value: value,
509            done: false
510          });
511          break;
512      }
513
514      front = front.next;
515
516      if (front) {
517        resume(front.key, front.arg);
518      } else {
519        back = null;
520      }
521    }
522
523    this._invoke = send;
524
525    if (typeof gen.return !== "function") {
526      this.return = undefined;
527    }
528  }
529
530  if (typeof Symbol === "function" && Symbol.asyncIterator) {
531    AsyncGenerator.prototype[Symbol.asyncIterator] = function () {
532      return this;
533    };
534  }
535
536  AsyncGenerator.prototype.next = function (arg) {
537    return this._invoke("next", arg);
538  };
539
540  AsyncGenerator.prototype.throw = function (arg) {
541    return this._invoke("throw", arg);
542  };
543
544  AsyncGenerator.prototype.return = function (arg) {
545    return this._invoke("return", arg);
546  };
547
548  return {
549    wrap: function (fn) {
550      return function () {
551        return new AsyncGenerator(fn.apply(this, arguments));
552      };
553    },
554    await: function (value) {
555      return new AwaitValue(value);
556    }
557  };
558}();
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574var _extends = Object.assign || function (target) {
575  for (var i = 1; i < arguments.length; i++) {
576    var source = arguments[i];
577
578    for (var key in source) {
579      if (Object.prototype.hasOwnProperty.call(source, key)) {
580        target[key] = source[key];
581      }
582    }
583  }
584
585  return target;
586};
587
588var modalParams = _extends({}, defaultParams);
589var queue = [];
590var swal2Observer = void 0;
591
592/*
593 * Check for the existence of Promise
594 * Hopefully to avoid many github issues
595 */
596if (typeof Promise === 'undefined') {
597  error('This package requires a Promise library, please include a shim to enable it in this browser (See: https://github.com/limonte/sweetalert2/wiki/Migration-from-SweetAlert-to-SweetAlert2#1-ie-support)');
598}
599
600/*
601 * Set type, text and actions on modal
602 */
603var setParameters = function setParameters(params) {
604  // If a custom element is set, determine if it is valid
605  if (typeof params.target === 'string' && !document.querySelector(params.target) || typeof params.target !== 'string' && !params.target.appendChild) {
606    warn('Target parameter is not valid, defaulting to "body"');
607    params.target = 'body';
608  }
609
610  var modal = void 0;
611  var oldModal = getModal();
612  var targetElement = typeof params.target === 'string' ? document.querySelector(params.target) : params.target;
613  // If the model target has changed, refresh the modal
614  if (oldModal && targetElement && oldModal.parentNode !== targetElement.parentNode) {
615    modal = init(params);
616  } else {
617    modal = oldModal || init(params);
618  }
619
620  for (var param in params) {
621    if (!sweetAlert.isValidParameter(param)) {
622      warn('Unknown parameter "' + param + '"');
623    }
624  }
625
626  // Set modal width
627  modal.style.width = typeof params.width === 'number' ? params.width + 'px' : params.width;
628
629  modal.style.padding = params.padding + 'px';
630  modal.style.background = params.background;
631  var successIconParts = modal.querySelectorAll('[class^=swal2-success-circular-line], .swal2-success-fix');
632  for (var i = 0; i < successIconParts.length; i++) {
633    successIconParts[i].style.background = params.background;
634  }
635
636  var title = getTitle();
637  var content = getContent();
638  var buttonsWrapper = getButtonsWrapper();
639  var confirmButton = getConfirmButton();
640  var cancelButton = getCancelButton();
641  var closeButton = getCloseButton();
642
643  // Title
644  if (params.titleText) {
645    title.innerText = params.titleText;
646  } else {
647    title.innerHTML = params.title.split('\n').join('<br />');
648  }
649
650  // Content
651  if (params.text || params.html) {
652    if (_typeof(params.html) === 'object') {
653      content.innerHTML = '';
654      if (0 in params.html) {
655        for (var _i = 0; _i in params.html; _i++) {
656          content.appendChild(params.html[_i].cloneNode(true));
657        }
658      } else {
659        content.appendChild(params.html.cloneNode(true));
660      }
661    } else if (params.html) {
662      content.innerHTML = params.html;
663    } else if (params.text) {
664      content.textContent = params.text;
665    }
666    show(content);
667  } else {
668    hide(content);
669  }
670
671  // Close button
672  if (params.showCloseButton) {
673    closeButton.setAttribute('aria-label', params.closeButtonAriaLabel);
674    show(closeButton);
675  } else {
676    hide(closeButton);
677  }
678
679  // Custom Class
680  modal.className = swalClasses.modal;
681  if (params.customClass) {
682    addClass(modal, params.customClass);
683  }
684
685  // Progress steps
686  var progressStepsContainer = getProgressSteps();
687  var currentProgressStep = parseInt(params.currentProgressStep === null ? sweetAlert.getQueueStep() : params.currentProgressStep, 10);
688  if (params.progressSteps.length) {
689    show(progressStepsContainer);
690    empty(progressStepsContainer);
691    if (currentProgressStep >= params.progressSteps.length) {
692      warn('Invalid currentProgressStep parameter, it should be less than progressSteps.length ' + '(currentProgressStep like JS arrays starts from 0)');
693    }
694    params.progressSteps.forEach(function (step, index) {
695      var circle = document.createElement('li');
696      addClass(circle, swalClasses.progresscircle);
697      circle.innerHTML = step;
698      if (index === currentProgressStep) {
699        addClass(circle, swalClasses.activeprogressstep);
700      }
701      progressStepsContainer.appendChild(circle);
702      if (index !== params.progressSteps.length - 1) {
703        var line = document.createElement('li');
704        addClass(line, swalClasses.progressline);
705        line.style.width = params.progressStepsDistance;
706        progressStepsContainer.appendChild(line);
707      }
708    });
709  } else {
710    hide(progressStepsContainer);
711  }
712
713  // Icon
714  var icons = getIcons();
715  for (var _i2 = 0; _i2 < icons.length; _i2++) {
716    hide(icons[_i2]);
717  }
718  if (params.type) {
719    var validType = false;
720    for (var iconType in iconTypes) {
721      if (params.type === iconType) {
722        validType = true;
723        break;
724      }
725    }
726    if (!validType) {
727      error('Unknown alert type: ' + params.type);
728      return false;
729    }
730    var icon = modal.querySelector('.' + swalClasses.icon + '.' + iconTypes[params.type]);
731    show(icon);
732
733    // Animate icon
734    if (params.animation) {
735      switch (params.type) {
736        case 'success':
737          addClass(icon, 'swal2-animate-success-icon');
738          addClass(icon.querySelector('.swal2-success-line-tip'), 'swal2-animate-success-line-tip');
739          addClass(icon.querySelector('.swal2-success-line-long'), 'swal2-animate-success-line-long');
740          break;
741        case 'error':
742          addClass(icon, 'swal2-animate-error-icon');
743          addClass(icon.querySelector('.swal2-x-mark'), 'swal2-animate-x-mark');
744          break;
745        default:
746          break;
747      }
748    }
749  }
750
751  // Custom image
752  var image = getImage();
753  if (params.imageUrl) {
754    image.setAttribute('src', params.imageUrl);
755    image.setAttribute('alt', params.imageAlt);
756    show(image);
757
758    if (params.imageWidth) {
759      image.setAttribute('width', params.imageWidth);
760    } else {
761      image.removeAttribute('width');
762    }
763
764    if (params.imageHeight) {
765      image.setAttribute('height', params.imageHeight);
766    } else {
767      image.removeAttribute('height');
768    }
769
770    image.className = swalClasses.image;
771    if (params.imageClass) {
772      addClass(image, params.imageClass);
773    }
774  } else {
775    hide(image);
776  }
777
778  // Cancel button
779  if (params.showCancelButton) {
780    cancelButton.style.display = 'inline-block';
781  } else {
782    hide(cancelButton);
783  }
784
785  // Confirm button
786  if (params.showConfirmButton) {
787    removeStyleProperty(confirmButton, 'display');
788  } else {
789    hide(confirmButton);
790  }
791
792  // Buttons wrapper
793  if (!params.showConfirmButton && !params.showCancelButton) {
794    hide(buttonsWrapper);
795  } else {
796    show(buttonsWrapper);
797  }
798
799  // Edit text on confirm and cancel buttons
800  confirmButton.innerHTML = params.confirmButtonText;
801  cancelButton.innerHTML = params.cancelButtonText;
802
803  // ARIA labels for confirm and cancel buttons
804  confirmButton.setAttribute('aria-label', params.confirmButtonAriaLabel);
805  cancelButton.setAttribute('aria-label', params.cancelButtonAriaLabel);
806
807  // Set buttons to selected background colors
808  if (params.buttonsStyling) {
809    confirmButton.style.backgroundColor = params.confirmButtonColor;
810    cancelButton.style.backgroundColor = params.cancelButtonColor;
811  }
812
813  // Add buttons custom classes
814  confirmButton.className = swalClasses.confirm;
815  addClass(confirmButton, params.confirmButtonClass);
816  cancelButton.className = swalClasses.cancel;
817  addClass(cancelButton, params.cancelButtonClass);
818
819  // Buttons styling
820  if (params.buttonsStyling) {
821    addClass(confirmButton, swalClasses.styled);
822    addClass(cancelButton, swalClasses.styled);
823  } else {
824    removeClass(confirmButton, swalClasses.styled);
825    removeClass(cancelButton, swalClasses.styled);
826
827    confirmButton.style.backgroundColor = confirmButton.style.borderLeftColor = confirmButton.style.borderRightColor = '';
828    cancelButton.style.backgroundColor = cancelButton.style.borderLeftColor = cancelButton.style.borderRightColor = '';
829  }
830
831  // CSS animation
832  if (params.animation === true) {
833    removeClass(modal, swalClasses.noanimation);
834  } else {
835    addClass(modal, swalClasses.noanimation);
836  }
837
838  // showLoaderOnConfirm && preConfirm
839  if (params.showLoaderOnConfirm && !params.preConfirm) {
840    warn('showLoaderOnConfirm is set to true, but preConfirm is not defined.\n' + 'showLoaderOnConfirm should be used together with preConfirm, see usage example:\n' + 'https://limonte.github.io/sweetalert2/#ajax-request');
841  }
842};
843
844/*
845 * Animations
846 */
847var openModal = function openModal(animation, onComplete) {
848  var container = getContainer();
849  var modal = getModal();
850
851  if (animation) {
852    addClass(modal, swalClasses.show);
853    addClass(container, swalClasses.fade);
854    removeClass(modal, swalClasses.hide);
855  } else {
856    removeClass(modal, swalClasses.fade);
857  }
858  show(modal);
859
860  // scrolling is 'hidden' until animation is done, after that 'auto'
861  container.style.overflowY = 'hidden';
862  if (animationEndEvent && !hasClass(modal, swalClasses.noanimation)) {
863    modal.addEventListener(animationEndEvent, function swalCloseEventFinished() {
864      modal.removeEventListener(animationEndEvent, swalCloseEventFinished);
865      container.style.overflowY = 'auto';
866    });
867  } else {
868    container.style.overflowY = 'auto';
869  }
870
871  addClass(document.documentElement, swalClasses.shown);
872  addClass(document.body, swalClasses.shown);
873  addClass(container, swalClasses.shown);
874  fixScrollbar();
875  iOSfix();
876  states.previousActiveElement = document.activeElement;
877  if (onComplete !== null && typeof onComplete === 'function') {
878    setTimeout(function () {
879      onComplete(modal);
880    });
881  }
882};
883
884var fixScrollbar = function fixScrollbar() {
885  // for queues, do not do this more than once
886  if (states.previousBodyPadding !== null) {
887    return;
888  }
889  // if the body has overflow
890  if (document.body.scrollHeight > window.innerHeight) {
891    // add padding so the content doesn't shift after removal of scrollbar
892    states.previousBodyPadding = document.body.style.paddingRight;
893    document.body.style.paddingRight = measureScrollbar() + 'px';
894  }
895};
896
897var undoScrollbar = function undoScrollbar() {
898  if (states.previousBodyPadding !== null) {
899    document.body.style.paddingRight = states.previousBodyPadding;
900    states.previousBodyPadding = null;
901  }
902};
903
904// Fix iOS scrolling http://stackoverflow.com/q/39626302/1331425
905var iOSfix = function iOSfix() {
906  var iOS = /iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream;
907  if (iOS && !hasClass(document.body, swalClasses.iosfix)) {
908    var offset = document.body.scrollTop;
909    document.body.style.top = offset * -1 + 'px';
910    addClass(document.body, swalClasses.iosfix);
911  }
912};
913
914var undoIOSfix = function undoIOSfix() {
915  if (hasClass(document.body, swalClasses.iosfix)) {
916    var offset = parseInt(document.body.style.top, 10);
917    removeClass(document.body, swalClasses.iosfix);
918    document.body.style.top = '';
919    document.body.scrollTop = offset * -1;
920  }
921};
922
923// SweetAlert entry point
924var sweetAlert = function sweetAlert() {
925  for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
926    args[_key] = arguments[_key];
927  }
928
929  if (args[0] === undefined) {
930    error('SweetAlert2 expects at least 1 attribute!');
931    return false;
932  }
933
934  var params = _extends({}, modalParams);
935
936  switch (_typeof(args[0])) {
937    case 'string':
938      params.title = args[0];
939      params.html = args[1];
940      params.type = args[2];
941
942      break;
943
944    case 'object':
945      _extends(params, args[0]);
946      params.extraParams = args[0].extraParams;
947
948      if (params.input === 'email' && params.inputValidator === null) {
949        params.inputValidator = function (email) {
950          return new Promise(function (resolve, reject) {
951            var emailRegex = /^[a-zA-Z0-9.+_-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,6}$/;
952            if (emailRegex.test(email)) {
953              resolve();
954            } else {
955              reject('Invalid email address');
956            }
957          });
958        };
959      }
960
961      if (params.input === 'url' && params.inputValidator === null) {
962        params.inputValidator = function (url) {
963          return new Promise(function (resolve, reject) {
964            // taken from https://stackoverflow.com/a/3809435/1331425
965            var urlRegex = /^https?:\/\/(www\.)?[-a-zA-Z0-9@:%._+~#=]{2,256}\.[a-z]{2,6}\b([-a-zA-Z0-9@:%_+.~#?&//=]*)$/;
966            if (urlRegex.test(url)) {
967              resolve();
968            } else {
969              reject('Invalid URL');
970            }
971          });
972        };
973      }
974      break;
975
976    default:
977      error('Unexpected type of argument! Expected "string" or "object", got ' + _typeof(args[0]));
978      return false;
979  }
980
981  setParameters(params);
982
983  var container = getContainer();
984  var modal = getModal();
985
986  return new Promise(function (resolve, reject) {
987    // Close on timer
988    if (params.timer) {
989      modal.timeout = setTimeout(function () {
990        sweetAlert.closeModal(params.onClose);
991        if (params.useRejections) {
992          reject('timer');
993        } else {
994          resolve({ dismiss: 'timer' });
995        }
996      }, params.timer);
997    }
998
999    // Get input element by specified type or, if type isn't specified, by params.input
1000    var getInput = function getInput(inputType) {
1001      inputType = inputType || params.input;
1002      if (!inputType) {
1003        return null;
1004      }
1005      switch (inputType) {
1006        case 'select':
1007        case 'textarea':
1008        case 'file':
1009          return getChildByClass(modal, swalClasses[inputType]);
1010        case 'checkbox':
1011          return modal.querySelector('.' + swalClasses.checkbox + ' input');
1012        case 'radio':
1013          return modal.querySelector('.' + swalClasses.radio + ' input:checked') || modal.querySelector('.' + swalClasses.radio + ' input:first-child');
1014        case 'range':
1015          return modal.querySelector('.' + swalClasses.range + ' input');
1016        default:
1017          return getChildByClass(modal, swalClasses.input);
1018      }
1019    };
1020
1021    // Get the value of the modal input
1022    var getInputValue = function getInputValue() {
1023      var input = getInput();
1024      if (!input) {
1025        return null;
1026      }
1027      switch (params.input) {
1028        case 'checkbox':
1029          return input.checked ? 1 : 0;
1030        case 'radio':
1031          return input.checked ? input.value : null;
1032        case 'file':
1033          return input.files.length ? input.files[0] : null;
1034        default:
1035          return params.inputAutoTrim ? input.value.trim() : input.value;
1036      }
1037    };
1038
1039    // input autofocus
1040    if (params.input) {
1041      setTimeout(function () {
1042        var input = getInput();
1043        if (input) {
1044          focusInput(input);
1045        }
1046      }, 0);
1047    }
1048
1049    var confirm = function confirm(value) {
1050      if (params.showLoaderOnConfirm) {
1051        sweetAlert.showLoading();
1052      }
1053
1054      if (params.preConfirm) {
1055        params.preConfirm(value, params.extraParams).then(function (preConfirmValue) {
1056          sweetAlert.closeModal(params.onClose);
1057          resolve(preConfirmValue || value);
1058        }, function (error$$1) {
1059          sweetAlert.hideLoading();
1060          if (error$$1) {
1061            sweetAlert.showValidationError(error$$1);
1062          }
1063        });
1064      } else {
1065        
1066        sweetAlert.closeModal(params.onClose);
1067        
1068        if (params.useRejections) {
1069          resolve(value);
1070        } else {
1071          resolve({ value: value });
1072        }
1073      }
1074    };
1075
1076    // Mouse interactions
1077    var onButtonEvent = function onButtonEvent(event) {
1078      var e = event || window.event;
1079      var target = e.target || e.srcElement;
1080      var confirmButton = getConfirmButton();
1081      var cancelButton = getCancelButton();
1082      var targetedConfirm = confirmButton && (confirmButton === target || confirmButton.contains(target));
1083      var targetedCancel = cancelButton && (cancelButton === target || cancelButton.contains(target));
1084
1085      switch (e.type) {
1086        case 'mouseover':
1087        case 'mouseup':
1088          if (params.buttonsStyling) {
1089            if (targetedConfirm) {
1090              confirmButton.style.backgroundColor = colorLuminance(params.confirmButtonColor, -0.1);
1091            } else if (targetedCancel) {
1092              cancelButton.style.backgroundColor = colorLuminance(params.cancelButtonColor, -0.1);
1093            }
1094          }
1095          break;
1096        case 'mouseout':
1097          if (params.buttonsStyling) {
1098            if (targetedConfirm) {
1099              confirmButton.style.backgroundColor = params.confirmButtonColor;
1100            } else if (targetedCancel) {
1101              cancelButton.style.backgroundColor = params.cancelButtonColor;
1102            }
1103          }
1104          break;
1105        case 'mousedown':
1106          if (params.buttonsStyling) {
1107            if (targetedConfirm) {
1108              confirmButton.style.backgroundColor = colorLuminance(params.confirmButtonColor, -0.2);
1109            } else if (targetedCancel) {
1110              cancelButton.style.backgroundColor = colorLuminance(params.cancelButtonColor, -0.2);
1111            }
1112          }
1113          break;
1114        case 'click':
1115          // Clicked 'confirm'
1116          if (targetedConfirm && sweetAlert.isVisible()) {
1117            sweetAlert.disableButtons();
1118            if (params.input) {
1119              var inputValue = getInputValue();
1120
1121              if (params.inputValidator) {
1122                sweetAlert.disableInput();
1123                params.inputValidator(inputValue, params.extraParams).then(function () {
1124                  sweetAlert.enableButtons();
1125                  sweetAlert.enableInput();
1126                  confirm(inputValue);
1127                }, function (error$$1) {
1128                  sweetAlert.enableButtons();
1129                  sweetAlert.enableInput();
1130                  if (error$$1) {
1131                    sweetAlert.showValidationError(error$$1);
1132                  }
1133                });
1134              } else {
1135                confirm(inputValue);
1136              }
1137            } else {
1138              confirm(true);
1139            }
1140
1141            // Clicked 'cancel'
1142          } else if (targetedCancel && sweetAlert.isVisible()) {
1143            sweetAlert.disableButtons();
1144            sweetAlert.closeModal(params.onClose);
1145            if (params.useRejections) {
1146              reject('cancel');
1147            } else {
1148              resolve({ dismiss: 'cancel' });
1149            }
1150          }
1151          break;
1152        default:
1153      }
1154    };
1155
1156    var buttons = modal.querySelectorAll('button');
1157    for (var i = 0; i < buttons.length; i++) {
1158      buttons[i].onclick = onButtonEvent;
1159      buttons[i].onmouseover = onButtonEvent;
1160      buttons[i].onmouseout = onButtonEvent;
1161      buttons[i].onmousedown = onButtonEvent;
1162    }
1163
1164    // Closing modal by close button
1165    getCloseButton().onclick = function () {
1166      sweetAlert.closeModal(params.onClose);
1167      if (params.useRejections) {
1168        reject('close');
1169      } else {
1170        resolve({ dismiss: 'close' });
1171      }
1172    };
1173
1174    // Closing modal by overlay click
1175    container.onclick = function (e) {
1176      if (e.target !== container) {
1177        return;
1178      }
1179      if (params.allowOutsideClick) {
1180        sweetAlert.closeModal(params.onClose);
1181        if (params.useRejections) {
1182          reject('overlay');
1183        } else {
1184          resolve({ dismiss: 'overlay' });
1185        }
1186      }
1187    };
1188
1189    var buttonsWrapper = getButtonsWrapper();
1190    var confirmButton = getConfirmButton();
1191    var cancelButton = getCancelButton();
1192
1193    // Reverse buttons (Confirm on the right side)
1194    if (params.reverseButtons) {
1195      confirmButton.parentNode.insertBefore(cancelButton, confirmButton);
1196    } else {
1197      confirmButton.parentNode.insertBefore(confirmButton, cancelButton);
1198    }
1199
1200    // Focus handling
1201    var setFocus = function setFocus(index, increment) {
1202      var focusableElements = getFocusableElements(params.focusCancel);
1203      // search for visible elements and select the next possible match
1204      for (var _i3 = 0; _i3 < focusableElements.length; _i3++) {
1205        index = index + increment;
1206
1207        // rollover to first item
1208        if (index === focusableElements.length) {
1209          index = 0;
1210
1211          // go to last item
1212        } else if (index === -1) {
1213          index = focusableElements.length - 1;
1214        }
1215
1216        // determine if element is visible
1217        var el = focusableElements[index];
1218        if (isVisible(el)) {
1219          return el.focus();
1220        }
1221      }
1222    };
1223
1224    var handleKeyDown = function handleKeyDown(event) {
1225      var e = event || window.event;
1226
1227      if (e.key === 'Enter') {
1228        if (e.target === getInput()) {
1229          sweetAlert.clickConfirm();
1230          e.preventDefault();
1231        }
1232
1233        // TAB
1234      } else if (e.key === 'Tab') {
1235        var targetElement = e.target || e.srcElement;
1236
1237        var focusableElements = getFocusableElements(params.focusCancel);
1238        var btnIndex = -1; // Find the button - note, this is a nodelist, not an array.
1239        for (var _i4 = 0; _i4 < focusableElements.length; _i4++) {
1240          if (targetElement === focusableElements[_i4]) {
1241            btnIndex = _i4;
1242            break;
1243          }
1244        }
1245
1246        if (!e.shiftKey) {
1247          // Cycle to the next button
1248          setFocus(btnIndex, 1);
1249        } else {
1250          // Cycle to the prev button
1251          setFocus(btnIndex, -1);
1252        }
1253        e.stopPropagation();
1254        e.preventDefault();
1255
1256        // ARROWS - switch focus between buttons
1257      } else if (['ArrowLeft', 'ArrowRight', 'ArrowUp', 'Arrowdown'].includes(e.key)) {
1258        // focus Cancel button if Confirm button is currently focused
1259        if (document.activeElement === confirmButton && isVisible(cancelButton)) {
1260          cancelButton.focus();
1261          // and vice versa
1262        } else if (document.activeElement === cancelButton && isVisible(confirmButton)) {
1263          confirmButton.focus();
1264        }
1265
1266        // ESC
1267      } else if (e.key === 'Escape' && params.allowEscapeKey === true) {
1268        sweetAlert.closeModal(params.onClose);
1269        if (params.useRejections) {
1270          reject('esc');
1271        } else {
1272          resolve({ dismiss: 'esc' });
1273        }
1274      }
1275    };
1276
1277    if (!window.onkeydown || window.onkeydown.toString() !== handleKeyDown.toString()) {
1278      states.previousWindowKeyDown = window.onkeydown;
1279      window.onkeydown = handleKeyDown;
1280    }
1281
1282    // Loading state
1283    if (params.buttonsStyling) {
1284      confirmButton.style.borderLeftColor = params.confirmButtonColor;
1285      confirmButton.style.borderRightColor = params.confirmButtonColor;
1286    }
1287
1288    /**
1289     * Show spinner instead of Confirm button and disable Cancel button
1290     */
1291    sweetAlert.hideLoading = sweetAlert.disableLoading = function () {
1292      if (!params.showConfirmButton) {
1293        hide(confirmButton);
1294        if (!params.showCancelButton) {
1295          hide(getButtonsWrapper());
1296        }
1297      }
1298      removeClass(buttonsWrapper, swalClasses.loading);
1299      removeClass(modal, swalClasses.loading);
1300      modal.removeAttribute('aria-busy');
1301      confirmButton.disabled = false;
1302      cancelButton.disabled = false;
1303    };
1304
1305    sweetAlert.getTitle = function () {
1306      return getTitle();
1307    };
1308    sweetAlert.getContent = function () {
1309      return getContent();
1310    };
1311    sweetAlert.getInput = function () {
1312      return getInput();
1313    };
1314    sweetAlert.getImage = function () {
1315      return getImage();
1316    };
1317    sweetAlert.getButtonsWrapper = function () {
1318      return getButtonsWrapper();
1319    };
1320    sweetAlert.getConfirmButton = function () {
1321      return getConfirmButton();
1322    };
1323    sweetAlert.getCancelButton = function () {
1324      return getCancelButton();
1325    };
1326
1327    sweetAlert.enableButtons = function () {
1328      confirmButton.disabled = false;
1329      cancelButton.disabled = false;
1330    };
1331
1332    sweetAlert.disableButtons = function () {
1333      confirmButton.disabled = true;
1334      cancelButton.disabled = true;
1335    };
1336
1337    sweetAlert.enableConfirmButton = function () {
1338      confirmButton.disabled = false;
1339    };
1340
1341    sweetAlert.disableConfirmButton = function () {
1342      confirmButton.disabled = true;
1343    };
1344
1345    sweetAlert.enableInput = function () {
1346      var input = getInput();
1347      if (!input) {
1348        return false;
1349      }
1350      if (input.type === 'radio') {
1351        var radiosContainer = input.parentNode.parentNode;
1352        var radios = radiosContainer.querySelectorAll('input');
1353        for (var _i5 = 0; _i5 < radios.length; _i5++) {
1354          radios[_i5].disabled = false;
1355        }
1356      } else {
1357        input.disabled = false;
1358      }
1359    };
1360
1361    sweetAlert.disableInput = function () {
1362      var input = getInput();
1363      if (!input) {
1364        return false;
1365      }
1366      if (input && input.type === 'radio') {
1367        var radiosContainer = input.parentNode.parentNode;
1368        var radios = radiosContainer.querySelectorAll('input');
1369        for (var _i6 = 0; _i6 < radios.length; _i6++) {
1370          radios[_i6].disabled = true;
1371        }
1372      } else {
1373        input.disabled = true;
1374      }
1375    };
1376
1377    // Set modal min-height to disable scrolling inside the modal
1378    sweetAlert.recalculateHeight = debounce(function () {
1379      var modal = getModal();
1380      if (!modal) {
1381        return;
1382      }
1383      var prevState = modal.style.display;
1384      modal.style.minHeight = '';
1385      show(modal);
1386      modal.style.minHeight = modal.scrollHeight + 1 + 'px';
1387      modal.style.display = prevState;
1388    }, 50);
1389
1390    // Show block with validation error
1391    sweetAlert.showValidationError = function (error$$1) {
1392      var validationError = getValidationError();
1393      validationError.innerHTML = error$$1;
1394      show(validationError);
1395
1396      var input = getInput();
1397      if (input) {
1398        input.setAttribute('aria-invalid', true);
1399        input.setAttribute('aria-describedBy', swalClasses.validationerror);
1400        focusInput(input);
1401        addClass(input, swalClasses.inputerror);
1402      }
1403    };
1404
1405    // Hide block with validation error
1406    sweetAlert.resetValidationError = function () {
1407      var validationError = getValidationError();
1408      hide(validationError);
1409      sweetAlert.recalculateHeight();
1410
1411      var input = getInput();
1412      if (input) {
1413        input.removeAttribute('aria-invalid');
1414        input.removeAttribute('aria-describedBy');
1415        removeClass(input, swalClasses.inputerror);
1416      }
1417    };
1418
1419    sweetAlert.getProgressSteps = function () {
1420      return params.progressSteps;
1421    };
1422
1423    sweetAlert.setProgressSteps = function (progressSteps) {
1424      params.progressSteps = progressSteps;
1425      setParameters(params);
1426    };
1427
1428    sweetAlert.showProgressSteps = function () {
1429      show(getProgressSteps());
1430    };
1431
1432    sweetAlert.hideProgressSteps = function () {
1433      hide(getProgressSteps());
1434    };
1435
1436    sweetAlert.enableButtons();
1437    sweetAlert.hideLoading();
1438    sweetAlert.resetValidationError();
1439
1440    // inputs
1441    var inputTypes = ['input', 'file', 'range', 'select', 'radio', 'checkbox', 'textarea'];
1442    var input = void 0;
1443    for (var _i7 = 0; _i7 < inputTypes.length; _i7++) {
1444      var inputClass = swalClasses[inputTypes[_i7]];
1445      var inputContainer = getChildByClass(modal, inputClass);
1446      input = getInput(inputTypes[_i7]);
1447
1448      // set attributes
1449      if (input) {
1450        for (var j in input.attributes) {
1451          if (input.attributes.hasOwnProperty(j)) {
1452            var attrName = input.attributes[j].name;
1453            if (attrName !== 'type' && attrName !== 'value') {
1454              input.removeAttribute(attrName);
1455            }
1456          }
1457        }
1458        for (var attr in params.inputAttributes) {
1459          input.setAttribute(attr, params.inputAttributes[attr]);
1460        }
1461      }
1462
1463      // set class
1464      inputContainer.className = inputClass;
1465      if (params.inputClass) {
1466        addClass(inputContainer, params.inputClass);
1467      }
1468
1469      hide(inputContainer);
1470    }
1471
1472    var populateInputOptions = void 0;
1473    switch (params.input) {
1474      case 'text':
1475      case 'email':
1476      case 'password':
1477      case 'number':
1478      case 'tel':
1479      case 'url':
1480        input = getChildByClass(modal, swalClasses.input);
1481        input.value = params.inputValue;
1482        input.placeholder = params.inputPlaceholder;
1483        input.type = params.input;
1484        show(input);
1485        break;
1486      case 'file':
1487        input = getChildByClass(modal, swalClasses.file);
1488        input.placeholder = params.inputPlaceholder;
1489        input.type = params.input;
1490        show(input);
1491        break;
1492      case 'range':
1493        var range = getChildByClass(modal, swalClasses.range);
1494        var rangeInput = range.querySelector('input');
1495        var rangeOutput = range.querySelector('output');
1496        rangeInput.value = params.inputValue;
1497        rangeInput.type = params.input;
1498        rangeOutput.value = params.inputValue;
1499        show(range);
1500        break;
1501      case 'select':
1502        var select = getChildByClass(modal, swalClasses.select);
1503        select.innerHTML = '';
1504        if (params.inputPlaceholder) {
1505          var placeholder = document.createElement('option');
1506          placeholder.innerHTML = params.inputPlaceholder;
1507          placeholder.value = '';
1508          placeholder.disabled = true;
1509          placeholder.selected = true;
1510          select.appendChild(placeholder);
1511        }
1512        populateInputOptions = function populateInputOptions(inputOptions) {
1513          for (var optionValue in inputOptions) {
1514            var option = document.createElement('option');
1515            option.value = optionValue;
1516            option.innerHTML = inputOptions[optionValue];
1517            if (params.inputValue === optionValue) {
1518              option.selected = true;
1519            }
1520            select.appendChild(option);
1521          }
1522          show(select);
1523          select.focus();
1524        };
1525        break;
1526      case 'radio':
1527        var radio = getChildByClass(modal, swalClasses.radio);
1528        radio.innerHTML = '';
1529        populateInputOptions = function populateInputOptions(inputOptions) {
1530          for (var radioValue in inputOptions) {
1531            var radioInput = document.createElement('input');
1532            var radioLabel = document.createElement('label');
1533            var radioLabelSpan = document.createElement('span');
1534            radioInput.type = 'radio';
1535            radioInput.name = swalClasses.radio;
1536            radioInput.value = radioValue;
1537            if (params.inputValue === radioValue) {
1538              radioInput.checked = true;
1539            }
1540            radioLabelSpan.innerHTML = inputOptions[radioValue];
1541            radioLabel.appendChild(radioInput);
1542            radioLabel.appendChild(radioLabelSpan);
1543            radioLabel.for = radioInput.id;
1544            radio.appendChild(radioLabel);
1545          }
1546          show(radio);
1547          var radios = radio.querySelectorAll('input');
1548          if (radios.length) {
1549            radios[0].focus();
1550          }
1551        };
1552        break;
1553      case 'checkbox':
1554        var checkbox = getChildByClass(modal, swalClasses.checkbox);
1555        var checkboxInput = getInput('checkbox');
1556        checkboxInput.type = 'checkbox';
1557        checkboxInput.value = 1;
1558        checkboxInput.id = swalClasses.checkbox;
1559        checkboxInput.checked = Boolean(params.inputValue);
1560        var label = checkbox.getElementsByTagName('span');
1561        if (label.length) {
1562          checkbox.removeChild(label[0]);
1563        }
1564        label = document.createElement('span');
1565        label.innerHTML = params.inputPlaceholder;
1566        checkbox.appendChild(label);
1567        show(checkbox);
1568        break;
1569      case 'textarea':
1570        var textarea = getChildByClass(modal, swalClasses.textarea);
1571        textarea.value = params.inputValue;
1572        textarea.placeholder = params.inputPlaceholder;
1573        show(textarea);
1574        break;
1575      case null:
1576        break;
1577      default:
1578        error('Unexpected type of input! Expected "text", "email", "password", "number", "tel", "select", "radio", "checkbox", "textarea", "file" or "url", got "' + params.input + '"');
1579        break;
1580    }
1581
1582    if (params.input === 'select' || params.input === 'radio') {
1583      if (params.inputOptions instanceof Promise) {
1584        sweetAlert.showLoading();
1585        params.inputOptions.then(function (inputOptions) {
1586          sweetAlert.hideLoading();
1587          populateInputOptions(inputOptions);
1588        });
1589      } else if (_typeof(params.inputOptions) === 'object') {
1590        populateInputOptions(params.inputOptions);
1591      } else {
1592        error('Unexpected type of inputOptions! Expected object or Promise, got ' + _typeof(params.inputOptions));
1593      }
1594    }
1595
1596    openModal(params.animation, params.onOpen);
1597
1598    if (!params.allowEnterKey) {
1599      if (document.activeElement) {
1600        document.activeElement.blur();
1601      }
1602    } else if (params.focusCancel && isVisible(cancelButton)) {
1603      cancelButton.focus();
1604    } else if (params.focusConfirm && isVisible(confirmButton)) {
1605      confirmButton.focus();
1606    } else {
1607      setFocus(-1, 1);
1608    }
1609
1610    // fix scroll
1611    getContainer().scrollTop = 0;
1612
1613    // Observe changes inside the modal and adjust height
1614    if (typeof MutationObserver !== 'undefined' && !swal2Observer) {
1615      swal2Observer = new MutationObserver(sweetAlert.recalculateHeight);
1616      swal2Observer.observe(modal, { childList: true, characterData: true, subtree: true });
1617    }
1618  });
1619};
1620
1621/*
1622 * Global function to determine if swal2 modal is shown
1623 */
1624sweetAlert.isVisible = function () {
1625  return !!getModal();
1626};
1627
1628/*
1629 * Global function for chaining sweetAlert modals
1630 */
1631sweetAlert.queue = function (steps) {
1632  queue = steps;
1633  var resetQueue = function resetQueue() {
1634    queue = [];
1635    document.body.removeAttribute('data-swal2-queue-step');
1636  };
1637  var queueResult = [];
1638  return new Promise(function (resolve, reject) {
1639    (function step(i, callback) {
1640      if (i < queue.length) {
1641        document.body.setAttribute('data-swal2-queue-step', i);
1642
1643        sweetAlert(queue[i]).then(function (result) {
1644          queueResult.push(result);
1645          step(i + 1, callback);
1646        }, function (dismiss) {
1647          resetQueue();
1648          reject(dismiss);
1649        });
1650      } else {
1651        resetQueue();
1652        resolve(queueResult);
1653      }
1654    })(0);
1655  });
1656};
1657
1658/*
1659 * Global function for getting the index of current modal in queue
1660 */
1661sweetAlert.getQueueStep = function () {
1662  return document.body.getAttribute('data-swal2-queue-step');
1663};
1664
1665/*
1666 * Global function for inserting a modal to the queue
1667 */
1668sweetAlert.insertQueueStep = function (step, index) {
1669  if (index && index < queue.length) {
1670    return queue.splice(index, 0, step);
1671  }
1672  return queue.push(step);
1673};
1674
1675/*
1676 * Global function for deleting a modal from the queue
1677 */
1678sweetAlert.deleteQueueStep = function (index) {
1679  if (typeof queue[index] !== 'undefined') {
1680    queue.splice(index, 1);
1681  }
1682};
1683
1684/*
1685 * Global function to close sweetAlert
1686 */
1687sweetAlert.close = sweetAlert.closeModal = function (onComplete) {
1688  var container = getContainer();
1689  var modal     = getModal();
1690  if (!modal) {
1691    return;
1692  }
1693
1694  removeClass(modal, swalClasses.show);
1695  addClass(modal, swalClasses.hide);
1696  clearTimeout(modal.timeout);
1697
1698  resetPrevState();
1699
1700  var removeModalAndResetState = function removeModalAndResetState() {
1701    if (container.parentNode) {
1702      container.parentNode.removeChild(container);
1703    }
1704    removeClass(document.documentElement, swalClasses.shown);
1705    removeClass(document.body, swalClasses.shown);
1706    undoScrollbar();
1707    undoIOSfix();
1708  };
1709
1710  // If animation is supported, animate
1711  if (animationEndEvent && !hasClass(modal, swalClasses.noanimation)) {
1712    modal.addEventListener(animationEndEvent, function swalCloseEventFinished() {
1713      modal.removeEventListener(animationEndEvent, swalCloseEventFinished);
1714      if (hasClass(modal, swalClasses.hide)) {
1715        removeModalAndResetState();
1716      }
1717    });
1718  } 
1719
1720  else {
1721    // Otherwise, remove immediately
1722    removeModalAndResetState();
1723  }
1724  if (onComplete !== null && typeof onComplete === 'function') {
1725    setTimeout(function () {
1726      onComplete(modal);
1727    });
1728  }
1729};
1730
1731/*
1732 * Global function to click 'Confirm' button
1733 */
1734sweetAlert.clickConfirm = function () {
1735  return getConfirmButton().click();
1736};
1737
1738/*
1739 * Global function to click 'Cancel' button
1740 */
1741sweetAlert.clickCancel = function () {
1742  return getCancelButton().click();
1743};
1744
1745/**
1746 * Show spinner instead of Confirm button and disable Cancel button
1747 */
1748sweetAlert.showLoading = sweetAlert.enableLoading = function () {
1749  var modal = getModal();
1750  if (!modal) {
1751    sweetAlert('');
1752  }
1753  modal = getModal();
1754  var buttonsWrapper = getButtonsWrapper();
1755  var confirmButton = getConfirmButton();
1756  var cancelButton = getCancelButton();
1757
1758  show(buttonsWrapper);
1759  show(confirmButton, 'inline-block');
1760  addClass(buttonsWrapper, swalClasses.loading);
1761  addClass(modal, swalClasses.loading);
1762  confirmButton.disabled = true;
1763  cancelButton.disabled = true;
1764
1765  modal.setAttribute('aria-busy', true);
1766  modal.focus();
1767};
1768
1769/**
1770 * Is valid parameter
1771 * @param {String} paramName
1772 */
1773sweetAlert.isValidParameter = function (paramName) {
1774  return defaultParams.hasOwnProperty(paramName) || paramName === 'extraParams';
1775};
1776
1777/**
1778* Set default params for each popup
1779* @param {Object} userParams
1780*/
1781sweetAlert.setDefaults = function (userParams) {
1782  if (!userParams || (typeof userParams === 'undefined' ? 'undefined' : _typeof(userParams)) !== 'object') {
1783    return error('the argument for setDefaults() is required and has to be a object');
1784  }
1785
1786  for (var param in userParams) {
1787    if (!sweetAlert.isValidParameter(param)) {
1788      warn('Unknown parameter "' + param + '"');
1789      delete userParams[param];
1790    }
1791  }
1792
1793  _extends(modalParams, userParams);
1794};
1795
1796/**
1797 * Reset default params for each popup
1798 */
1799sweetAlert.resetDefaults = function () {
1800  modalParams = _extends({}, defaultParams);
1801};
1802
1803sweetAlert.noop = function () {};
1804
1805sweetAlert.version = '6.10.2';
1806
1807sweetAlert.default = sweetAlert;
1808
1809return sweetAlert;
1810
1811})));
1812if (window.Sweetalert2) window.sweetAlert = window.swal = window.Sweetalert2;

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.