mirror of
https://github.com/edcommonwealth/Dashboard.git
synced 2026-03-08 23:08:14 -07:00
13703 lines
477 KiB
JavaScript
13703 lines
477 KiB
JavaScript
(() => {
|
||
var __create = Object.create;
|
||
var __defProp = Object.defineProperty;
|
||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
||
var __getOwnPropNames = Object.getOwnPropertyNames;
|
||
var __getProtoOf = Object.getPrototypeOf;
|
||
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
||
var __esm = (fn2, res) => function __init() {
|
||
return fn2 && (res = (0, fn2[__getOwnPropNames(fn2)[0]])(fn2 = 0)), res;
|
||
};
|
||
var __commonJS = (cb, mod) => function __require() {
|
||
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
||
};
|
||
var __export = (target, all) => {
|
||
for (var name in all)
|
||
__defProp(target, name, { get: all[name], enumerable: true });
|
||
};
|
||
var __copyProps = (to, from, except, desc) => {
|
||
if (from && typeof from === "object" || typeof from === "function") {
|
||
for (let key of __getOwnPropNames(from))
|
||
if (!__hasOwnProp.call(to, key) && key !== except)
|
||
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
||
}
|
||
return to;
|
||
};
|
||
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
||
// If the importer is in node compatibility mode or this is not an ESM
|
||
// file that has been converted to a CommonJS file using a Babel-
|
||
// compatible transform (i.e. "__esModule" has not been set), then set
|
||
// "default" to the CommonJS "module.exports" for node compatibility.
|
||
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
||
mod
|
||
));
|
||
|
||
// node_modules/@rails/ujs/lib/assets/compiled/rails-ujs.js
|
||
var require_rails_ujs = __commonJS({
|
||
"node_modules/@rails/ujs/lib/assets/compiled/rails-ujs.js"(exports, module) {
|
||
(function() {
|
||
var context = this;
|
||
(function() {
|
||
(function() {
|
||
this.Rails = {
|
||
linkClickSelector: "a[data-confirm], a[data-method], a[data-remote]:not([disabled]), a[data-disable-with], a[data-disable]",
|
||
buttonClickSelector: {
|
||
selector: "button[data-remote]:not([form]), button[data-confirm]:not([form])",
|
||
exclude: "form button"
|
||
},
|
||
inputChangeSelector: "select[data-remote], input[data-remote], textarea[data-remote]",
|
||
formSubmitSelector: "form:not([data-turbo=true])",
|
||
formInputClickSelector: "form:not([data-turbo=true]) input[type=submit], form:not([data-turbo=true]) input[type=image], form:not([data-turbo=true]) button[type=submit], form:not([data-turbo=true]) button:not([type]), input[type=submit][form], input[type=image][form], button[type=submit][form], button[form]:not([type])",
|
||
formDisableSelector: "input[data-disable-with]:enabled, button[data-disable-with]:enabled, textarea[data-disable-with]:enabled, input[data-disable]:enabled, button[data-disable]:enabled, textarea[data-disable]:enabled",
|
||
formEnableSelector: "input[data-disable-with]:disabled, button[data-disable-with]:disabled, textarea[data-disable-with]:disabled, input[data-disable]:disabled, button[data-disable]:disabled, textarea[data-disable]:disabled",
|
||
fileInputSelector: "input[name][type=file]:not([disabled])",
|
||
linkDisableSelector: "a[data-disable-with], a[data-disable]",
|
||
buttonDisableSelector: "button[data-remote][data-disable-with], button[data-remote][data-disable]"
|
||
};
|
||
}).call(this);
|
||
}).call(context);
|
||
var Rails2 = context.Rails;
|
||
(function() {
|
||
(function() {
|
||
var nonce;
|
||
nonce = null;
|
||
Rails2.loadCSPNonce = function() {
|
||
var ref;
|
||
return nonce = (ref = document.querySelector("meta[name=csp-nonce]")) != null ? ref.content : void 0;
|
||
};
|
||
Rails2.cspNonce = function() {
|
||
return nonce != null ? nonce : Rails2.loadCSPNonce();
|
||
};
|
||
}).call(this);
|
||
(function() {
|
||
var expando, m;
|
||
m = Element.prototype.matches || Element.prototype.matchesSelector || Element.prototype.mozMatchesSelector || Element.prototype.msMatchesSelector || Element.prototype.oMatchesSelector || Element.prototype.webkitMatchesSelector;
|
||
Rails2.matches = function(element, selector) {
|
||
if (selector.exclude != null) {
|
||
return m.call(element, selector.selector) && !m.call(element, selector.exclude);
|
||
} else {
|
||
return m.call(element, selector);
|
||
}
|
||
};
|
||
expando = "_ujsData";
|
||
Rails2.getData = function(element, key) {
|
||
var ref;
|
||
return (ref = element[expando]) != null ? ref[key] : void 0;
|
||
};
|
||
Rails2.setData = function(element, key, value) {
|
||
if (element[expando] == null) {
|
||
element[expando] = {};
|
||
}
|
||
return element[expando][key] = value;
|
||
};
|
||
Rails2.isContentEditable = function(element) {
|
||
var isEditable;
|
||
isEditable = false;
|
||
while (true) {
|
||
if (element.isContentEditable) {
|
||
isEditable = true;
|
||
break;
|
||
}
|
||
element = element.parentElement;
|
||
if (!element) {
|
||
break;
|
||
}
|
||
}
|
||
return isEditable;
|
||
};
|
||
Rails2.$ = function(selector) {
|
||
return Array.prototype.slice.call(document.querySelectorAll(selector));
|
||
};
|
||
}).call(this);
|
||
(function() {
|
||
var $, csrfParam, csrfToken;
|
||
$ = Rails2.$;
|
||
csrfToken = Rails2.csrfToken = function() {
|
||
var meta;
|
||
meta = document.querySelector("meta[name=csrf-token]");
|
||
return meta && meta.content;
|
||
};
|
||
csrfParam = Rails2.csrfParam = function() {
|
||
var meta;
|
||
meta = document.querySelector("meta[name=csrf-param]");
|
||
return meta && meta.content;
|
||
};
|
||
Rails2.CSRFProtection = function(xhr) {
|
||
var token;
|
||
token = csrfToken();
|
||
if (token != null) {
|
||
return xhr.setRequestHeader("X-CSRF-Token", token);
|
||
}
|
||
};
|
||
Rails2.refreshCSRFTokens = function() {
|
||
var param, token;
|
||
token = csrfToken();
|
||
param = csrfParam();
|
||
if (token != null && param != null) {
|
||
return $('form input[name="' + param + '"]').forEach(function(input) {
|
||
return input.value = token;
|
||
});
|
||
}
|
||
};
|
||
}).call(this);
|
||
(function() {
|
||
var CustomEvent2, fire, matches, preventDefault;
|
||
matches = Rails2.matches;
|
||
CustomEvent2 = window.CustomEvent;
|
||
if (typeof CustomEvent2 !== "function") {
|
||
CustomEvent2 = function(event, params) {
|
||
var evt;
|
||
evt = document.createEvent("CustomEvent");
|
||
evt.initCustomEvent(event, params.bubbles, params.cancelable, params.detail);
|
||
return evt;
|
||
};
|
||
CustomEvent2.prototype = window.Event.prototype;
|
||
preventDefault = CustomEvent2.prototype.preventDefault;
|
||
CustomEvent2.prototype.preventDefault = function() {
|
||
var result;
|
||
result = preventDefault.call(this);
|
||
if (this.cancelable && !this.defaultPrevented) {
|
||
Object.defineProperty(this, "defaultPrevented", {
|
||
get: function() {
|
||
return true;
|
||
}
|
||
});
|
||
}
|
||
return result;
|
||
};
|
||
}
|
||
fire = Rails2.fire = function(obj, name, data) {
|
||
var event;
|
||
event = new CustomEvent2(name, {
|
||
bubbles: true,
|
||
cancelable: true,
|
||
detail: data
|
||
});
|
||
obj.dispatchEvent(event);
|
||
return !event.defaultPrevented;
|
||
};
|
||
Rails2.stopEverything = function(e) {
|
||
fire(e.target, "ujs:everythingStopped");
|
||
e.preventDefault();
|
||
e.stopPropagation();
|
||
return e.stopImmediatePropagation();
|
||
};
|
||
Rails2.delegate = function(element, selector, eventType, handler) {
|
||
return element.addEventListener(eventType, function(e) {
|
||
var target;
|
||
target = e.target;
|
||
while (!(!(target instanceof Element) || matches(target, selector))) {
|
||
target = target.parentNode;
|
||
}
|
||
if (target instanceof Element && handler.call(target, e) === false) {
|
||
e.preventDefault();
|
||
return e.stopPropagation();
|
||
}
|
||
});
|
||
};
|
||
}).call(this);
|
||
(function() {
|
||
var AcceptHeaders, CSRFProtection, createXHR, cspNonce, fire, prepareOptions, processResponse;
|
||
cspNonce = Rails2.cspNonce, CSRFProtection = Rails2.CSRFProtection, fire = Rails2.fire;
|
||
AcceptHeaders = {
|
||
"*": "*/*",
|
||
text: "text/plain",
|
||
html: "text/html",
|
||
xml: "application/xml, text/xml",
|
||
json: "application/json, text/javascript",
|
||
script: "text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"
|
||
};
|
||
Rails2.ajax = function(options) {
|
||
var xhr;
|
||
options = prepareOptions(options);
|
||
xhr = createXHR(options, function() {
|
||
var ref, response;
|
||
response = processResponse((ref = xhr.response) != null ? ref : xhr.responseText, xhr.getResponseHeader("Content-Type"));
|
||
if (Math.floor(xhr.status / 100) === 2) {
|
||
if (typeof options.success === "function") {
|
||
options.success(response, xhr.statusText, xhr);
|
||
}
|
||
} else {
|
||
if (typeof options.error === "function") {
|
||
options.error(response, xhr.statusText, xhr);
|
||
}
|
||
}
|
||
return typeof options.complete === "function" ? options.complete(xhr, xhr.statusText) : void 0;
|
||
});
|
||
if (options.beforeSend != null && !options.beforeSend(xhr, options)) {
|
||
return false;
|
||
}
|
||
if (xhr.readyState === XMLHttpRequest.OPENED) {
|
||
return xhr.send(options.data);
|
||
}
|
||
};
|
||
prepareOptions = function(options) {
|
||
options.url = options.url || location.href;
|
||
options.type = options.type.toUpperCase();
|
||
if (options.type === "GET" && options.data) {
|
||
if (options.url.indexOf("?") < 0) {
|
||
options.url += "?" + options.data;
|
||
} else {
|
||
options.url += "&" + options.data;
|
||
}
|
||
}
|
||
if (AcceptHeaders[options.dataType] == null) {
|
||
options.dataType = "*";
|
||
}
|
||
options.accept = AcceptHeaders[options.dataType];
|
||
if (options.dataType !== "*") {
|
||
options.accept += ", */*; q=0.01";
|
||
}
|
||
return options;
|
||
};
|
||
createXHR = function(options, done) {
|
||
var xhr;
|
||
xhr = new XMLHttpRequest();
|
||
xhr.open(options.type, options.url, true);
|
||
xhr.setRequestHeader("Accept", options.accept);
|
||
if (typeof options.data === "string") {
|
||
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
|
||
}
|
||
if (!options.crossDomain) {
|
||
xhr.setRequestHeader("X-Requested-With", "XMLHttpRequest");
|
||
CSRFProtection(xhr);
|
||
}
|
||
xhr.withCredentials = !!options.withCredentials;
|
||
xhr.onreadystatechange = function() {
|
||
if (xhr.readyState === XMLHttpRequest.DONE) {
|
||
return done(xhr);
|
||
}
|
||
};
|
||
return xhr;
|
||
};
|
||
processResponse = function(response, type) {
|
||
var parser, script;
|
||
if (typeof response === "string" && typeof type === "string") {
|
||
if (type.match(/\bjson\b/)) {
|
||
try {
|
||
response = JSON.parse(response);
|
||
} catch (error2) {
|
||
}
|
||
} else if (type.match(/\b(?:java|ecma)script\b/)) {
|
||
script = document.createElement("script");
|
||
script.setAttribute("nonce", cspNonce());
|
||
script.text = response;
|
||
document.head.appendChild(script).parentNode.removeChild(script);
|
||
} else if (type.match(/\b(xml|html|svg)\b/)) {
|
||
parser = new DOMParser();
|
||
type = type.replace(/;.+/, "");
|
||
try {
|
||
response = parser.parseFromString(response, type);
|
||
} catch (error2) {
|
||
}
|
||
}
|
||
}
|
||
return response;
|
||
};
|
||
Rails2.href = function(element) {
|
||
return element.href;
|
||
};
|
||
Rails2.isCrossDomain = function(url) {
|
||
var e, originAnchor, urlAnchor;
|
||
originAnchor = document.createElement("a");
|
||
originAnchor.href = location.href;
|
||
urlAnchor = document.createElement("a");
|
||
try {
|
||
urlAnchor.href = url;
|
||
return !((!urlAnchor.protocol || urlAnchor.protocol === ":") && !urlAnchor.host || originAnchor.protocol + "//" + originAnchor.host === urlAnchor.protocol + "//" + urlAnchor.host);
|
||
} catch (error2) {
|
||
e = error2;
|
||
return true;
|
||
}
|
||
};
|
||
}).call(this);
|
||
(function() {
|
||
var matches, toArray2;
|
||
matches = Rails2.matches;
|
||
toArray2 = function(e) {
|
||
return Array.prototype.slice.call(e);
|
||
};
|
||
Rails2.serializeElement = function(element, additionalParam) {
|
||
var inputs, params;
|
||
inputs = [element];
|
||
if (matches(element, "form")) {
|
||
inputs = toArray2(element.elements);
|
||
}
|
||
params = [];
|
||
inputs.forEach(function(input) {
|
||
if (!input.name || input.disabled) {
|
||
return;
|
||
}
|
||
if (matches(input, "fieldset[disabled] *")) {
|
||
return;
|
||
}
|
||
if (matches(input, "select")) {
|
||
return toArray2(input.options).forEach(function(option) {
|
||
if (option.selected) {
|
||
return params.push({
|
||
name: input.name,
|
||
value: option.value
|
||
});
|
||
}
|
||
});
|
||
} else if (input.checked || ["radio", "checkbox", "submit"].indexOf(input.type) === -1) {
|
||
return params.push({
|
||
name: input.name,
|
||
value: input.value
|
||
});
|
||
}
|
||
});
|
||
if (additionalParam) {
|
||
params.push(additionalParam);
|
||
}
|
||
return params.map(function(param) {
|
||
if (param.name != null) {
|
||
return encodeURIComponent(param.name) + "=" + encodeURIComponent(param.value);
|
||
} else {
|
||
return param;
|
||
}
|
||
}).join("&");
|
||
};
|
||
Rails2.formElements = function(form, selector) {
|
||
if (matches(form, "form")) {
|
||
return toArray2(form.elements).filter(function(el) {
|
||
return matches(el, selector);
|
||
});
|
||
} else {
|
||
return toArray2(form.querySelectorAll(selector));
|
||
}
|
||
};
|
||
}).call(this);
|
||
(function() {
|
||
var allowAction, fire, stopEverything;
|
||
fire = Rails2.fire, stopEverything = Rails2.stopEverything;
|
||
Rails2.handleConfirm = function(e) {
|
||
if (!allowAction(this)) {
|
||
return stopEverything(e);
|
||
}
|
||
};
|
||
Rails2.confirm = function(message, element) {
|
||
return confirm(message);
|
||
};
|
||
allowAction = function(element) {
|
||
var answer, callback, message;
|
||
message = element.getAttribute("data-confirm");
|
||
if (!message) {
|
||
return true;
|
||
}
|
||
answer = false;
|
||
if (fire(element, "confirm")) {
|
||
try {
|
||
answer = Rails2.confirm(message, element);
|
||
} catch (error2) {
|
||
}
|
||
callback = fire(element, "confirm:complete", [answer]);
|
||
}
|
||
return answer && callback;
|
||
};
|
||
}).call(this);
|
||
(function() {
|
||
var disableFormElement, disableFormElements, disableLinkElement, enableFormElement, enableFormElements, enableLinkElement, formElements, getData, isContentEditable, isXhrRedirect, matches, setData, stopEverything;
|
||
matches = Rails2.matches, getData = Rails2.getData, setData = Rails2.setData, stopEverything = Rails2.stopEverything, formElements = Rails2.formElements, isContentEditable = Rails2.isContentEditable;
|
||
Rails2.handleDisabledElement = function(e) {
|
||
var element;
|
||
element = this;
|
||
if (element.disabled) {
|
||
return stopEverything(e);
|
||
}
|
||
};
|
||
Rails2.enableElement = function(e) {
|
||
var element;
|
||
if (e instanceof Event) {
|
||
if (isXhrRedirect(e)) {
|
||
return;
|
||
}
|
||
element = e.target;
|
||
} else {
|
||
element = e;
|
||
}
|
||
if (isContentEditable(element)) {
|
||
return;
|
||
}
|
||
if (matches(element, Rails2.linkDisableSelector)) {
|
||
return enableLinkElement(element);
|
||
} else if (matches(element, Rails2.buttonDisableSelector) || matches(element, Rails2.formEnableSelector)) {
|
||
return enableFormElement(element);
|
||
} else if (matches(element, Rails2.formSubmitSelector)) {
|
||
return enableFormElements(element);
|
||
}
|
||
};
|
||
Rails2.disableElement = function(e) {
|
||
var element;
|
||
element = e instanceof Event ? e.target : e;
|
||
if (isContentEditable(element)) {
|
||
return;
|
||
}
|
||
if (matches(element, Rails2.linkDisableSelector)) {
|
||
return disableLinkElement(element);
|
||
} else if (matches(element, Rails2.buttonDisableSelector) || matches(element, Rails2.formDisableSelector)) {
|
||
return disableFormElement(element);
|
||
} else if (matches(element, Rails2.formSubmitSelector)) {
|
||
return disableFormElements(element);
|
||
}
|
||
};
|
||
disableLinkElement = function(element) {
|
||
var replacement;
|
||
if (getData(element, "ujs:disabled")) {
|
||
return;
|
||
}
|
||
replacement = element.getAttribute("data-disable-with");
|
||
if (replacement != null) {
|
||
setData(element, "ujs:enable-with", element.innerHTML);
|
||
element.innerHTML = replacement;
|
||
}
|
||
element.addEventListener("click", stopEverything);
|
||
return setData(element, "ujs:disabled", true);
|
||
};
|
||
enableLinkElement = function(element) {
|
||
var originalText;
|
||
originalText = getData(element, "ujs:enable-with");
|
||
if (originalText != null) {
|
||
element.innerHTML = originalText;
|
||
setData(element, "ujs:enable-with", null);
|
||
}
|
||
element.removeEventListener("click", stopEverything);
|
||
return setData(element, "ujs:disabled", null);
|
||
};
|
||
disableFormElements = function(form) {
|
||
return formElements(form, Rails2.formDisableSelector).forEach(disableFormElement);
|
||
};
|
||
disableFormElement = function(element) {
|
||
var replacement;
|
||
if (getData(element, "ujs:disabled")) {
|
||
return;
|
||
}
|
||
replacement = element.getAttribute("data-disable-with");
|
||
if (replacement != null) {
|
||
if (matches(element, "button")) {
|
||
setData(element, "ujs:enable-with", element.innerHTML);
|
||
element.innerHTML = replacement;
|
||
} else {
|
||
setData(element, "ujs:enable-with", element.value);
|
||
element.value = replacement;
|
||
}
|
||
}
|
||
element.disabled = true;
|
||
return setData(element, "ujs:disabled", true);
|
||
};
|
||
enableFormElements = function(form) {
|
||
return formElements(form, Rails2.formEnableSelector).forEach(enableFormElement);
|
||
};
|
||
enableFormElement = function(element) {
|
||
var originalText;
|
||
originalText = getData(element, "ujs:enable-with");
|
||
if (originalText != null) {
|
||
if (matches(element, "button")) {
|
||
element.innerHTML = originalText;
|
||
} else {
|
||
element.value = originalText;
|
||
}
|
||
setData(element, "ujs:enable-with", null);
|
||
}
|
||
element.disabled = false;
|
||
return setData(element, "ujs:disabled", null);
|
||
};
|
||
isXhrRedirect = function(event) {
|
||
var ref, xhr;
|
||
xhr = (ref = event.detail) != null ? ref[0] : void 0;
|
||
return (xhr != null ? xhr.getResponseHeader("X-Xhr-Redirect") : void 0) != null;
|
||
};
|
||
}).call(this);
|
||
(function() {
|
||
var isContentEditable, stopEverything;
|
||
stopEverything = Rails2.stopEverything;
|
||
isContentEditable = Rails2.isContentEditable;
|
||
Rails2.handleMethod = function(e) {
|
||
var csrfParam, csrfToken, form, formContent, href, link, method;
|
||
link = this;
|
||
method = link.getAttribute("data-method");
|
||
if (!method) {
|
||
return;
|
||
}
|
||
if (isContentEditable(this)) {
|
||
return;
|
||
}
|
||
href = Rails2.href(link);
|
||
csrfToken = Rails2.csrfToken();
|
||
csrfParam = Rails2.csrfParam();
|
||
form = document.createElement("form");
|
||
formContent = "<input name='_method' value='" + method + "' type='hidden' />";
|
||
if (csrfParam != null && csrfToken != null && !Rails2.isCrossDomain(href)) {
|
||
formContent += "<input name='" + csrfParam + "' value='" + csrfToken + "' type='hidden' />";
|
||
}
|
||
formContent += '<input type="submit" />';
|
||
form.method = "post";
|
||
form.action = href;
|
||
form.target = link.target;
|
||
form.innerHTML = formContent;
|
||
form.style.display = "none";
|
||
document.body.appendChild(form);
|
||
form.querySelector('[type="submit"]').click();
|
||
return stopEverything(e);
|
||
};
|
||
}).call(this);
|
||
(function() {
|
||
var ajax, fire, getData, isContentEditable, isCrossDomain, isRemote, matches, serializeElement, setData, stopEverything, slice = [].slice;
|
||
matches = Rails2.matches, getData = Rails2.getData, setData = Rails2.setData, fire = Rails2.fire, stopEverything = Rails2.stopEverything, ajax = Rails2.ajax, isCrossDomain = Rails2.isCrossDomain, serializeElement = Rails2.serializeElement, isContentEditable = Rails2.isContentEditable;
|
||
isRemote = function(element) {
|
||
var value;
|
||
value = element.getAttribute("data-remote");
|
||
return value != null && value !== "false";
|
||
};
|
||
Rails2.handleRemote = function(e) {
|
||
var button, data, dataType, element, method, url, withCredentials;
|
||
element = this;
|
||
if (!isRemote(element)) {
|
||
return true;
|
||
}
|
||
if (!fire(element, "ajax:before")) {
|
||
fire(element, "ajax:stopped");
|
||
return false;
|
||
}
|
||
if (isContentEditable(element)) {
|
||
fire(element, "ajax:stopped");
|
||
return false;
|
||
}
|
||
withCredentials = element.getAttribute("data-with-credentials");
|
||
dataType = element.getAttribute("data-type") || "script";
|
||
if (matches(element, Rails2.formSubmitSelector)) {
|
||
button = getData(element, "ujs:submit-button");
|
||
method = getData(element, "ujs:submit-button-formmethod") || element.method;
|
||
url = getData(element, "ujs:submit-button-formaction") || element.getAttribute("action") || location.href;
|
||
if (method.toUpperCase() === "GET") {
|
||
url = url.replace(/\?.*$/, "");
|
||
}
|
||
if (element.enctype === "multipart/form-data") {
|
||
data = new FormData(element);
|
||
if (button != null) {
|
||
data.append(button.name, button.value);
|
||
}
|
||
} else {
|
||
data = serializeElement(element, button);
|
||
}
|
||
setData(element, "ujs:submit-button", null);
|
||
setData(element, "ujs:submit-button-formmethod", null);
|
||
setData(element, "ujs:submit-button-formaction", null);
|
||
} else if (matches(element, Rails2.buttonClickSelector) || matches(element, Rails2.inputChangeSelector)) {
|
||
method = element.getAttribute("data-method");
|
||
url = element.getAttribute("data-url");
|
||
data = serializeElement(element, element.getAttribute("data-params"));
|
||
} else {
|
||
method = element.getAttribute("data-method");
|
||
url = Rails2.href(element);
|
||
data = element.getAttribute("data-params");
|
||
}
|
||
ajax({
|
||
type: method || "GET",
|
||
url,
|
||
data,
|
||
dataType,
|
||
beforeSend: function(xhr, options) {
|
||
if (fire(element, "ajax:beforeSend", [xhr, options])) {
|
||
return fire(element, "ajax:send", [xhr]);
|
||
} else {
|
||
fire(element, "ajax:stopped");
|
||
return false;
|
||
}
|
||
},
|
||
success: function() {
|
||
var args;
|
||
args = 1 <= arguments.length ? slice.call(arguments, 0) : [];
|
||
return fire(element, "ajax:success", args);
|
||
},
|
||
error: function() {
|
||
var args;
|
||
args = 1 <= arguments.length ? slice.call(arguments, 0) : [];
|
||
return fire(element, "ajax:error", args);
|
||
},
|
||
complete: function() {
|
||
var args;
|
||
args = 1 <= arguments.length ? slice.call(arguments, 0) : [];
|
||
return fire(element, "ajax:complete", args);
|
||
},
|
||
crossDomain: isCrossDomain(url),
|
||
withCredentials: withCredentials != null && withCredentials !== "false"
|
||
});
|
||
return stopEverything(e);
|
||
};
|
||
Rails2.formSubmitButtonClick = function(e) {
|
||
var button, form;
|
||
button = this;
|
||
form = button.form;
|
||
if (!form) {
|
||
return;
|
||
}
|
||
if (button.name) {
|
||
setData(form, "ujs:submit-button", {
|
||
name: button.name,
|
||
value: button.value
|
||
});
|
||
}
|
||
setData(form, "ujs:formnovalidate-button", button.formNoValidate);
|
||
setData(form, "ujs:submit-button-formaction", button.getAttribute("formaction"));
|
||
return setData(form, "ujs:submit-button-formmethod", button.getAttribute("formmethod"));
|
||
};
|
||
Rails2.preventInsignificantClick = function(e) {
|
||
var data, insignificantMetaClick, link, metaClick, method, nonPrimaryMouseClick;
|
||
link = this;
|
||
method = (link.getAttribute("data-method") || "GET").toUpperCase();
|
||
data = link.getAttribute("data-params");
|
||
metaClick = e.metaKey || e.ctrlKey;
|
||
insignificantMetaClick = metaClick && method === "GET" && !data;
|
||
nonPrimaryMouseClick = e.button != null && e.button !== 0;
|
||
if (nonPrimaryMouseClick || insignificantMetaClick) {
|
||
return e.stopImmediatePropagation();
|
||
}
|
||
};
|
||
}).call(this);
|
||
(function() {
|
||
var $, CSRFProtection, delegate, disableElement, enableElement, fire, formSubmitButtonClick, getData, handleConfirm, handleDisabledElement, handleMethod, handleRemote, loadCSPNonce, preventInsignificantClick, refreshCSRFTokens;
|
||
fire = Rails2.fire, delegate = Rails2.delegate, getData = Rails2.getData, $ = Rails2.$, refreshCSRFTokens = Rails2.refreshCSRFTokens, CSRFProtection = Rails2.CSRFProtection, loadCSPNonce = Rails2.loadCSPNonce, enableElement = Rails2.enableElement, disableElement = Rails2.disableElement, handleDisabledElement = Rails2.handleDisabledElement, handleConfirm = Rails2.handleConfirm, preventInsignificantClick = Rails2.preventInsignificantClick, handleRemote = Rails2.handleRemote, formSubmitButtonClick = Rails2.formSubmitButtonClick, handleMethod = Rails2.handleMethod;
|
||
if (typeof jQuery !== "undefined" && jQuery !== null && jQuery.ajax != null) {
|
||
if (jQuery.rails) {
|
||
throw new Error("If you load both jquery_ujs and rails-ujs, use rails-ujs only.");
|
||
}
|
||
jQuery.rails = Rails2;
|
||
jQuery.ajaxPrefilter(function(options, originalOptions, xhr) {
|
||
if (!options.crossDomain) {
|
||
return CSRFProtection(xhr);
|
||
}
|
||
});
|
||
}
|
||
Rails2.start = function() {
|
||
if (window._rails_loaded) {
|
||
throw new Error("rails-ujs has already been loaded!");
|
||
}
|
||
window.addEventListener("pageshow", function() {
|
||
$(Rails2.formEnableSelector).forEach(function(el) {
|
||
if (getData(el, "ujs:disabled")) {
|
||
return enableElement(el);
|
||
}
|
||
});
|
||
return $(Rails2.linkDisableSelector).forEach(function(el) {
|
||
if (getData(el, "ujs:disabled")) {
|
||
return enableElement(el);
|
||
}
|
||
});
|
||
});
|
||
delegate(document, Rails2.linkDisableSelector, "ajax:complete", enableElement);
|
||
delegate(document, Rails2.linkDisableSelector, "ajax:stopped", enableElement);
|
||
delegate(document, Rails2.buttonDisableSelector, "ajax:complete", enableElement);
|
||
delegate(document, Rails2.buttonDisableSelector, "ajax:stopped", enableElement);
|
||
delegate(document, Rails2.linkClickSelector, "click", preventInsignificantClick);
|
||
delegate(document, Rails2.linkClickSelector, "click", handleDisabledElement);
|
||
delegate(document, Rails2.linkClickSelector, "click", handleConfirm);
|
||
delegate(document, Rails2.linkClickSelector, "click", disableElement);
|
||
delegate(document, Rails2.linkClickSelector, "click", handleRemote);
|
||
delegate(document, Rails2.linkClickSelector, "click", handleMethod);
|
||
delegate(document, Rails2.buttonClickSelector, "click", preventInsignificantClick);
|
||
delegate(document, Rails2.buttonClickSelector, "click", handleDisabledElement);
|
||
delegate(document, Rails2.buttonClickSelector, "click", handleConfirm);
|
||
delegate(document, Rails2.buttonClickSelector, "click", disableElement);
|
||
delegate(document, Rails2.buttonClickSelector, "click", handleRemote);
|
||
delegate(document, Rails2.inputChangeSelector, "change", handleDisabledElement);
|
||
delegate(document, Rails2.inputChangeSelector, "change", handleConfirm);
|
||
delegate(document, Rails2.inputChangeSelector, "change", handleRemote);
|
||
delegate(document, Rails2.formSubmitSelector, "submit", handleDisabledElement);
|
||
delegate(document, Rails2.formSubmitSelector, "submit", handleConfirm);
|
||
delegate(document, Rails2.formSubmitSelector, "submit", handleRemote);
|
||
delegate(document, Rails2.formSubmitSelector, "submit", function(e) {
|
||
return setTimeout(function() {
|
||
return disableElement(e);
|
||
}, 13);
|
||
});
|
||
delegate(document, Rails2.formSubmitSelector, "ajax:send", disableElement);
|
||
delegate(document, Rails2.formSubmitSelector, "ajax:complete", enableElement);
|
||
delegate(document, Rails2.formInputClickSelector, "click", preventInsignificantClick);
|
||
delegate(document, Rails2.formInputClickSelector, "click", handleDisabledElement);
|
||
delegate(document, Rails2.formInputClickSelector, "click", handleConfirm);
|
||
delegate(document, Rails2.formInputClickSelector, "click", formSubmitButtonClick);
|
||
document.addEventListener("DOMContentLoaded", refreshCSRFTokens);
|
||
document.addEventListener("DOMContentLoaded", loadCSPNonce);
|
||
return window._rails_loaded = true;
|
||
};
|
||
if (window.Rails === Rails2 && fire(document, "rails:attachBindings")) {
|
||
Rails2.start();
|
||
}
|
||
}).call(this);
|
||
}).call(this);
|
||
if (typeof module === "object" && module.exports) {
|
||
module.exports = Rails2;
|
||
} else if (typeof define === "function" && define.amd) {
|
||
define(Rails2);
|
||
}
|
||
}).call(exports);
|
||
}
|
||
});
|
||
|
||
// node_modules/@rails/actioncable/src/adapters.js
|
||
var adapters_default;
|
||
var init_adapters = __esm({
|
||
"node_modules/@rails/actioncable/src/adapters.js"() {
|
||
adapters_default = {
|
||
logger: self.console,
|
||
WebSocket: self.WebSocket
|
||
};
|
||
}
|
||
});
|
||
|
||
// node_modules/@rails/actioncable/src/logger.js
|
||
var logger_default;
|
||
var init_logger = __esm({
|
||
"node_modules/@rails/actioncable/src/logger.js"() {
|
||
init_adapters();
|
||
logger_default = {
|
||
log(...messages) {
|
||
if (this.enabled) {
|
||
messages.push(Date.now());
|
||
adapters_default.logger.log("[ActionCable]", ...messages);
|
||
}
|
||
}
|
||
};
|
||
}
|
||
});
|
||
|
||
// node_modules/@rails/actioncable/src/connection_monitor.js
|
||
var now, secondsSince, ConnectionMonitor, connection_monitor_default;
|
||
var init_connection_monitor = __esm({
|
||
"node_modules/@rails/actioncable/src/connection_monitor.js"() {
|
||
init_logger();
|
||
now = () => (/* @__PURE__ */ new Date()).getTime();
|
||
secondsSince = (time) => (now() - time) / 1e3;
|
||
ConnectionMonitor = class {
|
||
constructor(connection) {
|
||
this.visibilityDidChange = this.visibilityDidChange.bind(this);
|
||
this.connection = connection;
|
||
this.reconnectAttempts = 0;
|
||
}
|
||
start() {
|
||
if (!this.isRunning()) {
|
||
this.startedAt = now();
|
||
delete this.stoppedAt;
|
||
this.startPolling();
|
||
addEventListener("visibilitychange", this.visibilityDidChange);
|
||
logger_default.log(`ConnectionMonitor started. stale threshold = ${this.constructor.staleThreshold} s`);
|
||
}
|
||
}
|
||
stop() {
|
||
if (this.isRunning()) {
|
||
this.stoppedAt = now();
|
||
this.stopPolling();
|
||
removeEventListener("visibilitychange", this.visibilityDidChange);
|
||
logger_default.log("ConnectionMonitor stopped");
|
||
}
|
||
}
|
||
isRunning() {
|
||
return this.startedAt && !this.stoppedAt;
|
||
}
|
||
recordPing() {
|
||
this.pingedAt = now();
|
||
}
|
||
recordConnect() {
|
||
this.reconnectAttempts = 0;
|
||
this.recordPing();
|
||
delete this.disconnectedAt;
|
||
logger_default.log("ConnectionMonitor recorded connect");
|
||
}
|
||
recordDisconnect() {
|
||
this.disconnectedAt = now();
|
||
logger_default.log("ConnectionMonitor recorded disconnect");
|
||
}
|
||
// Private
|
||
startPolling() {
|
||
this.stopPolling();
|
||
this.poll();
|
||
}
|
||
stopPolling() {
|
||
clearTimeout(this.pollTimeout);
|
||
}
|
||
poll() {
|
||
this.pollTimeout = setTimeout(
|
||
() => {
|
||
this.reconnectIfStale();
|
||
this.poll();
|
||
},
|
||
this.getPollInterval()
|
||
);
|
||
}
|
||
getPollInterval() {
|
||
const { staleThreshold, reconnectionBackoffRate } = this.constructor;
|
||
const backoff = Math.pow(1 + reconnectionBackoffRate, Math.min(this.reconnectAttempts, 10));
|
||
const jitterMax = this.reconnectAttempts === 0 ? 1 : reconnectionBackoffRate;
|
||
const jitter = jitterMax * Math.random();
|
||
return staleThreshold * 1e3 * backoff * (1 + jitter);
|
||
}
|
||
reconnectIfStale() {
|
||
if (this.connectionIsStale()) {
|
||
logger_default.log(`ConnectionMonitor detected stale connection. reconnectAttempts = ${this.reconnectAttempts}, time stale = ${secondsSince(this.refreshedAt)} s, stale threshold = ${this.constructor.staleThreshold} s`);
|
||
this.reconnectAttempts++;
|
||
if (this.disconnectedRecently()) {
|
||
logger_default.log(`ConnectionMonitor skipping reopening recent disconnect. time disconnected = ${secondsSince(this.disconnectedAt)} s`);
|
||
} else {
|
||
logger_default.log("ConnectionMonitor reopening");
|
||
this.connection.reopen();
|
||
}
|
||
}
|
||
}
|
||
get refreshedAt() {
|
||
return this.pingedAt ? this.pingedAt : this.startedAt;
|
||
}
|
||
connectionIsStale() {
|
||
return secondsSince(this.refreshedAt) > this.constructor.staleThreshold;
|
||
}
|
||
disconnectedRecently() {
|
||
return this.disconnectedAt && secondsSince(this.disconnectedAt) < this.constructor.staleThreshold;
|
||
}
|
||
visibilityDidChange() {
|
||
if (document.visibilityState === "visible") {
|
||
setTimeout(
|
||
() => {
|
||
if (this.connectionIsStale() || !this.connection.isOpen()) {
|
||
logger_default.log(`ConnectionMonitor reopening stale connection on visibilitychange. visibilityState = ${document.visibilityState}`);
|
||
this.connection.reopen();
|
||
}
|
||
},
|
||
200
|
||
);
|
||
}
|
||
}
|
||
};
|
||
ConnectionMonitor.staleThreshold = 6;
|
||
ConnectionMonitor.reconnectionBackoffRate = 0.15;
|
||
connection_monitor_default = ConnectionMonitor;
|
||
}
|
||
});
|
||
|
||
// node_modules/@rails/actioncable/src/internal.js
|
||
var internal_default;
|
||
var init_internal = __esm({
|
||
"node_modules/@rails/actioncable/src/internal.js"() {
|
||
internal_default = {
|
||
"message_types": {
|
||
"welcome": "welcome",
|
||
"disconnect": "disconnect",
|
||
"ping": "ping",
|
||
"confirmation": "confirm_subscription",
|
||
"rejection": "reject_subscription"
|
||
},
|
||
"disconnect_reasons": {
|
||
"unauthorized": "unauthorized",
|
||
"invalid_request": "invalid_request",
|
||
"server_restart": "server_restart"
|
||
},
|
||
"default_mount_path": "/cable",
|
||
"protocols": [
|
||
"actioncable-v1-json",
|
||
"actioncable-unsupported"
|
||
]
|
||
};
|
||
}
|
||
});
|
||
|
||
// node_modules/@rails/actioncable/src/connection.js
|
||
var message_types, protocols, supportedProtocols, indexOf, Connection, connection_default;
|
||
var init_connection = __esm({
|
||
"node_modules/@rails/actioncable/src/connection.js"() {
|
||
init_adapters();
|
||
init_connection_monitor();
|
||
init_internal();
|
||
init_logger();
|
||
({ message_types, protocols } = internal_default);
|
||
supportedProtocols = protocols.slice(0, protocols.length - 1);
|
||
indexOf = [].indexOf;
|
||
Connection = class {
|
||
constructor(consumer2) {
|
||
this.open = this.open.bind(this);
|
||
this.consumer = consumer2;
|
||
this.subscriptions = this.consumer.subscriptions;
|
||
this.monitor = new connection_monitor_default(this);
|
||
this.disconnected = true;
|
||
}
|
||
send(data) {
|
||
if (this.isOpen()) {
|
||
this.webSocket.send(JSON.stringify(data));
|
||
return true;
|
||
} else {
|
||
return false;
|
||
}
|
||
}
|
||
open() {
|
||
if (this.isActive()) {
|
||
logger_default.log(`Attempted to open WebSocket, but existing socket is ${this.getState()}`);
|
||
return false;
|
||
} else {
|
||
logger_default.log(`Opening WebSocket, current state is ${this.getState()}, subprotocols: ${protocols}`);
|
||
if (this.webSocket) {
|
||
this.uninstallEventHandlers();
|
||
}
|
||
this.webSocket = new adapters_default.WebSocket(this.consumer.url, protocols);
|
||
this.installEventHandlers();
|
||
this.monitor.start();
|
||
return true;
|
||
}
|
||
}
|
||
close({ allowReconnect } = { allowReconnect: true }) {
|
||
if (!allowReconnect) {
|
||
this.monitor.stop();
|
||
}
|
||
if (this.isOpen()) {
|
||
return this.webSocket.close();
|
||
}
|
||
}
|
||
reopen() {
|
||
logger_default.log(`Reopening WebSocket, current state is ${this.getState()}`);
|
||
if (this.isActive()) {
|
||
try {
|
||
return this.close();
|
||
} catch (error2) {
|
||
logger_default.log("Failed to reopen WebSocket", error2);
|
||
} finally {
|
||
logger_default.log(`Reopening WebSocket in ${this.constructor.reopenDelay}ms`);
|
||
setTimeout(this.open, this.constructor.reopenDelay);
|
||
}
|
||
} else {
|
||
return this.open();
|
||
}
|
||
}
|
||
getProtocol() {
|
||
if (this.webSocket) {
|
||
return this.webSocket.protocol;
|
||
}
|
||
}
|
||
isOpen() {
|
||
return this.isState("open");
|
||
}
|
||
isActive() {
|
||
return this.isState("open", "connecting");
|
||
}
|
||
// Private
|
||
isProtocolSupported() {
|
||
return indexOf.call(supportedProtocols, this.getProtocol()) >= 0;
|
||
}
|
||
isState(...states) {
|
||
return indexOf.call(states, this.getState()) >= 0;
|
||
}
|
||
getState() {
|
||
if (this.webSocket) {
|
||
for (let state in adapters_default.WebSocket) {
|
||
if (adapters_default.WebSocket[state] === this.webSocket.readyState) {
|
||
return state.toLowerCase();
|
||
}
|
||
}
|
||
}
|
||
return null;
|
||
}
|
||
installEventHandlers() {
|
||
for (let eventName in this.events) {
|
||
const handler = this.events[eventName].bind(this);
|
||
this.webSocket[`on${eventName}`] = handler;
|
||
}
|
||
}
|
||
uninstallEventHandlers() {
|
||
for (let eventName in this.events) {
|
||
this.webSocket[`on${eventName}`] = function() {
|
||
};
|
||
}
|
||
}
|
||
};
|
||
Connection.reopenDelay = 500;
|
||
Connection.prototype.events = {
|
||
message(event) {
|
||
if (!this.isProtocolSupported()) {
|
||
return;
|
||
}
|
||
const { identifier, message, reason, reconnect, type } = JSON.parse(event.data);
|
||
switch (type) {
|
||
case message_types.welcome:
|
||
this.monitor.recordConnect();
|
||
return this.subscriptions.reload();
|
||
case message_types.disconnect:
|
||
logger_default.log(`Disconnecting. Reason: ${reason}`);
|
||
return this.close({ allowReconnect: reconnect });
|
||
case message_types.ping:
|
||
return this.monitor.recordPing();
|
||
case message_types.confirmation:
|
||
this.subscriptions.confirmSubscription(identifier);
|
||
return this.subscriptions.notify(identifier, "connected");
|
||
case message_types.rejection:
|
||
return this.subscriptions.reject(identifier);
|
||
default:
|
||
return this.subscriptions.notify(identifier, "received", message);
|
||
}
|
||
},
|
||
open() {
|
||
logger_default.log(`WebSocket onopen event, using '${this.getProtocol()}' subprotocol`);
|
||
this.disconnected = false;
|
||
if (!this.isProtocolSupported()) {
|
||
logger_default.log("Protocol is unsupported. Stopping monitor and disconnecting.");
|
||
return this.close({ allowReconnect: false });
|
||
}
|
||
},
|
||
close(event) {
|
||
logger_default.log("WebSocket onclose event");
|
||
if (this.disconnected) {
|
||
return;
|
||
}
|
||
this.disconnected = true;
|
||
this.monitor.recordDisconnect();
|
||
return this.subscriptions.notifyAll("disconnected", { willAttemptReconnect: this.monitor.isRunning() });
|
||
},
|
||
error() {
|
||
logger_default.log("WebSocket onerror event");
|
||
}
|
||
};
|
||
connection_default = Connection;
|
||
}
|
||
});
|
||
|
||
// node_modules/@rails/actioncable/src/subscription.js
|
||
var extend, Subscription;
|
||
var init_subscription = __esm({
|
||
"node_modules/@rails/actioncable/src/subscription.js"() {
|
||
extend = function(object, properties) {
|
||
if (properties != null) {
|
||
for (let key in properties) {
|
||
const value = properties[key];
|
||
object[key] = value;
|
||
}
|
||
}
|
||
return object;
|
||
};
|
||
Subscription = class {
|
||
constructor(consumer2, params = {}, mixin) {
|
||
this.consumer = consumer2;
|
||
this.identifier = JSON.stringify(params);
|
||
extend(this, mixin);
|
||
}
|
||
// Perform a channel action with the optional data passed as an attribute
|
||
perform(action, data = {}) {
|
||
data.action = action;
|
||
return this.send(data);
|
||
}
|
||
send(data) {
|
||
return this.consumer.send({ command: "message", identifier: this.identifier, data: JSON.stringify(data) });
|
||
}
|
||
unsubscribe() {
|
||
return this.consumer.subscriptions.remove(this);
|
||
}
|
||
};
|
||
}
|
||
});
|
||
|
||
// node_modules/@rails/actioncable/src/subscription_guarantor.js
|
||
var SubscriptionGuarantor, subscription_guarantor_default;
|
||
var init_subscription_guarantor = __esm({
|
||
"node_modules/@rails/actioncable/src/subscription_guarantor.js"() {
|
||
init_logger();
|
||
SubscriptionGuarantor = class {
|
||
constructor(subscriptions) {
|
||
this.subscriptions = subscriptions;
|
||
this.pendingSubscriptions = [];
|
||
}
|
||
guarantee(subscription) {
|
||
if (this.pendingSubscriptions.indexOf(subscription) == -1) {
|
||
logger_default.log(`SubscriptionGuarantor guaranteeing ${subscription.identifier}`);
|
||
this.pendingSubscriptions.push(subscription);
|
||
} else {
|
||
logger_default.log(`SubscriptionGuarantor already guaranteeing ${subscription.identifier}`);
|
||
}
|
||
this.startGuaranteeing();
|
||
}
|
||
forget(subscription) {
|
||
logger_default.log(`SubscriptionGuarantor forgetting ${subscription.identifier}`);
|
||
this.pendingSubscriptions = this.pendingSubscriptions.filter((s) => s !== subscription);
|
||
}
|
||
startGuaranteeing() {
|
||
this.stopGuaranteeing();
|
||
this.retrySubscribing();
|
||
}
|
||
stopGuaranteeing() {
|
||
clearTimeout(this.retryTimeout);
|
||
}
|
||
retrySubscribing() {
|
||
this.retryTimeout = setTimeout(
|
||
() => {
|
||
if (this.subscriptions && typeof this.subscriptions.subscribe === "function") {
|
||
this.pendingSubscriptions.map((subscription) => {
|
||
logger_default.log(`SubscriptionGuarantor resubscribing ${subscription.identifier}`);
|
||
this.subscriptions.subscribe(subscription);
|
||
});
|
||
}
|
||
},
|
||
500
|
||
);
|
||
}
|
||
};
|
||
subscription_guarantor_default = SubscriptionGuarantor;
|
||
}
|
||
});
|
||
|
||
// node_modules/@rails/actioncable/src/subscriptions.js
|
||
var Subscriptions;
|
||
var init_subscriptions = __esm({
|
||
"node_modules/@rails/actioncable/src/subscriptions.js"() {
|
||
init_subscription();
|
||
init_subscription_guarantor();
|
||
init_logger();
|
||
Subscriptions = class {
|
||
constructor(consumer2) {
|
||
this.consumer = consumer2;
|
||
this.guarantor = new subscription_guarantor_default(this);
|
||
this.subscriptions = [];
|
||
}
|
||
create(channelName, mixin) {
|
||
const channel = channelName;
|
||
const params = typeof channel === "object" ? channel : { channel };
|
||
const subscription = new Subscription(this.consumer, params, mixin);
|
||
return this.add(subscription);
|
||
}
|
||
// Private
|
||
add(subscription) {
|
||
this.subscriptions.push(subscription);
|
||
this.consumer.ensureActiveConnection();
|
||
this.notify(subscription, "initialized");
|
||
this.subscribe(subscription);
|
||
return subscription;
|
||
}
|
||
remove(subscription) {
|
||
this.forget(subscription);
|
||
if (!this.findAll(subscription.identifier).length) {
|
||
this.sendCommand(subscription, "unsubscribe");
|
||
}
|
||
return subscription;
|
||
}
|
||
reject(identifier) {
|
||
return this.findAll(identifier).map((subscription) => {
|
||
this.forget(subscription);
|
||
this.notify(subscription, "rejected");
|
||
return subscription;
|
||
});
|
||
}
|
||
forget(subscription) {
|
||
this.guarantor.forget(subscription);
|
||
this.subscriptions = this.subscriptions.filter((s) => s !== subscription);
|
||
return subscription;
|
||
}
|
||
findAll(identifier) {
|
||
return this.subscriptions.filter((s) => s.identifier === identifier);
|
||
}
|
||
reload() {
|
||
return this.subscriptions.map((subscription) => this.subscribe(subscription));
|
||
}
|
||
notifyAll(callbackName, ...args) {
|
||
return this.subscriptions.map((subscription) => this.notify(subscription, callbackName, ...args));
|
||
}
|
||
notify(subscription, callbackName, ...args) {
|
||
let subscriptions;
|
||
if (typeof subscription === "string") {
|
||
subscriptions = this.findAll(subscription);
|
||
} else {
|
||
subscriptions = [subscription];
|
||
}
|
||
return subscriptions.map((subscription2) => typeof subscription2[callbackName] === "function" ? subscription2[callbackName](...args) : void 0);
|
||
}
|
||
subscribe(subscription) {
|
||
if (this.sendCommand(subscription, "subscribe")) {
|
||
this.guarantor.guarantee(subscription);
|
||
}
|
||
}
|
||
confirmSubscription(identifier) {
|
||
logger_default.log(`Subscription confirmed ${identifier}`);
|
||
this.findAll(identifier).map((subscription) => this.guarantor.forget(subscription));
|
||
}
|
||
sendCommand(subscription, command) {
|
||
const { identifier } = subscription;
|
||
return this.consumer.send({ command, identifier });
|
||
}
|
||
};
|
||
}
|
||
});
|
||
|
||
// node_modules/@rails/actioncable/src/consumer.js
|
||
function createWebSocketURL(url) {
|
||
if (typeof url === "function") {
|
||
url = url();
|
||
}
|
||
if (url && !/^wss?:/i.test(url)) {
|
||
const a = document.createElement("a");
|
||
a.href = url;
|
||
a.href = a.href;
|
||
a.protocol = a.protocol.replace("http", "ws");
|
||
return a.href;
|
||
} else {
|
||
return url;
|
||
}
|
||
}
|
||
var Consumer;
|
||
var init_consumer = __esm({
|
||
"node_modules/@rails/actioncable/src/consumer.js"() {
|
||
init_connection();
|
||
init_subscriptions();
|
||
Consumer = class {
|
||
constructor(url) {
|
||
this._url = url;
|
||
this.subscriptions = new Subscriptions(this);
|
||
this.connection = new connection_default(this);
|
||
}
|
||
get url() {
|
||
return createWebSocketURL(this._url);
|
||
}
|
||
send(data) {
|
||
return this.connection.send(data);
|
||
}
|
||
connect() {
|
||
return this.connection.open();
|
||
}
|
||
disconnect() {
|
||
return this.connection.close({ allowReconnect: false });
|
||
}
|
||
ensureActiveConnection() {
|
||
if (!this.connection.isActive()) {
|
||
return this.connection.open();
|
||
}
|
||
}
|
||
};
|
||
}
|
||
});
|
||
|
||
// node_modules/@rails/actioncable/src/index.js
|
||
var src_exports = {};
|
||
__export(src_exports, {
|
||
Connection: () => connection_default,
|
||
ConnectionMonitor: () => connection_monitor_default,
|
||
Consumer: () => Consumer,
|
||
INTERNAL: () => internal_default,
|
||
Subscription: () => Subscription,
|
||
SubscriptionGuarantor: () => subscription_guarantor_default,
|
||
Subscriptions: () => Subscriptions,
|
||
adapters: () => adapters_default,
|
||
createConsumer: () => createConsumer,
|
||
createWebSocketURL: () => createWebSocketURL,
|
||
getConfig: () => getConfig,
|
||
logger: () => logger_default
|
||
});
|
||
function createConsumer(url = getConfig("url") || internal_default.default_mount_path) {
|
||
return new Consumer(url);
|
||
}
|
||
function getConfig(name) {
|
||
const element = document.head.querySelector(`meta[name='action-cable-${name}']`);
|
||
if (element) {
|
||
return element.getAttribute("content");
|
||
}
|
||
}
|
||
var init_src = __esm({
|
||
"node_modules/@rails/actioncable/src/index.js"() {
|
||
init_connection();
|
||
init_connection_monitor();
|
||
init_consumer();
|
||
init_internal();
|
||
init_subscription();
|
||
init_subscriptions();
|
||
init_subscription_guarantor();
|
||
init_adapters();
|
||
init_logger();
|
||
}
|
||
});
|
||
|
||
// node_modules/debounce/index.js
|
||
var require_debounce = __commonJS({
|
||
"node_modules/debounce/index.js"(exports, module) {
|
||
function debounce3(func, wait, immediate) {
|
||
var timeout, args, context, timestamp, result;
|
||
if (null == wait)
|
||
wait = 100;
|
||
function later() {
|
||
var last = Date.now() - timestamp;
|
||
if (last < wait && last >= 0) {
|
||
timeout = setTimeout(later, wait - last);
|
||
} else {
|
||
timeout = null;
|
||
if (!immediate) {
|
||
result = func.apply(context, args);
|
||
context = args = null;
|
||
}
|
||
}
|
||
}
|
||
;
|
||
var debounced = function() {
|
||
context = this;
|
||
args = arguments;
|
||
timestamp = Date.now();
|
||
var callNow = immediate && !timeout;
|
||
if (!timeout)
|
||
timeout = setTimeout(later, wait);
|
||
if (callNow) {
|
||
result = func.apply(context, args);
|
||
context = args = null;
|
||
}
|
||
return result;
|
||
};
|
||
debounced.clear = function() {
|
||
if (timeout) {
|
||
clearTimeout(timeout);
|
||
timeout = null;
|
||
}
|
||
};
|
||
debounced.flush = function() {
|
||
if (timeout) {
|
||
result = func.apply(context, args);
|
||
context = args = null;
|
||
clearTimeout(timeout);
|
||
timeout = null;
|
||
}
|
||
};
|
||
return debounced;
|
||
}
|
||
debounce3.debounce = debounce3;
|
||
module.exports = debounce3;
|
||
}
|
||
});
|
||
|
||
// app/javascript/application.js
|
||
var import_ujs = __toESM(require_rails_ujs());
|
||
|
||
// node_modules/@rails/activestorage/app/assets/javascripts/activestorage.esm.js
|
||
var sparkMd5 = {
|
||
exports: {}
|
||
};
|
||
(function(module, exports) {
|
||
(function(factory) {
|
||
{
|
||
module.exports = factory();
|
||
}
|
||
})(function(undefined$1) {
|
||
var hex_chr = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "a", "b", "c", "d", "e", "f"];
|
||
function md5cycle(x, k) {
|
||
var a = x[0], b = x[1], c = x[2], d = x[3];
|
||
a += (b & c | ~b & d) + k[0] - 680876936 | 0;
|
||
a = (a << 7 | a >>> 25) + b | 0;
|
||
d += (a & b | ~a & c) + k[1] - 389564586 | 0;
|
||
d = (d << 12 | d >>> 20) + a | 0;
|
||
c += (d & a | ~d & b) + k[2] + 606105819 | 0;
|
||
c = (c << 17 | c >>> 15) + d | 0;
|
||
b += (c & d | ~c & a) + k[3] - 1044525330 | 0;
|
||
b = (b << 22 | b >>> 10) + c | 0;
|
||
a += (b & c | ~b & d) + k[4] - 176418897 | 0;
|
||
a = (a << 7 | a >>> 25) + b | 0;
|
||
d += (a & b | ~a & c) + k[5] + 1200080426 | 0;
|
||
d = (d << 12 | d >>> 20) + a | 0;
|
||
c += (d & a | ~d & b) + k[6] - 1473231341 | 0;
|
||
c = (c << 17 | c >>> 15) + d | 0;
|
||
b += (c & d | ~c & a) + k[7] - 45705983 | 0;
|
||
b = (b << 22 | b >>> 10) + c | 0;
|
||
a += (b & c | ~b & d) + k[8] + 1770035416 | 0;
|
||
a = (a << 7 | a >>> 25) + b | 0;
|
||
d += (a & b | ~a & c) + k[9] - 1958414417 | 0;
|
||
d = (d << 12 | d >>> 20) + a | 0;
|
||
c += (d & a | ~d & b) + k[10] - 42063 | 0;
|
||
c = (c << 17 | c >>> 15) + d | 0;
|
||
b += (c & d | ~c & a) + k[11] - 1990404162 | 0;
|
||
b = (b << 22 | b >>> 10) + c | 0;
|
||
a += (b & c | ~b & d) + k[12] + 1804603682 | 0;
|
||
a = (a << 7 | a >>> 25) + b | 0;
|
||
d += (a & b | ~a & c) + k[13] - 40341101 | 0;
|
||
d = (d << 12 | d >>> 20) + a | 0;
|
||
c += (d & a | ~d & b) + k[14] - 1502002290 | 0;
|
||
c = (c << 17 | c >>> 15) + d | 0;
|
||
b += (c & d | ~c & a) + k[15] + 1236535329 | 0;
|
||
b = (b << 22 | b >>> 10) + c | 0;
|
||
a += (b & d | c & ~d) + k[1] - 165796510 | 0;
|
||
a = (a << 5 | a >>> 27) + b | 0;
|
||
d += (a & c | b & ~c) + k[6] - 1069501632 | 0;
|
||
d = (d << 9 | d >>> 23) + a | 0;
|
||
c += (d & b | a & ~b) + k[11] + 643717713 | 0;
|
||
c = (c << 14 | c >>> 18) + d | 0;
|
||
b += (c & a | d & ~a) + k[0] - 373897302 | 0;
|
||
b = (b << 20 | b >>> 12) + c | 0;
|
||
a += (b & d | c & ~d) + k[5] - 701558691 | 0;
|
||
a = (a << 5 | a >>> 27) + b | 0;
|
||
d += (a & c | b & ~c) + k[10] + 38016083 | 0;
|
||
d = (d << 9 | d >>> 23) + a | 0;
|
||
c += (d & b | a & ~b) + k[15] - 660478335 | 0;
|
||
c = (c << 14 | c >>> 18) + d | 0;
|
||
b += (c & a | d & ~a) + k[4] - 405537848 | 0;
|
||
b = (b << 20 | b >>> 12) + c | 0;
|
||
a += (b & d | c & ~d) + k[9] + 568446438 | 0;
|
||
a = (a << 5 | a >>> 27) + b | 0;
|
||
d += (a & c | b & ~c) + k[14] - 1019803690 | 0;
|
||
d = (d << 9 | d >>> 23) + a | 0;
|
||
c += (d & b | a & ~b) + k[3] - 187363961 | 0;
|
||
c = (c << 14 | c >>> 18) + d | 0;
|
||
b += (c & a | d & ~a) + k[8] + 1163531501 | 0;
|
||
b = (b << 20 | b >>> 12) + c | 0;
|
||
a += (b & d | c & ~d) + k[13] - 1444681467 | 0;
|
||
a = (a << 5 | a >>> 27) + b | 0;
|
||
d += (a & c | b & ~c) + k[2] - 51403784 | 0;
|
||
d = (d << 9 | d >>> 23) + a | 0;
|
||
c += (d & b | a & ~b) + k[7] + 1735328473 | 0;
|
||
c = (c << 14 | c >>> 18) + d | 0;
|
||
b += (c & a | d & ~a) + k[12] - 1926607734 | 0;
|
||
b = (b << 20 | b >>> 12) + c | 0;
|
||
a += (b ^ c ^ d) + k[5] - 378558 | 0;
|
||
a = (a << 4 | a >>> 28) + b | 0;
|
||
d += (a ^ b ^ c) + k[8] - 2022574463 | 0;
|
||
d = (d << 11 | d >>> 21) + a | 0;
|
||
c += (d ^ a ^ b) + k[11] + 1839030562 | 0;
|
||
c = (c << 16 | c >>> 16) + d | 0;
|
||
b += (c ^ d ^ a) + k[14] - 35309556 | 0;
|
||
b = (b << 23 | b >>> 9) + c | 0;
|
||
a += (b ^ c ^ d) + k[1] - 1530992060 | 0;
|
||
a = (a << 4 | a >>> 28) + b | 0;
|
||
d += (a ^ b ^ c) + k[4] + 1272893353 | 0;
|
||
d = (d << 11 | d >>> 21) + a | 0;
|
||
c += (d ^ a ^ b) + k[7] - 155497632 | 0;
|
||
c = (c << 16 | c >>> 16) + d | 0;
|
||
b += (c ^ d ^ a) + k[10] - 1094730640 | 0;
|
||
b = (b << 23 | b >>> 9) + c | 0;
|
||
a += (b ^ c ^ d) + k[13] + 681279174 | 0;
|
||
a = (a << 4 | a >>> 28) + b | 0;
|
||
d += (a ^ b ^ c) + k[0] - 358537222 | 0;
|
||
d = (d << 11 | d >>> 21) + a | 0;
|
||
c += (d ^ a ^ b) + k[3] - 722521979 | 0;
|
||
c = (c << 16 | c >>> 16) + d | 0;
|
||
b += (c ^ d ^ a) + k[6] + 76029189 | 0;
|
||
b = (b << 23 | b >>> 9) + c | 0;
|
||
a += (b ^ c ^ d) + k[9] - 640364487 | 0;
|
||
a = (a << 4 | a >>> 28) + b | 0;
|
||
d += (a ^ b ^ c) + k[12] - 421815835 | 0;
|
||
d = (d << 11 | d >>> 21) + a | 0;
|
||
c += (d ^ a ^ b) + k[15] + 530742520 | 0;
|
||
c = (c << 16 | c >>> 16) + d | 0;
|
||
b += (c ^ d ^ a) + k[2] - 995338651 | 0;
|
||
b = (b << 23 | b >>> 9) + c | 0;
|
||
a += (c ^ (b | ~d)) + k[0] - 198630844 | 0;
|
||
a = (a << 6 | a >>> 26) + b | 0;
|
||
d += (b ^ (a | ~c)) + k[7] + 1126891415 | 0;
|
||
d = (d << 10 | d >>> 22) + a | 0;
|
||
c += (a ^ (d | ~b)) + k[14] - 1416354905 | 0;
|
||
c = (c << 15 | c >>> 17) + d | 0;
|
||
b += (d ^ (c | ~a)) + k[5] - 57434055 | 0;
|
||
b = (b << 21 | b >>> 11) + c | 0;
|
||
a += (c ^ (b | ~d)) + k[12] + 1700485571 | 0;
|
||
a = (a << 6 | a >>> 26) + b | 0;
|
||
d += (b ^ (a | ~c)) + k[3] - 1894986606 | 0;
|
||
d = (d << 10 | d >>> 22) + a | 0;
|
||
c += (a ^ (d | ~b)) + k[10] - 1051523 | 0;
|
||
c = (c << 15 | c >>> 17) + d | 0;
|
||
b += (d ^ (c | ~a)) + k[1] - 2054922799 | 0;
|
||
b = (b << 21 | b >>> 11) + c | 0;
|
||
a += (c ^ (b | ~d)) + k[8] + 1873313359 | 0;
|
||
a = (a << 6 | a >>> 26) + b | 0;
|
||
d += (b ^ (a | ~c)) + k[15] - 30611744 | 0;
|
||
d = (d << 10 | d >>> 22) + a | 0;
|
||
c += (a ^ (d | ~b)) + k[6] - 1560198380 | 0;
|
||
c = (c << 15 | c >>> 17) + d | 0;
|
||
b += (d ^ (c | ~a)) + k[13] + 1309151649 | 0;
|
||
b = (b << 21 | b >>> 11) + c | 0;
|
||
a += (c ^ (b | ~d)) + k[4] - 145523070 | 0;
|
||
a = (a << 6 | a >>> 26) + b | 0;
|
||
d += (b ^ (a | ~c)) + k[11] - 1120210379 | 0;
|
||
d = (d << 10 | d >>> 22) + a | 0;
|
||
c += (a ^ (d | ~b)) + k[2] + 718787259 | 0;
|
||
c = (c << 15 | c >>> 17) + d | 0;
|
||
b += (d ^ (c | ~a)) + k[9] - 343485551 | 0;
|
||
b = (b << 21 | b >>> 11) + c | 0;
|
||
x[0] = a + x[0] | 0;
|
||
x[1] = b + x[1] | 0;
|
||
x[2] = c + x[2] | 0;
|
||
x[3] = d + x[3] | 0;
|
||
}
|
||
function md5blk(s) {
|
||
var md5blks = [], i;
|
||
for (i = 0; i < 64; i += 4) {
|
||
md5blks[i >> 2] = s.charCodeAt(i) + (s.charCodeAt(i + 1) << 8) + (s.charCodeAt(i + 2) << 16) + (s.charCodeAt(i + 3) << 24);
|
||
}
|
||
return md5blks;
|
||
}
|
||
function md5blk_array(a) {
|
||
var md5blks = [], i;
|
||
for (i = 0; i < 64; i += 4) {
|
||
md5blks[i >> 2] = a[i] + (a[i + 1] << 8) + (a[i + 2] << 16) + (a[i + 3] << 24);
|
||
}
|
||
return md5blks;
|
||
}
|
||
function md51(s) {
|
||
var n = s.length, state = [1732584193, -271733879, -1732584194, 271733878], i, length, tail, tmp, lo, hi;
|
||
for (i = 64; i <= n; i += 64) {
|
||
md5cycle(state, md5blk(s.substring(i - 64, i)));
|
||
}
|
||
s = s.substring(i - 64);
|
||
length = s.length;
|
||
tail = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
|
||
for (i = 0; i < length; i += 1) {
|
||
tail[i >> 2] |= s.charCodeAt(i) << (i % 4 << 3);
|
||
}
|
||
tail[i >> 2] |= 128 << (i % 4 << 3);
|
||
if (i > 55) {
|
||
md5cycle(state, tail);
|
||
for (i = 0; i < 16; i += 1) {
|
||
tail[i] = 0;
|
||
}
|
||
}
|
||
tmp = n * 8;
|
||
tmp = tmp.toString(16).match(/(.*?)(.{0,8})$/);
|
||
lo = parseInt(tmp[2], 16);
|
||
hi = parseInt(tmp[1], 16) || 0;
|
||
tail[14] = lo;
|
||
tail[15] = hi;
|
||
md5cycle(state, tail);
|
||
return state;
|
||
}
|
||
function md51_array(a) {
|
||
var n = a.length, state = [1732584193, -271733879, -1732584194, 271733878], i, length, tail, tmp, lo, hi;
|
||
for (i = 64; i <= n; i += 64) {
|
||
md5cycle(state, md5blk_array(a.subarray(i - 64, i)));
|
||
}
|
||
a = i - 64 < n ? a.subarray(i - 64) : new Uint8Array(0);
|
||
length = a.length;
|
||
tail = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
|
||
for (i = 0; i < length; i += 1) {
|
||
tail[i >> 2] |= a[i] << (i % 4 << 3);
|
||
}
|
||
tail[i >> 2] |= 128 << (i % 4 << 3);
|
||
if (i > 55) {
|
||
md5cycle(state, tail);
|
||
for (i = 0; i < 16; i += 1) {
|
||
tail[i] = 0;
|
||
}
|
||
}
|
||
tmp = n * 8;
|
||
tmp = tmp.toString(16).match(/(.*?)(.{0,8})$/);
|
||
lo = parseInt(tmp[2], 16);
|
||
hi = parseInt(tmp[1], 16) || 0;
|
||
tail[14] = lo;
|
||
tail[15] = hi;
|
||
md5cycle(state, tail);
|
||
return state;
|
||
}
|
||
function rhex(n) {
|
||
var s = "", j;
|
||
for (j = 0; j < 4; j += 1) {
|
||
s += hex_chr[n >> j * 8 + 4 & 15] + hex_chr[n >> j * 8 & 15];
|
||
}
|
||
return s;
|
||
}
|
||
function hex(x) {
|
||
var i;
|
||
for (i = 0; i < x.length; i += 1) {
|
||
x[i] = rhex(x[i]);
|
||
}
|
||
return x.join("");
|
||
}
|
||
if (hex(md51("hello")) !== "5d41402abc4b2a76b9719d911017c592")
|
||
;
|
||
if (typeof ArrayBuffer !== "undefined" && !ArrayBuffer.prototype.slice) {
|
||
(function() {
|
||
function clamp(val, length) {
|
||
val = val | 0 || 0;
|
||
if (val < 0) {
|
||
return Math.max(val + length, 0);
|
||
}
|
||
return Math.min(val, length);
|
||
}
|
||
ArrayBuffer.prototype.slice = function(from, to) {
|
||
var length = this.byteLength, begin = clamp(from, length), end2 = length, num, target, targetArray, sourceArray;
|
||
if (to !== undefined$1) {
|
||
end2 = clamp(to, length);
|
||
}
|
||
if (begin > end2) {
|
||
return new ArrayBuffer(0);
|
||
}
|
||
num = end2 - begin;
|
||
target = new ArrayBuffer(num);
|
||
targetArray = new Uint8Array(target);
|
||
sourceArray = new Uint8Array(this, begin, num);
|
||
targetArray.set(sourceArray);
|
||
return target;
|
||
};
|
||
})();
|
||
}
|
||
function toUtf8(str) {
|
||
if (/[\u0080-\uFFFF]/.test(str)) {
|
||
str = unescape(encodeURIComponent(str));
|
||
}
|
||
return str;
|
||
}
|
||
function utf8Str2ArrayBuffer(str, returnUInt8Array) {
|
||
var length = str.length, buff = new ArrayBuffer(length), arr = new Uint8Array(buff), i;
|
||
for (i = 0; i < length; i += 1) {
|
||
arr[i] = str.charCodeAt(i);
|
||
}
|
||
return returnUInt8Array ? arr : buff;
|
||
}
|
||
function arrayBuffer2Utf8Str(buff) {
|
||
return String.fromCharCode.apply(null, new Uint8Array(buff));
|
||
}
|
||
function concatenateArrayBuffers(first, second, returnUInt8Array) {
|
||
var result = new Uint8Array(first.byteLength + second.byteLength);
|
||
result.set(new Uint8Array(first));
|
||
result.set(new Uint8Array(second), first.byteLength);
|
||
return returnUInt8Array ? result : result.buffer;
|
||
}
|
||
function hexToBinaryString(hex2) {
|
||
var bytes = [], length = hex2.length, x;
|
||
for (x = 0; x < length - 1; x += 2) {
|
||
bytes.push(parseInt(hex2.substr(x, 2), 16));
|
||
}
|
||
return String.fromCharCode.apply(String, bytes);
|
||
}
|
||
function SparkMD52() {
|
||
this.reset();
|
||
}
|
||
SparkMD52.prototype.append = function(str) {
|
||
this.appendBinary(toUtf8(str));
|
||
return this;
|
||
};
|
||
SparkMD52.prototype.appendBinary = function(contents) {
|
||
this._buff += contents;
|
||
this._length += contents.length;
|
||
var length = this._buff.length, i;
|
||
for (i = 64; i <= length; i += 64) {
|
||
md5cycle(this._hash, md5blk(this._buff.substring(i - 64, i)));
|
||
}
|
||
this._buff = this._buff.substring(i - 64);
|
||
return this;
|
||
};
|
||
SparkMD52.prototype.end = function(raw) {
|
||
var buff = this._buff, length = buff.length, i, tail = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], ret;
|
||
for (i = 0; i < length; i += 1) {
|
||
tail[i >> 2] |= buff.charCodeAt(i) << (i % 4 << 3);
|
||
}
|
||
this._finish(tail, length);
|
||
ret = hex(this._hash);
|
||
if (raw) {
|
||
ret = hexToBinaryString(ret);
|
||
}
|
||
this.reset();
|
||
return ret;
|
||
};
|
||
SparkMD52.prototype.reset = function() {
|
||
this._buff = "";
|
||
this._length = 0;
|
||
this._hash = [1732584193, -271733879, -1732584194, 271733878];
|
||
return this;
|
||
};
|
||
SparkMD52.prototype.getState = function() {
|
||
return {
|
||
buff: this._buff,
|
||
length: this._length,
|
||
hash: this._hash.slice()
|
||
};
|
||
};
|
||
SparkMD52.prototype.setState = function(state) {
|
||
this._buff = state.buff;
|
||
this._length = state.length;
|
||
this._hash = state.hash;
|
||
return this;
|
||
};
|
||
SparkMD52.prototype.destroy = function() {
|
||
delete this._hash;
|
||
delete this._buff;
|
||
delete this._length;
|
||
};
|
||
SparkMD52.prototype._finish = function(tail, length) {
|
||
var i = length, tmp, lo, hi;
|
||
tail[i >> 2] |= 128 << (i % 4 << 3);
|
||
if (i > 55) {
|
||
md5cycle(this._hash, tail);
|
||
for (i = 0; i < 16; i += 1) {
|
||
tail[i] = 0;
|
||
}
|
||
}
|
||
tmp = this._length * 8;
|
||
tmp = tmp.toString(16).match(/(.*?)(.{0,8})$/);
|
||
lo = parseInt(tmp[2], 16);
|
||
hi = parseInt(tmp[1], 16) || 0;
|
||
tail[14] = lo;
|
||
tail[15] = hi;
|
||
md5cycle(this._hash, tail);
|
||
};
|
||
SparkMD52.hash = function(str, raw) {
|
||
return SparkMD52.hashBinary(toUtf8(str), raw);
|
||
};
|
||
SparkMD52.hashBinary = function(content, raw) {
|
||
var hash3 = md51(content), ret = hex(hash3);
|
||
return raw ? hexToBinaryString(ret) : ret;
|
||
};
|
||
SparkMD52.ArrayBuffer = function() {
|
||
this.reset();
|
||
};
|
||
SparkMD52.ArrayBuffer.prototype.append = function(arr) {
|
||
var buff = concatenateArrayBuffers(this._buff.buffer, arr, true), length = buff.length, i;
|
||
this._length += arr.byteLength;
|
||
for (i = 64; i <= length; i += 64) {
|
||
md5cycle(this._hash, md5blk_array(buff.subarray(i - 64, i)));
|
||
}
|
||
this._buff = i - 64 < length ? new Uint8Array(buff.buffer.slice(i - 64)) : new Uint8Array(0);
|
||
return this;
|
||
};
|
||
SparkMD52.ArrayBuffer.prototype.end = function(raw) {
|
||
var buff = this._buff, length = buff.length, tail = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], i, ret;
|
||
for (i = 0; i < length; i += 1) {
|
||
tail[i >> 2] |= buff[i] << (i % 4 << 3);
|
||
}
|
||
this._finish(tail, length);
|
||
ret = hex(this._hash);
|
||
if (raw) {
|
||
ret = hexToBinaryString(ret);
|
||
}
|
||
this.reset();
|
||
return ret;
|
||
};
|
||
SparkMD52.ArrayBuffer.prototype.reset = function() {
|
||
this._buff = new Uint8Array(0);
|
||
this._length = 0;
|
||
this._hash = [1732584193, -271733879, -1732584194, 271733878];
|
||
return this;
|
||
};
|
||
SparkMD52.ArrayBuffer.prototype.getState = function() {
|
||
var state = SparkMD52.prototype.getState.call(this);
|
||
state.buff = arrayBuffer2Utf8Str(state.buff);
|
||
return state;
|
||
};
|
||
SparkMD52.ArrayBuffer.prototype.setState = function(state) {
|
||
state.buff = utf8Str2ArrayBuffer(state.buff, true);
|
||
return SparkMD52.prototype.setState.call(this, state);
|
||
};
|
||
SparkMD52.ArrayBuffer.prototype.destroy = SparkMD52.prototype.destroy;
|
||
SparkMD52.ArrayBuffer.prototype._finish = SparkMD52.prototype._finish;
|
||
SparkMD52.ArrayBuffer.hash = function(arr, raw) {
|
||
var hash3 = md51_array(new Uint8Array(arr)), ret = hex(hash3);
|
||
return raw ? hexToBinaryString(ret) : ret;
|
||
};
|
||
return SparkMD52;
|
||
});
|
||
})(sparkMd5);
|
||
var SparkMD5 = sparkMd5.exports;
|
||
var fileSlice = File.prototype.slice || File.prototype.mozSlice || File.prototype.webkitSlice;
|
||
var FileChecksum = class _FileChecksum {
|
||
static create(file, callback) {
|
||
const instance = new _FileChecksum(file);
|
||
instance.create(callback);
|
||
}
|
||
constructor(file) {
|
||
this.file = file;
|
||
this.chunkSize = 2097152;
|
||
this.chunkCount = Math.ceil(this.file.size / this.chunkSize);
|
||
this.chunkIndex = 0;
|
||
}
|
||
create(callback) {
|
||
this.callback = callback;
|
||
this.md5Buffer = new SparkMD5.ArrayBuffer();
|
||
this.fileReader = new FileReader();
|
||
this.fileReader.addEventListener("load", (event) => this.fileReaderDidLoad(event));
|
||
this.fileReader.addEventListener("error", (event) => this.fileReaderDidError(event));
|
||
this.readNextChunk();
|
||
}
|
||
fileReaderDidLoad(event) {
|
||
this.md5Buffer.append(event.target.result);
|
||
if (!this.readNextChunk()) {
|
||
const binaryDigest = this.md5Buffer.end(true);
|
||
const base64digest = btoa(binaryDigest);
|
||
this.callback(null, base64digest);
|
||
}
|
||
}
|
||
fileReaderDidError(event) {
|
||
this.callback(`Error reading ${this.file.name}`);
|
||
}
|
||
readNextChunk() {
|
||
if (this.chunkIndex < this.chunkCount || this.chunkIndex == 0 && this.chunkCount == 0) {
|
||
const start4 = this.chunkIndex * this.chunkSize;
|
||
const end2 = Math.min(start4 + this.chunkSize, this.file.size);
|
||
const bytes = fileSlice.call(this.file, start4, end2);
|
||
this.fileReader.readAsArrayBuffer(bytes);
|
||
this.chunkIndex++;
|
||
return true;
|
||
} else {
|
||
return false;
|
||
}
|
||
}
|
||
};
|
||
function getMetaValue(name) {
|
||
const element = findElement(document.head, `meta[name="${name}"]`);
|
||
if (element) {
|
||
return element.getAttribute("content");
|
||
}
|
||
}
|
||
function findElements(root, selector) {
|
||
if (typeof root == "string") {
|
||
selector = root;
|
||
root = document;
|
||
}
|
||
const elements = root.querySelectorAll(selector);
|
||
return toArray(elements);
|
||
}
|
||
function findElement(root, selector) {
|
||
if (typeof root == "string") {
|
||
selector = root;
|
||
root = document;
|
||
}
|
||
return root.querySelector(selector);
|
||
}
|
||
function dispatchEvent2(element, type, eventInit = {}) {
|
||
const { disabled } = element;
|
||
const { bubbles, cancelable, detail } = eventInit;
|
||
const event = document.createEvent("Event");
|
||
event.initEvent(type, bubbles || true, cancelable || true);
|
||
event.detail = detail || {};
|
||
try {
|
||
element.disabled = false;
|
||
element.dispatchEvent(event);
|
||
} finally {
|
||
element.disabled = disabled;
|
||
}
|
||
return event;
|
||
}
|
||
function toArray(value) {
|
||
if (Array.isArray(value)) {
|
||
return value;
|
||
} else if (Array.from) {
|
||
return Array.from(value);
|
||
} else {
|
||
return [].slice.call(value);
|
||
}
|
||
}
|
||
var BlobRecord = class {
|
||
constructor(file, checksum, url) {
|
||
this.file = file;
|
||
this.attributes = {
|
||
filename: file.name,
|
||
content_type: file.type || "application/octet-stream",
|
||
byte_size: file.size,
|
||
checksum
|
||
};
|
||
this.xhr = new XMLHttpRequest();
|
||
this.xhr.open("POST", url, true);
|
||
this.xhr.responseType = "json";
|
||
this.xhr.setRequestHeader("Content-Type", "application/json");
|
||
this.xhr.setRequestHeader("Accept", "application/json");
|
||
this.xhr.setRequestHeader("X-Requested-With", "XMLHttpRequest");
|
||
const csrfToken = getMetaValue("csrf-token");
|
||
if (csrfToken != void 0) {
|
||
this.xhr.setRequestHeader("X-CSRF-Token", csrfToken);
|
||
}
|
||
this.xhr.addEventListener("load", (event) => this.requestDidLoad(event));
|
||
this.xhr.addEventListener("error", (event) => this.requestDidError(event));
|
||
}
|
||
get status() {
|
||
return this.xhr.status;
|
||
}
|
||
get response() {
|
||
const { responseType, response } = this.xhr;
|
||
if (responseType == "json") {
|
||
return response;
|
||
} else {
|
||
return JSON.parse(response);
|
||
}
|
||
}
|
||
create(callback) {
|
||
this.callback = callback;
|
||
this.xhr.send(JSON.stringify({
|
||
blob: this.attributes
|
||
}));
|
||
}
|
||
requestDidLoad(event) {
|
||
if (this.status >= 200 && this.status < 300) {
|
||
const { response } = this;
|
||
const { direct_upload } = response;
|
||
delete response.direct_upload;
|
||
this.attributes = response;
|
||
this.directUploadData = direct_upload;
|
||
this.callback(null, this.toJSON());
|
||
} else {
|
||
this.requestDidError(event);
|
||
}
|
||
}
|
||
requestDidError(event) {
|
||
this.callback(`Error creating Blob for "${this.file.name}". Status: ${this.status}`);
|
||
}
|
||
toJSON() {
|
||
const result = {};
|
||
for (const key in this.attributes) {
|
||
result[key] = this.attributes[key];
|
||
}
|
||
return result;
|
||
}
|
||
};
|
||
var BlobUpload = class {
|
||
constructor(blob) {
|
||
this.blob = blob;
|
||
this.file = blob.file;
|
||
const { url, headers } = blob.directUploadData;
|
||
this.xhr = new XMLHttpRequest();
|
||
this.xhr.open("PUT", url, true);
|
||
this.xhr.responseType = "text";
|
||
for (const key in headers) {
|
||
this.xhr.setRequestHeader(key, headers[key]);
|
||
}
|
||
this.xhr.addEventListener("load", (event) => this.requestDidLoad(event));
|
||
this.xhr.addEventListener("error", (event) => this.requestDidError(event));
|
||
}
|
||
create(callback) {
|
||
this.callback = callback;
|
||
this.xhr.send(this.file.slice());
|
||
}
|
||
requestDidLoad(event) {
|
||
const { status, response } = this.xhr;
|
||
if (status >= 200 && status < 300) {
|
||
this.callback(null, response);
|
||
} else {
|
||
this.requestDidError(event);
|
||
}
|
||
}
|
||
requestDidError(event) {
|
||
this.callback(`Error storing "${this.file.name}". Status: ${this.xhr.status}`);
|
||
}
|
||
};
|
||
var id = 0;
|
||
var DirectUpload = class {
|
||
constructor(file, url, delegate) {
|
||
this.id = ++id;
|
||
this.file = file;
|
||
this.url = url;
|
||
this.delegate = delegate;
|
||
}
|
||
create(callback) {
|
||
FileChecksum.create(this.file, (error2, checksum) => {
|
||
if (error2) {
|
||
callback(error2);
|
||
return;
|
||
}
|
||
const blob = new BlobRecord(this.file, checksum, this.url);
|
||
notify(this.delegate, "directUploadWillCreateBlobWithXHR", blob.xhr);
|
||
blob.create((error3) => {
|
||
if (error3) {
|
||
callback(error3);
|
||
} else {
|
||
const upload = new BlobUpload(blob);
|
||
notify(this.delegate, "directUploadWillStoreFileWithXHR", upload.xhr);
|
||
upload.create((error4) => {
|
||
if (error4) {
|
||
callback(error4);
|
||
} else {
|
||
callback(null, blob.toJSON());
|
||
}
|
||
});
|
||
}
|
||
});
|
||
});
|
||
}
|
||
};
|
||
function notify(object, methodName, ...messages) {
|
||
if (object && typeof object[methodName] == "function") {
|
||
return object[methodName](...messages);
|
||
}
|
||
}
|
||
var DirectUploadController = class {
|
||
constructor(input, file) {
|
||
this.input = input;
|
||
this.file = file;
|
||
this.directUpload = new DirectUpload(this.file, this.url, this);
|
||
this.dispatch("initialize");
|
||
}
|
||
start(callback) {
|
||
const hiddenInput = document.createElement("input");
|
||
hiddenInput.type = "hidden";
|
||
hiddenInput.name = this.input.name;
|
||
this.input.insertAdjacentElement("beforebegin", hiddenInput);
|
||
this.dispatch("start");
|
||
this.directUpload.create((error2, attributes) => {
|
||
if (error2) {
|
||
hiddenInput.parentNode.removeChild(hiddenInput);
|
||
this.dispatchError(error2);
|
||
} else {
|
||
hiddenInput.value = attributes.signed_id;
|
||
}
|
||
this.dispatch("end");
|
||
callback(error2);
|
||
});
|
||
}
|
||
uploadRequestDidProgress(event) {
|
||
const progress = event.loaded / event.total * 100;
|
||
if (progress) {
|
||
this.dispatch("progress", {
|
||
progress
|
||
});
|
||
}
|
||
}
|
||
get url() {
|
||
return this.input.getAttribute("data-direct-upload-url");
|
||
}
|
||
dispatch(name, detail = {}) {
|
||
detail.file = this.file;
|
||
detail.id = this.directUpload.id;
|
||
return dispatchEvent2(this.input, `direct-upload:${name}`, {
|
||
detail
|
||
});
|
||
}
|
||
dispatchError(error2) {
|
||
const event = this.dispatch("error", {
|
||
error: error2
|
||
});
|
||
if (!event.defaultPrevented) {
|
||
alert(error2);
|
||
}
|
||
}
|
||
directUploadWillCreateBlobWithXHR(xhr) {
|
||
this.dispatch("before-blob-request", {
|
||
xhr
|
||
});
|
||
}
|
||
directUploadWillStoreFileWithXHR(xhr) {
|
||
this.dispatch("before-storage-request", {
|
||
xhr
|
||
});
|
||
xhr.upload.addEventListener("progress", (event) => this.uploadRequestDidProgress(event));
|
||
}
|
||
};
|
||
var inputSelector = "input[type=file][data-direct-upload-url]:not([disabled])";
|
||
var DirectUploadsController = class {
|
||
constructor(form) {
|
||
this.form = form;
|
||
this.inputs = findElements(form, inputSelector).filter((input) => input.files.length);
|
||
}
|
||
start(callback) {
|
||
const controllers = this.createDirectUploadControllers();
|
||
const startNextController = () => {
|
||
const controller = controllers.shift();
|
||
if (controller) {
|
||
controller.start((error2) => {
|
||
if (error2) {
|
||
callback(error2);
|
||
this.dispatch("end");
|
||
} else {
|
||
startNextController();
|
||
}
|
||
});
|
||
} else {
|
||
callback();
|
||
this.dispatch("end");
|
||
}
|
||
};
|
||
this.dispatch("start");
|
||
startNextController();
|
||
}
|
||
createDirectUploadControllers() {
|
||
const controllers = [];
|
||
this.inputs.forEach((input) => {
|
||
toArray(input.files).forEach((file) => {
|
||
const controller = new DirectUploadController(input, file);
|
||
controllers.push(controller);
|
||
});
|
||
});
|
||
return controllers;
|
||
}
|
||
dispatch(name, detail = {}) {
|
||
return dispatchEvent2(this.form, `direct-uploads:${name}`, {
|
||
detail
|
||
});
|
||
}
|
||
};
|
||
var processingAttribute = "data-direct-uploads-processing";
|
||
var submitButtonsByForm = /* @__PURE__ */ new WeakMap();
|
||
var started = false;
|
||
function start() {
|
||
if (!started) {
|
||
started = true;
|
||
document.addEventListener("click", didClick, true);
|
||
document.addEventListener("submit", didSubmitForm, true);
|
||
document.addEventListener("ajax:before", didSubmitRemoteElement);
|
||
}
|
||
}
|
||
function didClick(event) {
|
||
const { target } = event;
|
||
if ((target.tagName == "INPUT" || target.tagName == "BUTTON") && target.type == "submit" && target.form) {
|
||
submitButtonsByForm.set(target.form, target);
|
||
}
|
||
}
|
||
function didSubmitForm(event) {
|
||
handleFormSubmissionEvent(event);
|
||
}
|
||
function didSubmitRemoteElement(event) {
|
||
if (event.target.tagName == "FORM") {
|
||
handleFormSubmissionEvent(event);
|
||
}
|
||
}
|
||
function handleFormSubmissionEvent(event) {
|
||
const form = event.target;
|
||
if (form.hasAttribute(processingAttribute)) {
|
||
event.preventDefault();
|
||
return;
|
||
}
|
||
const controller = new DirectUploadsController(form);
|
||
const { inputs } = controller;
|
||
if (inputs.length) {
|
||
event.preventDefault();
|
||
form.setAttribute(processingAttribute, "");
|
||
inputs.forEach(disable);
|
||
controller.start((error2) => {
|
||
form.removeAttribute(processingAttribute);
|
||
if (error2) {
|
||
inputs.forEach(enable);
|
||
} else {
|
||
submitForm(form);
|
||
}
|
||
});
|
||
}
|
||
}
|
||
function submitForm(form) {
|
||
let button = submitButtonsByForm.get(form) || findElement(form, "input[type=submit], button[type=submit]");
|
||
if (button) {
|
||
const { disabled } = button;
|
||
button.disabled = false;
|
||
button.focus();
|
||
button.click();
|
||
button.disabled = disabled;
|
||
} else {
|
||
button = document.createElement("input");
|
||
button.type = "submit";
|
||
button.style.display = "none";
|
||
form.appendChild(button);
|
||
button.click();
|
||
form.removeChild(button);
|
||
}
|
||
submitButtonsByForm.delete(form);
|
||
}
|
||
function disable(input) {
|
||
input.disabled = true;
|
||
}
|
||
function enable(input) {
|
||
input.disabled = false;
|
||
}
|
||
function autostart() {
|
||
if (window.ActiveStorage) {
|
||
start();
|
||
}
|
||
}
|
||
setTimeout(autostart, 1);
|
||
|
||
// node_modules/@popperjs/core/lib/index.js
|
||
var lib_exports = {};
|
||
__export(lib_exports, {
|
||
afterMain: () => afterMain,
|
||
afterRead: () => afterRead,
|
||
afterWrite: () => afterWrite,
|
||
applyStyles: () => applyStyles_default,
|
||
arrow: () => arrow_default,
|
||
auto: () => auto,
|
||
basePlacements: () => basePlacements,
|
||
beforeMain: () => beforeMain,
|
||
beforeRead: () => beforeRead,
|
||
beforeWrite: () => beforeWrite,
|
||
bottom: () => bottom,
|
||
clippingParents: () => clippingParents,
|
||
computeStyles: () => computeStyles_default,
|
||
createPopper: () => createPopper3,
|
||
createPopperBase: () => createPopper,
|
||
createPopperLite: () => createPopper2,
|
||
detectOverflow: () => detectOverflow,
|
||
end: () => end,
|
||
eventListeners: () => eventListeners_default,
|
||
flip: () => flip_default,
|
||
hide: () => hide_default,
|
||
left: () => left,
|
||
main: () => main,
|
||
modifierPhases: () => modifierPhases,
|
||
offset: () => offset_default,
|
||
placements: () => placements,
|
||
popper: () => popper,
|
||
popperGenerator: () => popperGenerator,
|
||
popperOffsets: () => popperOffsets_default,
|
||
preventOverflow: () => preventOverflow_default,
|
||
read: () => read,
|
||
reference: () => reference,
|
||
right: () => right,
|
||
start: () => start2,
|
||
top: () => top,
|
||
variationPlacements: () => variationPlacements,
|
||
viewport: () => viewport,
|
||
write: () => write
|
||
});
|
||
|
||
// node_modules/@popperjs/core/lib/enums.js
|
||
var top = "top";
|
||
var bottom = "bottom";
|
||
var right = "right";
|
||
var left = "left";
|
||
var auto = "auto";
|
||
var basePlacements = [top, bottom, right, left];
|
||
var start2 = "start";
|
||
var end = "end";
|
||
var clippingParents = "clippingParents";
|
||
var viewport = "viewport";
|
||
var popper = "popper";
|
||
var reference = "reference";
|
||
var variationPlacements = /* @__PURE__ */ basePlacements.reduce(function(acc, placement) {
|
||
return acc.concat([placement + "-" + start2, placement + "-" + end]);
|
||
}, []);
|
||
var placements = /* @__PURE__ */ [].concat(basePlacements, [auto]).reduce(function(acc, placement) {
|
||
return acc.concat([placement, placement + "-" + start2, placement + "-" + end]);
|
||
}, []);
|
||
var beforeRead = "beforeRead";
|
||
var read = "read";
|
||
var afterRead = "afterRead";
|
||
var beforeMain = "beforeMain";
|
||
var main = "main";
|
||
var afterMain = "afterMain";
|
||
var beforeWrite = "beforeWrite";
|
||
var write = "write";
|
||
var afterWrite = "afterWrite";
|
||
var modifierPhases = [beforeRead, read, afterRead, beforeMain, main, afterMain, beforeWrite, write, afterWrite];
|
||
|
||
// node_modules/@popperjs/core/lib/dom-utils/getNodeName.js
|
||
function getNodeName(element) {
|
||
return element ? (element.nodeName || "").toLowerCase() : null;
|
||
}
|
||
|
||
// node_modules/@popperjs/core/lib/dom-utils/getWindow.js
|
||
function getWindow(node) {
|
||
if (node == null) {
|
||
return window;
|
||
}
|
||
if (node.toString() !== "[object Window]") {
|
||
var ownerDocument = node.ownerDocument;
|
||
return ownerDocument ? ownerDocument.defaultView || window : window;
|
||
}
|
||
return node;
|
||
}
|
||
|
||
// node_modules/@popperjs/core/lib/dom-utils/instanceOf.js
|
||
function isElement(node) {
|
||
var OwnElement = getWindow(node).Element;
|
||
return node instanceof OwnElement || node instanceof Element;
|
||
}
|
||
function isHTMLElement(node) {
|
||
var OwnElement = getWindow(node).HTMLElement;
|
||
return node instanceof OwnElement || node instanceof HTMLElement;
|
||
}
|
||
function isShadowRoot(node) {
|
||
if (typeof ShadowRoot === "undefined") {
|
||
return false;
|
||
}
|
||
var OwnElement = getWindow(node).ShadowRoot;
|
||
return node instanceof OwnElement || node instanceof ShadowRoot;
|
||
}
|
||
|
||
// node_modules/@popperjs/core/lib/modifiers/applyStyles.js
|
||
function applyStyles(_ref) {
|
||
var state = _ref.state;
|
||
Object.keys(state.elements).forEach(function(name) {
|
||
var style = state.styles[name] || {};
|
||
var attributes = state.attributes[name] || {};
|
||
var element = state.elements[name];
|
||
if (!isHTMLElement(element) || !getNodeName(element)) {
|
||
return;
|
||
}
|
||
Object.assign(element.style, style);
|
||
Object.keys(attributes).forEach(function(name2) {
|
||
var value = attributes[name2];
|
||
if (value === false) {
|
||
element.removeAttribute(name2);
|
||
} else {
|
||
element.setAttribute(name2, value === true ? "" : value);
|
||
}
|
||
});
|
||
});
|
||
}
|
||
function effect(_ref2) {
|
||
var state = _ref2.state;
|
||
var initialStyles = {
|
||
popper: {
|
||
position: state.options.strategy,
|
||
left: "0",
|
||
top: "0",
|
||
margin: "0"
|
||
},
|
||
arrow: {
|
||
position: "absolute"
|
||
},
|
||
reference: {}
|
||
};
|
||
Object.assign(state.elements.popper.style, initialStyles.popper);
|
||
state.styles = initialStyles;
|
||
if (state.elements.arrow) {
|
||
Object.assign(state.elements.arrow.style, initialStyles.arrow);
|
||
}
|
||
return function() {
|
||
Object.keys(state.elements).forEach(function(name) {
|
||
var element = state.elements[name];
|
||
var attributes = state.attributes[name] || {};
|
||
var styleProperties = Object.keys(state.styles.hasOwnProperty(name) ? state.styles[name] : initialStyles[name]);
|
||
var style = styleProperties.reduce(function(style2, property) {
|
||
style2[property] = "";
|
||
return style2;
|
||
}, {});
|
||
if (!isHTMLElement(element) || !getNodeName(element)) {
|
||
return;
|
||
}
|
||
Object.assign(element.style, style);
|
||
Object.keys(attributes).forEach(function(attribute) {
|
||
element.removeAttribute(attribute);
|
||
});
|
||
});
|
||
};
|
||
}
|
||
var applyStyles_default = {
|
||
name: "applyStyles",
|
||
enabled: true,
|
||
phase: "write",
|
||
fn: applyStyles,
|
||
effect,
|
||
requires: ["computeStyles"]
|
||
};
|
||
|
||
// node_modules/@popperjs/core/lib/utils/getBasePlacement.js
|
||
function getBasePlacement(placement) {
|
||
return placement.split("-")[0];
|
||
}
|
||
|
||
// node_modules/@popperjs/core/lib/utils/math.js
|
||
var max = Math.max;
|
||
var min = Math.min;
|
||
var round = Math.round;
|
||
|
||
// node_modules/@popperjs/core/lib/utils/userAgent.js
|
||
function getUAString() {
|
||
var uaData = navigator.userAgentData;
|
||
if (uaData != null && uaData.brands && Array.isArray(uaData.brands)) {
|
||
return uaData.brands.map(function(item) {
|
||
return item.brand + "/" + item.version;
|
||
}).join(" ");
|
||
}
|
||
return navigator.userAgent;
|
||
}
|
||
|
||
// node_modules/@popperjs/core/lib/dom-utils/isLayoutViewport.js
|
||
function isLayoutViewport() {
|
||
return !/^((?!chrome|android).)*safari/i.test(getUAString());
|
||
}
|
||
|
||
// node_modules/@popperjs/core/lib/dom-utils/getBoundingClientRect.js
|
||
function getBoundingClientRect(element, includeScale, isFixedStrategy) {
|
||
if (includeScale === void 0) {
|
||
includeScale = false;
|
||
}
|
||
if (isFixedStrategy === void 0) {
|
||
isFixedStrategy = false;
|
||
}
|
||
var clientRect = element.getBoundingClientRect();
|
||
var scaleX = 1;
|
||
var scaleY = 1;
|
||
if (includeScale && isHTMLElement(element)) {
|
||
scaleX = element.offsetWidth > 0 ? round(clientRect.width) / element.offsetWidth || 1 : 1;
|
||
scaleY = element.offsetHeight > 0 ? round(clientRect.height) / element.offsetHeight || 1 : 1;
|
||
}
|
||
var _ref = isElement(element) ? getWindow(element) : window, visualViewport = _ref.visualViewport;
|
||
var addVisualOffsets = !isLayoutViewport() && isFixedStrategy;
|
||
var x = (clientRect.left + (addVisualOffsets && visualViewport ? visualViewport.offsetLeft : 0)) / scaleX;
|
||
var y = (clientRect.top + (addVisualOffsets && visualViewport ? visualViewport.offsetTop : 0)) / scaleY;
|
||
var width = clientRect.width / scaleX;
|
||
var height = clientRect.height / scaleY;
|
||
return {
|
||
width,
|
||
height,
|
||
top: y,
|
||
right: x + width,
|
||
bottom: y + height,
|
||
left: x,
|
||
x,
|
||
y
|
||
};
|
||
}
|
||
|
||
// node_modules/@popperjs/core/lib/dom-utils/getLayoutRect.js
|
||
function getLayoutRect(element) {
|
||
var clientRect = getBoundingClientRect(element);
|
||
var width = element.offsetWidth;
|
||
var height = element.offsetHeight;
|
||
if (Math.abs(clientRect.width - width) <= 1) {
|
||
width = clientRect.width;
|
||
}
|
||
if (Math.abs(clientRect.height - height) <= 1) {
|
||
height = clientRect.height;
|
||
}
|
||
return {
|
||
x: element.offsetLeft,
|
||
y: element.offsetTop,
|
||
width,
|
||
height
|
||
};
|
||
}
|
||
|
||
// node_modules/@popperjs/core/lib/dom-utils/contains.js
|
||
function contains(parent, child) {
|
||
var rootNode = child.getRootNode && child.getRootNode();
|
||
if (parent.contains(child)) {
|
||
return true;
|
||
} else if (rootNode && isShadowRoot(rootNode)) {
|
||
var next = child;
|
||
do {
|
||
if (next && parent.isSameNode(next)) {
|
||
return true;
|
||
}
|
||
next = next.parentNode || next.host;
|
||
} while (next);
|
||
}
|
||
return false;
|
||
}
|
||
|
||
// node_modules/@popperjs/core/lib/dom-utils/getComputedStyle.js
|
||
function getComputedStyle2(element) {
|
||
return getWindow(element).getComputedStyle(element);
|
||
}
|
||
|
||
// node_modules/@popperjs/core/lib/dom-utils/isTableElement.js
|
||
function isTableElement(element) {
|
||
return ["table", "td", "th"].indexOf(getNodeName(element)) >= 0;
|
||
}
|
||
|
||
// node_modules/@popperjs/core/lib/dom-utils/getDocumentElement.js
|
||
function getDocumentElement(element) {
|
||
return ((isElement(element) ? element.ownerDocument : (
|
||
// $FlowFixMe[prop-missing]
|
||
element.document
|
||
)) || window.document).documentElement;
|
||
}
|
||
|
||
// node_modules/@popperjs/core/lib/dom-utils/getParentNode.js
|
||
function getParentNode(element) {
|
||
if (getNodeName(element) === "html") {
|
||
return element;
|
||
}
|
||
return (
|
||
// this is a quicker (but less type safe) way to save quite some bytes from the bundle
|
||
// $FlowFixMe[incompatible-return]
|
||
// $FlowFixMe[prop-missing]
|
||
element.assignedSlot || // step into the shadow DOM of the parent of a slotted node
|
||
element.parentNode || // DOM Element detected
|
||
(isShadowRoot(element) ? element.host : null) || // ShadowRoot detected
|
||
// $FlowFixMe[incompatible-call]: HTMLElement is a Node
|
||
getDocumentElement(element)
|
||
);
|
||
}
|
||
|
||
// node_modules/@popperjs/core/lib/dom-utils/getOffsetParent.js
|
||
function getTrueOffsetParent(element) {
|
||
if (!isHTMLElement(element) || // https://github.com/popperjs/popper-core/issues/837
|
||
getComputedStyle2(element).position === "fixed") {
|
||
return null;
|
||
}
|
||
return element.offsetParent;
|
||
}
|
||
function getContainingBlock(element) {
|
||
var isFirefox = /firefox/i.test(getUAString());
|
||
var isIE = /Trident/i.test(getUAString());
|
||
if (isIE && isHTMLElement(element)) {
|
||
var elementCss = getComputedStyle2(element);
|
||
if (elementCss.position === "fixed") {
|
||
return null;
|
||
}
|
||
}
|
||
var currentNode = getParentNode(element);
|
||
if (isShadowRoot(currentNode)) {
|
||
currentNode = currentNode.host;
|
||
}
|
||
while (isHTMLElement(currentNode) && ["html", "body"].indexOf(getNodeName(currentNode)) < 0) {
|
||
var css = getComputedStyle2(currentNode);
|
||
if (css.transform !== "none" || css.perspective !== "none" || css.contain === "paint" || ["transform", "perspective"].indexOf(css.willChange) !== -1 || isFirefox && css.willChange === "filter" || isFirefox && css.filter && css.filter !== "none") {
|
||
return currentNode;
|
||
} else {
|
||
currentNode = currentNode.parentNode;
|
||
}
|
||
}
|
||
return null;
|
||
}
|
||
function getOffsetParent(element) {
|
||
var window2 = getWindow(element);
|
||
var offsetParent = getTrueOffsetParent(element);
|
||
while (offsetParent && isTableElement(offsetParent) && getComputedStyle2(offsetParent).position === "static") {
|
||
offsetParent = getTrueOffsetParent(offsetParent);
|
||
}
|
||
if (offsetParent && (getNodeName(offsetParent) === "html" || getNodeName(offsetParent) === "body" && getComputedStyle2(offsetParent).position === "static")) {
|
||
return window2;
|
||
}
|
||
return offsetParent || getContainingBlock(element) || window2;
|
||
}
|
||
|
||
// node_modules/@popperjs/core/lib/utils/getMainAxisFromPlacement.js
|
||
function getMainAxisFromPlacement(placement) {
|
||
return ["top", "bottom"].indexOf(placement) >= 0 ? "x" : "y";
|
||
}
|
||
|
||
// node_modules/@popperjs/core/lib/utils/within.js
|
||
function within(min2, value, max2) {
|
||
return max(min2, min(value, max2));
|
||
}
|
||
function withinMaxClamp(min2, value, max2) {
|
||
var v = within(min2, value, max2);
|
||
return v > max2 ? max2 : v;
|
||
}
|
||
|
||
// node_modules/@popperjs/core/lib/utils/getFreshSideObject.js
|
||
function getFreshSideObject() {
|
||
return {
|
||
top: 0,
|
||
right: 0,
|
||
bottom: 0,
|
||
left: 0
|
||
};
|
||
}
|
||
|
||
// node_modules/@popperjs/core/lib/utils/mergePaddingObject.js
|
||
function mergePaddingObject(paddingObject) {
|
||
return Object.assign({}, getFreshSideObject(), paddingObject);
|
||
}
|
||
|
||
// node_modules/@popperjs/core/lib/utils/expandToHashMap.js
|
||
function expandToHashMap(value, keys) {
|
||
return keys.reduce(function(hashMap, key) {
|
||
hashMap[key] = value;
|
||
return hashMap;
|
||
}, {});
|
||
}
|
||
|
||
// node_modules/@popperjs/core/lib/modifiers/arrow.js
|
||
var toPaddingObject = function toPaddingObject2(padding, state) {
|
||
padding = typeof padding === "function" ? padding(Object.assign({}, state.rects, {
|
||
placement: state.placement
|
||
})) : padding;
|
||
return mergePaddingObject(typeof padding !== "number" ? padding : expandToHashMap(padding, basePlacements));
|
||
};
|
||
function arrow(_ref) {
|
||
var _state$modifiersData$;
|
||
var state = _ref.state, name = _ref.name, options = _ref.options;
|
||
var arrowElement = state.elements.arrow;
|
||
var popperOffsets2 = state.modifiersData.popperOffsets;
|
||
var basePlacement = getBasePlacement(state.placement);
|
||
var axis = getMainAxisFromPlacement(basePlacement);
|
||
var isVertical = [left, right].indexOf(basePlacement) >= 0;
|
||
var len = isVertical ? "height" : "width";
|
||
if (!arrowElement || !popperOffsets2) {
|
||
return;
|
||
}
|
||
var paddingObject = toPaddingObject(options.padding, state);
|
||
var arrowRect = getLayoutRect(arrowElement);
|
||
var minProp = axis === "y" ? top : left;
|
||
var maxProp = axis === "y" ? bottom : right;
|
||
var endDiff = state.rects.reference[len] + state.rects.reference[axis] - popperOffsets2[axis] - state.rects.popper[len];
|
||
var startDiff = popperOffsets2[axis] - state.rects.reference[axis];
|
||
var arrowOffsetParent = getOffsetParent(arrowElement);
|
||
var clientSize = arrowOffsetParent ? axis === "y" ? arrowOffsetParent.clientHeight || 0 : arrowOffsetParent.clientWidth || 0 : 0;
|
||
var centerToReference = endDiff / 2 - startDiff / 2;
|
||
var min2 = paddingObject[minProp];
|
||
var max2 = clientSize - arrowRect[len] - paddingObject[maxProp];
|
||
var center = clientSize / 2 - arrowRect[len] / 2 + centerToReference;
|
||
var offset2 = within(min2, center, max2);
|
||
var axisProp = axis;
|
||
state.modifiersData[name] = (_state$modifiersData$ = {}, _state$modifiersData$[axisProp] = offset2, _state$modifiersData$.centerOffset = offset2 - center, _state$modifiersData$);
|
||
}
|
||
function effect2(_ref2) {
|
||
var state = _ref2.state, options = _ref2.options;
|
||
var _options$element = options.element, arrowElement = _options$element === void 0 ? "[data-popper-arrow]" : _options$element;
|
||
if (arrowElement == null) {
|
||
return;
|
||
}
|
||
if (typeof arrowElement === "string") {
|
||
arrowElement = state.elements.popper.querySelector(arrowElement);
|
||
if (!arrowElement) {
|
||
return;
|
||
}
|
||
}
|
||
if (!contains(state.elements.popper, arrowElement)) {
|
||
return;
|
||
}
|
||
state.elements.arrow = arrowElement;
|
||
}
|
||
var arrow_default = {
|
||
name: "arrow",
|
||
enabled: true,
|
||
phase: "main",
|
||
fn: arrow,
|
||
effect: effect2,
|
||
requires: ["popperOffsets"],
|
||
requiresIfExists: ["preventOverflow"]
|
||
};
|
||
|
||
// node_modules/@popperjs/core/lib/utils/getVariation.js
|
||
function getVariation(placement) {
|
||
return placement.split("-")[1];
|
||
}
|
||
|
||
// node_modules/@popperjs/core/lib/modifiers/computeStyles.js
|
||
var unsetSides = {
|
||
top: "auto",
|
||
right: "auto",
|
||
bottom: "auto",
|
||
left: "auto"
|
||
};
|
||
function roundOffsetsByDPR(_ref, win) {
|
||
var x = _ref.x, y = _ref.y;
|
||
var dpr = win.devicePixelRatio || 1;
|
||
return {
|
||
x: round(x * dpr) / dpr || 0,
|
||
y: round(y * dpr) / dpr || 0
|
||
};
|
||
}
|
||
function mapToStyles(_ref2) {
|
||
var _Object$assign2;
|
||
var popper2 = _ref2.popper, popperRect = _ref2.popperRect, placement = _ref2.placement, variation = _ref2.variation, offsets = _ref2.offsets, position = _ref2.position, gpuAcceleration = _ref2.gpuAcceleration, adaptive = _ref2.adaptive, roundOffsets = _ref2.roundOffsets, isFixed = _ref2.isFixed;
|
||
var _offsets$x = offsets.x, x = _offsets$x === void 0 ? 0 : _offsets$x, _offsets$y = offsets.y, y = _offsets$y === void 0 ? 0 : _offsets$y;
|
||
var _ref3 = typeof roundOffsets === "function" ? roundOffsets({
|
||
x,
|
||
y
|
||
}) : {
|
||
x,
|
||
y
|
||
};
|
||
x = _ref3.x;
|
||
y = _ref3.y;
|
||
var hasX = offsets.hasOwnProperty("x");
|
||
var hasY = offsets.hasOwnProperty("y");
|
||
var sideX = left;
|
||
var sideY = top;
|
||
var win = window;
|
||
if (adaptive) {
|
||
var offsetParent = getOffsetParent(popper2);
|
||
var heightProp = "clientHeight";
|
||
var widthProp = "clientWidth";
|
||
if (offsetParent === getWindow(popper2)) {
|
||
offsetParent = getDocumentElement(popper2);
|
||
if (getComputedStyle2(offsetParent).position !== "static" && position === "absolute") {
|
||
heightProp = "scrollHeight";
|
||
widthProp = "scrollWidth";
|
||
}
|
||
}
|
||
offsetParent = offsetParent;
|
||
if (placement === top || (placement === left || placement === right) && variation === end) {
|
||
sideY = bottom;
|
||
var offsetY = isFixed && offsetParent === win && win.visualViewport ? win.visualViewport.height : (
|
||
// $FlowFixMe[prop-missing]
|
||
offsetParent[heightProp]
|
||
);
|
||
y -= offsetY - popperRect.height;
|
||
y *= gpuAcceleration ? 1 : -1;
|
||
}
|
||
if (placement === left || (placement === top || placement === bottom) && variation === end) {
|
||
sideX = right;
|
||
var offsetX = isFixed && offsetParent === win && win.visualViewport ? win.visualViewport.width : (
|
||
// $FlowFixMe[prop-missing]
|
||
offsetParent[widthProp]
|
||
);
|
||
x -= offsetX - popperRect.width;
|
||
x *= gpuAcceleration ? 1 : -1;
|
||
}
|
||
}
|
||
var commonStyles = Object.assign({
|
||
position
|
||
}, adaptive && unsetSides);
|
||
var _ref4 = roundOffsets === true ? roundOffsetsByDPR({
|
||
x,
|
||
y
|
||
}, getWindow(popper2)) : {
|
||
x,
|
||
y
|
||
};
|
||
x = _ref4.x;
|
||
y = _ref4.y;
|
||
if (gpuAcceleration) {
|
||
var _Object$assign;
|
||
return Object.assign({}, commonStyles, (_Object$assign = {}, _Object$assign[sideY] = hasY ? "0" : "", _Object$assign[sideX] = hasX ? "0" : "", _Object$assign.transform = (win.devicePixelRatio || 1) <= 1 ? "translate(" + x + "px, " + y + "px)" : "translate3d(" + x + "px, " + y + "px, 0)", _Object$assign));
|
||
}
|
||
return Object.assign({}, commonStyles, (_Object$assign2 = {}, _Object$assign2[sideY] = hasY ? y + "px" : "", _Object$assign2[sideX] = hasX ? x + "px" : "", _Object$assign2.transform = "", _Object$assign2));
|
||
}
|
||
function computeStyles(_ref5) {
|
||
var state = _ref5.state, options = _ref5.options;
|
||
var _options$gpuAccelerat = options.gpuAcceleration, gpuAcceleration = _options$gpuAccelerat === void 0 ? true : _options$gpuAccelerat, _options$adaptive = options.adaptive, adaptive = _options$adaptive === void 0 ? true : _options$adaptive, _options$roundOffsets = options.roundOffsets, roundOffsets = _options$roundOffsets === void 0 ? true : _options$roundOffsets;
|
||
var commonStyles = {
|
||
placement: getBasePlacement(state.placement),
|
||
variation: getVariation(state.placement),
|
||
popper: state.elements.popper,
|
||
popperRect: state.rects.popper,
|
||
gpuAcceleration,
|
||
isFixed: state.options.strategy === "fixed"
|
||
};
|
||
if (state.modifiersData.popperOffsets != null) {
|
||
state.styles.popper = Object.assign({}, state.styles.popper, mapToStyles(Object.assign({}, commonStyles, {
|
||
offsets: state.modifiersData.popperOffsets,
|
||
position: state.options.strategy,
|
||
adaptive,
|
||
roundOffsets
|
||
})));
|
||
}
|
||
if (state.modifiersData.arrow != null) {
|
||
state.styles.arrow = Object.assign({}, state.styles.arrow, mapToStyles(Object.assign({}, commonStyles, {
|
||
offsets: state.modifiersData.arrow,
|
||
position: "absolute",
|
||
adaptive: false,
|
||
roundOffsets
|
||
})));
|
||
}
|
||
state.attributes.popper = Object.assign({}, state.attributes.popper, {
|
||
"data-popper-placement": state.placement
|
||
});
|
||
}
|
||
var computeStyles_default = {
|
||
name: "computeStyles",
|
||
enabled: true,
|
||
phase: "beforeWrite",
|
||
fn: computeStyles,
|
||
data: {}
|
||
};
|
||
|
||
// node_modules/@popperjs/core/lib/modifiers/eventListeners.js
|
||
var passive = {
|
||
passive: true
|
||
};
|
||
function effect3(_ref) {
|
||
var state = _ref.state, instance = _ref.instance, options = _ref.options;
|
||
var _options$scroll = options.scroll, scroll = _options$scroll === void 0 ? true : _options$scroll, _options$resize = options.resize, resize = _options$resize === void 0 ? true : _options$resize;
|
||
var window2 = getWindow(state.elements.popper);
|
||
var scrollParents = [].concat(state.scrollParents.reference, state.scrollParents.popper);
|
||
if (scroll) {
|
||
scrollParents.forEach(function(scrollParent) {
|
||
scrollParent.addEventListener("scroll", instance.update, passive);
|
||
});
|
||
}
|
||
if (resize) {
|
||
window2.addEventListener("resize", instance.update, passive);
|
||
}
|
||
return function() {
|
||
if (scroll) {
|
||
scrollParents.forEach(function(scrollParent) {
|
||
scrollParent.removeEventListener("scroll", instance.update, passive);
|
||
});
|
||
}
|
||
if (resize) {
|
||
window2.removeEventListener("resize", instance.update, passive);
|
||
}
|
||
};
|
||
}
|
||
var eventListeners_default = {
|
||
name: "eventListeners",
|
||
enabled: true,
|
||
phase: "write",
|
||
fn: function fn() {
|
||
},
|
||
effect: effect3,
|
||
data: {}
|
||
};
|
||
|
||
// node_modules/@popperjs/core/lib/utils/getOppositePlacement.js
|
||
var hash = {
|
||
left: "right",
|
||
right: "left",
|
||
bottom: "top",
|
||
top: "bottom"
|
||
};
|
||
function getOppositePlacement(placement) {
|
||
return placement.replace(/left|right|bottom|top/g, function(matched) {
|
||
return hash[matched];
|
||
});
|
||
}
|
||
|
||
// node_modules/@popperjs/core/lib/utils/getOppositeVariationPlacement.js
|
||
var hash2 = {
|
||
start: "end",
|
||
end: "start"
|
||
};
|
||
function getOppositeVariationPlacement(placement) {
|
||
return placement.replace(/start|end/g, function(matched) {
|
||
return hash2[matched];
|
||
});
|
||
}
|
||
|
||
// node_modules/@popperjs/core/lib/dom-utils/getWindowScroll.js
|
||
function getWindowScroll(node) {
|
||
var win = getWindow(node);
|
||
var scrollLeft = win.pageXOffset;
|
||
var scrollTop = win.pageYOffset;
|
||
return {
|
||
scrollLeft,
|
||
scrollTop
|
||
};
|
||
}
|
||
|
||
// node_modules/@popperjs/core/lib/dom-utils/getWindowScrollBarX.js
|
||
function getWindowScrollBarX(element) {
|
||
return getBoundingClientRect(getDocumentElement(element)).left + getWindowScroll(element).scrollLeft;
|
||
}
|
||
|
||
// node_modules/@popperjs/core/lib/dom-utils/getViewportRect.js
|
||
function getViewportRect(element, strategy) {
|
||
var win = getWindow(element);
|
||
var html = getDocumentElement(element);
|
||
var visualViewport = win.visualViewport;
|
||
var width = html.clientWidth;
|
||
var height = html.clientHeight;
|
||
var x = 0;
|
||
var y = 0;
|
||
if (visualViewport) {
|
||
width = visualViewport.width;
|
||
height = visualViewport.height;
|
||
var layoutViewport = isLayoutViewport();
|
||
if (layoutViewport || !layoutViewport && strategy === "fixed") {
|
||
x = visualViewport.offsetLeft;
|
||
y = visualViewport.offsetTop;
|
||
}
|
||
}
|
||
return {
|
||
width,
|
||
height,
|
||
x: x + getWindowScrollBarX(element),
|
||
y
|
||
};
|
||
}
|
||
|
||
// node_modules/@popperjs/core/lib/dom-utils/getDocumentRect.js
|
||
function getDocumentRect(element) {
|
||
var _element$ownerDocumen;
|
||
var html = getDocumentElement(element);
|
||
var winScroll = getWindowScroll(element);
|
||
var body = (_element$ownerDocumen = element.ownerDocument) == null ? void 0 : _element$ownerDocumen.body;
|
||
var width = max(html.scrollWidth, html.clientWidth, body ? body.scrollWidth : 0, body ? body.clientWidth : 0);
|
||
var height = max(html.scrollHeight, html.clientHeight, body ? body.scrollHeight : 0, body ? body.clientHeight : 0);
|
||
var x = -winScroll.scrollLeft + getWindowScrollBarX(element);
|
||
var y = -winScroll.scrollTop;
|
||
if (getComputedStyle2(body || html).direction === "rtl") {
|
||
x += max(html.clientWidth, body ? body.clientWidth : 0) - width;
|
||
}
|
||
return {
|
||
width,
|
||
height,
|
||
x,
|
||
y
|
||
};
|
||
}
|
||
|
||
// node_modules/@popperjs/core/lib/dom-utils/isScrollParent.js
|
||
function isScrollParent(element) {
|
||
var _getComputedStyle = getComputedStyle2(element), overflow = _getComputedStyle.overflow, overflowX = _getComputedStyle.overflowX, overflowY = _getComputedStyle.overflowY;
|
||
return /auto|scroll|overlay|hidden/.test(overflow + overflowY + overflowX);
|
||
}
|
||
|
||
// node_modules/@popperjs/core/lib/dom-utils/getScrollParent.js
|
||
function getScrollParent(node) {
|
||
if (["html", "body", "#document"].indexOf(getNodeName(node)) >= 0) {
|
||
return node.ownerDocument.body;
|
||
}
|
||
if (isHTMLElement(node) && isScrollParent(node)) {
|
||
return node;
|
||
}
|
||
return getScrollParent(getParentNode(node));
|
||
}
|
||
|
||
// node_modules/@popperjs/core/lib/dom-utils/listScrollParents.js
|
||
function listScrollParents(element, list) {
|
||
var _element$ownerDocumen;
|
||
if (list === void 0) {
|
||
list = [];
|
||
}
|
||
var scrollParent = getScrollParent(element);
|
||
var isBody = scrollParent === ((_element$ownerDocumen = element.ownerDocument) == null ? void 0 : _element$ownerDocumen.body);
|
||
var win = getWindow(scrollParent);
|
||
var target = isBody ? [win].concat(win.visualViewport || [], isScrollParent(scrollParent) ? scrollParent : []) : scrollParent;
|
||
var updatedList = list.concat(target);
|
||
return isBody ? updatedList : (
|
||
// $FlowFixMe[incompatible-call]: isBody tells us target will be an HTMLElement here
|
||
updatedList.concat(listScrollParents(getParentNode(target)))
|
||
);
|
||
}
|
||
|
||
// node_modules/@popperjs/core/lib/utils/rectToClientRect.js
|
||
function rectToClientRect(rect) {
|
||
return Object.assign({}, rect, {
|
||
left: rect.x,
|
||
top: rect.y,
|
||
right: rect.x + rect.width,
|
||
bottom: rect.y + rect.height
|
||
});
|
||
}
|
||
|
||
// node_modules/@popperjs/core/lib/dom-utils/getClippingRect.js
|
||
function getInnerBoundingClientRect(element, strategy) {
|
||
var rect = getBoundingClientRect(element, false, strategy === "fixed");
|
||
rect.top = rect.top + element.clientTop;
|
||
rect.left = rect.left + element.clientLeft;
|
||
rect.bottom = rect.top + element.clientHeight;
|
||
rect.right = rect.left + element.clientWidth;
|
||
rect.width = element.clientWidth;
|
||
rect.height = element.clientHeight;
|
||
rect.x = rect.left;
|
||
rect.y = rect.top;
|
||
return rect;
|
||
}
|
||
function getClientRectFromMixedType(element, clippingParent, strategy) {
|
||
return clippingParent === viewport ? rectToClientRect(getViewportRect(element, strategy)) : isElement(clippingParent) ? getInnerBoundingClientRect(clippingParent, strategy) : rectToClientRect(getDocumentRect(getDocumentElement(element)));
|
||
}
|
||
function getClippingParents(element) {
|
||
var clippingParents2 = listScrollParents(getParentNode(element));
|
||
var canEscapeClipping = ["absolute", "fixed"].indexOf(getComputedStyle2(element).position) >= 0;
|
||
var clipperElement = canEscapeClipping && isHTMLElement(element) ? getOffsetParent(element) : element;
|
||
if (!isElement(clipperElement)) {
|
||
return [];
|
||
}
|
||
return clippingParents2.filter(function(clippingParent) {
|
||
return isElement(clippingParent) && contains(clippingParent, clipperElement) && getNodeName(clippingParent) !== "body";
|
||
});
|
||
}
|
||
function getClippingRect(element, boundary, rootBoundary, strategy) {
|
||
var mainClippingParents = boundary === "clippingParents" ? getClippingParents(element) : [].concat(boundary);
|
||
var clippingParents2 = [].concat(mainClippingParents, [rootBoundary]);
|
||
var firstClippingParent = clippingParents2[0];
|
||
var clippingRect = clippingParents2.reduce(function(accRect, clippingParent) {
|
||
var rect = getClientRectFromMixedType(element, clippingParent, strategy);
|
||
accRect.top = max(rect.top, accRect.top);
|
||
accRect.right = min(rect.right, accRect.right);
|
||
accRect.bottom = min(rect.bottom, accRect.bottom);
|
||
accRect.left = max(rect.left, accRect.left);
|
||
return accRect;
|
||
}, getClientRectFromMixedType(element, firstClippingParent, strategy));
|
||
clippingRect.width = clippingRect.right - clippingRect.left;
|
||
clippingRect.height = clippingRect.bottom - clippingRect.top;
|
||
clippingRect.x = clippingRect.left;
|
||
clippingRect.y = clippingRect.top;
|
||
return clippingRect;
|
||
}
|
||
|
||
// node_modules/@popperjs/core/lib/utils/computeOffsets.js
|
||
function computeOffsets(_ref) {
|
||
var reference2 = _ref.reference, element = _ref.element, placement = _ref.placement;
|
||
var basePlacement = placement ? getBasePlacement(placement) : null;
|
||
var variation = placement ? getVariation(placement) : null;
|
||
var commonX = reference2.x + reference2.width / 2 - element.width / 2;
|
||
var commonY = reference2.y + reference2.height / 2 - element.height / 2;
|
||
var offsets;
|
||
switch (basePlacement) {
|
||
case top:
|
||
offsets = {
|
||
x: commonX,
|
||
y: reference2.y - element.height
|
||
};
|
||
break;
|
||
case bottom:
|
||
offsets = {
|
||
x: commonX,
|
||
y: reference2.y + reference2.height
|
||
};
|
||
break;
|
||
case right:
|
||
offsets = {
|
||
x: reference2.x + reference2.width,
|
||
y: commonY
|
||
};
|
||
break;
|
||
case left:
|
||
offsets = {
|
||
x: reference2.x - element.width,
|
||
y: commonY
|
||
};
|
||
break;
|
||
default:
|
||
offsets = {
|
||
x: reference2.x,
|
||
y: reference2.y
|
||
};
|
||
}
|
||
var mainAxis = basePlacement ? getMainAxisFromPlacement(basePlacement) : null;
|
||
if (mainAxis != null) {
|
||
var len = mainAxis === "y" ? "height" : "width";
|
||
switch (variation) {
|
||
case start2:
|
||
offsets[mainAxis] = offsets[mainAxis] - (reference2[len] / 2 - element[len] / 2);
|
||
break;
|
||
case end:
|
||
offsets[mainAxis] = offsets[mainAxis] + (reference2[len] / 2 - element[len] / 2);
|
||
break;
|
||
default:
|
||
}
|
||
}
|
||
return offsets;
|
||
}
|
||
|
||
// node_modules/@popperjs/core/lib/utils/detectOverflow.js
|
||
function detectOverflow(state, options) {
|
||
if (options === void 0) {
|
||
options = {};
|
||
}
|
||
var _options = options, _options$placement = _options.placement, placement = _options$placement === void 0 ? state.placement : _options$placement, _options$strategy = _options.strategy, strategy = _options$strategy === void 0 ? state.strategy : _options$strategy, _options$boundary = _options.boundary, boundary = _options$boundary === void 0 ? clippingParents : _options$boundary, _options$rootBoundary = _options.rootBoundary, rootBoundary = _options$rootBoundary === void 0 ? viewport : _options$rootBoundary, _options$elementConte = _options.elementContext, elementContext = _options$elementConte === void 0 ? popper : _options$elementConte, _options$altBoundary = _options.altBoundary, altBoundary = _options$altBoundary === void 0 ? false : _options$altBoundary, _options$padding = _options.padding, padding = _options$padding === void 0 ? 0 : _options$padding;
|
||
var paddingObject = mergePaddingObject(typeof padding !== "number" ? padding : expandToHashMap(padding, basePlacements));
|
||
var altContext = elementContext === popper ? reference : popper;
|
||
var popperRect = state.rects.popper;
|
||
var element = state.elements[altBoundary ? altContext : elementContext];
|
||
var clippingClientRect = getClippingRect(isElement(element) ? element : element.contextElement || getDocumentElement(state.elements.popper), boundary, rootBoundary, strategy);
|
||
var referenceClientRect = getBoundingClientRect(state.elements.reference);
|
||
var popperOffsets2 = computeOffsets({
|
||
reference: referenceClientRect,
|
||
element: popperRect,
|
||
strategy: "absolute",
|
||
placement
|
||
});
|
||
var popperClientRect = rectToClientRect(Object.assign({}, popperRect, popperOffsets2));
|
||
var elementClientRect = elementContext === popper ? popperClientRect : referenceClientRect;
|
||
var overflowOffsets = {
|
||
top: clippingClientRect.top - elementClientRect.top + paddingObject.top,
|
||
bottom: elementClientRect.bottom - clippingClientRect.bottom + paddingObject.bottom,
|
||
left: clippingClientRect.left - elementClientRect.left + paddingObject.left,
|
||
right: elementClientRect.right - clippingClientRect.right + paddingObject.right
|
||
};
|
||
var offsetData = state.modifiersData.offset;
|
||
if (elementContext === popper && offsetData) {
|
||
var offset2 = offsetData[placement];
|
||
Object.keys(overflowOffsets).forEach(function(key) {
|
||
var multiply = [right, bottom].indexOf(key) >= 0 ? 1 : -1;
|
||
var axis = [top, bottom].indexOf(key) >= 0 ? "y" : "x";
|
||
overflowOffsets[key] += offset2[axis] * multiply;
|
||
});
|
||
}
|
||
return overflowOffsets;
|
||
}
|
||
|
||
// node_modules/@popperjs/core/lib/utils/computeAutoPlacement.js
|
||
function computeAutoPlacement(state, options) {
|
||
if (options === void 0) {
|
||
options = {};
|
||
}
|
||
var _options = options, placement = _options.placement, boundary = _options.boundary, rootBoundary = _options.rootBoundary, padding = _options.padding, flipVariations = _options.flipVariations, _options$allowedAutoP = _options.allowedAutoPlacements, allowedAutoPlacements = _options$allowedAutoP === void 0 ? placements : _options$allowedAutoP;
|
||
var variation = getVariation(placement);
|
||
var placements2 = variation ? flipVariations ? variationPlacements : variationPlacements.filter(function(placement2) {
|
||
return getVariation(placement2) === variation;
|
||
}) : basePlacements;
|
||
var allowedPlacements = placements2.filter(function(placement2) {
|
||
return allowedAutoPlacements.indexOf(placement2) >= 0;
|
||
});
|
||
if (allowedPlacements.length === 0) {
|
||
allowedPlacements = placements2;
|
||
}
|
||
var overflows = allowedPlacements.reduce(function(acc, placement2) {
|
||
acc[placement2] = detectOverflow(state, {
|
||
placement: placement2,
|
||
boundary,
|
||
rootBoundary,
|
||
padding
|
||
})[getBasePlacement(placement2)];
|
||
return acc;
|
||
}, {});
|
||
return Object.keys(overflows).sort(function(a, b) {
|
||
return overflows[a] - overflows[b];
|
||
});
|
||
}
|
||
|
||
// node_modules/@popperjs/core/lib/modifiers/flip.js
|
||
function getExpandedFallbackPlacements(placement) {
|
||
if (getBasePlacement(placement) === auto) {
|
||
return [];
|
||
}
|
||
var oppositePlacement = getOppositePlacement(placement);
|
||
return [getOppositeVariationPlacement(placement), oppositePlacement, getOppositeVariationPlacement(oppositePlacement)];
|
||
}
|
||
function flip(_ref) {
|
||
var state = _ref.state, options = _ref.options, name = _ref.name;
|
||
if (state.modifiersData[name]._skip) {
|
||
return;
|
||
}
|
||
var _options$mainAxis = options.mainAxis, checkMainAxis = _options$mainAxis === void 0 ? true : _options$mainAxis, _options$altAxis = options.altAxis, checkAltAxis = _options$altAxis === void 0 ? true : _options$altAxis, specifiedFallbackPlacements = options.fallbackPlacements, padding = options.padding, boundary = options.boundary, rootBoundary = options.rootBoundary, altBoundary = options.altBoundary, _options$flipVariatio = options.flipVariations, flipVariations = _options$flipVariatio === void 0 ? true : _options$flipVariatio, allowedAutoPlacements = options.allowedAutoPlacements;
|
||
var preferredPlacement = state.options.placement;
|
||
var basePlacement = getBasePlacement(preferredPlacement);
|
||
var isBasePlacement = basePlacement === preferredPlacement;
|
||
var fallbackPlacements = specifiedFallbackPlacements || (isBasePlacement || !flipVariations ? [getOppositePlacement(preferredPlacement)] : getExpandedFallbackPlacements(preferredPlacement));
|
||
var placements2 = [preferredPlacement].concat(fallbackPlacements).reduce(function(acc, placement2) {
|
||
return acc.concat(getBasePlacement(placement2) === auto ? computeAutoPlacement(state, {
|
||
placement: placement2,
|
||
boundary,
|
||
rootBoundary,
|
||
padding,
|
||
flipVariations,
|
||
allowedAutoPlacements
|
||
}) : placement2);
|
||
}, []);
|
||
var referenceRect = state.rects.reference;
|
||
var popperRect = state.rects.popper;
|
||
var checksMap = /* @__PURE__ */ new Map();
|
||
var makeFallbackChecks = true;
|
||
var firstFittingPlacement = placements2[0];
|
||
for (var i = 0; i < placements2.length; i++) {
|
||
var placement = placements2[i];
|
||
var _basePlacement = getBasePlacement(placement);
|
||
var isStartVariation = getVariation(placement) === start2;
|
||
var isVertical = [top, bottom].indexOf(_basePlacement) >= 0;
|
||
var len = isVertical ? "width" : "height";
|
||
var overflow = detectOverflow(state, {
|
||
placement,
|
||
boundary,
|
||
rootBoundary,
|
||
altBoundary,
|
||
padding
|
||
});
|
||
var mainVariationSide = isVertical ? isStartVariation ? right : left : isStartVariation ? bottom : top;
|
||
if (referenceRect[len] > popperRect[len]) {
|
||
mainVariationSide = getOppositePlacement(mainVariationSide);
|
||
}
|
||
var altVariationSide = getOppositePlacement(mainVariationSide);
|
||
var checks = [];
|
||
if (checkMainAxis) {
|
||
checks.push(overflow[_basePlacement] <= 0);
|
||
}
|
||
if (checkAltAxis) {
|
||
checks.push(overflow[mainVariationSide] <= 0, overflow[altVariationSide] <= 0);
|
||
}
|
||
if (checks.every(function(check) {
|
||
return check;
|
||
})) {
|
||
firstFittingPlacement = placement;
|
||
makeFallbackChecks = false;
|
||
break;
|
||
}
|
||
checksMap.set(placement, checks);
|
||
}
|
||
if (makeFallbackChecks) {
|
||
var numberOfChecks = flipVariations ? 3 : 1;
|
||
var _loop = function _loop2(_i2) {
|
||
var fittingPlacement = placements2.find(function(placement2) {
|
||
var checks2 = checksMap.get(placement2);
|
||
if (checks2) {
|
||
return checks2.slice(0, _i2).every(function(check) {
|
||
return check;
|
||
});
|
||
}
|
||
});
|
||
if (fittingPlacement) {
|
||
firstFittingPlacement = fittingPlacement;
|
||
return "break";
|
||
}
|
||
};
|
||
for (var _i = numberOfChecks; _i > 0; _i--) {
|
||
var _ret = _loop(_i);
|
||
if (_ret === "break")
|
||
break;
|
||
}
|
||
}
|
||
if (state.placement !== firstFittingPlacement) {
|
||
state.modifiersData[name]._skip = true;
|
||
state.placement = firstFittingPlacement;
|
||
state.reset = true;
|
||
}
|
||
}
|
||
var flip_default = {
|
||
name: "flip",
|
||
enabled: true,
|
||
phase: "main",
|
||
fn: flip,
|
||
requiresIfExists: ["offset"],
|
||
data: {
|
||
_skip: false
|
||
}
|
||
};
|
||
|
||
// node_modules/@popperjs/core/lib/modifiers/hide.js
|
||
function getSideOffsets(overflow, rect, preventedOffsets) {
|
||
if (preventedOffsets === void 0) {
|
||
preventedOffsets = {
|
||
x: 0,
|
||
y: 0
|
||
};
|
||
}
|
||
return {
|
||
top: overflow.top - rect.height - preventedOffsets.y,
|
||
right: overflow.right - rect.width + preventedOffsets.x,
|
||
bottom: overflow.bottom - rect.height + preventedOffsets.y,
|
||
left: overflow.left - rect.width - preventedOffsets.x
|
||
};
|
||
}
|
||
function isAnySideFullyClipped(overflow) {
|
||
return [top, right, bottom, left].some(function(side) {
|
||
return overflow[side] >= 0;
|
||
});
|
||
}
|
||
function hide(_ref) {
|
||
var state = _ref.state, name = _ref.name;
|
||
var referenceRect = state.rects.reference;
|
||
var popperRect = state.rects.popper;
|
||
var preventedOffsets = state.modifiersData.preventOverflow;
|
||
var referenceOverflow = detectOverflow(state, {
|
||
elementContext: "reference"
|
||
});
|
||
var popperAltOverflow = detectOverflow(state, {
|
||
altBoundary: true
|
||
});
|
||
var referenceClippingOffsets = getSideOffsets(referenceOverflow, referenceRect);
|
||
var popperEscapeOffsets = getSideOffsets(popperAltOverflow, popperRect, preventedOffsets);
|
||
var isReferenceHidden = isAnySideFullyClipped(referenceClippingOffsets);
|
||
var hasPopperEscaped = isAnySideFullyClipped(popperEscapeOffsets);
|
||
state.modifiersData[name] = {
|
||
referenceClippingOffsets,
|
||
popperEscapeOffsets,
|
||
isReferenceHidden,
|
||
hasPopperEscaped
|
||
};
|
||
state.attributes.popper = Object.assign({}, state.attributes.popper, {
|
||
"data-popper-reference-hidden": isReferenceHidden,
|
||
"data-popper-escaped": hasPopperEscaped
|
||
});
|
||
}
|
||
var hide_default = {
|
||
name: "hide",
|
||
enabled: true,
|
||
phase: "main",
|
||
requiresIfExists: ["preventOverflow"],
|
||
fn: hide
|
||
};
|
||
|
||
// node_modules/@popperjs/core/lib/modifiers/offset.js
|
||
function distanceAndSkiddingToXY(placement, rects, offset2) {
|
||
var basePlacement = getBasePlacement(placement);
|
||
var invertDistance = [left, top].indexOf(basePlacement) >= 0 ? -1 : 1;
|
||
var _ref = typeof offset2 === "function" ? offset2(Object.assign({}, rects, {
|
||
placement
|
||
})) : offset2, skidding = _ref[0], distance = _ref[1];
|
||
skidding = skidding || 0;
|
||
distance = (distance || 0) * invertDistance;
|
||
return [left, right].indexOf(basePlacement) >= 0 ? {
|
||
x: distance,
|
||
y: skidding
|
||
} : {
|
||
x: skidding,
|
||
y: distance
|
||
};
|
||
}
|
||
function offset(_ref2) {
|
||
var state = _ref2.state, options = _ref2.options, name = _ref2.name;
|
||
var _options$offset = options.offset, offset2 = _options$offset === void 0 ? [0, 0] : _options$offset;
|
||
var data = placements.reduce(function(acc, placement) {
|
||
acc[placement] = distanceAndSkiddingToXY(placement, state.rects, offset2);
|
||
return acc;
|
||
}, {});
|
||
var _data$state$placement = data[state.placement], x = _data$state$placement.x, y = _data$state$placement.y;
|
||
if (state.modifiersData.popperOffsets != null) {
|
||
state.modifiersData.popperOffsets.x += x;
|
||
state.modifiersData.popperOffsets.y += y;
|
||
}
|
||
state.modifiersData[name] = data;
|
||
}
|
||
var offset_default = {
|
||
name: "offset",
|
||
enabled: true,
|
||
phase: "main",
|
||
requires: ["popperOffsets"],
|
||
fn: offset
|
||
};
|
||
|
||
// node_modules/@popperjs/core/lib/modifiers/popperOffsets.js
|
||
function popperOffsets(_ref) {
|
||
var state = _ref.state, name = _ref.name;
|
||
state.modifiersData[name] = computeOffsets({
|
||
reference: state.rects.reference,
|
||
element: state.rects.popper,
|
||
strategy: "absolute",
|
||
placement: state.placement
|
||
});
|
||
}
|
||
var popperOffsets_default = {
|
||
name: "popperOffsets",
|
||
enabled: true,
|
||
phase: "read",
|
||
fn: popperOffsets,
|
||
data: {}
|
||
};
|
||
|
||
// node_modules/@popperjs/core/lib/utils/getAltAxis.js
|
||
function getAltAxis(axis) {
|
||
return axis === "x" ? "y" : "x";
|
||
}
|
||
|
||
// node_modules/@popperjs/core/lib/modifiers/preventOverflow.js
|
||
function preventOverflow(_ref) {
|
||
var state = _ref.state, options = _ref.options, name = _ref.name;
|
||
var _options$mainAxis = options.mainAxis, checkMainAxis = _options$mainAxis === void 0 ? true : _options$mainAxis, _options$altAxis = options.altAxis, checkAltAxis = _options$altAxis === void 0 ? false : _options$altAxis, boundary = options.boundary, rootBoundary = options.rootBoundary, altBoundary = options.altBoundary, padding = options.padding, _options$tether = options.tether, tether = _options$tether === void 0 ? true : _options$tether, _options$tetherOffset = options.tetherOffset, tetherOffset = _options$tetherOffset === void 0 ? 0 : _options$tetherOffset;
|
||
var overflow = detectOverflow(state, {
|
||
boundary,
|
||
rootBoundary,
|
||
padding,
|
||
altBoundary
|
||
});
|
||
var basePlacement = getBasePlacement(state.placement);
|
||
var variation = getVariation(state.placement);
|
||
var isBasePlacement = !variation;
|
||
var mainAxis = getMainAxisFromPlacement(basePlacement);
|
||
var altAxis = getAltAxis(mainAxis);
|
||
var popperOffsets2 = state.modifiersData.popperOffsets;
|
||
var referenceRect = state.rects.reference;
|
||
var popperRect = state.rects.popper;
|
||
var tetherOffsetValue = typeof tetherOffset === "function" ? tetherOffset(Object.assign({}, state.rects, {
|
||
placement: state.placement
|
||
})) : tetherOffset;
|
||
var normalizedTetherOffsetValue = typeof tetherOffsetValue === "number" ? {
|
||
mainAxis: tetherOffsetValue,
|
||
altAxis: tetherOffsetValue
|
||
} : Object.assign({
|
||
mainAxis: 0,
|
||
altAxis: 0
|
||
}, tetherOffsetValue);
|
||
var offsetModifierState = state.modifiersData.offset ? state.modifiersData.offset[state.placement] : null;
|
||
var data = {
|
||
x: 0,
|
||
y: 0
|
||
};
|
||
if (!popperOffsets2) {
|
||
return;
|
||
}
|
||
if (checkMainAxis) {
|
||
var _offsetModifierState$;
|
||
var mainSide = mainAxis === "y" ? top : left;
|
||
var altSide = mainAxis === "y" ? bottom : right;
|
||
var len = mainAxis === "y" ? "height" : "width";
|
||
var offset2 = popperOffsets2[mainAxis];
|
||
var min2 = offset2 + overflow[mainSide];
|
||
var max2 = offset2 - overflow[altSide];
|
||
var additive = tether ? -popperRect[len] / 2 : 0;
|
||
var minLen = variation === start2 ? referenceRect[len] : popperRect[len];
|
||
var maxLen = variation === start2 ? -popperRect[len] : -referenceRect[len];
|
||
var arrowElement = state.elements.arrow;
|
||
var arrowRect = tether && arrowElement ? getLayoutRect(arrowElement) : {
|
||
width: 0,
|
||
height: 0
|
||
};
|
||
var arrowPaddingObject = state.modifiersData["arrow#persistent"] ? state.modifiersData["arrow#persistent"].padding : getFreshSideObject();
|
||
var arrowPaddingMin = arrowPaddingObject[mainSide];
|
||
var arrowPaddingMax = arrowPaddingObject[altSide];
|
||
var arrowLen = within(0, referenceRect[len], arrowRect[len]);
|
||
var minOffset = isBasePlacement ? referenceRect[len] / 2 - additive - arrowLen - arrowPaddingMin - normalizedTetherOffsetValue.mainAxis : minLen - arrowLen - arrowPaddingMin - normalizedTetherOffsetValue.mainAxis;
|
||
var maxOffset = isBasePlacement ? -referenceRect[len] / 2 + additive + arrowLen + arrowPaddingMax + normalizedTetherOffsetValue.mainAxis : maxLen + arrowLen + arrowPaddingMax + normalizedTetherOffsetValue.mainAxis;
|
||
var arrowOffsetParent = state.elements.arrow && getOffsetParent(state.elements.arrow);
|
||
var clientOffset = arrowOffsetParent ? mainAxis === "y" ? arrowOffsetParent.clientTop || 0 : arrowOffsetParent.clientLeft || 0 : 0;
|
||
var offsetModifierValue = (_offsetModifierState$ = offsetModifierState == null ? void 0 : offsetModifierState[mainAxis]) != null ? _offsetModifierState$ : 0;
|
||
var tetherMin = offset2 + minOffset - offsetModifierValue - clientOffset;
|
||
var tetherMax = offset2 + maxOffset - offsetModifierValue;
|
||
var preventedOffset = within(tether ? min(min2, tetherMin) : min2, offset2, tether ? max(max2, tetherMax) : max2);
|
||
popperOffsets2[mainAxis] = preventedOffset;
|
||
data[mainAxis] = preventedOffset - offset2;
|
||
}
|
||
if (checkAltAxis) {
|
||
var _offsetModifierState$2;
|
||
var _mainSide = mainAxis === "x" ? top : left;
|
||
var _altSide = mainAxis === "x" ? bottom : right;
|
||
var _offset = popperOffsets2[altAxis];
|
||
var _len = altAxis === "y" ? "height" : "width";
|
||
var _min = _offset + overflow[_mainSide];
|
||
var _max = _offset - overflow[_altSide];
|
||
var isOriginSide = [top, left].indexOf(basePlacement) !== -1;
|
||
var _offsetModifierValue = (_offsetModifierState$2 = offsetModifierState == null ? void 0 : offsetModifierState[altAxis]) != null ? _offsetModifierState$2 : 0;
|
||
var _tetherMin = isOriginSide ? _min : _offset - referenceRect[_len] - popperRect[_len] - _offsetModifierValue + normalizedTetherOffsetValue.altAxis;
|
||
var _tetherMax = isOriginSide ? _offset + referenceRect[_len] + popperRect[_len] - _offsetModifierValue - normalizedTetherOffsetValue.altAxis : _max;
|
||
var _preventedOffset = tether && isOriginSide ? withinMaxClamp(_tetherMin, _offset, _tetherMax) : within(tether ? _tetherMin : _min, _offset, tether ? _tetherMax : _max);
|
||
popperOffsets2[altAxis] = _preventedOffset;
|
||
data[altAxis] = _preventedOffset - _offset;
|
||
}
|
||
state.modifiersData[name] = data;
|
||
}
|
||
var preventOverflow_default = {
|
||
name: "preventOverflow",
|
||
enabled: true,
|
||
phase: "main",
|
||
fn: preventOverflow,
|
||
requiresIfExists: ["offset"]
|
||
};
|
||
|
||
// node_modules/@popperjs/core/lib/dom-utils/getHTMLElementScroll.js
|
||
function getHTMLElementScroll(element) {
|
||
return {
|
||
scrollLeft: element.scrollLeft,
|
||
scrollTop: element.scrollTop
|
||
};
|
||
}
|
||
|
||
// node_modules/@popperjs/core/lib/dom-utils/getNodeScroll.js
|
||
function getNodeScroll(node) {
|
||
if (node === getWindow(node) || !isHTMLElement(node)) {
|
||
return getWindowScroll(node);
|
||
} else {
|
||
return getHTMLElementScroll(node);
|
||
}
|
||
}
|
||
|
||
// node_modules/@popperjs/core/lib/dom-utils/getCompositeRect.js
|
||
function isElementScaled(element) {
|
||
var rect = element.getBoundingClientRect();
|
||
var scaleX = round(rect.width) / element.offsetWidth || 1;
|
||
var scaleY = round(rect.height) / element.offsetHeight || 1;
|
||
return scaleX !== 1 || scaleY !== 1;
|
||
}
|
||
function getCompositeRect(elementOrVirtualElement, offsetParent, isFixed) {
|
||
if (isFixed === void 0) {
|
||
isFixed = false;
|
||
}
|
||
var isOffsetParentAnElement = isHTMLElement(offsetParent);
|
||
var offsetParentIsScaled = isHTMLElement(offsetParent) && isElementScaled(offsetParent);
|
||
var documentElement = getDocumentElement(offsetParent);
|
||
var rect = getBoundingClientRect(elementOrVirtualElement, offsetParentIsScaled, isFixed);
|
||
var scroll = {
|
||
scrollLeft: 0,
|
||
scrollTop: 0
|
||
};
|
||
var offsets = {
|
||
x: 0,
|
||
y: 0
|
||
};
|
||
if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
|
||
if (getNodeName(offsetParent) !== "body" || // https://github.com/popperjs/popper-core/issues/1078
|
||
isScrollParent(documentElement)) {
|
||
scroll = getNodeScroll(offsetParent);
|
||
}
|
||
if (isHTMLElement(offsetParent)) {
|
||
offsets = getBoundingClientRect(offsetParent, true);
|
||
offsets.x += offsetParent.clientLeft;
|
||
offsets.y += offsetParent.clientTop;
|
||
} else if (documentElement) {
|
||
offsets.x = getWindowScrollBarX(documentElement);
|
||
}
|
||
}
|
||
return {
|
||
x: rect.left + scroll.scrollLeft - offsets.x,
|
||
y: rect.top + scroll.scrollTop - offsets.y,
|
||
width: rect.width,
|
||
height: rect.height
|
||
};
|
||
}
|
||
|
||
// node_modules/@popperjs/core/lib/utils/orderModifiers.js
|
||
function order(modifiers) {
|
||
var map = /* @__PURE__ */ new Map();
|
||
var visited = /* @__PURE__ */ new Set();
|
||
var result = [];
|
||
modifiers.forEach(function(modifier) {
|
||
map.set(modifier.name, modifier);
|
||
});
|
||
function sort(modifier) {
|
||
visited.add(modifier.name);
|
||
var requires = [].concat(modifier.requires || [], modifier.requiresIfExists || []);
|
||
requires.forEach(function(dep) {
|
||
if (!visited.has(dep)) {
|
||
var depModifier = map.get(dep);
|
||
if (depModifier) {
|
||
sort(depModifier);
|
||
}
|
||
}
|
||
});
|
||
result.push(modifier);
|
||
}
|
||
modifiers.forEach(function(modifier) {
|
||
if (!visited.has(modifier.name)) {
|
||
sort(modifier);
|
||
}
|
||
});
|
||
return result;
|
||
}
|
||
function orderModifiers(modifiers) {
|
||
var orderedModifiers = order(modifiers);
|
||
return modifierPhases.reduce(function(acc, phase) {
|
||
return acc.concat(orderedModifiers.filter(function(modifier) {
|
||
return modifier.phase === phase;
|
||
}));
|
||
}, []);
|
||
}
|
||
|
||
// node_modules/@popperjs/core/lib/utils/debounce.js
|
||
function debounce(fn2) {
|
||
var pending;
|
||
return function() {
|
||
if (!pending) {
|
||
pending = new Promise(function(resolve) {
|
||
Promise.resolve().then(function() {
|
||
pending = void 0;
|
||
resolve(fn2());
|
||
});
|
||
});
|
||
}
|
||
return pending;
|
||
};
|
||
}
|
||
|
||
// node_modules/@popperjs/core/lib/utils/mergeByName.js
|
||
function mergeByName(modifiers) {
|
||
var merged = modifiers.reduce(function(merged2, current) {
|
||
var existing = merged2[current.name];
|
||
merged2[current.name] = existing ? Object.assign({}, existing, current, {
|
||
options: Object.assign({}, existing.options, current.options),
|
||
data: Object.assign({}, existing.data, current.data)
|
||
}) : current;
|
||
return merged2;
|
||
}, {});
|
||
return Object.keys(merged).map(function(key) {
|
||
return merged[key];
|
||
});
|
||
}
|
||
|
||
// node_modules/@popperjs/core/lib/createPopper.js
|
||
var DEFAULT_OPTIONS = {
|
||
placement: "bottom",
|
||
modifiers: [],
|
||
strategy: "absolute"
|
||
};
|
||
function areValidElements() {
|
||
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
||
args[_key] = arguments[_key];
|
||
}
|
||
return !args.some(function(element) {
|
||
return !(element && typeof element.getBoundingClientRect === "function");
|
||
});
|
||
}
|
||
function popperGenerator(generatorOptions) {
|
||
if (generatorOptions === void 0) {
|
||
generatorOptions = {};
|
||
}
|
||
var _generatorOptions = generatorOptions, _generatorOptions$def = _generatorOptions.defaultModifiers, defaultModifiers3 = _generatorOptions$def === void 0 ? [] : _generatorOptions$def, _generatorOptions$def2 = _generatorOptions.defaultOptions, defaultOptions2 = _generatorOptions$def2 === void 0 ? DEFAULT_OPTIONS : _generatorOptions$def2;
|
||
return function createPopper4(reference2, popper2, options) {
|
||
if (options === void 0) {
|
||
options = defaultOptions2;
|
||
}
|
||
var state = {
|
||
placement: "bottom",
|
||
orderedModifiers: [],
|
||
options: Object.assign({}, DEFAULT_OPTIONS, defaultOptions2),
|
||
modifiersData: {},
|
||
elements: {
|
||
reference: reference2,
|
||
popper: popper2
|
||
},
|
||
attributes: {},
|
||
styles: {}
|
||
};
|
||
var effectCleanupFns = [];
|
||
var isDestroyed = false;
|
||
var instance = {
|
||
state,
|
||
setOptions: function setOptions(setOptionsAction) {
|
||
var options2 = typeof setOptionsAction === "function" ? setOptionsAction(state.options) : setOptionsAction;
|
||
cleanupModifierEffects();
|
||
state.options = Object.assign({}, defaultOptions2, state.options, options2);
|
||
state.scrollParents = {
|
||
reference: isElement(reference2) ? listScrollParents(reference2) : reference2.contextElement ? listScrollParents(reference2.contextElement) : [],
|
||
popper: listScrollParents(popper2)
|
||
};
|
||
var orderedModifiers = orderModifiers(mergeByName([].concat(defaultModifiers3, state.options.modifiers)));
|
||
state.orderedModifiers = orderedModifiers.filter(function(m) {
|
||
return m.enabled;
|
||
});
|
||
runModifierEffects();
|
||
return instance.update();
|
||
},
|
||
// Sync update – it will always be executed, even if not necessary. This
|
||
// is useful for low frequency updates where sync behavior simplifies the
|
||
// logic.
|
||
// For high frequency updates (e.g. `resize` and `scroll` events), always
|
||
// prefer the async Popper#update method
|
||
forceUpdate: function forceUpdate() {
|
||
if (isDestroyed) {
|
||
return;
|
||
}
|
||
var _state$elements = state.elements, reference3 = _state$elements.reference, popper3 = _state$elements.popper;
|
||
if (!areValidElements(reference3, popper3)) {
|
||
return;
|
||
}
|
||
state.rects = {
|
||
reference: getCompositeRect(reference3, getOffsetParent(popper3), state.options.strategy === "fixed"),
|
||
popper: getLayoutRect(popper3)
|
||
};
|
||
state.reset = false;
|
||
state.placement = state.options.placement;
|
||
state.orderedModifiers.forEach(function(modifier) {
|
||
return state.modifiersData[modifier.name] = Object.assign({}, modifier.data);
|
||
});
|
||
for (var index = 0; index < state.orderedModifiers.length; index++) {
|
||
if (state.reset === true) {
|
||
state.reset = false;
|
||
index = -1;
|
||
continue;
|
||
}
|
||
var _state$orderedModifie = state.orderedModifiers[index], fn2 = _state$orderedModifie.fn, _state$orderedModifie2 = _state$orderedModifie.options, _options = _state$orderedModifie2 === void 0 ? {} : _state$orderedModifie2, name = _state$orderedModifie.name;
|
||
if (typeof fn2 === "function") {
|
||
state = fn2({
|
||
state,
|
||
options: _options,
|
||
name,
|
||
instance
|
||
}) || state;
|
||
}
|
||
}
|
||
},
|
||
// Async and optimistically optimized update – it will not be executed if
|
||
// not necessary (debounced to run at most once-per-tick)
|
||
update: debounce(function() {
|
||
return new Promise(function(resolve) {
|
||
instance.forceUpdate();
|
||
resolve(state);
|
||
});
|
||
}),
|
||
destroy: function destroy() {
|
||
cleanupModifierEffects();
|
||
isDestroyed = true;
|
||
}
|
||
};
|
||
if (!areValidElements(reference2, popper2)) {
|
||
return instance;
|
||
}
|
||
instance.setOptions(options).then(function(state2) {
|
||
if (!isDestroyed && options.onFirstUpdate) {
|
||
options.onFirstUpdate(state2);
|
||
}
|
||
});
|
||
function runModifierEffects() {
|
||
state.orderedModifiers.forEach(function(_ref) {
|
||
var name = _ref.name, _ref$options = _ref.options, options2 = _ref$options === void 0 ? {} : _ref$options, effect4 = _ref.effect;
|
||
if (typeof effect4 === "function") {
|
||
var cleanupFn = effect4({
|
||
state,
|
||
name,
|
||
instance,
|
||
options: options2
|
||
});
|
||
var noopFn = function noopFn2() {
|
||
};
|
||
effectCleanupFns.push(cleanupFn || noopFn);
|
||
}
|
||
});
|
||
}
|
||
function cleanupModifierEffects() {
|
||
effectCleanupFns.forEach(function(fn2) {
|
||
return fn2();
|
||
});
|
||
effectCleanupFns = [];
|
||
}
|
||
return instance;
|
||
};
|
||
}
|
||
var createPopper = /* @__PURE__ */ popperGenerator();
|
||
|
||
// node_modules/@popperjs/core/lib/popper-lite.js
|
||
var defaultModifiers = [eventListeners_default, popperOffsets_default, computeStyles_default, applyStyles_default];
|
||
var createPopper2 = /* @__PURE__ */ popperGenerator({
|
||
defaultModifiers
|
||
});
|
||
|
||
// node_modules/@popperjs/core/lib/popper.js
|
||
var defaultModifiers2 = [eventListeners_default, popperOffsets_default, computeStyles_default, applyStyles_default, offset_default, flip_default, preventOverflow_default, arrow_default, hide_default];
|
||
var createPopper3 = /* @__PURE__ */ popperGenerator({
|
||
defaultModifiers: defaultModifiers2
|
||
});
|
||
|
||
// node_modules/bootstrap/dist/js/bootstrap.esm.js
|
||
var elementMap = /* @__PURE__ */ new Map();
|
||
var Data = {
|
||
set(element, key, instance) {
|
||
if (!elementMap.has(element)) {
|
||
elementMap.set(element, /* @__PURE__ */ new Map());
|
||
}
|
||
const instanceMap = elementMap.get(element);
|
||
if (!instanceMap.has(key) && instanceMap.size !== 0) {
|
||
console.error(`Bootstrap doesn't allow more than one instance per element. Bound instance: ${Array.from(instanceMap.keys())[0]}.`);
|
||
return;
|
||
}
|
||
instanceMap.set(key, instance);
|
||
},
|
||
get(element, key) {
|
||
if (elementMap.has(element)) {
|
||
return elementMap.get(element).get(key) || null;
|
||
}
|
||
return null;
|
||
},
|
||
remove(element, key) {
|
||
if (!elementMap.has(element)) {
|
||
return;
|
||
}
|
||
const instanceMap = elementMap.get(element);
|
||
instanceMap.delete(key);
|
||
if (instanceMap.size === 0) {
|
||
elementMap.delete(element);
|
||
}
|
||
}
|
||
};
|
||
var MAX_UID = 1e6;
|
||
var MILLISECONDS_MULTIPLIER = 1e3;
|
||
var TRANSITION_END = "transitionend";
|
||
var parseSelector = (selector) => {
|
||
if (selector && window.CSS && window.CSS.escape) {
|
||
selector = selector.replace(/#([^\s"#']+)/g, (match, id2) => `#${CSS.escape(id2)}`);
|
||
}
|
||
return selector;
|
||
};
|
||
var toType = (object) => {
|
||
if (object === null || object === void 0) {
|
||
return `${object}`;
|
||
}
|
||
return Object.prototype.toString.call(object).match(/\s([a-z]+)/i)[1].toLowerCase();
|
||
};
|
||
var getUID = (prefix) => {
|
||
do {
|
||
prefix += Math.floor(Math.random() * MAX_UID);
|
||
} while (document.getElementById(prefix));
|
||
return prefix;
|
||
};
|
||
var getTransitionDurationFromElement = (element) => {
|
||
if (!element) {
|
||
return 0;
|
||
}
|
||
let {
|
||
transitionDuration,
|
||
transitionDelay
|
||
} = window.getComputedStyle(element);
|
||
const floatTransitionDuration = Number.parseFloat(transitionDuration);
|
||
const floatTransitionDelay = Number.parseFloat(transitionDelay);
|
||
if (!floatTransitionDuration && !floatTransitionDelay) {
|
||
return 0;
|
||
}
|
||
transitionDuration = transitionDuration.split(",")[0];
|
||
transitionDelay = transitionDelay.split(",")[0];
|
||
return (Number.parseFloat(transitionDuration) + Number.parseFloat(transitionDelay)) * MILLISECONDS_MULTIPLIER;
|
||
};
|
||
var triggerTransitionEnd = (element) => {
|
||
element.dispatchEvent(new Event(TRANSITION_END));
|
||
};
|
||
var isElement2 = (object) => {
|
||
if (!object || typeof object !== "object") {
|
||
return false;
|
||
}
|
||
if (typeof object.jquery !== "undefined") {
|
||
object = object[0];
|
||
}
|
||
return typeof object.nodeType !== "undefined";
|
||
};
|
||
var getElement = (object) => {
|
||
if (isElement2(object)) {
|
||
return object.jquery ? object[0] : object;
|
||
}
|
||
if (typeof object === "string" && object.length > 0) {
|
||
return document.querySelector(parseSelector(object));
|
||
}
|
||
return null;
|
||
};
|
||
var isVisible = (element) => {
|
||
if (!isElement2(element) || element.getClientRects().length === 0) {
|
||
return false;
|
||
}
|
||
const elementIsVisible = getComputedStyle(element).getPropertyValue("visibility") === "visible";
|
||
const closedDetails = element.closest("details:not([open])");
|
||
if (!closedDetails) {
|
||
return elementIsVisible;
|
||
}
|
||
if (closedDetails !== element) {
|
||
const summary = element.closest("summary");
|
||
if (summary && summary.parentNode !== closedDetails) {
|
||
return false;
|
||
}
|
||
if (summary === null) {
|
||
return false;
|
||
}
|
||
}
|
||
return elementIsVisible;
|
||
};
|
||
var isDisabled = (element) => {
|
||
if (!element || element.nodeType !== Node.ELEMENT_NODE) {
|
||
return true;
|
||
}
|
||
if (element.classList.contains("disabled")) {
|
||
return true;
|
||
}
|
||
if (typeof element.disabled !== "undefined") {
|
||
return element.disabled;
|
||
}
|
||
return element.hasAttribute("disabled") && element.getAttribute("disabled") !== "false";
|
||
};
|
||
var findShadowRoot = (element) => {
|
||
if (!document.documentElement.attachShadow) {
|
||
return null;
|
||
}
|
||
if (typeof element.getRootNode === "function") {
|
||
const root = element.getRootNode();
|
||
return root instanceof ShadowRoot ? root : null;
|
||
}
|
||
if (element instanceof ShadowRoot) {
|
||
return element;
|
||
}
|
||
if (!element.parentNode) {
|
||
return null;
|
||
}
|
||
return findShadowRoot(element.parentNode);
|
||
};
|
||
var noop = () => {
|
||
};
|
||
var reflow = (element) => {
|
||
element.offsetHeight;
|
||
};
|
||
var getjQuery = () => {
|
||
if (window.jQuery && !document.body.hasAttribute("data-bs-no-jquery")) {
|
||
return window.jQuery;
|
||
}
|
||
return null;
|
||
};
|
||
var DOMContentLoadedCallbacks = [];
|
||
var onDOMContentLoaded = (callback) => {
|
||
if (document.readyState === "loading") {
|
||
if (!DOMContentLoadedCallbacks.length) {
|
||
document.addEventListener("DOMContentLoaded", () => {
|
||
for (const callback2 of DOMContentLoadedCallbacks) {
|
||
callback2();
|
||
}
|
||
});
|
||
}
|
||
DOMContentLoadedCallbacks.push(callback);
|
||
} else {
|
||
callback();
|
||
}
|
||
};
|
||
var isRTL = () => document.documentElement.dir === "rtl";
|
||
var defineJQueryPlugin = (plugin) => {
|
||
onDOMContentLoaded(() => {
|
||
const $ = getjQuery();
|
||
if ($) {
|
||
const name = plugin.NAME;
|
||
const JQUERY_NO_CONFLICT = $.fn[name];
|
||
$.fn[name] = plugin.jQueryInterface;
|
||
$.fn[name].Constructor = plugin;
|
||
$.fn[name].noConflict = () => {
|
||
$.fn[name] = JQUERY_NO_CONFLICT;
|
||
return plugin.jQueryInterface;
|
||
};
|
||
}
|
||
});
|
||
};
|
||
var execute = (possibleCallback, args = [], defaultValue = possibleCallback) => {
|
||
return typeof possibleCallback === "function" ? possibleCallback(...args) : defaultValue;
|
||
};
|
||
var executeAfterTransition = (callback, transitionElement, waitForTransition = true) => {
|
||
if (!waitForTransition) {
|
||
execute(callback);
|
||
return;
|
||
}
|
||
const durationPadding = 5;
|
||
const emulatedDuration = getTransitionDurationFromElement(transitionElement) + durationPadding;
|
||
let called = false;
|
||
const handler = ({
|
||
target
|
||
}) => {
|
||
if (target !== transitionElement) {
|
||
return;
|
||
}
|
||
called = true;
|
||
transitionElement.removeEventListener(TRANSITION_END, handler);
|
||
execute(callback);
|
||
};
|
||
transitionElement.addEventListener(TRANSITION_END, handler);
|
||
setTimeout(() => {
|
||
if (!called) {
|
||
triggerTransitionEnd(transitionElement);
|
||
}
|
||
}, emulatedDuration);
|
||
};
|
||
var getNextActiveElement = (list, activeElement, shouldGetNext, isCycleAllowed) => {
|
||
const listLength = list.length;
|
||
let index = list.indexOf(activeElement);
|
||
if (index === -1) {
|
||
return !shouldGetNext && isCycleAllowed ? list[listLength - 1] : list[0];
|
||
}
|
||
index += shouldGetNext ? 1 : -1;
|
||
if (isCycleAllowed) {
|
||
index = (index + listLength) % listLength;
|
||
}
|
||
return list[Math.max(0, Math.min(index, listLength - 1))];
|
||
};
|
||
var namespaceRegex = /[^.]*(?=\..*)\.|.*/;
|
||
var stripNameRegex = /\..*/;
|
||
var stripUidRegex = /::\d+$/;
|
||
var eventRegistry = {};
|
||
var uidEvent = 1;
|
||
var customEvents = {
|
||
mouseenter: "mouseover",
|
||
mouseleave: "mouseout"
|
||
};
|
||
var nativeEvents = /* @__PURE__ */ new Set(["click", "dblclick", "mouseup", "mousedown", "contextmenu", "mousewheel", "DOMMouseScroll", "mouseover", "mouseout", "mousemove", "selectstart", "selectend", "keydown", "keypress", "keyup", "orientationchange", "touchstart", "touchmove", "touchend", "touchcancel", "pointerdown", "pointermove", "pointerup", "pointerleave", "pointercancel", "gesturestart", "gesturechange", "gestureend", "focus", "blur", "change", "reset", "select", "submit", "focusin", "focusout", "load", "unload", "beforeunload", "resize", "move", "DOMContentLoaded", "readystatechange", "error", "abort", "scroll"]);
|
||
function makeEventUid(element, uid) {
|
||
return uid && `${uid}::${uidEvent++}` || element.uidEvent || uidEvent++;
|
||
}
|
||
function getElementEvents(element) {
|
||
const uid = makeEventUid(element);
|
||
element.uidEvent = uid;
|
||
eventRegistry[uid] = eventRegistry[uid] || {};
|
||
return eventRegistry[uid];
|
||
}
|
||
function bootstrapHandler(element, fn2) {
|
||
return function handler(event) {
|
||
hydrateObj(event, {
|
||
delegateTarget: element
|
||
});
|
||
if (handler.oneOff) {
|
||
EventHandler.off(element, event.type, fn2);
|
||
}
|
||
return fn2.apply(element, [event]);
|
||
};
|
||
}
|
||
function bootstrapDelegationHandler(element, selector, fn2) {
|
||
return function handler(event) {
|
||
const domElements = element.querySelectorAll(selector);
|
||
for (let {
|
||
target
|
||
} = event; target && target !== this; target = target.parentNode) {
|
||
for (const domElement of domElements) {
|
||
if (domElement !== target) {
|
||
continue;
|
||
}
|
||
hydrateObj(event, {
|
||
delegateTarget: target
|
||
});
|
||
if (handler.oneOff) {
|
||
EventHandler.off(element, event.type, selector, fn2);
|
||
}
|
||
return fn2.apply(target, [event]);
|
||
}
|
||
}
|
||
};
|
||
}
|
||
function findHandler(events, callable, delegationSelector = null) {
|
||
return Object.values(events).find((event) => event.callable === callable && event.delegationSelector === delegationSelector);
|
||
}
|
||
function normalizeParameters(originalTypeEvent, handler, delegationFunction) {
|
||
const isDelegated = typeof handler === "string";
|
||
const callable = isDelegated ? delegationFunction : handler || delegationFunction;
|
||
let typeEvent = getTypeEvent(originalTypeEvent);
|
||
if (!nativeEvents.has(typeEvent)) {
|
||
typeEvent = originalTypeEvent;
|
||
}
|
||
return [isDelegated, callable, typeEvent];
|
||
}
|
||
function addHandler(element, originalTypeEvent, handler, delegationFunction, oneOff) {
|
||
if (typeof originalTypeEvent !== "string" || !element) {
|
||
return;
|
||
}
|
||
let [isDelegated, callable, typeEvent] = normalizeParameters(originalTypeEvent, handler, delegationFunction);
|
||
if (originalTypeEvent in customEvents) {
|
||
const wrapFunction = (fn3) => {
|
||
return function(event) {
|
||
if (!event.relatedTarget || event.relatedTarget !== event.delegateTarget && !event.delegateTarget.contains(event.relatedTarget)) {
|
||
return fn3.call(this, event);
|
||
}
|
||
};
|
||
};
|
||
callable = wrapFunction(callable);
|
||
}
|
||
const events = getElementEvents(element);
|
||
const handlers = events[typeEvent] || (events[typeEvent] = {});
|
||
const previousFunction = findHandler(handlers, callable, isDelegated ? handler : null);
|
||
if (previousFunction) {
|
||
previousFunction.oneOff = previousFunction.oneOff && oneOff;
|
||
return;
|
||
}
|
||
const uid = makeEventUid(callable, originalTypeEvent.replace(namespaceRegex, ""));
|
||
const fn2 = isDelegated ? bootstrapDelegationHandler(element, handler, callable) : bootstrapHandler(element, callable);
|
||
fn2.delegationSelector = isDelegated ? handler : null;
|
||
fn2.callable = callable;
|
||
fn2.oneOff = oneOff;
|
||
fn2.uidEvent = uid;
|
||
handlers[uid] = fn2;
|
||
element.addEventListener(typeEvent, fn2, isDelegated);
|
||
}
|
||
function removeHandler(element, events, typeEvent, handler, delegationSelector) {
|
||
const fn2 = findHandler(events[typeEvent], handler, delegationSelector);
|
||
if (!fn2) {
|
||
return;
|
||
}
|
||
element.removeEventListener(typeEvent, fn2, Boolean(delegationSelector));
|
||
delete events[typeEvent][fn2.uidEvent];
|
||
}
|
||
function removeNamespacedHandlers(element, events, typeEvent, namespace) {
|
||
const storeElementEvent = events[typeEvent] || {};
|
||
for (const [handlerKey, event] of Object.entries(storeElementEvent)) {
|
||
if (handlerKey.includes(namespace)) {
|
||
removeHandler(element, events, typeEvent, event.callable, event.delegationSelector);
|
||
}
|
||
}
|
||
}
|
||
function getTypeEvent(event) {
|
||
event = event.replace(stripNameRegex, "");
|
||
return customEvents[event] || event;
|
||
}
|
||
var EventHandler = {
|
||
on(element, event, handler, delegationFunction) {
|
||
addHandler(element, event, handler, delegationFunction, false);
|
||
},
|
||
one(element, event, handler, delegationFunction) {
|
||
addHandler(element, event, handler, delegationFunction, true);
|
||
},
|
||
off(element, originalTypeEvent, handler, delegationFunction) {
|
||
if (typeof originalTypeEvent !== "string" || !element) {
|
||
return;
|
||
}
|
||
const [isDelegated, callable, typeEvent] = normalizeParameters(originalTypeEvent, handler, delegationFunction);
|
||
const inNamespace = typeEvent !== originalTypeEvent;
|
||
const events = getElementEvents(element);
|
||
const storeElementEvent = events[typeEvent] || {};
|
||
const isNamespace = originalTypeEvent.startsWith(".");
|
||
if (typeof callable !== "undefined") {
|
||
if (!Object.keys(storeElementEvent).length) {
|
||
return;
|
||
}
|
||
removeHandler(element, events, typeEvent, callable, isDelegated ? handler : null);
|
||
return;
|
||
}
|
||
if (isNamespace) {
|
||
for (const elementEvent of Object.keys(events)) {
|
||
removeNamespacedHandlers(element, events, elementEvent, originalTypeEvent.slice(1));
|
||
}
|
||
}
|
||
for (const [keyHandlers, event] of Object.entries(storeElementEvent)) {
|
||
const handlerKey = keyHandlers.replace(stripUidRegex, "");
|
||
if (!inNamespace || originalTypeEvent.includes(handlerKey)) {
|
||
removeHandler(element, events, typeEvent, event.callable, event.delegationSelector);
|
||
}
|
||
}
|
||
},
|
||
trigger(element, event, args) {
|
||
if (typeof event !== "string" || !element) {
|
||
return null;
|
||
}
|
||
const $ = getjQuery();
|
||
const typeEvent = getTypeEvent(event);
|
||
const inNamespace = event !== typeEvent;
|
||
let jQueryEvent = null;
|
||
let bubbles = true;
|
||
let nativeDispatch = true;
|
||
let defaultPrevented = false;
|
||
if (inNamespace && $) {
|
||
jQueryEvent = $.Event(event, args);
|
||
$(element).trigger(jQueryEvent);
|
||
bubbles = !jQueryEvent.isPropagationStopped();
|
||
nativeDispatch = !jQueryEvent.isImmediatePropagationStopped();
|
||
defaultPrevented = jQueryEvent.isDefaultPrevented();
|
||
}
|
||
const evt = hydrateObj(new Event(event, {
|
||
bubbles,
|
||
cancelable: true
|
||
}), args);
|
||
if (defaultPrevented) {
|
||
evt.preventDefault();
|
||
}
|
||
if (nativeDispatch) {
|
||
element.dispatchEvent(evt);
|
||
}
|
||
if (evt.defaultPrevented && jQueryEvent) {
|
||
jQueryEvent.preventDefault();
|
||
}
|
||
return evt;
|
||
}
|
||
};
|
||
function hydrateObj(obj, meta = {}) {
|
||
for (const [key, value] of Object.entries(meta)) {
|
||
try {
|
||
obj[key] = value;
|
||
} catch (_unused) {
|
||
Object.defineProperty(obj, key, {
|
||
configurable: true,
|
||
get() {
|
||
return value;
|
||
}
|
||
});
|
||
}
|
||
}
|
||
return obj;
|
||
}
|
||
function normalizeData(value) {
|
||
if (value === "true") {
|
||
return true;
|
||
}
|
||
if (value === "false") {
|
||
return false;
|
||
}
|
||
if (value === Number(value).toString()) {
|
||
return Number(value);
|
||
}
|
||
if (value === "" || value === "null") {
|
||
return null;
|
||
}
|
||
if (typeof value !== "string") {
|
||
return value;
|
||
}
|
||
try {
|
||
return JSON.parse(decodeURIComponent(value));
|
||
} catch (_unused) {
|
||
return value;
|
||
}
|
||
}
|
||
function normalizeDataKey(key) {
|
||
return key.replace(/[A-Z]/g, (chr) => `-${chr.toLowerCase()}`);
|
||
}
|
||
var Manipulator = {
|
||
setDataAttribute(element, key, value) {
|
||
element.setAttribute(`data-bs-${normalizeDataKey(key)}`, value);
|
||
},
|
||
removeDataAttribute(element, key) {
|
||
element.removeAttribute(`data-bs-${normalizeDataKey(key)}`);
|
||
},
|
||
getDataAttributes(element) {
|
||
if (!element) {
|
||
return {};
|
||
}
|
||
const attributes = {};
|
||
const bsKeys = Object.keys(element.dataset).filter((key) => key.startsWith("bs") && !key.startsWith("bsConfig"));
|
||
for (const key of bsKeys) {
|
||
let pureKey = key.replace(/^bs/, "");
|
||
pureKey = pureKey.charAt(0).toLowerCase() + pureKey.slice(1, pureKey.length);
|
||
attributes[pureKey] = normalizeData(element.dataset[key]);
|
||
}
|
||
return attributes;
|
||
},
|
||
getDataAttribute(element, key) {
|
||
return normalizeData(element.getAttribute(`data-bs-${normalizeDataKey(key)}`));
|
||
}
|
||
};
|
||
var Config = class {
|
||
// Getters
|
||
static get Default() {
|
||
return {};
|
||
}
|
||
static get DefaultType() {
|
||
return {};
|
||
}
|
||
static get NAME() {
|
||
throw new Error('You have to implement the static method "NAME", for each component!');
|
||
}
|
||
_getConfig(config) {
|
||
config = this._mergeConfigObj(config);
|
||
config = this._configAfterMerge(config);
|
||
this._typeCheckConfig(config);
|
||
return config;
|
||
}
|
||
_configAfterMerge(config) {
|
||
return config;
|
||
}
|
||
_mergeConfigObj(config, element) {
|
||
const jsonConfig = isElement2(element) ? Manipulator.getDataAttribute(element, "config") : {};
|
||
return {
|
||
...this.constructor.Default,
|
||
...typeof jsonConfig === "object" ? jsonConfig : {},
|
||
...isElement2(element) ? Manipulator.getDataAttributes(element) : {},
|
||
...typeof config === "object" ? config : {}
|
||
};
|
||
}
|
||
_typeCheckConfig(config, configTypes = this.constructor.DefaultType) {
|
||
for (const [property, expectedTypes] of Object.entries(configTypes)) {
|
||
const value = config[property];
|
||
const valueType = isElement2(value) ? "element" : toType(value);
|
||
if (!new RegExp(expectedTypes).test(valueType)) {
|
||
throw new TypeError(`${this.constructor.NAME.toUpperCase()}: Option "${property}" provided type "${valueType}" but expected type "${expectedTypes}".`);
|
||
}
|
||
}
|
||
}
|
||
};
|
||
var VERSION = "5.3.0";
|
||
var BaseComponent = class extends Config {
|
||
constructor(element, config) {
|
||
super();
|
||
element = getElement(element);
|
||
if (!element) {
|
||
return;
|
||
}
|
||
this._element = element;
|
||
this._config = this._getConfig(config);
|
||
Data.set(this._element, this.constructor.DATA_KEY, this);
|
||
}
|
||
// Public
|
||
dispose() {
|
||
Data.remove(this._element, this.constructor.DATA_KEY);
|
||
EventHandler.off(this._element, this.constructor.EVENT_KEY);
|
||
for (const propertyName of Object.getOwnPropertyNames(this)) {
|
||
this[propertyName] = null;
|
||
}
|
||
}
|
||
_queueCallback(callback, element, isAnimated = true) {
|
||
executeAfterTransition(callback, element, isAnimated);
|
||
}
|
||
_getConfig(config) {
|
||
config = this._mergeConfigObj(config, this._element);
|
||
config = this._configAfterMerge(config);
|
||
this._typeCheckConfig(config);
|
||
return config;
|
||
}
|
||
// Static
|
||
static getInstance(element) {
|
||
return Data.get(getElement(element), this.DATA_KEY);
|
||
}
|
||
static getOrCreateInstance(element, config = {}) {
|
||
return this.getInstance(element) || new this(element, typeof config === "object" ? config : null);
|
||
}
|
||
static get VERSION() {
|
||
return VERSION;
|
||
}
|
||
static get DATA_KEY() {
|
||
return `bs.${this.NAME}`;
|
||
}
|
||
static get EVENT_KEY() {
|
||
return `.${this.DATA_KEY}`;
|
||
}
|
||
static eventName(name) {
|
||
return `${name}${this.EVENT_KEY}`;
|
||
}
|
||
};
|
||
var getSelector = (element) => {
|
||
let selector = element.getAttribute("data-bs-target");
|
||
if (!selector || selector === "#") {
|
||
let hrefAttribute = element.getAttribute("href");
|
||
if (!hrefAttribute || !hrefAttribute.includes("#") && !hrefAttribute.startsWith(".")) {
|
||
return null;
|
||
}
|
||
if (hrefAttribute.includes("#") && !hrefAttribute.startsWith("#")) {
|
||
hrefAttribute = `#${hrefAttribute.split("#")[1]}`;
|
||
}
|
||
selector = hrefAttribute && hrefAttribute !== "#" ? hrefAttribute.trim() : null;
|
||
}
|
||
return parseSelector(selector);
|
||
};
|
||
var SelectorEngine = {
|
||
find(selector, element = document.documentElement) {
|
||
return [].concat(...Element.prototype.querySelectorAll.call(element, selector));
|
||
},
|
||
findOne(selector, element = document.documentElement) {
|
||
return Element.prototype.querySelector.call(element, selector);
|
||
},
|
||
children(element, selector) {
|
||
return [].concat(...element.children).filter((child) => child.matches(selector));
|
||
},
|
||
parents(element, selector) {
|
||
const parents = [];
|
||
let ancestor = element.parentNode.closest(selector);
|
||
while (ancestor) {
|
||
parents.push(ancestor);
|
||
ancestor = ancestor.parentNode.closest(selector);
|
||
}
|
||
return parents;
|
||
},
|
||
prev(element, selector) {
|
||
let previous = element.previousElementSibling;
|
||
while (previous) {
|
||
if (previous.matches(selector)) {
|
||
return [previous];
|
||
}
|
||
previous = previous.previousElementSibling;
|
||
}
|
||
return [];
|
||
},
|
||
// TODO: this is now unused; remove later along with prev()
|
||
next(element, selector) {
|
||
let next = element.nextElementSibling;
|
||
while (next) {
|
||
if (next.matches(selector)) {
|
||
return [next];
|
||
}
|
||
next = next.nextElementSibling;
|
||
}
|
||
return [];
|
||
},
|
||
focusableChildren(element) {
|
||
const focusables = ["a", "button", "input", "textarea", "select", "details", "[tabindex]", '[contenteditable="true"]'].map((selector) => `${selector}:not([tabindex^="-"])`).join(",");
|
||
return this.find(focusables, element).filter((el) => !isDisabled(el) && isVisible(el));
|
||
},
|
||
getSelectorFromElement(element) {
|
||
const selector = getSelector(element);
|
||
if (selector) {
|
||
return SelectorEngine.findOne(selector) ? selector : null;
|
||
}
|
||
return null;
|
||
},
|
||
getElementFromSelector(element) {
|
||
const selector = getSelector(element);
|
||
return selector ? SelectorEngine.findOne(selector) : null;
|
||
},
|
||
getMultipleElementsFromSelector(element) {
|
||
const selector = getSelector(element);
|
||
return selector ? SelectorEngine.find(selector) : [];
|
||
}
|
||
};
|
||
var enableDismissTrigger = (component, method = "hide") => {
|
||
const clickEvent = `click.dismiss${component.EVENT_KEY}`;
|
||
const name = component.NAME;
|
||
EventHandler.on(document, clickEvent, `[data-bs-dismiss="${name}"]`, function(event) {
|
||
if (["A", "AREA"].includes(this.tagName)) {
|
||
event.preventDefault();
|
||
}
|
||
if (isDisabled(this)) {
|
||
return;
|
||
}
|
||
const target = SelectorEngine.getElementFromSelector(this) || this.closest(`.${name}`);
|
||
const instance = component.getOrCreateInstance(target);
|
||
instance[method]();
|
||
});
|
||
};
|
||
var NAME$f = "alert";
|
||
var DATA_KEY$a = "bs.alert";
|
||
var EVENT_KEY$b = `.${DATA_KEY$a}`;
|
||
var EVENT_CLOSE = `close${EVENT_KEY$b}`;
|
||
var EVENT_CLOSED = `closed${EVENT_KEY$b}`;
|
||
var CLASS_NAME_FADE$5 = "fade";
|
||
var CLASS_NAME_SHOW$8 = "show";
|
||
var Alert = class _Alert extends BaseComponent {
|
||
// Getters
|
||
static get NAME() {
|
||
return NAME$f;
|
||
}
|
||
// Public
|
||
close() {
|
||
const closeEvent = EventHandler.trigger(this._element, EVENT_CLOSE);
|
||
if (closeEvent.defaultPrevented) {
|
||
return;
|
||
}
|
||
this._element.classList.remove(CLASS_NAME_SHOW$8);
|
||
const isAnimated = this._element.classList.contains(CLASS_NAME_FADE$5);
|
||
this._queueCallback(() => this._destroyElement(), this._element, isAnimated);
|
||
}
|
||
// Private
|
||
_destroyElement() {
|
||
this._element.remove();
|
||
EventHandler.trigger(this._element, EVENT_CLOSED);
|
||
this.dispose();
|
||
}
|
||
// Static
|
||
static jQueryInterface(config) {
|
||
return this.each(function() {
|
||
const data = _Alert.getOrCreateInstance(this);
|
||
if (typeof config !== "string") {
|
||
return;
|
||
}
|
||
if (data[config] === void 0 || config.startsWith("_") || config === "constructor") {
|
||
throw new TypeError(`No method named "${config}"`);
|
||
}
|
||
data[config](this);
|
||
});
|
||
}
|
||
};
|
||
enableDismissTrigger(Alert, "close");
|
||
defineJQueryPlugin(Alert);
|
||
var NAME$e = "button";
|
||
var DATA_KEY$9 = "bs.button";
|
||
var EVENT_KEY$a = `.${DATA_KEY$9}`;
|
||
var DATA_API_KEY$6 = ".data-api";
|
||
var CLASS_NAME_ACTIVE$3 = "active";
|
||
var SELECTOR_DATA_TOGGLE$5 = '[data-bs-toggle="button"]';
|
||
var EVENT_CLICK_DATA_API$6 = `click${EVENT_KEY$a}${DATA_API_KEY$6}`;
|
||
var Button = class _Button extends BaseComponent {
|
||
// Getters
|
||
static get NAME() {
|
||
return NAME$e;
|
||
}
|
||
// Public
|
||
toggle() {
|
||
this._element.setAttribute("aria-pressed", this._element.classList.toggle(CLASS_NAME_ACTIVE$3));
|
||
}
|
||
// Static
|
||
static jQueryInterface(config) {
|
||
return this.each(function() {
|
||
const data = _Button.getOrCreateInstance(this);
|
||
if (config === "toggle") {
|
||
data[config]();
|
||
}
|
||
});
|
||
}
|
||
};
|
||
EventHandler.on(document, EVENT_CLICK_DATA_API$6, SELECTOR_DATA_TOGGLE$5, (event) => {
|
||
event.preventDefault();
|
||
const button = event.target.closest(SELECTOR_DATA_TOGGLE$5);
|
||
const data = Button.getOrCreateInstance(button);
|
||
data.toggle();
|
||
});
|
||
defineJQueryPlugin(Button);
|
||
var NAME$d = "swipe";
|
||
var EVENT_KEY$9 = ".bs.swipe";
|
||
var EVENT_TOUCHSTART = `touchstart${EVENT_KEY$9}`;
|
||
var EVENT_TOUCHMOVE = `touchmove${EVENT_KEY$9}`;
|
||
var EVENT_TOUCHEND = `touchend${EVENT_KEY$9}`;
|
||
var EVENT_POINTERDOWN = `pointerdown${EVENT_KEY$9}`;
|
||
var EVENT_POINTERUP = `pointerup${EVENT_KEY$9}`;
|
||
var POINTER_TYPE_TOUCH = "touch";
|
||
var POINTER_TYPE_PEN = "pen";
|
||
var CLASS_NAME_POINTER_EVENT = "pointer-event";
|
||
var SWIPE_THRESHOLD = 40;
|
||
var Default$c = {
|
||
endCallback: null,
|
||
leftCallback: null,
|
||
rightCallback: null
|
||
};
|
||
var DefaultType$c = {
|
||
endCallback: "(function|null)",
|
||
leftCallback: "(function|null)",
|
||
rightCallback: "(function|null)"
|
||
};
|
||
var Swipe = class _Swipe extends Config {
|
||
constructor(element, config) {
|
||
super();
|
||
this._element = element;
|
||
if (!element || !_Swipe.isSupported()) {
|
||
return;
|
||
}
|
||
this._config = this._getConfig(config);
|
||
this._deltaX = 0;
|
||
this._supportPointerEvents = Boolean(window.PointerEvent);
|
||
this._initEvents();
|
||
}
|
||
// Getters
|
||
static get Default() {
|
||
return Default$c;
|
||
}
|
||
static get DefaultType() {
|
||
return DefaultType$c;
|
||
}
|
||
static get NAME() {
|
||
return NAME$d;
|
||
}
|
||
// Public
|
||
dispose() {
|
||
EventHandler.off(this._element, EVENT_KEY$9);
|
||
}
|
||
// Private
|
||
_start(event) {
|
||
if (!this._supportPointerEvents) {
|
||
this._deltaX = event.touches[0].clientX;
|
||
return;
|
||
}
|
||
if (this._eventIsPointerPenTouch(event)) {
|
||
this._deltaX = event.clientX;
|
||
}
|
||
}
|
||
_end(event) {
|
||
if (this._eventIsPointerPenTouch(event)) {
|
||
this._deltaX = event.clientX - this._deltaX;
|
||
}
|
||
this._handleSwipe();
|
||
execute(this._config.endCallback);
|
||
}
|
||
_move(event) {
|
||
this._deltaX = event.touches && event.touches.length > 1 ? 0 : event.touches[0].clientX - this._deltaX;
|
||
}
|
||
_handleSwipe() {
|
||
const absDeltaX = Math.abs(this._deltaX);
|
||
if (absDeltaX <= SWIPE_THRESHOLD) {
|
||
return;
|
||
}
|
||
const direction = absDeltaX / this._deltaX;
|
||
this._deltaX = 0;
|
||
if (!direction) {
|
||
return;
|
||
}
|
||
execute(direction > 0 ? this._config.rightCallback : this._config.leftCallback);
|
||
}
|
||
_initEvents() {
|
||
if (this._supportPointerEvents) {
|
||
EventHandler.on(this._element, EVENT_POINTERDOWN, (event) => this._start(event));
|
||
EventHandler.on(this._element, EVENT_POINTERUP, (event) => this._end(event));
|
||
this._element.classList.add(CLASS_NAME_POINTER_EVENT);
|
||
} else {
|
||
EventHandler.on(this._element, EVENT_TOUCHSTART, (event) => this._start(event));
|
||
EventHandler.on(this._element, EVENT_TOUCHMOVE, (event) => this._move(event));
|
||
EventHandler.on(this._element, EVENT_TOUCHEND, (event) => this._end(event));
|
||
}
|
||
}
|
||
_eventIsPointerPenTouch(event) {
|
||
return this._supportPointerEvents && (event.pointerType === POINTER_TYPE_PEN || event.pointerType === POINTER_TYPE_TOUCH);
|
||
}
|
||
// Static
|
||
static isSupported() {
|
||
return "ontouchstart" in document.documentElement || navigator.maxTouchPoints > 0;
|
||
}
|
||
};
|
||
var NAME$c = "carousel";
|
||
var DATA_KEY$8 = "bs.carousel";
|
||
var EVENT_KEY$8 = `.${DATA_KEY$8}`;
|
||
var DATA_API_KEY$5 = ".data-api";
|
||
var ARROW_LEFT_KEY$1 = "ArrowLeft";
|
||
var ARROW_RIGHT_KEY$1 = "ArrowRight";
|
||
var TOUCHEVENT_COMPAT_WAIT = 500;
|
||
var ORDER_NEXT = "next";
|
||
var ORDER_PREV = "prev";
|
||
var DIRECTION_LEFT = "left";
|
||
var DIRECTION_RIGHT = "right";
|
||
var EVENT_SLIDE = `slide${EVENT_KEY$8}`;
|
||
var EVENT_SLID = `slid${EVENT_KEY$8}`;
|
||
var EVENT_KEYDOWN$1 = `keydown${EVENT_KEY$8}`;
|
||
var EVENT_MOUSEENTER$1 = `mouseenter${EVENT_KEY$8}`;
|
||
var EVENT_MOUSELEAVE$1 = `mouseleave${EVENT_KEY$8}`;
|
||
var EVENT_DRAG_START = `dragstart${EVENT_KEY$8}`;
|
||
var EVENT_LOAD_DATA_API$3 = `load${EVENT_KEY$8}${DATA_API_KEY$5}`;
|
||
var EVENT_CLICK_DATA_API$5 = `click${EVENT_KEY$8}${DATA_API_KEY$5}`;
|
||
var CLASS_NAME_CAROUSEL = "carousel";
|
||
var CLASS_NAME_ACTIVE$2 = "active";
|
||
var CLASS_NAME_SLIDE = "slide";
|
||
var CLASS_NAME_END = "carousel-item-end";
|
||
var CLASS_NAME_START = "carousel-item-start";
|
||
var CLASS_NAME_NEXT = "carousel-item-next";
|
||
var CLASS_NAME_PREV = "carousel-item-prev";
|
||
var SELECTOR_ACTIVE = ".active";
|
||
var SELECTOR_ITEM = ".carousel-item";
|
||
var SELECTOR_ACTIVE_ITEM = SELECTOR_ACTIVE + SELECTOR_ITEM;
|
||
var SELECTOR_ITEM_IMG = ".carousel-item img";
|
||
var SELECTOR_INDICATORS = ".carousel-indicators";
|
||
var SELECTOR_DATA_SLIDE = "[data-bs-slide], [data-bs-slide-to]";
|
||
var SELECTOR_DATA_RIDE = '[data-bs-ride="carousel"]';
|
||
var KEY_TO_DIRECTION = {
|
||
[ARROW_LEFT_KEY$1]: DIRECTION_RIGHT,
|
||
[ARROW_RIGHT_KEY$1]: DIRECTION_LEFT
|
||
};
|
||
var Default$b = {
|
||
interval: 5e3,
|
||
keyboard: true,
|
||
pause: "hover",
|
||
ride: false,
|
||
touch: true,
|
||
wrap: true
|
||
};
|
||
var DefaultType$b = {
|
||
interval: "(number|boolean)",
|
||
// TODO:v6 remove boolean support
|
||
keyboard: "boolean",
|
||
pause: "(string|boolean)",
|
||
ride: "(boolean|string)",
|
||
touch: "boolean",
|
||
wrap: "boolean"
|
||
};
|
||
var Carousel = class _Carousel extends BaseComponent {
|
||
constructor(element, config) {
|
||
super(element, config);
|
||
this._interval = null;
|
||
this._activeElement = null;
|
||
this._isSliding = false;
|
||
this.touchTimeout = null;
|
||
this._swipeHelper = null;
|
||
this._indicatorsElement = SelectorEngine.findOne(SELECTOR_INDICATORS, this._element);
|
||
this._addEventListeners();
|
||
if (this._config.ride === CLASS_NAME_CAROUSEL) {
|
||
this.cycle();
|
||
}
|
||
}
|
||
// Getters
|
||
static get Default() {
|
||
return Default$b;
|
||
}
|
||
static get DefaultType() {
|
||
return DefaultType$b;
|
||
}
|
||
static get NAME() {
|
||
return NAME$c;
|
||
}
|
||
// Public
|
||
next() {
|
||
this._slide(ORDER_NEXT);
|
||
}
|
||
nextWhenVisible() {
|
||
if (!document.hidden && isVisible(this._element)) {
|
||
this.next();
|
||
}
|
||
}
|
||
prev() {
|
||
this._slide(ORDER_PREV);
|
||
}
|
||
pause() {
|
||
if (this._isSliding) {
|
||
triggerTransitionEnd(this._element);
|
||
}
|
||
this._clearInterval();
|
||
}
|
||
cycle() {
|
||
this._clearInterval();
|
||
this._updateInterval();
|
||
this._interval = setInterval(() => this.nextWhenVisible(), this._config.interval);
|
||
}
|
||
_maybeEnableCycle() {
|
||
if (!this._config.ride) {
|
||
return;
|
||
}
|
||
if (this._isSliding) {
|
||
EventHandler.one(this._element, EVENT_SLID, () => this.cycle());
|
||
return;
|
||
}
|
||
this.cycle();
|
||
}
|
||
to(index) {
|
||
const items = this._getItems();
|
||
if (index > items.length - 1 || index < 0) {
|
||
return;
|
||
}
|
||
if (this._isSliding) {
|
||
EventHandler.one(this._element, EVENT_SLID, () => this.to(index));
|
||
return;
|
||
}
|
||
const activeIndex = this._getItemIndex(this._getActive());
|
||
if (activeIndex === index) {
|
||
return;
|
||
}
|
||
const order2 = index > activeIndex ? ORDER_NEXT : ORDER_PREV;
|
||
this._slide(order2, items[index]);
|
||
}
|
||
dispose() {
|
||
if (this._swipeHelper) {
|
||
this._swipeHelper.dispose();
|
||
}
|
||
super.dispose();
|
||
}
|
||
// Private
|
||
_configAfterMerge(config) {
|
||
config.defaultInterval = config.interval;
|
||
return config;
|
||
}
|
||
_addEventListeners() {
|
||
if (this._config.keyboard) {
|
||
EventHandler.on(this._element, EVENT_KEYDOWN$1, (event) => this._keydown(event));
|
||
}
|
||
if (this._config.pause === "hover") {
|
||
EventHandler.on(this._element, EVENT_MOUSEENTER$1, () => this.pause());
|
||
EventHandler.on(this._element, EVENT_MOUSELEAVE$1, () => this._maybeEnableCycle());
|
||
}
|
||
if (this._config.touch && Swipe.isSupported()) {
|
||
this._addTouchEventListeners();
|
||
}
|
||
}
|
||
_addTouchEventListeners() {
|
||
for (const img of SelectorEngine.find(SELECTOR_ITEM_IMG, this._element)) {
|
||
EventHandler.on(img, EVENT_DRAG_START, (event) => event.preventDefault());
|
||
}
|
||
const endCallBack = () => {
|
||
if (this._config.pause !== "hover") {
|
||
return;
|
||
}
|
||
this.pause();
|
||
if (this.touchTimeout) {
|
||
clearTimeout(this.touchTimeout);
|
||
}
|
||
this.touchTimeout = setTimeout(() => this._maybeEnableCycle(), TOUCHEVENT_COMPAT_WAIT + this._config.interval);
|
||
};
|
||
const swipeConfig = {
|
||
leftCallback: () => this._slide(this._directionToOrder(DIRECTION_LEFT)),
|
||
rightCallback: () => this._slide(this._directionToOrder(DIRECTION_RIGHT)),
|
||
endCallback: endCallBack
|
||
};
|
||
this._swipeHelper = new Swipe(this._element, swipeConfig);
|
||
}
|
||
_keydown(event) {
|
||
if (/input|textarea/i.test(event.target.tagName)) {
|
||
return;
|
||
}
|
||
const direction = KEY_TO_DIRECTION[event.key];
|
||
if (direction) {
|
||
event.preventDefault();
|
||
this._slide(this._directionToOrder(direction));
|
||
}
|
||
}
|
||
_getItemIndex(element) {
|
||
return this._getItems().indexOf(element);
|
||
}
|
||
_setActiveIndicatorElement(index) {
|
||
if (!this._indicatorsElement) {
|
||
return;
|
||
}
|
||
const activeIndicator = SelectorEngine.findOne(SELECTOR_ACTIVE, this._indicatorsElement);
|
||
activeIndicator.classList.remove(CLASS_NAME_ACTIVE$2);
|
||
activeIndicator.removeAttribute("aria-current");
|
||
const newActiveIndicator = SelectorEngine.findOne(`[data-bs-slide-to="${index}"]`, this._indicatorsElement);
|
||
if (newActiveIndicator) {
|
||
newActiveIndicator.classList.add(CLASS_NAME_ACTIVE$2);
|
||
newActiveIndicator.setAttribute("aria-current", "true");
|
||
}
|
||
}
|
||
_updateInterval() {
|
||
const element = this._activeElement || this._getActive();
|
||
if (!element) {
|
||
return;
|
||
}
|
||
const elementInterval = Number.parseInt(element.getAttribute("data-bs-interval"), 10);
|
||
this._config.interval = elementInterval || this._config.defaultInterval;
|
||
}
|
||
_slide(order2, element = null) {
|
||
if (this._isSliding) {
|
||
return;
|
||
}
|
||
const activeElement = this._getActive();
|
||
const isNext = order2 === ORDER_NEXT;
|
||
const nextElement = element || getNextActiveElement(this._getItems(), activeElement, isNext, this._config.wrap);
|
||
if (nextElement === activeElement) {
|
||
return;
|
||
}
|
||
const nextElementIndex = this._getItemIndex(nextElement);
|
||
const triggerEvent = (eventName) => {
|
||
return EventHandler.trigger(this._element, eventName, {
|
||
relatedTarget: nextElement,
|
||
direction: this._orderToDirection(order2),
|
||
from: this._getItemIndex(activeElement),
|
||
to: nextElementIndex
|
||
});
|
||
};
|
||
const slideEvent = triggerEvent(EVENT_SLIDE);
|
||
if (slideEvent.defaultPrevented) {
|
||
return;
|
||
}
|
||
if (!activeElement || !nextElement) {
|
||
return;
|
||
}
|
||
const isCycling = Boolean(this._interval);
|
||
this.pause();
|
||
this._isSliding = true;
|
||
this._setActiveIndicatorElement(nextElementIndex);
|
||
this._activeElement = nextElement;
|
||
const directionalClassName = isNext ? CLASS_NAME_START : CLASS_NAME_END;
|
||
const orderClassName = isNext ? CLASS_NAME_NEXT : CLASS_NAME_PREV;
|
||
nextElement.classList.add(orderClassName);
|
||
reflow(nextElement);
|
||
activeElement.classList.add(directionalClassName);
|
||
nextElement.classList.add(directionalClassName);
|
||
const completeCallBack = () => {
|
||
nextElement.classList.remove(directionalClassName, orderClassName);
|
||
nextElement.classList.add(CLASS_NAME_ACTIVE$2);
|
||
activeElement.classList.remove(CLASS_NAME_ACTIVE$2, orderClassName, directionalClassName);
|
||
this._isSliding = false;
|
||
triggerEvent(EVENT_SLID);
|
||
};
|
||
this._queueCallback(completeCallBack, activeElement, this._isAnimated());
|
||
if (isCycling) {
|
||
this.cycle();
|
||
}
|
||
}
|
||
_isAnimated() {
|
||
return this._element.classList.contains(CLASS_NAME_SLIDE);
|
||
}
|
||
_getActive() {
|
||
return SelectorEngine.findOne(SELECTOR_ACTIVE_ITEM, this._element);
|
||
}
|
||
_getItems() {
|
||
return SelectorEngine.find(SELECTOR_ITEM, this._element);
|
||
}
|
||
_clearInterval() {
|
||
if (this._interval) {
|
||
clearInterval(this._interval);
|
||
this._interval = null;
|
||
}
|
||
}
|
||
_directionToOrder(direction) {
|
||
if (isRTL()) {
|
||
return direction === DIRECTION_LEFT ? ORDER_PREV : ORDER_NEXT;
|
||
}
|
||
return direction === DIRECTION_LEFT ? ORDER_NEXT : ORDER_PREV;
|
||
}
|
||
_orderToDirection(order2) {
|
||
if (isRTL()) {
|
||
return order2 === ORDER_PREV ? DIRECTION_LEFT : DIRECTION_RIGHT;
|
||
}
|
||
return order2 === ORDER_PREV ? DIRECTION_RIGHT : DIRECTION_LEFT;
|
||
}
|
||
// Static
|
||
static jQueryInterface(config) {
|
||
return this.each(function() {
|
||
const data = _Carousel.getOrCreateInstance(this, config);
|
||
if (typeof config === "number") {
|
||
data.to(config);
|
||
return;
|
||
}
|
||
if (typeof config === "string") {
|
||
if (data[config] === void 0 || config.startsWith("_") || config === "constructor") {
|
||
throw new TypeError(`No method named "${config}"`);
|
||
}
|
||
data[config]();
|
||
}
|
||
});
|
||
}
|
||
};
|
||
EventHandler.on(document, EVENT_CLICK_DATA_API$5, SELECTOR_DATA_SLIDE, function(event) {
|
||
const target = SelectorEngine.getElementFromSelector(this);
|
||
if (!target || !target.classList.contains(CLASS_NAME_CAROUSEL)) {
|
||
return;
|
||
}
|
||
event.preventDefault();
|
||
const carousel = Carousel.getOrCreateInstance(target);
|
||
const slideIndex = this.getAttribute("data-bs-slide-to");
|
||
if (slideIndex) {
|
||
carousel.to(slideIndex);
|
||
carousel._maybeEnableCycle();
|
||
return;
|
||
}
|
||
if (Manipulator.getDataAttribute(this, "slide") === "next") {
|
||
carousel.next();
|
||
carousel._maybeEnableCycle();
|
||
return;
|
||
}
|
||
carousel.prev();
|
||
carousel._maybeEnableCycle();
|
||
});
|
||
EventHandler.on(window, EVENT_LOAD_DATA_API$3, () => {
|
||
const carousels = SelectorEngine.find(SELECTOR_DATA_RIDE);
|
||
for (const carousel of carousels) {
|
||
Carousel.getOrCreateInstance(carousel);
|
||
}
|
||
});
|
||
defineJQueryPlugin(Carousel);
|
||
var NAME$b = "collapse";
|
||
var DATA_KEY$7 = "bs.collapse";
|
||
var EVENT_KEY$7 = `.${DATA_KEY$7}`;
|
||
var DATA_API_KEY$4 = ".data-api";
|
||
var EVENT_SHOW$6 = `show${EVENT_KEY$7}`;
|
||
var EVENT_SHOWN$6 = `shown${EVENT_KEY$7}`;
|
||
var EVENT_HIDE$6 = `hide${EVENT_KEY$7}`;
|
||
var EVENT_HIDDEN$6 = `hidden${EVENT_KEY$7}`;
|
||
var EVENT_CLICK_DATA_API$4 = `click${EVENT_KEY$7}${DATA_API_KEY$4}`;
|
||
var CLASS_NAME_SHOW$7 = "show";
|
||
var CLASS_NAME_COLLAPSE = "collapse";
|
||
var CLASS_NAME_COLLAPSING = "collapsing";
|
||
var CLASS_NAME_COLLAPSED = "collapsed";
|
||
var CLASS_NAME_DEEPER_CHILDREN = `:scope .${CLASS_NAME_COLLAPSE} .${CLASS_NAME_COLLAPSE}`;
|
||
var CLASS_NAME_HORIZONTAL = "collapse-horizontal";
|
||
var WIDTH = "width";
|
||
var HEIGHT = "height";
|
||
var SELECTOR_ACTIVES = ".collapse.show, .collapse.collapsing";
|
||
var SELECTOR_DATA_TOGGLE$4 = '[data-bs-toggle="collapse"]';
|
||
var Default$a = {
|
||
parent: null,
|
||
toggle: true
|
||
};
|
||
var DefaultType$a = {
|
||
parent: "(null|element)",
|
||
toggle: "boolean"
|
||
};
|
||
var Collapse = class _Collapse extends BaseComponent {
|
||
constructor(element, config) {
|
||
super(element, config);
|
||
this._isTransitioning = false;
|
||
this._triggerArray = [];
|
||
const toggleList = SelectorEngine.find(SELECTOR_DATA_TOGGLE$4);
|
||
for (const elem of toggleList) {
|
||
const selector = SelectorEngine.getSelectorFromElement(elem);
|
||
const filterElement = SelectorEngine.find(selector).filter((foundElement) => foundElement === this._element);
|
||
if (selector !== null && filterElement.length) {
|
||
this._triggerArray.push(elem);
|
||
}
|
||
}
|
||
this._initializeChildren();
|
||
if (!this._config.parent) {
|
||
this._addAriaAndCollapsedClass(this._triggerArray, this._isShown());
|
||
}
|
||
if (this._config.toggle) {
|
||
this.toggle();
|
||
}
|
||
}
|
||
// Getters
|
||
static get Default() {
|
||
return Default$a;
|
||
}
|
||
static get DefaultType() {
|
||
return DefaultType$a;
|
||
}
|
||
static get NAME() {
|
||
return NAME$b;
|
||
}
|
||
// Public
|
||
toggle() {
|
||
if (this._isShown()) {
|
||
this.hide();
|
||
} else {
|
||
this.show();
|
||
}
|
||
}
|
||
show() {
|
||
if (this._isTransitioning || this._isShown()) {
|
||
return;
|
||
}
|
||
let activeChildren = [];
|
||
if (this._config.parent) {
|
||
activeChildren = this._getFirstLevelChildren(SELECTOR_ACTIVES).filter((element) => element !== this._element).map((element) => _Collapse.getOrCreateInstance(element, {
|
||
toggle: false
|
||
}));
|
||
}
|
||
if (activeChildren.length && activeChildren[0]._isTransitioning) {
|
||
return;
|
||
}
|
||
const startEvent = EventHandler.trigger(this._element, EVENT_SHOW$6);
|
||
if (startEvent.defaultPrevented) {
|
||
return;
|
||
}
|
||
for (const activeInstance of activeChildren) {
|
||
activeInstance.hide();
|
||
}
|
||
const dimension = this._getDimension();
|
||
this._element.classList.remove(CLASS_NAME_COLLAPSE);
|
||
this._element.classList.add(CLASS_NAME_COLLAPSING);
|
||
this._element.style[dimension] = 0;
|
||
this._addAriaAndCollapsedClass(this._triggerArray, true);
|
||
this._isTransitioning = true;
|
||
const complete = () => {
|
||
this._isTransitioning = false;
|
||
this._element.classList.remove(CLASS_NAME_COLLAPSING);
|
||
this._element.classList.add(CLASS_NAME_COLLAPSE, CLASS_NAME_SHOW$7);
|
||
this._element.style[dimension] = "";
|
||
EventHandler.trigger(this._element, EVENT_SHOWN$6);
|
||
};
|
||
const capitalizedDimension = dimension[0].toUpperCase() + dimension.slice(1);
|
||
const scrollSize = `scroll${capitalizedDimension}`;
|
||
this._queueCallback(complete, this._element, true);
|
||
this._element.style[dimension] = `${this._element[scrollSize]}px`;
|
||
}
|
||
hide() {
|
||
if (this._isTransitioning || !this._isShown()) {
|
||
return;
|
||
}
|
||
const startEvent = EventHandler.trigger(this._element, EVENT_HIDE$6);
|
||
if (startEvent.defaultPrevented) {
|
||
return;
|
||
}
|
||
const dimension = this._getDimension();
|
||
this._element.style[dimension] = `${this._element.getBoundingClientRect()[dimension]}px`;
|
||
reflow(this._element);
|
||
this._element.classList.add(CLASS_NAME_COLLAPSING);
|
||
this._element.classList.remove(CLASS_NAME_COLLAPSE, CLASS_NAME_SHOW$7);
|
||
for (const trigger of this._triggerArray) {
|
||
const element = SelectorEngine.getElementFromSelector(trigger);
|
||
if (element && !this._isShown(element)) {
|
||
this._addAriaAndCollapsedClass([trigger], false);
|
||
}
|
||
}
|
||
this._isTransitioning = true;
|
||
const complete = () => {
|
||
this._isTransitioning = false;
|
||
this._element.classList.remove(CLASS_NAME_COLLAPSING);
|
||
this._element.classList.add(CLASS_NAME_COLLAPSE);
|
||
EventHandler.trigger(this._element, EVENT_HIDDEN$6);
|
||
};
|
||
this._element.style[dimension] = "";
|
||
this._queueCallback(complete, this._element, true);
|
||
}
|
||
_isShown(element = this._element) {
|
||
return element.classList.contains(CLASS_NAME_SHOW$7);
|
||
}
|
||
// Private
|
||
_configAfterMerge(config) {
|
||
config.toggle = Boolean(config.toggle);
|
||
config.parent = getElement(config.parent);
|
||
return config;
|
||
}
|
||
_getDimension() {
|
||
return this._element.classList.contains(CLASS_NAME_HORIZONTAL) ? WIDTH : HEIGHT;
|
||
}
|
||
_initializeChildren() {
|
||
if (!this._config.parent) {
|
||
return;
|
||
}
|
||
const children = this._getFirstLevelChildren(SELECTOR_DATA_TOGGLE$4);
|
||
for (const element of children) {
|
||
const selected = SelectorEngine.getElementFromSelector(element);
|
||
if (selected) {
|
||
this._addAriaAndCollapsedClass([element], this._isShown(selected));
|
||
}
|
||
}
|
||
}
|
||
_getFirstLevelChildren(selector) {
|
||
const children = SelectorEngine.find(CLASS_NAME_DEEPER_CHILDREN, this._config.parent);
|
||
return SelectorEngine.find(selector, this._config.parent).filter((element) => !children.includes(element));
|
||
}
|
||
_addAriaAndCollapsedClass(triggerArray, isOpen) {
|
||
if (!triggerArray.length) {
|
||
return;
|
||
}
|
||
for (const element of triggerArray) {
|
||
element.classList.toggle(CLASS_NAME_COLLAPSED, !isOpen);
|
||
element.setAttribute("aria-expanded", isOpen);
|
||
}
|
||
}
|
||
// Static
|
||
static jQueryInterface(config) {
|
||
const _config = {};
|
||
if (typeof config === "string" && /show|hide/.test(config)) {
|
||
_config.toggle = false;
|
||
}
|
||
return this.each(function() {
|
||
const data = _Collapse.getOrCreateInstance(this, _config);
|
||
if (typeof config === "string") {
|
||
if (typeof data[config] === "undefined") {
|
||
throw new TypeError(`No method named "${config}"`);
|
||
}
|
||
data[config]();
|
||
}
|
||
});
|
||
}
|
||
};
|
||
EventHandler.on(document, EVENT_CLICK_DATA_API$4, SELECTOR_DATA_TOGGLE$4, function(event) {
|
||
if (event.target.tagName === "A" || event.delegateTarget && event.delegateTarget.tagName === "A") {
|
||
event.preventDefault();
|
||
}
|
||
for (const element of SelectorEngine.getMultipleElementsFromSelector(this)) {
|
||
Collapse.getOrCreateInstance(element, {
|
||
toggle: false
|
||
}).toggle();
|
||
}
|
||
});
|
||
defineJQueryPlugin(Collapse);
|
||
var NAME$a = "dropdown";
|
||
var DATA_KEY$6 = "bs.dropdown";
|
||
var EVENT_KEY$6 = `.${DATA_KEY$6}`;
|
||
var DATA_API_KEY$3 = ".data-api";
|
||
var ESCAPE_KEY$2 = "Escape";
|
||
var TAB_KEY$1 = "Tab";
|
||
var ARROW_UP_KEY$1 = "ArrowUp";
|
||
var ARROW_DOWN_KEY$1 = "ArrowDown";
|
||
var RIGHT_MOUSE_BUTTON = 2;
|
||
var EVENT_HIDE$5 = `hide${EVENT_KEY$6}`;
|
||
var EVENT_HIDDEN$5 = `hidden${EVENT_KEY$6}`;
|
||
var EVENT_SHOW$5 = `show${EVENT_KEY$6}`;
|
||
var EVENT_SHOWN$5 = `shown${EVENT_KEY$6}`;
|
||
var EVENT_CLICK_DATA_API$3 = `click${EVENT_KEY$6}${DATA_API_KEY$3}`;
|
||
var EVENT_KEYDOWN_DATA_API = `keydown${EVENT_KEY$6}${DATA_API_KEY$3}`;
|
||
var EVENT_KEYUP_DATA_API = `keyup${EVENT_KEY$6}${DATA_API_KEY$3}`;
|
||
var CLASS_NAME_SHOW$6 = "show";
|
||
var CLASS_NAME_DROPUP = "dropup";
|
||
var CLASS_NAME_DROPEND = "dropend";
|
||
var CLASS_NAME_DROPSTART = "dropstart";
|
||
var CLASS_NAME_DROPUP_CENTER = "dropup-center";
|
||
var CLASS_NAME_DROPDOWN_CENTER = "dropdown-center";
|
||
var SELECTOR_DATA_TOGGLE$3 = '[data-bs-toggle="dropdown"]:not(.disabled):not(:disabled)';
|
||
var SELECTOR_DATA_TOGGLE_SHOWN = `${SELECTOR_DATA_TOGGLE$3}.${CLASS_NAME_SHOW$6}`;
|
||
var SELECTOR_MENU = ".dropdown-menu";
|
||
var SELECTOR_NAVBAR = ".navbar";
|
||
var SELECTOR_NAVBAR_NAV = ".navbar-nav";
|
||
var SELECTOR_VISIBLE_ITEMS = ".dropdown-menu .dropdown-item:not(.disabled):not(:disabled)";
|
||
var PLACEMENT_TOP = isRTL() ? "top-end" : "top-start";
|
||
var PLACEMENT_TOPEND = isRTL() ? "top-start" : "top-end";
|
||
var PLACEMENT_BOTTOM = isRTL() ? "bottom-end" : "bottom-start";
|
||
var PLACEMENT_BOTTOMEND = isRTL() ? "bottom-start" : "bottom-end";
|
||
var PLACEMENT_RIGHT = isRTL() ? "left-start" : "right-start";
|
||
var PLACEMENT_LEFT = isRTL() ? "right-start" : "left-start";
|
||
var PLACEMENT_TOPCENTER = "top";
|
||
var PLACEMENT_BOTTOMCENTER = "bottom";
|
||
var Default$9 = {
|
||
autoClose: true,
|
||
boundary: "clippingParents",
|
||
display: "dynamic",
|
||
offset: [0, 2],
|
||
popperConfig: null,
|
||
reference: "toggle"
|
||
};
|
||
var DefaultType$9 = {
|
||
autoClose: "(boolean|string)",
|
||
boundary: "(string|element)",
|
||
display: "string",
|
||
offset: "(array|string|function)",
|
||
popperConfig: "(null|object|function)",
|
||
reference: "(string|element|object)"
|
||
};
|
||
var Dropdown = class _Dropdown extends BaseComponent {
|
||
constructor(element, config) {
|
||
super(element, config);
|
||
this._popper = null;
|
||
this._parent = this._element.parentNode;
|
||
this._menu = SelectorEngine.next(this._element, SELECTOR_MENU)[0] || SelectorEngine.prev(this._element, SELECTOR_MENU)[0] || SelectorEngine.findOne(SELECTOR_MENU, this._parent);
|
||
this._inNavbar = this._detectNavbar();
|
||
}
|
||
// Getters
|
||
static get Default() {
|
||
return Default$9;
|
||
}
|
||
static get DefaultType() {
|
||
return DefaultType$9;
|
||
}
|
||
static get NAME() {
|
||
return NAME$a;
|
||
}
|
||
// Public
|
||
toggle() {
|
||
return this._isShown() ? this.hide() : this.show();
|
||
}
|
||
show() {
|
||
if (isDisabled(this._element) || this._isShown()) {
|
||
return;
|
||
}
|
||
const relatedTarget = {
|
||
relatedTarget: this._element
|
||
};
|
||
const showEvent = EventHandler.trigger(this._element, EVENT_SHOW$5, relatedTarget);
|
||
if (showEvent.defaultPrevented) {
|
||
return;
|
||
}
|
||
this._createPopper();
|
||
if ("ontouchstart" in document.documentElement && !this._parent.closest(SELECTOR_NAVBAR_NAV)) {
|
||
for (const element of [].concat(...document.body.children)) {
|
||
EventHandler.on(element, "mouseover", noop);
|
||
}
|
||
}
|
||
this._element.focus();
|
||
this._element.setAttribute("aria-expanded", true);
|
||
this._menu.classList.add(CLASS_NAME_SHOW$6);
|
||
this._element.classList.add(CLASS_NAME_SHOW$6);
|
||
EventHandler.trigger(this._element, EVENT_SHOWN$5, relatedTarget);
|
||
}
|
||
hide() {
|
||
if (isDisabled(this._element) || !this._isShown()) {
|
||
return;
|
||
}
|
||
const relatedTarget = {
|
||
relatedTarget: this._element
|
||
};
|
||
this._completeHide(relatedTarget);
|
||
}
|
||
dispose() {
|
||
if (this._popper) {
|
||
this._popper.destroy();
|
||
}
|
||
super.dispose();
|
||
}
|
||
update() {
|
||
this._inNavbar = this._detectNavbar();
|
||
if (this._popper) {
|
||
this._popper.update();
|
||
}
|
||
}
|
||
// Private
|
||
_completeHide(relatedTarget) {
|
||
const hideEvent = EventHandler.trigger(this._element, EVENT_HIDE$5, relatedTarget);
|
||
if (hideEvent.defaultPrevented) {
|
||
return;
|
||
}
|
||
if ("ontouchstart" in document.documentElement) {
|
||
for (const element of [].concat(...document.body.children)) {
|
||
EventHandler.off(element, "mouseover", noop);
|
||
}
|
||
}
|
||
if (this._popper) {
|
||
this._popper.destroy();
|
||
}
|
||
this._menu.classList.remove(CLASS_NAME_SHOW$6);
|
||
this._element.classList.remove(CLASS_NAME_SHOW$6);
|
||
this._element.setAttribute("aria-expanded", "false");
|
||
Manipulator.removeDataAttribute(this._menu, "popper");
|
||
EventHandler.trigger(this._element, EVENT_HIDDEN$5, relatedTarget);
|
||
}
|
||
_getConfig(config) {
|
||
config = super._getConfig(config);
|
||
if (typeof config.reference === "object" && !isElement2(config.reference) && typeof config.reference.getBoundingClientRect !== "function") {
|
||
throw new TypeError(`${NAME$a.toUpperCase()}: Option "reference" provided type "object" without a required "getBoundingClientRect" method.`);
|
||
}
|
||
return config;
|
||
}
|
||
_createPopper() {
|
||
if (typeof lib_exports === "undefined") {
|
||
throw new TypeError("Bootstrap's dropdowns require Popper (https://popper.js.org)");
|
||
}
|
||
let referenceElement = this._element;
|
||
if (this._config.reference === "parent") {
|
||
referenceElement = this._parent;
|
||
} else if (isElement2(this._config.reference)) {
|
||
referenceElement = getElement(this._config.reference);
|
||
} else if (typeof this._config.reference === "object") {
|
||
referenceElement = this._config.reference;
|
||
}
|
||
const popperConfig = this._getPopperConfig();
|
||
this._popper = createPopper3(referenceElement, this._menu, popperConfig);
|
||
}
|
||
_isShown() {
|
||
return this._menu.classList.contains(CLASS_NAME_SHOW$6);
|
||
}
|
||
_getPlacement() {
|
||
const parentDropdown = this._parent;
|
||
if (parentDropdown.classList.contains(CLASS_NAME_DROPEND)) {
|
||
return PLACEMENT_RIGHT;
|
||
}
|
||
if (parentDropdown.classList.contains(CLASS_NAME_DROPSTART)) {
|
||
return PLACEMENT_LEFT;
|
||
}
|
||
if (parentDropdown.classList.contains(CLASS_NAME_DROPUP_CENTER)) {
|
||
return PLACEMENT_TOPCENTER;
|
||
}
|
||
if (parentDropdown.classList.contains(CLASS_NAME_DROPDOWN_CENTER)) {
|
||
return PLACEMENT_BOTTOMCENTER;
|
||
}
|
||
const isEnd = getComputedStyle(this._menu).getPropertyValue("--bs-position").trim() === "end";
|
||
if (parentDropdown.classList.contains(CLASS_NAME_DROPUP)) {
|
||
return isEnd ? PLACEMENT_TOPEND : PLACEMENT_TOP;
|
||
}
|
||
return isEnd ? PLACEMENT_BOTTOMEND : PLACEMENT_BOTTOM;
|
||
}
|
||
_detectNavbar() {
|
||
return this._element.closest(SELECTOR_NAVBAR) !== null;
|
||
}
|
||
_getOffset() {
|
||
const {
|
||
offset: offset2
|
||
} = this._config;
|
||
if (typeof offset2 === "string") {
|
||
return offset2.split(",").map((value) => Number.parseInt(value, 10));
|
||
}
|
||
if (typeof offset2 === "function") {
|
||
return (popperData) => offset2(popperData, this._element);
|
||
}
|
||
return offset2;
|
||
}
|
||
_getPopperConfig() {
|
||
const defaultBsPopperConfig = {
|
||
placement: this._getPlacement(),
|
||
modifiers: [{
|
||
name: "preventOverflow",
|
||
options: {
|
||
boundary: this._config.boundary
|
||
}
|
||
}, {
|
||
name: "offset",
|
||
options: {
|
||
offset: this._getOffset()
|
||
}
|
||
}]
|
||
};
|
||
if (this._inNavbar || this._config.display === "static") {
|
||
Manipulator.setDataAttribute(this._menu, "popper", "static");
|
||
defaultBsPopperConfig.modifiers = [{
|
||
name: "applyStyles",
|
||
enabled: false
|
||
}];
|
||
}
|
||
return {
|
||
...defaultBsPopperConfig,
|
||
...execute(this._config.popperConfig, [defaultBsPopperConfig])
|
||
};
|
||
}
|
||
_selectMenuItem({
|
||
key,
|
||
target
|
||
}) {
|
||
const items = SelectorEngine.find(SELECTOR_VISIBLE_ITEMS, this._menu).filter((element) => isVisible(element));
|
||
if (!items.length) {
|
||
return;
|
||
}
|
||
getNextActiveElement(items, target, key === ARROW_DOWN_KEY$1, !items.includes(target)).focus();
|
||
}
|
||
// Static
|
||
static jQueryInterface(config) {
|
||
return this.each(function() {
|
||
const data = _Dropdown.getOrCreateInstance(this, config);
|
||
if (typeof config !== "string") {
|
||
return;
|
||
}
|
||
if (typeof data[config] === "undefined") {
|
||
throw new TypeError(`No method named "${config}"`);
|
||
}
|
||
data[config]();
|
||
});
|
||
}
|
||
static clearMenus(event) {
|
||
if (event.button === RIGHT_MOUSE_BUTTON || event.type === "keyup" && event.key !== TAB_KEY$1) {
|
||
return;
|
||
}
|
||
const openToggles = SelectorEngine.find(SELECTOR_DATA_TOGGLE_SHOWN);
|
||
for (const toggle of openToggles) {
|
||
const context = _Dropdown.getInstance(toggle);
|
||
if (!context || context._config.autoClose === false) {
|
||
continue;
|
||
}
|
||
const composedPath = event.composedPath();
|
||
const isMenuTarget = composedPath.includes(context._menu);
|
||
if (composedPath.includes(context._element) || context._config.autoClose === "inside" && !isMenuTarget || context._config.autoClose === "outside" && isMenuTarget) {
|
||
continue;
|
||
}
|
||
if (context._menu.contains(event.target) && (event.type === "keyup" && event.key === TAB_KEY$1 || /input|select|option|textarea|form/i.test(event.target.tagName))) {
|
||
continue;
|
||
}
|
||
const relatedTarget = {
|
||
relatedTarget: context._element
|
||
};
|
||
if (event.type === "click") {
|
||
relatedTarget.clickEvent = event;
|
||
}
|
||
context._completeHide(relatedTarget);
|
||
}
|
||
}
|
||
static dataApiKeydownHandler(event) {
|
||
const isInput = /input|textarea/i.test(event.target.tagName);
|
||
const isEscapeEvent = event.key === ESCAPE_KEY$2;
|
||
const isUpOrDownEvent = [ARROW_UP_KEY$1, ARROW_DOWN_KEY$1].includes(event.key);
|
||
if (!isUpOrDownEvent && !isEscapeEvent) {
|
||
return;
|
||
}
|
||
if (isInput && !isEscapeEvent) {
|
||
return;
|
||
}
|
||
event.preventDefault();
|
||
const getToggleButton = this.matches(SELECTOR_DATA_TOGGLE$3) ? this : SelectorEngine.prev(this, SELECTOR_DATA_TOGGLE$3)[0] || SelectorEngine.next(this, SELECTOR_DATA_TOGGLE$3)[0] || SelectorEngine.findOne(SELECTOR_DATA_TOGGLE$3, event.delegateTarget.parentNode);
|
||
const instance = _Dropdown.getOrCreateInstance(getToggleButton);
|
||
if (isUpOrDownEvent) {
|
||
event.stopPropagation();
|
||
instance.show();
|
||
instance._selectMenuItem(event);
|
||
return;
|
||
}
|
||
if (instance._isShown()) {
|
||
event.stopPropagation();
|
||
instance.hide();
|
||
getToggleButton.focus();
|
||
}
|
||
}
|
||
};
|
||
EventHandler.on(document, EVENT_KEYDOWN_DATA_API, SELECTOR_DATA_TOGGLE$3, Dropdown.dataApiKeydownHandler);
|
||
EventHandler.on(document, EVENT_KEYDOWN_DATA_API, SELECTOR_MENU, Dropdown.dataApiKeydownHandler);
|
||
EventHandler.on(document, EVENT_CLICK_DATA_API$3, Dropdown.clearMenus);
|
||
EventHandler.on(document, EVENT_KEYUP_DATA_API, Dropdown.clearMenus);
|
||
EventHandler.on(document, EVENT_CLICK_DATA_API$3, SELECTOR_DATA_TOGGLE$3, function(event) {
|
||
event.preventDefault();
|
||
Dropdown.getOrCreateInstance(this).toggle();
|
||
});
|
||
defineJQueryPlugin(Dropdown);
|
||
var NAME$9 = "backdrop";
|
||
var CLASS_NAME_FADE$4 = "fade";
|
||
var CLASS_NAME_SHOW$5 = "show";
|
||
var EVENT_MOUSEDOWN = `mousedown.bs.${NAME$9}`;
|
||
var Default$8 = {
|
||
className: "modal-backdrop",
|
||
clickCallback: null,
|
||
isAnimated: false,
|
||
isVisible: true,
|
||
// if false, we use the backdrop helper without adding any element to the dom
|
||
rootElement: "body"
|
||
// give the choice to place backdrop under different elements
|
||
};
|
||
var DefaultType$8 = {
|
||
className: "string",
|
||
clickCallback: "(function|null)",
|
||
isAnimated: "boolean",
|
||
isVisible: "boolean",
|
||
rootElement: "(element|string)"
|
||
};
|
||
var Backdrop = class extends Config {
|
||
constructor(config) {
|
||
super();
|
||
this._config = this._getConfig(config);
|
||
this._isAppended = false;
|
||
this._element = null;
|
||
}
|
||
// Getters
|
||
static get Default() {
|
||
return Default$8;
|
||
}
|
||
static get DefaultType() {
|
||
return DefaultType$8;
|
||
}
|
||
static get NAME() {
|
||
return NAME$9;
|
||
}
|
||
// Public
|
||
show(callback) {
|
||
if (!this._config.isVisible) {
|
||
execute(callback);
|
||
return;
|
||
}
|
||
this._append();
|
||
const element = this._getElement();
|
||
if (this._config.isAnimated) {
|
||
reflow(element);
|
||
}
|
||
element.classList.add(CLASS_NAME_SHOW$5);
|
||
this._emulateAnimation(() => {
|
||
execute(callback);
|
||
});
|
||
}
|
||
hide(callback) {
|
||
if (!this._config.isVisible) {
|
||
execute(callback);
|
||
return;
|
||
}
|
||
this._getElement().classList.remove(CLASS_NAME_SHOW$5);
|
||
this._emulateAnimation(() => {
|
||
this.dispose();
|
||
execute(callback);
|
||
});
|
||
}
|
||
dispose() {
|
||
if (!this._isAppended) {
|
||
return;
|
||
}
|
||
EventHandler.off(this._element, EVENT_MOUSEDOWN);
|
||
this._element.remove();
|
||
this._isAppended = false;
|
||
}
|
||
// Private
|
||
_getElement() {
|
||
if (!this._element) {
|
||
const backdrop = document.createElement("div");
|
||
backdrop.className = this._config.className;
|
||
if (this._config.isAnimated) {
|
||
backdrop.classList.add(CLASS_NAME_FADE$4);
|
||
}
|
||
this._element = backdrop;
|
||
}
|
||
return this._element;
|
||
}
|
||
_configAfterMerge(config) {
|
||
config.rootElement = getElement(config.rootElement);
|
||
return config;
|
||
}
|
||
_append() {
|
||
if (this._isAppended) {
|
||
return;
|
||
}
|
||
const element = this._getElement();
|
||
this._config.rootElement.append(element);
|
||
EventHandler.on(element, EVENT_MOUSEDOWN, () => {
|
||
execute(this._config.clickCallback);
|
||
});
|
||
this._isAppended = true;
|
||
}
|
||
_emulateAnimation(callback) {
|
||
executeAfterTransition(callback, this._getElement(), this._config.isAnimated);
|
||
}
|
||
};
|
||
var NAME$8 = "focustrap";
|
||
var DATA_KEY$5 = "bs.focustrap";
|
||
var EVENT_KEY$5 = `.${DATA_KEY$5}`;
|
||
var EVENT_FOCUSIN$2 = `focusin${EVENT_KEY$5}`;
|
||
var EVENT_KEYDOWN_TAB = `keydown.tab${EVENT_KEY$5}`;
|
||
var TAB_KEY = "Tab";
|
||
var TAB_NAV_FORWARD = "forward";
|
||
var TAB_NAV_BACKWARD = "backward";
|
||
var Default$7 = {
|
||
autofocus: true,
|
||
trapElement: null
|
||
// The element to trap focus inside of
|
||
};
|
||
var DefaultType$7 = {
|
||
autofocus: "boolean",
|
||
trapElement: "element"
|
||
};
|
||
var FocusTrap = class extends Config {
|
||
constructor(config) {
|
||
super();
|
||
this._config = this._getConfig(config);
|
||
this._isActive = false;
|
||
this._lastTabNavDirection = null;
|
||
}
|
||
// Getters
|
||
static get Default() {
|
||
return Default$7;
|
||
}
|
||
static get DefaultType() {
|
||
return DefaultType$7;
|
||
}
|
||
static get NAME() {
|
||
return NAME$8;
|
||
}
|
||
// Public
|
||
activate() {
|
||
if (this._isActive) {
|
||
return;
|
||
}
|
||
if (this._config.autofocus) {
|
||
this._config.trapElement.focus();
|
||
}
|
||
EventHandler.off(document, EVENT_KEY$5);
|
||
EventHandler.on(document, EVENT_FOCUSIN$2, (event) => this._handleFocusin(event));
|
||
EventHandler.on(document, EVENT_KEYDOWN_TAB, (event) => this._handleKeydown(event));
|
||
this._isActive = true;
|
||
}
|
||
deactivate() {
|
||
if (!this._isActive) {
|
||
return;
|
||
}
|
||
this._isActive = false;
|
||
EventHandler.off(document, EVENT_KEY$5);
|
||
}
|
||
// Private
|
||
_handleFocusin(event) {
|
||
const {
|
||
trapElement
|
||
} = this._config;
|
||
if (event.target === document || event.target === trapElement || trapElement.contains(event.target)) {
|
||
return;
|
||
}
|
||
const elements = SelectorEngine.focusableChildren(trapElement);
|
||
if (elements.length === 0) {
|
||
trapElement.focus();
|
||
} else if (this._lastTabNavDirection === TAB_NAV_BACKWARD) {
|
||
elements[elements.length - 1].focus();
|
||
} else {
|
||
elements[0].focus();
|
||
}
|
||
}
|
||
_handleKeydown(event) {
|
||
if (event.key !== TAB_KEY) {
|
||
return;
|
||
}
|
||
this._lastTabNavDirection = event.shiftKey ? TAB_NAV_BACKWARD : TAB_NAV_FORWARD;
|
||
}
|
||
};
|
||
var SELECTOR_FIXED_CONTENT = ".fixed-top, .fixed-bottom, .is-fixed, .sticky-top";
|
||
var SELECTOR_STICKY_CONTENT = ".sticky-top";
|
||
var PROPERTY_PADDING = "padding-right";
|
||
var PROPERTY_MARGIN = "margin-right";
|
||
var ScrollBarHelper = class {
|
||
constructor() {
|
||
this._element = document.body;
|
||
}
|
||
// Public
|
||
getWidth() {
|
||
const documentWidth = document.documentElement.clientWidth;
|
||
return Math.abs(window.innerWidth - documentWidth);
|
||
}
|
||
hide() {
|
||
const width = this.getWidth();
|
||
this._disableOverFlow();
|
||
this._setElementAttributes(this._element, PROPERTY_PADDING, (calculatedValue) => calculatedValue + width);
|
||
this._setElementAttributes(SELECTOR_FIXED_CONTENT, PROPERTY_PADDING, (calculatedValue) => calculatedValue + width);
|
||
this._setElementAttributes(SELECTOR_STICKY_CONTENT, PROPERTY_MARGIN, (calculatedValue) => calculatedValue - width);
|
||
}
|
||
reset() {
|
||
this._resetElementAttributes(this._element, "overflow");
|
||
this._resetElementAttributes(this._element, PROPERTY_PADDING);
|
||
this._resetElementAttributes(SELECTOR_FIXED_CONTENT, PROPERTY_PADDING);
|
||
this._resetElementAttributes(SELECTOR_STICKY_CONTENT, PROPERTY_MARGIN);
|
||
}
|
||
isOverflowing() {
|
||
return this.getWidth() > 0;
|
||
}
|
||
// Private
|
||
_disableOverFlow() {
|
||
this._saveInitialAttribute(this._element, "overflow");
|
||
this._element.style.overflow = "hidden";
|
||
}
|
||
_setElementAttributes(selector, styleProperty, callback) {
|
||
const scrollbarWidth = this.getWidth();
|
||
const manipulationCallBack = (element) => {
|
||
if (element !== this._element && window.innerWidth > element.clientWidth + scrollbarWidth) {
|
||
return;
|
||
}
|
||
this._saveInitialAttribute(element, styleProperty);
|
||
const calculatedValue = window.getComputedStyle(element).getPropertyValue(styleProperty);
|
||
element.style.setProperty(styleProperty, `${callback(Number.parseFloat(calculatedValue))}px`);
|
||
};
|
||
this._applyManipulationCallback(selector, manipulationCallBack);
|
||
}
|
||
_saveInitialAttribute(element, styleProperty) {
|
||
const actualValue = element.style.getPropertyValue(styleProperty);
|
||
if (actualValue) {
|
||
Manipulator.setDataAttribute(element, styleProperty, actualValue);
|
||
}
|
||
}
|
||
_resetElementAttributes(selector, styleProperty) {
|
||
const manipulationCallBack = (element) => {
|
||
const value = Manipulator.getDataAttribute(element, styleProperty);
|
||
if (value === null) {
|
||
element.style.removeProperty(styleProperty);
|
||
return;
|
||
}
|
||
Manipulator.removeDataAttribute(element, styleProperty);
|
||
element.style.setProperty(styleProperty, value);
|
||
};
|
||
this._applyManipulationCallback(selector, manipulationCallBack);
|
||
}
|
||
_applyManipulationCallback(selector, callBack) {
|
||
if (isElement2(selector)) {
|
||
callBack(selector);
|
||
return;
|
||
}
|
||
for (const sel of SelectorEngine.find(selector, this._element)) {
|
||
callBack(sel);
|
||
}
|
||
}
|
||
};
|
||
var NAME$7 = "modal";
|
||
var DATA_KEY$4 = "bs.modal";
|
||
var EVENT_KEY$4 = `.${DATA_KEY$4}`;
|
||
var DATA_API_KEY$2 = ".data-api";
|
||
var ESCAPE_KEY$1 = "Escape";
|
||
var EVENT_HIDE$4 = `hide${EVENT_KEY$4}`;
|
||
var EVENT_HIDE_PREVENTED$1 = `hidePrevented${EVENT_KEY$4}`;
|
||
var EVENT_HIDDEN$4 = `hidden${EVENT_KEY$4}`;
|
||
var EVENT_SHOW$4 = `show${EVENT_KEY$4}`;
|
||
var EVENT_SHOWN$4 = `shown${EVENT_KEY$4}`;
|
||
var EVENT_RESIZE$1 = `resize${EVENT_KEY$4}`;
|
||
var EVENT_CLICK_DISMISS = `click.dismiss${EVENT_KEY$4}`;
|
||
var EVENT_MOUSEDOWN_DISMISS = `mousedown.dismiss${EVENT_KEY$4}`;
|
||
var EVENT_KEYDOWN_DISMISS$1 = `keydown.dismiss${EVENT_KEY$4}`;
|
||
var EVENT_CLICK_DATA_API$2 = `click${EVENT_KEY$4}${DATA_API_KEY$2}`;
|
||
var CLASS_NAME_OPEN = "modal-open";
|
||
var CLASS_NAME_FADE$3 = "fade";
|
||
var CLASS_NAME_SHOW$4 = "show";
|
||
var CLASS_NAME_STATIC = "modal-static";
|
||
var OPEN_SELECTOR$1 = ".modal.show";
|
||
var SELECTOR_DIALOG = ".modal-dialog";
|
||
var SELECTOR_MODAL_BODY = ".modal-body";
|
||
var SELECTOR_DATA_TOGGLE$2 = '[data-bs-toggle="modal"]';
|
||
var Default$6 = {
|
||
backdrop: true,
|
||
focus: true,
|
||
keyboard: true
|
||
};
|
||
var DefaultType$6 = {
|
||
backdrop: "(boolean|string)",
|
||
focus: "boolean",
|
||
keyboard: "boolean"
|
||
};
|
||
var Modal = class _Modal extends BaseComponent {
|
||
constructor(element, config) {
|
||
super(element, config);
|
||
this._dialog = SelectorEngine.findOne(SELECTOR_DIALOG, this._element);
|
||
this._backdrop = this._initializeBackDrop();
|
||
this._focustrap = this._initializeFocusTrap();
|
||
this._isShown = false;
|
||
this._isTransitioning = false;
|
||
this._scrollBar = new ScrollBarHelper();
|
||
this._addEventListeners();
|
||
}
|
||
// Getters
|
||
static get Default() {
|
||
return Default$6;
|
||
}
|
||
static get DefaultType() {
|
||
return DefaultType$6;
|
||
}
|
||
static get NAME() {
|
||
return NAME$7;
|
||
}
|
||
// Public
|
||
toggle(relatedTarget) {
|
||
return this._isShown ? this.hide() : this.show(relatedTarget);
|
||
}
|
||
show(relatedTarget) {
|
||
if (this._isShown || this._isTransitioning) {
|
||
return;
|
||
}
|
||
const showEvent = EventHandler.trigger(this._element, EVENT_SHOW$4, {
|
||
relatedTarget
|
||
});
|
||
if (showEvent.defaultPrevented) {
|
||
return;
|
||
}
|
||
this._isShown = true;
|
||
this._isTransitioning = true;
|
||
this._scrollBar.hide();
|
||
document.body.classList.add(CLASS_NAME_OPEN);
|
||
this._adjustDialog();
|
||
this._backdrop.show(() => this._showElement(relatedTarget));
|
||
}
|
||
hide() {
|
||
if (!this._isShown || this._isTransitioning) {
|
||
return;
|
||
}
|
||
const hideEvent = EventHandler.trigger(this._element, EVENT_HIDE$4);
|
||
if (hideEvent.defaultPrevented) {
|
||
return;
|
||
}
|
||
this._isShown = false;
|
||
this._isTransitioning = true;
|
||
this._focustrap.deactivate();
|
||
this._element.classList.remove(CLASS_NAME_SHOW$4);
|
||
this._queueCallback(() => this._hideModal(), this._element, this._isAnimated());
|
||
}
|
||
dispose() {
|
||
EventHandler.off(window, EVENT_KEY$4);
|
||
EventHandler.off(this._dialog, EVENT_KEY$4);
|
||
this._backdrop.dispose();
|
||
this._focustrap.deactivate();
|
||
super.dispose();
|
||
}
|
||
handleUpdate() {
|
||
this._adjustDialog();
|
||
}
|
||
// Private
|
||
_initializeBackDrop() {
|
||
return new Backdrop({
|
||
isVisible: Boolean(this._config.backdrop),
|
||
// 'static' option will be translated to true, and booleans will keep their value,
|
||
isAnimated: this._isAnimated()
|
||
});
|
||
}
|
||
_initializeFocusTrap() {
|
||
return new FocusTrap({
|
||
trapElement: this._element
|
||
});
|
||
}
|
||
_showElement(relatedTarget) {
|
||
if (!document.body.contains(this._element)) {
|
||
document.body.append(this._element);
|
||
}
|
||
this._element.style.display = "block";
|
||
this._element.removeAttribute("aria-hidden");
|
||
this._element.setAttribute("aria-modal", true);
|
||
this._element.setAttribute("role", "dialog");
|
||
this._element.scrollTop = 0;
|
||
const modalBody = SelectorEngine.findOne(SELECTOR_MODAL_BODY, this._dialog);
|
||
if (modalBody) {
|
||
modalBody.scrollTop = 0;
|
||
}
|
||
reflow(this._element);
|
||
this._element.classList.add(CLASS_NAME_SHOW$4);
|
||
const transitionComplete = () => {
|
||
if (this._config.focus) {
|
||
this._focustrap.activate();
|
||
}
|
||
this._isTransitioning = false;
|
||
EventHandler.trigger(this._element, EVENT_SHOWN$4, {
|
||
relatedTarget
|
||
});
|
||
};
|
||
this._queueCallback(transitionComplete, this._dialog, this._isAnimated());
|
||
}
|
||
_addEventListeners() {
|
||
EventHandler.on(this._element, EVENT_KEYDOWN_DISMISS$1, (event) => {
|
||
if (event.key !== ESCAPE_KEY$1) {
|
||
return;
|
||
}
|
||
if (this._config.keyboard) {
|
||
this.hide();
|
||
return;
|
||
}
|
||
this._triggerBackdropTransition();
|
||
});
|
||
EventHandler.on(window, EVENT_RESIZE$1, () => {
|
||
if (this._isShown && !this._isTransitioning) {
|
||
this._adjustDialog();
|
||
}
|
||
});
|
||
EventHandler.on(this._element, EVENT_MOUSEDOWN_DISMISS, (event) => {
|
||
EventHandler.one(this._element, EVENT_CLICK_DISMISS, (event2) => {
|
||
if (this._element !== event.target || this._element !== event2.target) {
|
||
return;
|
||
}
|
||
if (this._config.backdrop === "static") {
|
||
this._triggerBackdropTransition();
|
||
return;
|
||
}
|
||
if (this._config.backdrop) {
|
||
this.hide();
|
||
}
|
||
});
|
||
});
|
||
}
|
||
_hideModal() {
|
||
this._element.style.display = "none";
|
||
this._element.setAttribute("aria-hidden", true);
|
||
this._element.removeAttribute("aria-modal");
|
||
this._element.removeAttribute("role");
|
||
this._isTransitioning = false;
|
||
this._backdrop.hide(() => {
|
||
document.body.classList.remove(CLASS_NAME_OPEN);
|
||
this._resetAdjustments();
|
||
this._scrollBar.reset();
|
||
EventHandler.trigger(this._element, EVENT_HIDDEN$4);
|
||
});
|
||
}
|
||
_isAnimated() {
|
||
return this._element.classList.contains(CLASS_NAME_FADE$3);
|
||
}
|
||
_triggerBackdropTransition() {
|
||
const hideEvent = EventHandler.trigger(this._element, EVENT_HIDE_PREVENTED$1);
|
||
if (hideEvent.defaultPrevented) {
|
||
return;
|
||
}
|
||
const isModalOverflowing = this._element.scrollHeight > document.documentElement.clientHeight;
|
||
const initialOverflowY = this._element.style.overflowY;
|
||
if (initialOverflowY === "hidden" || this._element.classList.contains(CLASS_NAME_STATIC)) {
|
||
return;
|
||
}
|
||
if (!isModalOverflowing) {
|
||
this._element.style.overflowY = "hidden";
|
||
}
|
||
this._element.classList.add(CLASS_NAME_STATIC);
|
||
this._queueCallback(() => {
|
||
this._element.classList.remove(CLASS_NAME_STATIC);
|
||
this._queueCallback(() => {
|
||
this._element.style.overflowY = initialOverflowY;
|
||
}, this._dialog);
|
||
}, this._dialog);
|
||
this._element.focus();
|
||
}
|
||
/**
|
||
* The following methods are used to handle overflowing modals
|
||
*/
|
||
_adjustDialog() {
|
||
const isModalOverflowing = this._element.scrollHeight > document.documentElement.clientHeight;
|
||
const scrollbarWidth = this._scrollBar.getWidth();
|
||
const isBodyOverflowing = scrollbarWidth > 0;
|
||
if (isBodyOverflowing && !isModalOverflowing) {
|
||
const property = isRTL() ? "paddingLeft" : "paddingRight";
|
||
this._element.style[property] = `${scrollbarWidth}px`;
|
||
}
|
||
if (!isBodyOverflowing && isModalOverflowing) {
|
||
const property = isRTL() ? "paddingRight" : "paddingLeft";
|
||
this._element.style[property] = `${scrollbarWidth}px`;
|
||
}
|
||
}
|
||
_resetAdjustments() {
|
||
this._element.style.paddingLeft = "";
|
||
this._element.style.paddingRight = "";
|
||
}
|
||
// Static
|
||
static jQueryInterface(config, relatedTarget) {
|
||
return this.each(function() {
|
||
const data = _Modal.getOrCreateInstance(this, config);
|
||
if (typeof config !== "string") {
|
||
return;
|
||
}
|
||
if (typeof data[config] === "undefined") {
|
||
throw new TypeError(`No method named "${config}"`);
|
||
}
|
||
data[config](relatedTarget);
|
||
});
|
||
}
|
||
};
|
||
EventHandler.on(document, EVENT_CLICK_DATA_API$2, SELECTOR_DATA_TOGGLE$2, function(event) {
|
||
const target = SelectorEngine.getElementFromSelector(this);
|
||
if (["A", "AREA"].includes(this.tagName)) {
|
||
event.preventDefault();
|
||
}
|
||
EventHandler.one(target, EVENT_SHOW$4, (showEvent) => {
|
||
if (showEvent.defaultPrevented) {
|
||
return;
|
||
}
|
||
EventHandler.one(target, EVENT_HIDDEN$4, () => {
|
||
if (isVisible(this)) {
|
||
this.focus();
|
||
}
|
||
});
|
||
});
|
||
const alreadyOpen = SelectorEngine.findOne(OPEN_SELECTOR$1);
|
||
if (alreadyOpen) {
|
||
Modal.getInstance(alreadyOpen).hide();
|
||
}
|
||
const data = Modal.getOrCreateInstance(target);
|
||
data.toggle(this);
|
||
});
|
||
enableDismissTrigger(Modal);
|
||
defineJQueryPlugin(Modal);
|
||
var NAME$6 = "offcanvas";
|
||
var DATA_KEY$3 = "bs.offcanvas";
|
||
var EVENT_KEY$3 = `.${DATA_KEY$3}`;
|
||
var DATA_API_KEY$1 = ".data-api";
|
||
var EVENT_LOAD_DATA_API$2 = `load${EVENT_KEY$3}${DATA_API_KEY$1}`;
|
||
var ESCAPE_KEY = "Escape";
|
||
var CLASS_NAME_SHOW$3 = "show";
|
||
var CLASS_NAME_SHOWING$1 = "showing";
|
||
var CLASS_NAME_HIDING = "hiding";
|
||
var CLASS_NAME_BACKDROP = "offcanvas-backdrop";
|
||
var OPEN_SELECTOR = ".offcanvas.show";
|
||
var EVENT_SHOW$3 = `show${EVENT_KEY$3}`;
|
||
var EVENT_SHOWN$3 = `shown${EVENT_KEY$3}`;
|
||
var EVENT_HIDE$3 = `hide${EVENT_KEY$3}`;
|
||
var EVENT_HIDE_PREVENTED = `hidePrevented${EVENT_KEY$3}`;
|
||
var EVENT_HIDDEN$3 = `hidden${EVENT_KEY$3}`;
|
||
var EVENT_RESIZE = `resize${EVENT_KEY$3}`;
|
||
var EVENT_CLICK_DATA_API$1 = `click${EVENT_KEY$3}${DATA_API_KEY$1}`;
|
||
var EVENT_KEYDOWN_DISMISS = `keydown.dismiss${EVENT_KEY$3}`;
|
||
var SELECTOR_DATA_TOGGLE$1 = '[data-bs-toggle="offcanvas"]';
|
||
var Default$5 = {
|
||
backdrop: true,
|
||
keyboard: true,
|
||
scroll: false
|
||
};
|
||
var DefaultType$5 = {
|
||
backdrop: "(boolean|string)",
|
||
keyboard: "boolean",
|
||
scroll: "boolean"
|
||
};
|
||
var Offcanvas = class _Offcanvas extends BaseComponent {
|
||
constructor(element, config) {
|
||
super(element, config);
|
||
this._isShown = false;
|
||
this._backdrop = this._initializeBackDrop();
|
||
this._focustrap = this._initializeFocusTrap();
|
||
this._addEventListeners();
|
||
}
|
||
// Getters
|
||
static get Default() {
|
||
return Default$5;
|
||
}
|
||
static get DefaultType() {
|
||
return DefaultType$5;
|
||
}
|
||
static get NAME() {
|
||
return NAME$6;
|
||
}
|
||
// Public
|
||
toggle(relatedTarget) {
|
||
return this._isShown ? this.hide() : this.show(relatedTarget);
|
||
}
|
||
show(relatedTarget) {
|
||
if (this._isShown) {
|
||
return;
|
||
}
|
||
const showEvent = EventHandler.trigger(this._element, EVENT_SHOW$3, {
|
||
relatedTarget
|
||
});
|
||
if (showEvent.defaultPrevented) {
|
||
return;
|
||
}
|
||
this._isShown = true;
|
||
this._backdrop.show();
|
||
if (!this._config.scroll) {
|
||
new ScrollBarHelper().hide();
|
||
}
|
||
this._element.setAttribute("aria-modal", true);
|
||
this._element.setAttribute("role", "dialog");
|
||
this._element.classList.add(CLASS_NAME_SHOWING$1);
|
||
const completeCallBack = () => {
|
||
if (!this._config.scroll || this._config.backdrop) {
|
||
this._focustrap.activate();
|
||
}
|
||
this._element.classList.add(CLASS_NAME_SHOW$3);
|
||
this._element.classList.remove(CLASS_NAME_SHOWING$1);
|
||
EventHandler.trigger(this._element, EVENT_SHOWN$3, {
|
||
relatedTarget
|
||
});
|
||
};
|
||
this._queueCallback(completeCallBack, this._element, true);
|
||
}
|
||
hide() {
|
||
if (!this._isShown) {
|
||
return;
|
||
}
|
||
const hideEvent = EventHandler.trigger(this._element, EVENT_HIDE$3);
|
||
if (hideEvent.defaultPrevented) {
|
||
return;
|
||
}
|
||
this._focustrap.deactivate();
|
||
this._element.blur();
|
||
this._isShown = false;
|
||
this._element.classList.add(CLASS_NAME_HIDING);
|
||
this._backdrop.hide();
|
||
const completeCallback = () => {
|
||
this._element.classList.remove(CLASS_NAME_SHOW$3, CLASS_NAME_HIDING);
|
||
this._element.removeAttribute("aria-modal");
|
||
this._element.removeAttribute("role");
|
||
if (!this._config.scroll) {
|
||
new ScrollBarHelper().reset();
|
||
}
|
||
EventHandler.trigger(this._element, EVENT_HIDDEN$3);
|
||
};
|
||
this._queueCallback(completeCallback, this._element, true);
|
||
}
|
||
dispose() {
|
||
this._backdrop.dispose();
|
||
this._focustrap.deactivate();
|
||
super.dispose();
|
||
}
|
||
// Private
|
||
_initializeBackDrop() {
|
||
const clickCallback = () => {
|
||
if (this._config.backdrop === "static") {
|
||
EventHandler.trigger(this._element, EVENT_HIDE_PREVENTED);
|
||
return;
|
||
}
|
||
this.hide();
|
||
};
|
||
const isVisible2 = Boolean(this._config.backdrop);
|
||
return new Backdrop({
|
||
className: CLASS_NAME_BACKDROP,
|
||
isVisible: isVisible2,
|
||
isAnimated: true,
|
||
rootElement: this._element.parentNode,
|
||
clickCallback: isVisible2 ? clickCallback : null
|
||
});
|
||
}
|
||
_initializeFocusTrap() {
|
||
return new FocusTrap({
|
||
trapElement: this._element
|
||
});
|
||
}
|
||
_addEventListeners() {
|
||
EventHandler.on(this._element, EVENT_KEYDOWN_DISMISS, (event) => {
|
||
if (event.key !== ESCAPE_KEY) {
|
||
return;
|
||
}
|
||
if (this._config.keyboard) {
|
||
this.hide();
|
||
return;
|
||
}
|
||
EventHandler.trigger(this._element, EVENT_HIDE_PREVENTED);
|
||
});
|
||
}
|
||
// Static
|
||
static jQueryInterface(config) {
|
||
return this.each(function() {
|
||
const data = _Offcanvas.getOrCreateInstance(this, config);
|
||
if (typeof config !== "string") {
|
||
return;
|
||
}
|
||
if (data[config] === void 0 || config.startsWith("_") || config === "constructor") {
|
||
throw new TypeError(`No method named "${config}"`);
|
||
}
|
||
data[config](this);
|
||
});
|
||
}
|
||
};
|
||
EventHandler.on(document, EVENT_CLICK_DATA_API$1, SELECTOR_DATA_TOGGLE$1, function(event) {
|
||
const target = SelectorEngine.getElementFromSelector(this);
|
||
if (["A", "AREA"].includes(this.tagName)) {
|
||
event.preventDefault();
|
||
}
|
||
if (isDisabled(this)) {
|
||
return;
|
||
}
|
||
EventHandler.one(target, EVENT_HIDDEN$3, () => {
|
||
if (isVisible(this)) {
|
||
this.focus();
|
||
}
|
||
});
|
||
const alreadyOpen = SelectorEngine.findOne(OPEN_SELECTOR);
|
||
if (alreadyOpen && alreadyOpen !== target) {
|
||
Offcanvas.getInstance(alreadyOpen).hide();
|
||
}
|
||
const data = Offcanvas.getOrCreateInstance(target);
|
||
data.toggle(this);
|
||
});
|
||
EventHandler.on(window, EVENT_LOAD_DATA_API$2, () => {
|
||
for (const selector of SelectorEngine.find(OPEN_SELECTOR)) {
|
||
Offcanvas.getOrCreateInstance(selector).show();
|
||
}
|
||
});
|
||
EventHandler.on(window, EVENT_RESIZE, () => {
|
||
for (const element of SelectorEngine.find("[aria-modal][class*=show][class*=offcanvas-]")) {
|
||
if (getComputedStyle(element).position !== "fixed") {
|
||
Offcanvas.getOrCreateInstance(element).hide();
|
||
}
|
||
}
|
||
});
|
||
enableDismissTrigger(Offcanvas);
|
||
defineJQueryPlugin(Offcanvas);
|
||
var ARIA_ATTRIBUTE_PATTERN = /^aria-[\w-]*$/i;
|
||
var DefaultAllowlist = {
|
||
// Global attributes allowed on any supplied element below.
|
||
"*": ["class", "dir", "id", "lang", "role", ARIA_ATTRIBUTE_PATTERN],
|
||
a: ["target", "href", "title", "rel"],
|
||
area: [],
|
||
b: [],
|
||
br: [],
|
||
col: [],
|
||
code: [],
|
||
div: [],
|
||
em: [],
|
||
hr: [],
|
||
h1: [],
|
||
h2: [],
|
||
h3: [],
|
||
h4: [],
|
||
h5: [],
|
||
h6: [],
|
||
i: [],
|
||
img: ["src", "srcset", "alt", "title", "width", "height"],
|
||
li: [],
|
||
ol: [],
|
||
p: [],
|
||
pre: [],
|
||
s: [],
|
||
small: [],
|
||
span: [],
|
||
sub: [],
|
||
sup: [],
|
||
strong: [],
|
||
u: [],
|
||
ul: []
|
||
};
|
||
var uriAttributes = /* @__PURE__ */ new Set(["background", "cite", "href", "itemtype", "longdesc", "poster", "src", "xlink:href"]);
|
||
var SAFE_URL_PATTERN = /^(?!javascript:)(?:[a-z0-9+.-]+:|[^&:/?#]*(?:[/?#]|$))/i;
|
||
var allowedAttribute = (attribute, allowedAttributeList) => {
|
||
const attributeName = attribute.nodeName.toLowerCase();
|
||
if (allowedAttributeList.includes(attributeName)) {
|
||
if (uriAttributes.has(attributeName)) {
|
||
return Boolean(SAFE_URL_PATTERN.test(attribute.nodeValue));
|
||
}
|
||
return true;
|
||
}
|
||
return allowedAttributeList.filter((attributeRegex) => attributeRegex instanceof RegExp).some((regex) => regex.test(attributeName));
|
||
};
|
||
function sanitizeHtml(unsafeHtml, allowList, sanitizeFunction) {
|
||
if (!unsafeHtml.length) {
|
||
return unsafeHtml;
|
||
}
|
||
if (sanitizeFunction && typeof sanitizeFunction === "function") {
|
||
return sanitizeFunction(unsafeHtml);
|
||
}
|
||
const domParser = new window.DOMParser();
|
||
const createdDocument = domParser.parseFromString(unsafeHtml, "text/html");
|
||
const elements = [].concat(...createdDocument.body.querySelectorAll("*"));
|
||
for (const element of elements) {
|
||
const elementName = element.nodeName.toLowerCase();
|
||
if (!Object.keys(allowList).includes(elementName)) {
|
||
element.remove();
|
||
continue;
|
||
}
|
||
const attributeList = [].concat(...element.attributes);
|
||
const allowedAttributes = [].concat(allowList["*"] || [], allowList[elementName] || []);
|
||
for (const attribute of attributeList) {
|
||
if (!allowedAttribute(attribute, allowedAttributes)) {
|
||
element.removeAttribute(attribute.nodeName);
|
||
}
|
||
}
|
||
}
|
||
return createdDocument.body.innerHTML;
|
||
}
|
||
var NAME$5 = "TemplateFactory";
|
||
var Default$4 = {
|
||
allowList: DefaultAllowlist,
|
||
content: {},
|
||
// { selector : text , selector2 : text2 , }
|
||
extraClass: "",
|
||
html: false,
|
||
sanitize: true,
|
||
sanitizeFn: null,
|
||
template: "<div></div>"
|
||
};
|
||
var DefaultType$4 = {
|
||
allowList: "object",
|
||
content: "object",
|
||
extraClass: "(string|function)",
|
||
html: "boolean",
|
||
sanitize: "boolean",
|
||
sanitizeFn: "(null|function)",
|
||
template: "string"
|
||
};
|
||
var DefaultContentType = {
|
||
entry: "(string|element|function|null)",
|
||
selector: "(string|element)"
|
||
};
|
||
var TemplateFactory = class extends Config {
|
||
constructor(config) {
|
||
super();
|
||
this._config = this._getConfig(config);
|
||
}
|
||
// Getters
|
||
static get Default() {
|
||
return Default$4;
|
||
}
|
||
static get DefaultType() {
|
||
return DefaultType$4;
|
||
}
|
||
static get NAME() {
|
||
return NAME$5;
|
||
}
|
||
// Public
|
||
getContent() {
|
||
return Object.values(this._config.content).map((config) => this._resolvePossibleFunction(config)).filter(Boolean);
|
||
}
|
||
hasContent() {
|
||
return this.getContent().length > 0;
|
||
}
|
||
changeContent(content) {
|
||
this._checkContent(content);
|
||
this._config.content = {
|
||
...this._config.content,
|
||
...content
|
||
};
|
||
return this;
|
||
}
|
||
toHtml() {
|
||
const templateWrapper = document.createElement("div");
|
||
templateWrapper.innerHTML = this._maybeSanitize(this._config.template);
|
||
for (const [selector, text] of Object.entries(this._config.content)) {
|
||
this._setContent(templateWrapper, text, selector);
|
||
}
|
||
const template = templateWrapper.children[0];
|
||
const extraClass = this._resolvePossibleFunction(this._config.extraClass);
|
||
if (extraClass) {
|
||
template.classList.add(...extraClass.split(" "));
|
||
}
|
||
return template;
|
||
}
|
||
// Private
|
||
_typeCheckConfig(config) {
|
||
super._typeCheckConfig(config);
|
||
this._checkContent(config.content);
|
||
}
|
||
_checkContent(arg) {
|
||
for (const [selector, content] of Object.entries(arg)) {
|
||
super._typeCheckConfig({
|
||
selector,
|
||
entry: content
|
||
}, DefaultContentType);
|
||
}
|
||
}
|
||
_setContent(template, content, selector) {
|
||
const templateElement = SelectorEngine.findOne(selector, template);
|
||
if (!templateElement) {
|
||
return;
|
||
}
|
||
content = this._resolvePossibleFunction(content);
|
||
if (!content) {
|
||
templateElement.remove();
|
||
return;
|
||
}
|
||
if (isElement2(content)) {
|
||
this._putElementInTemplate(getElement(content), templateElement);
|
||
return;
|
||
}
|
||
if (this._config.html) {
|
||
templateElement.innerHTML = this._maybeSanitize(content);
|
||
return;
|
||
}
|
||
templateElement.textContent = content;
|
||
}
|
||
_maybeSanitize(arg) {
|
||
return this._config.sanitize ? sanitizeHtml(arg, this._config.allowList, this._config.sanitizeFn) : arg;
|
||
}
|
||
_resolvePossibleFunction(arg) {
|
||
return execute(arg, [this]);
|
||
}
|
||
_putElementInTemplate(element, templateElement) {
|
||
if (this._config.html) {
|
||
templateElement.innerHTML = "";
|
||
templateElement.append(element);
|
||
return;
|
||
}
|
||
templateElement.textContent = element.textContent;
|
||
}
|
||
};
|
||
var NAME$4 = "tooltip";
|
||
var DISALLOWED_ATTRIBUTES = /* @__PURE__ */ new Set(["sanitize", "allowList", "sanitizeFn"]);
|
||
var CLASS_NAME_FADE$2 = "fade";
|
||
var CLASS_NAME_MODAL = "modal";
|
||
var CLASS_NAME_SHOW$2 = "show";
|
||
var SELECTOR_TOOLTIP_INNER = ".tooltip-inner";
|
||
var SELECTOR_MODAL = `.${CLASS_NAME_MODAL}`;
|
||
var EVENT_MODAL_HIDE = "hide.bs.modal";
|
||
var TRIGGER_HOVER = "hover";
|
||
var TRIGGER_FOCUS = "focus";
|
||
var TRIGGER_CLICK = "click";
|
||
var TRIGGER_MANUAL = "manual";
|
||
var EVENT_HIDE$2 = "hide";
|
||
var EVENT_HIDDEN$2 = "hidden";
|
||
var EVENT_SHOW$2 = "show";
|
||
var EVENT_SHOWN$2 = "shown";
|
||
var EVENT_INSERTED = "inserted";
|
||
var EVENT_CLICK$1 = "click";
|
||
var EVENT_FOCUSIN$1 = "focusin";
|
||
var EVENT_FOCUSOUT$1 = "focusout";
|
||
var EVENT_MOUSEENTER = "mouseenter";
|
||
var EVENT_MOUSELEAVE = "mouseleave";
|
||
var AttachmentMap = {
|
||
AUTO: "auto",
|
||
TOP: "top",
|
||
RIGHT: isRTL() ? "left" : "right",
|
||
BOTTOM: "bottom",
|
||
LEFT: isRTL() ? "right" : "left"
|
||
};
|
||
var Default$3 = {
|
||
allowList: DefaultAllowlist,
|
||
animation: true,
|
||
boundary: "clippingParents",
|
||
container: false,
|
||
customClass: "",
|
||
delay: 0,
|
||
fallbackPlacements: ["top", "right", "bottom", "left"],
|
||
html: false,
|
||
offset: [0, 6],
|
||
placement: "top",
|
||
popperConfig: null,
|
||
sanitize: true,
|
||
sanitizeFn: null,
|
||
selector: false,
|
||
template: '<div class="tooltip" role="tooltip"><div class="tooltip-arrow"></div><div class="tooltip-inner"></div></div>',
|
||
title: "",
|
||
trigger: "hover focus"
|
||
};
|
||
var DefaultType$3 = {
|
||
allowList: "object",
|
||
animation: "boolean",
|
||
boundary: "(string|element)",
|
||
container: "(string|element|boolean)",
|
||
customClass: "(string|function)",
|
||
delay: "(number|object)",
|
||
fallbackPlacements: "array",
|
||
html: "boolean",
|
||
offset: "(array|string|function)",
|
||
placement: "(string|function)",
|
||
popperConfig: "(null|object|function)",
|
||
sanitize: "boolean",
|
||
sanitizeFn: "(null|function)",
|
||
selector: "(string|boolean)",
|
||
template: "string",
|
||
title: "(string|element|function)",
|
||
trigger: "string"
|
||
};
|
||
var Tooltip = class _Tooltip extends BaseComponent {
|
||
constructor(element, config) {
|
||
if (typeof lib_exports === "undefined") {
|
||
throw new TypeError("Bootstrap's tooltips require Popper (https://popper.js.org)");
|
||
}
|
||
super(element, config);
|
||
this._isEnabled = true;
|
||
this._timeout = 0;
|
||
this._isHovered = null;
|
||
this._activeTrigger = {};
|
||
this._popper = null;
|
||
this._templateFactory = null;
|
||
this._newContent = null;
|
||
this.tip = null;
|
||
this._setListeners();
|
||
if (!this._config.selector) {
|
||
this._fixTitle();
|
||
}
|
||
}
|
||
// Getters
|
||
static get Default() {
|
||
return Default$3;
|
||
}
|
||
static get DefaultType() {
|
||
return DefaultType$3;
|
||
}
|
||
static get NAME() {
|
||
return NAME$4;
|
||
}
|
||
// Public
|
||
enable() {
|
||
this._isEnabled = true;
|
||
}
|
||
disable() {
|
||
this._isEnabled = false;
|
||
}
|
||
toggleEnabled() {
|
||
this._isEnabled = !this._isEnabled;
|
||
}
|
||
toggle() {
|
||
if (!this._isEnabled) {
|
||
return;
|
||
}
|
||
this._activeTrigger.click = !this._activeTrigger.click;
|
||
if (this._isShown()) {
|
||
this._leave();
|
||
return;
|
||
}
|
||
this._enter();
|
||
}
|
||
dispose() {
|
||
clearTimeout(this._timeout);
|
||
EventHandler.off(this._element.closest(SELECTOR_MODAL), EVENT_MODAL_HIDE, this._hideModalHandler);
|
||
if (this._element.getAttribute("data-bs-original-title")) {
|
||
this._element.setAttribute("title", this._element.getAttribute("data-bs-original-title"));
|
||
}
|
||
this._disposePopper();
|
||
super.dispose();
|
||
}
|
||
show() {
|
||
if (this._element.style.display === "none") {
|
||
throw new Error("Please use show on visible elements");
|
||
}
|
||
if (!(this._isWithContent() && this._isEnabled)) {
|
||
return;
|
||
}
|
||
const showEvent = EventHandler.trigger(this._element, this.constructor.eventName(EVENT_SHOW$2));
|
||
const shadowRoot = findShadowRoot(this._element);
|
||
const isInTheDom = (shadowRoot || this._element.ownerDocument.documentElement).contains(this._element);
|
||
if (showEvent.defaultPrevented || !isInTheDom) {
|
||
return;
|
||
}
|
||
this._disposePopper();
|
||
const tip = this._getTipElement();
|
||
this._element.setAttribute("aria-describedby", tip.getAttribute("id"));
|
||
const {
|
||
container
|
||
} = this._config;
|
||
if (!this._element.ownerDocument.documentElement.contains(this.tip)) {
|
||
container.append(tip);
|
||
EventHandler.trigger(this._element, this.constructor.eventName(EVENT_INSERTED));
|
||
}
|
||
this._popper = this._createPopper(tip);
|
||
tip.classList.add(CLASS_NAME_SHOW$2);
|
||
if ("ontouchstart" in document.documentElement) {
|
||
for (const element of [].concat(...document.body.children)) {
|
||
EventHandler.on(element, "mouseover", noop);
|
||
}
|
||
}
|
||
const complete = () => {
|
||
EventHandler.trigger(this._element, this.constructor.eventName(EVENT_SHOWN$2));
|
||
if (this._isHovered === false) {
|
||
this._leave();
|
||
}
|
||
this._isHovered = false;
|
||
};
|
||
this._queueCallback(complete, this.tip, this._isAnimated());
|
||
}
|
||
hide() {
|
||
if (!this._isShown()) {
|
||
return;
|
||
}
|
||
const hideEvent = EventHandler.trigger(this._element, this.constructor.eventName(EVENT_HIDE$2));
|
||
if (hideEvent.defaultPrevented) {
|
||
return;
|
||
}
|
||
const tip = this._getTipElement();
|
||
tip.classList.remove(CLASS_NAME_SHOW$2);
|
||
if ("ontouchstart" in document.documentElement) {
|
||
for (const element of [].concat(...document.body.children)) {
|
||
EventHandler.off(element, "mouseover", noop);
|
||
}
|
||
}
|
||
this._activeTrigger[TRIGGER_CLICK] = false;
|
||
this._activeTrigger[TRIGGER_FOCUS] = false;
|
||
this._activeTrigger[TRIGGER_HOVER] = false;
|
||
this._isHovered = null;
|
||
const complete = () => {
|
||
if (this._isWithActiveTrigger()) {
|
||
return;
|
||
}
|
||
if (!this._isHovered) {
|
||
this._disposePopper();
|
||
}
|
||
this._element.removeAttribute("aria-describedby");
|
||
EventHandler.trigger(this._element, this.constructor.eventName(EVENT_HIDDEN$2));
|
||
};
|
||
this._queueCallback(complete, this.tip, this._isAnimated());
|
||
}
|
||
update() {
|
||
if (this._popper) {
|
||
this._popper.update();
|
||
}
|
||
}
|
||
// Protected
|
||
_isWithContent() {
|
||
return Boolean(this._getTitle());
|
||
}
|
||
_getTipElement() {
|
||
if (!this.tip) {
|
||
this.tip = this._createTipElement(this._newContent || this._getContentForTemplate());
|
||
}
|
||
return this.tip;
|
||
}
|
||
_createTipElement(content) {
|
||
const tip = this._getTemplateFactory(content).toHtml();
|
||
if (!tip) {
|
||
return null;
|
||
}
|
||
tip.classList.remove(CLASS_NAME_FADE$2, CLASS_NAME_SHOW$2);
|
||
tip.classList.add(`bs-${this.constructor.NAME}-auto`);
|
||
const tipId = getUID(this.constructor.NAME).toString();
|
||
tip.setAttribute("id", tipId);
|
||
if (this._isAnimated()) {
|
||
tip.classList.add(CLASS_NAME_FADE$2);
|
||
}
|
||
return tip;
|
||
}
|
||
setContent(content) {
|
||
this._newContent = content;
|
||
if (this._isShown()) {
|
||
this._disposePopper();
|
||
this.show();
|
||
}
|
||
}
|
||
_getTemplateFactory(content) {
|
||
if (this._templateFactory) {
|
||
this._templateFactory.changeContent(content);
|
||
} else {
|
||
this._templateFactory = new TemplateFactory({
|
||
...this._config,
|
||
// the `content` var has to be after `this._config`
|
||
// to override config.content in case of popover
|
||
content,
|
||
extraClass: this._resolvePossibleFunction(this._config.customClass)
|
||
});
|
||
}
|
||
return this._templateFactory;
|
||
}
|
||
_getContentForTemplate() {
|
||
return {
|
||
[SELECTOR_TOOLTIP_INNER]: this._getTitle()
|
||
};
|
||
}
|
||
_getTitle() {
|
||
return this._resolvePossibleFunction(this._config.title) || this._element.getAttribute("data-bs-original-title");
|
||
}
|
||
// Private
|
||
_initializeOnDelegatedTarget(event) {
|
||
return this.constructor.getOrCreateInstance(event.delegateTarget, this._getDelegateConfig());
|
||
}
|
||
_isAnimated() {
|
||
return this._config.animation || this.tip && this.tip.classList.contains(CLASS_NAME_FADE$2);
|
||
}
|
||
_isShown() {
|
||
return this.tip && this.tip.classList.contains(CLASS_NAME_SHOW$2);
|
||
}
|
||
_createPopper(tip) {
|
||
const placement = execute(this._config.placement, [this, tip, this._element]);
|
||
const attachment = AttachmentMap[placement.toUpperCase()];
|
||
return createPopper3(this._element, tip, this._getPopperConfig(attachment));
|
||
}
|
||
_getOffset() {
|
||
const {
|
||
offset: offset2
|
||
} = this._config;
|
||
if (typeof offset2 === "string") {
|
||
return offset2.split(",").map((value) => Number.parseInt(value, 10));
|
||
}
|
||
if (typeof offset2 === "function") {
|
||
return (popperData) => offset2(popperData, this._element);
|
||
}
|
||
return offset2;
|
||
}
|
||
_resolvePossibleFunction(arg) {
|
||
return execute(arg, [this._element]);
|
||
}
|
||
_getPopperConfig(attachment) {
|
||
const defaultBsPopperConfig = {
|
||
placement: attachment,
|
||
modifiers: [{
|
||
name: "flip",
|
||
options: {
|
||
fallbackPlacements: this._config.fallbackPlacements
|
||
}
|
||
}, {
|
||
name: "offset",
|
||
options: {
|
||
offset: this._getOffset()
|
||
}
|
||
}, {
|
||
name: "preventOverflow",
|
||
options: {
|
||
boundary: this._config.boundary
|
||
}
|
||
}, {
|
||
name: "arrow",
|
||
options: {
|
||
element: `.${this.constructor.NAME}-arrow`
|
||
}
|
||
}, {
|
||
name: "preSetPlacement",
|
||
enabled: true,
|
||
phase: "beforeMain",
|
||
fn: (data) => {
|
||
this._getTipElement().setAttribute("data-popper-placement", data.state.placement);
|
||
}
|
||
}]
|
||
};
|
||
return {
|
||
...defaultBsPopperConfig,
|
||
...execute(this._config.popperConfig, [defaultBsPopperConfig])
|
||
};
|
||
}
|
||
_setListeners() {
|
||
const triggers = this._config.trigger.split(" ");
|
||
for (const trigger of triggers) {
|
||
if (trigger === "click") {
|
||
EventHandler.on(this._element, this.constructor.eventName(EVENT_CLICK$1), this._config.selector, (event) => {
|
||
const context = this._initializeOnDelegatedTarget(event);
|
||
context.toggle();
|
||
});
|
||
} else if (trigger !== TRIGGER_MANUAL) {
|
||
const eventIn = trigger === TRIGGER_HOVER ? this.constructor.eventName(EVENT_MOUSEENTER) : this.constructor.eventName(EVENT_FOCUSIN$1);
|
||
const eventOut = trigger === TRIGGER_HOVER ? this.constructor.eventName(EVENT_MOUSELEAVE) : this.constructor.eventName(EVENT_FOCUSOUT$1);
|
||
EventHandler.on(this._element, eventIn, this._config.selector, (event) => {
|
||
const context = this._initializeOnDelegatedTarget(event);
|
||
context._activeTrigger[event.type === "focusin" ? TRIGGER_FOCUS : TRIGGER_HOVER] = true;
|
||
context._enter();
|
||
});
|
||
EventHandler.on(this._element, eventOut, this._config.selector, (event) => {
|
||
const context = this._initializeOnDelegatedTarget(event);
|
||
context._activeTrigger[event.type === "focusout" ? TRIGGER_FOCUS : TRIGGER_HOVER] = context._element.contains(event.relatedTarget);
|
||
context._leave();
|
||
});
|
||
}
|
||
}
|
||
this._hideModalHandler = () => {
|
||
if (this._element) {
|
||
this.hide();
|
||
}
|
||
};
|
||
EventHandler.on(this._element.closest(SELECTOR_MODAL), EVENT_MODAL_HIDE, this._hideModalHandler);
|
||
}
|
||
_fixTitle() {
|
||
const title = this._element.getAttribute("title");
|
||
if (!title) {
|
||
return;
|
||
}
|
||
if (!this._element.getAttribute("aria-label") && !this._element.textContent.trim()) {
|
||
this._element.setAttribute("aria-label", title);
|
||
}
|
||
this._element.setAttribute("data-bs-original-title", title);
|
||
this._element.removeAttribute("title");
|
||
}
|
||
_enter() {
|
||
if (this._isShown() || this._isHovered) {
|
||
this._isHovered = true;
|
||
return;
|
||
}
|
||
this._isHovered = true;
|
||
this._setTimeout(() => {
|
||
if (this._isHovered) {
|
||
this.show();
|
||
}
|
||
}, this._config.delay.show);
|
||
}
|
||
_leave() {
|
||
if (this._isWithActiveTrigger()) {
|
||
return;
|
||
}
|
||
this._isHovered = false;
|
||
this._setTimeout(() => {
|
||
if (!this._isHovered) {
|
||
this.hide();
|
||
}
|
||
}, this._config.delay.hide);
|
||
}
|
||
_setTimeout(handler, timeout) {
|
||
clearTimeout(this._timeout);
|
||
this._timeout = setTimeout(handler, timeout);
|
||
}
|
||
_isWithActiveTrigger() {
|
||
return Object.values(this._activeTrigger).includes(true);
|
||
}
|
||
_getConfig(config) {
|
||
const dataAttributes = Manipulator.getDataAttributes(this._element);
|
||
for (const dataAttribute of Object.keys(dataAttributes)) {
|
||
if (DISALLOWED_ATTRIBUTES.has(dataAttribute)) {
|
||
delete dataAttributes[dataAttribute];
|
||
}
|
||
}
|
||
config = {
|
||
...dataAttributes,
|
||
...typeof config === "object" && config ? config : {}
|
||
};
|
||
config = this._mergeConfigObj(config);
|
||
config = this._configAfterMerge(config);
|
||
this._typeCheckConfig(config);
|
||
return config;
|
||
}
|
||
_configAfterMerge(config) {
|
||
config.container = config.container === false ? document.body : getElement(config.container);
|
||
if (typeof config.delay === "number") {
|
||
config.delay = {
|
||
show: config.delay,
|
||
hide: config.delay
|
||
};
|
||
}
|
||
if (typeof config.title === "number") {
|
||
config.title = config.title.toString();
|
||
}
|
||
if (typeof config.content === "number") {
|
||
config.content = config.content.toString();
|
||
}
|
||
return config;
|
||
}
|
||
_getDelegateConfig() {
|
||
const config = {};
|
||
for (const [key, value] of Object.entries(this._config)) {
|
||
if (this.constructor.Default[key] !== value) {
|
||
config[key] = value;
|
||
}
|
||
}
|
||
config.selector = false;
|
||
config.trigger = "manual";
|
||
return config;
|
||
}
|
||
_disposePopper() {
|
||
if (this._popper) {
|
||
this._popper.destroy();
|
||
this._popper = null;
|
||
}
|
||
if (this.tip) {
|
||
this.tip.remove();
|
||
this.tip = null;
|
||
}
|
||
}
|
||
// Static
|
||
static jQueryInterface(config) {
|
||
return this.each(function() {
|
||
const data = _Tooltip.getOrCreateInstance(this, config);
|
||
if (typeof config !== "string") {
|
||
return;
|
||
}
|
||
if (typeof data[config] === "undefined") {
|
||
throw new TypeError(`No method named "${config}"`);
|
||
}
|
||
data[config]();
|
||
});
|
||
}
|
||
};
|
||
defineJQueryPlugin(Tooltip);
|
||
var NAME$3 = "popover";
|
||
var SELECTOR_TITLE = ".popover-header";
|
||
var SELECTOR_CONTENT = ".popover-body";
|
||
var Default$2 = {
|
||
...Tooltip.Default,
|
||
content: "",
|
||
offset: [0, 8],
|
||
placement: "right",
|
||
template: '<div class="popover" role="tooltip"><div class="popover-arrow"></div><h3 class="popover-header"></h3><div class="popover-body"></div></div>',
|
||
trigger: "click"
|
||
};
|
||
var DefaultType$2 = {
|
||
...Tooltip.DefaultType,
|
||
content: "(null|string|element|function)"
|
||
};
|
||
var Popover = class _Popover extends Tooltip {
|
||
// Getters
|
||
static get Default() {
|
||
return Default$2;
|
||
}
|
||
static get DefaultType() {
|
||
return DefaultType$2;
|
||
}
|
||
static get NAME() {
|
||
return NAME$3;
|
||
}
|
||
// Overrides
|
||
_isWithContent() {
|
||
return this._getTitle() || this._getContent();
|
||
}
|
||
// Private
|
||
_getContentForTemplate() {
|
||
return {
|
||
[SELECTOR_TITLE]: this._getTitle(),
|
||
[SELECTOR_CONTENT]: this._getContent()
|
||
};
|
||
}
|
||
_getContent() {
|
||
return this._resolvePossibleFunction(this._config.content);
|
||
}
|
||
// Static
|
||
static jQueryInterface(config) {
|
||
return this.each(function() {
|
||
const data = _Popover.getOrCreateInstance(this, config);
|
||
if (typeof config !== "string") {
|
||
return;
|
||
}
|
||
if (typeof data[config] === "undefined") {
|
||
throw new TypeError(`No method named "${config}"`);
|
||
}
|
||
data[config]();
|
||
});
|
||
}
|
||
};
|
||
defineJQueryPlugin(Popover);
|
||
var NAME$2 = "scrollspy";
|
||
var DATA_KEY$2 = "bs.scrollspy";
|
||
var EVENT_KEY$2 = `.${DATA_KEY$2}`;
|
||
var DATA_API_KEY = ".data-api";
|
||
var EVENT_ACTIVATE = `activate${EVENT_KEY$2}`;
|
||
var EVENT_CLICK = `click${EVENT_KEY$2}`;
|
||
var EVENT_LOAD_DATA_API$1 = `load${EVENT_KEY$2}${DATA_API_KEY}`;
|
||
var CLASS_NAME_DROPDOWN_ITEM = "dropdown-item";
|
||
var CLASS_NAME_ACTIVE$1 = "active";
|
||
var SELECTOR_DATA_SPY = '[data-bs-spy="scroll"]';
|
||
var SELECTOR_TARGET_LINKS = "[href]";
|
||
var SELECTOR_NAV_LIST_GROUP = ".nav, .list-group";
|
||
var SELECTOR_NAV_LINKS = ".nav-link";
|
||
var SELECTOR_NAV_ITEMS = ".nav-item";
|
||
var SELECTOR_LIST_ITEMS = ".list-group-item";
|
||
var SELECTOR_LINK_ITEMS = `${SELECTOR_NAV_LINKS}, ${SELECTOR_NAV_ITEMS} > ${SELECTOR_NAV_LINKS}, ${SELECTOR_LIST_ITEMS}`;
|
||
var SELECTOR_DROPDOWN = ".dropdown";
|
||
var SELECTOR_DROPDOWN_TOGGLE$1 = ".dropdown-toggle";
|
||
var Default$1 = {
|
||
offset: null,
|
||
// TODO: v6 @deprecated, keep it for backwards compatibility reasons
|
||
rootMargin: "0px 0px -25%",
|
||
smoothScroll: false,
|
||
target: null,
|
||
threshold: [0.1, 0.5, 1]
|
||
};
|
||
var DefaultType$1 = {
|
||
offset: "(number|null)",
|
||
// TODO v6 @deprecated, keep it for backwards compatibility reasons
|
||
rootMargin: "string",
|
||
smoothScroll: "boolean",
|
||
target: "element",
|
||
threshold: "array"
|
||
};
|
||
var ScrollSpy = class _ScrollSpy extends BaseComponent {
|
||
constructor(element, config) {
|
||
super(element, config);
|
||
this._targetLinks = /* @__PURE__ */ new Map();
|
||
this._observableSections = /* @__PURE__ */ new Map();
|
||
this._rootElement = getComputedStyle(this._element).overflowY === "visible" ? null : this._element;
|
||
this._activeTarget = null;
|
||
this._observer = null;
|
||
this._previousScrollData = {
|
||
visibleEntryTop: 0,
|
||
parentScrollTop: 0
|
||
};
|
||
this.refresh();
|
||
}
|
||
// Getters
|
||
static get Default() {
|
||
return Default$1;
|
||
}
|
||
static get DefaultType() {
|
||
return DefaultType$1;
|
||
}
|
||
static get NAME() {
|
||
return NAME$2;
|
||
}
|
||
// Public
|
||
refresh() {
|
||
this._initializeTargetsAndObservables();
|
||
this._maybeEnableSmoothScroll();
|
||
if (this._observer) {
|
||
this._observer.disconnect();
|
||
} else {
|
||
this._observer = this._getNewObserver();
|
||
}
|
||
for (const section of this._observableSections.values()) {
|
||
this._observer.observe(section);
|
||
}
|
||
}
|
||
dispose() {
|
||
this._observer.disconnect();
|
||
super.dispose();
|
||
}
|
||
// Private
|
||
_configAfterMerge(config) {
|
||
config.target = getElement(config.target) || document.body;
|
||
config.rootMargin = config.offset ? `${config.offset}px 0px -30%` : config.rootMargin;
|
||
if (typeof config.threshold === "string") {
|
||
config.threshold = config.threshold.split(",").map((value) => Number.parseFloat(value));
|
||
}
|
||
return config;
|
||
}
|
||
_maybeEnableSmoothScroll() {
|
||
if (!this._config.smoothScroll) {
|
||
return;
|
||
}
|
||
EventHandler.off(this._config.target, EVENT_CLICK);
|
||
EventHandler.on(this._config.target, EVENT_CLICK, SELECTOR_TARGET_LINKS, (event) => {
|
||
const observableSection = this._observableSections.get(event.target.hash);
|
||
if (observableSection) {
|
||
event.preventDefault();
|
||
const root = this._rootElement || window;
|
||
const height = observableSection.offsetTop - this._element.offsetTop;
|
||
if (root.scrollTo) {
|
||
root.scrollTo({
|
||
top: height,
|
||
behavior: "smooth"
|
||
});
|
||
return;
|
||
}
|
||
root.scrollTop = height;
|
||
}
|
||
});
|
||
}
|
||
_getNewObserver() {
|
||
const options = {
|
||
root: this._rootElement,
|
||
threshold: this._config.threshold,
|
||
rootMargin: this._config.rootMargin
|
||
};
|
||
return new IntersectionObserver((entries) => this._observerCallback(entries), options);
|
||
}
|
||
// The logic of selection
|
||
_observerCallback(entries) {
|
||
const targetElement = (entry) => this._targetLinks.get(`#${entry.target.id}`);
|
||
const activate = (entry) => {
|
||
this._previousScrollData.visibleEntryTop = entry.target.offsetTop;
|
||
this._process(targetElement(entry));
|
||
};
|
||
const parentScrollTop = (this._rootElement || document.documentElement).scrollTop;
|
||
const userScrollsDown = parentScrollTop >= this._previousScrollData.parentScrollTop;
|
||
this._previousScrollData.parentScrollTop = parentScrollTop;
|
||
for (const entry of entries) {
|
||
if (!entry.isIntersecting) {
|
||
this._activeTarget = null;
|
||
this._clearActiveClass(targetElement(entry));
|
||
continue;
|
||
}
|
||
const entryIsLowerThanPrevious = entry.target.offsetTop >= this._previousScrollData.visibleEntryTop;
|
||
if (userScrollsDown && entryIsLowerThanPrevious) {
|
||
activate(entry);
|
||
if (!parentScrollTop) {
|
||
return;
|
||
}
|
||
continue;
|
||
}
|
||
if (!userScrollsDown && !entryIsLowerThanPrevious) {
|
||
activate(entry);
|
||
}
|
||
}
|
||
}
|
||
_initializeTargetsAndObservables() {
|
||
this._targetLinks = /* @__PURE__ */ new Map();
|
||
this._observableSections = /* @__PURE__ */ new Map();
|
||
const targetLinks = SelectorEngine.find(SELECTOR_TARGET_LINKS, this._config.target);
|
||
for (const anchor of targetLinks) {
|
||
if (!anchor.hash || isDisabled(anchor)) {
|
||
continue;
|
||
}
|
||
const observableSection = SelectorEngine.findOne(decodeURI(anchor.hash), this._element);
|
||
if (isVisible(observableSection)) {
|
||
this._targetLinks.set(decodeURI(anchor.hash), anchor);
|
||
this._observableSections.set(anchor.hash, observableSection);
|
||
}
|
||
}
|
||
}
|
||
_process(target) {
|
||
if (this._activeTarget === target) {
|
||
return;
|
||
}
|
||
this._clearActiveClass(this._config.target);
|
||
this._activeTarget = target;
|
||
target.classList.add(CLASS_NAME_ACTIVE$1);
|
||
this._activateParents(target);
|
||
EventHandler.trigger(this._element, EVENT_ACTIVATE, {
|
||
relatedTarget: target
|
||
});
|
||
}
|
||
_activateParents(target) {
|
||
if (target.classList.contains(CLASS_NAME_DROPDOWN_ITEM)) {
|
||
SelectorEngine.findOne(SELECTOR_DROPDOWN_TOGGLE$1, target.closest(SELECTOR_DROPDOWN)).classList.add(CLASS_NAME_ACTIVE$1);
|
||
return;
|
||
}
|
||
for (const listGroup of SelectorEngine.parents(target, SELECTOR_NAV_LIST_GROUP)) {
|
||
for (const item of SelectorEngine.prev(listGroup, SELECTOR_LINK_ITEMS)) {
|
||
item.classList.add(CLASS_NAME_ACTIVE$1);
|
||
}
|
||
}
|
||
}
|
||
_clearActiveClass(parent) {
|
||
parent.classList.remove(CLASS_NAME_ACTIVE$1);
|
||
const activeNodes = SelectorEngine.find(`${SELECTOR_TARGET_LINKS}.${CLASS_NAME_ACTIVE$1}`, parent);
|
||
for (const node of activeNodes) {
|
||
node.classList.remove(CLASS_NAME_ACTIVE$1);
|
||
}
|
||
}
|
||
// Static
|
||
static jQueryInterface(config) {
|
||
return this.each(function() {
|
||
const data = _ScrollSpy.getOrCreateInstance(this, config);
|
||
if (typeof config !== "string") {
|
||
return;
|
||
}
|
||
if (data[config] === void 0 || config.startsWith("_") || config === "constructor") {
|
||
throw new TypeError(`No method named "${config}"`);
|
||
}
|
||
data[config]();
|
||
});
|
||
}
|
||
};
|
||
EventHandler.on(window, EVENT_LOAD_DATA_API$1, () => {
|
||
for (const spy of SelectorEngine.find(SELECTOR_DATA_SPY)) {
|
||
ScrollSpy.getOrCreateInstance(spy);
|
||
}
|
||
});
|
||
defineJQueryPlugin(ScrollSpy);
|
||
var NAME$1 = "tab";
|
||
var DATA_KEY$1 = "bs.tab";
|
||
var EVENT_KEY$1 = `.${DATA_KEY$1}`;
|
||
var EVENT_HIDE$1 = `hide${EVENT_KEY$1}`;
|
||
var EVENT_HIDDEN$1 = `hidden${EVENT_KEY$1}`;
|
||
var EVENT_SHOW$1 = `show${EVENT_KEY$1}`;
|
||
var EVENT_SHOWN$1 = `shown${EVENT_KEY$1}`;
|
||
var EVENT_CLICK_DATA_API = `click${EVENT_KEY$1}`;
|
||
var EVENT_KEYDOWN = `keydown${EVENT_KEY$1}`;
|
||
var EVENT_LOAD_DATA_API = `load${EVENT_KEY$1}`;
|
||
var ARROW_LEFT_KEY = "ArrowLeft";
|
||
var ARROW_RIGHT_KEY = "ArrowRight";
|
||
var ARROW_UP_KEY = "ArrowUp";
|
||
var ARROW_DOWN_KEY = "ArrowDown";
|
||
var CLASS_NAME_ACTIVE = "active";
|
||
var CLASS_NAME_FADE$1 = "fade";
|
||
var CLASS_NAME_SHOW$1 = "show";
|
||
var CLASS_DROPDOWN = "dropdown";
|
||
var SELECTOR_DROPDOWN_TOGGLE = ".dropdown-toggle";
|
||
var SELECTOR_DROPDOWN_MENU = ".dropdown-menu";
|
||
var NOT_SELECTOR_DROPDOWN_TOGGLE = ":not(.dropdown-toggle)";
|
||
var SELECTOR_TAB_PANEL = '.list-group, .nav, [role="tablist"]';
|
||
var SELECTOR_OUTER = ".nav-item, .list-group-item";
|
||
var SELECTOR_INNER = `.nav-link${NOT_SELECTOR_DROPDOWN_TOGGLE}, .list-group-item${NOT_SELECTOR_DROPDOWN_TOGGLE}, [role="tab"]${NOT_SELECTOR_DROPDOWN_TOGGLE}`;
|
||
var SELECTOR_DATA_TOGGLE = '[data-bs-toggle="tab"], [data-bs-toggle="pill"], [data-bs-toggle="list"]';
|
||
var SELECTOR_INNER_ELEM = `${SELECTOR_INNER}, ${SELECTOR_DATA_TOGGLE}`;
|
||
var SELECTOR_DATA_TOGGLE_ACTIVE = `.${CLASS_NAME_ACTIVE}[data-bs-toggle="tab"], .${CLASS_NAME_ACTIVE}[data-bs-toggle="pill"], .${CLASS_NAME_ACTIVE}[data-bs-toggle="list"]`;
|
||
var Tab = class _Tab extends BaseComponent {
|
||
constructor(element) {
|
||
super(element);
|
||
this._parent = this._element.closest(SELECTOR_TAB_PANEL);
|
||
if (!this._parent) {
|
||
return;
|
||
}
|
||
this._setInitialAttributes(this._parent, this._getChildren());
|
||
EventHandler.on(this._element, EVENT_KEYDOWN, (event) => this._keydown(event));
|
||
}
|
||
// Getters
|
||
static get NAME() {
|
||
return NAME$1;
|
||
}
|
||
// Public
|
||
show() {
|
||
const innerElem = this._element;
|
||
if (this._elemIsActive(innerElem)) {
|
||
return;
|
||
}
|
||
const active = this._getActiveElem();
|
||
const hideEvent = active ? EventHandler.trigger(active, EVENT_HIDE$1, {
|
||
relatedTarget: innerElem
|
||
}) : null;
|
||
const showEvent = EventHandler.trigger(innerElem, EVENT_SHOW$1, {
|
||
relatedTarget: active
|
||
});
|
||
if (showEvent.defaultPrevented || hideEvent && hideEvent.defaultPrevented) {
|
||
return;
|
||
}
|
||
this._deactivate(active, innerElem);
|
||
this._activate(innerElem, active);
|
||
}
|
||
// Private
|
||
_activate(element, relatedElem) {
|
||
if (!element) {
|
||
return;
|
||
}
|
||
element.classList.add(CLASS_NAME_ACTIVE);
|
||
this._activate(SelectorEngine.getElementFromSelector(element));
|
||
const complete = () => {
|
||
if (element.getAttribute("role") !== "tab") {
|
||
element.classList.add(CLASS_NAME_SHOW$1);
|
||
return;
|
||
}
|
||
element.removeAttribute("tabindex");
|
||
element.setAttribute("aria-selected", true);
|
||
this._toggleDropDown(element, true);
|
||
EventHandler.trigger(element, EVENT_SHOWN$1, {
|
||
relatedTarget: relatedElem
|
||
});
|
||
};
|
||
this._queueCallback(complete, element, element.classList.contains(CLASS_NAME_FADE$1));
|
||
}
|
||
_deactivate(element, relatedElem) {
|
||
if (!element) {
|
||
return;
|
||
}
|
||
element.classList.remove(CLASS_NAME_ACTIVE);
|
||
element.blur();
|
||
this._deactivate(SelectorEngine.getElementFromSelector(element));
|
||
const complete = () => {
|
||
if (element.getAttribute("role") !== "tab") {
|
||
element.classList.remove(CLASS_NAME_SHOW$1);
|
||
return;
|
||
}
|
||
element.setAttribute("aria-selected", false);
|
||
element.setAttribute("tabindex", "-1");
|
||
this._toggleDropDown(element, false);
|
||
EventHandler.trigger(element, EVENT_HIDDEN$1, {
|
||
relatedTarget: relatedElem
|
||
});
|
||
};
|
||
this._queueCallback(complete, element, element.classList.contains(CLASS_NAME_FADE$1));
|
||
}
|
||
_keydown(event) {
|
||
if (![ARROW_LEFT_KEY, ARROW_RIGHT_KEY, ARROW_UP_KEY, ARROW_DOWN_KEY].includes(event.key)) {
|
||
return;
|
||
}
|
||
event.stopPropagation();
|
||
event.preventDefault();
|
||
const isNext = [ARROW_RIGHT_KEY, ARROW_DOWN_KEY].includes(event.key);
|
||
const nextActiveElement = getNextActiveElement(this._getChildren().filter((element) => !isDisabled(element)), event.target, isNext, true);
|
||
if (nextActiveElement) {
|
||
nextActiveElement.focus({
|
||
preventScroll: true
|
||
});
|
||
_Tab.getOrCreateInstance(nextActiveElement).show();
|
||
}
|
||
}
|
||
_getChildren() {
|
||
return SelectorEngine.find(SELECTOR_INNER_ELEM, this._parent);
|
||
}
|
||
_getActiveElem() {
|
||
return this._getChildren().find((child) => this._elemIsActive(child)) || null;
|
||
}
|
||
_setInitialAttributes(parent, children) {
|
||
this._setAttributeIfNotExists(parent, "role", "tablist");
|
||
for (const child of children) {
|
||
this._setInitialAttributesOnChild(child);
|
||
}
|
||
}
|
||
_setInitialAttributesOnChild(child) {
|
||
child = this._getInnerElement(child);
|
||
const isActive = this._elemIsActive(child);
|
||
const outerElem = this._getOuterElement(child);
|
||
child.setAttribute("aria-selected", isActive);
|
||
if (outerElem !== child) {
|
||
this._setAttributeIfNotExists(outerElem, "role", "presentation");
|
||
}
|
||
if (!isActive) {
|
||
child.setAttribute("tabindex", "-1");
|
||
}
|
||
this._setAttributeIfNotExists(child, "role", "tab");
|
||
this._setInitialAttributesOnTargetPanel(child);
|
||
}
|
||
_setInitialAttributesOnTargetPanel(child) {
|
||
const target = SelectorEngine.getElementFromSelector(child);
|
||
if (!target) {
|
||
return;
|
||
}
|
||
this._setAttributeIfNotExists(target, "role", "tabpanel");
|
||
if (child.id) {
|
||
this._setAttributeIfNotExists(target, "aria-labelledby", `${child.id}`);
|
||
}
|
||
}
|
||
_toggleDropDown(element, open) {
|
||
const outerElem = this._getOuterElement(element);
|
||
if (!outerElem.classList.contains(CLASS_DROPDOWN)) {
|
||
return;
|
||
}
|
||
const toggle = (selector, className) => {
|
||
const element2 = SelectorEngine.findOne(selector, outerElem);
|
||
if (element2) {
|
||
element2.classList.toggle(className, open);
|
||
}
|
||
};
|
||
toggle(SELECTOR_DROPDOWN_TOGGLE, CLASS_NAME_ACTIVE);
|
||
toggle(SELECTOR_DROPDOWN_MENU, CLASS_NAME_SHOW$1);
|
||
outerElem.setAttribute("aria-expanded", open);
|
||
}
|
||
_setAttributeIfNotExists(element, attribute, value) {
|
||
if (!element.hasAttribute(attribute)) {
|
||
element.setAttribute(attribute, value);
|
||
}
|
||
}
|
||
_elemIsActive(elem) {
|
||
return elem.classList.contains(CLASS_NAME_ACTIVE);
|
||
}
|
||
// Try to get the inner element (usually the .nav-link)
|
||
_getInnerElement(elem) {
|
||
return elem.matches(SELECTOR_INNER_ELEM) ? elem : SelectorEngine.findOne(SELECTOR_INNER_ELEM, elem);
|
||
}
|
||
// Try to get the outer element (usually the .nav-item)
|
||
_getOuterElement(elem) {
|
||
return elem.closest(SELECTOR_OUTER) || elem;
|
||
}
|
||
// Static
|
||
static jQueryInterface(config) {
|
||
return this.each(function() {
|
||
const data = _Tab.getOrCreateInstance(this);
|
||
if (typeof config !== "string") {
|
||
return;
|
||
}
|
||
if (data[config] === void 0 || config.startsWith("_") || config === "constructor") {
|
||
throw new TypeError(`No method named "${config}"`);
|
||
}
|
||
data[config]();
|
||
});
|
||
}
|
||
};
|
||
EventHandler.on(document, EVENT_CLICK_DATA_API, SELECTOR_DATA_TOGGLE, function(event) {
|
||
if (["A", "AREA"].includes(this.tagName)) {
|
||
event.preventDefault();
|
||
}
|
||
if (isDisabled(this)) {
|
||
return;
|
||
}
|
||
Tab.getOrCreateInstance(this).show();
|
||
});
|
||
EventHandler.on(window, EVENT_LOAD_DATA_API, () => {
|
||
for (const element of SelectorEngine.find(SELECTOR_DATA_TOGGLE_ACTIVE)) {
|
||
Tab.getOrCreateInstance(element);
|
||
}
|
||
});
|
||
defineJQueryPlugin(Tab);
|
||
var NAME = "toast";
|
||
var DATA_KEY = "bs.toast";
|
||
var EVENT_KEY = `.${DATA_KEY}`;
|
||
var EVENT_MOUSEOVER = `mouseover${EVENT_KEY}`;
|
||
var EVENT_MOUSEOUT = `mouseout${EVENT_KEY}`;
|
||
var EVENT_FOCUSIN = `focusin${EVENT_KEY}`;
|
||
var EVENT_FOCUSOUT = `focusout${EVENT_KEY}`;
|
||
var EVENT_HIDE = `hide${EVENT_KEY}`;
|
||
var EVENT_HIDDEN = `hidden${EVENT_KEY}`;
|
||
var EVENT_SHOW = `show${EVENT_KEY}`;
|
||
var EVENT_SHOWN = `shown${EVENT_KEY}`;
|
||
var CLASS_NAME_FADE = "fade";
|
||
var CLASS_NAME_HIDE = "hide";
|
||
var CLASS_NAME_SHOW = "show";
|
||
var CLASS_NAME_SHOWING = "showing";
|
||
var DefaultType = {
|
||
animation: "boolean",
|
||
autohide: "boolean",
|
||
delay: "number"
|
||
};
|
||
var Default = {
|
||
animation: true,
|
||
autohide: true,
|
||
delay: 5e3
|
||
};
|
||
var Toast = class _Toast extends BaseComponent {
|
||
constructor(element, config) {
|
||
super(element, config);
|
||
this._timeout = null;
|
||
this._hasMouseInteraction = false;
|
||
this._hasKeyboardInteraction = false;
|
||
this._setListeners();
|
||
}
|
||
// Getters
|
||
static get Default() {
|
||
return Default;
|
||
}
|
||
static get DefaultType() {
|
||
return DefaultType;
|
||
}
|
||
static get NAME() {
|
||
return NAME;
|
||
}
|
||
// Public
|
||
show() {
|
||
const showEvent = EventHandler.trigger(this._element, EVENT_SHOW);
|
||
if (showEvent.defaultPrevented) {
|
||
return;
|
||
}
|
||
this._clearTimeout();
|
||
if (this._config.animation) {
|
||
this._element.classList.add(CLASS_NAME_FADE);
|
||
}
|
||
const complete = () => {
|
||
this._element.classList.remove(CLASS_NAME_SHOWING);
|
||
EventHandler.trigger(this._element, EVENT_SHOWN);
|
||
this._maybeScheduleHide();
|
||
};
|
||
this._element.classList.remove(CLASS_NAME_HIDE);
|
||
reflow(this._element);
|
||
this._element.classList.add(CLASS_NAME_SHOW, CLASS_NAME_SHOWING);
|
||
this._queueCallback(complete, this._element, this._config.animation);
|
||
}
|
||
hide() {
|
||
if (!this.isShown()) {
|
||
return;
|
||
}
|
||
const hideEvent = EventHandler.trigger(this._element, EVENT_HIDE);
|
||
if (hideEvent.defaultPrevented) {
|
||
return;
|
||
}
|
||
const complete = () => {
|
||
this._element.classList.add(CLASS_NAME_HIDE);
|
||
this._element.classList.remove(CLASS_NAME_SHOWING, CLASS_NAME_SHOW);
|
||
EventHandler.trigger(this._element, EVENT_HIDDEN);
|
||
};
|
||
this._element.classList.add(CLASS_NAME_SHOWING);
|
||
this._queueCallback(complete, this._element, this._config.animation);
|
||
}
|
||
dispose() {
|
||
this._clearTimeout();
|
||
if (this.isShown()) {
|
||
this._element.classList.remove(CLASS_NAME_SHOW);
|
||
}
|
||
super.dispose();
|
||
}
|
||
isShown() {
|
||
return this._element.classList.contains(CLASS_NAME_SHOW);
|
||
}
|
||
// Private
|
||
_maybeScheduleHide() {
|
||
if (!this._config.autohide) {
|
||
return;
|
||
}
|
||
if (this._hasMouseInteraction || this._hasKeyboardInteraction) {
|
||
return;
|
||
}
|
||
this._timeout = setTimeout(() => {
|
||
this.hide();
|
||
}, this._config.delay);
|
||
}
|
||
_onInteraction(event, isInteracting) {
|
||
switch (event.type) {
|
||
case "mouseover":
|
||
case "mouseout": {
|
||
this._hasMouseInteraction = isInteracting;
|
||
break;
|
||
}
|
||
case "focusin":
|
||
case "focusout": {
|
||
this._hasKeyboardInteraction = isInteracting;
|
||
break;
|
||
}
|
||
}
|
||
if (isInteracting) {
|
||
this._clearTimeout();
|
||
return;
|
||
}
|
||
const nextElement = event.relatedTarget;
|
||
if (this._element === nextElement || this._element.contains(nextElement)) {
|
||
return;
|
||
}
|
||
this._maybeScheduleHide();
|
||
}
|
||
_setListeners() {
|
||
EventHandler.on(this._element, EVENT_MOUSEOVER, (event) => this._onInteraction(event, true));
|
||
EventHandler.on(this._element, EVENT_MOUSEOUT, (event) => this._onInteraction(event, false));
|
||
EventHandler.on(this._element, EVENT_FOCUSIN, (event) => this._onInteraction(event, true));
|
||
EventHandler.on(this._element, EVENT_FOCUSOUT, (event) => this._onInteraction(event, false));
|
||
}
|
||
_clearTimeout() {
|
||
clearTimeout(this._timeout);
|
||
this._timeout = null;
|
||
}
|
||
// Static
|
||
static jQueryInterface(config) {
|
||
return this.each(function() {
|
||
const data = _Toast.getOrCreateInstance(this, config);
|
||
if (typeof config === "string") {
|
||
if (typeof data[config] === "undefined") {
|
||
throw new TypeError(`No method named "${config}"`);
|
||
}
|
||
data[config](this);
|
||
}
|
||
});
|
||
}
|
||
};
|
||
enableDismissTrigger(Toast);
|
||
defineJQueryPlugin(Toast);
|
||
|
||
// app/javascript/overview.js
|
||
function initializeListenersForNavDropdowns() {
|
||
const schoolDropdown = document.querySelector("#select-school");
|
||
if (schoolDropdown) {
|
||
document.querySelector("#select-school").addEventListener("change", (event) => {
|
||
window.location = event.target.value;
|
||
});
|
||
document.querySelector("#select-district").addEventListener("change", (event) => {
|
||
window.location = event.target.value;
|
||
});
|
||
}
|
||
const academicYearDropdown = document.querySelector("#select-academic-year");
|
||
if (academicYearDropdown) {
|
||
academicYearDropdown.addEventListener("change", (event) => {
|
||
window.location = event.target.value;
|
||
});
|
||
}
|
||
}
|
||
function initializePopovers() {
|
||
document.querySelectorAll('[data-bs-toggle="popover"]').forEach((popoverElement) => {
|
||
new Popover(popoverElement, { trigger: "hover focus" });
|
||
});
|
||
}
|
||
|
||
// app/javascript/modal.js
|
||
function showEmptyDatasetModal() {
|
||
const modal = document.querySelector(".modal");
|
||
if (modal) {
|
||
new Modal(modal).show();
|
||
}
|
||
}
|
||
|
||
// node_modules/@hotwired/turbo/dist/turbo.es2017-esm.js
|
||
(function() {
|
||
if (window.Reflect === void 0 || window.customElements === void 0 || window.customElements.polyfillWrapFlushCallback) {
|
||
return;
|
||
}
|
||
const BuiltInHTMLElement = HTMLElement;
|
||
const wrapperForTheName = {
|
||
HTMLElement: function HTMLElement2() {
|
||
return Reflect.construct(BuiltInHTMLElement, [], this.constructor);
|
||
}
|
||
};
|
||
window.HTMLElement = wrapperForTheName["HTMLElement"];
|
||
HTMLElement.prototype = BuiltInHTMLElement.prototype;
|
||
HTMLElement.prototype.constructor = HTMLElement;
|
||
Object.setPrototypeOf(HTMLElement, BuiltInHTMLElement);
|
||
})();
|
||
(function(prototype) {
|
||
if (typeof prototype.requestSubmit == "function")
|
||
return;
|
||
prototype.requestSubmit = function(submitter) {
|
||
if (submitter) {
|
||
validateSubmitter(submitter, this);
|
||
submitter.click();
|
||
} else {
|
||
submitter = document.createElement("input");
|
||
submitter.type = "submit";
|
||
submitter.hidden = true;
|
||
this.appendChild(submitter);
|
||
submitter.click();
|
||
this.removeChild(submitter);
|
||
}
|
||
};
|
||
function validateSubmitter(submitter, form) {
|
||
submitter instanceof HTMLElement || raise(TypeError, "parameter 1 is not of type 'HTMLElement'");
|
||
submitter.type == "submit" || raise(TypeError, "The specified element is not a submit button");
|
||
submitter.form == form || raise(DOMException, "The specified element is not owned by this form element", "NotFoundError");
|
||
}
|
||
function raise(errorConstructor, message, name) {
|
||
throw new errorConstructor("Failed to execute 'requestSubmit' on 'HTMLFormElement': " + message + ".", name);
|
||
}
|
||
})(HTMLFormElement.prototype);
|
||
var submittersByForm = /* @__PURE__ */ new WeakMap();
|
||
function findSubmitterFromClickTarget(target) {
|
||
const element = target instanceof Element ? target : target instanceof Node ? target.parentElement : null;
|
||
const candidate = element ? element.closest("input, button") : null;
|
||
return (candidate === null || candidate === void 0 ? void 0 : candidate.type) == "submit" ? candidate : null;
|
||
}
|
||
function clickCaptured(event) {
|
||
const submitter = findSubmitterFromClickTarget(event.target);
|
||
if (submitter && submitter.form) {
|
||
submittersByForm.set(submitter.form, submitter);
|
||
}
|
||
}
|
||
(function() {
|
||
if ("submitter" in Event.prototype)
|
||
return;
|
||
let prototype = window.Event.prototype;
|
||
if ("SubmitEvent" in window && /Apple Computer/.test(navigator.vendor)) {
|
||
prototype = window.SubmitEvent.prototype;
|
||
} else if ("SubmitEvent" in window) {
|
||
return;
|
||
}
|
||
addEventListener("click", clickCaptured, true);
|
||
Object.defineProperty(prototype, "submitter", {
|
||
get() {
|
||
if (this.type == "submit" && this.target instanceof HTMLFormElement) {
|
||
return submittersByForm.get(this.target);
|
||
}
|
||
}
|
||
});
|
||
})();
|
||
var FrameLoadingStyle;
|
||
(function(FrameLoadingStyle2) {
|
||
FrameLoadingStyle2["eager"] = "eager";
|
||
FrameLoadingStyle2["lazy"] = "lazy";
|
||
})(FrameLoadingStyle || (FrameLoadingStyle = {}));
|
||
var FrameElement = class _FrameElement extends HTMLElement {
|
||
static get observedAttributes() {
|
||
return ["disabled", "complete", "loading", "src"];
|
||
}
|
||
constructor() {
|
||
super();
|
||
this.loaded = Promise.resolve();
|
||
this.delegate = new _FrameElement.delegateConstructor(this);
|
||
}
|
||
connectedCallback() {
|
||
this.delegate.connect();
|
||
}
|
||
disconnectedCallback() {
|
||
this.delegate.disconnect();
|
||
}
|
||
reload() {
|
||
return this.delegate.sourceURLReloaded();
|
||
}
|
||
attributeChangedCallback(name) {
|
||
if (name == "loading") {
|
||
this.delegate.loadingStyleChanged();
|
||
} else if (name == "complete") {
|
||
this.delegate.completeChanged();
|
||
} else if (name == "src") {
|
||
this.delegate.sourceURLChanged();
|
||
} else {
|
||
this.delegate.disabledChanged();
|
||
}
|
||
}
|
||
get src() {
|
||
return this.getAttribute("src");
|
||
}
|
||
set src(value) {
|
||
if (value) {
|
||
this.setAttribute("src", value);
|
||
} else {
|
||
this.removeAttribute("src");
|
||
}
|
||
}
|
||
get loading() {
|
||
return frameLoadingStyleFromString(this.getAttribute("loading") || "");
|
||
}
|
||
set loading(value) {
|
||
if (value) {
|
||
this.setAttribute("loading", value);
|
||
} else {
|
||
this.removeAttribute("loading");
|
||
}
|
||
}
|
||
get disabled() {
|
||
return this.hasAttribute("disabled");
|
||
}
|
||
set disabled(value) {
|
||
if (value) {
|
||
this.setAttribute("disabled", "");
|
||
} else {
|
||
this.removeAttribute("disabled");
|
||
}
|
||
}
|
||
get autoscroll() {
|
||
return this.hasAttribute("autoscroll");
|
||
}
|
||
set autoscroll(value) {
|
||
if (value) {
|
||
this.setAttribute("autoscroll", "");
|
||
} else {
|
||
this.removeAttribute("autoscroll");
|
||
}
|
||
}
|
||
get complete() {
|
||
return !this.delegate.isLoading;
|
||
}
|
||
get isActive() {
|
||
return this.ownerDocument === document && !this.isPreview;
|
||
}
|
||
get isPreview() {
|
||
var _a, _b;
|
||
return (_b = (_a = this.ownerDocument) === null || _a === void 0 ? void 0 : _a.documentElement) === null || _b === void 0 ? void 0 : _b.hasAttribute("data-turbo-preview");
|
||
}
|
||
};
|
||
function frameLoadingStyleFromString(style) {
|
||
switch (style.toLowerCase()) {
|
||
case "lazy":
|
||
return FrameLoadingStyle.lazy;
|
||
default:
|
||
return FrameLoadingStyle.eager;
|
||
}
|
||
}
|
||
function expandURL(locatable) {
|
||
return new URL(locatable.toString(), document.baseURI);
|
||
}
|
||
function getAnchor(url) {
|
||
let anchorMatch;
|
||
if (url.hash) {
|
||
return url.hash.slice(1);
|
||
} else if (anchorMatch = url.href.match(/#(.*)$/)) {
|
||
return anchorMatch[1];
|
||
}
|
||
}
|
||
function getAction(form, submitter) {
|
||
const action = (submitter === null || submitter === void 0 ? void 0 : submitter.getAttribute("formaction")) || form.getAttribute("action") || form.action;
|
||
return expandURL(action);
|
||
}
|
||
function getExtension(url) {
|
||
return (getLastPathComponent(url).match(/\.[^.]*$/) || [])[0] || "";
|
||
}
|
||
function isHTML(url) {
|
||
return !!getExtension(url).match(/^(?:|\.(?:htm|html|xhtml|php))$/);
|
||
}
|
||
function isPrefixedBy(baseURL, url) {
|
||
const prefix = getPrefix(url);
|
||
return baseURL.href === expandURL(prefix).href || baseURL.href.startsWith(prefix);
|
||
}
|
||
function locationIsVisitable(location2, rootLocation) {
|
||
return isPrefixedBy(location2, rootLocation) && isHTML(location2);
|
||
}
|
||
function getRequestURL(url) {
|
||
const anchor = getAnchor(url);
|
||
return anchor != null ? url.href.slice(0, -(anchor.length + 1)) : url.href;
|
||
}
|
||
function toCacheKey(url) {
|
||
return getRequestURL(url);
|
||
}
|
||
function urlsAreEqual(left2, right2) {
|
||
return expandURL(left2).href == expandURL(right2).href;
|
||
}
|
||
function getPathComponents(url) {
|
||
return url.pathname.split("/").slice(1);
|
||
}
|
||
function getLastPathComponent(url) {
|
||
return getPathComponents(url).slice(-1)[0];
|
||
}
|
||
function getPrefix(url) {
|
||
return addTrailingSlash(url.origin + url.pathname);
|
||
}
|
||
function addTrailingSlash(value) {
|
||
return value.endsWith("/") ? value : value + "/";
|
||
}
|
||
var FetchResponse = class {
|
||
constructor(response) {
|
||
this.response = response;
|
||
}
|
||
get succeeded() {
|
||
return this.response.ok;
|
||
}
|
||
get failed() {
|
||
return !this.succeeded;
|
||
}
|
||
get clientError() {
|
||
return this.statusCode >= 400 && this.statusCode <= 499;
|
||
}
|
||
get serverError() {
|
||
return this.statusCode >= 500 && this.statusCode <= 599;
|
||
}
|
||
get redirected() {
|
||
return this.response.redirected;
|
||
}
|
||
get location() {
|
||
return expandURL(this.response.url);
|
||
}
|
||
get isHTML() {
|
||
return this.contentType && this.contentType.match(/^(?:text\/([^\s;,]+\b)?html|application\/xhtml\+xml)\b/);
|
||
}
|
||
get statusCode() {
|
||
return this.response.status;
|
||
}
|
||
get contentType() {
|
||
return this.header("Content-Type");
|
||
}
|
||
get responseText() {
|
||
return this.response.clone().text();
|
||
}
|
||
get responseHTML() {
|
||
if (this.isHTML) {
|
||
return this.response.clone().text();
|
||
} else {
|
||
return Promise.resolve(void 0);
|
||
}
|
||
}
|
||
header(name) {
|
||
return this.response.headers.get(name);
|
||
}
|
||
};
|
||
function activateScriptElement(element) {
|
||
if (element.getAttribute("data-turbo-eval") == "false") {
|
||
return element;
|
||
} else {
|
||
const createdScriptElement = document.createElement("script");
|
||
const cspNonce = getMetaContent("csp-nonce");
|
||
if (cspNonce) {
|
||
createdScriptElement.nonce = cspNonce;
|
||
}
|
||
createdScriptElement.textContent = element.textContent;
|
||
createdScriptElement.async = false;
|
||
copyElementAttributes(createdScriptElement, element);
|
||
return createdScriptElement;
|
||
}
|
||
}
|
||
function copyElementAttributes(destinationElement, sourceElement) {
|
||
for (const { name, value } of sourceElement.attributes) {
|
||
destinationElement.setAttribute(name, value);
|
||
}
|
||
}
|
||
function createDocumentFragment(html) {
|
||
const template = document.createElement("template");
|
||
template.innerHTML = html;
|
||
return template.content;
|
||
}
|
||
function dispatch(eventName, { target, cancelable, detail } = {}) {
|
||
const event = new CustomEvent(eventName, {
|
||
cancelable,
|
||
bubbles: true,
|
||
composed: true,
|
||
detail
|
||
});
|
||
if (target && target.isConnected) {
|
||
target.dispatchEvent(event);
|
||
} else {
|
||
document.documentElement.dispatchEvent(event);
|
||
}
|
||
return event;
|
||
}
|
||
function nextAnimationFrame() {
|
||
return new Promise((resolve) => requestAnimationFrame(() => resolve()));
|
||
}
|
||
function nextEventLoopTick() {
|
||
return new Promise((resolve) => setTimeout(() => resolve(), 0));
|
||
}
|
||
function nextMicrotask() {
|
||
return Promise.resolve();
|
||
}
|
||
function parseHTMLDocument(html = "") {
|
||
return new DOMParser().parseFromString(html, "text/html");
|
||
}
|
||
function unindent(strings, ...values) {
|
||
const lines = interpolate(strings, values).replace(/^\n/, "").split("\n");
|
||
const match = lines[0].match(/^\s+/);
|
||
const indent = match ? match[0].length : 0;
|
||
return lines.map((line) => line.slice(indent)).join("\n");
|
||
}
|
||
function interpolate(strings, values) {
|
||
return strings.reduce((result, string, i) => {
|
||
const value = values[i] == void 0 ? "" : values[i];
|
||
return result + string + value;
|
||
}, "");
|
||
}
|
||
function uuid() {
|
||
return Array.from({ length: 36 }).map((_, i) => {
|
||
if (i == 8 || i == 13 || i == 18 || i == 23) {
|
||
return "-";
|
||
} else if (i == 14) {
|
||
return "4";
|
||
} else if (i == 19) {
|
||
return (Math.floor(Math.random() * 4) + 8).toString(16);
|
||
} else {
|
||
return Math.floor(Math.random() * 15).toString(16);
|
||
}
|
||
}).join("");
|
||
}
|
||
function getAttribute(attributeName, ...elements) {
|
||
for (const value of elements.map((element) => element === null || element === void 0 ? void 0 : element.getAttribute(attributeName))) {
|
||
if (typeof value == "string")
|
||
return value;
|
||
}
|
||
return null;
|
||
}
|
||
function hasAttribute(attributeName, ...elements) {
|
||
return elements.some((element) => element && element.hasAttribute(attributeName));
|
||
}
|
||
function markAsBusy(...elements) {
|
||
for (const element of elements) {
|
||
if (element.localName == "turbo-frame") {
|
||
element.setAttribute("busy", "");
|
||
}
|
||
element.setAttribute("aria-busy", "true");
|
||
}
|
||
}
|
||
function clearBusyState(...elements) {
|
||
for (const element of elements) {
|
||
if (element.localName == "turbo-frame") {
|
||
element.removeAttribute("busy");
|
||
}
|
||
element.removeAttribute("aria-busy");
|
||
}
|
||
}
|
||
function waitForLoad(element, timeoutInMilliseconds = 2e3) {
|
||
return new Promise((resolve) => {
|
||
const onComplete = () => {
|
||
element.removeEventListener("error", onComplete);
|
||
element.removeEventListener("load", onComplete);
|
||
resolve();
|
||
};
|
||
element.addEventListener("load", onComplete, { once: true });
|
||
element.addEventListener("error", onComplete, { once: true });
|
||
setTimeout(resolve, timeoutInMilliseconds);
|
||
});
|
||
}
|
||
function getHistoryMethodForAction(action) {
|
||
switch (action) {
|
||
case "replace":
|
||
return history.replaceState;
|
||
case "advance":
|
||
case "restore":
|
||
return history.pushState;
|
||
}
|
||
}
|
||
function isAction(action) {
|
||
return action == "advance" || action == "replace" || action == "restore";
|
||
}
|
||
function getVisitAction(...elements) {
|
||
const action = getAttribute("data-turbo-action", ...elements);
|
||
return isAction(action) ? action : null;
|
||
}
|
||
function getMetaElement(name) {
|
||
return document.querySelector(`meta[name="${name}"]`);
|
||
}
|
||
function getMetaContent(name) {
|
||
const element = getMetaElement(name);
|
||
return element && element.content;
|
||
}
|
||
function setMetaContent(name, content) {
|
||
let element = getMetaElement(name);
|
||
if (!element) {
|
||
element = document.createElement("meta");
|
||
element.setAttribute("name", name);
|
||
document.head.appendChild(element);
|
||
}
|
||
element.setAttribute("content", content);
|
||
return element;
|
||
}
|
||
function findClosestRecursively(element, selector) {
|
||
var _a;
|
||
if (element instanceof Element) {
|
||
return element.closest(selector) || findClosestRecursively(element.assignedSlot || ((_a = element.getRootNode()) === null || _a === void 0 ? void 0 : _a.host), selector);
|
||
}
|
||
}
|
||
var FetchMethod;
|
||
(function(FetchMethod2) {
|
||
FetchMethod2[FetchMethod2["get"] = 0] = "get";
|
||
FetchMethod2[FetchMethod2["post"] = 1] = "post";
|
||
FetchMethod2[FetchMethod2["put"] = 2] = "put";
|
||
FetchMethod2[FetchMethod2["patch"] = 3] = "patch";
|
||
FetchMethod2[FetchMethod2["delete"] = 4] = "delete";
|
||
})(FetchMethod || (FetchMethod = {}));
|
||
function fetchMethodFromString(method) {
|
||
switch (method.toLowerCase()) {
|
||
case "get":
|
||
return FetchMethod.get;
|
||
case "post":
|
||
return FetchMethod.post;
|
||
case "put":
|
||
return FetchMethod.put;
|
||
case "patch":
|
||
return FetchMethod.patch;
|
||
case "delete":
|
||
return FetchMethod.delete;
|
||
}
|
||
}
|
||
var FetchRequest = class {
|
||
constructor(delegate, method, location2, body = new URLSearchParams(), target = null) {
|
||
this.abortController = new AbortController();
|
||
this.resolveRequestPromise = (_value) => {
|
||
};
|
||
this.delegate = delegate;
|
||
this.method = method;
|
||
this.headers = this.defaultHeaders;
|
||
this.body = body;
|
||
this.url = location2;
|
||
this.target = target;
|
||
}
|
||
get location() {
|
||
return this.url;
|
||
}
|
||
get params() {
|
||
return this.url.searchParams;
|
||
}
|
||
get entries() {
|
||
return this.body ? Array.from(this.body.entries()) : [];
|
||
}
|
||
cancel() {
|
||
this.abortController.abort();
|
||
}
|
||
async perform() {
|
||
const { fetchOptions } = this;
|
||
this.delegate.prepareRequest(this);
|
||
await this.allowRequestToBeIntercepted(fetchOptions);
|
||
try {
|
||
this.delegate.requestStarted(this);
|
||
const response = await fetch(this.url.href, fetchOptions);
|
||
return await this.receive(response);
|
||
} catch (error2) {
|
||
if (error2.name !== "AbortError") {
|
||
if (this.willDelegateErrorHandling(error2)) {
|
||
this.delegate.requestErrored(this, error2);
|
||
}
|
||
throw error2;
|
||
}
|
||
} finally {
|
||
this.delegate.requestFinished(this);
|
||
}
|
||
}
|
||
async receive(response) {
|
||
const fetchResponse = new FetchResponse(response);
|
||
const event = dispatch("turbo:before-fetch-response", {
|
||
cancelable: true,
|
||
detail: { fetchResponse },
|
||
target: this.target
|
||
});
|
||
if (event.defaultPrevented) {
|
||
this.delegate.requestPreventedHandlingResponse(this, fetchResponse);
|
||
} else if (fetchResponse.succeeded) {
|
||
this.delegate.requestSucceededWithResponse(this, fetchResponse);
|
||
} else {
|
||
this.delegate.requestFailedWithResponse(this, fetchResponse);
|
||
}
|
||
return fetchResponse;
|
||
}
|
||
get fetchOptions() {
|
||
var _a;
|
||
return {
|
||
method: FetchMethod[this.method].toUpperCase(),
|
||
credentials: "same-origin",
|
||
headers: this.headers,
|
||
redirect: "follow",
|
||
body: this.isSafe ? null : this.body,
|
||
signal: this.abortSignal,
|
||
referrer: (_a = this.delegate.referrer) === null || _a === void 0 ? void 0 : _a.href
|
||
};
|
||
}
|
||
get defaultHeaders() {
|
||
return {
|
||
Accept: "text/html, application/xhtml+xml"
|
||
};
|
||
}
|
||
get isSafe() {
|
||
return this.method === FetchMethod.get;
|
||
}
|
||
get abortSignal() {
|
||
return this.abortController.signal;
|
||
}
|
||
acceptResponseType(mimeType) {
|
||
this.headers["Accept"] = [mimeType, this.headers["Accept"]].join(", ");
|
||
}
|
||
async allowRequestToBeIntercepted(fetchOptions) {
|
||
const requestInterception = new Promise((resolve) => this.resolveRequestPromise = resolve);
|
||
const event = dispatch("turbo:before-fetch-request", {
|
||
cancelable: true,
|
||
detail: {
|
||
fetchOptions,
|
||
url: this.url,
|
||
resume: this.resolveRequestPromise
|
||
},
|
||
target: this.target
|
||
});
|
||
if (event.defaultPrevented)
|
||
await requestInterception;
|
||
}
|
||
willDelegateErrorHandling(error2) {
|
||
const event = dispatch("turbo:fetch-request-error", {
|
||
target: this.target,
|
||
cancelable: true,
|
||
detail: { request: this, error: error2 }
|
||
});
|
||
return !event.defaultPrevented;
|
||
}
|
||
};
|
||
var AppearanceObserver = class {
|
||
constructor(delegate, element) {
|
||
this.started = false;
|
||
this.intersect = (entries) => {
|
||
const lastEntry = entries.slice(-1)[0];
|
||
if (lastEntry === null || lastEntry === void 0 ? void 0 : lastEntry.isIntersecting) {
|
||
this.delegate.elementAppearedInViewport(this.element);
|
||
}
|
||
};
|
||
this.delegate = delegate;
|
||
this.element = element;
|
||
this.intersectionObserver = new IntersectionObserver(this.intersect);
|
||
}
|
||
start() {
|
||
if (!this.started) {
|
||
this.started = true;
|
||
this.intersectionObserver.observe(this.element);
|
||
}
|
||
}
|
||
stop() {
|
||
if (this.started) {
|
||
this.started = false;
|
||
this.intersectionObserver.unobserve(this.element);
|
||
}
|
||
}
|
||
};
|
||
var StreamMessage = class {
|
||
static wrap(message) {
|
||
if (typeof message == "string") {
|
||
return new this(createDocumentFragment(message));
|
||
} else {
|
||
return message;
|
||
}
|
||
}
|
||
constructor(fragment) {
|
||
this.fragment = importStreamElements(fragment);
|
||
}
|
||
};
|
||
StreamMessage.contentType = "text/vnd.turbo-stream.html";
|
||
function importStreamElements(fragment) {
|
||
for (const element of fragment.querySelectorAll("turbo-stream")) {
|
||
const streamElement = document.importNode(element, true);
|
||
for (const inertScriptElement of streamElement.templateElement.content.querySelectorAll("script")) {
|
||
inertScriptElement.replaceWith(activateScriptElement(inertScriptElement));
|
||
}
|
||
element.replaceWith(streamElement);
|
||
}
|
||
return fragment;
|
||
}
|
||
var FormSubmissionState;
|
||
(function(FormSubmissionState2) {
|
||
FormSubmissionState2[FormSubmissionState2["initialized"] = 0] = "initialized";
|
||
FormSubmissionState2[FormSubmissionState2["requesting"] = 1] = "requesting";
|
||
FormSubmissionState2[FormSubmissionState2["waiting"] = 2] = "waiting";
|
||
FormSubmissionState2[FormSubmissionState2["receiving"] = 3] = "receiving";
|
||
FormSubmissionState2[FormSubmissionState2["stopping"] = 4] = "stopping";
|
||
FormSubmissionState2[FormSubmissionState2["stopped"] = 5] = "stopped";
|
||
})(FormSubmissionState || (FormSubmissionState = {}));
|
||
var FormEnctype;
|
||
(function(FormEnctype2) {
|
||
FormEnctype2["urlEncoded"] = "application/x-www-form-urlencoded";
|
||
FormEnctype2["multipart"] = "multipart/form-data";
|
||
FormEnctype2["plain"] = "text/plain";
|
||
})(FormEnctype || (FormEnctype = {}));
|
||
function formEnctypeFromString(encoding) {
|
||
switch (encoding.toLowerCase()) {
|
||
case FormEnctype.multipart:
|
||
return FormEnctype.multipart;
|
||
case FormEnctype.plain:
|
||
return FormEnctype.plain;
|
||
default:
|
||
return FormEnctype.urlEncoded;
|
||
}
|
||
}
|
||
var FormSubmission = class _FormSubmission {
|
||
static confirmMethod(message, _element, _submitter) {
|
||
return Promise.resolve(confirm(message));
|
||
}
|
||
constructor(delegate, formElement, submitter, mustRedirect = false) {
|
||
this.state = FormSubmissionState.initialized;
|
||
this.delegate = delegate;
|
||
this.formElement = formElement;
|
||
this.submitter = submitter;
|
||
this.formData = buildFormData(formElement, submitter);
|
||
this.location = expandURL(this.action);
|
||
if (this.method == FetchMethod.get) {
|
||
mergeFormDataEntries(this.location, [...this.body.entries()]);
|
||
}
|
||
this.fetchRequest = new FetchRequest(this, this.method, this.location, this.body, this.formElement);
|
||
this.mustRedirect = mustRedirect;
|
||
}
|
||
get method() {
|
||
var _a;
|
||
const method = ((_a = this.submitter) === null || _a === void 0 ? void 0 : _a.getAttribute("formmethod")) || this.formElement.getAttribute("method") || "";
|
||
return fetchMethodFromString(method.toLowerCase()) || FetchMethod.get;
|
||
}
|
||
get action() {
|
||
var _a;
|
||
const formElementAction = typeof this.formElement.action === "string" ? this.formElement.action : null;
|
||
if ((_a = this.submitter) === null || _a === void 0 ? void 0 : _a.hasAttribute("formaction")) {
|
||
return this.submitter.getAttribute("formaction") || "";
|
||
} else {
|
||
return this.formElement.getAttribute("action") || formElementAction || "";
|
||
}
|
||
}
|
||
get body() {
|
||
if (this.enctype == FormEnctype.urlEncoded || this.method == FetchMethod.get) {
|
||
return new URLSearchParams(this.stringFormData);
|
||
} else {
|
||
return this.formData;
|
||
}
|
||
}
|
||
get enctype() {
|
||
var _a;
|
||
return formEnctypeFromString(((_a = this.submitter) === null || _a === void 0 ? void 0 : _a.getAttribute("formenctype")) || this.formElement.enctype);
|
||
}
|
||
get isSafe() {
|
||
return this.fetchRequest.isSafe;
|
||
}
|
||
get stringFormData() {
|
||
return [...this.formData].reduce((entries, [name, value]) => {
|
||
return entries.concat(typeof value == "string" ? [[name, value]] : []);
|
||
}, []);
|
||
}
|
||
async start() {
|
||
const { initialized, requesting } = FormSubmissionState;
|
||
const confirmationMessage = getAttribute("data-turbo-confirm", this.submitter, this.formElement);
|
||
if (typeof confirmationMessage === "string") {
|
||
const answer = await _FormSubmission.confirmMethod(confirmationMessage, this.formElement, this.submitter);
|
||
if (!answer) {
|
||
return;
|
||
}
|
||
}
|
||
if (this.state == initialized) {
|
||
this.state = requesting;
|
||
return this.fetchRequest.perform();
|
||
}
|
||
}
|
||
stop() {
|
||
const { stopping, stopped } = FormSubmissionState;
|
||
if (this.state != stopping && this.state != stopped) {
|
||
this.state = stopping;
|
||
this.fetchRequest.cancel();
|
||
return true;
|
||
}
|
||
}
|
||
prepareRequest(request) {
|
||
if (!request.isSafe) {
|
||
const token = getCookieValue(getMetaContent("csrf-param")) || getMetaContent("csrf-token");
|
||
if (token) {
|
||
request.headers["X-CSRF-Token"] = token;
|
||
}
|
||
}
|
||
if (this.requestAcceptsTurboStreamResponse(request)) {
|
||
request.acceptResponseType(StreamMessage.contentType);
|
||
}
|
||
}
|
||
requestStarted(_request) {
|
||
var _a;
|
||
this.state = FormSubmissionState.waiting;
|
||
(_a = this.submitter) === null || _a === void 0 ? void 0 : _a.setAttribute("disabled", "");
|
||
this.setSubmitsWith();
|
||
dispatch("turbo:submit-start", {
|
||
target: this.formElement,
|
||
detail: { formSubmission: this }
|
||
});
|
||
this.delegate.formSubmissionStarted(this);
|
||
}
|
||
requestPreventedHandlingResponse(request, response) {
|
||
this.result = { success: response.succeeded, fetchResponse: response };
|
||
}
|
||
requestSucceededWithResponse(request, response) {
|
||
if (response.clientError || response.serverError) {
|
||
this.delegate.formSubmissionFailedWithResponse(this, response);
|
||
} else if (this.requestMustRedirect(request) && responseSucceededWithoutRedirect(response)) {
|
||
const error2 = new Error("Form responses must redirect to another location");
|
||
this.delegate.formSubmissionErrored(this, error2);
|
||
} else {
|
||
this.state = FormSubmissionState.receiving;
|
||
this.result = { success: true, fetchResponse: response };
|
||
this.delegate.formSubmissionSucceededWithResponse(this, response);
|
||
}
|
||
}
|
||
requestFailedWithResponse(request, response) {
|
||
this.result = { success: false, fetchResponse: response };
|
||
this.delegate.formSubmissionFailedWithResponse(this, response);
|
||
}
|
||
requestErrored(request, error2) {
|
||
this.result = { success: false, error: error2 };
|
||
this.delegate.formSubmissionErrored(this, error2);
|
||
}
|
||
requestFinished(_request) {
|
||
var _a;
|
||
this.state = FormSubmissionState.stopped;
|
||
(_a = this.submitter) === null || _a === void 0 ? void 0 : _a.removeAttribute("disabled");
|
||
this.resetSubmitterText();
|
||
dispatch("turbo:submit-end", {
|
||
target: this.formElement,
|
||
detail: Object.assign({ formSubmission: this }, this.result)
|
||
});
|
||
this.delegate.formSubmissionFinished(this);
|
||
}
|
||
setSubmitsWith() {
|
||
if (!this.submitter || !this.submitsWith)
|
||
return;
|
||
if (this.submitter.matches("button")) {
|
||
this.originalSubmitText = this.submitter.innerHTML;
|
||
this.submitter.innerHTML = this.submitsWith;
|
||
} else if (this.submitter.matches("input")) {
|
||
const input = this.submitter;
|
||
this.originalSubmitText = input.value;
|
||
input.value = this.submitsWith;
|
||
}
|
||
}
|
||
resetSubmitterText() {
|
||
if (!this.submitter || !this.originalSubmitText)
|
||
return;
|
||
if (this.submitter.matches("button")) {
|
||
this.submitter.innerHTML = this.originalSubmitText;
|
||
} else if (this.submitter.matches("input")) {
|
||
const input = this.submitter;
|
||
input.value = this.originalSubmitText;
|
||
}
|
||
}
|
||
requestMustRedirect(request) {
|
||
return !request.isSafe && this.mustRedirect;
|
||
}
|
||
requestAcceptsTurboStreamResponse(request) {
|
||
return !request.isSafe || hasAttribute("data-turbo-stream", this.submitter, this.formElement);
|
||
}
|
||
get submitsWith() {
|
||
var _a;
|
||
return (_a = this.submitter) === null || _a === void 0 ? void 0 : _a.getAttribute("data-turbo-submits-with");
|
||
}
|
||
};
|
||
function buildFormData(formElement, submitter) {
|
||
const formData = new FormData(formElement);
|
||
const name = submitter === null || submitter === void 0 ? void 0 : submitter.getAttribute("name");
|
||
const value = submitter === null || submitter === void 0 ? void 0 : submitter.getAttribute("value");
|
||
if (name) {
|
||
formData.append(name, value || "");
|
||
}
|
||
return formData;
|
||
}
|
||
function getCookieValue(cookieName) {
|
||
if (cookieName != null) {
|
||
const cookies = document.cookie ? document.cookie.split("; ") : [];
|
||
const cookie = cookies.find((cookie2) => cookie2.startsWith(cookieName));
|
||
if (cookie) {
|
||
const value = cookie.split("=").slice(1).join("=");
|
||
return value ? decodeURIComponent(value) : void 0;
|
||
}
|
||
}
|
||
}
|
||
function responseSucceededWithoutRedirect(response) {
|
||
return response.statusCode == 200 && !response.redirected;
|
||
}
|
||
function mergeFormDataEntries(url, entries) {
|
||
const searchParams = new URLSearchParams();
|
||
for (const [name, value] of entries) {
|
||
if (value instanceof File)
|
||
continue;
|
||
searchParams.append(name, value);
|
||
}
|
||
url.search = searchParams.toString();
|
||
return url;
|
||
}
|
||
var Snapshot = class {
|
||
constructor(element) {
|
||
this.element = element;
|
||
}
|
||
get activeElement() {
|
||
return this.element.ownerDocument.activeElement;
|
||
}
|
||
get children() {
|
||
return [...this.element.children];
|
||
}
|
||
hasAnchor(anchor) {
|
||
return this.getElementForAnchor(anchor) != null;
|
||
}
|
||
getElementForAnchor(anchor) {
|
||
return anchor ? this.element.querySelector(`[id='${anchor}'], a[name='${anchor}']`) : null;
|
||
}
|
||
get isConnected() {
|
||
return this.element.isConnected;
|
||
}
|
||
get firstAutofocusableElement() {
|
||
const inertDisabledOrHidden = "[inert], :disabled, [hidden], details:not([open]), dialog:not([open])";
|
||
for (const element of this.element.querySelectorAll("[autofocus]")) {
|
||
if (element.closest(inertDisabledOrHidden) == null)
|
||
return element;
|
||
else
|
||
continue;
|
||
}
|
||
return null;
|
||
}
|
||
get permanentElements() {
|
||
return queryPermanentElementsAll(this.element);
|
||
}
|
||
getPermanentElementById(id2) {
|
||
return getPermanentElementById(this.element, id2);
|
||
}
|
||
getPermanentElementMapForSnapshot(snapshot) {
|
||
const permanentElementMap = {};
|
||
for (const currentPermanentElement of this.permanentElements) {
|
||
const { id: id2 } = currentPermanentElement;
|
||
const newPermanentElement = snapshot.getPermanentElementById(id2);
|
||
if (newPermanentElement) {
|
||
permanentElementMap[id2] = [currentPermanentElement, newPermanentElement];
|
||
}
|
||
}
|
||
return permanentElementMap;
|
||
}
|
||
};
|
||
function getPermanentElementById(node, id2) {
|
||
return node.querySelector(`#${id2}[data-turbo-permanent]`);
|
||
}
|
||
function queryPermanentElementsAll(node) {
|
||
return node.querySelectorAll("[id][data-turbo-permanent]");
|
||
}
|
||
var FormSubmitObserver = class {
|
||
constructor(delegate, eventTarget) {
|
||
this.started = false;
|
||
this.submitCaptured = () => {
|
||
this.eventTarget.removeEventListener("submit", this.submitBubbled, false);
|
||
this.eventTarget.addEventListener("submit", this.submitBubbled, false);
|
||
};
|
||
this.submitBubbled = (event) => {
|
||
if (!event.defaultPrevented) {
|
||
const form = event.target instanceof HTMLFormElement ? event.target : void 0;
|
||
const submitter = event.submitter || void 0;
|
||
if (form && submissionDoesNotDismissDialog(form, submitter) && submissionDoesNotTargetIFrame(form, submitter) && this.delegate.willSubmitForm(form, submitter)) {
|
||
event.preventDefault();
|
||
event.stopImmediatePropagation();
|
||
this.delegate.formSubmitted(form, submitter);
|
||
}
|
||
}
|
||
};
|
||
this.delegate = delegate;
|
||
this.eventTarget = eventTarget;
|
||
}
|
||
start() {
|
||
if (!this.started) {
|
||
this.eventTarget.addEventListener("submit", this.submitCaptured, true);
|
||
this.started = true;
|
||
}
|
||
}
|
||
stop() {
|
||
if (this.started) {
|
||
this.eventTarget.removeEventListener("submit", this.submitCaptured, true);
|
||
this.started = false;
|
||
}
|
||
}
|
||
};
|
||
function submissionDoesNotDismissDialog(form, submitter) {
|
||
const method = (submitter === null || submitter === void 0 ? void 0 : submitter.getAttribute("formmethod")) || form.getAttribute("method");
|
||
return method != "dialog";
|
||
}
|
||
function submissionDoesNotTargetIFrame(form, submitter) {
|
||
if ((submitter === null || submitter === void 0 ? void 0 : submitter.hasAttribute("formtarget")) || form.hasAttribute("target")) {
|
||
const target = (submitter === null || submitter === void 0 ? void 0 : submitter.getAttribute("formtarget")) || form.target;
|
||
for (const element of document.getElementsByName(target)) {
|
||
if (element instanceof HTMLIFrameElement)
|
||
return false;
|
||
}
|
||
return true;
|
||
} else {
|
||
return true;
|
||
}
|
||
}
|
||
var View = class {
|
||
constructor(delegate, element) {
|
||
this.resolveRenderPromise = (_value) => {
|
||
};
|
||
this.resolveInterceptionPromise = (_value) => {
|
||
};
|
||
this.delegate = delegate;
|
||
this.element = element;
|
||
}
|
||
scrollToAnchor(anchor) {
|
||
const element = this.snapshot.getElementForAnchor(anchor);
|
||
if (element) {
|
||
this.scrollToElement(element);
|
||
this.focusElement(element);
|
||
} else {
|
||
this.scrollToPosition({ x: 0, y: 0 });
|
||
}
|
||
}
|
||
scrollToAnchorFromLocation(location2) {
|
||
this.scrollToAnchor(getAnchor(location2));
|
||
}
|
||
scrollToElement(element) {
|
||
element.scrollIntoView();
|
||
}
|
||
focusElement(element) {
|
||
if (element instanceof HTMLElement) {
|
||
if (element.hasAttribute("tabindex")) {
|
||
element.focus();
|
||
} else {
|
||
element.setAttribute("tabindex", "-1");
|
||
element.focus();
|
||
element.removeAttribute("tabindex");
|
||
}
|
||
}
|
||
}
|
||
scrollToPosition({ x, y }) {
|
||
this.scrollRoot.scrollTo(x, y);
|
||
}
|
||
scrollToTop() {
|
||
this.scrollToPosition({ x: 0, y: 0 });
|
||
}
|
||
get scrollRoot() {
|
||
return window;
|
||
}
|
||
async render(renderer) {
|
||
const { isPreview, shouldRender, newSnapshot: snapshot } = renderer;
|
||
if (shouldRender) {
|
||
try {
|
||
this.renderPromise = new Promise((resolve) => this.resolveRenderPromise = resolve);
|
||
this.renderer = renderer;
|
||
await this.prepareToRenderSnapshot(renderer);
|
||
const renderInterception = new Promise((resolve) => this.resolveInterceptionPromise = resolve);
|
||
const options = { resume: this.resolveInterceptionPromise, render: this.renderer.renderElement };
|
||
const immediateRender = this.delegate.allowsImmediateRender(snapshot, options);
|
||
if (!immediateRender)
|
||
await renderInterception;
|
||
await this.renderSnapshot(renderer);
|
||
this.delegate.viewRenderedSnapshot(snapshot, isPreview);
|
||
this.delegate.preloadOnLoadLinksForView(this.element);
|
||
this.finishRenderingSnapshot(renderer);
|
||
} finally {
|
||
delete this.renderer;
|
||
this.resolveRenderPromise(void 0);
|
||
delete this.renderPromise;
|
||
}
|
||
} else {
|
||
this.invalidate(renderer.reloadReason);
|
||
}
|
||
}
|
||
invalidate(reason) {
|
||
this.delegate.viewInvalidated(reason);
|
||
}
|
||
async prepareToRenderSnapshot(renderer) {
|
||
this.markAsPreview(renderer.isPreview);
|
||
await renderer.prepareToRender();
|
||
}
|
||
markAsPreview(isPreview) {
|
||
if (isPreview) {
|
||
this.element.setAttribute("data-turbo-preview", "");
|
||
} else {
|
||
this.element.removeAttribute("data-turbo-preview");
|
||
}
|
||
}
|
||
async renderSnapshot(renderer) {
|
||
await renderer.render();
|
||
}
|
||
finishRenderingSnapshot(renderer) {
|
||
renderer.finishRendering();
|
||
}
|
||
};
|
||
var FrameView = class extends View {
|
||
missing() {
|
||
this.element.innerHTML = `<strong class="turbo-frame-error">Content missing</strong>`;
|
||
}
|
||
get snapshot() {
|
||
return new Snapshot(this.element);
|
||
}
|
||
};
|
||
var LinkInterceptor = class {
|
||
constructor(delegate, element) {
|
||
this.clickBubbled = (event) => {
|
||
if (this.respondsToEventTarget(event.target)) {
|
||
this.clickEvent = event;
|
||
} else {
|
||
delete this.clickEvent;
|
||
}
|
||
};
|
||
this.linkClicked = (event) => {
|
||
if (this.clickEvent && this.respondsToEventTarget(event.target) && event.target instanceof Element) {
|
||
if (this.delegate.shouldInterceptLinkClick(event.target, event.detail.url, event.detail.originalEvent)) {
|
||
this.clickEvent.preventDefault();
|
||
event.preventDefault();
|
||
this.delegate.linkClickIntercepted(event.target, event.detail.url, event.detail.originalEvent);
|
||
}
|
||
}
|
||
delete this.clickEvent;
|
||
};
|
||
this.willVisit = (_event) => {
|
||
delete this.clickEvent;
|
||
};
|
||
this.delegate = delegate;
|
||
this.element = element;
|
||
}
|
||
start() {
|
||
this.element.addEventListener("click", this.clickBubbled);
|
||
document.addEventListener("turbo:click", this.linkClicked);
|
||
document.addEventListener("turbo:before-visit", this.willVisit);
|
||
}
|
||
stop() {
|
||
this.element.removeEventListener("click", this.clickBubbled);
|
||
document.removeEventListener("turbo:click", this.linkClicked);
|
||
document.removeEventListener("turbo:before-visit", this.willVisit);
|
||
}
|
||
respondsToEventTarget(target) {
|
||
const element = target instanceof Element ? target : target instanceof Node ? target.parentElement : null;
|
||
return element && element.closest("turbo-frame, html") == this.element;
|
||
}
|
||
};
|
||
var LinkClickObserver = class {
|
||
constructor(delegate, eventTarget) {
|
||
this.started = false;
|
||
this.clickCaptured = () => {
|
||
this.eventTarget.removeEventListener("click", this.clickBubbled, false);
|
||
this.eventTarget.addEventListener("click", this.clickBubbled, false);
|
||
};
|
||
this.clickBubbled = (event) => {
|
||
if (event instanceof MouseEvent && this.clickEventIsSignificant(event)) {
|
||
const target = event.composedPath && event.composedPath()[0] || event.target;
|
||
const link = this.findLinkFromClickTarget(target);
|
||
if (link && doesNotTargetIFrame(link)) {
|
||
const location2 = this.getLocationForLink(link);
|
||
if (this.delegate.willFollowLinkToLocation(link, location2, event)) {
|
||
event.preventDefault();
|
||
this.delegate.followedLinkToLocation(link, location2);
|
||
}
|
||
}
|
||
}
|
||
};
|
||
this.delegate = delegate;
|
||
this.eventTarget = eventTarget;
|
||
}
|
||
start() {
|
||
if (!this.started) {
|
||
this.eventTarget.addEventListener("click", this.clickCaptured, true);
|
||
this.started = true;
|
||
}
|
||
}
|
||
stop() {
|
||
if (this.started) {
|
||
this.eventTarget.removeEventListener("click", this.clickCaptured, true);
|
||
this.started = false;
|
||
}
|
||
}
|
||
clickEventIsSignificant(event) {
|
||
return !(event.target && event.target.isContentEditable || event.defaultPrevented || event.which > 1 || event.altKey || event.ctrlKey || event.metaKey || event.shiftKey);
|
||
}
|
||
findLinkFromClickTarget(target) {
|
||
return findClosestRecursively(target, "a[href]:not([target^=_]):not([download])");
|
||
}
|
||
getLocationForLink(link) {
|
||
return expandURL(link.getAttribute("href") || "");
|
||
}
|
||
};
|
||
function doesNotTargetIFrame(anchor) {
|
||
if (anchor.hasAttribute("target")) {
|
||
for (const element of document.getElementsByName(anchor.target)) {
|
||
if (element instanceof HTMLIFrameElement)
|
||
return false;
|
||
}
|
||
return true;
|
||
} else {
|
||
return true;
|
||
}
|
||
}
|
||
var FormLinkClickObserver = class {
|
||
constructor(delegate, element) {
|
||
this.delegate = delegate;
|
||
this.linkInterceptor = new LinkClickObserver(this, element);
|
||
}
|
||
start() {
|
||
this.linkInterceptor.start();
|
||
}
|
||
stop() {
|
||
this.linkInterceptor.stop();
|
||
}
|
||
willFollowLinkToLocation(link, location2, originalEvent) {
|
||
return this.delegate.willSubmitFormLinkToLocation(link, location2, originalEvent) && link.hasAttribute("data-turbo-method");
|
||
}
|
||
followedLinkToLocation(link, location2) {
|
||
const form = document.createElement("form");
|
||
const type = "hidden";
|
||
for (const [name, value] of location2.searchParams) {
|
||
form.append(Object.assign(document.createElement("input"), { type, name, value }));
|
||
}
|
||
const action = Object.assign(location2, { search: "" });
|
||
form.setAttribute("data-turbo", "true");
|
||
form.setAttribute("action", action.href);
|
||
form.setAttribute("hidden", "");
|
||
const method = link.getAttribute("data-turbo-method");
|
||
if (method)
|
||
form.setAttribute("method", method);
|
||
const turboFrame = link.getAttribute("data-turbo-frame");
|
||
if (turboFrame)
|
||
form.setAttribute("data-turbo-frame", turboFrame);
|
||
const turboAction = getVisitAction(link);
|
||
if (turboAction)
|
||
form.setAttribute("data-turbo-action", turboAction);
|
||
const turboConfirm = link.getAttribute("data-turbo-confirm");
|
||
if (turboConfirm)
|
||
form.setAttribute("data-turbo-confirm", turboConfirm);
|
||
const turboStream = link.hasAttribute("data-turbo-stream");
|
||
if (turboStream)
|
||
form.setAttribute("data-turbo-stream", "");
|
||
this.delegate.submittedFormLinkToLocation(link, location2, form);
|
||
document.body.appendChild(form);
|
||
form.addEventListener("turbo:submit-end", () => form.remove(), { once: true });
|
||
requestAnimationFrame(() => form.requestSubmit());
|
||
}
|
||
};
|
||
var Bardo = class {
|
||
static async preservingPermanentElements(delegate, permanentElementMap, callback) {
|
||
const bardo = new this(delegate, permanentElementMap);
|
||
bardo.enter();
|
||
await callback();
|
||
bardo.leave();
|
||
}
|
||
constructor(delegate, permanentElementMap) {
|
||
this.delegate = delegate;
|
||
this.permanentElementMap = permanentElementMap;
|
||
}
|
||
enter() {
|
||
for (const id2 in this.permanentElementMap) {
|
||
const [currentPermanentElement, newPermanentElement] = this.permanentElementMap[id2];
|
||
this.delegate.enteringBardo(currentPermanentElement, newPermanentElement);
|
||
this.replaceNewPermanentElementWithPlaceholder(newPermanentElement);
|
||
}
|
||
}
|
||
leave() {
|
||
for (const id2 in this.permanentElementMap) {
|
||
const [currentPermanentElement] = this.permanentElementMap[id2];
|
||
this.replaceCurrentPermanentElementWithClone(currentPermanentElement);
|
||
this.replacePlaceholderWithPermanentElement(currentPermanentElement);
|
||
this.delegate.leavingBardo(currentPermanentElement);
|
||
}
|
||
}
|
||
replaceNewPermanentElementWithPlaceholder(permanentElement) {
|
||
const placeholder = createPlaceholderForPermanentElement(permanentElement);
|
||
permanentElement.replaceWith(placeholder);
|
||
}
|
||
replaceCurrentPermanentElementWithClone(permanentElement) {
|
||
const clone = permanentElement.cloneNode(true);
|
||
permanentElement.replaceWith(clone);
|
||
}
|
||
replacePlaceholderWithPermanentElement(permanentElement) {
|
||
const placeholder = this.getPlaceholderById(permanentElement.id);
|
||
placeholder === null || placeholder === void 0 ? void 0 : placeholder.replaceWith(permanentElement);
|
||
}
|
||
getPlaceholderById(id2) {
|
||
return this.placeholders.find((element) => element.content == id2);
|
||
}
|
||
get placeholders() {
|
||
return [...document.querySelectorAll("meta[name=turbo-permanent-placeholder][content]")];
|
||
}
|
||
};
|
||
function createPlaceholderForPermanentElement(permanentElement) {
|
||
const element = document.createElement("meta");
|
||
element.setAttribute("name", "turbo-permanent-placeholder");
|
||
element.setAttribute("content", permanentElement.id);
|
||
return element;
|
||
}
|
||
var Renderer = class {
|
||
constructor(currentSnapshot, newSnapshot, renderElement, isPreview, willRender = true) {
|
||
this.activeElement = null;
|
||
this.currentSnapshot = currentSnapshot;
|
||
this.newSnapshot = newSnapshot;
|
||
this.isPreview = isPreview;
|
||
this.willRender = willRender;
|
||
this.renderElement = renderElement;
|
||
this.promise = new Promise((resolve, reject) => this.resolvingFunctions = { resolve, reject });
|
||
}
|
||
get shouldRender() {
|
||
return true;
|
||
}
|
||
get reloadReason() {
|
||
return;
|
||
}
|
||
prepareToRender() {
|
||
return;
|
||
}
|
||
finishRendering() {
|
||
if (this.resolvingFunctions) {
|
||
this.resolvingFunctions.resolve();
|
||
delete this.resolvingFunctions;
|
||
}
|
||
}
|
||
async preservingPermanentElements(callback) {
|
||
await Bardo.preservingPermanentElements(this, this.permanentElementMap, callback);
|
||
}
|
||
focusFirstAutofocusableElement() {
|
||
const element = this.connectedSnapshot.firstAutofocusableElement;
|
||
if (elementIsFocusable(element)) {
|
||
element.focus();
|
||
}
|
||
}
|
||
enteringBardo(currentPermanentElement) {
|
||
if (this.activeElement)
|
||
return;
|
||
if (currentPermanentElement.contains(this.currentSnapshot.activeElement)) {
|
||
this.activeElement = this.currentSnapshot.activeElement;
|
||
}
|
||
}
|
||
leavingBardo(currentPermanentElement) {
|
||
if (currentPermanentElement.contains(this.activeElement) && this.activeElement instanceof HTMLElement) {
|
||
this.activeElement.focus();
|
||
this.activeElement = null;
|
||
}
|
||
}
|
||
get connectedSnapshot() {
|
||
return this.newSnapshot.isConnected ? this.newSnapshot : this.currentSnapshot;
|
||
}
|
||
get currentElement() {
|
||
return this.currentSnapshot.element;
|
||
}
|
||
get newElement() {
|
||
return this.newSnapshot.element;
|
||
}
|
||
get permanentElementMap() {
|
||
return this.currentSnapshot.getPermanentElementMapForSnapshot(this.newSnapshot);
|
||
}
|
||
};
|
||
function elementIsFocusable(element) {
|
||
return element && typeof element.focus == "function";
|
||
}
|
||
var FrameRenderer = class extends Renderer {
|
||
static renderElement(currentElement, newElement) {
|
||
var _a;
|
||
const destinationRange = document.createRange();
|
||
destinationRange.selectNodeContents(currentElement);
|
||
destinationRange.deleteContents();
|
||
const frameElement = newElement;
|
||
const sourceRange = (_a = frameElement.ownerDocument) === null || _a === void 0 ? void 0 : _a.createRange();
|
||
if (sourceRange) {
|
||
sourceRange.selectNodeContents(frameElement);
|
||
currentElement.appendChild(sourceRange.extractContents());
|
||
}
|
||
}
|
||
constructor(delegate, currentSnapshot, newSnapshot, renderElement, isPreview, willRender = true) {
|
||
super(currentSnapshot, newSnapshot, renderElement, isPreview, willRender);
|
||
this.delegate = delegate;
|
||
}
|
||
get shouldRender() {
|
||
return true;
|
||
}
|
||
async render() {
|
||
await nextAnimationFrame();
|
||
this.preservingPermanentElements(() => {
|
||
this.loadFrameElement();
|
||
});
|
||
this.scrollFrameIntoView();
|
||
await nextAnimationFrame();
|
||
this.focusFirstAutofocusableElement();
|
||
await nextAnimationFrame();
|
||
this.activateScriptElements();
|
||
}
|
||
loadFrameElement() {
|
||
this.delegate.willRenderFrame(this.currentElement, this.newElement);
|
||
this.renderElement(this.currentElement, this.newElement);
|
||
}
|
||
scrollFrameIntoView() {
|
||
if (this.currentElement.autoscroll || this.newElement.autoscroll) {
|
||
const element = this.currentElement.firstElementChild;
|
||
const block = readScrollLogicalPosition(this.currentElement.getAttribute("data-autoscroll-block"), "end");
|
||
const behavior = readScrollBehavior(this.currentElement.getAttribute("data-autoscroll-behavior"), "auto");
|
||
if (element) {
|
||
element.scrollIntoView({ block, behavior });
|
||
return true;
|
||
}
|
||
}
|
||
return false;
|
||
}
|
||
activateScriptElements() {
|
||
for (const inertScriptElement of this.newScriptElements) {
|
||
const activatedScriptElement = activateScriptElement(inertScriptElement);
|
||
inertScriptElement.replaceWith(activatedScriptElement);
|
||
}
|
||
}
|
||
get newScriptElements() {
|
||
return this.currentElement.querySelectorAll("script");
|
||
}
|
||
};
|
||
function readScrollLogicalPosition(value, defaultValue) {
|
||
if (value == "end" || value == "start" || value == "center" || value == "nearest") {
|
||
return value;
|
||
} else {
|
||
return defaultValue;
|
||
}
|
||
}
|
||
function readScrollBehavior(value, defaultValue) {
|
||
if (value == "auto" || value == "smooth") {
|
||
return value;
|
||
} else {
|
||
return defaultValue;
|
||
}
|
||
}
|
||
var ProgressBar = class _ProgressBar {
|
||
static get defaultCSS() {
|
||
return unindent`
|
||
.turbo-progress-bar {
|
||
position: fixed;
|
||
display: block;
|
||
top: 0;
|
||
left: 0;
|
||
height: 3px;
|
||
background: #0076ff;
|
||
z-index: 2147483647;
|
||
transition:
|
||
width ${_ProgressBar.animationDuration}ms ease-out,
|
||
opacity ${_ProgressBar.animationDuration / 2}ms ${_ProgressBar.animationDuration / 2}ms ease-in;
|
||
transform: translate3d(0, 0, 0);
|
||
}
|
||
`;
|
||
}
|
||
constructor() {
|
||
this.hiding = false;
|
||
this.value = 0;
|
||
this.visible = false;
|
||
this.trickle = () => {
|
||
this.setValue(this.value + Math.random() / 100);
|
||
};
|
||
this.stylesheetElement = this.createStylesheetElement();
|
||
this.progressElement = this.createProgressElement();
|
||
this.installStylesheetElement();
|
||
this.setValue(0);
|
||
}
|
||
show() {
|
||
if (!this.visible) {
|
||
this.visible = true;
|
||
this.installProgressElement();
|
||
this.startTrickling();
|
||
}
|
||
}
|
||
hide() {
|
||
if (this.visible && !this.hiding) {
|
||
this.hiding = true;
|
||
this.fadeProgressElement(() => {
|
||
this.uninstallProgressElement();
|
||
this.stopTrickling();
|
||
this.visible = false;
|
||
this.hiding = false;
|
||
});
|
||
}
|
||
}
|
||
setValue(value) {
|
||
this.value = value;
|
||
this.refresh();
|
||
}
|
||
installStylesheetElement() {
|
||
document.head.insertBefore(this.stylesheetElement, document.head.firstChild);
|
||
}
|
||
installProgressElement() {
|
||
this.progressElement.style.width = "0";
|
||
this.progressElement.style.opacity = "1";
|
||
document.documentElement.insertBefore(this.progressElement, document.body);
|
||
this.refresh();
|
||
}
|
||
fadeProgressElement(callback) {
|
||
this.progressElement.style.opacity = "0";
|
||
setTimeout(callback, _ProgressBar.animationDuration * 1.5);
|
||
}
|
||
uninstallProgressElement() {
|
||
if (this.progressElement.parentNode) {
|
||
document.documentElement.removeChild(this.progressElement);
|
||
}
|
||
}
|
||
startTrickling() {
|
||
if (!this.trickleInterval) {
|
||
this.trickleInterval = window.setInterval(this.trickle, _ProgressBar.animationDuration);
|
||
}
|
||
}
|
||
stopTrickling() {
|
||
window.clearInterval(this.trickleInterval);
|
||
delete this.trickleInterval;
|
||
}
|
||
refresh() {
|
||
requestAnimationFrame(() => {
|
||
this.progressElement.style.width = `${10 + this.value * 90}%`;
|
||
});
|
||
}
|
||
createStylesheetElement() {
|
||
const element = document.createElement("style");
|
||
element.type = "text/css";
|
||
element.textContent = _ProgressBar.defaultCSS;
|
||
if (this.cspNonce) {
|
||
element.nonce = this.cspNonce;
|
||
}
|
||
return element;
|
||
}
|
||
createProgressElement() {
|
||
const element = document.createElement("div");
|
||
element.className = "turbo-progress-bar";
|
||
return element;
|
||
}
|
||
get cspNonce() {
|
||
return getMetaContent("csp-nonce");
|
||
}
|
||
};
|
||
ProgressBar.animationDuration = 300;
|
||
var HeadSnapshot = class extends Snapshot {
|
||
constructor() {
|
||
super(...arguments);
|
||
this.detailsByOuterHTML = this.children.filter((element) => !elementIsNoscript(element)).map((element) => elementWithoutNonce(element)).reduce((result, element) => {
|
||
const { outerHTML } = element;
|
||
const details = outerHTML in result ? result[outerHTML] : {
|
||
type: elementType(element),
|
||
tracked: elementIsTracked(element),
|
||
elements: []
|
||
};
|
||
return Object.assign(Object.assign({}, result), { [outerHTML]: Object.assign(Object.assign({}, details), { elements: [...details.elements, element] }) });
|
||
}, {});
|
||
}
|
||
get trackedElementSignature() {
|
||
return Object.keys(this.detailsByOuterHTML).filter((outerHTML) => this.detailsByOuterHTML[outerHTML].tracked).join("");
|
||
}
|
||
getScriptElementsNotInSnapshot(snapshot) {
|
||
return this.getElementsMatchingTypeNotInSnapshot("script", snapshot);
|
||
}
|
||
getStylesheetElementsNotInSnapshot(snapshot) {
|
||
return this.getElementsMatchingTypeNotInSnapshot("stylesheet", snapshot);
|
||
}
|
||
getElementsMatchingTypeNotInSnapshot(matchedType, snapshot) {
|
||
return Object.keys(this.detailsByOuterHTML).filter((outerHTML) => !(outerHTML in snapshot.detailsByOuterHTML)).map((outerHTML) => this.detailsByOuterHTML[outerHTML]).filter(({ type }) => type == matchedType).map(({ elements: [element] }) => element);
|
||
}
|
||
get provisionalElements() {
|
||
return Object.keys(this.detailsByOuterHTML).reduce((result, outerHTML) => {
|
||
const { type, tracked, elements } = this.detailsByOuterHTML[outerHTML];
|
||
if (type == null && !tracked) {
|
||
return [...result, ...elements];
|
||
} else if (elements.length > 1) {
|
||
return [...result, ...elements.slice(1)];
|
||
} else {
|
||
return result;
|
||
}
|
||
}, []);
|
||
}
|
||
getMetaValue(name) {
|
||
const element = this.findMetaElementByName(name);
|
||
return element ? element.getAttribute("content") : null;
|
||
}
|
||
findMetaElementByName(name) {
|
||
return Object.keys(this.detailsByOuterHTML).reduce((result, outerHTML) => {
|
||
const { elements: [element] } = this.detailsByOuterHTML[outerHTML];
|
||
return elementIsMetaElementWithName(element, name) ? element : result;
|
||
}, void 0);
|
||
}
|
||
};
|
||
function elementType(element) {
|
||
if (elementIsScript(element)) {
|
||
return "script";
|
||
} else if (elementIsStylesheet(element)) {
|
||
return "stylesheet";
|
||
}
|
||
}
|
||
function elementIsTracked(element) {
|
||
return element.getAttribute("data-turbo-track") == "reload";
|
||
}
|
||
function elementIsScript(element) {
|
||
const tagName = element.localName;
|
||
return tagName == "script";
|
||
}
|
||
function elementIsNoscript(element) {
|
||
const tagName = element.localName;
|
||
return tagName == "noscript";
|
||
}
|
||
function elementIsStylesheet(element) {
|
||
const tagName = element.localName;
|
||
return tagName == "style" || tagName == "link" && element.getAttribute("rel") == "stylesheet";
|
||
}
|
||
function elementIsMetaElementWithName(element, name) {
|
||
const tagName = element.localName;
|
||
return tagName == "meta" && element.getAttribute("name") == name;
|
||
}
|
||
function elementWithoutNonce(element) {
|
||
if (element.hasAttribute("nonce")) {
|
||
element.setAttribute("nonce", "");
|
||
}
|
||
return element;
|
||
}
|
||
var PageSnapshot = class _PageSnapshot extends Snapshot {
|
||
static fromHTMLString(html = "") {
|
||
return this.fromDocument(parseHTMLDocument(html));
|
||
}
|
||
static fromElement(element) {
|
||
return this.fromDocument(element.ownerDocument);
|
||
}
|
||
static fromDocument({ head, body }) {
|
||
return new this(body, new HeadSnapshot(head));
|
||
}
|
||
constructor(element, headSnapshot) {
|
||
super(element);
|
||
this.headSnapshot = headSnapshot;
|
||
}
|
||
clone() {
|
||
const clonedElement = this.element.cloneNode(true);
|
||
const selectElements = this.element.querySelectorAll("select");
|
||
const clonedSelectElements = clonedElement.querySelectorAll("select");
|
||
for (const [index, source] of selectElements.entries()) {
|
||
const clone = clonedSelectElements[index];
|
||
for (const option of clone.selectedOptions)
|
||
option.selected = false;
|
||
for (const option of source.selectedOptions)
|
||
clone.options[option.index].selected = true;
|
||
}
|
||
for (const clonedPasswordInput of clonedElement.querySelectorAll('input[type="password"]')) {
|
||
clonedPasswordInput.value = "";
|
||
}
|
||
return new _PageSnapshot(clonedElement, this.headSnapshot);
|
||
}
|
||
get headElement() {
|
||
return this.headSnapshot.element;
|
||
}
|
||
get rootLocation() {
|
||
var _a;
|
||
const root = (_a = this.getSetting("root")) !== null && _a !== void 0 ? _a : "/";
|
||
return expandURL(root);
|
||
}
|
||
get cacheControlValue() {
|
||
return this.getSetting("cache-control");
|
||
}
|
||
get isPreviewable() {
|
||
return this.cacheControlValue != "no-preview";
|
||
}
|
||
get isCacheable() {
|
||
return this.cacheControlValue != "no-cache";
|
||
}
|
||
get isVisitable() {
|
||
return this.getSetting("visit-control") != "reload";
|
||
}
|
||
getSetting(name) {
|
||
return this.headSnapshot.getMetaValue(`turbo-${name}`);
|
||
}
|
||
};
|
||
var TimingMetric;
|
||
(function(TimingMetric2) {
|
||
TimingMetric2["visitStart"] = "visitStart";
|
||
TimingMetric2["requestStart"] = "requestStart";
|
||
TimingMetric2["requestEnd"] = "requestEnd";
|
||
TimingMetric2["visitEnd"] = "visitEnd";
|
||
})(TimingMetric || (TimingMetric = {}));
|
||
var VisitState;
|
||
(function(VisitState2) {
|
||
VisitState2["initialized"] = "initialized";
|
||
VisitState2["started"] = "started";
|
||
VisitState2["canceled"] = "canceled";
|
||
VisitState2["failed"] = "failed";
|
||
VisitState2["completed"] = "completed";
|
||
})(VisitState || (VisitState = {}));
|
||
var defaultOptions = {
|
||
action: "advance",
|
||
historyChanged: false,
|
||
visitCachedSnapshot: () => {
|
||
},
|
||
willRender: true,
|
||
updateHistory: true,
|
||
shouldCacheSnapshot: true,
|
||
acceptsStreamResponse: false
|
||
};
|
||
var SystemStatusCode;
|
||
(function(SystemStatusCode2) {
|
||
SystemStatusCode2[SystemStatusCode2["networkFailure"] = 0] = "networkFailure";
|
||
SystemStatusCode2[SystemStatusCode2["timeoutFailure"] = -1] = "timeoutFailure";
|
||
SystemStatusCode2[SystemStatusCode2["contentTypeMismatch"] = -2] = "contentTypeMismatch";
|
||
})(SystemStatusCode || (SystemStatusCode = {}));
|
||
var Visit = class {
|
||
constructor(delegate, location2, restorationIdentifier, options = {}) {
|
||
this.identifier = uuid();
|
||
this.timingMetrics = {};
|
||
this.followedRedirect = false;
|
||
this.historyChanged = false;
|
||
this.scrolled = false;
|
||
this.shouldCacheSnapshot = true;
|
||
this.acceptsStreamResponse = false;
|
||
this.snapshotCached = false;
|
||
this.state = VisitState.initialized;
|
||
this.delegate = delegate;
|
||
this.location = location2;
|
||
this.restorationIdentifier = restorationIdentifier || uuid();
|
||
const { action, historyChanged, referrer, snapshot, snapshotHTML, response, visitCachedSnapshot, willRender, updateHistory, shouldCacheSnapshot, acceptsStreamResponse } = Object.assign(Object.assign({}, defaultOptions), options);
|
||
this.action = action;
|
||
this.historyChanged = historyChanged;
|
||
this.referrer = referrer;
|
||
this.snapshot = snapshot;
|
||
this.snapshotHTML = snapshotHTML;
|
||
this.response = response;
|
||
this.isSamePage = this.delegate.locationWithActionIsSamePage(this.location, this.action);
|
||
this.visitCachedSnapshot = visitCachedSnapshot;
|
||
this.willRender = willRender;
|
||
this.updateHistory = updateHistory;
|
||
this.scrolled = !willRender;
|
||
this.shouldCacheSnapshot = shouldCacheSnapshot;
|
||
this.acceptsStreamResponse = acceptsStreamResponse;
|
||
}
|
||
get adapter() {
|
||
return this.delegate.adapter;
|
||
}
|
||
get view() {
|
||
return this.delegate.view;
|
||
}
|
||
get history() {
|
||
return this.delegate.history;
|
||
}
|
||
get restorationData() {
|
||
return this.history.getRestorationDataForIdentifier(this.restorationIdentifier);
|
||
}
|
||
get silent() {
|
||
return this.isSamePage;
|
||
}
|
||
start() {
|
||
if (this.state == VisitState.initialized) {
|
||
this.recordTimingMetric(TimingMetric.visitStart);
|
||
this.state = VisitState.started;
|
||
this.adapter.visitStarted(this);
|
||
this.delegate.visitStarted(this);
|
||
}
|
||
}
|
||
cancel() {
|
||
if (this.state == VisitState.started) {
|
||
if (this.request) {
|
||
this.request.cancel();
|
||
}
|
||
this.cancelRender();
|
||
this.state = VisitState.canceled;
|
||
}
|
||
}
|
||
complete() {
|
||
if (this.state == VisitState.started) {
|
||
this.recordTimingMetric(TimingMetric.visitEnd);
|
||
this.state = VisitState.completed;
|
||
this.followRedirect();
|
||
if (!this.followedRedirect) {
|
||
this.adapter.visitCompleted(this);
|
||
this.delegate.visitCompleted(this);
|
||
}
|
||
}
|
||
}
|
||
fail() {
|
||
if (this.state == VisitState.started) {
|
||
this.state = VisitState.failed;
|
||
this.adapter.visitFailed(this);
|
||
}
|
||
}
|
||
changeHistory() {
|
||
var _a;
|
||
if (!this.historyChanged && this.updateHistory) {
|
||
const actionForHistory = this.location.href === ((_a = this.referrer) === null || _a === void 0 ? void 0 : _a.href) ? "replace" : this.action;
|
||
const method = getHistoryMethodForAction(actionForHistory);
|
||
this.history.update(method, this.location, this.restorationIdentifier);
|
||
this.historyChanged = true;
|
||
}
|
||
}
|
||
issueRequest() {
|
||
if (this.hasPreloadedResponse()) {
|
||
this.simulateRequest();
|
||
} else if (this.shouldIssueRequest() && !this.request) {
|
||
this.request = new FetchRequest(this, FetchMethod.get, this.location);
|
||
this.request.perform();
|
||
}
|
||
}
|
||
simulateRequest() {
|
||
if (this.response) {
|
||
this.startRequest();
|
||
this.recordResponse();
|
||
this.finishRequest();
|
||
}
|
||
}
|
||
startRequest() {
|
||
this.recordTimingMetric(TimingMetric.requestStart);
|
||
this.adapter.visitRequestStarted(this);
|
||
}
|
||
recordResponse(response = this.response) {
|
||
this.response = response;
|
||
if (response) {
|
||
const { statusCode } = response;
|
||
if (isSuccessful(statusCode)) {
|
||
this.adapter.visitRequestCompleted(this);
|
||
} else {
|
||
this.adapter.visitRequestFailedWithStatusCode(this, statusCode);
|
||
}
|
||
}
|
||
}
|
||
finishRequest() {
|
||
this.recordTimingMetric(TimingMetric.requestEnd);
|
||
this.adapter.visitRequestFinished(this);
|
||
}
|
||
loadResponse() {
|
||
if (this.response) {
|
||
const { statusCode, responseHTML } = this.response;
|
||
this.render(async () => {
|
||
if (this.shouldCacheSnapshot)
|
||
this.cacheSnapshot();
|
||
if (this.view.renderPromise)
|
||
await this.view.renderPromise;
|
||
if (isSuccessful(statusCode) && responseHTML != null) {
|
||
await this.view.renderPage(PageSnapshot.fromHTMLString(responseHTML), false, this.willRender, this);
|
||
this.performScroll();
|
||
this.adapter.visitRendered(this);
|
||
this.complete();
|
||
} else {
|
||
await this.view.renderError(PageSnapshot.fromHTMLString(responseHTML), this);
|
||
this.adapter.visitRendered(this);
|
||
this.fail();
|
||
}
|
||
});
|
||
}
|
||
}
|
||
getCachedSnapshot() {
|
||
const snapshot = this.view.getCachedSnapshotForLocation(this.location) || this.getPreloadedSnapshot();
|
||
if (snapshot && (!getAnchor(this.location) || snapshot.hasAnchor(getAnchor(this.location)))) {
|
||
if (this.action == "restore" || snapshot.isPreviewable) {
|
||
return snapshot;
|
||
}
|
||
}
|
||
}
|
||
getPreloadedSnapshot() {
|
||
if (this.snapshotHTML) {
|
||
return PageSnapshot.fromHTMLString(this.snapshotHTML);
|
||
}
|
||
}
|
||
hasCachedSnapshot() {
|
||
return this.getCachedSnapshot() != null;
|
||
}
|
||
loadCachedSnapshot() {
|
||
const snapshot = this.getCachedSnapshot();
|
||
if (snapshot) {
|
||
const isPreview = this.shouldIssueRequest();
|
||
this.render(async () => {
|
||
this.cacheSnapshot();
|
||
if (this.isSamePage) {
|
||
this.adapter.visitRendered(this);
|
||
} else {
|
||
if (this.view.renderPromise)
|
||
await this.view.renderPromise;
|
||
await this.view.renderPage(snapshot, isPreview, this.willRender, this);
|
||
this.performScroll();
|
||
this.adapter.visitRendered(this);
|
||
if (!isPreview) {
|
||
this.complete();
|
||
}
|
||
}
|
||
});
|
||
}
|
||
}
|
||
followRedirect() {
|
||
var _a;
|
||
if (this.redirectedToLocation && !this.followedRedirect && ((_a = this.response) === null || _a === void 0 ? void 0 : _a.redirected)) {
|
||
this.adapter.visitProposedToLocation(this.redirectedToLocation, {
|
||
action: "replace",
|
||
response: this.response,
|
||
shouldCacheSnapshot: false,
|
||
willRender: false
|
||
});
|
||
this.followedRedirect = true;
|
||
}
|
||
}
|
||
goToSamePageAnchor() {
|
||
if (this.isSamePage) {
|
||
this.render(async () => {
|
||
this.cacheSnapshot();
|
||
this.performScroll();
|
||
this.changeHistory();
|
||
this.adapter.visitRendered(this);
|
||
});
|
||
}
|
||
}
|
||
prepareRequest(request) {
|
||
if (this.acceptsStreamResponse) {
|
||
request.acceptResponseType(StreamMessage.contentType);
|
||
}
|
||
}
|
||
requestStarted() {
|
||
this.startRequest();
|
||
}
|
||
requestPreventedHandlingResponse(_request, _response) {
|
||
}
|
||
async requestSucceededWithResponse(request, response) {
|
||
const responseHTML = await response.responseHTML;
|
||
const { redirected, statusCode } = response;
|
||
if (responseHTML == void 0) {
|
||
this.recordResponse({
|
||
statusCode: SystemStatusCode.contentTypeMismatch,
|
||
redirected
|
||
});
|
||
} else {
|
||
this.redirectedToLocation = response.redirected ? response.location : void 0;
|
||
this.recordResponse({ statusCode, responseHTML, redirected });
|
||
}
|
||
}
|
||
async requestFailedWithResponse(request, response) {
|
||
const responseHTML = await response.responseHTML;
|
||
const { redirected, statusCode } = response;
|
||
if (responseHTML == void 0) {
|
||
this.recordResponse({
|
||
statusCode: SystemStatusCode.contentTypeMismatch,
|
||
redirected
|
||
});
|
||
} else {
|
||
this.recordResponse({ statusCode, responseHTML, redirected });
|
||
}
|
||
}
|
||
requestErrored(_request, _error) {
|
||
this.recordResponse({
|
||
statusCode: SystemStatusCode.networkFailure,
|
||
redirected: false
|
||
});
|
||
}
|
||
requestFinished() {
|
||
this.finishRequest();
|
||
}
|
||
performScroll() {
|
||
if (!this.scrolled && !this.view.forceReloaded) {
|
||
if (this.action == "restore") {
|
||
this.scrollToRestoredPosition() || this.scrollToAnchor() || this.view.scrollToTop();
|
||
} else {
|
||
this.scrollToAnchor() || this.view.scrollToTop();
|
||
}
|
||
if (this.isSamePage) {
|
||
this.delegate.visitScrolledToSamePageLocation(this.view.lastRenderedLocation, this.location);
|
||
}
|
||
this.scrolled = true;
|
||
}
|
||
}
|
||
scrollToRestoredPosition() {
|
||
const { scrollPosition } = this.restorationData;
|
||
if (scrollPosition) {
|
||
this.view.scrollToPosition(scrollPosition);
|
||
return true;
|
||
}
|
||
}
|
||
scrollToAnchor() {
|
||
const anchor = getAnchor(this.location);
|
||
if (anchor != null) {
|
||
this.view.scrollToAnchor(anchor);
|
||
return true;
|
||
}
|
||
}
|
||
recordTimingMetric(metric) {
|
||
this.timingMetrics[metric] = (/* @__PURE__ */ new Date()).getTime();
|
||
}
|
||
getTimingMetrics() {
|
||
return Object.assign({}, this.timingMetrics);
|
||
}
|
||
getHistoryMethodForAction(action) {
|
||
switch (action) {
|
||
case "replace":
|
||
return history.replaceState;
|
||
case "advance":
|
||
case "restore":
|
||
return history.pushState;
|
||
}
|
||
}
|
||
hasPreloadedResponse() {
|
||
return typeof this.response == "object";
|
||
}
|
||
shouldIssueRequest() {
|
||
if (this.isSamePage) {
|
||
return false;
|
||
} else if (this.action == "restore") {
|
||
return !this.hasCachedSnapshot();
|
||
} else {
|
||
return this.willRender;
|
||
}
|
||
}
|
||
cacheSnapshot() {
|
||
if (!this.snapshotCached) {
|
||
this.view.cacheSnapshot(this.snapshot).then((snapshot) => snapshot && this.visitCachedSnapshot(snapshot));
|
||
this.snapshotCached = true;
|
||
}
|
||
}
|
||
async render(callback) {
|
||
this.cancelRender();
|
||
await new Promise((resolve) => {
|
||
this.frame = requestAnimationFrame(() => resolve());
|
||
});
|
||
await callback();
|
||
delete this.frame;
|
||
}
|
||
cancelRender() {
|
||
if (this.frame) {
|
||
cancelAnimationFrame(this.frame);
|
||
delete this.frame;
|
||
}
|
||
}
|
||
};
|
||
function isSuccessful(statusCode) {
|
||
return statusCode >= 200 && statusCode < 300;
|
||
}
|
||
var BrowserAdapter = class {
|
||
constructor(session2) {
|
||
this.progressBar = new ProgressBar();
|
||
this.showProgressBar = () => {
|
||
this.progressBar.show();
|
||
};
|
||
this.session = session2;
|
||
}
|
||
visitProposedToLocation(location2, options) {
|
||
this.navigator.startVisit(location2, (options === null || options === void 0 ? void 0 : options.restorationIdentifier) || uuid(), options);
|
||
}
|
||
visitStarted(visit2) {
|
||
this.location = visit2.location;
|
||
visit2.loadCachedSnapshot();
|
||
visit2.issueRequest();
|
||
visit2.goToSamePageAnchor();
|
||
}
|
||
visitRequestStarted(visit2) {
|
||
this.progressBar.setValue(0);
|
||
if (visit2.hasCachedSnapshot() || visit2.action != "restore") {
|
||
this.showVisitProgressBarAfterDelay();
|
||
} else {
|
||
this.showProgressBar();
|
||
}
|
||
}
|
||
visitRequestCompleted(visit2) {
|
||
visit2.loadResponse();
|
||
}
|
||
visitRequestFailedWithStatusCode(visit2, statusCode) {
|
||
switch (statusCode) {
|
||
case SystemStatusCode.networkFailure:
|
||
case SystemStatusCode.timeoutFailure:
|
||
case SystemStatusCode.contentTypeMismatch:
|
||
return this.reload({
|
||
reason: "request_failed",
|
||
context: {
|
||
statusCode
|
||
}
|
||
});
|
||
default:
|
||
return visit2.loadResponse();
|
||
}
|
||
}
|
||
visitRequestFinished(_visit) {
|
||
this.progressBar.setValue(1);
|
||
this.hideVisitProgressBar();
|
||
}
|
||
visitCompleted(_visit) {
|
||
}
|
||
pageInvalidated(reason) {
|
||
this.reload(reason);
|
||
}
|
||
visitFailed(_visit) {
|
||
}
|
||
visitRendered(_visit) {
|
||
}
|
||
formSubmissionStarted(_formSubmission) {
|
||
this.progressBar.setValue(0);
|
||
this.showFormProgressBarAfterDelay();
|
||
}
|
||
formSubmissionFinished(_formSubmission) {
|
||
this.progressBar.setValue(1);
|
||
this.hideFormProgressBar();
|
||
}
|
||
showVisitProgressBarAfterDelay() {
|
||
this.visitProgressBarTimeout = window.setTimeout(this.showProgressBar, this.session.progressBarDelay);
|
||
}
|
||
hideVisitProgressBar() {
|
||
this.progressBar.hide();
|
||
if (this.visitProgressBarTimeout != null) {
|
||
window.clearTimeout(this.visitProgressBarTimeout);
|
||
delete this.visitProgressBarTimeout;
|
||
}
|
||
}
|
||
showFormProgressBarAfterDelay() {
|
||
if (this.formProgressBarTimeout == null) {
|
||
this.formProgressBarTimeout = window.setTimeout(this.showProgressBar, this.session.progressBarDelay);
|
||
}
|
||
}
|
||
hideFormProgressBar() {
|
||
this.progressBar.hide();
|
||
if (this.formProgressBarTimeout != null) {
|
||
window.clearTimeout(this.formProgressBarTimeout);
|
||
delete this.formProgressBarTimeout;
|
||
}
|
||
}
|
||
reload(reason) {
|
||
var _a;
|
||
dispatch("turbo:reload", { detail: reason });
|
||
window.location.href = ((_a = this.location) === null || _a === void 0 ? void 0 : _a.toString()) || window.location.href;
|
||
}
|
||
get navigator() {
|
||
return this.session.navigator;
|
||
}
|
||
};
|
||
var CacheObserver = class {
|
||
constructor() {
|
||
this.selector = "[data-turbo-temporary]";
|
||
this.deprecatedSelector = "[data-turbo-cache=false]";
|
||
this.started = false;
|
||
this.removeTemporaryElements = (_event) => {
|
||
for (const element of this.temporaryElements) {
|
||
element.remove();
|
||
}
|
||
};
|
||
}
|
||
start() {
|
||
if (!this.started) {
|
||
this.started = true;
|
||
addEventListener("turbo:before-cache", this.removeTemporaryElements, false);
|
||
}
|
||
}
|
||
stop() {
|
||
if (this.started) {
|
||
this.started = false;
|
||
removeEventListener("turbo:before-cache", this.removeTemporaryElements, false);
|
||
}
|
||
}
|
||
get temporaryElements() {
|
||
return [...document.querySelectorAll(this.selector), ...this.temporaryElementsWithDeprecation];
|
||
}
|
||
get temporaryElementsWithDeprecation() {
|
||
const elements = document.querySelectorAll(this.deprecatedSelector);
|
||
if (elements.length) {
|
||
console.warn(`The ${this.deprecatedSelector} selector is deprecated and will be removed in a future version. Use ${this.selector} instead.`);
|
||
}
|
||
return [...elements];
|
||
}
|
||
};
|
||
var FrameRedirector = class {
|
||
constructor(session2, element) {
|
||
this.session = session2;
|
||
this.element = element;
|
||
this.linkInterceptor = new LinkInterceptor(this, element);
|
||
this.formSubmitObserver = new FormSubmitObserver(this, element);
|
||
}
|
||
start() {
|
||
this.linkInterceptor.start();
|
||
this.formSubmitObserver.start();
|
||
}
|
||
stop() {
|
||
this.linkInterceptor.stop();
|
||
this.formSubmitObserver.stop();
|
||
}
|
||
shouldInterceptLinkClick(element, _location, _event) {
|
||
return this.shouldRedirect(element);
|
||
}
|
||
linkClickIntercepted(element, url, event) {
|
||
const frame = this.findFrameElement(element);
|
||
if (frame) {
|
||
frame.delegate.linkClickIntercepted(element, url, event);
|
||
}
|
||
}
|
||
willSubmitForm(element, submitter) {
|
||
return element.closest("turbo-frame") == null && this.shouldSubmit(element, submitter) && this.shouldRedirect(element, submitter);
|
||
}
|
||
formSubmitted(element, submitter) {
|
||
const frame = this.findFrameElement(element, submitter);
|
||
if (frame) {
|
||
frame.delegate.formSubmitted(element, submitter);
|
||
}
|
||
}
|
||
shouldSubmit(form, submitter) {
|
||
var _a;
|
||
const action = getAction(form, submitter);
|
||
const meta = this.element.ownerDocument.querySelector(`meta[name="turbo-root"]`);
|
||
const rootLocation = expandURL((_a = meta === null || meta === void 0 ? void 0 : meta.content) !== null && _a !== void 0 ? _a : "/");
|
||
return this.shouldRedirect(form, submitter) && locationIsVisitable(action, rootLocation);
|
||
}
|
||
shouldRedirect(element, submitter) {
|
||
const isNavigatable = element instanceof HTMLFormElement ? this.session.submissionIsNavigatable(element, submitter) : this.session.elementIsNavigatable(element);
|
||
if (isNavigatable) {
|
||
const frame = this.findFrameElement(element, submitter);
|
||
return frame ? frame != element.closest("turbo-frame") : false;
|
||
} else {
|
||
return false;
|
||
}
|
||
}
|
||
findFrameElement(element, submitter) {
|
||
const id2 = (submitter === null || submitter === void 0 ? void 0 : submitter.getAttribute("data-turbo-frame")) || element.getAttribute("data-turbo-frame");
|
||
if (id2 && id2 != "_top") {
|
||
const frame = this.element.querySelector(`#${id2}:not([disabled])`);
|
||
if (frame instanceof FrameElement) {
|
||
return frame;
|
||
}
|
||
}
|
||
}
|
||
};
|
||
var History = class {
|
||
constructor(delegate) {
|
||
this.restorationIdentifier = uuid();
|
||
this.restorationData = {};
|
||
this.started = false;
|
||
this.pageLoaded = false;
|
||
this.onPopState = (event) => {
|
||
if (this.shouldHandlePopState()) {
|
||
const { turbo } = event.state || {};
|
||
if (turbo) {
|
||
this.location = new URL(window.location.href);
|
||
const { restorationIdentifier } = turbo;
|
||
this.restorationIdentifier = restorationIdentifier;
|
||
this.delegate.historyPoppedToLocationWithRestorationIdentifier(this.location, restorationIdentifier);
|
||
}
|
||
}
|
||
};
|
||
this.onPageLoad = async (_event) => {
|
||
await nextMicrotask();
|
||
this.pageLoaded = true;
|
||
};
|
||
this.delegate = delegate;
|
||
}
|
||
start() {
|
||
if (!this.started) {
|
||
addEventListener("popstate", this.onPopState, false);
|
||
addEventListener("load", this.onPageLoad, false);
|
||
this.started = true;
|
||
this.replace(new URL(window.location.href));
|
||
}
|
||
}
|
||
stop() {
|
||
if (this.started) {
|
||
removeEventListener("popstate", this.onPopState, false);
|
||
removeEventListener("load", this.onPageLoad, false);
|
||
this.started = false;
|
||
}
|
||
}
|
||
push(location2, restorationIdentifier) {
|
||
this.update(history.pushState, location2, restorationIdentifier);
|
||
}
|
||
replace(location2, restorationIdentifier) {
|
||
this.update(history.replaceState, location2, restorationIdentifier);
|
||
}
|
||
update(method, location2, restorationIdentifier = uuid()) {
|
||
const state = { turbo: { restorationIdentifier } };
|
||
method.call(history, state, "", location2.href);
|
||
this.location = location2;
|
||
this.restorationIdentifier = restorationIdentifier;
|
||
}
|
||
getRestorationDataForIdentifier(restorationIdentifier) {
|
||
return this.restorationData[restorationIdentifier] || {};
|
||
}
|
||
updateRestorationData(additionalData) {
|
||
const { restorationIdentifier } = this;
|
||
const restorationData = this.restorationData[restorationIdentifier];
|
||
this.restorationData[restorationIdentifier] = Object.assign(Object.assign({}, restorationData), additionalData);
|
||
}
|
||
assumeControlOfScrollRestoration() {
|
||
var _a;
|
||
if (!this.previousScrollRestoration) {
|
||
this.previousScrollRestoration = (_a = history.scrollRestoration) !== null && _a !== void 0 ? _a : "auto";
|
||
history.scrollRestoration = "manual";
|
||
}
|
||
}
|
||
relinquishControlOfScrollRestoration() {
|
||
if (this.previousScrollRestoration) {
|
||
history.scrollRestoration = this.previousScrollRestoration;
|
||
delete this.previousScrollRestoration;
|
||
}
|
||
}
|
||
shouldHandlePopState() {
|
||
return this.pageIsLoaded();
|
||
}
|
||
pageIsLoaded() {
|
||
return this.pageLoaded || document.readyState == "complete";
|
||
}
|
||
};
|
||
var Navigator = class {
|
||
constructor(delegate) {
|
||
this.delegate = delegate;
|
||
}
|
||
proposeVisit(location2, options = {}) {
|
||
if (this.delegate.allowsVisitingLocationWithAction(location2, options.action)) {
|
||
if (locationIsVisitable(location2, this.view.snapshot.rootLocation)) {
|
||
this.delegate.visitProposedToLocation(location2, options);
|
||
} else {
|
||
window.location.href = location2.toString();
|
||
}
|
||
}
|
||
}
|
||
startVisit(locatable, restorationIdentifier, options = {}) {
|
||
this.stop();
|
||
this.currentVisit = new Visit(this, expandURL(locatable), restorationIdentifier, Object.assign({ referrer: this.location }, options));
|
||
this.currentVisit.start();
|
||
}
|
||
submitForm(form, submitter) {
|
||
this.stop();
|
||
this.formSubmission = new FormSubmission(this, form, submitter, true);
|
||
this.formSubmission.start();
|
||
}
|
||
stop() {
|
||
if (this.formSubmission) {
|
||
this.formSubmission.stop();
|
||
delete this.formSubmission;
|
||
}
|
||
if (this.currentVisit) {
|
||
this.currentVisit.cancel();
|
||
delete this.currentVisit;
|
||
}
|
||
}
|
||
get adapter() {
|
||
return this.delegate.adapter;
|
||
}
|
||
get view() {
|
||
return this.delegate.view;
|
||
}
|
||
get history() {
|
||
return this.delegate.history;
|
||
}
|
||
formSubmissionStarted(formSubmission) {
|
||
if (typeof this.adapter.formSubmissionStarted === "function") {
|
||
this.adapter.formSubmissionStarted(formSubmission);
|
||
}
|
||
}
|
||
async formSubmissionSucceededWithResponse(formSubmission, fetchResponse) {
|
||
if (formSubmission == this.formSubmission) {
|
||
const responseHTML = await fetchResponse.responseHTML;
|
||
if (responseHTML) {
|
||
const shouldCacheSnapshot = formSubmission.isSafe;
|
||
if (!shouldCacheSnapshot) {
|
||
this.view.clearSnapshotCache();
|
||
}
|
||
const { statusCode, redirected } = fetchResponse;
|
||
const action = this.getActionForFormSubmission(formSubmission);
|
||
const visitOptions = {
|
||
action,
|
||
shouldCacheSnapshot,
|
||
response: { statusCode, responseHTML, redirected }
|
||
};
|
||
this.proposeVisit(fetchResponse.location, visitOptions);
|
||
}
|
||
}
|
||
}
|
||
async formSubmissionFailedWithResponse(formSubmission, fetchResponse) {
|
||
const responseHTML = await fetchResponse.responseHTML;
|
||
if (responseHTML) {
|
||
const snapshot = PageSnapshot.fromHTMLString(responseHTML);
|
||
if (fetchResponse.serverError) {
|
||
await this.view.renderError(snapshot, this.currentVisit);
|
||
} else {
|
||
await this.view.renderPage(snapshot, false, true, this.currentVisit);
|
||
}
|
||
this.view.scrollToTop();
|
||
this.view.clearSnapshotCache();
|
||
}
|
||
}
|
||
formSubmissionErrored(formSubmission, error2) {
|
||
console.error(error2);
|
||
}
|
||
formSubmissionFinished(formSubmission) {
|
||
if (typeof this.adapter.formSubmissionFinished === "function") {
|
||
this.adapter.formSubmissionFinished(formSubmission);
|
||
}
|
||
}
|
||
visitStarted(visit2) {
|
||
this.delegate.visitStarted(visit2);
|
||
}
|
||
visitCompleted(visit2) {
|
||
this.delegate.visitCompleted(visit2);
|
||
}
|
||
locationWithActionIsSamePage(location2, action) {
|
||
const anchor = getAnchor(location2);
|
||
const currentAnchor = getAnchor(this.view.lastRenderedLocation);
|
||
const isRestorationToTop = action === "restore" && typeof anchor === "undefined";
|
||
return action !== "replace" && getRequestURL(location2) === getRequestURL(this.view.lastRenderedLocation) && (isRestorationToTop || anchor != null && anchor !== currentAnchor);
|
||
}
|
||
visitScrolledToSamePageLocation(oldURL, newURL) {
|
||
this.delegate.visitScrolledToSamePageLocation(oldURL, newURL);
|
||
}
|
||
get location() {
|
||
return this.history.location;
|
||
}
|
||
get restorationIdentifier() {
|
||
return this.history.restorationIdentifier;
|
||
}
|
||
getActionForFormSubmission({ submitter, formElement }) {
|
||
return getVisitAction(submitter, formElement) || "advance";
|
||
}
|
||
};
|
||
var PageStage;
|
||
(function(PageStage2) {
|
||
PageStage2[PageStage2["initial"] = 0] = "initial";
|
||
PageStage2[PageStage2["loading"] = 1] = "loading";
|
||
PageStage2[PageStage2["interactive"] = 2] = "interactive";
|
||
PageStage2[PageStage2["complete"] = 3] = "complete";
|
||
})(PageStage || (PageStage = {}));
|
||
var PageObserver = class {
|
||
constructor(delegate) {
|
||
this.stage = PageStage.initial;
|
||
this.started = false;
|
||
this.interpretReadyState = () => {
|
||
const { readyState } = this;
|
||
if (readyState == "interactive") {
|
||
this.pageIsInteractive();
|
||
} else if (readyState == "complete") {
|
||
this.pageIsComplete();
|
||
}
|
||
};
|
||
this.pageWillUnload = () => {
|
||
this.delegate.pageWillUnload();
|
||
};
|
||
this.delegate = delegate;
|
||
}
|
||
start() {
|
||
if (!this.started) {
|
||
if (this.stage == PageStage.initial) {
|
||
this.stage = PageStage.loading;
|
||
}
|
||
document.addEventListener("readystatechange", this.interpretReadyState, false);
|
||
addEventListener("pagehide", this.pageWillUnload, false);
|
||
this.started = true;
|
||
}
|
||
}
|
||
stop() {
|
||
if (this.started) {
|
||
document.removeEventListener("readystatechange", this.interpretReadyState, false);
|
||
removeEventListener("pagehide", this.pageWillUnload, false);
|
||
this.started = false;
|
||
}
|
||
}
|
||
pageIsInteractive() {
|
||
if (this.stage == PageStage.loading) {
|
||
this.stage = PageStage.interactive;
|
||
this.delegate.pageBecameInteractive();
|
||
}
|
||
}
|
||
pageIsComplete() {
|
||
this.pageIsInteractive();
|
||
if (this.stage == PageStage.interactive) {
|
||
this.stage = PageStage.complete;
|
||
this.delegate.pageLoaded();
|
||
}
|
||
}
|
||
get readyState() {
|
||
return document.readyState;
|
||
}
|
||
};
|
||
var ScrollObserver = class {
|
||
constructor(delegate) {
|
||
this.started = false;
|
||
this.onScroll = () => {
|
||
this.updatePosition({ x: window.pageXOffset, y: window.pageYOffset });
|
||
};
|
||
this.delegate = delegate;
|
||
}
|
||
start() {
|
||
if (!this.started) {
|
||
addEventListener("scroll", this.onScroll, false);
|
||
this.onScroll();
|
||
this.started = true;
|
||
}
|
||
}
|
||
stop() {
|
||
if (this.started) {
|
||
removeEventListener("scroll", this.onScroll, false);
|
||
this.started = false;
|
||
}
|
||
}
|
||
updatePosition(position) {
|
||
this.delegate.scrollPositionChanged(position);
|
||
}
|
||
};
|
||
var StreamMessageRenderer = class {
|
||
render({ fragment }) {
|
||
Bardo.preservingPermanentElements(this, getPermanentElementMapForFragment(fragment), () => document.documentElement.appendChild(fragment));
|
||
}
|
||
enteringBardo(currentPermanentElement, newPermanentElement) {
|
||
newPermanentElement.replaceWith(currentPermanentElement.cloneNode(true));
|
||
}
|
||
leavingBardo() {
|
||
}
|
||
};
|
||
function getPermanentElementMapForFragment(fragment) {
|
||
const permanentElementsInDocument = queryPermanentElementsAll(document.documentElement);
|
||
const permanentElementMap = {};
|
||
for (const permanentElementInDocument of permanentElementsInDocument) {
|
||
const { id: id2 } = permanentElementInDocument;
|
||
for (const streamElement of fragment.querySelectorAll("turbo-stream")) {
|
||
const elementInStream = getPermanentElementById(streamElement.templateElement.content, id2);
|
||
if (elementInStream) {
|
||
permanentElementMap[id2] = [permanentElementInDocument, elementInStream];
|
||
}
|
||
}
|
||
}
|
||
return permanentElementMap;
|
||
}
|
||
var StreamObserver = class {
|
||
constructor(delegate) {
|
||
this.sources = /* @__PURE__ */ new Set();
|
||
this.started = false;
|
||
this.inspectFetchResponse = (event) => {
|
||
const response = fetchResponseFromEvent(event);
|
||
if (response && fetchResponseIsStream(response)) {
|
||
event.preventDefault();
|
||
this.receiveMessageResponse(response);
|
||
}
|
||
};
|
||
this.receiveMessageEvent = (event) => {
|
||
if (this.started && typeof event.data == "string") {
|
||
this.receiveMessageHTML(event.data);
|
||
}
|
||
};
|
||
this.delegate = delegate;
|
||
}
|
||
start() {
|
||
if (!this.started) {
|
||
this.started = true;
|
||
addEventListener("turbo:before-fetch-response", this.inspectFetchResponse, false);
|
||
}
|
||
}
|
||
stop() {
|
||
if (this.started) {
|
||
this.started = false;
|
||
removeEventListener("turbo:before-fetch-response", this.inspectFetchResponse, false);
|
||
}
|
||
}
|
||
connectStreamSource(source) {
|
||
if (!this.streamSourceIsConnected(source)) {
|
||
this.sources.add(source);
|
||
source.addEventListener("message", this.receiveMessageEvent, false);
|
||
}
|
||
}
|
||
disconnectStreamSource(source) {
|
||
if (this.streamSourceIsConnected(source)) {
|
||
this.sources.delete(source);
|
||
source.removeEventListener("message", this.receiveMessageEvent, false);
|
||
}
|
||
}
|
||
streamSourceIsConnected(source) {
|
||
return this.sources.has(source);
|
||
}
|
||
async receiveMessageResponse(response) {
|
||
const html = await response.responseHTML;
|
||
if (html) {
|
||
this.receiveMessageHTML(html);
|
||
}
|
||
}
|
||
receiveMessageHTML(html) {
|
||
this.delegate.receivedMessageFromStream(StreamMessage.wrap(html));
|
||
}
|
||
};
|
||
function fetchResponseFromEvent(event) {
|
||
var _a;
|
||
const fetchResponse = (_a = event.detail) === null || _a === void 0 ? void 0 : _a.fetchResponse;
|
||
if (fetchResponse instanceof FetchResponse) {
|
||
return fetchResponse;
|
||
}
|
||
}
|
||
function fetchResponseIsStream(response) {
|
||
var _a;
|
||
const contentType = (_a = response.contentType) !== null && _a !== void 0 ? _a : "";
|
||
return contentType.startsWith(StreamMessage.contentType);
|
||
}
|
||
var ErrorRenderer = class extends Renderer {
|
||
static renderElement(currentElement, newElement) {
|
||
const { documentElement, body } = document;
|
||
documentElement.replaceChild(newElement, body);
|
||
}
|
||
async render() {
|
||
this.replaceHeadAndBody();
|
||
this.activateScriptElements();
|
||
}
|
||
replaceHeadAndBody() {
|
||
const { documentElement, head } = document;
|
||
documentElement.replaceChild(this.newHead, head);
|
||
this.renderElement(this.currentElement, this.newElement);
|
||
}
|
||
activateScriptElements() {
|
||
for (const replaceableElement of this.scriptElements) {
|
||
const parentNode = replaceableElement.parentNode;
|
||
if (parentNode) {
|
||
const element = activateScriptElement(replaceableElement);
|
||
parentNode.replaceChild(element, replaceableElement);
|
||
}
|
||
}
|
||
}
|
||
get newHead() {
|
||
return this.newSnapshot.headSnapshot.element;
|
||
}
|
||
get scriptElements() {
|
||
return document.documentElement.querySelectorAll("script");
|
||
}
|
||
};
|
||
var PageRenderer = class extends Renderer {
|
||
static renderElement(currentElement, newElement) {
|
||
if (document.body && newElement instanceof HTMLBodyElement) {
|
||
document.body.replaceWith(newElement);
|
||
} else {
|
||
document.documentElement.appendChild(newElement);
|
||
}
|
||
}
|
||
get shouldRender() {
|
||
return this.newSnapshot.isVisitable && this.trackedElementsAreIdentical;
|
||
}
|
||
get reloadReason() {
|
||
if (!this.newSnapshot.isVisitable) {
|
||
return {
|
||
reason: "turbo_visit_control_is_reload"
|
||
};
|
||
}
|
||
if (!this.trackedElementsAreIdentical) {
|
||
return {
|
||
reason: "tracked_element_mismatch"
|
||
};
|
||
}
|
||
}
|
||
async prepareToRender() {
|
||
await this.mergeHead();
|
||
}
|
||
async render() {
|
||
if (this.willRender) {
|
||
await this.replaceBody();
|
||
}
|
||
}
|
||
finishRendering() {
|
||
super.finishRendering();
|
||
if (!this.isPreview) {
|
||
this.focusFirstAutofocusableElement();
|
||
}
|
||
}
|
||
get currentHeadSnapshot() {
|
||
return this.currentSnapshot.headSnapshot;
|
||
}
|
||
get newHeadSnapshot() {
|
||
return this.newSnapshot.headSnapshot;
|
||
}
|
||
get newElement() {
|
||
return this.newSnapshot.element;
|
||
}
|
||
async mergeHead() {
|
||
const mergedHeadElements = this.mergeProvisionalElements();
|
||
const newStylesheetElements = this.copyNewHeadStylesheetElements();
|
||
this.copyNewHeadScriptElements();
|
||
await mergedHeadElements;
|
||
await newStylesheetElements;
|
||
}
|
||
async replaceBody() {
|
||
await this.preservingPermanentElements(async () => {
|
||
this.activateNewBody();
|
||
await this.assignNewBody();
|
||
});
|
||
}
|
||
get trackedElementsAreIdentical() {
|
||
return this.currentHeadSnapshot.trackedElementSignature == this.newHeadSnapshot.trackedElementSignature;
|
||
}
|
||
async copyNewHeadStylesheetElements() {
|
||
const loadingElements = [];
|
||
for (const element of this.newHeadStylesheetElements) {
|
||
loadingElements.push(waitForLoad(element));
|
||
document.head.appendChild(element);
|
||
}
|
||
await Promise.all(loadingElements);
|
||
}
|
||
copyNewHeadScriptElements() {
|
||
for (const element of this.newHeadScriptElements) {
|
||
document.head.appendChild(activateScriptElement(element));
|
||
}
|
||
}
|
||
async mergeProvisionalElements() {
|
||
const newHeadElements = [...this.newHeadProvisionalElements];
|
||
for (const element of this.currentHeadProvisionalElements) {
|
||
if (!this.isCurrentElementInElementList(element, newHeadElements)) {
|
||
document.head.removeChild(element);
|
||
}
|
||
}
|
||
for (const element of newHeadElements) {
|
||
document.head.appendChild(element);
|
||
}
|
||
}
|
||
isCurrentElementInElementList(element, elementList) {
|
||
for (const [index, newElement] of elementList.entries()) {
|
||
if (element.tagName == "TITLE") {
|
||
if (newElement.tagName != "TITLE") {
|
||
continue;
|
||
}
|
||
if (element.innerHTML == newElement.innerHTML) {
|
||
elementList.splice(index, 1);
|
||
return true;
|
||
}
|
||
}
|
||
if (newElement.isEqualNode(element)) {
|
||
elementList.splice(index, 1);
|
||
return true;
|
||
}
|
||
}
|
||
return false;
|
||
}
|
||
removeCurrentHeadProvisionalElements() {
|
||
for (const element of this.currentHeadProvisionalElements) {
|
||
document.head.removeChild(element);
|
||
}
|
||
}
|
||
copyNewHeadProvisionalElements() {
|
||
for (const element of this.newHeadProvisionalElements) {
|
||
document.head.appendChild(element);
|
||
}
|
||
}
|
||
activateNewBody() {
|
||
document.adoptNode(this.newElement);
|
||
this.activateNewBodyScriptElements();
|
||
}
|
||
activateNewBodyScriptElements() {
|
||
for (const inertScriptElement of this.newBodyScriptElements) {
|
||
const activatedScriptElement = activateScriptElement(inertScriptElement);
|
||
inertScriptElement.replaceWith(activatedScriptElement);
|
||
}
|
||
}
|
||
async assignNewBody() {
|
||
await this.renderElement(this.currentElement, this.newElement);
|
||
}
|
||
get newHeadStylesheetElements() {
|
||
return this.newHeadSnapshot.getStylesheetElementsNotInSnapshot(this.currentHeadSnapshot);
|
||
}
|
||
get newHeadScriptElements() {
|
||
return this.newHeadSnapshot.getScriptElementsNotInSnapshot(this.currentHeadSnapshot);
|
||
}
|
||
get currentHeadProvisionalElements() {
|
||
return this.currentHeadSnapshot.provisionalElements;
|
||
}
|
||
get newHeadProvisionalElements() {
|
||
return this.newHeadSnapshot.provisionalElements;
|
||
}
|
||
get newBodyScriptElements() {
|
||
return this.newElement.querySelectorAll("script");
|
||
}
|
||
};
|
||
var SnapshotCache = class {
|
||
constructor(size) {
|
||
this.keys = [];
|
||
this.snapshots = {};
|
||
this.size = size;
|
||
}
|
||
has(location2) {
|
||
return toCacheKey(location2) in this.snapshots;
|
||
}
|
||
get(location2) {
|
||
if (this.has(location2)) {
|
||
const snapshot = this.read(location2);
|
||
this.touch(location2);
|
||
return snapshot;
|
||
}
|
||
}
|
||
put(location2, snapshot) {
|
||
this.write(location2, snapshot);
|
||
this.touch(location2);
|
||
return snapshot;
|
||
}
|
||
clear() {
|
||
this.snapshots = {};
|
||
}
|
||
read(location2) {
|
||
return this.snapshots[toCacheKey(location2)];
|
||
}
|
||
write(location2, snapshot) {
|
||
this.snapshots[toCacheKey(location2)] = snapshot;
|
||
}
|
||
touch(location2) {
|
||
const key = toCacheKey(location2);
|
||
const index = this.keys.indexOf(key);
|
||
if (index > -1)
|
||
this.keys.splice(index, 1);
|
||
this.keys.unshift(key);
|
||
this.trim();
|
||
}
|
||
trim() {
|
||
for (const key of this.keys.splice(this.size)) {
|
||
delete this.snapshots[key];
|
||
}
|
||
}
|
||
};
|
||
var PageView = class extends View {
|
||
constructor() {
|
||
super(...arguments);
|
||
this.snapshotCache = new SnapshotCache(10);
|
||
this.lastRenderedLocation = new URL(location.href);
|
||
this.forceReloaded = false;
|
||
}
|
||
renderPage(snapshot, isPreview = false, willRender = true, visit2) {
|
||
const renderer = new PageRenderer(this.snapshot, snapshot, PageRenderer.renderElement, isPreview, willRender);
|
||
if (!renderer.shouldRender) {
|
||
this.forceReloaded = true;
|
||
} else {
|
||
visit2 === null || visit2 === void 0 ? void 0 : visit2.changeHistory();
|
||
}
|
||
return this.render(renderer);
|
||
}
|
||
renderError(snapshot, visit2) {
|
||
visit2 === null || visit2 === void 0 ? void 0 : visit2.changeHistory();
|
||
const renderer = new ErrorRenderer(this.snapshot, snapshot, ErrorRenderer.renderElement, false);
|
||
return this.render(renderer);
|
||
}
|
||
clearSnapshotCache() {
|
||
this.snapshotCache.clear();
|
||
}
|
||
async cacheSnapshot(snapshot = this.snapshot) {
|
||
if (snapshot.isCacheable) {
|
||
this.delegate.viewWillCacheSnapshot();
|
||
const { lastRenderedLocation: location2 } = this;
|
||
await nextEventLoopTick();
|
||
const cachedSnapshot = snapshot.clone();
|
||
this.snapshotCache.put(location2, cachedSnapshot);
|
||
return cachedSnapshot;
|
||
}
|
||
}
|
||
getCachedSnapshotForLocation(location2) {
|
||
return this.snapshotCache.get(location2);
|
||
}
|
||
get snapshot() {
|
||
return PageSnapshot.fromElement(this.element);
|
||
}
|
||
};
|
||
var Preloader = class {
|
||
constructor(delegate) {
|
||
this.selector = "a[data-turbo-preload]";
|
||
this.delegate = delegate;
|
||
}
|
||
get snapshotCache() {
|
||
return this.delegate.navigator.view.snapshotCache;
|
||
}
|
||
start() {
|
||
if (document.readyState === "loading") {
|
||
return document.addEventListener("DOMContentLoaded", () => {
|
||
this.preloadOnLoadLinksForView(document.body);
|
||
});
|
||
} else {
|
||
this.preloadOnLoadLinksForView(document.body);
|
||
}
|
||
}
|
||
preloadOnLoadLinksForView(element) {
|
||
for (const link of element.querySelectorAll(this.selector)) {
|
||
this.preloadURL(link);
|
||
}
|
||
}
|
||
async preloadURL(link) {
|
||
const location2 = new URL(link.href);
|
||
if (this.snapshotCache.has(location2)) {
|
||
return;
|
||
}
|
||
try {
|
||
const response = await fetch(location2.toString(), { headers: { "VND.PREFETCH": "true", Accept: "text/html" } });
|
||
const responseText = await response.text();
|
||
const snapshot = PageSnapshot.fromHTMLString(responseText);
|
||
this.snapshotCache.put(location2, snapshot);
|
||
} catch (_) {
|
||
}
|
||
}
|
||
};
|
||
var Session = class {
|
||
constructor() {
|
||
this.navigator = new Navigator(this);
|
||
this.history = new History(this);
|
||
this.preloader = new Preloader(this);
|
||
this.view = new PageView(this, document.documentElement);
|
||
this.adapter = new BrowserAdapter(this);
|
||
this.pageObserver = new PageObserver(this);
|
||
this.cacheObserver = new CacheObserver();
|
||
this.linkClickObserver = new LinkClickObserver(this, window);
|
||
this.formSubmitObserver = new FormSubmitObserver(this, document);
|
||
this.scrollObserver = new ScrollObserver(this);
|
||
this.streamObserver = new StreamObserver(this);
|
||
this.formLinkClickObserver = new FormLinkClickObserver(this, document.documentElement);
|
||
this.frameRedirector = new FrameRedirector(this, document.documentElement);
|
||
this.streamMessageRenderer = new StreamMessageRenderer();
|
||
this.drive = true;
|
||
this.enabled = true;
|
||
this.progressBarDelay = 500;
|
||
this.started = false;
|
||
this.formMode = "on";
|
||
}
|
||
start() {
|
||
if (!this.started) {
|
||
this.pageObserver.start();
|
||
this.cacheObserver.start();
|
||
this.formLinkClickObserver.start();
|
||
this.linkClickObserver.start();
|
||
this.formSubmitObserver.start();
|
||
this.scrollObserver.start();
|
||
this.streamObserver.start();
|
||
this.frameRedirector.start();
|
||
this.history.start();
|
||
this.preloader.start();
|
||
this.started = true;
|
||
this.enabled = true;
|
||
}
|
||
}
|
||
disable() {
|
||
this.enabled = false;
|
||
}
|
||
stop() {
|
||
if (this.started) {
|
||
this.pageObserver.stop();
|
||
this.cacheObserver.stop();
|
||
this.formLinkClickObserver.stop();
|
||
this.linkClickObserver.stop();
|
||
this.formSubmitObserver.stop();
|
||
this.scrollObserver.stop();
|
||
this.streamObserver.stop();
|
||
this.frameRedirector.stop();
|
||
this.history.stop();
|
||
this.started = false;
|
||
}
|
||
}
|
||
registerAdapter(adapter) {
|
||
this.adapter = adapter;
|
||
}
|
||
visit(location2, options = {}) {
|
||
const frameElement = options.frame ? document.getElementById(options.frame) : null;
|
||
if (frameElement instanceof FrameElement) {
|
||
frameElement.src = location2.toString();
|
||
frameElement.loaded;
|
||
} else {
|
||
this.navigator.proposeVisit(expandURL(location2), options);
|
||
}
|
||
}
|
||
connectStreamSource(source) {
|
||
this.streamObserver.connectStreamSource(source);
|
||
}
|
||
disconnectStreamSource(source) {
|
||
this.streamObserver.disconnectStreamSource(source);
|
||
}
|
||
renderStreamMessage(message) {
|
||
this.streamMessageRenderer.render(StreamMessage.wrap(message));
|
||
}
|
||
clearCache() {
|
||
this.view.clearSnapshotCache();
|
||
}
|
||
setProgressBarDelay(delay) {
|
||
this.progressBarDelay = delay;
|
||
}
|
||
setFormMode(mode) {
|
||
this.formMode = mode;
|
||
}
|
||
get location() {
|
||
return this.history.location;
|
||
}
|
||
get restorationIdentifier() {
|
||
return this.history.restorationIdentifier;
|
||
}
|
||
historyPoppedToLocationWithRestorationIdentifier(location2, restorationIdentifier) {
|
||
if (this.enabled) {
|
||
this.navigator.startVisit(location2, restorationIdentifier, {
|
||
action: "restore",
|
||
historyChanged: true
|
||
});
|
||
} else {
|
||
this.adapter.pageInvalidated({
|
||
reason: "turbo_disabled"
|
||
});
|
||
}
|
||
}
|
||
scrollPositionChanged(position) {
|
||
this.history.updateRestorationData({ scrollPosition: position });
|
||
}
|
||
willSubmitFormLinkToLocation(link, location2) {
|
||
return this.elementIsNavigatable(link) && locationIsVisitable(location2, this.snapshot.rootLocation);
|
||
}
|
||
submittedFormLinkToLocation() {
|
||
}
|
||
willFollowLinkToLocation(link, location2, event) {
|
||
return this.elementIsNavigatable(link) && locationIsVisitable(location2, this.snapshot.rootLocation) && this.applicationAllowsFollowingLinkToLocation(link, location2, event);
|
||
}
|
||
followedLinkToLocation(link, location2) {
|
||
const action = this.getActionForLink(link);
|
||
const acceptsStreamResponse = link.hasAttribute("data-turbo-stream");
|
||
this.visit(location2.href, { action, acceptsStreamResponse });
|
||
}
|
||
allowsVisitingLocationWithAction(location2, action) {
|
||
return this.locationWithActionIsSamePage(location2, action) || this.applicationAllowsVisitingLocation(location2);
|
||
}
|
||
visitProposedToLocation(location2, options) {
|
||
extendURLWithDeprecatedProperties(location2);
|
||
this.adapter.visitProposedToLocation(location2, options);
|
||
}
|
||
visitStarted(visit2) {
|
||
if (!visit2.acceptsStreamResponse) {
|
||
markAsBusy(document.documentElement);
|
||
}
|
||
extendURLWithDeprecatedProperties(visit2.location);
|
||
if (!visit2.silent) {
|
||
this.notifyApplicationAfterVisitingLocation(visit2.location, visit2.action);
|
||
}
|
||
}
|
||
visitCompleted(visit2) {
|
||
clearBusyState(document.documentElement);
|
||
this.notifyApplicationAfterPageLoad(visit2.getTimingMetrics());
|
||
}
|
||
locationWithActionIsSamePage(location2, action) {
|
||
return this.navigator.locationWithActionIsSamePage(location2, action);
|
||
}
|
||
visitScrolledToSamePageLocation(oldURL, newURL) {
|
||
this.notifyApplicationAfterVisitingSamePageLocation(oldURL, newURL);
|
||
}
|
||
willSubmitForm(form, submitter) {
|
||
const action = getAction(form, submitter);
|
||
return this.submissionIsNavigatable(form, submitter) && locationIsVisitable(expandURL(action), this.snapshot.rootLocation);
|
||
}
|
||
formSubmitted(form, submitter) {
|
||
this.navigator.submitForm(form, submitter);
|
||
}
|
||
pageBecameInteractive() {
|
||
this.view.lastRenderedLocation = this.location;
|
||
this.notifyApplicationAfterPageLoad();
|
||
}
|
||
pageLoaded() {
|
||
this.history.assumeControlOfScrollRestoration();
|
||
}
|
||
pageWillUnload() {
|
||
this.history.relinquishControlOfScrollRestoration();
|
||
}
|
||
receivedMessageFromStream(message) {
|
||
this.renderStreamMessage(message);
|
||
}
|
||
viewWillCacheSnapshot() {
|
||
var _a;
|
||
if (!((_a = this.navigator.currentVisit) === null || _a === void 0 ? void 0 : _a.silent)) {
|
||
this.notifyApplicationBeforeCachingSnapshot();
|
||
}
|
||
}
|
||
allowsImmediateRender({ element }, options) {
|
||
const event = this.notifyApplicationBeforeRender(element, options);
|
||
const { defaultPrevented, detail: { render } } = event;
|
||
if (this.view.renderer && render) {
|
||
this.view.renderer.renderElement = render;
|
||
}
|
||
return !defaultPrevented;
|
||
}
|
||
viewRenderedSnapshot(_snapshot, _isPreview) {
|
||
this.view.lastRenderedLocation = this.history.location;
|
||
this.notifyApplicationAfterRender();
|
||
}
|
||
preloadOnLoadLinksForView(element) {
|
||
this.preloader.preloadOnLoadLinksForView(element);
|
||
}
|
||
viewInvalidated(reason) {
|
||
this.adapter.pageInvalidated(reason);
|
||
}
|
||
frameLoaded(frame) {
|
||
this.notifyApplicationAfterFrameLoad(frame);
|
||
}
|
||
frameRendered(fetchResponse, frame) {
|
||
this.notifyApplicationAfterFrameRender(fetchResponse, frame);
|
||
}
|
||
applicationAllowsFollowingLinkToLocation(link, location2, ev) {
|
||
const event = this.notifyApplicationAfterClickingLinkToLocation(link, location2, ev);
|
||
return !event.defaultPrevented;
|
||
}
|
||
applicationAllowsVisitingLocation(location2) {
|
||
const event = this.notifyApplicationBeforeVisitingLocation(location2);
|
||
return !event.defaultPrevented;
|
||
}
|
||
notifyApplicationAfterClickingLinkToLocation(link, location2, event) {
|
||
return dispatch("turbo:click", {
|
||
target: link,
|
||
detail: { url: location2.href, originalEvent: event },
|
||
cancelable: true
|
||
});
|
||
}
|
||
notifyApplicationBeforeVisitingLocation(location2) {
|
||
return dispatch("turbo:before-visit", {
|
||
detail: { url: location2.href },
|
||
cancelable: true
|
||
});
|
||
}
|
||
notifyApplicationAfterVisitingLocation(location2, action) {
|
||
return dispatch("turbo:visit", { detail: { url: location2.href, action } });
|
||
}
|
||
notifyApplicationBeforeCachingSnapshot() {
|
||
return dispatch("turbo:before-cache");
|
||
}
|
||
notifyApplicationBeforeRender(newBody, options) {
|
||
return dispatch("turbo:before-render", {
|
||
detail: Object.assign({ newBody }, options),
|
||
cancelable: true
|
||
});
|
||
}
|
||
notifyApplicationAfterRender() {
|
||
return dispatch("turbo:render");
|
||
}
|
||
notifyApplicationAfterPageLoad(timing = {}) {
|
||
return dispatch("turbo:load", {
|
||
detail: { url: this.location.href, timing }
|
||
});
|
||
}
|
||
notifyApplicationAfterVisitingSamePageLocation(oldURL, newURL) {
|
||
dispatchEvent(new HashChangeEvent("hashchange", {
|
||
oldURL: oldURL.toString(),
|
||
newURL: newURL.toString()
|
||
}));
|
||
}
|
||
notifyApplicationAfterFrameLoad(frame) {
|
||
return dispatch("turbo:frame-load", { target: frame });
|
||
}
|
||
notifyApplicationAfterFrameRender(fetchResponse, frame) {
|
||
return dispatch("turbo:frame-render", {
|
||
detail: { fetchResponse },
|
||
target: frame,
|
||
cancelable: true
|
||
});
|
||
}
|
||
submissionIsNavigatable(form, submitter) {
|
||
if (this.formMode == "off") {
|
||
return false;
|
||
} else {
|
||
const submitterIsNavigatable = submitter ? this.elementIsNavigatable(submitter) : true;
|
||
if (this.formMode == "optin") {
|
||
return submitterIsNavigatable && form.closest('[data-turbo="true"]') != null;
|
||
} else {
|
||
return submitterIsNavigatable && this.elementIsNavigatable(form);
|
||
}
|
||
}
|
||
}
|
||
elementIsNavigatable(element) {
|
||
const container = findClosestRecursively(element, "[data-turbo]");
|
||
const withinFrame = findClosestRecursively(element, "turbo-frame");
|
||
if (this.drive || withinFrame) {
|
||
if (container) {
|
||
return container.getAttribute("data-turbo") != "false";
|
||
} else {
|
||
return true;
|
||
}
|
||
} else {
|
||
if (container) {
|
||
return container.getAttribute("data-turbo") == "true";
|
||
} else {
|
||
return false;
|
||
}
|
||
}
|
||
}
|
||
getActionForLink(link) {
|
||
return getVisitAction(link) || "advance";
|
||
}
|
||
get snapshot() {
|
||
return this.view.snapshot;
|
||
}
|
||
};
|
||
function extendURLWithDeprecatedProperties(url) {
|
||
Object.defineProperties(url, deprecatedLocationPropertyDescriptors);
|
||
}
|
||
var deprecatedLocationPropertyDescriptors = {
|
||
absoluteURL: {
|
||
get() {
|
||
return this.toString();
|
||
}
|
||
}
|
||
};
|
||
var Cache = class {
|
||
constructor(session2) {
|
||
this.session = session2;
|
||
}
|
||
clear() {
|
||
this.session.clearCache();
|
||
}
|
||
resetCacheControl() {
|
||
this.setCacheControl("");
|
||
}
|
||
exemptPageFromCache() {
|
||
this.setCacheControl("no-cache");
|
||
}
|
||
exemptPageFromPreview() {
|
||
this.setCacheControl("no-preview");
|
||
}
|
||
setCacheControl(value) {
|
||
setMetaContent("turbo-cache-control", value);
|
||
}
|
||
};
|
||
var StreamActions = {
|
||
after() {
|
||
this.targetElements.forEach((e) => {
|
||
var _a;
|
||
return (_a = e.parentElement) === null || _a === void 0 ? void 0 : _a.insertBefore(this.templateContent, e.nextSibling);
|
||
});
|
||
},
|
||
append() {
|
||
this.removeDuplicateTargetChildren();
|
||
this.targetElements.forEach((e) => e.append(this.templateContent));
|
||
},
|
||
before() {
|
||
this.targetElements.forEach((e) => {
|
||
var _a;
|
||
return (_a = e.parentElement) === null || _a === void 0 ? void 0 : _a.insertBefore(this.templateContent, e);
|
||
});
|
||
},
|
||
prepend() {
|
||
this.removeDuplicateTargetChildren();
|
||
this.targetElements.forEach((e) => e.prepend(this.templateContent));
|
||
},
|
||
remove() {
|
||
this.targetElements.forEach((e) => e.remove());
|
||
},
|
||
replace() {
|
||
this.targetElements.forEach((e) => e.replaceWith(this.templateContent));
|
||
},
|
||
update() {
|
||
this.targetElements.forEach((targetElement) => {
|
||
targetElement.innerHTML = "";
|
||
targetElement.append(this.templateContent);
|
||
});
|
||
}
|
||
};
|
||
var session = new Session();
|
||
var cache = new Cache(session);
|
||
var { navigator: navigator$1 } = session;
|
||
function start3() {
|
||
session.start();
|
||
}
|
||
function registerAdapter(adapter) {
|
||
session.registerAdapter(adapter);
|
||
}
|
||
function visit(location2, options) {
|
||
session.visit(location2, options);
|
||
}
|
||
function connectStreamSource(source) {
|
||
session.connectStreamSource(source);
|
||
}
|
||
function disconnectStreamSource(source) {
|
||
session.disconnectStreamSource(source);
|
||
}
|
||
function renderStreamMessage(message) {
|
||
session.renderStreamMessage(message);
|
||
}
|
||
function clearCache() {
|
||
console.warn("Please replace `Turbo.clearCache()` with `Turbo.cache.clear()`. The top-level function is deprecated and will be removed in a future version of Turbo.`");
|
||
session.clearCache();
|
||
}
|
||
function setProgressBarDelay(delay) {
|
||
session.setProgressBarDelay(delay);
|
||
}
|
||
function setConfirmMethod(confirmMethod) {
|
||
FormSubmission.confirmMethod = confirmMethod;
|
||
}
|
||
function setFormMode(mode) {
|
||
session.setFormMode(mode);
|
||
}
|
||
var Turbo = /* @__PURE__ */ Object.freeze({
|
||
__proto__: null,
|
||
navigator: navigator$1,
|
||
session,
|
||
cache,
|
||
PageRenderer,
|
||
PageSnapshot,
|
||
FrameRenderer,
|
||
start: start3,
|
||
registerAdapter,
|
||
visit,
|
||
connectStreamSource,
|
||
disconnectStreamSource,
|
||
renderStreamMessage,
|
||
clearCache,
|
||
setProgressBarDelay,
|
||
setConfirmMethod,
|
||
setFormMode,
|
||
StreamActions
|
||
});
|
||
var TurboFrameMissingError = class extends Error {
|
||
};
|
||
var FrameController = class {
|
||
constructor(element) {
|
||
this.fetchResponseLoaded = (_fetchResponse) => {
|
||
};
|
||
this.currentFetchRequest = null;
|
||
this.resolveVisitPromise = () => {
|
||
};
|
||
this.connected = false;
|
||
this.hasBeenLoaded = false;
|
||
this.ignoredAttributes = /* @__PURE__ */ new Set();
|
||
this.action = null;
|
||
this.visitCachedSnapshot = ({ element: element2 }) => {
|
||
const frame = element2.querySelector("#" + this.element.id);
|
||
if (frame && this.previousFrameElement) {
|
||
frame.replaceChildren(...this.previousFrameElement.children);
|
||
}
|
||
delete this.previousFrameElement;
|
||
};
|
||
this.element = element;
|
||
this.view = new FrameView(this, this.element);
|
||
this.appearanceObserver = new AppearanceObserver(this, this.element);
|
||
this.formLinkClickObserver = new FormLinkClickObserver(this, this.element);
|
||
this.linkInterceptor = new LinkInterceptor(this, this.element);
|
||
this.restorationIdentifier = uuid();
|
||
this.formSubmitObserver = new FormSubmitObserver(this, this.element);
|
||
}
|
||
connect() {
|
||
if (!this.connected) {
|
||
this.connected = true;
|
||
if (this.loadingStyle == FrameLoadingStyle.lazy) {
|
||
this.appearanceObserver.start();
|
||
} else {
|
||
this.loadSourceURL();
|
||
}
|
||
this.formLinkClickObserver.start();
|
||
this.linkInterceptor.start();
|
||
this.formSubmitObserver.start();
|
||
}
|
||
}
|
||
disconnect() {
|
||
if (this.connected) {
|
||
this.connected = false;
|
||
this.appearanceObserver.stop();
|
||
this.formLinkClickObserver.stop();
|
||
this.linkInterceptor.stop();
|
||
this.formSubmitObserver.stop();
|
||
}
|
||
}
|
||
disabledChanged() {
|
||
if (this.loadingStyle == FrameLoadingStyle.eager) {
|
||
this.loadSourceURL();
|
||
}
|
||
}
|
||
sourceURLChanged() {
|
||
if (this.isIgnoringChangesTo("src"))
|
||
return;
|
||
if (this.element.isConnected) {
|
||
this.complete = false;
|
||
}
|
||
if (this.loadingStyle == FrameLoadingStyle.eager || this.hasBeenLoaded) {
|
||
this.loadSourceURL();
|
||
}
|
||
}
|
||
sourceURLReloaded() {
|
||
const { src } = this.element;
|
||
this.ignoringChangesToAttribute("complete", () => {
|
||
this.element.removeAttribute("complete");
|
||
});
|
||
this.element.src = null;
|
||
this.element.src = src;
|
||
return this.element.loaded;
|
||
}
|
||
completeChanged() {
|
||
if (this.isIgnoringChangesTo("complete"))
|
||
return;
|
||
this.loadSourceURL();
|
||
}
|
||
loadingStyleChanged() {
|
||
if (this.loadingStyle == FrameLoadingStyle.lazy) {
|
||
this.appearanceObserver.start();
|
||
} else {
|
||
this.appearanceObserver.stop();
|
||
this.loadSourceURL();
|
||
}
|
||
}
|
||
async loadSourceURL() {
|
||
if (this.enabled && this.isActive && !this.complete && this.sourceURL) {
|
||
this.element.loaded = this.visit(expandURL(this.sourceURL));
|
||
this.appearanceObserver.stop();
|
||
await this.element.loaded;
|
||
this.hasBeenLoaded = true;
|
||
}
|
||
}
|
||
async loadResponse(fetchResponse) {
|
||
if (fetchResponse.redirected || fetchResponse.succeeded && fetchResponse.isHTML) {
|
||
this.sourceURL = fetchResponse.response.url;
|
||
}
|
||
try {
|
||
const html = await fetchResponse.responseHTML;
|
||
if (html) {
|
||
const document2 = parseHTMLDocument(html);
|
||
const pageSnapshot = PageSnapshot.fromDocument(document2);
|
||
if (pageSnapshot.isVisitable) {
|
||
await this.loadFrameResponse(fetchResponse, document2);
|
||
} else {
|
||
await this.handleUnvisitableFrameResponse(fetchResponse);
|
||
}
|
||
}
|
||
} finally {
|
||
this.fetchResponseLoaded = () => {
|
||
};
|
||
}
|
||
}
|
||
elementAppearedInViewport(element) {
|
||
this.proposeVisitIfNavigatedWithAction(element, element);
|
||
this.loadSourceURL();
|
||
}
|
||
willSubmitFormLinkToLocation(link) {
|
||
return this.shouldInterceptNavigation(link);
|
||
}
|
||
submittedFormLinkToLocation(link, _location, form) {
|
||
const frame = this.findFrameElement(link);
|
||
if (frame)
|
||
form.setAttribute("data-turbo-frame", frame.id);
|
||
}
|
||
shouldInterceptLinkClick(element, _location, _event) {
|
||
return this.shouldInterceptNavigation(element);
|
||
}
|
||
linkClickIntercepted(element, location2) {
|
||
this.navigateFrame(element, location2);
|
||
}
|
||
willSubmitForm(element, submitter) {
|
||
return element.closest("turbo-frame") == this.element && this.shouldInterceptNavigation(element, submitter);
|
||
}
|
||
formSubmitted(element, submitter) {
|
||
if (this.formSubmission) {
|
||
this.formSubmission.stop();
|
||
}
|
||
this.formSubmission = new FormSubmission(this, element, submitter);
|
||
const { fetchRequest } = this.formSubmission;
|
||
this.prepareRequest(fetchRequest);
|
||
this.formSubmission.start();
|
||
}
|
||
prepareRequest(request) {
|
||
var _a;
|
||
request.headers["Turbo-Frame"] = this.id;
|
||
if ((_a = this.currentNavigationElement) === null || _a === void 0 ? void 0 : _a.hasAttribute("data-turbo-stream")) {
|
||
request.acceptResponseType(StreamMessage.contentType);
|
||
}
|
||
}
|
||
requestStarted(_request) {
|
||
markAsBusy(this.element);
|
||
}
|
||
requestPreventedHandlingResponse(_request, _response) {
|
||
this.resolveVisitPromise();
|
||
}
|
||
async requestSucceededWithResponse(request, response) {
|
||
await this.loadResponse(response);
|
||
this.resolveVisitPromise();
|
||
}
|
||
async requestFailedWithResponse(request, response) {
|
||
await this.loadResponse(response);
|
||
this.resolveVisitPromise();
|
||
}
|
||
requestErrored(request, error2) {
|
||
console.error(error2);
|
||
this.resolveVisitPromise();
|
||
}
|
||
requestFinished(_request) {
|
||
clearBusyState(this.element);
|
||
}
|
||
formSubmissionStarted({ formElement }) {
|
||
markAsBusy(formElement, this.findFrameElement(formElement));
|
||
}
|
||
formSubmissionSucceededWithResponse(formSubmission, response) {
|
||
const frame = this.findFrameElement(formSubmission.formElement, formSubmission.submitter);
|
||
frame.delegate.proposeVisitIfNavigatedWithAction(frame, formSubmission.formElement, formSubmission.submitter);
|
||
frame.delegate.loadResponse(response);
|
||
if (!formSubmission.isSafe) {
|
||
session.clearCache();
|
||
}
|
||
}
|
||
formSubmissionFailedWithResponse(formSubmission, fetchResponse) {
|
||
this.element.delegate.loadResponse(fetchResponse);
|
||
session.clearCache();
|
||
}
|
||
formSubmissionErrored(formSubmission, error2) {
|
||
console.error(error2);
|
||
}
|
||
formSubmissionFinished({ formElement }) {
|
||
clearBusyState(formElement, this.findFrameElement(formElement));
|
||
}
|
||
allowsImmediateRender({ element: newFrame }, options) {
|
||
const event = dispatch("turbo:before-frame-render", {
|
||
target: this.element,
|
||
detail: Object.assign({ newFrame }, options),
|
||
cancelable: true
|
||
});
|
||
const { defaultPrevented, detail: { render } } = event;
|
||
if (this.view.renderer && render) {
|
||
this.view.renderer.renderElement = render;
|
||
}
|
||
return !defaultPrevented;
|
||
}
|
||
viewRenderedSnapshot(_snapshot, _isPreview) {
|
||
}
|
||
preloadOnLoadLinksForView(element) {
|
||
session.preloadOnLoadLinksForView(element);
|
||
}
|
||
viewInvalidated() {
|
||
}
|
||
willRenderFrame(currentElement, _newElement) {
|
||
this.previousFrameElement = currentElement.cloneNode(true);
|
||
}
|
||
async loadFrameResponse(fetchResponse, document2) {
|
||
const newFrameElement = await this.extractForeignFrameElement(document2.body);
|
||
if (newFrameElement) {
|
||
const snapshot = new Snapshot(newFrameElement);
|
||
const renderer = new FrameRenderer(this, this.view.snapshot, snapshot, FrameRenderer.renderElement, false, false);
|
||
if (this.view.renderPromise)
|
||
await this.view.renderPromise;
|
||
this.changeHistory();
|
||
await this.view.render(renderer);
|
||
this.complete = true;
|
||
session.frameRendered(fetchResponse, this.element);
|
||
session.frameLoaded(this.element);
|
||
this.fetchResponseLoaded(fetchResponse);
|
||
} else if (this.willHandleFrameMissingFromResponse(fetchResponse)) {
|
||
this.handleFrameMissingFromResponse(fetchResponse);
|
||
}
|
||
}
|
||
async visit(url) {
|
||
var _a;
|
||
const request = new FetchRequest(this, FetchMethod.get, url, new URLSearchParams(), this.element);
|
||
(_a = this.currentFetchRequest) === null || _a === void 0 ? void 0 : _a.cancel();
|
||
this.currentFetchRequest = request;
|
||
return new Promise((resolve) => {
|
||
this.resolveVisitPromise = () => {
|
||
this.resolveVisitPromise = () => {
|
||
};
|
||
this.currentFetchRequest = null;
|
||
resolve();
|
||
};
|
||
request.perform();
|
||
});
|
||
}
|
||
navigateFrame(element, url, submitter) {
|
||
const frame = this.findFrameElement(element, submitter);
|
||
frame.delegate.proposeVisitIfNavigatedWithAction(frame, element, submitter);
|
||
this.withCurrentNavigationElement(element, () => {
|
||
frame.src = url;
|
||
});
|
||
}
|
||
proposeVisitIfNavigatedWithAction(frame, element, submitter) {
|
||
this.action = getVisitAction(submitter, element, frame);
|
||
if (this.action) {
|
||
const pageSnapshot = PageSnapshot.fromElement(frame).clone();
|
||
const { visitCachedSnapshot } = frame.delegate;
|
||
frame.delegate.fetchResponseLoaded = (fetchResponse) => {
|
||
if (frame.src) {
|
||
const { statusCode, redirected } = fetchResponse;
|
||
const responseHTML = frame.ownerDocument.documentElement.outerHTML;
|
||
const response = { statusCode, redirected, responseHTML };
|
||
const options = {
|
||
response,
|
||
visitCachedSnapshot,
|
||
willRender: false,
|
||
updateHistory: false,
|
||
restorationIdentifier: this.restorationIdentifier,
|
||
snapshot: pageSnapshot
|
||
};
|
||
if (this.action)
|
||
options.action = this.action;
|
||
session.visit(frame.src, options);
|
||
}
|
||
};
|
||
}
|
||
}
|
||
changeHistory() {
|
||
if (this.action) {
|
||
const method = getHistoryMethodForAction(this.action);
|
||
session.history.update(method, expandURL(this.element.src || ""), this.restorationIdentifier);
|
||
}
|
||
}
|
||
async handleUnvisitableFrameResponse(fetchResponse) {
|
||
console.warn(`The response (${fetchResponse.statusCode}) from <turbo-frame id="${this.element.id}"> is performing a full page visit due to turbo-visit-control.`);
|
||
await this.visitResponse(fetchResponse.response);
|
||
}
|
||
willHandleFrameMissingFromResponse(fetchResponse) {
|
||
this.element.setAttribute("complete", "");
|
||
const response = fetchResponse.response;
|
||
const visit2 = async (url, options = {}) => {
|
||
if (url instanceof Response) {
|
||
this.visitResponse(url);
|
||
} else {
|
||
session.visit(url, options);
|
||
}
|
||
};
|
||
const event = dispatch("turbo:frame-missing", {
|
||
target: this.element,
|
||
detail: { response, visit: visit2 },
|
||
cancelable: true
|
||
});
|
||
return !event.defaultPrevented;
|
||
}
|
||
handleFrameMissingFromResponse(fetchResponse) {
|
||
this.view.missing();
|
||
this.throwFrameMissingError(fetchResponse);
|
||
}
|
||
throwFrameMissingError(fetchResponse) {
|
||
const message = `The response (${fetchResponse.statusCode}) did not contain the expected <turbo-frame id="${this.element.id}"> and will be ignored. To perform a full page visit instead, set turbo-visit-control to reload.`;
|
||
throw new TurboFrameMissingError(message);
|
||
}
|
||
async visitResponse(response) {
|
||
const wrapped = new FetchResponse(response);
|
||
const responseHTML = await wrapped.responseHTML;
|
||
const { location: location2, redirected, statusCode } = wrapped;
|
||
return session.visit(location2, { response: { redirected, statusCode, responseHTML } });
|
||
}
|
||
findFrameElement(element, submitter) {
|
||
var _a;
|
||
const id2 = getAttribute("data-turbo-frame", submitter, element) || this.element.getAttribute("target");
|
||
return (_a = getFrameElementById(id2)) !== null && _a !== void 0 ? _a : this.element;
|
||
}
|
||
async extractForeignFrameElement(container) {
|
||
let element;
|
||
const id2 = CSS.escape(this.id);
|
||
try {
|
||
element = activateElement(container.querySelector(`turbo-frame#${id2}`), this.sourceURL);
|
||
if (element) {
|
||
return element;
|
||
}
|
||
element = activateElement(container.querySelector(`turbo-frame[src][recurse~=${id2}]`), this.sourceURL);
|
||
if (element) {
|
||
await element.loaded;
|
||
return await this.extractForeignFrameElement(element);
|
||
}
|
||
} catch (error2) {
|
||
console.error(error2);
|
||
return new FrameElement();
|
||
}
|
||
return null;
|
||
}
|
||
formActionIsVisitable(form, submitter) {
|
||
const action = getAction(form, submitter);
|
||
return locationIsVisitable(expandURL(action), this.rootLocation);
|
||
}
|
||
shouldInterceptNavigation(element, submitter) {
|
||
const id2 = getAttribute("data-turbo-frame", submitter, element) || this.element.getAttribute("target");
|
||
if (element instanceof HTMLFormElement && !this.formActionIsVisitable(element, submitter)) {
|
||
return false;
|
||
}
|
||
if (!this.enabled || id2 == "_top") {
|
||
return false;
|
||
}
|
||
if (id2) {
|
||
const frameElement = getFrameElementById(id2);
|
||
if (frameElement) {
|
||
return !frameElement.disabled;
|
||
}
|
||
}
|
||
if (!session.elementIsNavigatable(element)) {
|
||
return false;
|
||
}
|
||
if (submitter && !session.elementIsNavigatable(submitter)) {
|
||
return false;
|
||
}
|
||
return true;
|
||
}
|
||
get id() {
|
||
return this.element.id;
|
||
}
|
||
get enabled() {
|
||
return !this.element.disabled;
|
||
}
|
||
get sourceURL() {
|
||
if (this.element.src) {
|
||
return this.element.src;
|
||
}
|
||
}
|
||
set sourceURL(sourceURL) {
|
||
this.ignoringChangesToAttribute("src", () => {
|
||
this.element.src = sourceURL !== null && sourceURL !== void 0 ? sourceURL : null;
|
||
});
|
||
}
|
||
get loadingStyle() {
|
||
return this.element.loading;
|
||
}
|
||
get isLoading() {
|
||
return this.formSubmission !== void 0 || this.resolveVisitPromise() !== void 0;
|
||
}
|
||
get complete() {
|
||
return this.element.hasAttribute("complete");
|
||
}
|
||
set complete(value) {
|
||
this.ignoringChangesToAttribute("complete", () => {
|
||
if (value) {
|
||
this.element.setAttribute("complete", "");
|
||
} else {
|
||
this.element.removeAttribute("complete");
|
||
}
|
||
});
|
||
}
|
||
get isActive() {
|
||
return this.element.isActive && this.connected;
|
||
}
|
||
get rootLocation() {
|
||
var _a;
|
||
const meta = this.element.ownerDocument.querySelector(`meta[name="turbo-root"]`);
|
||
const root = (_a = meta === null || meta === void 0 ? void 0 : meta.content) !== null && _a !== void 0 ? _a : "/";
|
||
return expandURL(root);
|
||
}
|
||
isIgnoringChangesTo(attributeName) {
|
||
return this.ignoredAttributes.has(attributeName);
|
||
}
|
||
ignoringChangesToAttribute(attributeName, callback) {
|
||
this.ignoredAttributes.add(attributeName);
|
||
callback();
|
||
this.ignoredAttributes.delete(attributeName);
|
||
}
|
||
withCurrentNavigationElement(element, callback) {
|
||
this.currentNavigationElement = element;
|
||
callback();
|
||
delete this.currentNavigationElement;
|
||
}
|
||
};
|
||
function getFrameElementById(id2) {
|
||
if (id2 != null) {
|
||
const element = document.getElementById(id2);
|
||
if (element instanceof FrameElement) {
|
||
return element;
|
||
}
|
||
}
|
||
}
|
||
function activateElement(element, currentURL) {
|
||
if (element) {
|
||
const src = element.getAttribute("src");
|
||
if (src != null && currentURL != null && urlsAreEqual(src, currentURL)) {
|
||
throw new Error(`Matching <turbo-frame id="${element.id}"> element has a source URL which references itself`);
|
||
}
|
||
if (element.ownerDocument !== document) {
|
||
element = document.importNode(element, true);
|
||
}
|
||
if (element instanceof FrameElement) {
|
||
element.connectedCallback();
|
||
element.disconnectedCallback();
|
||
return element;
|
||
}
|
||
}
|
||
}
|
||
var StreamElement = class _StreamElement extends HTMLElement {
|
||
static async renderElement(newElement) {
|
||
await newElement.performAction();
|
||
}
|
||
async connectedCallback() {
|
||
try {
|
||
await this.render();
|
||
} catch (error2) {
|
||
console.error(error2);
|
||
} finally {
|
||
this.disconnect();
|
||
}
|
||
}
|
||
async render() {
|
||
var _a;
|
||
return (_a = this.renderPromise) !== null && _a !== void 0 ? _a : this.renderPromise = (async () => {
|
||
const event = this.beforeRenderEvent;
|
||
if (this.dispatchEvent(event)) {
|
||
await nextAnimationFrame();
|
||
await event.detail.render(this);
|
||
}
|
||
})();
|
||
}
|
||
disconnect() {
|
||
try {
|
||
this.remove();
|
||
} catch (_a) {
|
||
}
|
||
}
|
||
removeDuplicateTargetChildren() {
|
||
this.duplicateChildren.forEach((c) => c.remove());
|
||
}
|
||
get duplicateChildren() {
|
||
var _a;
|
||
const existingChildren = this.targetElements.flatMap((e) => [...e.children]).filter((c) => !!c.id);
|
||
const newChildrenIds = [...((_a = this.templateContent) === null || _a === void 0 ? void 0 : _a.children) || []].filter((c) => !!c.id).map((c) => c.id);
|
||
return existingChildren.filter((c) => newChildrenIds.includes(c.id));
|
||
}
|
||
get performAction() {
|
||
if (this.action) {
|
||
const actionFunction = StreamActions[this.action];
|
||
if (actionFunction) {
|
||
return actionFunction;
|
||
}
|
||
this.raise("unknown action");
|
||
}
|
||
this.raise("action attribute is missing");
|
||
}
|
||
get targetElements() {
|
||
if (this.target) {
|
||
return this.targetElementsById;
|
||
} else if (this.targets) {
|
||
return this.targetElementsByQuery;
|
||
} else {
|
||
this.raise("target or targets attribute is missing");
|
||
}
|
||
}
|
||
get templateContent() {
|
||
return this.templateElement.content.cloneNode(true);
|
||
}
|
||
get templateElement() {
|
||
if (this.firstElementChild === null) {
|
||
const template = this.ownerDocument.createElement("template");
|
||
this.appendChild(template);
|
||
return template;
|
||
} else if (this.firstElementChild instanceof HTMLTemplateElement) {
|
||
return this.firstElementChild;
|
||
}
|
||
this.raise("first child element must be a <template> element");
|
||
}
|
||
get action() {
|
||
return this.getAttribute("action");
|
||
}
|
||
get target() {
|
||
return this.getAttribute("target");
|
||
}
|
||
get targets() {
|
||
return this.getAttribute("targets");
|
||
}
|
||
raise(message) {
|
||
throw new Error(`${this.description}: ${message}`);
|
||
}
|
||
get description() {
|
||
var _a, _b;
|
||
return (_b = ((_a = this.outerHTML.match(/<[^>]+>/)) !== null && _a !== void 0 ? _a : [])[0]) !== null && _b !== void 0 ? _b : "<turbo-stream>";
|
||
}
|
||
get beforeRenderEvent() {
|
||
return new CustomEvent("turbo:before-stream-render", {
|
||
bubbles: true,
|
||
cancelable: true,
|
||
detail: { newStream: this, render: _StreamElement.renderElement }
|
||
});
|
||
}
|
||
get targetElementsById() {
|
||
var _a;
|
||
const element = (_a = this.ownerDocument) === null || _a === void 0 ? void 0 : _a.getElementById(this.target);
|
||
if (element !== null) {
|
||
return [element];
|
||
} else {
|
||
return [];
|
||
}
|
||
}
|
||
get targetElementsByQuery() {
|
||
var _a;
|
||
const elements = (_a = this.ownerDocument) === null || _a === void 0 ? void 0 : _a.querySelectorAll(this.targets);
|
||
if (elements.length !== 0) {
|
||
return Array.prototype.slice.call(elements);
|
||
} else {
|
||
return [];
|
||
}
|
||
}
|
||
};
|
||
var StreamSourceElement = class extends HTMLElement {
|
||
constructor() {
|
||
super(...arguments);
|
||
this.streamSource = null;
|
||
}
|
||
connectedCallback() {
|
||
this.streamSource = this.src.match(/^ws{1,2}:/) ? new WebSocket(this.src) : new EventSource(this.src);
|
||
connectStreamSource(this.streamSource);
|
||
}
|
||
disconnectedCallback() {
|
||
if (this.streamSource) {
|
||
disconnectStreamSource(this.streamSource);
|
||
}
|
||
}
|
||
get src() {
|
||
return this.getAttribute("src") || "";
|
||
}
|
||
};
|
||
FrameElement.delegateConstructor = FrameController;
|
||
if (customElements.get("turbo-frame") === void 0) {
|
||
customElements.define("turbo-frame", FrameElement);
|
||
}
|
||
if (customElements.get("turbo-stream") === void 0) {
|
||
customElements.define("turbo-stream", StreamElement);
|
||
}
|
||
if (customElements.get("turbo-stream-source") === void 0) {
|
||
customElements.define("turbo-stream-source", StreamSourceElement);
|
||
}
|
||
(() => {
|
||
let element = document.currentScript;
|
||
if (!element)
|
||
return;
|
||
if (element.hasAttribute("data-turbo-suppress-warning"))
|
||
return;
|
||
element = element.parentElement;
|
||
while (element) {
|
||
if (element == document.body) {
|
||
return console.warn(unindent`
|
||
You are loading Turbo from a <script> element inside the <body> element. This is probably not what you meant to do!
|
||
|
||
Load your application’s JavaScript bundle inside the <head> element instead. <script> elements in <body> are evaluated with each page change.
|
||
|
||
For more information, see: https://turbo.hotwired.dev/handbook/building#working-with-script-elements
|
||
|
||
——
|
||
Suppress this warning by adding a "data-turbo-suppress-warning" attribute to: %s
|
||
`, element.outerHTML);
|
||
}
|
||
element = element.parentElement;
|
||
}
|
||
})();
|
||
window.Turbo = Turbo;
|
||
start3();
|
||
|
||
// node_modules/@hotwired/turbo-rails/app/javascript/turbo/cable.js
|
||
var consumer;
|
||
async function getConsumer() {
|
||
return consumer || setConsumer(createConsumer2().then(setConsumer));
|
||
}
|
||
function setConsumer(newConsumer) {
|
||
return consumer = newConsumer;
|
||
}
|
||
async function createConsumer2() {
|
||
const { createConsumer: createConsumer3 } = await Promise.resolve().then(() => (init_src(), src_exports));
|
||
return createConsumer3();
|
||
}
|
||
async function subscribeTo(channel, mixin) {
|
||
const { subscriptions } = await getConsumer();
|
||
return subscriptions.create(channel, mixin);
|
||
}
|
||
|
||
// node_modules/@hotwired/turbo-rails/app/javascript/turbo/snakeize.js
|
||
function walk(obj) {
|
||
if (!obj || typeof obj !== "object")
|
||
return obj;
|
||
if (obj instanceof Date || obj instanceof RegExp)
|
||
return obj;
|
||
if (Array.isArray(obj))
|
||
return obj.map(walk);
|
||
return Object.keys(obj).reduce(function(acc, key) {
|
||
var camel = key[0].toLowerCase() + key.slice(1).replace(/([A-Z]+)/g, function(m, x) {
|
||
return "_" + x.toLowerCase();
|
||
});
|
||
acc[camel] = walk(obj[key]);
|
||
return acc;
|
||
}, {});
|
||
}
|
||
|
||
// node_modules/@hotwired/turbo-rails/app/javascript/turbo/cable_stream_source_element.js
|
||
var TurboCableStreamSourceElement = class extends HTMLElement {
|
||
async connectedCallback() {
|
||
connectStreamSource(this);
|
||
this.subscription = await subscribeTo(this.channel, {
|
||
received: this.dispatchMessageEvent.bind(this),
|
||
connected: this.subscriptionConnected.bind(this),
|
||
disconnected: this.subscriptionDisconnected.bind(this)
|
||
});
|
||
}
|
||
disconnectedCallback() {
|
||
disconnectStreamSource(this);
|
||
if (this.subscription)
|
||
this.subscription.unsubscribe();
|
||
}
|
||
dispatchMessageEvent(data) {
|
||
const event = new MessageEvent("message", { data });
|
||
return this.dispatchEvent(event);
|
||
}
|
||
subscriptionConnected() {
|
||
this.setAttribute("connected", "");
|
||
}
|
||
subscriptionDisconnected() {
|
||
this.removeAttribute("connected");
|
||
}
|
||
get channel() {
|
||
const channel = this.getAttribute("channel");
|
||
const signed_stream_name = this.getAttribute("signed-stream-name");
|
||
return { channel, signed_stream_name, ...walk({ ...this.dataset }) };
|
||
}
|
||
};
|
||
if (customElements.get("turbo-cable-stream-source") === void 0) {
|
||
customElements.define("turbo-cable-stream-source", TurboCableStreamSourceElement);
|
||
}
|
||
|
||
// node_modules/@hotwired/turbo-rails/app/javascript/turbo/fetch_requests.js
|
||
function encodeMethodIntoRequestBody(event) {
|
||
if (event.target instanceof HTMLFormElement) {
|
||
const { target: form, detail: { fetchOptions } } = event;
|
||
form.addEventListener("turbo:submit-start", ({ detail: { formSubmission: { submitter } } }) => {
|
||
const body = isBodyInit(fetchOptions.body) ? fetchOptions.body : new URLSearchParams();
|
||
const method = determineFetchMethod(submitter, body, form);
|
||
if (!/get/i.test(method)) {
|
||
if (/post/i.test(method)) {
|
||
body.delete("_method");
|
||
} else {
|
||
body.set("_method", method);
|
||
}
|
||
fetchOptions.method = "post";
|
||
}
|
||
}, { once: true });
|
||
}
|
||
}
|
||
function determineFetchMethod(submitter, body, form) {
|
||
const formMethod = determineFormMethod(submitter);
|
||
const overrideMethod = body.get("_method");
|
||
const method = form.getAttribute("method") || "get";
|
||
if (typeof formMethod == "string") {
|
||
return formMethod;
|
||
} else if (typeof overrideMethod == "string") {
|
||
return overrideMethod;
|
||
} else {
|
||
return method;
|
||
}
|
||
}
|
||
function determineFormMethod(submitter) {
|
||
if (submitter instanceof HTMLButtonElement || submitter instanceof HTMLInputElement) {
|
||
if (submitter.hasAttribute("formmethod")) {
|
||
return submitter.formMethod;
|
||
} else {
|
||
return null;
|
||
}
|
||
} else {
|
||
return null;
|
||
}
|
||
}
|
||
function isBodyInit(body) {
|
||
return body instanceof FormData || body instanceof URLSearchParams;
|
||
}
|
||
|
||
// node_modules/@hotwired/turbo-rails/app/javascript/turbo/index.js
|
||
addEventListener("turbo:before-fetch-request", encodeMethodIntoRequestBody);
|
||
|
||
// node_modules/@hotwired/stimulus/dist/stimulus.js
|
||
var EventListener = class {
|
||
constructor(eventTarget, eventName, eventOptions) {
|
||
this.eventTarget = eventTarget;
|
||
this.eventName = eventName;
|
||
this.eventOptions = eventOptions;
|
||
this.unorderedBindings = /* @__PURE__ */ new Set();
|
||
}
|
||
connect() {
|
||
this.eventTarget.addEventListener(this.eventName, this, this.eventOptions);
|
||
}
|
||
disconnect() {
|
||
this.eventTarget.removeEventListener(this.eventName, this, this.eventOptions);
|
||
}
|
||
bindingConnected(binding) {
|
||
this.unorderedBindings.add(binding);
|
||
}
|
||
bindingDisconnected(binding) {
|
||
this.unorderedBindings.delete(binding);
|
||
}
|
||
handleEvent(event) {
|
||
const extendedEvent = extendEvent(event);
|
||
for (const binding of this.bindings) {
|
||
if (extendedEvent.immediatePropagationStopped) {
|
||
break;
|
||
} else {
|
||
binding.handleEvent(extendedEvent);
|
||
}
|
||
}
|
||
}
|
||
hasBindings() {
|
||
return this.unorderedBindings.size > 0;
|
||
}
|
||
get bindings() {
|
||
return Array.from(this.unorderedBindings).sort((left2, right2) => {
|
||
const leftIndex = left2.index, rightIndex = right2.index;
|
||
return leftIndex < rightIndex ? -1 : leftIndex > rightIndex ? 1 : 0;
|
||
});
|
||
}
|
||
};
|
||
function extendEvent(event) {
|
||
if ("immediatePropagationStopped" in event) {
|
||
return event;
|
||
} else {
|
||
const { stopImmediatePropagation } = event;
|
||
return Object.assign(event, {
|
||
immediatePropagationStopped: false,
|
||
stopImmediatePropagation() {
|
||
this.immediatePropagationStopped = true;
|
||
stopImmediatePropagation.call(this);
|
||
}
|
||
});
|
||
}
|
||
}
|
||
var Dispatcher = class {
|
||
constructor(application2) {
|
||
this.application = application2;
|
||
this.eventListenerMaps = /* @__PURE__ */ new Map();
|
||
this.started = false;
|
||
}
|
||
start() {
|
||
if (!this.started) {
|
||
this.started = true;
|
||
this.eventListeners.forEach((eventListener) => eventListener.connect());
|
||
}
|
||
}
|
||
stop() {
|
||
if (this.started) {
|
||
this.started = false;
|
||
this.eventListeners.forEach((eventListener) => eventListener.disconnect());
|
||
}
|
||
}
|
||
get eventListeners() {
|
||
return Array.from(this.eventListenerMaps.values()).reduce((listeners, map) => listeners.concat(Array.from(map.values())), []);
|
||
}
|
||
bindingConnected(binding) {
|
||
this.fetchEventListenerForBinding(binding).bindingConnected(binding);
|
||
}
|
||
bindingDisconnected(binding, clearEventListeners = false) {
|
||
this.fetchEventListenerForBinding(binding).bindingDisconnected(binding);
|
||
if (clearEventListeners)
|
||
this.clearEventListenersForBinding(binding);
|
||
}
|
||
handleError(error2, message, detail = {}) {
|
||
this.application.handleError(error2, `Error ${message}`, detail);
|
||
}
|
||
clearEventListenersForBinding(binding) {
|
||
const eventListener = this.fetchEventListenerForBinding(binding);
|
||
if (!eventListener.hasBindings()) {
|
||
eventListener.disconnect();
|
||
this.removeMappedEventListenerFor(binding);
|
||
}
|
||
}
|
||
removeMappedEventListenerFor(binding) {
|
||
const { eventTarget, eventName, eventOptions } = binding;
|
||
const eventListenerMap = this.fetchEventListenerMapForEventTarget(eventTarget);
|
||
const cacheKey = this.cacheKey(eventName, eventOptions);
|
||
eventListenerMap.delete(cacheKey);
|
||
if (eventListenerMap.size == 0)
|
||
this.eventListenerMaps.delete(eventTarget);
|
||
}
|
||
fetchEventListenerForBinding(binding) {
|
||
const { eventTarget, eventName, eventOptions } = binding;
|
||
return this.fetchEventListener(eventTarget, eventName, eventOptions);
|
||
}
|
||
fetchEventListener(eventTarget, eventName, eventOptions) {
|
||
const eventListenerMap = this.fetchEventListenerMapForEventTarget(eventTarget);
|
||
const cacheKey = this.cacheKey(eventName, eventOptions);
|
||
let eventListener = eventListenerMap.get(cacheKey);
|
||
if (!eventListener) {
|
||
eventListener = this.createEventListener(eventTarget, eventName, eventOptions);
|
||
eventListenerMap.set(cacheKey, eventListener);
|
||
}
|
||
return eventListener;
|
||
}
|
||
createEventListener(eventTarget, eventName, eventOptions) {
|
||
const eventListener = new EventListener(eventTarget, eventName, eventOptions);
|
||
if (this.started) {
|
||
eventListener.connect();
|
||
}
|
||
return eventListener;
|
||
}
|
||
fetchEventListenerMapForEventTarget(eventTarget) {
|
||
let eventListenerMap = this.eventListenerMaps.get(eventTarget);
|
||
if (!eventListenerMap) {
|
||
eventListenerMap = /* @__PURE__ */ new Map();
|
||
this.eventListenerMaps.set(eventTarget, eventListenerMap);
|
||
}
|
||
return eventListenerMap;
|
||
}
|
||
cacheKey(eventName, eventOptions) {
|
||
const parts = [eventName];
|
||
Object.keys(eventOptions).sort().forEach((key) => {
|
||
parts.push(`${eventOptions[key] ? "" : "!"}${key}`);
|
||
});
|
||
return parts.join(":");
|
||
}
|
||
};
|
||
var defaultActionDescriptorFilters = {
|
||
stop({ event, value }) {
|
||
if (value)
|
||
event.stopPropagation();
|
||
return true;
|
||
},
|
||
prevent({ event, value }) {
|
||
if (value)
|
||
event.preventDefault();
|
||
return true;
|
||
},
|
||
self({ event, value, element }) {
|
||
if (value) {
|
||
return element === event.target;
|
||
} else {
|
||
return true;
|
||
}
|
||
}
|
||
};
|
||
var descriptorPattern = /^(?:(.+?)(?:\.(.+?))?(?:@(window|document))?->)?(.+?)(?:#([^:]+?))(?::(.+))?$/;
|
||
function parseActionDescriptorString(descriptorString) {
|
||
const source = descriptorString.trim();
|
||
const matches = source.match(descriptorPattern) || [];
|
||
let eventName = matches[1];
|
||
let keyFilter = matches[2];
|
||
if (keyFilter && !["keydown", "keyup", "keypress"].includes(eventName)) {
|
||
eventName += `.${keyFilter}`;
|
||
keyFilter = "";
|
||
}
|
||
return {
|
||
eventTarget: parseEventTarget(matches[3]),
|
||
eventName,
|
||
eventOptions: matches[6] ? parseEventOptions(matches[6]) : {},
|
||
identifier: matches[4],
|
||
methodName: matches[5],
|
||
keyFilter
|
||
};
|
||
}
|
||
function parseEventTarget(eventTargetName) {
|
||
if (eventTargetName == "window") {
|
||
return window;
|
||
} else if (eventTargetName == "document") {
|
||
return document;
|
||
}
|
||
}
|
||
function parseEventOptions(eventOptions) {
|
||
return eventOptions.split(":").reduce((options, token) => Object.assign(options, { [token.replace(/^!/, "")]: !/^!/.test(token) }), {});
|
||
}
|
||
function stringifyEventTarget(eventTarget) {
|
||
if (eventTarget == window) {
|
||
return "window";
|
||
} else if (eventTarget == document) {
|
||
return "document";
|
||
}
|
||
}
|
||
function camelize(value) {
|
||
return value.replace(/(?:[_-])([a-z0-9])/g, (_, char) => char.toUpperCase());
|
||
}
|
||
function namespaceCamelize(value) {
|
||
return camelize(value.replace(/--/g, "-").replace(/__/g, "_"));
|
||
}
|
||
function capitalize(value) {
|
||
return value.charAt(0).toUpperCase() + value.slice(1);
|
||
}
|
||
function dasherize(value) {
|
||
return value.replace(/([A-Z])/g, (_, char) => `-${char.toLowerCase()}`);
|
||
}
|
||
function tokenize(value) {
|
||
return value.match(/[^\s]+/g) || [];
|
||
}
|
||
var Action = class {
|
||
constructor(element, index, descriptor, schema) {
|
||
this.element = element;
|
||
this.index = index;
|
||
this.eventTarget = descriptor.eventTarget || element;
|
||
this.eventName = descriptor.eventName || getDefaultEventNameForElement(element) || error("missing event name");
|
||
this.eventOptions = descriptor.eventOptions || {};
|
||
this.identifier = descriptor.identifier || error("missing identifier");
|
||
this.methodName = descriptor.methodName || error("missing method name");
|
||
this.keyFilter = descriptor.keyFilter || "";
|
||
this.schema = schema;
|
||
}
|
||
static forToken(token, schema) {
|
||
return new this(token.element, token.index, parseActionDescriptorString(token.content), schema);
|
||
}
|
||
toString() {
|
||
const eventFilter = this.keyFilter ? `.${this.keyFilter}` : "";
|
||
const eventTarget = this.eventTargetName ? `@${this.eventTargetName}` : "";
|
||
return `${this.eventName}${eventFilter}${eventTarget}->${this.identifier}#${this.methodName}`;
|
||
}
|
||
isFilterTarget(event) {
|
||
if (!this.keyFilter) {
|
||
return false;
|
||
}
|
||
const filteres = this.keyFilter.split("+");
|
||
const modifiers = ["meta", "ctrl", "alt", "shift"];
|
||
const [meta, ctrl, alt, shift] = modifiers.map((modifier) => filteres.includes(modifier));
|
||
if (event.metaKey !== meta || event.ctrlKey !== ctrl || event.altKey !== alt || event.shiftKey !== shift) {
|
||
return true;
|
||
}
|
||
const standardFilter = filteres.filter((key) => !modifiers.includes(key))[0];
|
||
if (!standardFilter) {
|
||
return false;
|
||
}
|
||
if (!Object.prototype.hasOwnProperty.call(this.keyMappings, standardFilter)) {
|
||
error(`contains unknown key filter: ${this.keyFilter}`);
|
||
}
|
||
return this.keyMappings[standardFilter].toLowerCase() !== event.key.toLowerCase();
|
||
}
|
||
get params() {
|
||
const params = {};
|
||
const pattern = new RegExp(`^data-${this.identifier}-(.+)-param$`, "i");
|
||
for (const { name, value } of Array.from(this.element.attributes)) {
|
||
const match = name.match(pattern);
|
||
const key = match && match[1];
|
||
if (key) {
|
||
params[camelize(key)] = typecast(value);
|
||
}
|
||
}
|
||
return params;
|
||
}
|
||
get eventTargetName() {
|
||
return stringifyEventTarget(this.eventTarget);
|
||
}
|
||
get keyMappings() {
|
||
return this.schema.keyMappings;
|
||
}
|
||
};
|
||
var defaultEventNames = {
|
||
a: () => "click",
|
||
button: () => "click",
|
||
form: () => "submit",
|
||
details: () => "toggle",
|
||
input: (e) => e.getAttribute("type") == "submit" ? "click" : "input",
|
||
select: () => "change",
|
||
textarea: () => "input"
|
||
};
|
||
function getDefaultEventNameForElement(element) {
|
||
const tagName = element.tagName.toLowerCase();
|
||
if (tagName in defaultEventNames) {
|
||
return defaultEventNames[tagName](element);
|
||
}
|
||
}
|
||
function error(message) {
|
||
throw new Error(message);
|
||
}
|
||
function typecast(value) {
|
||
try {
|
||
return JSON.parse(value);
|
||
} catch (o_O) {
|
||
return value;
|
||
}
|
||
}
|
||
var Binding = class {
|
||
constructor(context, action) {
|
||
this.context = context;
|
||
this.action = action;
|
||
}
|
||
get index() {
|
||
return this.action.index;
|
||
}
|
||
get eventTarget() {
|
||
return this.action.eventTarget;
|
||
}
|
||
get eventOptions() {
|
||
return this.action.eventOptions;
|
||
}
|
||
get identifier() {
|
||
return this.context.identifier;
|
||
}
|
||
handleEvent(event) {
|
||
if (this.willBeInvokedByEvent(event) && this.applyEventModifiers(event)) {
|
||
this.invokeWithEvent(event);
|
||
}
|
||
}
|
||
get eventName() {
|
||
return this.action.eventName;
|
||
}
|
||
get method() {
|
||
const method = this.controller[this.methodName];
|
||
if (typeof method == "function") {
|
||
return method;
|
||
}
|
||
throw new Error(`Action "${this.action}" references undefined method "${this.methodName}"`);
|
||
}
|
||
applyEventModifiers(event) {
|
||
const { element } = this.action;
|
||
const { actionDescriptorFilters } = this.context.application;
|
||
let passes = true;
|
||
for (const [name, value] of Object.entries(this.eventOptions)) {
|
||
if (name in actionDescriptorFilters) {
|
||
const filter = actionDescriptorFilters[name];
|
||
passes = passes && filter({ name, value, event, element });
|
||
} else {
|
||
continue;
|
||
}
|
||
}
|
||
return passes;
|
||
}
|
||
invokeWithEvent(event) {
|
||
const { target, currentTarget } = event;
|
||
try {
|
||
const { params } = this.action;
|
||
const actionEvent = Object.assign(event, { params });
|
||
this.method.call(this.controller, actionEvent);
|
||
this.context.logDebugActivity(this.methodName, { event, target, currentTarget, action: this.methodName });
|
||
} catch (error2) {
|
||
const { identifier, controller, element, index } = this;
|
||
const detail = { identifier, controller, element, index, event };
|
||
this.context.handleError(error2, `invoking action "${this.action}"`, detail);
|
||
}
|
||
}
|
||
willBeInvokedByEvent(event) {
|
||
const eventTarget = event.target;
|
||
if (event instanceof KeyboardEvent && this.action.isFilterTarget(event)) {
|
||
return false;
|
||
}
|
||
if (this.element === eventTarget) {
|
||
return true;
|
||
} else if (eventTarget instanceof Element && this.element.contains(eventTarget)) {
|
||
return this.scope.containsElement(eventTarget);
|
||
} else {
|
||
return this.scope.containsElement(this.action.element);
|
||
}
|
||
}
|
||
get controller() {
|
||
return this.context.controller;
|
||
}
|
||
get methodName() {
|
||
return this.action.methodName;
|
||
}
|
||
get element() {
|
||
return this.scope.element;
|
||
}
|
||
get scope() {
|
||
return this.context.scope;
|
||
}
|
||
};
|
||
var ElementObserver = class {
|
||
constructor(element, delegate) {
|
||
this.mutationObserverInit = { attributes: true, childList: true, subtree: true };
|
||
this.element = element;
|
||
this.started = false;
|
||
this.delegate = delegate;
|
||
this.elements = /* @__PURE__ */ new Set();
|
||
this.mutationObserver = new MutationObserver((mutations) => this.processMutations(mutations));
|
||
}
|
||
start() {
|
||
if (!this.started) {
|
||
this.started = true;
|
||
this.mutationObserver.observe(this.element, this.mutationObserverInit);
|
||
this.refresh();
|
||
}
|
||
}
|
||
pause(callback) {
|
||
if (this.started) {
|
||
this.mutationObserver.disconnect();
|
||
this.started = false;
|
||
}
|
||
callback();
|
||
if (!this.started) {
|
||
this.mutationObserver.observe(this.element, this.mutationObserverInit);
|
||
this.started = true;
|
||
}
|
||
}
|
||
stop() {
|
||
if (this.started) {
|
||
this.mutationObserver.takeRecords();
|
||
this.mutationObserver.disconnect();
|
||
this.started = false;
|
||
}
|
||
}
|
||
refresh() {
|
||
if (this.started) {
|
||
const matches = new Set(this.matchElementsInTree());
|
||
for (const element of Array.from(this.elements)) {
|
||
if (!matches.has(element)) {
|
||
this.removeElement(element);
|
||
}
|
||
}
|
||
for (const element of Array.from(matches)) {
|
||
this.addElement(element);
|
||
}
|
||
}
|
||
}
|
||
processMutations(mutations) {
|
||
if (this.started) {
|
||
for (const mutation of mutations) {
|
||
this.processMutation(mutation);
|
||
}
|
||
}
|
||
}
|
||
processMutation(mutation) {
|
||
if (mutation.type == "attributes") {
|
||
this.processAttributeChange(mutation.target, mutation.attributeName);
|
||
} else if (mutation.type == "childList") {
|
||
this.processRemovedNodes(mutation.removedNodes);
|
||
this.processAddedNodes(mutation.addedNodes);
|
||
}
|
||
}
|
||
processAttributeChange(node, attributeName) {
|
||
const element = node;
|
||
if (this.elements.has(element)) {
|
||
if (this.delegate.elementAttributeChanged && this.matchElement(element)) {
|
||
this.delegate.elementAttributeChanged(element, attributeName);
|
||
} else {
|
||
this.removeElement(element);
|
||
}
|
||
} else if (this.matchElement(element)) {
|
||
this.addElement(element);
|
||
}
|
||
}
|
||
processRemovedNodes(nodes) {
|
||
for (const node of Array.from(nodes)) {
|
||
const element = this.elementFromNode(node);
|
||
if (element) {
|
||
this.processTree(element, this.removeElement);
|
||
}
|
||
}
|
||
}
|
||
processAddedNodes(nodes) {
|
||
for (const node of Array.from(nodes)) {
|
||
const element = this.elementFromNode(node);
|
||
if (element && this.elementIsActive(element)) {
|
||
this.processTree(element, this.addElement);
|
||
}
|
||
}
|
||
}
|
||
matchElement(element) {
|
||
return this.delegate.matchElement(element);
|
||
}
|
||
matchElementsInTree(tree = this.element) {
|
||
return this.delegate.matchElementsInTree(tree);
|
||
}
|
||
processTree(tree, processor) {
|
||
for (const element of this.matchElementsInTree(tree)) {
|
||
processor.call(this, element);
|
||
}
|
||
}
|
||
elementFromNode(node) {
|
||
if (node.nodeType == Node.ELEMENT_NODE) {
|
||
return node;
|
||
}
|
||
}
|
||
elementIsActive(element) {
|
||
if (element.isConnected != this.element.isConnected) {
|
||
return false;
|
||
} else {
|
||
return this.element.contains(element);
|
||
}
|
||
}
|
||
addElement(element) {
|
||
if (!this.elements.has(element)) {
|
||
if (this.elementIsActive(element)) {
|
||
this.elements.add(element);
|
||
if (this.delegate.elementMatched) {
|
||
this.delegate.elementMatched(element);
|
||
}
|
||
}
|
||
}
|
||
}
|
||
removeElement(element) {
|
||
if (this.elements.has(element)) {
|
||
this.elements.delete(element);
|
||
if (this.delegate.elementUnmatched) {
|
||
this.delegate.elementUnmatched(element);
|
||
}
|
||
}
|
||
}
|
||
};
|
||
var AttributeObserver = class {
|
||
constructor(element, attributeName, delegate) {
|
||
this.attributeName = attributeName;
|
||
this.delegate = delegate;
|
||
this.elementObserver = new ElementObserver(element, this);
|
||
}
|
||
get element() {
|
||
return this.elementObserver.element;
|
||
}
|
||
get selector() {
|
||
return `[${this.attributeName}]`;
|
||
}
|
||
start() {
|
||
this.elementObserver.start();
|
||
}
|
||
pause(callback) {
|
||
this.elementObserver.pause(callback);
|
||
}
|
||
stop() {
|
||
this.elementObserver.stop();
|
||
}
|
||
refresh() {
|
||
this.elementObserver.refresh();
|
||
}
|
||
get started() {
|
||
return this.elementObserver.started;
|
||
}
|
||
matchElement(element) {
|
||
return element.hasAttribute(this.attributeName);
|
||
}
|
||
matchElementsInTree(tree) {
|
||
const match = this.matchElement(tree) ? [tree] : [];
|
||
const matches = Array.from(tree.querySelectorAll(this.selector));
|
||
return match.concat(matches);
|
||
}
|
||
elementMatched(element) {
|
||
if (this.delegate.elementMatchedAttribute) {
|
||
this.delegate.elementMatchedAttribute(element, this.attributeName);
|
||
}
|
||
}
|
||
elementUnmatched(element) {
|
||
if (this.delegate.elementUnmatchedAttribute) {
|
||
this.delegate.elementUnmatchedAttribute(element, this.attributeName);
|
||
}
|
||
}
|
||
elementAttributeChanged(element, attributeName) {
|
||
if (this.delegate.elementAttributeValueChanged && this.attributeName == attributeName) {
|
||
this.delegate.elementAttributeValueChanged(element, attributeName);
|
||
}
|
||
}
|
||
};
|
||
function add(map, key, value) {
|
||
fetch2(map, key).add(value);
|
||
}
|
||
function del(map, key, value) {
|
||
fetch2(map, key).delete(value);
|
||
prune(map, key);
|
||
}
|
||
function fetch2(map, key) {
|
||
let values = map.get(key);
|
||
if (!values) {
|
||
values = /* @__PURE__ */ new Set();
|
||
map.set(key, values);
|
||
}
|
||
return values;
|
||
}
|
||
function prune(map, key) {
|
||
const values = map.get(key);
|
||
if (values != null && values.size == 0) {
|
||
map.delete(key);
|
||
}
|
||
}
|
||
var Multimap = class {
|
||
constructor() {
|
||
this.valuesByKey = /* @__PURE__ */ new Map();
|
||
}
|
||
get keys() {
|
||
return Array.from(this.valuesByKey.keys());
|
||
}
|
||
get values() {
|
||
const sets = Array.from(this.valuesByKey.values());
|
||
return sets.reduce((values, set) => values.concat(Array.from(set)), []);
|
||
}
|
||
get size() {
|
||
const sets = Array.from(this.valuesByKey.values());
|
||
return sets.reduce((size, set) => size + set.size, 0);
|
||
}
|
||
add(key, value) {
|
||
add(this.valuesByKey, key, value);
|
||
}
|
||
delete(key, value) {
|
||
del(this.valuesByKey, key, value);
|
||
}
|
||
has(key, value) {
|
||
const values = this.valuesByKey.get(key);
|
||
return values != null && values.has(value);
|
||
}
|
||
hasKey(key) {
|
||
return this.valuesByKey.has(key);
|
||
}
|
||
hasValue(value) {
|
||
const sets = Array.from(this.valuesByKey.values());
|
||
return sets.some((set) => set.has(value));
|
||
}
|
||
getValuesForKey(key) {
|
||
const values = this.valuesByKey.get(key);
|
||
return values ? Array.from(values) : [];
|
||
}
|
||
getKeysForValue(value) {
|
||
return Array.from(this.valuesByKey).filter(([_key, values]) => values.has(value)).map(([key, _values]) => key);
|
||
}
|
||
};
|
||
var SelectorObserver = class {
|
||
constructor(element, selector, delegate, details = {}) {
|
||
this.selector = selector;
|
||
this.details = details;
|
||
this.elementObserver = new ElementObserver(element, this);
|
||
this.delegate = delegate;
|
||
this.matchesByElement = new Multimap();
|
||
}
|
||
get started() {
|
||
return this.elementObserver.started;
|
||
}
|
||
start() {
|
||
this.elementObserver.start();
|
||
}
|
||
pause(callback) {
|
||
this.elementObserver.pause(callback);
|
||
}
|
||
stop() {
|
||
this.elementObserver.stop();
|
||
}
|
||
refresh() {
|
||
this.elementObserver.refresh();
|
||
}
|
||
get element() {
|
||
return this.elementObserver.element;
|
||
}
|
||
matchElement(element) {
|
||
const matches = element.matches(this.selector);
|
||
if (this.delegate.selectorMatchElement) {
|
||
return matches && this.delegate.selectorMatchElement(element, this.details);
|
||
}
|
||
return matches;
|
||
}
|
||
matchElementsInTree(tree) {
|
||
const match = this.matchElement(tree) ? [tree] : [];
|
||
const matches = Array.from(tree.querySelectorAll(this.selector)).filter((match2) => this.matchElement(match2));
|
||
return match.concat(matches);
|
||
}
|
||
elementMatched(element) {
|
||
this.selectorMatched(element);
|
||
}
|
||
elementUnmatched(element) {
|
||
this.selectorUnmatched(element);
|
||
}
|
||
elementAttributeChanged(element, _attributeName) {
|
||
const matches = this.matchElement(element);
|
||
const matchedBefore = this.matchesByElement.has(this.selector, element);
|
||
if (!matches && matchedBefore) {
|
||
this.selectorUnmatched(element);
|
||
}
|
||
}
|
||
selectorMatched(element) {
|
||
if (this.delegate.selectorMatched) {
|
||
this.delegate.selectorMatched(element, this.selector, this.details);
|
||
this.matchesByElement.add(this.selector, element);
|
||
}
|
||
}
|
||
selectorUnmatched(element) {
|
||
this.delegate.selectorUnmatched(element, this.selector, this.details);
|
||
this.matchesByElement.delete(this.selector, element);
|
||
}
|
||
};
|
||
var StringMapObserver = class {
|
||
constructor(element, delegate) {
|
||
this.element = element;
|
||
this.delegate = delegate;
|
||
this.started = false;
|
||
this.stringMap = /* @__PURE__ */ new Map();
|
||
this.mutationObserver = new MutationObserver((mutations) => this.processMutations(mutations));
|
||
}
|
||
start() {
|
||
if (!this.started) {
|
||
this.started = true;
|
||
this.mutationObserver.observe(this.element, { attributes: true, attributeOldValue: true });
|
||
this.refresh();
|
||
}
|
||
}
|
||
stop() {
|
||
if (this.started) {
|
||
this.mutationObserver.takeRecords();
|
||
this.mutationObserver.disconnect();
|
||
this.started = false;
|
||
}
|
||
}
|
||
refresh() {
|
||
if (this.started) {
|
||
for (const attributeName of this.knownAttributeNames) {
|
||
this.refreshAttribute(attributeName, null);
|
||
}
|
||
}
|
||
}
|
||
processMutations(mutations) {
|
||
if (this.started) {
|
||
for (const mutation of mutations) {
|
||
this.processMutation(mutation);
|
||
}
|
||
}
|
||
}
|
||
processMutation(mutation) {
|
||
const attributeName = mutation.attributeName;
|
||
if (attributeName) {
|
||
this.refreshAttribute(attributeName, mutation.oldValue);
|
||
}
|
||
}
|
||
refreshAttribute(attributeName, oldValue) {
|
||
const key = this.delegate.getStringMapKeyForAttribute(attributeName);
|
||
if (key != null) {
|
||
if (!this.stringMap.has(attributeName)) {
|
||
this.stringMapKeyAdded(key, attributeName);
|
||
}
|
||
const value = this.element.getAttribute(attributeName);
|
||
if (this.stringMap.get(attributeName) != value) {
|
||
this.stringMapValueChanged(value, key, oldValue);
|
||
}
|
||
if (value == null) {
|
||
const oldValue2 = this.stringMap.get(attributeName);
|
||
this.stringMap.delete(attributeName);
|
||
if (oldValue2)
|
||
this.stringMapKeyRemoved(key, attributeName, oldValue2);
|
||
} else {
|
||
this.stringMap.set(attributeName, value);
|
||
}
|
||
}
|
||
}
|
||
stringMapKeyAdded(key, attributeName) {
|
||
if (this.delegate.stringMapKeyAdded) {
|
||
this.delegate.stringMapKeyAdded(key, attributeName);
|
||
}
|
||
}
|
||
stringMapValueChanged(value, key, oldValue) {
|
||
if (this.delegate.stringMapValueChanged) {
|
||
this.delegate.stringMapValueChanged(value, key, oldValue);
|
||
}
|
||
}
|
||
stringMapKeyRemoved(key, attributeName, oldValue) {
|
||
if (this.delegate.stringMapKeyRemoved) {
|
||
this.delegate.stringMapKeyRemoved(key, attributeName, oldValue);
|
||
}
|
||
}
|
||
get knownAttributeNames() {
|
||
return Array.from(new Set(this.currentAttributeNames.concat(this.recordedAttributeNames)));
|
||
}
|
||
get currentAttributeNames() {
|
||
return Array.from(this.element.attributes).map((attribute) => attribute.name);
|
||
}
|
||
get recordedAttributeNames() {
|
||
return Array.from(this.stringMap.keys());
|
||
}
|
||
};
|
||
var TokenListObserver = class {
|
||
constructor(element, attributeName, delegate) {
|
||
this.attributeObserver = new AttributeObserver(element, attributeName, this);
|
||
this.delegate = delegate;
|
||
this.tokensByElement = new Multimap();
|
||
}
|
||
get started() {
|
||
return this.attributeObserver.started;
|
||
}
|
||
start() {
|
||
this.attributeObserver.start();
|
||
}
|
||
pause(callback) {
|
||
this.attributeObserver.pause(callback);
|
||
}
|
||
stop() {
|
||
this.attributeObserver.stop();
|
||
}
|
||
refresh() {
|
||
this.attributeObserver.refresh();
|
||
}
|
||
get element() {
|
||
return this.attributeObserver.element;
|
||
}
|
||
get attributeName() {
|
||
return this.attributeObserver.attributeName;
|
||
}
|
||
elementMatchedAttribute(element) {
|
||
this.tokensMatched(this.readTokensForElement(element));
|
||
}
|
||
elementAttributeValueChanged(element) {
|
||
const [unmatchedTokens, matchedTokens] = this.refreshTokensForElement(element);
|
||
this.tokensUnmatched(unmatchedTokens);
|
||
this.tokensMatched(matchedTokens);
|
||
}
|
||
elementUnmatchedAttribute(element) {
|
||
this.tokensUnmatched(this.tokensByElement.getValuesForKey(element));
|
||
}
|
||
tokensMatched(tokens) {
|
||
tokens.forEach((token) => this.tokenMatched(token));
|
||
}
|
||
tokensUnmatched(tokens) {
|
||
tokens.forEach((token) => this.tokenUnmatched(token));
|
||
}
|
||
tokenMatched(token) {
|
||
this.delegate.tokenMatched(token);
|
||
this.tokensByElement.add(token.element, token);
|
||
}
|
||
tokenUnmatched(token) {
|
||
this.delegate.tokenUnmatched(token);
|
||
this.tokensByElement.delete(token.element, token);
|
||
}
|
||
refreshTokensForElement(element) {
|
||
const previousTokens = this.tokensByElement.getValuesForKey(element);
|
||
const currentTokens = this.readTokensForElement(element);
|
||
const firstDifferingIndex = zip(previousTokens, currentTokens).findIndex(([previousToken, currentToken]) => !tokensAreEqual(previousToken, currentToken));
|
||
if (firstDifferingIndex == -1) {
|
||
return [[], []];
|
||
} else {
|
||
return [previousTokens.slice(firstDifferingIndex), currentTokens.slice(firstDifferingIndex)];
|
||
}
|
||
}
|
||
readTokensForElement(element) {
|
||
const attributeName = this.attributeName;
|
||
const tokenString = element.getAttribute(attributeName) || "";
|
||
return parseTokenString(tokenString, element, attributeName);
|
||
}
|
||
};
|
||
function parseTokenString(tokenString, element, attributeName) {
|
||
return tokenString.trim().split(/\s+/).filter((content) => content.length).map((content, index) => ({ element, attributeName, content, index }));
|
||
}
|
||
function zip(left2, right2) {
|
||
const length = Math.max(left2.length, right2.length);
|
||
return Array.from({ length }, (_, index) => [left2[index], right2[index]]);
|
||
}
|
||
function tokensAreEqual(left2, right2) {
|
||
return left2 && right2 && left2.index == right2.index && left2.content == right2.content;
|
||
}
|
||
var ValueListObserver = class {
|
||
constructor(element, attributeName, delegate) {
|
||
this.tokenListObserver = new TokenListObserver(element, attributeName, this);
|
||
this.delegate = delegate;
|
||
this.parseResultsByToken = /* @__PURE__ */ new WeakMap();
|
||
this.valuesByTokenByElement = /* @__PURE__ */ new WeakMap();
|
||
}
|
||
get started() {
|
||
return this.tokenListObserver.started;
|
||
}
|
||
start() {
|
||
this.tokenListObserver.start();
|
||
}
|
||
stop() {
|
||
this.tokenListObserver.stop();
|
||
}
|
||
refresh() {
|
||
this.tokenListObserver.refresh();
|
||
}
|
||
get element() {
|
||
return this.tokenListObserver.element;
|
||
}
|
||
get attributeName() {
|
||
return this.tokenListObserver.attributeName;
|
||
}
|
||
tokenMatched(token) {
|
||
const { element } = token;
|
||
const { value } = this.fetchParseResultForToken(token);
|
||
if (value) {
|
||
this.fetchValuesByTokenForElement(element).set(token, value);
|
||
this.delegate.elementMatchedValue(element, value);
|
||
}
|
||
}
|
||
tokenUnmatched(token) {
|
||
const { element } = token;
|
||
const { value } = this.fetchParseResultForToken(token);
|
||
if (value) {
|
||
this.fetchValuesByTokenForElement(element).delete(token);
|
||
this.delegate.elementUnmatchedValue(element, value);
|
||
}
|
||
}
|
||
fetchParseResultForToken(token) {
|
||
let parseResult = this.parseResultsByToken.get(token);
|
||
if (!parseResult) {
|
||
parseResult = this.parseToken(token);
|
||
this.parseResultsByToken.set(token, parseResult);
|
||
}
|
||
return parseResult;
|
||
}
|
||
fetchValuesByTokenForElement(element) {
|
||
let valuesByToken = this.valuesByTokenByElement.get(element);
|
||
if (!valuesByToken) {
|
||
valuesByToken = /* @__PURE__ */ new Map();
|
||
this.valuesByTokenByElement.set(element, valuesByToken);
|
||
}
|
||
return valuesByToken;
|
||
}
|
||
parseToken(token) {
|
||
try {
|
||
const value = this.delegate.parseValueForToken(token);
|
||
return { value };
|
||
} catch (error2) {
|
||
return { error: error2 };
|
||
}
|
||
}
|
||
};
|
||
var BindingObserver = class {
|
||
constructor(context, delegate) {
|
||
this.context = context;
|
||
this.delegate = delegate;
|
||
this.bindingsByAction = /* @__PURE__ */ new Map();
|
||
}
|
||
start() {
|
||
if (!this.valueListObserver) {
|
||
this.valueListObserver = new ValueListObserver(this.element, this.actionAttribute, this);
|
||
this.valueListObserver.start();
|
||
}
|
||
}
|
||
stop() {
|
||
if (this.valueListObserver) {
|
||
this.valueListObserver.stop();
|
||
delete this.valueListObserver;
|
||
this.disconnectAllActions();
|
||
}
|
||
}
|
||
get element() {
|
||
return this.context.element;
|
||
}
|
||
get identifier() {
|
||
return this.context.identifier;
|
||
}
|
||
get actionAttribute() {
|
||
return this.schema.actionAttribute;
|
||
}
|
||
get schema() {
|
||
return this.context.schema;
|
||
}
|
||
get bindings() {
|
||
return Array.from(this.bindingsByAction.values());
|
||
}
|
||
connectAction(action) {
|
||
const binding = new Binding(this.context, action);
|
||
this.bindingsByAction.set(action, binding);
|
||
this.delegate.bindingConnected(binding);
|
||
}
|
||
disconnectAction(action) {
|
||
const binding = this.bindingsByAction.get(action);
|
||
if (binding) {
|
||
this.bindingsByAction.delete(action);
|
||
this.delegate.bindingDisconnected(binding);
|
||
}
|
||
}
|
||
disconnectAllActions() {
|
||
this.bindings.forEach((binding) => this.delegate.bindingDisconnected(binding, true));
|
||
this.bindingsByAction.clear();
|
||
}
|
||
parseValueForToken(token) {
|
||
const action = Action.forToken(token, this.schema);
|
||
if (action.identifier == this.identifier) {
|
||
return action;
|
||
}
|
||
}
|
||
elementMatchedValue(element, action) {
|
||
this.connectAction(action);
|
||
}
|
||
elementUnmatchedValue(element, action) {
|
||
this.disconnectAction(action);
|
||
}
|
||
};
|
||
var ValueObserver = class {
|
||
constructor(context, receiver) {
|
||
this.context = context;
|
||
this.receiver = receiver;
|
||
this.stringMapObserver = new StringMapObserver(this.element, this);
|
||
this.valueDescriptorMap = this.controller.valueDescriptorMap;
|
||
}
|
||
start() {
|
||
this.stringMapObserver.start();
|
||
this.invokeChangedCallbacksForDefaultValues();
|
||
}
|
||
stop() {
|
||
this.stringMapObserver.stop();
|
||
}
|
||
get element() {
|
||
return this.context.element;
|
||
}
|
||
get controller() {
|
||
return this.context.controller;
|
||
}
|
||
getStringMapKeyForAttribute(attributeName) {
|
||
if (attributeName in this.valueDescriptorMap) {
|
||
return this.valueDescriptorMap[attributeName].name;
|
||
}
|
||
}
|
||
stringMapKeyAdded(key, attributeName) {
|
||
const descriptor = this.valueDescriptorMap[attributeName];
|
||
if (!this.hasValue(key)) {
|
||
this.invokeChangedCallback(key, descriptor.writer(this.receiver[key]), descriptor.writer(descriptor.defaultValue));
|
||
}
|
||
}
|
||
stringMapValueChanged(value, name, oldValue) {
|
||
const descriptor = this.valueDescriptorNameMap[name];
|
||
if (value === null)
|
||
return;
|
||
if (oldValue === null) {
|
||
oldValue = descriptor.writer(descriptor.defaultValue);
|
||
}
|
||
this.invokeChangedCallback(name, value, oldValue);
|
||
}
|
||
stringMapKeyRemoved(key, attributeName, oldValue) {
|
||
const descriptor = this.valueDescriptorNameMap[key];
|
||
if (this.hasValue(key)) {
|
||
this.invokeChangedCallback(key, descriptor.writer(this.receiver[key]), oldValue);
|
||
} else {
|
||
this.invokeChangedCallback(key, descriptor.writer(descriptor.defaultValue), oldValue);
|
||
}
|
||
}
|
||
invokeChangedCallbacksForDefaultValues() {
|
||
for (const { key, name, defaultValue, writer } of this.valueDescriptors) {
|
||
if (defaultValue != void 0 && !this.controller.data.has(key)) {
|
||
this.invokeChangedCallback(name, writer(defaultValue), void 0);
|
||
}
|
||
}
|
||
}
|
||
invokeChangedCallback(name, rawValue, rawOldValue) {
|
||
const changedMethodName = `${name}Changed`;
|
||
const changedMethod = this.receiver[changedMethodName];
|
||
if (typeof changedMethod == "function") {
|
||
const descriptor = this.valueDescriptorNameMap[name];
|
||
try {
|
||
const value = descriptor.reader(rawValue);
|
||
let oldValue = rawOldValue;
|
||
if (rawOldValue) {
|
||
oldValue = descriptor.reader(rawOldValue);
|
||
}
|
||
changedMethod.call(this.receiver, value, oldValue);
|
||
} catch (error2) {
|
||
if (error2 instanceof TypeError) {
|
||
error2.message = `Stimulus Value "${this.context.identifier}.${descriptor.name}" - ${error2.message}`;
|
||
}
|
||
throw error2;
|
||
}
|
||
}
|
||
}
|
||
get valueDescriptors() {
|
||
const { valueDescriptorMap } = this;
|
||
return Object.keys(valueDescriptorMap).map((key) => valueDescriptorMap[key]);
|
||
}
|
||
get valueDescriptorNameMap() {
|
||
const descriptors = {};
|
||
Object.keys(this.valueDescriptorMap).forEach((key) => {
|
||
const descriptor = this.valueDescriptorMap[key];
|
||
descriptors[descriptor.name] = descriptor;
|
||
});
|
||
return descriptors;
|
||
}
|
||
hasValue(attributeName) {
|
||
const descriptor = this.valueDescriptorNameMap[attributeName];
|
||
const hasMethodName = `has${capitalize(descriptor.name)}`;
|
||
return this.receiver[hasMethodName];
|
||
}
|
||
};
|
||
var TargetObserver = class {
|
||
constructor(context, delegate) {
|
||
this.context = context;
|
||
this.delegate = delegate;
|
||
this.targetsByName = new Multimap();
|
||
}
|
||
start() {
|
||
if (!this.tokenListObserver) {
|
||
this.tokenListObserver = new TokenListObserver(this.element, this.attributeName, this);
|
||
this.tokenListObserver.start();
|
||
}
|
||
}
|
||
stop() {
|
||
if (this.tokenListObserver) {
|
||
this.disconnectAllTargets();
|
||
this.tokenListObserver.stop();
|
||
delete this.tokenListObserver;
|
||
}
|
||
}
|
||
tokenMatched({ element, content: name }) {
|
||
if (this.scope.containsElement(element)) {
|
||
this.connectTarget(element, name);
|
||
}
|
||
}
|
||
tokenUnmatched({ element, content: name }) {
|
||
this.disconnectTarget(element, name);
|
||
}
|
||
connectTarget(element, name) {
|
||
var _a;
|
||
if (!this.targetsByName.has(name, element)) {
|
||
this.targetsByName.add(name, element);
|
||
(_a = this.tokenListObserver) === null || _a === void 0 ? void 0 : _a.pause(() => this.delegate.targetConnected(element, name));
|
||
}
|
||
}
|
||
disconnectTarget(element, name) {
|
||
var _a;
|
||
if (this.targetsByName.has(name, element)) {
|
||
this.targetsByName.delete(name, element);
|
||
(_a = this.tokenListObserver) === null || _a === void 0 ? void 0 : _a.pause(() => this.delegate.targetDisconnected(element, name));
|
||
}
|
||
}
|
||
disconnectAllTargets() {
|
||
for (const name of this.targetsByName.keys) {
|
||
for (const element of this.targetsByName.getValuesForKey(name)) {
|
||
this.disconnectTarget(element, name);
|
||
}
|
||
}
|
||
}
|
||
get attributeName() {
|
||
return `data-${this.context.identifier}-target`;
|
||
}
|
||
get element() {
|
||
return this.context.element;
|
||
}
|
||
get scope() {
|
||
return this.context.scope;
|
||
}
|
||
};
|
||
function readInheritableStaticArrayValues(constructor, propertyName) {
|
||
const ancestors = getAncestorsForConstructor(constructor);
|
||
return Array.from(ancestors.reduce((values, constructor2) => {
|
||
getOwnStaticArrayValues(constructor2, propertyName).forEach((name) => values.add(name));
|
||
return values;
|
||
}, /* @__PURE__ */ new Set()));
|
||
}
|
||
function readInheritableStaticObjectPairs(constructor, propertyName) {
|
||
const ancestors = getAncestorsForConstructor(constructor);
|
||
return ancestors.reduce((pairs, constructor2) => {
|
||
pairs.push(...getOwnStaticObjectPairs(constructor2, propertyName));
|
||
return pairs;
|
||
}, []);
|
||
}
|
||
function getAncestorsForConstructor(constructor) {
|
||
const ancestors = [];
|
||
while (constructor) {
|
||
ancestors.push(constructor);
|
||
constructor = Object.getPrototypeOf(constructor);
|
||
}
|
||
return ancestors.reverse();
|
||
}
|
||
function getOwnStaticArrayValues(constructor, propertyName) {
|
||
const definition = constructor[propertyName];
|
||
return Array.isArray(definition) ? definition : [];
|
||
}
|
||
function getOwnStaticObjectPairs(constructor, propertyName) {
|
||
const definition = constructor[propertyName];
|
||
return definition ? Object.keys(definition).map((key) => [key, definition[key]]) : [];
|
||
}
|
||
var OutletObserver = class {
|
||
constructor(context, delegate) {
|
||
this.context = context;
|
||
this.delegate = delegate;
|
||
this.outletsByName = new Multimap();
|
||
this.outletElementsByName = new Multimap();
|
||
this.selectorObserverMap = /* @__PURE__ */ new Map();
|
||
}
|
||
start() {
|
||
if (this.selectorObserverMap.size === 0) {
|
||
this.outletDefinitions.forEach((outletName) => {
|
||
const selector = this.selector(outletName);
|
||
const details = { outletName };
|
||
if (selector) {
|
||
this.selectorObserverMap.set(outletName, new SelectorObserver(document.body, selector, this, details));
|
||
}
|
||
});
|
||
this.selectorObserverMap.forEach((observer) => observer.start());
|
||
}
|
||
this.dependentContexts.forEach((context) => context.refresh());
|
||
}
|
||
stop() {
|
||
if (this.selectorObserverMap.size > 0) {
|
||
this.disconnectAllOutlets();
|
||
this.selectorObserverMap.forEach((observer) => observer.stop());
|
||
this.selectorObserverMap.clear();
|
||
}
|
||
}
|
||
refresh() {
|
||
this.selectorObserverMap.forEach((observer) => observer.refresh());
|
||
}
|
||
selectorMatched(element, _selector, { outletName }) {
|
||
const outlet = this.getOutlet(element, outletName);
|
||
if (outlet) {
|
||
this.connectOutlet(outlet, element, outletName);
|
||
}
|
||
}
|
||
selectorUnmatched(element, _selector, { outletName }) {
|
||
const outlet = this.getOutletFromMap(element, outletName);
|
||
if (outlet) {
|
||
this.disconnectOutlet(outlet, element, outletName);
|
||
}
|
||
}
|
||
selectorMatchElement(element, { outletName }) {
|
||
return this.hasOutlet(element, outletName) && element.matches(`[${this.context.application.schema.controllerAttribute}~=${outletName}]`);
|
||
}
|
||
connectOutlet(outlet, element, outletName) {
|
||
var _a;
|
||
if (!this.outletElementsByName.has(outletName, element)) {
|
||
this.outletsByName.add(outletName, outlet);
|
||
this.outletElementsByName.add(outletName, element);
|
||
(_a = this.selectorObserverMap.get(outletName)) === null || _a === void 0 ? void 0 : _a.pause(() => this.delegate.outletConnected(outlet, element, outletName));
|
||
}
|
||
}
|
||
disconnectOutlet(outlet, element, outletName) {
|
||
var _a;
|
||
if (this.outletElementsByName.has(outletName, element)) {
|
||
this.outletsByName.delete(outletName, outlet);
|
||
this.outletElementsByName.delete(outletName, element);
|
||
(_a = this.selectorObserverMap.get(outletName)) === null || _a === void 0 ? void 0 : _a.pause(() => this.delegate.outletDisconnected(outlet, element, outletName));
|
||
}
|
||
}
|
||
disconnectAllOutlets() {
|
||
for (const outletName of this.outletElementsByName.keys) {
|
||
for (const element of this.outletElementsByName.getValuesForKey(outletName)) {
|
||
for (const outlet of this.outletsByName.getValuesForKey(outletName)) {
|
||
this.disconnectOutlet(outlet, element, outletName);
|
||
}
|
||
}
|
||
}
|
||
}
|
||
selector(outletName) {
|
||
return this.scope.outlets.getSelectorForOutletName(outletName);
|
||
}
|
||
get outletDependencies() {
|
||
const dependencies = new Multimap();
|
||
this.router.modules.forEach((module) => {
|
||
const constructor = module.definition.controllerConstructor;
|
||
const outlets = readInheritableStaticArrayValues(constructor, "outlets");
|
||
outlets.forEach((outlet) => dependencies.add(outlet, module.identifier));
|
||
});
|
||
return dependencies;
|
||
}
|
||
get outletDefinitions() {
|
||
return this.outletDependencies.getKeysForValue(this.identifier);
|
||
}
|
||
get dependentControllerIdentifiers() {
|
||
return this.outletDependencies.getValuesForKey(this.identifier);
|
||
}
|
||
get dependentContexts() {
|
||
const identifiers = this.dependentControllerIdentifiers;
|
||
return this.router.contexts.filter((context) => identifiers.includes(context.identifier));
|
||
}
|
||
hasOutlet(element, outletName) {
|
||
return !!this.getOutlet(element, outletName) || !!this.getOutletFromMap(element, outletName);
|
||
}
|
||
getOutlet(element, outletName) {
|
||
return this.application.getControllerForElementAndIdentifier(element, outletName);
|
||
}
|
||
getOutletFromMap(element, outletName) {
|
||
return this.outletsByName.getValuesForKey(outletName).find((outlet) => outlet.element === element);
|
||
}
|
||
get scope() {
|
||
return this.context.scope;
|
||
}
|
||
get identifier() {
|
||
return this.context.identifier;
|
||
}
|
||
get application() {
|
||
return this.context.application;
|
||
}
|
||
get router() {
|
||
return this.application.router;
|
||
}
|
||
};
|
||
var Context = class {
|
||
constructor(module, scope) {
|
||
this.logDebugActivity = (functionName, detail = {}) => {
|
||
const { identifier, controller, element } = this;
|
||
detail = Object.assign({ identifier, controller, element }, detail);
|
||
this.application.logDebugActivity(this.identifier, functionName, detail);
|
||
};
|
||
this.module = module;
|
||
this.scope = scope;
|
||
this.controller = new module.controllerConstructor(this);
|
||
this.bindingObserver = new BindingObserver(this, this.dispatcher);
|
||
this.valueObserver = new ValueObserver(this, this.controller);
|
||
this.targetObserver = new TargetObserver(this, this);
|
||
this.outletObserver = new OutletObserver(this, this);
|
||
try {
|
||
this.controller.initialize();
|
||
this.logDebugActivity("initialize");
|
||
} catch (error2) {
|
||
this.handleError(error2, "initializing controller");
|
||
}
|
||
}
|
||
connect() {
|
||
this.bindingObserver.start();
|
||
this.valueObserver.start();
|
||
this.targetObserver.start();
|
||
this.outletObserver.start();
|
||
try {
|
||
this.controller.connect();
|
||
this.logDebugActivity("connect");
|
||
} catch (error2) {
|
||
this.handleError(error2, "connecting controller");
|
||
}
|
||
}
|
||
refresh() {
|
||
this.outletObserver.refresh();
|
||
}
|
||
disconnect() {
|
||
try {
|
||
this.controller.disconnect();
|
||
this.logDebugActivity("disconnect");
|
||
} catch (error2) {
|
||
this.handleError(error2, "disconnecting controller");
|
||
}
|
||
this.outletObserver.stop();
|
||
this.targetObserver.stop();
|
||
this.valueObserver.stop();
|
||
this.bindingObserver.stop();
|
||
}
|
||
get application() {
|
||
return this.module.application;
|
||
}
|
||
get identifier() {
|
||
return this.module.identifier;
|
||
}
|
||
get schema() {
|
||
return this.application.schema;
|
||
}
|
||
get dispatcher() {
|
||
return this.application.dispatcher;
|
||
}
|
||
get element() {
|
||
return this.scope.element;
|
||
}
|
||
get parentElement() {
|
||
return this.element.parentElement;
|
||
}
|
||
handleError(error2, message, detail = {}) {
|
||
const { identifier, controller, element } = this;
|
||
detail = Object.assign({ identifier, controller, element }, detail);
|
||
this.application.handleError(error2, `Error ${message}`, detail);
|
||
}
|
||
targetConnected(element, name) {
|
||
this.invokeControllerMethod(`${name}TargetConnected`, element);
|
||
}
|
||
targetDisconnected(element, name) {
|
||
this.invokeControllerMethod(`${name}TargetDisconnected`, element);
|
||
}
|
||
outletConnected(outlet, element, name) {
|
||
this.invokeControllerMethod(`${namespaceCamelize(name)}OutletConnected`, outlet, element);
|
||
}
|
||
outletDisconnected(outlet, element, name) {
|
||
this.invokeControllerMethod(`${namespaceCamelize(name)}OutletDisconnected`, outlet, element);
|
||
}
|
||
invokeControllerMethod(methodName, ...args) {
|
||
const controller = this.controller;
|
||
if (typeof controller[methodName] == "function") {
|
||
controller[methodName](...args);
|
||
}
|
||
}
|
||
};
|
||
function bless(constructor) {
|
||
return shadow(constructor, getBlessedProperties(constructor));
|
||
}
|
||
function shadow(constructor, properties) {
|
||
const shadowConstructor = extend2(constructor);
|
||
const shadowProperties = getShadowProperties(constructor.prototype, properties);
|
||
Object.defineProperties(shadowConstructor.prototype, shadowProperties);
|
||
return shadowConstructor;
|
||
}
|
||
function getBlessedProperties(constructor) {
|
||
const blessings = readInheritableStaticArrayValues(constructor, "blessings");
|
||
return blessings.reduce((blessedProperties, blessing) => {
|
||
const properties = blessing(constructor);
|
||
for (const key in properties) {
|
||
const descriptor = blessedProperties[key] || {};
|
||
blessedProperties[key] = Object.assign(descriptor, properties[key]);
|
||
}
|
||
return blessedProperties;
|
||
}, {});
|
||
}
|
||
function getShadowProperties(prototype, properties) {
|
||
return getOwnKeys(properties).reduce((shadowProperties, key) => {
|
||
const descriptor = getShadowedDescriptor(prototype, properties, key);
|
||
if (descriptor) {
|
||
Object.assign(shadowProperties, { [key]: descriptor });
|
||
}
|
||
return shadowProperties;
|
||
}, {});
|
||
}
|
||
function getShadowedDescriptor(prototype, properties, key) {
|
||
const shadowingDescriptor = Object.getOwnPropertyDescriptor(prototype, key);
|
||
const shadowedByValue = shadowingDescriptor && "value" in shadowingDescriptor;
|
||
if (!shadowedByValue) {
|
||
const descriptor = Object.getOwnPropertyDescriptor(properties, key).value;
|
||
if (shadowingDescriptor) {
|
||
descriptor.get = shadowingDescriptor.get || descriptor.get;
|
||
descriptor.set = shadowingDescriptor.set || descriptor.set;
|
||
}
|
||
return descriptor;
|
||
}
|
||
}
|
||
var getOwnKeys = (() => {
|
||
if (typeof Object.getOwnPropertySymbols == "function") {
|
||
return (object) => [...Object.getOwnPropertyNames(object), ...Object.getOwnPropertySymbols(object)];
|
||
} else {
|
||
return Object.getOwnPropertyNames;
|
||
}
|
||
})();
|
||
var extend2 = (() => {
|
||
function extendWithReflect(constructor) {
|
||
function extended() {
|
||
return Reflect.construct(constructor, arguments, new.target);
|
||
}
|
||
extended.prototype = Object.create(constructor.prototype, {
|
||
constructor: { value: extended }
|
||
});
|
||
Reflect.setPrototypeOf(extended, constructor);
|
||
return extended;
|
||
}
|
||
function testReflectExtension() {
|
||
const a = function() {
|
||
this.a.call(this);
|
||
};
|
||
const b = extendWithReflect(a);
|
||
b.prototype.a = function() {
|
||
};
|
||
return new b();
|
||
}
|
||
try {
|
||
testReflectExtension();
|
||
return extendWithReflect;
|
||
} catch (error2) {
|
||
return (constructor) => class extended extends constructor {
|
||
};
|
||
}
|
||
})();
|
||
function blessDefinition(definition) {
|
||
return {
|
||
identifier: definition.identifier,
|
||
controllerConstructor: bless(definition.controllerConstructor)
|
||
};
|
||
}
|
||
var Module = class {
|
||
constructor(application2, definition) {
|
||
this.application = application2;
|
||
this.definition = blessDefinition(definition);
|
||
this.contextsByScope = /* @__PURE__ */ new WeakMap();
|
||
this.connectedContexts = /* @__PURE__ */ new Set();
|
||
}
|
||
get identifier() {
|
||
return this.definition.identifier;
|
||
}
|
||
get controllerConstructor() {
|
||
return this.definition.controllerConstructor;
|
||
}
|
||
get contexts() {
|
||
return Array.from(this.connectedContexts);
|
||
}
|
||
connectContextForScope(scope) {
|
||
const context = this.fetchContextForScope(scope);
|
||
this.connectedContexts.add(context);
|
||
context.connect();
|
||
}
|
||
disconnectContextForScope(scope) {
|
||
const context = this.contextsByScope.get(scope);
|
||
if (context) {
|
||
this.connectedContexts.delete(context);
|
||
context.disconnect();
|
||
}
|
||
}
|
||
fetchContextForScope(scope) {
|
||
let context = this.contextsByScope.get(scope);
|
||
if (!context) {
|
||
context = new Context(this, scope);
|
||
this.contextsByScope.set(scope, context);
|
||
}
|
||
return context;
|
||
}
|
||
};
|
||
var ClassMap = class {
|
||
constructor(scope) {
|
||
this.scope = scope;
|
||
}
|
||
has(name) {
|
||
return this.data.has(this.getDataKey(name));
|
||
}
|
||
get(name) {
|
||
return this.getAll(name)[0];
|
||
}
|
||
getAll(name) {
|
||
const tokenString = this.data.get(this.getDataKey(name)) || "";
|
||
return tokenize(tokenString);
|
||
}
|
||
getAttributeName(name) {
|
||
return this.data.getAttributeNameForKey(this.getDataKey(name));
|
||
}
|
||
getDataKey(name) {
|
||
return `${name}-class`;
|
||
}
|
||
get data() {
|
||
return this.scope.data;
|
||
}
|
||
};
|
||
var DataMap = class {
|
||
constructor(scope) {
|
||
this.scope = scope;
|
||
}
|
||
get element() {
|
||
return this.scope.element;
|
||
}
|
||
get identifier() {
|
||
return this.scope.identifier;
|
||
}
|
||
get(key) {
|
||
const name = this.getAttributeNameForKey(key);
|
||
return this.element.getAttribute(name);
|
||
}
|
||
set(key, value) {
|
||
const name = this.getAttributeNameForKey(key);
|
||
this.element.setAttribute(name, value);
|
||
return this.get(key);
|
||
}
|
||
has(key) {
|
||
const name = this.getAttributeNameForKey(key);
|
||
return this.element.hasAttribute(name);
|
||
}
|
||
delete(key) {
|
||
if (this.has(key)) {
|
||
const name = this.getAttributeNameForKey(key);
|
||
this.element.removeAttribute(name);
|
||
return true;
|
||
} else {
|
||
return false;
|
||
}
|
||
}
|
||
getAttributeNameForKey(key) {
|
||
return `data-${this.identifier}-${dasherize(key)}`;
|
||
}
|
||
};
|
||
var Guide = class {
|
||
constructor(logger) {
|
||
this.warnedKeysByObject = /* @__PURE__ */ new WeakMap();
|
||
this.logger = logger;
|
||
}
|
||
warn(object, key, message) {
|
||
let warnedKeys = this.warnedKeysByObject.get(object);
|
||
if (!warnedKeys) {
|
||
warnedKeys = /* @__PURE__ */ new Set();
|
||
this.warnedKeysByObject.set(object, warnedKeys);
|
||
}
|
||
if (!warnedKeys.has(key)) {
|
||
warnedKeys.add(key);
|
||
this.logger.warn(message, object);
|
||
}
|
||
}
|
||
};
|
||
function attributeValueContainsToken(attributeName, token) {
|
||
return `[${attributeName}~="${token}"]`;
|
||
}
|
||
var TargetSet = class {
|
||
constructor(scope) {
|
||
this.scope = scope;
|
||
}
|
||
get element() {
|
||
return this.scope.element;
|
||
}
|
||
get identifier() {
|
||
return this.scope.identifier;
|
||
}
|
||
get schema() {
|
||
return this.scope.schema;
|
||
}
|
||
has(targetName) {
|
||
return this.find(targetName) != null;
|
||
}
|
||
find(...targetNames) {
|
||
return targetNames.reduce((target, targetName) => target || this.findTarget(targetName) || this.findLegacyTarget(targetName), void 0);
|
||
}
|
||
findAll(...targetNames) {
|
||
return targetNames.reduce((targets, targetName) => [
|
||
...targets,
|
||
...this.findAllTargets(targetName),
|
||
...this.findAllLegacyTargets(targetName)
|
||
], []);
|
||
}
|
||
findTarget(targetName) {
|
||
const selector = this.getSelectorForTargetName(targetName);
|
||
return this.scope.findElement(selector);
|
||
}
|
||
findAllTargets(targetName) {
|
||
const selector = this.getSelectorForTargetName(targetName);
|
||
return this.scope.findAllElements(selector);
|
||
}
|
||
getSelectorForTargetName(targetName) {
|
||
const attributeName = this.schema.targetAttributeForScope(this.identifier);
|
||
return attributeValueContainsToken(attributeName, targetName);
|
||
}
|
||
findLegacyTarget(targetName) {
|
||
const selector = this.getLegacySelectorForTargetName(targetName);
|
||
return this.deprecate(this.scope.findElement(selector), targetName);
|
||
}
|
||
findAllLegacyTargets(targetName) {
|
||
const selector = this.getLegacySelectorForTargetName(targetName);
|
||
return this.scope.findAllElements(selector).map((element) => this.deprecate(element, targetName));
|
||
}
|
||
getLegacySelectorForTargetName(targetName) {
|
||
const targetDescriptor = `${this.identifier}.${targetName}`;
|
||
return attributeValueContainsToken(this.schema.targetAttribute, targetDescriptor);
|
||
}
|
||
deprecate(element, targetName) {
|
||
if (element) {
|
||
const { identifier } = this;
|
||
const attributeName = this.schema.targetAttribute;
|
||
const revisedAttributeName = this.schema.targetAttributeForScope(identifier);
|
||
this.guide.warn(element, `target:${targetName}`, `Please replace ${attributeName}="${identifier}.${targetName}" with ${revisedAttributeName}="${targetName}". The ${attributeName} attribute is deprecated and will be removed in a future version of Stimulus.`);
|
||
}
|
||
return element;
|
||
}
|
||
get guide() {
|
||
return this.scope.guide;
|
||
}
|
||
};
|
||
var OutletSet = class {
|
||
constructor(scope, controllerElement) {
|
||
this.scope = scope;
|
||
this.controllerElement = controllerElement;
|
||
}
|
||
get element() {
|
||
return this.scope.element;
|
||
}
|
||
get identifier() {
|
||
return this.scope.identifier;
|
||
}
|
||
get schema() {
|
||
return this.scope.schema;
|
||
}
|
||
has(outletName) {
|
||
return this.find(outletName) != null;
|
||
}
|
||
find(...outletNames) {
|
||
return outletNames.reduce((outlet, outletName) => outlet || this.findOutlet(outletName), void 0);
|
||
}
|
||
findAll(...outletNames) {
|
||
return outletNames.reduce((outlets, outletName) => [...outlets, ...this.findAllOutlets(outletName)], []);
|
||
}
|
||
getSelectorForOutletName(outletName) {
|
||
const attributeName = this.schema.outletAttributeForScope(this.identifier, outletName);
|
||
return this.controllerElement.getAttribute(attributeName);
|
||
}
|
||
findOutlet(outletName) {
|
||
const selector = this.getSelectorForOutletName(outletName);
|
||
if (selector)
|
||
return this.findElement(selector, outletName);
|
||
}
|
||
findAllOutlets(outletName) {
|
||
const selector = this.getSelectorForOutletName(outletName);
|
||
return selector ? this.findAllElements(selector, outletName) : [];
|
||
}
|
||
findElement(selector, outletName) {
|
||
const elements = this.scope.queryElements(selector);
|
||
return elements.filter((element) => this.matchesElement(element, selector, outletName))[0];
|
||
}
|
||
findAllElements(selector, outletName) {
|
||
const elements = this.scope.queryElements(selector);
|
||
return elements.filter((element) => this.matchesElement(element, selector, outletName));
|
||
}
|
||
matchesElement(element, selector, outletName) {
|
||
const controllerAttribute = element.getAttribute(this.scope.schema.controllerAttribute) || "";
|
||
return element.matches(selector) && controllerAttribute.split(" ").includes(outletName);
|
||
}
|
||
};
|
||
var Scope = class _Scope {
|
||
constructor(schema, element, identifier, logger) {
|
||
this.targets = new TargetSet(this);
|
||
this.classes = new ClassMap(this);
|
||
this.data = new DataMap(this);
|
||
this.containsElement = (element2) => {
|
||
return element2.closest(this.controllerSelector) === this.element;
|
||
};
|
||
this.schema = schema;
|
||
this.element = element;
|
||
this.identifier = identifier;
|
||
this.guide = new Guide(logger);
|
||
this.outlets = new OutletSet(this.documentScope, element);
|
||
}
|
||
findElement(selector) {
|
||
return this.element.matches(selector) ? this.element : this.queryElements(selector).find(this.containsElement);
|
||
}
|
||
findAllElements(selector) {
|
||
return [
|
||
...this.element.matches(selector) ? [this.element] : [],
|
||
...this.queryElements(selector).filter(this.containsElement)
|
||
];
|
||
}
|
||
queryElements(selector) {
|
||
return Array.from(this.element.querySelectorAll(selector));
|
||
}
|
||
get controllerSelector() {
|
||
return attributeValueContainsToken(this.schema.controllerAttribute, this.identifier);
|
||
}
|
||
get isDocumentScope() {
|
||
return this.element === document.documentElement;
|
||
}
|
||
get documentScope() {
|
||
return this.isDocumentScope ? this : new _Scope(this.schema, document.documentElement, this.identifier, this.guide.logger);
|
||
}
|
||
};
|
||
var ScopeObserver = class {
|
||
constructor(element, schema, delegate) {
|
||
this.element = element;
|
||
this.schema = schema;
|
||
this.delegate = delegate;
|
||
this.valueListObserver = new ValueListObserver(this.element, this.controllerAttribute, this);
|
||
this.scopesByIdentifierByElement = /* @__PURE__ */ new WeakMap();
|
||
this.scopeReferenceCounts = /* @__PURE__ */ new WeakMap();
|
||
}
|
||
start() {
|
||
this.valueListObserver.start();
|
||
}
|
||
stop() {
|
||
this.valueListObserver.stop();
|
||
}
|
||
get controllerAttribute() {
|
||
return this.schema.controllerAttribute;
|
||
}
|
||
parseValueForToken(token) {
|
||
const { element, content: identifier } = token;
|
||
const scopesByIdentifier = this.fetchScopesByIdentifierForElement(element);
|
||
let scope = scopesByIdentifier.get(identifier);
|
||
if (!scope) {
|
||
scope = this.delegate.createScopeForElementAndIdentifier(element, identifier);
|
||
scopesByIdentifier.set(identifier, scope);
|
||
}
|
||
return scope;
|
||
}
|
||
elementMatchedValue(element, value) {
|
||
const referenceCount = (this.scopeReferenceCounts.get(value) || 0) + 1;
|
||
this.scopeReferenceCounts.set(value, referenceCount);
|
||
if (referenceCount == 1) {
|
||
this.delegate.scopeConnected(value);
|
||
}
|
||
}
|
||
elementUnmatchedValue(element, value) {
|
||
const referenceCount = this.scopeReferenceCounts.get(value);
|
||
if (referenceCount) {
|
||
this.scopeReferenceCounts.set(value, referenceCount - 1);
|
||
if (referenceCount == 1) {
|
||
this.delegate.scopeDisconnected(value);
|
||
}
|
||
}
|
||
}
|
||
fetchScopesByIdentifierForElement(element) {
|
||
let scopesByIdentifier = this.scopesByIdentifierByElement.get(element);
|
||
if (!scopesByIdentifier) {
|
||
scopesByIdentifier = /* @__PURE__ */ new Map();
|
||
this.scopesByIdentifierByElement.set(element, scopesByIdentifier);
|
||
}
|
||
return scopesByIdentifier;
|
||
}
|
||
};
|
||
var Router = class {
|
||
constructor(application2) {
|
||
this.application = application2;
|
||
this.scopeObserver = new ScopeObserver(this.element, this.schema, this);
|
||
this.scopesByIdentifier = new Multimap();
|
||
this.modulesByIdentifier = /* @__PURE__ */ new Map();
|
||
}
|
||
get element() {
|
||
return this.application.element;
|
||
}
|
||
get schema() {
|
||
return this.application.schema;
|
||
}
|
||
get logger() {
|
||
return this.application.logger;
|
||
}
|
||
get controllerAttribute() {
|
||
return this.schema.controllerAttribute;
|
||
}
|
||
get modules() {
|
||
return Array.from(this.modulesByIdentifier.values());
|
||
}
|
||
get contexts() {
|
||
return this.modules.reduce((contexts, module) => contexts.concat(module.contexts), []);
|
||
}
|
||
start() {
|
||
this.scopeObserver.start();
|
||
}
|
||
stop() {
|
||
this.scopeObserver.stop();
|
||
}
|
||
loadDefinition(definition) {
|
||
this.unloadIdentifier(definition.identifier);
|
||
const module = new Module(this.application, definition);
|
||
this.connectModule(module);
|
||
const afterLoad = definition.controllerConstructor.afterLoad;
|
||
if (afterLoad) {
|
||
afterLoad(definition.identifier, this.application);
|
||
}
|
||
}
|
||
unloadIdentifier(identifier) {
|
||
const module = this.modulesByIdentifier.get(identifier);
|
||
if (module) {
|
||
this.disconnectModule(module);
|
||
}
|
||
}
|
||
getContextForElementAndIdentifier(element, identifier) {
|
||
const module = this.modulesByIdentifier.get(identifier);
|
||
if (module) {
|
||
return module.contexts.find((context) => context.element == element);
|
||
}
|
||
}
|
||
handleError(error2, message, detail) {
|
||
this.application.handleError(error2, message, detail);
|
||
}
|
||
createScopeForElementAndIdentifier(element, identifier) {
|
||
return new Scope(this.schema, element, identifier, this.logger);
|
||
}
|
||
scopeConnected(scope) {
|
||
this.scopesByIdentifier.add(scope.identifier, scope);
|
||
const module = this.modulesByIdentifier.get(scope.identifier);
|
||
if (module) {
|
||
module.connectContextForScope(scope);
|
||
}
|
||
}
|
||
scopeDisconnected(scope) {
|
||
this.scopesByIdentifier.delete(scope.identifier, scope);
|
||
const module = this.modulesByIdentifier.get(scope.identifier);
|
||
if (module) {
|
||
module.disconnectContextForScope(scope);
|
||
}
|
||
}
|
||
connectModule(module) {
|
||
this.modulesByIdentifier.set(module.identifier, module);
|
||
const scopes = this.scopesByIdentifier.getValuesForKey(module.identifier);
|
||
scopes.forEach((scope) => module.connectContextForScope(scope));
|
||
}
|
||
disconnectModule(module) {
|
||
this.modulesByIdentifier.delete(module.identifier);
|
||
const scopes = this.scopesByIdentifier.getValuesForKey(module.identifier);
|
||
scopes.forEach((scope) => module.disconnectContextForScope(scope));
|
||
}
|
||
};
|
||
var defaultSchema = {
|
||
controllerAttribute: "data-controller",
|
||
actionAttribute: "data-action",
|
||
targetAttribute: "data-target",
|
||
targetAttributeForScope: (identifier) => `data-${identifier}-target`,
|
||
outletAttributeForScope: (identifier, outlet) => `data-${identifier}-${outlet}-outlet`,
|
||
keyMappings: Object.assign(Object.assign({ enter: "Enter", tab: "Tab", esc: "Escape", space: " ", up: "ArrowUp", down: "ArrowDown", left: "ArrowLeft", right: "ArrowRight", home: "Home", end: "End" }, objectFromEntries("abcdefghijklmnopqrstuvwxyz".split("").map((c) => [c, c]))), objectFromEntries("0123456789".split("").map((n) => [n, n])))
|
||
};
|
||
function objectFromEntries(array) {
|
||
return array.reduce((memo, [k, v]) => Object.assign(Object.assign({}, memo), { [k]: v }), {});
|
||
}
|
||
var Application = class {
|
||
constructor(element = document.documentElement, schema = defaultSchema) {
|
||
this.logger = console;
|
||
this.debug = false;
|
||
this.logDebugActivity = (identifier, functionName, detail = {}) => {
|
||
if (this.debug) {
|
||
this.logFormattedMessage(identifier, functionName, detail);
|
||
}
|
||
};
|
||
this.element = element;
|
||
this.schema = schema;
|
||
this.dispatcher = new Dispatcher(this);
|
||
this.router = new Router(this);
|
||
this.actionDescriptorFilters = Object.assign({}, defaultActionDescriptorFilters);
|
||
}
|
||
static start(element, schema) {
|
||
const application2 = new this(element, schema);
|
||
application2.start();
|
||
return application2;
|
||
}
|
||
async start() {
|
||
await domReady();
|
||
this.logDebugActivity("application", "starting");
|
||
this.dispatcher.start();
|
||
this.router.start();
|
||
this.logDebugActivity("application", "start");
|
||
}
|
||
stop() {
|
||
this.logDebugActivity("application", "stopping");
|
||
this.dispatcher.stop();
|
||
this.router.stop();
|
||
this.logDebugActivity("application", "stop");
|
||
}
|
||
register(identifier, controllerConstructor) {
|
||
this.load({ identifier, controllerConstructor });
|
||
}
|
||
registerActionOption(name, filter) {
|
||
this.actionDescriptorFilters[name] = filter;
|
||
}
|
||
load(head, ...rest) {
|
||
const definitions = Array.isArray(head) ? head : [head, ...rest];
|
||
definitions.forEach((definition) => {
|
||
if (definition.controllerConstructor.shouldLoad) {
|
||
this.router.loadDefinition(definition);
|
||
}
|
||
});
|
||
}
|
||
unload(head, ...rest) {
|
||
const identifiers = Array.isArray(head) ? head : [head, ...rest];
|
||
identifiers.forEach((identifier) => this.router.unloadIdentifier(identifier));
|
||
}
|
||
get controllers() {
|
||
return this.router.contexts.map((context) => context.controller);
|
||
}
|
||
getControllerForElementAndIdentifier(element, identifier) {
|
||
const context = this.router.getContextForElementAndIdentifier(element, identifier);
|
||
return context ? context.controller : null;
|
||
}
|
||
handleError(error2, message, detail) {
|
||
var _a;
|
||
this.logger.error(`%s
|
||
|
||
%o
|
||
|
||
%o`, message, error2, detail);
|
||
(_a = window.onerror) === null || _a === void 0 ? void 0 : _a.call(window, message, "", 0, 0, error2);
|
||
}
|
||
logFormattedMessage(identifier, functionName, detail = {}) {
|
||
detail = Object.assign({ application: this }, detail);
|
||
this.logger.groupCollapsed(`${identifier} #${functionName}`);
|
||
this.logger.log("details:", Object.assign({}, detail));
|
||
this.logger.groupEnd();
|
||
}
|
||
};
|
||
function domReady() {
|
||
return new Promise((resolve) => {
|
||
if (document.readyState == "loading") {
|
||
document.addEventListener("DOMContentLoaded", () => resolve());
|
||
} else {
|
||
resolve();
|
||
}
|
||
});
|
||
}
|
||
function ClassPropertiesBlessing(constructor) {
|
||
const classes = readInheritableStaticArrayValues(constructor, "classes");
|
||
return classes.reduce((properties, classDefinition) => {
|
||
return Object.assign(properties, propertiesForClassDefinition(classDefinition));
|
||
}, {});
|
||
}
|
||
function propertiesForClassDefinition(key) {
|
||
return {
|
||
[`${key}Class`]: {
|
||
get() {
|
||
const { classes } = this;
|
||
if (classes.has(key)) {
|
||
return classes.get(key);
|
||
} else {
|
||
const attribute = classes.getAttributeName(key);
|
||
throw new Error(`Missing attribute "${attribute}"`);
|
||
}
|
||
}
|
||
},
|
||
[`${key}Classes`]: {
|
||
get() {
|
||
return this.classes.getAll(key);
|
||
}
|
||
},
|
||
[`has${capitalize(key)}Class`]: {
|
||
get() {
|
||
return this.classes.has(key);
|
||
}
|
||
}
|
||
};
|
||
}
|
||
function OutletPropertiesBlessing(constructor) {
|
||
const outlets = readInheritableStaticArrayValues(constructor, "outlets");
|
||
return outlets.reduce((properties, outletDefinition) => {
|
||
return Object.assign(properties, propertiesForOutletDefinition(outletDefinition));
|
||
}, {});
|
||
}
|
||
function propertiesForOutletDefinition(name) {
|
||
const camelizedName = namespaceCamelize(name);
|
||
return {
|
||
[`${camelizedName}Outlet`]: {
|
||
get() {
|
||
const outlet = this.outlets.find(name);
|
||
if (outlet) {
|
||
const outletController = this.application.getControllerForElementAndIdentifier(outlet, name);
|
||
if (outletController) {
|
||
return outletController;
|
||
} else {
|
||
throw new Error(`Missing "data-controller=${name}" attribute on outlet element for "${this.identifier}" controller`);
|
||
}
|
||
}
|
||
throw new Error(`Missing outlet element "${name}" for "${this.identifier}" controller`);
|
||
}
|
||
},
|
||
[`${camelizedName}Outlets`]: {
|
||
get() {
|
||
const outlets = this.outlets.findAll(name);
|
||
if (outlets.length > 0) {
|
||
return outlets.map((outlet) => {
|
||
const controller = this.application.getControllerForElementAndIdentifier(outlet, name);
|
||
if (controller) {
|
||
return controller;
|
||
} else {
|
||
console.warn(`The provided outlet element is missing the outlet controller "${name}" for "${this.identifier}"`, outlet);
|
||
}
|
||
}).filter((controller) => controller);
|
||
}
|
||
return [];
|
||
}
|
||
},
|
||
[`${camelizedName}OutletElement`]: {
|
||
get() {
|
||
const outlet = this.outlets.find(name);
|
||
if (outlet) {
|
||
return outlet;
|
||
} else {
|
||
throw new Error(`Missing outlet element "${name}" for "${this.identifier}" controller`);
|
||
}
|
||
}
|
||
},
|
||
[`${camelizedName}OutletElements`]: {
|
||
get() {
|
||
return this.outlets.findAll(name);
|
||
}
|
||
},
|
||
[`has${capitalize(camelizedName)}Outlet`]: {
|
||
get() {
|
||
return this.outlets.has(name);
|
||
}
|
||
}
|
||
};
|
||
}
|
||
function TargetPropertiesBlessing(constructor) {
|
||
const targets = readInheritableStaticArrayValues(constructor, "targets");
|
||
return targets.reduce((properties, targetDefinition) => {
|
||
return Object.assign(properties, propertiesForTargetDefinition(targetDefinition));
|
||
}, {});
|
||
}
|
||
function propertiesForTargetDefinition(name) {
|
||
return {
|
||
[`${name}Target`]: {
|
||
get() {
|
||
const target = this.targets.find(name);
|
||
if (target) {
|
||
return target;
|
||
} else {
|
||
throw new Error(`Missing target element "${name}" for "${this.identifier}" controller`);
|
||
}
|
||
}
|
||
},
|
||
[`${name}Targets`]: {
|
||
get() {
|
||
return this.targets.findAll(name);
|
||
}
|
||
},
|
||
[`has${capitalize(name)}Target`]: {
|
||
get() {
|
||
return this.targets.has(name);
|
||
}
|
||
}
|
||
};
|
||
}
|
||
function ValuePropertiesBlessing(constructor) {
|
||
const valueDefinitionPairs = readInheritableStaticObjectPairs(constructor, "values");
|
||
const propertyDescriptorMap = {
|
||
valueDescriptorMap: {
|
||
get() {
|
||
return valueDefinitionPairs.reduce((result, valueDefinitionPair) => {
|
||
const valueDescriptor = parseValueDefinitionPair(valueDefinitionPair, this.identifier);
|
||
const attributeName = this.data.getAttributeNameForKey(valueDescriptor.key);
|
||
return Object.assign(result, { [attributeName]: valueDescriptor });
|
||
}, {});
|
||
}
|
||
}
|
||
};
|
||
return valueDefinitionPairs.reduce((properties, valueDefinitionPair) => {
|
||
return Object.assign(properties, propertiesForValueDefinitionPair(valueDefinitionPair));
|
||
}, propertyDescriptorMap);
|
||
}
|
||
function propertiesForValueDefinitionPair(valueDefinitionPair, controller) {
|
||
const definition = parseValueDefinitionPair(valueDefinitionPair, controller);
|
||
const { key, name, reader: read2, writer: write2 } = definition;
|
||
return {
|
||
[name]: {
|
||
get() {
|
||
const value = this.data.get(key);
|
||
if (value !== null) {
|
||
return read2(value);
|
||
} else {
|
||
return definition.defaultValue;
|
||
}
|
||
},
|
||
set(value) {
|
||
if (value === void 0) {
|
||
this.data.delete(key);
|
||
} else {
|
||
this.data.set(key, write2(value));
|
||
}
|
||
}
|
||
},
|
||
[`has${capitalize(name)}`]: {
|
||
get() {
|
||
return this.data.has(key) || definition.hasCustomDefaultValue;
|
||
}
|
||
}
|
||
};
|
||
}
|
||
function parseValueDefinitionPair([token, typeDefinition], controller) {
|
||
return valueDescriptorForTokenAndTypeDefinition({
|
||
controller,
|
||
token,
|
||
typeDefinition
|
||
});
|
||
}
|
||
function parseValueTypeConstant(constant) {
|
||
switch (constant) {
|
||
case Array:
|
||
return "array";
|
||
case Boolean:
|
||
return "boolean";
|
||
case Number:
|
||
return "number";
|
||
case Object:
|
||
return "object";
|
||
case String:
|
||
return "string";
|
||
}
|
||
}
|
||
function parseValueTypeDefault(defaultValue) {
|
||
switch (typeof defaultValue) {
|
||
case "boolean":
|
||
return "boolean";
|
||
case "number":
|
||
return "number";
|
||
case "string":
|
||
return "string";
|
||
}
|
||
if (Array.isArray(defaultValue))
|
||
return "array";
|
||
if (Object.prototype.toString.call(defaultValue) === "[object Object]")
|
||
return "object";
|
||
}
|
||
function parseValueTypeObject(payload) {
|
||
const typeFromObject = parseValueTypeConstant(payload.typeObject.type);
|
||
if (!typeFromObject)
|
||
return;
|
||
const defaultValueType = parseValueTypeDefault(payload.typeObject.default);
|
||
if (typeFromObject !== defaultValueType) {
|
||
const propertyPath = payload.controller ? `${payload.controller}.${payload.token}` : payload.token;
|
||
throw new Error(`The specified default value for the Stimulus Value "${propertyPath}" must match the defined type "${typeFromObject}". The provided default value of "${payload.typeObject.default}" is of type "${defaultValueType}".`);
|
||
}
|
||
return typeFromObject;
|
||
}
|
||
function parseValueTypeDefinition(payload) {
|
||
const typeFromObject = parseValueTypeObject({
|
||
controller: payload.controller,
|
||
token: payload.token,
|
||
typeObject: payload.typeDefinition
|
||
});
|
||
const typeFromDefaultValue = parseValueTypeDefault(payload.typeDefinition);
|
||
const typeFromConstant = parseValueTypeConstant(payload.typeDefinition);
|
||
const type = typeFromObject || typeFromDefaultValue || typeFromConstant;
|
||
if (type)
|
||
return type;
|
||
const propertyPath = payload.controller ? `${payload.controller}.${payload.typeDefinition}` : payload.token;
|
||
throw new Error(`Unknown value type "${propertyPath}" for "${payload.token}" value`);
|
||
}
|
||
function defaultValueForDefinition(typeDefinition) {
|
||
const constant = parseValueTypeConstant(typeDefinition);
|
||
if (constant)
|
||
return defaultValuesByType[constant];
|
||
const defaultValue = typeDefinition.default;
|
||
if (defaultValue !== void 0)
|
||
return defaultValue;
|
||
return typeDefinition;
|
||
}
|
||
function valueDescriptorForTokenAndTypeDefinition(payload) {
|
||
const key = `${dasherize(payload.token)}-value`;
|
||
const type = parseValueTypeDefinition(payload);
|
||
return {
|
||
type,
|
||
key,
|
||
name: camelize(key),
|
||
get defaultValue() {
|
||
return defaultValueForDefinition(payload.typeDefinition);
|
||
},
|
||
get hasCustomDefaultValue() {
|
||
return parseValueTypeDefault(payload.typeDefinition) !== void 0;
|
||
},
|
||
reader: readers[type],
|
||
writer: writers[type] || writers.default
|
||
};
|
||
}
|
||
var defaultValuesByType = {
|
||
get array() {
|
||
return [];
|
||
},
|
||
boolean: false,
|
||
number: 0,
|
||
get object() {
|
||
return {};
|
||
},
|
||
string: ""
|
||
};
|
||
var readers = {
|
||
array(value) {
|
||
const array = JSON.parse(value);
|
||
if (!Array.isArray(array)) {
|
||
throw new TypeError(`expected value of type "array" but instead got value "${value}" of type "${parseValueTypeDefault(array)}"`);
|
||
}
|
||
return array;
|
||
},
|
||
boolean(value) {
|
||
return !(value == "0" || String(value).toLowerCase() == "false");
|
||
},
|
||
number(value) {
|
||
return Number(value);
|
||
},
|
||
object(value) {
|
||
const object = JSON.parse(value);
|
||
if (object === null || typeof object != "object" || Array.isArray(object)) {
|
||
throw new TypeError(`expected value of type "object" but instead got value "${value}" of type "${parseValueTypeDefault(object)}"`);
|
||
}
|
||
return object;
|
||
},
|
||
string(value) {
|
||
return value;
|
||
}
|
||
};
|
||
var writers = {
|
||
default: writeString,
|
||
array: writeJSON,
|
||
object: writeJSON
|
||
};
|
||
function writeJSON(value) {
|
||
return JSON.stringify(value);
|
||
}
|
||
function writeString(value) {
|
||
return `${value}`;
|
||
}
|
||
var Controller = class {
|
||
constructor(context) {
|
||
this.context = context;
|
||
}
|
||
static get shouldLoad() {
|
||
return true;
|
||
}
|
||
static afterLoad(_identifier, _application) {
|
||
return;
|
||
}
|
||
get application() {
|
||
return this.context.application;
|
||
}
|
||
get scope() {
|
||
return this.context.scope;
|
||
}
|
||
get element() {
|
||
return this.scope.element;
|
||
}
|
||
get identifier() {
|
||
return this.scope.identifier;
|
||
}
|
||
get targets() {
|
||
return this.scope.targets;
|
||
}
|
||
get outlets() {
|
||
return this.scope.outlets;
|
||
}
|
||
get classes() {
|
||
return this.scope.classes;
|
||
}
|
||
get data() {
|
||
return this.scope.data;
|
||
}
|
||
initialize() {
|
||
}
|
||
connect() {
|
||
}
|
||
disconnect() {
|
||
}
|
||
dispatch(eventName, { target = this.element, detail = {}, prefix = this.identifier, bubbles = true, cancelable = true } = {}) {
|
||
const type = prefix ? `${prefix}:${eventName}` : eventName;
|
||
const event = new CustomEvent(type, { detail, bubbles, cancelable });
|
||
target.dispatchEvent(event);
|
||
return event;
|
||
}
|
||
};
|
||
Controller.blessings = [
|
||
ClassPropertiesBlessing,
|
||
TargetPropertiesBlessing,
|
||
ValuePropertiesBlessing,
|
||
OutletPropertiesBlessing
|
||
];
|
||
Controller.targets = [];
|
||
Controller.outlets = [];
|
||
Controller.values = {};
|
||
|
||
// app/javascript/controllers/application.js
|
||
var application = Application.start();
|
||
application.debug = false;
|
||
window.Stimulus = application;
|
||
|
||
// app/javascript/controllers/analyze_controller.js
|
||
var analyze_controller_default = class extends Controller {
|
||
connect() {
|
||
}
|
||
refresh(event) {
|
||
let base_url = event.target.value;
|
||
let target = event.target;
|
||
console.log(this.selected_slice(target));
|
||
console.log(target.name);
|
||
let url = base_url + "&academic_years=" + this.selected_years().join(",") + "&source=" + this.selected_source(target) + "&slice=" + this.selected_slice(target) + "&group=" + this.selected_group() + "&graph=" + this.selected_graph(target) + "&races=" + this.selected_items("race").join(",") + "&genders=" + this.selected_items("gender").join(",") + "&incomes=" + this.selected_items("income").join(",") + "&grades=" + this.selected_items("grade").join(",") + "&ells=" + this.selected_items("ell").join(",") + "&speds=" + this.selected_items("sped").join(",");
|
||
this.go_to(url);
|
||
}
|
||
go_to(location2) {
|
||
window.location = location2;
|
||
}
|
||
selected_years() {
|
||
let year_checkboxes = [...document.getElementsByName("year-checkbox")];
|
||
let years = year_checkboxes.filter((item) => {
|
||
return item.checked;
|
||
}).map((item) => {
|
||
return item.id;
|
||
});
|
||
return years;
|
||
}
|
||
selected_group() {
|
||
let groups = [...document.getElementsByName("group-option")];
|
||
let selected_group = groups.filter((item) => {
|
||
return item.selected;
|
||
}).map((item) => {
|
||
return item.id;
|
||
});
|
||
return selected_group[0];
|
||
}
|
||
selected_source(target) {
|
||
if (target.name === "source") {
|
||
return target.id;
|
||
}
|
||
if (target.name === "slice" || target.name === "group") {
|
||
return "survey-data-only";
|
||
}
|
||
return window.source;
|
||
}
|
||
selected_slice(target) {
|
||
if (target.name === "source" && target.id === "all-data") {
|
||
return "all-data";
|
||
}
|
||
if (target.name === "source" && target.id === "survey-data-only") {
|
||
return "students-and-teachers";
|
||
}
|
||
if (target.name === "group") {
|
||
return "students-by-group";
|
||
}
|
||
if (target.name === "source" || target.name === "slice") {
|
||
let slices = [...document.getElementsByName("slice")];
|
||
let selected_slice = slices.filter((item) => {
|
||
return item.id != "all-data";
|
||
}).filter((item) => {
|
||
return item.checked;
|
||
}).map((item) => {
|
||
return item.id;
|
||
});
|
||
return selected_slice[0];
|
||
}
|
||
return window.slice;
|
||
}
|
||
selected_graph(target) {
|
||
if (target.name === "source" && target.id === "all-data") {
|
||
return "all-data";
|
||
}
|
||
if (target.name === "source" && target.id === "survey-data-only") {
|
||
return "students-and-teachers";
|
||
}
|
||
let graphs = [...document.getElementsByName("slice")];
|
||
let selected_slice = graphs.filter((item) => {
|
||
return item.checked;
|
||
}).map((item) => {
|
||
return item.id;
|
||
})[0];
|
||
if (target.name === "slice" || target.name === "group") {
|
||
if (selected_slice === "students-and-teachers") {
|
||
return "students-and-teachers";
|
||
}
|
||
return `students-by-${this.selected_group()}`;
|
||
}
|
||
return window.graph;
|
||
}
|
||
selected_items(type) {
|
||
let checkboxes = [...document.getElementsByName(`${type}-checkbox`)];
|
||
let items = checkboxes.filter((item) => {
|
||
return item.checked;
|
||
}).map((item) => {
|
||
return item.id.replace(`${type}-`, "");
|
||
});
|
||
return items;
|
||
}
|
||
};
|
||
|
||
// app/javascript/controllers/form_controller.js
|
||
var import_debounce2 = __toESM(require_debounce());
|
||
var form_controller_default = class extends Controller {
|
||
initialize() {
|
||
this.submit = (0, import_debounce2.default)(this.submit.bind(this), 300);
|
||
}
|
||
submit() {
|
||
this.element.requestSubmit();
|
||
}
|
||
};
|
||
|
||
// app/javascript/controllers/index.js
|
||
application.register("analyze", analyze_controller_default);
|
||
application.register("form", form_controller_default);
|
||
|
||
// app/javascript/application.js
|
||
import_ujs.default.start();
|
||
start();
|
||
document.addEventListener("turbo:load", () => {
|
||
initializeListenersForNavDropdowns();
|
||
initializePopovers();
|
||
showEmptyDatasetModal();
|
||
});
|
||
})();
|
||
/*! Bundled license information:
|
||
|
||
bootstrap/dist/js/bootstrap.esm.js:
|
||
(*!
|
||
* Bootstrap v5.3.0 (https://getbootstrap.com/)
|
||
* Copyright 2011-2023 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors)
|
||
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
|
||
*)
|
||
*/
|