4672 lines
146 KiB
JavaScript
4672 lines
146 KiB
JavaScript
import {
|
||
CustomSelect,
|
||
taskCenterManager,
|
||
toastManager
|
||
} from "./chunk-U67KAGZP.js";
|
||
import {
|
||
apiFetch,
|
||
apiFetchJson,
|
||
modalManager,
|
||
uiPatterns
|
||
} from "./chunk-VOGCL6QZ.js";
|
||
import "./chunk-JSBRDJBE.js";
|
||
|
||
// frontend/js/vendor/sweetalert2.esm.js
|
||
function _assertClassBrand(e, t, n) {
|
||
if ("function" == typeof e ? e === t : e.has(t)) return arguments.length < 3 ? t : n;
|
||
throw new TypeError("Private element is not present on this object");
|
||
}
|
||
function _checkPrivateRedeclaration(e, t) {
|
||
if (t.has(e)) throw new TypeError("Cannot initialize the same private elements twice on an object");
|
||
}
|
||
function _classPrivateFieldGet2(s, a) {
|
||
return s.get(_assertClassBrand(s, a));
|
||
}
|
||
function _classPrivateFieldInitSpec(e, t, a) {
|
||
_checkPrivateRedeclaration(e, t), t.set(e, a);
|
||
}
|
||
function _classPrivateFieldSet2(s, a, r) {
|
||
return s.set(_assertClassBrand(s, a), r), r;
|
||
}
|
||
var RESTORE_FOCUS_TIMEOUT = 100;
|
||
var globalState = {};
|
||
var focusPreviousActiveElement = () => {
|
||
if (globalState.previousActiveElement instanceof HTMLElement) {
|
||
globalState.previousActiveElement.focus();
|
||
globalState.previousActiveElement = null;
|
||
} else if (document.body) {
|
||
document.body.focus();
|
||
}
|
||
};
|
||
var restoreActiveElement = (returnFocus) => {
|
||
return new Promise((resolve) => {
|
||
if (!returnFocus) {
|
||
return resolve();
|
||
}
|
||
const x = window.scrollX;
|
||
const y = window.scrollY;
|
||
globalState.restoreFocusTimeout = setTimeout(() => {
|
||
focusPreviousActiveElement();
|
||
resolve();
|
||
}, RESTORE_FOCUS_TIMEOUT);
|
||
window.scrollTo(x, y);
|
||
});
|
||
};
|
||
var swalPrefix = "swal2-";
|
||
var classNames = ["container", "shown", "height-auto", "iosfix", "popup", "modal", "no-backdrop", "no-transition", "toast", "toast-shown", "show", "hide", "close", "title", "html-container", "actions", "confirm", "deny", "cancel", "footer", "icon", "icon-content", "image", "input", "file", "range", "select", "radio", "checkbox", "label", "textarea", "inputerror", "input-label", "validation-message", "progress-steps", "active-progress-step", "progress-step", "progress-step-line", "loader", "loading", "styled", "top", "top-start", "top-end", "top-left", "top-right", "center", "center-start", "center-end", "center-left", "center-right", "bottom", "bottom-start", "bottom-end", "bottom-left", "bottom-right", "grow-row", "grow-column", "grow-fullscreen", "rtl", "timer-progress-bar", "timer-progress-bar-container", "scrollbar-measure", "icon-success", "icon-warning", "icon-info", "icon-question", "icon-error", "draggable", "dragging"];
|
||
var swalClasses = classNames.reduce(
|
||
(acc, className) => {
|
||
acc[className] = swalPrefix + className;
|
||
return acc;
|
||
},
|
||
/** @type {SwalClasses} */
|
||
{}
|
||
);
|
||
var icons = ["success", "warning", "info", "question", "error"];
|
||
var iconTypes = icons.reduce(
|
||
(acc, icon) => {
|
||
acc[icon] = swalPrefix + icon;
|
||
return acc;
|
||
},
|
||
/** @type {SwalIcons} */
|
||
{}
|
||
);
|
||
var consolePrefix = "SweetAlert2:";
|
||
var capitalizeFirstLetter = (str) => str.charAt(0).toUpperCase() + str.slice(1);
|
||
var warn = (message) => {
|
||
console.warn(`${consolePrefix} ${typeof message === "object" ? message.join(" ") : message}`);
|
||
};
|
||
var error = (message) => {
|
||
console.error(`${consolePrefix} ${message}`);
|
||
};
|
||
var previousWarnOnceMessages = [];
|
||
var warnOnce = (message) => {
|
||
if (!previousWarnOnceMessages.includes(message)) {
|
||
previousWarnOnceMessages.push(message);
|
||
warn(message);
|
||
}
|
||
};
|
||
var warnAboutDeprecation = (deprecatedParam, useInstead = null) => {
|
||
warnOnce(`"${deprecatedParam}" is deprecated and will be removed in the next major release.${useInstead ? ` Use "${useInstead}" instead.` : ""}`);
|
||
};
|
||
var callIfFunction = (arg) => typeof arg === "function" ? arg() : arg;
|
||
var hasToPromiseFn = (arg) => arg && typeof arg.toPromise === "function";
|
||
var asPromise = (arg) => hasToPromiseFn(arg) ? arg.toPromise() : Promise.resolve(arg);
|
||
var isPromise = (arg) => arg && Promise.resolve(arg) === arg;
|
||
var getContainer = () => document.body.querySelector(`.${swalClasses.container}`);
|
||
var elementBySelector = (selectorString) => {
|
||
const container = getContainer();
|
||
return container ? container.querySelector(selectorString) : null;
|
||
};
|
||
var elementByClass = (className) => {
|
||
return elementBySelector(`.${className}`);
|
||
};
|
||
var getPopup = () => elementByClass(swalClasses.popup);
|
||
var getIcon = () => elementByClass(swalClasses.icon);
|
||
var getIconContent = () => elementByClass(swalClasses["icon-content"]);
|
||
var getTitle = () => elementByClass(swalClasses.title);
|
||
var getHtmlContainer = () => elementByClass(swalClasses["html-container"]);
|
||
var getImage = () => elementByClass(swalClasses.image);
|
||
var getProgressSteps = () => elementByClass(swalClasses["progress-steps"]);
|
||
var getValidationMessage = () => elementByClass(swalClasses["validation-message"]);
|
||
var getConfirmButton = () => (
|
||
/** @type {HTMLButtonElement} */
|
||
elementBySelector(`.${swalClasses.actions} .${swalClasses.confirm}`)
|
||
);
|
||
var getCancelButton = () => (
|
||
/** @type {HTMLButtonElement} */
|
||
elementBySelector(`.${swalClasses.actions} .${swalClasses.cancel}`)
|
||
);
|
||
var getDenyButton = () => (
|
||
/** @type {HTMLButtonElement} */
|
||
elementBySelector(`.${swalClasses.actions} .${swalClasses.deny}`)
|
||
);
|
||
var getInputLabel = () => elementByClass(swalClasses["input-label"]);
|
||
var getLoader = () => elementBySelector(`.${swalClasses.loader}`);
|
||
var getActions = () => elementByClass(swalClasses.actions);
|
||
var getFooter = () => elementByClass(swalClasses.footer);
|
||
var getTimerProgressBar = () => elementByClass(swalClasses["timer-progress-bar"]);
|
||
var getCloseButton = () => elementByClass(swalClasses.close);
|
||
var focusable = `
|
||
a[href],
|
||
area[href],
|
||
input:not([disabled]),
|
||
select:not([disabled]),
|
||
textarea:not([disabled]),
|
||
button:not([disabled]),
|
||
iframe,
|
||
object,
|
||
embed,
|
||
[tabindex="0"],
|
||
[contenteditable],
|
||
audio[controls],
|
||
video[controls],
|
||
summary
|
||
`;
|
||
var getFocusableElements = () => {
|
||
const popup = getPopup();
|
||
if (!popup) {
|
||
return [];
|
||
}
|
||
const focusableElementsWithTabindex = popup.querySelectorAll('[tabindex]:not([tabindex="-1"]):not([tabindex="0"])');
|
||
const focusableElementsWithTabindexSorted = Array.from(focusableElementsWithTabindex).sort((a, b) => {
|
||
const tabindexA = parseInt(a.getAttribute("tabindex") || "0");
|
||
const tabindexB = parseInt(b.getAttribute("tabindex") || "0");
|
||
if (tabindexA > tabindexB) {
|
||
return 1;
|
||
} else if (tabindexA < tabindexB) {
|
||
return -1;
|
||
}
|
||
return 0;
|
||
});
|
||
const otherFocusableElements = popup.querySelectorAll(focusable);
|
||
const otherFocusableElementsFiltered = Array.from(otherFocusableElements).filter((el) => el.getAttribute("tabindex") !== "-1");
|
||
return [...new Set(focusableElementsWithTabindexSorted.concat(otherFocusableElementsFiltered))].filter((el) => isVisible$1(el));
|
||
};
|
||
var isModal = () => {
|
||
return hasClass(document.body, swalClasses.shown) && !hasClass(document.body, swalClasses["toast-shown"]) && !hasClass(document.body, swalClasses["no-backdrop"]);
|
||
};
|
||
var isToast = () => {
|
||
const popup = getPopup();
|
||
if (!popup) {
|
||
return false;
|
||
}
|
||
return hasClass(popup, swalClasses.toast);
|
||
};
|
||
var isLoading = () => {
|
||
const popup = getPopup();
|
||
if (!popup) {
|
||
return false;
|
||
}
|
||
return popup.hasAttribute("data-loading");
|
||
};
|
||
var setInnerHtml = (elem, html) => {
|
||
elem.textContent = "";
|
||
if (html) {
|
||
const parser = new DOMParser();
|
||
const parsed = parser.parseFromString(html, `text/html`);
|
||
const head = parsed.querySelector("head");
|
||
if (head) {
|
||
Array.from(head.childNodes).forEach((child) => {
|
||
elem.appendChild(child);
|
||
});
|
||
}
|
||
const body = parsed.querySelector("body");
|
||
if (body) {
|
||
Array.from(body.childNodes).forEach((child) => {
|
||
if (child instanceof HTMLVideoElement || child instanceof HTMLAudioElement) {
|
||
elem.appendChild(child.cloneNode(true));
|
||
} else {
|
||
elem.appendChild(child);
|
||
}
|
||
});
|
||
}
|
||
}
|
||
};
|
||
var hasClass = (elem, className) => {
|
||
if (!className) {
|
||
return false;
|
||
}
|
||
const classList = className.split(/\s+/);
|
||
for (let i = 0; i < classList.length; i++) {
|
||
if (!elem.classList.contains(classList[i])) {
|
||
return false;
|
||
}
|
||
}
|
||
return true;
|
||
};
|
||
var removeCustomClasses = (elem, params) => {
|
||
Array.from(elem.classList).forEach((className) => {
|
||
if (!Object.values(swalClasses).includes(className) && !Object.values(iconTypes).includes(className) && !Object.values(params.showClass || {}).includes(className)) {
|
||
elem.classList.remove(className);
|
||
}
|
||
});
|
||
};
|
||
var applyCustomClass = (elem, params, className) => {
|
||
removeCustomClasses(elem, params);
|
||
if (!params.customClass) {
|
||
return;
|
||
}
|
||
const customClass = params.customClass[
|
||
/** @type {keyof SweetAlertCustomClass} */
|
||
className
|
||
];
|
||
if (!customClass) {
|
||
return;
|
||
}
|
||
if (typeof customClass !== "string" && !customClass.forEach) {
|
||
warn(`Invalid type of customClass.${className}! Expected string or iterable object, got "${typeof customClass}"`);
|
||
return;
|
||
}
|
||
addClass(elem, customClass);
|
||
};
|
||
var getInput$1 = (popup, inputClass) => {
|
||
if (!inputClass) {
|
||
return null;
|
||
}
|
||
switch (inputClass) {
|
||
case "select":
|
||
case "textarea":
|
||
case "file":
|
||
return popup.querySelector(`.${swalClasses.popup} > .${swalClasses[inputClass]}`);
|
||
case "checkbox":
|
||
return popup.querySelector(`.${swalClasses.popup} > .${swalClasses.checkbox} input`);
|
||
case "radio":
|
||
return popup.querySelector(`.${swalClasses.popup} > .${swalClasses.radio} input:checked`) || popup.querySelector(`.${swalClasses.popup} > .${swalClasses.radio} input:first-child`);
|
||
case "range":
|
||
return popup.querySelector(`.${swalClasses.popup} > .${swalClasses.range} input`);
|
||
default:
|
||
return popup.querySelector(`.${swalClasses.popup} > .${swalClasses.input}`);
|
||
}
|
||
};
|
||
var focusInput = (input) => {
|
||
input.focus();
|
||
if (input.type !== "file") {
|
||
const val = input.value;
|
||
input.value = "";
|
||
input.value = val;
|
||
}
|
||
};
|
||
var toggleClass = (target, classList, condition) => {
|
||
if (!target || !classList) {
|
||
return;
|
||
}
|
||
if (typeof classList === "string") {
|
||
classList = classList.split(/\s+/).filter(Boolean);
|
||
}
|
||
classList.forEach((className) => {
|
||
if (Array.isArray(target)) {
|
||
target.forEach((elem) => {
|
||
if (condition) {
|
||
elem.classList.add(className);
|
||
} else {
|
||
elem.classList.remove(className);
|
||
}
|
||
});
|
||
} else {
|
||
if (condition) {
|
||
target.classList.add(className);
|
||
} else {
|
||
target.classList.remove(className);
|
||
}
|
||
}
|
||
});
|
||
};
|
||
var addClass = (target, classList) => {
|
||
toggleClass(target, classList, true);
|
||
};
|
||
var removeClass = (target, classList) => {
|
||
toggleClass(target, classList, false);
|
||
};
|
||
var getDirectChildByClass = (elem, className) => {
|
||
const children = Array.from(elem.children);
|
||
for (let i = 0; i < children.length; i++) {
|
||
const child = children[i];
|
||
if (child instanceof HTMLElement && hasClass(child, className)) {
|
||
return child;
|
||
}
|
||
}
|
||
};
|
||
var applyNumericalStyle = (elem, property, value) => {
|
||
if (value === `${parseInt(`${value}`)}`) {
|
||
value = parseInt(value);
|
||
}
|
||
if (value || parseInt(`${value}`) === 0) {
|
||
elem.style.setProperty(property, typeof value === "number" ? `${value}px` : value);
|
||
} else {
|
||
elem.style.removeProperty(property);
|
||
}
|
||
};
|
||
var show = (elem, display = "flex") => {
|
||
if (!elem) {
|
||
return;
|
||
}
|
||
elem.style.display = display;
|
||
};
|
||
var hide = (elem) => {
|
||
if (!elem) {
|
||
return;
|
||
}
|
||
elem.style.display = "none";
|
||
};
|
||
var showWhenInnerHtmlPresent = (elem, display = "block") => {
|
||
if (!elem) {
|
||
return;
|
||
}
|
||
new MutationObserver(() => {
|
||
toggle(elem, elem.innerHTML, display);
|
||
}).observe(elem, {
|
||
childList: true,
|
||
subtree: true
|
||
});
|
||
};
|
||
var setStyle = (parent, selector, property, value) => {
|
||
const el = parent.querySelector(selector);
|
||
if (el) {
|
||
el.style.setProperty(property, value);
|
||
}
|
||
};
|
||
var toggle = (elem, condition, display = "flex") => {
|
||
if (condition) {
|
||
show(elem, display);
|
||
} else {
|
||
hide(elem);
|
||
}
|
||
};
|
||
var isVisible$1 = (elem) => !!(elem && (elem.offsetWidth || elem.offsetHeight || elem.getClientRects().length));
|
||
var allButtonsAreHidden = () => !isVisible$1(getConfirmButton()) && !isVisible$1(getDenyButton()) && !isVisible$1(getCancelButton());
|
||
var isScrollable = (elem) => !!(elem.scrollHeight > elem.clientHeight);
|
||
var selfOrParentIsScrollable = (element, stopElement) => {
|
||
let parent = element;
|
||
while (parent && parent !== stopElement) {
|
||
if (isScrollable(parent)) {
|
||
return true;
|
||
}
|
||
parent = parent.parentElement;
|
||
}
|
||
return false;
|
||
};
|
||
var hasCssAnimation = (elem) => {
|
||
const style = window.getComputedStyle(elem);
|
||
const animDuration = parseFloat(style.getPropertyValue("animation-duration") || "0");
|
||
const transDuration = parseFloat(style.getPropertyValue("transition-duration") || "0");
|
||
return animDuration > 0 || transDuration > 0;
|
||
};
|
||
var animateTimerProgressBar = (timer, reset = false) => {
|
||
const timerProgressBar = getTimerProgressBar();
|
||
if (!timerProgressBar) {
|
||
return;
|
||
}
|
||
if (isVisible$1(timerProgressBar)) {
|
||
if (reset) {
|
||
timerProgressBar.style.transition = "none";
|
||
timerProgressBar.style.width = "100%";
|
||
}
|
||
setTimeout(() => {
|
||
timerProgressBar.style.transition = `width ${timer / 1e3}s linear`;
|
||
timerProgressBar.style.width = "0%";
|
||
}, 10);
|
||
}
|
||
};
|
||
var stopTimerProgressBar = () => {
|
||
const timerProgressBar = getTimerProgressBar();
|
||
if (!timerProgressBar) {
|
||
return;
|
||
}
|
||
const timerProgressBarWidth = parseInt(window.getComputedStyle(timerProgressBar).width);
|
||
timerProgressBar.style.removeProperty("transition");
|
||
timerProgressBar.style.width = "100%";
|
||
const timerProgressBarFullWidth = parseInt(window.getComputedStyle(timerProgressBar).width);
|
||
const timerProgressBarPercent = timerProgressBarWidth / timerProgressBarFullWidth * 100;
|
||
timerProgressBar.style.width = `${timerProgressBarPercent}%`;
|
||
};
|
||
var isNodeEnv = () => typeof window === "undefined" || typeof document === "undefined";
|
||
var sweetHTML = `
|
||
<div aria-labelledby="${swalClasses.title}" aria-describedby="${swalClasses["html-container"]}" class="${swalClasses.popup}" tabindex="-1">
|
||
<button type="button" class="${swalClasses.close}"></button>
|
||
<ul class="${swalClasses["progress-steps"]}"></ul>
|
||
<div class="${swalClasses.icon}"></div>
|
||
<img class="${swalClasses.image}" />
|
||
<h2 class="${swalClasses.title}" id="${swalClasses.title}"></h2>
|
||
<div class="${swalClasses["html-container"]}" id="${swalClasses["html-container"]}"></div>
|
||
<input class="${swalClasses.input}" id="${swalClasses.input}" />
|
||
<input type="file" class="${swalClasses.file}" />
|
||
<div class="${swalClasses.range}">
|
||
<input type="range" />
|
||
<output></output>
|
||
</div>
|
||
<select class="${swalClasses.select}" id="${swalClasses.select}"></select>
|
||
<div class="${swalClasses.radio}"></div>
|
||
<label class="${swalClasses.checkbox}">
|
||
<input type="checkbox" id="${swalClasses.checkbox}" />
|
||
<span class="${swalClasses.label}"></span>
|
||
</label>
|
||
<textarea class="${swalClasses.textarea}" id="${swalClasses.textarea}"></textarea>
|
||
<div class="${swalClasses["validation-message"]}" id="${swalClasses["validation-message"]}"></div>
|
||
<div class="${swalClasses.actions}">
|
||
<div class="${swalClasses.loader}"></div>
|
||
<button type="button" class="${swalClasses.confirm}"></button>
|
||
<button type="button" class="${swalClasses.deny}"></button>
|
||
<button type="button" class="${swalClasses.cancel}"></button>
|
||
</div>
|
||
<div class="${swalClasses.footer}"></div>
|
||
<div class="${swalClasses["timer-progress-bar-container"]}">
|
||
<div class="${swalClasses["timer-progress-bar"]}"></div>
|
||
</div>
|
||
</div>
|
||
`.replace(/(^|\n)\s*/g, "");
|
||
var resetOldContainer = () => {
|
||
const oldContainer = getContainer();
|
||
if (!oldContainer) {
|
||
return false;
|
||
}
|
||
oldContainer.remove();
|
||
removeClass([document.documentElement, document.body], [swalClasses["no-backdrop"], swalClasses["toast-shown"], swalClasses["has-column"]]);
|
||
return true;
|
||
};
|
||
var resetValidationMessage$1 = () => {
|
||
globalState.currentInstance.resetValidationMessage();
|
||
};
|
||
var addInputChangeListeners = () => {
|
||
const popup = getPopup();
|
||
const input = getDirectChildByClass(popup, swalClasses.input);
|
||
const file = getDirectChildByClass(popup, swalClasses.file);
|
||
const range = popup.querySelector(`.${swalClasses.range} input`);
|
||
const rangeOutput = popup.querySelector(`.${swalClasses.range} output`);
|
||
const select = getDirectChildByClass(popup, swalClasses.select);
|
||
const checkbox = popup.querySelector(`.${swalClasses.checkbox} input`);
|
||
const textarea = getDirectChildByClass(popup, swalClasses.textarea);
|
||
input.oninput = resetValidationMessage$1;
|
||
file.onchange = resetValidationMessage$1;
|
||
select.onchange = resetValidationMessage$1;
|
||
checkbox.onchange = resetValidationMessage$1;
|
||
textarea.oninput = resetValidationMessage$1;
|
||
range.oninput = () => {
|
||
resetValidationMessage$1();
|
||
rangeOutput.value = range.value;
|
||
};
|
||
range.onchange = () => {
|
||
resetValidationMessage$1();
|
||
rangeOutput.value = range.value;
|
||
};
|
||
};
|
||
var getTarget = (target) => typeof target === "string" ? document.querySelector(target) : target;
|
||
var setupAccessibility = (params) => {
|
||
const popup = getPopup();
|
||
popup.setAttribute("role", params.toast ? "alert" : "dialog");
|
||
popup.setAttribute("aria-live", params.toast ? "polite" : "assertive");
|
||
if (!params.toast) {
|
||
popup.setAttribute("aria-modal", "true");
|
||
}
|
||
};
|
||
var setupRTL = (targetElement) => {
|
||
if (window.getComputedStyle(targetElement).direction === "rtl") {
|
||
addClass(getContainer(), swalClasses.rtl);
|
||
}
|
||
};
|
||
var init = (params) => {
|
||
const oldContainerExisted = resetOldContainer();
|
||
if (isNodeEnv()) {
|
||
error("SweetAlert2 requires document to initialize");
|
||
return;
|
||
}
|
||
const container = document.createElement("div");
|
||
container.className = swalClasses.container;
|
||
if (oldContainerExisted) {
|
||
addClass(container, swalClasses["no-transition"]);
|
||
}
|
||
setInnerHtml(container, sweetHTML);
|
||
container.dataset["swal2Theme"] = params.theme;
|
||
const targetElement = getTarget(params.target);
|
||
targetElement.appendChild(container);
|
||
if (params.topLayer) {
|
||
container.setAttribute("popover", "");
|
||
container.showPopover();
|
||
}
|
||
setupAccessibility(params);
|
||
setupRTL(targetElement);
|
||
addInputChangeListeners();
|
||
};
|
||
var parseHtmlToContainer = (param, target) => {
|
||
if (param instanceof HTMLElement) {
|
||
target.appendChild(param);
|
||
} else if (typeof param === "object") {
|
||
handleObject(param, target);
|
||
} else if (param) {
|
||
setInnerHtml(target, param);
|
||
}
|
||
};
|
||
var handleObject = (param, target) => {
|
||
if (param.jquery) {
|
||
handleJqueryElem(target, param);
|
||
} else {
|
||
setInnerHtml(target, param.toString());
|
||
}
|
||
};
|
||
var handleJqueryElem = (target, elem) => {
|
||
target.textContent = "";
|
||
if (0 in elem) {
|
||
for (let i = 0; i in elem; i++) {
|
||
target.appendChild(elem[i].cloneNode(true));
|
||
}
|
||
} else {
|
||
target.appendChild(elem.cloneNode(true));
|
||
}
|
||
};
|
||
var renderActions = (instance, params) => {
|
||
const actions = getActions();
|
||
const loader = getLoader();
|
||
if (!actions || !loader) {
|
||
return;
|
||
}
|
||
if (!params.showConfirmButton && !params.showDenyButton && !params.showCancelButton) {
|
||
hide(actions);
|
||
} else {
|
||
show(actions);
|
||
}
|
||
applyCustomClass(actions, params, "actions");
|
||
renderButtons(actions, loader, params);
|
||
setInnerHtml(loader, params.loaderHtml || "");
|
||
applyCustomClass(loader, params, "loader");
|
||
};
|
||
function renderButtons(actions, loader, params) {
|
||
const confirmButton = getConfirmButton();
|
||
const denyButton = getDenyButton();
|
||
const cancelButton = getCancelButton();
|
||
if (!confirmButton || !denyButton || !cancelButton) {
|
||
return;
|
||
}
|
||
renderButton(confirmButton, "confirm", params);
|
||
renderButton(denyButton, "deny", params);
|
||
renderButton(cancelButton, "cancel", params);
|
||
handleButtonsStyling(confirmButton, denyButton, cancelButton, params);
|
||
if (params.reverseButtons) {
|
||
if (params.toast) {
|
||
actions.insertBefore(cancelButton, confirmButton);
|
||
actions.insertBefore(denyButton, confirmButton);
|
||
} else {
|
||
actions.insertBefore(cancelButton, loader);
|
||
actions.insertBefore(denyButton, loader);
|
||
actions.insertBefore(confirmButton, loader);
|
||
}
|
||
}
|
||
}
|
||
function handleButtonsStyling(confirmButton, denyButton, cancelButton, params) {
|
||
if (!params.buttonsStyling) {
|
||
removeClass([confirmButton, denyButton, cancelButton], swalClasses.styled);
|
||
return;
|
||
}
|
||
addClass([confirmButton, denyButton, cancelButton], swalClasses.styled);
|
||
if (params.confirmButtonColor) {
|
||
confirmButton.style.setProperty("--swal2-confirm-button-background-color", params.confirmButtonColor);
|
||
}
|
||
if (params.denyButtonColor) {
|
||
denyButton.style.setProperty("--swal2-deny-button-background-color", params.denyButtonColor);
|
||
}
|
||
if (params.cancelButtonColor) {
|
||
cancelButton.style.setProperty("--swal2-cancel-button-background-color", params.cancelButtonColor);
|
||
}
|
||
applyOutlineColor(confirmButton);
|
||
applyOutlineColor(denyButton);
|
||
applyOutlineColor(cancelButton);
|
||
}
|
||
function applyOutlineColor(button) {
|
||
const buttonStyle = window.getComputedStyle(button);
|
||
if (buttonStyle.getPropertyValue("--swal2-action-button-focus-box-shadow")) {
|
||
return;
|
||
}
|
||
const outlineColor = buttonStyle.backgroundColor.replace(/rgba?\((\d+), (\d+), (\d+).*/, "rgba($1, $2, $3, 0.5)");
|
||
button.style.setProperty("--swal2-action-button-focus-box-shadow", buttonStyle.getPropertyValue("--swal2-outline").replace(/ rgba\(.*/, ` ${outlineColor}`));
|
||
}
|
||
function renderButton(button, buttonType, params) {
|
||
const buttonName = (
|
||
/** @type {'Confirm' | 'Deny' | 'Cancel'} */
|
||
capitalizeFirstLetter(buttonType)
|
||
);
|
||
toggle(button, params[`show${buttonName}Button`], "inline-block");
|
||
setInnerHtml(button, params[`${buttonType}ButtonText`] || "");
|
||
button.setAttribute("aria-label", params[`${buttonType}ButtonAriaLabel`] || "");
|
||
button.className = swalClasses[buttonType];
|
||
applyCustomClass(button, params, `${buttonType}Button`);
|
||
}
|
||
var renderCloseButton = (instance, params) => {
|
||
const closeButton = getCloseButton();
|
||
if (!closeButton) {
|
||
return;
|
||
}
|
||
setInnerHtml(closeButton, params.closeButtonHtml || "");
|
||
applyCustomClass(closeButton, params, "closeButton");
|
||
toggle(closeButton, params.showCloseButton);
|
||
closeButton.setAttribute("aria-label", params.closeButtonAriaLabel || "");
|
||
};
|
||
var renderContainer = (instance, params) => {
|
||
const container = getContainer();
|
||
if (!container) {
|
||
return;
|
||
}
|
||
handleBackdropParam(container, params.backdrop);
|
||
handlePositionParam(container, params.position);
|
||
handleGrowParam(container, params.grow);
|
||
applyCustomClass(container, params, "container");
|
||
};
|
||
function handleBackdropParam(container, backdrop) {
|
||
if (typeof backdrop === "string") {
|
||
container.style.background = backdrop;
|
||
} else if (!backdrop) {
|
||
addClass([document.documentElement, document.body], swalClasses["no-backdrop"]);
|
||
}
|
||
}
|
||
function handlePositionParam(container, position) {
|
||
if (!position) {
|
||
return;
|
||
}
|
||
if (position in swalClasses) {
|
||
addClass(container, swalClasses[position]);
|
||
} else {
|
||
warn('The "position" parameter is not valid, defaulting to "center"');
|
||
addClass(container, swalClasses.center);
|
||
}
|
||
}
|
||
function handleGrowParam(container, grow) {
|
||
if (!grow) {
|
||
return;
|
||
}
|
||
addClass(container, swalClasses[`grow-${grow}`]);
|
||
}
|
||
var privateProps = {
|
||
innerParams: /* @__PURE__ */ new WeakMap(),
|
||
domCache: /* @__PURE__ */ new WeakMap()
|
||
};
|
||
var inputClasses = ["input", "file", "range", "select", "radio", "checkbox", "textarea"];
|
||
var renderInput = (instance, params) => {
|
||
const popup = getPopup();
|
||
if (!popup) {
|
||
return;
|
||
}
|
||
const innerParams = privateProps.innerParams.get(instance);
|
||
const rerender = !innerParams || params.input !== innerParams.input;
|
||
inputClasses.forEach((inputClass) => {
|
||
const inputContainer = getDirectChildByClass(popup, swalClasses[inputClass]);
|
||
if (!inputContainer) {
|
||
return;
|
||
}
|
||
setAttributes(inputClass, params.inputAttributes);
|
||
inputContainer.className = swalClasses[inputClass];
|
||
if (rerender) {
|
||
hide(inputContainer);
|
||
}
|
||
});
|
||
if (params.input) {
|
||
if (rerender) {
|
||
showInput(params);
|
||
}
|
||
setCustomClass(params);
|
||
}
|
||
};
|
||
var showInput = (params) => {
|
||
if (!params.input) {
|
||
return;
|
||
}
|
||
if (!renderInputType[params.input]) {
|
||
error(`Unexpected type of input! Expected ${Object.keys(renderInputType).join(" | ")}, got "${params.input}"`);
|
||
return;
|
||
}
|
||
const inputContainer = getInputContainer(params.input);
|
||
if (!inputContainer) {
|
||
return;
|
||
}
|
||
const input = renderInputType[params.input](inputContainer, params);
|
||
show(inputContainer);
|
||
if (params.inputAutoFocus) {
|
||
setTimeout(() => {
|
||
focusInput(input);
|
||
});
|
||
}
|
||
};
|
||
var removeAttributes = (input) => {
|
||
for (let i = 0; i < input.attributes.length; i++) {
|
||
const attrName = input.attributes[i].name;
|
||
if (!["id", "type", "value", "style"].includes(attrName)) {
|
||
input.removeAttribute(attrName);
|
||
}
|
||
}
|
||
};
|
||
var setAttributes = (inputClass, inputAttributes) => {
|
||
const popup = getPopup();
|
||
if (!popup) {
|
||
return;
|
||
}
|
||
const input = getInput$1(popup, inputClass);
|
||
if (!input) {
|
||
return;
|
||
}
|
||
removeAttributes(input);
|
||
for (const attr in inputAttributes) {
|
||
input.setAttribute(attr, inputAttributes[attr]);
|
||
}
|
||
};
|
||
var setCustomClass = (params) => {
|
||
if (!params.input) {
|
||
return;
|
||
}
|
||
const inputContainer = getInputContainer(params.input);
|
||
if (inputContainer) {
|
||
applyCustomClass(inputContainer, params, "input");
|
||
}
|
||
};
|
||
var setInputPlaceholder = (input, params) => {
|
||
if (!input.placeholder && params.inputPlaceholder) {
|
||
input.placeholder = params.inputPlaceholder;
|
||
}
|
||
};
|
||
var setInputLabel = (input, prependTo, params) => {
|
||
if (params.inputLabel) {
|
||
const label = document.createElement("label");
|
||
const labelClass = swalClasses["input-label"];
|
||
label.setAttribute("for", input.id);
|
||
label.className = labelClass;
|
||
if (typeof params.customClass === "object") {
|
||
addClass(label, params.customClass.inputLabel);
|
||
}
|
||
label.innerText = params.inputLabel;
|
||
prependTo.insertAdjacentElement("beforebegin", label);
|
||
}
|
||
};
|
||
var getInputContainer = (inputType) => {
|
||
const popup = getPopup();
|
||
if (!popup) {
|
||
return;
|
||
}
|
||
return getDirectChildByClass(popup, swalClasses[
|
||
/** @type {SwalClass} */
|
||
inputType
|
||
] || swalClasses.input);
|
||
};
|
||
var checkAndSetInputValue = (input, inputValue) => {
|
||
if (["string", "number"].includes(typeof inputValue)) {
|
||
input.value = `${inputValue}`;
|
||
} else if (!isPromise(inputValue)) {
|
||
warn(`Unexpected type of inputValue! Expected "string", "number" or "Promise", got "${typeof inputValue}"`);
|
||
}
|
||
};
|
||
var renderInputType = {};
|
||
renderInputType.text = renderInputType.email = renderInputType.password = renderInputType.number = renderInputType.tel = renderInputType.url = renderInputType.search = renderInputType.date = renderInputType["datetime-local"] = renderInputType.time = renderInputType.week = renderInputType.month = /** @type {(input: Input | HTMLElement, params: SweetAlertOptions) => Input} */
|
||
(input, params) => {
|
||
checkAndSetInputValue(input, params.inputValue);
|
||
setInputLabel(input, input, params);
|
||
setInputPlaceholder(input, params);
|
||
input.type = params.input;
|
||
return input;
|
||
};
|
||
renderInputType.file = (input, params) => {
|
||
setInputLabel(input, input, params);
|
||
setInputPlaceholder(input, params);
|
||
return input;
|
||
};
|
||
renderInputType.range = (range, params) => {
|
||
const rangeInput = range.querySelector("input");
|
||
const rangeOutput = range.querySelector("output");
|
||
checkAndSetInputValue(rangeInput, params.inputValue);
|
||
rangeInput.type = params.input;
|
||
checkAndSetInputValue(rangeOutput, params.inputValue);
|
||
setInputLabel(rangeInput, range, params);
|
||
return range;
|
||
};
|
||
renderInputType.select = (select, params) => {
|
||
select.textContent = "";
|
||
if (params.inputPlaceholder) {
|
||
const placeholder = document.createElement("option");
|
||
setInnerHtml(placeholder, params.inputPlaceholder);
|
||
placeholder.value = "";
|
||
placeholder.disabled = true;
|
||
placeholder.selected = true;
|
||
select.appendChild(placeholder);
|
||
}
|
||
setInputLabel(select, select, params);
|
||
return select;
|
||
};
|
||
renderInputType.radio = (radio) => {
|
||
radio.textContent = "";
|
||
return radio;
|
||
};
|
||
renderInputType.checkbox = (checkboxContainer, params) => {
|
||
const checkbox = getInput$1(getPopup(), "checkbox");
|
||
checkbox.value = "1";
|
||
checkbox.checked = Boolean(params.inputValue);
|
||
const label = checkboxContainer.querySelector("span");
|
||
setInnerHtml(label, params.inputPlaceholder || params.inputLabel);
|
||
return checkbox;
|
||
};
|
||
renderInputType.textarea = (textarea, params) => {
|
||
checkAndSetInputValue(textarea, params.inputValue);
|
||
setInputPlaceholder(textarea, params);
|
||
setInputLabel(textarea, textarea, params);
|
||
const getMargin = (el) => parseInt(window.getComputedStyle(el).marginLeft) + parseInt(window.getComputedStyle(el).marginRight);
|
||
setTimeout(() => {
|
||
if ("MutationObserver" in window) {
|
||
const initialPopupWidth = parseInt(window.getComputedStyle(getPopup()).width);
|
||
const textareaResizeHandler = () => {
|
||
if (!document.body.contains(textarea)) {
|
||
return;
|
||
}
|
||
const textareaWidth = textarea.offsetWidth + getMargin(textarea);
|
||
if (textareaWidth > initialPopupWidth) {
|
||
getPopup().style.width = `${textareaWidth}px`;
|
||
} else {
|
||
applyNumericalStyle(getPopup(), "width", params.width);
|
||
}
|
||
};
|
||
new MutationObserver(textareaResizeHandler).observe(textarea, {
|
||
attributes: true,
|
||
attributeFilter: ["style"]
|
||
});
|
||
}
|
||
});
|
||
return textarea;
|
||
};
|
||
var renderContent = (instance, params) => {
|
||
const htmlContainer = getHtmlContainer();
|
||
if (!htmlContainer) {
|
||
return;
|
||
}
|
||
showWhenInnerHtmlPresent(htmlContainer);
|
||
applyCustomClass(htmlContainer, params, "htmlContainer");
|
||
if (params.html) {
|
||
parseHtmlToContainer(params.html, htmlContainer);
|
||
show(htmlContainer, "block");
|
||
} else if (params.text) {
|
||
htmlContainer.textContent = params.text;
|
||
show(htmlContainer, "block");
|
||
} else {
|
||
hide(htmlContainer);
|
||
}
|
||
renderInput(instance, params);
|
||
};
|
||
var renderFooter = (instance, params) => {
|
||
const footer = getFooter();
|
||
if (!footer) {
|
||
return;
|
||
}
|
||
showWhenInnerHtmlPresent(footer);
|
||
toggle(footer, Boolean(params.footer), "block");
|
||
if (params.footer) {
|
||
parseHtmlToContainer(params.footer, footer);
|
||
}
|
||
applyCustomClass(footer, params, "footer");
|
||
};
|
||
var renderIcon = (instance, params) => {
|
||
const innerParams = privateProps.innerParams.get(instance);
|
||
const icon = getIcon();
|
||
if (!icon) {
|
||
return;
|
||
}
|
||
if (innerParams && params.icon === innerParams.icon) {
|
||
setContent(icon, params);
|
||
applyStyles(icon, params);
|
||
return;
|
||
}
|
||
if (!params.icon && !params.iconHtml) {
|
||
hide(icon);
|
||
return;
|
||
}
|
||
if (params.icon && Object.keys(iconTypes).indexOf(params.icon) === -1) {
|
||
error(`Unknown icon! Expected "success", "error", "warning", "info" or "question", got "${params.icon}"`);
|
||
hide(icon);
|
||
return;
|
||
}
|
||
show(icon);
|
||
setContent(icon, params);
|
||
applyStyles(icon, params);
|
||
addClass(icon, params.showClass && params.showClass.icon);
|
||
const colorSchemeQueryList = window.matchMedia("(prefers-color-scheme: dark)");
|
||
colorSchemeQueryList.addEventListener("change", adjustSuccessIconBackgroundColor);
|
||
};
|
||
var applyStyles = (icon, params) => {
|
||
for (const [iconType, iconClassName] of Object.entries(iconTypes)) {
|
||
if (params.icon !== iconType) {
|
||
removeClass(icon, iconClassName);
|
||
}
|
||
}
|
||
addClass(icon, params.icon && iconTypes[params.icon]);
|
||
setColor(icon, params);
|
||
adjustSuccessIconBackgroundColor();
|
||
applyCustomClass(icon, params, "icon");
|
||
};
|
||
var adjustSuccessIconBackgroundColor = () => {
|
||
const popup = getPopup();
|
||
if (!popup) {
|
||
return;
|
||
}
|
||
const popupBackgroundColor = window.getComputedStyle(popup).getPropertyValue("background-color");
|
||
const successIconParts = popup.querySelectorAll("[class^=swal2-success-circular-line], .swal2-success-fix");
|
||
for (let i = 0; i < successIconParts.length; i++) {
|
||
successIconParts[i].style.backgroundColor = popupBackgroundColor;
|
||
}
|
||
};
|
||
var successIconHtml = (params) => `
|
||
${params.animation ? '<div class="swal2-success-circular-line-left"></div>' : ""}
|
||
<span class="swal2-success-line-tip"></span> <span class="swal2-success-line-long"></span>
|
||
<div class="swal2-success-ring"></div>
|
||
${params.animation ? '<div class="swal2-success-fix"></div>' : ""}
|
||
${params.animation ? '<div class="swal2-success-circular-line-right"></div>' : ""}
|
||
`;
|
||
var errorIconHtml = `
|
||
<span class="swal2-x-mark">
|
||
<span class="swal2-x-mark-line-left"></span>
|
||
<span class="swal2-x-mark-line-right"></span>
|
||
</span>
|
||
`;
|
||
var setContent = (icon, params) => {
|
||
if (!params.icon && !params.iconHtml) {
|
||
return;
|
||
}
|
||
let oldContent = icon.innerHTML;
|
||
let newContent = "";
|
||
if (params.iconHtml) {
|
||
newContent = iconContent(params.iconHtml);
|
||
} else if (params.icon === "success") {
|
||
newContent = successIconHtml(params);
|
||
oldContent = oldContent.replace(/ style=".*?"/g, "");
|
||
} else if (params.icon === "error") {
|
||
newContent = errorIconHtml;
|
||
} else if (params.icon) {
|
||
const defaultIconHtml = {
|
||
question: "?",
|
||
warning: "!",
|
||
info: "i"
|
||
};
|
||
newContent = iconContent(defaultIconHtml[params.icon]);
|
||
}
|
||
if (oldContent.trim() !== newContent.trim()) {
|
||
setInnerHtml(icon, newContent);
|
||
}
|
||
};
|
||
var setColor = (icon, params) => {
|
||
if (!params.iconColor) {
|
||
return;
|
||
}
|
||
icon.style.color = params.iconColor;
|
||
icon.style.borderColor = params.iconColor;
|
||
for (const sel of [".swal2-success-line-tip", ".swal2-success-line-long", ".swal2-x-mark-line-left", ".swal2-x-mark-line-right"]) {
|
||
setStyle(icon, sel, "background-color", params.iconColor);
|
||
}
|
||
setStyle(icon, ".swal2-success-ring", "border-color", params.iconColor);
|
||
};
|
||
var iconContent = (content) => `<div class="${swalClasses["icon-content"]}">${content}</div>`;
|
||
var renderImage = (instance, params) => {
|
||
const image = getImage();
|
||
if (!image) {
|
||
return;
|
||
}
|
||
if (!params.imageUrl) {
|
||
hide(image);
|
||
return;
|
||
}
|
||
show(image, "");
|
||
image.setAttribute("src", params.imageUrl);
|
||
image.setAttribute("alt", params.imageAlt || "");
|
||
applyNumericalStyle(image, "width", params.imageWidth);
|
||
applyNumericalStyle(image, "height", params.imageHeight);
|
||
image.className = swalClasses.image;
|
||
applyCustomClass(image, params, "image");
|
||
};
|
||
var dragging = false;
|
||
var mousedownX = 0;
|
||
var mousedownY = 0;
|
||
var initialX = 0;
|
||
var initialY = 0;
|
||
var addDraggableListeners = (popup) => {
|
||
popup.addEventListener("mousedown", down);
|
||
document.body.addEventListener("mousemove", move);
|
||
popup.addEventListener("mouseup", up);
|
||
popup.addEventListener("touchstart", down);
|
||
document.body.addEventListener("touchmove", move);
|
||
popup.addEventListener("touchend", up);
|
||
};
|
||
var removeDraggableListeners = (popup) => {
|
||
popup.removeEventListener("mousedown", down);
|
||
document.body.removeEventListener("mousemove", move);
|
||
popup.removeEventListener("mouseup", up);
|
||
popup.removeEventListener("touchstart", down);
|
||
document.body.removeEventListener("touchmove", move);
|
||
popup.removeEventListener("touchend", up);
|
||
};
|
||
var down = (event) => {
|
||
const popup = getPopup();
|
||
if (event.target === popup || getIcon().contains(
|
||
/** @type {HTMLElement} */
|
||
event.target
|
||
)) {
|
||
dragging = true;
|
||
const clientXY = getClientXY(event);
|
||
mousedownX = clientXY.clientX;
|
||
mousedownY = clientXY.clientY;
|
||
initialX = parseInt(popup.style.insetInlineStart) || 0;
|
||
initialY = parseInt(popup.style.insetBlockStart) || 0;
|
||
addClass(popup, "swal2-dragging");
|
||
}
|
||
};
|
||
var move = (event) => {
|
||
const popup = getPopup();
|
||
if (dragging) {
|
||
let {
|
||
clientX,
|
||
clientY
|
||
} = getClientXY(event);
|
||
popup.style.insetInlineStart = `${initialX + (clientX - mousedownX)}px`;
|
||
popup.style.insetBlockStart = `${initialY + (clientY - mousedownY)}px`;
|
||
}
|
||
};
|
||
var up = () => {
|
||
const popup = getPopup();
|
||
dragging = false;
|
||
removeClass(popup, "swal2-dragging");
|
||
};
|
||
var getClientXY = (event) => {
|
||
let clientX = 0, clientY = 0;
|
||
if (event.type.startsWith("mouse")) {
|
||
clientX = /** @type {MouseEvent} */
|
||
event.clientX;
|
||
clientY = /** @type {MouseEvent} */
|
||
event.clientY;
|
||
} else if (event.type.startsWith("touch")) {
|
||
clientX = /** @type {TouchEvent} */
|
||
event.touches[0].clientX;
|
||
clientY = /** @type {TouchEvent} */
|
||
event.touches[0].clientY;
|
||
}
|
||
return {
|
||
clientX,
|
||
clientY
|
||
};
|
||
};
|
||
var renderPopup = (instance, params) => {
|
||
const container = getContainer();
|
||
const popup = getPopup();
|
||
if (!container || !popup) {
|
||
return;
|
||
}
|
||
if (params.toast) {
|
||
applyNumericalStyle(container, "width", params.width);
|
||
popup.style.width = "100%";
|
||
const loader = getLoader();
|
||
if (loader) {
|
||
popup.insertBefore(loader, getIcon());
|
||
}
|
||
} else {
|
||
applyNumericalStyle(popup, "width", params.width);
|
||
}
|
||
applyNumericalStyle(popup, "padding", params.padding);
|
||
if (params.color) {
|
||
popup.style.color = params.color;
|
||
}
|
||
if (params.background) {
|
||
popup.style.background = params.background;
|
||
}
|
||
hide(getValidationMessage());
|
||
addClasses$1(popup, params);
|
||
if (params.draggable && !params.toast) {
|
||
addClass(popup, swalClasses.draggable);
|
||
addDraggableListeners(popup);
|
||
} else {
|
||
removeClass(popup, swalClasses.draggable);
|
||
removeDraggableListeners(popup);
|
||
}
|
||
};
|
||
var addClasses$1 = (popup, params) => {
|
||
const showClass = params.showClass || {};
|
||
popup.className = `${swalClasses.popup} ${isVisible$1(popup) ? showClass.popup : ""}`;
|
||
if (params.toast) {
|
||
addClass([document.documentElement, document.body], swalClasses["toast-shown"]);
|
||
addClass(popup, swalClasses.toast);
|
||
} else {
|
||
addClass(popup, swalClasses.modal);
|
||
}
|
||
applyCustomClass(popup, params, "popup");
|
||
if (typeof params.customClass === "string") {
|
||
addClass(popup, params.customClass);
|
||
}
|
||
if (params.icon) {
|
||
addClass(popup, swalClasses[`icon-${params.icon}`]);
|
||
}
|
||
};
|
||
var renderProgressSteps = (instance, params) => {
|
||
const progressStepsContainer = getProgressSteps();
|
||
if (!progressStepsContainer) {
|
||
return;
|
||
}
|
||
const {
|
||
progressSteps,
|
||
currentProgressStep
|
||
} = params;
|
||
if (!progressSteps || progressSteps.length === 0 || currentProgressStep === void 0) {
|
||
hide(progressStepsContainer);
|
||
return;
|
||
}
|
||
show(progressStepsContainer);
|
||
progressStepsContainer.textContent = "";
|
||
if (currentProgressStep >= progressSteps.length) {
|
||
warn("Invalid currentProgressStep parameter, it should be less than progressSteps.length (currentProgressStep like JS arrays starts from 0)");
|
||
}
|
||
progressSteps.forEach((step, index) => {
|
||
const stepEl = createStepElement(step);
|
||
progressStepsContainer.appendChild(stepEl);
|
||
if (index === currentProgressStep) {
|
||
addClass(stepEl, swalClasses["active-progress-step"]);
|
||
}
|
||
if (index !== progressSteps.length - 1) {
|
||
const lineEl = createLineElement(params);
|
||
progressStepsContainer.appendChild(lineEl);
|
||
}
|
||
});
|
||
};
|
||
var createStepElement = (step) => {
|
||
const stepEl = document.createElement("li");
|
||
addClass(stepEl, swalClasses["progress-step"]);
|
||
setInnerHtml(stepEl, step);
|
||
return stepEl;
|
||
};
|
||
var createLineElement = (params) => {
|
||
const lineEl = document.createElement("li");
|
||
addClass(lineEl, swalClasses["progress-step-line"]);
|
||
if (params.progressStepsDistance) {
|
||
applyNumericalStyle(lineEl, "width", params.progressStepsDistance);
|
||
}
|
||
return lineEl;
|
||
};
|
||
var renderTitle = (instance, params) => {
|
||
const title = getTitle();
|
||
if (!title) {
|
||
return;
|
||
}
|
||
showWhenInnerHtmlPresent(title);
|
||
toggle(title, Boolean(params.title || params.titleText), "block");
|
||
if (params.title) {
|
||
parseHtmlToContainer(params.title, title);
|
||
}
|
||
if (params.titleText) {
|
||
title.innerText = params.titleText;
|
||
}
|
||
applyCustomClass(title, params, "title");
|
||
};
|
||
var render = (instance, params) => {
|
||
renderPopup(instance, params);
|
||
renderContainer(instance, params);
|
||
renderProgressSteps(instance, params);
|
||
renderIcon(instance, params);
|
||
renderImage(instance, params);
|
||
renderTitle(instance, params);
|
||
renderCloseButton(instance, params);
|
||
renderContent(instance, params);
|
||
renderActions(instance, params);
|
||
renderFooter(instance, params);
|
||
const popup = getPopup();
|
||
if (typeof params.didRender === "function" && popup) {
|
||
params.didRender(popup);
|
||
}
|
||
globalState.eventEmitter.emit("didRender", popup);
|
||
};
|
||
var isVisible = () => {
|
||
return isVisible$1(getPopup());
|
||
};
|
||
var clickConfirm = () => {
|
||
var _dom$getConfirmButton;
|
||
return (_dom$getConfirmButton = getConfirmButton()) === null || _dom$getConfirmButton === void 0 ? void 0 : _dom$getConfirmButton.click();
|
||
};
|
||
var clickDeny = () => {
|
||
var _dom$getDenyButton;
|
||
return (_dom$getDenyButton = getDenyButton()) === null || _dom$getDenyButton === void 0 ? void 0 : _dom$getDenyButton.click();
|
||
};
|
||
var clickCancel = () => {
|
||
var _dom$getCancelButton;
|
||
return (_dom$getCancelButton = getCancelButton()) === null || _dom$getCancelButton === void 0 ? void 0 : _dom$getCancelButton.click();
|
||
};
|
||
var DismissReason = Object.freeze({
|
||
cancel: "cancel",
|
||
backdrop: "backdrop",
|
||
close: "close",
|
||
esc: "esc",
|
||
timer: "timer"
|
||
});
|
||
var removeKeydownHandler = (globalState2) => {
|
||
if (globalState2.keydownTarget && globalState2.keydownHandlerAdded) {
|
||
globalState2.keydownTarget.removeEventListener("keydown", globalState2.keydownHandler, {
|
||
capture: globalState2.keydownListenerCapture
|
||
});
|
||
globalState2.keydownHandlerAdded = false;
|
||
}
|
||
};
|
||
var addKeydownHandler = (globalState2, innerParams, dismissWith) => {
|
||
removeKeydownHandler(globalState2);
|
||
if (!innerParams.toast) {
|
||
globalState2.keydownHandler = (e) => keydownHandler(innerParams, e, dismissWith);
|
||
globalState2.keydownTarget = innerParams.keydownListenerCapture ? window : getPopup();
|
||
globalState2.keydownListenerCapture = innerParams.keydownListenerCapture;
|
||
globalState2.keydownTarget.addEventListener("keydown", globalState2.keydownHandler, {
|
||
capture: globalState2.keydownListenerCapture
|
||
});
|
||
globalState2.keydownHandlerAdded = true;
|
||
}
|
||
};
|
||
var setFocus = (index, increment) => {
|
||
var _dom$getPopup;
|
||
const focusableElements = getFocusableElements();
|
||
if (focusableElements.length) {
|
||
index = index + increment;
|
||
if (index === -2) {
|
||
index = focusableElements.length - 1;
|
||
}
|
||
if (index === focusableElements.length) {
|
||
index = 0;
|
||
} else if (index === -1) {
|
||
index = focusableElements.length - 1;
|
||
}
|
||
focusableElements[index].focus();
|
||
return;
|
||
}
|
||
(_dom$getPopup = getPopup()) === null || _dom$getPopup === void 0 || _dom$getPopup.focus();
|
||
};
|
||
var arrowKeysNextButton = ["ArrowRight", "ArrowDown"];
|
||
var arrowKeysPreviousButton = ["ArrowLeft", "ArrowUp"];
|
||
var keydownHandler = (innerParams, event, dismissWith) => {
|
||
if (!innerParams) {
|
||
return;
|
||
}
|
||
if (event.isComposing || event.keyCode === 229) {
|
||
return;
|
||
}
|
||
if (innerParams.stopKeydownPropagation) {
|
||
event.stopPropagation();
|
||
}
|
||
if (event.key === "Enter") {
|
||
handleEnter(event, innerParams);
|
||
} else if (event.key === "Tab") {
|
||
handleTab(event);
|
||
} else if ([...arrowKeysNextButton, ...arrowKeysPreviousButton].includes(event.key)) {
|
||
handleArrows(event.key);
|
||
} else if (event.key === "Escape") {
|
||
handleEsc(event, innerParams, dismissWith);
|
||
}
|
||
};
|
||
var handleEnter = (event, innerParams) => {
|
||
if (!callIfFunction(innerParams.allowEnterKey)) {
|
||
return;
|
||
}
|
||
const input = getInput$1(getPopup(), innerParams.input);
|
||
if (event.target && input && event.target instanceof HTMLElement && event.target.outerHTML === input.outerHTML) {
|
||
if (["textarea", "file"].includes(innerParams.input)) {
|
||
return;
|
||
}
|
||
clickConfirm();
|
||
event.preventDefault();
|
||
}
|
||
};
|
||
var handleTab = (event) => {
|
||
const targetElement = event.target;
|
||
const focusableElements = getFocusableElements();
|
||
let btnIndex = -1;
|
||
for (let i = 0; i < focusableElements.length; i++) {
|
||
if (targetElement === focusableElements[i]) {
|
||
btnIndex = i;
|
||
break;
|
||
}
|
||
}
|
||
if (!event.shiftKey) {
|
||
setFocus(btnIndex, 1);
|
||
} else {
|
||
setFocus(btnIndex, -1);
|
||
}
|
||
event.stopPropagation();
|
||
event.preventDefault();
|
||
};
|
||
var handleArrows = (key) => {
|
||
const actions = getActions();
|
||
const confirmButton = getConfirmButton();
|
||
const denyButton = getDenyButton();
|
||
const cancelButton = getCancelButton();
|
||
if (!actions || !confirmButton || !denyButton || !cancelButton) {
|
||
return;
|
||
}
|
||
const buttons = [confirmButton, denyButton, cancelButton];
|
||
if (document.activeElement instanceof HTMLElement && !buttons.includes(document.activeElement)) {
|
||
return;
|
||
}
|
||
const sibling = arrowKeysNextButton.includes(key) ? "nextElementSibling" : "previousElementSibling";
|
||
let buttonToFocus = document.activeElement;
|
||
if (!buttonToFocus) {
|
||
return;
|
||
}
|
||
for (let i = 0; i < actions.children.length; i++) {
|
||
buttonToFocus = buttonToFocus[sibling];
|
||
if (!buttonToFocus) {
|
||
return;
|
||
}
|
||
if (buttonToFocus instanceof HTMLButtonElement && isVisible$1(buttonToFocus)) {
|
||
break;
|
||
}
|
||
}
|
||
if (buttonToFocus instanceof HTMLButtonElement) {
|
||
buttonToFocus.focus();
|
||
}
|
||
};
|
||
var handleEsc = (event, innerParams, dismissWith) => {
|
||
event.preventDefault();
|
||
if (callIfFunction(innerParams.allowEscapeKey)) {
|
||
dismissWith(DismissReason.esc);
|
||
}
|
||
};
|
||
var privateMethods = {
|
||
swalPromiseResolve: /* @__PURE__ */ new WeakMap(),
|
||
swalPromiseReject: /* @__PURE__ */ new WeakMap()
|
||
};
|
||
var setAriaHidden = () => {
|
||
const container = getContainer();
|
||
const bodyChildren = Array.from(document.body.children);
|
||
bodyChildren.forEach((el) => {
|
||
if (el.contains(container)) {
|
||
return;
|
||
}
|
||
if (el.hasAttribute("aria-hidden")) {
|
||
el.setAttribute("data-previous-aria-hidden", el.getAttribute("aria-hidden") || "");
|
||
}
|
||
el.setAttribute("aria-hidden", "true");
|
||
});
|
||
};
|
||
var unsetAriaHidden = () => {
|
||
const bodyChildren = Array.from(document.body.children);
|
||
bodyChildren.forEach((el) => {
|
||
if (el.hasAttribute("data-previous-aria-hidden")) {
|
||
el.setAttribute("aria-hidden", el.getAttribute("data-previous-aria-hidden") || "");
|
||
el.removeAttribute("data-previous-aria-hidden");
|
||
} else {
|
||
el.removeAttribute("aria-hidden");
|
||
}
|
||
});
|
||
};
|
||
var isSafariOrIOS = typeof window !== "undefined" && !!window.GestureEvent;
|
||
var iOSfix = () => {
|
||
if (isSafariOrIOS && !hasClass(document.body, swalClasses.iosfix)) {
|
||
const offset = document.body.scrollTop;
|
||
document.body.style.top = `${offset * -1}px`;
|
||
addClass(document.body, swalClasses.iosfix);
|
||
lockBodyScroll();
|
||
}
|
||
};
|
||
var lockBodyScroll = () => {
|
||
const container = getContainer();
|
||
if (!container) {
|
||
return;
|
||
}
|
||
let preventTouchMove;
|
||
container.ontouchstart = (event) => {
|
||
preventTouchMove = shouldPreventTouchMove(event);
|
||
};
|
||
container.ontouchmove = (event) => {
|
||
if (preventTouchMove) {
|
||
event.preventDefault();
|
||
event.stopPropagation();
|
||
}
|
||
};
|
||
};
|
||
var shouldPreventTouchMove = (event) => {
|
||
const target = event.target;
|
||
const container = getContainer();
|
||
const htmlContainer = getHtmlContainer();
|
||
if (!container || !htmlContainer) {
|
||
return false;
|
||
}
|
||
if (isStylus(event) || isZoom(event)) {
|
||
return false;
|
||
}
|
||
if (target === container) {
|
||
return true;
|
||
}
|
||
if (!isScrollable(container) && target instanceof HTMLElement && !selfOrParentIsScrollable(target, htmlContainer) && // #2823
|
||
target.tagName !== "INPUT" && // #1603
|
||
target.tagName !== "TEXTAREA" && // #2266
|
||
!(isScrollable(htmlContainer) && // #1944
|
||
htmlContainer.contains(target))) {
|
||
return true;
|
||
}
|
||
return false;
|
||
};
|
||
var isStylus = (event) => {
|
||
return event.touches && event.touches.length && event.touches[0].touchType === "stylus";
|
||
};
|
||
var isZoom = (event) => {
|
||
return event.touches && event.touches.length > 1;
|
||
};
|
||
var undoIOSfix = () => {
|
||
if (hasClass(document.body, swalClasses.iosfix)) {
|
||
const offset = parseInt(document.body.style.top, 10);
|
||
removeClass(document.body, swalClasses.iosfix);
|
||
document.body.style.top = "";
|
||
document.body.scrollTop = offset * -1;
|
||
}
|
||
};
|
||
var measureScrollbar = () => {
|
||
const scrollDiv = document.createElement("div");
|
||
scrollDiv.className = swalClasses["scrollbar-measure"];
|
||
document.body.appendChild(scrollDiv);
|
||
const scrollbarWidth = scrollDiv.getBoundingClientRect().width - scrollDiv.clientWidth;
|
||
document.body.removeChild(scrollDiv);
|
||
return scrollbarWidth;
|
||
};
|
||
var previousBodyPadding = null;
|
||
var replaceScrollbarWithPadding = (initialBodyOverflow) => {
|
||
if (previousBodyPadding !== null) {
|
||
return;
|
||
}
|
||
if (document.body.scrollHeight > window.innerHeight || initialBodyOverflow === "scroll") {
|
||
previousBodyPadding = parseInt(window.getComputedStyle(document.body).getPropertyValue("padding-right"));
|
||
document.body.style.paddingRight = `${previousBodyPadding + measureScrollbar()}px`;
|
||
}
|
||
};
|
||
var undoReplaceScrollbarWithPadding = () => {
|
||
if (previousBodyPadding !== null) {
|
||
document.body.style.paddingRight = `${previousBodyPadding}px`;
|
||
previousBodyPadding = null;
|
||
}
|
||
};
|
||
function removePopupAndResetState(instance, container, returnFocus, didClose) {
|
||
if (isToast()) {
|
||
triggerDidCloseAndDispose(instance, didClose);
|
||
} else {
|
||
restoreActiveElement(returnFocus).then(() => triggerDidCloseAndDispose(instance, didClose));
|
||
removeKeydownHandler(globalState);
|
||
}
|
||
if (isSafariOrIOS) {
|
||
container.setAttribute("style", "display:none !important");
|
||
container.removeAttribute("class");
|
||
container.innerHTML = "";
|
||
} else {
|
||
container.remove();
|
||
}
|
||
if (isModal()) {
|
||
undoReplaceScrollbarWithPadding();
|
||
undoIOSfix();
|
||
unsetAriaHidden();
|
||
}
|
||
removeBodyClasses();
|
||
}
|
||
function removeBodyClasses() {
|
||
removeClass([document.documentElement, document.body], [swalClasses.shown, swalClasses["height-auto"], swalClasses["no-backdrop"], swalClasses["toast-shown"]]);
|
||
}
|
||
function close(resolveValue) {
|
||
resolveValue = prepareResolveValue(resolveValue);
|
||
const swalPromiseResolve = privateMethods.swalPromiseResolve.get(this);
|
||
const didClose = triggerClosePopup(this);
|
||
if (this.isAwaitingPromise) {
|
||
if (!resolveValue.isDismissed) {
|
||
handleAwaitingPromise(this);
|
||
swalPromiseResolve(resolveValue);
|
||
}
|
||
} else if (didClose) {
|
||
swalPromiseResolve(resolveValue);
|
||
}
|
||
}
|
||
var triggerClosePopup = (instance) => {
|
||
const popup = getPopup();
|
||
if (!popup) {
|
||
return false;
|
||
}
|
||
const innerParams = privateProps.innerParams.get(instance);
|
||
if (!innerParams || hasClass(popup, innerParams.hideClass.popup)) {
|
||
return false;
|
||
}
|
||
removeClass(popup, innerParams.showClass.popup);
|
||
addClass(popup, innerParams.hideClass.popup);
|
||
const backdrop = getContainer();
|
||
removeClass(backdrop, innerParams.showClass.backdrop);
|
||
addClass(backdrop, innerParams.hideClass.backdrop);
|
||
handlePopupAnimation(instance, popup, innerParams);
|
||
return true;
|
||
};
|
||
function rejectPromise(error2) {
|
||
const rejectPromise2 = privateMethods.swalPromiseReject.get(this);
|
||
handleAwaitingPromise(this);
|
||
if (rejectPromise2) {
|
||
rejectPromise2(error2);
|
||
}
|
||
}
|
||
var handleAwaitingPromise = (instance) => {
|
||
if (instance.isAwaitingPromise) {
|
||
delete instance.isAwaitingPromise;
|
||
if (!privateProps.innerParams.get(instance)) {
|
||
instance._destroy();
|
||
}
|
||
}
|
||
};
|
||
var prepareResolveValue = (resolveValue) => {
|
||
if (typeof resolveValue === "undefined") {
|
||
return {
|
||
isConfirmed: false,
|
||
isDenied: false,
|
||
isDismissed: true
|
||
};
|
||
}
|
||
return Object.assign({
|
||
isConfirmed: false,
|
||
isDenied: false,
|
||
isDismissed: false
|
||
}, resolveValue);
|
||
};
|
||
var handlePopupAnimation = (instance, popup, innerParams) => {
|
||
var _globalState$eventEmi;
|
||
const container = getContainer();
|
||
const animationIsSupported = hasCssAnimation(popup);
|
||
if (typeof innerParams.willClose === "function") {
|
||
innerParams.willClose(popup);
|
||
}
|
||
(_globalState$eventEmi = globalState.eventEmitter) === null || _globalState$eventEmi === void 0 || _globalState$eventEmi.emit("willClose", popup);
|
||
if (animationIsSupported) {
|
||
animatePopup(instance, popup, container, innerParams.returnFocus, innerParams.didClose);
|
||
} else {
|
||
removePopupAndResetState(instance, container, innerParams.returnFocus, innerParams.didClose);
|
||
}
|
||
};
|
||
var animatePopup = (instance, popup, container, returnFocus, didClose) => {
|
||
globalState.swalCloseEventFinishedCallback = removePopupAndResetState.bind(null, instance, container, returnFocus, didClose);
|
||
const swalCloseAnimationFinished = function(e) {
|
||
if (e.target === popup) {
|
||
var _globalState$swalClos;
|
||
(_globalState$swalClos = globalState.swalCloseEventFinishedCallback) === null || _globalState$swalClos === void 0 || _globalState$swalClos.call(globalState);
|
||
delete globalState.swalCloseEventFinishedCallback;
|
||
popup.removeEventListener("animationend", swalCloseAnimationFinished);
|
||
popup.removeEventListener("transitionend", swalCloseAnimationFinished);
|
||
}
|
||
};
|
||
popup.addEventListener("animationend", swalCloseAnimationFinished);
|
||
popup.addEventListener("transitionend", swalCloseAnimationFinished);
|
||
};
|
||
var triggerDidCloseAndDispose = (instance, didClose) => {
|
||
setTimeout(() => {
|
||
var _globalState$eventEmi2;
|
||
if (typeof didClose === "function") {
|
||
didClose.bind(instance.params)();
|
||
}
|
||
(_globalState$eventEmi2 = globalState.eventEmitter) === null || _globalState$eventEmi2 === void 0 || _globalState$eventEmi2.emit("didClose");
|
||
if (instance._destroy) {
|
||
instance._destroy();
|
||
}
|
||
});
|
||
};
|
||
var showLoading = (buttonToReplace) => {
|
||
let popup = getPopup();
|
||
if (!popup) {
|
||
new Swal();
|
||
}
|
||
popup = getPopup();
|
||
if (!popup) {
|
||
return;
|
||
}
|
||
const loader = getLoader();
|
||
if (isToast()) {
|
||
hide(getIcon());
|
||
} else {
|
||
replaceButton(popup, buttonToReplace);
|
||
}
|
||
show(loader);
|
||
popup.setAttribute("data-loading", "true");
|
||
popup.setAttribute("aria-busy", "true");
|
||
popup.focus();
|
||
};
|
||
var replaceButton = (popup, buttonToReplace) => {
|
||
const actions = getActions();
|
||
const loader = getLoader();
|
||
if (!actions || !loader) {
|
||
return;
|
||
}
|
||
if (!buttonToReplace && isVisible$1(getConfirmButton())) {
|
||
buttonToReplace = getConfirmButton();
|
||
}
|
||
show(actions);
|
||
if (buttonToReplace) {
|
||
hide(buttonToReplace);
|
||
loader.setAttribute("data-button-to-replace", buttonToReplace.className);
|
||
actions.insertBefore(loader, buttonToReplace);
|
||
}
|
||
addClass([popup, actions], swalClasses.loading);
|
||
};
|
||
var handleInputOptionsAndValue = (instance, params) => {
|
||
if (params.input === "select" || params.input === "radio") {
|
||
handleInputOptions(instance, params);
|
||
} else if (["text", "email", "number", "tel", "textarea"].some((i) => i === params.input) && (hasToPromiseFn(params.inputValue) || isPromise(params.inputValue))) {
|
||
showLoading(getConfirmButton());
|
||
handleInputValue(instance, params);
|
||
}
|
||
};
|
||
var getInputValue = (instance, innerParams) => {
|
||
const input = instance.getInput();
|
||
if (!input) {
|
||
return null;
|
||
}
|
||
switch (innerParams.input) {
|
||
case "checkbox":
|
||
return getCheckboxValue(input);
|
||
case "radio":
|
||
return getRadioValue(input);
|
||
case "file":
|
||
return getFileValue(input);
|
||
default:
|
||
return innerParams.inputAutoTrim ? input.value.trim() : input.value;
|
||
}
|
||
};
|
||
var getCheckboxValue = (input) => input.checked ? 1 : 0;
|
||
var getRadioValue = (input) => input.checked ? input.value : null;
|
||
var getFileValue = (input) => input.files && input.files.length ? input.getAttribute("multiple") !== null ? input.files : input.files[0] : null;
|
||
var handleInputOptions = (instance, params) => {
|
||
const popup = getPopup();
|
||
if (!popup) {
|
||
return;
|
||
}
|
||
const processInputOptions = (inputOptions) => {
|
||
if (params.input === "select") {
|
||
populateSelectOptions(popup, formatInputOptions(inputOptions), params);
|
||
} else if (params.input === "radio") {
|
||
populateRadioOptions(popup, formatInputOptions(inputOptions), params);
|
||
}
|
||
};
|
||
if (hasToPromiseFn(params.inputOptions) || isPromise(params.inputOptions)) {
|
||
showLoading(getConfirmButton());
|
||
asPromise(params.inputOptions).then((inputOptions) => {
|
||
instance.hideLoading();
|
||
processInputOptions(inputOptions);
|
||
});
|
||
} else if (typeof params.inputOptions === "object") {
|
||
processInputOptions(params.inputOptions);
|
||
} else {
|
||
error(`Unexpected type of inputOptions! Expected object, Map or Promise, got ${typeof params.inputOptions}`);
|
||
}
|
||
};
|
||
var handleInputValue = (instance, params) => {
|
||
const input = instance.getInput();
|
||
if (!input) {
|
||
return;
|
||
}
|
||
hide(input);
|
||
asPromise(params.inputValue).then((inputValue) => {
|
||
input.value = params.input === "number" ? `${parseFloat(inputValue) || 0}` : `${inputValue}`;
|
||
show(input);
|
||
input.focus();
|
||
instance.hideLoading();
|
||
}).catch((err) => {
|
||
error(`Error in inputValue promise: ${err}`);
|
||
input.value = "";
|
||
show(input);
|
||
input.focus();
|
||
instance.hideLoading();
|
||
});
|
||
};
|
||
function populateSelectOptions(popup, inputOptions, params) {
|
||
const select = getDirectChildByClass(popup, swalClasses.select);
|
||
if (!select) {
|
||
return;
|
||
}
|
||
const renderOption = (parent, optionLabel, optionValue) => {
|
||
const option = document.createElement("option");
|
||
option.value = optionValue;
|
||
setInnerHtml(option, optionLabel);
|
||
option.selected = isSelected(optionValue, params.inputValue);
|
||
parent.appendChild(option);
|
||
};
|
||
inputOptions.forEach((inputOption) => {
|
||
const optionValue = inputOption[0];
|
||
const optionLabel = inputOption[1];
|
||
if (Array.isArray(optionLabel)) {
|
||
const optgroup = document.createElement("optgroup");
|
||
optgroup.label = optionValue;
|
||
optgroup.disabled = false;
|
||
select.appendChild(optgroup);
|
||
optionLabel.forEach((o) => renderOption(optgroup, o[1], o[0]));
|
||
} else {
|
||
renderOption(select, optionLabel, optionValue);
|
||
}
|
||
});
|
||
select.focus();
|
||
}
|
||
function populateRadioOptions(popup, inputOptions, params) {
|
||
const radio = getDirectChildByClass(popup, swalClasses.radio);
|
||
if (!radio) {
|
||
return;
|
||
}
|
||
inputOptions.forEach((inputOption) => {
|
||
const radioValue = inputOption[0];
|
||
const radioLabel = inputOption[1];
|
||
const radioInput = document.createElement("input");
|
||
const radioLabelElement = document.createElement("label");
|
||
radioInput.type = "radio";
|
||
radioInput.name = swalClasses.radio;
|
||
radioInput.value = radioValue;
|
||
if (isSelected(radioValue, params.inputValue)) {
|
||
radioInput.checked = true;
|
||
}
|
||
const label = document.createElement("span");
|
||
setInnerHtml(label, radioLabel);
|
||
label.className = swalClasses.label;
|
||
radioLabelElement.appendChild(radioInput);
|
||
radioLabelElement.appendChild(label);
|
||
radio.appendChild(radioLabelElement);
|
||
});
|
||
const radios = radio.querySelectorAll("input");
|
||
if (radios.length) {
|
||
radios[0].focus();
|
||
}
|
||
}
|
||
var formatInputOptions = (inputOptions) => {
|
||
const result = [];
|
||
if (inputOptions instanceof Map) {
|
||
inputOptions.forEach((value, key) => {
|
||
let valueFormatted = value;
|
||
if (typeof valueFormatted === "object") {
|
||
valueFormatted = formatInputOptions(valueFormatted);
|
||
}
|
||
result.push([key, valueFormatted]);
|
||
});
|
||
} else {
|
||
Object.keys(inputOptions).forEach((key) => {
|
||
let valueFormatted = inputOptions[key];
|
||
if (typeof valueFormatted === "object") {
|
||
valueFormatted = formatInputOptions(valueFormatted);
|
||
}
|
||
result.push([key, valueFormatted]);
|
||
});
|
||
}
|
||
return result;
|
||
};
|
||
var isSelected = (optionValue, inputValue) => {
|
||
return !!inputValue && inputValue.toString() === optionValue.toString();
|
||
};
|
||
var handleConfirmButtonClick = (instance) => {
|
||
const innerParams = privateProps.innerParams.get(instance);
|
||
instance.disableButtons();
|
||
if (innerParams.input) {
|
||
handleConfirmOrDenyWithInput(instance, "confirm");
|
||
} else {
|
||
confirm(instance, true);
|
||
}
|
||
};
|
||
var handleDenyButtonClick = (instance) => {
|
||
const innerParams = privateProps.innerParams.get(instance);
|
||
instance.disableButtons();
|
||
if (innerParams.returnInputValueOnDeny) {
|
||
handleConfirmOrDenyWithInput(instance, "deny");
|
||
} else {
|
||
deny(instance, false);
|
||
}
|
||
};
|
||
var handleCancelButtonClick = (instance, dismissWith) => {
|
||
instance.disableButtons();
|
||
dismissWith(DismissReason.cancel);
|
||
};
|
||
var handleConfirmOrDenyWithInput = (instance, type) => {
|
||
const innerParams = privateProps.innerParams.get(instance);
|
||
if (!innerParams.input) {
|
||
error(`The "input" parameter is needed to be set when using returnInputValueOn${capitalizeFirstLetter(type)}`);
|
||
return;
|
||
}
|
||
const input = instance.getInput();
|
||
const inputValue = getInputValue(instance, innerParams);
|
||
if (innerParams.inputValidator) {
|
||
handleInputValidator(instance, inputValue, type);
|
||
} else if (input && !input.checkValidity()) {
|
||
instance.enableButtons();
|
||
instance.showValidationMessage(innerParams.validationMessage || input.validationMessage);
|
||
} else if (type === "deny") {
|
||
deny(instance, inputValue);
|
||
} else {
|
||
confirm(instance, inputValue);
|
||
}
|
||
};
|
||
var handleInputValidator = (instance, inputValue, type) => {
|
||
const innerParams = privateProps.innerParams.get(instance);
|
||
instance.disableInput();
|
||
const validationPromise = Promise.resolve().then(() => asPromise(innerParams.inputValidator(inputValue, innerParams.validationMessage)));
|
||
validationPromise.then((validationMessage) => {
|
||
instance.enableButtons();
|
||
instance.enableInput();
|
||
if (validationMessage) {
|
||
instance.showValidationMessage(validationMessage);
|
||
} else if (type === "deny") {
|
||
deny(instance, inputValue);
|
||
} else {
|
||
confirm(instance, inputValue);
|
||
}
|
||
});
|
||
};
|
||
var deny = (instance, value) => {
|
||
const innerParams = privateProps.innerParams.get(instance || void 0);
|
||
if (innerParams.showLoaderOnDeny) {
|
||
showLoading(getDenyButton());
|
||
}
|
||
if (innerParams.preDeny) {
|
||
instance.isAwaitingPromise = true;
|
||
const preDenyPromise = Promise.resolve().then(() => asPromise(innerParams.preDeny(value, innerParams.validationMessage)));
|
||
preDenyPromise.then((preDenyValue) => {
|
||
if (preDenyValue === false) {
|
||
instance.hideLoading();
|
||
handleAwaitingPromise(instance);
|
||
} else {
|
||
instance.close(
|
||
/** @type SweetAlertResult */
|
||
{
|
||
isDenied: true,
|
||
value: typeof preDenyValue === "undefined" ? value : preDenyValue
|
||
}
|
||
);
|
||
}
|
||
}).catch((error2) => rejectWith(instance || void 0, error2));
|
||
} else {
|
||
instance.close(
|
||
/** @type SweetAlertResult */
|
||
{
|
||
isDenied: true,
|
||
value
|
||
}
|
||
);
|
||
}
|
||
};
|
||
var succeedWith = (instance, value) => {
|
||
instance.close(
|
||
/** @type SweetAlertResult */
|
||
{
|
||
isConfirmed: true,
|
||
value
|
||
}
|
||
);
|
||
};
|
||
var rejectWith = (instance, error2) => {
|
||
instance.rejectPromise(error2);
|
||
};
|
||
var confirm = (instance, value) => {
|
||
const innerParams = privateProps.innerParams.get(instance || void 0);
|
||
if (innerParams.showLoaderOnConfirm) {
|
||
showLoading();
|
||
}
|
||
if (innerParams.preConfirm) {
|
||
instance.resetValidationMessage();
|
||
instance.isAwaitingPromise = true;
|
||
const preConfirmPromise = Promise.resolve().then(() => asPromise(innerParams.preConfirm(value, innerParams.validationMessage)));
|
||
preConfirmPromise.then((preConfirmValue) => {
|
||
if (isVisible$1(getValidationMessage()) || preConfirmValue === false) {
|
||
instance.hideLoading();
|
||
handleAwaitingPromise(instance);
|
||
} else {
|
||
succeedWith(instance, typeof preConfirmValue === "undefined" ? value : preConfirmValue);
|
||
}
|
||
}).catch((error2) => rejectWith(instance || void 0, error2));
|
||
} else {
|
||
succeedWith(instance, value);
|
||
}
|
||
};
|
||
function hideLoading() {
|
||
const innerParams = privateProps.innerParams.get(this);
|
||
if (!innerParams) {
|
||
return;
|
||
}
|
||
const domCache = privateProps.domCache.get(this);
|
||
hide(domCache.loader);
|
||
if (isToast()) {
|
||
if (innerParams.icon) {
|
||
show(getIcon());
|
||
}
|
||
} else {
|
||
showRelatedButton(domCache);
|
||
}
|
||
removeClass([domCache.popup, domCache.actions], swalClasses.loading);
|
||
domCache.popup.removeAttribute("aria-busy");
|
||
domCache.popup.removeAttribute("data-loading");
|
||
domCache.confirmButton.disabled = false;
|
||
domCache.denyButton.disabled = false;
|
||
domCache.cancelButton.disabled = false;
|
||
}
|
||
var showRelatedButton = (domCache) => {
|
||
const buttonToReplace = domCache.popup.getElementsByClassName(domCache.loader.getAttribute("data-button-to-replace"));
|
||
if (buttonToReplace.length) {
|
||
show(buttonToReplace[0], "inline-block");
|
||
} else if (allButtonsAreHidden()) {
|
||
hide(domCache.actions);
|
||
}
|
||
};
|
||
function getInput() {
|
||
const innerParams = privateProps.innerParams.get(this);
|
||
const domCache = privateProps.domCache.get(this);
|
||
if (!domCache) {
|
||
return null;
|
||
}
|
||
return getInput$1(domCache.popup, innerParams.input);
|
||
}
|
||
function setButtonsDisabled(instance, buttons, disabled) {
|
||
const domCache = privateProps.domCache.get(instance);
|
||
buttons.forEach((button) => {
|
||
domCache[button].disabled = disabled;
|
||
});
|
||
}
|
||
function setInputDisabled(input, disabled) {
|
||
const popup = getPopup();
|
||
if (!popup || !input) {
|
||
return;
|
||
}
|
||
if (input.type === "radio") {
|
||
const radios = popup.querySelectorAll(`[name="${swalClasses.radio}"]`);
|
||
for (let i = 0; i < radios.length; i++) {
|
||
radios[i].disabled = disabled;
|
||
}
|
||
} else {
|
||
input.disabled = disabled;
|
||
}
|
||
}
|
||
function enableButtons() {
|
||
setButtonsDisabled(this, ["confirmButton", "denyButton", "cancelButton"], false);
|
||
}
|
||
function disableButtons() {
|
||
setButtonsDisabled(this, ["confirmButton", "denyButton", "cancelButton"], true);
|
||
}
|
||
function enableInput() {
|
||
setInputDisabled(this.getInput(), false);
|
||
}
|
||
function disableInput() {
|
||
setInputDisabled(this.getInput(), true);
|
||
}
|
||
function showValidationMessage(error2) {
|
||
const domCache = privateProps.domCache.get(this);
|
||
const params = privateProps.innerParams.get(this);
|
||
setInnerHtml(domCache.validationMessage, error2);
|
||
domCache.validationMessage.className = swalClasses["validation-message"];
|
||
if (params.customClass && params.customClass.validationMessage) {
|
||
addClass(domCache.validationMessage, params.customClass.validationMessage);
|
||
}
|
||
show(domCache.validationMessage);
|
||
const input = this.getInput();
|
||
if (input) {
|
||
input.setAttribute("aria-invalid", "true");
|
||
input.setAttribute("aria-describedby", swalClasses["validation-message"]);
|
||
focusInput(input);
|
||
addClass(input, swalClasses.inputerror);
|
||
}
|
||
}
|
||
function resetValidationMessage() {
|
||
const domCache = privateProps.domCache.get(this);
|
||
if (domCache.validationMessage) {
|
||
hide(domCache.validationMessage);
|
||
}
|
||
const input = this.getInput();
|
||
if (input) {
|
||
input.removeAttribute("aria-invalid");
|
||
input.removeAttribute("aria-describedby");
|
||
removeClass(input, swalClasses.inputerror);
|
||
}
|
||
}
|
||
var defaultParams = {
|
||
title: "",
|
||
titleText: "",
|
||
text: "",
|
||
html: "",
|
||
footer: "",
|
||
icon: void 0,
|
||
iconColor: void 0,
|
||
iconHtml: void 0,
|
||
template: void 0,
|
||
toast: false,
|
||
draggable: false,
|
||
animation: true,
|
||
theme: "light",
|
||
showClass: {
|
||
popup: "swal2-show",
|
||
backdrop: "swal2-backdrop-show",
|
||
icon: "swal2-icon-show"
|
||
},
|
||
hideClass: {
|
||
popup: "swal2-hide",
|
||
backdrop: "swal2-backdrop-hide",
|
||
icon: "swal2-icon-hide"
|
||
},
|
||
customClass: {},
|
||
target: "body",
|
||
color: void 0,
|
||
backdrop: true,
|
||
heightAuto: true,
|
||
allowOutsideClick: true,
|
||
allowEscapeKey: true,
|
||
allowEnterKey: true,
|
||
stopKeydownPropagation: true,
|
||
keydownListenerCapture: false,
|
||
showConfirmButton: true,
|
||
showDenyButton: false,
|
||
showCancelButton: false,
|
||
preConfirm: void 0,
|
||
preDeny: void 0,
|
||
confirmButtonText: "OK",
|
||
confirmButtonAriaLabel: "",
|
||
confirmButtonColor: void 0,
|
||
denyButtonText: "No",
|
||
denyButtonAriaLabel: "",
|
||
denyButtonColor: void 0,
|
||
cancelButtonText: "Cancel",
|
||
cancelButtonAriaLabel: "",
|
||
cancelButtonColor: void 0,
|
||
buttonsStyling: true,
|
||
reverseButtons: false,
|
||
focusConfirm: true,
|
||
focusDeny: false,
|
||
focusCancel: false,
|
||
returnFocus: true,
|
||
showCloseButton: false,
|
||
closeButtonHtml: "×",
|
||
closeButtonAriaLabel: "Close this dialog",
|
||
loaderHtml: "",
|
||
showLoaderOnConfirm: false,
|
||
showLoaderOnDeny: false,
|
||
imageUrl: void 0,
|
||
imageWidth: void 0,
|
||
imageHeight: void 0,
|
||
imageAlt: "",
|
||
timer: void 0,
|
||
timerProgressBar: false,
|
||
width: void 0,
|
||
padding: void 0,
|
||
background: void 0,
|
||
input: void 0,
|
||
inputPlaceholder: "",
|
||
inputLabel: "",
|
||
inputValue: "",
|
||
inputOptions: {},
|
||
inputAutoFocus: true,
|
||
inputAutoTrim: true,
|
||
inputAttributes: {},
|
||
inputValidator: void 0,
|
||
returnInputValueOnDeny: false,
|
||
validationMessage: void 0,
|
||
grow: false,
|
||
position: "center",
|
||
progressSteps: [],
|
||
currentProgressStep: void 0,
|
||
progressStepsDistance: void 0,
|
||
willOpen: void 0,
|
||
didOpen: void 0,
|
||
didRender: void 0,
|
||
willClose: void 0,
|
||
didClose: void 0,
|
||
didDestroy: void 0,
|
||
scrollbarPadding: true,
|
||
topLayer: false
|
||
};
|
||
var updatableParams = ["allowEscapeKey", "allowOutsideClick", "background", "buttonsStyling", "cancelButtonAriaLabel", "cancelButtonColor", "cancelButtonText", "closeButtonAriaLabel", "closeButtonHtml", "color", "confirmButtonAriaLabel", "confirmButtonColor", "confirmButtonText", "currentProgressStep", "customClass", "denyButtonAriaLabel", "denyButtonColor", "denyButtonText", "didClose", "didDestroy", "draggable", "footer", "hideClass", "html", "icon", "iconColor", "iconHtml", "imageAlt", "imageHeight", "imageUrl", "imageWidth", "preConfirm", "preDeny", "progressSteps", "returnFocus", "reverseButtons", "showCancelButton", "showCloseButton", "showConfirmButton", "showDenyButton", "text", "title", "titleText", "theme", "willClose"];
|
||
var deprecatedParams = {
|
||
allowEnterKey: void 0
|
||
};
|
||
var toastIncompatibleParams = ["allowOutsideClick", "allowEnterKey", "backdrop", "draggable", "focusConfirm", "focusDeny", "focusCancel", "returnFocus", "heightAuto", "keydownListenerCapture"];
|
||
var isValidParameter = (paramName) => {
|
||
return Object.prototype.hasOwnProperty.call(defaultParams, paramName);
|
||
};
|
||
var isUpdatableParameter = (paramName) => {
|
||
return updatableParams.indexOf(paramName) !== -1;
|
||
};
|
||
var isDeprecatedParameter = (paramName) => {
|
||
return deprecatedParams[paramName];
|
||
};
|
||
var checkIfParamIsValid = (param) => {
|
||
if (!isValidParameter(param)) {
|
||
warn(`Unknown parameter "${param}"`);
|
||
}
|
||
};
|
||
var checkIfToastParamIsValid = (param) => {
|
||
if (toastIncompatibleParams.includes(param)) {
|
||
warn(`The parameter "${param}" is incompatible with toasts`);
|
||
}
|
||
};
|
||
var checkIfParamIsDeprecated = (param) => {
|
||
const isDeprecated = isDeprecatedParameter(param);
|
||
if (isDeprecated) {
|
||
warnAboutDeprecation(param, isDeprecated);
|
||
}
|
||
};
|
||
var showWarningsForParams = (params) => {
|
||
if (params.backdrop === false && params.allowOutsideClick) {
|
||
warn('"allowOutsideClick" parameter requires `backdrop` parameter to be set to `true`');
|
||
}
|
||
if (params.theme && !["light", "dark", "auto", "minimal", "borderless", "bootstrap-4", "bootstrap-4-light", "bootstrap-4-dark", "bootstrap-5", "bootstrap-5-light", "bootstrap-5-dark", "material-ui", "material-ui-light", "material-ui-dark", "embed-iframe", "bulma", "bulma-light", "bulma-dark"].includes(params.theme)) {
|
||
warn(`Invalid theme "${params.theme}"`);
|
||
}
|
||
for (const param in params) {
|
||
checkIfParamIsValid(param);
|
||
if (params.toast) {
|
||
checkIfToastParamIsValid(param);
|
||
}
|
||
checkIfParamIsDeprecated(param);
|
||
}
|
||
};
|
||
function update(params) {
|
||
const container = getContainer();
|
||
const popup = getPopup();
|
||
const innerParams = privateProps.innerParams.get(this);
|
||
if (!popup || hasClass(popup, innerParams.hideClass.popup)) {
|
||
warn(`You're trying to update the closed or closing popup, that won't work. Use the update() method in preConfirm parameter or show a new popup.`);
|
||
return;
|
||
}
|
||
const validUpdatableParams = filterValidParams(params);
|
||
const updatedParams = Object.assign({}, innerParams, validUpdatableParams);
|
||
showWarningsForParams(updatedParams);
|
||
container.dataset["swal2Theme"] = updatedParams.theme;
|
||
render(this, updatedParams);
|
||
privateProps.innerParams.set(this, updatedParams);
|
||
Object.defineProperties(this, {
|
||
params: {
|
||
value: Object.assign({}, this.params, params),
|
||
writable: false,
|
||
enumerable: true
|
||
}
|
||
});
|
||
}
|
||
var filterValidParams = (params) => {
|
||
const validUpdatableParams = {};
|
||
Object.keys(params).forEach((param) => {
|
||
if (isUpdatableParameter(param)) {
|
||
validUpdatableParams[param] = params[param];
|
||
} else {
|
||
warn(`Invalid parameter to update: ${param}`);
|
||
}
|
||
});
|
||
return validUpdatableParams;
|
||
};
|
||
function _destroy() {
|
||
const domCache = privateProps.domCache.get(this);
|
||
const innerParams = privateProps.innerParams.get(this);
|
||
if (!innerParams) {
|
||
disposeWeakMaps(this);
|
||
return;
|
||
}
|
||
if (domCache.popup && globalState.swalCloseEventFinishedCallback) {
|
||
globalState.swalCloseEventFinishedCallback();
|
||
delete globalState.swalCloseEventFinishedCallback;
|
||
}
|
||
if (typeof innerParams.didDestroy === "function") {
|
||
innerParams.didDestroy();
|
||
}
|
||
globalState.eventEmitter.emit("didDestroy");
|
||
disposeSwal(this);
|
||
}
|
||
var disposeSwal = (instance) => {
|
||
disposeWeakMaps(instance);
|
||
delete instance.params;
|
||
delete globalState.keydownHandler;
|
||
delete globalState.keydownTarget;
|
||
delete globalState.currentInstance;
|
||
};
|
||
var disposeWeakMaps = (instance) => {
|
||
if (instance.isAwaitingPromise) {
|
||
unsetWeakMaps(privateProps, instance);
|
||
instance.isAwaitingPromise = true;
|
||
} else {
|
||
unsetWeakMaps(privateMethods, instance);
|
||
unsetWeakMaps(privateProps, instance);
|
||
delete instance.isAwaitingPromise;
|
||
delete instance.disableButtons;
|
||
delete instance.enableButtons;
|
||
delete instance.getInput;
|
||
delete instance.disableInput;
|
||
delete instance.enableInput;
|
||
delete instance.hideLoading;
|
||
delete instance.disableLoading;
|
||
delete instance.showValidationMessage;
|
||
delete instance.resetValidationMessage;
|
||
delete instance.close;
|
||
delete instance.closePopup;
|
||
delete instance.closeModal;
|
||
delete instance.closeToast;
|
||
delete instance.rejectPromise;
|
||
delete instance.update;
|
||
delete instance._destroy;
|
||
}
|
||
};
|
||
var unsetWeakMaps = (obj, instance) => {
|
||
for (const i in obj) {
|
||
obj[i].delete(instance);
|
||
}
|
||
};
|
||
var instanceMethods = /* @__PURE__ */ Object.freeze({
|
||
__proto__: null,
|
||
_destroy,
|
||
close,
|
||
closeModal: close,
|
||
closePopup: close,
|
||
closeToast: close,
|
||
disableButtons,
|
||
disableInput,
|
||
disableLoading: hideLoading,
|
||
enableButtons,
|
||
enableInput,
|
||
getInput,
|
||
handleAwaitingPromise,
|
||
hideLoading,
|
||
rejectPromise,
|
||
resetValidationMessage,
|
||
showValidationMessage,
|
||
update
|
||
});
|
||
var handlePopupClick = (innerParams, domCache, dismissWith) => {
|
||
if (innerParams.toast) {
|
||
handleToastClick(innerParams, domCache, dismissWith);
|
||
} else {
|
||
handleModalMousedown(domCache);
|
||
handleContainerMousedown(domCache);
|
||
handleModalClick(innerParams, domCache, dismissWith);
|
||
}
|
||
};
|
||
var handleToastClick = (innerParams, domCache, dismissWith) => {
|
||
domCache.popup.onclick = () => {
|
||
if (innerParams && (isAnyButtonShown(innerParams) || innerParams.timer || innerParams.input)) {
|
||
return;
|
||
}
|
||
dismissWith(DismissReason.close);
|
||
};
|
||
};
|
||
var isAnyButtonShown = (innerParams) => {
|
||
return !!(innerParams.showConfirmButton || innerParams.showDenyButton || innerParams.showCancelButton || innerParams.showCloseButton);
|
||
};
|
||
var ignoreOutsideClick = false;
|
||
var handleModalMousedown = (domCache) => {
|
||
domCache.popup.onmousedown = () => {
|
||
domCache.container.onmouseup = function(e) {
|
||
domCache.container.onmouseup = () => {
|
||
};
|
||
if (e.target === domCache.container) {
|
||
ignoreOutsideClick = true;
|
||
}
|
||
};
|
||
};
|
||
};
|
||
var handleContainerMousedown = (domCache) => {
|
||
domCache.container.onmousedown = (e) => {
|
||
if (e.target === domCache.container) {
|
||
e.preventDefault();
|
||
}
|
||
domCache.popup.onmouseup = function(e2) {
|
||
domCache.popup.onmouseup = () => {
|
||
};
|
||
if (e2.target === domCache.popup || e2.target instanceof HTMLElement && domCache.popup.contains(e2.target)) {
|
||
ignoreOutsideClick = true;
|
||
}
|
||
};
|
||
};
|
||
};
|
||
var handleModalClick = (innerParams, domCache, dismissWith) => {
|
||
domCache.container.onclick = (e) => {
|
||
if (ignoreOutsideClick) {
|
||
ignoreOutsideClick = false;
|
||
return;
|
||
}
|
||
if (e.target === domCache.container && callIfFunction(innerParams.allowOutsideClick)) {
|
||
dismissWith(DismissReason.backdrop);
|
||
}
|
||
};
|
||
};
|
||
var isJqueryElement = (elem) => typeof elem === "object" && elem.jquery;
|
||
var isElement = (elem) => elem instanceof Element || isJqueryElement(elem);
|
||
var argsToParams = (args) => {
|
||
const params = {};
|
||
if (typeof args[0] === "object" && !isElement(args[0])) {
|
||
Object.assign(params, args[0]);
|
||
} else {
|
||
["title", "html", "icon"].forEach((name, index) => {
|
||
const arg = args[index];
|
||
if (typeof arg === "string" || isElement(arg)) {
|
||
params[name] = arg;
|
||
} else if (arg !== void 0) {
|
||
error(`Unexpected type of ${name}! Expected "string" or "Element", got ${typeof arg}`);
|
||
}
|
||
});
|
||
}
|
||
return params;
|
||
};
|
||
function fire(...args) {
|
||
return new this(...args);
|
||
}
|
||
function mixin(mixinParams) {
|
||
class MixinSwal extends this {
|
||
_main(params, priorityMixinParams) {
|
||
return super._main(params, Object.assign({}, mixinParams, priorityMixinParams));
|
||
}
|
||
}
|
||
return MixinSwal;
|
||
}
|
||
var getTimerLeft = () => {
|
||
return globalState.timeout && globalState.timeout.getTimerLeft();
|
||
};
|
||
var stopTimer = () => {
|
||
if (globalState.timeout) {
|
||
stopTimerProgressBar();
|
||
return globalState.timeout.stop();
|
||
}
|
||
};
|
||
var resumeTimer = () => {
|
||
if (globalState.timeout) {
|
||
const remaining = globalState.timeout.start();
|
||
animateTimerProgressBar(remaining);
|
||
return remaining;
|
||
}
|
||
};
|
||
var toggleTimer = () => {
|
||
const timer = globalState.timeout;
|
||
return timer && (timer.running ? stopTimer() : resumeTimer());
|
||
};
|
||
var increaseTimer = (ms) => {
|
||
if (globalState.timeout) {
|
||
const remaining = globalState.timeout.increase(ms);
|
||
animateTimerProgressBar(remaining, true);
|
||
return remaining;
|
||
}
|
||
};
|
||
var isTimerRunning = () => {
|
||
return !!(globalState.timeout && globalState.timeout.isRunning());
|
||
};
|
||
var bodyClickListenerAdded = false;
|
||
var clickHandlers = {};
|
||
function bindClickHandler(attr = "data-swal-template") {
|
||
clickHandlers[attr] = this;
|
||
if (!bodyClickListenerAdded) {
|
||
document.body.addEventListener("click", bodyClickListener);
|
||
bodyClickListenerAdded = true;
|
||
}
|
||
}
|
||
var bodyClickListener = (event) => {
|
||
for (let el = event.target; el && el !== document; el = el.parentNode) {
|
||
for (const attr in clickHandlers) {
|
||
const template = el.getAttribute(attr);
|
||
if (template) {
|
||
clickHandlers[attr].fire({
|
||
template
|
||
});
|
||
return;
|
||
}
|
||
}
|
||
}
|
||
};
|
||
var EventEmitter = class {
|
||
constructor() {
|
||
this.events = {};
|
||
}
|
||
/**
|
||
* @param {string} eventName
|
||
* @returns {EventHandlers}
|
||
*/
|
||
_getHandlersByEventName(eventName) {
|
||
if (typeof this.events[eventName] === "undefined") {
|
||
this.events[eventName] = [];
|
||
}
|
||
return this.events[eventName];
|
||
}
|
||
/**
|
||
* @param {string} eventName
|
||
* @param {EventHandler} eventHandler
|
||
*/
|
||
on(eventName, eventHandler) {
|
||
const currentHandlers = this._getHandlersByEventName(eventName);
|
||
if (!currentHandlers.includes(eventHandler)) {
|
||
currentHandlers.push(eventHandler);
|
||
}
|
||
}
|
||
/**
|
||
* @param {string} eventName
|
||
* @param {EventHandler} eventHandler
|
||
*/
|
||
once(eventName, eventHandler) {
|
||
const onceFn = (...args) => {
|
||
this.removeListener(eventName, onceFn);
|
||
eventHandler.apply(this, args);
|
||
};
|
||
this.on(eventName, onceFn);
|
||
}
|
||
/**
|
||
* @param {string} eventName
|
||
* @param {Array} args
|
||
*/
|
||
emit(eventName, ...args) {
|
||
this._getHandlersByEventName(eventName).forEach(
|
||
/**
|
||
* @param {EventHandler} eventHandler
|
||
*/
|
||
(eventHandler) => {
|
||
try {
|
||
eventHandler.apply(this, args);
|
||
} catch (error2) {
|
||
console.error(error2);
|
||
}
|
||
}
|
||
);
|
||
}
|
||
/**
|
||
* @param {string} eventName
|
||
* @param {EventHandler} eventHandler
|
||
*/
|
||
removeListener(eventName, eventHandler) {
|
||
const currentHandlers = this._getHandlersByEventName(eventName);
|
||
const index = currentHandlers.indexOf(eventHandler);
|
||
if (index > -1) {
|
||
currentHandlers.splice(index, 1);
|
||
}
|
||
}
|
||
/**
|
||
* @param {string} eventName
|
||
*/
|
||
removeAllListeners(eventName) {
|
||
if (this.events[eventName] !== void 0) {
|
||
this.events[eventName].length = 0;
|
||
}
|
||
}
|
||
reset() {
|
||
this.events = {};
|
||
}
|
||
};
|
||
globalState.eventEmitter = new EventEmitter();
|
||
var on = (eventName, eventHandler) => {
|
||
globalState.eventEmitter.on(eventName, eventHandler);
|
||
};
|
||
var once = (eventName, eventHandler) => {
|
||
globalState.eventEmitter.once(eventName, eventHandler);
|
||
};
|
||
var off = (eventName, eventHandler) => {
|
||
if (!eventName) {
|
||
globalState.eventEmitter.reset();
|
||
return;
|
||
}
|
||
if (eventHandler) {
|
||
globalState.eventEmitter.removeListener(eventName, eventHandler);
|
||
} else {
|
||
globalState.eventEmitter.removeAllListeners(eventName);
|
||
}
|
||
};
|
||
var staticMethods = /* @__PURE__ */ Object.freeze({
|
||
__proto__: null,
|
||
argsToParams,
|
||
bindClickHandler,
|
||
clickCancel,
|
||
clickConfirm,
|
||
clickDeny,
|
||
enableLoading: showLoading,
|
||
fire,
|
||
getActions,
|
||
getCancelButton,
|
||
getCloseButton,
|
||
getConfirmButton,
|
||
getContainer,
|
||
getDenyButton,
|
||
getFocusableElements,
|
||
getFooter,
|
||
getHtmlContainer,
|
||
getIcon,
|
||
getIconContent,
|
||
getImage,
|
||
getInputLabel,
|
||
getLoader,
|
||
getPopup,
|
||
getProgressSteps,
|
||
getTimerLeft,
|
||
getTimerProgressBar,
|
||
getTitle,
|
||
getValidationMessage,
|
||
increaseTimer,
|
||
isDeprecatedParameter,
|
||
isLoading,
|
||
isTimerRunning,
|
||
isUpdatableParameter,
|
||
isValidParameter,
|
||
isVisible,
|
||
mixin,
|
||
off,
|
||
on,
|
||
once,
|
||
resumeTimer,
|
||
showLoading,
|
||
stopTimer,
|
||
toggleTimer
|
||
});
|
||
var Timer = class {
|
||
/**
|
||
* @param {() => void} callback
|
||
* @param {number} delay
|
||
*/
|
||
constructor(callback, delay) {
|
||
this.callback = callback;
|
||
this.remaining = delay;
|
||
this.running = false;
|
||
this.start();
|
||
}
|
||
/**
|
||
* @returns {number}
|
||
*/
|
||
start() {
|
||
if (!this.running) {
|
||
this.running = true;
|
||
this.started = /* @__PURE__ */ new Date();
|
||
this.id = setTimeout(this.callback, this.remaining);
|
||
}
|
||
return this.remaining;
|
||
}
|
||
/**
|
||
* @returns {number}
|
||
*/
|
||
stop() {
|
||
if (this.started && this.running) {
|
||
this.running = false;
|
||
clearTimeout(this.id);
|
||
this.remaining -= (/* @__PURE__ */ new Date()).getTime() - this.started.getTime();
|
||
}
|
||
return this.remaining;
|
||
}
|
||
/**
|
||
* @param {number} n
|
||
* @returns {number}
|
||
*/
|
||
increase(n) {
|
||
const running = this.running;
|
||
if (running) {
|
||
this.stop();
|
||
}
|
||
this.remaining += n;
|
||
if (running) {
|
||
this.start();
|
||
}
|
||
return this.remaining;
|
||
}
|
||
/**
|
||
* @returns {number}
|
||
*/
|
||
getTimerLeft() {
|
||
if (this.running) {
|
||
this.stop();
|
||
this.start();
|
||
}
|
||
return this.remaining;
|
||
}
|
||
/**
|
||
* @returns {boolean}
|
||
*/
|
||
isRunning() {
|
||
return this.running;
|
||
}
|
||
};
|
||
var swalStringParams = ["swal-title", "swal-html", "swal-footer"];
|
||
var getTemplateParams = (params) => {
|
||
const template = typeof params.template === "string" ? (
|
||
/** @type {HTMLTemplateElement} */
|
||
document.querySelector(params.template)
|
||
) : params.template;
|
||
if (!template) {
|
||
return {};
|
||
}
|
||
const templateContent = template.content;
|
||
showWarningsForElements(templateContent);
|
||
const result = Object.assign(getSwalParams(templateContent), getSwalFunctionParams(templateContent), getSwalButtons(templateContent), getSwalImage(templateContent), getSwalIcon(templateContent), getSwalInput(templateContent), getSwalStringParams(templateContent, swalStringParams));
|
||
return result;
|
||
};
|
||
var getSwalParams = (templateContent) => {
|
||
const result = {};
|
||
const swalParams = Array.from(templateContent.querySelectorAll("swal-param"));
|
||
swalParams.forEach((param) => {
|
||
showWarningsForAttributes(param, ["name", "value"]);
|
||
const paramName = (
|
||
/** @type {keyof SweetAlertOptions} */
|
||
param.getAttribute("name")
|
||
);
|
||
const value = param.getAttribute("value");
|
||
if (!paramName || !value) {
|
||
return;
|
||
}
|
||
if (typeof defaultParams[paramName] === "boolean") {
|
||
result[paramName] = value !== "false";
|
||
} else if (typeof defaultParams[paramName] === "object") {
|
||
result[paramName] = JSON.parse(value);
|
||
} else {
|
||
result[paramName] = value;
|
||
}
|
||
});
|
||
return result;
|
||
};
|
||
var getSwalFunctionParams = (templateContent) => {
|
||
const result = {};
|
||
const swalFunctions = Array.from(templateContent.querySelectorAll("swal-function-param"));
|
||
swalFunctions.forEach((param) => {
|
||
const paramName = (
|
||
/** @type {keyof SweetAlertOptions} */
|
||
param.getAttribute("name")
|
||
);
|
||
const value = param.getAttribute("value");
|
||
if (!paramName || !value) {
|
||
return;
|
||
}
|
||
result[paramName] = new Function(`return ${value}`)();
|
||
});
|
||
return result;
|
||
};
|
||
var getSwalButtons = (templateContent) => {
|
||
const result = {};
|
||
const swalButtons = Array.from(templateContent.querySelectorAll("swal-button"));
|
||
swalButtons.forEach((button) => {
|
||
showWarningsForAttributes(button, ["type", "color", "aria-label"]);
|
||
const type = button.getAttribute("type");
|
||
if (!type || !["confirm", "cancel", "deny"].includes(type)) {
|
||
return;
|
||
}
|
||
result[`${type}ButtonText`] = button.innerHTML;
|
||
result[`show${capitalizeFirstLetter(type)}Button`] = true;
|
||
if (button.hasAttribute("color")) {
|
||
result[`${type}ButtonColor`] = button.getAttribute("color");
|
||
}
|
||
if (button.hasAttribute("aria-label")) {
|
||
result[`${type}ButtonAriaLabel`] = button.getAttribute("aria-label");
|
||
}
|
||
});
|
||
return result;
|
||
};
|
||
var getSwalImage = (templateContent) => {
|
||
const result = {};
|
||
const image = templateContent.querySelector("swal-image");
|
||
if (image) {
|
||
showWarningsForAttributes(image, ["src", "width", "height", "alt"]);
|
||
if (image.hasAttribute("src")) {
|
||
result.imageUrl = image.getAttribute("src") || void 0;
|
||
}
|
||
if (image.hasAttribute("width")) {
|
||
result.imageWidth = image.getAttribute("width") || void 0;
|
||
}
|
||
if (image.hasAttribute("height")) {
|
||
result.imageHeight = image.getAttribute("height") || void 0;
|
||
}
|
||
if (image.hasAttribute("alt")) {
|
||
result.imageAlt = image.getAttribute("alt") || void 0;
|
||
}
|
||
}
|
||
return result;
|
||
};
|
||
var getSwalIcon = (templateContent) => {
|
||
const result = {};
|
||
const icon = templateContent.querySelector("swal-icon");
|
||
if (icon) {
|
||
showWarningsForAttributes(icon, ["type", "color"]);
|
||
if (icon.hasAttribute("type")) {
|
||
result.icon = icon.getAttribute("type");
|
||
}
|
||
if (icon.hasAttribute("color")) {
|
||
result.iconColor = icon.getAttribute("color");
|
||
}
|
||
result.iconHtml = icon.innerHTML;
|
||
}
|
||
return result;
|
||
};
|
||
var getSwalInput = (templateContent) => {
|
||
const result = {};
|
||
const input = templateContent.querySelector("swal-input");
|
||
if (input) {
|
||
showWarningsForAttributes(input, ["type", "label", "placeholder", "value"]);
|
||
result.input = input.getAttribute("type") || "text";
|
||
if (input.hasAttribute("label")) {
|
||
result.inputLabel = input.getAttribute("label");
|
||
}
|
||
if (input.hasAttribute("placeholder")) {
|
||
result.inputPlaceholder = input.getAttribute("placeholder");
|
||
}
|
||
if (input.hasAttribute("value")) {
|
||
result.inputValue = input.getAttribute("value");
|
||
}
|
||
}
|
||
const inputOptions = Array.from(templateContent.querySelectorAll("swal-input-option"));
|
||
if (inputOptions.length) {
|
||
result.inputOptions = {};
|
||
inputOptions.forEach((option) => {
|
||
showWarningsForAttributes(option, ["value"]);
|
||
const optionValue = option.getAttribute("value");
|
||
if (!optionValue) {
|
||
return;
|
||
}
|
||
const optionName = option.innerHTML;
|
||
result.inputOptions[optionValue] = optionName;
|
||
});
|
||
}
|
||
return result;
|
||
};
|
||
var getSwalStringParams = (templateContent, paramNames) => {
|
||
const result = {};
|
||
for (const i in paramNames) {
|
||
const paramName = paramNames[i];
|
||
const tag = templateContent.querySelector(paramName);
|
||
if (tag) {
|
||
showWarningsForAttributes(tag, []);
|
||
result[paramName.replace(/^swal-/, "")] = tag.innerHTML.trim();
|
||
}
|
||
}
|
||
return result;
|
||
};
|
||
var showWarningsForElements = (templateContent) => {
|
||
const allowedElements = swalStringParams.concat(["swal-param", "swal-function-param", "swal-button", "swal-image", "swal-icon", "swal-input", "swal-input-option"]);
|
||
Array.from(templateContent.children).forEach((el) => {
|
||
const tagName = el.tagName.toLowerCase();
|
||
if (!allowedElements.includes(tagName)) {
|
||
warn(`Unrecognized element <${tagName}>`);
|
||
}
|
||
});
|
||
};
|
||
var showWarningsForAttributes = (el, allowedAttributes) => {
|
||
Array.from(el.attributes).forEach((attribute) => {
|
||
if (allowedAttributes.indexOf(attribute.name) === -1) {
|
||
warn([`Unrecognized attribute "${attribute.name}" on <${el.tagName.toLowerCase()}>.`, `${allowedAttributes.length ? `Allowed attributes are: ${allowedAttributes.join(", ")}` : "To set the value, use HTML within the element."}`]);
|
||
}
|
||
});
|
||
};
|
||
var SHOW_CLASS_TIMEOUT = 10;
|
||
var openPopup = (params) => {
|
||
const container = getContainer();
|
||
const popup = getPopup();
|
||
if (typeof params.willOpen === "function") {
|
||
params.willOpen(popup);
|
||
}
|
||
globalState.eventEmitter.emit("willOpen", popup);
|
||
const bodyStyles = window.getComputedStyle(document.body);
|
||
const initialBodyOverflow = bodyStyles.overflowY;
|
||
addClasses(container, popup, params);
|
||
setTimeout(() => {
|
||
setScrollingVisibility(container, popup);
|
||
}, SHOW_CLASS_TIMEOUT);
|
||
if (isModal()) {
|
||
fixScrollContainer(container, params.scrollbarPadding, initialBodyOverflow);
|
||
setAriaHidden();
|
||
}
|
||
if (!isToast() && !globalState.previousActiveElement) {
|
||
globalState.previousActiveElement = document.activeElement;
|
||
}
|
||
if (typeof params.didOpen === "function") {
|
||
setTimeout(() => params.didOpen(popup));
|
||
}
|
||
globalState.eventEmitter.emit("didOpen", popup);
|
||
};
|
||
var swalOpenAnimationFinished = (event) => {
|
||
const popup = getPopup();
|
||
if (event.target !== popup) {
|
||
return;
|
||
}
|
||
const container = getContainer();
|
||
popup.removeEventListener("animationend", swalOpenAnimationFinished);
|
||
popup.removeEventListener("transitionend", swalOpenAnimationFinished);
|
||
container.style.overflowY = "auto";
|
||
removeClass(container, swalClasses["no-transition"]);
|
||
};
|
||
var setScrollingVisibility = (container, popup) => {
|
||
if (hasCssAnimation(popup)) {
|
||
container.style.overflowY = "hidden";
|
||
popup.addEventListener("animationend", swalOpenAnimationFinished);
|
||
popup.addEventListener("transitionend", swalOpenAnimationFinished);
|
||
} else {
|
||
container.style.overflowY = "auto";
|
||
}
|
||
};
|
||
var fixScrollContainer = (container, scrollbarPadding, initialBodyOverflow) => {
|
||
iOSfix();
|
||
if (scrollbarPadding && initialBodyOverflow !== "hidden") {
|
||
replaceScrollbarWithPadding(initialBodyOverflow);
|
||
}
|
||
setTimeout(() => {
|
||
container.scrollTop = 0;
|
||
});
|
||
};
|
||
var addClasses = (container, popup, params) => {
|
||
addClass(container, params.showClass.backdrop);
|
||
if (params.animation) {
|
||
popup.style.setProperty("opacity", "0", "important");
|
||
show(popup, "grid");
|
||
setTimeout(() => {
|
||
addClass(popup, params.showClass.popup);
|
||
popup.style.removeProperty("opacity");
|
||
}, SHOW_CLASS_TIMEOUT);
|
||
} else {
|
||
show(popup, "grid");
|
||
}
|
||
addClass([document.documentElement, document.body], swalClasses.shown);
|
||
if (params.heightAuto && params.backdrop && !params.toast) {
|
||
addClass([document.documentElement, document.body], swalClasses["height-auto"]);
|
||
}
|
||
};
|
||
var defaultInputValidators = {
|
||
/**
|
||
* @param {string} string
|
||
* @param {string} [validationMessage]
|
||
* @returns {Promise<string | void>}
|
||
*/
|
||
email: (string, validationMessage) => {
|
||
return /^[a-zA-Z0-9.+_'-]+@[a-zA-Z0-9.-]+\.[a-zA-Z0-9-]+$/.test(string) ? Promise.resolve() : Promise.resolve(validationMessage || "Invalid email address");
|
||
},
|
||
/**
|
||
* @param {string} string
|
||
* @param {string} [validationMessage]
|
||
* @returns {Promise<string | void>}
|
||
*/
|
||
url: (string, validationMessage) => {
|
||
return /^https?:\/\/(www\.)?[-a-zA-Z0-9@:%._+~#=]{1,256}\.[a-z]{2,63}\b([-a-zA-Z0-9@:%_+.~#?&/=]*)$/.test(string) ? Promise.resolve() : Promise.resolve(validationMessage || "Invalid URL");
|
||
}
|
||
};
|
||
function setDefaultInputValidators(params) {
|
||
if (params.inputValidator) {
|
||
return;
|
||
}
|
||
if (params.input === "email") {
|
||
params.inputValidator = defaultInputValidators["email"];
|
||
}
|
||
if (params.input === "url") {
|
||
params.inputValidator = defaultInputValidators["url"];
|
||
}
|
||
}
|
||
function validateCustomTargetElement(params) {
|
||
if (!params.target || typeof params.target === "string" && !document.querySelector(params.target) || typeof params.target !== "string" && !params.target.appendChild) {
|
||
warn('Target parameter is not valid, defaulting to "body"');
|
||
params.target = "body";
|
||
}
|
||
}
|
||
function setParameters(params) {
|
||
setDefaultInputValidators(params);
|
||
if (params.showLoaderOnConfirm && !params.preConfirm) {
|
||
warn("showLoaderOnConfirm is set to true, but preConfirm is not defined.\nshowLoaderOnConfirm should be used together with preConfirm, see usage example:\nhttps://sweetalert2.github.io/#ajax-request");
|
||
}
|
||
validateCustomTargetElement(params);
|
||
if (typeof params.title === "string") {
|
||
params.title = params.title.split("\n").join("<br />");
|
||
}
|
||
init(params);
|
||
}
|
||
var currentInstance;
|
||
var _promise = /* @__PURE__ */ new WeakMap();
|
||
var SweetAlert = class {
|
||
/**
|
||
* @param {...(SweetAlertOptions | string)} args
|
||
* @this {SweetAlert}
|
||
*/
|
||
constructor(...args) {
|
||
_classPrivateFieldInitSpec(this, _promise, void 0);
|
||
if (typeof window === "undefined") {
|
||
return;
|
||
}
|
||
currentInstance = this;
|
||
const outerParams = Object.freeze(this.constructor.argsToParams(args));
|
||
this.params = outerParams;
|
||
this.isAwaitingPromise = false;
|
||
_classPrivateFieldSet2(_promise, this, this._main(currentInstance.params));
|
||
}
|
||
_main(userParams, mixinParams = {}) {
|
||
showWarningsForParams(Object.assign({}, mixinParams, userParams));
|
||
if (globalState.currentInstance) {
|
||
const swalPromiseResolve = privateMethods.swalPromiseResolve.get(globalState.currentInstance);
|
||
const {
|
||
isAwaitingPromise
|
||
} = globalState.currentInstance;
|
||
globalState.currentInstance._destroy();
|
||
if (!isAwaitingPromise) {
|
||
swalPromiseResolve({
|
||
isDismissed: true
|
||
});
|
||
}
|
||
if (isModal()) {
|
||
unsetAriaHidden();
|
||
}
|
||
}
|
||
globalState.currentInstance = currentInstance;
|
||
const innerParams = prepareParams(userParams, mixinParams);
|
||
setParameters(innerParams);
|
||
Object.freeze(innerParams);
|
||
if (globalState.timeout) {
|
||
globalState.timeout.stop();
|
||
delete globalState.timeout;
|
||
}
|
||
clearTimeout(globalState.restoreFocusTimeout);
|
||
const domCache = populateDomCache(currentInstance);
|
||
render(currentInstance, innerParams);
|
||
privateProps.innerParams.set(currentInstance, innerParams);
|
||
return swalPromise(currentInstance, domCache, innerParams);
|
||
}
|
||
// `catch` cannot be the name of a module export, so we define our thenable methods here instead
|
||
then(onFulfilled) {
|
||
return _classPrivateFieldGet2(_promise, this).then(onFulfilled);
|
||
}
|
||
finally(onFinally) {
|
||
return _classPrivateFieldGet2(_promise, this).finally(onFinally);
|
||
}
|
||
};
|
||
var swalPromise = (instance, domCache, innerParams) => {
|
||
return new Promise((resolve, reject) => {
|
||
const dismissWith = (dismiss) => {
|
||
instance.close({
|
||
isDismissed: true,
|
||
dismiss,
|
||
isConfirmed: false,
|
||
isDenied: false
|
||
});
|
||
};
|
||
privateMethods.swalPromiseResolve.set(instance, resolve);
|
||
privateMethods.swalPromiseReject.set(instance, reject);
|
||
domCache.confirmButton.onclick = () => {
|
||
handleConfirmButtonClick(instance);
|
||
};
|
||
domCache.denyButton.onclick = () => {
|
||
handleDenyButtonClick(instance);
|
||
};
|
||
domCache.cancelButton.onclick = () => {
|
||
handleCancelButtonClick(instance, dismissWith);
|
||
};
|
||
domCache.closeButton.onclick = () => {
|
||
dismissWith(DismissReason.close);
|
||
};
|
||
handlePopupClick(innerParams, domCache, dismissWith);
|
||
addKeydownHandler(globalState, innerParams, dismissWith);
|
||
handleInputOptionsAndValue(instance, innerParams);
|
||
openPopup(innerParams);
|
||
setupTimer(globalState, innerParams, dismissWith);
|
||
initFocus(domCache, innerParams);
|
||
setTimeout(() => {
|
||
domCache.container.scrollTop = 0;
|
||
});
|
||
});
|
||
};
|
||
var prepareParams = (userParams, mixinParams) => {
|
||
const templateParams = getTemplateParams(userParams);
|
||
const params = Object.assign({}, defaultParams, mixinParams, templateParams, userParams);
|
||
params.showClass = Object.assign({}, defaultParams.showClass, params.showClass);
|
||
params.hideClass = Object.assign({}, defaultParams.hideClass, params.hideClass);
|
||
if (params.animation === false) {
|
||
params.showClass = {
|
||
backdrop: "swal2-noanimation"
|
||
};
|
||
params.hideClass = {};
|
||
}
|
||
return params;
|
||
};
|
||
var populateDomCache = (instance) => {
|
||
const domCache = {
|
||
popup: getPopup(),
|
||
container: getContainer(),
|
||
actions: getActions(),
|
||
confirmButton: getConfirmButton(),
|
||
denyButton: getDenyButton(),
|
||
cancelButton: getCancelButton(),
|
||
loader: getLoader(),
|
||
closeButton: getCloseButton(),
|
||
validationMessage: getValidationMessage(),
|
||
progressSteps: getProgressSteps()
|
||
};
|
||
privateProps.domCache.set(instance, domCache);
|
||
return domCache;
|
||
};
|
||
var setupTimer = (globalState2, innerParams, dismissWith) => {
|
||
const timerProgressBar = getTimerProgressBar();
|
||
hide(timerProgressBar);
|
||
if (innerParams.timer) {
|
||
globalState2.timeout = new Timer(() => {
|
||
dismissWith("timer");
|
||
delete globalState2.timeout;
|
||
}, innerParams.timer);
|
||
if (innerParams.timerProgressBar) {
|
||
show(timerProgressBar);
|
||
applyCustomClass(timerProgressBar, innerParams, "timerProgressBar");
|
||
setTimeout(() => {
|
||
if (globalState2.timeout && globalState2.timeout.running) {
|
||
animateTimerProgressBar(innerParams.timer);
|
||
}
|
||
});
|
||
}
|
||
}
|
||
};
|
||
var initFocus = (domCache, innerParams) => {
|
||
if (innerParams.toast) {
|
||
return;
|
||
}
|
||
if (!callIfFunction(innerParams.allowEnterKey)) {
|
||
warnAboutDeprecation("allowEnterKey");
|
||
blurActiveElement();
|
||
return;
|
||
}
|
||
if (focusAutofocus(domCache)) {
|
||
return;
|
||
}
|
||
if (focusButton(domCache, innerParams)) {
|
||
return;
|
||
}
|
||
setFocus(-1, 1);
|
||
};
|
||
var focusAutofocus = (domCache) => {
|
||
const autofocusElements = Array.from(domCache.popup.querySelectorAll("[autofocus]"));
|
||
for (const autofocusElement of autofocusElements) {
|
||
if (autofocusElement instanceof HTMLElement && isVisible$1(autofocusElement)) {
|
||
autofocusElement.focus();
|
||
return true;
|
||
}
|
||
}
|
||
return false;
|
||
};
|
||
var focusButton = (domCache, innerParams) => {
|
||
if (innerParams.focusDeny && isVisible$1(domCache.denyButton)) {
|
||
domCache.denyButton.focus();
|
||
return true;
|
||
}
|
||
if (innerParams.focusCancel && isVisible$1(domCache.cancelButton)) {
|
||
domCache.cancelButton.focus();
|
||
return true;
|
||
}
|
||
if (innerParams.focusConfirm && isVisible$1(domCache.confirmButton)) {
|
||
domCache.confirmButton.focus();
|
||
return true;
|
||
}
|
||
return false;
|
||
};
|
||
var blurActiveElement = () => {
|
||
if (document.activeElement instanceof HTMLElement && typeof document.activeElement.blur === "function") {
|
||
document.activeElement.blur();
|
||
}
|
||
};
|
||
SweetAlert.prototype.disableButtons = disableButtons;
|
||
SweetAlert.prototype.enableButtons = enableButtons;
|
||
SweetAlert.prototype.getInput = getInput;
|
||
SweetAlert.prototype.disableInput = disableInput;
|
||
SweetAlert.prototype.enableInput = enableInput;
|
||
SweetAlert.prototype.hideLoading = hideLoading;
|
||
SweetAlert.prototype.disableLoading = hideLoading;
|
||
SweetAlert.prototype.showValidationMessage = showValidationMessage;
|
||
SweetAlert.prototype.resetValidationMessage = resetValidationMessage;
|
||
SweetAlert.prototype.close = close;
|
||
SweetAlert.prototype.closePopup = close;
|
||
SweetAlert.prototype.closeModal = close;
|
||
SweetAlert.prototype.closeToast = close;
|
||
SweetAlert.prototype.rejectPromise = rejectPromise;
|
||
SweetAlert.prototype.update = update;
|
||
SweetAlert.prototype._destroy = _destroy;
|
||
Object.assign(SweetAlert, staticMethods);
|
||
Object.keys(instanceMethods).forEach((key) => {
|
||
SweetAlert[key] = function(...args) {
|
||
if (currentInstance && currentInstance[key]) {
|
||
return currentInstance[key](...args);
|
||
}
|
||
return null;
|
||
};
|
||
});
|
||
SweetAlert.DismissReason = DismissReason;
|
||
SweetAlert.version = "11.26.3";
|
||
var Swal = SweetAlert;
|
||
Swal.default = Swal;
|
||
|
||
// frontend/js/vendor/anime.esm.js
|
||
var defaultInstanceSettings = {
|
||
update: null,
|
||
begin: null,
|
||
loopBegin: null,
|
||
changeBegin: null,
|
||
change: null,
|
||
changeComplete: null,
|
||
loopComplete: null,
|
||
complete: null,
|
||
loop: 1,
|
||
direction: "normal",
|
||
autoplay: true,
|
||
timelineOffset: 0
|
||
};
|
||
var defaultTweenSettings = {
|
||
duration: 1e3,
|
||
delay: 0,
|
||
endDelay: 0,
|
||
easing: "easeOutElastic(1, .5)",
|
||
round: 0
|
||
};
|
||
var validTransforms = ["translateX", "translateY", "translateZ", "rotate", "rotateX", "rotateY", "rotateZ", "scale", "scaleX", "scaleY", "scaleZ", "skew", "skewX", "skewY", "perspective", "matrix", "matrix3d"];
|
||
var cache = {
|
||
CSS: {},
|
||
springs: {}
|
||
};
|
||
function minMax(val, min, max) {
|
||
return Math.min(Math.max(val, min), max);
|
||
}
|
||
function stringContains(str, text) {
|
||
return str.indexOf(text) > -1;
|
||
}
|
||
function applyArguments(func, args) {
|
||
return func.apply(null, args);
|
||
}
|
||
var is = {
|
||
arr: function(a) {
|
||
return Array.isArray(a);
|
||
},
|
||
obj: function(a) {
|
||
return stringContains(Object.prototype.toString.call(a), "Object");
|
||
},
|
||
pth: function(a) {
|
||
return is.obj(a) && a.hasOwnProperty("totalLength");
|
||
},
|
||
svg: function(a) {
|
||
return a instanceof SVGElement;
|
||
},
|
||
inp: function(a) {
|
||
return a instanceof HTMLInputElement;
|
||
},
|
||
dom: function(a) {
|
||
return a.nodeType || is.svg(a);
|
||
},
|
||
str: function(a) {
|
||
return typeof a === "string";
|
||
},
|
||
fnc: function(a) {
|
||
return typeof a === "function";
|
||
},
|
||
und: function(a) {
|
||
return typeof a === "undefined";
|
||
},
|
||
nil: function(a) {
|
||
return is.und(a) || a === null;
|
||
},
|
||
hex: function(a) {
|
||
return /(^#[0-9A-F]{6}$)|(^#[0-9A-F]{3}$)/i.test(a);
|
||
},
|
||
rgb: function(a) {
|
||
return /^rgb/.test(a);
|
||
},
|
||
hsl: function(a) {
|
||
return /^hsl/.test(a);
|
||
},
|
||
col: function(a) {
|
||
return is.hex(a) || is.rgb(a) || is.hsl(a);
|
||
},
|
||
key: function(a) {
|
||
return !defaultInstanceSettings.hasOwnProperty(a) && !defaultTweenSettings.hasOwnProperty(a) && a !== "targets" && a !== "keyframes";
|
||
}
|
||
};
|
||
function parseEasingParameters(string) {
|
||
var match = /\(([^)]+)\)/.exec(string);
|
||
return match ? match[1].split(",").map(function(p) {
|
||
return parseFloat(p);
|
||
}) : [];
|
||
}
|
||
function spring(string, duration) {
|
||
var params = parseEasingParameters(string);
|
||
var mass = minMax(is.und(params[0]) ? 1 : params[0], 0.1, 100);
|
||
var stiffness = minMax(is.und(params[1]) ? 100 : params[1], 0.1, 100);
|
||
var damping = minMax(is.und(params[2]) ? 10 : params[2], 0.1, 100);
|
||
var velocity = minMax(is.und(params[3]) ? 0 : params[3], 0.1, 100);
|
||
var w0 = Math.sqrt(stiffness / mass);
|
||
var zeta = damping / (2 * Math.sqrt(stiffness * mass));
|
||
var wd = zeta < 1 ? w0 * Math.sqrt(1 - zeta * zeta) : 0;
|
||
var a = 1;
|
||
var b = zeta < 1 ? (zeta * w0 + -velocity) / wd : -velocity + w0;
|
||
function solver(t) {
|
||
var progress = duration ? duration * t / 1e3 : t;
|
||
if (zeta < 1) {
|
||
progress = Math.exp(-progress * zeta * w0) * (a * Math.cos(wd * progress) + b * Math.sin(wd * progress));
|
||
} else {
|
||
progress = (a + b * progress) * Math.exp(-progress * w0);
|
||
}
|
||
if (t === 0 || t === 1) {
|
||
return t;
|
||
}
|
||
return 1 - progress;
|
||
}
|
||
function getDuration() {
|
||
var cached = cache.springs[string];
|
||
if (cached) {
|
||
return cached;
|
||
}
|
||
var frame = 1 / 6;
|
||
var elapsed = 0;
|
||
var rest = 0;
|
||
while (true) {
|
||
elapsed += frame;
|
||
if (solver(elapsed) === 1) {
|
||
rest++;
|
||
if (rest >= 16) {
|
||
break;
|
||
}
|
||
} else {
|
||
rest = 0;
|
||
}
|
||
}
|
||
var duration2 = elapsed * frame * 1e3;
|
||
cache.springs[string] = duration2;
|
||
return duration2;
|
||
}
|
||
return duration ? solver : getDuration;
|
||
}
|
||
function steps(steps2) {
|
||
if (steps2 === void 0) steps2 = 10;
|
||
return function(t) {
|
||
return Math.ceil(minMax(t, 1e-6, 1) * steps2) * (1 / steps2);
|
||
};
|
||
}
|
||
var bezier = (function() {
|
||
var kSplineTableSize = 11;
|
||
var kSampleStepSize = 1 / (kSplineTableSize - 1);
|
||
function A(aA1, aA2) {
|
||
return 1 - 3 * aA2 + 3 * aA1;
|
||
}
|
||
function B(aA1, aA2) {
|
||
return 3 * aA2 - 6 * aA1;
|
||
}
|
||
function C(aA1) {
|
||
return 3 * aA1;
|
||
}
|
||
function calcBezier(aT, aA1, aA2) {
|
||
return ((A(aA1, aA2) * aT + B(aA1, aA2)) * aT + C(aA1)) * aT;
|
||
}
|
||
function getSlope(aT, aA1, aA2) {
|
||
return 3 * A(aA1, aA2) * aT * aT + 2 * B(aA1, aA2) * aT + C(aA1);
|
||
}
|
||
function binarySubdivide(aX, aA, aB, mX1, mX2) {
|
||
var currentX, currentT, i = 0;
|
||
do {
|
||
currentT = aA + (aB - aA) / 2;
|
||
currentX = calcBezier(currentT, mX1, mX2) - aX;
|
||
if (currentX > 0) {
|
||
aB = currentT;
|
||
} else {
|
||
aA = currentT;
|
||
}
|
||
} while (Math.abs(currentX) > 1e-7 && ++i < 10);
|
||
return currentT;
|
||
}
|
||
function newtonRaphsonIterate(aX, aGuessT, mX1, mX2) {
|
||
for (var i = 0; i < 4; ++i) {
|
||
var currentSlope = getSlope(aGuessT, mX1, mX2);
|
||
if (currentSlope === 0) {
|
||
return aGuessT;
|
||
}
|
||
var currentX = calcBezier(aGuessT, mX1, mX2) - aX;
|
||
aGuessT -= currentX / currentSlope;
|
||
}
|
||
return aGuessT;
|
||
}
|
||
function bezier2(mX1, mY1, mX2, mY2) {
|
||
if (!(0 <= mX1 && mX1 <= 1 && 0 <= mX2 && mX2 <= 1)) {
|
||
return;
|
||
}
|
||
var sampleValues = new Float32Array(kSplineTableSize);
|
||
if (mX1 !== mY1 || mX2 !== mY2) {
|
||
for (var i = 0; i < kSplineTableSize; ++i) {
|
||
sampleValues[i] = calcBezier(i * kSampleStepSize, mX1, mX2);
|
||
}
|
||
}
|
||
function getTForX(aX) {
|
||
var intervalStart = 0;
|
||
var currentSample = 1;
|
||
var lastSample = kSplineTableSize - 1;
|
||
for (; currentSample !== lastSample && sampleValues[currentSample] <= aX; ++currentSample) {
|
||
intervalStart += kSampleStepSize;
|
||
}
|
||
--currentSample;
|
||
var dist = (aX - sampleValues[currentSample]) / (sampleValues[currentSample + 1] - sampleValues[currentSample]);
|
||
var guessForT = intervalStart + dist * kSampleStepSize;
|
||
var initialSlope = getSlope(guessForT, mX1, mX2);
|
||
if (initialSlope >= 1e-3) {
|
||
return newtonRaphsonIterate(aX, guessForT, mX1, mX2);
|
||
} else if (initialSlope === 0) {
|
||
return guessForT;
|
||
} else {
|
||
return binarySubdivide(aX, intervalStart, intervalStart + kSampleStepSize, mX1, mX2);
|
||
}
|
||
}
|
||
return function(x) {
|
||
if (mX1 === mY1 && mX2 === mY2) {
|
||
return x;
|
||
}
|
||
if (x === 0 || x === 1) {
|
||
return x;
|
||
}
|
||
return calcBezier(getTForX(x), mY1, mY2);
|
||
};
|
||
}
|
||
return bezier2;
|
||
})();
|
||
var penner = (function() {
|
||
var eases = { linear: function() {
|
||
return function(t) {
|
||
return t;
|
||
};
|
||
} };
|
||
var functionEasings = {
|
||
Sine: function() {
|
||
return function(t) {
|
||
return 1 - Math.cos(t * Math.PI / 2);
|
||
};
|
||
},
|
||
Expo: function() {
|
||
return function(t) {
|
||
return t ? Math.pow(2, 10 * t - 10) : 0;
|
||
};
|
||
},
|
||
Circ: function() {
|
||
return function(t) {
|
||
return 1 - Math.sqrt(1 - t * t);
|
||
};
|
||
},
|
||
Back: function() {
|
||
return function(t) {
|
||
return t * t * (3 * t - 2);
|
||
};
|
||
},
|
||
Bounce: function() {
|
||
return function(t) {
|
||
var pow2, b = 4;
|
||
while (t < ((pow2 = Math.pow(2, --b)) - 1) / 11) {
|
||
}
|
||
return 1 / Math.pow(4, 3 - b) - 7.5625 * Math.pow((pow2 * 3 - 2) / 22 - t, 2);
|
||
};
|
||
},
|
||
Elastic: function(amplitude, period) {
|
||
if (amplitude === void 0) amplitude = 1;
|
||
if (period === void 0) period = 0.5;
|
||
var a = minMax(amplitude, 1, 10);
|
||
var p = minMax(period, 0.1, 2);
|
||
return function(t) {
|
||
return t === 0 || t === 1 ? t : -a * Math.pow(2, 10 * (t - 1)) * Math.sin((t - 1 - p / (Math.PI * 2) * Math.asin(1 / a)) * (Math.PI * 2) / p);
|
||
};
|
||
}
|
||
};
|
||
var baseEasings = ["Quad", "Cubic", "Quart", "Quint"];
|
||
baseEasings.forEach(function(name, i) {
|
||
functionEasings[name] = function() {
|
||
return function(t) {
|
||
return Math.pow(t, i + 2);
|
||
};
|
||
};
|
||
});
|
||
Object.keys(functionEasings).forEach(function(name) {
|
||
var easeIn = functionEasings[name];
|
||
eases["easeIn" + name] = easeIn;
|
||
eases["easeOut" + name] = function(a, b) {
|
||
return function(t) {
|
||
return 1 - easeIn(a, b)(1 - t);
|
||
};
|
||
};
|
||
eases["easeInOut" + name] = function(a, b) {
|
||
return function(t) {
|
||
return t < 0.5 ? easeIn(a, b)(t * 2) / 2 : 1 - easeIn(a, b)(t * -2 + 2) / 2;
|
||
};
|
||
};
|
||
eases["easeOutIn" + name] = function(a, b) {
|
||
return function(t) {
|
||
return t < 0.5 ? (1 - easeIn(a, b)(1 - t * 2)) / 2 : (easeIn(a, b)(t * 2 - 1) + 1) / 2;
|
||
};
|
||
};
|
||
});
|
||
return eases;
|
||
})();
|
||
function parseEasings(easing, duration) {
|
||
if (is.fnc(easing)) {
|
||
return easing;
|
||
}
|
||
var name = easing.split("(")[0];
|
||
var ease = penner[name];
|
||
var args = parseEasingParameters(easing);
|
||
switch (name) {
|
||
case "spring":
|
||
return spring(easing, duration);
|
||
case "cubicBezier":
|
||
return applyArguments(bezier, args);
|
||
case "steps":
|
||
return applyArguments(steps, args);
|
||
default:
|
||
return applyArguments(ease, args);
|
||
}
|
||
}
|
||
function selectString(str) {
|
||
try {
|
||
var nodes = document.querySelectorAll(str);
|
||
return nodes;
|
||
} catch (e) {
|
||
return;
|
||
}
|
||
}
|
||
function filterArray(arr, callback) {
|
||
var len = arr.length;
|
||
var thisArg = arguments.length >= 2 ? arguments[1] : void 0;
|
||
var result = [];
|
||
for (var i = 0; i < len; i++) {
|
||
if (i in arr) {
|
||
var val = arr[i];
|
||
if (callback.call(thisArg, val, i, arr)) {
|
||
result.push(val);
|
||
}
|
||
}
|
||
}
|
||
return result;
|
||
}
|
||
function flattenArray(arr) {
|
||
return arr.reduce(function(a, b) {
|
||
return a.concat(is.arr(b) ? flattenArray(b) : b);
|
||
}, []);
|
||
}
|
||
function toArray(o) {
|
||
if (is.arr(o)) {
|
||
return o;
|
||
}
|
||
if (is.str(o)) {
|
||
o = selectString(o) || o;
|
||
}
|
||
if (o instanceof NodeList || o instanceof HTMLCollection) {
|
||
return [].slice.call(o);
|
||
}
|
||
return [o];
|
||
}
|
||
function arrayContains(arr, val) {
|
||
return arr.some(function(a) {
|
||
return a === val;
|
||
});
|
||
}
|
||
function cloneObject(o) {
|
||
var clone = {};
|
||
for (var p in o) {
|
||
clone[p] = o[p];
|
||
}
|
||
return clone;
|
||
}
|
||
function replaceObjectProps(o1, o2) {
|
||
var o = cloneObject(o1);
|
||
for (var p in o1) {
|
||
o[p] = o2.hasOwnProperty(p) ? o2[p] : o1[p];
|
||
}
|
||
return o;
|
||
}
|
||
function mergeObjects(o1, o2) {
|
||
var o = cloneObject(o1);
|
||
for (var p in o2) {
|
||
o[p] = is.und(o1[p]) ? o2[p] : o1[p];
|
||
}
|
||
return o;
|
||
}
|
||
function rgbToRgba(rgbValue) {
|
||
var rgb = /rgb\((\d+,\s*[\d]+,\s*[\d]+)\)/g.exec(rgbValue);
|
||
return rgb ? "rgba(" + rgb[1] + ",1)" : rgbValue;
|
||
}
|
||
function hexToRgba(hexValue) {
|
||
var rgx = /^#?([a-f\d])([a-f\d])([a-f\d])$/i;
|
||
var hex = hexValue.replace(rgx, function(m, r2, g2, b2) {
|
||
return r2 + r2 + g2 + g2 + b2 + b2;
|
||
});
|
||
var rgb = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);
|
||
var r = parseInt(rgb[1], 16);
|
||
var g = parseInt(rgb[2], 16);
|
||
var b = parseInt(rgb[3], 16);
|
||
return "rgba(" + r + "," + g + "," + b + ",1)";
|
||
}
|
||
function hslToRgba(hslValue) {
|
||
var hsl = /hsl\((\d+),\s*([\d.]+)%,\s*([\d.]+)%\)/g.exec(hslValue) || /hsla\((\d+),\s*([\d.]+)%,\s*([\d.]+)%,\s*([\d.]+)\)/g.exec(hslValue);
|
||
var h = parseInt(hsl[1], 10) / 360;
|
||
var s = parseInt(hsl[2], 10) / 100;
|
||
var l = parseInt(hsl[3], 10) / 100;
|
||
var a = hsl[4] || 1;
|
||
function hue2rgb(p2, q2, t) {
|
||
if (t < 0) {
|
||
t += 1;
|
||
}
|
||
if (t > 1) {
|
||
t -= 1;
|
||
}
|
||
if (t < 1 / 6) {
|
||
return p2 + (q2 - p2) * 6 * t;
|
||
}
|
||
if (t < 1 / 2) {
|
||
return q2;
|
||
}
|
||
if (t < 2 / 3) {
|
||
return p2 + (q2 - p2) * (2 / 3 - t) * 6;
|
||
}
|
||
return p2;
|
||
}
|
||
var r, g, b;
|
||
if (s == 0) {
|
||
r = g = b = l;
|
||
} else {
|
||
var q = l < 0.5 ? l * (1 + s) : l + s - l * s;
|
||
var p = 2 * l - q;
|
||
r = hue2rgb(p, q, h + 1 / 3);
|
||
g = hue2rgb(p, q, h);
|
||
b = hue2rgb(p, q, h - 1 / 3);
|
||
}
|
||
return "rgba(" + r * 255 + "," + g * 255 + "," + b * 255 + "," + a + ")";
|
||
}
|
||
function colorToRgb(val) {
|
||
if (is.rgb(val)) {
|
||
return rgbToRgba(val);
|
||
}
|
||
if (is.hex(val)) {
|
||
return hexToRgba(val);
|
||
}
|
||
if (is.hsl(val)) {
|
||
return hslToRgba(val);
|
||
}
|
||
}
|
||
function getUnit(val) {
|
||
var split = /[+-]?\d*\.?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?(%|px|pt|em|rem|in|cm|mm|ex|ch|pc|vw|vh|vmin|vmax|deg|rad|turn)?$/.exec(val);
|
||
if (split) {
|
||
return split[1];
|
||
}
|
||
}
|
||
function getTransformUnit(propName) {
|
||
if (stringContains(propName, "translate") || propName === "perspective") {
|
||
return "px";
|
||
}
|
||
if (stringContains(propName, "rotate") || stringContains(propName, "skew")) {
|
||
return "deg";
|
||
}
|
||
}
|
||
function getFunctionValue(val, animatable) {
|
||
if (!is.fnc(val)) {
|
||
return val;
|
||
}
|
||
return val(animatable.target, animatable.id, animatable.total);
|
||
}
|
||
function getAttribute(el, prop) {
|
||
return el.getAttribute(prop);
|
||
}
|
||
function convertPxToUnit(el, value, unit) {
|
||
var valueUnit = getUnit(value);
|
||
if (arrayContains([unit, "deg", "rad", "turn"], valueUnit)) {
|
||
return value;
|
||
}
|
||
var cached = cache.CSS[value + unit];
|
||
if (!is.und(cached)) {
|
||
return cached;
|
||
}
|
||
var baseline = 100;
|
||
var tempEl = document.createElement(el.tagName);
|
||
var parentEl = el.parentNode && el.parentNode !== document ? el.parentNode : document.body;
|
||
parentEl.appendChild(tempEl);
|
||
tempEl.style.position = "absolute";
|
||
tempEl.style.width = baseline + unit;
|
||
var factor = baseline / tempEl.offsetWidth;
|
||
parentEl.removeChild(tempEl);
|
||
var convertedUnit = factor * parseFloat(value);
|
||
cache.CSS[value + unit] = convertedUnit;
|
||
return convertedUnit;
|
||
}
|
||
function getCSSValue(el, prop, unit) {
|
||
if (prop in el.style) {
|
||
var uppercasePropName = prop.replace(/([a-z])([A-Z])/g, "$1-$2").toLowerCase();
|
||
var value = el.style[prop] || getComputedStyle(el).getPropertyValue(uppercasePropName) || "0";
|
||
return unit ? convertPxToUnit(el, value, unit) : value;
|
||
}
|
||
}
|
||
function getAnimationType(el, prop) {
|
||
if (is.dom(el) && !is.inp(el) && (!is.nil(getAttribute(el, prop)) || is.svg(el) && el[prop])) {
|
||
return "attribute";
|
||
}
|
||
if (is.dom(el) && arrayContains(validTransforms, prop)) {
|
||
return "transform";
|
||
}
|
||
if (is.dom(el) && (prop !== "transform" && getCSSValue(el, prop))) {
|
||
return "css";
|
||
}
|
||
if (el[prop] != null) {
|
||
return "object";
|
||
}
|
||
}
|
||
function getElementTransforms(el) {
|
||
if (!is.dom(el)) {
|
||
return;
|
||
}
|
||
var str = el.style.transform || "";
|
||
var reg = /(\w+)\(([^)]*)\)/g;
|
||
var transforms = /* @__PURE__ */ new Map();
|
||
var m;
|
||
while (m = reg.exec(str)) {
|
||
transforms.set(m[1], m[2]);
|
||
}
|
||
return transforms;
|
||
}
|
||
function getTransformValue(el, propName, animatable, unit) {
|
||
var defaultVal = stringContains(propName, "scale") ? 1 : 0 + getTransformUnit(propName);
|
||
var value = getElementTransforms(el).get(propName) || defaultVal;
|
||
if (animatable) {
|
||
animatable.transforms.list.set(propName, value);
|
||
animatable.transforms["last"] = propName;
|
||
}
|
||
return unit ? convertPxToUnit(el, value, unit) : value;
|
||
}
|
||
function getOriginalTargetValue(target, propName, unit, animatable) {
|
||
switch (getAnimationType(target, propName)) {
|
||
case "transform":
|
||
return getTransformValue(target, propName, animatable, unit);
|
||
case "css":
|
||
return getCSSValue(target, propName, unit);
|
||
case "attribute":
|
||
return getAttribute(target, propName);
|
||
default:
|
||
return target[propName] || 0;
|
||
}
|
||
}
|
||
function getRelativeValue(to, from) {
|
||
var operator = /^(\*=|\+=|-=)/.exec(to);
|
||
if (!operator) {
|
||
return to;
|
||
}
|
||
var u = getUnit(to) || 0;
|
||
var x = parseFloat(from);
|
||
var y = parseFloat(to.replace(operator[0], ""));
|
||
switch (operator[0][0]) {
|
||
case "+":
|
||
return x + y + u;
|
||
case "-":
|
||
return x - y + u;
|
||
case "*":
|
||
return x * y + u;
|
||
}
|
||
}
|
||
function validateValue(val, unit) {
|
||
if (is.col(val)) {
|
||
return colorToRgb(val);
|
||
}
|
||
if (/\s/g.test(val)) {
|
||
return val;
|
||
}
|
||
var originalUnit = getUnit(val);
|
||
var unitLess = originalUnit ? val.substr(0, val.length - originalUnit.length) : val;
|
||
if (unit) {
|
||
return unitLess + unit;
|
||
}
|
||
return unitLess;
|
||
}
|
||
function getDistance(p1, p2) {
|
||
return Math.sqrt(Math.pow(p2.x - p1.x, 2) + Math.pow(p2.y - p1.y, 2));
|
||
}
|
||
function getCircleLength(el) {
|
||
return Math.PI * 2 * getAttribute(el, "r");
|
||
}
|
||
function getRectLength(el) {
|
||
return getAttribute(el, "width") * 2 + getAttribute(el, "height") * 2;
|
||
}
|
||
function getLineLength(el) {
|
||
return getDistance(
|
||
{ x: getAttribute(el, "x1"), y: getAttribute(el, "y1") },
|
||
{ x: getAttribute(el, "x2"), y: getAttribute(el, "y2") }
|
||
);
|
||
}
|
||
function getPolylineLength(el) {
|
||
var points = el.points;
|
||
var totalLength = 0;
|
||
var previousPos;
|
||
for (var i = 0; i < points.numberOfItems; i++) {
|
||
var currentPos = points.getItem(i);
|
||
if (i > 0) {
|
||
totalLength += getDistance(previousPos, currentPos);
|
||
}
|
||
previousPos = currentPos;
|
||
}
|
||
return totalLength;
|
||
}
|
||
function getPolygonLength(el) {
|
||
var points = el.points;
|
||
return getPolylineLength(el) + getDistance(points.getItem(points.numberOfItems - 1), points.getItem(0));
|
||
}
|
||
function getTotalLength(el) {
|
||
if (el.getTotalLength) {
|
||
return el.getTotalLength();
|
||
}
|
||
switch (el.tagName.toLowerCase()) {
|
||
case "circle":
|
||
return getCircleLength(el);
|
||
case "rect":
|
||
return getRectLength(el);
|
||
case "line":
|
||
return getLineLength(el);
|
||
case "polyline":
|
||
return getPolylineLength(el);
|
||
case "polygon":
|
||
return getPolygonLength(el);
|
||
}
|
||
}
|
||
function setDashoffset(el) {
|
||
var pathLength = getTotalLength(el);
|
||
el.setAttribute("stroke-dasharray", pathLength);
|
||
return pathLength;
|
||
}
|
||
function getParentSvgEl(el) {
|
||
var parentEl = el.parentNode;
|
||
while (is.svg(parentEl)) {
|
||
if (!is.svg(parentEl.parentNode)) {
|
||
break;
|
||
}
|
||
parentEl = parentEl.parentNode;
|
||
}
|
||
return parentEl;
|
||
}
|
||
function getParentSvg(pathEl, svgData) {
|
||
var svg = svgData || {};
|
||
var parentSvgEl = svg.el || getParentSvgEl(pathEl);
|
||
var rect = parentSvgEl.getBoundingClientRect();
|
||
var viewBoxAttr = getAttribute(parentSvgEl, "viewBox");
|
||
var width = rect.width;
|
||
var height = rect.height;
|
||
var viewBox = svg.viewBox || (viewBoxAttr ? viewBoxAttr.split(" ") : [0, 0, width, height]);
|
||
return {
|
||
el: parentSvgEl,
|
||
viewBox,
|
||
x: viewBox[0] / 1,
|
||
y: viewBox[1] / 1,
|
||
w: width,
|
||
h: height,
|
||
vW: viewBox[2],
|
||
vH: viewBox[3]
|
||
};
|
||
}
|
||
function getPath(path, percent) {
|
||
var pathEl = is.str(path) ? selectString(path)[0] : path;
|
||
var p = percent || 100;
|
||
return function(property) {
|
||
return {
|
||
property,
|
||
el: pathEl,
|
||
svg: getParentSvg(pathEl),
|
||
totalLength: getTotalLength(pathEl) * (p / 100)
|
||
};
|
||
};
|
||
}
|
||
function getPathProgress(path, progress, isPathTargetInsideSVG) {
|
||
function point(offset) {
|
||
if (offset === void 0) offset = 0;
|
||
var l = progress + offset >= 1 ? progress + offset : 0;
|
||
return path.el.getPointAtLength(l);
|
||
}
|
||
var svg = getParentSvg(path.el, path.svg);
|
||
var p = point();
|
||
var p0 = point(-1);
|
||
var p1 = point(1);
|
||
var scaleX = isPathTargetInsideSVG ? 1 : svg.w / svg.vW;
|
||
var scaleY = isPathTargetInsideSVG ? 1 : svg.h / svg.vH;
|
||
switch (path.property) {
|
||
case "x":
|
||
return (p.x - svg.x) * scaleX;
|
||
case "y":
|
||
return (p.y - svg.y) * scaleY;
|
||
case "angle":
|
||
return Math.atan2(p1.y - p0.y, p1.x - p0.x) * 180 / Math.PI;
|
||
}
|
||
}
|
||
function decomposeValue(val, unit) {
|
||
var rgx = /[+-]?\d*\.?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?/g;
|
||
var value = validateValue(is.pth(val) ? val.totalLength : val, unit) + "";
|
||
return {
|
||
original: value,
|
||
numbers: value.match(rgx) ? value.match(rgx).map(Number) : [0],
|
||
strings: is.str(val) || unit ? value.split(rgx) : []
|
||
};
|
||
}
|
||
function parseTargets(targets) {
|
||
var targetsArray = targets ? flattenArray(is.arr(targets) ? targets.map(toArray) : toArray(targets)) : [];
|
||
return filterArray(targetsArray, function(item, pos, self) {
|
||
return self.indexOf(item) === pos;
|
||
});
|
||
}
|
||
function getAnimatables(targets) {
|
||
var parsed = parseTargets(targets);
|
||
return parsed.map(function(t, i) {
|
||
return { target: t, id: i, total: parsed.length, transforms: { list: getElementTransforms(t) } };
|
||
});
|
||
}
|
||
function normalizePropertyTweens(prop, tweenSettings) {
|
||
var settings = cloneObject(tweenSettings);
|
||
if (/^spring/.test(settings.easing)) {
|
||
settings.duration = spring(settings.easing);
|
||
}
|
||
if (is.arr(prop)) {
|
||
var l = prop.length;
|
||
var isFromTo = l === 2 && !is.obj(prop[0]);
|
||
if (!isFromTo) {
|
||
if (!is.fnc(tweenSettings.duration)) {
|
||
settings.duration = tweenSettings.duration / l;
|
||
}
|
||
} else {
|
||
prop = { value: prop };
|
||
}
|
||
}
|
||
var propArray = is.arr(prop) ? prop : [prop];
|
||
return propArray.map(function(v, i) {
|
||
var obj = is.obj(v) && !is.pth(v) ? v : { value: v };
|
||
if (is.und(obj.delay)) {
|
||
obj.delay = !i ? tweenSettings.delay : 0;
|
||
}
|
||
if (is.und(obj.endDelay)) {
|
||
obj.endDelay = i === propArray.length - 1 ? tweenSettings.endDelay : 0;
|
||
}
|
||
return obj;
|
||
}).map(function(k) {
|
||
return mergeObjects(k, settings);
|
||
});
|
||
}
|
||
function flattenKeyframes(keyframes) {
|
||
var propertyNames = filterArray(flattenArray(keyframes.map(function(key) {
|
||
return Object.keys(key);
|
||
})), function(p) {
|
||
return is.key(p);
|
||
}).reduce(function(a, b) {
|
||
if (a.indexOf(b) < 0) {
|
||
a.push(b);
|
||
}
|
||
return a;
|
||
}, []);
|
||
var properties = {};
|
||
var loop = function(i2) {
|
||
var propName = propertyNames[i2];
|
||
properties[propName] = keyframes.map(function(key) {
|
||
var newKey = {};
|
||
for (var p in key) {
|
||
if (is.key(p)) {
|
||
if (p == propName) {
|
||
newKey.value = key[p];
|
||
}
|
||
} else {
|
||
newKey[p] = key[p];
|
||
}
|
||
}
|
||
return newKey;
|
||
});
|
||
};
|
||
for (var i = 0; i < propertyNames.length; i++) loop(i);
|
||
return properties;
|
||
}
|
||
function getProperties(tweenSettings, params) {
|
||
var properties = [];
|
||
var keyframes = params.keyframes;
|
||
if (keyframes) {
|
||
params = mergeObjects(flattenKeyframes(keyframes), params);
|
||
}
|
||
for (var p in params) {
|
||
if (is.key(p)) {
|
||
properties.push({
|
||
name: p,
|
||
tweens: normalizePropertyTweens(params[p], tweenSettings)
|
||
});
|
||
}
|
||
}
|
||
return properties;
|
||
}
|
||
function normalizeTweenValues(tween, animatable) {
|
||
var t = {};
|
||
for (var p in tween) {
|
||
var value = getFunctionValue(tween[p], animatable);
|
||
if (is.arr(value)) {
|
||
value = value.map(function(v) {
|
||
return getFunctionValue(v, animatable);
|
||
});
|
||
if (value.length === 1) {
|
||
value = value[0];
|
||
}
|
||
}
|
||
t[p] = value;
|
||
}
|
||
t.duration = parseFloat(t.duration);
|
||
t.delay = parseFloat(t.delay);
|
||
return t;
|
||
}
|
||
function normalizeTweens(prop, animatable) {
|
||
var previousTween;
|
||
return prop.tweens.map(function(t) {
|
||
var tween = normalizeTweenValues(t, animatable);
|
||
var tweenValue = tween.value;
|
||
var to = is.arr(tweenValue) ? tweenValue[1] : tweenValue;
|
||
var toUnit = getUnit(to);
|
||
var originalValue = getOriginalTargetValue(animatable.target, prop.name, toUnit, animatable);
|
||
var previousValue = previousTween ? previousTween.to.original : originalValue;
|
||
var from = is.arr(tweenValue) ? tweenValue[0] : previousValue;
|
||
var fromUnit = getUnit(from) || getUnit(originalValue);
|
||
var unit = toUnit || fromUnit;
|
||
if (is.und(to)) {
|
||
to = previousValue;
|
||
}
|
||
tween.from = decomposeValue(from, unit);
|
||
tween.to = decomposeValue(getRelativeValue(to, from), unit);
|
||
tween.start = previousTween ? previousTween.end : 0;
|
||
tween.end = tween.start + tween.delay + tween.duration + tween.endDelay;
|
||
tween.easing = parseEasings(tween.easing, tween.duration);
|
||
tween.isPath = is.pth(tweenValue);
|
||
tween.isPathTargetInsideSVG = tween.isPath && is.svg(animatable.target);
|
||
tween.isColor = is.col(tween.from.original);
|
||
if (tween.isColor) {
|
||
tween.round = 1;
|
||
}
|
||
previousTween = tween;
|
||
return tween;
|
||
});
|
||
}
|
||
var setProgressValue = {
|
||
css: function(t, p, v) {
|
||
return t.style[p] = v;
|
||
},
|
||
attribute: function(t, p, v) {
|
||
return t.setAttribute(p, v);
|
||
},
|
||
object: function(t, p, v) {
|
||
return t[p] = v;
|
||
},
|
||
transform: function(t, p, v, transforms, manual) {
|
||
transforms.list.set(p, v);
|
||
if (p === transforms.last || manual) {
|
||
var str = "";
|
||
transforms.list.forEach(function(value, prop) {
|
||
str += prop + "(" + value + ") ";
|
||
});
|
||
t.style.transform = str;
|
||
}
|
||
}
|
||
};
|
||
function setTargetsValue(targets, properties) {
|
||
var animatables = getAnimatables(targets);
|
||
animatables.forEach(function(animatable) {
|
||
for (var property in properties) {
|
||
var value = getFunctionValue(properties[property], animatable);
|
||
var target = animatable.target;
|
||
var valueUnit = getUnit(value);
|
||
var originalValue = getOriginalTargetValue(target, property, valueUnit, animatable);
|
||
var unit = valueUnit || getUnit(originalValue);
|
||
var to = getRelativeValue(validateValue(value, unit), originalValue);
|
||
var animType = getAnimationType(target, property);
|
||
setProgressValue[animType](target, property, to, animatable.transforms, true);
|
||
}
|
||
});
|
||
}
|
||
function createAnimation(animatable, prop) {
|
||
var animType = getAnimationType(animatable.target, prop.name);
|
||
if (animType) {
|
||
var tweens = normalizeTweens(prop, animatable);
|
||
var lastTween = tweens[tweens.length - 1];
|
||
return {
|
||
type: animType,
|
||
property: prop.name,
|
||
animatable,
|
||
tweens,
|
||
duration: lastTween.end,
|
||
delay: tweens[0].delay,
|
||
endDelay: lastTween.endDelay
|
||
};
|
||
}
|
||
}
|
||
function getAnimations(animatables, properties) {
|
||
return filterArray(flattenArray(animatables.map(function(animatable) {
|
||
return properties.map(function(prop) {
|
||
return createAnimation(animatable, prop);
|
||
});
|
||
})), function(a) {
|
||
return !is.und(a);
|
||
});
|
||
}
|
||
function getInstanceTimings(animations, tweenSettings) {
|
||
var animLength = animations.length;
|
||
var getTlOffset = function(anim) {
|
||
return anim.timelineOffset ? anim.timelineOffset : 0;
|
||
};
|
||
var timings = {};
|
||
timings.duration = animLength ? Math.max.apply(Math, animations.map(function(anim) {
|
||
return getTlOffset(anim) + anim.duration;
|
||
})) : tweenSettings.duration;
|
||
timings.delay = animLength ? Math.min.apply(Math, animations.map(function(anim) {
|
||
return getTlOffset(anim) + anim.delay;
|
||
})) : tweenSettings.delay;
|
||
timings.endDelay = animLength ? timings.duration - Math.max.apply(Math, animations.map(function(anim) {
|
||
return getTlOffset(anim) + anim.duration - anim.endDelay;
|
||
})) : tweenSettings.endDelay;
|
||
return timings;
|
||
}
|
||
var instanceID = 0;
|
||
function createNewInstance(params) {
|
||
var instanceSettings = replaceObjectProps(defaultInstanceSettings, params);
|
||
var tweenSettings = replaceObjectProps(defaultTweenSettings, params);
|
||
var properties = getProperties(tweenSettings, params);
|
||
var animatables = getAnimatables(params.targets);
|
||
var animations = getAnimations(animatables, properties);
|
||
var timings = getInstanceTimings(animations, tweenSettings);
|
||
var id = instanceID;
|
||
instanceID++;
|
||
return mergeObjects(instanceSettings, {
|
||
id,
|
||
children: [],
|
||
animatables,
|
||
animations,
|
||
duration: timings.duration,
|
||
delay: timings.delay,
|
||
endDelay: timings.endDelay
|
||
});
|
||
}
|
||
var activeInstances = [];
|
||
var engine = (function() {
|
||
var raf;
|
||
function play() {
|
||
if (!raf && (!isDocumentHidden() || !anime.suspendWhenDocumentHidden) && activeInstances.length > 0) {
|
||
raf = requestAnimationFrame(step);
|
||
}
|
||
}
|
||
function step(t) {
|
||
var activeInstancesLength = activeInstances.length;
|
||
var i = 0;
|
||
while (i < activeInstancesLength) {
|
||
var activeInstance = activeInstances[i];
|
||
if (!activeInstance.paused) {
|
||
activeInstance.tick(t);
|
||
i++;
|
||
} else {
|
||
activeInstances.splice(i, 1);
|
||
activeInstancesLength--;
|
||
}
|
||
}
|
||
raf = i > 0 ? requestAnimationFrame(step) : void 0;
|
||
}
|
||
function handleVisibilityChange() {
|
||
if (!anime.suspendWhenDocumentHidden) {
|
||
return;
|
||
}
|
||
if (isDocumentHidden()) {
|
||
raf = cancelAnimationFrame(raf);
|
||
} else {
|
||
activeInstances.forEach(
|
||
function(instance) {
|
||
return instance._onDocumentVisibility();
|
||
}
|
||
);
|
||
engine();
|
||
}
|
||
}
|
||
if (typeof document !== "undefined") {
|
||
document.addEventListener("visibilitychange", handleVisibilityChange);
|
||
}
|
||
return play;
|
||
})();
|
||
function isDocumentHidden() {
|
||
return !!document && document.hidden;
|
||
}
|
||
function anime(params) {
|
||
if (params === void 0) params = {};
|
||
var startTime = 0, lastTime = 0, now = 0;
|
||
var children, childrenLength = 0;
|
||
var resolve = null;
|
||
function makePromise(instance2) {
|
||
var promise2 = window.Promise && new Promise(function(_resolve) {
|
||
return resolve = _resolve;
|
||
});
|
||
instance2.finished = promise2;
|
||
return promise2;
|
||
}
|
||
var instance = createNewInstance(params);
|
||
var promise = makePromise(instance);
|
||
function toggleInstanceDirection() {
|
||
var direction = instance.direction;
|
||
if (direction !== "alternate") {
|
||
instance.direction = direction !== "normal" ? "normal" : "reverse";
|
||
}
|
||
instance.reversed = !instance.reversed;
|
||
children.forEach(function(child) {
|
||
return child.reversed = instance.reversed;
|
||
});
|
||
}
|
||
function adjustTime(time) {
|
||
return instance.reversed ? instance.duration - time : time;
|
||
}
|
||
function resetTime() {
|
||
startTime = 0;
|
||
lastTime = adjustTime(instance.currentTime) * (1 / anime.speed);
|
||
}
|
||
function seekChild(time, child) {
|
||
if (child) {
|
||
child.seek(time - child.timelineOffset);
|
||
}
|
||
}
|
||
function syncInstanceChildren(time) {
|
||
if (!instance.reversePlayback) {
|
||
for (var i = 0; i < childrenLength; i++) {
|
||
seekChild(time, children[i]);
|
||
}
|
||
} else {
|
||
for (var i$1 = childrenLength; i$1--; ) {
|
||
seekChild(time, children[i$1]);
|
||
}
|
||
}
|
||
}
|
||
function setAnimationsProgress(insTime) {
|
||
var i = 0;
|
||
var animations = instance.animations;
|
||
var animationsLength = animations.length;
|
||
while (i < animationsLength) {
|
||
var anim = animations[i];
|
||
var animatable = anim.animatable;
|
||
var tweens = anim.tweens;
|
||
var tweenLength = tweens.length - 1;
|
||
var tween = tweens[tweenLength];
|
||
if (tweenLength) {
|
||
tween = filterArray(tweens, function(t) {
|
||
return insTime < t.end;
|
||
})[0] || tween;
|
||
}
|
||
var elapsed = minMax(insTime - tween.start - tween.delay, 0, tween.duration) / tween.duration;
|
||
var eased = isNaN(elapsed) ? 1 : tween.easing(elapsed);
|
||
var strings = tween.to.strings;
|
||
var round = tween.round;
|
||
var numbers = [];
|
||
var toNumbersLength = tween.to.numbers.length;
|
||
var progress = void 0;
|
||
for (var n = 0; n < toNumbersLength; n++) {
|
||
var value = void 0;
|
||
var toNumber = tween.to.numbers[n];
|
||
var fromNumber = tween.from.numbers[n] || 0;
|
||
if (!tween.isPath) {
|
||
value = fromNumber + eased * (toNumber - fromNumber);
|
||
} else {
|
||
value = getPathProgress(tween.value, eased * toNumber, tween.isPathTargetInsideSVG);
|
||
}
|
||
if (round) {
|
||
if (!(tween.isColor && n > 2)) {
|
||
value = Math.round(value * round) / round;
|
||
}
|
||
}
|
||
numbers.push(value);
|
||
}
|
||
var stringsLength = strings.length;
|
||
if (!stringsLength) {
|
||
progress = numbers[0];
|
||
} else {
|
||
progress = strings[0];
|
||
for (var s = 0; s < stringsLength; s++) {
|
||
var a = strings[s];
|
||
var b = strings[s + 1];
|
||
var n$1 = numbers[s];
|
||
if (!isNaN(n$1)) {
|
||
if (!b) {
|
||
progress += n$1 + " ";
|
||
} else {
|
||
progress += n$1 + b;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
setProgressValue[anim.type](animatable.target, anim.property, progress, animatable.transforms);
|
||
anim.currentValue = progress;
|
||
i++;
|
||
}
|
||
}
|
||
function setCallback(cb) {
|
||
if (instance[cb] && !instance.passThrough) {
|
||
instance[cb](instance);
|
||
}
|
||
}
|
||
function countIteration() {
|
||
if (instance.remaining && instance.remaining !== true) {
|
||
instance.remaining--;
|
||
}
|
||
}
|
||
function setInstanceProgress(engineTime) {
|
||
var insDuration = instance.duration;
|
||
var insDelay = instance.delay;
|
||
var insEndDelay = insDuration - instance.endDelay;
|
||
var insTime = adjustTime(engineTime);
|
||
instance.progress = minMax(insTime / insDuration * 100, 0, 100);
|
||
instance.reversePlayback = insTime < instance.currentTime;
|
||
if (children) {
|
||
syncInstanceChildren(insTime);
|
||
}
|
||
if (!instance.began && instance.currentTime > 0) {
|
||
instance.began = true;
|
||
setCallback("begin");
|
||
}
|
||
if (!instance.loopBegan && instance.currentTime > 0) {
|
||
instance.loopBegan = true;
|
||
setCallback("loopBegin");
|
||
}
|
||
if (insTime <= insDelay && instance.currentTime !== 0) {
|
||
setAnimationsProgress(0);
|
||
}
|
||
if (insTime >= insEndDelay && instance.currentTime !== insDuration || !insDuration) {
|
||
setAnimationsProgress(insDuration);
|
||
}
|
||
if (insTime > insDelay && insTime < insEndDelay) {
|
||
if (!instance.changeBegan) {
|
||
instance.changeBegan = true;
|
||
instance.changeCompleted = false;
|
||
setCallback("changeBegin");
|
||
}
|
||
setCallback("change");
|
||
setAnimationsProgress(insTime);
|
||
} else {
|
||
if (instance.changeBegan) {
|
||
instance.changeCompleted = true;
|
||
instance.changeBegan = false;
|
||
setCallback("changeComplete");
|
||
}
|
||
}
|
||
instance.currentTime = minMax(insTime, 0, insDuration);
|
||
if (instance.began) {
|
||
setCallback("update");
|
||
}
|
||
if (engineTime >= insDuration) {
|
||
lastTime = 0;
|
||
countIteration();
|
||
if (!instance.remaining) {
|
||
instance.paused = true;
|
||
if (!instance.completed) {
|
||
instance.completed = true;
|
||
setCallback("loopComplete");
|
||
setCallback("complete");
|
||
if (!instance.passThrough && "Promise" in window) {
|
||
resolve();
|
||
promise = makePromise(instance);
|
||
}
|
||
}
|
||
} else {
|
||
startTime = now;
|
||
setCallback("loopComplete");
|
||
instance.loopBegan = false;
|
||
if (instance.direction === "alternate") {
|
||
toggleInstanceDirection();
|
||
}
|
||
}
|
||
}
|
||
}
|
||
instance.reset = function() {
|
||
var direction = instance.direction;
|
||
instance.passThrough = false;
|
||
instance.currentTime = 0;
|
||
instance.progress = 0;
|
||
instance.paused = true;
|
||
instance.began = false;
|
||
instance.loopBegan = false;
|
||
instance.changeBegan = false;
|
||
instance.completed = false;
|
||
instance.changeCompleted = false;
|
||
instance.reversePlayback = false;
|
||
instance.reversed = direction === "reverse";
|
||
instance.remaining = instance.loop;
|
||
children = instance.children;
|
||
childrenLength = children.length;
|
||
for (var i = childrenLength; i--; ) {
|
||
instance.children[i].reset();
|
||
}
|
||
if (instance.reversed && instance.loop !== true || direction === "alternate" && instance.loop === 1) {
|
||
instance.remaining++;
|
||
}
|
||
setAnimationsProgress(instance.reversed ? instance.duration : 0);
|
||
};
|
||
instance._onDocumentVisibility = resetTime;
|
||
instance.set = function(targets, properties) {
|
||
setTargetsValue(targets, properties);
|
||
return instance;
|
||
};
|
||
instance.tick = function(t) {
|
||
now = t;
|
||
if (!startTime) {
|
||
startTime = now;
|
||
}
|
||
setInstanceProgress((now + (lastTime - startTime)) * anime.speed);
|
||
};
|
||
instance.seek = function(time) {
|
||
setInstanceProgress(adjustTime(time));
|
||
};
|
||
instance.pause = function() {
|
||
instance.paused = true;
|
||
resetTime();
|
||
};
|
||
instance.play = function() {
|
||
if (!instance.paused) {
|
||
return;
|
||
}
|
||
if (instance.completed) {
|
||
instance.reset();
|
||
}
|
||
instance.paused = false;
|
||
activeInstances.push(instance);
|
||
resetTime();
|
||
engine();
|
||
};
|
||
instance.reverse = function() {
|
||
toggleInstanceDirection();
|
||
instance.completed = instance.reversed ? false : true;
|
||
resetTime();
|
||
};
|
||
instance.restart = function() {
|
||
instance.reset();
|
||
instance.play();
|
||
};
|
||
instance.remove = function(targets) {
|
||
var targetsArray = parseTargets(targets);
|
||
removeTargetsFromInstance(targetsArray, instance);
|
||
};
|
||
instance.reset();
|
||
if (instance.autoplay) {
|
||
instance.play();
|
||
}
|
||
return instance;
|
||
}
|
||
function removeTargetsFromAnimations(targetsArray, animations) {
|
||
for (var a = animations.length; a--; ) {
|
||
if (arrayContains(targetsArray, animations[a].animatable.target)) {
|
||
animations.splice(a, 1);
|
||
}
|
||
}
|
||
}
|
||
function removeTargetsFromInstance(targetsArray, instance) {
|
||
var animations = instance.animations;
|
||
var children = instance.children;
|
||
removeTargetsFromAnimations(targetsArray, animations);
|
||
for (var c = children.length; c--; ) {
|
||
var child = children[c];
|
||
var childAnimations = child.animations;
|
||
removeTargetsFromAnimations(targetsArray, childAnimations);
|
||
if (!childAnimations.length && !child.children.length) {
|
||
children.splice(c, 1);
|
||
}
|
||
}
|
||
if (!animations.length && !children.length) {
|
||
instance.pause();
|
||
}
|
||
}
|
||
function removeTargetsFromActiveInstances(targets) {
|
||
var targetsArray = parseTargets(targets);
|
||
for (var i = activeInstances.length; i--; ) {
|
||
var instance = activeInstances[i];
|
||
removeTargetsFromInstance(targetsArray, instance);
|
||
}
|
||
}
|
||
function stagger(val, params) {
|
||
if (params === void 0) params = {};
|
||
var direction = params.direction || "normal";
|
||
var easing = params.easing ? parseEasings(params.easing) : null;
|
||
var grid = params.grid;
|
||
var axis = params.axis;
|
||
var fromIndex = params.from || 0;
|
||
var fromFirst = fromIndex === "first";
|
||
var fromCenter = fromIndex === "center";
|
||
var fromLast = fromIndex === "last";
|
||
var isRange = is.arr(val);
|
||
var val1 = isRange ? parseFloat(val[0]) : parseFloat(val);
|
||
var val2 = isRange ? parseFloat(val[1]) : 0;
|
||
var unit = getUnit(isRange ? val[1] : val) || 0;
|
||
var start = params.start || 0 + (isRange ? val1 : 0);
|
||
var values = [];
|
||
var maxValue = 0;
|
||
return function(el, i, t) {
|
||
if (fromFirst) {
|
||
fromIndex = 0;
|
||
}
|
||
if (fromCenter) {
|
||
fromIndex = (t - 1) / 2;
|
||
}
|
||
if (fromLast) {
|
||
fromIndex = t - 1;
|
||
}
|
||
if (!values.length) {
|
||
for (var index = 0; index < t; index++) {
|
||
if (!grid) {
|
||
values.push(Math.abs(fromIndex - index));
|
||
} else {
|
||
var fromX = !fromCenter ? fromIndex % grid[0] : (grid[0] - 1) / 2;
|
||
var fromY = !fromCenter ? Math.floor(fromIndex / grid[0]) : (grid[1] - 1) / 2;
|
||
var toX = index % grid[0];
|
||
var toY = Math.floor(index / grid[0]);
|
||
var distanceX = fromX - toX;
|
||
var distanceY = fromY - toY;
|
||
var value = Math.sqrt(distanceX * distanceX + distanceY * distanceY);
|
||
if (axis === "x") {
|
||
value = -distanceX;
|
||
}
|
||
if (axis === "y") {
|
||
value = -distanceY;
|
||
}
|
||
values.push(value);
|
||
}
|
||
maxValue = Math.max.apply(Math, values);
|
||
}
|
||
if (easing) {
|
||
values = values.map(function(val3) {
|
||
return easing(val3 / maxValue) * maxValue;
|
||
});
|
||
}
|
||
if (direction === "reverse") {
|
||
values = values.map(function(val3) {
|
||
return axis ? val3 < 0 ? val3 * -1 : -val3 : Math.abs(maxValue - val3);
|
||
});
|
||
}
|
||
}
|
||
var spacing = isRange ? (val2 - val1) / maxValue : val1;
|
||
return start + spacing * (Math.round(values[i] * 100) / 100) + unit;
|
||
};
|
||
}
|
||
function timeline(params) {
|
||
if (params === void 0) params = {};
|
||
var tl = anime(params);
|
||
tl.duration = 0;
|
||
tl.add = function(instanceParams, timelineOffset) {
|
||
var tlIndex = activeInstances.indexOf(tl);
|
||
var children = tl.children;
|
||
if (tlIndex > -1) {
|
||
activeInstances.splice(tlIndex, 1);
|
||
}
|
||
function passThrough(ins2) {
|
||
ins2.passThrough = true;
|
||
}
|
||
for (var i = 0; i < children.length; i++) {
|
||
passThrough(children[i]);
|
||
}
|
||
var insParams = mergeObjects(instanceParams, replaceObjectProps(defaultTweenSettings, params));
|
||
insParams.targets = insParams.targets || params.targets;
|
||
var tlDuration = tl.duration;
|
||
insParams.autoplay = false;
|
||
insParams.direction = tl.direction;
|
||
insParams.timelineOffset = is.und(timelineOffset) ? tlDuration : getRelativeValue(timelineOffset, tlDuration);
|
||
passThrough(tl);
|
||
tl.seek(insParams.timelineOffset);
|
||
var ins = anime(insParams);
|
||
passThrough(ins);
|
||
children.push(ins);
|
||
var timings = getInstanceTimings(children, params);
|
||
tl.delay = timings.delay;
|
||
tl.endDelay = timings.endDelay;
|
||
tl.duration = timings.duration;
|
||
tl.seek(0);
|
||
tl.reset();
|
||
if (tl.autoplay) {
|
||
tl.play();
|
||
}
|
||
return tl;
|
||
};
|
||
return tl;
|
||
}
|
||
anime.version = "3.2.1";
|
||
anime.speed = 1;
|
||
anime.suspendWhenDocumentHidden = true;
|
||
anime.running = activeInstances;
|
||
anime.remove = removeTargetsFromActiveInstances;
|
||
anime.get = getOriginalTargetValue;
|
||
anime.set = setTargetsValue;
|
||
anime.convertPx = convertPxToUnit;
|
||
anime.path = getPath;
|
||
anime.setDashoffset = setDashoffset;
|
||
anime.stagger = stagger;
|
||
anime.timeline = timeline;
|
||
anime.easing = parseEasings;
|
||
anime.penner = penner;
|
||
anime.random = function(min, max) {
|
||
return Math.floor(Math.random() * (max - min + 1)) + min;
|
||
};
|
||
var anime_esm_default = anime;
|
||
|
||
// frontend/js/components/slidingTabs.js
|
||
var SlidingTabs = class {
|
||
/**
|
||
* @param {HTMLElement} containerElement - The main container element with the `data-sliding-tabs-container` attribute.
|
||
*/
|
||
constructor(containerElement) {
|
||
this.container = containerElement;
|
||
this.indicator = this.container.querySelector("[data-tab-indicator]");
|
||
this.tabs = this.container.querySelectorAll("[data-tab-item]");
|
||
this.activeTab = this.container.querySelector(".tab-active");
|
||
if (!this.indicator || this.tabs.length === 0) {
|
||
console.error("SlidingTabs component is missing required elements (indicator or items).", this.container);
|
||
return;
|
||
}
|
||
this.init();
|
||
}
|
||
init() {
|
||
if (this.activeTab) {
|
||
setTimeout(() => this.updateIndicator(this.activeTab), 50);
|
||
}
|
||
this.bindEvents();
|
||
}
|
||
updateIndicator(targetTab) {
|
||
if (!targetTab) return;
|
||
const containerRect = this.container.getBoundingClientRect();
|
||
const targetRect = targetTab.getBoundingClientRect();
|
||
const left = targetRect.left - containerRect.left;
|
||
const width = targetRect.width;
|
||
this.indicator.style.left = `${left}px`;
|
||
this.indicator.style.width = `${width}px`;
|
||
}
|
||
bindEvents() {
|
||
this.tabs.forEach((tab) => {
|
||
tab.addEventListener("click", (e) => {
|
||
if (this.activeTab) {
|
||
this.activeTab.classList.remove("tab-active");
|
||
}
|
||
tab.classList.add("tab-active");
|
||
this.activeTab = tab;
|
||
this.updateIndicator(this.activeTab);
|
||
});
|
||
tab.addEventListener("mouseenter", () => {
|
||
this.updateIndicator(tab);
|
||
});
|
||
});
|
||
this.container.addEventListener("mouseleave", () => {
|
||
this.updateIndicator(this.activeTab);
|
||
});
|
||
}
|
||
};
|
||
document.addEventListener("DOMContentLoaded", () => {
|
||
const allTabContainers = document.querySelectorAll("[data-sliding-tabs-container]");
|
||
allTabContainers.forEach((container) => {
|
||
new SlidingTabs(container);
|
||
});
|
||
});
|
||
|
||
// frontend/js/components/themeManager.js
|
||
var themeManager = {
|
||
// 用于存储图标的 SVG HTML
|
||
icons: {},
|
||
init: function() {
|
||
this.html = document.documentElement;
|
||
this.buttons = document.querySelectorAll(".theme-btn");
|
||
this.cyclerBtn = document.getElementById("theme-cycler-btn");
|
||
this.cyclerIconContainer = document.getElementById("theme-cycler-icon");
|
||
if (!this.html || this.buttons.length === 0 || !this.cyclerBtn || !this.cyclerIconContainer) {
|
||
console.warn("ThemeManager init failed: one or more required elements not found.");
|
||
return;
|
||
}
|
||
this.mediaQuery = window.matchMedia("(prefers-color-scheme: dark)");
|
||
this.storeIcons();
|
||
this.buttons.forEach((btn) => {
|
||
btn.addEventListener("click", () => this.setTheme(btn.dataset.theme));
|
||
});
|
||
this.cyclerBtn.addEventListener("click", () => this.cycleTheme());
|
||
this.mediaQuery.addEventListener("change", () => this.applyTheme());
|
||
this.applyTheme();
|
||
},
|
||
// 从现有按钮中提取并存储 SVG 图标
|
||
storeIcons: function() {
|
||
this.buttons.forEach((btn) => {
|
||
const theme = btn.dataset.theme;
|
||
const svg = btn.querySelector("svg");
|
||
if (theme && svg) {
|
||
this.icons[theme] = svg.outerHTML;
|
||
}
|
||
});
|
||
},
|
||
// 循环切换主题的核心逻辑
|
||
cycleTheme: function() {
|
||
const themes = ["system", "light", "dark"];
|
||
const currentTheme = this.getTheme();
|
||
const currentIndex = themes.indexOf(currentTheme);
|
||
const nextIndex = (currentIndex + 1) % themes.length;
|
||
this.setTheme(themes[nextIndex]);
|
||
},
|
||
applyTheme: function() {
|
||
let theme = this.getTheme();
|
||
if (theme === "system") {
|
||
theme = this.mediaQuery.matches ? "dark" : "light";
|
||
}
|
||
if (theme === "dark") {
|
||
this.html.classList.add("dark");
|
||
} else {
|
||
this.html.classList.remove("dark");
|
||
}
|
||
this.updateButtons();
|
||
this.updateCyclerIcon();
|
||
},
|
||
setTheme: function(theme) {
|
||
localStorage.setItem("theme", theme);
|
||
this.applyTheme();
|
||
},
|
||
getTheme: function() {
|
||
return localStorage.getItem("theme") || "system";
|
||
},
|
||
updateButtons: function() {
|
||
const currentTheme = this.getTheme();
|
||
this.buttons.forEach((btn) => {
|
||
if (btn.dataset.theme === currentTheme) {
|
||
btn.classList.add("bg-white", "dark:bg-zinc-700");
|
||
} else {
|
||
btn.classList.remove("bg-white", "dark:bg-zinc-700");
|
||
}
|
||
});
|
||
},
|
||
// 更新移动端循环按钮的图标
|
||
updateCyclerIcon: function() {
|
||
if (this.cyclerIconContainer) {
|
||
const currentTheme = this.getTheme();
|
||
if (this.icons[currentTheme]) {
|
||
this.cyclerIconContainer.innerHTML = this.icons[currentTheme];
|
||
}
|
||
}
|
||
}
|
||
};
|
||
|
||
// frontend/js/layout/base.js
|
||
function initActiveNav() {
|
||
const currentPath = window.location.pathname;
|
||
const navLinks = document.querySelectorAll(".nav-link");
|
||
navLinks.forEach((link) => {
|
||
const linkPath = link.getAttribute("href");
|
||
if (linkPath && linkPath !== "/" && currentPath.startsWith(linkPath)) {
|
||
const wrapper = link.closest(".nav-item-wrapper");
|
||
if (wrapper) {
|
||
wrapper.dataset.active = "true";
|
||
}
|
||
}
|
||
});
|
||
}
|
||
function bridgeApiToGlobal() {
|
||
window.apiFetch = apiFetch;
|
||
window.apiFetchJson = apiFetchJson;
|
||
console.log("[Bridge] apiFetch and apiFetchJson are now globally available.");
|
||
}
|
||
function initLayout() {
|
||
console.log("[Init] Executing global layout JavaScript...");
|
||
initActiveNav();
|
||
themeManager.init();
|
||
bridgeApiToGlobal();
|
||
}
|
||
var base_default = initLayout;
|
||
|
||
// frontend/js/main.js
|
||
var pageModules = {
|
||
// 键 'dashboard' 对应一个函数,该函数调用 import() 返回一个 Promise
|
||
// esbuild 看到这个 import() 语法,就会自动将 dashboard.js 及其依赖打包成一个独立的 chunk 文件
|
||
"dashboard": () => import("./dashboard-XFUWX3IN.js"),
|
||
"keys": () => import("./keys-V4KPRAAB.js"),
|
||
"logs": () => import("./logs-4XXDCFYG.js"),
|
||
"chat": () => import("./chat-2W4NJWMO.js")
|
||
// 'settings': () => import('./pages/settings.js'), // 未来启用 settings 页面
|
||
// 未来新增的页面,只需在这里添加一行映射,esbuild会自动处理
|
||
};
|
||
document.addEventListener("DOMContentLoaded", async () => {
|
||
base_default();
|
||
const allTabContainers = document.querySelectorAll("[data-sliding-tabs-container]");
|
||
allTabContainers.forEach((container) => new SlidingTabs(container));
|
||
const allSelectContainers = document.querySelectorAll("[data-custom-select-container]");
|
||
allSelectContainers.forEach((container) => new CustomSelect(container));
|
||
taskCenterManager.init();
|
||
const pageContainer = document.querySelector("[data-page-id]");
|
||
if (pageContainer) {
|
||
const pageId = pageContainer.dataset.pageId;
|
||
if (pageId && pageModules[pageId]) {
|
||
try {
|
||
const pageModule = await pageModules[pageId]();
|
||
if (pageModule.default && typeof pageModule.default === "function") {
|
||
pageModule.default();
|
||
}
|
||
} catch (error2) {
|
||
console.error(`Failed to load module for page: ${pageId}`, error2);
|
||
}
|
||
}
|
||
}
|
||
});
|
||
window.modalManager = modalManager;
|
||
window.taskCenterManager = taskCenterManager;
|
||
window.toastManager = toastManager;
|
||
window.uiPatterns = uiPatterns;
|
||
window.Swal = Swal;
|
||
window.anime = anime_esm_default;
|
||
/*!
|
||
* sweetalert2 v11.26.3
|
||
* Released under the MIT License.
|
||
*/
|