{"version":3,"file":"sweetalert-BGcozryV.js","sources":["../../../node_modules/.pnpm/sweetalert2@11.15.1/node_modules/sweetalert2/dist/sweetalert2.esm.all.js","../../../app/frontend/javascript/libs/sweetalert.js"],"sourcesContent":["/*!\n* sweetalert2 v11.15.1\n* Released under the MIT License.\n*/\nfunction _assertClassBrand(e, t, n) {\n if (\"function\" == typeof e ? e === t : e.has(t)) return arguments.length < 3 ? t : n;\n throw new TypeError(\"Private element is not present on this object\");\n}\nfunction _checkPrivateRedeclaration(e, t) {\n if (t.has(e)) throw new TypeError(\"Cannot initialize the same private elements twice on an object\");\n}\nfunction _classPrivateFieldGet2(s, a) {\n return s.get(_assertClassBrand(s, a));\n}\nfunction _classPrivateFieldInitSpec(e, t, a) {\n _checkPrivateRedeclaration(e, t), t.set(e, a);\n}\nfunction _classPrivateFieldSet2(s, a, r) {\n return s.set(_assertClassBrand(s, a), r), r;\n}\n\nconst RESTORE_FOCUS_TIMEOUT = 100;\n\n/** @type {GlobalState} */\nconst globalState = {};\nconst focusPreviousActiveElement = () => {\n if (globalState.previousActiveElement instanceof HTMLElement) {\n globalState.previousActiveElement.focus();\n globalState.previousActiveElement = null;\n } else if (document.body) {\n document.body.focus();\n }\n};\n\n/**\n * Restore previous active (focused) element\n *\n * @param {boolean} returnFocus\n * @returns {Promise}\n */\nconst restoreActiveElement = returnFocus => {\n return new Promise(resolve => {\n if (!returnFocus) {\n return resolve();\n }\n const x = window.scrollX;\n const y = window.scrollY;\n globalState.restoreFocusTimeout = setTimeout(() => {\n focusPreviousActiveElement();\n resolve();\n }, RESTORE_FOCUS_TIMEOUT); // issues/900\n\n window.scrollTo(x, y);\n });\n};\n\nconst swalPrefix = 'swal2-';\n\n/**\n * @typedef {Record} SwalClasses\n */\n\n/**\n * @typedef {'success' | 'warning' | 'info' | 'question' | 'error'} SwalIcon\n * @typedef {Record} SwalIcons\n */\n\n/** @type {SwalClass[]} */\nconst 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', 'default-outline', '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', 'dragging'];\nconst swalClasses = classNames.reduce((acc, className) => {\n acc[className] = swalPrefix + className;\n return acc;\n}, /** @type {SwalClasses} */{});\n\n/** @type {SwalIcon[]} */\nconst icons = ['success', 'warning', 'info', 'question', 'error'];\nconst iconTypes = icons.reduce((acc, icon) => {\n acc[icon] = swalPrefix + icon;\n return acc;\n}, /** @type {SwalIcons} */{});\n\nconst consolePrefix = 'SweetAlert2:';\n\n/**\n * Capitalize the first letter of a string\n *\n * @param {string} str\n * @returns {string}\n */\nconst capitalizeFirstLetter = str => str.charAt(0).toUpperCase() + str.slice(1);\n\n/**\n * Standardize console warnings\n *\n * @param {string | string[]} message\n */\nconst warn = message => {\n console.warn(`${consolePrefix} ${typeof message === 'object' ? message.join(' ') : message}`);\n};\n\n/**\n * Standardize console errors\n *\n * @param {string} message\n */\nconst error = message => {\n console.error(`${consolePrefix} ${message}`);\n};\n\n/**\n * Private global state for `warnOnce`\n *\n * @type {string[]}\n * @private\n */\nconst previousWarnOnceMessages = [];\n\n/**\n * Show a console warning, but only if it hasn't already been shown\n *\n * @param {string} message\n */\nconst warnOnce = message => {\n if (!previousWarnOnceMessages.includes(message)) {\n previousWarnOnceMessages.push(message);\n warn(message);\n }\n};\n\n/**\n * Show a one-time console warning about deprecated params/methods\n *\n * @param {string} deprecatedParam\n * @param {string?} useInstead\n */\nconst warnAboutDeprecation = function (deprecatedParam) {\n let useInstead = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;\n warnOnce(`\"${deprecatedParam}\" is deprecated and will be removed in the next major release.${useInstead ? ` Use \"${useInstead}\" instead.` : ''}`);\n};\n\n/**\n * If `arg` is a function, call it (with no arguments or context) and return the result.\n * Otherwise, just pass the value through\n *\n * @param {Function | any} arg\n * @returns {any}\n */\nconst callIfFunction = arg => typeof arg === 'function' ? arg() : arg;\n\n/**\n * @param {any} arg\n * @returns {boolean}\n */\nconst hasToPromiseFn = arg => arg && typeof arg.toPromise === 'function';\n\n/**\n * @param {any} arg\n * @returns {Promise}\n */\nconst asPromise = arg => hasToPromiseFn(arg) ? arg.toPromise() : Promise.resolve(arg);\n\n/**\n * @param {any} arg\n * @returns {boolean}\n */\nconst isPromise = arg => arg && Promise.resolve(arg) === arg;\n\n/**\n * Gets the popup container which contains the backdrop and the popup itself.\n *\n * @returns {HTMLElement | null}\n */\nconst getContainer = () => document.body.querySelector(`.${swalClasses.container}`);\n\n/**\n * @param {string} selectorString\n * @returns {HTMLElement | null}\n */\nconst elementBySelector = selectorString => {\n const container = getContainer();\n return container ? container.querySelector(selectorString) : null;\n};\n\n/**\n * @param {string} className\n * @returns {HTMLElement | null}\n */\nconst elementByClass = className => {\n return elementBySelector(`.${className}`);\n};\n\n/**\n * @returns {HTMLElement | null}\n */\nconst getPopup = () => elementByClass(swalClasses.popup);\n\n/**\n * @returns {HTMLElement | null}\n */\nconst getIcon = () => elementByClass(swalClasses.icon);\n\n/**\n * @returns {HTMLElement | null}\n */\nconst getIconContent = () => elementByClass(swalClasses['icon-content']);\n\n/**\n * @returns {HTMLElement | null}\n */\nconst getTitle = () => elementByClass(swalClasses.title);\n\n/**\n * @returns {HTMLElement | null}\n */\nconst getHtmlContainer = () => elementByClass(swalClasses['html-container']);\n\n/**\n * @returns {HTMLElement | null}\n */\nconst getImage = () => elementByClass(swalClasses.image);\n\n/**\n * @returns {HTMLElement | null}\n */\nconst getProgressSteps = () => elementByClass(swalClasses['progress-steps']);\n\n/**\n * @returns {HTMLElement | null}\n */\nconst getValidationMessage = () => elementByClass(swalClasses['validation-message']);\n\n/**\n * @returns {HTMLButtonElement | null}\n */\nconst getConfirmButton = () => (/** @type {HTMLButtonElement} */elementBySelector(`.${swalClasses.actions} .${swalClasses.confirm}`));\n\n/**\n * @returns {HTMLButtonElement | null}\n */\nconst getCancelButton = () => (/** @type {HTMLButtonElement} */elementBySelector(`.${swalClasses.actions} .${swalClasses.cancel}`));\n\n/**\n * @returns {HTMLButtonElement | null}\n */\nconst getDenyButton = () => (/** @type {HTMLButtonElement} */elementBySelector(`.${swalClasses.actions} .${swalClasses.deny}`));\n\n/**\n * @returns {HTMLElement | null}\n */\nconst getInputLabel = () => elementByClass(swalClasses['input-label']);\n\n/**\n * @returns {HTMLElement | null}\n */\nconst getLoader = () => elementBySelector(`.${swalClasses.loader}`);\n\n/**\n * @returns {HTMLElement | null}\n */\nconst getActions = () => elementByClass(swalClasses.actions);\n\n/**\n * @returns {HTMLElement | null}\n */\nconst getFooter = () => elementByClass(swalClasses.footer);\n\n/**\n * @returns {HTMLElement | null}\n */\nconst getTimerProgressBar = () => elementByClass(swalClasses['timer-progress-bar']);\n\n/**\n * @returns {HTMLElement | null}\n */\nconst getCloseButton = () => elementByClass(swalClasses.close);\n\n// https://github.com/jkup/focusable/blob/master/index.js\nconst focusable = `\n a[href],\n area[href],\n input:not([disabled]),\n select:not([disabled]),\n textarea:not([disabled]),\n button:not([disabled]),\n iframe,\n object,\n embed,\n [tabindex=\"0\"],\n [contenteditable],\n audio[controls],\n video[controls],\n summary\n`;\n/**\n * @returns {HTMLElement[]}\n */\nconst getFocusableElements = () => {\n const popup = getPopup();\n if (!popup) {\n return [];\n }\n /** @type {NodeListOf} */\n const focusableElementsWithTabindex = popup.querySelectorAll('[tabindex]:not([tabindex=\"-1\"]):not([tabindex=\"0\"])');\n const focusableElementsWithTabindexSorted = Array.from(focusableElementsWithTabindex)\n // sort according to tabindex\n .sort((a, b) => {\n const tabindexA = parseInt(a.getAttribute('tabindex') || '0');\n const tabindexB = parseInt(b.getAttribute('tabindex') || '0');\n if (tabindexA > tabindexB) {\n return 1;\n } else if (tabindexA < tabindexB) {\n return -1;\n }\n return 0;\n });\n\n /** @type {NodeListOf} */\n const otherFocusableElements = popup.querySelectorAll(focusable);\n const otherFocusableElementsFiltered = Array.from(otherFocusableElements).filter(el => el.getAttribute('tabindex') !== '-1');\n return [...new Set(focusableElementsWithTabindexSorted.concat(otherFocusableElementsFiltered))].filter(el => isVisible$1(el));\n};\n\n/**\n * @returns {boolean}\n */\nconst isModal = () => {\n return hasClass(document.body, swalClasses.shown) && !hasClass(document.body, swalClasses['toast-shown']) && !hasClass(document.body, swalClasses['no-backdrop']);\n};\n\n/**\n * @returns {boolean}\n */\nconst isToast = () => {\n const popup = getPopup();\n if (!popup) {\n return false;\n }\n return hasClass(popup, swalClasses.toast);\n};\n\n/**\n * @returns {boolean}\n */\nconst isLoading = () => {\n const popup = getPopup();\n if (!popup) {\n return false;\n }\n return popup.hasAttribute('data-loading');\n};\n\n/**\n * Securely set innerHTML of an element\n * https://github.com/sweetalert2/sweetalert2/issues/1926\n *\n * @param {HTMLElement} elem\n * @param {string} html\n */\nconst setInnerHtml = (elem, html) => {\n elem.textContent = '';\n if (html) {\n const parser = new DOMParser();\n const parsed = parser.parseFromString(html, `text/html`);\n const head = parsed.querySelector('head');\n if (head) {\n Array.from(head.childNodes).forEach(child => {\n elem.appendChild(child);\n });\n }\n const body = parsed.querySelector('body');\n if (body) {\n Array.from(body.childNodes).forEach(child => {\n if (child instanceof HTMLVideoElement || child instanceof HTMLAudioElement) {\n elem.appendChild(child.cloneNode(true)); // https://github.com/sweetalert2/sweetalert2/issues/2507\n } else {\n elem.appendChild(child);\n }\n });\n }\n }\n};\n\n/**\n * @param {HTMLElement} elem\n * @param {string} className\n * @returns {boolean}\n */\nconst hasClass = (elem, className) => {\n if (!className) {\n return false;\n }\n const classList = className.split(/\\s+/);\n for (let i = 0; i < classList.length; i++) {\n if (!elem.classList.contains(classList[i])) {\n return false;\n }\n }\n return true;\n};\n\n/**\n * @param {HTMLElement} elem\n * @param {SweetAlertOptions} params\n */\nconst removeCustomClasses = (elem, params) => {\n Array.from(elem.classList).forEach(className => {\n if (!Object.values(swalClasses).includes(className) && !Object.values(iconTypes).includes(className) && !Object.values(params.showClass || {}).includes(className)) {\n elem.classList.remove(className);\n }\n });\n};\n\n/**\n * @param {HTMLElement} elem\n * @param {SweetAlertOptions} params\n * @param {string} className\n */\nconst applyCustomClass = (elem, params, className) => {\n removeCustomClasses(elem, params);\n if (!params.customClass) {\n return;\n }\n const customClass = params.customClass[(/** @type {keyof SweetAlertCustomClass} */className)];\n if (!customClass) {\n return;\n }\n if (typeof customClass !== 'string' && !customClass.forEach) {\n warn(`Invalid type of customClass.${className}! Expected string or iterable object, got \"${typeof customClass}\"`);\n return;\n }\n addClass(elem, customClass);\n};\n\n/**\n * @param {HTMLElement} popup\n * @param {import('./renderers/renderInput').InputClass | SweetAlertInput} inputClass\n * @returns {HTMLInputElement | null}\n */\nconst getInput$1 = (popup, inputClass) => {\n if (!inputClass) {\n return null;\n }\n switch (inputClass) {\n case 'select':\n case 'textarea':\n case 'file':\n return popup.querySelector(`.${swalClasses.popup} > .${swalClasses[inputClass]}`);\n case 'checkbox':\n return popup.querySelector(`.${swalClasses.popup} > .${swalClasses.checkbox} input`);\n case 'radio':\n return popup.querySelector(`.${swalClasses.popup} > .${swalClasses.radio} input:checked`) || popup.querySelector(`.${swalClasses.popup} > .${swalClasses.radio} input:first-child`);\n case 'range':\n return popup.querySelector(`.${swalClasses.popup} > .${swalClasses.range} input`);\n default:\n return popup.querySelector(`.${swalClasses.popup} > .${swalClasses.input}`);\n }\n};\n\n/**\n * @param {HTMLInputElement | HTMLTextAreaElement | HTMLSelectElement} input\n */\nconst focusInput = input => {\n input.focus();\n\n // place cursor at end of text in text input\n if (input.type !== 'file') {\n // http://stackoverflow.com/a/2345915\n const val = input.value;\n input.value = '';\n input.value = val;\n }\n};\n\n/**\n * @param {HTMLElement | HTMLElement[] | null} target\n * @param {string | string[] | readonly string[] | undefined} classList\n * @param {boolean} condition\n */\nconst toggleClass = (target, classList, condition) => {\n if (!target || !classList) {\n return;\n }\n if (typeof classList === 'string') {\n classList = classList.split(/\\s+/).filter(Boolean);\n }\n classList.forEach(className => {\n if (Array.isArray(target)) {\n target.forEach(elem => {\n if (condition) {\n elem.classList.add(className);\n } else {\n elem.classList.remove(className);\n }\n });\n } else {\n if (condition) {\n target.classList.add(className);\n } else {\n target.classList.remove(className);\n }\n }\n });\n};\n\n/**\n * @param {HTMLElement | HTMLElement[] | null} target\n * @param {string | string[] | readonly string[] | undefined} classList\n */\nconst addClass = (target, classList) => {\n toggleClass(target, classList, true);\n};\n\n/**\n * @param {HTMLElement | HTMLElement[] | null} target\n * @param {string | string[] | readonly string[] | undefined} classList\n */\nconst removeClass = (target, classList) => {\n toggleClass(target, classList, false);\n};\n\n/**\n * Get direct child of an element by class name\n *\n * @param {HTMLElement} elem\n * @param {string} className\n * @returns {HTMLElement | undefined}\n */\nconst getDirectChildByClass = (elem, className) => {\n const children = Array.from(elem.children);\n for (let i = 0; i < children.length; i++) {\n const child = children[i];\n if (child instanceof HTMLElement && hasClass(child, className)) {\n return child;\n }\n }\n};\n\n/**\n * @param {HTMLElement} elem\n * @param {string} property\n * @param {*} value\n */\nconst applyNumericalStyle = (elem, property, value) => {\n if (value === `${parseInt(value)}`) {\n value = parseInt(value);\n }\n if (value || parseInt(value) === 0) {\n elem.style.setProperty(property, typeof value === 'number' ? `${value}px` : value);\n } else {\n elem.style.removeProperty(property);\n }\n};\n\n/**\n * @param {HTMLElement | null} elem\n * @param {string} display\n */\nconst show = function (elem) {\n let display = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'flex';\n if (!elem) {\n return;\n }\n elem.style.display = display;\n};\n\n/**\n * @param {HTMLElement | null} elem\n */\nconst hide = elem => {\n if (!elem) {\n return;\n }\n elem.style.display = 'none';\n};\n\n/**\n * @param {HTMLElement | null} elem\n * @param {string} display\n */\nconst showWhenInnerHtmlPresent = function (elem) {\n let display = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'block';\n if (!elem) {\n return;\n }\n new MutationObserver(() => {\n toggle(elem, elem.innerHTML, display);\n }).observe(elem, {\n childList: true,\n subtree: true\n });\n};\n\n/**\n * @param {HTMLElement} parent\n * @param {string} selector\n * @param {string} property\n * @param {string} value\n */\nconst setStyle = (parent, selector, property, value) => {\n /** @type {HTMLElement | null} */\n const el = parent.querySelector(selector);\n if (el) {\n el.style.setProperty(property, value);\n }\n};\n\n/**\n * @param {HTMLElement} elem\n * @param {any} condition\n * @param {string} display\n */\nconst toggle = function (elem, condition) {\n let display = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'flex';\n if (condition) {\n show(elem, display);\n } else {\n hide(elem);\n }\n};\n\n/**\n * borrowed from jquery $(elem).is(':visible') implementation\n *\n * @param {HTMLElement | null} elem\n * @returns {boolean}\n */\nconst isVisible$1 = elem => !!(elem && (elem.offsetWidth || elem.offsetHeight || elem.getClientRects().length));\n\n/**\n * @returns {boolean}\n */\nconst allButtonsAreHidden = () => !isVisible$1(getConfirmButton()) && !isVisible$1(getDenyButton()) && !isVisible$1(getCancelButton());\n\n/**\n * @param {HTMLElement} elem\n * @returns {boolean}\n */\nconst isScrollable = elem => !!(elem.scrollHeight > elem.clientHeight);\n\n/**\n * borrowed from https://stackoverflow.com/a/46352119\n *\n * @param {HTMLElement} elem\n * @returns {boolean}\n */\nconst hasCssAnimation = elem => {\n const style = window.getComputedStyle(elem);\n const animDuration = parseFloat(style.getPropertyValue('animation-duration') || '0');\n const transDuration = parseFloat(style.getPropertyValue('transition-duration') || '0');\n return animDuration > 0 || transDuration > 0;\n};\n\n/**\n * @param {number} timer\n * @param {boolean} reset\n */\nconst animateTimerProgressBar = function (timer) {\n let reset = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;\n const timerProgressBar = getTimerProgressBar();\n if (!timerProgressBar) {\n return;\n }\n if (isVisible$1(timerProgressBar)) {\n if (reset) {\n timerProgressBar.style.transition = 'none';\n timerProgressBar.style.width = '100%';\n }\n setTimeout(() => {\n timerProgressBar.style.transition = `width ${timer / 1000}s linear`;\n timerProgressBar.style.width = '0%';\n }, 10);\n }\n};\nconst stopTimerProgressBar = () => {\n const timerProgressBar = getTimerProgressBar();\n if (!timerProgressBar) {\n return;\n }\n const timerProgressBarWidth = parseInt(window.getComputedStyle(timerProgressBar).width);\n timerProgressBar.style.removeProperty('transition');\n timerProgressBar.style.width = '100%';\n const timerProgressBarFullWidth = parseInt(window.getComputedStyle(timerProgressBar).width);\n const timerProgressBarPercent = timerProgressBarWidth / timerProgressBarFullWidth * 100;\n timerProgressBar.style.width = `${timerProgressBarPercent}%`;\n};\n\n/**\n * Detect Node env\n *\n * @returns {boolean}\n */\nconst isNodeEnv = () => typeof window === 'undefined' || typeof document === 'undefined';\n\nconst sweetHTML = `\n
\n \n
    \n
    \n \n

    \n
    \n \n \n
    \n \n \n
    \n \n
    \n \n \n
    \n
    \n
    \n \n \n \n
    \n
    \n
    \n
    \n
    \n
    \n`.replace(/(^|\\n)\\s*/g, '');\n\n/**\n * @returns {boolean}\n */\nconst resetOldContainer = () => {\n const oldContainer = getContainer();\n if (!oldContainer) {\n return false;\n }\n oldContainer.remove();\n removeClass([document.documentElement, document.body], [swalClasses['no-backdrop'], swalClasses['toast-shown'], swalClasses['has-column']]);\n return true;\n};\nconst resetValidationMessage$1 = () => {\n globalState.currentInstance.resetValidationMessage();\n};\nconst addInputChangeListeners = () => {\n const popup = getPopup();\n const input = getDirectChildByClass(popup, swalClasses.input);\n const file = getDirectChildByClass(popup, swalClasses.file);\n /** @type {HTMLInputElement} */\n const range = popup.querySelector(`.${swalClasses.range} input`);\n /** @type {HTMLOutputElement} */\n const rangeOutput = popup.querySelector(`.${swalClasses.range} output`);\n const select = getDirectChildByClass(popup, swalClasses.select);\n /** @type {HTMLInputElement} */\n const checkbox = popup.querySelector(`.${swalClasses.checkbox} input`);\n const textarea = getDirectChildByClass(popup, swalClasses.textarea);\n input.oninput = resetValidationMessage$1;\n file.onchange = resetValidationMessage$1;\n select.onchange = resetValidationMessage$1;\n checkbox.onchange = resetValidationMessage$1;\n textarea.oninput = resetValidationMessage$1;\n range.oninput = () => {\n resetValidationMessage$1();\n rangeOutput.value = range.value;\n };\n range.onchange = () => {\n resetValidationMessage$1();\n rangeOutput.value = range.value;\n };\n};\n\n/**\n * @param {string | HTMLElement} target\n * @returns {HTMLElement}\n */\nconst getTarget = target => typeof target === 'string' ? document.querySelector(target) : target;\n\n/**\n * @param {SweetAlertOptions} params\n */\nconst setupAccessibility = params => {\n const popup = getPopup();\n popup.setAttribute('role', params.toast ? 'alert' : 'dialog');\n popup.setAttribute('aria-live', params.toast ? 'polite' : 'assertive');\n if (!params.toast) {\n popup.setAttribute('aria-modal', 'true');\n }\n};\n\n/**\n * @param {HTMLElement} targetElement\n */\nconst setupRTL = targetElement => {\n if (window.getComputedStyle(targetElement).direction === 'rtl') {\n addClass(getContainer(), swalClasses.rtl);\n }\n};\n\n/**\n * Add modal + backdrop + no-war message for Russians to DOM\n *\n * @param {SweetAlertOptions} params\n */\nconst init = params => {\n // Clean up the old popup container if it exists\n const oldContainerExisted = resetOldContainer();\n if (isNodeEnv()) {\n error('SweetAlert2 requires document to initialize');\n return;\n }\n const container = document.createElement('div');\n container.className = swalClasses.container;\n if (oldContainerExisted) {\n addClass(container, swalClasses['no-transition']);\n }\n setInnerHtml(container, sweetHTML);\n const targetElement = getTarget(params.target);\n targetElement.appendChild(container);\n setupAccessibility(params);\n setupRTL(targetElement);\n addInputChangeListeners();\n};\n\n/**\n * @param {HTMLElement | object | string} param\n * @param {HTMLElement} target\n */\nconst parseHtmlToContainer = (param, target) => {\n // DOM element\n if (param instanceof HTMLElement) {\n target.appendChild(param);\n }\n\n // Object\n else if (typeof param === 'object') {\n handleObject(param, target);\n }\n\n // Plain string\n else if (param) {\n setInnerHtml(target, param);\n }\n};\n\n/**\n * @param {any} param\n * @param {HTMLElement} target\n */\nconst handleObject = (param, target) => {\n // JQuery element(s)\n if (param.jquery) {\n handleJqueryElem(target, param);\n }\n\n // For other objects use their string representation\n else {\n setInnerHtml(target, param.toString());\n }\n};\n\n/**\n * @param {HTMLElement} target\n * @param {any} elem\n */\nconst handleJqueryElem = (target, elem) => {\n target.textContent = '';\n if (0 in elem) {\n for (let i = 0; i in elem; i++) {\n target.appendChild(elem[i].cloneNode(true));\n }\n } else {\n target.appendChild(elem.cloneNode(true));\n }\n};\n\n/**\n * @param {SweetAlert} instance\n * @param {SweetAlertOptions} params\n */\nconst renderActions = (instance, params) => {\n const actions = getActions();\n const loader = getLoader();\n if (!actions || !loader) {\n return;\n }\n\n // Actions (buttons) wrapper\n if (!params.showConfirmButton && !params.showDenyButton && !params.showCancelButton) {\n hide(actions);\n } else {\n show(actions);\n }\n\n // Custom class\n applyCustomClass(actions, params, 'actions');\n\n // Render all the buttons\n renderButtons(actions, loader, params);\n\n // Loader\n setInnerHtml(loader, params.loaderHtml || '');\n applyCustomClass(loader, params, 'loader');\n};\n\n/**\n * @param {HTMLElement} actions\n * @param {HTMLElement} loader\n * @param {SweetAlertOptions} params\n */\nfunction renderButtons(actions, loader, params) {\n const confirmButton = getConfirmButton();\n const denyButton = getDenyButton();\n const cancelButton = getCancelButton();\n if (!confirmButton || !denyButton || !cancelButton) {\n return;\n }\n\n // Render buttons\n renderButton(confirmButton, 'confirm', params);\n renderButton(denyButton, 'deny', params);\n renderButton(cancelButton, 'cancel', params);\n handleButtonsStyling(confirmButton, denyButton, cancelButton, params);\n if (params.reverseButtons) {\n if (params.toast) {\n actions.insertBefore(cancelButton, confirmButton);\n actions.insertBefore(denyButton, confirmButton);\n } else {\n actions.insertBefore(cancelButton, loader);\n actions.insertBefore(denyButton, loader);\n actions.insertBefore(confirmButton, loader);\n }\n }\n}\n\n/**\n * @param {HTMLElement} confirmButton\n * @param {HTMLElement} denyButton\n * @param {HTMLElement} cancelButton\n * @param {SweetAlertOptions} params\n */\nfunction handleButtonsStyling(confirmButton, denyButton, cancelButton, params) {\n if (!params.buttonsStyling) {\n removeClass([confirmButton, denyButton, cancelButton], swalClasses.styled);\n return;\n }\n addClass([confirmButton, denyButton, cancelButton], swalClasses.styled);\n\n // Buttons background colors\n if (params.confirmButtonColor) {\n confirmButton.style.backgroundColor = params.confirmButtonColor;\n addClass(confirmButton, swalClasses['default-outline']);\n }\n if (params.denyButtonColor) {\n denyButton.style.backgroundColor = params.denyButtonColor;\n addClass(denyButton, swalClasses['default-outline']);\n }\n if (params.cancelButtonColor) {\n cancelButton.style.backgroundColor = params.cancelButtonColor;\n addClass(cancelButton, swalClasses['default-outline']);\n }\n}\n\n/**\n * @param {HTMLElement} button\n * @param {'confirm' | 'deny' | 'cancel'} buttonType\n * @param {SweetAlertOptions} params\n */\nfunction renderButton(button, buttonType, params) {\n const buttonName = /** @type {'Confirm' | 'Deny' | 'Cancel'} */capitalizeFirstLetter(buttonType);\n toggle(button, params[`show${buttonName}Button`], 'inline-block');\n setInnerHtml(button, params[`${buttonType}ButtonText`] || ''); // Set caption text\n button.setAttribute('aria-label', params[`${buttonType}ButtonAriaLabel`] || ''); // ARIA label\n\n // Add buttons custom classes\n button.className = swalClasses[buttonType];\n applyCustomClass(button, params, `${buttonType}Button`);\n}\n\n/**\n * @param {SweetAlert} instance\n * @param {SweetAlertOptions} params\n */\nconst renderCloseButton = (instance, params) => {\n const closeButton = getCloseButton();\n if (!closeButton) {\n return;\n }\n setInnerHtml(closeButton, params.closeButtonHtml || '');\n\n // Custom class\n applyCustomClass(closeButton, params, 'closeButton');\n toggle(closeButton, params.showCloseButton);\n closeButton.setAttribute('aria-label', params.closeButtonAriaLabel || '');\n};\n\n/**\n * @param {SweetAlert} instance\n * @param {SweetAlertOptions} params\n */\nconst renderContainer = (instance, params) => {\n const container = getContainer();\n if (!container) {\n return;\n }\n handleBackdropParam(container, params.backdrop);\n handlePositionParam(container, params.position);\n handleGrowParam(container, params.grow);\n\n // Custom class\n applyCustomClass(container, params, 'container');\n};\n\n/**\n * @param {HTMLElement} container\n * @param {SweetAlertOptions['backdrop']} backdrop\n */\nfunction handleBackdropParam(container, backdrop) {\n if (typeof backdrop === 'string') {\n container.style.background = backdrop;\n } else if (!backdrop) {\n addClass([document.documentElement, document.body], swalClasses['no-backdrop']);\n }\n}\n\n/**\n * @param {HTMLElement} container\n * @param {SweetAlertOptions['position']} position\n */\nfunction handlePositionParam(container, position) {\n if (!position) {\n return;\n }\n if (position in swalClasses) {\n addClass(container, swalClasses[position]);\n } else {\n warn('The \"position\" parameter is not valid, defaulting to \"center\"');\n addClass(container, swalClasses.center);\n }\n}\n\n/**\n * @param {HTMLElement} container\n * @param {SweetAlertOptions['grow']} grow\n */\nfunction handleGrowParam(container, grow) {\n if (!grow) {\n return;\n }\n addClass(container, swalClasses[`grow-${grow}`]);\n}\n\n/**\n * This module contains `WeakMap`s for each effectively-\"private property\" that a `Swal` has.\n * For example, to set the private property \"foo\" of `this` to \"bar\", you can `privateProps.foo.set(this, 'bar')`\n * This is the approach that Babel will probably take to implement private methods/fields\n * https://github.com/tc39/proposal-private-methods\n * https://github.com/babel/babel/pull/7555\n * Once we have the changes from that PR in Babel, and our core class fits reasonable in *one module*\n * then we can use that language feature.\n */\n\nvar privateProps = {\n innerParams: new WeakMap(),\n domCache: new WeakMap()\n};\n\n/// \n\n\n/** @type {InputClass[]} */\nconst inputClasses = ['input', 'file', 'range', 'select', 'radio', 'checkbox', 'textarea'];\n\n/**\n * @param {SweetAlert} instance\n * @param {SweetAlertOptions} params\n */\nconst renderInput = (instance, params) => {\n const popup = getPopup();\n if (!popup) {\n return;\n }\n const innerParams = privateProps.innerParams.get(instance);\n const rerender = !innerParams || params.input !== innerParams.input;\n inputClasses.forEach(inputClass => {\n const inputContainer = getDirectChildByClass(popup, swalClasses[inputClass]);\n if (!inputContainer) {\n return;\n }\n\n // set attributes\n setAttributes(inputClass, params.inputAttributes);\n\n // set class\n inputContainer.className = swalClasses[inputClass];\n if (rerender) {\n hide(inputContainer);\n }\n });\n if (params.input) {\n if (rerender) {\n showInput(params);\n }\n // set custom class\n setCustomClass(params);\n }\n};\n\n/**\n * @param {SweetAlertOptions} params\n */\nconst showInput = params => {\n if (!params.input) {\n return;\n }\n if (!renderInputType[params.input]) {\n error(`Unexpected type of input! Expected ${Object.keys(renderInputType).join(' | ')}, got \"${params.input}\"`);\n return;\n }\n const inputContainer = getInputContainer(params.input);\n if (!inputContainer) {\n return;\n }\n const input = renderInputType[params.input](inputContainer, params);\n show(inputContainer);\n\n // input autofocus\n if (params.inputAutoFocus) {\n setTimeout(() => {\n focusInput(input);\n });\n }\n};\n\n/**\n * @param {HTMLInputElement} input\n */\nconst removeAttributes = input => {\n for (let i = 0; i < input.attributes.length; i++) {\n const attrName = input.attributes[i].name;\n if (!['id', 'type', 'value', 'style'].includes(attrName)) {\n input.removeAttribute(attrName);\n }\n }\n};\n\n/**\n * @param {InputClass} inputClass\n * @param {SweetAlertOptions['inputAttributes']} inputAttributes\n */\nconst setAttributes = (inputClass, inputAttributes) => {\n const popup = getPopup();\n if (!popup) {\n return;\n }\n const input = getInput$1(popup, inputClass);\n if (!input) {\n return;\n }\n removeAttributes(input);\n for (const attr in inputAttributes) {\n input.setAttribute(attr, inputAttributes[attr]);\n }\n};\n\n/**\n * @param {SweetAlertOptions} params\n */\nconst setCustomClass = params => {\n if (!params.input) {\n return;\n }\n const inputContainer = getInputContainer(params.input);\n if (inputContainer) {\n applyCustomClass(inputContainer, params, 'input');\n }\n};\n\n/**\n * @param {HTMLInputElement | HTMLTextAreaElement} input\n * @param {SweetAlertOptions} params\n */\nconst setInputPlaceholder = (input, params) => {\n if (!input.placeholder && params.inputPlaceholder) {\n input.placeholder = params.inputPlaceholder;\n }\n};\n\n/**\n * @param {Input} input\n * @param {Input} prependTo\n * @param {SweetAlertOptions} params\n */\nconst setInputLabel = (input, prependTo, params) => {\n if (params.inputLabel) {\n const label = document.createElement('label');\n const labelClass = swalClasses['input-label'];\n label.setAttribute('for', input.id);\n label.className = labelClass;\n if (typeof params.customClass === 'object') {\n addClass(label, params.customClass.inputLabel);\n }\n label.innerText = params.inputLabel;\n prependTo.insertAdjacentElement('beforebegin', label);\n }\n};\n\n/**\n * @param {SweetAlertInput} inputType\n * @returns {HTMLElement | undefined}\n */\nconst getInputContainer = inputType => {\n const popup = getPopup();\n if (!popup) {\n return;\n }\n return getDirectChildByClass(popup, swalClasses[(/** @type {SwalClass} */inputType)] || swalClasses.input);\n};\n\n/**\n * @param {HTMLInputElement | HTMLOutputElement | HTMLTextAreaElement} input\n * @param {SweetAlertOptions['inputValue']} inputValue\n */\nconst checkAndSetInputValue = (input, inputValue) => {\n if (['string', 'number'].includes(typeof inputValue)) {\n input.value = `${inputValue}`;\n } else if (!isPromise(inputValue)) {\n warn(`Unexpected type of inputValue! Expected \"string\", \"number\" or \"Promise\", got \"${typeof inputValue}\"`);\n }\n};\n\n/** @type {Record Input>} */\nconst renderInputType = {};\n\n/**\n * @param {HTMLInputElement} input\n * @param {SweetAlertOptions} params\n * @returns {HTMLInputElement}\n */\nrenderInputType.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} */\n(input, params) => {\n checkAndSetInputValue(input, params.inputValue);\n setInputLabel(input, input, params);\n setInputPlaceholder(input, params);\n input.type = params.input;\n return input;\n};\n\n/**\n * @param {HTMLInputElement} input\n * @param {SweetAlertOptions} params\n * @returns {HTMLInputElement}\n */\nrenderInputType.file = (input, params) => {\n setInputLabel(input, input, params);\n setInputPlaceholder(input, params);\n return input;\n};\n\n/**\n * @param {HTMLInputElement} range\n * @param {SweetAlertOptions} params\n * @returns {HTMLInputElement}\n */\nrenderInputType.range = (range, params) => {\n const rangeInput = range.querySelector('input');\n const rangeOutput = range.querySelector('output');\n checkAndSetInputValue(rangeInput, params.inputValue);\n rangeInput.type = params.input;\n checkAndSetInputValue(rangeOutput, params.inputValue);\n setInputLabel(rangeInput, range, params);\n return range;\n};\n\n/**\n * @param {HTMLSelectElement} select\n * @param {SweetAlertOptions} params\n * @returns {HTMLSelectElement}\n */\nrenderInputType.select = (select, params) => {\n select.textContent = '';\n if (params.inputPlaceholder) {\n const placeholder = document.createElement('option');\n setInnerHtml(placeholder, params.inputPlaceholder);\n placeholder.value = '';\n placeholder.disabled = true;\n placeholder.selected = true;\n select.appendChild(placeholder);\n }\n setInputLabel(select, select, params);\n return select;\n};\n\n/**\n * @param {HTMLInputElement} radio\n * @returns {HTMLInputElement}\n */\nrenderInputType.radio = radio => {\n radio.textContent = '';\n return radio;\n};\n\n/**\n * @param {HTMLLabelElement} checkboxContainer\n * @param {SweetAlertOptions} params\n * @returns {HTMLInputElement}\n */\nrenderInputType.checkbox = (checkboxContainer, params) => {\n const checkbox = getInput$1(getPopup(), 'checkbox');\n checkbox.value = '1';\n checkbox.checked = Boolean(params.inputValue);\n const label = checkboxContainer.querySelector('span');\n setInnerHtml(label, params.inputPlaceholder || params.inputLabel);\n return checkbox;\n};\n\n/**\n * @param {HTMLTextAreaElement} textarea\n * @param {SweetAlertOptions} params\n * @returns {HTMLTextAreaElement}\n */\nrenderInputType.textarea = (textarea, params) => {\n checkAndSetInputValue(textarea, params.inputValue);\n setInputPlaceholder(textarea, params);\n setInputLabel(textarea, textarea, params);\n\n /**\n * @param {HTMLElement} el\n * @returns {number}\n */\n const getMargin = el => parseInt(window.getComputedStyle(el).marginLeft) + parseInt(window.getComputedStyle(el).marginRight);\n\n // https://github.com/sweetalert2/sweetalert2/issues/2291\n setTimeout(() => {\n // https://github.com/sweetalert2/sweetalert2/issues/1699\n if ('MutationObserver' in window) {\n const initialPopupWidth = parseInt(window.getComputedStyle(getPopup()).width);\n const textareaResizeHandler = () => {\n // check if texarea is still in document (i.e. popup wasn't closed in the meantime)\n if (!document.body.contains(textarea)) {\n return;\n }\n const textareaWidth = textarea.offsetWidth + getMargin(textarea);\n if (textareaWidth > initialPopupWidth) {\n getPopup().style.width = `${textareaWidth}px`;\n } else {\n applyNumericalStyle(getPopup(), 'width', params.width);\n }\n };\n new MutationObserver(textareaResizeHandler).observe(textarea, {\n attributes: true,\n attributeFilter: ['style']\n });\n }\n });\n return textarea;\n};\n\n/**\n * @param {SweetAlert} instance\n * @param {SweetAlertOptions} params\n */\nconst renderContent = (instance, params) => {\n const htmlContainer = getHtmlContainer();\n if (!htmlContainer) {\n return;\n }\n showWhenInnerHtmlPresent(htmlContainer);\n applyCustomClass(htmlContainer, params, 'htmlContainer');\n\n // Content as HTML\n if (params.html) {\n parseHtmlToContainer(params.html, htmlContainer);\n show(htmlContainer, 'block');\n }\n\n // Content as plain text\n else if (params.text) {\n htmlContainer.textContent = params.text;\n show(htmlContainer, 'block');\n }\n\n // No content\n else {\n hide(htmlContainer);\n }\n renderInput(instance, params);\n};\n\n/**\n * @param {SweetAlert} instance\n * @param {SweetAlertOptions} params\n */\nconst renderFooter = (instance, params) => {\n const footer = getFooter();\n if (!footer) {\n return;\n }\n showWhenInnerHtmlPresent(footer);\n toggle(footer, params.footer, 'block');\n if (params.footer) {\n parseHtmlToContainer(params.footer, footer);\n }\n\n // Custom class\n applyCustomClass(footer, params, 'footer');\n};\n\n/**\n * @param {SweetAlert} instance\n * @param {SweetAlertOptions} params\n */\nconst renderIcon = (instance, params) => {\n const innerParams = privateProps.innerParams.get(instance);\n const icon = getIcon();\n if (!icon) {\n return;\n }\n\n // if the given icon already rendered, apply the styling without re-rendering the icon\n if (innerParams && params.icon === innerParams.icon) {\n // Custom or default content\n setContent(icon, params);\n applyStyles(icon, params);\n return;\n }\n if (!params.icon && !params.iconHtml) {\n hide(icon);\n return;\n }\n if (params.icon && Object.keys(iconTypes).indexOf(params.icon) === -1) {\n error(`Unknown icon! Expected \"success\", \"error\", \"warning\", \"info\" or \"question\", got \"${params.icon}\"`);\n hide(icon);\n return;\n }\n show(icon);\n\n // Custom or default content\n setContent(icon, params);\n applyStyles(icon, params);\n\n // Animate icon\n addClass(icon, params.showClass && params.showClass.icon);\n};\n\n/**\n * @param {HTMLElement} icon\n * @param {SweetAlertOptions} params\n */\nconst applyStyles = (icon, params) => {\n for (const [iconType, iconClassName] of Object.entries(iconTypes)) {\n if (params.icon !== iconType) {\n removeClass(icon, iconClassName);\n }\n }\n addClass(icon, params.icon && iconTypes[params.icon]);\n\n // Icon color\n setColor(icon, params);\n\n // Success icon background color\n adjustSuccessIconBackgroundColor();\n\n // Custom class\n applyCustomClass(icon, params, 'icon');\n};\n\n// Adjust success icon background color to match the popup background color\nconst adjustSuccessIconBackgroundColor = () => {\n const popup = getPopup();\n if (!popup) {\n return;\n }\n const popupBackgroundColor = window.getComputedStyle(popup).getPropertyValue('background-color');\n /** @type {NodeListOf} */\n const successIconParts = popup.querySelectorAll('[class^=swal2-success-circular-line], .swal2-success-fix');\n for (let i = 0; i < successIconParts.length; i++) {\n successIconParts[i].style.backgroundColor = popupBackgroundColor;\n }\n};\nconst successIconHtml = `\n
    \n \n
    \n
    \n`;\nconst errorIconHtml = `\n \n \n \n \n`;\n\n/**\n * @param {HTMLElement} icon\n * @param {SweetAlertOptions} params\n */\nconst setContent = (icon, params) => {\n if (!params.icon && !params.iconHtml) {\n return;\n }\n let oldContent = icon.innerHTML;\n let newContent = '';\n if (params.iconHtml) {\n newContent = iconContent(params.iconHtml);\n } else if (params.icon === 'success') {\n newContent = successIconHtml;\n oldContent = oldContent.replace(/ style=\".*?\"/g, ''); // undo adjustSuccessIconBackgroundColor()\n } else if (params.icon === 'error') {\n newContent = errorIconHtml;\n } else if (params.icon) {\n const defaultIconHtml = {\n question: '?',\n warning: '!',\n info: 'i'\n };\n newContent = iconContent(defaultIconHtml[params.icon]);\n }\n if (oldContent.trim() !== newContent.trim()) {\n setInnerHtml(icon, newContent);\n }\n};\n\n/**\n * @param {HTMLElement} icon\n * @param {SweetAlertOptions} params\n */\nconst setColor = (icon, params) => {\n if (!params.iconColor) {\n return;\n }\n icon.style.color = params.iconColor;\n icon.style.borderColor = params.iconColor;\n for (const sel of ['.swal2-success-line-tip', '.swal2-success-line-long', '.swal2-x-mark-line-left', '.swal2-x-mark-line-right']) {\n setStyle(icon, sel, 'background-color', params.iconColor);\n }\n setStyle(icon, '.swal2-success-ring', 'border-color', params.iconColor);\n};\n\n/**\n * @param {string} content\n * @returns {string}\n */\nconst iconContent = content => `
    ${content}
    `;\n\n/**\n * @param {SweetAlert} instance\n * @param {SweetAlertOptions} params\n */\nconst renderImage = (instance, params) => {\n const image = getImage();\n if (!image) {\n return;\n }\n if (!params.imageUrl) {\n hide(image);\n return;\n }\n show(image, '');\n\n // Src, alt\n image.setAttribute('src', params.imageUrl);\n image.setAttribute('alt', params.imageAlt || '');\n\n // Width, height\n applyNumericalStyle(image, 'width', params.imageWidth);\n applyNumericalStyle(image, 'height', params.imageHeight);\n\n // Class\n image.className = swalClasses.image;\n applyCustomClass(image, params, 'image');\n};\n\nlet dragging = false;\nlet mousedownX = 0;\nlet mousedownY = 0;\nlet initialX = 0;\nlet initialY = 0;\n\n/**\n * @param {HTMLElement} popup\n */\nconst addDraggableListeners = popup => {\n popup.addEventListener('mousedown', down);\n document.body.addEventListener('mousemove', move);\n popup.addEventListener('mouseup', up);\n popup.addEventListener('touchstart', down);\n document.body.addEventListener('touchmove', move);\n popup.addEventListener('touchend', up);\n};\n\n/**\n * @param {HTMLElement} popup\n */\nconst removeDraggableListeners = popup => {\n popup.removeEventListener('mousedown', down);\n document.body.removeEventListener('mousemove', move);\n popup.removeEventListener('mouseup', up);\n popup.removeEventListener('touchstart', down);\n document.body.removeEventListener('touchmove', move);\n popup.removeEventListener('touchend', up);\n};\n\n/**\n * @param {MouseEvent | TouchEvent} event\n */\nconst down = event => {\n const popup = getPopup();\n if (event.target === popup || getIcon().contains(/** @type {HTMLElement} */event.target)) {\n dragging = true;\n const clientXY = getClientXY(event);\n mousedownX = clientXY.clientX;\n mousedownY = clientXY.clientY;\n initialX = parseInt(popup.style.insetInlineStart) || 0;\n initialY = parseInt(popup.style.insetBlockStart) || 0;\n addClass(popup, 'swal2-dragging');\n }\n};\n\n/**\n * @param {MouseEvent | TouchEvent} event\n */\nconst move = event => {\n const popup = getPopup();\n if (dragging) {\n let {\n clientX,\n clientY\n } = getClientXY(event);\n popup.style.insetInlineStart = `${initialX + (clientX - mousedownX)}px`;\n popup.style.insetBlockStart = `${initialY + (clientY - mousedownY)}px`;\n }\n};\nconst up = () => {\n const popup = getPopup();\n dragging = false;\n removeClass(popup, 'swal2-dragging');\n};\n\n/**\n * @param {MouseEvent | TouchEvent} event\n * @returns {{ clientX: number, clientY: number }}\n */\nconst getClientXY = event => {\n let clientX = 0,\n clientY = 0;\n if (event.type.startsWith('mouse')) {\n clientX = /** @type {MouseEvent} */event.clientX;\n clientY = /** @type {MouseEvent} */event.clientY;\n } else if (event.type.startsWith('touch')) {\n clientX = /** @type {TouchEvent} */event.touches[0].clientX;\n clientY = /** @type {TouchEvent} */event.touches[0].clientY;\n }\n return {\n clientX,\n clientY\n };\n};\n\n/**\n * @param {SweetAlert} instance\n * @param {SweetAlertOptions} params\n */\nconst renderPopup = (instance, params) => {\n const container = getContainer();\n const popup = getPopup();\n if (!container || !popup) {\n return;\n }\n\n // Width\n // https://github.com/sweetalert2/sweetalert2/issues/2170\n if (params.toast) {\n applyNumericalStyle(container, 'width', params.width);\n popup.style.width = '100%';\n const loader = getLoader();\n if (loader) {\n popup.insertBefore(loader, getIcon());\n }\n } else {\n applyNumericalStyle(popup, 'width', params.width);\n }\n\n // Padding\n applyNumericalStyle(popup, 'padding', params.padding);\n\n // Color\n if (params.color) {\n popup.style.color = params.color;\n }\n\n // Background\n if (params.background) {\n popup.style.background = params.background;\n }\n hide(getValidationMessage());\n\n // Classes\n addClasses$1(popup, params);\n if (params.draggable && !params.toast) {\n addDraggableListeners(popup);\n } else {\n removeDraggableListeners(popup);\n }\n};\n\n/**\n * @param {HTMLElement} popup\n * @param {SweetAlertOptions} params\n */\nconst addClasses$1 = (popup, params) => {\n const showClass = params.showClass || {};\n // Default Class + showClass when updating Swal.update({})\n popup.className = `${swalClasses.popup} ${isVisible$1(popup) ? showClass.popup : ''}`;\n if (params.toast) {\n addClass([document.documentElement, document.body], swalClasses['toast-shown']);\n addClass(popup, swalClasses.toast);\n } else {\n addClass(popup, swalClasses.modal);\n }\n\n // Custom class\n applyCustomClass(popup, params, 'popup');\n // TODO: remove in the next major\n if (typeof params.customClass === 'string') {\n addClass(popup, params.customClass);\n }\n\n // Icon class (#1842)\n if (params.icon) {\n addClass(popup, swalClasses[`icon-${params.icon}`]);\n }\n};\n\n/**\n * @param {SweetAlert} instance\n * @param {SweetAlertOptions} params\n */\nconst renderProgressSteps = (instance, params) => {\n const progressStepsContainer = getProgressSteps();\n if (!progressStepsContainer) {\n return;\n }\n const {\n progressSteps,\n currentProgressStep\n } = params;\n if (!progressSteps || progressSteps.length === 0 || currentProgressStep === undefined) {\n hide(progressStepsContainer);\n return;\n }\n show(progressStepsContainer);\n progressStepsContainer.textContent = '';\n if (currentProgressStep >= progressSteps.length) {\n warn('Invalid currentProgressStep parameter, it should be less than progressSteps.length ' + '(currentProgressStep like JS arrays starts from 0)');\n }\n progressSteps.forEach((step, index) => {\n const stepEl = createStepElement(step);\n progressStepsContainer.appendChild(stepEl);\n if (index === currentProgressStep) {\n addClass(stepEl, swalClasses['active-progress-step']);\n }\n if (index !== progressSteps.length - 1) {\n const lineEl = createLineElement(params);\n progressStepsContainer.appendChild(lineEl);\n }\n });\n};\n\n/**\n * @param {string} step\n * @returns {HTMLLIElement}\n */\nconst createStepElement = step => {\n const stepEl = document.createElement('li');\n addClass(stepEl, swalClasses['progress-step']);\n setInnerHtml(stepEl, step);\n return stepEl;\n};\n\n/**\n * @param {SweetAlertOptions} params\n * @returns {HTMLLIElement}\n */\nconst createLineElement = params => {\n const lineEl = document.createElement('li');\n addClass(lineEl, swalClasses['progress-step-line']);\n if (params.progressStepsDistance) {\n applyNumericalStyle(lineEl, 'width', params.progressStepsDistance);\n }\n return lineEl;\n};\n\n/**\n * @param {SweetAlert} instance\n * @param {SweetAlertOptions} params\n */\nconst renderTitle = (instance, params) => {\n const title = getTitle();\n if (!title) {\n return;\n }\n showWhenInnerHtmlPresent(title);\n toggle(title, params.title || params.titleText, 'block');\n if (params.title) {\n parseHtmlToContainer(params.title, title);\n }\n if (params.titleText) {\n title.innerText = params.titleText;\n }\n\n // Custom class\n applyCustomClass(title, params, 'title');\n};\n\n/**\n * @param {SweetAlert} instance\n * @param {SweetAlertOptions} params\n */\nconst render = (instance, params) => {\n renderPopup(instance, params);\n renderContainer(instance, params);\n renderProgressSteps(instance, params);\n renderIcon(instance, params);\n renderImage(instance, params);\n renderTitle(instance, params);\n renderCloseButton(instance, params);\n renderContent(instance, params);\n renderActions(instance, params);\n renderFooter(instance, params);\n const popup = getPopup();\n if (typeof params.didRender === 'function' && popup) {\n params.didRender(popup);\n }\n globalState.eventEmitter.emit('didRender', popup);\n};\n\n/*\n * Global function to determine if SweetAlert2 popup is shown\n */\nconst isVisible = () => {\n return isVisible$1(getPopup());\n};\n\n/*\n * Global function to click 'Confirm' button\n */\nconst clickConfirm = () => {\n var _dom$getConfirmButton;\n return (_dom$getConfirmButton = getConfirmButton()) === null || _dom$getConfirmButton === void 0 ? void 0 : _dom$getConfirmButton.click();\n};\n\n/*\n * Global function to click 'Deny' button\n */\nconst clickDeny = () => {\n var _dom$getDenyButton;\n return (_dom$getDenyButton = getDenyButton()) === null || _dom$getDenyButton === void 0 ? void 0 : _dom$getDenyButton.click();\n};\n\n/*\n * Global function to click 'Cancel' button\n */\nconst clickCancel = () => {\n var _dom$getCancelButton;\n return (_dom$getCancelButton = getCancelButton()) === null || _dom$getCancelButton === void 0 ? void 0 : _dom$getCancelButton.click();\n};\n\n/** @typedef {'cancel' | 'backdrop' | 'close' | 'esc' | 'timer'} DismissReason */\n\n/** @type {Record} */\nconst DismissReason = Object.freeze({\n cancel: 'cancel',\n backdrop: 'backdrop',\n close: 'close',\n esc: 'esc',\n timer: 'timer'\n});\n\n/**\n * @param {GlobalState} globalState\n */\nconst removeKeydownHandler = globalState => {\n if (globalState.keydownTarget && globalState.keydownHandlerAdded) {\n globalState.keydownTarget.removeEventListener('keydown', globalState.keydownHandler, {\n capture: globalState.keydownListenerCapture\n });\n globalState.keydownHandlerAdded = false;\n }\n};\n\n/**\n * @param {GlobalState} globalState\n * @param {SweetAlertOptions} innerParams\n * @param {*} dismissWith\n */\nconst addKeydownHandler = (globalState, innerParams, dismissWith) => {\n removeKeydownHandler(globalState);\n if (!innerParams.toast) {\n globalState.keydownHandler = e => keydownHandler(innerParams, e, dismissWith);\n globalState.keydownTarget = innerParams.keydownListenerCapture ? window : getPopup();\n globalState.keydownListenerCapture = innerParams.keydownListenerCapture;\n globalState.keydownTarget.addEventListener('keydown', globalState.keydownHandler, {\n capture: globalState.keydownListenerCapture\n });\n globalState.keydownHandlerAdded = true;\n }\n};\n\n/**\n * @param {number} index\n * @param {number} increment\n */\nconst setFocus = (index, increment) => {\n var _dom$getPopup;\n const focusableElements = getFocusableElements();\n // search for visible elements and select the next possible match\n if (focusableElements.length) {\n index = index + increment;\n\n // rollover to first item\n if (index === focusableElements.length) {\n index = 0;\n\n // go to last item\n } else if (index === -1) {\n index = focusableElements.length - 1;\n }\n focusableElements[index].focus();\n return;\n }\n // no visible focusable elements, focus the popup\n (_dom$getPopup = getPopup()) === null || _dom$getPopup === void 0 || _dom$getPopup.focus();\n};\nconst arrowKeysNextButton = ['ArrowRight', 'ArrowDown'];\nconst arrowKeysPreviousButton = ['ArrowLeft', 'ArrowUp'];\n\n/**\n * @param {SweetAlertOptions} innerParams\n * @param {KeyboardEvent} event\n * @param {Function} dismissWith\n */\nconst keydownHandler = (innerParams, event, dismissWith) => {\n if (!innerParams) {\n return; // This instance has already been destroyed\n }\n\n // Ignore keydown during IME composition\n // https://developer.mozilla.org/en-US/docs/Web/API/Document/keydown_event#ignoring_keydown_during_ime_composition\n // https://github.com/sweetalert2/sweetalert2/issues/720\n // https://github.com/sweetalert2/sweetalert2/issues/2406\n if (event.isComposing || event.keyCode === 229) {\n return;\n }\n if (innerParams.stopKeydownPropagation) {\n event.stopPropagation();\n }\n\n // ENTER\n if (event.key === 'Enter') {\n handleEnter(event, innerParams);\n }\n\n // TAB\n else if (event.key === 'Tab') {\n handleTab(event);\n }\n\n // ARROWS - switch focus between buttons\n else if ([...arrowKeysNextButton, ...arrowKeysPreviousButton].includes(event.key)) {\n handleArrows(event.key);\n }\n\n // ESC\n else if (event.key === 'Escape') {\n handleEsc(event, innerParams, dismissWith);\n }\n};\n\n/**\n * @param {KeyboardEvent} event\n * @param {SweetAlertOptions} innerParams\n */\nconst handleEnter = (event, innerParams) => {\n // https://github.com/sweetalert2/sweetalert2/issues/2386\n if (!callIfFunction(innerParams.allowEnterKey)) {\n return;\n }\n const input = getInput$1(getPopup(), innerParams.input);\n if (event.target && input && event.target instanceof HTMLElement && event.target.outerHTML === input.outerHTML) {\n if (['textarea', 'file'].includes(innerParams.input)) {\n return; // do not submit\n }\n clickConfirm();\n event.preventDefault();\n }\n};\n\n/**\n * @param {KeyboardEvent} event\n */\nconst handleTab = event => {\n const targetElement = event.target;\n const focusableElements = getFocusableElements();\n let btnIndex = -1;\n for (let i = 0; i < focusableElements.length; i++) {\n if (targetElement === focusableElements[i]) {\n btnIndex = i;\n break;\n }\n }\n\n // Cycle to the next button\n if (!event.shiftKey) {\n setFocus(btnIndex, 1);\n }\n\n // Cycle to the prev button\n else {\n setFocus(btnIndex, -1);\n }\n event.stopPropagation();\n event.preventDefault();\n};\n\n/**\n * @param {string} key\n */\nconst handleArrows = key => {\n const actions = getActions();\n const confirmButton = getConfirmButton();\n const denyButton = getDenyButton();\n const cancelButton = getCancelButton();\n if (!actions || !confirmButton || !denyButton || !cancelButton) {\n return;\n }\n /** @type HTMLElement[] */\n const buttons = [confirmButton, denyButton, cancelButton];\n if (document.activeElement instanceof HTMLElement && !buttons.includes(document.activeElement)) {\n return;\n }\n const sibling = arrowKeysNextButton.includes(key) ? 'nextElementSibling' : 'previousElementSibling';\n let buttonToFocus = document.activeElement;\n if (!buttonToFocus) {\n return;\n }\n for (let i = 0; i < actions.children.length; i++) {\n buttonToFocus = buttonToFocus[sibling];\n if (!buttonToFocus) {\n return;\n }\n if (buttonToFocus instanceof HTMLButtonElement && isVisible$1(buttonToFocus)) {\n break;\n }\n }\n if (buttonToFocus instanceof HTMLButtonElement) {\n buttonToFocus.focus();\n }\n};\n\n/**\n * @param {KeyboardEvent} event\n * @param {SweetAlertOptions} innerParams\n * @param {Function} dismissWith\n */\nconst handleEsc = (event, innerParams, dismissWith) => {\n if (callIfFunction(innerParams.allowEscapeKey)) {\n event.preventDefault();\n dismissWith(DismissReason.esc);\n }\n};\n\n/**\n * This module contains `WeakMap`s for each effectively-\"private property\" that a `Swal` has.\n * For example, to set the private property \"foo\" of `this` to \"bar\", you can `privateProps.foo.set(this, 'bar')`\n * This is the approach that Babel will probably take to implement private methods/fields\n * https://github.com/tc39/proposal-private-methods\n * https://github.com/babel/babel/pull/7555\n * Once we have the changes from that PR in Babel, and our core class fits reasonable in *one module*\n * then we can use that language feature.\n */\n\nvar privateMethods = {\n swalPromiseResolve: new WeakMap(),\n swalPromiseReject: new WeakMap()\n};\n\n// From https://developer.paciellogroup.com/blog/2018/06/the-current-state-of-modal-dialog-accessibility/\n// Adding aria-hidden=\"true\" to elements outside of the active modal dialog ensures that\n// elements not within the active modal dialog will not be surfaced if a user opens a screen\n// reader’s list of elements (headings, form controls, landmarks, etc.) in the document.\n\nconst setAriaHidden = () => {\n const container = getContainer();\n const bodyChildren = Array.from(document.body.children);\n bodyChildren.forEach(el => {\n if (el.contains(container)) {\n return;\n }\n if (el.hasAttribute('aria-hidden')) {\n el.setAttribute('data-previous-aria-hidden', el.getAttribute('aria-hidden') || '');\n }\n el.setAttribute('aria-hidden', 'true');\n });\n};\nconst unsetAriaHidden = () => {\n const bodyChildren = Array.from(document.body.children);\n bodyChildren.forEach(el => {\n if (el.hasAttribute('data-previous-aria-hidden')) {\n el.setAttribute('aria-hidden', el.getAttribute('data-previous-aria-hidden') || '');\n el.removeAttribute('data-previous-aria-hidden');\n } else {\n el.removeAttribute('aria-hidden');\n }\n });\n};\n\n// @ts-ignore\nconst isSafariOrIOS = typeof window !== 'undefined' && !!window.GestureEvent; // true for Safari desktop + all iOS browsers https://stackoverflow.com/a/70585394\n\n/**\n * Fix iOS scrolling\n * http://stackoverflow.com/q/39626302\n */\nconst iOSfix = () => {\n if (isSafariOrIOS && !hasClass(document.body, swalClasses.iosfix)) {\n const offset = document.body.scrollTop;\n document.body.style.top = `${offset * -1}px`;\n addClass(document.body, swalClasses.iosfix);\n lockBodyScroll();\n }\n};\n\n/**\n * https://github.com/sweetalert2/sweetalert2/issues/1246\n */\nconst lockBodyScroll = () => {\n const container = getContainer();\n if (!container) {\n return;\n }\n /** @type {boolean} */\n let preventTouchMove;\n /**\n * @param {TouchEvent} event\n */\n container.ontouchstart = event => {\n preventTouchMove = shouldPreventTouchMove(event);\n };\n /**\n * @param {TouchEvent} event\n */\n container.ontouchmove = event => {\n if (preventTouchMove) {\n event.preventDefault();\n event.stopPropagation();\n }\n };\n};\n\n/**\n * @param {TouchEvent} event\n * @returns {boolean}\n */\nconst shouldPreventTouchMove = event => {\n const target = event.target;\n const container = getContainer();\n const htmlContainer = getHtmlContainer();\n if (!container || !htmlContainer) {\n return false;\n }\n if (isStylus(event) || isZoom(event)) {\n return false;\n }\n if (target === container) {\n return true;\n }\n if (!isScrollable(container) && target instanceof HTMLElement && target.tagName !== 'INPUT' &&\n // #1603\n target.tagName !== 'TEXTAREA' &&\n // #2266\n !(isScrollable(htmlContainer) &&\n // #1944\n htmlContainer.contains(target))) {\n return true;\n }\n return false;\n};\n\n/**\n * https://github.com/sweetalert2/sweetalert2/issues/1786\n *\n * @param {*} event\n * @returns {boolean}\n */\nconst isStylus = event => {\n return event.touches && event.touches.length && event.touches[0].touchType === 'stylus';\n};\n\n/**\n * https://github.com/sweetalert2/sweetalert2/issues/1891\n *\n * @param {TouchEvent} event\n * @returns {boolean}\n */\nconst isZoom = event => {\n return event.touches && event.touches.length > 1;\n};\nconst undoIOSfix = () => {\n if (hasClass(document.body, swalClasses.iosfix)) {\n const offset = parseInt(document.body.style.top, 10);\n removeClass(document.body, swalClasses.iosfix);\n document.body.style.top = '';\n document.body.scrollTop = offset * -1;\n }\n};\n\n/**\n * Measure scrollbar width for padding body during modal show/hide\n * https://github.com/twbs/bootstrap/blob/master/js/src/modal.js\n *\n * @returns {number}\n */\nconst measureScrollbar = () => {\n const scrollDiv = document.createElement('div');\n scrollDiv.className = swalClasses['scrollbar-measure'];\n document.body.appendChild(scrollDiv);\n const scrollbarWidth = scrollDiv.getBoundingClientRect().width - scrollDiv.clientWidth;\n document.body.removeChild(scrollDiv);\n return scrollbarWidth;\n};\n\n/**\n * Remember state in cases where opening and handling a modal will fiddle with it.\n * @type {number | null}\n */\nlet previousBodyPadding = null;\n\n/**\n * @param {string} initialBodyOverflow\n */\nconst replaceScrollbarWithPadding = initialBodyOverflow => {\n // for queues, do not do this more than once\n if (previousBodyPadding !== null) {\n return;\n }\n // if the body has overflow\n if (document.body.scrollHeight > window.innerHeight || initialBodyOverflow === 'scroll' // https://github.com/sweetalert2/sweetalert2/issues/2663\n ) {\n // add padding so the content doesn't shift after removal of scrollbar\n previousBodyPadding = parseInt(window.getComputedStyle(document.body).getPropertyValue('padding-right'));\n document.body.style.paddingRight = `${previousBodyPadding + measureScrollbar()}px`;\n }\n};\nconst undoReplaceScrollbarWithPadding = () => {\n if (previousBodyPadding !== null) {\n document.body.style.paddingRight = `${previousBodyPadding}px`;\n previousBodyPadding = null;\n }\n};\n\n/**\n * @param {SweetAlert} instance\n * @param {HTMLElement} container\n * @param {boolean} returnFocus\n * @param {Function} didClose\n */\nfunction removePopupAndResetState(instance, container, returnFocus, didClose) {\n if (isToast()) {\n triggerDidCloseAndDispose(instance, didClose);\n } else {\n restoreActiveElement(returnFocus).then(() => triggerDidCloseAndDispose(instance, didClose));\n removeKeydownHandler(globalState);\n }\n\n // workaround for https://github.com/sweetalert2/sweetalert2/issues/2088\n // for some reason removing the container in Safari will scroll the document to bottom\n if (isSafariOrIOS) {\n container.setAttribute('style', 'display:none !important');\n container.removeAttribute('class');\n container.innerHTML = '';\n } else {\n container.remove();\n }\n if (isModal()) {\n undoReplaceScrollbarWithPadding();\n undoIOSfix();\n unsetAriaHidden();\n }\n removeBodyClasses();\n}\n\n/**\n * Remove SweetAlert2 classes from body\n */\nfunction removeBodyClasses() {\n removeClass([document.documentElement, document.body], [swalClasses.shown, swalClasses['height-auto'], swalClasses['no-backdrop'], swalClasses['toast-shown']]);\n}\n\n/**\n * Instance method to close sweetAlert\n *\n * @param {any} resolveValue\n */\nfunction close(resolveValue) {\n resolveValue = prepareResolveValue(resolveValue);\n const swalPromiseResolve = privateMethods.swalPromiseResolve.get(this);\n const didClose = triggerClosePopup(this);\n if (this.isAwaitingPromise) {\n // A swal awaiting for a promise (after a click on Confirm or Deny) cannot be dismissed anymore #2335\n if (!resolveValue.isDismissed) {\n handleAwaitingPromise(this);\n swalPromiseResolve(resolveValue);\n }\n } else if (didClose) {\n // Resolve Swal promise\n swalPromiseResolve(resolveValue);\n }\n}\nconst triggerClosePopup = instance => {\n const popup = getPopup();\n if (!popup) {\n return false;\n }\n const innerParams = privateProps.innerParams.get(instance);\n if (!innerParams || hasClass(popup, innerParams.hideClass.popup)) {\n return false;\n }\n removeClass(popup, innerParams.showClass.popup);\n addClass(popup, innerParams.hideClass.popup);\n const backdrop = getContainer();\n removeClass(backdrop, innerParams.showClass.backdrop);\n addClass(backdrop, innerParams.hideClass.backdrop);\n handlePopupAnimation(instance, popup, innerParams);\n return true;\n};\n\n/**\n * @param {any} error\n */\nfunction rejectPromise(error) {\n const rejectPromise = privateMethods.swalPromiseReject.get(this);\n handleAwaitingPromise(this);\n if (rejectPromise) {\n // Reject Swal promise\n rejectPromise(error);\n }\n}\n\n/**\n * @param {SweetAlert} instance\n */\nconst handleAwaitingPromise = instance => {\n if (instance.isAwaitingPromise) {\n delete instance.isAwaitingPromise;\n // The instance might have been previously partly destroyed, we must resume the destroy process in this case #2335\n if (!privateProps.innerParams.get(instance)) {\n instance._destroy();\n }\n }\n};\n\n/**\n * @param {any} resolveValue\n * @returns {SweetAlertResult}\n */\nconst prepareResolveValue = resolveValue => {\n // When user calls Swal.close()\n if (typeof resolveValue === 'undefined') {\n return {\n isConfirmed: false,\n isDenied: false,\n isDismissed: true\n };\n }\n return Object.assign({\n isConfirmed: false,\n isDenied: false,\n isDismissed: false\n }, resolveValue);\n};\n\n/**\n * @param {SweetAlert} instance\n * @param {HTMLElement} popup\n * @param {SweetAlertOptions} innerParams\n */\nconst handlePopupAnimation = (instance, popup, innerParams) => {\n var _globalState$eventEmi;\n const container = getContainer();\n // If animation is supported, animate\n const animationIsSupported = hasCssAnimation(popup);\n if (typeof innerParams.willClose === 'function') {\n innerParams.willClose(popup);\n }\n (_globalState$eventEmi = globalState.eventEmitter) === null || _globalState$eventEmi === void 0 || _globalState$eventEmi.emit('willClose', popup);\n if (animationIsSupported) {\n animatePopup(instance, popup, container, innerParams.returnFocus, innerParams.didClose);\n } else {\n // Otherwise, remove immediately\n removePopupAndResetState(instance, container, innerParams.returnFocus, innerParams.didClose);\n }\n};\n\n/**\n * @param {SweetAlert} instance\n * @param {HTMLElement} popup\n * @param {HTMLElement} container\n * @param {boolean} returnFocus\n * @param {Function} didClose\n */\nconst animatePopup = (instance, popup, container, returnFocus, didClose) => {\n globalState.swalCloseEventFinishedCallback = removePopupAndResetState.bind(null, instance, container, returnFocus, didClose);\n /**\n * @param {AnimationEvent | TransitionEvent} e\n */\n const swalCloseAnimationFinished = function (e) {\n if (e.target === popup) {\n var _globalState$swalClos;\n (_globalState$swalClos = globalState.swalCloseEventFinishedCallback) === null || _globalState$swalClos === void 0 || _globalState$swalClos.call(globalState);\n delete globalState.swalCloseEventFinishedCallback;\n popup.removeEventListener('animationend', swalCloseAnimationFinished);\n popup.removeEventListener('transitionend', swalCloseAnimationFinished);\n }\n };\n popup.addEventListener('animationend', swalCloseAnimationFinished);\n popup.addEventListener('transitionend', swalCloseAnimationFinished);\n};\n\n/**\n * @param {SweetAlert} instance\n * @param {Function} didClose\n */\nconst triggerDidCloseAndDispose = (instance, didClose) => {\n setTimeout(() => {\n var _globalState$eventEmi2;\n if (typeof didClose === 'function') {\n didClose.bind(instance.params)();\n }\n (_globalState$eventEmi2 = globalState.eventEmitter) === null || _globalState$eventEmi2 === void 0 || _globalState$eventEmi2.emit('didClose');\n // instance might have been destroyed already\n if (instance._destroy) {\n instance._destroy();\n }\n });\n};\n\n/**\n * Shows loader (spinner), this is useful with AJAX requests.\n * By default the loader be shown instead of the \"Confirm\" button.\n *\n * @param {HTMLButtonElement | null} [buttonToReplace]\n */\nconst showLoading = buttonToReplace => {\n let popup = getPopup();\n if (!popup) {\n new Swal();\n }\n popup = getPopup();\n if (!popup) {\n return;\n }\n const loader = getLoader();\n if (isToast()) {\n hide(getIcon());\n } else {\n replaceButton(popup, buttonToReplace);\n }\n show(loader);\n popup.setAttribute('data-loading', 'true');\n popup.setAttribute('aria-busy', 'true');\n popup.focus();\n};\n\n/**\n * @param {HTMLElement} popup\n * @param {HTMLButtonElement | null} [buttonToReplace]\n */\nconst replaceButton = (popup, buttonToReplace) => {\n const actions = getActions();\n const loader = getLoader();\n if (!actions || !loader) {\n return;\n }\n if (!buttonToReplace && isVisible$1(getConfirmButton())) {\n buttonToReplace = getConfirmButton();\n }\n show(actions);\n if (buttonToReplace) {\n hide(buttonToReplace);\n loader.setAttribute('data-button-to-replace', buttonToReplace.className);\n actions.insertBefore(loader, buttonToReplace);\n }\n addClass([popup, actions], swalClasses.loading);\n};\n\n/**\n * @param {SweetAlert} instance\n * @param {SweetAlertOptions} params\n */\nconst handleInputOptionsAndValue = (instance, params) => {\n if (params.input === 'select' || params.input === 'radio') {\n handleInputOptions(instance, params);\n } else if (['text', 'email', 'number', 'tel', 'textarea'].some(i => i === params.input) && (hasToPromiseFn(params.inputValue) || isPromise(params.inputValue))) {\n showLoading(getConfirmButton());\n handleInputValue(instance, params);\n }\n};\n\n/**\n * @param {SweetAlert} instance\n * @param {SweetAlertOptions} innerParams\n * @returns {SweetAlertInputValue}\n */\nconst getInputValue = (instance, innerParams) => {\n const input = instance.getInput();\n if (!input) {\n return null;\n }\n switch (innerParams.input) {\n case 'checkbox':\n return getCheckboxValue(input);\n case 'radio':\n return getRadioValue(input);\n case 'file':\n return getFileValue(input);\n default:\n return innerParams.inputAutoTrim ? input.value.trim() : input.value;\n }\n};\n\n/**\n * @param {HTMLInputElement} input\n * @returns {number}\n */\nconst getCheckboxValue = input => input.checked ? 1 : 0;\n\n/**\n * @param {HTMLInputElement} input\n * @returns {string | null}\n */\nconst getRadioValue = input => input.checked ? input.value : null;\n\n/**\n * @param {HTMLInputElement} input\n * @returns {FileList | File | null}\n */\nconst getFileValue = input => input.files && input.files.length ? input.getAttribute('multiple') !== null ? input.files : input.files[0] : null;\n\n/**\n * @param {SweetAlert} instance\n * @param {SweetAlertOptions} params\n */\nconst handleInputOptions = (instance, params) => {\n const popup = getPopup();\n if (!popup) {\n return;\n }\n /**\n * @param {Record} inputOptions\n */\n const processInputOptions = inputOptions => {\n if (params.input === 'select') {\n populateSelectOptions(popup, formatInputOptions(inputOptions), params);\n } else if (params.input === 'radio') {\n populateRadioOptions(popup, formatInputOptions(inputOptions), params);\n }\n };\n if (hasToPromiseFn(params.inputOptions) || isPromise(params.inputOptions)) {\n showLoading(getConfirmButton());\n asPromise(params.inputOptions).then(inputOptions => {\n instance.hideLoading();\n processInputOptions(inputOptions);\n });\n } else if (typeof params.inputOptions === 'object') {\n processInputOptions(params.inputOptions);\n } else {\n error(`Unexpected type of inputOptions! Expected object, Map or Promise, got ${typeof params.inputOptions}`);\n }\n};\n\n/**\n * @param {SweetAlert} instance\n * @param {SweetAlertOptions} params\n */\nconst handleInputValue = (instance, params) => {\n const input = instance.getInput();\n if (!input) {\n return;\n }\n hide(input);\n asPromise(params.inputValue).then(inputValue => {\n input.value = params.input === 'number' ? `${parseFloat(inputValue) || 0}` : `${inputValue}`;\n show(input);\n input.focus();\n instance.hideLoading();\n }).catch(err => {\n error(`Error in inputValue promise: ${err}`);\n input.value = '';\n show(input);\n input.focus();\n instance.hideLoading();\n });\n};\n\n/**\n * @param {HTMLElement} popup\n * @param {InputOptionFlattened[]} inputOptions\n * @param {SweetAlertOptions} params\n */\nfunction populateSelectOptions(popup, inputOptions, params) {\n const select = getDirectChildByClass(popup, swalClasses.select);\n if (!select) {\n return;\n }\n /**\n * @param {HTMLElement} parent\n * @param {string} optionLabel\n * @param {string} optionValue\n */\n const renderOption = (parent, optionLabel, optionValue) => {\n const option = document.createElement('option');\n option.value = optionValue;\n setInnerHtml(option, optionLabel);\n option.selected = isSelected(optionValue, params.inputValue);\n parent.appendChild(option);\n };\n inputOptions.forEach(inputOption => {\n const optionValue = inputOption[0];\n const optionLabel = inputOption[1];\n // spec:\n // https://www.w3.org/TR/html401/interact/forms.html#h-17.6\n // \"...all OPTGROUP elements must be specified directly within a SELECT element (i.e., groups may not be nested)...\"\n // check whether this is a \n if (Array.isArray(optionLabel)) {\n // if it is an array, then it is an \n const optgroup = document.createElement('optgroup');\n optgroup.label = optionValue;\n optgroup.disabled = false; // not configurable for now\n select.appendChild(optgroup);\n optionLabel.forEach(o => renderOption(optgroup, o[1], o[0]));\n } else {\n // case of