You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

6812 lines
205 KiB

  1. /*!
  2. * Bootstrap v5.1.3 (https://getbootstrap.com/)
  3. * Copyright 2011-2021 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors)
  4. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
  5. */
  6. (function (global, factory) {
  7. typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
  8. typeof define === 'function' && define.amd ? define(factory) :
  9. (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.bootstrap = factory());
  10. })(this, (function () { 'use strict';
  11. /**
  12. * --------------------------------------------------------------------------
  13. * Bootstrap (v5.1.3): util/index.js
  14. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
  15. * --------------------------------------------------------------------------
  16. */
  17. const MAX_UID = 1000000;
  18. const MILLISECONDS_MULTIPLIER = 1000;
  19. const TRANSITION_END = 'transitionend'; // Shoutout AngusCroll (https://goo.gl/pxwQGp)
  20. const toType = obj => {
  21. if (obj === null || obj === undefined) {
  22. return `${obj}`;
  23. }
  24. return {}.toString.call(obj).match(/\s([a-z]+)/i)[1].toLowerCase();
  25. };
  26. /**
  27. * --------------------------------------------------------------------------
  28. * Public Util Api
  29. * --------------------------------------------------------------------------
  30. */
  31. const getUID = prefix => {
  32. do {
  33. prefix += Math.floor(Math.random() * MAX_UID);
  34. } while (document.getElementById(prefix));
  35. return prefix;
  36. };
  37. const getSelector = element => {
  38. let selector = element.getAttribute('data-bs-target');
  39. if (!selector || selector === '#') {
  40. let hrefAttr = element.getAttribute('href'); // The only valid content that could double as a selector are IDs or classes,
  41. // so everything starting with `#` or `.`. If a "real" URL is used as the selector,
  42. // `document.querySelector` will rightfully complain it is invalid.
  43. // See https://github.com/twbs/bootstrap/issues/32273
  44. if (!hrefAttr || !hrefAttr.includes('#') && !hrefAttr.startsWith('.')) {
  45. return null;
  46. } // Just in case some CMS puts out a full URL with the anchor appended
  47. if (hrefAttr.includes('#') && !hrefAttr.startsWith('#')) {
  48. hrefAttr = `#${hrefAttr.split('#')[1]}`;
  49. }
  50. selector = hrefAttr && hrefAttr !== '#' ? hrefAttr.trim() : null;
  51. }
  52. return selector;
  53. };
  54. const getSelectorFromElement = element => {
  55. const selector = getSelector(element);
  56. if (selector) {
  57. return document.querySelector(selector) ? selector : null;
  58. }
  59. return null;
  60. };
  61. const getElementFromSelector = element => {
  62. const selector = getSelector(element);
  63. return selector ? document.querySelector(selector) : null;
  64. };
  65. const getTransitionDurationFromElement = element => {
  66. if (!element) {
  67. return 0;
  68. } // Get transition-duration of the element
  69. let {
  70. transitionDuration,
  71. transitionDelay
  72. } = window.getComputedStyle(element);
  73. const floatTransitionDuration = Number.parseFloat(transitionDuration);
  74. const floatTransitionDelay = Number.parseFloat(transitionDelay); // Return 0 if element or transition duration is not found
  75. if (!floatTransitionDuration && !floatTransitionDelay) {
  76. return 0;
  77. } // If multiple durations are defined, take the first
  78. transitionDuration = transitionDuration.split(',')[0];
  79. transitionDelay = transitionDelay.split(',')[0];
  80. return (Number.parseFloat(transitionDuration) + Number.parseFloat(transitionDelay)) * MILLISECONDS_MULTIPLIER;
  81. };
  82. const triggerTransitionEnd = element => {
  83. element.dispatchEvent(new Event(TRANSITION_END));
  84. };
  85. const isElement$1 = obj => {
  86. if (!obj || typeof obj !== 'object') {
  87. return false;
  88. }
  89. if (typeof obj.jquery !== 'undefined') {
  90. obj = obj[0];
  91. }
  92. return typeof obj.nodeType !== 'undefined';
  93. };
  94. const getElement = obj => {
  95. if (isElement$1(obj)) {
  96. // it's a jQuery object or a node element
  97. return obj.jquery ? obj[0] : obj;
  98. }
  99. if (typeof obj === 'string' && obj.length > 0) {
  100. return document.querySelector(obj);
  101. }
  102. return null;
  103. };
  104. const typeCheckConfig = (componentName, config, configTypes) => {
  105. Object.keys(configTypes).forEach(property => {
  106. const expectedTypes = configTypes[property];
  107. const value = config[property];
  108. const valueType = value && isElement$1(value) ? 'element' : toType(value);
  109. if (!new RegExp(expectedTypes).test(valueType)) {
  110. throw new TypeError(`${componentName.toUpperCase()}: Option "${property}" provided type "${valueType}" but expected type "${expectedTypes}".`);
  111. }
  112. });
  113. };
  114. const isVisible = element => {
  115. if (!isElement$1(element) || element.getClientRects().length === 0) {
  116. return false;
  117. }
  118. return getComputedStyle(element).getPropertyValue('visibility') === 'visible';
  119. };
  120. const isDisabled = element => {
  121. if (!element || element.nodeType !== Node.ELEMENT_NODE) {
  122. return true;
  123. }
  124. if (element.classList.contains('disabled')) {
  125. return true;
  126. }
  127. if (typeof element.disabled !== 'undefined') {
  128. return element.disabled;
  129. }
  130. return element.hasAttribute('disabled') && element.getAttribute('disabled') !== 'false';
  131. };
  132. const findShadowRoot = element => {
  133. if (!document.documentElement.attachShadow) {
  134. return null;
  135. } // Can find the shadow root otherwise it'll return the document
  136. if (typeof element.getRootNode === 'function') {
  137. const root = element.getRootNode();
  138. return root instanceof ShadowRoot ? root : null;
  139. }
  140. if (element instanceof ShadowRoot) {
  141. return element;
  142. } // when we don't find a shadow root
  143. if (!element.parentNode) {
  144. return null;
  145. }
  146. return findShadowRoot(element.parentNode);
  147. };
  148. const noop = () => {};
  149. /**
  150. * Trick to restart an element's animation
  151. *
  152. * @param {HTMLElement} element
  153. * @return void
  154. *
  155. * @see https://www.charistheo.io/blog/2021/02/restart-a-css-animation-with-javascript/#restarting-a-css-animation
  156. */
  157. const reflow = element => {
  158. // eslint-disable-next-line no-unused-expressions
  159. element.offsetHeight;
  160. };
  161. const getjQuery = () => {
  162. const {
  163. jQuery
  164. } = window;
  165. if (jQuery && !document.body.hasAttribute('data-bs-no-jquery')) {
  166. return jQuery;
  167. }
  168. return null;
  169. };
  170. const DOMContentLoadedCallbacks = [];
  171. const onDOMContentLoaded = callback => {
  172. if (document.readyState === 'loading') {
  173. // add listener on the first call when the document is in loading state
  174. if (!DOMContentLoadedCallbacks.length) {
  175. document.addEventListener('DOMContentLoaded', () => {
  176. DOMContentLoadedCallbacks.forEach(callback => callback());
  177. });
  178. }
  179. DOMContentLoadedCallbacks.push(callback);
  180. } else {
  181. callback();
  182. }
  183. };
  184. const isRTL = () => document.documentElement.dir === 'rtl';
  185. const defineJQueryPlugin = plugin => {
  186. onDOMContentLoaded(() => {
  187. const $ = getjQuery();
  188. /* istanbul ignore if */
  189. if ($) {
  190. const name = plugin.NAME;
  191. const JQUERY_NO_CONFLICT = $.fn[name];
  192. $.fn[name] = plugin.jQueryInterface;
  193. $.fn[name].Constructor = plugin;
  194. $.fn[name].noConflict = () => {
  195. $.fn[name] = JQUERY_NO_CONFLICT;
  196. return plugin.jQueryInterface;
  197. };
  198. }
  199. });
  200. };
  201. const execute = callback => {
  202. if (typeof callback === 'function') {
  203. callback();
  204. }
  205. };
  206. const executeAfterTransition = (callback, transitionElement, waitForTransition = true) => {
  207. if (!waitForTransition) {
  208. execute(callback);
  209. return;
  210. }
  211. const durationPadding = 5;
  212. const emulatedDuration = getTransitionDurationFromElement(transitionElement) + durationPadding;
  213. let called = false;
  214. const handler = ({
  215. target
  216. }) => {
  217. if (target !== transitionElement) {
  218. return;
  219. }
  220. called = true;
  221. transitionElement.removeEventListener(TRANSITION_END, handler);
  222. execute(callback);
  223. };
  224. transitionElement.addEventListener(TRANSITION_END, handler);
  225. setTimeout(() => {
  226. if (!called) {
  227. triggerTransitionEnd(transitionElement);
  228. }
  229. }, emulatedDuration);
  230. };
  231. /**
  232. * Return the previous/next element of a list.
  233. *
  234. * @param {array} list The list of elements
  235. * @param activeElement The active element
  236. * @param shouldGetNext Choose to get next or previous element
  237. * @param isCycleAllowed
  238. * @return {Element|elem} The proper element
  239. */
  240. const getNextActiveElement = (list, activeElement, shouldGetNext, isCycleAllowed) => {
  241. let index = list.indexOf(activeElement); // if the element does not exist in the list return an element depending on the direction and if cycle is allowed
  242. if (index === -1) {
  243. return list[!shouldGetNext && isCycleAllowed ? list.length - 1 : 0];
  244. }
  245. const listLength = list.length;
  246. index += shouldGetNext ? 1 : -1;
  247. if (isCycleAllowed) {
  248. index = (index + listLength) % listLength;
  249. }
  250. return list[Math.max(0, Math.min(index, listLength - 1))];
  251. };
  252. /**
  253. * --------------------------------------------------------------------------
  254. * Bootstrap (v5.1.3): dom/event-handler.js
  255. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
  256. * --------------------------------------------------------------------------
  257. */
  258. /**
  259. * ------------------------------------------------------------------------
  260. * Constants
  261. * ------------------------------------------------------------------------
  262. */
  263. const namespaceRegex = /[^.]*(?=\..*)\.|.*/;
  264. const stripNameRegex = /\..*/;
  265. const stripUidRegex = /::\d+$/;
  266. const eventRegistry = {}; // Events storage
  267. let uidEvent = 1;
  268. const customEvents = {
  269. mouseenter: 'mouseover',
  270. mouseleave: 'mouseout'
  271. };
  272. const customEventsRegex = /^(mouseenter|mouseleave)/i;
  273. const nativeEvents = new Set(['click', 'dblclick', 'mouseup', 'mousedown', 'contextmenu', 'mousewheel', 'DOMMouseScroll', 'mouseover', 'mouseout', 'mousemove', 'selectstart', 'selectend', 'keydown', 'keypress', 'keyup', 'orientationchange', 'touchstart', 'touchmove', 'touchend', 'touchcancel', 'pointerdown', 'pointermove', 'pointerup', 'pointerleave', 'pointercancel', 'gesturestart', 'gesturechange', 'gestureend', 'focus', 'blur', 'change', 'reset', 'select', 'submit', 'focusin', 'focusout', 'load', 'unload', 'beforeunload', 'resize', 'move', 'DOMContentLoaded', 'readystatechange', 'error', 'abort', 'scroll']);
  274. /**
  275. * ------------------------------------------------------------------------
  276. * Private methods
  277. * ------------------------------------------------------------------------
  278. */
  279. function getUidEvent(element, uid) {
  280. return uid && `${uid}::${uidEvent++}` || element.uidEvent || uidEvent++;
  281. }
  282. function getEvent(element) {
  283. const uid = getUidEvent(element);
  284. element.uidEvent = uid;
  285. eventRegistry[uid] = eventRegistry[uid] || {};
  286. return eventRegistry[uid];
  287. }
  288. function bootstrapHandler(element, fn) {
  289. return function handler(event) {
  290. event.delegateTarget = element;
  291. if (handler.oneOff) {
  292. EventHandler.off(element, event.type, fn);
  293. }
  294. return fn.apply(element, [event]);
  295. };
  296. }
  297. function bootstrapDelegationHandler(element, selector, fn) {
  298. return function handler(event) {
  299. const domElements = element.querySelectorAll(selector);
  300. for (let {
  301. target
  302. } = event; target && target !== this; target = target.parentNode) {
  303. for (let i = domElements.length; i--;) {
  304. if (domElements[i] === target) {
  305. event.delegateTarget = target;
  306. if (handler.oneOff) {
  307. EventHandler.off(element, event.type, selector, fn);
  308. }
  309. return fn.apply(target, [event]);
  310. }
  311. }
  312. } // To please ESLint
  313. return null;
  314. };
  315. }
  316. function findHandler(events, handler, delegationSelector = null) {
  317. const uidEventList = Object.keys(events);
  318. for (let i = 0, len = uidEventList.length; i < len; i++) {
  319. const event = events[uidEventList[i]];
  320. if (event.originalHandler === handler && event.delegationSelector === delegationSelector) {
  321. return event;
  322. }
  323. }
  324. return null;
  325. }
  326. function normalizeParams(originalTypeEvent, handler, delegationFn) {
  327. const delegation = typeof handler === 'string';
  328. const originalHandler = delegation ? delegationFn : handler;
  329. let typeEvent = getTypeEvent(originalTypeEvent);
  330. const isNative = nativeEvents.has(typeEvent);
  331. if (!isNative) {
  332. typeEvent = originalTypeEvent;
  333. }
  334. return [delegation, originalHandler, typeEvent];
  335. }
  336. function addHandler(element, originalTypeEvent, handler, delegationFn, oneOff) {
  337. if (typeof originalTypeEvent !== 'string' || !element) {
  338. return;
  339. }
  340. if (!handler) {
  341. handler = delegationFn;
  342. delegationFn = null;
  343. } // in case of mouseenter or mouseleave wrap the handler within a function that checks for its DOM position
  344. // this prevents the handler from being dispatched the same way as mouseover or mouseout does
  345. if (customEventsRegex.test(originalTypeEvent)) {
  346. const wrapFn = fn => {
  347. return function (event) {
  348. if (!event.relatedTarget || event.relatedTarget !== event.delegateTarget && !event.delegateTarget.contains(event.relatedTarget)) {
  349. return fn.call(this, event);
  350. }
  351. };
  352. };
  353. if (delegationFn) {
  354. delegationFn = wrapFn(delegationFn);
  355. } else {
  356. handler = wrapFn(handler);
  357. }
  358. }
  359. const [delegation, originalHandler, typeEvent] = normalizeParams(originalTypeEvent, handler, delegationFn);
  360. const events = getEvent(element);
  361. const handlers = events[typeEvent] || (events[typeEvent] = {});
  362. const previousFn = findHandler(handlers, originalHandler, delegation ? handler : null);
  363. if (previousFn) {
  364. previousFn.oneOff = previousFn.oneOff && oneOff;
  365. return;
  366. }
  367. const uid = getUidEvent(originalHandler, originalTypeEvent.replace(namespaceRegex, ''));
  368. const fn = delegation ? bootstrapDelegationHandler(element, handler, delegationFn) : bootstrapHandler(element, handler);
  369. fn.delegationSelector = delegation ? handler : null;
  370. fn.originalHandler = originalHandler;
  371. fn.oneOff = oneOff;
  372. fn.uidEvent = uid;
  373. handlers[uid] = fn;
  374. element.addEventListener(typeEvent, fn, delegation);
  375. }
  376. function removeHandler(element, events, typeEvent, handler, delegationSelector) {
  377. const fn = findHandler(events[typeEvent], handler, delegationSelector);
  378. if (!fn) {
  379. return;
  380. }
  381. element.removeEventListener(typeEvent, fn, Boolean(delegationSelector));
  382. delete events[typeEvent][fn.uidEvent];
  383. }
  384. function removeNamespacedHandlers(element, events, typeEvent, namespace) {
  385. const storeElementEvent = events[typeEvent] || {};
  386. Object.keys(storeElementEvent).forEach(handlerKey => {
  387. if (handlerKey.includes(namespace)) {
  388. const event = storeElementEvent[handlerKey];
  389. removeHandler(element, events, typeEvent, event.originalHandler, event.delegationSelector);
  390. }
  391. });
  392. }
  393. function getTypeEvent(event) {
  394. // allow to get the native events from namespaced events ('click.bs.button' --> 'click')
  395. event = event.replace(stripNameRegex, '');
  396. return customEvents[event] || event;
  397. }
  398. const EventHandler = {
  399. on(element, event, handler, delegationFn) {
  400. addHandler(element, event, handler, delegationFn, false);
  401. },
  402. one(element, event, handler, delegationFn) {
  403. addHandler(element, event, handler, delegationFn, true);
  404. },
  405. off(element, originalTypeEvent, handler, delegationFn) {
  406. if (typeof originalTypeEvent !== 'string' || !element) {
  407. return;
  408. }
  409. const [delegation, originalHandler, typeEvent] = normalizeParams(originalTypeEvent, handler, delegationFn);
  410. const inNamespace = typeEvent !== originalTypeEvent;
  411. const events = getEvent(element);
  412. const isNamespace = originalTypeEvent.startsWith('.');
  413. if (typeof originalHandler !== 'undefined') {
  414. // Simplest case: handler is passed, remove that listener ONLY.
  415. if (!events || !events[typeEvent]) {
  416. return;
  417. }
  418. removeHandler(element, events, typeEvent, originalHandler, delegation ? handler : null);
  419. return;
  420. }
  421. if (isNamespace) {
  422. Object.keys(events).forEach(elementEvent => {
  423. removeNamespacedHandlers(element, events, elementEvent, originalTypeEvent.slice(1));
  424. });
  425. }
  426. const storeElementEvent = events[typeEvent] || {};
  427. Object.keys(storeElementEvent).forEach(keyHandlers => {
  428. const handlerKey = keyHandlers.replace(stripUidRegex, '');
  429. if (!inNamespace || originalTypeEvent.includes(handlerKey)) {
  430. const event = storeElementEvent[keyHandlers];
  431. removeHandler(element, events, typeEvent, event.originalHandler, event.delegationSelector);
  432. }
  433. });
  434. },
  435. trigger(element, event, args) {
  436. if (typeof event !== 'string' || !element) {
  437. return null;
  438. }
  439. const $ = getjQuery();
  440. const typeEvent = getTypeEvent(event);
  441. const inNamespace = event !== typeEvent;
  442. const isNative = nativeEvents.has(typeEvent);
  443. let jQueryEvent;
  444. let bubbles = true;
  445. let nativeDispatch = true;
  446. let defaultPrevented = false;
  447. let evt = null;
  448. if (inNamespace && $) {
  449. jQueryEvent = $.Event(event, args);
  450. $(element).trigger(jQueryEvent);
  451. bubbles = !jQueryEvent.isPropagationStopped();
  452. nativeDispatch = !jQueryEvent.isImmediatePropagationStopped();
  453. defaultPrevented = jQueryEvent.isDefaultPrevented();
  454. }
  455. if (isNative) {
  456. evt = document.createEvent('HTMLEvents');
  457. evt.initEvent(typeEvent, bubbles, true);
  458. } else {
  459. evt = new CustomEvent(event, {
  460. bubbles,
  461. cancelable: true
  462. });
  463. } // merge custom information in our event
  464. if (typeof args !== 'undefined') {
  465. Object.keys(args).forEach(key => {
  466. Object.defineProperty(evt, key, {
  467. get() {
  468. return args[key];
  469. }
  470. });
  471. });
  472. }
  473. if (defaultPrevented) {
  474. evt.preventDefault();
  475. }
  476. if (nativeDispatch) {
  477. element.dispatchEvent(evt);
  478. }
  479. if (evt.defaultPrevented && typeof jQueryEvent !== 'undefined') {
  480. jQueryEvent.preventDefault();
  481. }
  482. return evt;
  483. }
  484. };
  485. /**
  486. * --------------------------------------------------------------------------
  487. * Bootstrap (v5.1.3): dom/data.js
  488. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
  489. * --------------------------------------------------------------------------
  490. */
  491. /**
  492. * ------------------------------------------------------------------------
  493. * Constants
  494. * ------------------------------------------------------------------------
  495. */
  496. const elementMap = new Map();
  497. const Data = {
  498. set(element, key, instance) {
  499. if (!elementMap.has(element)) {
  500. elementMap.set(element, new Map());
  501. }
  502. const instanceMap = elementMap.get(element); // make it clear we only want one instance per element
  503. // can be removed later when multiple key/instances are fine to be used
  504. if (!instanceMap.has(key) && instanceMap.size !== 0) {
  505. // eslint-disable-next-line no-console
  506. console.error(`Bootstrap doesn't allow more than one instance per element. Bound instance: ${Array.from(instanceMap.keys())[0]}.`);
  507. return;
  508. }
  509. instanceMap.set(key, instance);
  510. },
  511. get(element, key) {
  512. if (elementMap.has(element)) {
  513. return elementMap.get(element).get(key) || null;
  514. }
  515. return null;
  516. },
  517. remove(element, key) {
  518. if (!elementMap.has(element)) {
  519. return;
  520. }
  521. const instanceMap = elementMap.get(element);
  522. instanceMap.delete(key); // free up element references if there are no instances left for an element
  523. if (instanceMap.size === 0) {
  524. elementMap.delete(element);
  525. }
  526. }
  527. };
  528. /**
  529. * --------------------------------------------------------------------------
  530. * Bootstrap (v5.1.3): base-component.js
  531. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
  532. * --------------------------------------------------------------------------
  533. */
  534. /**
  535. * ------------------------------------------------------------------------
  536. * Constants
  537. * ------------------------------------------------------------------------
  538. */
  539. const VERSION = '5.1.3';
  540. class BaseComponent {
  541. constructor(element) {
  542. element = getElement(element);
  543. if (!element) {
  544. return;
  545. }
  546. this._element = element;
  547. Data.set(this._element, this.constructor.DATA_KEY, this);
  548. }
  549. dispose() {
  550. Data.remove(this._element, this.constructor.DATA_KEY);
  551. EventHandler.off(this._element, this.constructor.EVENT_KEY);
  552. Object.getOwnPropertyNames(this).forEach(propertyName => {
  553. this[propertyName] = null;
  554. });
  555. }
  556. _queueCallback(callback, element, isAnimated = true) {
  557. executeAfterTransition(callback, element, isAnimated);
  558. }
  559. /** Static */
  560. static getInstance(element) {
  561. return Data.get(getElement(element), this.DATA_KEY);
  562. }
  563. static getOrCreateInstance(element, config = {}) {
  564. return this.getInstance(element) || new this(element, typeof config === 'object' ? config : null);
  565. }
  566. static get VERSION() {
  567. return VERSION;
  568. }
  569. static get NAME() {
  570. throw new Error('You have to implement the static method "NAME", for each component!');
  571. }
  572. static get DATA_KEY() {
  573. return `bs.${this.NAME}`;
  574. }
  575. static get EVENT_KEY() {
  576. return `.${this.DATA_KEY}`;
  577. }
  578. }
  579. /**
  580. * --------------------------------------------------------------------------
  581. * Bootstrap (v5.1.3): util/component-functions.js
  582. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
  583. * --------------------------------------------------------------------------
  584. */
  585. const enableDismissTrigger = (component, method = 'hide') => {
  586. const clickEvent = `click.dismiss${component.EVENT_KEY}`;
  587. const name = component.NAME;
  588. EventHandler.on(document, clickEvent, `[data-bs-dismiss="${name}"]`, function (event) {
  589. if (['A', 'AREA'].includes(this.tagName)) {
  590. event.preventDefault();
  591. }
  592. if (isDisabled(this)) {
  593. return;
  594. }
  595. const target = getElementFromSelector(this) || this.closest(`.${name}`);
  596. const instance = component.getOrCreateInstance(target); // Method argument is left, for Alert and only, as it doesn't implement the 'hide' method
  597. instance[method]();
  598. });
  599. };
  600. /**
  601. * --------------------------------------------------------------------------
  602. * Bootstrap (v5.1.3): alert.js
  603. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
  604. * --------------------------------------------------------------------------
  605. */
  606. /**
  607. * ------------------------------------------------------------------------
  608. * Constants
  609. * ------------------------------------------------------------------------
  610. */
  611. const NAME$d = 'alert';
  612. const DATA_KEY$c = 'bs.alert';
  613. const EVENT_KEY$c = `.${DATA_KEY$c}`;
  614. const EVENT_CLOSE = `close${EVENT_KEY$c}`;
  615. const EVENT_CLOSED = `closed${EVENT_KEY$c}`;
  616. const CLASS_NAME_FADE$5 = 'fade';
  617. const CLASS_NAME_SHOW$8 = 'show';
  618. /**
  619. * ------------------------------------------------------------------------
  620. * Class Definition
  621. * ------------------------------------------------------------------------
  622. */
  623. class Alert extends BaseComponent {
  624. // Getters
  625. static get NAME() {
  626. return NAME$d;
  627. } // Public
  628. close() {
  629. const closeEvent = EventHandler.trigger(this._element, EVENT_CLOSE);
  630. if (closeEvent.defaultPrevented) {
  631. return;
  632. }
  633. this._element.classList.remove(CLASS_NAME_SHOW$8);
  634. const isAnimated = this._element.classList.contains(CLASS_NAME_FADE$5);
  635. this._queueCallback(() => this._destroyElement(), this._element, isAnimated);
  636. } // Private
  637. _destroyElement() {
  638. this._element.remove();
  639. EventHandler.trigger(this._element, EVENT_CLOSED);
  640. this.dispose();
  641. } // Static
  642. static jQueryInterface(config) {
  643. return this.each(function () {
  644. const data = Alert.getOrCreateInstance(this);
  645. if (typeof config !== 'string') {
  646. return;
  647. }
  648. if (data[config] === undefined || config.startsWith('_') || config === 'constructor') {
  649. throw new TypeError(`No method named "${config}"`);
  650. }
  651. data[config](this);
  652. });
  653. }
  654. }
  655. /**
  656. * ------------------------------------------------------------------------
  657. * Data Api implementation
  658. * ------------------------------------------------------------------------
  659. */
  660. enableDismissTrigger(Alert, 'close');
  661. /**
  662. * ------------------------------------------------------------------------
  663. * jQuery
  664. * ------------------------------------------------------------------------
  665. * add .Alert to jQuery only if jQuery is present
  666. */
  667. defineJQueryPlugin(Alert);
  668. /**
  669. * --------------------------------------------------------------------------
  670. * Bootstrap (v5.1.3): button.js
  671. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
  672. * --------------------------------------------------------------------------
  673. */
  674. /**
  675. * ------------------------------------------------------------------------
  676. * Constants
  677. * ------------------------------------------------------------------------
  678. */
  679. const NAME$c = 'button';
  680. const DATA_KEY$b = 'bs.button';
  681. const EVENT_KEY$b = `.${DATA_KEY$b}`;
  682. const DATA_API_KEY$7 = '.data-api';
  683. const CLASS_NAME_ACTIVE$3 = 'active';
  684. const SELECTOR_DATA_TOGGLE$5 = '[data-bs-toggle="button"]';
  685. const EVENT_CLICK_DATA_API$6 = `click${EVENT_KEY$b}${DATA_API_KEY$7}`;
  686. /**
  687. * ------------------------------------------------------------------------
  688. * Class Definition
  689. * ------------------------------------------------------------------------
  690. */
  691. class Button extends BaseComponent {
  692. // Getters
  693. static get NAME() {
  694. return NAME$c;
  695. } // Public
  696. toggle() {
  697. // Toggle class and sync the `aria-pressed` attribute with the return value of the `.toggle()` method
  698. this._element.setAttribute('aria-pressed', this._element.classList.toggle(CLASS_NAME_ACTIVE$3));
  699. } // Static
  700. static jQueryInterface(config) {
  701. return this.each(function () {
  702. const data = Button.getOrCreateInstance(this);
  703. if (config === 'toggle') {
  704. data[config]();
  705. }
  706. });
  707. }
  708. }
  709. /**
  710. * ------------------------------------------------------------------------
  711. * Data Api implementation
  712. * ------------------------------------------------------------------------
  713. */
  714. EventHandler.on(document, EVENT_CLICK_DATA_API$6, SELECTOR_DATA_TOGGLE$5, event => {
  715. event.preventDefault();
  716. const button = event.target.closest(SELECTOR_DATA_TOGGLE$5);
  717. const data = Button.getOrCreateInstance(button);
  718. data.toggle();
  719. });
  720. /**
  721. * ------------------------------------------------------------------------
  722. * jQuery
  723. * ------------------------------------------------------------------------
  724. * add .Button to jQuery only if jQuery is present
  725. */
  726. defineJQueryPlugin(Button);
  727. /**
  728. * --------------------------------------------------------------------------
  729. * Bootstrap (v5.1.3): dom/manipulator.js
  730. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
  731. * --------------------------------------------------------------------------
  732. */
  733. function normalizeData(val) {
  734. if (val === 'true') {
  735. return true;
  736. }
  737. if (val === 'false') {
  738. return false;
  739. }
  740. if (val === Number(val).toString()) {
  741. return Number(val);
  742. }
  743. if (val === '' || val === 'null') {
  744. return null;
  745. }
  746. return val;
  747. }
  748. function normalizeDataKey(key) {
  749. return key.replace(/[A-Z]/g, chr => `-${chr.toLowerCase()}`);
  750. }
  751. const Manipulator = {
  752. setDataAttribute(element, key, value) {
  753. element.setAttribute(`data-bs-${normalizeDataKey(key)}`, value);
  754. },
  755. removeDataAttribute(element, key) {
  756. element.removeAttribute(`data-bs-${normalizeDataKey(key)}`);
  757. },
  758. getDataAttributes(element) {
  759. if (!element) {
  760. return {};
  761. }
  762. const attributes = {};
  763. Object.keys(element.dataset).filter(key => key.startsWith('bs')).forEach(key => {
  764. let pureKey = key.replace(/^bs/, '');
  765. pureKey = pureKey.charAt(0).toLowerCase() + pureKey.slice(1, pureKey.length);
  766. attributes[pureKey] = normalizeData(element.dataset[key]);
  767. });
  768. return attributes;
  769. },
  770. getDataAttribute(element, key) {
  771. return normalizeData(element.getAttribute(`data-bs-${normalizeDataKey(key)}`));
  772. },
  773. offset(element) {
  774. const rect = element.getBoundingClientRect();
  775. return {
  776. top: rect.top + window.pageYOffset,
  777. left: rect.left + window.pageXOffset
  778. };
  779. },
  780. position(element) {
  781. return {
  782. top: element.offsetTop,
  783. left: element.offsetLeft
  784. };
  785. }
  786. };
  787. /**
  788. * --------------------------------------------------------------------------
  789. * Bootstrap (v5.1.3): dom/selector-engine.js
  790. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
  791. * --------------------------------------------------------------------------
  792. */
  793. const NODE_TEXT = 3;
  794. const SelectorEngine = {
  795. find(selector, element = document.documentElement) {
  796. return [].concat(...Element.prototype.querySelectorAll.call(element, selector));
  797. },
  798. findOne(selector, element = document.documentElement) {
  799. return Element.prototype.querySelector.call(element, selector);
  800. },
  801. children(element, selector) {
  802. return [].concat(...element.children).filter(child => child.matches(selector));
  803. },
  804. parents(element, selector) {
  805. const parents = [];
  806. let ancestor = element.parentNode;
  807. while (ancestor && ancestor.nodeType === Node.ELEMENT_NODE && ancestor.nodeType !== NODE_TEXT) {
  808. if (ancestor.matches(selector)) {
  809. parents.push(ancestor);
  810. }
  811. ancestor = ancestor.parentNode;
  812. }
  813. return parents;
  814. },
  815. prev(element, selector) {
  816. let previous = element.previousElementSibling;
  817. while (previous) {
  818. if (previous.matches(selector)) {
  819. return [previous];
  820. }
  821. previous = previous.previousElementSibling;
  822. }
  823. return [];
  824. },
  825. next(element, selector) {
  826. let next = element.nextElementSibling;
  827. while (next) {
  828. if (next.matches(selector)) {
  829. return [next];
  830. }
  831. next = next.nextElementSibling;
  832. }
  833. return [];
  834. },
  835. focusableChildren(element) {
  836. const focusables = ['a', 'button', 'input', 'textarea', 'select', 'details', '[tabindex]', '[contenteditable="true"]'].map(selector => `${selector}:not([tabindex^="-"])`).join(', ');
  837. return this.find(focusables, element).filter(el => !isDisabled(el) && isVisible(el));
  838. }
  839. };
  840. /**
  841. * --------------------------------------------------------------------------
  842. * Bootstrap (v5.1.3): carousel.js
  843. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
  844. * --------------------------------------------------------------------------
  845. */
  846. /**
  847. * ------------------------------------------------------------------------
  848. * Constants
  849. * ------------------------------------------------------------------------
  850. */
  851. const NAME$b = 'carousel';
  852. const DATA_KEY$a = 'bs.carousel';
  853. const EVENT_KEY$a = `.${DATA_KEY$a}`;
  854. const DATA_API_KEY$6 = '.data-api';
  855. const ARROW_LEFT_KEY = 'ArrowLeft';
  856. const ARROW_RIGHT_KEY = 'ArrowRight';
  857. const TOUCHEVENT_COMPAT_WAIT = 500; // Time for mouse compat events to fire after touch
  858. const SWIPE_THRESHOLD = 40;
  859. const Default$a = {
  860. interval: 5000,
  861. keyboard: true,
  862. slide: false,
  863. pause: 'hover',
  864. wrap: true,
  865. touch: true
  866. };
  867. const DefaultType$a = {
  868. interval: '(number|boolean)',
  869. keyboard: 'boolean',
  870. slide: '(boolean|string)',
  871. pause: '(string|boolean)',
  872. wrap: 'boolean',
  873. touch: 'boolean'
  874. };
  875. const ORDER_NEXT = 'next';
  876. const ORDER_PREV = 'prev';
  877. const DIRECTION_LEFT = 'left';
  878. const DIRECTION_RIGHT = 'right';
  879. const KEY_TO_DIRECTION = {
  880. [ARROW_LEFT_KEY]: DIRECTION_RIGHT,
  881. [ARROW_RIGHT_KEY]: DIRECTION_LEFT
  882. };
  883. const EVENT_SLIDE = `slide${EVENT_KEY$a}`;
  884. const EVENT_SLID = `slid${EVENT_KEY$a}`;
  885. const EVENT_KEYDOWN = `keydown${EVENT_KEY$a}`;
  886. const EVENT_MOUSEENTER = `mouseenter${EVENT_KEY$a}`;
  887. const EVENT_MOUSELEAVE = `mouseleave${EVENT_KEY$a}`;
  888. const EVENT_TOUCHSTART = `touchstart${EVENT_KEY$a}`;
  889. const EVENT_TOUCHMOVE = `touchmove${EVENT_KEY$a}`;
  890. const EVENT_TOUCHEND = `touchend${EVENT_KEY$a}`;
  891. const EVENT_POINTERDOWN = `pointerdown${EVENT_KEY$a}`;
  892. const EVENT_POINTERUP = `pointerup${EVENT_KEY$a}`;
  893. const EVENT_DRAG_START = `dragstart${EVENT_KEY$a}`;
  894. const EVENT_LOAD_DATA_API$2 = `load${EVENT_KEY$a}${DATA_API_KEY$6}`;
  895. const EVENT_CLICK_DATA_API$5 = `click${EVENT_KEY$a}${DATA_API_KEY$6}`;
  896. const CLASS_NAME_CAROUSEL = 'carousel';
  897. const CLASS_NAME_ACTIVE$2 = 'active';
  898. const CLASS_NAME_SLIDE = 'slide';
  899. const CLASS_NAME_END = 'carousel-item-end';
  900. const CLASS_NAME_START = 'carousel-item-start';
  901. const CLASS_NAME_NEXT = 'carousel-item-next';
  902. const CLASS_NAME_PREV = 'carousel-item-prev';
  903. const CLASS_NAME_POINTER_EVENT = 'pointer-event';
  904. const SELECTOR_ACTIVE$1 = '.active';
  905. const SELECTOR_ACTIVE_ITEM = '.active.carousel-item';
  906. const SELECTOR_ITEM = '.carousel-item';
  907. const SELECTOR_ITEM_IMG = '.carousel-item img';
  908. const SELECTOR_NEXT_PREV = '.carousel-item-next, .carousel-item-prev';
  909. const SELECTOR_INDICATORS = '.carousel-indicators';
  910. const SELECTOR_INDICATOR = '[data-bs-target]';
  911. const SELECTOR_DATA_SLIDE = '[data-bs-slide], [data-bs-slide-to]';
  912. const SELECTOR_DATA_RIDE = '[data-bs-ride="carousel"]';
  913. const POINTER_TYPE_TOUCH = 'touch';
  914. const POINTER_TYPE_PEN = 'pen';
  915. /**
  916. * ------------------------------------------------------------------------
  917. * Class Definition
  918. * ------------------------------------------------------------------------
  919. */
  920. class Carousel extends BaseComponent {
  921. constructor(element, config) {
  922. super(element);
  923. this._items = null;
  924. this._interval = null;
  925. this._activeElement = null;
  926. this._isPaused = false;
  927. this._isSliding = false;
  928. this.touchTimeout = null;
  929. this.touchStartX = 0;
  930. this.touchDeltaX = 0;
  931. this._config = this._getConfig(config);
  932. this._indicatorsElement = SelectorEngine.findOne(SELECTOR_INDICATORS, this._element);
  933. this._touchSupported = 'ontouchstart' in document.documentElement || navigator.maxTouchPoints > 0;
  934. this._pointerEvent = Boolean(window.PointerEvent);
  935. this._addEventListeners();
  936. } // Getters
  937. static get Default() {
  938. return Default$a;
  939. }
  940. static get NAME() {
  941. return NAME$b;
  942. } // Public
  943. next() {
  944. this._slide(ORDER_NEXT);
  945. }
  946. nextWhenVisible() {
  947. // Don't call next when the page isn't visible
  948. // or the carousel or its parent isn't visible
  949. if (!document.hidden && isVisible(this._element)) {
  950. this.next();
  951. }
  952. }
  953. prev() {
  954. this._slide(ORDER_PREV);
  955. }
  956. pause(event) {
  957. if (!event) {
  958. this._isPaused = true;
  959. }
  960. if (SelectorEngine.findOne(SELECTOR_NEXT_PREV, this._element)) {
  961. triggerTransitionEnd(this._element);
  962. this.cycle(true);
  963. }
  964. clearInterval(this._interval);
  965. this._interval = null;
  966. }
  967. cycle(event) {
  968. if (!event) {
  969. this._isPaused = false;
  970. }
  971. if (this._interval) {
  972. clearInterval(this._interval);
  973. this._interval = null;
  974. }
  975. if (this._config && this._config.interval && !this._isPaused) {
  976. this._updateInterval();
  977. this._interval = setInterval((document.visibilityState ? this.nextWhenVisible : this.next).bind(this), this._config.interval);
  978. }
  979. }
  980. to(index) {
  981. this._activeElement = SelectorEngine.findOne(SELECTOR_ACTIVE_ITEM, this._element);
  982. const activeIndex = this._getItemIndex(this._activeElement);
  983. if (index > this._items.length - 1 || index < 0) {
  984. return;
  985. }
  986. if (this._isSliding) {
  987. EventHandler.one(this._element, EVENT_SLID, () => this.to(index));
  988. return;
  989. }
  990. if (activeIndex === index) {
  991. this.pause();
  992. this.cycle();
  993. return;
  994. }
  995. const order = index > activeIndex ? ORDER_NEXT : ORDER_PREV;
  996. this._slide(order, this._items[index]);
  997. } // Private
  998. _getConfig(config) {
  999. config = { ...Default$a,
  1000. ...Manipulator.getDataAttributes(this._element),
  1001. ...(typeof config === 'object' ? config : {})
  1002. };
  1003. typeCheckConfig(NAME$b, config, DefaultType$a);
  1004. return config;
  1005. }
  1006. _handleSwipe() {
  1007. const absDeltax = Math.abs(this.touchDeltaX);
  1008. if (absDeltax <= SWIPE_THRESHOLD) {
  1009. return;
  1010. }
  1011. const direction = absDeltax / this.touchDeltaX;
  1012. this.touchDeltaX = 0;
  1013. if (!direction) {
  1014. return;
  1015. }
  1016. this._slide(direction > 0 ? DIRECTION_RIGHT : DIRECTION_LEFT);
  1017. }
  1018. _addEventListeners() {
  1019. if (this._config.keyboard) {
  1020. EventHandler.on(this._element, EVENT_KEYDOWN, event => this._keydown(event));
  1021. }
  1022. if (this._config.pause === 'hover') {
  1023. EventHandler.on(this._element, EVENT_MOUSEENTER, event => this.pause(event));
  1024. EventHandler.on(this._element, EVENT_MOUSELEAVE, event => this.cycle(event));
  1025. }
  1026. if (this._config.touch && this._touchSupported) {
  1027. this._addTouchEventListeners();
  1028. }
  1029. }
  1030. _addTouchEventListeners() {
  1031. const hasPointerPenTouch = event => {
  1032. return this._pointerEvent && (event.pointerType === POINTER_TYPE_PEN || event.pointerType === POINTER_TYPE_TOUCH);
  1033. };
  1034. const start = event => {
  1035. if (hasPointerPenTouch(event)) {
  1036. this.touchStartX = event.clientX;
  1037. } else if (!this._pointerEvent) {
  1038. this.touchStartX = event.touches[0].clientX;
  1039. }
  1040. };
  1041. const move = event => {
  1042. // ensure swiping with one touch and not pinching
  1043. this.touchDeltaX = event.touches && event.touches.length > 1 ? 0 : event.touches[0].clientX - this.touchStartX;
  1044. };
  1045. const end = event => {
  1046. if (hasPointerPenTouch(event)) {
  1047. this.touchDeltaX = event.clientX - this.touchStartX;
  1048. }
  1049. this._handleSwipe();
  1050. if (this._config.pause === 'hover') {
  1051. // If it's a touch-enabled device, mouseenter/leave are fired as
  1052. // part of the mouse compatibility events on first tap - the carousel
  1053. // would stop cycling until user tapped out of it;
  1054. // here, we listen for touchend, explicitly pause the carousel
  1055. // (as if it's the second time we tap on it, mouseenter compat event
  1056. // is NOT fired) and after a timeout (to allow for mouse compatibility
  1057. // events to fire) we explicitly restart cycling
  1058. this.pause();
  1059. if (this.touchTimeout) {
  1060. clearTimeout(this.touchTimeout);
  1061. }
  1062. this.touchTimeout = setTimeout(event => this.cycle(event), TOUCHEVENT_COMPAT_WAIT + this._config.interval);
  1063. }
  1064. };
  1065. SelectorEngine.find(SELECTOR_ITEM_IMG, this._element).forEach(itemImg => {
  1066. EventHandler.on(itemImg, EVENT_DRAG_START, event => event.preventDefault());
  1067. });
  1068. if (this._pointerEvent) {
  1069. EventHandler.on(this._element, EVENT_POINTERDOWN, event => start(event));
  1070. EventHandler.on(this._element, EVENT_POINTERUP, event => end(event));
  1071. this._element.classList.add(CLASS_NAME_POINTER_EVENT);
  1072. } else {
  1073. EventHandler.on(this._element, EVENT_TOUCHSTART, event => start(event));
  1074. EventHandler.on(this._element, EVENT_TOUCHMOVE, event => move(event));
  1075. EventHandler.on(this._element, EVENT_TOUCHEND, event => end(event));
  1076. }
  1077. }
  1078. _keydown(event) {
  1079. if (/input|textarea/i.test(event.target.tagName)) {
  1080. return;
  1081. }
  1082. const direction = KEY_TO_DIRECTION[event.key];
  1083. if (direction) {
  1084. event.preventDefault();
  1085. this._slide(direction);
  1086. }
  1087. }
  1088. _getItemIndex(element) {
  1089. this._items = element && element.parentNode ? SelectorEngine.find(SELECTOR_ITEM, element.parentNode) : [];
  1090. return this._items.indexOf(element);
  1091. }
  1092. _getItemByOrder(order, activeElement) {
  1093. const isNext = order === ORDER_NEXT;
  1094. return getNextActiveElement(this._items, activeElement, isNext, this._config.wrap);
  1095. }
  1096. _triggerSlideEvent(relatedTarget, eventDirectionName) {
  1097. const targetIndex = this._getItemIndex(relatedTarget);
  1098. const fromIndex = this._getItemIndex(SelectorEngine.findOne(SELECTOR_ACTIVE_ITEM, this._element));
  1099. return EventHandler.trigger(this._element, EVENT_SLIDE, {
  1100. relatedTarget,
  1101. direction: eventDirectionName,
  1102. from: fromIndex,
  1103. to: targetIndex
  1104. });
  1105. }
  1106. _setActiveIndicatorElement(element) {
  1107. if (this._indicatorsElement) {
  1108. const activeIndicator = SelectorEngine.findOne(SELECTOR_ACTIVE$1, this._indicatorsElement);
  1109. activeIndicator.classList.remove(CLASS_NAME_ACTIVE$2);
  1110. activeIndicator.removeAttribute('aria-current');
  1111. const indicators = SelectorEngine.find(SELECTOR_INDICATOR, this._indicatorsElement);
  1112. for (let i = 0; i < indicators.length; i++) {
  1113. if (Number.parseInt(indicators[i].getAttribute('data-bs-slide-to'), 10) === this._getItemIndex(element)) {
  1114. indicators[i].classList.add(CLASS_NAME_ACTIVE$2);
  1115. indicators[i].setAttribute('aria-current', 'true');
  1116. break;
  1117. }
  1118. }
  1119. }
  1120. }
  1121. _updateInterval() {
  1122. const element = this._activeElement || SelectorEngine.findOne(SELECTOR_ACTIVE_ITEM, this._element);
  1123. if (!element) {
  1124. return;
  1125. }
  1126. const elementInterval = Number.parseInt(element.getAttribute('data-bs-interval'), 10);
  1127. if (elementInterval) {
  1128. this._config.defaultInterval = this._config.defaultInterval || this._config.interval;
  1129. this._config.interval = elementInterval;
  1130. } else {
  1131. this._config.interval = this._config.defaultInterval || this._config.interval;
  1132. }
  1133. }
  1134. _slide(directionOrOrder, element) {
  1135. const order = this._directionToOrder(directionOrOrder);
  1136. const activeElement = SelectorEngine.findOne(SELECTOR_ACTIVE_ITEM, this._element);
  1137. const activeElementIndex = this._getItemIndex(activeElement);
  1138. const nextElement = element || this._getItemByOrder(order, activeElement);
  1139. const nextElementIndex = this._getItemIndex(nextElement);
  1140. const isCycling = Boolean(this._interval);
  1141. const isNext = order === ORDER_NEXT;
  1142. const directionalClassName = isNext ? CLASS_NAME_START : CLASS_NAME_END;
  1143. const orderClassName = isNext ? CLASS_NAME_NEXT : CLASS_NAME_PREV;
  1144. const eventDirectionName = this._orderToDirection(order);
  1145. if (nextElement && nextElement.classList.contains(CLASS_NAME_ACTIVE$2)) {
  1146. this._isSliding = false;
  1147. return;
  1148. }
  1149. if (this._isSliding) {
  1150. return;
  1151. }
  1152. const slideEvent = this._triggerSlideEvent(nextElement, eventDirectionName);
  1153. if (slideEvent.defaultPrevented) {
  1154. return;
  1155. }
  1156. if (!activeElement || !nextElement) {
  1157. // Some weirdness is happening, so we bail
  1158. return;
  1159. }
  1160. this._isSliding = true;
  1161. if (isCycling) {
  1162. this.pause();
  1163. }
  1164. this._setActiveIndicatorElement(nextElement);
  1165. this._activeElement = nextElement;
  1166. const triggerSlidEvent = () => {
  1167. EventHandler.trigger(this._element, EVENT_SLID, {
  1168. relatedTarget: nextElement,
  1169. direction: eventDirectionName,
  1170. from: activeElementIndex,
  1171. to: nextElementIndex
  1172. });
  1173. };
  1174. if (this._element.classList.contains(CLASS_NAME_SLIDE)) {
  1175. nextElement.classList.add(orderClassName);
  1176. reflow(nextElement);
  1177. activeElement.classList.add(directionalClassName);
  1178. nextElement.classList.add(directionalClassName);
  1179. const completeCallBack = () => {
  1180. nextElement.classList.remove(directionalClassName, orderClassName);
  1181. nextElement.classList.add(CLASS_NAME_ACTIVE$2);
  1182. activeElement.classList.remove(CLASS_NAME_ACTIVE$2, orderClassName, directionalClassName);
  1183. this._isSliding = false;
  1184. setTimeout(triggerSlidEvent, 0);
  1185. };
  1186. this._queueCallback(completeCallBack, activeElement, true);
  1187. } else {
  1188. activeElement.classList.remove(CLASS_NAME_ACTIVE$2);
  1189. nextElement.classList.add(CLASS_NAME_ACTIVE$2);
  1190. this._isSliding = false;
  1191. triggerSlidEvent();
  1192. }
  1193. if (isCycling) {
  1194. this.cycle();
  1195. }
  1196. }
  1197. _directionToOrder(direction) {
  1198. if (![DIRECTION_RIGHT, DIRECTION_LEFT].includes(direction)) {
  1199. return direction;
  1200. }
  1201. if (isRTL()) {
  1202. return direction === DIRECTION_LEFT ? ORDER_PREV : ORDER_NEXT;
  1203. }
  1204. return direction === DIRECTION_LEFT ? ORDER_NEXT : ORDER_PREV;
  1205. }
  1206. _orderToDirection(order) {
  1207. if (![ORDER_NEXT, ORDER_PREV].includes(order)) {
  1208. return order;
  1209. }
  1210. if (isRTL()) {
  1211. return order === ORDER_PREV ? DIRECTION_LEFT : DIRECTION_RIGHT;
  1212. }
  1213. return order === ORDER_PREV ? DIRECTION_RIGHT : DIRECTION_LEFT;
  1214. } // Static
  1215. static carouselInterface(element, config) {
  1216. const data = Carousel.getOrCreateInstance(element, config);
  1217. let {
  1218. _config
  1219. } = data;
  1220. if (typeof config === 'object') {
  1221. _config = { ..._config,
  1222. ...config
  1223. };
  1224. }
  1225. const action = typeof config === 'string' ? config : _config.slide;
  1226. if (typeof config === 'number') {
  1227. data.to(config);
  1228. } else if (typeof action === 'string') {
  1229. if (typeof data[action] === 'undefined') {
  1230. throw new TypeError(`No method named "${action}"`);
  1231. }
  1232. data[action]();
  1233. } else if (_config.interval && _config.ride) {
  1234. data.pause();
  1235. data.cycle();
  1236. }
  1237. }
  1238. static jQueryInterface(config) {
  1239. return this.each(function () {
  1240. Carousel.carouselInterface(this, config);
  1241. });
  1242. }
  1243. static dataApiClickHandler(event) {
  1244. const target = getElementFromSelector(this);
  1245. if (!target || !target.classList.contains(CLASS_NAME_CAROUSEL)) {
  1246. return;
  1247. }
  1248. const config = { ...Manipulator.getDataAttributes(target),
  1249. ...Manipulator.getDataAttributes(this)
  1250. };
  1251. const slideIndex = this.getAttribute('data-bs-slide-to');
  1252. if (slideIndex) {
  1253. config.interval = false;
  1254. }
  1255. Carousel.carouselInterface(target, config);
  1256. if (slideIndex) {
  1257. Carousel.getInstance(target).to(slideIndex);
  1258. }
  1259. event.preventDefault();
  1260. }
  1261. }
  1262. /**
  1263. * ------------------------------------------------------------------------
  1264. * Data Api implementation
  1265. * ------------------------------------------------------------------------
  1266. */
  1267. EventHandler.on(document, EVENT_CLICK_DATA_API$5, SELECTOR_DATA_SLIDE, Carousel.dataApiClickHandler);
  1268. EventHandler.on(window, EVENT_LOAD_DATA_API$2, () => {
  1269. const carousels = SelectorEngine.find(SELECTOR_DATA_RIDE);
  1270. for (let i = 0, len = carousels.length; i < len; i++) {
  1271. Carousel.carouselInterface(carousels[i], Carousel.getInstance(carousels[i]));
  1272. }
  1273. });
  1274. /**
  1275. * ------------------------------------------------------------------------
  1276. * jQuery
  1277. * ------------------------------------------------------------------------
  1278. * add .Carousel to jQuery only if jQuery is present
  1279. */
  1280. defineJQueryPlugin(Carousel);
  1281. /**
  1282. * --------------------------------------------------------------------------
  1283. * Bootstrap (v5.1.3): collapse.js
  1284. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
  1285. * --------------------------------------------------------------------------
  1286. */
  1287. /**
  1288. * ------------------------------------------------------------------------
  1289. * Constants
  1290. * ------------------------------------------------------------------------
  1291. */
  1292. const NAME$a = 'collapse';
  1293. const DATA_KEY$9 = 'bs.collapse';
  1294. const EVENT_KEY$9 = `.${DATA_KEY$9}`;
  1295. const DATA_API_KEY$5 = '.data-api';
  1296. const Default$9 = {
  1297. toggle: true,
  1298. parent: null
  1299. };
  1300. const DefaultType$9 = {
  1301. toggle: 'boolean',
  1302. parent: '(null|element)'
  1303. };
  1304. const EVENT_SHOW$5 = `show${EVENT_KEY$9}`;
  1305. const EVENT_SHOWN$5 = `shown${EVENT_KEY$9}`;
  1306. const EVENT_HIDE$5 = `hide${EVENT_KEY$9}`;
  1307. const EVENT_HIDDEN$5 = `hidden${EVENT_KEY$9}`;
  1308. const EVENT_CLICK_DATA_API$4 = `click${EVENT_KEY$9}${DATA_API_KEY$5}`;
  1309. const CLASS_NAME_SHOW$7 = 'show';
  1310. const CLASS_NAME_COLLAPSE = 'collapse';
  1311. const CLASS_NAME_COLLAPSING = 'collapsing';
  1312. const CLASS_NAME_COLLAPSED = 'collapsed';
  1313. const CLASS_NAME_DEEPER_CHILDREN = `:scope .${CLASS_NAME_COLLAPSE} .${CLASS_NAME_COLLAPSE}`;
  1314. const CLASS_NAME_HORIZONTAL = 'collapse-horizontal';
  1315. const WIDTH = 'width';
  1316. const HEIGHT = 'height';
  1317. const SELECTOR_ACTIVES = '.collapse.show, .collapse.collapsing';
  1318. const SELECTOR_DATA_TOGGLE$4 = '[data-bs-toggle="collapse"]';
  1319. /**
  1320. * ------------------------------------------------------------------------
  1321. * Class Definition
  1322. * ------------------------------------------------------------------------
  1323. */
  1324. class Collapse extends BaseComponent {
  1325. constructor(element, config) {
  1326. super(element);
  1327. this._isTransitioning = false;
  1328. this._config = this._getConfig(config);
  1329. this._triggerArray = [];
  1330. const toggleList = SelectorEngine.find(SELECTOR_DATA_TOGGLE$4);
  1331. for (let i = 0, len = toggleList.length; i < len; i++) {
  1332. const elem = toggleList[i];
  1333. const selector = getSelectorFromElement(elem);
  1334. const filterElement = SelectorEngine.find(selector).filter(foundElem => foundElem === this._element);
  1335. if (selector !== null && filterElement.length) {
  1336. this._selector = selector;
  1337. this._triggerArray.push(elem);
  1338. }
  1339. }
  1340. this._initializeChildren();
  1341. if (!this._config.parent) {
  1342. this._addAriaAndCollapsedClass(this._triggerArray, this._isShown());
  1343. }
  1344. if (this._config.toggle) {
  1345. this.toggle();
  1346. }
  1347. } // Getters
  1348. static get Default() {
  1349. return Default$9;
  1350. }
  1351. static get NAME() {
  1352. return NAME$a;
  1353. } // Public
  1354. toggle() {
  1355. if (this._isShown()) {
  1356. this.hide();
  1357. } else {
  1358. this.show();
  1359. }
  1360. }
  1361. show() {
  1362. if (this._isTransitioning || this._isShown()) {
  1363. return;
  1364. }
  1365. let actives = [];
  1366. let activesData;
  1367. if (this._config.parent) {
  1368. const children = SelectorEngine.find(CLASS_NAME_DEEPER_CHILDREN, this._config.parent);
  1369. actives = SelectorEngine.find(SELECTOR_ACTIVES, this._config.parent).filter(elem => !children.includes(elem)); // remove children if greater depth
  1370. }
  1371. const container = SelectorEngine.findOne(this._selector);
  1372. if (actives.length) {
  1373. const tempActiveData = actives.find(elem => container !== elem);
  1374. activesData = tempActiveData ? Collapse.getInstance(tempActiveData) : null;
  1375. if (activesData && activesData._isTransitioning) {
  1376. return;
  1377. }
  1378. }
  1379. const startEvent = EventHandler.trigger(this._element, EVENT_SHOW$5);
  1380. if (startEvent.defaultPrevented) {
  1381. return;
  1382. }
  1383. actives.forEach(elemActive => {
  1384. if (container !== elemActive) {
  1385. Collapse.getOrCreateInstance(elemActive, {
  1386. toggle: false
  1387. }).hide();
  1388. }
  1389. if (!activesData) {
  1390. Data.set(elemActive, DATA_KEY$9, null);
  1391. }
  1392. });
  1393. const dimension = this._getDimension();
  1394. this._element.classList.remove(CLASS_NAME_COLLAPSE);
  1395. this._element.classList.add(CLASS_NAME_COLLAPSING);
  1396. this._element.style[dimension] = 0;
  1397. this._addAriaAndCollapsedClass(this._triggerArray, true);
  1398. this._isTransitioning = true;
  1399. const complete = () => {
  1400. this._isTransitioning = false;
  1401. this._element.classList.remove(CLASS_NAME_COLLAPSING);
  1402. this._element.classList.add(CLASS_NAME_COLLAPSE, CLASS_NAME_SHOW$7);
  1403. this._element.style[dimension] = '';
  1404. EventHandler.trigger(this._element, EVENT_SHOWN$5);
  1405. };
  1406. const capitalizedDimension = dimension[0].toUpperCase() + dimension.slice(1);
  1407. const scrollSize = `scroll${capitalizedDimension}`;
  1408. this._queueCallback(complete, this._element, true);
  1409. this._element.style[dimension] = `${this._element[scrollSize]}px`;
  1410. }
  1411. hide() {
  1412. if (this._isTransitioning || !this._isShown()) {
  1413. return;
  1414. }
  1415. const startEvent = EventHandler.trigger(this._element, EVENT_HIDE$5);
  1416. if (startEvent.defaultPrevented) {
  1417. return;
  1418. }
  1419. const dimension = this._getDimension();
  1420. this._element.style[dimension] = `${this._element.getBoundingClientRect()[dimension]}px`;
  1421. reflow(this._element);
  1422. this._element.classList.add(CLASS_NAME_COLLAPSING);
  1423. this._element.classList.remove(CLASS_NAME_COLLAPSE, CLASS_NAME_SHOW$7);
  1424. const triggerArrayLength = this._triggerArray.length;
  1425. for (let i = 0; i < triggerArrayLength; i++) {
  1426. const trigger = this._triggerArray[i];
  1427. const elem = getElementFromSelector(trigger);
  1428. if (elem && !this._isShown(elem)) {
  1429. this._addAriaAndCollapsedClass([trigger], false);
  1430. }
  1431. }
  1432. this._isTransitioning = true;
  1433. const complete = () => {
  1434. this._isTransitioning = false;
  1435. this._element.classList.remove(CLASS_NAME_COLLAPSING);
  1436. this._element.classList.add(CLASS_NAME_COLLAPSE);
  1437. EventHandler.trigger(this._element, EVENT_HIDDEN$5);
  1438. };
  1439. this._element.style[dimension] = '';
  1440. this._queueCallback(complete, this._element, true);
  1441. }
  1442. _isShown(element = this._element) {
  1443. return element.classList.contains(CLASS_NAME_SHOW$7);
  1444. } // Private
  1445. _getConfig(config) {
  1446. config = { ...Default$9,
  1447. ...Manipulator.getDataAttributes(this._element),
  1448. ...config
  1449. };
  1450. config.toggle = Boolean(config.toggle); // Coerce string values
  1451. config.parent = getElement(config.parent);
  1452. typeCheckConfig(NAME$a, config, DefaultType$9);
  1453. return config;
  1454. }
  1455. _getDimension() {
  1456. return this._element.classList.contains(CLASS_NAME_HORIZONTAL) ? WIDTH : HEIGHT;
  1457. }
  1458. _initializeChildren() {
  1459. if (!this._config.parent) {
  1460. return;
  1461. }
  1462. const children = SelectorEngine.find(CLASS_NAME_DEEPER_CHILDREN, this._config.parent);
  1463. SelectorEngine.find(SELECTOR_DATA_TOGGLE$4, this._config.parent).filter(elem => !children.includes(elem)).forEach(element => {
  1464. const selected = getElementFromSelector(element);
  1465. if (selected) {
  1466. this._addAriaAndCollapsedClass([element], this._isShown(selected));
  1467. }
  1468. });
  1469. }
  1470. _addAriaAndCollapsedClass(triggerArray, isOpen) {
  1471. if (!triggerArray.length) {
  1472. return;
  1473. }
  1474. triggerArray.forEach(elem => {
  1475. if (isOpen) {
  1476. elem.classList.remove(CLASS_NAME_COLLAPSED);
  1477. } else {
  1478. elem.classList.add(CLASS_NAME_COLLAPSED);
  1479. }
  1480. elem.setAttribute('aria-expanded', isOpen);
  1481. });
  1482. } // Static
  1483. static jQueryInterface(config) {
  1484. return this.each(function () {
  1485. const _config = {};
  1486. if (typeof config === 'string' && /show|hide/.test(config)) {
  1487. _config.toggle = false;
  1488. }
  1489. const data = Collapse.getOrCreateInstance(this, _config);
  1490. if (typeof config === 'string') {
  1491. if (typeof data[config] === 'undefined') {
  1492. throw new TypeError(`No method named "${config}"`);
  1493. }
  1494. data[config]();
  1495. }
  1496. });
  1497. }
  1498. }
  1499. /**
  1500. * ------------------------------------------------------------------------
  1501. * Data Api implementation
  1502. * ------------------------------------------------------------------------
  1503. */
  1504. EventHandler.on(document, EVENT_CLICK_DATA_API$4, SELECTOR_DATA_TOGGLE$4, function (event) {
  1505. // preventDefault only for <a> elements (which change the URL) not inside the collapsible element
  1506. if (event.target.tagName === 'A' || event.delegateTarget && event.delegateTarget.tagName === 'A') {
  1507. event.preventDefault();
  1508. }
  1509. const selector = getSelectorFromElement(this);
  1510. const selectorElements = SelectorEngine.find(selector);
  1511. selectorElements.forEach(element => {
  1512. Collapse.getOrCreateInstance(element, {
  1513. toggle: false
  1514. }).toggle();
  1515. });
  1516. });
  1517. /**
  1518. * ------------------------------------------------------------------------
  1519. * jQuery
  1520. * ------------------------------------------------------------------------
  1521. * add .Collapse to jQuery only if jQuery is present
  1522. */
  1523. defineJQueryPlugin(Collapse);
  1524. var top = 'top';
  1525. var bottom = 'bottom';
  1526. var right = 'right';
  1527. var left = 'left';
  1528. var auto = 'auto';
  1529. var basePlacements = [top, bottom, right, left];
  1530. var start = 'start';
  1531. var end = 'end';
  1532. var clippingParents = 'clippingParents';
  1533. var viewport = 'viewport';
  1534. var popper = 'popper';
  1535. var reference = 'reference';
  1536. var variationPlacements = /*#__PURE__*/basePlacements.reduce(function (acc, placement) {
  1537. return acc.concat([placement + "-" + start, placement + "-" + end]);
  1538. }, []);
  1539. var placements = /*#__PURE__*/[].concat(basePlacements, [auto]).reduce(function (acc, placement) {
  1540. return acc.concat([placement, placement + "-" + start, placement + "-" + end]);
  1541. }, []); // modifiers that need to read the DOM
  1542. var beforeRead = 'beforeRead';
  1543. var read = 'read';
  1544. var afterRead = 'afterRead'; // pure-logic modifiers
  1545. var beforeMain = 'beforeMain';
  1546. var main = 'main';
  1547. var afterMain = 'afterMain'; // modifier with the purpose to write to the DOM (or write into a framework state)
  1548. var beforeWrite = 'beforeWrite';
  1549. var write = 'write';
  1550. var afterWrite = 'afterWrite';
  1551. var modifierPhases = [beforeRead, read, afterRead, beforeMain, main, afterMain, beforeWrite, write, afterWrite];
  1552. function getNodeName(element) {
  1553. return element ? (element.nodeName || '').toLowerCase() : null;
  1554. }
  1555. function getWindow(node) {
  1556. if (node == null) {
  1557. return window;
  1558. }
  1559. if (node.toString() !== '[object Window]') {
  1560. var ownerDocument = node.ownerDocument;
  1561. return ownerDocument ? ownerDocument.defaultView || window : window;
  1562. }
  1563. return node;
  1564. }
  1565. function isElement(node) {
  1566. var OwnElement = getWindow(node).Element;
  1567. return node instanceof OwnElement || node instanceof Element;
  1568. }
  1569. function isHTMLElement(node) {
  1570. var OwnElement = getWindow(node).HTMLElement;
  1571. return node instanceof OwnElement || node instanceof HTMLElement;
  1572. }
  1573. function isShadowRoot(node) {
  1574. // IE 11 has no ShadowRoot
  1575. if (typeof ShadowRoot === 'undefined') {
  1576. return false;
  1577. }
  1578. var OwnElement = getWindow(node).ShadowRoot;
  1579. return node instanceof OwnElement || node instanceof ShadowRoot;
  1580. }
  1581. // and applies them to the HTMLElements such as popper and arrow
  1582. function applyStyles(_ref) {
  1583. var state = _ref.state;
  1584. Object.keys(state.elements).forEach(function (name) {
  1585. var style = state.styles[name] || {};
  1586. var attributes = state.attributes[name] || {};
  1587. var element = state.elements[name]; // arrow is optional + virtual elements
  1588. if (!isHTMLElement(element) || !getNodeName(element)) {
  1589. return;
  1590. } // Flow doesn't support to extend this property, but it's the most
  1591. // effective way to apply styles to an HTMLElement
  1592. // $FlowFixMe[cannot-write]
  1593. Object.assign(element.style, style);
  1594. Object.keys(attributes).forEach(function (name) {
  1595. var value = attributes[name];
  1596. if (value === false) {
  1597. element.removeAttribute(name);
  1598. } else {
  1599. element.setAttribute(name, value === true ? '' : value);
  1600. }
  1601. });
  1602. });
  1603. }
  1604. function effect$2(_ref2) {
  1605. var state = _ref2.state;
  1606. var initialStyles = {
  1607. popper: {
  1608. position: state.options.strategy,
  1609. left: '0',
  1610. top: '0',
  1611. margin: '0'
  1612. },
  1613. arrow: {
  1614. position: 'absolute'
  1615. },
  1616. reference: {}
  1617. };
  1618. Object.assign(state.elements.popper.style, initialStyles.popper);
  1619. state.styles = initialStyles;
  1620. if (state.elements.arrow) {
  1621. Object.assign(state.elements.arrow.style, initialStyles.arrow);
  1622. }
  1623. return function () {
  1624. Object.keys(state.elements).forEach(function (name) {
  1625. var element = state.elements[name];
  1626. var attributes = state.attributes[name] || {};
  1627. var styleProperties = Object.keys(state.styles.hasOwnProperty(name) ? state.styles[name] : initialStyles[name]); // Set all values to an empty string to unset them
  1628. var style = styleProperties.reduce(function (style, property) {
  1629. style[property] = '';
  1630. return style;
  1631. }, {}); // arrow is optional + virtual elements
  1632. if (!isHTMLElement(element) || !getNodeName(element)) {
  1633. return;
  1634. }
  1635. Object.assign(element.style, style);
  1636. Object.keys(attributes).forEach(function (attribute) {
  1637. element.removeAttribute(attribute);
  1638. });
  1639. });
  1640. };
  1641. } // eslint-disable-next-line import/no-unused-modules
  1642. const applyStyles$1 = {
  1643. name: 'applyStyles',
  1644. enabled: true,
  1645. phase: 'write',
  1646. fn: applyStyles,
  1647. effect: effect$2,
  1648. requires: ['computeStyles']
  1649. };
  1650. function getBasePlacement(placement) {
  1651. return placement.split('-')[0];
  1652. }
  1653. // import { isHTMLElement } from './instanceOf';
  1654. function getBoundingClientRect(element, // eslint-disable-next-line unused-imports/no-unused-vars
  1655. includeScale) {
  1656. var rect = element.getBoundingClientRect();
  1657. var scaleX = 1;
  1658. var scaleY = 1; // FIXME:
  1659. // `offsetWidth` returns an integer while `getBoundingClientRect`
  1660. // returns a float. This results in `scaleX` or `scaleY` being
  1661. // non-1 when it should be for elements that aren't a full pixel in
  1662. // width or height.
  1663. // if (isHTMLElement(element) && includeScale) {
  1664. // const offsetHeight = element.offsetHeight;
  1665. // const offsetWidth = element.offsetWidth;
  1666. // // Do not attempt to divide by 0, otherwise we get `Infinity` as scale
  1667. // // Fallback to 1 in case both values are `0`
  1668. // if (offsetWidth > 0) {
  1669. // scaleX = rect.width / offsetWidth || 1;
  1670. // }
  1671. // if (offsetHeight > 0) {
  1672. // scaleY = rect.height / offsetHeight || 1;
  1673. // }
  1674. // }
  1675. return {
  1676. width: rect.width / scaleX,
  1677. height: rect.height / scaleY,
  1678. top: rect.top / scaleY,
  1679. right: rect.right / scaleX,
  1680. bottom: rect.bottom / scaleY,
  1681. left: rect.left / scaleX,
  1682. x: rect.left / scaleX,
  1683. y: rect.top / scaleY
  1684. };
  1685. }
  1686. // means it doesn't take into account transforms.
  1687. function getLayoutRect(element) {
  1688. var clientRect = getBoundingClientRect(element); // Use the clientRect sizes if it's not been transformed.
  1689. // Fixes https://github.com/popperjs/popper-core/issues/1223
  1690. var width = element.offsetWidth;
  1691. var height = element.offsetHeight;
  1692. if (Math.abs(clientRect.width - width) <= 1) {
  1693. width = clientRect.width;
  1694. }
  1695. if (Math.abs(clientRect.height - height) <= 1) {
  1696. height = clientRect.height;
  1697. }
  1698. return {
  1699. x: element.offsetLeft,
  1700. y: element.offsetTop,
  1701. width: width,
  1702. height: height
  1703. };
  1704. }
  1705. function contains(parent, child) {
  1706. var rootNode = child.getRootNode && child.getRootNode(); // First, attempt with faster native method
  1707. if (parent.contains(child)) {
  1708. return true;
  1709. } // then fallback to custom implementation with Shadow DOM support
  1710. else if (rootNode && isShadowRoot(rootNode)) {
  1711. var next = child;
  1712. do {
  1713. if (next && parent.isSameNode(next)) {
  1714. return true;
  1715. } // $FlowFixMe[prop-missing]: need a better way to handle this...
  1716. next = next.parentNode || next.host;
  1717. } while (next);
  1718. } // Give up, the result is false
  1719. return false;
  1720. }
  1721. function getComputedStyle$1(element) {
  1722. return getWindow(element).getComputedStyle(element);
  1723. }
  1724. function isTableElement(element) {
  1725. return ['table', 'td', 'th'].indexOf(getNodeName(element)) >= 0;
  1726. }
  1727. function getDocumentElement(element) {
  1728. // $FlowFixMe[incompatible-return]: assume body is always available
  1729. return ((isElement(element) ? element.ownerDocument : // $FlowFixMe[prop-missing]
  1730. element.document) || window.document).documentElement;
  1731. }
  1732. function getParentNode(element) {
  1733. if (getNodeName(element) === 'html') {
  1734. return element;
  1735. }
  1736. return (// this is a quicker (but less type safe) way to save quite some bytes from the bundle
  1737. // $FlowFixMe[incompatible-return]
  1738. // $FlowFixMe[prop-missing]
  1739. element.assignedSlot || // step into the shadow DOM of the parent of a slotted node
  1740. element.parentNode || ( // DOM Element detected
  1741. isShadowRoot(element) ? element.host : null) || // ShadowRoot detected
  1742. // $FlowFixMe[incompatible-call]: HTMLElement is a Node
  1743. getDocumentElement(element) // fallback
  1744. );
  1745. }
  1746. function getTrueOffsetParent(element) {
  1747. if (!isHTMLElement(element) || // https://github.com/popperjs/popper-core/issues/837
  1748. getComputedStyle$1(element).position === 'fixed') {
  1749. return null;
  1750. }
  1751. return element.offsetParent;
  1752. } // `.offsetParent` reports `null` for fixed elements, while absolute elements
  1753. // return the containing block
  1754. function getContainingBlock(element) {
  1755. var isFirefox = navigator.userAgent.toLowerCase().indexOf('firefox') !== -1;
  1756. var isIE = navigator.userAgent.indexOf('Trident') !== -1;
  1757. if (isIE && isHTMLElement(element)) {
  1758. // In IE 9, 10 and 11 fixed elements containing block is always established by the viewport
  1759. var elementCss = getComputedStyle$1(element);
  1760. if (elementCss.position === 'fixed') {
  1761. return null;
  1762. }
  1763. }
  1764. var currentNode = getParentNode(element);
  1765. while (isHTMLElement(currentNode) && ['html', 'body'].indexOf(getNodeName(currentNode)) < 0) {
  1766. var css = getComputedStyle$1(currentNode); // This is non-exhaustive but covers the most common CSS properties that
  1767. // create a containing block.
  1768. // https://developer.mozilla.org/en-US/docs/Web/CSS/Containing_block#identifying_the_containing_block
  1769. if (css.transform !== 'none' || css.perspective !== 'none' || css.contain === 'paint' || ['transform', 'perspective'].indexOf(css.willChange) !== -1 || isFirefox && css.willChange === 'filter' || isFirefox && css.filter && css.filter !== 'none') {
  1770. return currentNode;
  1771. } else {
  1772. currentNode = currentNode.parentNode;
  1773. }
  1774. }
  1775. return null;
  1776. } // Gets the closest ancestor positioned element. Handles some edge cases,
  1777. // such as table ancestors and cross browser bugs.
  1778. function getOffsetParent(element) {
  1779. var window = getWindow(element);
  1780. var offsetParent = getTrueOffsetParent(element);
  1781. while (offsetParent && isTableElement(offsetParent) && getComputedStyle$1(offsetParent).position === 'static') {
  1782. offsetParent = getTrueOffsetParent(offsetParent);
  1783. }
  1784. if (offsetParent && (getNodeName(offsetParent) === 'html' || getNodeName(offsetParent) === 'body' && getComputedStyle$1(offsetParent).position === 'static')) {
  1785. return window;
  1786. }
  1787. return offsetParent || getContainingBlock(element) || window;
  1788. }
  1789. function getMainAxisFromPlacement(placement) {
  1790. return ['top', 'bottom'].indexOf(placement) >= 0 ? 'x' : 'y';
  1791. }
  1792. var max = Math.max;
  1793. var min = Math.min;
  1794. var round = Math.round;
  1795. function within(min$1, value, max$1) {
  1796. return max(min$1, min(value, max$1));
  1797. }
  1798. function getFreshSideObject() {
  1799. return {
  1800. top: 0,
  1801. right: 0,
  1802. bottom: 0,
  1803. left: 0
  1804. };
  1805. }
  1806. function mergePaddingObject(paddingObject) {
  1807. return Object.assign({}, getFreshSideObject(), paddingObject);
  1808. }
  1809. function expandToHashMap(value, keys) {
  1810. return keys.reduce(function (hashMap, key) {
  1811. hashMap[key] = value;
  1812. return hashMap;
  1813. }, {});
  1814. }
  1815. var toPaddingObject = function toPaddingObject(padding, state) {
  1816. padding = typeof padding === 'function' ? padding(Object.assign({}, state.rects, {
  1817. placement: state.placement
  1818. })) : padding;
  1819. return mergePaddingObject(typeof padding !== 'number' ? padding : expandToHashMap(padding, basePlacements));
  1820. };
  1821. function arrow(_ref) {
  1822. var _state$modifiersData$;
  1823. var state = _ref.state,
  1824. name = _ref.name,
  1825. options = _ref.options;
  1826. var arrowElement = state.elements.arrow;
  1827. var popperOffsets = state.modifiersData.popperOffsets;
  1828. var basePlacement = getBasePlacement(state.placement);
  1829. var axis = getMainAxisFromPlacement(basePlacement);
  1830. var isVertical = [left, right].indexOf(basePlacement) >= 0;
  1831. var len = isVertical ? 'height' : 'width';
  1832. if (!arrowElement || !popperOffsets) {
  1833. return;
  1834. }
  1835. var paddingObject = toPaddingObject(options.padding, state);
  1836. var arrowRect = getLayoutRect(arrowElement);
  1837. var minProp = axis === 'y' ? top : left;
  1838. var maxProp = axis === 'y' ? bottom : right;
  1839. var endDiff = state.rects.reference[len] + state.rects.reference[axis] - popperOffsets[axis] - state.rects.popper[len];
  1840. var startDiff = popperOffsets[axis] - state.rects.reference[axis];
  1841. var arrowOffsetParent = getOffsetParent(arrowElement);
  1842. var clientSize = arrowOffsetParent ? axis === 'y' ? arrowOffsetParent.clientHeight || 0 : arrowOffsetParent.clientWidth || 0 : 0;
  1843. var centerToReference = endDiff / 2 - startDiff / 2; // Make sure the arrow doesn't overflow the popper if the center point is
  1844. // outside of the popper bounds
  1845. var min = paddingObject[minProp];
  1846. var max = clientSize - arrowRect[len] - paddingObject[maxProp];
  1847. var center = clientSize / 2 - arrowRect[len] / 2 + centerToReference;
  1848. var offset = within(min, center, max); // Prevents breaking syntax highlighting...
  1849. var axisProp = axis;
  1850. state.modifiersData[name] = (_state$modifiersData$ = {}, _state$modifiersData$[axisProp] = offset, _state$modifiersData$.centerOffset = offset - center, _state$modifiersData$);
  1851. }
  1852. function effect$1(_ref2) {
  1853. var state = _ref2.state,
  1854. options = _ref2.options;
  1855. var _options$element = options.element,
  1856. arrowElement = _options$element === void 0 ? '[data-popper-arrow]' : _options$element;
  1857. if (arrowElement == null) {
  1858. return;
  1859. } // CSS selector
  1860. if (typeof arrowElement === 'string') {
  1861. arrowElement = state.elements.popper.querySelector(arrowElement);
  1862. if (!arrowElement) {
  1863. return;
  1864. }
  1865. }
  1866. if (!contains(state.elements.popper, arrowElement)) {
  1867. return;
  1868. }
  1869. state.elements.arrow = arrowElement;
  1870. } // eslint-disable-next-line import/no-unused-modules
  1871. const arrow$1 = {
  1872. name: 'arrow',
  1873. enabled: true,
  1874. phase: 'main',
  1875. fn: arrow,
  1876. effect: effect$1,
  1877. requires: ['popperOffsets'],
  1878. requiresIfExists: ['preventOverflow']
  1879. };
  1880. function getVariation(placement) {
  1881. return placement.split('-')[1];
  1882. }
  1883. var unsetSides = {
  1884. top: 'auto',
  1885. right: 'auto',
  1886. bottom: 'auto',
  1887. left: 'auto'
  1888. }; // Round the offsets to the nearest suitable subpixel based on the DPR.
  1889. // Zooming can change the DPR, but it seems to report a value that will
  1890. // cleanly divide the values into the appropriate subpixels.
  1891. function roundOffsetsByDPR(_ref) {
  1892. var x = _ref.x,
  1893. y = _ref.y;
  1894. var win = window;
  1895. var dpr = win.devicePixelRatio || 1;
  1896. return {
  1897. x: round(round(x * dpr) / dpr) || 0,
  1898. y: round(round(y * dpr) / dpr) || 0
  1899. };
  1900. }
  1901. function mapToStyles(_ref2) {
  1902. var _Object$assign2;
  1903. var popper = _ref2.popper,
  1904. popperRect = _ref2.popperRect,
  1905. placement = _ref2.placement,
  1906. variation = _ref2.variation,
  1907. offsets = _ref2.offsets,
  1908. position = _ref2.position,
  1909. gpuAcceleration = _ref2.gpuAcceleration,
  1910. adaptive = _ref2.adaptive,
  1911. roundOffsets = _ref2.roundOffsets;
  1912. var _ref3 = roundOffsets === true ? roundOffsetsByDPR(offsets) : typeof roundOffsets === 'function' ? roundOffsets(offsets) : offsets,
  1913. _ref3$x = _ref3.x,
  1914. x = _ref3$x === void 0 ? 0 : _ref3$x,
  1915. _ref3$y = _ref3.y,
  1916. y = _ref3$y === void 0 ? 0 : _ref3$y;
  1917. var hasX = offsets.hasOwnProperty('x');
  1918. var hasY = offsets.hasOwnProperty('y');
  1919. var sideX = left;
  1920. var sideY = top;
  1921. var win = window;
  1922. if (adaptive) {
  1923. var offsetParent = getOffsetParent(popper);
  1924. var heightProp = 'clientHeight';
  1925. var widthProp = 'clientWidth';
  1926. if (offsetParent === getWindow(popper)) {
  1927. offsetParent = getDocumentElement(popper);
  1928. if (getComputedStyle$1(offsetParent).position !== 'static' && position === 'absolute') {
  1929. heightProp = 'scrollHeight';
  1930. widthProp = 'scrollWidth';
  1931. }
  1932. } // $FlowFixMe[incompatible-cast]: force type refinement, we compare offsetParent with window above, but Flow doesn't detect it
  1933. offsetParent = offsetParent;
  1934. if (placement === top || (placement === left || placement === right) && variation === end) {
  1935. sideY = bottom; // $FlowFixMe[prop-missing]
  1936. y -= offsetParent[heightProp] - popperRect.height;
  1937. y *= gpuAcceleration ? 1 : -1;
  1938. }
  1939. if (placement === left || (placement === top || placement === bottom) && variation === end) {
  1940. sideX = right; // $FlowFixMe[prop-missing]
  1941. x -= offsetParent[widthProp] - popperRect.width;
  1942. x *= gpuAcceleration ? 1 : -1;
  1943. }
  1944. }
  1945. var commonStyles = Object.assign({
  1946. position: position
  1947. }, adaptive && unsetSides);
  1948. if (gpuAcceleration) {
  1949. var _Object$assign;
  1950. return Object.assign({}, commonStyles, (_Object$assign = {}, _Object$assign[sideY] = hasY ? '0' : '', _Object$assign[sideX] = hasX ? '0' : '', _Object$assign.transform = (win.devicePixelRatio || 1) <= 1 ? "translate(" + x + "px, " + y + "px)" : "translate3d(" + x + "px, " + y + "px, 0)", _Object$assign));
  1951. }
  1952. return Object.assign({}, commonStyles, (_Object$assign2 = {}, _Object$assign2[sideY] = hasY ? y + "px" : '', _Object$assign2[sideX] = hasX ? x + "px" : '', _Object$assign2.transform = '', _Object$assign2));
  1953. }
  1954. function computeStyles(_ref4) {
  1955. var state = _ref4.state,
  1956. options = _ref4.options;
  1957. var _options$gpuAccelerat = options.gpuAcceleration,
  1958. gpuAcceleration = _options$gpuAccelerat === void 0 ? true : _options$gpuAccelerat,
  1959. _options$adaptive = options.adaptive,
  1960. adaptive = _options$adaptive === void 0 ? true : _options$adaptive,
  1961. _options$roundOffsets = options.roundOffsets,
  1962. roundOffsets = _options$roundOffsets === void 0 ? true : _options$roundOffsets;
  1963. var commonStyles = {
  1964. placement: getBasePlacement(state.placement),
  1965. variation: getVariation(state.placement),
  1966. popper: state.elements.popper,
  1967. popperRect: state.rects.popper,
  1968. gpuAcceleration: gpuAcceleration
  1969. };
  1970. if (state.modifiersData.popperOffsets != null) {
  1971. state.styles.popper = Object.assign({}, state.styles.popper, mapToStyles(Object.assign({}, commonStyles, {
  1972. offsets: state.modifiersData.popperOffsets,
  1973. position: state.options.strategy,
  1974. adaptive: adaptive,
  1975. roundOffsets: roundOffsets
  1976. })));
  1977. }
  1978. if (state.modifiersData.arrow != null) {
  1979. state.styles.arrow = Object.assign({}, state.styles.arrow, mapToStyles(Object.assign({}, commonStyles, {
  1980. offsets: state.modifiersData.arrow,
  1981. position: 'absolute',
  1982. adaptive: false,
  1983. roundOffsets: roundOffsets
  1984. })));
  1985. }
  1986. state.attributes.popper = Object.assign({}, state.attributes.popper, {
  1987. 'data-popper-placement': state.placement
  1988. });
  1989. } // eslint-disable-next-line import/no-unused-modules
  1990. const computeStyles$1 = {
  1991. name: 'computeStyles',
  1992. enabled: true,
  1993. phase: 'beforeWrite',
  1994. fn: computeStyles,
  1995. data: {}
  1996. };
  1997. var passive = {
  1998. passive: true
  1999. };
  2000. function effect(_ref) {
  2001. var state = _ref.state,
  2002. instance = _ref.instance,
  2003. options = _ref.options;
  2004. var _options$scroll = options.scroll,
  2005. scroll = _options$scroll === void 0 ? true : _options$scroll,
  2006. _options$resize = options.resize,
  2007. resize = _options$resize === void 0 ? true : _options$resize;
  2008. var window = getWindow(state.elements.popper);
  2009. var scrollParents = [].concat(state.scrollParents.reference, state.scrollParents.popper);
  2010. if (scroll) {
  2011. scrollParents.forEach(function (scrollParent) {
  2012. scrollParent.addEventListener('scroll', instance.update, passive);
  2013. });
  2014. }
  2015. if (resize) {
  2016. window.addEventListener('resize', instance.update, passive);
  2017. }
  2018. return function () {
  2019. if (scroll) {
  2020. scrollParents.forEach(function (scrollParent) {
  2021. scrollParent.removeEventListener('scroll', instance.update, passive);
  2022. });
  2023. }
  2024. if (resize) {
  2025. window.removeEventListener('resize', instance.update, passive);
  2026. }
  2027. };
  2028. } // eslint-disable-next-line import/no-unused-modules
  2029. const eventListeners = {
  2030. name: 'eventListeners',
  2031. enabled: true,
  2032. phase: 'write',
  2033. fn: function fn() {},
  2034. effect: effect,
  2035. data: {}
  2036. };
  2037. var hash$1 = {
  2038. left: 'right',
  2039. right: 'left',
  2040. bottom: 'top',
  2041. top: 'bottom'
  2042. };
  2043. function getOppositePlacement(placement) {
  2044. return placement.replace(/left|right|bottom|top/g, function (matched) {
  2045. return hash$1[matched];
  2046. });
  2047. }
  2048. var hash = {
  2049. start: 'end',
  2050. end: 'start'
  2051. };
  2052. function getOppositeVariationPlacement(placement) {
  2053. return placement.replace(/start|end/g, function (matched) {
  2054. return hash[matched];
  2055. });
  2056. }
  2057. function getWindowScroll(node) {
  2058. var win = getWindow(node);
  2059. var scrollLeft = win.pageXOffset;
  2060. var scrollTop = win.pageYOffset;
  2061. return {
  2062. scrollLeft: scrollLeft,
  2063. scrollTop: scrollTop
  2064. };
  2065. }
  2066. function getWindowScrollBarX(element) {
  2067. // If <html> has a CSS width greater than the viewport, then this will be
  2068. // incorrect for RTL.
  2069. // Popper 1 is broken in this case and never had a bug report so let's assume
  2070. // it's not an issue. I don't think anyone ever specifies width on <html>
  2071. // anyway.
  2072. // Browsers where the left scrollbar doesn't cause an issue report `0` for
  2073. // this (e.g. Edge 2019, IE11, Safari)
  2074. return getBoundingClientRect(getDocumentElement(element)).left + getWindowScroll(element).scrollLeft;
  2075. }
  2076. function getViewportRect(element) {
  2077. var win = getWindow(element);
  2078. var html = getDocumentElement(element);
  2079. var visualViewport = win.visualViewport;
  2080. var width = html.clientWidth;
  2081. var height = html.clientHeight;
  2082. var x = 0;
  2083. var y = 0; // NB: This isn't supported on iOS <= 12. If the keyboard is open, the popper
  2084. // can be obscured underneath it.
  2085. // Also, `html.clientHeight` adds the bottom bar height in Safari iOS, even
  2086. // if it isn't open, so if this isn't available, the popper will be detected
  2087. // to overflow the bottom of the screen too early.
  2088. if (visualViewport) {
  2089. width = visualViewport.width;
  2090. height = visualViewport.height; // Uses Layout Viewport (like Chrome; Safari does not currently)
  2091. // In Chrome, it returns a value very close to 0 (+/-) but contains rounding
  2092. // errors due to floating point numbers, so we need to check precision.
  2093. // Safari returns a number <= 0, usually < -1 when pinch-zoomed
  2094. // Feature detection fails in mobile emulation mode in Chrome.
  2095. // Math.abs(win.innerWidth / visualViewport.scale - visualViewport.width) <
  2096. // 0.001
  2097. // Fallback here: "Not Safari" userAgent
  2098. if (!/^((?!chrome|android).)*safari/i.test(navigator.userAgent)) {
  2099. x = visualViewport.offsetLeft;
  2100. y = visualViewport.offsetTop;
  2101. }
  2102. }
  2103. return {
  2104. width: width,
  2105. height: height,
  2106. x: x + getWindowScrollBarX(element),
  2107. y: y
  2108. };
  2109. }
  2110. // of the `<html>` and `<body>` rect bounds if horizontally scrollable
  2111. function getDocumentRect(element) {
  2112. var _element$ownerDocumen;
  2113. var html = getDocumentElement(element);
  2114. var winScroll = getWindowScroll(element);
  2115. var body = (_element$ownerDocumen = element.ownerDocument) == null ? void 0 : _element$ownerDocumen.body;
  2116. var width = max(html.scrollWidth, html.clientWidth, body ? body.scrollWidth : 0, body ? body.clientWidth : 0);
  2117. var height = max(html.scrollHeight, html.clientHeight, body ? body.scrollHeight : 0, body ? body.clientHeight : 0);
  2118. var x = -winScroll.scrollLeft + getWindowScrollBarX(element);
  2119. var y = -winScroll.scrollTop;
  2120. if (getComputedStyle$1(body || html).direction === 'rtl') {
  2121. x += max(html.clientWidth, body ? body.clientWidth : 0) - width;
  2122. }
  2123. return {
  2124. width: width,
  2125. height: height,
  2126. x: x,
  2127. y: y
  2128. };
  2129. }
  2130. function isScrollParent(element) {
  2131. // Firefox wants us to check `-x` and `-y` variations as well
  2132. var _getComputedStyle = getComputedStyle$1(element),
  2133. overflow = _getComputedStyle.overflow,
  2134. overflowX = _getComputedStyle.overflowX,
  2135. overflowY = _getComputedStyle.overflowY;
  2136. return /auto|scroll|overlay|hidden/.test(overflow + overflowY + overflowX);
  2137. }
  2138. function getScrollParent(node) {
  2139. if (['html', 'body', '#document'].indexOf(getNodeName(node)) >= 0) {
  2140. // $FlowFixMe[incompatible-return]: assume body is always available
  2141. return node.ownerDocument.body;
  2142. }
  2143. if (isHTMLElement(node) && isScrollParent(node)) {
  2144. return node;
  2145. }
  2146. return getScrollParent(getParentNode(node));
  2147. }
  2148. /*
  2149. given a DOM element, return the list of all scroll parents, up the list of ancesors
  2150. until we get to the top window object. This list is what we attach scroll listeners
  2151. to, because if any of these parent elements scroll, we'll need to re-calculate the
  2152. reference element's position.
  2153. */
  2154. function listScrollParents(element, list) {
  2155. var _element$ownerDocumen;
  2156. if (list === void 0) {
  2157. list = [];
  2158. }
  2159. var scrollParent = getScrollParent(element);
  2160. var isBody = scrollParent === ((_element$ownerDocumen = element.ownerDocument) == null ? void 0 : _element$ownerDocumen.body);
  2161. var win = getWindow(scrollParent);
  2162. var target = isBody ? [win].concat(win.visualViewport || [], isScrollParent(scrollParent) ? scrollParent : []) : scrollParent;
  2163. var updatedList = list.concat(target);
  2164. return isBody ? updatedList : // $FlowFixMe[incompatible-call]: isBody tells us target will be an HTMLElement here
  2165. updatedList.concat(listScrollParents(getParentNode(target)));
  2166. }
  2167. function rectToClientRect(rect) {
  2168. return Object.assign({}, rect, {
  2169. left: rect.x,
  2170. top: rect.y,
  2171. right: rect.x + rect.width,
  2172. bottom: rect.y + rect.height
  2173. });
  2174. }
  2175. function getInnerBoundingClientRect(element) {
  2176. var rect = getBoundingClientRect(element);
  2177. rect.top = rect.top + element.clientTop;
  2178. rect.left = rect.left + element.clientLeft;
  2179. rect.bottom = rect.top + element.clientHeight;
  2180. rect.right = rect.left + element.clientWidth;
  2181. rect.width = element.clientWidth;
  2182. rect.height = element.clientHeight;
  2183. rect.x = rect.left;
  2184. rect.y = rect.top;
  2185. return rect;
  2186. }
  2187. function getClientRectFromMixedType(element, clippingParent) {
  2188. return clippingParent === viewport ? rectToClientRect(getViewportRect(element)) : isHTMLElement(clippingParent) ? getInnerBoundingClientRect(clippingParent) : rectToClientRect(getDocumentRect(getDocumentElement(element)));
  2189. } // A "clipping parent" is an overflowable container with the characteristic of
  2190. // clipping (or hiding) overflowing elements with a position different from
  2191. // `initial`
  2192. function getClippingParents(element) {
  2193. var clippingParents = listScrollParents(getParentNode(element));
  2194. var canEscapeClipping = ['absolute', 'fixed'].indexOf(getComputedStyle$1(element).position) >= 0;
  2195. var clipperElement = canEscapeClipping && isHTMLElement(element) ? getOffsetParent(element) : element;
  2196. if (!isElement(clipperElement)) {
  2197. return [];
  2198. } // $FlowFixMe[incompatible-return]: https://github.com/facebook/flow/issues/1414
  2199. return clippingParents.filter(function (clippingParent) {
  2200. return isElement(clippingParent) && contains(clippingParent, clipperElement) && getNodeName(clippingParent) !== 'body';
  2201. });
  2202. } // Gets the maximum area that the element is visible in due to any number of
  2203. // clipping parents
  2204. function getClippingRect(element, boundary, rootBoundary) {
  2205. var mainClippingParents = boundary === 'clippingParents' ? getClippingParents(element) : [].concat(boundary);
  2206. var clippingParents = [].concat(mainClippingParents, [rootBoundary]);
  2207. var firstClippingParent = clippingParents[0];
  2208. var clippingRect = clippingParents.reduce(function (accRect, clippingParent) {
  2209. var rect = getClientRectFromMixedType(element, clippingParent);
  2210. accRect.top = max(rect.top, accRect.top);
  2211. accRect.right = min(rect.right, accRect.right);
  2212. accRect.bottom = min(rect.bottom, accRect.bottom);
  2213. accRect.left = max(rect.left, accRect.left);
  2214. return accRect;
  2215. }, getClientRectFromMixedType(element, firstClippingParent));
  2216. clippingRect.width = clippingRect.right - clippingRect.left;
  2217. clippingRect.height = clippingRect.bottom - clippingRect.top;
  2218. clippingRect.x = clippingRect.left;
  2219. clippingRect.y = clippingRect.top;
  2220. return clippingRect;
  2221. }
  2222. function computeOffsets(_ref) {
  2223. var reference = _ref.reference,
  2224. element = _ref.element,
  2225. placement = _ref.placement;
  2226. var basePlacement = placement ? getBasePlacement(placement) : null;
  2227. var variation = placement ? getVariation(placement) : null;
  2228. var commonX = reference.x + reference.width / 2 - element.width / 2;
  2229. var commonY = reference.y + reference.height / 2 - element.height / 2;
  2230. var offsets;
  2231. switch (basePlacement) {
  2232. case top:
  2233. offsets = {
  2234. x: commonX,
  2235. y: reference.y - element.height
  2236. };
  2237. break;
  2238. case bottom:
  2239. offsets = {
  2240. x: commonX,
  2241. y: reference.y + reference.height
  2242. };
  2243. break;
  2244. case right:
  2245. offsets = {
  2246. x: reference.x + reference.width,
  2247. y: commonY
  2248. };
  2249. break;
  2250. case left:
  2251. offsets = {
  2252. x: reference.x - element.width,
  2253. y: commonY
  2254. };
  2255. break;
  2256. default:
  2257. offsets = {
  2258. x: reference.x,
  2259. y: reference.y
  2260. };
  2261. }
  2262. var mainAxis = basePlacement ? getMainAxisFromPlacement(basePlacement) : null;
  2263. if (mainAxis != null) {
  2264. var len = mainAxis === 'y' ? 'height' : 'width';
  2265. switch (variation) {
  2266. case start:
  2267. offsets[mainAxis] = offsets[mainAxis] - (reference[len] / 2 - element[len] / 2);
  2268. break;
  2269. case end:
  2270. offsets[mainAxis] = offsets[mainAxis] + (reference[len] / 2 - element[len] / 2);
  2271. break;
  2272. }
  2273. }
  2274. return offsets;
  2275. }
  2276. function detectOverflow(state, options) {
  2277. if (options === void 0) {
  2278. options = {};
  2279. }
  2280. var _options = options,
  2281. _options$placement = _options.placement,
  2282. placement = _options$placement === void 0 ? state.placement : _options$placement,
  2283. _options$boundary = _options.boundary,
  2284. boundary = _options$boundary === void 0 ? clippingParents : _options$boundary,
  2285. _options$rootBoundary = _options.rootBoundary,
  2286. rootBoundary = _options$rootBoundary === void 0 ? viewport : _options$rootBoundary,
  2287. _options$elementConte = _options.elementContext,
  2288. elementContext = _options$elementConte === void 0 ? popper : _options$elementConte,
  2289. _options$altBoundary = _options.altBoundary,
  2290. altBoundary = _options$altBoundary === void 0 ? false : _options$altBoundary,
  2291. _options$padding = _options.padding,
  2292. padding = _options$padding === void 0 ? 0 : _options$padding;
  2293. var paddingObject = mergePaddingObject(typeof padding !== 'number' ? padding : expandToHashMap(padding, basePlacements));
  2294. var altContext = elementContext === popper ? reference : popper;
  2295. var popperRect = state.rects.popper;
  2296. var element = state.elements[altBoundary ? altContext : elementContext];
  2297. var clippingClientRect = getClippingRect(isElement(element) ? element : element.contextElement || getDocumentElement(state.elements.popper), boundary, rootBoundary);
  2298. var referenceClientRect = getBoundingClientRect(state.elements.reference);
  2299. var popperOffsets = computeOffsets({
  2300. reference: referenceClientRect,
  2301. element: popperRect,
  2302. strategy: 'absolute',
  2303. placement: placement
  2304. });
  2305. var popperClientRect = rectToClientRect(Object.assign({}, popperRect, popperOffsets));
  2306. var elementClientRect = elementContext === popper ? popperClientRect : referenceClientRect; // positive = overflowing the clipping rect
  2307. // 0 or negative = within the clipping rect
  2308. var overflowOffsets = {
  2309. top: clippingClientRect.top - elementClientRect.top + paddingObject.top,
  2310. bottom: elementClientRect.bottom - clippingClientRect.bottom + paddingObject.bottom,
  2311. left: clippingClientRect.left - elementClientRect.left + paddingObject.left,
  2312. right: elementClientRect.right - clippingClientRect.right + paddingObject.right
  2313. };
  2314. var offsetData = state.modifiersData.offset; // Offsets can be applied only to the popper element
  2315. if (elementContext === popper && offsetData) {
  2316. var offset = offsetData[placement];
  2317. Object.keys(overflowOffsets).forEach(function (key) {
  2318. var multiply = [right, bottom].indexOf(key) >= 0 ? 1 : -1;
  2319. var axis = [top, bottom].indexOf(key) >= 0 ? 'y' : 'x';
  2320. overflowOffsets[key] += offset[axis] * multiply;
  2321. });
  2322. }
  2323. return overflowOffsets;
  2324. }
  2325. function computeAutoPlacement(state, options) {
  2326. if (options === void 0) {
  2327. options = {};
  2328. }
  2329. var _options = options,
  2330. placement = _options.placement,
  2331. boundary = _options.boundary,
  2332. rootBoundary = _options.rootBoundary,
  2333. padding = _options.padding,
  2334. flipVariations = _options.flipVariations,
  2335. _options$allowedAutoP = _options.allowedAutoPlacements,
  2336. allowedAutoPlacements = _options$allowedAutoP === void 0 ? placements : _options$allowedAutoP;
  2337. var variation = getVariation(placement);
  2338. var placements$1 = variation ? flipVariations ? variationPlacements : variationPlacements.filter(function (placement) {
  2339. return getVariation(placement) === variation;
  2340. }) : basePlacements;
  2341. var allowedPlacements = placements$1.filter(function (placement) {
  2342. return allowedAutoPlacements.indexOf(placement) >= 0;
  2343. });
  2344. if (allowedPlacements.length === 0) {
  2345. allowedPlacements = placements$1;
  2346. } // $FlowFixMe[incompatible-type]: Flow seems to have problems with two array unions...
  2347. var overflows = allowedPlacements.reduce(function (acc, placement) {
  2348. acc[placement] = detectOverflow(state, {
  2349. placement: placement,
  2350. boundary: boundary,
  2351. rootBoundary: rootBoundary,
  2352. padding: padding
  2353. })[getBasePlacement(placement)];
  2354. return acc;
  2355. }, {});
  2356. return Object.keys(overflows).sort(function (a, b) {
  2357. return overflows[a] - overflows[b];
  2358. });
  2359. }
  2360. function getExpandedFallbackPlacements(placement) {
  2361. if (getBasePlacement(placement) === auto) {
  2362. return [];
  2363. }
  2364. var oppositePlacement = getOppositePlacement(placement);
  2365. return [getOppositeVariationPlacement(placement), oppositePlacement, getOppositeVariationPlacement(oppositePlacement)];
  2366. }
  2367. function flip(_ref) {
  2368. var state = _ref.state,
  2369. options = _ref.options,
  2370. name = _ref.name;
  2371. if (state.modifiersData[name]._skip) {
  2372. return;
  2373. }
  2374. var _options$mainAxis = options.mainAxis,
  2375. checkMainAxis = _options$mainAxis === void 0 ? true : _options$mainAxis,
  2376. _options$altAxis = options.altAxis,
  2377. checkAltAxis = _options$altAxis === void 0 ? true : _options$altAxis,
  2378. specifiedFallbackPlacements = options.fallbackPlacements,
  2379. padding = options.padding,
  2380. boundary = options.boundary,
  2381. rootBoundary = options.rootBoundary,
  2382. altBoundary = options.altBoundary,
  2383. _options$flipVariatio = options.flipVariations,
  2384. flipVariations = _options$flipVariatio === void 0 ? true : _options$flipVariatio,
  2385. allowedAutoPlacements = options.allowedAutoPlacements;
  2386. var preferredPlacement = state.options.placement;
  2387. var basePlacement = getBasePlacement(preferredPlacement);
  2388. var isBasePlacement = basePlacement === preferredPlacement;
  2389. var fallbackPlacements = specifiedFallbackPlacements || (isBasePlacement || !flipVariations ? [getOppositePlacement(preferredPlacement)] : getExpandedFallbackPlacements(preferredPlacement));
  2390. var placements = [preferredPlacement].concat(fallbackPlacements).reduce(function (acc, placement) {
  2391. return acc.concat(getBasePlacement(placement) === auto ? computeAutoPlacement(state, {
  2392. placement: placement,
  2393. boundary: boundary,
  2394. rootBoundary: rootBoundary,
  2395. padding: padding,
  2396. flipVariations: flipVariations,
  2397. allowedAutoPlacements: allowedAutoPlacements
  2398. }) : placement);
  2399. }, []);
  2400. var referenceRect = state.rects.reference;
  2401. var popperRect = state.rects.popper;
  2402. var checksMap = new Map();
  2403. var makeFallbackChecks = true;
  2404. var firstFittingPlacement = placements[0];
  2405. for (var i = 0; i < placements.length; i++) {
  2406. var placement = placements[i];
  2407. var _basePlacement = getBasePlacement(placement);
  2408. var isStartVariation = getVariation(placement) === start;
  2409. var isVertical = [top, bottom].indexOf(_basePlacement) >= 0;
  2410. var len = isVertical ? 'width' : 'height';
  2411. var overflow = detectOverflow(state, {
  2412. placement: placement,
  2413. boundary: boundary,
  2414. rootBoundary: rootBoundary,
  2415. altBoundary: altBoundary,
  2416. padding: padding
  2417. });
  2418. var mainVariationSide = isVertical ? isStartVariation ? right : left : isStartVariation ? bottom : top;
  2419. if (referenceRect[len] > popperRect[len]) {
  2420. mainVariationSide = getOppositePlacement(mainVariationSide);
  2421. }
  2422. var altVariationSide = getOppositePlacement(mainVariationSide);
  2423. var checks = [];
  2424. if (checkMainAxis) {
  2425. checks.push(overflow[_basePlacement] <= 0);
  2426. }
  2427. if (checkAltAxis) {
  2428. checks.push(overflow[mainVariationSide] <= 0, overflow[altVariationSide] <= 0);
  2429. }
  2430. if (checks.every(function (check) {
  2431. return check;
  2432. })) {
  2433. firstFittingPlacement = placement;
  2434. makeFallbackChecks = false;
  2435. break;
  2436. }
  2437. checksMap.set(placement, checks);
  2438. }
  2439. if (makeFallbackChecks) {
  2440. // `2` may be desired in some cases – research later
  2441. var numberOfChecks = flipVariations ? 3 : 1;
  2442. var _loop = function _loop(_i) {
  2443. var fittingPlacement = placements.find(function (placement) {
  2444. var checks = checksMap.get(placement);
  2445. if (checks) {
  2446. return checks.slice(0, _i).every(function (check) {
  2447. return check;
  2448. });
  2449. }
  2450. });
  2451. if (fittingPlacement) {
  2452. firstFittingPlacement = fittingPlacement;
  2453. return "break";
  2454. }
  2455. };
  2456. for (var _i = numberOfChecks; _i > 0; _i--) {
  2457. var _ret = _loop(_i);
  2458. if (_ret === "break") break;
  2459. }
  2460. }
  2461. if (state.placement !== firstFittingPlacement) {
  2462. state.modifiersData[name]._skip = true;
  2463. state.placement = firstFittingPlacement;
  2464. state.reset = true;
  2465. }
  2466. } // eslint-disable-next-line import/no-unused-modules
  2467. const flip$1 = {
  2468. name: 'flip',
  2469. enabled: true,
  2470. phase: 'main',
  2471. fn: flip,
  2472. requiresIfExists: ['offset'],
  2473. data: {
  2474. _skip: false
  2475. }
  2476. };
  2477. function getSideOffsets(overflow, rect, preventedOffsets) {
  2478. if (preventedOffsets === void 0) {
  2479. preventedOffsets = {
  2480. x: 0,
  2481. y: 0
  2482. };
  2483. }
  2484. return {
  2485. top: overflow.top - rect.height - preventedOffsets.y,
  2486. right: overflow.right - rect.width + preventedOffsets.x,
  2487. bottom: overflow.bottom - rect.height + preventedOffsets.y,
  2488. left: overflow.left - rect.width - preventedOffsets.x
  2489. };
  2490. }
  2491. function isAnySideFullyClipped(overflow) {
  2492. return [top, right, bottom, left].some(function (side) {
  2493. return overflow[side] >= 0;
  2494. });
  2495. }
  2496. function hide(_ref) {
  2497. var state = _ref.state,
  2498. name = _ref.name;
  2499. var referenceRect = state.rects.reference;
  2500. var popperRect = state.rects.popper;
  2501. var preventedOffsets = state.modifiersData.preventOverflow;
  2502. var referenceOverflow = detectOverflow(state, {
  2503. elementContext: 'reference'
  2504. });
  2505. var popperAltOverflow = detectOverflow(state, {
  2506. altBoundary: true
  2507. });
  2508. var referenceClippingOffsets = getSideOffsets(referenceOverflow, referenceRect);
  2509. var popperEscapeOffsets = getSideOffsets(popperAltOverflow, popperRect, preventedOffsets);
  2510. var isReferenceHidden = isAnySideFullyClipped(referenceClippingOffsets);
  2511. var hasPopperEscaped = isAnySideFullyClipped(popperEscapeOffsets);
  2512. state.modifiersData[name] = {
  2513. referenceClippingOffsets: referenceClippingOffsets,
  2514. popperEscapeOffsets: popperEscapeOffsets,
  2515. isReferenceHidden: isReferenceHidden,
  2516. hasPopperEscaped: hasPopperEscaped
  2517. };
  2518. state.attributes.popper = Object.assign({}, state.attributes.popper, {
  2519. 'data-popper-reference-hidden': isReferenceHidden,
  2520. 'data-popper-escaped': hasPopperEscaped
  2521. });
  2522. } // eslint-disable-next-line import/no-unused-modules
  2523. const hide$1 = {
  2524. name: 'hide',
  2525. enabled: true,
  2526. phase: 'main',
  2527. requiresIfExists: ['preventOverflow'],
  2528. fn: hide
  2529. };
  2530. function distanceAndSkiddingToXY(placement, rects, offset) {
  2531. var basePlacement = getBasePlacement(placement);
  2532. var invertDistance = [left, top].indexOf(basePlacement) >= 0 ? -1 : 1;
  2533. var _ref = typeof offset === 'function' ? offset(Object.assign({}, rects, {
  2534. placement: placement
  2535. })) : offset,
  2536. skidding = _ref[0],
  2537. distance = _ref[1];
  2538. skidding = skidding || 0;
  2539. distance = (distance || 0) * invertDistance;
  2540. return [left, right].indexOf(basePlacement) >= 0 ? {
  2541. x: distance,
  2542. y: skidding
  2543. } : {
  2544. x: skidding,
  2545. y: distance
  2546. };
  2547. }
  2548. function offset(_ref2) {
  2549. var state = _ref2.state,
  2550. options = _ref2.options,
  2551. name = _ref2.name;
  2552. var _options$offset = options.offset,
  2553. offset = _options$offset === void 0 ? [0, 0] : _options$offset;
  2554. var data = placements.reduce(function (acc, placement) {
  2555. acc[placement] = distanceAndSkiddingToXY(placement, state.rects, offset);
  2556. return acc;
  2557. }, {});
  2558. var _data$state$placement = data[state.placement],
  2559. x = _data$state$placement.x,
  2560. y = _data$state$placement.y;
  2561. if (state.modifiersData.popperOffsets != null) {
  2562. state.modifiersData.popperOffsets.x += x;
  2563. state.modifiersData.popperOffsets.y += y;
  2564. }
  2565. state.modifiersData[name] = data;
  2566. } // eslint-disable-next-line import/no-unused-modules
  2567. const offset$1 = {
  2568. name: 'offset',
  2569. enabled: true,
  2570. phase: 'main',
  2571. requires: ['popperOffsets'],
  2572. fn: offset
  2573. };
  2574. function popperOffsets(_ref) {
  2575. var state = _ref.state,
  2576. name = _ref.name;
  2577. // Offsets are the actual position the popper needs to have to be
  2578. // properly positioned near its reference element
  2579. // This is the most basic placement, and will be adjusted by
  2580. // the modifiers in the next step
  2581. state.modifiersData[name] = computeOffsets({
  2582. reference: state.rects.reference,
  2583. element: state.rects.popper,
  2584. strategy: 'absolute',
  2585. placement: state.placement
  2586. });
  2587. } // eslint-disable-next-line import/no-unused-modules
  2588. const popperOffsets$1 = {
  2589. name: 'popperOffsets',
  2590. enabled: true,
  2591. phase: 'read',
  2592. fn: popperOffsets,
  2593. data: {}
  2594. };
  2595. function getAltAxis(axis) {
  2596. return axis === 'x' ? 'y' : 'x';
  2597. }
  2598. function preventOverflow(_ref) {
  2599. var state = _ref.state,
  2600. options = _ref.options,
  2601. name = _ref.name;
  2602. var _options$mainAxis = options.mainAxis,
  2603. checkMainAxis = _options$mainAxis === void 0 ? true : _options$mainAxis,
  2604. _options$altAxis = options.altAxis,
  2605. checkAltAxis = _options$altAxis === void 0 ? false : _options$altAxis,
  2606. boundary = options.boundary,
  2607. rootBoundary = options.rootBoundary,
  2608. altBoundary = options.altBoundary,
  2609. padding = options.padding,
  2610. _options$tether = options.tether,
  2611. tether = _options$tether === void 0 ? true : _options$tether,
  2612. _options$tetherOffset = options.tetherOffset,
  2613. tetherOffset = _options$tetherOffset === void 0 ? 0 : _options$tetherOffset;
  2614. var overflow = detectOverflow(state, {
  2615. boundary: boundary,
  2616. rootBoundary: rootBoundary,
  2617. padding: padding,
  2618. altBoundary: altBoundary
  2619. });
  2620. var basePlacement = getBasePlacement(state.placement);
  2621. var variation = getVariation(state.placement);
  2622. var isBasePlacement = !variation;
  2623. var mainAxis = getMainAxisFromPlacement(basePlacement);
  2624. var altAxis = getAltAxis(mainAxis);
  2625. var popperOffsets = state.modifiersData.popperOffsets;
  2626. var referenceRect = state.rects.reference;
  2627. var popperRect = state.rects.popper;
  2628. var tetherOffsetValue = typeof tetherOffset === 'function' ? tetherOffset(Object.assign({}, state.rects, {
  2629. placement: state.placement
  2630. })) : tetherOffset;
  2631. var data = {
  2632. x: 0,
  2633. y: 0
  2634. };
  2635. if (!popperOffsets) {
  2636. return;
  2637. }
  2638. if (checkMainAxis || checkAltAxis) {
  2639. var mainSide = mainAxis === 'y' ? top : left;
  2640. var altSide = mainAxis === 'y' ? bottom : right;
  2641. var len = mainAxis === 'y' ? 'height' : 'width';
  2642. var offset = popperOffsets[mainAxis];
  2643. var min$1 = popperOffsets[mainAxis] + overflow[mainSide];
  2644. var max$1 = popperOffsets[mainAxis] - overflow[altSide];
  2645. var additive = tether ? -popperRect[len] / 2 : 0;
  2646. var minLen = variation === start ? referenceRect[len] : popperRect[len];
  2647. var maxLen = variation === start ? -popperRect[len] : -referenceRect[len]; // We need to include the arrow in the calculation so the arrow doesn't go
  2648. // outside the reference bounds
  2649. var arrowElement = state.elements.arrow;
  2650. var arrowRect = tether && arrowElement ? getLayoutRect(arrowElement) : {
  2651. width: 0,
  2652. height: 0
  2653. };
  2654. var arrowPaddingObject = state.modifiersData['arrow#persistent'] ? state.modifiersData['arrow#persistent'].padding : getFreshSideObject();
  2655. var arrowPaddingMin = arrowPaddingObject[mainSide];
  2656. var arrowPaddingMax = arrowPaddingObject[altSide]; // If the reference length is smaller than the arrow length, we don't want
  2657. // to include its full size in the calculation. If the reference is small
  2658. // and near the edge of a boundary, the popper can overflow even if the
  2659. // reference is not overflowing as well (e.g. virtual elements with no
  2660. // width or height)
  2661. var arrowLen = within(0, referenceRect[len], arrowRect[len]);
  2662. var minOffset = isBasePlacement ? referenceRect[len] / 2 - additive - arrowLen - arrowPaddingMin - tetherOffsetValue : minLen - arrowLen - arrowPaddingMin - tetherOffsetValue;
  2663. var maxOffset = isBasePlacement ? -referenceRect[len] / 2 + additive + arrowLen + arrowPaddingMax + tetherOffsetValue : maxLen + arrowLen + arrowPaddingMax + tetherOffsetValue;
  2664. var arrowOffsetParent = state.elements.arrow && getOffsetParent(state.elements.arrow);
  2665. var clientOffset = arrowOffsetParent ? mainAxis === 'y' ? arrowOffsetParent.clientTop || 0 : arrowOffsetParent.clientLeft || 0 : 0;
  2666. var offsetModifierValue = state.modifiersData.offset ? state.modifiersData.offset[state.placement][mainAxis] : 0;
  2667. var tetherMin = popperOffsets[mainAxis] + minOffset - offsetModifierValue - clientOffset;
  2668. var tetherMax = popperOffsets[mainAxis] + maxOffset - offsetModifierValue;
  2669. if (checkMainAxis) {
  2670. var preventedOffset = within(tether ? min(min$1, tetherMin) : min$1, offset, tether ? max(max$1, tetherMax) : max$1);
  2671. popperOffsets[mainAxis] = preventedOffset;
  2672. data[mainAxis] = preventedOffset - offset;
  2673. }
  2674. if (checkAltAxis) {
  2675. var _mainSide = mainAxis === 'x' ? top : left;
  2676. var _altSide = mainAxis === 'x' ? bottom : right;
  2677. var _offset = popperOffsets[altAxis];
  2678. var _min = _offset + overflow[_mainSide];
  2679. var _max = _offset - overflow[_altSide];
  2680. var _preventedOffset = within(tether ? min(_min, tetherMin) : _min, _offset, tether ? max(_max, tetherMax) : _max);
  2681. popperOffsets[altAxis] = _preventedOffset;
  2682. data[altAxis] = _preventedOffset - _offset;
  2683. }
  2684. }
  2685. state.modifiersData[name] = data;
  2686. } // eslint-disable-next-line import/no-unused-modules
  2687. const preventOverflow$1 = {
  2688. name: 'preventOverflow',
  2689. enabled: true,
  2690. phase: 'main',
  2691. fn: preventOverflow,
  2692. requiresIfExists: ['offset']
  2693. };
  2694. function getHTMLElementScroll(element) {
  2695. return {
  2696. scrollLeft: element.scrollLeft,
  2697. scrollTop: element.scrollTop
  2698. };
  2699. }
  2700. function getNodeScroll(node) {
  2701. if (node === getWindow(node) || !isHTMLElement(node)) {
  2702. return getWindowScroll(node);
  2703. } else {
  2704. return getHTMLElementScroll(node);
  2705. }
  2706. }
  2707. function isElementScaled(element) {
  2708. var rect = element.getBoundingClientRect();
  2709. var scaleX = rect.width / element.offsetWidth || 1;
  2710. var scaleY = rect.height / element.offsetHeight || 1;
  2711. return scaleX !== 1 || scaleY !== 1;
  2712. } // Returns the composite rect of an element relative to its offsetParent.
  2713. // Composite means it takes into account transforms as well as layout.
  2714. function getCompositeRect(elementOrVirtualElement, offsetParent, isFixed) {
  2715. if (isFixed === void 0) {
  2716. isFixed = false;
  2717. }
  2718. var isOffsetParentAnElement = isHTMLElement(offsetParent);
  2719. isHTMLElement(offsetParent) && isElementScaled(offsetParent);
  2720. var documentElement = getDocumentElement(offsetParent);
  2721. var rect = getBoundingClientRect(elementOrVirtualElement);
  2722. var scroll = {
  2723. scrollLeft: 0,
  2724. scrollTop: 0
  2725. };
  2726. var offsets = {
  2727. x: 0,
  2728. y: 0
  2729. };
  2730. if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
  2731. if (getNodeName(offsetParent) !== 'body' || // https://github.com/popperjs/popper-core/issues/1078
  2732. isScrollParent(documentElement)) {
  2733. scroll = getNodeScroll(offsetParent);
  2734. }
  2735. if (isHTMLElement(offsetParent)) {
  2736. offsets = getBoundingClientRect(offsetParent);
  2737. offsets.x += offsetParent.clientLeft;
  2738. offsets.y += offsetParent.clientTop;
  2739. } else if (documentElement) {
  2740. offsets.x = getWindowScrollBarX(documentElement);
  2741. }
  2742. }
  2743. return {
  2744. x: rect.left + scroll.scrollLeft - offsets.x,
  2745. y: rect.top + scroll.scrollTop - offsets.y,
  2746. width: rect.width,
  2747. height: rect.height
  2748. };
  2749. }
  2750. function order(modifiers) {
  2751. var map = new Map();
  2752. var visited = new Set();
  2753. var result = [];
  2754. modifiers.forEach(function (modifier) {
  2755. map.set(modifier.name, modifier);
  2756. }); // On visiting object, check for its dependencies and visit them recursively
  2757. function sort(modifier) {
  2758. visited.add(modifier.name);
  2759. var requires = [].concat(modifier.requires || [], modifier.requiresIfExists || []);
  2760. requires.forEach(function (dep) {
  2761. if (!visited.has(dep)) {
  2762. var depModifier = map.get(dep);
  2763. if (depModifier) {
  2764. sort(depModifier);
  2765. }
  2766. }
  2767. });
  2768. result.push(modifier);
  2769. }
  2770. modifiers.forEach(function (modifier) {
  2771. if (!visited.has(modifier.name)) {
  2772. // check for visited object
  2773. sort(modifier);
  2774. }
  2775. });
  2776. return result;
  2777. }
  2778. function orderModifiers(modifiers) {
  2779. // order based on dependencies
  2780. var orderedModifiers = order(modifiers); // order based on phase
  2781. return modifierPhases.reduce(function (acc, phase) {
  2782. return acc.concat(orderedModifiers.filter(function (modifier) {
  2783. return modifier.phase === phase;
  2784. }));
  2785. }, []);
  2786. }
  2787. function debounce(fn) {
  2788. var pending;
  2789. return function () {
  2790. if (!pending) {
  2791. pending = new Promise(function (resolve) {
  2792. Promise.resolve().then(function () {
  2793. pending = undefined;
  2794. resolve(fn());
  2795. });
  2796. });
  2797. }
  2798. return pending;
  2799. };
  2800. }
  2801. function mergeByName(modifiers) {
  2802. var merged = modifiers.reduce(function (merged, current) {
  2803. var existing = merged[current.name];
  2804. merged[current.name] = existing ? Object.assign({}, existing, current, {
  2805. options: Object.assign({}, existing.options, current.options),
  2806. data: Object.assign({}, existing.data, current.data)
  2807. }) : current;
  2808. return merged;
  2809. }, {}); // IE11 does not support Object.values
  2810. return Object.keys(merged).map(function (key) {
  2811. return merged[key];
  2812. });
  2813. }
  2814. var DEFAULT_OPTIONS = {
  2815. placement: 'bottom',
  2816. modifiers: [],
  2817. strategy: 'absolute'
  2818. };
  2819. function areValidElements() {
  2820. for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
  2821. args[_key] = arguments[_key];
  2822. }
  2823. return !args.some(function (element) {
  2824. return !(element && typeof element.getBoundingClientRect === 'function');
  2825. });
  2826. }
  2827. function popperGenerator(generatorOptions) {
  2828. if (generatorOptions === void 0) {
  2829. generatorOptions = {};
  2830. }
  2831. var _generatorOptions = generatorOptions,
  2832. _generatorOptions$def = _generatorOptions.defaultModifiers,
  2833. defaultModifiers = _generatorOptions$def === void 0 ? [] : _generatorOptions$def,
  2834. _generatorOptions$def2 = _generatorOptions.defaultOptions,
  2835. defaultOptions = _generatorOptions$def2 === void 0 ? DEFAULT_OPTIONS : _generatorOptions$def2;
  2836. return function createPopper(reference, popper, options) {
  2837. if (options === void 0) {
  2838. options = defaultOptions;
  2839. }
  2840. var state = {
  2841. placement: 'bottom',
  2842. orderedModifiers: [],
  2843. options: Object.assign({}, DEFAULT_OPTIONS, defaultOptions),
  2844. modifiersData: {},
  2845. elements: {
  2846. reference: reference,
  2847. popper: popper
  2848. },
  2849. attributes: {},
  2850. styles: {}
  2851. };
  2852. var effectCleanupFns = [];
  2853. var isDestroyed = false;
  2854. var instance = {
  2855. state: state,
  2856. setOptions: function setOptions(setOptionsAction) {
  2857. var options = typeof setOptionsAction === 'function' ? setOptionsAction(state.options) : setOptionsAction;
  2858. cleanupModifierEffects();
  2859. state.options = Object.assign({}, defaultOptions, state.options, options);
  2860. state.scrollParents = {
  2861. reference: isElement(reference) ? listScrollParents(reference) : reference.contextElement ? listScrollParents(reference.contextElement) : [],
  2862. popper: listScrollParents(popper)
  2863. }; // Orders the modifiers based on their dependencies and `phase`
  2864. // properties
  2865. var orderedModifiers = orderModifiers(mergeByName([].concat(defaultModifiers, state.options.modifiers))); // Strip out disabled modifiers
  2866. state.orderedModifiers = orderedModifiers.filter(function (m) {
  2867. return m.enabled;
  2868. }); // Validate the provided modifiers so that the consumer will get warned
  2869. runModifierEffects();
  2870. return instance.update();
  2871. },
  2872. // Sync update – it will always be executed, even if not necessary. This
  2873. // is useful for low frequency updates where sync behavior simplifies the
  2874. // logic.
  2875. // For high frequency updates (e.g. `resize` and `scroll` events), always
  2876. // prefer the async Popper#update method
  2877. forceUpdate: function forceUpdate() {
  2878. if (isDestroyed) {
  2879. return;
  2880. }
  2881. var _state$elements = state.elements,
  2882. reference = _state$elements.reference,
  2883. popper = _state$elements.popper; // Don't proceed if `reference` or `popper` are not valid elements
  2884. // anymore
  2885. if (!areValidElements(reference, popper)) {
  2886. return;
  2887. } // Store the reference and popper rects to be read by modifiers
  2888. state.rects = {
  2889. reference: getCompositeRect(reference, getOffsetParent(popper), state.options.strategy === 'fixed'),
  2890. popper: getLayoutRect(popper)
  2891. }; // Modifiers have the ability to reset the current update cycle. The
  2892. // most common use case for this is the `flip` modifier changing the
  2893. // placement, which then needs to re-run all the modifiers, because the
  2894. // logic was previously ran for the previous placement and is therefore
  2895. // stale/incorrect
  2896. state.reset = false;
  2897. state.placement = state.options.placement; // On each update cycle, the `modifiersData` property for each modifier
  2898. // is filled with the initial data specified by the modifier. This means
  2899. // it doesn't persist and is fresh on each update.
  2900. // To ensure persistent data, use `${name}#persistent`
  2901. state.orderedModifiers.forEach(function (modifier) {
  2902. return state.modifiersData[modifier.name] = Object.assign({}, modifier.data);
  2903. });
  2904. for (var index = 0; index < state.orderedModifiers.length; index++) {
  2905. if (state.reset === true) {
  2906. state.reset = false;
  2907. index = -1;
  2908. continue;
  2909. }
  2910. var _state$orderedModifie = state.orderedModifiers[index],
  2911. fn = _state$orderedModifie.fn,
  2912. _state$orderedModifie2 = _state$orderedModifie.options,
  2913. _options = _state$orderedModifie2 === void 0 ? {} : _state$orderedModifie2,
  2914. name = _state$orderedModifie.name;
  2915. if (typeof fn === 'function') {
  2916. state = fn({
  2917. state: state,
  2918. options: _options,
  2919. name: name,
  2920. instance: instance
  2921. }) || state;
  2922. }
  2923. }
  2924. },
  2925. // Async and optimistically optimized update – it will not be executed if
  2926. // not necessary (debounced to run at most once-per-tick)
  2927. update: debounce(function () {
  2928. return new Promise(function (resolve) {
  2929. instance.forceUpdate();
  2930. resolve(state);
  2931. });
  2932. }),
  2933. destroy: function destroy() {
  2934. cleanupModifierEffects();
  2935. isDestroyed = true;
  2936. }
  2937. };
  2938. if (!areValidElements(reference, popper)) {
  2939. return instance;
  2940. }
  2941. instance.setOptions(options).then(function (state) {
  2942. if (!isDestroyed && options.onFirstUpdate) {
  2943. options.onFirstUpdate(state);
  2944. }
  2945. }); // Modifiers have the ability to execute arbitrary code before the first
  2946. // update cycle runs. They will be executed in the same order as the update
  2947. // cycle. This is useful when a modifier adds some persistent data that
  2948. // other modifiers need to use, but the modifier is run after the dependent
  2949. // one.
  2950. function runModifierEffects() {
  2951. state.orderedModifiers.forEach(function (_ref3) {
  2952. var name = _ref3.name,
  2953. _ref3$options = _ref3.options,
  2954. options = _ref3$options === void 0 ? {} : _ref3$options,
  2955. effect = _ref3.effect;
  2956. if (typeof effect === 'function') {
  2957. var cleanupFn = effect({
  2958. state: state,
  2959. name: name,
  2960. instance: instance,
  2961. options: options
  2962. });
  2963. var noopFn = function noopFn() {};
  2964. effectCleanupFns.push(cleanupFn || noopFn);
  2965. }
  2966. });
  2967. }
  2968. function cleanupModifierEffects() {
  2969. effectCleanupFns.forEach(function (fn) {
  2970. return fn();
  2971. });
  2972. effectCleanupFns = [];
  2973. }
  2974. return instance;
  2975. };
  2976. }
  2977. var createPopper$2 = /*#__PURE__*/popperGenerator(); // eslint-disable-next-line import/no-unused-modules
  2978. var defaultModifiers$1 = [eventListeners, popperOffsets$1, computeStyles$1, applyStyles$1];
  2979. var createPopper$1 = /*#__PURE__*/popperGenerator({
  2980. defaultModifiers: defaultModifiers$1
  2981. }); // eslint-disable-next-line import/no-unused-modules
  2982. var defaultModifiers = [eventListeners, popperOffsets$1, computeStyles$1, applyStyles$1, offset$1, flip$1, preventOverflow$1, arrow$1, hide$1];
  2983. var createPopper = /*#__PURE__*/popperGenerator({
  2984. defaultModifiers: defaultModifiers
  2985. }); // eslint-disable-next-line import/no-unused-modules
  2986. const Popper = /*#__PURE__*/Object.freeze({
  2987. __proto__: null,
  2988. popperGenerator,
  2989. detectOverflow,
  2990. createPopperBase: createPopper$2,
  2991. createPopper,
  2992. createPopperLite: createPopper$1,
  2993. top,
  2994. bottom,
  2995. right,
  2996. left,
  2997. auto,
  2998. basePlacements,
  2999. start,
  3000. end,
  3001. clippingParents,
  3002. viewport,
  3003. popper,
  3004. reference,
  3005. variationPlacements,
  3006. placements,
  3007. beforeRead,
  3008. read,
  3009. afterRead,
  3010. beforeMain,
  3011. main,
  3012. afterMain,
  3013. beforeWrite,
  3014. write,
  3015. afterWrite,
  3016. modifierPhases,
  3017. applyStyles: applyStyles$1,
  3018. arrow: arrow$1,
  3019. computeStyles: computeStyles$1,
  3020. eventListeners,
  3021. flip: flip$1,
  3022. hide: hide$1,
  3023. offset: offset$1,
  3024. popperOffsets: popperOffsets$1,
  3025. preventOverflow: preventOverflow$1
  3026. });
  3027. /**
  3028. * --------------------------------------------------------------------------
  3029. * Bootstrap (v5.1.3): dropdown.js
  3030. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
  3031. * --------------------------------------------------------------------------
  3032. */
  3033. /**
  3034. * ------------------------------------------------------------------------
  3035. * Constants
  3036. * ------------------------------------------------------------------------
  3037. */
  3038. const NAME$9 = 'dropdown';
  3039. const DATA_KEY$8 = 'bs.dropdown';
  3040. const EVENT_KEY$8 = `.${DATA_KEY$8}`;
  3041. const DATA_API_KEY$4 = '.data-api';
  3042. const ESCAPE_KEY$2 = 'Escape';
  3043. const SPACE_KEY = 'Space';
  3044. const TAB_KEY$1 = 'Tab';
  3045. const ARROW_UP_KEY = 'ArrowUp';
  3046. const ARROW_DOWN_KEY = 'ArrowDown';
  3047. const RIGHT_MOUSE_BUTTON = 2; // MouseEvent.button value for the secondary button, usually the right button
  3048. const REGEXP_KEYDOWN = new RegExp(`${ARROW_UP_KEY}|${ARROW_DOWN_KEY}|${ESCAPE_KEY$2}`);
  3049. const EVENT_HIDE$4 = `hide${EVENT_KEY$8}`;
  3050. const EVENT_HIDDEN$4 = `hidden${EVENT_KEY$8}`;
  3051. const EVENT_SHOW$4 = `show${EVENT_KEY$8}`;
  3052. const EVENT_SHOWN$4 = `shown${EVENT_KEY$8}`;
  3053. const EVENT_CLICK_DATA_API$3 = `click${EVENT_KEY$8}${DATA_API_KEY$4}`;
  3054. const EVENT_KEYDOWN_DATA_API = `keydown${EVENT_KEY$8}${DATA_API_KEY$4}`;
  3055. const EVENT_KEYUP_DATA_API = `keyup${EVENT_KEY$8}${DATA_API_KEY$4}`;
  3056. const CLASS_NAME_SHOW$6 = 'show';
  3057. const CLASS_NAME_DROPUP = 'dropup';
  3058. const CLASS_NAME_DROPEND = 'dropend';
  3059. const CLASS_NAME_DROPSTART = 'dropstart';
  3060. const CLASS_NAME_NAVBAR = 'navbar';
  3061. const SELECTOR_DATA_TOGGLE$3 = '[data-bs-toggle="dropdown"]';
  3062. const SELECTOR_MENU = '.dropdown-menu';
  3063. const SELECTOR_NAVBAR_NAV = '.navbar-nav';
  3064. const SELECTOR_VISIBLE_ITEMS = '.dropdown-menu .dropdown-item:not(.disabled):not(:disabled)';
  3065. const PLACEMENT_TOP = isRTL() ? 'top-end' : 'top-start';
  3066. const PLACEMENT_TOPEND = isRTL() ? 'top-start' : 'top-end';
  3067. const PLACEMENT_BOTTOM = isRTL() ? 'bottom-end' : 'bottom-start';
  3068. const PLACEMENT_BOTTOMEND = isRTL() ? 'bottom-start' : 'bottom-end';
  3069. const PLACEMENT_RIGHT = isRTL() ? 'left-start' : 'right-start';
  3070. const PLACEMENT_LEFT = isRTL() ? 'right-start' : 'left-start';
  3071. const Default$8 = {
  3072. offset: [0, 2],
  3073. boundary: 'clippingParents',
  3074. reference: 'toggle',
  3075. display: 'dynamic',
  3076. popperConfig: null,
  3077. autoClose: true
  3078. };
  3079. const DefaultType$8 = {
  3080. offset: '(array|string|function)',
  3081. boundary: '(string|element)',
  3082. reference: '(string|element|object)',
  3083. display: 'string',
  3084. popperConfig: '(null|object|function)',
  3085. autoClose: '(boolean|string)'
  3086. };
  3087. /**
  3088. * ------------------------------------------------------------------------
  3089. * Class Definition
  3090. * ------------------------------------------------------------------------
  3091. */
  3092. class Dropdown extends BaseComponent {
  3093. constructor(element, config) {
  3094. super(element);
  3095. this._popper = null;
  3096. this._config = this._getConfig(config);
  3097. this._menu = this._getMenuElement();
  3098. this._inNavbar = this._detectNavbar();
  3099. } // Getters
  3100. static get Default() {
  3101. return Default$8;
  3102. }
  3103. static get DefaultType() {
  3104. return DefaultType$8;
  3105. }
  3106. static get NAME() {
  3107. return NAME$9;
  3108. } // Public
  3109. toggle() {
  3110. return this._isShown() ? this.hide() : this.show();
  3111. }
  3112. show() {
  3113. if (isDisabled(this._element) || this._isShown(this._menu)) {
  3114. return;
  3115. }
  3116. const relatedTarget = {
  3117. relatedTarget: this._element
  3118. };
  3119. const showEvent = EventHandler.trigger(this._element, EVENT_SHOW$4, relatedTarget);
  3120. if (showEvent.defaultPrevented) {
  3121. return;
  3122. }
  3123. const parent = Dropdown.getParentFromElement(this._element); // Totally disable Popper for Dropdowns in Navbar
  3124. if (this._inNavbar) {
  3125. Manipulator.setDataAttribute(this._menu, 'popper', 'none');
  3126. } else {
  3127. this._createPopper(parent);
  3128. } // If this is a touch-enabled device we add extra
  3129. // empty mouseover listeners to the body's immediate children;
  3130. // only needed because of broken event delegation on iOS
  3131. // https://www.quirksmode.org/blog/archives/2014/02/mouse_event_bub.html
  3132. if ('ontouchstart' in document.documentElement && !parent.closest(SELECTOR_NAVBAR_NAV)) {
  3133. [].concat(...document.body.children).forEach(elem => EventHandler.on(elem, 'mouseover', noop));
  3134. }
  3135. this._element.focus();
  3136. this._element.setAttribute('aria-expanded', true);
  3137. this._menu.classList.add(CLASS_NAME_SHOW$6);
  3138. this._element.classList.add(CLASS_NAME_SHOW$6);
  3139. EventHandler.trigger(this._element, EVENT_SHOWN$4, relatedTarget);
  3140. }
  3141. hide() {
  3142. if (isDisabled(this._element) || !this._isShown(this._menu)) {
  3143. return;
  3144. }
  3145. const relatedTarget = {
  3146. relatedTarget: this._element
  3147. };
  3148. this._completeHide(relatedTarget);
  3149. }
  3150. dispose() {
  3151. if (this._popper) {
  3152. this._popper.destroy();
  3153. }
  3154. super.dispose();
  3155. }
  3156. update() {
  3157. this._inNavbar = this._detectNavbar();
  3158. if (this._popper) {
  3159. this._popper.update();
  3160. }
  3161. } // Private
  3162. _completeHide(relatedTarget) {
  3163. const hideEvent = EventHandler.trigger(this._element, EVENT_HIDE$4, relatedTarget);
  3164. if (hideEvent.defaultPrevented) {
  3165. return;
  3166. } // If this is a touch-enabled device we remove the extra
  3167. // empty mouseover listeners we added for iOS support
  3168. if ('ontouchstart' in document.documentElement) {
  3169. [].concat(...document.body.children).forEach(elem => EventHandler.off(elem, 'mouseover', noop));
  3170. }
  3171. if (this._popper) {
  3172. this._popper.destroy();
  3173. }
  3174. this._menu.classList.remove(CLASS_NAME_SHOW$6);
  3175. this._element.classList.remove(CLASS_NAME_SHOW$6);
  3176. this._element.setAttribute('aria-expanded', 'false');
  3177. Manipulator.removeDataAttribute(this._menu, 'popper');
  3178. EventHandler.trigger(this._element, EVENT_HIDDEN$4, relatedTarget);
  3179. }
  3180. _getConfig(config) {
  3181. config = { ...this.constructor.Default,
  3182. ...Manipulator.getDataAttributes(this._element),
  3183. ...config
  3184. };
  3185. typeCheckConfig(NAME$9, config, this.constructor.DefaultType);
  3186. if (typeof config.reference === 'object' && !isElement$1(config.reference) && typeof config.reference.getBoundingClientRect !== 'function') {
  3187. // Popper virtual elements require a getBoundingClientRect method
  3188. throw new TypeError(`${NAME$9.toUpperCase()}: Option "reference" provided type "object" without a required "getBoundingClientRect" method.`);
  3189. }
  3190. return config;
  3191. }
  3192. _createPopper(parent) {
  3193. if (typeof Popper === 'undefined') {
  3194. throw new TypeError('Bootstrap\'s dropdowns require Popper (https://popper.js.org)');
  3195. }
  3196. let referenceElement = this._element;
  3197. if (this._config.reference === 'parent') {
  3198. referenceElement = parent;
  3199. } else if (isElement$1(this._config.reference)) {
  3200. referenceElement = getElement(this._config.reference);
  3201. } else if (typeof this._config.reference === 'object') {
  3202. referenceElement = this._config.reference;
  3203. }
  3204. const popperConfig = this._getPopperConfig();
  3205. const isDisplayStatic = popperConfig.modifiers.find(modifier => modifier.name === 'applyStyles' && modifier.enabled === false);
  3206. this._popper = createPopper(referenceElement, this._menu, popperConfig);
  3207. if (isDisplayStatic) {
  3208. Manipulator.setDataAttribute(this._menu, 'popper', 'static');
  3209. }
  3210. }
  3211. _isShown(element = this._element) {
  3212. return element.classList.contains(CLASS_NAME_SHOW$6);
  3213. }
  3214. _getMenuElement() {
  3215. return SelectorEngine.next(this._element, SELECTOR_MENU)[0];
  3216. }
  3217. _getPlacement() {
  3218. const parentDropdown = this._element.parentNode;
  3219. if (parentDropdown.classList.contains(CLASS_NAME_DROPEND)) {
  3220. return PLACEMENT_RIGHT;
  3221. }
  3222. if (parentDropdown.classList.contains(CLASS_NAME_DROPSTART)) {
  3223. return PLACEMENT_LEFT;
  3224. } // We need to trim the value because custom properties can also include spaces
  3225. const isEnd = getComputedStyle(this._menu).getPropertyValue('--bs-position').trim() === 'end';
  3226. if (parentDropdown.classList.contains(CLASS_NAME_DROPUP)) {
  3227. return isEnd ? PLACEMENT_TOPEND : PLACEMENT_TOP;
  3228. }
  3229. return isEnd ? PLACEMENT_BOTTOMEND : PLACEMENT_BOTTOM;
  3230. }
  3231. _detectNavbar() {
  3232. return this._element.closest(`.${CLASS_NAME_NAVBAR}`) !== null;
  3233. }
  3234. _getOffset() {
  3235. const {
  3236. offset
  3237. } = this._config;
  3238. if (typeof offset === 'string') {
  3239. return offset.split(',').map(val => Number.parseInt(val, 10));
  3240. }
  3241. if (typeof offset === 'function') {
  3242. return popperData => offset(popperData, this._element);
  3243. }
  3244. return offset;
  3245. }
  3246. _getPopperConfig() {
  3247. const defaultBsPopperConfig = {
  3248. placement: this._getPlacement(),
  3249. modifiers: [{
  3250. name: 'preventOverflow',
  3251. options: {
  3252. boundary: this._config.boundary
  3253. }
  3254. }, {
  3255. name: 'offset',
  3256. options: {
  3257. offset: this._getOffset()
  3258. }
  3259. }]
  3260. }; // Disable Popper if we have a static display
  3261. if (this._config.display === 'static') {
  3262. defaultBsPopperConfig.modifiers = [{
  3263. name: 'applyStyles',
  3264. enabled: false
  3265. }];
  3266. }
  3267. return { ...defaultBsPopperConfig,
  3268. ...(typeof this._config.popperConfig === 'function' ? this._config.popperConfig(defaultBsPopperConfig) : this._config.popperConfig)
  3269. };
  3270. }
  3271. _selectMenuItem({
  3272. key,
  3273. target
  3274. }) {
  3275. const items = SelectorEngine.find(SELECTOR_VISIBLE_ITEMS, this._menu).filter(isVisible);
  3276. if (!items.length) {
  3277. return;
  3278. } // if target isn't included in items (e.g. when expanding the dropdown)
  3279. // allow cycling to get the last item in case key equals ARROW_UP_KEY
  3280. getNextActiveElement(items, target, key === ARROW_DOWN_KEY, !items.includes(target)).focus();
  3281. } // Static
  3282. static jQueryInterface(config) {
  3283. return this.each(function () {
  3284. const data = Dropdown.getOrCreateInstance(this, config);
  3285. if (typeof config !== 'string') {
  3286. return;
  3287. }
  3288. if (typeof data[config] === 'undefined') {
  3289. throw new TypeError(`No method named "${config}"`);
  3290. }
  3291. data[config]();
  3292. });
  3293. }
  3294. static clearMenus(event) {
  3295. if (event && (event.button === RIGHT_MOUSE_BUTTON || event.type === 'keyup' && event.key !== TAB_KEY$1)) {
  3296. return;
  3297. }
  3298. const toggles = SelectorEngine.find(SELECTOR_DATA_TOGGLE$3);
  3299. for (let i = 0, len = toggles.length; i < len; i++) {
  3300. const context = Dropdown.getInstance(toggles[i]);
  3301. if (!context || context._config.autoClose === false) {
  3302. continue;
  3303. }
  3304. if (!context._isShown()) {
  3305. continue;
  3306. }
  3307. const relatedTarget = {
  3308. relatedTarget: context._element
  3309. };
  3310. if (event) {
  3311. const composedPath = event.composedPath();
  3312. const isMenuTarget = composedPath.includes(context._menu);
  3313. if (composedPath.includes(context._element) || context._config.autoClose === 'inside' && !isMenuTarget || context._config.autoClose === 'outside' && isMenuTarget) {
  3314. continue;
  3315. } // Tab navigation through the dropdown menu or events from contained inputs shouldn't close the menu
  3316. if (context._menu.contains(event.target) && (event.type === 'keyup' && event.key === TAB_KEY$1 || /input|select|option|textarea|form/i.test(event.target.tagName))) {
  3317. continue;
  3318. }
  3319. if (event.type === 'click') {
  3320. relatedTarget.clickEvent = event;
  3321. }
  3322. }
  3323. context._completeHide(relatedTarget);
  3324. }
  3325. }
  3326. static getParentFromElement(element) {
  3327. return getElementFromSelector(element) || element.parentNode;
  3328. }
  3329. static dataApiKeydownHandler(event) {
  3330. // If not input/textarea:
  3331. // - And not a key in REGEXP_KEYDOWN => not a dropdown command
  3332. // If input/textarea:
  3333. // - If space key => not a dropdown command
  3334. // - If key is other than escape
  3335. // - If key is not up or down => not a dropdown command
  3336. // - If trigger inside the menu => not a dropdown command
  3337. if (/input|textarea/i.test(event.target.tagName) ? event.key === SPACE_KEY || event.key !== ESCAPE_KEY$2 && (event.key !== ARROW_DOWN_KEY && event.key !== ARROW_UP_KEY || event.target.closest(SELECTOR_MENU)) : !REGEXP_KEYDOWN.test(event.key)) {
  3338. return;
  3339. }
  3340. const isActive = this.classList.contains(CLASS_NAME_SHOW$6);
  3341. if (!isActive && event.key === ESCAPE_KEY$2) {
  3342. return;
  3343. }
  3344. event.preventDefault();
  3345. event.stopPropagation();
  3346. if (isDisabled(this)) {
  3347. return;
  3348. }
  3349. const getToggleButton = this.matches(SELECTOR_DATA_TOGGLE$3) ? this : SelectorEngine.prev(this, SELECTOR_DATA_TOGGLE$3)[0];
  3350. const instance = Dropdown.getOrCreateInstance(getToggleButton);
  3351. if (event.key === ESCAPE_KEY$2) {
  3352. instance.hide();
  3353. return;
  3354. }
  3355. if (event.key === ARROW_UP_KEY || event.key === ARROW_DOWN_KEY) {
  3356. if (!isActive) {
  3357. instance.show();
  3358. }
  3359. instance._selectMenuItem(event);
  3360. return;
  3361. }
  3362. if (!isActive || event.key === SPACE_KEY) {
  3363. Dropdown.clearMenus();
  3364. }
  3365. }
  3366. }
  3367. /**
  3368. * ------------------------------------------------------------------------
  3369. * Data Api implementation
  3370. * ------------------------------------------------------------------------
  3371. */
  3372. EventHandler.on(document, EVENT_KEYDOWN_DATA_API, SELECTOR_DATA_TOGGLE$3, Dropdown.dataApiKeydownHandler);
  3373. EventHandler.on(document, EVENT_KEYDOWN_DATA_API, SELECTOR_MENU, Dropdown.dataApiKeydownHandler);
  3374. EventHandler.on(document, EVENT_CLICK_DATA_API$3, Dropdown.clearMenus);
  3375. EventHandler.on(document, EVENT_KEYUP_DATA_API, Dropdown.clearMenus);
  3376. EventHandler.on(document, EVENT_CLICK_DATA_API$3, SELECTOR_DATA_TOGGLE$3, function (event) {
  3377. event.preventDefault();
  3378. Dropdown.getOrCreateInstance(this).toggle();
  3379. });
  3380. /**
  3381. * ------------------------------------------------------------------------
  3382. * jQuery
  3383. * ------------------------------------------------------------------------
  3384. * add .Dropdown to jQuery only if jQuery is present
  3385. */
  3386. defineJQueryPlugin(Dropdown);
  3387. /**
  3388. * --------------------------------------------------------------------------
  3389. * Bootstrap (v5.1.3): util/scrollBar.js
  3390. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
  3391. * --------------------------------------------------------------------------
  3392. */
  3393. const SELECTOR_FIXED_CONTENT = '.fixed-top, .fixed-bottom, .is-fixed, .sticky-top';
  3394. const SELECTOR_STICKY_CONTENT = '.sticky-top';
  3395. class ScrollBarHelper {
  3396. constructor() {
  3397. this._element = document.body;
  3398. }
  3399. getWidth() {
  3400. // https://developer.mozilla.org/en-US/docs/Web/API/Window/innerWidth#usage_notes
  3401. const documentWidth = document.documentElement.clientWidth;
  3402. return Math.abs(window.innerWidth - documentWidth);
  3403. }
  3404. hide() {
  3405. const width = this.getWidth();
  3406. this._disableOverFlow(); // give padding to element to balance the hidden scrollbar width
  3407. this._setElementAttributes(this._element, 'paddingRight', calculatedValue => calculatedValue + width); // trick: We adjust positive paddingRight and negative marginRight to sticky-top elements to keep showing fullwidth
  3408. this._setElementAttributes(SELECTOR_FIXED_CONTENT, 'paddingRight', calculatedValue => calculatedValue + width);
  3409. this._setElementAttributes(SELECTOR_STICKY_CONTENT, 'marginRight', calculatedValue => calculatedValue - width);
  3410. }
  3411. _disableOverFlow() {
  3412. this._saveInitialAttribute(this._element, 'overflow');
  3413. this._element.style.overflow = 'hidden';
  3414. }
  3415. _setElementAttributes(selector, styleProp, callback) {
  3416. const scrollbarWidth = this.getWidth();
  3417. const manipulationCallBack = element => {
  3418. if (element !== this._element && window.innerWidth > element.clientWidth + scrollbarWidth) {
  3419. return;
  3420. }
  3421. this._saveInitialAttribute(element, styleProp);
  3422. const calculatedValue = window.getComputedStyle(element)[styleProp];
  3423. element.style[styleProp] = `${callback(Number.parseFloat(calculatedValue))}px`;
  3424. };
  3425. this._applyManipulationCallback(selector, manipulationCallBack);
  3426. }
  3427. reset() {
  3428. this._resetElementAttributes(this._element, 'overflow');
  3429. this._resetElementAttributes(this._element, 'paddingRight');
  3430. this._resetElementAttributes(SELECTOR_FIXED_CONTENT, 'paddingRight');
  3431. this._resetElementAttributes(SELECTOR_STICKY_CONTENT, 'marginRight');
  3432. }
  3433. _saveInitialAttribute(element, styleProp) {
  3434. const actualValue = element.style[styleProp];
  3435. if (actualValue) {
  3436. Manipulator.setDataAttribute(element, styleProp, actualValue);
  3437. }
  3438. }
  3439. _resetElementAttributes(selector, styleProp) {
  3440. const manipulationCallBack = element => {
  3441. const value = Manipulator.getDataAttribute(element, styleProp);
  3442. if (typeof value === 'undefined') {
  3443. element.style.removeProperty(styleProp);
  3444. } else {
  3445. Manipulator.removeDataAttribute(element, styleProp);
  3446. element.style[styleProp] = value;
  3447. }
  3448. };
  3449. this._applyManipulationCallback(selector, manipulationCallBack);
  3450. }
  3451. _applyManipulationCallback(selector, callBack) {
  3452. if (isElement$1(selector)) {
  3453. callBack(selector);
  3454. } else {
  3455. SelectorEngine.find(selector, this._element).forEach(callBack);
  3456. }
  3457. }
  3458. isOverflowing() {
  3459. return this.getWidth() > 0;
  3460. }
  3461. }
  3462. /**
  3463. * --------------------------------------------------------------------------
  3464. * Bootstrap (v5.1.3): util/backdrop.js
  3465. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
  3466. * --------------------------------------------------------------------------
  3467. */
  3468. const Default$7 = {
  3469. className: 'modal-backdrop',
  3470. isVisible: true,
  3471. // if false, we use the backdrop helper without adding any element to the dom
  3472. isAnimated: false,
  3473. rootElement: 'body',
  3474. // give the choice to place backdrop under different elements
  3475. clickCallback: null
  3476. };
  3477. const DefaultType$7 = {
  3478. className: 'string',
  3479. isVisible: 'boolean',
  3480. isAnimated: 'boolean',
  3481. rootElement: '(element|string)',
  3482. clickCallback: '(function|null)'
  3483. };
  3484. const NAME$8 = 'backdrop';
  3485. const CLASS_NAME_FADE$4 = 'fade';
  3486. const CLASS_NAME_SHOW$5 = 'show';
  3487. const EVENT_MOUSEDOWN = `mousedown.bs.${NAME$8}`;
  3488. class Backdrop {
  3489. constructor(config) {
  3490. this._config = this._getConfig(config);
  3491. this._isAppended = false;
  3492. this._element = null;
  3493. }
  3494. show(callback) {
  3495. if (!this._config.isVisible) {
  3496. execute(callback);
  3497. return;
  3498. }
  3499. this._append();
  3500. if (this._config.isAnimated) {
  3501. reflow(this._getElement());
  3502. }
  3503. this._getElement().classList.add(CLASS_NAME_SHOW$5);
  3504. this._emulateAnimation(() => {
  3505. execute(callback);
  3506. });
  3507. }
  3508. hide(callback) {
  3509. if (!this._config.isVisible) {
  3510. execute(callback);
  3511. return;
  3512. }
  3513. this._getElement().classList.remove(CLASS_NAME_SHOW$5);
  3514. this._emulateAnimation(() => {
  3515. this.dispose();
  3516. execute(callback);
  3517. });
  3518. } // Private
  3519. _getElement() {
  3520. if (!this._element) {
  3521. const backdrop = document.createElement('div');
  3522. backdrop.className = this._config.className;
  3523. if (this._config.isAnimated) {
  3524. backdrop.classList.add(CLASS_NAME_FADE$4);
  3525. }
  3526. this._element = backdrop;
  3527. }
  3528. return this._element;
  3529. }
  3530. _getConfig(config) {
  3531. config = { ...Default$7,
  3532. ...(typeof config === 'object' ? config : {})
  3533. }; // use getElement() with the default "body" to get a fresh Element on each instantiation
  3534. config.rootElement = getElement(config.rootElement);
  3535. typeCheckConfig(NAME$8, config, DefaultType$7);
  3536. return config;
  3537. }
  3538. _append() {
  3539. if (this._isAppended) {
  3540. return;
  3541. }
  3542. this._config.rootElement.append(this._getElement());
  3543. EventHandler.on(this._getElement(), EVENT_MOUSEDOWN, () => {
  3544. execute(this._config.clickCallback);
  3545. });
  3546. this._isAppended = true;
  3547. }
  3548. dispose() {
  3549. if (!this._isAppended) {
  3550. return;
  3551. }
  3552. EventHandler.off(this._element, EVENT_MOUSEDOWN);
  3553. this._element.remove();
  3554. this._isAppended = false;
  3555. }
  3556. _emulateAnimation(callback) {
  3557. executeAfterTransition(callback, this._getElement(), this._config.isAnimated);
  3558. }
  3559. }
  3560. /**
  3561. * --------------------------------------------------------------------------
  3562. * Bootstrap (v5.1.3): util/focustrap.js
  3563. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
  3564. * --------------------------------------------------------------------------
  3565. */
  3566. const Default$6 = {
  3567. trapElement: null,
  3568. // The element to trap focus inside of
  3569. autofocus: true
  3570. };
  3571. const DefaultType$6 = {
  3572. trapElement: 'element',
  3573. autofocus: 'boolean'
  3574. };
  3575. const NAME$7 = 'focustrap';
  3576. const DATA_KEY$7 = 'bs.focustrap';
  3577. const EVENT_KEY$7 = `.${DATA_KEY$7}`;
  3578. const EVENT_FOCUSIN$1 = `focusin${EVENT_KEY$7}`;
  3579. const EVENT_KEYDOWN_TAB = `keydown.tab${EVENT_KEY$7}`;
  3580. const TAB_KEY = 'Tab';
  3581. const TAB_NAV_FORWARD = 'forward';
  3582. const TAB_NAV_BACKWARD = 'backward';
  3583. class FocusTrap {
  3584. constructor(config) {
  3585. this._config = this._getConfig(config);
  3586. this._isActive = false;
  3587. this._lastTabNavDirection = null;
  3588. }
  3589. activate() {
  3590. const {
  3591. trapElement,
  3592. autofocus
  3593. } = this._config;
  3594. if (this._isActive) {
  3595. return;
  3596. }
  3597. if (autofocus) {
  3598. trapElement.focus();
  3599. }
  3600. EventHandler.off(document, EVENT_KEY$7); // guard against infinite focus loop
  3601. EventHandler.on(document, EVENT_FOCUSIN$1, event => this._handleFocusin(event));
  3602. EventHandler.on(document, EVENT_KEYDOWN_TAB, event => this._handleKeydown(event));
  3603. this._isActive = true;
  3604. }
  3605. deactivate() {
  3606. if (!this._isActive) {
  3607. return;
  3608. }
  3609. this._isActive = false;
  3610. EventHandler.off(document, EVENT_KEY$7);
  3611. } // Private
  3612. _handleFocusin(event) {
  3613. const {
  3614. target
  3615. } = event;
  3616. const {
  3617. trapElement
  3618. } = this._config;
  3619. if (target === document || target === trapElement || trapElement.contains(target)) {
  3620. return;
  3621. }
  3622. const elements = SelectorEngine.focusableChildren(trapElement);
  3623. if (elements.length === 0) {
  3624. trapElement.focus();
  3625. } else if (this._lastTabNavDirection === TAB_NAV_BACKWARD) {
  3626. elements[elements.length - 1].focus();
  3627. } else {
  3628. elements[0].focus();
  3629. }
  3630. }
  3631. _handleKeydown(event) {
  3632. if (event.key !== TAB_KEY) {
  3633. return;
  3634. }
  3635. this._lastTabNavDirection = event.shiftKey ? TAB_NAV_BACKWARD : TAB_NAV_FORWARD;
  3636. }
  3637. _getConfig(config) {
  3638. config = { ...Default$6,
  3639. ...(typeof config === 'object' ? config : {})
  3640. };
  3641. typeCheckConfig(NAME$7, config, DefaultType$6);
  3642. return config;
  3643. }
  3644. }
  3645. /**
  3646. * --------------------------------------------------------------------------
  3647. * Bootstrap (v5.1.3): modal.js
  3648. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
  3649. * --------------------------------------------------------------------------
  3650. */
  3651. /**
  3652. * ------------------------------------------------------------------------
  3653. * Constants
  3654. * ------------------------------------------------------------------------
  3655. */
  3656. const NAME$6 = 'modal';
  3657. const DATA_KEY$6 = 'bs.modal';
  3658. const EVENT_KEY$6 = `.${DATA_KEY$6}`;
  3659. const DATA_API_KEY$3 = '.data-api';
  3660. const ESCAPE_KEY$1 = 'Escape';
  3661. const Default$5 = {
  3662. backdrop: true,
  3663. keyboard: true,
  3664. focus: true
  3665. };
  3666. const DefaultType$5 = {
  3667. backdrop: '(boolean|string)',
  3668. keyboard: 'boolean',
  3669. focus: 'boolean'
  3670. };
  3671. const EVENT_HIDE$3 = `hide${EVENT_KEY$6}`;
  3672. const EVENT_HIDE_PREVENTED = `hidePrevented${EVENT_KEY$6}`;
  3673. const EVENT_HIDDEN$3 = `hidden${EVENT_KEY$6}`;
  3674. const EVENT_SHOW$3 = `show${EVENT_KEY$6}`;
  3675. const EVENT_SHOWN$3 = `shown${EVENT_KEY$6}`;
  3676. const EVENT_RESIZE = `resize${EVENT_KEY$6}`;
  3677. const EVENT_CLICK_DISMISS = `click.dismiss${EVENT_KEY$6}`;
  3678. const EVENT_KEYDOWN_DISMISS$1 = `keydown.dismiss${EVENT_KEY$6}`;
  3679. const EVENT_MOUSEUP_DISMISS = `mouseup.dismiss${EVENT_KEY$6}`;
  3680. const EVENT_MOUSEDOWN_DISMISS = `mousedown.dismiss${EVENT_KEY$6}`;
  3681. const EVENT_CLICK_DATA_API$2 = `click${EVENT_KEY$6}${DATA_API_KEY$3}`;
  3682. const CLASS_NAME_OPEN = 'modal-open';
  3683. const CLASS_NAME_FADE$3 = 'fade';
  3684. const CLASS_NAME_SHOW$4 = 'show';
  3685. const CLASS_NAME_STATIC = 'modal-static';
  3686. const OPEN_SELECTOR$1 = '.modal.show';
  3687. const SELECTOR_DIALOG = '.modal-dialog';
  3688. const SELECTOR_MODAL_BODY = '.modal-body';
  3689. const SELECTOR_DATA_TOGGLE$2 = '[data-bs-toggle="modal"]';
  3690. /**
  3691. * ------------------------------------------------------------------------
  3692. * Class Definition
  3693. * ------------------------------------------------------------------------
  3694. */
  3695. class Modal extends BaseComponent {
  3696. constructor(element, config) {
  3697. super(element);
  3698. this._config = this._getConfig(config);
  3699. this._dialog = SelectorEngine.findOne(SELECTOR_DIALOG, this._element);
  3700. this._backdrop = this._initializeBackDrop();
  3701. this._focustrap = this._initializeFocusTrap();
  3702. this._isShown = false;
  3703. this._ignoreBackdropClick = false;
  3704. this._isTransitioning = false;
  3705. this._scrollBar = new ScrollBarHelper();
  3706. } // Getters
  3707. static get Default() {
  3708. return Default$5;
  3709. }
  3710. static get NAME() {
  3711. return NAME$6;
  3712. } // Public
  3713. toggle(relatedTarget) {
  3714. return this._isShown ? this.hide() : this.show(relatedTarget);
  3715. }
  3716. show(relatedTarget) {
  3717. if (this._isShown || this._isTransitioning) {
  3718. return;
  3719. }
  3720. const showEvent = EventHandler.trigger(this._element, EVENT_SHOW$3, {
  3721. relatedTarget
  3722. });
  3723. if (showEvent.defaultPrevented) {
  3724. return;
  3725. }
  3726. this._isShown = true;
  3727. if (this._isAnimated()) {
  3728. this._isTransitioning = true;
  3729. }
  3730. this._scrollBar.hide();
  3731. document.body.classList.add(CLASS_NAME_OPEN);
  3732. this._adjustDialog();
  3733. this._setEscapeEvent();
  3734. this._setResizeEvent();
  3735. EventHandler.on(this._dialog, EVENT_MOUSEDOWN_DISMISS, () => {
  3736. EventHandler.one(this._element, EVENT_MOUSEUP_DISMISS, event => {
  3737. if (event.target === this._element) {
  3738. this._ignoreBackdropClick = true;
  3739. }
  3740. });
  3741. });
  3742. this._showBackdrop(() => this._showElement(relatedTarget));
  3743. }
  3744. hide() {
  3745. if (!this._isShown || this._isTransitioning) {
  3746. return;
  3747. }
  3748. const hideEvent = EventHandler.trigger(this._element, EVENT_HIDE$3);
  3749. if (hideEvent.defaultPrevented) {
  3750. return;
  3751. }
  3752. this._isShown = false;
  3753. const isAnimated = this._isAnimated();
  3754. if (isAnimated) {
  3755. this._isTransitioning = true;
  3756. }
  3757. this._setEscapeEvent();
  3758. this._setResizeEvent();
  3759. this._focustrap.deactivate();
  3760. this._element.classList.remove(CLASS_NAME_SHOW$4);
  3761. EventHandler.off(this._element, EVENT_CLICK_DISMISS);
  3762. EventHandler.off(this._dialog, EVENT_MOUSEDOWN_DISMISS);
  3763. this._queueCallback(() => this._hideModal(), this._element, isAnimated);
  3764. }
  3765. dispose() {
  3766. [window, this._dialog].forEach(htmlElement => EventHandler.off(htmlElement, EVENT_KEY$6));
  3767. this._backdrop.dispose();
  3768. this._focustrap.deactivate();
  3769. super.dispose();
  3770. }
  3771. handleUpdate() {
  3772. this._adjustDialog();
  3773. } // Private
  3774. _initializeBackDrop() {
  3775. return new Backdrop({
  3776. isVisible: Boolean(this._config.backdrop),
  3777. // 'static' option will be translated to true, and booleans will keep their value
  3778. isAnimated: this._isAnimated()
  3779. });
  3780. }
  3781. _initializeFocusTrap() {
  3782. return new FocusTrap({
  3783. trapElement: this._element
  3784. });
  3785. }
  3786. _getConfig(config) {
  3787. config = { ...Default$5,
  3788. ...Manipulator.getDataAttributes(this._element),
  3789. ...(typeof config === 'object' ? config : {})
  3790. };
  3791. typeCheckConfig(NAME$6, config, DefaultType$5);
  3792. return config;
  3793. }
  3794. _showElement(relatedTarget) {
  3795. const isAnimated = this._isAnimated();
  3796. const modalBody = SelectorEngine.findOne(SELECTOR_MODAL_BODY, this._dialog);
  3797. if (!this._element.parentNode || this._element.parentNode.nodeType !== Node.ELEMENT_NODE) {
  3798. // Don't move modal's DOM position
  3799. document.body.append(this._element);
  3800. }
  3801. this._element.style.display = 'block';
  3802. this._element.removeAttribute('aria-hidden');
  3803. this._element.setAttribute('aria-modal', true);
  3804. this._element.setAttribute('role', 'dialog');
  3805. this._element.scrollTop = 0;
  3806. if (modalBody) {
  3807. modalBody.scrollTop = 0;
  3808. }
  3809. if (isAnimated) {
  3810. reflow(this._element);
  3811. }
  3812. this._element.classList.add(CLASS_NAME_SHOW$4);
  3813. const transitionComplete = () => {
  3814. if (this._config.focus) {
  3815. this._focustrap.activate();
  3816. }
  3817. this._isTransitioning = false;
  3818. EventHandler.trigger(this._element, EVENT_SHOWN$3, {
  3819. relatedTarget
  3820. });
  3821. };
  3822. this._queueCallback(transitionComplete, this._dialog, isAnimated);
  3823. }
  3824. _setEscapeEvent() {
  3825. if (this._isShown) {
  3826. EventHandler.on(this._element, EVENT_KEYDOWN_DISMISS$1, event => {
  3827. if (this._config.keyboard && event.key === ESCAPE_KEY$1) {
  3828. event.preventDefault();
  3829. this.hide();
  3830. } else if (!this._config.keyboard && event.key === ESCAPE_KEY$1) {
  3831. this._triggerBackdropTransition();
  3832. }
  3833. });
  3834. } else {
  3835. EventHandler.off(this._element, EVENT_KEYDOWN_DISMISS$1);
  3836. }
  3837. }
  3838. _setResizeEvent() {
  3839. if (this._isShown) {
  3840. EventHandler.on(window, EVENT_RESIZE, () => this._adjustDialog());
  3841. } else {
  3842. EventHandler.off(window, EVENT_RESIZE);
  3843. }
  3844. }
  3845. _hideModal() {
  3846. this._element.style.display = 'none';
  3847. this._element.setAttribute('aria-hidden', true);
  3848. this._element.removeAttribute('aria-modal');
  3849. this._element.removeAttribute('role');
  3850. this._isTransitioning = false;
  3851. this._backdrop.hide(() => {
  3852. document.body.classList.remove(CLASS_NAME_OPEN);
  3853. this._resetAdjustments();
  3854. this._scrollBar.reset();
  3855. EventHandler.trigger(this._element, EVENT_HIDDEN$3);
  3856. });
  3857. }
  3858. _showBackdrop(callback) {
  3859. EventHandler.on(this._element, EVENT_CLICK_DISMISS, event => {
  3860. if (this._ignoreBackdropClick) {
  3861. this._ignoreBackdropClick = false;
  3862. return;
  3863. }
  3864. if (event.target !== event.currentTarget) {
  3865. return;
  3866. }
  3867. if (this._config.backdrop === true) {
  3868. this.hide();
  3869. } else if (this._config.backdrop === 'static') {
  3870. this._triggerBackdropTransition();
  3871. }
  3872. });
  3873. this._backdrop.show(callback);
  3874. }
  3875. _isAnimated() {
  3876. return this._element.classList.contains(CLASS_NAME_FADE$3);
  3877. }
  3878. _triggerBackdropTransition() {
  3879. const hideEvent = EventHandler.trigger(this._element, EVENT_HIDE_PREVENTED);
  3880. if (hideEvent.defaultPrevented) {
  3881. return;
  3882. }
  3883. const {
  3884. classList,
  3885. scrollHeight,
  3886. style
  3887. } = this._element;
  3888. const isModalOverflowing = scrollHeight > document.documentElement.clientHeight; // return if the following background transition hasn't yet completed
  3889. if (!isModalOverflowing && style.overflowY === 'hidden' || classList.contains(CLASS_NAME_STATIC)) {
  3890. return;
  3891. }
  3892. if (!isModalOverflowing) {
  3893. style.overflowY = 'hidden';
  3894. }
  3895. classList.add(CLASS_NAME_STATIC);
  3896. this._queueCallback(() => {
  3897. classList.remove(CLASS_NAME_STATIC);
  3898. if (!isModalOverflowing) {
  3899. this._queueCallback(() => {
  3900. style.overflowY = '';
  3901. }, this._dialog);
  3902. }
  3903. }, this._dialog);
  3904. this._element.focus();
  3905. } // ----------------------------------------------------------------------
  3906. // the following methods are used to handle overflowing modals
  3907. // ----------------------------------------------------------------------
  3908. _adjustDialog() {
  3909. const isModalOverflowing = this._element.scrollHeight > document.documentElement.clientHeight;
  3910. const scrollbarWidth = this._scrollBar.getWidth();
  3911. const isBodyOverflowing = scrollbarWidth > 0;
  3912. if (!isBodyOverflowing && isModalOverflowing && !isRTL() || isBodyOverflowing && !isModalOverflowing && isRTL()) {
  3913. this._element.style.paddingLeft = `${scrollbarWidth}px`;
  3914. }
  3915. if (isBodyOverflowing && !isModalOverflowing && !isRTL() || !isBodyOverflowing && isModalOverflowing && isRTL()) {
  3916. this._element.style.paddingRight = `${scrollbarWidth}px`;
  3917. }
  3918. }
  3919. _resetAdjustments() {
  3920. this._element.style.paddingLeft = '';
  3921. this._element.style.paddingRight = '';
  3922. } // Static
  3923. static jQueryInterface(config, relatedTarget) {
  3924. return this.each(function () {
  3925. const data = Modal.getOrCreateInstance(this, config);
  3926. if (typeof config !== 'string') {
  3927. return;
  3928. }
  3929. if (typeof data[config] === 'undefined') {
  3930. throw new TypeError(`No method named "${config}"`);
  3931. }
  3932. data[config](relatedTarget);
  3933. });
  3934. }
  3935. }
  3936. /**
  3937. * ------------------------------------------------------------------------
  3938. * Data Api implementation
  3939. * ------------------------------------------------------------------------
  3940. */
  3941. EventHandler.on(document, EVENT_CLICK_DATA_API$2, SELECTOR_DATA_TOGGLE$2, function (event) {
  3942. const target = getElementFromSelector(this);
  3943. if (['A', 'AREA'].includes(this.tagName)) {
  3944. event.preventDefault();
  3945. }
  3946. EventHandler.one(target, EVENT_SHOW$3, showEvent => {
  3947. if (showEvent.defaultPrevented) {
  3948. // only register focus restorer if modal will actually get shown
  3949. return;
  3950. }
  3951. EventHandler.one(target, EVENT_HIDDEN$3, () => {
  3952. if (isVisible(this)) {
  3953. this.focus();
  3954. }
  3955. });
  3956. }); // avoid conflict when clicking moddal toggler while another one is open
  3957. const allReadyOpen = SelectorEngine.findOne(OPEN_SELECTOR$1);
  3958. if (allReadyOpen) {
  3959. Modal.getInstance(allReadyOpen).hide();
  3960. }
  3961. const data = Modal.getOrCreateInstance(target);
  3962. data.toggle(this);
  3963. });
  3964. enableDismissTrigger(Modal);
  3965. /**
  3966. * ------------------------------------------------------------------------
  3967. * jQuery
  3968. * ------------------------------------------------------------------------
  3969. * add .Modal to jQuery only if jQuery is present
  3970. */
  3971. defineJQueryPlugin(Modal);
  3972. /**
  3973. * --------------------------------------------------------------------------
  3974. * Bootstrap (v5.1.3): offcanvas.js
  3975. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
  3976. * --------------------------------------------------------------------------
  3977. */
  3978. /**
  3979. * ------------------------------------------------------------------------
  3980. * Constants
  3981. * ------------------------------------------------------------------------
  3982. */
  3983. const NAME$5 = 'offcanvas';
  3984. const DATA_KEY$5 = 'bs.offcanvas';
  3985. const EVENT_KEY$5 = `.${DATA_KEY$5}`;
  3986. const DATA_API_KEY$2 = '.data-api';
  3987. const EVENT_LOAD_DATA_API$1 = `load${EVENT_KEY$5}${DATA_API_KEY$2}`;
  3988. const ESCAPE_KEY = 'Escape';
  3989. const Default$4 = {
  3990. backdrop: true,
  3991. keyboard: true,
  3992. scroll: false
  3993. };
  3994. const DefaultType$4 = {
  3995. backdrop: 'boolean',
  3996. keyboard: 'boolean',
  3997. scroll: 'boolean'
  3998. };
  3999. const CLASS_NAME_SHOW$3 = 'show';
  4000. const CLASS_NAME_BACKDROP = 'offcanvas-backdrop';
  4001. const OPEN_SELECTOR = '.offcanvas.show';
  4002. const EVENT_SHOW$2 = `show${EVENT_KEY$5}`;
  4003. const EVENT_SHOWN$2 = `shown${EVENT_KEY$5}`;
  4004. const EVENT_HIDE$2 = `hide${EVENT_KEY$5}`;
  4005. const EVENT_HIDDEN$2 = `hidden${EVENT_KEY$5}`;
  4006. const EVENT_CLICK_DATA_API$1 = `click${EVENT_KEY$5}${DATA_API_KEY$2}`;
  4007. const EVENT_KEYDOWN_DISMISS = `keydown.dismiss${EVENT_KEY$5}`;
  4008. const SELECTOR_DATA_TOGGLE$1 = '[data-bs-toggle="offcanvas"]';
  4009. /**
  4010. * ------------------------------------------------------------------------
  4011. * Class Definition
  4012. * ------------------------------------------------------------------------
  4013. */
  4014. class Offcanvas extends BaseComponent {
  4015. constructor(element, config) {
  4016. super(element);
  4017. this._config = this._getConfig(config);
  4018. this._isShown = false;
  4019. this._backdrop = this._initializeBackDrop();
  4020. this._focustrap = this._initializeFocusTrap();
  4021. this._addEventListeners();
  4022. } // Getters
  4023. static get NAME() {
  4024. return NAME$5;
  4025. }
  4026. static get Default() {
  4027. return Default$4;
  4028. } // Public
  4029. toggle(relatedTarget) {
  4030. return this._isShown ? this.hide() : this.show(relatedTarget);
  4031. }
  4032. show(relatedTarget) {
  4033. if (this._isShown) {
  4034. return;
  4035. }
  4036. const showEvent = EventHandler.trigger(this._element, EVENT_SHOW$2, {
  4037. relatedTarget
  4038. });
  4039. if (showEvent.defaultPrevented) {
  4040. return;
  4041. }
  4042. this._isShown = true;
  4043. this._element.style.visibility = 'visible';
  4044. this._backdrop.show();
  4045. if (!this._config.scroll) {
  4046. new ScrollBarHelper().hide();
  4047. }
  4048. this._element.removeAttribute('aria-hidden');
  4049. this._element.setAttribute('aria-modal', true);
  4050. this._element.setAttribute('role', 'dialog');
  4051. this._element.classList.add(CLASS_NAME_SHOW$3);
  4052. const completeCallBack = () => {
  4053. if (!this._config.scroll) {
  4054. this._focustrap.activate();
  4055. }
  4056. EventHandler.trigger(this._element, EVENT_SHOWN$2, {
  4057. relatedTarget
  4058. });
  4059. };
  4060. this._queueCallback(completeCallBack, this._element, true);
  4061. }
  4062. hide() {
  4063. if (!this._isShown) {
  4064. return;
  4065. }
  4066. const hideEvent = EventHandler.trigger(this._element, EVENT_HIDE$2);
  4067. if (hideEvent.defaultPrevented) {
  4068. return;
  4069. }
  4070. this._focustrap.deactivate();
  4071. this._element.blur();
  4072. this._isShown = false;
  4073. this._element.classList.remove(CLASS_NAME_SHOW$3);
  4074. this._backdrop.hide();
  4075. const completeCallback = () => {
  4076. this._element.setAttribute('aria-hidden', true);
  4077. this._element.removeAttribute('aria-modal');
  4078. this._element.removeAttribute('role');
  4079. this._element.style.visibility = 'hidden';
  4080. if (!this._config.scroll) {
  4081. new ScrollBarHelper().reset();
  4082. }
  4083. EventHandler.trigger(this._element, EVENT_HIDDEN$2);
  4084. };
  4085. this._queueCallback(completeCallback, this._element, true);
  4086. }
  4087. dispose() {
  4088. this._backdrop.dispose();
  4089. this._focustrap.deactivate();
  4090. super.dispose();
  4091. } // Private
  4092. _getConfig(config) {
  4093. config = { ...Default$4,
  4094. ...Manipulator.getDataAttributes(this._element),
  4095. ...(typeof config === 'object' ? config : {})
  4096. };
  4097. typeCheckConfig(NAME$5, config, DefaultType$4);
  4098. return config;
  4099. }
  4100. _initializeBackDrop() {
  4101. return new Backdrop({
  4102. className: CLASS_NAME_BACKDROP,
  4103. isVisible: this._config.backdrop,
  4104. isAnimated: true,
  4105. rootElement: this._element.parentNode,
  4106. clickCallback: () => this.hide()
  4107. });
  4108. }
  4109. _initializeFocusTrap() {
  4110. return new FocusTrap({
  4111. trapElement: this._element
  4112. });
  4113. }
  4114. _addEventListeners() {
  4115. EventHandler.on(this._element, EVENT_KEYDOWN_DISMISS, event => {
  4116. if (this._config.keyboard && event.key === ESCAPE_KEY) {
  4117. this.hide();
  4118. }
  4119. });
  4120. } // Static
  4121. static jQueryInterface(config) {
  4122. return this.each(function () {
  4123. const data = Offcanvas.getOrCreateInstance(this, config);
  4124. if (typeof config !== 'string') {
  4125. return;
  4126. }
  4127. if (data[config] === undefined || config.startsWith('_') || config === 'constructor') {
  4128. throw new TypeError(`No method named "${config}"`);
  4129. }
  4130. data[config](this);
  4131. });
  4132. }
  4133. }
  4134. /**
  4135. * ------------------------------------------------------------------------
  4136. * Data Api implementation
  4137. * ------------------------------------------------------------------------
  4138. */
  4139. EventHandler.on(document, EVENT_CLICK_DATA_API$1, SELECTOR_DATA_TOGGLE$1, function (event) {
  4140. const target = getElementFromSelector(this);
  4141. if (['A', 'AREA'].includes(this.tagName)) {
  4142. event.preventDefault();
  4143. }
  4144. if (isDisabled(this)) {
  4145. return;
  4146. }
  4147. EventHandler.one(target, EVENT_HIDDEN$2, () => {
  4148. // focus on trigger when it is closed
  4149. if (isVisible(this)) {
  4150. this.focus();
  4151. }
  4152. }); // avoid conflict when clicking a toggler of an offcanvas, while another is open
  4153. const allReadyOpen = SelectorEngine.findOne(OPEN_SELECTOR);
  4154. if (allReadyOpen && allReadyOpen !== target) {
  4155. Offcanvas.getInstance(allReadyOpen).hide();
  4156. }
  4157. const data = Offcanvas.getOrCreateInstance(target);
  4158. data.toggle(this);
  4159. });
  4160. EventHandler.on(window, EVENT_LOAD_DATA_API$1, () => SelectorEngine.find(OPEN_SELECTOR).forEach(el => Offcanvas.getOrCreateInstance(el).show()));
  4161. enableDismissTrigger(Offcanvas);
  4162. /**
  4163. * ------------------------------------------------------------------------
  4164. * jQuery
  4165. * ------------------------------------------------------------------------
  4166. */
  4167. defineJQueryPlugin(Offcanvas);
  4168. /**
  4169. * --------------------------------------------------------------------------
  4170. * Bootstrap (v5.1.3): util/sanitizer.js
  4171. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
  4172. * --------------------------------------------------------------------------
  4173. */
  4174. const uriAttributes = new Set(['background', 'cite', 'href', 'itemtype', 'longdesc', 'poster', 'src', 'xlink:href']);
  4175. const ARIA_ATTRIBUTE_PATTERN = /^aria-[\w-]*$/i;
  4176. /**
  4177. * A pattern that recognizes a commonly useful subset of URLs that are safe.
  4178. *
  4179. * Shoutout to Angular https://github.com/angular/angular/blob/12.2.x/packages/core/src/sanitization/url_sanitizer.ts
  4180. */
  4181. const SAFE_URL_PATTERN = /^(?:(?:https?|mailto|ftp|tel|file|sms):|[^#&/:?]*(?:[#/?]|$))/i;
  4182. /**
  4183. * A pattern that matches safe data URLs. Only matches image, video and audio types.
  4184. *
  4185. * Shoutout to Angular https://github.com/angular/angular/blob/12.2.x/packages/core/src/sanitization/url_sanitizer.ts
  4186. */
  4187. 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;
  4188. const allowedAttribute = (attribute, allowedAttributeList) => {
  4189. const attributeName = attribute.nodeName.toLowerCase();
  4190. if (allowedAttributeList.includes(attributeName)) {
  4191. if (uriAttributes.has(attributeName)) {
  4192. return Boolean(SAFE_URL_PATTERN.test(attribute.nodeValue) || DATA_URL_PATTERN.test(attribute.nodeValue));
  4193. }
  4194. return true;
  4195. }
  4196. const regExp = allowedAttributeList.filter(attributeRegex => attributeRegex instanceof RegExp); // Check if a regular expression validates the attribute.
  4197. for (let i = 0, len = regExp.length; i < len; i++) {
  4198. if (regExp[i].test(attributeName)) {
  4199. return true;
  4200. }
  4201. }
  4202. return false;
  4203. };
  4204. const DefaultAllowlist = {
  4205. // Global attributes allowed on any supplied element below.
  4206. '*': ['class', 'dir', 'id', 'lang', 'role', ARIA_ATTRIBUTE_PATTERN],
  4207. a: ['target', 'href', 'title', 'rel'],
  4208. area: [],
  4209. b: [],
  4210. br: [],
  4211. col: [],
  4212. code: [],
  4213. div: [],
  4214. em: [],
  4215. hr: [],
  4216. h1: [],
  4217. h2: [],
  4218. h3: [],
  4219. h4: [],
  4220. h5: [],
  4221. h6: [],
  4222. i: [],
  4223. img: ['src', 'srcset', 'alt', 'title', 'width', 'height'],
  4224. li: [],
  4225. ol: [],
  4226. p: [],
  4227. pre: [],
  4228. s: [],
  4229. small: [],
  4230. span: [],
  4231. sub: [],
  4232. sup: [],
  4233. strong: [],
  4234. u: [],
  4235. ul: []
  4236. };
  4237. function sanitizeHtml(unsafeHtml, allowList, sanitizeFn) {
  4238. if (!unsafeHtml.length) {
  4239. return unsafeHtml;
  4240. }
  4241. if (sanitizeFn && typeof sanitizeFn === 'function') {
  4242. return sanitizeFn(unsafeHtml);
  4243. }
  4244. const domParser = new window.DOMParser();
  4245. const createdDocument = domParser.parseFromString(unsafeHtml, 'text/html');
  4246. const elements = [].concat(...createdDocument.body.querySelectorAll('*'));
  4247. for (let i = 0, len = elements.length; i < len; i++) {
  4248. const element = elements[i];
  4249. const elementName = element.nodeName.toLowerCase();
  4250. if (!Object.keys(allowList).includes(elementName)) {
  4251. element.remove();
  4252. continue;
  4253. }
  4254. const attributeList = [].concat(...element.attributes);
  4255. const allowedAttributes = [].concat(allowList['*'] || [], allowList[elementName] || []);
  4256. attributeList.forEach(attribute => {
  4257. if (!allowedAttribute(attribute, allowedAttributes)) {
  4258. element.removeAttribute(attribute.nodeName);
  4259. }
  4260. });
  4261. }
  4262. return createdDocument.body.innerHTML;
  4263. }
  4264. /**
  4265. * --------------------------------------------------------------------------
  4266. * Bootstrap (v5.1.3): tooltip.js
  4267. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
  4268. * --------------------------------------------------------------------------
  4269. */
  4270. /**
  4271. * ------------------------------------------------------------------------
  4272. * Constants
  4273. * ------------------------------------------------------------------------
  4274. */
  4275. const NAME$4 = 'tooltip';
  4276. const DATA_KEY$4 = 'bs.tooltip';
  4277. const EVENT_KEY$4 = `.${DATA_KEY$4}`;
  4278. const CLASS_PREFIX$1 = 'bs-tooltip';
  4279. const DISALLOWED_ATTRIBUTES = new Set(['sanitize', 'allowList', 'sanitizeFn']);
  4280. const DefaultType$3 = {
  4281. animation: 'boolean',
  4282. template: 'string',
  4283. title: '(string|element|function)',
  4284. trigger: 'string',
  4285. delay: '(number|object)',
  4286. html: 'boolean',
  4287. selector: '(string|boolean)',
  4288. placement: '(string|function)',
  4289. offset: '(array|string|function)',
  4290. container: '(string|element|boolean)',
  4291. fallbackPlacements: 'array',
  4292. boundary: '(string|element)',
  4293. customClass: '(string|function)',
  4294. sanitize: 'boolean',
  4295. sanitizeFn: '(null|function)',
  4296. allowList: 'object',
  4297. popperConfig: '(null|object|function)'
  4298. };
  4299. const AttachmentMap = {
  4300. AUTO: 'auto',
  4301. TOP: 'top',
  4302. RIGHT: isRTL() ? 'left' : 'right',
  4303. BOTTOM: 'bottom',
  4304. LEFT: isRTL() ? 'right' : 'left'
  4305. };
  4306. const Default$3 = {
  4307. animation: true,
  4308. template: '<div class="tooltip" role="tooltip">' + '<div class="tooltip-arrow"></div>' + '<div class="tooltip-inner"></div>' + '</div>',
  4309. trigger: 'hover focus',
  4310. title: '',
  4311. delay: 0,
  4312. html: false,
  4313. selector: false,
  4314. placement: 'top',
  4315. offset: [0, 0],
  4316. container: false,
  4317. fallbackPlacements: ['top', 'right', 'bottom', 'left'],
  4318. boundary: 'clippingParents',
  4319. customClass: '',
  4320. sanitize: true,
  4321. sanitizeFn: null,
  4322. allowList: DefaultAllowlist,
  4323. popperConfig: null
  4324. };
  4325. const Event$2 = {
  4326. HIDE: `hide${EVENT_KEY$4}`,
  4327. HIDDEN: `hidden${EVENT_KEY$4}`,
  4328. SHOW: `show${EVENT_KEY$4}`,
  4329. SHOWN: `shown${EVENT_KEY$4}`,
  4330. INSERTED: `inserted${EVENT_KEY$4}`,
  4331. CLICK: `click${EVENT_KEY$4}`,
  4332. FOCUSIN: `focusin${EVENT_KEY$4}`,
  4333. FOCUSOUT: `focusout${EVENT_KEY$4}`,
  4334. MOUSEENTER: `mouseenter${EVENT_KEY$4}`,
  4335. MOUSELEAVE: `mouseleave${EVENT_KEY$4}`
  4336. };
  4337. const CLASS_NAME_FADE$2 = 'fade';
  4338. const CLASS_NAME_MODAL = 'modal';
  4339. const CLASS_NAME_SHOW$2 = 'show';
  4340. const HOVER_STATE_SHOW = 'show';
  4341. const HOVER_STATE_OUT = 'out';
  4342. const SELECTOR_TOOLTIP_INNER = '.tooltip-inner';
  4343. const SELECTOR_MODAL = `.${CLASS_NAME_MODAL}`;
  4344. const EVENT_MODAL_HIDE = 'hide.bs.modal';
  4345. const TRIGGER_HOVER = 'hover';
  4346. const TRIGGER_FOCUS = 'focus';
  4347. const TRIGGER_CLICK = 'click';
  4348. const TRIGGER_MANUAL = 'manual';
  4349. /**
  4350. * ------------------------------------------------------------------------
  4351. * Class Definition
  4352. * ------------------------------------------------------------------------
  4353. */
  4354. class Tooltip extends BaseComponent {
  4355. constructor(element, config) {
  4356. if (typeof Popper === 'undefined') {
  4357. throw new TypeError('Bootstrap\'s tooltips require Popper (https://popper.js.org)');
  4358. }
  4359. super(element); // private
  4360. this._isEnabled = true;
  4361. this._timeout = 0;
  4362. this._hoverState = '';
  4363. this._activeTrigger = {};
  4364. this._popper = null; // Protected
  4365. this._config = this._getConfig(config);
  4366. this.tip = null;
  4367. this._setListeners();
  4368. } // Getters
  4369. static get Default() {
  4370. return Default$3;
  4371. }
  4372. static get NAME() {
  4373. return NAME$4;
  4374. }
  4375. static get Event() {
  4376. return Event$2;
  4377. }
  4378. static get DefaultType() {
  4379. return DefaultType$3;
  4380. } // Public
  4381. enable() {
  4382. this._isEnabled = true;
  4383. }
  4384. disable() {
  4385. this._isEnabled = false;
  4386. }
  4387. toggleEnabled() {
  4388. this._isEnabled = !this._isEnabled;
  4389. }
  4390. toggle(event) {
  4391. if (!this._isEnabled) {
  4392. return;
  4393. }
  4394. if (event) {
  4395. const context = this._initializeOnDelegatedTarget(event);
  4396. context._activeTrigger.click = !context._activeTrigger.click;
  4397. if (context._isWithActiveTrigger()) {
  4398. context._enter(null, context);
  4399. } else {
  4400. context._leave(null, context);
  4401. }
  4402. } else {
  4403. if (this.getTipElement().classList.contains(CLASS_NAME_SHOW$2)) {
  4404. this._leave(null, this);
  4405. return;
  4406. }
  4407. this._enter(null, this);
  4408. }
  4409. }
  4410. dispose() {
  4411. clearTimeout(this._timeout);
  4412. EventHandler.off(this._element.closest(SELECTOR_MODAL), EVENT_MODAL_HIDE, this._hideModalHandler);
  4413. if (this.tip) {
  4414. this.tip.remove();
  4415. }
  4416. this._disposePopper();
  4417. super.dispose();
  4418. }
  4419. show() {
  4420. if (this._element.style.display === 'none') {
  4421. throw new Error('Please use show on visible elements');
  4422. }
  4423. if (!(this.isWithContent() && this._isEnabled)) {
  4424. return;
  4425. }
  4426. const showEvent = EventHandler.trigger(this._element, this.constructor.Event.SHOW);
  4427. const shadowRoot = findShadowRoot(this._element);
  4428. const isInTheDom = shadowRoot === null ? this._element.ownerDocument.documentElement.contains(this._element) : shadowRoot.contains(this._element);
  4429. if (showEvent.defaultPrevented || !isInTheDom) {
  4430. return;
  4431. } // A trick to recreate a tooltip in case a new title is given by using the NOT documented `data-bs-original-title`
  4432. // This will be removed later in favor of a `setContent` method
  4433. if (this.constructor.NAME === 'tooltip' && this.tip && this.getTitle() !== this.tip.querySelector(SELECTOR_TOOLTIP_INNER).innerHTML) {
  4434. this._disposePopper();
  4435. this.tip.remove();
  4436. this.tip = null;
  4437. }
  4438. const tip = this.getTipElement();
  4439. const tipId = getUID(this.constructor.NAME);
  4440. tip.setAttribute('id', tipId);
  4441. this._element.setAttribute('aria-describedby', tipId);
  4442. if (this._config.animation) {
  4443. tip.classList.add(CLASS_NAME_FADE$2);
  4444. }
  4445. const placement = typeof this._config.placement === 'function' ? this._config.placement.call(this, tip, this._element) : this._config.placement;
  4446. const attachment = this._getAttachment(placement);
  4447. this._addAttachmentClass(attachment);
  4448. const {
  4449. container
  4450. } = this._config;
  4451. Data.set(tip, this.constructor.DATA_KEY, this);
  4452. if (!this._element.ownerDocument.documentElement.contains(this.tip)) {
  4453. container.append(tip);
  4454. EventHandler.trigger(this._element, this.constructor.Event.INSERTED);
  4455. }
  4456. if (this._popper) {
  4457. this._popper.update();
  4458. } else {
  4459. this._popper = createPopper(this._element, tip, this._getPopperConfig(attachment));
  4460. }
  4461. tip.classList.add(CLASS_NAME_SHOW$2);
  4462. const customClass = this._resolvePossibleFunction(this._config.customClass);
  4463. if (customClass) {
  4464. tip.classList.add(...customClass.split(' '));
  4465. } // If this is a touch-enabled device we add extra
  4466. // empty mouseover listeners to the body's immediate children;
  4467. // only needed because of broken event delegation on iOS
  4468. // https://www.quirksmode.org/blog/archives/2014/02/mouse_event_bub.html
  4469. if ('ontouchstart' in document.documentElement) {
  4470. [].concat(...document.body.children).forEach(element => {
  4471. EventHandler.on(element, 'mouseover', noop);
  4472. });
  4473. }
  4474. const complete = () => {
  4475. const prevHoverState = this._hoverState;
  4476. this._hoverState = null;
  4477. EventHandler.trigger(this._element, this.constructor.Event.SHOWN);
  4478. if (prevHoverState === HOVER_STATE_OUT) {
  4479. this._leave(null, this);
  4480. }
  4481. };
  4482. const isAnimated = this.tip.classList.contains(CLASS_NAME_FADE$2);
  4483. this._queueCallback(complete, this.tip, isAnimated);
  4484. }
  4485. hide() {
  4486. if (!this._popper) {
  4487. return;
  4488. }
  4489. const tip = this.getTipElement();
  4490. const complete = () => {
  4491. if (this._isWithActiveTrigger()) {
  4492. return;
  4493. }
  4494. if (this._hoverState !== HOVER_STATE_SHOW) {
  4495. tip.remove();
  4496. }
  4497. this._cleanTipClass();
  4498. this._element.removeAttribute('aria-describedby');
  4499. EventHandler.trigger(this._element, this.constructor.Event.HIDDEN);
  4500. this._disposePopper();
  4501. };
  4502. const hideEvent = EventHandler.trigger(this._element, this.constructor.Event.HIDE);
  4503. if (hideEvent.defaultPrevented) {
  4504. return;
  4505. }
  4506. tip.classList.remove(CLASS_NAME_SHOW$2); // If this is a touch-enabled device we remove the extra
  4507. // empty mouseover listeners we added for iOS support
  4508. if ('ontouchstart' in document.documentElement) {
  4509. [].concat(...document.body.children).forEach(element => EventHandler.off(element, 'mouseover', noop));
  4510. }
  4511. this._activeTrigger[TRIGGER_CLICK] = false;
  4512. this._activeTrigger[TRIGGER_FOCUS] = false;
  4513. this._activeTrigger[TRIGGER_HOVER] = false;
  4514. const isAnimated = this.tip.classList.contains(CLASS_NAME_FADE$2);
  4515. this._queueCallback(complete, this.tip, isAnimated);
  4516. this._hoverState = '';
  4517. }
  4518. update() {
  4519. if (this._popper !== null) {
  4520. this._popper.update();
  4521. }
  4522. } // Protected
  4523. isWithContent() {
  4524. return Boolean(this.getTitle());
  4525. }
  4526. getTipElement() {
  4527. if (this.tip) {
  4528. return this.tip;
  4529. }
  4530. const element = document.createElement('div');
  4531. element.innerHTML = this._config.template;
  4532. const tip = element.children[0];
  4533. this.setContent(tip);
  4534. tip.classList.remove(CLASS_NAME_FADE$2, CLASS_NAME_SHOW$2);
  4535. this.tip = tip;
  4536. return this.tip;
  4537. }
  4538. setContent(tip) {
  4539. this._sanitizeAndSetContent(tip, this.getTitle(), SELECTOR_TOOLTIP_INNER);
  4540. }
  4541. _sanitizeAndSetContent(template, content, selector) {
  4542. const templateElement = SelectorEngine.findOne(selector, template);
  4543. if (!content && templateElement) {
  4544. templateElement.remove();
  4545. return;
  4546. } // we use append for html objects to maintain js events
  4547. this.setElementContent(templateElement, content);
  4548. }
  4549. setElementContent(element, content) {
  4550. if (element === null) {
  4551. return;
  4552. }
  4553. if (isElement$1(content)) {
  4554. content = getElement(content); // content is a DOM node or a jQuery
  4555. if (this._config.html) {
  4556. if (content.parentNode !== element) {
  4557. element.innerHTML = '';
  4558. element.append(content);
  4559. }
  4560. } else {
  4561. element.textContent = content.textContent;
  4562. }
  4563. return;
  4564. }
  4565. if (this._config.html) {
  4566. if (this._config.sanitize) {
  4567. content = sanitizeHtml(content, this._config.allowList, this._config.sanitizeFn);
  4568. }
  4569. element.innerHTML = content;
  4570. } else {
  4571. element.textContent = content;
  4572. }
  4573. }
  4574. getTitle() {
  4575. const title = this._element.getAttribute('data-bs-original-title') || this._config.title;
  4576. return this._resolvePossibleFunction(title);
  4577. }
  4578. updateAttachment(attachment) {
  4579. if (attachment === 'right') {
  4580. return 'end';
  4581. }
  4582. if (attachment === 'left') {
  4583. return 'start';
  4584. }
  4585. return attachment;
  4586. } // Private
  4587. _initializeOnDelegatedTarget(event, context) {
  4588. return context || this.constructor.getOrCreateInstance(event.delegateTarget, this._getDelegateConfig());
  4589. }
  4590. _getOffset() {
  4591. const {
  4592. offset
  4593. } = this._config;
  4594. if (typeof offset === 'string') {
  4595. return offset.split(',').map(val => Number.parseInt(val, 10));
  4596. }
  4597. if (typeof offset === 'function') {
  4598. return popperData => offset(popperData, this._element);
  4599. }
  4600. return offset;
  4601. }
  4602. _resolvePossibleFunction(content) {
  4603. return typeof content === 'function' ? content.call(this._element) : content;
  4604. }
  4605. _getPopperConfig(attachment) {
  4606. const defaultBsPopperConfig = {
  4607. placement: attachment,
  4608. modifiers: [{
  4609. name: 'flip',
  4610. options: {
  4611. fallbackPlacements: this._config.fallbackPlacements
  4612. }
  4613. }, {
  4614. name: 'offset',
  4615. options: {
  4616. offset: this._getOffset()
  4617. }
  4618. }, {
  4619. name: 'preventOverflow',
  4620. options: {
  4621. boundary: this._config.boundary
  4622. }
  4623. }, {
  4624. name: 'arrow',
  4625. options: {
  4626. element: `.${this.constructor.NAME}-arrow`
  4627. }
  4628. }, {
  4629. name: 'onChange',
  4630. enabled: true,
  4631. phase: 'afterWrite',
  4632. fn: data => this._handlePopperPlacementChange(data)
  4633. }],
  4634. onFirstUpdate: data => {
  4635. if (data.options.placement !== data.placement) {
  4636. this._handlePopperPlacementChange(data);
  4637. }
  4638. }
  4639. };
  4640. return { ...defaultBsPopperConfig,
  4641. ...(typeof this._config.popperConfig === 'function' ? this._config.popperConfig(defaultBsPopperConfig) : this._config.popperConfig)
  4642. };
  4643. }
  4644. _addAttachmentClass(attachment) {
  4645. this.getTipElement().classList.add(`${this._getBasicClassPrefix()}-${this.updateAttachment(attachment)}`);
  4646. }
  4647. _getAttachment(placement) {
  4648. return AttachmentMap[placement.toUpperCase()];
  4649. }
  4650. _setListeners() {
  4651. const triggers = this._config.trigger.split(' ');
  4652. triggers.forEach(trigger => {
  4653. if (trigger === 'click') {
  4654. EventHandler.on(this._element, this.constructor.Event.CLICK, this._config.selector, event => this.toggle(event));
  4655. } else if (trigger !== TRIGGER_MANUAL) {
  4656. const eventIn = trigger === TRIGGER_HOVER ? this.constructor.Event.MOUSEENTER : this.constructor.Event.FOCUSIN;
  4657. const eventOut = trigger === TRIGGER_HOVER ? this.constructor.Event.MOUSELEAVE : this.constructor.Event.FOCUSOUT;
  4658. EventHandler.on(this._element, eventIn, this._config.selector, event => this._enter(event));
  4659. EventHandler.on(this._element, eventOut, this._config.selector, event => this._leave(event));
  4660. }
  4661. });
  4662. this._hideModalHandler = () => {
  4663. if (this._element) {
  4664. this.hide();
  4665. }
  4666. };
  4667. EventHandler.on(this._element.closest(SELECTOR_MODAL), EVENT_MODAL_HIDE, this._hideModalHandler);
  4668. if (this._config.selector) {
  4669. this._config = { ...this._config,
  4670. trigger: 'manual',
  4671. selector: ''
  4672. };
  4673. } else {
  4674. this._fixTitle();
  4675. }
  4676. }
  4677. _fixTitle() {
  4678. const title = this._element.getAttribute('title');
  4679. const originalTitleType = typeof this._element.getAttribute('data-bs-original-title');
  4680. if (title || originalTitleType !== 'string') {
  4681. this._element.setAttribute('data-bs-original-title', title || '');
  4682. if (title && !this._element.getAttribute('aria-label') && !this._element.textContent) {
  4683. this._element.setAttribute('aria-label', title);
  4684. }
  4685. this._element.setAttribute('title', '');
  4686. }
  4687. }
  4688. _enter(event, context) {
  4689. context = this._initializeOnDelegatedTarget(event, context);
  4690. if (event) {
  4691. context._activeTrigger[event.type === 'focusin' ? TRIGGER_FOCUS : TRIGGER_HOVER] = true;
  4692. }
  4693. if (context.getTipElement().classList.contains(CLASS_NAME_SHOW$2) || context._hoverState === HOVER_STATE_SHOW) {
  4694. context._hoverState = HOVER_STATE_SHOW;
  4695. return;
  4696. }
  4697. clearTimeout(context._timeout);
  4698. context._hoverState = HOVER_STATE_SHOW;
  4699. if (!context._config.delay || !context._config.delay.show) {
  4700. context.show();
  4701. return;
  4702. }
  4703. context._timeout = setTimeout(() => {
  4704. if (context._hoverState === HOVER_STATE_SHOW) {
  4705. context.show();
  4706. }
  4707. }, context._config.delay.show);
  4708. }
  4709. _leave(event, context) {
  4710. context = this._initializeOnDelegatedTarget(event, context);
  4711. if (event) {
  4712. context._activeTrigger[event.type === 'focusout' ? TRIGGER_FOCUS : TRIGGER_HOVER] = context._element.contains(event.relatedTarget);
  4713. }
  4714. if (context._isWithActiveTrigger()) {
  4715. return;
  4716. }
  4717. clearTimeout(context._timeout);
  4718. context._hoverState = HOVER_STATE_OUT;
  4719. if (!context._config.delay || !context._config.delay.hide) {
  4720. context.hide();
  4721. return;
  4722. }
  4723. context._timeout = setTimeout(() => {
  4724. if (context._hoverState === HOVER_STATE_OUT) {
  4725. context.hide();
  4726. }
  4727. }, context._config.delay.hide);
  4728. }
  4729. _isWithActiveTrigger() {
  4730. for (const trigger in this._activeTrigger) {
  4731. if (this._activeTrigger[trigger]) {
  4732. return true;
  4733. }
  4734. }
  4735. return false;
  4736. }
  4737. _getConfig(config) {
  4738. const dataAttributes = Manipulator.getDataAttributes(this._element);
  4739. Object.keys(dataAttributes).forEach(dataAttr => {
  4740. if (DISALLOWED_ATTRIBUTES.has(dataAttr)) {
  4741. delete dataAttributes[dataAttr];
  4742. }
  4743. });
  4744. config = { ...this.constructor.Default,
  4745. ...dataAttributes,
  4746. ...(typeof config === 'object' && config ? config : {})
  4747. };
  4748. config.container = config.container === false ? document.body : getElement(config.container);
  4749. if (typeof config.delay === 'number') {
  4750. config.delay = {
  4751. show: config.delay,
  4752. hide: config.delay
  4753. };
  4754. }
  4755. if (typeof config.title === 'number') {
  4756. config.title = config.title.toString();
  4757. }
  4758. if (typeof config.content === 'number') {
  4759. config.content = config.content.toString();
  4760. }
  4761. typeCheckConfig(NAME$4, config, this.constructor.DefaultType);
  4762. if (config.sanitize) {
  4763. config.template = sanitizeHtml(config.template, config.allowList, config.sanitizeFn);
  4764. }
  4765. return config;
  4766. }
  4767. _getDelegateConfig() {
  4768. const config = {};
  4769. for (const key in this._config) {
  4770. if (this.constructor.Default[key] !== this._config[key]) {
  4771. config[key] = this._config[key];
  4772. }
  4773. } // In the future can be replaced with:
  4774. // const keysWithDifferentValues = Object.entries(this._config).filter(entry => this.constructor.Default[entry[0]] !== this._config[entry[0]])
  4775. // `Object.fromEntries(keysWithDifferentValues)`
  4776. return config;
  4777. }
  4778. _cleanTipClass() {
  4779. const tip = this.getTipElement();
  4780. const basicClassPrefixRegex = new RegExp(`(^|\\s)${this._getBasicClassPrefix()}\\S+`, 'g');
  4781. const tabClass = tip.getAttribute('class').match(basicClassPrefixRegex);
  4782. if (tabClass !== null && tabClass.length > 0) {
  4783. tabClass.map(token => token.trim()).forEach(tClass => tip.classList.remove(tClass));
  4784. }
  4785. }
  4786. _getBasicClassPrefix() {
  4787. return CLASS_PREFIX$1;
  4788. }
  4789. _handlePopperPlacementChange(popperData) {
  4790. const {
  4791. state
  4792. } = popperData;
  4793. if (!state) {
  4794. return;
  4795. }
  4796. this.tip = state.elements.popper;
  4797. this._cleanTipClass();
  4798. this._addAttachmentClass(this._getAttachment(state.placement));
  4799. }
  4800. _disposePopper() {
  4801. if (this._popper) {
  4802. this._popper.destroy();
  4803. this._popper = null;
  4804. }
  4805. } // Static
  4806. static jQueryInterface(config) {
  4807. return this.each(function () {
  4808. const data = Tooltip.getOrCreateInstance(this, config);
  4809. if (typeof config === 'string') {
  4810. if (typeof data[config] === 'undefined') {
  4811. throw new TypeError(`No method named "${config}"`);
  4812. }
  4813. data[config]();
  4814. }
  4815. });
  4816. }
  4817. }
  4818. /**
  4819. * ------------------------------------------------------------------------
  4820. * jQuery
  4821. * ------------------------------------------------------------------------
  4822. * add .Tooltip to jQuery only if jQuery is present
  4823. */
  4824. defineJQueryPlugin(Tooltip);
  4825. /**
  4826. * --------------------------------------------------------------------------
  4827. * Bootstrap (v5.1.3): popover.js
  4828. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
  4829. * --------------------------------------------------------------------------
  4830. */
  4831. /**
  4832. * ------------------------------------------------------------------------
  4833. * Constants
  4834. * ------------------------------------------------------------------------
  4835. */
  4836. const NAME$3 = 'popover';
  4837. const DATA_KEY$3 = 'bs.popover';
  4838. const EVENT_KEY$3 = `.${DATA_KEY$3}`;
  4839. const CLASS_PREFIX = 'bs-popover';
  4840. const Default$2 = { ...Tooltip.Default,
  4841. placement: 'right',
  4842. offset: [0, 8],
  4843. trigger: 'click',
  4844. content: '',
  4845. template: '<div class="popover" role="tooltip">' + '<div class="popover-arrow"></div>' + '<h3 class="popover-header"></h3>' + '<div class="popover-body"></div>' + '</div>'
  4846. };
  4847. const DefaultType$2 = { ...Tooltip.DefaultType,
  4848. content: '(string|element|function)'
  4849. };
  4850. const Event$1 = {
  4851. HIDE: `hide${EVENT_KEY$3}`,
  4852. HIDDEN: `hidden${EVENT_KEY$3}`,
  4853. SHOW: `show${EVENT_KEY$3}`,
  4854. SHOWN: `shown${EVENT_KEY$3}`,
  4855. INSERTED: `inserted${EVENT_KEY$3}`,
  4856. CLICK: `click${EVENT_KEY$3}`,
  4857. FOCUSIN: `focusin${EVENT_KEY$3}`,
  4858. FOCUSOUT: `focusout${EVENT_KEY$3}`,
  4859. MOUSEENTER: `mouseenter${EVENT_KEY$3}`,
  4860. MOUSELEAVE: `mouseleave${EVENT_KEY$3}`
  4861. };
  4862. const SELECTOR_TITLE = '.popover-header';
  4863. const SELECTOR_CONTENT = '.popover-body';
  4864. /**
  4865. * ------------------------------------------------------------------------
  4866. * Class Definition
  4867. * ------------------------------------------------------------------------
  4868. */
  4869. class Popover extends Tooltip {
  4870. // Getters
  4871. static get Default() {
  4872. return Default$2;
  4873. }
  4874. static get NAME() {
  4875. return NAME$3;
  4876. }
  4877. static get Event() {
  4878. return Event$1;
  4879. }
  4880. static get DefaultType() {
  4881. return DefaultType$2;
  4882. } // Overrides
  4883. isWithContent() {
  4884. return this.getTitle() || this._getContent();
  4885. }
  4886. setContent(tip) {
  4887. this._sanitizeAndSetContent(tip, this.getTitle(), SELECTOR_TITLE);
  4888. this._sanitizeAndSetContent(tip, this._getContent(), SELECTOR_CONTENT);
  4889. } // Private
  4890. _getContent() {
  4891. return this._resolvePossibleFunction(this._config.content);
  4892. }
  4893. _getBasicClassPrefix() {
  4894. return CLASS_PREFIX;
  4895. } // Static
  4896. static jQueryInterface(config) {
  4897. return this.each(function () {
  4898. const data = Popover.getOrCreateInstance(this, config);
  4899. if (typeof config === 'string') {
  4900. if (typeof data[config] === 'undefined') {
  4901. throw new TypeError(`No method named "${config}"`);
  4902. }
  4903. data[config]();
  4904. }
  4905. });
  4906. }
  4907. }
  4908. /**
  4909. * ------------------------------------------------------------------------
  4910. * jQuery
  4911. * ------------------------------------------------------------------------
  4912. * add .Popover to jQuery only if jQuery is present
  4913. */
  4914. defineJQueryPlugin(Popover);
  4915. /**
  4916. * --------------------------------------------------------------------------
  4917. * Bootstrap (v5.1.3): scrollspy.js
  4918. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
  4919. * --------------------------------------------------------------------------
  4920. */
  4921. /**
  4922. * ------------------------------------------------------------------------
  4923. * Constants
  4924. * ------------------------------------------------------------------------
  4925. */
  4926. const NAME$2 = 'scrollspy';
  4927. const DATA_KEY$2 = 'bs.scrollspy';
  4928. const EVENT_KEY$2 = `.${DATA_KEY$2}`;
  4929. const DATA_API_KEY$1 = '.data-api';
  4930. const Default$1 = {
  4931. offset: 10,
  4932. method: 'auto',
  4933. target: ''
  4934. };
  4935. const DefaultType$1 = {
  4936. offset: 'number',
  4937. method: 'string',
  4938. target: '(string|element)'
  4939. };
  4940. const EVENT_ACTIVATE = `activate${EVENT_KEY$2}`;
  4941. const EVENT_SCROLL = `scroll${EVENT_KEY$2}`;
  4942. const EVENT_LOAD_DATA_API = `load${EVENT_KEY$2}${DATA_API_KEY$1}`;
  4943. const CLASS_NAME_DROPDOWN_ITEM = 'dropdown-item';
  4944. const CLASS_NAME_ACTIVE$1 = 'active';
  4945. const SELECTOR_DATA_SPY = '[data-bs-spy="scroll"]';
  4946. const SELECTOR_NAV_LIST_GROUP$1 = '.nav, .list-group';
  4947. const SELECTOR_NAV_LINKS = '.nav-link';
  4948. const SELECTOR_NAV_ITEMS = '.nav-item';
  4949. const SELECTOR_LIST_ITEMS = '.list-group-item';
  4950. const SELECTOR_LINK_ITEMS = `${SELECTOR_NAV_LINKS}, ${SELECTOR_LIST_ITEMS}, .${CLASS_NAME_DROPDOWN_ITEM}`;
  4951. const SELECTOR_DROPDOWN$1 = '.dropdown';
  4952. const SELECTOR_DROPDOWN_TOGGLE$1 = '.dropdown-toggle';
  4953. const METHOD_OFFSET = 'offset';
  4954. const METHOD_POSITION = 'position';
  4955. /**
  4956. * ------------------------------------------------------------------------
  4957. * Class Definition
  4958. * ------------------------------------------------------------------------
  4959. */
  4960. class ScrollSpy extends BaseComponent {
  4961. constructor(element, config) {
  4962. super(element);
  4963. this._scrollElement = this._element.tagName === 'BODY' ? window : this._element;
  4964. this._config = this._getConfig(config);
  4965. this._offsets = [];
  4966. this._targets = [];
  4967. this._activeTarget = null;
  4968. this._scrollHeight = 0;
  4969. EventHandler.on(this._scrollElement, EVENT_SCROLL, () => this._process());
  4970. this.refresh();
  4971. this._process();
  4972. } // Getters
  4973. static get Default() {
  4974. return Default$1;
  4975. }
  4976. static get NAME() {
  4977. return NAME$2;
  4978. } // Public
  4979. refresh() {
  4980. const autoMethod = this._scrollElement === this._scrollElement.window ? METHOD_OFFSET : METHOD_POSITION;
  4981. const offsetMethod = this._config.method === 'auto' ? autoMethod : this._config.method;
  4982. const offsetBase = offsetMethod === METHOD_POSITION ? this._getScrollTop() : 0;
  4983. this._offsets = [];
  4984. this._targets = [];
  4985. this._scrollHeight = this._getScrollHeight();
  4986. const targets = SelectorEngine.find(SELECTOR_LINK_ITEMS, this._config.target);
  4987. targets.map(element => {
  4988. const targetSelector = getSelectorFromElement(element);
  4989. const target = targetSelector ? SelectorEngine.findOne(targetSelector) : null;
  4990. if (target) {
  4991. const targetBCR = target.getBoundingClientRect();
  4992. if (targetBCR.width || targetBCR.height) {
  4993. return [Manipulator[offsetMethod](target).top + offsetBase, targetSelector];
  4994. }
  4995. }
  4996. return null;
  4997. }).filter(item => item).sort((a, b) => a[0] - b[0]).forEach(item => {
  4998. this._offsets.push(item[0]);
  4999. this._targets.push(item[1]);
  5000. });
  5001. }
  5002. dispose() {
  5003. EventHandler.off(this._scrollElement, EVENT_KEY$2);
  5004. super.dispose();
  5005. } // Private
  5006. _getConfig(config) {
  5007. config = { ...Default$1,
  5008. ...Manipulator.getDataAttributes(this._element),
  5009. ...(typeof config === 'object' && config ? config : {})
  5010. };
  5011. config.target = getElement(config.target) || document.documentElement;
  5012. typeCheckConfig(NAME$2, config, DefaultType$1);
  5013. return config;
  5014. }
  5015. _getScrollTop() {
  5016. return this._scrollElement === window ? this._scrollElement.pageYOffset : this._scrollElement.scrollTop;
  5017. }
  5018. _getScrollHeight() {
  5019. return this._scrollElement.scrollHeight || Math.max(document.body.scrollHeight, document.documentElement.scrollHeight);
  5020. }
  5021. _getOffsetHeight() {
  5022. return this._scrollElement === window ? window.innerHeight : this._scrollElement.getBoundingClientRect().height;
  5023. }
  5024. _process() {
  5025. const scrollTop = this._getScrollTop() + this._config.offset;
  5026. const scrollHeight = this._getScrollHeight();
  5027. const maxScroll = this._config.offset + scrollHeight - this._getOffsetHeight();
  5028. if (this._scrollHeight !== scrollHeight) {
  5029. this.refresh();
  5030. }
  5031. if (scrollTop >= maxScroll) {
  5032. const target = this._targets[this._targets.length - 1];
  5033. if (this._activeTarget !== target) {
  5034. this._activate(target);
  5035. }
  5036. return;
  5037. }
  5038. if (this._activeTarget && scrollTop < this._offsets[0] && this._offsets[0] > 0) {
  5039. this._activeTarget = null;
  5040. this._clear();
  5041. return;
  5042. }
  5043. for (let i = this._offsets.length; i--;) {
  5044. const isActiveTarget = this._activeTarget !== this._targets[i] && scrollTop >= this._offsets[i] && (typeof this._offsets[i + 1] === 'undefined' || scrollTop < this._offsets[i + 1]);
  5045. if (isActiveTarget) {
  5046. this._activate(this._targets[i]);
  5047. }
  5048. }
  5049. }
  5050. _activate(target) {
  5051. this._activeTarget = target;
  5052. this._clear();
  5053. const queries = SELECTOR_LINK_ITEMS.split(',').map(selector => `${selector}[data-bs-target="${target}"],${selector}[href="${target}"]`);
  5054. const link = SelectorEngine.findOne(queries.join(','), this._config.target);
  5055. link.classList.add(CLASS_NAME_ACTIVE$1);
  5056. if (link.classList.contains(CLASS_NAME_DROPDOWN_ITEM)) {
  5057. SelectorEngine.findOne(SELECTOR_DROPDOWN_TOGGLE$1, link.closest(SELECTOR_DROPDOWN$1)).classList.add(CLASS_NAME_ACTIVE$1);
  5058. } else {
  5059. SelectorEngine.parents(link, SELECTOR_NAV_LIST_GROUP$1).forEach(listGroup => {
  5060. // Set triggered links parents as active
  5061. // With both <ul> and <nav> markup a parent is the previous sibling of any nav ancestor
  5062. SelectorEngine.prev(listGroup, `${SELECTOR_NAV_LINKS}, ${SELECTOR_LIST_ITEMS}`).forEach(item => item.classList.add(CLASS_NAME_ACTIVE$1)); // Handle special case when .nav-link is inside .nav-item
  5063. SelectorEngine.prev(listGroup, SELECTOR_NAV_ITEMS).forEach(navItem => {
  5064. SelectorEngine.children(navItem, SELECTOR_NAV_LINKS).forEach(item => item.classList.add(CLASS_NAME_ACTIVE$1));
  5065. });
  5066. });
  5067. }
  5068. EventHandler.trigger(this._scrollElement, EVENT_ACTIVATE, {
  5069. relatedTarget: target
  5070. });
  5071. }
  5072. _clear() {
  5073. SelectorEngine.find(SELECTOR_LINK_ITEMS, this._config.target).filter(node => node.classList.contains(CLASS_NAME_ACTIVE$1)).forEach(node => node.classList.remove(CLASS_NAME_ACTIVE$1));
  5074. } // Static
  5075. static jQueryInterface(config) {
  5076. return this.each(function () {
  5077. const data = ScrollSpy.getOrCreateInstance(this, config);
  5078. if (typeof config !== 'string') {
  5079. return;
  5080. }
  5081. if (typeof data[config] === 'undefined') {
  5082. throw new TypeError(`No method named "${config}"`);
  5083. }
  5084. data[config]();
  5085. });
  5086. }
  5087. }
  5088. /**
  5089. * ------------------------------------------------------------------------
  5090. * Data Api implementation
  5091. * ------------------------------------------------------------------------
  5092. */
  5093. EventHandler.on(window, EVENT_LOAD_DATA_API, () => {
  5094. SelectorEngine.find(SELECTOR_DATA_SPY).forEach(spy => new ScrollSpy(spy));
  5095. });
  5096. /**
  5097. * ------------------------------------------------------------------------
  5098. * jQuery
  5099. * ------------------------------------------------------------------------
  5100. * add .ScrollSpy to jQuery only if jQuery is present
  5101. */
  5102. defineJQueryPlugin(ScrollSpy);
  5103. /**
  5104. * --------------------------------------------------------------------------
  5105. * Bootstrap (v5.1.3): tab.js
  5106. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
  5107. * --------------------------------------------------------------------------
  5108. */
  5109. /**
  5110. * ------------------------------------------------------------------------
  5111. * Constants
  5112. * ------------------------------------------------------------------------
  5113. */
  5114. const NAME$1 = 'tab';
  5115. const DATA_KEY$1 = 'bs.tab';
  5116. const EVENT_KEY$1 = `.${DATA_KEY$1}`;
  5117. const DATA_API_KEY = '.data-api';
  5118. const EVENT_HIDE$1 = `hide${EVENT_KEY$1}`;
  5119. const EVENT_HIDDEN$1 = `hidden${EVENT_KEY$1}`;
  5120. const EVENT_SHOW$1 = `show${EVENT_KEY$1}`;
  5121. const EVENT_SHOWN$1 = `shown${EVENT_KEY$1}`;
  5122. const EVENT_CLICK_DATA_API = `click${EVENT_KEY$1}${DATA_API_KEY}`;
  5123. const CLASS_NAME_DROPDOWN_MENU = 'dropdown-menu';
  5124. const CLASS_NAME_ACTIVE = 'active';
  5125. const CLASS_NAME_FADE$1 = 'fade';
  5126. const CLASS_NAME_SHOW$1 = 'show';
  5127. const SELECTOR_DROPDOWN = '.dropdown';
  5128. const SELECTOR_NAV_LIST_GROUP = '.nav, .list-group';
  5129. const SELECTOR_ACTIVE = '.active';
  5130. const SELECTOR_ACTIVE_UL = ':scope > li > .active';
  5131. const SELECTOR_DATA_TOGGLE = '[data-bs-toggle="tab"], [data-bs-toggle="pill"], [data-bs-toggle="list"]';
  5132. const SELECTOR_DROPDOWN_TOGGLE = '.dropdown-toggle';
  5133. const SELECTOR_DROPDOWN_ACTIVE_CHILD = ':scope > .dropdown-menu .active';
  5134. /**
  5135. * ------------------------------------------------------------------------
  5136. * Class Definition
  5137. * ------------------------------------------------------------------------
  5138. */
  5139. class Tab extends BaseComponent {
  5140. // Getters
  5141. static get NAME() {
  5142. return NAME$1;
  5143. } // Public
  5144. show() {
  5145. if (this._element.parentNode && this._element.parentNode.nodeType === Node.ELEMENT_NODE && this._element.classList.contains(CLASS_NAME_ACTIVE)) {
  5146. return;
  5147. }
  5148. let previous;
  5149. const target = getElementFromSelector(this._element);
  5150. const listElement = this._element.closest(SELECTOR_NAV_LIST_GROUP);
  5151. if (listElement) {
  5152. const itemSelector = listElement.nodeName === 'UL' || listElement.nodeName === 'OL' ? SELECTOR_ACTIVE_UL : SELECTOR_ACTIVE;
  5153. previous = SelectorEngine.find(itemSelector, listElement);
  5154. previous = previous[previous.length - 1];
  5155. }
  5156. const hideEvent = previous ? EventHandler.trigger(previous, EVENT_HIDE$1, {
  5157. relatedTarget: this._element
  5158. }) : null;
  5159. const showEvent = EventHandler.trigger(this._element, EVENT_SHOW$1, {
  5160. relatedTarget: previous
  5161. });
  5162. if (showEvent.defaultPrevented || hideEvent !== null && hideEvent.defaultPrevented) {
  5163. return;
  5164. }
  5165. this._activate(this._element, listElement);
  5166. const complete = () => {
  5167. EventHandler.trigger(previous, EVENT_HIDDEN$1, {
  5168. relatedTarget: this._element
  5169. });
  5170. EventHandler.trigger(this._element, EVENT_SHOWN$1, {
  5171. relatedTarget: previous
  5172. });
  5173. };
  5174. if (target) {
  5175. this._activate(target, target.parentNode, complete);
  5176. } else {
  5177. complete();
  5178. }
  5179. } // Private
  5180. _activate(element, container, callback) {
  5181. const activeElements = container && (container.nodeName === 'UL' || container.nodeName === 'OL') ? SelectorEngine.find(SELECTOR_ACTIVE_UL, container) : SelectorEngine.children(container, SELECTOR_ACTIVE);
  5182. const active = activeElements[0];
  5183. const isTransitioning = callback && active && active.classList.contains(CLASS_NAME_FADE$1);
  5184. const complete = () => this._transitionComplete(element, active, callback);
  5185. if (active && isTransitioning) {
  5186. active.classList.remove(CLASS_NAME_SHOW$1);
  5187. this._queueCallback(complete, element, true);
  5188. } else {
  5189. complete();
  5190. }
  5191. }
  5192. _transitionComplete(element, active, callback) {
  5193. if (active) {
  5194. active.classList.remove(CLASS_NAME_ACTIVE);
  5195. const dropdownChild = SelectorEngine.findOne(SELECTOR_DROPDOWN_ACTIVE_CHILD, active.parentNode);
  5196. if (dropdownChild) {
  5197. dropdownChild.classList.remove(CLASS_NAME_ACTIVE);
  5198. }
  5199. if (active.getAttribute('role') === 'tab') {
  5200. active.setAttribute('aria-selected', false);
  5201. }
  5202. }
  5203. element.classList.add(CLASS_NAME_ACTIVE);
  5204. if (element.getAttribute('role') === 'tab') {
  5205. element.setAttribute('aria-selected', true);
  5206. }
  5207. reflow(element);
  5208. if (element.classList.contains(CLASS_NAME_FADE$1)) {
  5209. element.classList.add(CLASS_NAME_SHOW$1);
  5210. }
  5211. let parent = element.parentNode;
  5212. if (parent && parent.nodeName === 'LI') {
  5213. parent = parent.parentNode;
  5214. }
  5215. if (parent && parent.classList.contains(CLASS_NAME_DROPDOWN_MENU)) {
  5216. const dropdownElement = element.closest(SELECTOR_DROPDOWN);
  5217. if (dropdownElement) {
  5218. SelectorEngine.find(SELECTOR_DROPDOWN_TOGGLE, dropdownElement).forEach(dropdown => dropdown.classList.add(CLASS_NAME_ACTIVE));
  5219. }
  5220. element.setAttribute('aria-expanded', true);
  5221. }
  5222. if (callback) {
  5223. callback();
  5224. }
  5225. } // Static
  5226. static jQueryInterface(config) {
  5227. return this.each(function () {
  5228. const data = Tab.getOrCreateInstance(this);
  5229. if (typeof config === 'string') {
  5230. if (typeof data[config] === 'undefined') {
  5231. throw new TypeError(`No method named "${config}"`);
  5232. }
  5233. data[config]();
  5234. }
  5235. });
  5236. }
  5237. }
  5238. /**
  5239. * ------------------------------------------------------------------------
  5240. * Data Api implementation
  5241. * ------------------------------------------------------------------------
  5242. */
  5243. EventHandler.on(document, EVENT_CLICK_DATA_API, SELECTOR_DATA_TOGGLE, function (event) {
  5244. if (['A', 'AREA'].includes(this.tagName)) {
  5245. event.preventDefault();
  5246. }
  5247. if (isDisabled(this)) {
  5248. return;
  5249. }
  5250. const data = Tab.getOrCreateInstance(this);
  5251. data.show();
  5252. });
  5253. /**
  5254. * ------------------------------------------------------------------------
  5255. * jQuery
  5256. * ------------------------------------------------------------------------
  5257. * add .Tab to jQuery only if jQuery is present
  5258. */
  5259. defineJQueryPlugin(Tab);
  5260. /**
  5261. * --------------------------------------------------------------------------
  5262. * Bootstrap (v5.1.3): toast.js
  5263. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
  5264. * --------------------------------------------------------------------------
  5265. */
  5266. /**
  5267. * ------------------------------------------------------------------------
  5268. * Constants
  5269. * ------------------------------------------------------------------------
  5270. */
  5271. const NAME = 'toast';
  5272. const DATA_KEY = 'bs.toast';
  5273. const EVENT_KEY = `.${DATA_KEY}`;
  5274. const EVENT_MOUSEOVER = `mouseover${EVENT_KEY}`;
  5275. const EVENT_MOUSEOUT = `mouseout${EVENT_KEY}`;
  5276. const EVENT_FOCUSIN = `focusin${EVENT_KEY}`;
  5277. const EVENT_FOCUSOUT = `focusout${EVENT_KEY}`;
  5278. const EVENT_HIDE = `hide${EVENT_KEY}`;
  5279. const EVENT_HIDDEN = `hidden${EVENT_KEY}`;
  5280. const EVENT_SHOW = `show${EVENT_KEY}`;
  5281. const EVENT_SHOWN = `shown${EVENT_KEY}`;
  5282. const CLASS_NAME_FADE = 'fade';
  5283. const CLASS_NAME_HIDE = 'hide'; // @deprecated - kept here only for backwards compatibility
  5284. const CLASS_NAME_SHOW = 'show';
  5285. const CLASS_NAME_SHOWING = 'showing';
  5286. const DefaultType = {
  5287. animation: 'boolean',
  5288. autohide: 'boolean',
  5289. delay: 'number'
  5290. };
  5291. const Default = {
  5292. animation: true,
  5293. autohide: true,
  5294. delay: 5000
  5295. };
  5296. /**
  5297. * ------------------------------------------------------------------------
  5298. * Class Definition
  5299. * ------------------------------------------------------------------------
  5300. */
  5301. class Toast extends BaseComponent {
  5302. constructor(element, config) {
  5303. super(element);
  5304. this._config = this._getConfig(config);
  5305. this._timeout = null;
  5306. this._hasMouseInteraction = false;
  5307. this._hasKeyboardInteraction = false;
  5308. this._setListeners();
  5309. } // Getters
  5310. static get DefaultType() {
  5311. return DefaultType;
  5312. }
  5313. static get Default() {
  5314. return Default;
  5315. }
  5316. static get NAME() {
  5317. return NAME;
  5318. } // Public
  5319. show() {
  5320. const showEvent = EventHandler.trigger(this._element, EVENT_SHOW);
  5321. if (showEvent.defaultPrevented) {
  5322. return;
  5323. }
  5324. this._clearTimeout();
  5325. if (this._config.animation) {
  5326. this._element.classList.add(CLASS_NAME_FADE);
  5327. }
  5328. const complete = () => {
  5329. this._element.classList.remove(CLASS_NAME_SHOWING);
  5330. EventHandler.trigger(this._element, EVENT_SHOWN);
  5331. this._maybeScheduleHide();
  5332. };
  5333. this._element.classList.remove(CLASS_NAME_HIDE); // @deprecated
  5334. reflow(this._element);
  5335. this._element.classList.add(CLASS_NAME_SHOW);
  5336. this._element.classList.add(CLASS_NAME_SHOWING);
  5337. this._queueCallback(complete, this._element, this._config.animation);
  5338. }
  5339. hide() {
  5340. if (!this._element.classList.contains(CLASS_NAME_SHOW)) {
  5341. return;
  5342. }
  5343. const hideEvent = EventHandler.trigger(this._element, EVENT_HIDE);
  5344. if (hideEvent.defaultPrevented) {
  5345. return;
  5346. }
  5347. const complete = () => {
  5348. this._element.classList.add(CLASS_NAME_HIDE); // @deprecated
  5349. this._element.classList.remove(CLASS_NAME_SHOWING);
  5350. this._element.classList.remove(CLASS_NAME_SHOW);
  5351. EventHandler.trigger(this._element, EVENT_HIDDEN);
  5352. };
  5353. this._element.classList.add(CLASS_NAME_SHOWING);
  5354. this._queueCallback(complete, this._element, this._config.animation);
  5355. }
  5356. dispose() {
  5357. this._clearTimeout();
  5358. if (this._element.classList.contains(CLASS_NAME_SHOW)) {
  5359. this._element.classList.remove(CLASS_NAME_SHOW);
  5360. }
  5361. super.dispose();
  5362. } // Private
  5363. _getConfig(config) {
  5364. config = { ...Default,
  5365. ...Manipulator.getDataAttributes(this._element),
  5366. ...(typeof config === 'object' && config ? config : {})
  5367. };
  5368. typeCheckConfig(NAME, config, this.constructor.DefaultType);
  5369. return config;
  5370. }
  5371. _maybeScheduleHide() {
  5372. if (!this._config.autohide) {
  5373. return;
  5374. }
  5375. if (this._hasMouseInteraction || this._hasKeyboardInteraction) {
  5376. return;
  5377. }
  5378. this._timeout = setTimeout(() => {
  5379. this.hide();
  5380. }, this._config.delay);
  5381. }
  5382. _onInteraction(event, isInteracting) {
  5383. switch (event.type) {
  5384. case 'mouseover':
  5385. case 'mouseout':
  5386. this._hasMouseInteraction = isInteracting;
  5387. break;
  5388. case 'focusin':
  5389. case 'focusout':
  5390. this._hasKeyboardInteraction = isInteracting;
  5391. break;
  5392. }
  5393. if (isInteracting) {
  5394. this._clearTimeout();
  5395. return;
  5396. }
  5397. const nextElement = event.relatedTarget;
  5398. if (this._element === nextElement || this._element.contains(nextElement)) {
  5399. return;
  5400. }
  5401. this._maybeScheduleHide();
  5402. }
  5403. _setListeners() {
  5404. EventHandler.on(this._element, EVENT_MOUSEOVER, event => this._onInteraction(event, true));
  5405. EventHandler.on(this._element, EVENT_MOUSEOUT, event => this._onInteraction(event, false));
  5406. EventHandler.on(this._element, EVENT_FOCUSIN, event => this._onInteraction(event, true));
  5407. EventHandler.on(this._element, EVENT_FOCUSOUT, event => this._onInteraction(event, false));
  5408. }
  5409. _clearTimeout() {
  5410. clearTimeout(this._timeout);
  5411. this._timeout = null;
  5412. } // Static
  5413. static jQueryInterface(config) {
  5414. return this.each(function () {
  5415. const data = Toast.getOrCreateInstance(this, config);
  5416. if (typeof config === 'string') {
  5417. if (typeof data[config] === 'undefined') {
  5418. throw new TypeError(`No method named "${config}"`);
  5419. }
  5420. data[config](this);
  5421. }
  5422. });
  5423. }
  5424. }
  5425. enableDismissTrigger(Toast);
  5426. /**
  5427. * ------------------------------------------------------------------------
  5428. * jQuery
  5429. * ------------------------------------------------------------------------
  5430. * add .Toast to jQuery only if jQuery is present
  5431. */
  5432. defineJQueryPlugin(Toast);
  5433. /**
  5434. * --------------------------------------------------------------------------
  5435. * Bootstrap (v5.1.3): index.umd.js
  5436. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
  5437. * --------------------------------------------------------------------------
  5438. */
  5439. const index_umd = {
  5440. Alert,
  5441. Button,
  5442. Carousel,
  5443. Collapse,
  5444. Dropdown,
  5445. Modal,
  5446. Offcanvas,
  5447. Popover,
  5448. ScrollSpy,
  5449. Tab,
  5450. Toast,
  5451. Tooltip
  5452. };
  5453. return index_umd;
  5454. }));
  5455. //# sourceMappingURL=bootstrap.bundle.js.map