blob: dd6bdf9c848e3b1bf652ed1dcf5401300cd27a56 [file] [edit]
/*!
* Bootstrap v6.0.0-alpha.2 (https://getbootstrap.com/)
* Copyright 2011-2026 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors)
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
*/
import { arrow, autoUpdate, computePosition, flip, offset, shift, size } from "@floating-ui/dom";
import { Calendar, months } from "vanilla-calendar-pro";
//#region js/src/dom/data.ts
/**
* --------------------------------------------------------------------------
* Bootstrap dom/data.ts
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
* --------------------------------------------------------------------------
*/
/**
* Constants
*/
const elementMap = /* @__PURE__ */ new Map();
var data_default = {
set(element, key, instance) {
if (!elementMap.has(element)) elementMap.set(element, /* @__PURE__ */ new Map());
elementMap.get(element).set(key, instance);
},
get(element, key) {
if (element && 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);
}
};
//#endregion
//#region js/src/dom/event-handler.ts
/**
* Constants
*/
const namespaceRegex = /[^.]*(?=\..*)\.|.*/;
const stripNameRegex = /\..*/;
const stripUidRegex = /::\d+$/;
const eventRegistry = {};
let uidEvent = 1;
const customEvents = {
mouseenter: "mouseover",
mouseleave: "mouseout"
};
const nativeEvents = /* @__PURE__ */ new Set([
"click",
"dblclick",
"mouseup",
"mousedown",
"contextmenu",
"mousewheel",
"DOMMouseScroll",
"mouseover",
"mouseout",
"mousemove",
"selectstart",
"selectend",
"keydown",
"keypress",
"keyup",
"input",
"compositionstart",
"compositionupdate",
"compositionend",
"paste",
"orientationchange",
"touchstart",
"touchmove",
"touchend",
"touchcancel",
"pointerdown",
"pointermove",
"pointerover",
"pointerup",
"pointerleave",
"pointercancel",
"gesturestart",
"gesturechange",
"gestureend",
"focus",
"blur",
"change",
"reset",
"select",
"submit",
"focusin",
"focusout",
"load",
"unload",
"beforeunload",
"resize",
"move",
"DOMContentLoaded",
"readystatechange",
"error",
"abort",
"scroll",
"scrollend",
"hashchange"
]);
/**
* Private methods
*/
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 isMouseEventWithinTarget(event) {
const { delegateTarget, relatedTarget } = event;
return Boolean(relatedTarget && delegateTarget.contains(relatedTarget));
}
function bootstrapHandler(element, fn, handlerTypeEvent) {
const isCustomMouseEvent = handlerTypeEvent in customEvents;
return function handler(event) {
const bootstrapEvent = hydrateObj(event, { delegateTarget: element });
if (isCustomMouseEvent && isMouseEventWithinTarget(bootstrapEvent)) return;
if (handler.oneOff) EventHandler.off(element, handlerTypeEvent, fn);
return fn.apply(element, [bootstrapEvent]);
};
}
function bootstrapDelegationHandler(element, selector, fn, handlerTypeEvent) {
const isCustomMouseEvent = handlerTypeEvent in customEvents;
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;
const bootstrapEvent = hydrateObj(event, { delegateTarget: target });
if (isCustomMouseEvent && isMouseEventWithinTarget(bootstrapEvent)) return;
if (handler.oneOff) EventHandler.off(element, handlerTypeEvent, selector, fn);
return fn.apply(target, [bootstrapEvent]);
}
};
}
function findHandler(events, callable, handlerTypeEvent, delegationSelector = null) {
return Object.values(events).find((event) => event.callable === callable && event.handlerTypeEvent === handlerTypeEvent && event.delegationSelector === delegationSelector);
}
function normalizeParameters(originalTypeEvent, handler, delegationFunction) {
const isDelegated = typeof handler === "string";
const callable = isDelegated ? delegationFunction : handler || delegationFunction;
const baseTypeEvent = originalTypeEvent.replace(stripNameRegex, "");
let typeEvent = customEvents[baseTypeEvent] || baseTypeEvent;
if (!nativeEvents.has(typeEvent)) typeEvent = originalTypeEvent;
const handlerTypeEvent = baseTypeEvent in customEvents ? baseTypeEvent : typeEvent;
return {
isDelegated,
callable,
typeEvent,
handlerTypeEvent
};
}
function addHandler(element, originalTypeEvent, handler, delegationFunction, oneOff) {
if (typeof originalTypeEvent !== "string" || !element) return;
const { isDelegated, callable, typeEvent, handlerTypeEvent } = normalizeParameters(originalTypeEvent, handler, delegationFunction);
const events = getElementEvents(element);
const handlers = events[typeEvent] || (events[typeEvent] = {});
const previousFunction = findHandler(handlers, callable, handlerTypeEvent, isDelegated ? handler : null);
if (previousFunction) {
previousFunction.oneOff = previousFunction.oneOff && oneOff;
return;
}
const uid = makeEventUid(callable, originalTypeEvent.replace(namespaceRegex, ""));
const fn = isDelegated ? bootstrapDelegationHandler(element, handler, callable, handlerTypeEvent) : bootstrapHandler(element, callable, handlerTypeEvent);
fn.delegationSelector = isDelegated ? handler : null;
fn.callable = callable;
fn.handlerTypeEvent = handlerTypeEvent;
fn.oneOff = oneOff;
fn.uidEvent = uid;
handlers[uid] = fn;
element.addEventListener(typeEvent, fn, isDelegated);
}
function removeHandler(element, events, typeEvent, handler) {
element.removeEventListener(typeEvent, handler, Boolean(handler.delegationSelector));
delete events[typeEvent][handler.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);
}
function trigger(element, event, args) {
if (typeof event !== "string" || !element) return null;
const evt = hydrateObj(new Event(event, {
bubbles: true,
cancelable: true
}), args);
element.dispatchEvent(evt);
return evt;
}
const 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, handlerTypeEvent } = normalizeParameters(originalTypeEvent, handler, delegationFunction);
const inNamespace = typeEvent !== originalTypeEvent && handlerTypeEvent !== originalTypeEvent;
const events = getElementEvents(element);
const storeElementEvent = events[typeEvent] || {};
const isNamespace = originalTypeEvent.startsWith(".");
if (typeof callable !== "undefined") {
if (!Object.keys(storeElementEvent).length) return;
const fn = findHandler(storeElementEvent, callable, handlerTypeEvent, isDelegated ? handler : null);
if (fn) removeHandler(element, events, typeEvent, fn);
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 (event.handlerTypeEvent === handlerTypeEvent && (!inNamespace || originalTypeEvent.includes(handlerKey))) removeHandler(element, events, typeEvent, event);
}
},
trigger
};
function hydrateObj(obj, meta = {}) {
for (const [key, value] of Object.entries(meta)) try {
obj[key] = value;
} catch {
Object.defineProperty(obj, key, {
configurable: true,
get() {
return value;
}
});
}
return obj;
}
//#endregion
//#region js/src/dom/manipulator.ts
/**
* --------------------------------------------------------------------------
* Bootstrap dom/manipulator.ts
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
* --------------------------------------------------------------------------
*/
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 {
return value;
}
}
function normalizeDataKey(key) {
return key.replace(/[A-Z]/g, (chr) => `-${chr.toLowerCase()}`);
}
const 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);
attributes[pureKey] = normalizeData(element.dataset[key]);
}
return attributes;
},
getDataAttribute(element, key) {
return normalizeData(element.getAttribute(`data-bs-${normalizeDataKey(key)}`));
}
};
//#endregion
//#region js/src/util/index.ts
/**
* --------------------------------------------------------------------------
* Bootstrap util/index.ts
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
* --------------------------------------------------------------------------
*/
const MAX_UID = 1e6;
const MILLISECONDS_MULTIPLIER = 1e3;
const TRANSITION_END = "transitionend";
/**
* Properly escapes ID selectors to handle special characters in IDs
* (e.g. forward slashes, periods) so that they work with `document.querySelector`.
*
* @param selector - The selector to escape
* @returns The escaped selector
*/
const parseSelector = (selector) => {
if (selector && window.CSS && window.CSS.escape) selector = selector.replace(/#([^\s"#']+)/g, (match, id) => `#${CSS.escape(id)}`);
return selector;
};
const toType = (object) => {
if (object === null || object === void 0) return `${object}`;
return Object.prototype.toString.call(object).match(/\s([a-z]+)/i)[1].toLowerCase();
};
/**
* Public Util API
*/
const getUID = (prefix) => {
do
prefix += Math.floor(Math.random() * MAX_UID);
while (document.getElementById(prefix));
return prefix;
};
const getTransitionDurationFromElement = (element) => {
if (!element) return 0;
let { transitionDuration, transitionDelay } = window.getComputedStyle(element);
if (!Number.parseFloat(transitionDuration) && !Number.parseFloat(transitionDelay)) return 0;
transitionDuration = transitionDuration.split(",")[0];
transitionDelay = transitionDelay.split(",")[0];
return (Number.parseFloat(transitionDuration) + Number.parseFloat(transitionDelay)) * MILLISECONDS_MULTIPLIER;
};
const triggerTransitionEnd = (element) => {
element.dispatchEvent(new Event(TRANSITION_END));
};
const isElement = (object) => {
if (!object || typeof object !== "object") return false;
return typeof object.nodeType !== "undefined";
};
const getElement = (object) => {
if (isElement(object)) return object;
if (typeof object === "string" && object.length > 0) return document.querySelector(parseSelector(object));
return null;
};
const isVisible = (element) => {
if (!isElement(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;
};
const isDisabled = (element) => {
if (!element || element.nodeType !== Node.ELEMENT_NODE) return true;
if (element.classList.contains("disabled")) return true;
const disableableElement = element;
if (typeof disableableElement.disabled !== "undefined") return disableableElement.disabled;
return element.hasAttribute("disabled") && element.getAttribute("disabled") !== "false";
};
const setAriaAttribute = (element, name, value) => {
element.setAttribute(name, String(value));
};
const 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);
};
const noop = () => {};
const isRTL = () => document.documentElement.dir === "rtl";
const execute = (possibleCallback, args = [], defaultValue = possibleCallback) => {
return typeof possibleCallback === "function" ? possibleCallback.call(...args) : defaultValue;
};
const executeAfterTransition = (callback, transitionElement, waitForTransition = true) => {
if (!waitForTransition) {
execute(callback);
return;
}
const emulatedDuration = getTransitionDurationFromElement(transitionElement) + 5;
const handler = ({ target }) => {
if (target !== transitionElement) return;
cancel();
execute(callback);
};
transitionElement.addEventListener(TRANSITION_END, handler);
const timeout = setTimeout(() => triggerTransitionEnd(transitionElement), emulatedDuration);
const cancel = () => {
clearTimeout(timeout);
transitionElement.removeEventListener(TRANSITION_END, handler);
};
return cancel;
};
/**
* Return the previous/next element of a list.
*
* @param list - The list of elements to traverse
* @param activeElement - The currently active element
* @param shouldGetNext - Whether to return the next element (`true`) or the previous one (`false`)
* @param isCycleAllowed - Whether to cycle back to the opposite end of the list when reaching the boundary
* @returns The appropriate previous/next element from the list
*/
const 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))];
};
//#endregion
//#region js/src/util/config.ts
/**
* --------------------------------------------------------------------------
* Bootstrap util/config.ts
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
* --------------------------------------------------------------------------
*/
/**
* Class definition
*/
var Config = class {
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 = isElement(element) ? Manipulator.getDataAttribute(element, "config") : {};
return {
...this.constructor.Default,
...typeof jsonConfig === "object" ? jsonConfig : {},
...isElement(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 = isElement(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}".`);
}
}
};
//#endregion
//#region js/src/base-component.ts
/**
* --------------------------------------------------------------------------
* Bootstrap base-component.ts
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
* --------------------------------------------------------------------------
*/
/**
* Constants
*/
const VERSION = "6.0.0-alpha.2";
/**
* Class definition
*/
var BaseComponent = class extends Config {
constructor(element, config) {
super();
element = getElement(element);
if (!element) return;
this._element = element;
this._config = this._getConfig(config);
const existingInstance = data_default.get(this._element, this.constructor.DATA_KEY);
if (existingInstance) existingInstance.dispose();
data_default.set(this._element, this.constructor.DATA_KEY, this);
}
dispose() {
data_default.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) {
return new Promise((resolve) => {
executeAfterTransition(() => {
if (this._element) callback();
resolve();
}, element, isAnimated);
});
}
_getConfig(config) {
config = this._mergeConfigObj(config, this._element);
config = this._configAfterMerge(config);
this._typeCheckConfig(config);
return config;
}
static getInstance(element) {
return data_default.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}`;
}
};
//#endregion
//#region js/src/dom/selector-engine.ts
/**
* --------------------------------------------------------------------------
* Bootstrap dom/selector-engine.ts
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
* --------------------------------------------------------------------------
*/
const 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 selector ? selector.split(",").map((sel) => parseSelector(sel)).join(",") : null;
};
const SelectorEngine = {
find(selector, element = document.documentElement) {
return [...Element.prototype.querySelectorAll.call(element, selector)];
},
findOne(selector, element = document.documentElement) {
return Element.prototype.querySelector.call(element, selector);
},
parents(element, selector) {
const parents = [];
let ancestor = element.parentNode.closest(selector);
while (ancestor) {
parents.push(ancestor);
ancestor = ancestor.parentNode.closest(selector);
}
return parents;
},
closest(element, selector) {
return Element.prototype.closest.call(element, selector);
},
prev(element, selector) {
let previous = element.previousElementSibling;
while (previous) {
if (previous.matches(selector)) return [previous];
previous = previous.previousElementSibling;
}
return [];
},
next(element, selector) {
let next = element.nextElementSibling;
while (next) {
if (next.matches(selector)) return [next];
next = next.nextElementSibling;
}
return [];
},
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) : [];
}
};
//#endregion
//#region js/src/util/component-functions.ts
const enableDismissTrigger = (component, method = "hide") => {
const clickEvent = `click.dismiss${component.EVENT_KEY}`;
const name = component.NAME;
const usesNativeDialog = name === "dialog" || name === "drawer";
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}, [class*=":${name}"]`);
if (!target || usesNativeDialog && !(target instanceof HTMLDialogElement)) return;
component.getOrCreateInstance(target)[method]();
});
};
const eventActionOnPlugin = (Plugin, onEvent, stringSelector, method, callback = null) => {
eventAction(`${onEvent}.${Plugin.NAME}`, stringSelector, (data) => {
const instances = data.targets.filter(Boolean).map((element) => Plugin.getOrCreateInstance(element));
if (typeof callback === "function") callback({
...data,
instances
});
for (const instance of instances) instance[method]();
});
};
const eventAction = (onEvent, stringSelector, callback) => {
const selector = `${stringSelector}:not(.disabled):not(:disabled)`;
EventHandler.on(document, onEvent, selector, function(event) {
if (["A", "AREA"].includes(this.tagName)) event.preventDefault();
const selector = SelectorEngine.getSelectorFromElement(this);
callback({
targets: selector ? SelectorEngine.find(selector) : [this],
event
});
});
};
const onDocumentReady = (eventName, callback) => {
EventHandler.on(document, eventName, callback);
if (document.readyState !== "loading") callback();
};
//#endregion
//#region js/src/alert.ts
/**
* --------------------------------------------------------------------------
* Bootstrap alert.ts
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
* --------------------------------------------------------------------------
*/
/**
* Constants
*/
const NAME$20 = "alert";
const EVENT_KEY$17 = `.bs.alert`;
const EVENT_CLOSE = `close${EVENT_KEY$17}`;
const EVENT_CLOSED = `closed${EVENT_KEY$17}`;
const CLASS_NAME_HIDING = "hiding";
const CLASS_NAME_SHOW$7 = "show";
/**
* Class definition
*/
var Alert = class extends BaseComponent {
static get NAME() {
return NAME$20;
}
async close() {
if (EventHandler.trigger(this._element, EVENT_CLOSE).defaultPrevented) return;
this._element.classList.remove(CLASS_NAME_SHOW$7);
this._element.classList.add(CLASS_NAME_HIDING);
const isAnimated = getTransitionDurationFromElement(this._element) > 0;
await this._queueCallback(() => this._destroyElement(), this._element, isAnimated);
}
_destroyElement() {
this._element.remove();
EventHandler.trigger(this._element, EVENT_CLOSED);
this.dispose();
}
};
/**
* Data API implementation
*/
enableDismissTrigger(Alert, "close");
//#endregion
//#region js/src/button.ts
/**
* --------------------------------------------------------------------------
* Bootstrap button.ts
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
* --------------------------------------------------------------------------
*/
/**
* Constants
*/
const NAME$19 = "button";
const EVENT_KEY$16 = `.bs.button`;
const DATA_API_KEY$11 = ".data-api";
const CLASS_NAME_ACTIVE$3 = "active";
const SELECTOR_DATA_TOGGLE$10 = "[data-bs-toggle=\"button\"]";
const EVENT_CLICK_DATA_API$8 = `click${EVENT_KEY$16}${DATA_API_KEY$11}`;
const EVENT_DOM_CONTENT_LOADED$1 = `DOMContentLoaded${EVENT_KEY$16}${DATA_API_KEY$11}`;
/**
* Class definition
*/
var Button = class extends BaseComponent {
static get NAME() {
return NAME$19;
}
toggle() {
setAriaAttribute(this._element, "aria-pressed", this._element.classList.toggle(CLASS_NAME_ACTIVE$3));
}
};
/**
* Data API implementation
*/
EventHandler.on(document, EVENT_CLICK_DATA_API$8, SELECTOR_DATA_TOGGLE$10, (event) => {
event.preventDefault();
const button = event.target.closest(SELECTOR_DATA_TOGGLE$10);
Button.getOrCreateInstance(button).toggle();
});
onDocumentReady(EVENT_DOM_CONTENT_LOADED$1, () => {
for (const element of SelectorEngine.find(SELECTOR_DATA_TOGGLE$10)) if (!element.hasAttribute("aria-pressed")) setAriaAttribute(element, "aria-pressed", element.classList.contains(CLASS_NAME_ACTIVE$3));
});
//#endregion
//#region js/src/carousel.ts
/**
* --------------------------------------------------------------------------
* Bootstrap carousel.ts
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
* --------------------------------------------------------------------------
*/
/**
* Constants
*/
const NAME$18 = "carousel";
const EVENT_KEY$15 = `.bs.carousel`;
const DATA_API_KEY$10 = ".data-api";
const ARROW_LEFT_KEY$2 = "ArrowLeft";
const ARROW_RIGHT_KEY$2 = "ArrowRight";
const DIRECTION_LEFT = "left";
const DIRECTION_RIGHT = "right";
const EVENT_SLIDE = `slide${EVENT_KEY$15}`;
const EVENT_SLID = `slid${EVENT_KEY$15}`;
const EVENT_KEYDOWN$3 = `keydown${EVENT_KEY$15}`;
const EVENT_MOUSEENTER$2 = `mouseenter${EVENT_KEY$15}`;
const EVENT_MOUSELEAVE$1 = `mouseleave${EVENT_KEY$15}`;
const EVENT_POINTERDOWN$3 = `pointerdown${EVENT_KEY$15}`;
const EVENT_LOAD_DATA_API$3 = `load${EVENT_KEY$15}${DATA_API_KEY$10}`;
const EVENT_CLICK_DATA_API$7 = `click${EVENT_KEY$15}${DATA_API_KEY$10}`;
const CLASS_NAME_CAROUSEL = "carousel";
const CLASS_NAME_ACTIVE$2 = "active";
const CLASS_NAME_FADE = "carousel-fade";
const CLASS_NAME_CENTER = "carousel-center";
const CLASS_NAME_AUTO = "carousel-auto";
const CLASS_NAME_CLONE = "carousel-item-clone";
const CLASS_NAME_PAUSED = "paused";
const CLASS_NAME_PLAYING = "carousel-playing";
const PROPERTY_INTERVAL = "--bs-carousel-interval";
const SCROLL_DURATION = 300;
const ACTIVE_RATIO_TOLERANCE = .05;
const SELECTOR_ACTIVE = ".active";
const SELECTOR_ITEM = `.carousel-item:not(.${CLASS_NAME_CLONE})`;
const SELECTOR_ACTIVE_ITEM = SELECTOR_ACTIVE + SELECTOR_ITEM;
const SELECTOR_INNER$1 = ".carousel-inner";
const SELECTOR_INDICATORS = ".carousel-indicators";
const SELECTOR_PLAY_PAUSE = ".carousel-control-play-pause";
const SELECTOR_DATA_SLIDE = "[data-bs-slide], [data-bs-slide-to]";
const SELECTOR_DATA_SLIDE_PREV = "[data-bs-slide=\"prev\"]";
const SELECTOR_DATA_SLIDE_NEXT = "[data-bs-slide=\"next\"]";
const SELECTOR_DATA_AUTOPLAY = "[data-bs-autoplay=\"true\"]";
const ENDS_STOP = "stop";
const ENDS_WRAP = "wrap";
const ENDS_LOOP = "loop";
const Default$17 = {
autoplay: false,
ends: ENDS_LOOP,
interval: 5e3,
keyboard: true,
pause: "hover"
};
const DefaultType$17 = {
autoplay: "boolean",
ends: "string",
interval: "number",
keyboard: "boolean",
pause: "(string|boolean)"
};
const easeInOutCubic = (progress) => progress < .5 ? 4 * progress * progress * progress : 1 - (-2 * progress + 2) ** 3 / 2;
/**
* Class definition
*/
var Carousel = class extends BaseComponent {
constructor(element, config) {
super(element, config);
this._viewport = SelectorEngine.findOne(SELECTOR_INNER$1, this._element) || this._element;
this._indicatorsElement = SelectorEngine.findOne(SELECTOR_INDICATORS, this._element);
this._playPauseElement = SelectorEngine.findOne(SELECTOR_PLAY_PAUSE, this._element);
this._prevControls = SelectorEngine.find(SELECTOR_DATA_SLIDE_PREV, this._element);
this._nextControls = SelectorEngine.find(SELECTOR_DATA_SLIDE_NEXT, this._element);
this._interval = null;
this._observer = null;
this._scrollFrame = null;
this._looping = false;
this._visibility = /* @__PURE__ */ new Map();
this._playing = this._config.autoplay;
this._activeIndex = this._initialActiveIndex();
this._addEventListeners();
this._observeItems();
this._refreshActiveState();
if (this._playing) this.cycle();
this._updatePlayPauseControl();
}
static get Default() {
return Default$17;
}
static get DefaultType() {
return DefaultType$17;
}
static get NAME() {
return NAME$18;
}
next() {
this.to(this._navIndex() + 1);
}
nextWhenVisible() {
if (document.visibilityState === "visible" && isVisible(this._element)) this.next();
}
prev() {
this.to(this._navIndex() - 1);
}
pause() {
this._clearInterval();
this._element.classList.remove(CLASS_NAME_PLAYING);
}
cycle() {
this._clearInterval();
this._scheduleAutoplay();
this._element.classList.add(CLASS_NAME_PLAYING);
}
to(index) {
if (this._looping) return;
const items = this._getItems();
const rawIndex = Number.parseInt(index, 10);
if (this._config.ends === ENDS_LOOP && !this._prefersReducedMotion() && this._canLoop()) {
if (rawIndex > items.length - 1) {
this._loopTransition(true);
return;
}
if (rawIndex < 0) {
this._loopTransition(false);
return;
}
}
const targetIndex = this._normalizeIndex(rawIndex, items.length);
const currentIndex = this._navIndex();
if (targetIndex === null || targetIndex === currentIndex) return;
if (EventHandler.trigger(this._element, EVENT_SLIDE, {
relatedTarget: items[targetIndex],
direction: this._direction(currentIndex, targetIndex),
from: currentIndex,
to: targetIndex
}).defaultPrevented) return;
if (this._isFade()) {
this._fadeTo(targetIndex);
return;
}
this._scrollToIndex(targetIndex);
}
dispose() {
this._clearInterval();
if (this._observer) this._observer.disconnect();
if (this._scrollFrame !== null) cancelAnimationFrame(this._scrollFrame);
for (const clone of SelectorEngine.find(`.${CLASS_NAME_CLONE}`, this._viewport)) clone.remove();
this._viewport.style.scrollSnapType = "";
EventHandler.off(this._viewport, EVENT_KEY$15);
super.dispose();
}
_configAfterMerge(config) {
if (![
ENDS_STOP,
ENDS_WRAP,
ENDS_LOOP
].includes(config.ends)) config.ends = Default$17.ends;
return config;
}
_initialActiveIndex() {
const active = SelectorEngine.findOne(SELECTOR_ACTIVE_ITEM, this._element);
const index = active ? this._getItems().indexOf(active) : 0;
return Math.max(index, 0);
}
_addEventListeners() {
if (this._config.keyboard) EventHandler.on(this._element, EVENT_KEYDOWN$3, (event) => this._keydown(event));
if (this._config.pause === "hover") {
EventHandler.on(this._element, EVENT_MOUSEENTER$2, () => this.pause());
EventHandler.on(this._element, EVENT_MOUSELEAVE$1, () => this._maybeEnableCycle());
}
EventHandler.on(this._viewport, EVENT_POINTERDOWN$3, () => this._pauseFromInteraction());
}
_keydown(event) {
if (/input|textarea/i.test(event.target.tagName)) return;
const { key } = event;
if (key !== ARROW_LEFT_KEY$2 && key !== ARROW_RIGHT_KEY$2) return;
event.preventDefault();
this._pauseFromInteraction();
if (key === (isRTL() ? ARROW_LEFT_KEY$2 : ARROW_RIGHT_KEY$2)) this.next();
else this.prev();
}
_observeItems() {
if (this._isFade() || typeof IntersectionObserver === "undefined") return;
this._observer = new IntersectionObserver((entries) => this._handleIntersection(entries), {
root: this._viewport,
threshold: [
0,
.25,
.5,
.75,
1
]
});
for (const item of this._getItems()) this._observer.observe(item);
}
_handleIntersection(entries) {
if (this._looping) return;
for (const entry of entries) this._visibility.set(entry.target, entry.isIntersecting ? entry.intersectionRatio : 0);
const ratios = this._getItems().map((item) => this._visibility.get(item) ?? 0);
const maxRatio = Math.max(...ratios);
let bestIndex = this._activeIndex;
if (maxRatio > 0) bestIndex = ratios.findIndex((ratio) => ratio >= maxRatio - ACTIVE_RATIO_TOLERANCE);
this._setActive(bestIndex);
this._updateEndControls();
}
_navIndex() {
if (this._isFade() || this._viewport.scrollWidth - this._viewport.clientWidth <= 0) return this._activeIndex;
let index = this._activeIndex;
let smallestDelta = Number.POSITIVE_INFINITY;
for (const [itemIndex, item] of this._getItems().entries()) {
const delta = Math.abs(this._scrollDelta(item));
if (delta < smallestDelta) {
smallestDelta = delta;
index = itemIndex;
}
}
return index;
}
_scrollToIndex(index) {
const item = this._getItems()[index];
if (!item) return;
const left = this._scrollDelta(item);
if (Math.abs(left) < 1) return;
const targetLeft = this._viewport.scrollLeft + left;
this._viewport.style.scrollSnapType = "none";
this._animateScroll(targetLeft, () => {
this._viewport.style.scrollSnapType = "";
if (!this._observer) this._setActive(index);
this._updateEndControls();
});
}
_animateScroll(targetLeft, onComplete) {
if (this._scrollFrame !== null) {
cancelAnimationFrame(this._scrollFrame);
this._scrollFrame = null;
}
const startLeft = this._viewport.scrollLeft;
const distance = targetLeft - startLeft;
if (this._prefersReducedMotion() || typeof requestAnimationFrame === "undefined") {
this._viewport.scrollTo({
left: targetLeft,
behavior: "instant"
});
onComplete();
return;
}
let startTime = null;
const step = (now) => {
if (startTime === null) startTime = now;
const progress = Math.min((now - startTime) / SCROLL_DURATION, 1);
this._viewport.scrollTo({
left: startLeft + distance * easeInOutCubic(progress),
behavior: "instant"
});
if (progress < 1) {
this._scrollFrame = requestAnimationFrame(step);
return;
}
this._viewport.scrollTo({
left: targetLeft,
behavior: "instant"
});
this._scrollFrame = null;
onComplete();
};
this._scrollFrame = requestAnimationFrame(step);
}
_scrollDelta(element) {
const viewportRect = this._viewport.getBoundingClientRect();
const rect = element.getBoundingClientRect();
if (this._element.classList.contains(CLASS_NAME_CENTER)) return rect.left + rect.width / 2 - (viewportRect.left + viewportRect.width / 2);
const padStart = Number.parseFloat(getComputedStyle(this._viewport).scrollPaddingInlineStart) || 0;
return isRTL() ? rect.right - (viewportRect.right - padStart) : rect.left - (viewportRect.left + padStart);
}
_loopTransition(isNext) {
const items = this._getItems();
const last = items.length - 1;
const fromIndex = this._activeIndex;
const toIndex = isNext ? 0 : last;
const direction = this._loopDirection(isNext);
if (EventHandler.trigger(this._element, EVENT_SLIDE, {
relatedTarget: items[toIndex],
direction,
from: fromIndex,
to: toIndex
}).defaultPrevented) return;
this._looping = true;
const clone = (isNext ? items[0] : items[last]).cloneNode(true);
clone.classList.add(CLASS_NAME_CLONE);
clone.classList.remove(CLASS_NAME_ACTIVE$2);
clone.removeAttribute("id");
for (const node of SelectorEngine.find("[id]", clone)) node.removeAttribute("id");
clone.setAttribute("aria-hidden", "true");
clone.inert = true;
this._viewport.style.scrollSnapType = "none";
if (isNext) this._viewport.append(clone);
else {
this._viewport.prepend(clone);
this._jumpScroll(this._scrollDelta(items[fromIndex]));
}
this._animateScroll(this._viewport.scrollLeft + this._scrollDelta(clone), () => {
clone.remove();
this._jumpScroll(this._scrollDelta(items[toIndex]));
this._activeIndex = toIndex;
this._refreshActiveState();
EventHandler.trigger(this._element, EVENT_SLID, {
relatedTarget: items[toIndex],
direction,
from: fromIndex,
to: toIndex
});
this._viewport.style.scrollSnapType = "";
this._looping = false;
});
}
_loopDirection(isNext) {
if (isRTL()) return isNext ? DIRECTION_RIGHT : DIRECTION_LEFT;
return isNext ? DIRECTION_LEFT : DIRECTION_RIGHT;
}
_jumpScroll(delta) {
this._viewport.style.scrollSnapType = "none";
this._viewport.scrollBy({
left: delta,
top: 0,
behavior: "instant"
});
}
_fadeTo(index) {
this._setActive(index);
}
_setActive(index) {
const items = this._getItems();
if (index === this._activeIndex || !items[index]) return;
const from = this._activeIndex;
this._activeIndex = index;
this._refreshActiveState();
EventHandler.trigger(this._element, EVENT_SLID, {
relatedTarget: items[index],
direction: this._direction(from, index),
from,
to: index
});
}
_refreshActiveState() {
const items = this._getItems();
for (const [index, item] of items.entries()) item.classList.toggle(CLASS_NAME_ACTIVE$2, index === this._activeIndex);
this._setActiveIndicatorElement(this._activeIndex);
this._updateEndControls();
}
_updateEndControls() {
if (this._config.ends !== ENDS_STOP) return;
const viewport = this._viewport;
const maxScroll = viewport.scrollWidth - viewport.clientWidth;
let atStart;
let atEnd;
if (maxScroll > 0) {
const progress = Math.abs(viewport.scrollLeft);
atStart = progress <= 1;
atEnd = progress >= maxScroll - 1;
} else {
const last = this._getItems().length - 1;
atStart = this._activeIndex <= 0;
atEnd = this._activeIndex >= last;
}
this._setControlsDisabled(this._prevControls, atStart);
this._setControlsDisabled(this._nextControls, atEnd);
}
_setControlsDisabled(controls, disabled) {
for (const control of controls) {
if (disabled && control === document.activeElement) {
((controls === this._prevControls ? this._nextControls : this._prevControls)[0] ?? this._viewport).focus({ preventScroll: true });
if (document.activeElement === control) control.blur();
}
control.disabled = disabled;
}
}
_setActiveIndicatorElement(index) {
if (!this._indicatorsElement) return;
const active = SelectorEngine.findOne(SELECTOR_ACTIVE, this._indicatorsElement);
if (active) {
active.classList.remove(CLASS_NAME_ACTIVE$2);
active.removeAttribute("aria-current");
}
const newActive = SelectorEngine.findOne(`[data-bs-slide-to="${index}"]`, this._indicatorsElement);
if (newActive) {
newActive.classList.add(CLASS_NAME_ACTIVE$2);
newActive.setAttribute("aria-current", "true");
}
}
_normalizeIndex(index, length) {
if (Number.isNaN(index) || length === 0) return null;
if (index < 0) return this._wrapsAround() ? length - 1 : null;
if (index > length - 1) return this._wrapsAround() ? 0 : null;
return index;
}
_wrapsAround() {
return this._config.ends === ENDS_WRAP || this._config.ends === ENDS_LOOP;
}
_canLoop() {
if (this._isFade() || this._getItems().length < 2) return false;
const styles = getComputedStyle(this._element);
const num = (name) => Number.parseFloat(styles.getPropertyValue(name)) || 0;
return (num("--bs-carousel-items") || 1) === 1 && num("--bs-carousel-items-peek") === 0 && !this._element.classList.contains(CLASS_NAME_CENTER) && !this._element.classList.contains(CLASS_NAME_AUTO);
}
_direction(from, to) {
const isNext = to > from;
if (isRTL()) return isNext ? DIRECTION_RIGHT : DIRECTION_LEFT;
return isNext ? DIRECTION_LEFT : DIRECTION_RIGHT;
}
_scheduleAutoplay(index = this._activeIndex) {
const interval = this._itemInterval(index);
this._element.style.setProperty(PROPERTY_INTERVAL, `${interval}ms`);
this._interval = setTimeout(() => {
const upcoming = this._upcomingIndex();
this.nextWhenVisible();
if (upcoming === null) {
this.pause();
return;
}
this._scheduleAutoplay(upcoming);
}, interval);
}
_upcomingIndex() {
return this._normalizeIndex(this._navIndex() + 1, this._getItems().length);
}
_itemInterval(index = this._activeIndex) {
const item = this._getItems()[index];
const interval = item ? Number.parseInt(item.getAttribute("data-bs-interval"), 10) : NaN;
return Number.isNaN(interval) ? this._config.interval : interval;
}
_maybeEnableCycle() {
if (!this._playing) return;
this.cycle();
}
_pauseFromInteraction() {
this._playing = false;
this.pause();
this._updatePlayPauseControl();
}
_togglePlayPause() {
if (this._playing) {
this._pauseFromInteraction();
return;
}
this._playing = true;
this.cycle();
this._updatePlayPauseControl();
}
_updatePlayPauseControl() {
if (!this._playPauseElement) return;
this._playPauseElement.classList.toggle(CLASS_NAME_PAUSED, !this._playing);
const label = this._playPauseElement.getAttribute(this._playing ? "data-bs-pause-label" : "data-bs-play-label");
if (label) this._playPauseElement.setAttribute("aria-label", label);
}
_isFade() {
return this._element.classList.contains(CLASS_NAME_FADE);
}
_prefersReducedMotion() {
return typeof window !== "undefined" && typeof window.matchMedia === "function" && window.matchMedia("(prefers-reduced-motion: reduce)").matches;
}
_getItems() {
return SelectorEngine.find(SELECTOR_ITEM, this._element);
}
_clearInterval() {
if (this._interval) {
clearTimeout(this._interval);
this._interval = null;
}
}
};
/**
* Data API implementation
*/
EventHandler.on(document, EVENT_CLICK_DATA_API$7, 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);
carousel._pauseFromInteraction();
const slideIndex = this.getAttribute("data-bs-slide-to");
if (slideIndex) {
carousel.to(slideIndex);
return;
}
if (Manipulator.getDataAttribute(this, "slide") === "next") {
carousel.next();
return;
}
carousel.prev();
});
EventHandler.on(document, EVENT_CLICK_DATA_API$7, SELECTOR_PLAY_PAUSE, function(event) {
const target = SelectorEngine.getElementFromSelector(this);
if (!target || !target.classList.contains(CLASS_NAME_CAROUSEL)) return;
event.preventDefault();
Carousel.getOrCreateInstance(target)._togglePlayPause();
});
EventHandler.on(window, EVENT_LOAD_DATA_API$3, () => {
const carousels = SelectorEngine.find(SELECTOR_DATA_AUTOPLAY);
for (const carousel of carousels) Carousel.getOrCreateInstance(carousel);
});
/**
* Decode a URL fragment id, tolerating malformed escapes (returns it as-is).
*/
const decodeFragment$1 = (value) => {
try {
return decodeURIComponent(value);
} catch {
return value;
}
};
/**
* Resolve the element named by `location.hash` when it opts in with `data-bs-hash`.
*/
const getHashTarget = () => {
const { hash } = window.location;
if (!hash || hash === "#") return null;
const id = decodeFragment$1(hash.slice(1));
if (!id) return null;
const element = document.getElementById(id);
if (!element?.hasAttribute("data-bs-hash")) return null;
return element;
};
/**
* Open an opted-in hash target on `load` and `hashchange`.
* Put `data-bs-hash` on the collapse or tab pane that the URL fragment names.
*
* Scrolls a visible anchor first when one exists, then opens the target, then
* scrolls the target into view after it is shown.
*/
const enableHashTarget = (namespace, handler) => {
let generation = 0;
const onHash = () => {
const current = ++generation;
const element = getHashTarget();
if (!element || !handler.matches(element)) return;
const anchor = handler.getAnchor?.(element);
if (anchor) anchor.scrollIntoView();
handler.open(element, () => {
if (current === generation && element.isConnected && getHashTarget() === element) element.scrollIntoView();
});
};
EventHandler.on(window, `load${namespace}`, onHash);
EventHandler.on(window, `hashchange${namespace}`, onHash);
if (document.readyState === "complete") onHash();
};
//#endregion
//#region js/src/collapse.ts
/**
* --------------------------------------------------------------------------
* Bootstrap collapse.ts
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
* --------------------------------------------------------------------------
*/
/**
* Constants
*/
const NAME$17 = "collapse";
const EVENT_KEY$14 = `.bs.collapse`;
const DATA_API_KEY$9 = ".data-api";
const EVENT_SHOW$5 = `show${EVENT_KEY$14}`;
const EVENT_SHOWN$5 = `shown${EVENT_KEY$14}`;
const EVENT_HIDE$5 = `hide${EVENT_KEY$14}`;
const EVENT_HIDDEN$5 = `hidden${EVENT_KEY$14}`;
const EVENT_CLICK_DATA_API$6 = `click${EVENT_KEY$14}${DATA_API_KEY$9}`;
const CLASS_NAME_SHOW$6 = "show";
const CLASS_NAME_COLLAPSE = "collapse";
const CLASS_NAME_DEEPER_CHILDREN = `:scope .${CLASS_NAME_COLLAPSE} .${CLASS_NAME_COLLAPSE}`;
const SELECTOR_ACTIVES = ".collapse.show";
const SELECTOR_DATA_TOGGLE$9 = "[data-bs-toggle=\"collapse\"]";
const Default$16 = { parent: null };
const DefaultType$16 = { parent: "(null|element)" };
/**
* Class definition
*/
var Collapse = class Collapse extends BaseComponent {
constructor(element, config) {
super(element, config);
this._isTransitioning = false;
this._triggerArray = [];
const toggleList = SelectorEngine.find(SELECTOR_DATA_TOGGLE$9);
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._setAriaExpanded(this._triggerArray, this._isShown());
}
static get Default() {
return Default$16;
}
static get DefaultType() {
return DefaultType$16;
}
static get NAME() {
return NAME$17;
}
toggle() {
return this._isShown() ? this.hide() : this.show();
}
async show() {
if (this._isTransitioning || this._isShown()) return;
let activeChildren = [];
if (this._config.parent) activeChildren = this._getFirstLevelChildren(SELECTOR_ACTIVES).filter((element) => element !== this._element && !this._sharesTrigger(element)).map((element) => Collapse.getOrCreateInstance(element));
if (activeChildren.length && activeChildren[0]._isTransitioning) return;
if (EventHandler.trigger(this._element, EVENT_SHOW$5).defaultPrevented) return;
for (const activeInstance of activeChildren) activeInstance.hide();
this._element.classList.add(CLASS_NAME_SHOW$6);
this._setAriaExpanded(this._triggerArray, true);
this._isTransitioning = true;
const complete = () => {
this._isTransitioning = false;
EventHandler.trigger(this._element, EVENT_SHOWN$5);
};
await this._queueCallback(complete, this._element, this._isAnimated());
}
async hide() {
if (this._isTransitioning || !this._isShown()) return;
if (EventHandler.trigger(this._element, EVENT_HIDE$5).defaultPrevented) return;
this._element.classList.remove(CLASS_NAME_SHOW$6);
for (const trigger of this._triggerArray) {
const element = SelectorEngine.getElementFromSelector(trigger);
if (element && !this._isShown(element)) this._setAriaExpanded([trigger], false);
}
this._isTransitioning = true;
const complete = () => {
this._isTransitioning = false;
EventHandler.trigger(this._element, EVENT_HIDDEN$5);
};
await this._queueCallback(complete, this._element, this._isAnimated());
}
_isShown(element = this._element) {
return element.classList.contains(CLASS_NAME_SHOW$6);
}
_isAnimated() {
return getTransitionDurationFromElement(this._element) > 0;
}
_sharesTrigger(element) {
return this._triggerArray.some((trigger) => SelectorEngine.getMultipleElementsFromSelector(trigger).includes(element));
}
_configAfterMerge(config) {
config.parent = getElement(config.parent);
return config;
}
_initializeChildren() {
if (!this._config.parent) return;
const children = this._getFirstLevelChildren(SELECTOR_DATA_TOGGLE$9);
for (const element of children) {
const selected = SelectorEngine.getElementFromSelector(element);
if (selected) this._setAriaExpanded([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));
}
_setAriaExpanded(triggerArray, isOpen) {
if (!triggerArray.length) return;
for (const element of triggerArray) setAriaAttribute(element, "aria-expanded", isOpen);
}
};
/**
* Data API implementation
*/
EventHandler.on(document, EVENT_CLICK_DATA_API$6, SELECTOR_DATA_TOGGLE$9, 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();
});
/**
* Find a trigger that targets this collapse.
*/
const getCollapseTrigger = (collapseEl) => {
for (const trigger of SelectorEngine.find(SELECTOR_DATA_TOGGLE$9)) if (SelectorEngine.getMultipleElementsFromSelector(trigger).includes(collapseEl)) return trigger;
return null;
};
/**
* Open opted-in collapses when the URL fragment matches their id.
* Put `data-bs-hash` on the collapsible target.
*/
enableHashTarget(`${EVENT_KEY$14}${DATA_API_KEY$9}`, {
matches: (element) => element.classList.contains(CLASS_NAME_COLLAPSE),
getAnchor: getCollapseTrigger,
async open(element, done) {
if (element.classList.contains(CLASS_NAME_SHOW$6)) {
done();
return;
}
await Collapse.getOrCreateInstance(element).show();
if (element.classList.contains(CLASS_NAME_SHOW$6)) done();
}
});
//#endregion
//#region js/src/util/floating-ui.ts
/**
* Breakpoints for responsive placement (matches SCSS $breakpoints)
*/
const BREAKPOINTS = {
sm: 576,
md: 768,
lg: 1024,
xl: 1280,
"2xl": 1536
};
/**
* Parse a placement string that may contain responsive prefixes
* Example: "bottom-start md:top-end lg:right" returns { xs: 'bottom-start', md: 'top-end', lg: 'right' }
*
* @param placementString - The placement string to parse
* @param defaultPlacement - The default placement to use for xs/base
* @returns Object with breakpoint keys and placement values, or null if not responsive
*/
const parseResponsivePlacement = (placementString, defaultPlacement = "bottom") => {
if (!placementString || !placementString.includes(":")) return null;
const parts = placementString.split(/\s+/);
const placements = { xs: defaultPlacement };
for (const part of parts) if (part.includes(":")) {
const [breakpoint, placement] = part.split(":");
if (BREAKPOINTS[breakpoint] !== void 0) placements[breakpoint] = placement;
} else placements.xs = part;
return placements;
};
/**
* Get the active placement for the current viewport width
*
* @param responsivePlacements - Object with breakpoint keys and placement values
* @param defaultPlacement - Fallback placement
* @returns The active placement for current viewport
*/
const getResponsivePlacement = (responsivePlacements, defaultPlacement = "bottom") => {
if (!responsivePlacements) return defaultPlacement;
const viewportWidth = window.innerWidth;
let activePlacement = responsivePlacements.xs || defaultPlacement;
for (const breakpoint of [
"sm",
"md",
"lg",
"xl",
"2xl"
]) if (viewportWidth >= BREAKPOINTS[breakpoint] && responsivePlacements[breakpoint]) activePlacement = responsivePlacements[breakpoint];
return activePlacement;
};
/**
* Create media query listeners for responsive placement changes
*
* @param callback - Callback to run when breakpoint changes
* @returns Array of { mql, handler } objects for cleanup
*/
const createBreakpointListeners = (callback) => {
const listeners = [];
for (const breakpoint of Object.keys(BREAKPOINTS)) {
const minWidth = BREAKPOINTS[breakpoint];
const mql = window.matchMedia(`(min-width: ${minWidth}px)`);
mql.addEventListener("change", callback);
listeners.push({
mql,
handler: callback
});
}
return listeners;
};
/**
* Clean up media query listeners
*
* @param listeners - Array of { mql, handler } objects
*/
const disposeBreakpointListeners = (listeners) => {
for (const { mql, handler } of listeners) mql.removeEventListener("change", handler);
};
/**
* Normalize an offset value into Floating UI's offset shape.
* A `[skidding, distance]` array becomes `{ mainAxis: distance, crossAxis: skidding }`;
* numbers and axis objects pass through unchanged.
*/
const toFloatingOffset = (value) => {
return Array.isArray(value) ? {
mainAxis: value[1] || 0,
crossAxis: value[0] || 0
} : value;
};
//#endregion
//#region js/src/menu.ts
/**
* --------------------------------------------------------------------------
* Bootstrap menu.ts
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
* --------------------------------------------------------------------------
*/
/**
* Constants
*/
const NAME$16 = "menu";
const EVENT_KEY$13 = `.bs.menu`;
const DATA_API_KEY$8 = ".data-api";
const ESCAPE_KEY$2 = "Escape";
const TAB_KEY$1 = "Tab";
const ARROW_UP_KEY$2 = "ArrowUp";
const ARROW_DOWN_KEY$2 = "ArrowDown";
const ARROW_LEFT_KEY$1 = "ArrowLeft";
const ARROW_RIGHT_KEY$1 = "ArrowRight";
const HOME_KEY$2 = "Home";
const END_KEY$2 = "End";
const ENTER_KEY$1 = "Enter";
const SPACE_KEY$1 = " ";
const ITEM_NAVIGATION_KEYS = /* @__PURE__ */ new Set([
ARROW_UP_KEY$2,
ARROW_DOWN_KEY$2,
ARROW_LEFT_KEY$1,
ARROW_RIGHT_KEY$1,
HOME_KEY$2,
END_KEY$2
]);
const RIGHT_MOUSE_BUTTON = 2;
const SUBMENU_CLOSE_DELAY = 100;
const EVENT_HIDE$4 = `hide${EVENT_KEY$13}`;
const EVENT_HIDDEN$4 = `hidden${EVENT_KEY$13}`;
const EVENT_SHOW$4 = `show${EVENT_KEY$13}`;
const EVENT_SHOWN$4 = `shown${EVENT_KEY$13}`;
const EVENT_CLICK_DATA_API$5 = `click${EVENT_KEY$13}${DATA_API_KEY$8}`;
const EVENT_KEYDOWN_DATA_API = `keydown${EVENT_KEY$13}${DATA_API_KEY$8}`;
const EVENT_KEYUP_DATA_API = `keyup${EVENT_KEY$13}${DATA_API_KEY$8}`;
const EVENT_TOUCH_MOUSEOVER = `mouseover${EVENT_KEY$13}`;
const CLASS_NAME_SHOW$5 = "show";
const CLASS_NAME_MENU_BACK = "menu-back";
const SELECTOR_DATA_TOGGLE$8 = "[data-bs-toggle=\"menu\"]:not(.disabled):not(:disabled)";
const SELECTOR_MENU$3 = ".menu";
const SELECTOR_SUBMENU = ".submenu";
const SELECTOR_SUBMENU_TOGGLE = ".submenu > .menu-item";
const SELECTOR_NAVBAR_NAV = ".navbar-nav";
const SELECTOR_VISIBLE_ITEMS$1 = ".menu-item:not(.disabled):not(:disabled)";
const SELECTOR_TAB_STOPS = ":is(a[href], button, input, select, textarea, summary, [tabindex], [contenteditable]):not(:disabled, .disabled)";
const DEFAULT_PLACEMENT = "bottom-start";
const SUBMENU_PLACEMENT = "end-start";
const resolveLogicalPlacement = (placement) => {
if (isRTL()) return placement.replace(/^start(?=-|$)/, "right").replace(/^end(?=-|$)/, "left");
return placement.replace(/^start(?=-|$)/, "left").replace(/^end(?=-|$)/, "right");
};
const triangleSign = (p1, p2, p3) => (p1.x - p3.x) * (p2.y - p3.y) - (p2.x - p3.x) * (p1.y - p3.y);
const Default$15 = {
autoClose: true,
boundary: "clippingParents",
container: false,
display: "dynamic",
offset: [0, 2],
floatingConfig: null,
menu: null,
placement: DEFAULT_PLACEMENT,
reference: "toggle",
strategy: "absolute",
submenuTrigger: "both",
submenuDelay: SUBMENU_CLOSE_DELAY
};
const DefaultType$15 = {
autoClose: "(boolean|string)",
boundary: "(string|element)",
container: "(string|element|boolean)",
display: "string",
offset: "(array|string|function)",
floatingConfig: "(null|object|function)",
menu: "(null|element)",
placement: "string",
reference: "(string|element|object)",
strategy: "string",
submenuTrigger: "string",
submenuDelay: "number"
};
/**
* Class definition
*/
var Menu = class Menu extends BaseComponent {
static _openInstances = /* @__PURE__ */ new Set();
constructor(element, config) {
if (typeof computePosition === "undefined") throw new TypeError("Bootstrap's menus require Floating UI (https://floating-ui.com)");
super(element, config);
this._floatingCleanup = null;
this._mediaQueryListeners = [];
this._responsivePlacements = null;
this._parent = this._element.parentNode;
this._openSubmenus = /* @__PURE__ */ new Map();
this._submenuCloseTimeouts = /* @__PURE__ */ new Map();
this._hoverIntentData = null;
this._submenuPointerType = "mouse";
this._touchMouseover = () => void 0;
this._touchMouseoverTargets = /* @__PURE__ */ new Set();
this._menu = this._config.menu || this._findMenu();
if (!this._config.menu && this._menu) this._parent = this._findWrapper(this._menu);
this._isSubmenu = this._parent.classList?.contains("submenu");
this._menuOriginalParent = this._menu?.parentNode;
this._menuOriginalNextSibling = null;
this._parseResponsivePlacements();
this._setupSubmenuListeners();
this._initSubmenuTriggers();
}
static get Default() {
return Default$15;
}
static get DefaultType() {
return DefaultType$15;
}
static get NAME() {
return NAME$16;
}
toggle() {
return this._isShown() ? this.hide() : this.show();
}
show() {
return this._show();
}
async _show(focus) {
if (isDisabled(this._element) || this._isShown()) return;
const relatedTarget = { relatedTarget: this._element };
if (EventHandler.trigger(this._element, EVENT_SHOW$4, relatedTarget).defaultPrevented) return;
this._moveMenuToContainer();
this._disposeFloating();
this._submenuPointerType = "mouse";
if ("ontouchstart" in document.documentElement && !this._parent.closest(SELECTOR_NAVBAR_NAV)) for (const element of document.body.children) {
EventHandler.on(element, EVENT_TOUCH_MOUSEOVER, this._touchMouseover);
this._touchMouseoverTargets.add(element);
}
this._element.setAttribute("aria-expanded", "true");
this._menu.classList.add(CLASS_NAME_SHOW$5);
this._element.classList.add(CLASS_NAME_SHOW$5);
if (this._parent) this._parent.classList.add(CLASS_NAME_SHOW$5);
this._syncSubmenuLayout();
this._createFloating();
Menu._openInstances.add(this);
if (focus) focus();
else this._element.focus({ focusVisible: false });
if (!this._element || !this._isShown()) return;
await this._queueCallback(() => {
if (this._menu && this._isShown()) EventHandler.trigger(this._element, EVENT_SHOWN$4, relatedTarget);
}, this._menu, this._isAnimated());
}
async hide() {
if (isDisabled(this._element) || !this._isShown()) return;
const relatedTarget = { relatedTarget: this._element };
await this._completeHide(relatedTarget);
}
dispose() {
this._removeTouchMouseoverListeners();
EventHandler.off(this._menu, EVENT_KEY$13);
this._disposeFloating();
this._clearSize();
this._restoreMenuToOriginalParent();
this._disposeMediaQueryListeners();
this._closeAllSubmenus();
this._clearAllSubmenuTimeouts();
Menu._openInstances.delete(this);
super.dispose();
}
update() {
if (this._floatingCleanup) this._updateFloatingPosition();
}
_findMenu() {
const wrapper = SelectorEngine.closest(this._element, `:has(${SELECTOR_MENU$3})`);
return SelectorEngine.next(this._element, SELECTOR_MENU$3)[0] || SelectorEngine.prev(this._element, SELECTOR_MENU$3)[0] || SelectorEngine.findOne(SELECTOR_MENU$3, wrapper || this._parent);
}
_findWrapper(menu) {
let wrapper = this._element.parentNode;
while (wrapper instanceof Element && !wrapper.contains(menu)) wrapper = wrapper.parentNode;
return wrapper instanceof Element ? wrapper : this._element.parentNode;
}
async _completeHide(relatedTarget) {
if (EventHandler.trigger(this._element, EVENT_HIDE$4, relatedTarget).defaultPrevented) return;
this._closeAllSubmenus();
this._removeTouchMouseoverListeners();
this._menu.classList.remove(CLASS_NAME_SHOW$5);
this._element.classList.remove(CLASS_NAME_SHOW$5);
if (this._parent) this._parent.classList.remove(CLASS_NAME_SHOW$5);
this._element.setAttribute("aria-expanded", "false");
Menu._openInstances.delete(this);
await this._queueCallback(() => {
if (!this._menu || this._isShown()) return;
this._disposeFloating();
this._clearSize();
this._restoreMenuToOriginalParent();
Manipulator.removeDataAttribute(this._menu, "placement");
Manipulator.removeDataAttribute(this._menu, "display");
EventHandler.trigger(this._element, EVENT_HIDDEN$4, relatedTarget);
}, this._menu, this._isAnimated());
}
_removeTouchMouseoverListeners() {
for (const element of this._touchMouseoverTargets) EventHandler.off(element, EVENT_TOUCH_MOUSEOVER, this._touchMouseover);
this._touchMouseoverTargets.clear();
}
_getConfig(config) {
config = super._getConfig(config);
if (typeof config.reference === "object" && !isElement(config.reference) && typeof config.reference.getBoundingClientRect !== "function") throw new TypeError(`${NAME$16.toUpperCase()}: Option "reference" provided type "object" without a required "getBoundingClientRect" method.`);
return config;
}
_createFloating() {
if (this._config.display === "static") {
Manipulator.setDataAttribute(this._menu, "display", "static");
return;
}
let referenceElement = this._element;
if (this._config.reference === "parent") referenceElement = this._parent;
else if (isElement(this._config.reference)) referenceElement = getElement(this._config.reference);
else if (typeof this._config.reference === "object") referenceElement = this._config.reference;
this._floatingCleanup = autoUpdate(referenceElement, this._menu, () => this._updateFloatingPosition(referenceElement));
}
async _updateFloatingPosition(referenceElement = null) {
if (!this._menu) return;
if (!referenceElement) if (this._config.reference === "parent") referenceElement = this._parent;
else if (isElement(this._config.reference)) referenceElement = getElement(this._config.reference);
else if (typeof this._config.reference === "object") referenceElement = this._config.reference;
else referenceElement = this._element;
const placement = this._getPlacement();
const middleware = this._getFloatingMiddleware();
const floatingConfig = this._getFloatingConfig(placement, middleware);
await this._applyFloatingPosition(referenceElement, this._menu, floatingConfig.placement, floatingConfig.middleware, floatingConfig.strategy);
}
_isShown() {
return this._menu.classList.contains(CLASS_NAME_SHOW$5);
}
_isAnimated() {
return getTransitionDurationFromElement(this._menu) > 0;
}
_getPlacement() {
const placement = this._responsivePlacements ? getResponsivePlacement(this._responsivePlacements, DEFAULT_PLACEMENT) : this._config.placement;
return resolveLogicalPlacement(placement);
}
_parseResponsivePlacements() {
this._responsivePlacements = parseResponsivePlacement(this._config.placement, DEFAULT_PLACEMENT);
if (this._responsivePlacements) this._setupMediaQueryListeners();
}
_setupMediaQueryListeners() {
this._disposeMediaQueryListeners();
this._mediaQueryListeners = createBreakpointListeners(() => {
if (this._isShown()) this._updateFloatingPosition();
});
}
_disposeMediaQueryListeners() {
disposeBreakpointListeners(this._mediaQueryListeners);
this._mediaQueryListeners = [];
}
_getOffset() {
const { offset: offsetConfig } = this._config;
if (typeof offsetConfig === "string") return offsetConfig.split(",").map((value) => Number.parseInt(value, 10));
if (typeof offsetConfig === "function") return ({ placement, rects }) => {
return toFloatingOffset(offsetConfig({
placement,
reference: rects.reference,
floating: rects.floating
}, this._element));
};
return offsetConfig;
}
_getFloatingMiddleware() {
const offsetValue = this._getOffset();
const boundary = this._config.boundary === "clippingParents" ? "clippingAncestors" : this._config.boundary;
return [
offset(typeof offsetValue === "function" ? offsetValue : toFloatingOffset(offsetValue)),
flip({
boundary,
fallbackPlacements: this._getFallbackPlacements()
}),
shift({ boundary }),
size({
boundary,
apply: ({ availableWidth, availableHeight, elements }) => {
if (this._menu !== elements.floating || !this._isShown() || getComputedStyle(this._menu).position === "static") return;
this._menu.style.setProperty("--bs-menu-available-width", `${Math.max(0, Math.floor(availableWidth))}px`);
this._menu.style.setProperty("--bs-menu-available-height", `${Math.max(0, Math.floor(availableHeight))}px`);
this._syncSubmenuLayout();
}
})
];
}
_syncSubmenuLayout() {
if (!this._openSubmenus.size) this._menu.toggleAttribute("data-bs-menu-constrained", this._menu.scrollHeight > this._menu.clientHeight);
else if (this._usesStackedSubmenus() && this._menu.scrollHeight > this._menu.clientHeight) this._menu.setAttribute("data-bs-menu-constrained", "");
const { overflowX, overflowY } = getComputedStyle(this._menu);
this._menu.toggleAttribute("data-bs-menu-stacked", overflowX !== "visible" || overflowY !== "visible");
}
_clearSize() {
if (this._menu) {
this._menu.style.removeProperty("--bs-menu-available-width");
this._menu.style.removeProperty("--bs-menu-available-height");
this._menu.removeAttribute("data-bs-menu-constrained");
this._menu.removeAttribute("data-bs-menu-stacked");
}
}
_getFallbackPlacements() {
return {
bottom: [
"top",
"bottom-start",
"bottom-end",
"top-start",
"top-end"
],
"bottom-start": [
"top-start",
"bottom-end",
"top-end"
],
"bottom-end": [
"top-end",
"bottom-start",
"top-start"
],
top: [
"bottom",
"top-start",
"top-end",
"bottom-start",
"bottom-end"
],
"top-start": [
"bottom-start",
"top-end",
"bottom-end"
],
"top-end": [
"bottom-end",
"top-start",
"bottom-start"
],
right: [
"left",
"right-start",
"right-end",
"left-start",
"left-end"
],
"right-start": [
"left-start",
"right-end",
"left-end",
"top-start",
"bottom-start"
],
"right-end": [
"left-end",
"right-start",
"left-start",
"top-end",
"bottom-end"
],
left: [
"right",
"left-start",
"left-end",
"right-start",
"right-end"
],
"left-start": [
"right-start",
"left-end",
"right-end",
"top-start",
"bottom-start"
],
"left-end": [
"right-end",
"left-start",
"right-start",
"top-end",
"bottom-end"
]
}[this._getPlacement()] || [
"top",
"bottom",
"right",
"left"
];
}
_getFloatingConfig(placement, middleware) {
const defaultConfig = {
placement,
middleware,
strategy: this._config.strategy
};
return {
...defaultConfig,
...execute(this._config.floatingConfig, [void 0, defaultConfig])
};
}
_disposeFloating() {
if (this._floatingCleanup) {
this._floatingCleanup();
this._floatingCleanup = null;
}
}
_getContainer() {
const { container } = this._config;
if (container === false) return null;
return container === true ? document.body : getElement(container);
}
_moveMenuToContainer() {
const container = this._getContainer();
if (!container || !this._menu) return;
if (this._menu.parentNode !== container) {
this._menuOriginalNextSibling = this._menu.nextSibling;
container.append(this._menu);
}
}
_restoreMenuToOriginalParent() {
if (!this._menuOriginalParent || !this._menu) return;
if (this._menu.parentNode !== this._menuOriginalParent) {
const nextSibling = this._menuOriginalNextSibling;
this._menuOriginalParent.insertBefore(this._menu, nextSibling?.parentNode === this._menuOriginalParent ? nextSibling : null);
}
}
async _applyFloatingPosition(reference, floating, placement, middleware, strategy = "absolute") {
if (!floating.isConnected) return null;
const { x, y, placement: finalPlacement } = await computePosition(reference, floating, {
placement,
middleware,
strategy
});
if (!floating.isConnected) return null;
Object.assign(floating.style, {
position: strategy,
left: `${x}px`,
top: `${y}px`,
margin: "0"
});
Manipulator.setDataAttribute(floating, "placement", finalPlacement);
return finalPlacement;
}
_setupSubmenuListeners() {
if (this._config.submenuTrigger === "hover" || this._config.submenuTrigger === "both") {
EventHandler.on(this._menu, `mouseenter${EVENT_KEY$13}`, SELECTOR_SUBMENU_TOGGLE, (event) => {
this._onSubmenuTriggerEnter(event);
});
EventHandler.on(this._menu, `mouseleave${EVENT_KEY$13}`, SELECTOR_SUBMENU, (event) => {
this._onSubmenuLeave(event);
});
EventHandler.on(this._menu, `mousemove${EVENT_KEY$13}`, (event) => {
this._trackMousePosition(event);
});
}
if (this._config.submenuTrigger === "both") EventHandler.on(this._menu, `pointerover${EVENT_KEY$13}`, (event) => {
this._submenuPointerType = event.pointerType;
});
if ([
"click",
"hover",
"both"
].includes(this._config.submenuTrigger)) EventHandler.on(this._menu, `click${EVENT_KEY$13}`, SELECTOR_SUBMENU_TOGGLE, (event) => {
if (this._config.submenuTrigger !== "hover" || this._usesStackedSubmenus()) this._onSubmenuTriggerClick(event);
});
}
_usesStackedSubmenus() {
return getComputedStyle(this._menu).getPropertyValue("--bs-menu-stack-submenus") === "1";
}
_onSubmenuTriggerEnter(event) {
if (this._submenuPointerType !== "mouse" || this._usesStackedSubmenus()) return;
const trigger = event.target.closest(SELECTOR_SUBMENU_TOGGLE);
if (!trigger) return;
const submenuWrapper = trigger.closest(SELECTOR_SUBMENU);
const submenu = SelectorEngine.findOne(SELECTOR_MENU$3, submenuWrapper);
if (!submenu) return;
this._cancelSubmenuCloseTimeout(submenu);
this._closeSiblingSubmenus(submenuWrapper);
this._openSubmenu(trigger, submenu, submenuWrapper);
}
_onSubmenuLeave(event) {
if (this._submenuPointerType !== "mouse" || this._usesStackedSubmenus()) return;
const submenuWrapper = event.target.closest(SELECTOR_SUBMENU);
const submenu = SelectorEngine.findOne(SELECTOR_MENU$3, submenuWrapper);
if (!submenu || !this._openSubmenus.has(submenu)) return;
if (this._isMovingTowardSubmenu(event, submenu)) return;
this._scheduleSubmenuClose(submenu, submenuWrapper);
}
_onSubmenuTriggerClick(event) {
const trigger = event.target.closest(SELECTOR_SUBMENU_TOGGLE);
if (!trigger) return;
event.preventDefault();
event.stopPropagation();
const submenuWrapper = trigger.closest(SELECTOR_SUBMENU);
const submenu = SelectorEngine.findOne(SELECTOR_MENU$3, submenuWrapper);
if (!submenu) return;
if (this._openSubmenus.has(submenu)) this._closeSubmenu(submenu, submenuWrapper);
else {
this._closeSiblingSubmenus(submenuWrapper);
this._openSubmenu(trigger, submenu, submenuWrapper);
if (this._usesStackedSubmenus()) this._getItemsInMenu(submenu)[0]?.focus();
}
}
_initSubmenuTriggers() {
if (!this._menu) return;
for (const trigger of SelectorEngine.find(SELECTOR_SUBMENU_TOGGLE, this._menu)) {
if (!SelectorEngine.findOne(SELECTOR_MENU$3, trigger.parentElement)) continue;
trigger.setAttribute("aria-haspopup", "true");
if (!trigger.hasAttribute("aria-expanded")) trigger.setAttribute("aria-expanded", "false");
}
}
_openSubmenu(trigger, submenu, submenuWrapper) {
if (this._openSubmenus.has(submenu)) return;
trigger.setAttribute("aria-expanded", "true");
trigger.setAttribute("aria-haspopup", "true");
submenu.style.opacity = "0";
submenu.classList.add(CLASS_NAME_SHOW$5);
submenuWrapper.classList.add(CLASS_NAME_SHOW$5);
const backItem = document.createElement(submenu.matches("ul, ol, menu") ? "li" : "div");
backItem.className = CLASS_NAME_MENU_BACK;
const backButton = document.createElement("button");
backButton.type = "button";
backButton.className = "menu-item";
backButton.textContent = "Back";
backButton.addEventListener("click", (event) => {
event.stopPropagation();
this._closeSubmenu(submenu, submenuWrapper);
trigger.focus();
});
backItem.append(backButton);
submenu.prepend(backItem);
const cleanup = this._createSubmenuFloating(submenu, submenuWrapper);
this._openSubmenus.set(submenu, () => {
cleanup();
backItem.remove();
});
EventHandler.on(submenu, `mouseenter${EVENT_KEY$13}`, () => {
this._cancelSubmenuCloseTimeout(submenu);
});
}
_closeSubmenu(submenu, submenuWrapper) {
if (!this._openSubmenus.has(submenu)) return;
const nestedSubmenus = SelectorEngine.find(`${SELECTOR_SUBMENU} ${SELECTOR_MENU$3}.${CLASS_NAME_SHOW$5}`, submenu);
for (const nested of nestedSubmenus) {
const nestedWrapper = nested.closest(SELECTOR_SUBMENU);
this._closeSubmenu(nested, nestedWrapper);
}
const trigger = SelectorEngine.findOne(SELECTOR_SUBMENU_TOGGLE, submenuWrapper);
const cleanup = this._openSubmenus.get(submenu);
if (cleanup) cleanup();
this._openSubmenus.delete(submenu);
EventHandler.off(submenu, `mouseenter${EVENT_KEY$13}`);
this._cancelSubmenuCloseTimeout(submenu);
if (trigger) trigger.setAttribute("aria-expanded", "false");
submenu.classList.remove(CLASS_NAME_SHOW$5);
submenuWrapper.classList.remove(CLASS_NAME_SHOW$5);
submenu.style.opacity = "";
}
_closeAllSubmenus() {
for (const [submenu] of this._openSubmenus) {
const submenuWrapper = submenu.closest(SELECTOR_SUBMENU);
this._closeSubmenu(submenu, submenuWrapper);
}
}
_closeSiblingSubmenus(currentSubmenuWrapper) {
const parent = currentSubmenuWrapper.parentNode;
const siblingSubmenus = SelectorEngine.find(`${SELECTOR_SUBMENU} > ${SELECTOR_MENU$3}.${CLASS_NAME_SHOW$5}`, parent);
for (const siblingMenu of siblingSubmenus) {
const siblingWrapper = siblingMenu.closest(SELECTOR_SUBMENU);
if (siblingWrapper !== currentSubmenuWrapper) this._closeSubmenu(siblingMenu, siblingWrapper);
}
}
_createSubmenuFloating(submenu, submenuWrapper) {
const referenceElement = submenuWrapper;
const placement = resolveLogicalPlacement(SUBMENU_PLACEMENT);
const middleware = [
offset({
mainAxis: 0,
crossAxis: -4
}),
flip({ fallbackPlacements: [
resolveLogicalPlacement("start-start"),
resolveLogicalPlacement("end-end"),
resolveLogicalPlacement("start-end")
] }),
shift({ padding: 8 })
];
const updatePosition = async () => {
if (this._usesStackedSubmenus()) {
submenu.style.opacity = "";
return;
}
await this._applyFloatingPosition(referenceElement, submenu, placement, middleware);
submenu.style.opacity = "";
};
return autoUpdate(referenceElement, submenu, updatePosition);
}
_scheduleSubmenuClose(submenu, submenuWrapper) {
this._cancelSubmenuCloseTimeout(submenu);
const timeoutId = setTimeout(() => {
this._closeSubmenu(submenu, submenuWrapper);
this._submenuCloseTimeouts.delete(submenu);
}, this._config.submenuDelay);
this._submenuCloseTimeouts.set(submenu, timeoutId);
}
_cancelSubmenuCloseTimeout(submenu) {
const timeoutId = this._submenuCloseTimeouts.get(submenu);
if (timeoutId) {
clearTimeout(timeoutId);
this._submenuCloseTimeouts.delete(submenu);
}
}
_clearAllSubmenuTimeouts() {
for (const timeoutId of this._submenuCloseTimeouts.values()) clearTimeout(timeoutId);
this._submenuCloseTimeouts.clear();
}
_trackMousePosition(event) {
this._hoverIntentData = {
x: event.clientX,
y: event.clientY,
timestamp: Date.now()
};
}
_isMovingTowardSubmenu(event, submenu) {
if (!this._hoverIntentData) return false;
const submenuRect = submenu.getBoundingClientRect();
const currentPos = {
x: event.clientX,
y: event.clientY
};
const lastPos = {
x: this._hoverIntentData.x,
y: this._hoverIntentData.y
};
const targetX = isRTL() ? submenuRect.right : submenuRect.left;
const topCorner = {
x: targetX,
y: submenuRect.top
};
const bottomCorner = {
x: targetX,
y: submenuRect.bottom
};
return this._pointInTriangle(currentPos, lastPos, topCorner, bottomCorner);
}
_pointInTriangle(point, v1, v2, v3) {
const d1 = triangleSign(point, v1, v2);
const d2 = triangleSign(point, v2, v3);
const d3 = triangleSign(point, v3, v1);
return !((d1 < 0 || d2 < 0 || d3 < 0) && (d1 > 0 || d2 > 0 || d3 > 0));
}
_getItemsInMenu(menu) {
const backSelector = this._usesStackedSubmenus() ? `, :scope > .${CLASS_NAME_MENU_BACK} > ${SELECTOR_VISIBLE_ITEMS$1}` : "";
return SelectorEngine.find(`:scope > ${SELECTOR_VISIBLE_ITEMS$1}, :scope > ${SELECTOR_SUBMENU} > ${SELECTOR_VISIBLE_ITEMS$1}${backSelector}`, menu).filter((element) => isVisible(element));
}
_selectMenuItem({ key, target }) {
const currentMenu = target.closest(SELECTOR_MENU$3) || this._menu;
const items = this._getItemsInMenu(currentMenu);
if (!items.length) return;
const nextItem = getNextActiveElement(items, target, key === ARROW_DOWN_KEY$2, !items.includes(target));
nextItem.focus();
this._closeUnrelatedSubmenus(currentMenu, nextItem);
}
_handlePortaledTab(event) {
if (!this._isShown() || this._menu.parentNode === this._menuOriginalParent || event.defaultPrevented) return;
const stops = SelectorEngine.find(SELECTOR_TAB_STOPS, this._menu).filter((element) => (element.tabIndex >= 0 || element.isContentEditable && !element.hasAttribute("tabindex")) && !element.closest("[inert]") && isVisible(element));
const first = stops[0];
if (event.target === this._element && !event.shiftKey && first) {
event.preventDefault();
first.focus();
return;
}
if (event.shiftKey && event.target === first) {
event.preventDefault();
this._element.focus();
} else if (!event.shiftKey && event.target === stops.at(-1)) this._element.focus();
}
_closeUnrelatedSubmenus(currentMenu, focusedElement) {
for (const [submenu] of this._openSubmenus) {
const submenuWrapper = submenu.closest(SELECTOR_SUBMENU);
if (!submenuWrapper || submenuWrapper.parentElement !== currentMenu || submenuWrapper.contains(focusedElement)) continue;
this._closeSubmenu(submenu, submenuWrapper);
}
}
_handleSubmenuKeydown(event) {
const { key, target } = event;
const isRtl = isRTL();
const enterKey = isRtl ? ARROW_LEFT_KEY$1 : ARROW_RIGHT_KEY$1;
const exitKey = isRtl ? ARROW_RIGHT_KEY$1 : ARROW_LEFT_KEY$1;
const submenuWrapper = target.closest(SELECTOR_SUBMENU);
const isSubmenuToggle = target.matches(SELECTOR_SUBMENU_TOGGLE);
if ((key === ENTER_KEY$1 || key === SPACE_KEY$1 || key === enterKey) && submenuWrapper && isSubmenuToggle) {
event.preventDefault();
event.stopPropagation();
const submenu = SelectorEngine.findOne(SELECTOR_MENU$3, submenuWrapper);
if (submenu) {
this._closeSiblingSubmenus(submenuWrapper);
this._openSubmenu(target, submenu, submenuWrapper);
requestAnimationFrame(() => {
if (this._openSubmenus?.has(submenu)) (this._usesStackedSubmenus() ? this._getItemsInMenu(submenu)[0] : SelectorEngine.findOne(`${SELECTOR_VISIBLE_ITEMS$1}:not(.${CLASS_NAME_MENU_BACK} > *)`, submenu))?.focus();
});
}
return true;
}
if (key === exitKey) {
const currentMenu = target.closest(SELECTOR_MENU$3);
const parentSubmenuWrapper = currentMenu?.closest(SELECTOR_SUBMENU);
if (parentSubmenuWrapper) {
event.preventDefault();
event.stopPropagation();
const parentTrigger = SelectorEngine.findOne(SELECTOR_SUBMENU_TOGGLE, parentSubmenuWrapper);
this._closeSubmenu(currentMenu, parentSubmenuWrapper);
if (parentTrigger) parentTrigger.focus();
return true;
}
}
if (key === HOME_KEY$2 || key === END_KEY$2) {
const currentMenu = target.closest(SELECTOR_MENU$3);
if (!currentMenu) return false;
event.preventDefault();
event.stopPropagation();
const items = this._getItemsInMenu(currentMenu);
if (items.length) {
const targetItem = key === HOME_KEY$2 ? items[0] : items.at(-1);
targetItem.focus();
this._closeUnrelatedSubmenus(currentMenu, targetItem);
}
return true;
}
return false;
}
_handleEscape(event) {
if (!this._isShown()) return;
event.preventDefault();
event.stopPropagation();
const currentMenu = event.target.closest(SELECTOR_MENU$3);
const parentSubmenuWrapper = currentMenu?.closest(SELECTOR_SUBMENU);
if (currentMenu && parentSubmenuWrapper && this._openSubmenus.has(currentMenu)) {
this._closeSubmenu(currentMenu, parentSubmenuWrapper);
SelectorEngine.findOne(SELECTOR_SUBMENU_TOGGLE, parentSubmenuWrapper)?.focus();
return;
}
this.hide();
this._element.focus();
}
static clearMenus(event) {
if (event.button === RIGHT_MOUSE_BUTTON || event.type === "keyup" && event.key !== TAB_KEY$1) return;
for (const instance of Menu._openInstances) {
if (instance._config.autoClose === false) continue;
const composedPath = event.composedPath();
const isMenuTarget = composedPath.includes(instance._menu);
if (composedPath.includes(instance._element) || instance._config.autoClose === "inside" && !isMenuTarget || instance._config.autoClose === "outside" && isMenuTarget) continue;
const formAncestor = event.target.closest?.("form");
const isInsideMenuForm = Boolean(formAncestor) && instance._menu.contains(formAncestor);
if (instance._menu.contains(event.target) && (event.type === "keyup" && event.key === TAB_KEY$1 || /input|select|option|textarea|form/i.test(event.target.tagName) || isInsideMenuForm)) continue;
const relatedTarget = { relatedTarget: instance._element };
if (event.type === "click") relatedTarget.clickEvent = event;
instance._completeHide(relatedTarget);
}
}
static _getToggleFromKeydownContext(element, event) {
if (element.matches(SELECTOR_DATA_TOGGLE$8)) return element;
for (const instance of Menu._openInstances) if (instance._element === event.target || instance._menu?.contains(event.target)) return instance._element;
return SelectorEngine.prev(element, SELECTOR_DATA_TOGGLE$8)[0] || SelectorEngine.next(element, SELECTOR_DATA_TOGGLE$8)[0] || SelectorEngine.findOne(SELECTOR_DATA_TOGGLE$8, event.delegateTarget.parentNode);
}
static dataApiKeydownHandler(event) {
if (event.isComposing || event.keyCode === 229) return;
const { key, target } = event;
if (key !== ESCAPE_KEY$2 && key !== TAB_KEY$1) {
const activatesSubmenu = (key === ENTER_KEY$1 || key === SPACE_KEY$1) && target.matches(SELECTOR_SUBMENU_TOGGLE);
const isMenuItemOrToggle = target.matches(`${SELECTOR_DATA_TOGGLE$8}, .menu-item`);
if (!(ITEM_NAVIGATION_KEYS.has(key) || activatesSubmenu) || !isMenuItemOrToggle || target.isContentEditable || target.matches("input, select, textarea")) return;
}
const getToggleButton = Menu._getToggleFromKeydownContext(this, event);
if (!getToggleButton) return;
if (key === TAB_KEY$1) {
Menu.getInstance(getToggleButton)?._handlePortaledTab(event);
return;
}
const instance = Menu.getOrCreateInstance(getToggleButton);
if (key === ESCAPE_KEY$2) instance._handleEscape(event);
else if (key === ARROW_UP_KEY$2 || key === ARROW_DOWN_KEY$2) {
event.preventDefault();
event.stopPropagation();
instance.show();
instance._selectMenuItem(event);
} else instance._handleSubmenuKeydown(event);
}
};
/**
* Data API implementation
*/
EventHandler.on(document, EVENT_KEYDOWN_DATA_API, SELECTOR_DATA_TOGGLE$8, Menu.dataApiKeydownHandler);
EventHandler.on(document, EVENT_KEYDOWN_DATA_API, SELECTOR_MENU$3, Menu.dataApiKeydownHandler);
EventHandler.on(document, EVENT_CLICK_DATA_API$5, Menu.clearMenus);
EventHandler.on(document, EVENT_KEYUP_DATA_API, Menu.clearMenus);
EventHandler.on(document, EVENT_CLICK_DATA_API$5, SELECTOR_DATA_TOGGLE$8, function(event) {
event.preventDefault();
Menu.getOrCreateInstance(this).toggle();
});
//#endregion
//#region js/src/combobox.ts
/**
* Constants
*/
const NAME$15 = "combobox";
const EVENT_KEY$12 = `.bs.combobox`;
const DATA_API_KEY$7 = ".data-api";
const ESCAPE_KEY$1 = "Escape";
const TAB_KEY = "Tab";
const ARROW_UP_KEY$1 = "ArrowUp";
const ARROW_DOWN_KEY$1 = "ArrowDown";
const HOME_KEY$1 = "Home";
const END_KEY$1 = "End";
const ENTER_KEY = "Enter";
const SPACE_KEY = " ";
const EVENT_CHANGE$2 = `change${EVENT_KEY$12}`;
const EVENT_CLICK_DATA_API$4 = `click${EVENT_KEY$12}${DATA_API_KEY$7}`;
const CLASS_NAME_SHOW$4 = "show";
const CLASS_NAME_SELECTED = "selected";
const CLASS_NAME_PLACEHOLDER = "combobox-placeholder";
const DISMISS_ICON = "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"16\" height=\"16\" viewBox=\"0 0 16 16\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" aria-hidden=\"true\"><line x1=\"4\" y1=\"4\" x2=\"12\" y2=\"12\"/><line x1=\"12\" y1=\"4\" x2=\"4\" y2=\"12\"/></svg>";
const SELECTOR_DATA_TOGGLE$7 = "[data-bs-toggle=\"combobox\"]";
const SELECTOR_MENU$2 = ".menu";
const SELECTOR_MENU_ITEM = ".menu-item[data-bs-value]";
const SELECTOR_VISIBLE_ITEMS = ".menu-item[data-bs-value]:not(.disabled):not(:disabled)";
const SELECTOR_VALUE = ".combobox-value";
const SELECTOR_SEARCH_INPUT = ".combobox-search-input";
const SELECTOR_NO_RESULTS = ".combobox-no-results";
var ComboboxMenu = class extends Menu {
show(focus) {
return this._show(focus);
}
};
const Default$14 = {
allowCustom: false,
createOnBlur: false,
maxItems: null,
separator: null,
boundary: "clippingParents",
input: null,
multiple: false,
name: null,
offset: [0, 2],
placeholder: "",
placement: "bottom-start",
search: false,
searchNormalize: false
};
const DefaultType$14 = {
allowCustom: "boolean",
createOnBlur: "boolean",
maxItems: "(number|null)",
separator: "(string|null)",
boundary: "(string|element)",
input: "(null|element)",
multiple: "boolean",
name: "(string|null)",
offset: "(array|string|function)",
placeholder: "string",
placement: "string",
search: "boolean",
searchNormalize: "boolean"
};
/**
* Class definition
*/
var Combobox = class extends BaseComponent {
constructor(element, config) {
super(element, config);
this._editor = this._element.matches("input") ? this._element : SelectorEngine.findOne(".combobox-input, .form-ghost", this._element);
if (this._editor === this._element && this._config.multiple) throw new TypeError("COMBOBOX: Multiple selection requires a wrapping element.");
this._toggle = this._editor ?? this._element;
const field = this._editor && !this._element.matches("input") ? this._element : this._toggle;
this._menu = SelectorEngine.next(field, SELECTOR_MENU$2)[0];
this._ownsMenu = !this._menu && Boolean(this._editor);
if (this._ownsMenu) {
this._menu = document.createElement("div");
this._menu.className = "menu";
field.after(this._menu);
}
this._menuMinWidth = this._menu.style.minWidth;
this._valueDisplay = SelectorEngine.findOne(SELECTOR_VALUE, this._toggle);
this._searchInput = this._editor ?? SelectorEngine.findOne(SELECTOR_SEARCH_INPUT, this._menu);
this._noResults = SelectorEngine.findOne(SELECTOR_NO_RESULTS, this._menu);
this._activeItem = null;
this._chips = /* @__PURE__ */ new Map();
this._selectedChips = /* @__PURE__ */ new Set();
this._anchorChip = null;
this._focusingChip = false;
this._composing = false;
this._query = null;
this._status = null;
this._attributes = /* @__PURE__ */ new Map();
if (this._editor) this._setupEditor();
this._hiddenInput = null;
this._menuInstance = null;
this._ownsInput = false;
this._inputDisabled = false;
this._extraInputs = [];
this._initialSelection = this._getSelectedItems();
this._form = null;
this._menuEventHandlers = /* @__PURE__ */ new Map();
this._changeId = 0;
this._formObserver = new MutationObserver((records) => {
this._readInputDisabled(records);
this.update();
});
this._submitHandler = () => this.update();
this._resetTimeouts = /* @__PURE__ */ new Set();
this._resetHandler = (event) => {
const timeout = window.setTimeout(() => {
this._resetTimeouts.delete(timeout);
if (!this._element || event.defaultPrevented || event.target !== this._form) return;
const selected = new Set(this._initialSelection);
for (const item of SelectorEngine.find(SELECTOR_MENU_ITEM, this._menu)) {
item.classList.toggle(CLASS_NAME_SELECTED, selected.has(item));
setAriaAttribute(item, "aria-selected", selected.has(item));
}
this._query = null;
this._selectedChips.clear();
this._anchorChip = null;
this.update();
});
this._resetTimeouts.add(timeout);
};
this._createHiddenInput();
this._createMenuInstance();
this.update();
this._addEventListeners();
}
static get Default() {
return Default$14;
}
static get DefaultType() {
return DefaultType$14;
}
static get NAME() {
return NAME$15;
}
toggle() {
return this._isShown() ? this.hide() : this.show();
}
show() {
return this._showMenu();
}
async hide() {
await this._menuInstance.hide();
}
update() {
this._changeId++;
this._readInputDisabled(this._formObserver.takeRecords());
this._syncOptionRoles();
this._updateToggleText();
this._updateHiddenInput();
this._observeFormState();
if (this._editor && this._activeItem && !this._getVisibleItems().includes(this._activeItem)) this._setActiveItem(null);
}
dispose() {
this._resetTimeouts.forEach((timeout) => clearTimeout(timeout));
this._readInputDisabled(this._formObserver.takeRecords());
this._formObserver.disconnect();
EventHandler.off(this._form, `reset${EVENT_KEY$12}`, this._resetHandler);
EventHandler.off(this._form, `submit${EVENT_KEY$12}`, this._submitHandler);
for (const [event, handler] of this._menuEventHandlers) EventHandler.off(this._toggle, event, handler);
this._removeExtraInputs();
if (this._hiddenInput && !this._ownsInput) this._hiddenInput.disabled = this._inputDisabled;
if (this._menuInstance) {
this._menuInstance.dispose();
this._menuInstance = null;
}
if (this._hiddenInput && this._ownsInput) {
this._hiddenInput.remove();
this._hiddenInput = null;
}
for (const chip of this._chips.values()) chip.remove();
if (this._editor) {
this._editor.classList.remove(CLASS_NAME_SHOW$4);
this._element.classList.remove(CLASS_NAME_SHOW$4);
this._menu.classList.remove(CLASS_NAME_SHOW$4);
this._activeItem?.classList.remove("active");
}
this._status?.remove();
this._menu.style.minWidth = this._menuMinWidth;
for (const [element, attributes] of this._attributes) for (const [name, value] of attributes) if (value === null) element.removeAttribute(name);
else element.setAttribute(name, value);
if (this._ownsMenu) this._menu.remove();
EventHandler.off(this._menu, EVENT_KEY$12);
EventHandler.off(this._toggle, EVENT_KEY$12);
EventHandler.off(this._searchInput, EVENT_KEY$12);
super.dispose();
}
getValues() {
return this._getSelectedItems().map((item) => item.dataset.bsValue ?? "");
}
add(value) {
if (this._isDisabled() || this._config.multiple && this._config.maxItems !== null && this.getValues().length >= this._config.maxItems) return null;
let item = SelectorEngine.find(SELECTOR_MENU_ITEM, this._menu).find((option) => option.dataset.bsValue === value);
if (!item && this._config.allowCustom && value.trim()) {
item = document.createElement("button");
item.setAttribute("type", "button");
item.className = "menu-item";
item.dataset.bsValue = value;
item.textContent = value;
this._menu.append(item);
}
if (!item || item.classList.contains(CLASS_NAME_SELECTED) || isDisabled(item)) return null;
this._selectItem(item);
return this._element && item.classList.contains(CLASS_NAME_SELECTED) ? this._chips.get(item) ?? item : null;
}
remove(value) {
const item = this._getSelectedItems().find((option) => typeof value === "string" ? option.dataset.bsValue === value : option === value || this._chips.get(option) === value);
if (!item || isDisabled(item) || this._isDisabled()) return false;
return this._removeItems([item]);
}
clear() {
this._clearSelection(null);
}
_clearSelection(query) {
this._removeItems(this._getSelectedItems(), query);
}
focus() {
this._toggle?.focus();
}
getSelectedValues() {
return this._getSelectedItems().filter((item) => this._selectedChips.has(this._chips.get(item))).map((item) => item.dataset.bsValue ?? "");
}
selectChip(chip, options = {}) {
const chips = this._getChipElements();
if (this._isDisabled() || !chips.includes(chip)) return;
const previous = new Set(this._selectedChips);
const { addToSelection = false, rangeSelect = false } = options;
if (rangeSelect && this._anchorChip && chips.includes(this._anchorChip)) {
const anchor = chips.indexOf(this._anchorChip);
const target = chips.indexOf(chip);
if (!addToSelection) this._selectedChips.clear();
for (let index = Math.min(anchor, target); index <= Math.max(anchor, target); index++) this._selectedChips.add(chips[index]);
} else if (addToSelection) if (this._selectedChips.has(chip)) this._selectedChips.delete(chip);
else {
this._selectedChips.add(chip);
this._anchorChip = chip;
}
else {
this._selectedChips = /* @__PURE__ */ new Set([chip]);
this._anchorChip = chip;
}
if (previous.size !== this._selectedChips.size || [...previous].some((element) => !this._selectedChips.has(element))) this._notifyChipSelection();
}
clearSelection() {
this._anchorChip = null;
if (!this._selectedChips.size) return;
this._selectedChips.clear();
this._notifyChipSelection();
}
removeSelected() {
const chips = this._getChipElements();
const active = document.activeElement?.closest(".chip");
const index = Math.max(0, chips.indexOf(active));
const items = this._getSelectedItems().filter((item) => this._selectedChips.has(this._chips.get(item)));
const changed = this._removeItems(items);
if (changed && this._element) {
const remaining = this._getChipElements();
const target = remaining[Math.min(index, remaining.length - 1)];
if (target) this._focusChip(target);
else this._editor.focus();
}
return changed;
}
_getChipElements() {
return this._getSelectedItems().filter((item) => !isDisabled(item)).map((item) => this._chips.get(item)).filter((chip) => Boolean(chip));
}
_syncChipSelection() {
for (const chip of this._chips.values()) {
const selected = this._selectedChips.has(chip);
chip.classList.toggle("active", selected);
if (selected) chip.setAttribute("aria-description", "Selected for removal");
else chip.removeAttribute("aria-description");
}
}
_notifyChipSelection() {
this._syncChipSelection();
const items = this._getSelectedItems().filter((item) => this._selectedChips.has(this._chips.get(item)));
const selected = items.map((item) => item.dataset.bsValue ?? "");
if (this._status) this._status.textContent = selected.length ? `${selected.length} chip${selected.length === 1 ? "" : "s"} selected for removal` : "Chip selection cleared";
EventHandler.trigger(this._element, `select${EVENT_KEY$12}`, {
selected,
items
});
}
_focusChip(chip, options = {}) {
this.selectChip(chip, options);
if (!this._element) return;
this.hide();
if (this._element) this._focusSelectedChip(chip);
}
_focusSelectedChip(chip) {
this._focusingChip = true;
try {
chip.focus();
} finally {
if (this._element) this._focusingChip = false;
}
}
_selectAllChips() {
const chips = this._getChipElements();
if (!chips.length) return;
this._selectedChips = new Set(chips);
this._anchorChip ??= chips[0];
this._notifyChipSelection();
}
_removeItems(items, query = null) {
if (this._isDisabled() || !items.length) return false;
const allowed = [];
const changeId = this._changeId;
for (const item of items) {
if (isDisabled(item)) continue;
const event = EventHandler.trigger(this._element, `remove${EVENT_KEY$12}`, {
value: item.dataset.bsValue,
item
});
if (!this._element || changeId !== this._changeId) return false;
if (!event.defaultPrevented) allowed.push(item);
}
for (const item of allowed) {
item.classList.remove(CLASS_NAME_SELECTED);
setAriaAttribute(item, "aria-selected", false);
}
if (allowed.length) this._selectionChanged(allowed.length === 1 ? allowed[0] : null, query);
return allowed.length > 0;
}
_isDisabled() {
return isDisabled(this._element) || isDisabled(this._toggle) || this._toggle.matches(":disabled");
}
_setAttribute(element, name, value) {
if (!this._attributes.has(element)) this._attributes.set(element, /* @__PURE__ */ new Map());
const attributes = this._attributes.get(element);
if (!attributes.has(name)) attributes.set(name, element.getAttribute(name));
element.setAttribute(name, value);
}
_syncOptionRoles() {
if (!this._menu.id) this._setAttribute(this._menu, "id", getUID("combobox-"));
this._setAttribute(this._toggle, "aria-controls", this._menu.id);
this._setAttribute(this._toggle, "aria-haspopup", "listbox");
this._setAttribute(this._menu, "role", "listbox");
if (this._config.multiple) this._setAttribute(this._menu, "aria-multiselectable", "true");
for (const item of SelectorEngine.find(SELECTOR_MENU_ITEM, this._menu)) {
this._setAttribute(item, "role", "option");
this._setAttribute(item, "aria-selected", String(item.classList.contains(CLASS_NAME_SELECTED)));
}
}
_setupEditor() {
const editor = this._editor;
if (this._config.placeholder && !editor.placeholder) this._setAttribute(editor, "placeholder", this._config.placeholder);
if (!this._menu.id) this._setAttribute(this._menu, "id", getUID("combobox-"));
this._setAttribute(editor, "role", "combobox");
this._setAttribute(editor, "aria-autocomplete", "list");
this._setAttribute(editor, "aria-expanded", "false");
this._setAttribute(editor, "aria-controls", this._menu.id);
this._setAttribute(editor, "autocomplete", "off");
this._setAttribute(editor, "aria-activedescendant", "");
editor.removeAttribute("aria-activedescendant");
this._setAttribute(this._menu, "role", "listbox");
if (this._config.multiple) this._setAttribute(this._menu, "aria-multiselectable", "true");
this._status = document.createElement("span");
this._status.className = "visually-hidden";
this._status.setAttribute("role", "status");
this._menu.after(this._status);
}
_getItemLabel(item) {
return SelectorEngine.findOne(".menu-item-content > span:first-child", item)?.textContent ?? item.textContent.trim();
}
_renderEditor() {
const editor = this._editor;
const selected = this._getSelectedItems();
const selectedSet = new Set(selected);
for (const [item, chip] of this._chips) if (!selectedSet.has(item)) {
chip.remove();
this._chips.delete(item);
this._selectedChips.delete(chip);
if (this._anchorChip === chip) this._anchorChip = null;
}
for (const item of SelectorEngine.find(SELECTOR_MENU_ITEM, this._menu)) {
if (!item.id) this._setAttribute(item, "id", getUID("combobox-option-"));
this._setAttribute(item, "tabindex", "-1");
}
if (!this._config.multiple) {
const value = this._query ?? (selected.length ? this._getItemLabel(selected[0]) : "");
if (editor.value !== value) editor.value = value;
return;
}
let next = this._hiddenInput?.parentElement === editor.parentElement && this._hiddenInput.compareDocumentPosition(editor) === Node.DOCUMENT_POSITION_FOLLOWING ? this._hiddenInput : editor;
for (let index = selected.length - 1; index >= 0; index--) {
const item = selected[index];
let chip = this._chips.get(item);
const label = this._getItemLabel(item);
if (!chip) {
chip = document.createElement("span");
chip.className = "chip";
chip.tabIndex = -1;
const text = document.createElement("span");
const button = document.createElement("button");
button.type = "button";
button.className = "chip-dismiss";
button.innerHTML = DISMISS_ICON;
chip.append(text, button);
this._chips.set(item, chip);
}
this._updateChipState(item, chip, label);
if (chip.nextElementSibling !== next) next.before(chip);
next = chip;
}
this._syncChipSelection();
const value = this._query ?? "";
if (editor.value !== value) editor.value = value;
this._menuInstance?.update();
}
_updateChipState(item, chip, label) {
chip.firstElementChild.textContent = label;
const button = chip.lastElementChild;
button.setAttribute("aria-label", `Remove ${label}`);
button.disabled = this._isDisabled() || isDisabled(item);
chip.setAttribute("role", "group");
chip.setAttribute("aria-label", label);
chip.classList.toggle("disabled", button.disabled);
if (button.disabled) {
chip.setAttribute("aria-disabled", "true");
this._selectedChips.delete(chip);
if (this._anchorChip === chip) this._anchorChip = null;
} else chip.removeAttribute("aria-disabled");
}
_setActiveItem(item) {
this._activeItem?.classList.remove("active");
this._activeItem = item;
if (!item) {
this._editor.removeAttribute("aria-activedescendant");
return;
}
item.classList.add("active");
this._editor.setAttribute("aria-activedescendant", item.id);
item.scrollIntoView({ block: "nearest" });
}
_addEditorListeners() {
const editor = this._editor;
EventHandler.on(this._menu, `mousedown${EVENT_KEY$12}`, SELECTOR_MENU_ITEM, (event) => event.preventDefault());
EventHandler.on(editor, `input${EVENT_KEY$12}`, (event) => {
if (this._composing || event.isComposing) {
this._query = editor.value;
return;
}
if (this._isDisabled()) return;
this._handleEditorInput();
});
EventHandler.on(editor, `compositionstart${EVENT_KEY$12}`, () => {
this._composing = true;
});
EventHandler.on(editor, `compositionend${EVENT_KEY$12}`, () => {
this._composing = false;
if (this._element && !this._isDisabled()) this._handleEditorInput(document.activeElement === editor);
});
EventHandler.on(editor, `paste${EVENT_KEY$12}`, (event) => {
const { separator, allowCustom } = this._config;
const text = event.clipboardData?.getData("text") ?? "";
if (!allowCustom || !separator || !text.includes(separator) || this._isDisabled()) return;
event.preventDefault();
for (const value of text.split(separator)) {
this.add(value.trim());
if (!this._element) return;
}
});
EventHandler.on(editor, `blur${EVENT_KEY$12}`, (event) => {
if (!this._composing && this._config.allowCustom && this._config.createOnBlur && !event.relatedTarget?.closest(".chip, .menu")) this.add(editor.value.trim());
});
EventHandler.on(editor, `focus${EVENT_KEY$12}`, () => this.clearSelection());
EventHandler.on(this._element, `mousedown${EVENT_KEY$12}`, ".chip", (event) => {
if (!event.target.closest(".chip-dismiss")) event.preventDefault();
});
EventHandler.on(this._element, `focusin${EVENT_KEY$12}`, ".chip", (event) => {
if (this._focusingChip || this._isDisabled()) return;
const chip = event.target.closest(".chip");
if (!this._selectedChips.has(chip)) this.selectChip(chip);
if (this._element) this.hide();
});
EventHandler.on(this._element, `click${EVENT_KEY$12}`, ".chip", (event) => {
if (event.target.closest(".chip-dismiss") || this._isDisabled()) return;
event.preventDefault();
event.stopPropagation();
const chip = event.target.closest(".chip");
this._focusChip(chip, {
addToSelection: event.metaKey || event.ctrlKey,
rangeSelect: event.shiftKey
});
});
EventHandler.on(this._element, `keydown${EVENT_KEY$12}`, ".chip", (event) => this._handleChipKeydown(event));
EventHandler.on(this._element, `click${EVENT_KEY$12}`, ".chip-dismiss", (event) => {
event.preventDefault();
event.stopPropagation();
const chip = event.target.closest(".chip");
this.remove(chip);
if (this._element) editor.focus();
});
}
_handleEditorInput(openMenu = true) {
const editor = this._editor;
let query = editor.value;
if (this._config.allowCustom && this._config.separator && query.includes(this._config.separator)) {
const parts = query.split(this._config.separator);
query = parts.pop();
for (const part of parts) {
this.add(part.trim());
if (!this._element) return;
}
}
if (!this._config.multiple && this._getSelectedItems().length) {
this._clearSelection(query);
if (!this._element) return;
if (this._getSelectedItems().length) {
this._query = null;
this._renderEditor();
return;
}
}
this._query = query;
if (editor.value !== query) editor.value = query;
this._filterItems(query);
this._setActiveItem(null);
if (openMenu && this._getVisibleItems().length) this.show();
else this.hide();
}
_handleEditorKeydown(event) {
if (this._composing || event.isComposing || event.keyCode === 229 || this._isDisabled()) return;
const editor = this._editor;
if ([ARROW_DOWN_KEY$1, ARROW_UP_KEY$1].includes(event.key)) {
event.preventDefault();
const items = this._getVisibleItems();
if (items.length) {
const item = getNextActiveElement(items, this._activeItem, event.key === ARROW_DOWN_KEY$1, true);
this.show();
if (this._element) this._setActiveItem(item);
}
return;
}
if (event.key === ENTER_KEY) {
if (this._activeItem && this._isShown()) {
event.preventDefault();
this._selectItem(this._activeItem);
} else if (this._config.allowCustom && editor.value.trim()) {
event.preventDefault();
this.add(editor.value.trim());
}
return;
}
if (event.key === ESCAPE_KEY$1 || event.key === TAB_KEY) {
if (event.key === ESCAPE_KEY$1 && this._isShown()) event.preventDefault();
this.hide();
if (this._element) this._setActiveItem(null);
return;
}
this._handleEditorChipFocus(event);
}
_handleEditorChipFocus(event) {
const editor = this._editor;
if ((event.metaKey || event.ctrlKey) && event.key.toLowerCase() === "a" && !editor.value) {
const chips = this._getChipElements();
if (chips.length) {
event.preventDefault();
this._selectAllChips();
if (this._element) {
this.hide();
if (this._element) this._focusSelectedChip(chips.at(-1));
}
}
return;
}
if (event.metaKey || event.ctrlKey || event.altKey) return;
const previousKey = getComputedStyle(editor).direction === "rtl" ? "ArrowRight" : "ArrowLeft";
const backwardDelete = ["Backspace", "Delete"].includes(event.key) && !editor.value;
const atStart = event.key === previousKey && editor.selectionStart === 0 && editor.selectionEnd === 0;
if (backwardDelete || atStart) {
const chip = this._getChipElements().at(-1);
if (chip) {
event.preventDefault();
this._focusChip(chip, { addToSelection: event.shiftKey });
}
}
}
_handleChipKeydown(event) {
if (this._composing || event.isComposing || event.keyCode === 229 || this._isDisabled()) return;
const chip = event.target.closest(".chip");
const chips = this._getChipElements();
const index = chips.indexOf(chip);
if (index === -1) return;
if ((event.metaKey || event.ctrlKey) && event.key.toLowerCase() === "a") {
event.preventDefault();
this._selectAllChips();
return;
}
if (["Backspace", "Delete"].includes(event.key)) {
event.preventDefault();
this._deleteChipSelection(chip);
return;
}
const rtl = getComputedStyle(this._editor).direction === "rtl";
if (["ArrowLeft", "ArrowRight"].includes(event.key)) {
event.preventDefault();
const next = index + (event.key === "ArrowRight" === rtl ? -1 : 1);
if (next >= chips.length) {
this.clearSelection();
if (this._element) this._editor.focus();
} else this._focusChip(chips[Math.max(0, next)], { rangeSelect: event.shiftKey });
} else if (event.key === HOME_KEY$1 || event.key === END_KEY$1 && event.shiftKey) {
event.preventDefault();
const target = event.key === HOME_KEY$1 ? chips[0] : chips.at(-1);
this._focusChip(target, { rangeSelect: event.shiftKey });
} else if ([END_KEY$1, ESCAPE_KEY$1].includes(event.key)) {
event.preventDefault();
this.clearSelection();
if (this._element) this._editor.focus();
}
}
_deleteChipSelection(chip) {
if (!this._selectedChips.has(chip)) this.selectChip(chip);
if (this._element) this.removeSelected();
}
_isShown() {
return this._menu.classList.contains(CLASS_NAME_SHOW$4);
}
_configAfterMerge(config) {
if (config.maxItems !== null && (!Number.isSafeInteger(config.maxItems) || config.maxItems < 1)) throw new TypeError("COMBOBOX: Option \"maxItems\" must be a positive integer or null.");
if (config.input !== null) {
const input = getElement(config.input);
if (!(input instanceof HTMLInputElement) || input.type !== "hidden") throw new TypeError("COMBOBOX: Option \"input\" must reference a hidden input.");
config.input = input;
}
return config;
}
_createHiddenInput() {
if (this._config.input) {
this._hiddenInput = this._config.input;
this._inputDisabled = this._hiddenInput.disabled;
return;
}
if (!this._config.name) return;
this._hiddenInput = document.createElement("input");
this._hiddenInput.type = "hidden";
this._hiddenInput.name = this._config.name;
(this._editor ? this._element : this._toggle).before(this._hiddenInput);
this._ownsInput = true;
}
_removeExtraInputs() {
for (const input of this._extraInputs) input.remove();
this._extraInputs = [];
}
_readInputDisabled(records) {
if (!this._ownsInput && records.some((record) => record.target === this._hiddenInput && record.attributeName === "disabled")) this._inputDisabled = this._hiddenInput.disabled;
}
_observeFormState() {
this._formObserver.disconnect();
if (this._element !== this._toggle) this._formObserver.observe(this._element, {
attributes: true,
attributeFilter: ["class"]
});
this._formObserver.observe(this._toggle, {
attributes: true,
attributeFilter: [
"disabled",
"class",
"form"
]
});
if (this._hiddenInput) this._formObserver.observe(this._hiddenInput, {
attributes: true,
attributeFilter: [
"disabled",
"name",
"form"
]
});
const fieldsets = /* @__PURE__ */ new Set();
for (const element of [this._toggle, this._hiddenInput]) for (let parent = element?.parentElement; parent; parent = parent.parentElement) if (parent.matches("fieldset")) fieldsets.add(parent);
for (const fieldset of fieldsets) this._formObserver.observe(fieldset, {
attributes: true,
attributeFilter: ["disabled"]
});
const form = this._hiddenInput ? this._hiddenInput.form : this._toggle instanceof HTMLInputElement || this._toggle instanceof HTMLButtonElement ? this._toggle.form : this._toggle.closest("form");
if (form !== this._form) {
EventHandler.off(this._form, `reset${EVENT_KEY$12}`, this._resetHandler);
EventHandler.off(this._form, `submit${EVENT_KEY$12}`, this._submitHandler);
this._form = form;
EventHandler.on(this._form, `reset${EVENT_KEY$12}`, this._resetHandler);
EventHandler.on(this._form, `submit${EVENT_KEY$12}`, this._submitHandler);
}
}
async _showMenu(focus) {
if (this._isDisabled() || this._isShown() || this._editor && !this._getVisibleItems().length) return;
const search = this._editor || isDisabled(this._searchInput) ? null : this._searchInput;
await this._menuInstance.show(focus ?? (search ? () => search.focus({ preventScroll: true }) : void 0));
}
_createMenuInstance() {
this._menuInstance = new ComboboxMenu(this._toggle, {
menu: this._menu,
reference: this._editor ? this._element : "toggle",
autoClose: this._config.multiple ? "outside" : true,
boundary: this._config.boundary,
offset: this._config.offset,
placement: this._config.placement,
floatingConfig: this._editor ? (config) => ({
...config,
middleware: [...config.middleware, {
name: "comboboxSize",
fn: ({ elements, rects }) => {
if (this._element) elements.floating.style.minWidth = `${rects.reference.width}px`;
return {};
}
}]
}) : null
});
}
_addEventListeners() {
for (const type of [
"show",
"shown",
"hide",
"hidden"
]) {
const event = Menu.eventName(type);
const handler = (menuEvent) => {
if (!this._element) return;
if (type === "hidden" && this._editor) this._setActiveItem(null);
if (EventHandler.trigger(this._element, this.constructor.eventName(type))?.defaultPrevented || !this._element) {
menuEvent.preventDefault();
return;
}
if (type === "show" && !menuEvent.defaultPrevented && this._searchInput && !this._editor) {
this._searchInput.value = "";
this._filterItems("");
}
};
this._menuEventHandlers.set(event, handler);
EventHandler.on(this._toggle, event, handler);
}
EventHandler.on(this._menu, `click${EVENT_KEY$12}`, SELECTOR_MENU_ITEM, (event) => {
const item = event.target.closest(SELECTOR_MENU_ITEM);
if (!item || isDisabled(item)) return;
event.preventDefault();
event.stopPropagation();
this._selectItem(item);
});
EventHandler.on(this._toggle, `keydown${EVENT_KEY$12}`, (event) => {
if (this._editor) this._handleEditorKeydown(event);
else this._handleToggleKeydown(event);
});
EventHandler.on(this._menu, `keydown${EVENT_KEY$12}`, (event) => {
this._handleMenuKeydown(event);
});
if (this._editor) {
this._addEditorListeners();
return;
}
if (this._searchInput) {
EventHandler.on(this._toggle, `mousedown${EVENT_KEY$12}`, (event) => {
if (event.button === 0 && !this._isShown() && !this._isDisabled() && !isDisabled(this._searchInput)) event.preventDefault();
});
EventHandler.on(this._searchInput, `input${EVENT_KEY$12}`, () => {
this._filterItems(this._searchInput.value);
});
EventHandler.on(this._searchInput, `keydown${EVENT_KEY$12}`, (event) => {
if (event.isComposing || event.keyCode === 229) return;
if (event.key === ARROW_DOWN_KEY$1) {
event.preventDefault();
const items = this._getVisibleItems();
if (items.length > 0) items[0].focus();
}
if (event.key === ESCAPE_KEY$1) {
this.hide();
this._toggle?.focus();
}
});
}
}
_selectItem(item) {
if (this._isDisabled() || isDisabled(item) || !this._menu.contains(item)) return;
const previous = this._getSelectedItems();
if (this._config.multiple && !previous.includes(item) && this._config.maxItems !== null && previous.length >= this._config.maxItems) return;
if (!this._config.multiple && previous.length === 1 && previous[0] === item) return;
const changeId = this._changeId;
const type = this._config.multiple && previous.includes(item) ? "remove" : "add";
const event = EventHandler.trigger(this._element, `${type}${EVENT_KEY$12}`, {
value: item.dataset.bsValue,
item
});
if (!this._element || event.defaultPrevented || changeId !== this._changeId || this._isDisabled() || isDisabled(item) || !this._menu.contains(item)) return;
if (this._config.multiple) {
item.classList.toggle(CLASS_NAME_SELECTED);
setAriaAttribute(item, "aria-selected", item.classList.contains(CLASS_NAME_SELECTED));
} else {
for (const selected of previous) {
selected.classList.remove(CLASS_NAME_SELECTED);
selected.setAttribute("aria-selected", "false");
}
item.classList.add(CLASS_NAME_SELECTED);
item.setAttribute("aria-selected", "true");
}
this._selectionChanged(item);
}
_selectionChanged(item, query = null) {
this._query = query;
this.update();
const changeId = this._changeId;
const { multiple } = this._config;
const values = this.getValues();
const value = multiple ? values : values[0] ?? "";
const target = this._hiddenInput ?? this._element;
for (const event of ["input", "change"]) {
EventHandler.trigger(target, event);
if (!this._element || changeId !== this._changeId) return;
}
EventHandler.trigger(this._element, EVENT_CHANGE$2, {
value,
item
});
if (!this._element || changeId !== this._changeId) return;
if (this._editor) {
this._setActiveItem(null);
this._filterItems("");
if (this._status) this._status.textContent = `${values.length} selected`;
}
if (!multiple && query === null) {
this.hide();
this._toggle?.focus();
}
}
_updateToggleText() {
if (this._editor) {
this._renderEditor();
return;
}
const selectedItems = this._getSelectedItems();
if (selectedItems.length === 0) {
this._showPlaceholder();
return;
}
this._valueDisplay.classList.remove(CLASS_NAME_PLACEHOLDER);
if (this._config.multiple && selectedItems.length > 1) this._valueDisplay.textContent = `${selectedItems.length} selected`;
else {
const item = selectedItems[0];
const label = SelectorEngine.findOne(".menu-item-content > span:first-child", item);
this._valueDisplay.textContent = label ? label.textContent : item.textContent.trim();
}
}
_showPlaceholder() {
const { placeholder } = this._config;
this._valueDisplay.textContent = placeholder;
this._valueDisplay.classList.toggle(CLASS_NAME_PLACEHOLDER, Boolean(placeholder));
}
_updateHiddenInput() {
const input = this._hiddenInput;
if (!input) return;
const selected = this._getSelectedItems();
const values = selected.filter((item) => !isDisabled(item)).map((item) => item.dataset.bsValue ?? "");
const submittedValues = this._config.multiple ? values : [values[0] ?? ""];
const disabled = this._inputDisabled || this._isDisabled() || selected.length > 0 && values.length === 0;
if (this._ownsInput) {
const anchor = this._editor ? this._element : this._toggle;
const fields = [input, ...this._extraInputs];
if (fields.at(-1).nextElementSibling !== anchor) for (const field of fields) anchor.before(field);
const form = this._toggle.getAttribute("form");
if (form === null) input.removeAttribute("form");
else input.setAttribute("form", form);
}
input.value = submittedValues[0] ?? "";
input.disabled = disabled || submittedValues.length === 0;
for (let index = 1; index < submittedValues.length; index++) {
let extra = this._extraInputs[index - 1];
if (!extra) {
extra = document.createElement("input");
extra.type = "hidden";
this._extraInputs.push(extra);
}
const previous = this._extraInputs[index - 2] ?? input;
if (!previous.parentNode) extra.remove();
else if (extra.previousElementSibling !== previous) previous.after(extra);
extra.name = input.name;
extra.value = submittedValues[index];
extra.disabled = disabled;
const form = input.getAttribute("form");
if (form === null) extra.removeAttribute("form");
else extra.setAttribute("form", form);
}
for (const extra of this._extraInputs.splice(Math.max(0, submittedValues.length - 1))) extra.remove();
this._formObserver.takeRecords();
}
_getSelectedItems() {
return SelectorEngine.find(`${SELECTOR_MENU_ITEM}.${CLASS_NAME_SELECTED}`, this._menu);
}
_getVisibleItems() {
return SelectorEngine.find(SELECTOR_VISIBLE_ITEMS, this._menu).filter((item) => {
if (!this._editor) return isVisible(item);
for (let current = item; current && current !== this._menu; current = current.parentElement) {
const style = getComputedStyle(current);
if (current.hidden || style.display === "none" || style.visibility === "hidden") return false;
}
return true;
});
}
_filterItems(query) {
const normalizedQuery = this._normalizeText(query.toLowerCase().trim());
const items = SelectorEngine.find(SELECTOR_MENU_ITEM, this._menu);
let visibleCount = 0;
for (const item of items) {
const text = this._normalizeText(item.textContent.toLowerCase().trim());
const matches = !normalizedQuery || text.includes(normalizedQuery);
item.style.display = matches ? "" : "none";
if (matches) visibleCount++;
}
if (this._noResults) this._noResults.classList.toggle("d-none", visibleCount > 0);
}
_normalizeText(text) {
if (this._config.searchNormalize) return text.normalize("NFD").replace(/[\u0300-\u036F]/g, "");
return text;
}
_handleToggleKeydown(event) {
if (event.isComposing || event.keyCode === 229) return;
const { key } = event;
if (key === ARROW_DOWN_KEY$1 || key === ARROW_UP_KEY$1) {
event.preventDefault();
const focusItem = () => {
const items = this._getVisibleItems();
((key === ARROW_DOWN_KEY$1 ? items[0] : items.at(-1)) ?? (isDisabled(this._searchInput) ? this._toggle : this._searchInput))?.focus();
};
if (this._isShown()) focusItem();
else this._showMenu(focusItem);
return;
}
if (key === ESCAPE_KEY$1 && this._isShown()) {
event.preventDefault();
event.stopPropagation();
this.hide();
return;
}
if ((key === ENTER_KEY || key === SPACE_KEY) && !this._isShown()) {
event.preventDefault();
this.show();
}
}
_handleMenuKeydown(event) {
if (event.isComposing || event.keyCode === 229) return;
const { key, target } = event;
if (key === ESCAPE_KEY$1) {
event.preventDefault();
event.stopPropagation();
this.hide();
this._toggle?.focus();
return;
}
if (key === TAB_KEY) {
this.hide();
return;
}
const isInput = target.matches("input");
if (key === ARROW_DOWN_KEY$1 || key === ARROW_UP_KEY$1) {
event.preventDefault();
const items = this._getVisibleItems();
if (items.length > 0) getNextActiveElement(items, target, key === ARROW_DOWN_KEY$1, !items.includes(target)).focus();
return;
}
if ((key === HOME_KEY$1 || key === END_KEY$1) && !isInput) {
event.preventDefault();
const items = this._getVisibleItems();
if (items.length > 0) (key === HOME_KEY$1 ? items[0] : items.at(-1)).focus();
return;
}
if ((key === ENTER_KEY || key === SPACE_KEY) && !isInput) {
event.preventDefault();
const item = target.closest(SELECTOR_MENU_ITEM);
if (item && !isDisabled(item)) this._selectItem(item);
}
}
};
/**
* Data API implementation
*/
EventHandler.on(document, EVENT_CLICK_DATA_API$4, SELECTOR_DATA_TOGGLE$7, function(event) {
const instance = Combobox.getOrCreateInstance(this);
if (this.matches("input") || this.querySelector(".combobox-input, .form-ghost")) {
if (!event.target.closest(".chip")) {
instance.focus();
instance.show();
}
return;
}
event.preventDefault();
instance.toggle();
});
onDocumentReady("DOMContentLoaded", () => {
for (const toggle of SelectorEngine.find(SELECTOR_DATA_TOGGLE$7)) Combobox.getOrCreateInstance(toggle);
});
//#endregion
//#region js/src/datepicker.ts
/**
* --------------------------------------------------------------------------
* Bootstrap datepicker.ts
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
* --------------------------------------------------------------------------
*/
/**
* Constants
*/
const NAME$14 = "datepicker";
const EVENT_KEY$11 = `.bs.datepicker`;
const DATA_API_KEY$6 = ".data-api";
const EVENT_CHANGE$1 = `change${EVENT_KEY$11}`;
const EVENT_SHOW$3 = `show${EVENT_KEY$11}`;
const EVENT_SHOWN$3 = `shown${EVENT_KEY$11}`;
const EVENT_HIDE$3 = `hide${EVENT_KEY$11}`;
const EVENT_HIDDEN$3 = `hidden${EVENT_KEY$11}`;
const EVENT_FOCUSIN$3 = `focusin${EVENT_KEY$11}`;
const EVENT_POINTERDOWN$2 = `pointerdown${EVENT_KEY$11}`;
const EVENT_CLICK$4 = `click${EVENT_KEY$11}`;
const EVENT_CLICK_DATA_API$3 = `click${EVENT_KEY$11}${DATA_API_KEY$6}`;
const EVENT_FOCUSIN_DATA_API = `focusin${EVENT_KEY$11}${DATA_API_KEY$6}`;
const SELECTOR_DATA_TOGGLE$6 = "[data-bs-toggle=\"datepicker\"]";
const EVENT_KEYDOWN$2 = `keydown${EVENT_KEY$11}`;
const FOCUSABLE = "a[href], button, input, select, textarea, [tabindex], [contenteditable=\"true\"]";
const Default$13 = {
datepickerTheme: null,
dateMin: null,
dateMax: null,
dateFormat: null,
displayElement: null,
displayMonthsCount: 1,
firstWeekday: 1,
invalidDateMessage: "Enter a valid date available in the calendar.",
inline: false,
showOnFocus: true,
toggleElement: null,
locale: "default",
positionElement: null,
selectedDates: [],
selectionMode: "single",
rangeEndMessage: "Choose an end date.",
placement: "left",
vcpOptions: {}
};
const DefaultType$13 = {
datepickerTheme: "(null|string)",
dateMin: "(null|string|number|object)",
dateMax: "(null|string|number|object)",
dateFormat: "(null|object|function)",
displayElement: "(null|string|element|boolean)",
displayMonthsCount: "number",
firstWeekday: "number",
inline: "boolean",
invalidDateMessage: "string",
showOnFocus: "boolean",
toggleElement: "(null|string|element)",
locale: "string",
positionElement: "(null|string|element)",
selectedDates: "array",
selectionMode: "string",
placement: "string",
rangeEndMessage: "string",
vcpOptions: "object"
};
const formBindings = /* @__PURE__ */ new WeakMap();
const bindFormData = (form, key, serialize) => {
let binding = formBindings.get(form);
if (!binding) {
const state = {
controls: /* @__PURE__ */ new Map(),
handler() {}
};
state.handler = (event) => {
const entries = [];
for (const [name, value] of event.formData) {
const control = state.controls.get(name);
if (!control) {
entries.push([name, value]);
continue;
}
const entry = control();
if (entry) entries.push(entry);
}
for (const name of new Set(event.formData.keys())) event.formData.delete(name);
for (const [name, value] of entries) event.formData.append(name, value);
};
binding = state;
formBindings.set(form, binding);
form.addEventListener("formdata", binding.handler, true);
}
binding.controls.set(key, serialize);
return () => {
binding.controls.delete(key);
if (binding.controls.size === 0) {
form.removeEventListener("formdata", binding.handler, true);
formBindings.delete(form);
}
};
};
/**
* Class definition
*/
var Datepicker = class extends BaseComponent {
constructor(element, config) {
super(element, config);
this._calendar = null;
this._toggleElement = null;
this._returnFocusElement = this._element;
this._originalToggleAria = /* @__PURE__ */ new Map();
this._popup = null;
this._isShown = false;
this._floatingCleanup = null;
this._resetTimeouts = /* @__PURE__ */ new Set();
this._suppressFocus = false;
this._positionGeneration = 0;
this._showGeneration = 0;
this._inputName = null;
this._inputObserver = null;
this._form = null;
this._formCleanup = null;
this._dialog = null;
this._initialDates = [];
this._rangeDates = [];
this._pendingRange = false;
this._rangeStatus = null;
this._inputError = null;
this._inputErrorMessage = "";
this._originalInvalid = null;
this._eventPending = false;
this._originalAria = new Map([
"aria-haspopup",
"aria-expanded",
"aria-controls"
].map((name) => [name, this._element.getAttribute(name)]));
try {
this._initCalendar();
} catch (error) {
this.dispose();
throw error;
}
}
static get Default() {
return Default$13;
}
static get DefaultType() {
return DefaultType$13;
}
static get NAME() {
return NAME$14;
}
toggle(relatedTarget) {
if (this._isInline) return Promise.resolve();
return this._isShown ? this.hide() : this.show(relatedTarget);
}
async show(relatedTarget) {
if (this._skipFocusTrigger(relatedTarget)) return;
if (!this._calendar || this._isInline || this._isShown || this._eventPending || this._suppressFocus || isDisabled(this._element) || this._element.matches(":disabled")) return;
if (this._triggerLifecycleEvent(EVENT_SHOW$3).defaultPrevented || !this._calendar || this._isShown) return;
this._popup.style.removeProperty("max-inline-size");
this._popup.style.removeProperty("max-block-size");
this._returnFocusElement = relatedTarget || this._element;
const generation = ++this._showGeneration;
this._isShown = true;
const popup = this._popup;
this._mountPopup();
this._syncDisplayMonths();
this._syncPopupState(this._calendar);
popup.removeAttribute("data-vc-calendar-closing");
if (typeof popup.showPopover === "function" && !popup.matches(":popover-open")) popup.showPopover();
this._element.setAttribute("aria-expanded", "true");
await this._updatePosition();
if (!this._isCurrentOpening(generation)) return;
this._floatingCleanup?.();
this._floatingCleanup = autoUpdate(this._positionElement, popup, () => {
this._syncDisplayMonths();
this._updatePosition();
});
if (!this._isInput || relatedTarget && relatedTarget !== this._element) this._focusCalendarDate();
await this._queueCallback(() => {
if (this._isCurrentOpening(generation)) EventHandler.trigger(this._element, EVENT_SHOWN$3);
}, popup, getTransitionDurationFromElement(popup) > 0);
}
async hide() {
if (!this._calendar || this._isInline || !this._isShown || this._eventPending) return;
if (this._triggerLifecycleEvent(EVENT_HIDE$3).defaultPrevented || !this._calendar) return;
const popup = this._popup;
const animated = getTransitionDurationFromElement(popup) > 0;
this._closePopup(animated);
const generation = this._showGeneration;
await this._queueCallback(() => {
if (this._calendar && !this._isShown && generation === this._showGeneration) {
this._finishPopupClose();
EventHandler.trigger(this._element, EVENT_HIDDEN$3);
}
}, popup, animated);
}
_triggerLifecycleEvent(name) {
this._eventPending = true;
try {
return EventHandler.trigger(this._element, name);
} finally {
this._eventPending = false;
}
}
_closePopup(animated = false) {
this._showGeneration++;
this._isShown = false;
this._positionGeneration++;
if (animated) this._popup?.setAttribute("data-vc-calendar-closing", "");
else this._finishPopupClose();
if (this._calendar) {
this._cancelPendingRange();
this._syncPopupState(this._calendar);
}
this._element?.setAttribute("aria-expanded", "false");
}
_finishPopupClose() {
this._floatingCleanup?.();
this._floatingCleanup = null;
if (this._popup?.matches(":popover-open")) this._popup.hidePopover();
this._popup?.removeAttribute("data-vc-calendar-closing");
}
dispose() {
this._syncBoundInput();
this._setInputError("");
if (this._onInvalid) this._element.removeEventListener("invalid", this._onInvalid);
this._resetTimeouts.forEach((timeout) => clearTimeout(timeout));
this._closePopup();
this._themeObserver?.disconnect();
this._inputObserver?.disconnect();
this._formCleanup?.();
if (this._form && this._onReset) EventHandler.off(this._form, `reset${EVENT_KEY$11}`, this._onReset);
if (this._onOutside) {
EventHandler.off(document, EVENT_FOCUSIN$3, this._onOutside);
EventHandler.off(document, EVENT_POINTERDOWN$2, this._onOutside);
}
if (this._onKeydown) {
EventHandler.off(this._element, EVENT_KEYDOWN$2, this._onKeydown);
this._popup?.removeEventListener("keydown", this._onKeydown, true);
}
if (this._toggleElement) {
EventHandler.off(this._toggleElement, EVENT_CLICK$4, this._onToggleClick);
EventHandler.off(this._toggleElement, EVENT_KEYDOWN$2, this._onKeydown);
this._restoreAria(this._toggleElement, this._originalToggleAria);
}
if (this._onTriggerClick) EventHandler.off(this._positionElement, EVENT_CLICK$4, this._onTriggerClick);
if (this._dialog) EventHandler.off(this._dialog, "close", this._onDialogClose);
if (this._calendar?.context.isInit) {
this._calendar.destroy();
this._calendar.context.mainElement.remove();
} else this._popup?.remove();
if (this._inputName !== null) {
this._element.setAttribute("name", this._inputName);
this._boundInput?.remove();
}
this._restoreAria(this._element, this._originalAria);
this._calendar = null;
super.dispose();
}
getSelectedDates() {
const dates = this._config?.selectionMode === "multiple-ranged" ? this._rangeDates : this._calendar?.context.selectedDates;
return dates ? [...dates] : [];
}
setSelectedDates(dates) {
if (this._calendar) {
for (const date of dates) if (typeof date === "string" && /^\d{4}-\d{2}-\d{2}$/.test(date) && !this._parseIsoDate(date)) throw new TypeError("Invalid ISO date");
this._pendingRange = false;
this._calendar.set({ selectedDates: dates });
this._rangeDates = [...this._calendar.context.selectedDates];
this._syncSelectedDates(this.getSelectedDates());
}
}
_getConfig(config) {
return super._getConfig({
vcpOptions: Default$13.vcpOptions,
...config
});
}
_isCurrentOpening(generation) {
return Boolean(this._calendar) && this._isShown && generation === this._showGeneration;
}
_skipFocusTrigger(relatedTarget) {
return this._isInput && relatedTarget === this._element && !this._config.showOnFocus;
}
_containsTrigger(target) {
return this._positionElement.contains(target) || this._element.contains(target) || Boolean(this._toggleElement?.contains(target));
}
_restoreAria(element, original) {
for (const [name, value] of original) if (value === null) element.removeAttribute(name);
else element.setAttribute(name, value);
}
_initCalendar() {
this._isInput = this._element.tagName === "INPUT";
this._isInline = this._config.inline;
if (this._isInline && !this._isInput) this._boundInput = this._element.querySelector("input[type=\"hidden\"], input[name]");
if (this._isInput && !this._isInline && this._config.toggleElement) {
const root = this._element.getRootNode();
this._toggleElement = typeof this._config.toggleElement === "string" ? root.querySelector(this._config.toggleElement) : this._config.toggleElement;
if (this._toggleElement === this._element) throw new TypeError("The Datepicker toggle must be separate from its input");
if (this._toggleElement) this._originalToggleAria = new Map([
"aria-haspopup",
"aria-expanded",
"aria-controls"
].map((name) => [name, this._toggleElement.getAttribute(name)]));
}
this._positionElement = this._resolvePositionElement();
this._displayElement = this._resolveDisplayElement();
const display = this._displayElement;
this._displayPlaceholder = display && this._element.contains(display) && display.hasAttribute("data-bs-datepicker-display") ? display.textContent : "";
this._popup = document.createElement("div");
if (this._isInline) this._element.append(this._popup);
else {
this._popup.id = getUID("bs-datepicker-calendar-");
this._popup.setAttribute("popover", "manual");
this._element.setAttribute("aria-haspopup", "dialog");
this._element.setAttribute("aria-expanded", "false");
this._element.setAttribute("aria-controls", this._popup.id);
if (this._toggleElement) {
this._toggleElement.setAttribute("aria-haspopup", "dialog");
this._toggleElement.setAttribute("aria-controls", this._popup.id);
}
this._mountPopup();
}
this._calendar = new Calendar(this._popup, this._buildCalendarOptions());
this._calendar.init();
this._rangeDates = [...this._calendar.context.selectedDates];
if (this._isInput && this._element.value && (!this._element.readOnly || !this._rangeDates.length)) this._parseInputValue();
this._initialDates = this.getSelectedDates();
if (this._isInput && !this._isInline) {
this._createBoundInput();
this._bindInputForm();
EventHandler.on(this._element, `input${EVENT_KEY$11}`, () => this._parseInputValue());
this._onInvalid = () => this._showInputError();
EventHandler.on(this._element, `blur${EVENT_KEY$11}`, this._onInvalid);
this._element.addEventListener("invalid", this._onInvalid);
}
this._updateDisplayWithSelectedDates();
if (this._isInline && this._boundInput) this._bindInputForm();
this._setupThemeObserver();
this._setupDismiss();
}
_createBoundInput() {
const name = this._element.getAttribute("name");
if (!name) return;
this._inputName = name;
this._boundInput = document.createElement("input");
this._boundInput.type = "hidden";
this._boundInput.id = getUID("bs-datepicker-");
this._boundInput.name = this._boundInput.id;
this._element.before(this._boundInput);
this._element.removeAttribute("name");
this._syncBoundInput();
this._inputObserver = new MutationObserver(() => {
this._syncBoundInput();
this._bindInputForm();
});
this._inputObserver.observe(this._element, {
attributes: true,
attributeFilter: [
"name",
"disabled",
"form"
]
});
}
_syncBoundInput() {
if (this._inputName === null || !this._boundInput) return;
const name = this._element.getAttribute("name");
if (name !== null) {
this._inputName = name;
this._element.removeAttribute("name");
}
const form = this._element.getAttribute("form");
if (form === null) this._boundInput.removeAttribute("form");
else this._boundInput.setAttribute("form", form);
this._boundInput.value = this.getSelectedDates().join(",");
}
_bindInputForm() {
const form = this._isInput ? this._element.form : this._boundInput?.form ?? null;
if (form === this._form) return;
this._formCleanup?.();
this._resetTimeouts.forEach((timeout) => clearTimeout(timeout));
this._resetTimeouts.clear();
if (this._form) EventHandler.off(this._form, `reset${EVENT_KEY$11}`, this._onReset);
this._form = form;
if (!form) return;
if (this._inputName !== null && this._boundInput) this._formCleanup = bindFormData(form, this._boundInput.name, () => {
this._syncBoundInput();
return this._element.matches(":disabled") || isDisabled(this._element) || !this._inputName ? null : [this._inputName, this.getSelectedDates().join(",")];
});
this._onReset = (event) => {
const timeout = setTimeout(() => {
this._resetTimeouts.delete(timeout);
if (!event.defaultPrevented && this._calendar && event.target === this._form) this.setSelectedDates(this._initialDates);
}, 0);
this._resetTimeouts.add(timeout);
};
EventHandler.on(form, `reset${EVENT_KEY$11}`, this._onReset);
}
_mountPopup() {
let ancestor = this._element;
let dialog = null;
while (ancestor && !dialog) {
dialog = ancestor.closest("dialog[open]");
const root = ancestor.getRootNode();
ancestor = root instanceof ShadowRoot ? root.host : null;
}
if (dialog !== this._dialog) {
if (this._dialog) EventHandler.off(this._dialog, "close", this._onDialogClose);
this._dialog = dialog;
this._onDialogClose = () => this._closePopup();
if (dialog) EventHandler.on(dialog, "close", this._onDialogClose);
}
const root = this._element.getRootNode();
const parent = root instanceof ShadowRoot ? root : dialog || document.body;
if (this._popup.parentNode !== parent) parent.append(this._popup);
}
async _updatePosition() {
const popup = this._popup;
if (!popup || !this._isShown && !popup.hasAttribute("data-vc-calendar-closing")) return;
const generation = ++this._positionGeneration;
const left = popup.dir === "rtl" ? "-end" : "-start";
const right = popup.dir === "rtl" ? "-start" : "-end";
const alignment = this._config.placement === "center" ? "" : this._config.placement === "right" ? right : left;
const result = await computePosition(this._positionElement, popup, {
placement: `bottom${alignment}`,
strategy: "fixed",
middleware: [
offset(4),
flip({ padding: 8 }),
shift({
padding: 8,
crossAxis: true
}),
size({
padding: 8,
apply: ({ availableWidth, availableHeight, elements }) => {
if (generation === this._positionGeneration) Object.assign(elements.floating.style, {
maxInlineSize: `${Math.max(0, availableWidth)}px`,
maxBlockSize: `${Math.max(0, availableHeight)}px`
});
}
})
]
});
if (generation !== this._positionGeneration || !this._isShown && !popup.hasAttribute("data-vc-calendar-closing")) return;
Object.assign(popup.style, {
position: result.strategy,
left: `${result.x}px`,
top: `${result.y}px`
});
popup.dataset.vcPosition = result.placement.startsWith("top") ? "top" : "bottom";
}
_getCalendarLabel() {
const root = this._element.getRootNode();
const label = this._element.getAttribute("aria-labelledby")?.trim().split(/\s+/).map((id) => {
const label = root.getElementById?.(id);
return label?.hasAttribute("data-bs-datepicker-display") ? "" : label?.textContent.trim();
}).filter(Boolean).join(" ") || this._element.getAttribute("aria-label");
if (label) return label;
if (this._isInput) return [...this._element.labels || []].map((label) => label.textContent.trim()).filter(Boolean).join(" ");
return "";
}
_getDisplayMonths() {
const { displayMonthsCount } = this._config;
return displayMonthsCount > 1 && !this._isInline && window.matchMedia("(width < 576px)").matches ? 1 : displayMonthsCount;
}
_syncDisplayMonths() {
const calendar = this._calendar;
const count = this._getDisplayMonths();
if (!calendar || calendar.displayMonthsCount === count) return;
const root = this._popup.getRootNode();
const hadFocus = this._popup.contains(root.activeElement);
calendar.set({
type: count > 1 ? "multiple" : "default",
displayMonthsCount: count,
selectedDates: [...calendar.context.selectedDates]
}, {
month: false,
year: false
});
if (hadFocus) this._focusCalendarDate();
}
_syncPopupState(self) {
this._normalizeRangeDates(self);
const popup = self.context.mainElement;
if (!this._isInline) {
popup.dataset.vcInput = "";
popup.role = "dialog";
const label = this._getCalendarLabel();
if (label) popup.setAttribute("aria-label", label);
popup.toggleAttribute("data-vc-calendar-hidden", !this._isShown);
popup.inert = !this._isShown;
popup.setAttribute("aria-hidden", String(!this._isShown));
this._toggleElement?.setAttribute("aria-expanded", String(this._isShown));
}
if (this._config.selectionMode === "multiple-ranged") {
this._rangeStatus ??= document.createElement("span");
if (!popup.contains(this._rangeStatus)) {
this._rangeStatus.className = "visually-hidden";
this._rangeStatus.setAttribute("role", "status");
popup.append(this._rangeStatus);
}
this._updateRangeStatus();
}
this._syncThemeAttribute(popup);
}
_updateRangeStatus() {
const message = this._pendingRange ? this._config.rangeEndMessage : "";
if (this._rangeStatus && this._rangeStatus.textContent !== message) this._rangeStatus.textContent = message;
}
_updateDisplayWithSelectedDates() {
const selectedDates = this.getSelectedDates();
if (selectedDates.length > 0) this._syncSelectedDates(selectedDates);
}
_syncSelectedDates(selectedDates) {
this._setInputError("");
const formattedDate = this._formatDateForInput(selectedDates);
if (this._isInput) this._element.value = formattedDate;
if (this._boundInput) {
this._boundInput.value = selectedDates.join(",");
this._syncBoundInput();
}
this._syncDisplay(selectedDates, formattedDate);
}
_syncDisplay(selectedDates, formattedDate = this._formatDateForInput(selectedDates)) {
if (this._displayElement) {
const endPlaceholder = this._displayElement.dataset.bsDatepickerEndPlaceholder;
const partialRange = this._config.selectionMode === "multiple-ranged" && selectedDates.length === 1;
this._displayElement.textContent = partialRange && endPlaceholder ? `${formattedDate} – ${endPlaceholder}` : selectedDates.length ? formattedDate : this._displayPlaceholder;
}
}
_resolvePositionElement() {
let { positionElement } = this._config;
if (typeof positionElement === "string") positionElement = this._element.getRootNode().querySelector(positionElement);
if (!positionElement && this._isInput && !this._isInline) {
const parent = this._element.closest(".form-adorn");
if (parent) positionElement = parent;
}
return positionElement || this._element;
}
_resolveDisplayElement() {
const { displayElement } = this._config;
if (typeof displayElement === "string") return this._element.getRootNode().querySelector(displayElement);
if (displayElement === true || displayElement === null && !this._isInput && !this._isInline) return this._element.querySelector("[data-bs-datepicker-display]") || this._element;
return displayElement;
}
_getThemeAncestor() {
return this._element.closest("[data-bs-theme]");
}
_getEffectiveTheme() {
return this._config.datepickerTheme || this._getThemeAncestor()?.getAttribute("data-bs-theme") || null;
}
_syncThemeAttribute(element) {
if (!element) return;
const theme = this._getEffectiveTheme();
if (theme) element.setAttribute("data-bs-theme", theme);
else element.removeAttribute("data-bs-theme");
const computed = getComputedStyle(this._element);
element.dir = computed.direction;
const explicit = this._config.datepickerTheme;
element.style.colorScheme = explicit === "auto" ? "light dark" : explicit === "light" || explicit === "dark" ? explicit : computed.colorScheme;
if (!this._isInline) for (const prefix of ["", "bs-"]) for (const role of [
"base",
"bg",
"bg-subtle",
"bg-muted",
"fg",
"fg-emphasis",
"contrast",
"border",
"focus-ring"
]) {
const property = `--${prefix}theme-${role}`;
const value = computed.getPropertyValue(property);
if (value) element.style.setProperty(property, value);
else element.style.removeProperty(property);
}
}
_setupThemeObserver() {
this._themeObserver = new MutationObserver((records) => {
if (records.some((record) => {
if (!(record.target instanceof Element)) return false;
let node = this._element;
while (node) {
if (record.target.contains(node)) return true;
const root = node.getRootNode();
node = root instanceof ShadowRoot ? root.host : null;
}
return false;
})) this._syncThemeAttribute(this._popup ?? void 0);
});
const root = this._element.getRootNode();
const options = {
subtree: true,
attributes: true,
attributeFilter: [
"data-bs-theme",
"class",
"style",
"dir"
]
};
this._themeObserver.observe(document.documentElement, options);
if (root instanceof ShadowRoot) this._themeObserver.observe(root, options);
}
_setupDismiss() {
this._onKeydown = (event) => this._handleKeydown(event);
this._popup?.addEventListener("keydown", this._onKeydown, true);
if (this._isInline) return;
this._onTriggerClick = (event) => {
if (event.target instanceof Node && this._toggleElement?.contains(event.target)) return;
if (this._isInput) this.show(this._element);
else if (this._element.dataset.bsToggle !== NAME$14) this.toggle();
};
EventHandler.on(this._positionElement, EVENT_CLICK$4, this._onTriggerClick);
if (this._isInput) EventHandler.on(this._element, EVENT_FOCUSIN$3, () => this.show(this._element));
this._onOutside = (event) => {
if (!this._isShown) return;
if (!event.composedPath().some((node) => node instanceof Node && (this._positionElement.contains(node) || this._element.contains(node) || this._toggleElement?.contains(node) || this._popup?.contains(node)))) this.hide();
};
EventHandler.on(document, EVENT_FOCUSIN$3, this._onOutside);
EventHandler.on(document, EVENT_POINTERDOWN$2, this._onOutside);
EventHandler.on(this._element, EVENT_KEYDOWN$2, this._onKeydown);
if (this._toggleElement) {
this._onToggleClick = () => {
if (!isDisabled(this._toggleElement) && !this._toggleElement.matches(":disabled")) this.toggle(this._toggleElement);
};
EventHandler.on(this._toggleElement, EVENT_CLICK$4, this._onToggleClick);
EventHandler.on(this._toggleElement, EVENT_KEYDOWN$2, this._onKeydown);
}
}
_focusCalendarDate() {
for (const selector of [
"[data-vc-date-selected] [data-vc-date-btn]",
"[data-vc-date-today] [data-vc-date-btn]",
"[data-vc-date-btn][tabindex=\"0\"]",
"button"
]) {
const control = [...this._popup?.querySelectorAll(selector) || []].find((element) => !isDisabled(element) && isVisible(element));
if (control) {
control.focus();
return;
}
}
}
_focusTrigger() {
if (!this._element) return;
this._suppressFocus = true;
(this._returnFocusElement?.isConnected ? this._returnFocusElement : this._element).focus();
this._suppressFocus = false;
}
_handleKeydown(event) {
const { target } = event;
if (!this._isShown && !this._isInline || !(target instanceof Node) || !this._containsTrigger(target) && !this._popup?.contains(target)) return;
if (this._handleCalendarNavigation(event)) {
event.preventDefault();
event.stopPropagation();
return;
}
if (this._isInline) {
this._handleInlineEscape(event);
return;
}
if (event.key === "Escape") {
event.preventDefault();
event.stopPropagation();
this.hide();
if (!this._isShown) this._focusTrigger();
return;
}
if (event.key !== "Tab") return;
const controls = [...this._popup.querySelectorAll(FOCUSABLE)].filter((element) => element.tabIndex >= 0 && !isDisabled(element) && isVisible(element));
if (this._containsTrigger(target)) {
if (!event.shiftKey && controls[0]) {
event.preventDefault();
controls[0].focus();
} else this.hide();
return;
}
if (target === (event.shiftKey ? controls[0] : controls.at(-1))) {
this.hide();
if (this._isShown) event.preventDefault();
else {
this._focusTrigger();
if (event.shiftKey) event.preventDefault();
}
}
}
_handleInlineEscape(event) {
if (event.key !== "Escape" || !this._pendingRange) return;
event.preventDefault();
event.stopPropagation();
const date = event.target.closest("[data-vc-date]")?.dataset.vcDate;
this._cancelPendingRange();
const control = date && this._findCalendarDay(date);
if (control) this._focusDay(control);
else this._focusCalendarDate();
}
_findCalendarDay(date) {
return this._popup?.querySelector(`[data-vc-date="${date}"][data-vc-date-month="current"] [data-vc-date-btn]:not(:disabled)`) ?? null;
}
_focusDay(day) {
day.closest("[role=\"grid\"]")?.querySelectorAll("[data-vc-date-btn][tabindex=\"0\"]").forEach((control) => {
control.tabIndex = -1;
});
day.tabIndex = 0;
day.focus();
}
_handleCalendarNavigation(event) {
const { target } = event;
if (!this._calendar || !(target instanceof HTMLElement) || !target.matches("[data-vc-date-btn]") || event.altKey || event.ctrlKey || event.metaKey) return false;
const day = target.closest("[data-vc-date]");
const date = this._parseIsoDate(day?.dataset.vcDate || "");
if (!date) return false;
const { key } = event;
const page = key === "PageUp" || key === "PageDown";
const week = key === "Home" || key === "End";
if (!page && !week && !key.startsWith("Arrow")) return false;
const currentMonth = date.getMonth();
let direction;
if (page) {
direction = key === "PageUp" ? -1 : 1;
const dayOfMonth = date.getDate();
date.setDate(1);
date.setMonth(currentMonth + (event.shiftKey ? 12 : 1) * direction);
const monthEnd = new Date(date.getFullYear(), date.getMonth() + 1, 0).getDate();
date.setDate(Math.min(dayOfMonth, monthEnd));
} else if (week) {
const weekday = (date.getDay() - this._config.firstWeekday + 7) % 7;
date.setDate(date.getDate() + (key === "Home" ? -weekday : 6 - weekday));
direction = key === "Home" ? 1 : -1;
} else {
const rtl = this._popup?.dir === "rtl";
const step = {
ArrowLeft: rtl ? 1 : -1,
ArrowRight: rtl ? -1 : 1,
ArrowUp: -7,
ArrowDown: 7
}[key];
if (!step) return false;
date.setDate(date.getDate() + step);
if (date.getMonth() === currentMonth && day?.dataset.vcDateMonth === "current") return false;
direction = Math.sign(step);
}
this._focusNavigationDate(date, direction, target);
return true;
}
_focusNavigationDate(date, direction, target) {
const calendar = this._calendar;
const { displayDateMin, displayDateMax } = calendar.context;
let iso = this._toIsoDate(date);
if (iso < displayDateMin) iso = displayDateMin;
else if (iso > displayDateMax) iso = displayDateMax;
date = this._parseIsoDate(iso) || date;
const month = date.getMonth();
if (!this._findCalendarDay(iso) && (month !== calendar.context.selectedMonth || date.getFullYear() !== calendar.context.selectedYear)) calendar.set({
selectedMonth: month,
selectedYear: date.getFullYear(),
selectedDates: [...calendar.context.selectedDates]
});
let control = this._findCalendarDay(iso);
while (!control && date.getMonth() === month) {
date.setDate(date.getDate() + direction);
if (date.getMonth() === month) control = this._findCalendarDay(this._toIsoDate(date));
}
if (control) this._focusDay(control);
else if (!target.isConnected) this._focusCalendarDate();
}
_buildCalendarOptions() {
const theme = this._getEffectiveTheme();
const vcpTheme = !theme || theme === "auto" ? "system" : theme;
const displayMonthsCount = this._getDisplayMonths();
const calendarOptions = {
...this._config.vcpOptions,
extensions: [months],
inputMode: false,
positionToInput: this._config.placement,
firstWeekday: this._config.firstWeekday,
locale: this._config.vcpOptions.locale ?? this._config.locale,
selectionDatesMode: this._config.selectionMode,
selectedDates: this._config.selectedDates,
displayMonthsCount,
type: displayMonthsCount > 1 ? "multiple" : "default",
selectedTheme: vcpTheme,
themeAttrDetect: "[data-bs-theme]",
onClickDate: (self, event) => this._handleDateClick(self, event),
onInit: (self) => this._syncPopupState(self),
onUpdate: (self) => this._syncPopupState(self)
};
if (this._config.selectedDates.length > 0) {
const firstDate = this._parseIsoDate(this._config.selectedDates[0]);
if (!firstDate) throw new TypeError("Invalid ISO date");
calendarOptions.selectedMonth = firstDate.getMonth();
calendarOptions.selectedYear = firstDate.getFullYear();
}
if (this._config.dateMin) calendarOptions.dateMin = this._config.dateMin;
if (this._config.dateMax) calendarOptions.dateMax = this._config.dateMax;
return calendarOptions;
}
_normalizeRangeDates(self) {
if (this._config.selectionMode === "multiple-ranged" && self.context.selectedDates.length && !self.context.selectedDates[0]) self.context.selectedDates.length = 0;
}
_cancelPendingRange() {
if (!this._pendingRange || !this._calendar) return;
this._pendingRange = false;
this._calendar.set({ selectedDates: this._rangeDates }, {
month: false,
year: false
});
this._syncDisplay(this._rangeDates);
}
_handleDateClick(self, event) {
this._normalizeRangeDates(self);
const selectedDates = [...self.context.selectedDates];
if (this._config.selectionMode === "multiple-ranged") {
if (selectedDates.length === 1) {
this._pendingRange = true;
this._updateRangeStatus();
this._syncDisplay(selectedDates);
return;
}
if (this._pendingRange && selectedDates.length === 0) {
this._cancelPendingRange();
return;
}
this._pendingRange = false;
this._rangeDates = selectedDates;
this._updateRangeStatus();
}
this._syncSelectedDates(selectedDates);
EventHandler.trigger(this._element, EVENT_CHANGE$1, {
dates: selectedDates,
event
});
if (this._calendar && this._element) this._maybeHideAfterSelection(selectedDates);
}
_maybeHideAfterSelection(selectedDates) {
if (this._isInline) return;
if (this._config.selectionMode === "single" && selectedDates.length > 0 || this._config.selectionMode === "multiple-ranged" && selectedDates.length >= 2) {
const root = this._popup.getRootNode();
const wasInCalendar = this._popup?.contains(root.activeElement);
this.hide();
const active = root.activeElement;
if (!this._isShown && this._calendar && wasInCalendar && (active === document.body || this._popup?.contains(active))) this._focusTrigger();
}
}
_parseIsoDate(value) {
const parts = /^(\d{4})-(\d{2})-(\d{2})$/.exec(value);
if (!parts) return null;
const year = Number(parts[1]);
const month = Number(parts[2]) - 1;
const day = Number(parts[3]);
const date = /* @__PURE__ */ new Date(0);
date.setHours(0, 0, 0, 0);
date.setFullYear(year, month, day);
return date.getFullYear() === year && date.getMonth() === month && date.getDate() === day ? date : null;
}
_parseDate(value) {
return this._parseIsoDate(value) ?? /* @__PURE__ */ new Date(NaN);
}
_toIsoDate(date) {
return `${String(date.getFullYear()).padStart(4, "0")}-${String(date.getMonth() + 1).padStart(2, "0")}-${String(date.getDate()).padStart(2, "0")}`;
}
_formatDate(dateStr) {
const date = this._parseDate(dateStr);
const locale = this._config.locale === "default" ? void 0 : this._config.locale;
const { dateFormat } = this._config;
if (typeof dateFormat === "function") return dateFormat(date, locale);
if (dateFormat && typeof dateFormat === "object") return new Intl.DateTimeFormat(locale, dateFormat).format(date);
return date.toLocaleDateString(locale);
}
_formatDateForInput(dates) {
if (dates.length === 0) return "";
if (dates.length === 1) return this._formatDate(dates[0]);
const separator = this._config.selectionMode === "multiple-ranged" ? " – " : ", ";
return dates.map((d) => this._formatDate(d)).join(separator);
}
_setInputError(message) {
if (!this._isInput) return;
const input = this._element;
if (!input.validity.customError || input.validationMessage === this._inputErrorMessage) input.setCustomValidity(message);
this._inputErrorMessage = message;
if (!message && this._inputError) {
const descriptions = (input.getAttribute("aria-describedby") || "").split(/\s+/).filter((id) => id && id !== this._inputError.id);
if (descriptions.length) input.setAttribute("aria-describedby", descriptions.join(" "));
else input.removeAttribute("aria-describedby");
if (this._originalInvalid === null) input.removeAttribute("aria-invalid");
else input.setAttribute("aria-invalid", this._originalInvalid);
this._inputError.remove();
this._inputError = null;
}
}
_showInputError() {
if (!this._inputErrorMessage || this._inputError) return;
const error = document.createElement("div");
error.id = getUID("bs-datepicker-error-");
error.className = "form-text fg-danger";
error.setAttribute("role", "status");
this._positionElement.after(error);
error.textContent = this._inputErrorMessage;
this._inputError = error;
this._originalInvalid = this._element.getAttribute("aria-invalid");
this._element.setAttribute("aria-invalid", "true");
const describedBy = this._element.getAttribute("aria-describedby");
this._element.setAttribute("aria-describedby", describedBy ? `${describedBy} ${error.id}` : error.id);
}
_parseInputValue() {
this._pendingRange = false;
const value = this._element.value.trim();
let date = this._parseIsoDate(value);
if (!date && !/^\d{4}-/.test(value) && typeof this._config.dateFormat !== "function") {
const numbers = value.match(/\d+/g);
const locale = this._config.locale === "default" ? void 0 : this._config.locale;
const order = new Intl.DateTimeFormat(locale, this._config.dateFormat ?? void 0).formatToParts(new Date(2e3, 0, 1)).filter((part) => [
"year",
"month",
"day"
].includes(part.type));
if (numbers?.length === 3 && order.length === 3) {
const parts = Object.fromEntries(order.map((part, index) => [part.type, numbers[index]]));
if (parts.year.length === 4) {
const iso = `${parts.year}-${parts.month.padStart(2, "0")}-${parts.day.padStart(2, "0")}`;
const candidate = this._parseIsoDate(iso);
if (candidate && this._formatDate(iso) === value) date = candidate;
}
}
}
const dates = date && this._config.selectionMode !== "multiple-ranged" ? [this._toIsoDate(date)] : [];
this._calendar?.set({
selectedDates: dates,
...date ? {
selectedMonth: date.getMonth(),
selectedYear: date.getFullYear()
} : {}
});
if (dates.length && this._calendar) {
const button = this._popup?.querySelector(`[data-vc-date="${dates[0]}"] [data-vc-date-btn]`);
if (!button || isDisabled(button)) this._calendar.set({ selectedDates: [] });
}
this._rangeDates = [...this._calendar?.context.selectedDates || []];
this._setInputError(this._element.value && this.getSelectedDates().length === 0 ? this._config.invalidDateMessage : "");
this._syncBoundInput();
}
};
/**
* Data API implementation
*/
EventHandler.on(document, EVENT_CLICK_DATA_API$3, SELECTOR_DATA_TOGGLE$6, function(event) {
if (this.tagName === "INPUT" || this.dataset.bsInline === "true") return;
event.preventDefault();
Datepicker.getOrCreateInstance(this).toggle(this);
});
EventHandler.on(document, EVENT_FOCUSIN_DATA_API, SELECTOR_DATA_TOGGLE$6, function() {
if (this.tagName !== "INPUT") return;
Datepicker.getOrCreateInstance(this).show(this);
});
onDocumentReady(`DOMContentLoaded${EVENT_KEY$11}${DATA_API_KEY$6}`, () => {
const selector = [
`${SELECTOR_DATA_TOGGLE$6}[data-bs-inline="true"]`,
`${SELECTOR_DATA_TOGGLE$6}[data-bs-selected-dates]`,
`input${SELECTOR_DATA_TOGGLE$6}[value]:not([value=""])`,
`input${SELECTOR_DATA_TOGGLE$6}[data-bs-toggle-element]`
].join(", ");
for (const element of document.querySelectorAll(selector)) Datepicker.getOrCreateInstance(element);
});
//#endregion
//#region js/src/util/scroll-lock.ts
/**
* --------------------------------------------------------------------------
* Bootstrap util/scroll-lock.ts
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
* --------------------------------------------------------------------------
*/
const CLASS_NAME_OPEN = "dialog-open";
const SELECTOR_FIXED_CONTENT = ".fixed-top, .fixed-bottom, .is-fixed";
const owners = /* @__PURE__ */ new Map();
let restore = null;
let observer = null;
const getStyleChange = (element, property, offset) => {
const value = Number.parseFloat(getComputedStyle(element).getPropertyValue(property)) || 0;
return {
element,
property,
value: element.style.getPropertyValue(property),
priority: element.style.getPropertyPriority(property),
adjustedValue: `${value + offset}px`
};
};
const releaseUnusedLock = () => {
for (const [owner, onDetach] of owners) if (!owner.isConnected) {
owners.delete(owner);
if (onDetach) queueMicrotask(onDetach);
} else if (!owner.open) owners.delete(owner);
if (owners.size === 0 && restore) {
observer?.disconnect();
observer = null;
restore();
restore = null;
}
};
const lockScroll = (owner, onDetach) => {
releaseUnusedLock();
if (owners.has(owner)) return;
owners.set(owner, onDetach);
if (owners.size > 1) return;
const root = document.documentElement;
const alreadyLocked = root.classList.contains(CLASS_NAME_OPEN);
const initialWidth = root.offsetWidth;
const viewportWidth = root.clientWidth;
const initialLeft = root.getBoundingClientRect().left + root.clientLeft + window.scrollX;
const changes = [];
const fixed = SelectorEngine.find(SELECTOR_FIXED_CONTENT).filter((element) => !element.closest("dialog") && getComputedStyle(element).position === "fixed" && element.clientWidth >= viewportWidth).map((element) => ({
element,
width: element.offsetWidth
}));
root.classList.add(CLASS_NAME_OPEN);
const width = Math.max(0, root.offsetWidth - initialWidth);
const side = initialLeft > root.getBoundingClientRect().left + root.clientLeft + window.scrollX ? "left" : "right";
const fixedChanges = fixed.map((item) => ({
element: item.element,
width: Math.max(0, item.element.offsetWidth - item.width)
}));
if (width > 0) changes.push(getStyleChange(root, `padding-${side}`, width));
for (const item of fixedChanges) if (item.width > 0) changes.push(getStyleChange(item.element, `margin-${side}`, item.width));
for (const { element, property, adjustedValue } of changes) element.style.setProperty(property, adjustedValue, "important");
restore = () => {
for (const { element, property, value, priority } of changes) if (value) element.style.setProperty(property, value, priority);
else element.style.removeProperty(property);
if (!alreadyLocked) root.classList.remove(CLASS_NAME_OPEN);
};
observer = new MutationObserver(releaseUnusedLock);
observer.observe(root, {
childList: true,
subtree: true,
attributes: true,
attributeFilter: ["open"]
});
};
const unlockScroll = (owner) => {
owners.delete(owner);
releaseUnusedLock();
};
//#endregion
//#region js/src/dialog-base.ts
/**
* --------------------------------------------------------------------------
* Bootstrap dialog-base.ts
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
* --------------------------------------------------------------------------
*/
/**
* Class definition
*
* Shared base class for Dialog and Drawer components that use
* the native <dialog> element. Provides common behavior for:
* - Show/hide/toggle lifecycle with events
* - Opening/closing via showModal()/show()/close()
* - Escape key handling (modal and non-modal)
* - Backdrop click handling
* - Static backdrop transition ("bounce")
* - Body scroll prevention
* - Transition coordination
* - Child component cleanup (tooltips, popovers, toasts)
*/
var DialogBase = class extends BaseComponent {
constructor(element, config) {
super(element, config);
this._isTransitioning = false;
this._opening = false;
this._active = Boolean(this._element?.open);
this._openedAsModal = Boolean(this._element?.matches(":modal"));
this._operation = 0;
this._returnFocus = null;
this._closedBy = void 0;
this._cancelTransition = null;
this._addDialogListeners();
}
static get NAME() {
return "dialogbase";
}
toggle(relatedTarget) {
return this._element?.open ? this.hide() : this.show(relatedTarget);
}
async show(relatedTarget) {
if (!this._canShow(relatedTarget)) return;
await this._show(relatedTarget);
}
async hide() {
if (!this._canHide()) return;
await this._hide();
}
_canShow(relatedTarget) {
if (this._active && this._element?.isConnected && !this._element.open) {
unlockScroll(this._element);
this._finishHide();
}
if (!this._element?.isConnected || this._element.open || this._isTransitioning) return false;
return !EventHandler.trigger(this._element, this.constructor.eventName("show"), { relatedTarget }).defaultPrevented;
}
async _show(relatedTarget, returnFocus = relatedTarget) {
if (!this._element?.isConnected || this._element.open || this._isTransitioning) return;
const operation = ++this._operation;
this._isTransitioning = true;
this._opening = true;
this._active = true;
const previousFocus = this._element.ownerDocument.activeElement;
this._returnFocus = returnFocus === void 0 && previousFocus instanceof HTMLElement ? previousFocus : returnFocus ?? null;
this._onBeforeShow();
const { modal, preventBodyScroll } = this._getShowOptions();
this._showElement({
modal,
preventBodyScroll
});
if (!this._element || this._operation !== operation) return;
if (!this._element.open) {
this._clearOpenState();
this._active = false;
this._returnFocus = null;
this._isTransitioning = false;
this._opening = false;
return;
}
await this._queueLifecycle(() => {
if (this._operation !== operation || !this._element.open || !this._element.isConnected) return;
this._isTransitioning = false;
this._opening = false;
EventHandler.trigger(this._element, this.constructor.eventName("shown"), { relatedTarget });
}, this._isAnimated());
}
_canHide() {
if (!this._element?.open || this._isTransitioning && !this._opening) return false;
return !EventHandler.trigger(this._element, this.constructor.eventName("hide")).defaultPrevented;
}
async _hide(restoreFocus = true) {
if (!this._element?.open || this._isTransitioning && !this._opening) return;
const operation = ++this._operation;
this._cancelTransition?.();
this._isTransitioning = true;
this._opening = false;
if (!restoreFocus) this._returnFocus = null;
this._hideElement();
await this._queueLifecycle(() => {
if (this._operation === operation) {
this._closeAndCleanup();
if (this._element && !this._element.open && this._operation === operation) this._finishHide();
}
}, this._shouldDeferClose());
}
dispose() {
if (!this._element) return;
this._cancelTransition?.();
if (this._element.open) {
this._hideChildComponents();
this._closeAndCleanup();
}
if (!this._element) return;
unlockScroll(this._element);
this._clearOpenState();
EventHandler.off(this._element, "cancel", this._cancelHandler);
EventHandler.off(this._element, "close", this._closeHandler);
EventHandler.off(this._element, "toggle", this._toggleHandler);
super.dispose();
}
_getShowOptions() {
return {
modal: true,
preventBodyScroll: true
};
}
_onBeforeShow() {}
_onAfterHide() {}
_isAnimated() {
return !this._element.classList.contains(this._getInstantClassName());
}
_getInstantClassName() {
return "dialog-instant";
}
_getStaticClassName() {
return "dialog-static";
}
_onCancel() {}
_showElement({ modal = true, preventBodyScroll = true } = {}) {
this._openedAsModal = modal;
this._closedBy = this._element.getAttribute("closedby");
this._element.setAttribute("closedby", modal && this._config.keyboard ? "closerequest" : "none");
this._element.classList.toggle("dialog-no-backdrop", !this._config.backdrop);
if (modal) this._element.showModal();
else this._element.show();
if (preventBodyScroll && this._element?.open) {
const element = this._element;
lockScroll(element, () => {
if (this._element === element && this._active && !element.isConnected) {
this._hideChildComponents();
this._closeAndCleanup();
this._finishHide();
}
});
}
}
_hideElement() {
this._hideChildComponents();
this._element.classList.add("hiding");
}
_closeAndCleanup() {
const element = this._element;
element.close();
unlockScroll(element);
}
_clearOpenState() {
this._openedAsModal = false;
this._element.classList.remove("hiding", "dialog-no-backdrop", this._getStaticClassName());
if (this._closedBy === null) this._element.removeAttribute("closedby");
else if (this._closedBy !== void 0) this._element.setAttribute("closedby", this._closedBy);
this._closedBy = void 0;
this._onAfterHide();
}
_finishHide() {
const element = this._element;
const trigger = this._returnFocus;
const { activeElement, body } = element.ownerDocument;
const restoreFocus = activeElement === body || element.contains(activeElement);
this._cancelTransition?.();
this._clearOpenState();
this._active = false;
this._returnFocus = null;
this._isTransitioning = false;
this._opening = false;
this._operation++;
if (trigger && restoreFocus && isVisible(trigger)) trigger.focus({ preventScroll: true });
EventHandler.trigger(element, this.constructor.eventName("hidden"));
}
_queueLifecycle(callback, animated) {
if (!animated) {
callback();
return Promise.resolve();
}
return new Promise((resolve) => {
const cancel = executeAfterTransition(() => {
this._cancelTransition = null;
callback();
resolve();
}, this._element);
this._cancelTransition = () => {
cancel?.();
this._cancelTransition = null;
resolve();
};
});
}
_shouldDeferClose() {
return false;
}
_triggerBackdropTransition() {
if (EventHandler.trigger(this._element, this.constructor.eventName("hidePrevented")).defaultPrevented) return;
const staticClass = this._getStaticClassName();
this._element.classList.add(staticClass);
this._queueCallback(() => {
this._element.classList.remove(staticClass);
}, this._element);
}
_hideChildComponents() {
for (const el of SelectorEngine.find("[data-bs-toggle=\"tooltip\"], [data-bs-toggle=\"popover\"], [data-bs-toggle=\"datepicker\"]", this._element)) {
const instance = data_default.get(el, `bs.${el.getAttribute("data-bs-toggle")}`);
if (instance && typeof instance.hide === "function") instance.hide();
}
for (const el of SelectorEngine.find(".toast.show", this._element)) {
const instance = data_default.get(el, "bs.toast");
if (instance && typeof instance.hide === "function") instance.hide();
}
}
_addDialogListeners() {
if (!this._element) return;
const eventKey = this.constructor.EVENT_KEY;
this._closeHandler = () => {
if (!this._element.open) {
unlockScroll(this._element);
if (this._active) {
this._hideChildComponents();
this._finishHide();
}
}
};
EventHandler.on(this._element, "close", this._closeHandler);
this._toggleHandler = () => {
if (this._element.open && !this._active) {
this._active = true;
this._openedAsModal = this._element.matches(":modal");
}
};
EventHandler.on(this._element, "toggle", this._toggleHandler);
this._cancelHandler = (event) => {
if (event.target !== this._element) return;
event.preventDefault();
if (!this._config.keyboard) {
this._triggerBackdropTransition();
return;
}
this._onCancel();
this.hide();
};
EventHandler.on(this._element, "cancel", this._cancelHandler);
EventHandler.on(this._element, `keydown${eventKey}`, (event) => {
if (event.key !== "Escape" || event.defaultPrevented || !this._element.open || event.target.closest("dialog") !== this._element) return;
if (this._openedAsModal && this._config.keyboard) return;
event.preventDefault();
if (!this._config.keyboard) {
if (this._openedAsModal) this._triggerBackdropTransition();
return;
}
this._onCancel();
this.hide();
});
const isOutside = (event) => {
const { left, right, top, bottom } = this._element.getBoundingClientRect();
return event.clientX < left || event.clientX >= right || event.clientY < top || event.clientY >= bottom;
};
let backdropPress = false;
EventHandler.on(this._element, `pointerdown${eventKey}`, (event) => {
backdropPress = event.button === 0 && event.target === this._element && isOutside(event);
});
EventHandler.on(this._element, `pointercancel${eventKey}`, () => {
backdropPress = false;
});
EventHandler.on(this._element, `click${eventKey}`, (event) => {
const startedOutside = backdropPress;
backdropPress = false;
if (!startedOutside || !event.detail || event.target !== this._element || !this._openedAsModal || !isOutside(event)) return;
if (this._config.backdrop === false) return;
if (this._config.backdrop === "static") {
this._triggerBackdropTransition();
return;
}
this.hide();
});
}
};
//#endregion
//#region js/src/dialog.ts
/**
* --------------------------------------------------------------------------
* Bootstrap dialog.ts
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
* --------------------------------------------------------------------------
*/
/**
* Constants
*/
const NAME$13 = "dialog";
const EVENT_KEY$10 = `.bs.dialog`;
const DATA_API_KEY$5 = ".data-api";
const EVENT_CANCEL = `cancel${EVENT_KEY$10}`;
const EVENT_CLICK_DATA_API$2 = `click${EVENT_KEY$10}${DATA_API_KEY$5}`;
const CLASS_NAME_NONMODAL = "dialog-nonmodal";
const CLASS_NAME_INSTANT$1 = "dialog-instant";
const CLASS_NAME_SWAP_IN = "dialog-swap-in";
const SELECTOR_DATA_TOGGLE$5 = "[data-bs-toggle=\"dialog\"]";
const Default$12 = {
backdrop: true,
keyboard: true,
modal: true
};
const DefaultType$12 = {
backdrop: "(boolean|string)",
keyboard: "boolean",
modal: "boolean"
};
/**
* Class definition
*/
var Dialog = class Dialog extends DialogBase {
constructor(element, config) {
super(element, config);
}
static get Default() {
return Default$12;
}
static get DefaultType() {
return DefaultType$12;
}
static get NAME() {
return NAME$13;
}
static {
EventHandler.on(document, EVENT_CLICK_DATA_API$2, SELECTOR_DATA_TOGGLE$5, function(event) {
Dialog._handleDataApiClick(this, event);
});
}
static _handleDataApiClick(trigger, event) {
const target = SelectorEngine.getElementFromSelector(trigger);
if (!(target instanceof HTMLDialogElement) || isDisabled(trigger)) return;
if (["A", "AREA"].includes(trigger.tagName)) event.preventDefault();
const config = Manipulator.getDataAttributes(trigger);
const currentDialog = trigger.closest("dialog.dialog[open]");
if (currentDialog === target) return;
if (!(currentDialog && currentDialog !== target)) {
Dialog.getOrCreateInstance(target, config).toggle(trigger);
return;
}
if (currentDialog.classList.contains(CLASS_NAME_SWAP_IN)) return;
const newDialog = Dialog.getOrCreateInstance(target, config);
const currentInstance = Dialog.getOrCreateInstance(currentDialog);
if (!newDialog._canShow(trigger) || !currentInstance._canHide()) return;
const returnFocus = currentInstance._returnFocus;
const wasInstant = currentDialog.classList.contains(CLASS_NAME_INSTANT$1);
target.classList.add(CLASS_NAME_SWAP_IN);
newDialog._show(trigger, returnFocus).finally(() => {
target.classList.remove(CLASS_NAME_SWAP_IN);
});
if (target.open) {
currentDialog.classList.add(CLASS_NAME_INSTANT$1);
currentInstance._hide(false).finally(() => {
if (!wasInstant) currentDialog.classList.remove(CLASS_NAME_INSTANT$1);
});
}
}
handleUpdate() {}
_getShowOptions() {
return {
modal: this._config.modal,
preventBodyScroll: this._config.modal
};
}
_onBeforeShow() {
if (!this._config.modal) this._element.classList.add(CLASS_NAME_NONMODAL);
}
_onAfterHide() {
this._element.classList.remove(CLASS_NAME_NONMODAL);
}
_shouldDeferClose() {
return this._isAnimated();
}
_onCancel() {
EventHandler.trigger(this._element, EVENT_CANCEL);
}
};
/**
* Data API implementation
*/
enableDismissTrigger(Dialog);
//#endregion
//#region js/src/util/sanitizer.ts
const ARIA_ATTRIBUTE_PATTERN = /^aria-[\w-]*$/i;
const DefaultAllowlist = {
"*": [
"class",
"dir",
"id",
"lang",
"role",
ARIA_ATTRIBUTE_PATTERN
],
a: [
"target",
"href",
"title",
"rel"
],
area: [],
b: [],
br: [],
col: [],
code: [],
dd: [],
div: [],
dl: [],
dt: [],
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: []
};
/**
* Allowlist for icon HTML options (NavOverflow `moreIcon`,
* and markup supplied via `[data-bs-overflow-icon]`). Covers the default SVG
* icons plus common inline-icon markup. Event-handler attributes and tags not
* listed here are stripped by `sanitizeHtml`.
*/
const DefaultIconAllowlist = {
"*": [
"class",
"role",
ARIA_ATTRIBUTE_PATTERN
],
svg: [
"xmlns",
"width",
"height",
"viewbox",
"fill",
"stroke",
"stroke-width",
"stroke-linecap",
"stroke-linejoin",
"focusable"
],
path: [
"d",
"fill",
"stroke",
"stroke-width",
"fill-rule",
"clip-rule"
],
line: [
"x1",
"y1",
"x2",
"y2",
"stroke",
"stroke-width",
"stroke-linecap"
],
circle: [
"cx",
"cy",
"r",
"fill",
"stroke",
"stroke-width"
],
rect: [
"x",
"y",
"width",
"height",
"rx",
"ry",
"fill",
"stroke",
"stroke-width"
],
polyline: [
"points",
"fill",
"stroke",
"stroke-width"
],
polygon: [
"points",
"fill",
"stroke",
"stroke-width"
],
g: [
"fill",
"stroke",
"stroke-width",
"transform"
],
span: [],
i: []
};
const uriAttributes = /* @__PURE__ */ new Set([
"background",
"cite",
"href",
"itemtype",
"longdesc",
"poster",
"src",
"xlink:href"
]);
/**
* A pattern that recognizes URLs that are safe wrt. XSS in URL navigation
* contexts.
*
* Shout-out to Angular https://github.com/angular/angular/blob/15.2.8/packages/core/src/sanitization/url_sanitizer.ts#L38
*/
const SAFE_URL_PATTERN = /^(?!(?:javascript|data|vbscript):)(?:[a-z0-9+.-]+:|[^&:/?#]*(?:[/?#]|$))/i;
/**
* A pattern that matches safe data URLs. Only matches image, video and audio
* types — notably NOT `data:text/html`, which is an XSS vector.
*
* Shout-out to Angular https://github.com/angular/angular/blob/15.2.8/packages/core/src/sanitization/url_sanitizer.ts#L49
*/
const DATA_URL_PATTERN = /^data:(?:image\/(?:bmp|gif|jpeg|jpg|png|tiff|webp)|video\/(?:mpeg|mp4|ogg|webm)|audio\/(?:mp3|oga|ogg|opus));base64,[\d+/a-z=]+$/i;
const allowedAttribute = (attribute, allowedAttributeList) => {
const attributeName = attribute.nodeName.toLowerCase();
if (allowedAttributeList.includes(attributeName)) {
if (uriAttributes.has(attributeName)) return Boolean(SAFE_URL_PATTERN.test(attribute.nodeValue) || DATA_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 createdDocument = new window.DOMParser().parseFromString(unsafeHtml, "text/html");
const elements = [...createdDocument.body.querySelectorAll("*")];
for (const element of elements) {
const elementName = element.nodeName.toLowerCase();
if (!Object.keys(allowList).includes(elementName)) {
element.remove();
continue;
}
const attributeList = [...element.attributes];
const allowedAttributes = [...allowList["*"] || [], ...allowList[elementName] || []];
for (const attribute of attributeList) if (!allowedAttribute(attribute, allowedAttributes)) element.removeAttribute(attribute.nodeName);
}
return createdDocument.body.innerHTML;
}
//#endregion
//#region js/src/nav-overflow.ts
/**
* --------------------------------------------------------------------------
* Bootstrap nav-overflow.ts
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
* --------------------------------------------------------------------------
*/
/**
* Constants
*/
const NAME$12 = "navoverflow";
const EVENT_KEY$9 = `.bs.navoverflow`;
const EVENT_UPDATE = `update${EVENT_KEY$9}`;
const EVENT_OVERFLOW = `overflow${EVENT_KEY$9}`;
const EVENT_RESIZE$2 = `resize${EVENT_KEY$9}`;
const CLASS_NAME_OVERFLOW = "nav-overflow";
const CLASS_NAME_OVERFLOW_MENU = "nav-overflow-menu";
const CLASS_NAME_HIDDEN = "d-none";
const CLASS_NAME_KEEP = "nav-overflow-keep";
const CLASS_NAME_INITIALIZED = "nav-overflow-initialized";
const CLASS_NAME_SUBMENU = "submenu";
const CLASS_NAME_SHOW$3 = "show";
const SELECTOR_NAV = ".nav";
const SELECTOR_NAV_ITEM = ".nav-item";
const SELECTOR_NAV_LINK = ".nav-link";
const SELECTOR_OVERFLOW_TOGGLE = ".nav-overflow-toggle";
const SELECTOR_OVERFLOW_MENU = ".nav-overflow-menu";
const SELECTOR_CUSTOM_ICON = "[data-bs-overflow-icon]";
const SELECTOR_MENU$1 = ".menu";
const SELECTOR_MENU_TOGGLE$2 = "[data-bs-toggle=\"menu\"]";
const DEFAULT_TEXT = "More";
const Default$11 = {
collapseBelow: 0,
iconPlacement: "start",
menuPlacement: "bottom-end",
menuStrategy: "absolute",
moreText: DEFAULT_TEXT,
moreIcon: "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"16\" height=\"16\" fill=\"currentColor\" viewBox=\"0 0 16 16\"><path d=\"M3 9.5a1.5 1.5 0 1 1 0-3 1.5 1.5 0 0 1 0 3m5 0a1.5 1.5 0 1 1 0-3 1.5 1.5 0 0 1 0 3m5 0a1.5 1.5 0 1 1 0-3 1.5 1.5 0 0 1 0 3\"/></svg>",
threshold: 0
};
const DefaultType$11 = {
collapseBelow: "(number|string)",
iconPlacement: "string",
menuPlacement: "string",
menuStrategy: "string",
moreText: "(string|boolean)",
moreIcon: "string",
threshold: "number"
};
/**
* Class definition
*/
var NavOverflow = class extends BaseComponent {
constructor(element, config) {
super(element, config);
const nav = SelectorEngine.findOne(SELECTOR_NAV, this._element);
if (!nav) throw new TypeError(`${this._element.outerHTML} has no child ${SELECTOR_NAV} to collapse`);
this._nav = nav;
this._items = [];
this._overflowItems = [];
this._overflowMenu = null;
this._overflowToggle = null;
this._resizeObserver = null;
this._resizeHandler = null;
this._collapseBelow = 0;
this._itemMenus = /* @__PURE__ */ new Map();
this._relocatedMenus = /* @__PURE__ */ new Map();
this._init();
}
static get Default() {
return Default$11;
}
static get DefaultType() {
return DefaultType$11;
}
static get NAME() {
return NAME$12;
}
update() {
this._calculateOverflow();
EventHandler.trigger(this._element, EVENT_UPDATE);
}
dispose() {
if (this._resizeObserver) this._resizeObserver.disconnect();
if (this._resizeHandler) EventHandler.off(window, EVENT_RESIZE$2, this._resizeHandler);
this._restoreItems();
if (this._overflowToggle && this._overflowToggle.parentElement) this._overflowToggle.parentElement.remove();
super.dispose();
}
_init() {
this._element.classList.add(CLASS_NAME_OVERFLOW);
this._items = SelectorEngine.find(SELECTOR_NAV_ITEM, this._nav).filter((item) => !item.querySelector(SELECTOR_OVERFLOW_TOGGLE));
for (const [index, item] of this._items.entries()) {
item.dataset.bsNavOrder = index;
const link = SelectorEngine.findOne(SELECTOR_NAV_LINK, item);
if (link?.matches(SELECTOR_MENU_TOGGLE$2)) this._findItemMenu(item, link);
}
this._collapseBelow = this._resolveCollapseBelow();
this._createOverflowMenu();
this._setupResizeObserver();
this._calculateOverflow();
this._element.classList.add(CLASS_NAME_INITIALIZED);
}
_createOverflowMenu() {
this._overflowToggle = SelectorEngine.findOne(SELECTOR_OVERFLOW_TOGGLE, this._element);
if (this._overflowToggle) {
this._overflowMenu = SelectorEngine.findOne(SELECTOR_OVERFLOW_MENU, this._element);
return;
}
const { moreText } = this._config;
const label = typeof moreText === "string" ? moreText : "";
const overflowItem = document.createElement("li");
overflowItem.className = "nav-item nav-overflow-item";
const button = document.createElement("button");
button.type = "button";
button.className = "nav-link nav-overflow-toggle";
button.setAttribute("data-bs-toggle", "menu");
button.setAttribute("data-bs-placement", this._config.menuPlacement);
button.setAttribute("data-bs-strategy", this._config.menuStrategy);
button.setAttribute("aria-expanded", "false");
if (label === "") button.setAttribute("aria-label", DEFAULT_TEXT);
const iconSpan = document.createElement("span");
iconSpan.className = "nav-overflow-icon";
iconSpan.innerHTML = sanitizeHtml(this._resolveIcon(), DefaultIconAllowlist);
if (label === "") button.append(iconSpan);
else {
const textSpan = document.createElement("span");
textSpan.className = "nav-overflow-text";
textSpan.textContent = label;
if (this._config.iconPlacement === "end") button.append(textSpan, iconSpan);
else button.append(iconSpan, textSpan);
}
const menu = document.createElement("div");
menu.className = `${CLASS_NAME_OVERFLOW_MENU} menu`;
overflowItem.append(button, menu);
this._nav.append(overflowItem);
this._overflowToggle = button;
this._overflowMenu = menu;
}
_resolveIcon() {
const customIconElement = SelectorEngine.findOne(SELECTOR_CUSTOM_ICON, this._element);
if (!customIconElement) return this._config.moreIcon;
const iconClone = customIconElement.cloneNode(true);
iconClone.removeAttribute("data-bs-overflow-icon");
const iconHtml = iconClone.outerHTML;
customIconElement.remove();
return iconHtml;
}
_resolveCollapseBelow() {
const value = this._config.collapseBelow;
if (typeof value === "number") return value;
if (typeof value === "string" && value !== "") {
const cssValue = getComputedStyle(document.documentElement).getPropertyValue(`--bs-breakpoint-${value}`);
return Number.parseFloat(cssValue) || 0;
}
return 0;
}
_setupResizeObserver() {
if (typeof ResizeObserver === "undefined") {
this._resizeHandler = () => this._calculateOverflow();
EventHandler.on(window, EVENT_RESIZE$2, this._resizeHandler);
return;
}
this._resizeObserver = new ResizeObserver(() => {
this._calculateOverflow();
});
this._resizeObserver.observe(this._element);
}
_availableWidth() {
const { paddingInlineStart, paddingInlineEnd } = getComputedStyle(this._element);
const padding = (Number.parseFloat(paddingInlineStart) || 0) + (Number.parseFloat(paddingInlineEnd) || 0);
return this._element.clientWidth - padding;
}
_navGap() {
return Number.parseFloat(getComputedStyle(this._nav).columnGap) || 0;
}
_calculateOverflow() {
this._restoreItems();
const availableWidth = this._availableWidth();
const overflowItem = this._overflowToggle?.closest(SELECTOR_NAV_ITEM) ?? null;
const candidates = this._items.filter((item) => !item.classList.contains(CLASS_NAME_KEEP));
if (this._collapseBelow > 0 && availableWidth < this._collapseBelow) {
this._applyOverflow(candidates, overflowItem);
return;
}
const gap = this._navGap();
const widthOf = (items) => items.reduce((sum, item) => sum + item.offsetWidth + gap, 0);
const space = availableWidth - widthOf(this._items.filter((item) => item.classList.contains(CLASS_NAME_KEEP))) + gap;
if (widthOf(candidates) <= space + 1) {
this._applyOverflow([], overflowItem);
return;
}
const limit = space - (overflowItem ? overflowItem.offsetWidth + gap : 0);
let usedWidth = 0;
let itemsToOverflow = [];
for (const item of candidates) {
usedWidth += item.offsetWidth + gap;
if (usedWidth > limit + 1) itemsToOverflow.push(item);
}
if (this._items.length - itemsToOverflow.length < this._config.threshold && this._items.length > this._config.threshold) itemsToOverflow = this._items.slice(this._config.threshold).filter((item) => !item.classList.contains(CLASS_NAME_KEEP));
this._applyOverflow(itemsToOverflow, overflowItem);
}
_applyOverflow(items, overflowItem) {
this._moveToOverflow(items);
overflowItem?.classList.toggle(CLASS_NAME_HIDDEN, items.length === 0);
if (items.length > 0) EventHandler.trigger(this._element, EVENT_OVERFLOW, {
overflowCount: items.length,
visibleCount: this._items.length - items.length
});
}
_moveToOverflow(items) {
if (!this._overflowMenu) return;
this._overflowMenu.replaceChildren();
this._overflowItems = [];
for (const item of items) {
const link = SelectorEngine.findOne(SELECTOR_NAV_LINK, item);
if (!link) continue;
const menu = this._findItemMenu(item, link);
if (menu && link.matches(SELECTOR_MENU_TOGGLE$2)) this._overflowMenu.append(this._relocateAsSubmenu(item, link, menu));
else this._overflowMenu.append(this._cloneAsMenuItem(link));
item.classList.add(CLASS_NAME_HIDDEN);
item.dataset.bsNavOverflow = "true";
this._overflowItems.push(item);
}
}
_relocateAsSubmenu(item, link, menu) {
this._resetMenu(link, menu);
item.classList.remove(CLASS_NAME_SHOW$3);
this._relocatedMenus.set(item, {
menu,
parent: menu.parentNode,
nextSibling: menu.nextSibling
});
const submenu = document.createElement("div");
submenu.className = CLASS_NAME_SUBMENU;
submenu.append(this._cloneAsMenuItem(link, true), menu);
return submenu;
}
_cloneAsMenuItem(link, submenu = false) {
const clonedLink = link.cloneNode(true);
clonedLink.className = "menu-item";
clonedLink.removeAttribute("id");
if (link.classList.contains("active")) clonedLink.classList.add("active");
if (link.classList.contains("disabled") || link.hasAttribute("disabled")) clonedLink.classList.add("disabled");
if (submenu) {
for (const name of clonedLink.getAttributeNames()) if (name.startsWith("data-bs-") && name !== "data-bs-theme") clonedLink.removeAttribute(name);
clonedLink.removeAttribute("href");
clonedLink.setAttribute("aria-haspopup", "true");
clonedLink.setAttribute("aria-expanded", "false");
if (clonedLink.tagName === "A") {
clonedLink.setAttribute("role", "button");
if (!clonedLink.hasAttribute("tabindex")) clonedLink.setAttribute("tabindex", "0");
}
}
return clonedLink;
}
_findItemMenu(item, link) {
const sibling = SelectorEngine.next(link, SELECTOR_MENU$1)[0];
if (sibling && !sibling.classList.contains(CLASS_NAME_OVERFLOW_MENU)) {
this._itemMenus.set(item, sibling);
return sibling;
}
const nested = SelectorEngine.findOne(SELECTOR_MENU$1, item);
if (nested && !nested.classList.contains(CLASS_NAME_OVERFLOW_MENU)) {
this._itemMenus.set(item, nested);
return nested;
}
const cached = this._itemMenus.get(item);
if (cached?.isConnected) return cached;
this._itemMenus.delete(item);
return null;
}
_resetMenu(toggle, menu) {
Menu.getInstance(toggle)?.dispose();
toggle.classList.remove(CLASS_NAME_SHOW$3);
toggle.setAttribute("aria-expanded", "false");
toggle.parentElement?.classList.remove(CLASS_NAME_SHOW$3);
menu.classList.remove(CLASS_NAME_SHOW$3);
}
_restoreRelocatedMenus() {
for (const { menu, parent, nextSibling } of this._relocatedMenus.values()) if (nextSibling) nextSibling.before(menu);
else parent.append(menu);
this._relocatedMenus.clear();
}
_restoreItems() {
if (this._overflowToggle && this._overflowMenu) {
this._resetMenu(this._overflowToggle, this._overflowMenu);
this._overflowToggle.closest(SELECTOR_NAV_ITEM)?.classList.remove(CLASS_NAME_SHOW$3);
}
this._restoreRelocatedMenus();
for (const item of this._items) {
item.classList.remove(CLASS_NAME_HIDDEN);
delete item.dataset.bsNavOverflow;
}
this._overflowToggle?.closest(SELECTOR_NAV_ITEM)?.classList.remove(CLASS_NAME_HIDDEN);
this._overflowMenu?.replaceChildren();
this._overflowItems = [];
}
};
/**
* Data API implementation
*/
onDocumentReady("DOMContentLoaded", () => {
for (const element of SelectorEngine.find("[data-bs-toggle=\"nav-overflow\"]")) NavOverflow.getOrCreateInstance(element);
});
//#endregion
//#region js/src/util/swipe.ts
/**
* --------------------------------------------------------------------------
* Bootstrap util/swipe.ts
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
* --------------------------------------------------------------------------
*/
/**
* Constants
*/
const NAME$11 = "swipe";
const EVENT_KEY$8 = ".bs.swipe";
const EVENT_TOUCHSTART = `touchstart${EVENT_KEY$8}`;
const EVENT_TOUCHMOVE = `touchmove${EVENT_KEY$8}`;
const EVENT_TOUCHEND = `touchend${EVENT_KEY$8}`;
const EVENT_TOUCHCANCEL = `touchcancel${EVENT_KEY$8}`;
const EVENT_POINTERDOWN$1 = `pointerdown${EVENT_KEY$8}`;
const EVENT_POINTERUP$1 = `pointerup${EVENT_KEY$8}`;
const EVENT_POINTERCANCEL = `pointercancel${EVENT_KEY$8}`;
const POINTER_TYPE_TOUCH = "touch";
const POINTER_TYPE_PEN = "pen";
const CLASS_NAME_POINTER_EVENT = "pointer-event";
const SWIPE_THRESHOLD = 40;
const Default$10 = {
endCallback: null,
leftCallback: null,
rightCallback: null,
upCallback: null,
downCallback: null
};
const DefaultType$10 = {
endCallback: "(function|null)",
leftCallback: "(function|null)",
rightCallback: "(function|null)",
upCallback: "(function|null)",
downCallback: "(function|null)"
};
/**
* Class definition
*/
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._deltaY = 0;
this._pointerId = null;
this._touchStart = null;
this._supportPointerEvents = Boolean(window.PointerEvent);
this._initEvents();
}
static get Default() {
return Default$10;
}
static get DefaultType() {
return DefaultType$10;
}
static get NAME() {
return NAME$11;
}
dispose() {
EventHandler.off(this._element, EVENT_KEY$8);
this._element?.classList.remove(CLASS_NAME_POINTER_EVENT);
}
_start(event) {
if (!this._supportPointerEvents) {
this._touchStart = event.touches.length === 1 ? event.touches[0] : null;
this._deltaX = 0;
this._deltaY = 0;
return;
}
if (this._eventIsPointerPenTouch(event)) {
this._pointerId = event.pointerId;
this._deltaX = event.clientX;
this._deltaY = event.clientY;
}
}
_end(event) {
if (this._supportPointerEvents) {
if (!this._eventIsPointerPenTouch(event) || this._pointerId !== event.pointerId) return;
this._pointerId = null;
this._deltaX = event.clientX - this._deltaX;
this._deltaY = event.clientY - this._deltaY;
} else if (!this._touchStart) return;
this._touchStart = null;
this._handleSwipe();
execute(this._config.endCallback);
}
_move(event) {
if (event.touches.length !== 1) this._touchStart = null;
if (!this._touchStart) return;
this._deltaX = event.touches[0].clientX - this._touchStart.clientX;
this._deltaY = event.touches[0].clientY - this._touchStart.clientY;
}
_handleSwipe() {
const absDeltaX = Math.abs(this._deltaX);
const absDeltaY = Math.abs(this._deltaY);
if (absDeltaY > absDeltaX && absDeltaY > SWIPE_THRESHOLD) {
const direction = this._deltaY > 0 ? "down" : "up";
this._deltaX = 0;
this._deltaY = 0;
execute(direction === "down" ? this._config.downCallback : this._config.upCallback);
return;
}
if (absDeltaX > SWIPE_THRESHOLD) {
const direction = absDeltaX / this._deltaX;
this._deltaX = 0;
this._deltaY = 0;
if (!direction) return;
execute(direction > 0 ? this._config.rightCallback : this._config.leftCallback);
return;
}
this._deltaX = 0;
this._deltaY = 0;
}
_initEvents() {
if (this._supportPointerEvents) {
EventHandler.on(this._element, EVENT_POINTERDOWN$1, (event) => this._start(event));
EventHandler.on(this._element, EVENT_POINTERUP$1, (event) => this._end(event));
EventHandler.on(this._element, EVENT_POINTERCANCEL, (event) => {
if (this._pointerId === event.pointerId) this._pointerId = null;
});
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));
EventHandler.on(this._element, EVENT_TOUCHCANCEL, () => {
this._touchStart = null;
});
}
}
_eventIsPointerPenTouch(event) {
return this._supportPointerEvents && (event.pointerType === POINTER_TYPE_PEN || event.pointerType === POINTER_TYPE_TOUCH);
}
static isSupported() {
return "ontouchstart" in document.documentElement || navigator.maxTouchPoints > 0;
}
};
//#endregion
//#region js/src/drawer.ts
/**
* --------------------------------------------------------------------------
* Bootstrap drawer.ts
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
* --------------------------------------------------------------------------
*/
/**
* Constants
*/
const NAME$10 = "drawer";
const EVENT_KEY$7 = `.bs.drawer`;
const DATA_API_KEY$4 = ".data-api";
const EVENT_LOAD_DATA_API$2 = `load${EVENT_KEY$7}${DATA_API_KEY$4}`;
const EVENT_RESIZE$1 = `resize${EVENT_KEY$7}`;
const EVENT_CLICK_DATA_API$1 = `click${EVENT_KEY$7}${DATA_API_KEY$4}`;
const SELECTOR_DATA_TOGGLE$4 = "[data-bs-toggle=\"drawer\"]";
const SELECTOR_RESPONSIVE = "dialog[class*=\"\\:drawer\"]";
const SELECTOR_OPEN = "dialog.drawer[open], dialog[open][class*=\"\\:drawer\"]";
const SELECTOR_RESIZE = `${SELECTOR_OPEN}, ${SELECTOR_RESPONSIVE}`;
const inlineAttributes = /* @__PURE__ */ new WeakMap();
const drawerIsInline = (element) => element.matches(SELECTOR_RESPONSIVE) && getComputedStyle(element).getPropertyValue("--drawer-inline").trim() === "1";
const syncInlineSemantics = (element, inline) => {
const saved = inlineAttributes.get(element);
if (inline && !saved) {
const attributes = /* @__PURE__ */ new Map();
for (const name of [
"role",
"aria-label",
"aria-labelledby",
"aria-describedby",
"aria-modal"
]) {
attributes.set(name, element.getAttribute(name));
element.removeAttribute(name);
}
element.setAttribute("role", "presentation");
inlineAttributes.set(element, attributes);
} else if (!inline && saved) {
for (const [name, value] of saved) if (value === null) element.removeAttribute(name);
else element.setAttribute(name, value);
inlineAttributes.delete(element);
}
};
const Default$9 = {
backdrop: true,
keyboard: true,
scroll: false
};
const DefaultType$9 = {
backdrop: "(boolean|string)",
keyboard: "boolean",
scroll: "boolean"
};
/**
* Class definition
*/
var Drawer = class Drawer extends DialogBase {
constructor(element, config) {
super(element, config);
this._swipeHelper = null;
this._resizeObserver = null;
this._resizeFrame = null;
this._initResizeObserver();
}
static get Default() {
return Default$9;
}
static get DefaultType() {
return DefaultType$9;
}
static get NAME() {
return NAME$10;
}
static {
EventHandler.on(document, EVENT_CLICK_DATA_API$1, SELECTOR_DATA_TOGGLE$4, function(event) {
const target = SelectorEngine.getElementFromSelector(this);
if (!(target instanceof HTMLDialogElement) || isDisabled(this)) return;
if (["A", "AREA"].includes(this.tagName)) event.preventDefault();
Drawer._toggleDrawer(target, this);
});
}
static _toggleDrawer(target, trigger) {
const drawer = Drawer.getOrCreateInstance(target, Manipulator.getDataAttributes(trigger));
if (target.open) {
drawer.hide();
return;
}
const other = SelectorEngine.findOne(SELECTOR_OPEN);
if (!other) {
drawer.show(trigger);
return;
}
const source = Drawer.getOrCreateInstance(other);
if (!drawer._canShow(trigger) || !source._canHide()) return;
const returnFocus = other.contains(trigger) ? source._returnFocus : trigger;
drawer._show(trigger, returnFocus);
if (target.open) source._hide(false);
}
dispose() {
if (this._swipeHelper) this._swipeHelper.dispose();
if (this._resizeObserver) this._resizeObserver.disconnect();
if (this._resizeFrame !== null) cancelAnimationFrame(this._resizeFrame);
super.dispose();
}
_getShowOptions() {
return {
modal: Boolean(this._config.backdrop) || !this._config.scroll,
preventBodyScroll: !this._config.scroll
};
}
_onBeforeShow() {
this._swipeHelper?.dispose();
this._swipeHelper = null;
this._initSwipe();
}
_canShow(relatedTarget) {
return !this._isInline() && super._canShow(relatedTarget);
}
async _show(relatedTarget, returnFocus = relatedTarget) {
if (this._isInline()) return;
await super._show(relatedTarget, returnFocus);
if (this._element?.open && this._isInline()) await this.hide();
}
_onAfterHide() {
syncInlineSemantics(this._element, this._isInline());
}
_isInline() {
return Boolean(this._element && drawerIsInline(this._element));
}
_getInstantClassName() {
return "drawer-instant";
}
_getStaticClassName() {
return "drawer-static";
}
_shouldDeferClose() {
return this._isAnimated();
}
_initResizeObserver() {
const navbar = this._element?.closest(".navbar");
if (!navbar || typeof ResizeObserver === "undefined") return;
this._resizeObserver = new ResizeObserver(() => {
if (this._resizeFrame !== null) cancelAnimationFrame(this._resizeFrame);
this._resizeFrame = requestAnimationFrame(() => {
this._resizeFrame = null;
if (this._element.open && getComputedStyle(this._element).position !== "fixed") this.hide();
});
});
this._resizeObserver.observe(navbar);
}
_initSwipe() {
if (this._swipeHelper || !Swipe.isSupported()) return;
const swipeConfig = {};
const element = this._element;
const rtl = element.matches(":dir(rtl)");
if (element.classList.contains("drawer-bottom")) swipeConfig.downCallback = () => this.hide();
else if (element.classList.contains("drawer-top")) swipeConfig.upCallback = () => this.hide();
else if (element.classList.contains("drawer-end")) if (rtl) swipeConfig.leftCallback = () => this.hide();
else swipeConfig.rightCallback = () => this.hide();
else if (rtl) swipeConfig.rightCallback = () => this.hide();
else swipeConfig.leftCallback = () => this.hide();
this._swipeHelper = new Swipe(SelectorEngine.findOne(".drawer-header", element) || element, swipeConfig);
}
};
/**
* Data API implementation
*/
EventHandler.on(window, EVENT_LOAD_DATA_API$2, () => {
for (const element of SelectorEngine.find(SELECTOR_OPEN)) Drawer.getOrCreateInstance(element);
});
onDocumentReady(`DOMContentLoaded${EVENT_KEY$7}${DATA_API_KEY$4}`, () => {
for (const element of SelectorEngine.find(SELECTOR_RESPONSIVE)) syncInlineSemantics(element, !element.open && drawerIsInline(element));
});
document.addEventListener("beforetoggle", (event) => {
if (event.target instanceof HTMLDialogElement && event.newState === "open") syncInlineSemantics(event.target, false);
}, true);
document.addEventListener("close", (event) => {
if (event.target instanceof HTMLDialogElement && event.target.matches(SELECTOR_RESPONSIVE)) syncInlineSemantics(event.target, !event.target.open && drawerIsInline(event.target));
}, true);
EventHandler.on(window, EVENT_RESIZE$1, () => {
for (const element of SelectorEngine.find(SELECTOR_RESIZE)) {
const inline = drawerIsInline(element);
syncInlineSemantics(element, !element.open && inline);
if (element.open && (inline || getComputedStyle(element).position !== "fixed")) Drawer.getOrCreateInstance(element).hide();
}
});
enableDismissTrigger(Drawer);
//#endregion
//#region js/src/strength.ts
/**
* --------------------------------------------------------------------------
* Bootstrap strength.ts
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
* --------------------------------------------------------------------------
*/
/**
* Constants
*/
const NAME$9 = "strength";
const EVENT_KEY$6 = `.bs.strength`;
const DATA_API_KEY$3 = ".data-api";
const EVENT_STRENGTH_CHANGE = `strengthChange${EVENT_KEY$6}`;
const SELECTOR_DATA_STRENGTH = "[data-bs-strength]";
const STRENGTH_LEVELS = [
"weak",
"fair",
"good",
"strong"
];
const Default$8 = {
input: null,
minLength: 8,
messages: {
weak: "Weak",
fair: "Fair",
good: "Good",
strong: "Strong"
},
weights: {
minLength: 1,
extraLength: 1,
lowercase: 1,
uppercase: 1,
numbers: 1,
special: 1,
multipleSpecial: 1,
longPassword: 1
},
thresholds: [
2,
4,
6
],
scorer: null
};
const DefaultType$8 = {
input: "(string|element|null)",
minLength: "number",
messages: "object",
weights: "object",
thresholds: "array",
scorer: "(function|null)"
};
/**
* Class definition
*/
var Strength = class extends BaseComponent {
constructor(element, config) {
super(element, config);
this._input = this._getInput();
this._segments = SelectorEngine.find(".strength-segment", this._element);
this._textElement = SelectorEngine.findOne(".strength-text", this._element.parentElement);
this._currentStrength = null;
if (this._input) {
this._addEventListeners();
this._evaluate();
}
}
static get Default() {
return Default$8;
}
static get DefaultType() {
return DefaultType$8;
}
static get NAME() {
return NAME$9;
}
getStrength() {
return this._currentStrength;
}
evaluate() {
this._evaluate();
}
dispose() {
EventHandler.off(this._input, EVENT_KEY$6);
super.dispose();
}
_getInput() {
if (this._config.input) return typeof this._config.input === "string" ? SelectorEngine.findOne(this._config.input) : this._config.input;
const parent = this._element.parentElement;
return SelectorEngine.findOne("input[type=\"password\"]", parent);
}
_addEventListeners() {
EventHandler.on(this._input, `input${EVENT_KEY$6}`, () => this._evaluate());
EventHandler.on(this._input, `change${EVENT_KEY$6}`, () => this._evaluate());
}
_evaluate() {
const password = this._input.value;
const score = this._calculateScore(password);
const strength = this._scoreToStrength(score);
if (strength !== this._currentStrength) {
this._currentStrength = strength;
this._updateUI(strength);
EventHandler.trigger(this._element, EVENT_STRENGTH_CHANGE, {
strength,
score,
password: password.length > 0 ? "***" : ""
});
}
}
_calculateScore(password) {
if (!password) return 0;
if (typeof this._config.scorer === "function") return this._config.scorer(password);
const { weights } = this._config;
let score = 0;
if (password.length >= this._config.minLength) score += weights.minLength;
if (password.length >= this._config.minLength + 4) score += weights.extraLength;
if (/[a-z]/.test(password)) score += weights.lowercase;
if (/[A-Z]/.test(password)) score += weights.uppercase;
if (/\d/.test(password)) score += weights.numbers;
const specialCount = password.match(/[ \p{P}\p{S}]/gu)?.length ?? 0;
if (specialCount >= 1) score += weights.special;
if (specialCount >= 2) score += weights.multipleSpecial;
if (password.length >= 16) score += weights.longPassword;
return score;
}
_scoreToStrength(score) {
if (score === 0) return null;
const [weak, fair, good] = this._config.thresholds;
if (score <= weak) return "weak";
if (score <= fair) return "fair";
if (score <= good) return "good";
return "strong";
}
_updateUI(strength) {
if (strength) this._element.dataset.bsStrength = strength;
else delete this._element.dataset.bsStrength;
const strengthIndex = strength ? STRENGTH_LEVELS.indexOf(strength) : -1;
for (const [index, segment] of this._segments.entries()) if (index <= strengthIndex) segment.classList.add("active");
else segment.classList.remove("active");
if (this._textElement) if (strength && this._config.messages[strength]) {
this._textElement.textContent = this._config.messages[strength];
this._textElement.dataset.bsStrength = strength;
} else {
this._textElement.textContent = "";
delete this._textElement.dataset.bsStrength;
}
}
};
/**
* Data API implementation
*/
onDocumentReady(`DOMContentLoaded${EVENT_KEY$6}${DATA_API_KEY$3}`, () => {
for (const element of SelectorEngine.find(SELECTOR_DATA_STRENGTH)) Strength.getOrCreateInstance(element);
});
//#endregion
//#region js/src/otp-input.ts
/**
* --------------------------------------------------------------------------
* Bootstrap otp-input.ts
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
* --------------------------------------------------------------------------
*/
/**
* Constants
*/
const NAME$8 = "otpInput";
const EVENT_KEY$5 = `.bs.otpInput`;
const DATA_API_KEY$2 = ".data-api";
const EVENT_COMPLETE = `complete${EVENT_KEY$5}`;
const EVENT_INPUT$1 = `input${EVENT_KEY$5}`;
const EVENT_DOMCONTENT_LOADED = `DOMContentLoaded${EVENT_KEY$5}${DATA_API_KEY$2}`;
const SELECTOR_DATA_OTP = "[data-bs-otp]";
const SELECTOR_INPUT$1 = "input";
const CLASS_NAME_INPUT = "otp-input";
const CLASS_NAME_RENDERED = "otp-rendered";
const CLASS_NAME_SLOTS = "otp-slots";
const CLASS_NAME_SLOT = "otp-slot";
const CLASS_NAME_SLOT_FILLED = "otp-slot-filled";
const CLASS_NAME_SLOT_ACTIVE = "otp-slot-active";
const CLASS_NAME_SLOT_SELECTED = "otp-slot-selected";
const CLASS_NAME_SEPARATOR = "otp-separator";
const MASK_CHARACTER = "•";
const TYPES = {
numeric: {
inputmode: "numeric",
pattern: "[0-9]*",
filter: /[^0-9]/g
},
alphanumeric: {
inputmode: "text",
pattern: "[A-Za-z0-9]*",
filter: /[^A-Za-z0-9]/g
},
alpha: {
inputmode: "text",
pattern: "[A-Za-z]*",
filter: /[^A-Za-z]/g
}
};
const Default$7 = {
groups: null,
length: null,
mask: false,
pasteTransformer: null,
separator: "·",
type: "numeric"
};
const DefaultType$7 = {
groups: "(array|null)",
length: "(number|null)",
mask: "boolean",
pasteTransformer: "(function|null)",
separator: "string",
type: "string"
};
/**
* Class definition
*/
var OtpInput = class extends BaseComponent {
constructor(element, config) {
super(element, config);
const input = SelectorEngine.findOne(SELECTOR_INPUT$1, this._element);
if (!input) return;
this._input = input;
this._type = TYPES[this._config.type] || TYPES.numeric;
this._length = this._resolveLength();
this._slots = [];
this._pointerActive = false;
this._pointerIndex = 0;
this._touchPointer = false;
this._setupInput();
this._lastCompleteValue = null;
this._renderSlots();
this._addEventListeners();
this._render();
}
static get Default() {
return Default$7;
}
static get DefaultType() {
return DefaultType$7;
}
static get NAME() {
return NAME$8;
}
getValue() {
return this._input.value;
}
setValue(value) {
this._input.value = this._sanitize(String(value));
this._render();
this._checkComplete();
}
clear() {
this._input.value = "";
this._lastCompleteValue = null;
this._render();
this._input.focus();
}
focus() {
this._input.focus();
this._selectSlot(this._firstEmptyIndex());
this._render();
}
dispose() {
for (const [type, listener] of Object.entries(this._inputListeners ?? {})) EventHandler.off(this._input, type, listener);
EventHandler.off(document, "selectionchange", this._onSelectionChange);
document.removeEventListener("reset", this._onReset, true);
for (const [attribute, value] of this._inputDefaults ?? []) if (this._input.getAttribute(attribute) === value) this._input.removeAttribute(attribute);
this._slotsContainer?.remove();
this._element.classList.remove(CLASS_NAME_RENDERED);
super.dispose();
}
_resolveLength() {
if (this._config.length) return this._config.length;
const maxLength = Number.parseInt(this._input.getAttribute("maxlength"), 10);
return Number.isNaN(maxLength) || maxLength < 1 ? 6 : maxLength;
}
_setupInput() {
const input = this._input;
if (input.type === "number" || input.type === "password") input.type = "text";
input.classList.add(CLASS_NAME_INPUT);
input.setAttribute("maxlength", String(this._length));
this._inputDefaults = /* @__PURE__ */ new Map();
const pattern = input.minLength > 0 ? `${this._type.pattern.slice(0, -1)}{${input.minLength},}` : this._type.pattern;
const defaults = {
inputmode: this._type.inputmode,
pattern,
spellcheck: "false"
};
for (const [attribute, value] of Object.entries(defaults)) if (!input.hasAttribute(attribute)) {
input.setAttribute(attribute, value);
this._inputDefaults.set(attribute, value);
}
if (!input.getAttribute("autocomplete")) input.setAttribute("autocomplete", "one-time-code");
if (input.value) input.value = this._sanitize(input.value);
}
_renderSlots() {
const container = document.createElement("div");
container.className = CLASS_NAME_SLOTS;
container.setAttribute("aria-hidden", "true");
const { groups } = this._config;
let groupIndex = 0;
let inGroup = 0;
for (let i = 0; i < this._length; i++) {
const slot = document.createElement("div");
slot.className = CLASS_NAME_SLOT;
container.append(slot);
this._slots.push(slot);
if (Array.isArray(groups) && groups.length > 0) {
inGroup++;
if (inGroup === groups[groupIndex] && i < this._length - 1) {
const separator = document.createElement("div");
separator.className = CLASS_NAME_SEPARATOR;
separator.textContent = this._config.separator;
container.append(separator);
groupIndex = Math.min(groupIndex + 1, groups.length - 1);
inGroup = 0;
}
}
}
this._slotsContainer = container;
this._element.append(container);
this._element.classList.add(CLASS_NAME_RENDERED);
}
_addEventListeners() {
this._inputListeners = {
input: (event) => this._handleInput(event),
compositionend: () => this._handleInput(),
beforeinput: (event) => this._handleBeforeInput(event),
keydown: (event) => this._handleKeydown(event),
paste: (event) => this._handlePaste(event),
pointerdown: (event) => this._handlePointerDown(event),
pointercancel: () => {
this._touchPointer = false;
},
click: (event) => this._handleClick(event)
};
this._inputListeners.focus = () => {
if (this._pointerActive) {
this._pointerActive = false;
this._selectSlot(this._pointerIndex);
this._render();
return;
}
this._selectSlot(this._firstEmptyIndex());
this._render();
};
const onSync = () => this._render();
this._onSelectionChange = () => {
if (document.activeElement === this._input) this._render();
};
for (const type of [
"blur",
"keyup",
"select"
]) this._inputListeners[type] = onSync;
for (const [type, listener] of Object.entries(this._inputListeners)) EventHandler.on(this._input, type, listener);
EventHandler.on(document, "selectionchange", this._onSelectionChange);
this._onReset = (event) => {
if (event.target !== this._input.form) return;
setTimeout(() => {
if (event.defaultPrevented || event.target !== this._input?.form) return;
const sanitized = this._sanitize(this._input.value);
if (sanitized !== this._input.value) this._input.value = sanitized;
this._lastCompleteValue = null;
this._render();
});
};
document.addEventListener("reset", this._onReset, true);
}
_handleInput(event) {
if (event?.isComposing) return;
const { value, selectionStart } = this._input;
const sanitized = this._sanitize(value);
if (sanitized !== value) this._input.value = sanitized;
if (document.activeElement === this._input) {
const inputType = event?.inputType;
if (inputType === "insertText" || inputType?.startsWith("delete")) {
const caret = selectionStart ?? sanitized.length;
this._selectSlot(this._sanitize(value.slice(0, caret)).length);
} else if (!inputType || inputType === "insertReplacementText") this._selectSlot(this._firstEmptyIndex());
}
this._afterValueChange();
}
_handlePaste(event) {
const pastedValue = event.clipboardData?.getData("text");
if (!pastedValue || !this._isEditable()) return;
const transformed = this._config.pasteTransformer?.(pastedValue) ?? pastedValue;
const sanitized = this._sanitize(transformed);
let start = this._input.selectionStart ?? this._input.value.length;
let end = this._input.selectionEnd ?? start;
if (sanitized.length === this._length) {
start = 0;
end = this._input.value.length;
}
const inserted = sanitized.slice(0, this._length - this._input.value.length + end - start);
if (start === this._input.selectionStart && end === this._input.selectionEnd && inserted === pastedValue) return;
event.preventDefault();
if (!inserted) return;
const input = this._input;
if (input.matches(":focus")) {
input.setSelectionRange(start, end);
if (input.ownerDocument.execCommand("insertText", false, inserted)) return;
}
input.setRangeText(inserted, start, end, "end");
input.dispatchEvent(new InputEvent("input", {
bubbles: true,
composed: true,
inputType: "insertFromPaste",
data: inserted
}));
}
_handleBeforeInput(event) {
const { inputType, data, isComposing } = event;
if (inputType !== "insertText" || isComposing || data?.length !== 1 || !this._isEditable()) return;
if (!this._sanitize(data)) {
event.preventDefault();
return;
}
if (this._input.selectionStart === this._input.selectionEnd) this._selectSlot(this._input.selectionStart ?? 0);
}
_handleKeydown(event) {
const { key, altKey, ctrlKey, metaKey, shiftKey, isComposing, defaultPrevented } = event;
if (defaultPrevented || isComposing || altKey || ctrlKey || metaKey || shiftKey || key !== "ArrowLeft" && key !== "ArrowRight") return;
if (getComputedStyle(this._slotsContainer).direction !== "rtl") return;
const start = this._input.selectionStart ?? 0;
const end = this._input.selectionEnd ?? start;
const isMovingRight = key === "ArrowRight";
const rangeEdge = isMovingRight ? start : end;
const nextSlot = start + (isMovingRight ? -1 : 1);
const index = end - start > 1 ? rangeEdge : nextSlot;
event.preventDefault();
this._selectSlot(Math.min(index, this._firstEmptyIndex()));
this._render();
}
_handleClick(event) {
if (!this._touchPointer) return;
this._touchPointer = false;
const index = this._slotIndexFromPoint(event.clientX);
if (index === null) return;
requestAnimationFrame(() => {
if (this._input && document.activeElement === this._input) {
this._selectSlot(Math.min(index, this._firstEmptyIndex()));
this._render();
}
});
}
_handlePointerDown(event) {
if (event.button !== 0 || this._input.matches(":disabled")) return;
this._touchPointer = event.pointerType === "touch";
const index = this._slotIndexFromPoint(event.clientX);
if (index === null) return;
const target = Math.min(index, this._firstEmptyIndex());
if (document.activeElement === this._input) {
if (!this._touchPointer) {
event.preventDefault();
this._selectSlot(target);
this._render();
}
return;
}
this._pointerActive = true;
this._pointerIndex = target;
}
_slotIndexFromPoint(x) {
const rtl = getComputedStyle(this._slotsContainer).direction === "rtl";
for (const [index, slot] of this._slots.entries()) {
const { left, right } = slot.getBoundingClientRect();
if ((rtl ? x >= left : x <= right) || index === this._slots.length - 1) return index;
}
return null;
}
_afterValueChange() {
this._render();
EventHandler.trigger(this._element, EVENT_INPUT$1, { value: this._input.value });
if (this._input) this._checkComplete();
}
_firstEmptyIndex() {
return Math.min(this._input.value.length, this._length - 1);
}
_isEditable() {
return !this._input.readOnly && !this._input.matches(":disabled");
}
_selectSlot(index) {
const clamped = Math.max(0, Math.min(index, this._length - 1));
const end = clamped < this._input.value.length ? clamped + 1 : clamped;
this._input.setSelectionRange(clamped, end);
}
_sanitize(value) {
return value.replace(this._type.filter, "").slice(0, this._length);
}
_render() {
const { value } = this._input;
const isFocused = document.activeElement === this._input;
const start = this._input.selectionStart ?? value.length;
const end = this._input.selectionEnd ?? start;
const caret = Math.min(start, this._length - 1);
for (const [index, slot] of this._slots.entries()) {
const char = value[index] ?? "";
const placeholder = value ? "" : this._input.placeholder[index] ?? "";
const text = char && this._config.mask ? MASK_CHARACTER : char || placeholder;
if (slot.textContent !== text) slot.textContent = text;
slot.classList.toggle(CLASS_NAME_SLOT_FILLED, Boolean(char));
slot.classList.toggle(CLASS_NAME_SLOT_ACTIVE, isFocused && index === caret);
slot.classList.toggle(CLASS_NAME_SLOT_SELECTED, isFocused && end - start > 1 && index >= start && index < end);
}
}
_checkComplete() {
const { value } = this._input;
const completeValue = value.length === this._length ? value : null;
const changed = completeValue !== this._lastCompleteValue;
this._lastCompleteValue = completeValue;
if (completeValue && changed) EventHandler.trigger(this._element, EVENT_COMPLETE, { value });
}
};
/**
* Data API implementation
*/
onDocumentReady(EVENT_DOMCONTENT_LOADED, () => {
for (const element of SelectorEngine.find(SELECTOR_DATA_OTP)) OtpInput.getOrCreateInstance(element);
});
//#endregion
//#region js/src/util/template-factory.ts
/**
* --------------------------------------------------------------------------
* Bootstrap util/template-factory.ts
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
* --------------------------------------------------------------------------
*/
/**
* Constants
*/
const NAME$7 = "TemplateFactory";
const Default$6 = {
allowList: DefaultAllowlist,
content: {},
extraClass: "",
html: false,
sanitize: true,
sanitizeFn: null,
template: "<div></div>"
};
const DefaultType$6 = {
allowList: "object",
content: "object",
extraClass: "(string|function)",
html: "boolean",
sanitize: "boolean",
sanitizeFn: "(null|function)",
template: "string"
};
const DefaultContentType = {
entry: "(string|element|function|null)",
selector: "(string|element)"
};
/**
* Class definition
*/
var TemplateFactory = class extends Config {
constructor(config) {
super();
this._config = this._getConfig(config);
}
static get Default() {
return Default$6;
}
static get DefaultType() {
return DefaultType$6;
}
static get NAME() {
return NAME$7;
}
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;
}
_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 (isElement(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, [void 0, this]);
}
_putElementInTemplate(element, templateElement) {
if (this._config.html) {
templateElement.innerHTML = "";
templateElement.append(element);
return;
}
templateElement.textContent = element.textContent;
}
};
//#endregion
//#region js/src/tooltip.ts
/**
* --------------------------------------------------------------------------
* Bootstrap tooltip.ts
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
* --------------------------------------------------------------------------
*/
/**
* Constants
*/
const NAME$6 = "tooltip";
const DISALLOWED_ATTRIBUTES$1 = /* @__PURE__ */ new Set([
"sanitize",
"allowList",
"sanitizeFn"
]);
const ESCAPE_KEY = "Escape";
const CLASS_NAME_SHOW$2 = "show";
const SELECTOR_TOOLTIP_INNER = ".tooltip-inner";
const SELECTOR_DATA_TOGGLE$3 = "[data-bs-toggle=\"tooltip\"]";
const TRIGGER_HOVER = "hover";
const TRIGGER_FOCUS = "focus";
const TRIGGER_CLICK = "click";
const TRIGGER_MANUAL = "manual";
const EVENT_HIDE$2 = "hide";
const EVENT_HIDDEN$2 = "hidden";
const EVENT_SHOW$2 = "show";
const EVENT_SHOWN$2 = "shown";
const EVENT_INSERTED = "inserted";
const EVENT_CLICK$3 = "click";
const EVENT_FOCUSIN$2 = "focusin";
const EVENT_FOCUSOUT$1 = "focusout";
const EVENT_MOUSEENTER$1 = "mouseenter";
const EVENT_MOUSELEAVE = "mouseleave";
const EVENT_POINTERDOWN = "pointerdown";
const EVENT_POINTERUP = "pointerup";
const EVENT_KEYDOWN$1 = "keydown";
const AttachmentMap = {
AUTO: "auto",
TOP: "top",
RIGHT: isRTL() ? "left" : "right",
BOTTOM: "bottom",
LEFT: isRTL() ? "right" : "left"
};
const Default$5 = {
allowList: DefaultAllowlist,
animation: true,
boundary: "clippingParents",
container: false,
customClass: "",
delay: 0,
fallbackPlacements: [
"top",
"right",
"bottom",
"left"
],
html: false,
offset: [0, 6],
placement: "top",
floatingConfig: 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"
};
const DefaultType$5 = {
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)",
floatingConfig: "(null|object|function)",
sanitize: "boolean",
sanitizeFn: "(null|function)",
selector: "(string|boolean)",
template: "string",
title: "(string|element|function)",
trigger: "string"
};
/**
* Class definition
*/
var Tooltip = class extends BaseComponent {
constructor(element, config) {
if (typeof computePosition === "undefined") throw new TypeError("Bootstrap's tooltips require Floating UI (https://floating-ui.com)");
super(element, config);
this._isEnabled = true;
this._timeout = 0;
this._resolveTimeout = null;
this._isHovered = null;
this._activeTrigger = {};
this._floatingCleanup = null;
this._keydownHandler = null;
this._tipEventOut = null;
this._outsidePointerHandler = null;
this._tipPointerUpHandler = null;
this._tipPointerDown = false;
this._templateFactory = null;
this._newContent = null;
this._mediaQueryListeners = [];
this._responsivePlacements = null;
this.tip = null;
this._parseResponsivePlacements();
this._setListeners();
if (!this._config.selector) this._fixTitle();
}
static get Default() {
return Default$5;
}
static get DefaultType() {
return DefaultType$5;
}
static get NAME() {
return NAME$6;
}
enable() {
this._isEnabled = true;
}
disable() {
this._isEnabled = false;
}
toggleEnabled() {
this._isEnabled = !this._isEnabled;
}
toggle() {
if (!this._isEnabled) return Promise.resolve();
return this._isShown() ? this._leave() : this._enter();
}
dispose() {
this._clearTimeout();
this._removeEscapeListener();
this._removeFocusOutsideListener();
if (this._element.getAttribute("data-bs-original-title")) this._element.setAttribute("title", this._element.getAttribute("data-bs-original-title"));
this._disposeFloating();
this._disposeMediaQueryListeners();
super.dispose();
}
async 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 isInTheDom = (findShadowRoot(this._element) || this._element.ownerDocument.documentElement).contains(this._element);
if (showEvent.defaultPrevented || !isInTheDom) {
this._isHovered = false;
return;
}
this._disposeFloating();
const tip = this._getTipElement();
this._element.setAttribute("aria-describedby", tip.getAttribute("id"));
let { container } = this._config;
const closestDialog = this._element.closest("dialog[open]");
if (closestDialog && container === document.body) container = closestDialog;
if (!this._element.ownerDocument.documentElement.contains(this.tip)) {
container.append(tip);
EventHandler.trigger(this._element, this.constructor.eventName(EVENT_INSERTED));
this._setTipListeners(tip);
}
await this._createFloating(tip);
tip.classList.add(CLASS_NAME_SHOW$2);
this._setEscapeListener();
this._setFocusOutsideListener();
if ("ontouchstart" in document.documentElement) for (const element of 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 = null;
};
await this._queueCallback(complete, this.tip, this._isAnimated());
}
async hide() {
if (!this._isShown()) return;
if (EventHandler.trigger(this._element, this.constructor.eventName(EVENT_HIDE$2)).defaultPrevented) return;
this._removeEscapeListener();
this._removeFocusOutsideListener();
this._getTipElement().classList.remove(CLASS_NAME_SHOW$2);
if ("ontouchstart" in document.documentElement) for (const element of 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._disposeFloating();
this._element.removeAttribute("aria-describedby");
EventHandler.trigger(this._element, this.constructor.eventName(EVENT_HIDDEN$2));
};
await this._queueCallback(complete, this.tip, this._isAnimated());
}
update() {
if (this._floatingCleanup && this.tip) this._updateFloatingPosition();
}
_isWithContent() {
return Boolean(this._getTitle()) || this._hasNewContent();
}
_hasNewContent() {
return Boolean(this._newContent) && Object.values(this._newContent).some(Boolean);
}
_getTipElement() {
if (!this.tip) this.tip = this._createTipElement(this._newContent || this._getContentForTemplate());
return this.tip;
}
_createTipElement(content) {
const tip = this._getTemplateFactory(content).toHtml();
tip.classList.remove(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._config.animation) tip.classList.add(this._getInstantClassName());
this._setFocusTipListeners(tip);
return tip;
}
setContent(content) {
this._newContent = content;
if (this._isShown()) {
this._disposeFloating();
this.show();
}
}
_getTemplateFactory(content) {
if (this._templateFactory) this._templateFactory.changeContent(content);
else this._templateFactory = new TemplateFactory({
...this._config,
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");
}
_initializeOnDelegatedTarget(event) {
return this.constructor.getOrCreateInstance(event.delegateTarget, this._getDelegateConfig());
}
_getInstantClassName() {
return `${this.constructor.NAME}-instant`;
}
_isAnimated() {
return getTransitionDurationFromElement(this.tip) > 0;
}
_isShown() {
return this.tip && this.tip.classList.contains(CLASS_NAME_SHOW$2);
}
_getPlacement(tip) {
if (this._responsivePlacements) {
const placement = getResponsivePlacement(this._responsivePlacements, "top");
return AttachmentMap[placement.toUpperCase()] || placement;
}
const placement = execute(this._config.placement, [
this,
tip,
this._element
]);
return AttachmentMap[placement.toUpperCase()] || placement;
}
_parseResponsivePlacements() {
if (typeof this._config.placement !== "string") {
this._responsivePlacements = null;
return;
}
this._responsivePlacements = parseResponsivePlacement(this._config.placement, "top");
if (this._responsivePlacements) this._setupMediaQueryListeners();
}
_setupMediaQueryListeners() {
this._disposeMediaQueryListeners();
this._mediaQueryListeners = createBreakpointListeners(() => {
if (this._isShown()) this._updateFloatingPosition();
});
}
_disposeMediaQueryListeners() {
disposeBreakpointListeners(this._mediaQueryListeners);
this._mediaQueryListeners = [];
}
async _createFloating(tip) {
const placement = this._getPlacement(tip);
const arrowElement = tip.querySelector(`.${this.constructor.NAME}-arrow`);
await this._updateFloatingPosition(tip, placement, arrowElement);
this._floatingCleanup = autoUpdate(this._element, tip, () => this._updateFloatingPosition(tip, null, arrowElement));
}
async _updateFloatingPosition(tip = this.tip, placement = null, arrowElement = null) {
if (!tip) return;
if (!placement) placement = this._getPlacement(tip);
if (!arrowElement) arrowElement = tip.querySelector(`.${this.constructor.NAME}-arrow`);
const middleware = this._getFloatingMiddleware(arrowElement);
const floatingConfig = this._getFloatingConfig(placement, middleware);
const { x, y, placement: finalPlacement, middlewareData } = await computePosition(this._element, tip, floatingConfig);
Object.assign(tip.style, {
position: "absolute",
left: `${x}px`,
top: `${y}px`
});
if (arrowElement) arrowElement.style.position = "absolute";
Manipulator.setDataAttribute(tip, "placement", finalPlacement);
if (arrowElement && middlewareData.arrow) {
const { x: arrowX, y: arrowY } = middlewareData.arrow;
const isVertical = finalPlacement.startsWith("top") || finalPlacement.startsWith("bottom");
Object.assign(arrowElement.style, {
left: isVertical && arrowX !== void 0 ? `${arrowX}px` : "",
top: !isVertical && arrowY !== void 0 ? `${arrowY}px` : "",
right: "",
bottom: ""
});
}
}
_getOffset() {
const { offset } = this._config;
if (typeof offset === "string") return offset.split(",").map((value) => Number.parseInt(value, 10));
if (typeof offset === "function") return ({ placement, rects }) => {
return toFloatingOffset(offset({
placement,
reference: rects.reference,
floating: rects.floating
}, this._element));
};
return offset;
}
_resolvePossibleFunction(arg) {
return execute(arg, [this._element, this._element]);
}
_getFloatingMiddleware(arrowElement) {
const offsetValue = this._getOffset();
const middleware = [
offset(typeof offsetValue === "function" ? offsetValue : toFloatingOffset(offsetValue)),
flip({ fallbackPlacements: this._config.fallbackPlacements }),
shift({ boundary: this._config.boundary === "clippingParents" ? "clippingAncestors" : this._config.boundary })
];
if (arrowElement) middleware.push(arrow({ element: arrowElement }));
return middleware;
}
_getFloatingConfig(placement, middleware) {
const defaultConfig = {
placement,
middleware
};
return {
...defaultConfig,
...execute(this._config.floatingConfig, [void 0, defaultConfig])
};
}
_setListeners() {
const triggers = this._config.trigger.split(" ");
for (const trigger of triggers) if (trigger === "click") EventHandler.on(this._element, this.constructor.eventName(EVENT_CLICK$3), this._config.selector, (event) => {
const context = this._initializeOnDelegatedTarget(event);
context._activeTrigger[TRIGGER_CLICK] = !(context._isShown() && context._activeTrigger[TRIGGER_CLICK]);
context.toggle();
});
else if (trigger !== TRIGGER_MANUAL) {
const [eventIn, eventOut] = this._getTriggerEvents(trigger);
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);
if (event.type === "focusout") context._activeTrigger[TRIGGER_FOCUS] = context._isInside(event.relatedTarget) || context._tipPointerDown;
else context._activeTrigger[TRIGGER_HOVER] = context._isInside(event.relatedTarget);
context._leave();
});
}
}
_setTipListeners(tip) {
const trigger = this._getTrigger();
if (trigger === TRIGGER_MANUAL || trigger.includes(TRIGGER_CLICK)) return;
this._tipEventOut = (event) => {
this._activeTrigger[event.type === "focusout" ? TRIGGER_FOCUS : TRIGGER_HOVER] = this._isInside(event.relatedTarget);
this._leave();
};
for (const name of trigger.split(" ")) if (name === TRIGGER_HOVER || name === TRIGGER_FOCUS) {
const [, eventOut] = this._getTriggerEvents(name);
EventHandler.on(tip, eventOut, this._tipEventOut);
}
}
_removeTipListeners(tip) {
if (!this._tipEventOut) return;
const trigger = this._getTrigger();
for (const name of trigger.split(" ")) if (name === TRIGGER_HOVER || name === TRIGGER_FOCUS) {
const [, eventOut] = this._getTriggerEvents(name);
EventHandler.off(tip, eventOut, this._tipEventOut);
}
this._tipEventOut = null;
}
_isInside(target) {
return target instanceof Node && (this._element.contains(target) || Boolean(this.tip?.contains(target)));
}
_getTrigger() {
return this._config._trigger;
}
_getTriggerEvents(trigger) {
return {
[TRIGGER_HOVER]: [this.constructor.eventName(EVENT_MOUSEENTER$1), this.constructor.eventName(EVENT_MOUSELEAVE)],
[TRIGGER_FOCUS]: [this.constructor.eventName(EVENT_FOCUSIN$2), this.constructor.eventName(EVENT_FOCUSOUT$1)]
}[trigger];
}
_hasFocusTrigger() {
return this._getTrigger().split(" ").includes(TRIGGER_FOCUS);
}
_setFocusTipListeners(tip) {
if (!this._hasFocusTrigger()) return;
EventHandler.on(tip, this.constructor.eventName(EVENT_POINTERDOWN), () => {
this._tipPointerDown = true;
this._activeTrigger[TRIGGER_FOCUS] = true;
});
EventHandler.on(tip, this.constructor.eventName(EVENT_FOCUSIN$2), () => {
this._activeTrigger[TRIGGER_FOCUS] = true;
});
EventHandler.on(tip, this.constructor.eventName(EVENT_FOCUSOUT$1), (event) => {
this._activeTrigger[TRIGGER_FOCUS] = this._isInside(event.relatedTarget) || this._tipPointerDown;
this._leave();
});
}
_setFocusOutsideListener() {
if (this._outsidePointerHandler || !this._hasFocusTrigger()) return;
this._tipPointerUpHandler = () => {
this._tipPointerDown = false;
};
this._outsidePointerHandler = (event) => {
if (!this._isShown() || this._isInside(event.target)) return;
this._activeTrigger[TRIGGER_FOCUS] = false;
this.hide();
};
const doc = this._element.ownerDocument;
doc.addEventListener(EVENT_POINTERUP, this._tipPointerUpHandler, true);
doc.addEventListener(EVENT_POINTERDOWN, this._outsidePointerHandler, true);
}
_removeFocusOutsideListener() {
const doc = this._element?.ownerDocument;
if (this._tipPointerUpHandler && doc) doc.removeEventListener(EVENT_POINTERUP, this._tipPointerUpHandler, true);
if (this._outsidePointerHandler && doc) doc.removeEventListener(EVENT_POINTERDOWN, this._outsidePointerHandler, true);
this._tipPointerUpHandler = null;
this._outsidePointerHandler = null;
this._tipPointerDown = false;
}
_setEscapeListener() {
if (this._keydownHandler) return;
this._keydownHandler = (event) => {
if (event.key !== ESCAPE_KEY || !this._isShown() || !this.tip.isConnected) return;
event.preventDefault();
event.stopPropagation();
this.hide();
};
this._element.ownerDocument.addEventListener(EVENT_KEYDOWN$1, this._keydownHandler, true);
}
_removeEscapeListener() {
if (!this._keydownHandler) return;
this._element.ownerDocument.removeEventListener(EVENT_KEYDOWN$1, this._keydownHandler, true);
this._keydownHandler = null;
}
_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 Promise.resolve();
}
this._isHovered = true;
return this._setTimeout(() => this._isHovered ? this.show() : void 0, this._config.delay.show);
}
_leave() {
if (this._isWithActiveTrigger()) return Promise.resolve();
this._isHovered = false;
return this._setTimeout(() => this._isHovered ? void 0 : this.hide(), this._config.delay.hide);
}
_setTimeout(handler, timeout) {
this._clearTimeout();
return new Promise((resolve) => {
this._resolveTimeout = resolve;
this._timeout = setTimeout(() => {
this._resolveTimeout = null;
resolve(handler());
}, timeout);
});
}
_clearTimeout() {
clearTimeout(this._timeout);
if (this._resolveTimeout) {
this._resolveTimeout();
this._resolveTimeout = null;
}
}
_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$1.has(dataAttribute)) delete dataAttributes[dataAttribute];
if (this._element.getAttribute("data-bs-title") !== null) dataAttributes.title = this._element.getAttribute("data-bs-title");
if (this._element.getAttribute("data-bs-content") !== null) dataAttributes.content = this._element.getAttribute("data-bs-content");
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);
config._trigger = config._trigger || config.trigger;
if (typeof config.delay === "number") config.delay = {
show: config.delay,
hide: config.delay
};
if (config.title === null) config.title = "";
else if (typeof config.title === "number" || typeof config.title === "boolean") config.title = config.title.toString();
if (config.content === null) config.content = "";
else if (typeof config.content === "number" || typeof config.content === "boolean") 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;
}
_disposeFloating() {
if (this._floatingCleanup) {
this._floatingCleanup();
this._floatingCleanup = null;
}
if (this.tip) {
this._removeTipListeners(this.tip);
EventHandler.off(this.tip, this.constructor.EVENT_KEY);
this.tip.remove();
this.tip = null;
}
}
};
/**
* Data API implementation - auto-initialize tooltips
*/
const initTooltip = (event) => {
const target = event.target.closest(SELECTOR_DATA_TOGGLE$3);
if (!target) return;
Tooltip.getOrCreateInstance(target);
};
EventHandler.on(document, EVENT_FOCUSIN$2, SELECTOR_DATA_TOGGLE$3, initTooltip);
EventHandler.on(document, EVENT_MOUSEENTER$1, SELECTOR_DATA_TOGGLE$3, initTooltip);
//#endregion
//#region js/src/popover.ts
/**
* --------------------------------------------------------------------------
* Bootstrap popover.ts
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
* --------------------------------------------------------------------------
*/
/**
* Constants
*/
const NAME$5 = "popover";
const SELECTOR_TITLE = ".popover-header";
const SELECTOR_CONTENT = ".popover-body";
const SELECTOR_DATA_TOGGLE$2 = "[data-bs-toggle=\"popover\"]";
const EVENT_CLICK$2 = "click";
const EVENT_FOCUSIN$1 = "focusin";
const EVENT_MOUSEENTER = "mouseenter";
const Default$4 = {
...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"
};
const DefaultType$4 = {
...Tooltip.DefaultType,
content: "(null|string|element|function)"
};
/**
* Class definition
*/
var Popover = class extends Tooltip {
constructor(element, config) {
super(element, config);
}
static get Default() {
return Default$4;
}
static get DefaultType() {
return DefaultType$4;
}
static get NAME() {
return NAME$5;
}
_isWithContent() {
return Boolean(this._getTitle() || this._getContent()) || this._hasNewContent();
}
_getContentForTemplate() {
return {
[SELECTOR_TITLE]: this._getTitle(),
[SELECTOR_CONTENT]: this._getContent()
};
}
_getContent() {
return this._resolvePossibleFunction(this._config.content);
}
};
/**
* Data API implementation - auto-initialize popovers
*/
const initPopover = (event) => {
const target = event.target.closest(SELECTOR_DATA_TOGGLE$2);
if (!target) return;
const popover = Popover.getOrCreateInstance(target);
if (event.type === "click" && popover._getTrigger().split(" ").includes("click")) event.preventDefault();
};
EventHandler.on(document, EVENT_CLICK$2, SELECTOR_DATA_TOGGLE$2, initPopover);
EventHandler.on(document, EVENT_FOCUSIN$1, SELECTOR_DATA_TOGGLE$2, initPopover);
EventHandler.on(document, EVENT_MOUSEENTER, SELECTOR_DATA_TOGGLE$2, initPopover);
//#endregion
//#region js/src/range.ts
/**
* --------------------------------------------------------------------------
* Bootstrap range.ts
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
* --------------------------------------------------------------------------
*/
/**
* Constants
*/
const NAME$4 = "range";
const EVENT_KEY$4 = `.bs.range`;
const DATA_API_KEY$1 = ".data-api";
const EVENT_CHANGED = `changed${EVENT_KEY$4}`;
const EVENT_DOM_CONTENT_LOADED = `DOMContentLoaded${EVENT_KEY$4}${DATA_API_KEY$1}`;
const EVENT_INPUT = "input";
const EVENT_CHANGE = "change";
const EVENT_RESET = "reset";
const SELECTOR_RANGE = ".form-range";
const SELECTOR_INPUT = ".form-range-input";
const CLASS_NAME_BUBBLE = "form-range-bubble";
const CLASS_NAME_TICKS = "form-range-ticks";
const CLASS_NAME_TICK = "form-range-tick";
const CLASS_NAME_TICK_LABEL = "form-range-tick-label";
const PROPERTY_FILL = "--bs-range-fill";
const Default$3 = {
bubble: false,
formatter: null
};
const DefaultType$3 = {
bubble: "(boolean|null)",
formatter: "(function|null)"
};
/**
* Class definition
*/
var Range = class extends BaseComponent {
constructor(element, config) {
super(element, config);
if (!this._element) return;
this._input = SelectorEngine.findOne(SELECTOR_INPUT, this._element);
if (!this._input) return;
this._bubble = null;
this._bubbleText = null;
this._ticks = null;
this._updateHandler = () => this._update();
this._initialConfig = { ...config };
this._form = null;
this._resetTimeouts = /* @__PURE__ */ new Set();
this._resetHandler = (event) => {
const timeout = window.setTimeout(() => {
this._resetTimeouts.delete(timeout);
if (!event.defaultPrevented) this._update();
}, 0);
this._resetTimeouts.add(timeout);
};
this._syncBubble();
this._syncForm();
this._createTicks();
this._addEventListeners();
this._update();
}
static get Default() {
return Default$3;
}
static get DefaultType() {
return DefaultType$3;
}
static get NAME() {
return NAME$4;
}
update() {
if (!this._input) return;
this._config = this._getConfig(this._initialConfig);
this._syncBubble();
this._ticks?.remove();
this._ticks = null;
this._createTicks();
this._syncForm();
this._update();
}
dispose() {
EventHandler.off(this._input, EVENT_INPUT, this._updateHandler);
EventHandler.off(this._input, EVENT_CHANGE, this._updateHandler);
EventHandler.off(this._form, EVENT_RESET, this._resetHandler);
this._resetTimeouts?.forEach((timeout) => clearTimeout(timeout));
this._bubble?.remove();
this._ticks?.remove();
super.dispose();
}
_configAfterMerge(config) {
if (config.bubble === null) config.bubble = true;
return config;
}
_syncBubble() {
if (this._config.bubble) {
if (!this._bubble) this._createBubble();
} else {
this._bubble?.remove();
this._bubble = null;
this._bubbleText = null;
}
}
_syncForm() {
const { form } = this._input;
if (form === this._form) return;
EventHandler.off(this._form, EVENT_RESET, this._resetHandler);
this._resetTimeouts.forEach((timeout) => clearTimeout(timeout));
this._resetTimeouts.clear();
this._form = form;
EventHandler.on(this._form, EVENT_RESET, this._resetHandler);
}
_addEventListeners() {
EventHandler.on(this._input, EVENT_INPUT, this._updateHandler);
EventHandler.on(this._input, EVENT_CHANGE, this._updateHandler);
}
_min() {
return this._input.min === "" ? 0 : Number.parseFloat(this._input.min);
}
_max() {
return this._input.max === "" ? 100 : Number.parseFloat(this._input.max);
}
_value() {
return Number.parseFloat(this._input.value);
}
_ratio() {
const span = this._max() - this._min();
return span > 0 ? (this._value() - this._min()) / span : 0;
}
_update() {
this._element.style.setProperty(PROPERTY_FILL, `${this._ratio()}`);
if (this._bubbleText) this._bubbleText.textContent = this._format(this._value());
EventHandler.trigger(this._input, EVENT_CHANGED, { value: this._value() });
}
_format(value) {
return typeof this._config.formatter === "function" ? this._config.formatter(value) : String(value);
}
_createBubble() {
this._bubble = document.createElement("div");
this._bubble.className = `${CLASS_NAME_BUBBLE} tooltip bs-tooltip-top show`;
this._bubble.setAttribute("aria-hidden", "true");
const arrow = document.createElement("div");
arrow.className = "tooltip-arrow";
this._bubbleText = document.createElement("div");
this._bubbleText.className = "tooltip-inner";
this._bubble.append(arrow, this._bubbleText);
this._input.insertAdjacentElement("afterend", this._bubble);
}
_createTicks() {
const listId = this._input.getAttribute("list");
const datalist = listId ? document.getElementById(listId) : null;
if (!datalist) return;
const min = this._min();
const span = this._max() - min || 1;
const points = [];
for (const option of SelectorEngine.find("option", datalist)) {
const value = Number.parseFloat(option.value);
if (!Number.isNaN(value)) {
const ratio = Math.min(Math.max((value - min) / span, 0), 1);
points.push({
ratio,
label: option.label
});
}
}
if (points.length === 0) return;
points.sort((a, b) => a.ratio - b.ratio);
this._ticks = document.createElement("div");
this._ticks.className = CLASS_NAME_TICKS;
this._ticks.setAttribute("aria-hidden", "true");
const stops = [
0,
...points.map((point) => point.ratio),
1
];
this._ticks.style.gridTemplateColumns = stops.slice(1).map((stop, index) => `${stop - stops[index]}fr`).join(" ");
for (const [index, point] of points.entries()) {
const tick = document.createElement("span");
tick.className = CLASS_NAME_TICK;
tick.style.gridColumnStart = `${index + 2}`;
if (point.label) {
const label = document.createElement("span");
label.className = CLASS_NAME_TICK_LABEL;
label.textContent = point.label;
tick.append(label);
}
this._ticks.append(tick);
}
this._element.append(this._ticks);
}
};
/**
* Data API implementation
*/
onDocumentReady(EVENT_DOM_CONTENT_LOADED, () => {
for (const element of SelectorEngine.find(SELECTOR_RANGE)) Range.getOrCreateInstance(element);
});
//#endregion
//#region js/src/scrollspy.ts
/**
* --------------------------------------------------------------------------
* Bootstrap scrollspy.ts
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
* --------------------------------------------------------------------------
*/
/**
* Constants
*/
const NAME$3 = "scrollspy";
const EVENT_KEY$3 = `.bs.scrollspy`;
const DATA_API_KEY = ".data-api";
const EVENT_ACTIVATE = `activate${EVENT_KEY$3}`;
const EVENT_CLICK$1 = `click${EVENT_KEY$3}`;
const EVENT_SCROLL = `scroll${EVENT_KEY$3}`;
const EVENT_SCROLLEND = `scrollend${EVENT_KEY$3}`;
const EVENT_RESIZE = `resize${EVENT_KEY$3}`;
const EVENT_LOAD_DATA_API$1 = `load${EVENT_KEY$3}${DATA_API_KEY}`;
const CLASS_NAME_MENU_ITEM = "menu-item";
const CLASS_NAME_ACTIVE$1 = "active";
const SELECTOR_DATA_SPY = "[data-bs-spy=\"scroll\"]";
const SELECTOR_TARGET_LINKS = "[href]";
const SELECTOR_NAV_LIST_GROUP = ".nav, .list-group";
const SELECTOR_NAV_LINKS = ".nav-link";
const SELECTOR_LINK_ITEMS = `${SELECTOR_NAV_LINKS}, .nav-item > ${SELECTOR_NAV_LINKS}, .list-group-item`;
const SELECTOR_MENU_TOGGLE$1 = "[data-bs-toggle=\"menu\"]";
const SCROLL_IDLE_TIMEOUT = 100;
const RESIZE_DEBOUNCE = 100;
const Default$2 = {
rootMargin: null,
smoothScroll: false,
target: null,
threshold: [0],
topMargin: "12%"
};
const DefaultType$2 = {
rootMargin: "(string|null)",
smoothScroll: "boolean",
target: "element",
threshold: "array",
topMargin: "string"
};
/**
* Class definition
*/
var ScrollSpy = class extends BaseComponent {
constructor(element, config) {
super(element, config);
this._sections = [];
this._linkBySection = /* @__PURE__ */ new Map();
this._sectionByLink = /* @__PURE__ */ new Map();
this._intersecting = /* @__PURE__ */ new Set();
this._activeTarget = null;
this._lastActive = null;
this._atBottom = false;
this._rootElement = getComputedStyle(this._element).overflowY === "visible" ? null : this._element;
this._observer = null;
this._sentinel = null;
this._sentinelObserver = null;
this._pendingNavigation = null;
this._settleTimeout = null;
this._settleHandler = null;
this._scrollIdleHandler = null;
this._resizeHandler = null;
this._resizeTimeout = null;
this.refresh();
}
static get Default() {
return Default$2;
}
static get DefaultType() {
return DefaultType$2;
}
static get NAME() {
return NAME$3;
}
refresh() {
this._initializeTargetsAndObservables();
this._maybeEnableSmoothScroll();
this._observer?.disconnect();
this._intersecting.clear();
this._observer = this._getNewObserver();
for (const section of this._sections) this._observer.observe(section);
this._setUpSentinel();
this._maybeAddResizeListener();
}
dispose() {
this._observer?.disconnect();
this._teardownSentinel();
this._disarmSettle();
this._removeResizeListener();
EventHandler.off(this._config.target, EVENT_CLICK$1);
super.dispose();
}
_configAfterMerge(config) {
config.target = getElement(config.target) || document.body;
if (typeof config.threshold === "string") config.threshold = config.threshold.split(",").map((value) => Number.parseFloat(value));
return config;
}
_getNewObserver() {
const options = {
root: this._rootElement,
threshold: this._config.threshold,
rootMargin: this._config.rootMargin ?? this._getDerivedRootMargin()
};
return new IntersectionObserver((entries) => this._onIntersect(entries), options);
}
_onIntersect(entries) {
for (const entry of entries) if (entry.isIntersecting) this._intersecting.add(entry.target);
else this._intersecting.delete(entry.target);
this._computeActive();
}
_computeActive() {
if (!this._element?.isConnected || this._sections.length === 0) return;
let active = null;
if (this._atBottom) active = this._sections.at(-1);
else {
for (const section of this._sections) if (this._intersecting.has(section)) active = section;
active ||= this._lastActive ?? this._sections.at(0);
}
if (!active) return;
this._lastActive = active;
const link = this._linkBySection.get(active);
if (link) this._process(link);
}
_parseTopMargin() {
const value = String(this._config.topMargin);
return {
value: Number.parseFloat(value) || 0,
unit: value.endsWith("%") ? "%" : "px"
};
}
_getDerivedRootMargin() {
const { value, unit } = this._parseTopMargin();
let percent = value;
if (unit === "px") {
const rootHeight = this._rootElement ? this._rootElement.clientHeight : document.documentElement.clientHeight || window.innerHeight;
percent = rootHeight ? value / rootHeight * 100 : 12;
}
return `0px 0px -${Math.min(Math.max(100 - percent, 0), 100)}% 0px`;
}
_usesPixelMargin() {
return !this._config.rootMargin && this._parseTopMargin().unit === "px";
}
_setUpSentinel() {
this._teardownSentinel();
if (this._sections.length === 0) return;
const sentinel = document.createElement("div");
sentinel.setAttribute("aria-hidden", "true");
sentinel.style.cssText = "position:relative;width:0;height:0;margin:0;padding:0;border:0;visibility:hidden;";
this._element.append(sentinel);
this._sentinel = sentinel;
this._sentinelObserver = new IntersectionObserver((entries) => this._onSentinel(entries), {
root: this._rootElement,
threshold: [0]
});
this._sentinelObserver.observe(sentinel);
}
_onSentinel(entries) {
const entry = entries.at(-1);
this._atBottom = Boolean(entry?.isIntersecting) && this._isOverflowing();
this._computeActive();
}
_isOverflowing() {
const scroller = this._rootElement || document.scrollingElement || document.documentElement;
return scroller.scrollHeight > scroller.clientHeight;
}
_teardownSentinel() {
this._sentinelObserver?.disconnect();
this._sentinelObserver = null;
this._sentinel?.remove();
this._sentinel = null;
this._atBottom = false;
}
_maybeAddResizeListener() {
this._removeResizeListener();
if (!this._usesPixelMargin()) return;
this._resizeHandler = () => {
clearTimeout(this._resizeTimeout);
this._resizeTimeout = setTimeout(() => this._rebuildObserver(), RESIZE_DEBOUNCE);
};
EventHandler.on(window, EVENT_RESIZE, this._resizeHandler);
}
_removeResizeListener() {
clearTimeout(this._resizeTimeout);
this._resizeTimeout = null;
if (this._resizeHandler) {
EventHandler.off(window, EVENT_RESIZE, this._resizeHandler);
this._resizeHandler = null;
}
}
_rebuildObserver() {
if (!this._observer) return;
this._observer.disconnect();
this._intersecting.clear();
this._observer = this._getNewObserver();
for (const section of this._sections) this._observer.observe(section);
}
_maybeEnableSmoothScroll() {
if (!this._config.smoothScroll) return;
EventHandler.off(this._config.target, EVENT_CLICK$1);
EventHandler.on(this._config.target, EVENT_CLICK$1, SELECTOR_TARGET_LINKS, (event) => {
const link = event.target.closest(SELECTOR_TARGET_LINKS);
const section = link && this._sectionByLink.get(link);
if (!section || !this._element) return;
event.preventDefault();
const root = this._rootElement || window;
const height = section.offsetTop - this._element.offsetTop;
const currentTop = this._rootElement ? this._rootElement.scrollTop : window.scrollY ?? window.pageYOffset;
if (matchMedia("(prefers-reduced-motion: reduce)").matches || Math.abs(currentTop - height) <= 2) {
if (root.scrollTo) root.scrollTo({
top: height,
behavior: "auto"
});
else root.scrollTop = height;
this._settleNavigation(link.hash, section);
return;
}
this._pendingNavigation = {
hash: link.hash,
section
};
this._armSettle();
if (root.scrollTo) root.scrollTo({
top: height,
behavior: "smooth"
});
else root.scrollTop = height;
});
}
_armSettle() {
this._disarmSettle();
const target = this._getSettleTarget();
this._settleHandler = () => this._onSettle();
this._scrollIdleHandler = () => {
clearTimeout(this._settleTimeout);
this._settleTimeout = setTimeout(() => this._onSettle(), SCROLL_IDLE_TIMEOUT);
};
EventHandler.on(target, EVENT_SCROLLEND, this._settleHandler);
EventHandler.on(target, EVENT_SCROLL, this._scrollIdleHandler);
}
_disarmSettle() {
clearTimeout(this._settleTimeout);
this._settleTimeout = null;
const target = this._getSettleTarget();
if (this._settleHandler) {
EventHandler.off(target, EVENT_SCROLLEND, this._settleHandler);
this._settleHandler = null;
}
if (this._scrollIdleHandler) {
EventHandler.off(target, EVENT_SCROLL, this._scrollIdleHandler);
this._scrollIdleHandler = null;
}
}
_getSettleTarget() {
return this._rootElement || document;
}
_onSettle() {
this._disarmSettle();
if (!this._pendingNavigation) return;
const { hash, section } = this._pendingNavigation;
this._settleNavigation(hash, section);
}
_settleNavigation(hash, section) {
this._pendingNavigation = null;
if (window.history?.replaceState) window.history.replaceState(null, "", hash);
if (!section.hasAttribute("tabindex")) section.setAttribute("tabindex", "-1");
section.focus({ preventScroll: true });
}
_initializeTargetsAndObservables() {
this._sections = [];
this._linkBySection = /* @__PURE__ */ new Map();
this._sectionByLink = /* @__PURE__ */ new Map();
const targetLinks = SelectorEngine.find(SELECTOR_TARGET_LINKS, this._config.target);
const seen = /* @__PURE__ */ new Set();
for (const anchor of targetLinks) {
if (!anchor.hash || isDisabled(anchor)) continue;
const id = decodeFragment(anchor.hash.slice(1));
if (!id) continue;
const section = document.getElementById(id);
if (!section || !this._element.contains(section) || !isVisible(section)) continue;
this._sectionByLink.set(anchor, section);
this._linkBySection.set(section, anchor);
if (!seen.has(section)) {
seen.add(section);
this._sections.push(section);
}
}
this._sections.sort((a, b) => a.getBoundingClientRect().top - b.getBoundingClientRect().top);
}
_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_MENU_ITEM)) {
const menuToggle = target.closest(".menu")?.previousElementSibling;
if (menuToggle?.matches(SELECTOR_MENU_TOGGLE$1)) menuToggle.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);
}
};
function decodeFragment(hash) {
try {
return decodeURIComponent(hash);
} catch {
return hash;
}
}
/**
* Data API implementation
*/
EventHandler.on(window, EVENT_LOAD_DATA_API$1, () => {
for (const spy of SelectorEngine.find(SELECTOR_DATA_SPY)) ScrollSpy.getOrCreateInstance(spy);
});
//#endregion
//#region js/src/tab.ts
/**
* --------------------------------------------------------------------------
* Bootstrap tab.ts
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
* --------------------------------------------------------------------------
*/
/**
* Constants
*/
const NAME$2 = "tab";
const EVENT_KEY$2 = `.bs.tab`;
const EVENT_HIDE$1 = `hide${EVENT_KEY$2}`;
const EVENT_HIDDEN$1 = `hidden${EVENT_KEY$2}`;
const EVENT_SHOW$1 = `show${EVENT_KEY$2}`;
const EVENT_SHOWN$1 = `shown${EVENT_KEY$2}`;
const EVENT_CLICK_DATA_API = `click${EVENT_KEY$2}`;
const EVENT_KEYDOWN = `keydown${EVENT_KEY$2}`;
const EVENT_LOAD_DATA_API = `load${EVENT_KEY$2}`;
const ARROW_LEFT_KEY = "ArrowLeft";
const ARROW_RIGHT_KEY = "ArrowRight";
const ARROW_UP_KEY = "ArrowUp";
const ARROW_DOWN_KEY = "ArrowDown";
const HOME_KEY = "Home";
const END_KEY = "End";
const CLASS_NAME_ACTIVE = "active";
const CLASS_NAME_SHOW$1 = "show";
const SELECTOR_MENU_TOGGLE = "[data-bs-toggle=\"menu\"]";
const SELECTOR_MENU = ".menu";
const NOT_SELECTOR_MENU_TOGGLE = `:not(${SELECTOR_MENU_TOGGLE})`;
const SELECTOR_TAB_PANEL = ".list-group, .nav, [role=\"tablist\"]";
const SELECTOR_OUTER = ".nav-item, .list-group-item";
const SELECTOR_INNER = `.nav-link${NOT_SELECTOR_MENU_TOGGLE}, .list-group-item${NOT_SELECTOR_MENU_TOGGLE}, [role="tab"]${NOT_SELECTOR_MENU_TOGGLE}`;
const SELECTOR_DATA_TOGGLE$1 = "[data-bs-toggle=\"tab\"]";
const SELECTOR_INNER_ELEM = `${SELECTOR_INNER}, ${SELECTOR_DATA_TOGGLE$1}`;
const SELECTOR_DATA_TOGGLE_ACTIVE = `.${CLASS_NAME_ACTIVE}[data-bs-toggle="tab"]`;
const activationIds = /* @__PURE__ */ new WeakMap();
/**
* Class definition
*/
var Tab = class Tab extends BaseComponent {
constructor(element) {
super(element);
this._parent = this._element.closest(SELECTOR_TAB_PANEL);
if (!this._parent) throw new TypeError(`${this._element.outerHTML} has no valid parent ${SELECTOR_TAB_PANEL}`);
this._setInitialAttributes(this._parent, this._getChildren());
EventHandler.on(this._element, EVENT_KEYDOWN, (event) => this._keydown(event));
}
static get NAME() {
return NAME$2;
}
async 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;
if (EventHandler.trigger(innerElem, EVENT_SHOW$1, { relatedTarget: active }).defaultPrevented || hideEvent && hideEvent.defaultPrevented) return;
const activationId = (activationIds.get(this._parent) || 0) + 1;
activationIds.set(this._parent, activationId);
this._deactivate(active, innerElem);
await this._activate(innerElem, active, activationId);
}
async _activate(element, relatedElem, activationId) {
if (!element) return;
element.classList.add(CLASS_NAME_ACTIVE);
if (element.getAttribute("role") !== "tab") {
element.classList.add(CLASS_NAME_SHOW$1);
return;
}
const pane = SelectorEngine.getElementFromSelector(element);
this._activate(pane);
const complete = () => {
if (activationId !== activationIds.get(this._parent) || !this._elemIsActive(element)) return;
element.removeAttribute("tabindex");
setAriaAttribute(element, "aria-selected", true);
this._toggleMenu(element, true);
EventHandler.trigger(element, EVENT_SHOWN$1, { relatedTarget: relatedElem });
};
await this._queueCallback(complete, pane ?? element, getTransitionDurationFromElement(pane) > 0);
}
async _deactivate(element, relatedElem) {
if (!element) return;
element.classList.remove(CLASS_NAME_ACTIVE);
element.blur();
if (element.getAttribute("role") !== "tab") {
element.classList.remove(CLASS_NAME_SHOW$1);
return;
}
this._deactivate(SelectorEngine.getElementFromSelector(element));
const complete = () => {
setAriaAttribute(element, "aria-selected", false);
element.setAttribute("tabindex", "-1");
this._toggleMenu(element, false);
EventHandler.trigger(element, EVENT_HIDDEN$1, { relatedTarget: relatedElem });
};
await this._queueCallback(complete, element, false);
}
_keydown(event) {
if (![
ARROW_LEFT_KEY,
ARROW_RIGHT_KEY,
ARROW_UP_KEY,
ARROW_DOWN_KEY,
HOME_KEY,
END_KEY
].includes(event.key)) return;
if (event.altKey || event.ctrlKey || event.metaKey) return;
event.stopPropagation();
event.preventDefault();
const children = this._getChildren().filter((element) => !isDisabled(element));
let nextActiveElement;
if ([HOME_KEY, END_KEY].includes(event.key)) nextActiveElement = event.key === HOME_KEY ? children[0] : children.at(-1);
else {
const isNext = [ARROW_RIGHT_KEY, ARROW_DOWN_KEY].includes(event.key);
nextActiveElement = getNextActiveElement(children, 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);
setAriaAttribute(child, "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}`);
}
_toggleMenu(element, open) {
const outerElem = this._getOuterElement(element);
const menuToggle = SelectorEngine.findOne(SELECTOR_MENU_TOGGLE, outerElem);
if (!menuToggle) return;
const menu = SelectorEngine.findOne(SELECTOR_MENU, outerElem);
menuToggle.classList.toggle(CLASS_NAME_ACTIVE, open);
if (menu) menu.classList.toggle(CLASS_NAME_SHOW$1, open);
setAriaAttribute(menuToggle, "aria-expanded", open);
}
_setAttributeIfNotExists(element, attribute, value) {
if (!element.hasAttribute(attribute)) element.setAttribute(attribute, value);
}
_elemIsActive(elem) {
return elem.classList.contains(CLASS_NAME_ACTIVE);
}
_getInnerElement(elem) {
return elem.matches(SELECTOR_INNER_ELEM) ? elem : SelectorEngine.findOne(SELECTOR_INNER_ELEM, elem);
}
_getOuterElement(elem) {
return elem.closest(SELECTOR_OUTER) || elem;
}
};
/**
* Data API implementation
*/
EventHandler.on(document, EVENT_CLICK_DATA_API, SELECTOR_DATA_TOGGLE$1, function(event) {
if (["A", "AREA"].includes(this.tagName)) event.preventDefault();
if (isDisabled(this)) return;
Tab.getOrCreateInstance(this).show();
});
/**
* Initialize on focus
*/
EventHandler.on(window, EVENT_LOAD_DATA_API, () => {
for (const element of SelectorEngine.find(SELECTOR_DATA_TOGGLE_ACTIVE)) Tab.getOrCreateInstance(element);
});
/**
* Find the tab trigger that targets a pane.
*/
const getTabTriggerFromPane = (pane) => {
const labelledBy = pane.getAttribute("aria-labelledby");
if (labelledBy) {
const byLabel = document.getElementById(labelledBy);
if (byLabel?.matches(SELECTOR_DATA_TOGGLE$1)) return byLabel;
}
const { id } = pane;
if (!id) return null;
const escapedId = CSS.escape(id);
return SelectorEngine.findOne(`${SELECTOR_DATA_TOGGLE$1}[data-bs-target="#${escapedId}"], ${SELECTOR_DATA_TOGGLE$1}[href="#${escapedId}"]`);
};
/**
* Open opted-in tab panes when the URL fragment matches their id.
* Put `data-bs-hash` on the tab pane.
*/
enableHashTarget(`${EVENT_KEY$2}.data-api`, {
matches: (element) => Boolean(getTabTriggerFromPane(element)),
getAnchor: getTabTriggerFromPane,
async open(element, done) {
const trigger = getTabTriggerFromPane(element);
if (!trigger) return;
if (trigger.classList.contains(CLASS_NAME_ACTIVE)) {
done();
return;
}
await Tab.getOrCreateInstance(trigger).show();
if (trigger.classList.contains(CLASS_NAME_ACTIVE)) done();
}
});
//#endregion
//#region js/src/toast.ts
/**
* --------------------------------------------------------------------------
* Bootstrap toast.ts
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
* --------------------------------------------------------------------------
*/
/**
* Constants
*/
const NAME$1 = "toast";
const EVENT_KEY$1 = `.bs.toast`;
const EVENT_MOUSEOVER = `mouseover${EVENT_KEY$1}`;
const EVENT_MOUSEOUT = `mouseout${EVENT_KEY$1}`;
const EVENT_FOCUSIN = `focusin${EVENT_KEY$1}`;
const EVENT_FOCUSOUT = `focusout${EVENT_KEY$1}`;
const EVENT_HIDE = `hide${EVENT_KEY$1}`;
const EVENT_HIDDEN = `hidden${EVENT_KEY$1}`;
const EVENT_SHOW = `show${EVENT_KEY$1}`;
const EVENT_SHOWN = `shown${EVENT_KEY$1}`;
const CLASS_NAME_INSTANT = "toast-instant";
const CLASS_NAME_SHOW = "show";
const DefaultType$1 = {
autohide: "boolean",
delay: "number"
};
const Default$1 = {
autohide: true,
delay: 5e3
};
/**
* Class definition
*/
var Toast = class extends BaseComponent {
constructor(element, config) {
super(element, config);
this._timeout = null;
this._hasMouseInteraction = false;
this._hasKeyboardInteraction = false;
this._setListeners();
}
static get Default() {
return Default$1;
}
static get DefaultType() {
return DefaultType$1;
}
static get NAME() {
return NAME$1;
}
async show() {
if (EventHandler.trigger(this._element, EVENT_SHOW).defaultPrevented) return;
this._clearTimeout();
const complete = () => {
EventHandler.trigger(this._element, EVENT_SHOWN);
this._maybeScheduleHide();
};
this._element.classList.add(CLASS_NAME_SHOW);
await this._queueCallback(complete, this._element, this._isAnimated());
}
async hide() {
if (!this.isShown()) return;
if (EventHandler.trigger(this._element, EVENT_HIDE).defaultPrevented) return;
const complete = () => {
EventHandler.trigger(this._element, EVENT_HIDDEN);
};
this._element.classList.remove(CLASS_NAME_SHOW);
await this._queueCallback(complete, this._element, this._isAnimated());
}
dispose() {
this._clearTimeout();
if (this.isShown()) this._element.classList.remove(CLASS_NAME_SHOW);
super.dispose();
}
isShown() {
return this._element.classList.contains(CLASS_NAME_SHOW);
}
_isAnimated() {
return !this._element.classList.contains(CLASS_NAME_INSTANT);
}
_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;
default: 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;
}
};
/**
* Data API implementation
*/
enableDismissTrigger(Toast);
//#endregion
//#region js/src/toggler.ts
/**
* --------------------------------------------------------------------------
* Bootstrap toggler.ts
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
* --------------------------------------------------------------------------
*/
/**
* Constants
*/
const NAME = "toggler";
const EVENT_KEY = `.bs.toggler`;
const EVENT_TOGGLE = `toggle${EVENT_KEY}`;
const EVENT_TOGGLED = `toggled${EVENT_KEY}`;
const EVENT_CLICK = "click";
const SELECTOR_DATA_TOGGLE = "[data-bs-toggle=\"toggler\"]";
const EVENT_HANDLER_PATTERN = /^on/i;
const DISALLOWED_ATTRIBUTES = /* @__PURE__ */ new Set([
"action",
"background",
"data",
"formaction",
"href",
"id",
"poster",
"src",
"srcdoc",
"srcset",
"style",
"xlink:href"
]);
const DefaultType = {
attribute: "string",
value: "(string|number|boolean|null)"
};
const Default = {
attribute: "class",
value: null
};
/**
* Class definition
*/
var Toggler = class extends BaseComponent {
static get Default() {
return Default;
}
static get DefaultType() {
return DefaultType;
}
static get NAME() {
return NAME;
}
toggle() {
if (EventHandler.trigger(this._element, EVENT_TOGGLE).defaultPrevented) return;
this._execute();
EventHandler.trigger(this._element, EVENT_TOGGLED);
}
_execute() {
const { attribute, value } = this._config;
if (EVENT_HANDLER_PATTERN.test(attribute) || DISALLOWED_ATTRIBUTES.has(attribute.toLowerCase())) return;
if (value === null || value === void 0) return;
if (attribute === "class") {
this._element.classList.toggle(value);
return;
}
if (this._element.getAttribute(attribute) === String(value)) {
this._element.removeAttribute(attribute);
return;
}
this._element.setAttribute(attribute, value);
}
};
/**
* Data API implementation
*/
eventActionOnPlugin(Toggler, EVENT_CLICK, SELECTOR_DATA_TOGGLE, "toggle");
//#endregion
export { Alert, Button, Carousel, Collapse, Combobox, Datepicker, Dialog, Drawer, Menu, NavOverflow, OtpInput, Popover, Range, ScrollSpy, Strength, Tab, Toast, Toggler, Tooltip };
//# sourceMappingURL=bootstrap.js.map