accessible-menu-bootstrap-5
Advanced tools
Comparing version 2.0.0-beta.1 to 2.0.0-beta.2
@@ -1,3 +0,3 @@ | ||
var AccessibleMenuBootstrap5=function(){"use strict";var ue=Object.defineProperty;var he=(a,d,v)=>d in a?ue(a,d,{enumerable:!0,configurable:!0,writable:!0,value:v}):a[d]=v;var u=(a,d,v)=>(he(a,typeof d!="symbol"?d+"":d,v),v);function a(o,t){typeof o=="string"?t.classList.add(o):t.classList.add(...o)}function d(o,t){typeof o=="string"?t.classList.remove(o):t.classList.remove(...o)}function v(o,t){try{if(typeof t!="object"){const e=typeof t;throw new TypeError(`Elements given to isValidInstance() must be inside of an object. "${e}" given.`)}for(const e in t)if(!(t[e]instanceof o)){const s=typeof t[e];throw new TypeError(`${e} must be an instance of ${o.name}. "${s}" given.`)}return{status:!0,error:null}}catch(e){return{status:!1,error:e}}}function I(o,t){try{if(typeof t!="object"){const e=typeof t;throw new TypeError(`Values given to isValidType() must be inside of an object. "${e}" given.`)}for(const e in t){const s=typeof t[e];if(s!==o)throw new TypeError(`${e} must be a ${o}. "${s}" given.`)}return{status:!0,error:null}}catch(e){return{status:!1,error:e}}}function x(o){try{if(typeof o!="object"){const t=typeof o;throw new TypeError(`Values given to isCSSSelector() must be inside of an object. "${t}" given.`)}for(const t in o)try{if(o[t]===null)throw new Error;document.querySelector(o[t])}catch{throw new TypeError(`${t} must be a valid CSS selector. "${o[t]}" given.`)}return{status:!0,error:null}}catch(t){return{status:!1,error:t}}}function A(o){try{if(typeof o!="object"||Array.isArray(o)){const t=typeof o;throw new TypeError(`Values given to isValidClassList() must be inside of an object. "${t}" given.`)}for(const t in o){const e=typeof o[t];if(e!=="string")if(Array.isArray(o[t]))o[t].forEach(s=>{if(typeof s!="string")throw new TypeError(`${t} must be a string or an array of strings. An array containing non-strings given.`)});else throw new TypeError(`${t} must be a string or an array of strings. "${e}" given.`);else{const s={};s[t]=o[t],x(s)}}return{status:!0,error:null}}catch(t){return{status:!1,error:t}}}function Q(o){try{if(typeof o!="object"){const e=typeof o;throw new TypeError(`Values given to isValidState() must be inside of an object. "${e}" given.`)}const t=["none","self","child"];for(const e in o)if(!t.includes(o[e]))throw new TypeError(`${e} must be one of the following values: ${t.join(", ")}. "${o[e]}" given.`);return{status:!0,error:null}}catch(t){return{status:!1,error:t}}}function X(o){try{if(typeof o!="object"){const e=typeof o;throw new TypeError(`Values given to isValidEvent() must be inside of an object. "${e}" given.`)}const t=["none","mouse","keyboard","character"];for(const e in o)if(!t.includes(o[e]))throw new TypeError(`${e} must be one of the following values: ${t.join(", ")}. "${o[e]}" given.`);return{status:!0,error:null}}catch(t){return{status:!1,error:t}}}function V(o){try{if(typeof o!="object"){const e=typeof o;throw new TypeError(`Values given to isValidHoverType() must be inside of an object. "${e}" given.`)}const t=["off","on","dynamic"];for(const e in o)if(!t.includes(o[e]))throw new TypeError(`${e} must be one of the following values: ${t.join(", ")}. "${o[e]}" given.`);return{status:!0,error:null}}catch(t){return{status:!1,error:t}}}function Y(o,t){if(I("string",{tagName:o}).status&&v(HTMLElement,t).status){const e=o.toLowerCase();let s=!0;for(const n in t)t[n].tagName.toLowerCase()!==e&&(s=!1);return s}else return!1}class L{constructor({menuToggleElement:t,parentElement:e,controlledMenu:s,parentMenu:n=null}){u(this,"_dom",{toggle:null,parent:null});u(this,"_elements",{controlledMenu:null,parentMenu:null});u(this,"_open",!1);u(this,"_expandEvent",new CustomEvent("accessibleMenuExpand",{bubbles:!0,detail:{toggle:this}}));u(this,"_collapseEvent",new CustomEvent("accessibleMenuCollapse",{bubbles:!0,detail:{toggle:this}}));this._dom.toggle=t,this._dom.parent=e,this._elements.controlledMenu=s,this._elements.parentMenu=n}initialize(){var t;if(this.dom.toggle.setAttribute("aria-haspopup","true"),this.dom.toggle.setAttribute("aria-expanded","false"),Y("button",{toggle:this.dom.toggle})||this.dom.toggle.setAttribute("role","button"),this.dom.toggle.id===""||this.elements.controlledMenu.dom.menu.id===""){const e=Math.random().toString(36).replace(/[^a-z]+/g,"").substr(0,10);let s=((t=this.dom.toggle.innerText)==null?void 0:t.replace(/[^a-zA-Z0-9\s]/g,""))||"",n=e;!s.replace(/\s/g,"").length&&this.dom.toggle.getAttribute("aria-label")&&(s=this.dom.toggle.getAttribute("aria-label").replace(/[^a-zA-Z0-9\s]/g,"")),s.replace(/\s/g,"").length>0&&(s=s.toLowerCase().replace(/\s+/g,"-"),s.startsWith("-")&&(s=s.substring(1)),s.endsWith("-")&&(s=s.slice(0,-1)),n=`${s}-${n}`),this.dom.toggle.id=this.dom.toggle.id||`${n}-menu-button`,this.elements.controlledMenu.dom.menu.id=this.elements.controlledMenu.dom.menu.id||`${n}-menu`}this.elements.controlledMenu.dom.menu.setAttribute("aria-labelledby",this.dom.toggle.id),this.dom.toggle.setAttribute("aria-controls",this.elements.controlledMenu.dom.menu.id),this._collapse(!1)}get dom(){return this._dom}get elements(){return this._elements}get isOpen(){return this._open}set isOpen(t){I("boolean",{value:t}),this._open=t}_expand(t=!0){const{closeClass:e,openClass:s,transitionClass:n}=this.elements.controlledMenu;this.dom.toggle.setAttribute("aria-expanded","true"),n!==""?(a(n,this.elements.controlledMenu.dom.menu),requestAnimationFrame(()=>{e!==""&&d(e,this.elements.controlledMenu.dom.menu),requestAnimationFrame(()=>{s!==""&&a(s,this.elements.controlledMenu.dom.menu),requestAnimationFrame(()=>{d(n,this.elements.controlledMenu.dom.menu)})})})):(s!==""&&a(s,this.elements.controlledMenu.dom.menu),e!==""&&d(e,this.elements.controlledMenu.dom.menu)),t&&this.dom.toggle.dispatchEvent(this._expandEvent)}_collapse(t=!0){const{closeClass:e,openClass:s,transitionClass:n}=this.elements.controlledMenu;this.dom.toggle.setAttribute("aria-expanded","false"),n!==""?(a(n,this.elements.controlledMenu.dom.menu),requestAnimationFrame(()=>{s!==""&&d(s,this.elements.controlledMenu.dom.menu),requestAnimationFrame(()=>{e!==""&&a(e,this.elements.controlledMenu.dom.menu),requestAnimationFrame(()=>{d(n,this.elements.controlledMenu.dom.menu)})})})):(e!==""&&a(e,this.elements.controlledMenu.dom.menu),s!==""&&d(s,this.elements.controlledMenu.dom.menu)),t&&this.dom.toggle.dispatchEvent(this._collapseEvent)}open(){this.elements.controlledMenu.focusState="self",this._expand(),this.isOpen=!0}preview(){this.elements.parentMenu&&(this.elements.parentMenu.focusState="self"),this._expand(),this.isOpen=!0}close(){this.isOpen&&(this.elements.controlledMenu.currentChild=0,this.elements.controlledMenu.blur(),this.elements.parentMenu&&(this.elements.parentMenu.focusState="self"),this._collapse(),this.isOpen=!1)}toggle(){this.isOpen?this.close():this.open()}closeSiblings(){this.elements.parentMenu&&this.elements.parentMenu.elements.submenuToggles.forEach(t=>{t!==this&&t.close()})}closeChildren(){this.elements.controlledMenu.elements.submenuToggles.forEach(t=>t.close())}}class D{constructor({menuItemElement:t,menuLinkElement:e,parentMenu:s,isSubmenuItem:n=!1,childMenu:i=null,toggle:r=null}){u(this,"_dom",{item:null,link:null});u(this,"_elements",{parentMenu:null,childMenu:null,toggle:null});u(this,"_submenu",!1);this._dom.item=t,this._dom.link=e,this._elements.parentMenu=s,this._elements.childMenu=i,this._elements.toggle=r,this._submenu=n}initialize(){}get dom(){return this._dom}get elements(){return this._elements}get isSubmenuItem(){return this._submenu}focus(){this.elements.parentMenu.shouldFocus&&this.dom.link.focus()}blur(){this.elements.parentMenu.shouldFocus&&this.dom.link.blur()}}function w(o){try{const t=o.key||o.keyCode,e={Enter:t==="Enter"||t===13,Space:t===" "||t==="Spacebar"||t===32,Escape:t==="Escape"||t==="Esc"||t===27,ArrowUp:t==="ArrowUp"||t==="Up"||t===38,ArrowRight:t==="ArrowRight"||t==="Right"||t===39,ArrowDown:t==="ArrowDown"||t==="Down"||t===40,ArrowLeft:t==="ArrowLeft"||t==="Left"||t===37,Home:t==="Home"||t===36,End:t==="End"||t===35,Character:isNaN(t)&&!!t.match(/^[a-zA-Z]{1}$/),Tab:t==="Tab"||t===9,Asterisk:t==="*"||t===56};return Object.keys(e).find(s=>e[s]===!0)||""}catch{return""}}function l(o){o.preventDefault(),o.stopPropagation()}class S{constructor({menuElement:t,menuItemSelector:e="li",menuLinkSelector:s="a",submenuItemSelector:n="",submenuToggleSelector:i="a",submenuSelector:r="ul",controllerElement:h=null,containerElement:m=null,openClass:c="show",closeClass:f="hide",transitionClass:p="transitioning",isTopLevel:g=!0,parentMenu:M=null,hoverType:b="off",hoverDelay:y=250,enterDelay:_=-1,leaveDelay:C=-1}){u(this,"_MenuType",S);u(this,"_MenuItemType",D);u(this,"_MenuToggleType",L);u(this,"_dom",{menu:null,menuItems:[],submenuItems:[],submenuToggles:[],submenus:[],controller:null,container:null});u(this,"_selectors",{menuItems:"",menuLinks:"",submenuItems:"",submenuToggles:"",submenus:""});u(this,"_elements",{menuItems:[],submenuToggles:[],controller:null,parentMenu:null,rootMenu:null});u(this,"_openClass","show");u(this,"_closeClass","hide");u(this,"_transitionClass","transitioning");u(this,"_root",!0);u(this,"_currentChild",0);u(this,"_focusState","none");u(this,"_currentEvent","none");u(this,"_hoverType","off");u(this,"_hoverDelay",250);u(this,"_enterDelay",-1);u(this,"_leaveDelay",-1);u(this,"_hoverTimeout",null);u(this,"_errors",[]);this._dom.menu=t,this._dom.controller=h,this._dom.container=m,this._selectors.menuItems=e,this._selectors.menuLinks=s,this._selectors.submenuItems=n,this._selectors.submenuToggles=i,this._selectors.submenus=r,this._elements.menuItems=[],this._elements.submenuToggles=[],this._elements.controller=null,this._elements.parentMenu=M,this._elements.rootMenu=g?this:null,this._openClass=c||"",this._closeClass=f||"",this._transitionClass=p||"",this._root=g,this._hoverType=b,this._hoverDelay=y,this._enterDelay=_,this._leaveDelay=C}initialize(){if(!this._validate())throw new Error(`AccesibleMenu: cannot initialize menu. The following errors have been found: | ||
var AccessibleMenuBootstrap5=function(){"use strict";var ue=Object.defineProperty;var he=(a,d,I)=>d in a?ue(a,d,{enumerable:!0,configurable:!0,writable:!0,value:I}):a[d]=I;var u=(a,d,I)=>(he(a,typeof d!="symbol"?d+"":d,I),I);function a(o,t){typeof o=="string"?t.classList.add(o):t.classList.add(...o)}function d(o,t){typeof o=="string"?t.classList.remove(o):t.classList.remove(...o)}function I(o,t){try{if(typeof t!="object"){const e=typeof t;throw new TypeError(`Elements given to isValidInstance() must be inside of an object. "${e}" given.`)}for(const e in t)if(!(t[e]instanceof o)){const s=typeof t[e];throw new TypeError(`${e} must be an instance of ${o.name}. "${s}" given.`)}return{status:!0,error:null}}catch(e){return{status:!1,error:e}}}function v(o,t){try{if(typeof t!="object"){const e=typeof t;throw new TypeError(`Values given to isValidType() must be inside of an object. "${e}" given.`)}for(const e in t){const s=typeof t[e];if(s!==o)throw new TypeError(`${e} must be a ${o}. "${s}" given.`)}return{status:!0,error:null}}catch(e){return{status:!1,error:e}}}function x(o){try{if(typeof o!="object"){const t=typeof o;throw new TypeError(`Values given to isCSSSelector() must be inside of an object. "${t}" given.`)}for(const t in o)try{if(o[t]===null)throw new Error;document.querySelector(o[t])}catch{throw new TypeError(`${t} must be a valid CSS selector. "${o[t]}" given.`)}return{status:!0,error:null}}catch(t){return{status:!1,error:t}}}function A(o){try{if(typeof o!="object"||Array.isArray(o)){const t=typeof o;throw new TypeError(`Values given to isValidClassList() must be inside of an object. "${t}" given.`)}for(const t in o){const e=typeof o[t];if(e!=="string")if(Array.isArray(o[t]))o[t].forEach(s=>{if(typeof s!="string")throw new TypeError(`${t} must be a string or an array of strings. An array containing non-strings given.`)});else throw new TypeError(`${t} must be a string or an array of strings. "${e}" given.`);else{const s={};s[t]=o[t],x(s)}}return{status:!0,error:null}}catch(t){return{status:!1,error:t}}}function Q(o){try{if(typeof o!="object"){const e=typeof o;throw new TypeError(`Values given to isValidState() must be inside of an object. "${e}" given.`)}const t=["none","self","child"];for(const e in o)if(!t.includes(o[e]))throw new TypeError(`${e} must be one of the following values: ${t.join(", ")}. "${o[e]}" given.`);return{status:!0,error:null}}catch(t){return{status:!1,error:t}}}function X(o){try{if(typeof o!="object"){const e=typeof o;throw new TypeError(`Values given to isValidEvent() must be inside of an object. "${e}" given.`)}const t=["none","mouse","keyboard","character"];for(const e in o)if(!t.includes(o[e]))throw new TypeError(`${e} must be one of the following values: ${t.join(", ")}. "${o[e]}" given.`);return{status:!0,error:null}}catch(t){return{status:!1,error:t}}}function V(o){try{if(typeof o!="object"){const e=typeof o;throw new TypeError(`Values given to isValidHoverType() must be inside of an object. "${e}" given.`)}const t=["off","on","dynamic"];for(const e in o)if(!t.includes(o[e]))throw new TypeError(`${e} must be one of the following values: ${t.join(", ")}. "${o[e]}" given.`);return{status:!0,error:null}}catch(t){return{status:!1,error:t}}}function Y(o,t){if(v("string",{tagName:o}).status&&I(HTMLElement,t).status){const e=o.toLowerCase();let s=!0;for(const n in t)t[n].tagName.toLowerCase()!==e&&(s=!1);return s}else return!1}class L{constructor({menuToggleElement:t,parentElement:e,controlledMenu:s,parentMenu:n=null}){u(this,"_dom",{toggle:null,parent:null});u(this,"_elements",{controlledMenu:null,parentMenu:null});u(this,"_open",!1);u(this,"_expandEvent",new CustomEvent("accessibleMenuExpand",{bubbles:!0,detail:{toggle:this}}));u(this,"_collapseEvent",new CustomEvent("accessibleMenuCollapse",{bubbles:!0,detail:{toggle:this}}));this._dom.toggle=t,this._dom.parent=e,this._elements.controlledMenu=s,this._elements.parentMenu=n}initialize(){var t;if(this.dom.toggle.setAttribute("aria-haspopup","true"),this.dom.toggle.setAttribute("aria-expanded","false"),Y("button",{toggle:this.dom.toggle})||this.dom.toggle.setAttribute("role","button"),this.dom.toggle.id===""||this.elements.controlledMenu.dom.menu.id===""){const e=Math.random().toString(36).replace(/[^a-z]+/g,"").substr(0,10);let s=((t=this.dom.toggle.innerText)==null?void 0:t.replace(/[^a-zA-Z0-9\s]/g,""))||"",n=e;!s.replace(/\s/g,"").length&&this.dom.toggle.getAttribute("aria-label")&&(s=this.dom.toggle.getAttribute("aria-label").replace(/[^a-zA-Z0-9\s]/g,"")),s.replace(/\s/g,"").length>0&&(s=s.toLowerCase().replace(/\s+/g,"-"),s.startsWith("-")&&(s=s.substring(1)),s.endsWith("-")&&(s=s.slice(0,-1)),n=`${s}-${n}`),this.dom.toggle.id=this.dom.toggle.id||`${n}-menu-button`,this.elements.controlledMenu.dom.menu.id=this.elements.controlledMenu.dom.menu.id||`${n}-menu`}this.elements.controlledMenu.dom.menu.setAttribute("aria-labelledby",this.dom.toggle.id),this.dom.toggle.setAttribute("aria-controls",this.elements.controlledMenu.dom.menu.id),this._collapse(!1)}get dom(){return this._dom}get elements(){return this._elements}get isOpen(){return this._open}set isOpen(t){v("boolean",{value:t}),this._open=t}_expand(t=!0){const{closeClass:e,openClass:s,transitionClass:n}=this.elements.controlledMenu;this.dom.toggle.setAttribute("aria-expanded","true"),n!==""?(a(n,this.elements.controlledMenu.dom.menu),requestAnimationFrame(()=>{e!==""&&d(e,this.elements.controlledMenu.dom.menu),requestAnimationFrame(()=>{s!==""&&a(s,this.elements.controlledMenu.dom.menu),requestAnimationFrame(()=>{d(n,this.elements.controlledMenu.dom.menu)})})})):(s!==""&&a(s,this.elements.controlledMenu.dom.menu),e!==""&&d(e,this.elements.controlledMenu.dom.menu)),t&&this.dom.toggle.dispatchEvent(this._expandEvent)}_collapse(t=!0){const{closeClass:e,openClass:s,transitionClass:n}=this.elements.controlledMenu;this.dom.toggle.setAttribute("aria-expanded","false"),n!==""?(a(n,this.elements.controlledMenu.dom.menu),requestAnimationFrame(()=>{s!==""&&d(s,this.elements.controlledMenu.dom.menu),requestAnimationFrame(()=>{e!==""&&a(e,this.elements.controlledMenu.dom.menu),requestAnimationFrame(()=>{d(n,this.elements.controlledMenu.dom.menu)})})})):(e!==""&&a(e,this.elements.controlledMenu.dom.menu),s!==""&&d(s,this.elements.controlledMenu.dom.menu)),t&&this.dom.toggle.dispatchEvent(this._collapseEvent)}open(){this.elements.controlledMenu.focusState="self",this._expand(),this.isOpen=!0}preview(){this.elements.parentMenu&&(this.elements.parentMenu.focusState="self"),this._expand(),this.isOpen=!0}close(){this.isOpen&&(this.elements.controlledMenu.blur(),this.elements.parentMenu&&(this.elements.parentMenu.focusState="self"),this._collapse(),this.isOpen=!1)}toggle(){this.isOpen?this.close():this.open()}closeSiblings(){this.elements.parentMenu&&this.elements.parentMenu.elements.submenuToggles.forEach(t=>{t!==this&&t.close()})}closeChildren(){this.elements.controlledMenu.elements.submenuToggles.forEach(t=>t.close())}}class D{constructor({menuItemElement:t,menuLinkElement:e,parentMenu:s,isSubmenuItem:n=!1,childMenu:i=null,toggle:r=null}){u(this,"_dom",{item:null,link:null});u(this,"_elements",{parentMenu:null,childMenu:null,toggle:null});u(this,"_submenu",!1);this._dom.item=t,this._dom.link=e,this._elements.parentMenu=s,this._elements.childMenu=i,this._elements.toggle=r,this._submenu=n}initialize(){}get dom(){return this._dom}get elements(){return this._elements}get isSubmenuItem(){return this._submenu}focus(){this.elements.parentMenu.shouldFocus&&this.dom.link.focus()}blur(){this.elements.parentMenu.shouldFocus&&this.dom.link.blur()}}function w(o){try{const t=o.key||o.keyCode,e={Enter:t==="Enter"||t===13,Space:t===" "||t==="Spacebar"||t===32,Escape:t==="Escape"||t==="Esc"||t===27,ArrowUp:t==="ArrowUp"||t==="Up"||t===38,ArrowRight:t==="ArrowRight"||t==="Right"||t===39,ArrowDown:t==="ArrowDown"||t==="Down"||t===40,ArrowLeft:t==="ArrowLeft"||t==="Left"||t===37,Home:t==="Home"||t===36,End:t==="End"||t===35,Character:isNaN(t)&&!!t.match(/^[a-zA-Z]{1}$/),Tab:t==="Tab"||t===9,Asterisk:t==="*"||t===56};return Object.keys(e).find(s=>e[s]===!0)||""}catch{return""}}function l(o){o.preventDefault(),o.stopPropagation()}class S{constructor({menuElement:t,menuItemSelector:e="li",menuLinkSelector:s="a",submenuItemSelector:n="",submenuToggleSelector:i="a",submenuSelector:r="ul",controllerElement:h=null,containerElement:m=null,openClass:c="show",closeClass:f="hide",transitionClass:p="transitioning",isTopLevel:g=!0,parentMenu:M=null,hoverType:y="off",hoverDelay:b=250,enterDelay:C=-1,leaveDelay:_=-1}){u(this,"_MenuType",S);u(this,"_MenuItemType",D);u(this,"_MenuToggleType",L);u(this,"_dom",{menu:null,menuItems:[],submenuItems:[],submenuToggles:[],submenus:[],controller:null,container:null});u(this,"_selectors",{menuItems:"",menuLinks:"",submenuItems:"",submenuToggles:"",submenus:""});u(this,"_elements",{menuItems:[],submenuToggles:[],controller:null,parentMenu:null,rootMenu:null});u(this,"_openClass","show");u(this,"_closeClass","hide");u(this,"_transitionClass","transitioning");u(this,"_root",!0);u(this,"_currentChild",0);u(this,"_focusState","none");u(this,"_currentEvent","none");u(this,"_hoverType","off");u(this,"_hoverDelay",250);u(this,"_enterDelay",-1);u(this,"_leaveDelay",-1);u(this,"_hoverTimeout",null);u(this,"_errors",[]);this._dom.menu=t,this._dom.controller=h,this._dom.container=m,this._selectors.menuItems=e,this._selectors.menuLinks=s,this._selectors.submenuItems=n,this._selectors.submenuToggles=i,this._selectors.submenus=r,this._elements.menuItems=[],this._elements.submenuToggles=[],this._elements.controller=null,this._elements.parentMenu=M,this._elements.rootMenu=g?this:null,this._openClass=c||"",this._closeClass=f||"",this._transitionClass=p||"",this._root=g,this._hoverType=y,this._hoverDelay=b,this._enterDelay=C,this._leaveDelay=_}initialize(){if(!this._validate())throw new Error(`AccesibleMenu: cannot initialize menu. The following errors have been found: | ||
- ${this.errors.join(` | ||
- `)}`);if(this.elements.rootMenu===null&&this._findRootMenu(this),this._setDOMElements(),this.isTopLevel&&this.dom.controller&&this.dom.container){const t=new this._MenuToggleType({menuToggleElement:this.dom.controller,parentElement:this.dom.container,controlledMenu:this});this._elements.controller=t}this._createChildElements()}get dom(){return this._dom}get selectors(){return this._selectors}get elements(){return this._elements}get isTopLevel(){return this._root}get openClass(){return this.isTopLevel?this._openClass:this.elements.rootMenu.openClass}get closeClass(){return this.isTopLevel?this._closeClass:this.elements.rootMenu.closeClass}get transitionClass(){return this.isTopLevel?this._transitionClass:this.elements.rootMenu.transitionClass}get currentChild(){return this._currentChild}get focusState(){return this._focusState}get currentEvent(){return this._currentEvent}get currentMenuItem(){return this.elements.menuItems[this.currentChild]}get hoverType(){return this._root?this._hoverType:this.elements.rootMenu.hoverType}get hoverDelay(){return this._root?this._hoverDelay:this.elements.rootMenu.hoverDelay}get enterDelay(){return this._enterDelay===-1?this.hoverDelay:this._root?this._enterDelay:this.elements.rootMenu.enterDelay}get leaveDelay(){return this._leaveDelay===-1?this.hoverDelay:this._root?this._leaveDelay:this.elements.rootMenu.leaveDelay}get shouldFocus(){let t=!1;return(this.currentEvent==="keyboard"||this.currentEvent==="character")&&(t=!0),this.currentEvent==="mouse"&&this.hoverType==="dynamic"&&(t=!0),t}get errors(){return this._errors}set openClass(t){A({openClass:t}),this._openClass!==t&&(this._openClass=t)}set closeClass(t){A({closeClass:t}),this._closeClass!==t&&(this._closeClass=t)}set transitionClass(t){A({transitionClass:t}),this._transitionClass!==t&&(this._transitionClass=t)}set currentChild(t){I("number",{value:t});function e(s){if(["mouse","character"].includes(s.currentEvent)&&s.elements.parentMenu){let i=0,r=!1;for(;!r&&i<s.elements.parentMenu.elements.menuItems.length;){const h=s.elements.parentMenu.elements.menuItems[i];h.isSubmenuItem&&h.elements.toggle.elements.controlledMenu===s&&(r=!0,s.elements.parentMenu.currentEvent=s.currentEvent,s.elements.parentMenu.currentChild=i),i++}}}t<-1?(this._currentChild=-1,e(this)):t>=this.elements.menuItems.length?(this._currentChild=this.elements.menuItems.length-1,e(this)):this.focusChild!==t&&(this._currentChild=t,e(this))}set focusState(t){Q({value:t}),this._focusState!==t&&(this._focusState=t),this.elements.submenuToggles.length>0&&(t==="self"||t==="none")&&this.elements.submenuToggles.forEach(e=>{e.elements.controlledMenu.focusState="none"}),this.elements.parentMenu&&(t==="self"||t==="child")&&(this.elements.parentMenu.focusState="child")}set currentEvent(t){X({value:t}),this._currentEvent!==t&&(this._currentEvent=t,this.elements.submenuToggles.length>0&&this.elements.submenuToggles.forEach(e=>{e.elements.controlledMenu.currentEvent=t}))}set hoverType(t){V({value:t}),this._hoverType!==t&&(this._hoverType=t)}set hoverDelay(t){I("number",{value:t}),this._hoverDelay!==t&&(this._hoverDelay=t)}set enterDelay(t){I("number",{value:t}),this._enterDelay!==t&&(this._enterDelay=t)}set leaveDelay(t){I("number",{value:t}),this._leaveDelay!==t&&(this._leaveDelay=t)}_validate(){let t=!0,e;this._dom.container!==null||this._dom.controller!==null?e=v(HTMLElement,{menuElement:this._dom.menu,controllerElement:this._dom.controller,containerElement:this._dom.container}):e=v(HTMLElement,{menuElement:this._dom.menu}),e.status||(this._errors.push(e.error.message),t=!1);let s;if(this._selectors.submenuItems!==""?s=x({menuItemSelector:this._selectors.menuItems,menuLinkSelector:this._selectors.menuLinks,submenuItemSelector:this._selectors.submenuItems,submenuToggleSelector:this._selectors.submenuToggles,submenuSelector:this._selectors.submenus}):s=x({menuItemSelector:this._selectors.menuItems,menuLinkSelector:this._selectors.menuLinks}),s.status||(this._errors.push(s.error.message),t=!1),this._openClass!==""){const c=A({openClass:this._openClass});c.status||(this._errors.push(c.error.message),t=!1)}if(this._closeClass!==""){const c=A({closeClass:this._closeClass});c.status||(this._errors.push(c.error.message),t=!1)}if(this._transitionClass!==""){const c=A({transitionClass:this._transitionClass});c.status||(this._errors.push(c.error.message),t=!1)}const n=I("boolean",{isTopLevel:this._root});if(n.status||(this._errors.push(n.error.message),t=!1),this._elements.parentMenu!==null){const c=v(S,{parentMenu:this._elements.parentMenu});c.status||(this._errors.push(c.error.message),t=!1)}const i=V({hoverType:this._hoverType});i.status||(this._errors.push(i.error.message),t=!1);const r=I("number",{hoverDelay:this._hoverDelay});r.status||(this._errors.push(r.error.message),t=!1);const h=I("number",{enterDelay:this._enterDelay});h.status||(this._errors.push(h.error.message),t=!1);const m=I("number",{leaveDelay:this._leaveDelay});return m.status||(this._errors.push(m.error.message),t=!1),t}_setDOMElementType(t,e=this.dom.menu,s=!0){if(typeof this.selectors[t]=="string"){if(!Array.isArray(this.dom[t]))throw new Error(`AccessibleMenu: The "${t}" element cannot be set through _setDOMElementType.`);e!==this.dom.menu&&v(HTMLElement,{base:e});const i=Array.from(e.querySelectorAll(this.selectors[t])).filter(r=>r.parentElement===e);s?this._dom[t]=i:this._dom[t]=[...this._dom[t],...i]}else throw new Error(`AccessibleMenu: "${t}" is not a valid element type within the menu.`)}_resetDOMElementType(t){if(typeof this.dom[t]<"u"){if(!Array.isArray(this.dom[t]))throw new Error(`AccessibleMenu: The "${t}" element cannot be reset through _resetDOMElementType.`);this._dom[t]=[]}else throw new Error(`AccessibleMenu: "${t}" is not a valid element type within the menu.`)}_setDOMElements(){this._setDOMElementType("menuItems"),this.selectors.submenuItems!==""&&(this._setDOMElementType("submenuItems"),this._resetDOMElementType("submenuToggles"),this._resetDOMElementType("submenus"),this.dom.submenuItems.forEach(t=>{this._setDOMElementType("submenuToggles",t,!1),this._setDOMElementType("submenus",t,!1)}))}_findRootMenu(t){if(t.isTopLevel)this._elements.rootMenu=t;else if(t.elements.parentMenu!==null)this._findRootMenu(t.elements.parentMenu);else throw new Error("Cannot find root menu.")}_createChildElements(){this.dom.menuItems.forEach(t=>{let e;if(this.dom.submenuItems.includes(t)){const s=t.querySelector(this.selectors.submenuToggles),n=t.querySelector(this.selectors.submenus),i=new this._MenuType({menuElement:n,menuItemSelector:this.selectors.menuItems,menuLinkSelector:this.selectors.menuLinks,submenuItemSelector:this.selectors.submenuItems,submenuToggleSelector:this.selectors.submenuToggles,submenuSelector:this.selectors.submenus,openClass:this.openClass,closeClass:this.closeClass,isTopLevel:!1,parentMenu:this,hoverType:this.hoverType,hoverDelay:this.hoverDelay}),r=new this._MenuToggleType({menuToggleElement:s,parentElement:t,controlledMenu:i,parentMenu:this});this._elements.submenuToggles.push(r),e=new this._MenuItemType({menuItemElement:t,menuLinkElement:s,parentMenu:this,isSubmenuItem:!0,childMenu:i,toggle:r})}else{const s=t.querySelector(this.selectors.menuLinks);e=new this._MenuItemType({menuItemElement:t,menuLinkElement:s,parentMenu:this})}this._elements.menuItems.push(e)})}_handleFocus(){this.elements.menuItems.forEach((t,e)=>{t.dom.link.addEventListener("focus",()=>{this.focusState="self",this.currentChild=e})})}_handleClick(){function t(e,s,n){l(n),s.toggle(),s.isOpen&&(e.focusState="self",s.elements.controlledMenu.focusState="none")}this.elements.menuItems.forEach((e,s)=>{e.dom.link.addEventListener("pointerdown",()=>{this.currentEvent="mouse",this.elements.rootMenu.blurChildren(),this.focusChild(s)},{passive:!0}),e.isSubmenuItem&&e.elements.toggle.dom.toggle.addEventListener("pointerup",n=>{this.currentEvent="mouse",t(this,e.elements.toggle,n)})}),this.isTopLevel&&this.elements.controller&&this.elements.controller.dom.toggle.addEventListener("pointerup",e=>{this.currentEvent="mouse",t(this,this.elements.controller,e)})}_handleHover(){this.elements.menuItems.forEach((t,e)=>{t.dom.link.addEventListener("pointerenter",s=>{if(!(s.pointerType==="pen"||s.pointerType==="touch")){if(this.hoverType==="on")this.currentEvent="mouse",this.currentChild=e,t.isSubmenuItem&&(this.enterDelay>0?this._hoverTimeout=setTimeout(()=>{t.elements.toggle.preview()},this.enterDelay):t.elements.toggle.preview());else if(this.hoverType==="dynamic"){const n=this.elements.submenuToggles.some(i=>i.isOpen);this.currentChild=e,(!this.isTopLevel||this.focusState!=="none")&&(this.currentEvent="mouse",this.focusCurrentChild()),t.isSubmenuItem&&(!this.isTopLevel||n)&&(this.currentEvent="mouse",this.enterDelay>0?this._hoverTimeout=setTimeout(()=>{t.elements.toggle.preview()},this.enterDelay):t.elements.toggle.preview())}}}),t.isSubmenuItem&&t.dom.item.addEventListener("pointerleave",s=>{s.pointerType==="pen"||s.pointerType==="touch"||(this.hoverType==="on"?this.leaveDelay>0?(clearTimeout(this._hoverTimeout),setTimeout(()=>{this.currentEvent="mouse",t.elements.toggle.close()},this.leaveDelay)):(this.currentEvent="mouse",t.elements.toggle.close()):this.hoverType==="dynamic"&&(this.isTopLevel||(this.leaveDelay>0?(clearTimeout(this._hoverTimeout),setTimeout(()=>{this.currentEvent="mouse",t.elements.toggle.close(),this.focusCurrentChild()},this.leaveDelay)):(this.currentEvent="mouse",t.elements.toggle.close(),this.focusCurrentChild()))))})})}_handleKeydown(){this.isTopLevel&&this.elements.controller&&this.elements.controller.dom.toggle.addEventListener("keydown",t=>{this.currentEvent="keyboard";const e=w(t);(e==="Space"||e==="Enter")&&l(t)})}_handleKeyup(){this.isTopLevel&&this.elements.controller&&this.elements.controller.dom.toggle.addEventListener("keyup",t=>{this.currentEvent="keyboard";const e=w(t);(e==="Space"||e==="Enter")&&(l(t),this.elements.controller.open(),this.focusFirstChild())})}focus(){this.focusState="self",this.shouldFocus&&this.dom.menu.focus()}blur(){this.focusState="none",this.shouldFocus&&this.dom.menu.blur()}focusCurrentChild(){this.focusState="self",this.currentChild!==-1&&this.currentMenuItem.focus()}focusChild(t){this.blurCurrentChild(),this.currentChild=t,this.focusCurrentChild()}focusFirstChild(){this.focusChild(0)}focusLastChild(){this.focusChild(this.elements.menuItems.length-1)}focusNextChild(){this.currentChild<this.elements.menuItems.length-1?this.focusChild(this.currentChild+1):this.focusCurrentChild()}focusPreviousChild(){this.currentChild>0?this.focusChild(this.currentChild-1):this.focusCurrentChild()}blurCurrentChild(){this.focusState="none",this.currentChild!==-1&&this.currentMenuItem.blur()}focusController(){this.dom.controller&&(this.shouldFocus&&this.dom.controller.focus(),this.focusState="none")}focusContainer(){this.dom.container&&(this.shouldFocus&&this.dom.container.focus(),this.focusState="none")}closeChildren(){this.elements.submenuToggles.forEach(t=>t.close())}blurChildren(){this.elements.menuItems.forEach(t=>{t.blur(),t.isSubmenuItem&&t.elements.childMenu.blurChildren()})}}class R extends D{constructor({menuItemElement:t,menuLinkElement:e,parentMenu:s,isSubmenuItem:n=!1,childMenu:i=null,toggle:r=null,initialize:h=!0}){super({menuItemElement:t,menuLinkElement:e,parentMenu:s,isSubmenuItem:n,childMenu:i,toggle:r}),h&&this.initialize()}}class P extends L{constructor({menuToggleElement:t,parentElement:e,controlledMenu:s,parentMenu:n=null,initialize:i=!0}){super({menuToggleElement:t,parentElement:e,controlledMenu:s,parentMenu:n}),i&&this.initialize()}open(){this.closeSiblings(),super.open()}preview(){this.closeSiblings(),super.preview()}close(){this.isOpen&&this.closeChildren(),super.close()}}class z extends S{constructor({menuElement:e,menuItemSelector:s="li",menuLinkSelector:n="a",submenuItemSelector:i="",submenuToggleSelector:r="a",submenuSelector:h="ul",controllerElement:m=null,containerElement:c=null,openClass:f="show",closeClass:p="hide",transitionClass:g="transitioning",isTopLevel:M=!0,parentMenu:b=null,hoverType:y="off",hoverDelay:_=250,enterDelay:C=-1,leaveDelay:E=-1,optionalKeySupport:T=!1,initialize:k=!0}){super({menuElement:e,menuItemSelector:s,menuLinkSelector:n,submenuItemSelector:i,submenuToggleSelector:r,submenuSelector:h,controllerElement:m,containerElement:c,openClass:f,closeClass:p,transitionClass:g,isTopLevel:M,parentMenu:b,hoverType:y,hoverDelay:_,enterDelay:C,leaveDelay:E});u(this,"_MenuType",z);u(this,"_MenuItemType",R);u(this,"_MenuToggleType",P);u(this,"_currentChild",-1);u(this,"_optionalSupport",!1);this._optionalSupport=T,k&&this.initialize()}initialize(){try{super.initialize(),this._handleFocus(),this._handleClick(),this._handleHover(),this._handleKeydown(),this._handleKeyup()}catch(e){console.error(e)}}get optionalKeySupport(){return this.isTopLevel?this._optionalSupport:this.elements.rootMenu.optionalKeySupport}set optionalKeySupport(e){I("boolean",{optionalKeySupport:e}),this._optionalSupport=e}_validate(){let e=super._validate();const s=I("boolean",{optionalKeySupport:this._optionalSupport});return s.status||(this._errors.push(s.error.message),e=!1),e}_handleClick(){super._handleClick(),document.addEventListener("pointerup",e=>{this.focusState!=="none"&&(this.currentEvent="mouse",!this.dom.menu.contains(e.target)&&!this.dom.menu!==e.target&&(this.closeChildren(),this.blur(),this.elements.controller&&this.elements.controller.close()))})}_handleKeydown(){super._handleKeydown(),this.dom.menu.addEventListener("keydown",e=>{this.currentEvent="keyboard";const s=w(e);if(this.focusState==="self"){const n=["Space","Enter"],i=["Escape"],r=["Escape"];this.optionalKeySupport?["ArrowUp","ArrowRight","ArrowDown","ArrowLeft","Home","End"].includes(s)&&l(e):(this.currentMenuItem.isSubmenuItem&&n.includes(s)||this.elements.controller&&i.includes(s)||this.elements.parentMenu&&r.includes(s))&&l(e)}})}_handleKeyup(){super._handleKeyup(),this.dom.menu.addEventListener("keyup",e=>{this.currentEvent="keyboard";const s=w(e);this.focusState==="self"&&(s==="Space"||s==="Enter"?this.currentMenuItem.isSubmenuItem?(l(e),this.currentMenuItem.elements.toggle.isOpen?this.currentMenuItem.elements.toggle.close():this.currentMenuItem.elements.toggle.preview()):this.currentMenuItem.dom.link.click():s==="Escape"?this.elements.submenuToggles.some(i=>i.isOpen)?(l(e),this.closeChildren()):this.elements.parentMenu?(l(e),this.elements.parentMenu.currentEvent=this.currentEvent,this.elements.parentMenu.closeChildren(),this.elements.parentMenu.focusCurrentChild()):this.isTopLevel&&this.elements.controller&&this.elements.controller.isOpen&&(this.elements.controller.close(),this.focusController()):this.optionalKeySupport&&(s==="ArrowDown"||s==="ArrowRight"?(l(e),this.currentMenuItem.isSubmenuItem&&this.currentMenuItem.elements.toggle.isOpen?(this.currentMenuItem.elements.childMenu.currentEvent="keyboard",this.currentMenuItem.elements.childMenu.focusFirstChild()):this.focusNextChild()):s==="ArrowUp"||s==="ArrowLeft"?(l(e),this.focusPreviousChild()):s==="Home"?(l(e),this.focusFirstChild()):s==="End"&&(l(e),this.focusLastChild())))})}}class ee extends R{constructor({menuItemElement:t,menuLinkElement:e,parentMenu:s,isSubmenuItem:n=!1,childMenu:i=null,toggle:r=null,initialize:h=!0}){super({menuItemElement:t,menuLinkElement:e,parentMenu:s,isSubmenuItem:n,childMenu:i,toggle:r,initialize:!1}),h&&this.initialize()}}class te extends P{constructor({menuToggleElement:e,parentElement:s,controlledMenu:n,parentMenu:i=null,initialize:r=!0}){super({menuToggleElement:e,parentElement:s,controlledMenu:n,parentMenu:i,initialize:!1});u(this,"_dom",{toggle:null,parent:null,container:null});this._dom.toggle=e,this._dom.parent=s,this._dom.container=n.isTopLevel?n.dom.container:n.dom.menu,r&&this.initialize()}initialize(){super.initialize(),this.dom.toggle.hasAttribute("data-bs-toggle")&&this.dom.toggle.removeAttribute("data-bs-toggle"),this.dom.toggle.hasAttribute("data-bs-target")&&this.dom.toggle.removeAttribute("data-bs-target")}_expand(e=!0){const{openClass:s,transitionClass:n}=this.elements.controlledMenu;this.dom.toggle.setAttribute("aria-expanded","true"),n!==""?(a(n,this.dom.container),requestAnimationFrame(()=>{a(s,this.dom.container),requestAnimationFrame(()=>{d(n,this.dom.container)})})):s!==""&&a(s,this.dom.container),e&&this.dom.toggle.dispatchEvent(this._expandEvent)}_collapse(e=!0){const{closeClass:s,openClass:n,transitionClass:i}=this.elements.controlledMenu;this.dom.toggle.setAttribute("aria-expanded","false"),i!==""?(a(i,this.dom.container),requestAnimationFrame(()=>{n!==""&&d(n,this.dom.container),requestAnimationFrame(()=>{s!==""&&a(s,this.dom.container),requestAnimationFrame(()=>{d(i,this.dom.container)})})})):(s!==""&&a(s,this.dom.container),n!==""&&d(n,this.dom.container)),e&&this.dom.toggle.dispatchEvent(this._collapseEvent)}}class O extends z{constructor({menuElement:e,menuItemSelector:s=".nav-item,li",menuLinkSelector:n=".nav-link,.dropdown-item",submenuItemSelector:i=".dropdown",submenuToggleSelector:r=".dropdown-toggle",submenuSelector:h=".dropdown-menu",controllerElement:m=null,containerElement:c=null,openClass:f="show",closeClass:p="collapse",transitionClass:g="transitioning",isTopLevel:M=!0,parentMenu:b=null,hoverType:y="off",hoverDelay:_=250,enterDelay:C=-1,leaveDelay:E=-1,optionalKeySupport:T=!1,initialize:k=!0}){super({menuElement:e,menuItemSelector:s,menuLinkSelector:n,submenuItemSelector:i,submenuToggleSelector:r,submenuSelector:h,controllerElement:m,containerElement:c,openClass:f,closeClass:p,transitionClass:g,isTopLevel:M,parentMenu:b,hoverType:y,hoverDelay:_,enterDelay:C,leaveDelay:E,optionalKeySupport:T,initialize:!1});u(this,"_MenuType",O);u(this,"_MenuItemType",ee);u(this,"_MenuToggleType",te);k&&this.initialize()}}class U extends D{constructor({menuItemElement:t,menuLinkElement:e,parentMenu:s,isSubmenuItem:n=!1,childMenu:i=null,toggle:r=null,initialize:h=!0}){super({menuItemElement:t,menuLinkElement:e,parentMenu:s,isSubmenuItem:n,childMenu:i,toggle:r}),h&&this.initialize()}initialize(){super.initialize(),this.dom.item.setAttribute("role","none"),this.dom.link.setAttribute("role","menuitem"),this.dom.link.tabIndex=-1}focus(){super.focus(),this.elements.parentMenu.isTopLevel&&(this.dom.link.tabIndex=0)}blur(){super.blur(),this.elements.parentMenu.isTopLevel&&(this.dom.link.tabIndex=-1)}}class B extends L{constructor({menuToggleElement:t,parentElement:e,controlledMenu:s,parentMenu:n=null,initialize:i=!0}){super({menuToggleElement:t,parentElement:e,controlledMenu:s,parentMenu:n}),i&&this.initialize()}open(){this.closeSiblings(),super.open()}preview(){this.closeSiblings(),super.preview()}close(){this.isOpen&&this.closeChildren(),super.close()}}class F extends S{constructor({menuElement:e,menuItemSelector:s="li",menuLinkSelector:n="a",submenuItemSelector:i="",submenuToggleSelector:r="a",submenuSelector:h="ul",controllerElement:m=null,containerElement:c=null,openClass:f="show",closeClass:p="hide",transitionClass:g="transitioning",isTopLevel:M=!0,parentMenu:b=null,hoverType:y="off",hoverDelay:_=250,enterDelay:C=-1,leaveDelay:E=-1,initialize:T=!0}){super({menuElement:e,menuItemSelector:s,menuLinkSelector:n,submenuItemSelector:i,submenuToggleSelector:r,submenuSelector:h,controllerElement:m,containerElement:c,openClass:f,closeClass:p,transitionClass:g,isTopLevel:M,parentMenu:b,hoverType:y,hoverDelay:_,enterDelay:C,leaveDelay:E});u(this,"_MenuType",F);u(this,"_MenuItemType",U);u(this,"_MenuToggleType",B);T&&this.initialize()}initialize(){try{super.initialize(),this.dom.menu.setAttribute("role","menubar"),this._handleFocus(),this._handleClick(),this._handleHover(),this._handleKeydown(),this._handleKeyup(),this.isTopLevel&&(this.elements.menuItems[0].dom.link.tabIndex=0)}catch(e){console.error(e)}}_handleClick(){super._handleClick(),document.addEventListener("pointerup",e=>{this.focusState!=="none"&&(this.currentEvent="mouse",!this.dom.menu.contains(e.target)&&!this.dom.menu!==e.target&&(this.closeChildren(),this.blur(),this.elements.controller&&this.elements.controller.close()))})}_handleKeydown(){super._handleKeydown(),this.dom.menu.addEventListener("keydown",e=>{this.currentEvent="keyboard";const s=w(e);if(s==="Tab"&&(this.elements.rootMenu.focusState!=="none"?(this.elements.rootMenu.blur(),this.elements.rootMenu.closeChildren()):this.elements.rootMenu.focus()),s==="Character")l(e);else if(this.isTopLevel){if(this.focusState==="self"){const n=["ArrowRight","ArrowLeft","Home","End"],i=["Space","Enter","ArrowDown","ArrowUp"],r=["Escape"];(n.includes(s)||this.currentMenuItem.isSubmenuItem&&i.includes(s)||this.elements.controller&&r.includes(s))&&l(e)}}else{const n=["Escape","ArrowRight","ArrowLeft","ArrowDown","ArrowUp","Home","End"],i=["Space","Enter"];(n.includes(s)||this.currentMenuItem.isSubmenuItem&&i.includes(s))&&l(e)}})}_handleKeyup(){super._handleKeyup(),this.dom.menu.addEventListener("keyup",e=>{this.currentEvent="keyboard";const s=w(e),{altKey:n,crtlKey:i,metaKey:r}=e;if(s==="Character"&&!(n||i||r))l(e),this.elements.rootMenu.currentEvent="character",this.focusNextChildWithCharacter(e.key);else if(this.isTopLevel){if(this.focusState==="self")if(s==="Space"||s==="Enter")this.currentMenuItem.isSubmenuItem?(l(e),this.currentMenuItem.elements.childMenu.currentEvent="keyboard",this.currentMenuItem.elements.toggle.open(),requestAnimationFrame(()=>{this.currentMenuItem.elements.childMenu.focusFirstChild()})):this.currentMenuItem.dom.link.click();else if(s==="ArrowRight"){l(e);const m=this.currentMenuItem.isSubmenuItem&&this.currentMenuItem.elements.toggle.isOpen;this.focusNextChild(),m&&(this.currentMenuItem.isSubmenuItem?(this.currentMenuItem.elements.childMenu.currentEvent="keyboard",this.currentMenuItem.elements.toggle.preview()):this.closeChildren())}else if(s==="ArrowLeft"){l(e);const m=this.currentMenuItem.isSubmenuItem&&this.currentMenuItem.elements.toggle.isOpen;this.focusPreviousChild(),m&&(this.currentMenuItem.isSubmenuItem?(this.currentMenuItem.elements.childMenu.currentEvent="keyboard",this.currentMenuItem.elements.toggle.preview()):this.closeChildren())}else s==="ArrowDown"?this.currentMenuItem.isSubmenuItem&&(l(e),this.currentMenuItem.elements.childMenu.currentEvent="keyboard",this.currentMenuItem.elements.toggle.open(),requestAnimationFrame(()=>{this.currentMenuItem.elements.childMenu.focusFirstChild()})):s==="ArrowUp"?this.currentMenuItem.isSubmenuItem&&(l(e),this.currentMenuItem.elements.childMenu.currentEvent="keyboard",this.currentMenuItem.elements.toggle.open(),requestAnimationFrame(()=>{this.currentMenuItem.elements.childMenu.focusLastChild()})):s==="Home"?(l(e),this.focusFirstChild()):s==="End"?(l(e),this.focusLastChild()):s==="Escape"&&(this.elements.submenuToggles.some(c=>c.isOpen)?(l(e),this.closeChildren()):this.isTopLevel&&this.elements.controller&&this.elements.controller.isOpen&&(l(e),this.elements.controller.close(),this.focusController()))}else s==="Space"||s==="Enter"?this.currentMenuItem.isSubmenuItem?(l(e),this.currentMenuItem.elements.childMenu.currentEvent="keyboard",this.currentMenuItem.elements.toggle.open(),requestAnimationFrame(()=>{this.currentMenuItem.elements.childMenu.focusFirstChild()})):this.currentMenuItem.dom.link.click():s==="Escape"?(l(e),this.elements.rootMenu.closeChildren(),this.elements.rootMenu.focusCurrentChild()):s==="ArrowRight"?this.currentMenuItem.isSubmenuItem?(l(e),this.currentMenuItem.elements.childMenu.currentEvent="keyboard",this.currentMenuItem.elements.toggle.open(),requestAnimationFrame(()=>{this.currentMenuItem.elements.childMenu.focusFirstChild()})):(l(e),this.elements.rootMenu.closeChildren(),this.elements.rootMenu.focusNextChild(),this.elements.rootMenu.currentMenuItem.isSubmenuItem&&this.elements.rootMenu.currentMenuItem.elements.toggle.preview()):s==="ArrowLeft"?this.elements.parentMenu.currentMenuItem.isSubmenuItem&&(l(e),this.elements.parentMenu.currentMenuItem.elements.toggle.close(),this.elements.parentMenu.focusCurrentChild(),this.elements.parentMenu===this.elements.rootMenu&&(this.elements.rootMenu.closeChildren(),this.elements.rootMenu.focusPreviousChild(),this.elements.rootMenu.currentMenuItem.isSubmenuItem&&(this.elements.rootMenu.currentMenuItem.elements.childMenu.currentEvent="keyboard",this.elements.rootMenu.currentMenuItem.elements.toggle.preview()))):s==="ArrowDown"?(l(e),this.focusNextChild()):s==="ArrowUp"?(l(e),this.focusPreviousChild()):s==="Home"?(l(e),this.focusFirstChild()):s==="End"&&(l(e),this.focusLastChild())})}focusNextChild(){this.currentChild===this.elements.menuItems.length-1?this.focusFirstChild():this.focusChild(this.currentChild+1)}focusPreviousChild(){this.currentChild===0?this.focusLastChild():this.focusChild(this.currentChild-1)}focusNextChildWithCharacter(e){const s=e.toLowerCase();let n=this.currentChild+1,i=!1;for(;!i&&n<this.elements.menuItems.length;){let r="";this.elements.menuItems[n].dom.item.innerText?r=this.elements.menuItems[n].dom.item.innerText:r=this.elements.menuItems[n].dom.item.textContent,r=r.replace(/[\s]/g,"").toLowerCase().charAt(0),r===s&&(i=!0,this.focusChild(n)),n++}}}class se extends U{constructor({menuItemElement:t,menuLinkElement:e,parentMenu:s,isSubmenuItem:n=!1,childMenu:i=null,toggle:r=null,initialize:h=!0}){super({menuItemElement:t,menuLinkElement:e,parentMenu:s,isSubmenuItem:n,childMenu:i,toggle:r,initialize:!1}),h&&this.initialize()}}class ne extends B{constructor({menuToggleElement:e,parentElement:s,controlledMenu:n,parentMenu:i=null,initialize:r=!0}){super({menuToggleElement:e,parentElement:s,controlledMenu:n,parentMenu:i,initialize:!1});u(this,"_dom",{toggle:null,parent:null,container:null});this._dom.toggle=e,this._dom.parent=s,this._dom.container=n.isTopLevel?n.dom.container:n.dom.menu,r&&this.initialize()}initialize(){super.initialize(),this.dom.toggle.hasAttribute("data-bs-toggle")&&this.dom.toggle.removeAttribute("data-bs-toggle"),this.dom.toggle.hasAttribute("data-bs-target")&&this.dom.toggle.removeAttribute("data-bs-target")}_expand(e=!0){const{openClass:s,transitionClass:n}=this.elements.controlledMenu;this.dom.toggle.setAttribute("aria-expanded","true"),n!==""?(a(n,this.dom.container),requestAnimationFrame(()=>{a(s,this.dom.container),requestAnimationFrame(()=>{d(n,this.dom.container)})})):s!==""&&a(s,this.dom.container),e&&this.dom.toggle.dispatchEvent(this._expandEvent)}_collapse(e=!0){const{closeClass:s,openClass:n,transitionClass:i}=this.elements.controlledMenu;this.dom.toggle.setAttribute("aria-expanded","false"),i!==""?(a(i,this.dom.container),requestAnimationFrame(()=>{n!==""&&d(n,this.dom.container),requestAnimationFrame(()=>{s!==""&&a(s,this.dom.container),requestAnimationFrame(()=>{d(i,this.dom.container)})})})):(s!==""&&a(s,this.dom.container),n!==""&&d(n,this.dom.container)),e&&this.dom.toggle.dispatchEvent(this._collapseEvent)}}class K extends F{constructor({menuElement:e,menuItemSelector:s=".nav-item,li",menuLinkSelector:n=".nav-link,.dropdown-item",submenuItemSelector:i=".dropdown",submenuToggleSelector:r=".dropdown-toggle",submenuSelector:h=".dropdown-menu",controllerElement:m=null,containerElement:c=null,openClass:f="show",closeClass:p="collapse",transitionClass:g="transitioning",isTopLevel:M=!0,parentMenu:b=null,hoverType:y="off",hoverDelay:_=250,enterDelay:C=-1,leaveDelay:E=-1,initialize:T=!0}){super({menuElement:e,menuItemSelector:s,menuLinkSelector:n,submenuItemSelector:i,submenuToggleSelector:r,submenuSelector:h,controllerElement:m,containerElement:c,openClass:f,closeClass:p,transitionClass:g,isTopLevel:M,parentMenu:b,hoverType:y,hoverDelay:_,enterDelay:C,leaveDelay:E,initialize:!1});u(this,"_MenuType",K);u(this,"_MenuItemType",se);u(this,"_MenuToggleType",ne);T&&this.initialize()}}class W extends D{constructor({menuItemElement:e,menuLinkElement:s,parentMenu:n,isSubmenuItem:i=!1,childMenu:r=null,toggle:h=null,initialize:m=!0,submenuSibling:c=null}){super({menuItemElement:e,menuLinkElement:s,parentMenu:n,isSubmenuItem:i,childMenu:r,toggle:h});u(this,"_elements",{parentMenu:null,childMenu:null,toggle:null,sibling:null});this._elements.parentMenu=n,this._elements.childMenu=r,this._elements.toggle=h,this._elements.sibling=c,m&&this.initialize()}}class Z extends L{constructor({menuToggleElement:t,parentElement:e,controlledMenu:s,parentMenu:n=null,initialize:i=!0}){super({menuToggleElement:t,parentElement:e,controlledMenu:s,parentMenu:n}),i&&this.initialize()}open(){this.closeSiblings(),super.open()}preview(){this.closeSiblings(),super.preview()}close(){this.isOpen&&this.closeChildren(),super.close()}}class q extends S{constructor({menuElement:e,menuItemSelector:s="li",menuLinkSelector:n="a",submenuItemSelector:i="",submenuToggleSelector:r="button",submenuSelector:h="ul",submenuSubtoggleSelector:m="a",controllerElement:c=null,containerElement:f=null,openClass:p="show",closeClass:g="hide",transitionClass:M="transitioning",isTopLevel:b=!0,parentMenu:y=null,hoverType:_="off",hoverDelay:C=250,enterDelay:E=-1,leaveDelay:T=-1,optionalKeySupport:k=!1,initialize:j=!0}){super({menuElement:e,menuItemSelector:s,menuLinkSelector:n,submenuItemSelector:i,submenuSelector:h,submenuToggleSelector:r,controllerElement:c,containerElement:f,openClass:p,closeClass:g,transitionClass:M,isTopLevel:b,parentMenu:y,hoverType:_,hoverDelay:C,enterDelay:E,leaveDelay:T});u(this,"_MenuType",q);u(this,"_MenuItemType",W);u(this,"_MenuToggleType",Z);u(this,"_currentChild",-1);u(this,"_selectors",{menuItems:"",menuLinks:"",submenuItems:"",submenuToggles:"",submenus:"",submenuSubtoggles:""});u(this,"_optionalSupport",!1);this._optionalSupport=k,this._selectors.menuItems=s,this._selectors.submenuItems=i,this._selectors.submenuToggles=r,this._selectors.submenus=h,this._selectors.submenuSubtoggles=m,this._selectors.menuLinks=[...new Set([n,r])].join(","),j&&this.initialize()}initialize(){try{super.initialize(),this._handleFocus(),this._handleClick(),this._handleHover(),this._handleKeydown(),this._handleKeyup()}catch(e){console.error(e)}}get optionalKeySupport(){return this.isTopLevel?this._optionalSupport:this.elements.rootMenu.optionalKeySupport}set optionalKeySupport(e){I("boolean",{optionalKeySupport:e}),this._optionalSupport=e}_createChildElements(){this.dom.menuItems.forEach(e=>{let s,n;const i=e.querySelector(this.selectors.menuLinks);if(this.dom.submenuItems.includes(e)){const r=e.querySelector(this.selectors.submenuToggles),h=e.querySelector(this.selectors.submenus),m=new this._MenuType({menuElement:h,menuItemSelector:this.selectors.menuItems,menuLinkSelector:this.selectors.menuLinks,submenuItemSelector:this.selectors.submenuItems,submenuToggleSelector:this.selectors.submenuSubtoggles,submenuSelector:this.selectors.submenus,submenuSubtoggleSelector:this.selectors.submenuSubtoggles,openClass:this.openClass,closeClass:this.closeClass,isTopLevel:!1,parentMenu:this,hoverType:this.hoverType,hoverDelay:this.hoverDelay}),c=new this._MenuToggleType({menuToggleElement:r,parentElement:e,controlledMenu:m,parentMenu:this});this._elements.submenuToggles.push(c),r!==i?(n=new this._MenuItemType({menuItemElement:e,menuLinkElement:r,parentMenu:this,isSubmenuItem:!0,childMenu:m,toggle:c}),s=new this._MenuItemType({menuItemElement:e,menuLinkElement:i,parentMenu:this,submenuSibling:n})):s=new this._MenuItemType({menuItemElement:e,menuLinkElement:i,parentMenu:this,isSubmenuItem:!0,childMenu:m,toggle:c})}else s=new this._MenuItemType({menuItemElement:e,menuLinkElement:i,parentMenu:this});this._elements.menuItems.push(s),typeof n<"u"&&this._elements.menuItems.push(n)})}_validate(){let e=super._validate();const s=x({submenuSubtoggleSelector:this._selectors.submenuSubtoggles});s.status||(this._errors.push(s.error.message),e=!1);const n=I("boolean",{optionalKeySupport:this._optionalSupport});return n.status||(this._errors.push(n.error.message),e=!1),e}_handleClick(){super._handleClick(),document.addEventListener("pointerup",e=>{this.focusState!=="none"&&(this.currentEvent="mouse",!this.dom.menu.contains(e.target)&&!this.dom.menu!==e.target&&(this.closeChildren(),this.blur(),this.elements.controller&&this.elements.controller.close()))})}_handleHover(){this.elements.menuItems.forEach((e,s)=>{e.dom.link.addEventListener("pointerenter",n=>{if(!(n.pointerType==="pen"||n.pointerType==="touch")){if(this.hoverType==="on"){this.currentEvent="mouse",this.currentChild=s;let i=e.isSubmenuItem?e.elements.toggle:null;if(e.elements.sibling!==null&&(i=e.elements.sibling.elements.toggle),i===null)return;this.enterDelay>0?(clearTimeout(this._hoverTimeout),this._hoverTimeout=setTimeout(()=>{i.preview()},this.enterDelay)):i.preview()}else if(this.hoverType==="dynamic"){const i=this.elements.submenuToggles.some(r=>r.isOpen);if(this.currentChild=s,(!this.isTopLevel||this.focusState!=="none")&&(this.currentEvent="mouse",this.focusCurrentChild()),!this.isTopLevel||i){this.currentEvent="mouse";let r=e.isSubmenuItem?e.elements.toggle:null;if(e.elements.sibling!==null&&(r=e.elements.sibling.elements.toggle),r===null)return;this.enterDelay>0?(clearTimeout(this._hoverTimeout),this._hoverTimeout=setTimeout(()=>{r.preview()},this.enterDelay)):r.preview()}}}}),e.isSubmenuItem&&e.dom.item.addEventListener("pointerleave",n=>{n.pointerType==="pen"||n.pointerType==="touch"||(this.hoverType==="on"?this.leaveDelay>0?(clearTimeout(this._hoverTimeout),setTimeout(()=>{this.currentEvent="mouse",e.elements.toggle.close()},this.leaveDelay)):(this.currentEvent="mouse",e.elements.toggle.close()):this.hoverType==="dynamic"&&(this.isTopLevel||(this.leaveDelay>0?(clearTimeout(this._hoverTimeout),setTimeout(()=>{this.currentEvent="mouse",e.elements.toggle.close(),this.focusCurrentChild()},this.leaveDelay)):(this.currentEvent="mouse",e.elements.toggle.close(),this.focusCurrentChild()))))})})}_handleKeydown(){super._handleKeydown(),this.dom.menu.addEventListener("keydown",e=>{this.currentEvent="keyboard";const s=w(e);if(this.focusState==="self"){const n=["Space","Enter"],i=["Escape"],r=["Escape"];this.optionalKeySupport?["ArrowUp","ArrowRight","ArrowDown","ArrowLeft","Home","End"].includes(s)&&l(e):(this.currentMenuItem.isSubmenuItem&&n.includes(s)||this.elements.controller&&i.includes(s)||this.elements.parentMenu&&r.includes(s))&&l(e)}})}_handleKeyup(){super._handleKeyup(),this.dom.menu.addEventListener("keyup",e=>{this.currentEvent="keyboard";const s=w(e);this.focusState==="self"&&(s==="Space"||s==="Enter"?this.currentMenuItem.isSubmenuItem?(l(e),this.currentMenuItem.elements.toggle.isOpen?this.currentMenuItem.elements.toggle.close():this.currentMenuItem.elements.toggle.preview()):this.currentMenuItem.dom.link.click():s==="Escape"?this.elements.submenuToggles.some(i=>i.isOpen)?(l(e),this.closeChildren()):this.elements.parentMenu?(l(e),this.elements.parentMenu.currentEvent=this.currentEvent,this.elements.parentMenu.closeChildren(),this.elements.parentMenu.focusCurrentChild()):this.isTopLevel&&this.elements.controller&&this.elements.controller.isOpen&&(this.elements.controller.close(),this.focusController()):this.optionalKeySupport&&(s==="ArrowDown"||s==="ArrowRight"?(l(e),this.currentMenuItem.isSubmenuItem&&this.currentMenuItem.elements.toggle.isOpen?(this.currentMenuItem.elements.childMenu.currentEvent="keyboard",this.currentMenuItem.elements.childMenu.focusFirstChild()):this.focusNextChild()):s==="ArrowUp"||s==="ArrowLeft"?(l(e),this.focusPreviousChild()):s==="Home"?(l(e),this.focusFirstChild()):s==="End"&&(l(e),this.focusLastChild())))})}}class ie extends W{constructor({menuItemElement:t,menuLinkElement:e,parentMenu:s,isSubmenuItem:n=!1,childMenu:i=null,toggle:r=null,initialize:h=!0,submenuSibling:m=null}){super({menuItemElement:t,menuLinkElement:e,parentMenu:s,isSubmenuItem:n,childMenu:i,toggle:r,initialize:!1,submenuSibling:m}),h&&this.initialize()}}class re extends Z{constructor({menuToggleElement:e,parentElement:s,controlledMenu:n,parentMenu:i=null,initialize:r=!0}){super({menuToggleElement:e,parentElement:s,controlledMenu:n,parentMenu:i,initialize:!1});u(this,"_dom",{toggle:null,parent:null,container:null});this._dom.toggle=e,this._dom.parent=s,this._dom.container=n.isTopLevel?n.dom.container:n.dom.menu,r&&this.initialize()}initialize(){super.initialize(),this.dom.toggle.hasAttribute("data-bs-toggle")&&this.dom.toggle.removeAttribute("data-bs-toggle"),this.dom.toggle.hasAttribute("data-bs-target")&&this.dom.toggle.removeAttribute("data-bs-target")}_expand(e=!0){const{openClass:s,transitionClass:n}=this.elements.controlledMenu;this.dom.toggle.setAttribute("aria-expanded","true"),n!==""?(a(n,this.dom.container),requestAnimationFrame(()=>{a(s,this.dom.container),requestAnimationFrame(()=>{d(n,this.dom.container)})})):s!==""&&a(s,this.dom.container),e&&this.dom.toggle.dispatchEvent(this._expandEvent)}_collapse(e=!0){const{closeClass:s,openClass:n,transitionClass:i}=this.elements.controlledMenu;this.dom.toggle.setAttribute("aria-expanded","false"),i!==""?(a(i,this.dom.container),requestAnimationFrame(()=>{n!==""&&d(n,this.dom.container),requestAnimationFrame(()=>{s!==""&&a(s,this.dom.container),requestAnimationFrame(()=>{d(i,this.dom.container)})})})):(s!==""&&a(s,this.dom.container),n!==""&&d(n,this.dom.container)),e&&this.dom.toggle.dispatchEvent(this._collapseEvent)}}class $ extends q{constructor({menuElement:e,menuItemSelector:s=".nav-item,li",menuLinkSelector:n=".nav-link,.dropdown-item",submenuItemSelector:i=".dropdown",submenuToggleSelector:r=".dropdown-toggle",submenuSelector:h=".dropdown-menu",submenuSubtoggleSelector:m=".dropdown-toggle",controllerElement:c=null,containerElement:f=null,openClass:p="show",closeClass:g="collapse",transitionClass:M="transitioning",isTopLevel:b=!0,parentMenu:y=null,hoverType:_="off",hoverDelay:C=250,enterDelay:E=-1,leaveDelay:T=-1,optionalKeySupport:k=!1,initialize:j=!0}){super({menuElement:e,menuItemSelector:s,menuLinkSelector:n,submenuItemSelector:i,submenuToggleSelector:r,submenuSelector:h,submenuSubtoggleSelector:m,controllerElement:c,containerElement:f,openClass:p,closeClass:g,transitionClass:M,isTopLevel:b,parentMenu:y,hoverType:_,hoverDelay:C,enterDelay:E,leaveDelay:T,optionalKeySupport:k,initialize:!1});u(this,"_MenuType",$);u(this,"_MenuItemType",ie);u(this,"_MenuToggleType",re);j&&this.initialize()}}class G extends D{constructor({menuItemElement:t,menuLinkElement:e,parentMenu:s,isSubmenuItem:n=!1,childMenu:i=null,toggle:r=null,initialize:h=!0}){super({menuItemElement:t,menuLinkElement:e,parentMenu:s,isSubmenuItem:n,childMenu:i,toggle:r}),h&&this.initialize()}initialize(){super.initialize(),this.dom.item.setAttribute("role","none"),this.dom.link.setAttribute("role","treeitem"),this.dom.link.tabIndex=-1}focus(){super.focus(),this.dom.link.tabIndex=0}blur(){super.blur(),this.dom.link.tabIndex=-1}}class J extends L{constructor({menuToggleElement:t,parentElement:e,controlledMenu:s,parentMenu:n=null,initialize:i=!0}){super({menuToggleElement:t,parentElement:e,controlledMenu:s,parentMenu:n}),i&&this.initialize()}}class H extends S{constructor({menuElement:e,menuItemSelector:s="li",menuLinkSelector:n="a",submenuItemSelector:i="",submenuToggleSelector:r="a",submenuSelector:h="ul",controllerElement:m=null,containerElement:c=null,openClass:f="show",closeClass:p="hide",transitionClass:g="transitioning",isTopLevel:M=!0,parentMenu:b=null,hoverType:y="off",hoverDelay:_=250,enterDelay:C=-1,leaveDelay:E=-1,initialize:T=!0}){super({menuElement:e,menuItemSelector:s,menuLinkSelector:n,submenuItemSelector:i,submenuToggleSelector:r,submenuSelector:h,controllerElement:m,containerElement:c,openClass:f,closeClass:p,transitionClass:g,isTopLevel:M,parentMenu:b,hoverType:y,hoverDelay:_,enterDelay:C,leaveDelay:E});u(this,"_MenuType",H);u(this,"_MenuItemType",G);u(this,"_MenuToggleType",J);T&&this.initialize()}initialize(){try{super.initialize(),this.isTopLevel?(this.dom.menu.setAttribute("role","tree"),this.elements.menuItems[0].dom.link.tabIndex=0):this.dom.menu.setAttribute("role","group"),this._handleFocus(),this._handleClick(),this._handleHover(),this._handleKeydown(),this._handleKeyup()}catch(e){console.error(e)}}_handleKeydown(){super._handleKeydown(),this.dom.menu.addEventListener("keydown",e=>{this.currentEvent="keyboard";const s=w(e);if(s==="Tab"&&(this.elements.rootMenu.focusState!=="none"?this.elements.rootMenu.blur():this.elements.rootMenu.focus()),this.focusState==="self"){const n=["Space","ArrowUp","ArrowDown","ArrowLeft","Asterisk","Home","End"],i=["Enter","ArrowRight"],r=["Escape"];(n.includes(s)||this.currentMenuItem.isSubmenuItem&&i.includes(s)||this.elements.controller&&r.includes(s))&&l(e)}})}_handleKeyup(){super._handleKeyup(),this.dom.menu.addEventListener("keyup",e=>{this.currentEvent="keyboard";const s=w(e),{altKey:n,crtlKey:i,metaKey:r}=e;if(s==="Character"&&!(n||i||r))l(e),this.elements.rootMenu.currentEvent="character",this.focusNextNodeWithCharacter(e.key);else if(this.focusState==="self")if(s==="Enter"||s==="Space")l(e),this.currentMenuItem.isSubmenuItem?this.currentMenuItem.elements.toggle.isOpen?this.currentMenuItem.elements.toggle.close():this.currentMenuItem.elements.toggle.preview():this.currentMenuItem.dom.link.click();else if(s==="Escape")this.isTopLevel&&this.elements.controller&&this.elements.controller.isOpen&&(this.elements.controller.close(),this.focusController());else if(s==="ArrowDown")l(e),this.currentMenuItem.isSubmenuItem&&this.currentMenuItem.elements.toggle.isOpen?(this.blurCurrentChild(),this.currentMenuItem.elements.childMenu.currentEvent=this.currentEvent,this.currentMenuItem.elements.childMenu.focusFirstChild()):!this.isTopLevel&&this.currentChild===this.elements.menuItems.length-1?this.focusParentsNextChild():this.focusNextChild();else if(s==="ArrowUp"){l(e);const m=this.elements.menuItems[this.currentChild-1];m&&m.isSubmenuItem&&m.elements.toggle.isOpen?(this.blurCurrentChild(),this.currentChild=this.currentChild-1,this.currentMenuItem.elements.childMenu.currentEvent=this.currentEvent,this.focusChildsLastNode()):!this.isTopLevel&&this.currentChild===0?(this.blurCurrentChild(),this.elements.parentMenu.currentEvent=this.currentEvent,this.elements.parentMenu.focusCurrentChild()):this.focusPreviousChild()}else s==="ArrowRight"?this.currentMenuItem.isSubmenuItem&&(l(e),this.currentMenuItem.elements.toggle.isOpen?(this.blurCurrentChild(),this.currentMenuItem.elements.childMenu.currentEvent=this.currentEvent,this.currentMenuItem.elements.childMenu.focusFirstChild()):this.currentMenuItem.elements.toggle.preview()):s==="ArrowLeft"?(l(e),this.currentMenuItem.isSubmenuItem&&this.currentMenuItem.elements.toggle.isOpen?(this.currentMenuItem.elements.childMenu.blurCurrentChild(),this.currentMenuItem.elements.toggle.close()):this.isTopLevel||(this.blurCurrentChild(),this.elements.parentMenu.currentEvent=this.currentEvent,this.elements.parentMenu.focusCurrentChild())):s==="Home"?(l(e),this.blurCurrentChild(),this.elements.rootMenu.focusFirstChild()):s==="End"?(l(e),this.blurCurrentChild(),this.elements.rootMenu.focusLastNode()):s==="Asterisk"&&(l(e),this.openChildren())})}focusLastNode(){const e=this.elements.menuItems.length-1,s=this.elements.menuItems[e];s.isSubmenuItem&&s.elements.toggle.isOpen?(this.currentChild=e,s.elements.childMenu.currentEvent=this.currentEvent,s.elements.childMenu.focusLastNode()):this.focusLastChild()}openChildren(){this.elements.submenuToggles.forEach(e=>e.preview())}focusNextNodeWithCharacter(e){function s(f){let p=[];return f.elements.menuItems.forEach(g=>{p.push(g),g.isSubmenuItem&&g.elements.toggle.isOpen&&(p=[...p,...s(g.elements.toggle.elements.controlledMenu)])}),p}const n=e.toLowerCase(),i=s(this.elements.rootMenu),r=i.indexOf(this.currentMenuItem)+1,h=[...i.slice(r),...i.slice(0,r)];let m=0,c=!1;for(;!c&&m<h.length;){let f="";if(h[m].dom.item.innerText?f=h[m].dom.item.innerText:f=h[m].dom.item.textContent,f=f.replace(/[\s]/g,"").toLowerCase().charAt(0),f===n){c=!0;const p=h[m].elements.parentMenu,g=p.elements.menuItems.indexOf(h[m]);this.elements.rootMenu.blurChildren(),p.focusChild(g)}m++}}focusParentsNextChild(){this.elements.parentMenu&&(this.elements.parentMenu.currentEvent=this.currentEvent,this.elements.parentMenu.currentChild===this.elements.parentMenu.elements.menuItems.length-1?(this.elements.parentMenu.blurCurrentChild(),this.elements.parentMenu.focusParentsNextChild()):(this.blurChildren(),this.elements.parentMenu.focusNextChild()))}focusChildsLastNode(){this.currentMenuItem.elements.childMenu.currentEvent=this.currentEvent,this.currentMenuItem.elements.childMenu.focusLastChild(),this.currentMenuItem.elements.childMenu.currentMenuItem.isSubmenuItem&&this.currentMenuItem.elements.childMenu.currentMenuItem.elements.toggle.isOpen&&(this.currentMenuItem.elements.childMenu.blurCurrentChild(),this.currentMenuItem.elements.childMenu.focusChildsLastNode())}}class oe extends G{constructor({menuItemElement:t,menuLinkElement:e,parentMenu:s,isSubmenuItem:n=!1,childMenu:i=null,toggle:r=null,initialize:h=!0}){super({menuItemElement:t,menuLinkElement:e,parentMenu:s,isSubmenuItem:n,childMenu:i,toggle:r,initialize:!1}),h&&this.initialize()}}class le extends J{constructor({menuToggleElement:e,parentElement:s,controlledMenu:n,parentMenu:i=null,initialize:r=!0}){super({menuToggleElement:e,parentElement:s,controlledMenu:n,parentMenu:i,initialize:!1});u(this,"_dom",{toggle:null,parent:null,container:null});this._dom.toggle=e,this._dom.parent=s,this._dom.container=n.isTopLevel?n.dom.container:n.dom.menu,r&&this.initialize()}initialize(){super.initialize(),this.dom.toggle.hasAttribute("data-bs-toggle")&&this.dom.toggle.removeAttribute("data-bs-toggle"),this.dom.toggle.hasAttribute("data-bs-target")&&this.dom.toggle.removeAttribute("data-bs-target")}_expand(e=!0){const{openClass:s,transitionClass:n}=this.elements.controlledMenu;this.dom.toggle.setAttribute("aria-expanded","true"),n!==""?(a(n,this.dom.container),requestAnimationFrame(()=>{a(s,this.dom.container),requestAnimationFrame(()=>{d(n,this.dom.container)})})):s!==""&&a(s,this.dom.container),e&&this.dom.toggle.dispatchEvent(this._expandEvent)}_collapse(e=!0){const{closeClass:s,openClass:n,transitionClass:i}=this.elements.controlledMenu;this.dom.toggle.setAttribute("aria-expanded","false"),i!==""?(a(i,this.dom.container),requestAnimationFrame(()=>{n!==""&&d(n,this.dom.container),requestAnimationFrame(()=>{s!==""&&a(s,this.dom.container),requestAnimationFrame(()=>{d(i,this.dom.container)})})})):(s!==""&&a(s,this.dom.container),n!==""&&d(n,this.dom.container)),e&&this.dom.toggle.dispatchEvent(this._collapseEvent)}}class N extends H{constructor({menuElement:e,menuItemSelector:s=".nav-item,li",menuLinkSelector:n=".nav-link,.dropdown-item",submenuItemSelector:i=".dropdown",submenuToggleSelector:r=".dropdown-toggle",submenuSelector:h=".dropdown-menu",controllerElement:m=null,containerElement:c=null,openClass:f="show",closeClass:p="collapse",transitionClass:g="transitioning",isTopLevel:M=!0,parentMenu:b=null,hoverType:y="off",hoverDelay:_=250,enterDelay:C=-1,leaveDelay:E=-1,initialize:T=!0}){super({menuElement:e,menuItemSelector:s,menuLinkSelector:n,submenuItemSelector:i,submenuToggleSelector:r,submenuSelector:h,controllerElement:m,containerElement:c,openClass:f,closeClass:p,transitionClass:g,isTopLevel:M,parentMenu:b,hoverType:y,hoverDelay:_,enterDelay:C,leaveDelay:E,initialize:!1});u(this,"_MenuType",N);u(this,"_MenuItemType",oe);u(this,"_MenuToggleType",le);T&&this.initialize()}}return{Bootstrap5DisclosureMenu:O,Bootstrap5Menubar:K,Bootstrap5TopLinkDisclosureMenu:$,Bootstrap5Treeview:N}}(); | ||
- `)}`);if(this.elements.rootMenu===null&&this._findRootMenu(this),this._setDOMElements(),this.isTopLevel&&this.dom.controller&&this.dom.container){const t=new this._MenuToggleType({menuToggleElement:this.dom.controller,parentElement:this.dom.container,controlledMenu:this});this._elements.controller=t}this._createChildElements()}get dom(){return this._dom}get selectors(){return this._selectors}get elements(){return this._elements}get isTopLevel(){return this._root}get openClass(){return this.isTopLevel?this._openClass:this.elements.rootMenu.openClass}get closeClass(){return this.isTopLevel?this._closeClass:this.elements.rootMenu.closeClass}get transitionClass(){return this.isTopLevel?this._transitionClass:this.elements.rootMenu.transitionClass}get currentChild(){return this._currentChild}get focusState(){return this._focusState}get currentEvent(){return this._currentEvent}get currentMenuItem(){return this.elements.menuItems[this.currentChild]}get hoverType(){return this._root?this._hoverType:this.elements.rootMenu.hoverType}get hoverDelay(){return this._root?this._hoverDelay:this.elements.rootMenu.hoverDelay}get enterDelay(){return this._enterDelay===-1?this.hoverDelay:this._root?this._enterDelay:this.elements.rootMenu.enterDelay}get leaveDelay(){return this._leaveDelay===-1?this.hoverDelay:this._root?this._leaveDelay:this.elements.rootMenu.leaveDelay}get shouldFocus(){let t=!1;return(this.currentEvent==="keyboard"||this.currentEvent==="character")&&(t=!0),this.currentEvent==="mouse"&&this.hoverType==="dynamic"&&(t=!0),t}get errors(){return this._errors}set openClass(t){A({openClass:t}),this._openClass!==t&&(this._openClass=t)}set closeClass(t){A({closeClass:t}),this._closeClass!==t&&(this._closeClass=t)}set transitionClass(t){A({transitionClass:t}),this._transitionClass!==t&&(this._transitionClass=t)}set currentChild(t){v("number",{value:t});function e(s){if(["mouse","character"].includes(s.currentEvent)&&s.elements.parentMenu){let i=0,r=!1;for(;!r&&i<s.elements.parentMenu.elements.menuItems.length;){const h=s.elements.parentMenu.elements.menuItems[i];h.isSubmenuItem&&h.elements.toggle.elements.controlledMenu===s&&(r=!0,s.elements.parentMenu.currentEvent=s.currentEvent,s.elements.parentMenu.currentChild=i),i++}}}t<-1?(this._currentChild=-1,e(this)):t>=this.elements.menuItems.length?(this._currentChild=this.elements.menuItems.length-1,e(this)):this.focusChild!==t&&(this._currentChild=t,e(this))}set focusState(t){Q({value:t}),this._focusState!==t&&(this._focusState=t),this.elements.submenuToggles.length>0&&(t==="self"||t==="none")&&this.elements.submenuToggles.forEach(e=>{e.elements.controlledMenu.focusState="none"}),this.elements.parentMenu&&(t==="self"||t==="child")&&(this.elements.parentMenu.focusState="child")}set currentEvent(t){X({value:t}),this._currentEvent!==t&&(this._currentEvent=t,this.elements.submenuToggles.length>0&&this.elements.submenuToggles.forEach(e=>{e.elements.controlledMenu.currentEvent=t}))}set hoverType(t){V({value:t}),this._hoverType!==t&&(this._hoverType=t)}set hoverDelay(t){v("number",{value:t}),this._hoverDelay!==t&&(this._hoverDelay=t)}set enterDelay(t){v("number",{value:t}),this._enterDelay!==t&&(this._enterDelay=t)}set leaveDelay(t){v("number",{value:t}),this._leaveDelay!==t&&(this._leaveDelay=t)}_validate(){let t=!0,e;this._dom.container!==null||this._dom.controller!==null?e=I(HTMLElement,{menuElement:this._dom.menu,controllerElement:this._dom.controller,containerElement:this._dom.container}):e=I(HTMLElement,{menuElement:this._dom.menu}),e.status||(this._errors.push(e.error.message),t=!1);let s;if(this._selectors.submenuItems!==""?s=x({menuItemSelector:this._selectors.menuItems,menuLinkSelector:this._selectors.menuLinks,submenuItemSelector:this._selectors.submenuItems,submenuToggleSelector:this._selectors.submenuToggles,submenuSelector:this._selectors.submenus}):s=x({menuItemSelector:this._selectors.menuItems,menuLinkSelector:this._selectors.menuLinks}),s.status||(this._errors.push(s.error.message),t=!1),this._openClass!==""){const c=A({openClass:this._openClass});c.status||(this._errors.push(c.error.message),t=!1)}if(this._closeClass!==""){const c=A({closeClass:this._closeClass});c.status||(this._errors.push(c.error.message),t=!1)}if(this._transitionClass!==""){const c=A({transitionClass:this._transitionClass});c.status||(this._errors.push(c.error.message),t=!1)}const n=v("boolean",{isTopLevel:this._root});if(n.status||(this._errors.push(n.error.message),t=!1),this._elements.parentMenu!==null){const c=I(S,{parentMenu:this._elements.parentMenu});c.status||(this._errors.push(c.error.message),t=!1)}const i=V({hoverType:this._hoverType});i.status||(this._errors.push(i.error.message),t=!1);const r=v("number",{hoverDelay:this._hoverDelay});r.status||(this._errors.push(r.error.message),t=!1);const h=v("number",{enterDelay:this._enterDelay});h.status||(this._errors.push(h.error.message),t=!1);const m=v("number",{leaveDelay:this._leaveDelay});return m.status||(this._errors.push(m.error.message),t=!1),t}_setDOMElementType(t,e=this.dom.menu,s=!0){if(typeof this.selectors[t]=="string"){if(!Array.isArray(this.dom[t]))throw new Error(`AccessibleMenu: The "${t}" element cannot be set through _setDOMElementType.`);e!==this.dom.menu&&I(HTMLElement,{base:e});const i=Array.from(e.querySelectorAll(this.selectors[t])).filter(r=>r.parentElement===e);s?this._dom[t]=i:this._dom[t]=[...this._dom[t],...i]}else throw new Error(`AccessibleMenu: "${t}" is not a valid element type within the menu.`)}_resetDOMElementType(t){if(typeof this.dom[t]<"u"){if(!Array.isArray(this.dom[t]))throw new Error(`AccessibleMenu: The "${t}" element cannot be reset through _resetDOMElementType.`);this._dom[t]=[]}else throw new Error(`AccessibleMenu: "${t}" is not a valid element type within the menu.`)}_setDOMElements(){this._setDOMElementType("menuItems"),this.selectors.submenuItems!==""&&(this._setDOMElementType("submenuItems"),this._resetDOMElementType("submenuToggles"),this._resetDOMElementType("submenus"),this.dom.submenuItems.forEach(t=>{this._setDOMElementType("submenuToggles",t,!1),this._setDOMElementType("submenus",t,!1)}))}_findRootMenu(t){if(t.isTopLevel)this._elements.rootMenu=t;else if(t.elements.parentMenu!==null)this._findRootMenu(t.elements.parentMenu);else throw new Error("Cannot find root menu.")}_createChildElements(){this.dom.menuItems.forEach(t=>{let e;if(this.dom.submenuItems.includes(t)){const s=t.querySelector(this.selectors.submenuToggles),n=t.querySelector(this.selectors.submenus),i=new this._MenuType({menuElement:n,menuItemSelector:this.selectors.menuItems,menuLinkSelector:this.selectors.menuLinks,submenuItemSelector:this.selectors.submenuItems,submenuToggleSelector:this.selectors.submenuToggles,submenuSelector:this.selectors.submenus,openClass:this.openClass,closeClass:this.closeClass,transitionClass:this.transitionClass,isTopLevel:!1,parentMenu:this,hoverType:this.hoverType,hoverDelay:this.hoverDelay,enterDelay:this.enterDelay,leaveDelay:this.leaveDelay}),r=new this._MenuToggleType({menuToggleElement:s,parentElement:t,controlledMenu:i,parentMenu:this});this._elements.submenuToggles.push(r),e=new this._MenuItemType({menuItemElement:t,menuLinkElement:s,parentMenu:this,isSubmenuItem:!0,childMenu:i,toggle:r})}else{const s=t.querySelector(this.selectors.menuLinks);e=new this._MenuItemType({menuItemElement:t,menuLinkElement:s,parentMenu:this})}this._elements.menuItems.push(e)})}_handleFocus(){this.elements.menuItems.forEach((t,e)=>{t.dom.link.addEventListener("focus",()=>{this.focusState="self",this.currentChild=e})})}_handleClick(){function t(e,s,n){l(n),s.toggle(),s.isOpen&&(e.focusState="self",s.elements.controlledMenu.focusState="none")}this.elements.menuItems.forEach((e,s)=>{e.dom.link.addEventListener("pointerdown",()=>{this.currentEvent="mouse",this.elements.rootMenu.blurChildren(),this.focusChild(s)},{passive:!0}),e.isSubmenuItem&&e.elements.toggle.dom.toggle.addEventListener("pointerup",n=>{this.currentEvent="mouse",t(this,e.elements.toggle,n)})}),this.isTopLevel&&this.elements.controller&&this.elements.controller.dom.toggle.addEventListener("pointerup",e=>{this.currentEvent="mouse",t(this,this.elements.controller,e)})}_handleHover(){this.elements.menuItems.forEach((t,e)=>{t.dom.link.addEventListener("pointerenter",s=>{if(!(s.pointerType==="pen"||s.pointerType==="touch")){if(this.hoverType==="on")this.currentEvent="mouse",this.elements.rootMenu.blurChildren(),this.focusChild(e),t.isSubmenuItem&&(this.enterDelay>0?this._hoverTimeout=setTimeout(()=>{t.elements.toggle.preview()},this.enterDelay):t.elements.toggle.preview());else if(this.hoverType==="dynamic"){const n=this.elements.submenuToggles.some(i=>i.isOpen);this.currentChild=e,(!this.isTopLevel||this.focusState!=="none")&&(this.currentEvent="mouse",this.elements.rootMenu.blurChildren(),this.focusCurrentChild()),t.isSubmenuItem&&(!this.isTopLevel||n)&&(this.currentEvent="mouse",this.elements.rootMenu.blurChildren(),this.focusCurrentChild(),this.enterDelay>0?this._hoverTimeout=setTimeout(()=>{t.elements.toggle.preview()},this.enterDelay):t.elements.toggle.preview())}}}),t.isSubmenuItem&&t.dom.item.addEventListener("pointerleave",s=>{s.pointerType==="pen"||s.pointerType==="touch"||(this.hoverType==="on"?this.leaveDelay>0?(clearTimeout(this._hoverTimeout),setTimeout(()=>{this.currentEvent="mouse",t.elements.toggle.close()},this.leaveDelay)):(this.currentEvent="mouse",t.elements.toggle.close()):this.hoverType==="dynamic"&&(this.isTopLevel||(this.leaveDelay>0?(clearTimeout(this._hoverTimeout),setTimeout(()=>{this.currentEvent="mouse",t.elements.toggle.close(),this.focusCurrentChild()},this.leaveDelay)):(this.currentEvent="mouse",t.elements.toggle.close(),this.focusCurrentChild()))))})})}_handleKeydown(){this.isTopLevel&&this.elements.controller&&this.elements.controller.dom.toggle.addEventListener("keydown",t=>{this.currentEvent="keyboard";const e=w(t);(e==="Space"||e==="Enter")&&l(t)})}_handleKeyup(){this.isTopLevel&&this.elements.controller&&this.elements.controller.dom.toggle.addEventListener("keyup",t=>{this.currentEvent="keyboard";const e=w(t);(e==="Space"||e==="Enter")&&(l(t),this.elements.controller.toggle(),this.elements.controller.isOpen&&this.focusFirstChild())})}focus(){this.focusState="self",this.shouldFocus&&this.dom.menu.focus()}blur(){this.focusState="none",this.shouldFocus&&this.dom.menu.blur()}focusCurrentChild(){this.focusState="self",this.currentChild!==-1&&this.currentMenuItem.focus()}focusChild(t){this.blurCurrentChild(),this.currentChild=t,this.focusCurrentChild()}focusFirstChild(){this.focusChild(0)}focusLastChild(){this.focusChild(this.elements.menuItems.length-1)}focusNextChild(){this.currentChild<this.elements.menuItems.length-1?this.focusChild(this.currentChild+1):this.focusCurrentChild()}focusPreviousChild(){this.currentChild>0?this.focusChild(this.currentChild-1):this.focusCurrentChild()}blurCurrentChild(){this.focusState="none",this.currentChild!==-1&&this.currentMenuItem.blur()}focusController(){this.dom.controller&&(this.shouldFocus&&this.dom.controller.focus(),this.focusState="none")}focusContainer(){this.dom.container&&(this.shouldFocus&&this.dom.container.focus(),this.focusState="none")}closeChildren(){this.elements.submenuToggles.forEach(t=>t.close())}blurChildren(){this.elements.menuItems.forEach(t=>{t.blur(),t.isSubmenuItem&&t.elements.childMenu.blurChildren()})}}class R extends D{constructor({menuItemElement:t,menuLinkElement:e,parentMenu:s,isSubmenuItem:n=!1,childMenu:i=null,toggle:r=null,initialize:h=!0}){super({menuItemElement:t,menuLinkElement:e,parentMenu:s,isSubmenuItem:n,childMenu:i,toggle:r}),h&&this.initialize()}}class P extends L{constructor({menuToggleElement:t,parentElement:e,controlledMenu:s,parentMenu:n=null,initialize:i=!0}){super({menuToggleElement:t,parentElement:e,controlledMenu:s,parentMenu:n}),i&&this.initialize()}open(){this.closeSiblings(),super.open()}preview(){this.closeSiblings(),super.preview()}close(){this.isOpen&&this.closeChildren(),super.close()}}class z extends S{constructor({menuElement:e,menuItemSelector:s="li",menuLinkSelector:n="a",submenuItemSelector:i="",submenuToggleSelector:r="a",submenuSelector:h="ul",controllerElement:m=null,containerElement:c=null,openClass:f="show",closeClass:p="hide",transitionClass:g="transitioning",isTopLevel:M=!0,parentMenu:y=null,hoverType:b="off",hoverDelay:C=250,enterDelay:_=-1,leaveDelay:E=-1,optionalKeySupport:T=!1,initialize:k=!0}){super({menuElement:e,menuItemSelector:s,menuLinkSelector:n,submenuItemSelector:i,submenuToggleSelector:r,submenuSelector:h,controllerElement:m,containerElement:c,openClass:f,closeClass:p,transitionClass:g,isTopLevel:M,parentMenu:y,hoverType:b,hoverDelay:C,enterDelay:_,leaveDelay:E});u(this,"_MenuType",z);u(this,"_MenuItemType",R);u(this,"_MenuToggleType",P);u(this,"_currentChild",-1);u(this,"_optionalSupport",!1);this._optionalSupport=T,k&&this.initialize()}initialize(){try{super.initialize(),this._handleFocus(),this._handleClick(),this._handleHover(),this._handleKeydown(),this._handleKeyup()}catch(e){console.error(e)}}get optionalKeySupport(){return this.isTopLevel?this._optionalSupport:this.elements.rootMenu.optionalKeySupport}set optionalKeySupport(e){v("boolean",{optionalKeySupport:e}),this._optionalSupport=e}_validate(){let e=super._validate();const s=v("boolean",{optionalKeySupport:this._optionalSupport});return s.status||(this._errors.push(s.error.message),e=!1),e}_handleClick(){super._handleClick(),document.addEventListener("pointerup",e=>{this.focusState!=="none"&&(this.currentEvent="mouse",!this.dom.menu.contains(e.target)&&!this.dom.menu!==e.target&&(this.closeChildren(),this.blur(),this.elements.controller&&this.elements.controller.close()))})}_handleKeydown(){super._handleKeydown(),this.dom.menu.addEventListener("keydown",e=>{this.currentEvent="keyboard";const s=w(e);if(this.focusState==="self"){const n=["Space","Enter"],i=["Escape"],r=["Escape"];this.optionalKeySupport?["ArrowUp","ArrowRight","ArrowDown","ArrowLeft","Home","End"].includes(s)&&l(e):(this.currentMenuItem.isSubmenuItem&&n.includes(s)||this.elements.controller&&i.includes(s)||this.elements.parentMenu&&r.includes(s))&&l(e)}})}_handleKeyup(){super._handleKeyup(),this.dom.menu.addEventListener("keyup",e=>{this.currentEvent="keyboard";const s=w(e);this.focusState==="self"&&(s==="Space"||s==="Enter"?this.currentMenuItem.isSubmenuItem?(l(e),this.currentMenuItem.elements.toggle.isOpen?this.currentMenuItem.elements.toggle.close():this.currentMenuItem.elements.toggle.preview()):this.currentMenuItem.dom.link.click():s==="Escape"?this.elements.submenuToggles.some(i=>i.isOpen)?(l(e),this.closeChildren()):this.elements.parentMenu?(l(e),this.elements.parentMenu.currentEvent=this.currentEvent,this.elements.parentMenu.closeChildren(),this.elements.parentMenu.focusCurrentChild()):this.isTopLevel&&this.elements.controller&&this.elements.controller.isOpen&&(this.elements.controller.close(),this.focusController()):this.optionalKeySupport&&(s==="ArrowDown"||s==="ArrowRight"?(l(e),this.currentMenuItem.isSubmenuItem&&this.currentMenuItem.elements.toggle.isOpen?(this.currentMenuItem.elements.childMenu.currentEvent="keyboard",this.currentMenuItem.elements.childMenu.focusFirstChild()):this.focusNextChild()):s==="ArrowUp"||s==="ArrowLeft"?(l(e),this.focusPreviousChild()):s==="Home"?(l(e),this.focusFirstChild()):s==="End"&&(l(e),this.focusLastChild())))})}}class ee extends R{constructor({menuItemElement:t,menuLinkElement:e,parentMenu:s,isSubmenuItem:n=!1,childMenu:i=null,toggle:r=null,initialize:h=!0}){super({menuItemElement:t,menuLinkElement:e,parentMenu:s,isSubmenuItem:n,childMenu:i,toggle:r,initialize:!1}),h&&this.initialize()}}class te extends P{constructor({menuToggleElement:e,parentElement:s,controlledMenu:n,parentMenu:i=null,initialize:r=!0}){super({menuToggleElement:e,parentElement:s,controlledMenu:n,parentMenu:i,initialize:!1});u(this,"_dom",{toggle:null,parent:null,container:null});this._dom.toggle=e,this._dom.parent=s,this._dom.container=n.isTopLevel?n.dom.container:n.dom.menu,r&&this.initialize()}initialize(){super.initialize(),this.dom.toggle.hasAttribute("data-bs-toggle")&&this.dom.toggle.removeAttribute("data-bs-toggle"),this.dom.toggle.hasAttribute("data-bs-target")&&this.dom.toggle.removeAttribute("data-bs-target")}_expand(e=!0){const{openClass:s,transitionClass:n}=this.elements.controlledMenu;this.dom.toggle.setAttribute("aria-expanded","true"),n!==""?(a(n,this.dom.container),requestAnimationFrame(()=>{a(s,this.dom.container),requestAnimationFrame(()=>{d(n,this.dom.container)})})):s!==""&&a(s,this.dom.container),e&&this.dom.toggle.dispatchEvent(this._expandEvent)}_collapse(e=!0){const{closeClass:s,openClass:n,transitionClass:i}=this.elements.controlledMenu;this.dom.toggle.setAttribute("aria-expanded","false"),i!==""?(a(i,this.dom.container),requestAnimationFrame(()=>{n!==""&&d(n,this.dom.container),requestAnimationFrame(()=>{s!==""&&a(s,this.dom.container),requestAnimationFrame(()=>{d(i,this.dom.container)})})})):(s!==""&&a(s,this.dom.container),n!==""&&d(n,this.dom.container)),e&&this.dom.toggle.dispatchEvent(this._collapseEvent)}}class O extends z{constructor({menuElement:e,menuItemSelector:s=".nav-item,li",menuLinkSelector:n=".nav-link,.dropdown-item",submenuItemSelector:i=".dropdown",submenuToggleSelector:r=".dropdown-toggle",submenuSelector:h=".dropdown-menu",controllerElement:m=null,containerElement:c=null,openClass:f="show",closeClass:p="collapse",transitionClass:g="transitioning",isTopLevel:M=!0,parentMenu:y=null,hoverType:b="off",hoverDelay:C=250,enterDelay:_=-1,leaveDelay:E=-1,optionalKeySupport:T=!1,initialize:k=!0}){super({menuElement:e,menuItemSelector:s,menuLinkSelector:n,submenuItemSelector:i,submenuToggleSelector:r,submenuSelector:h,controllerElement:m,containerElement:c,openClass:f,closeClass:p,transitionClass:g,isTopLevel:M,parentMenu:y,hoverType:b,hoverDelay:C,enterDelay:_,leaveDelay:E,optionalKeySupport:T,initialize:!1});u(this,"_MenuType",O);u(this,"_MenuItemType",ee);u(this,"_MenuToggleType",te);k&&this.initialize()}}class U extends D{constructor({menuItemElement:t,menuLinkElement:e,parentMenu:s,isSubmenuItem:n=!1,childMenu:i=null,toggle:r=null,initialize:h=!0}){super({menuItemElement:t,menuLinkElement:e,parentMenu:s,isSubmenuItem:n,childMenu:i,toggle:r}),h&&this.initialize()}initialize(){super.initialize(),this.dom.item.setAttribute("role","none"),this.dom.link.setAttribute("role","menuitem"),this.dom.link.tabIndex=-1}focus(){super.focus(),this.elements.parentMenu.isTopLevel&&(this.dom.link.tabIndex=0)}blur(){super.blur(),this.elements.parentMenu.isTopLevel&&(this.dom.link.tabIndex=-1)}}class B extends L{constructor({menuToggleElement:t,parentElement:e,controlledMenu:s,parentMenu:n=null,initialize:i=!0}){super({menuToggleElement:t,parentElement:e,controlledMenu:s,parentMenu:n}),i&&this.initialize()}open(){this.closeSiblings(),super.open()}preview(){this.closeSiblings(),super.preview()}close(){this.isOpen&&(this.closeChildren(),this.elements.parentMenu&&this.elements.parentMenu.focusCurrentChild()),super.close()}}class F extends S{constructor({menuElement:e,menuItemSelector:s="li",menuLinkSelector:n="a",submenuItemSelector:i="",submenuToggleSelector:r="a",submenuSelector:h="ul",controllerElement:m=null,containerElement:c=null,openClass:f="show",closeClass:p="hide",transitionClass:g="transitioning",isTopLevel:M=!0,parentMenu:y=null,hoverType:b="off",hoverDelay:C=250,enterDelay:_=-1,leaveDelay:E=-1,initialize:T=!0}){super({menuElement:e,menuItemSelector:s,menuLinkSelector:n,submenuItemSelector:i,submenuToggleSelector:r,submenuSelector:h,controllerElement:m,containerElement:c,openClass:f,closeClass:p,transitionClass:g,isTopLevel:M,parentMenu:y,hoverType:b,hoverDelay:C,enterDelay:_,leaveDelay:E});u(this,"_MenuType",F);u(this,"_MenuItemType",U);u(this,"_MenuToggleType",B);T&&this.initialize()}initialize(){try{super.initialize(),this.isTopLevel?this.dom.menu.setAttribute("role","menubar"):this.dom.menu.setAttribute("role","menu"),this._handleFocus(),this._handleClick(),this._handleHover(),this._handleKeydown(),this._handleKeyup(),this.isTopLevel&&(this.elements.menuItems[0].dom.link.tabIndex=0)}catch(e){console.error(e)}}_handleClick(){super._handleClick(),document.addEventListener("pointerup",e=>{this.focusState!=="none"&&(this.currentEvent="mouse",!this.dom.menu.contains(e.target)&&!this.dom.menu!==e.target&&(this.closeChildren(),this.blur(),this.elements.controller&&this.elements.controller.close()))})}_handleKeydown(){super._handleKeydown(),this.dom.menu.addEventListener("keydown",e=>{this.currentEvent="keyboard";const s=w(e);if(s==="Tab"&&(this.elements.rootMenu.focusState!=="none"?(this.elements.rootMenu.blur(),this.elements.rootMenu.closeChildren()):this.elements.rootMenu.focus()),s==="Character")l(e);else if(this.isTopLevel){if(this.focusState==="self"){const n=["ArrowRight","ArrowLeft","Home","End"],i=["Space","Enter","ArrowDown","ArrowUp"],r=["Escape"];(n.includes(s)||this.currentMenuItem.isSubmenuItem&&i.includes(s)||this.elements.controller&&r.includes(s))&&l(e)}}else{const n=["Escape","ArrowRight","ArrowLeft","ArrowDown","ArrowUp","Home","End"],i=["Space","Enter"];(n.includes(s)||this.currentMenuItem.isSubmenuItem&&i.includes(s))&&l(e)}})}_handleKeyup(){super._handleKeyup(),this.dom.menu.addEventListener("keyup",e=>{this.currentEvent="keyboard";const s=w(e),{altKey:n,crtlKey:i,metaKey:r}=e;if(s==="Character"&&!(n||i||r))l(e),this.elements.rootMenu.currentEvent="character",this.focusNextChildWithCharacter(e.key);else if(this.isTopLevel){if(this.focusState==="self")if(s==="Space"||s==="Enter")this.currentMenuItem.isSubmenuItem?(l(e),this.currentMenuItem.elements.childMenu.currentEvent="keyboard",this.currentMenuItem.elements.toggle.open(),requestAnimationFrame(()=>{this.currentMenuItem.elements.childMenu.focusFirstChild()})):this.currentMenuItem.dom.link.click();else if(s==="ArrowRight"){l(e);const m=this.currentMenuItem.isSubmenuItem&&this.currentMenuItem.elements.toggle.isOpen;this.focusNextChild(),m&&(this.currentMenuItem.isSubmenuItem?(this.currentMenuItem.elements.childMenu.currentEvent="keyboard",this.currentMenuItem.elements.toggle.preview()):this.closeChildren())}else if(s==="ArrowLeft"){l(e);const m=this.currentMenuItem.isSubmenuItem&&this.currentMenuItem.elements.toggle.isOpen;this.focusPreviousChild(),m&&(this.currentMenuItem.isSubmenuItem?(this.currentMenuItem.elements.childMenu.currentEvent="keyboard",this.currentMenuItem.elements.toggle.preview()):this.closeChildren())}else s==="ArrowDown"?this.currentMenuItem.isSubmenuItem&&(l(e),this.currentMenuItem.elements.childMenu.currentEvent="keyboard",this.currentMenuItem.elements.toggle.open(),requestAnimationFrame(()=>{this.currentMenuItem.elements.childMenu.focusFirstChild()})):s==="ArrowUp"?this.currentMenuItem.isSubmenuItem&&(l(e),this.currentMenuItem.elements.childMenu.currentEvent="keyboard",this.currentMenuItem.elements.toggle.open(),requestAnimationFrame(()=>{this.currentMenuItem.elements.childMenu.focusLastChild()})):s==="Home"?(l(e),this.focusFirstChild()):s==="End"?(l(e),this.focusLastChild()):s==="Escape"&&(this.elements.submenuToggles.some(c=>c.isOpen)?(l(e),this.closeChildren()):this.isTopLevel&&this.elements.controller&&this.elements.controller.isOpen&&(l(e),this.elements.controller.close(),this.focusController()))}else s==="Space"||s==="Enter"?this.currentMenuItem.isSubmenuItem?(l(e),this.currentMenuItem.elements.childMenu.currentEvent="keyboard",this.currentMenuItem.elements.toggle.open(),requestAnimationFrame(()=>{this.currentMenuItem.elements.childMenu.focusFirstChild()})):this.currentMenuItem.dom.link.click():s==="Escape"?(l(e),this.elements.rootMenu.closeChildren(),this.elements.rootMenu.focusCurrentChild()):s==="ArrowRight"?this.currentMenuItem.isSubmenuItem?(l(e),this.currentMenuItem.elements.childMenu.currentEvent="keyboard",this.currentMenuItem.elements.toggle.open(),requestAnimationFrame(()=>{this.currentMenuItem.elements.childMenu.focusFirstChild()})):(l(e),this.elements.rootMenu.closeChildren(),this.elements.rootMenu.focusNextChild(),this.elements.rootMenu.currentMenuItem.isSubmenuItem&&this.elements.rootMenu.currentMenuItem.elements.toggle.preview()):s==="ArrowLeft"?this.elements.parentMenu.currentMenuItem.isSubmenuItem&&(l(e),this.elements.parentMenu.currentMenuItem.elements.toggle.close(),this.elements.parentMenu.focusCurrentChild(),this.elements.parentMenu===this.elements.rootMenu&&(this.elements.rootMenu.closeChildren(),this.elements.rootMenu.focusPreviousChild(),this.elements.rootMenu.currentMenuItem.isSubmenuItem&&(this.elements.rootMenu.currentMenuItem.elements.childMenu.currentEvent="keyboard",this.elements.rootMenu.currentMenuItem.elements.toggle.preview()))):s==="ArrowDown"?(l(e),this.focusNextChild()):s==="ArrowUp"?(l(e),this.focusPreviousChild()):s==="Home"?(l(e),this.focusFirstChild()):s==="End"&&(l(e),this.focusLastChild())})}focusNextChild(){this.currentChild===this.elements.menuItems.length-1?this.focusFirstChild():this.focusChild(this.currentChild+1)}focusPreviousChild(){this.currentChild===0?this.focusLastChild():this.focusChild(this.currentChild-1)}focusNextChildWithCharacter(e){const s=e.toLowerCase();let n=this.currentChild+1,i=!1;for(;!i&&n<this.elements.menuItems.length;){let r="";this.elements.menuItems[n].dom.item.innerText?r=this.elements.menuItems[n].dom.item.innerText:r=this.elements.menuItems[n].dom.item.textContent,r=r.replace(/[\s]/g,"").toLowerCase().charAt(0),r===s&&(i=!0,this.focusChild(n)),n++}}}class se extends U{constructor({menuItemElement:t,menuLinkElement:e,parentMenu:s,isSubmenuItem:n=!1,childMenu:i=null,toggle:r=null,initialize:h=!0}){super({menuItemElement:t,menuLinkElement:e,parentMenu:s,isSubmenuItem:n,childMenu:i,toggle:r,initialize:!1}),h&&this.initialize()}}class ne extends B{constructor({menuToggleElement:e,parentElement:s,controlledMenu:n,parentMenu:i=null,initialize:r=!0}){super({menuToggleElement:e,parentElement:s,controlledMenu:n,parentMenu:i,initialize:!1});u(this,"_dom",{toggle:null,parent:null,container:null});this._dom.toggle=e,this._dom.parent=s,this._dom.container=n.isTopLevel?n.dom.container:n.dom.menu,r&&this.initialize()}initialize(){super.initialize(),this.dom.toggle.hasAttribute("data-bs-toggle")&&this.dom.toggle.removeAttribute("data-bs-toggle"),this.dom.toggle.hasAttribute("data-bs-target")&&this.dom.toggle.removeAttribute("data-bs-target")}_expand(e=!0){const{openClass:s,transitionClass:n}=this.elements.controlledMenu;this.dom.toggle.setAttribute("aria-expanded","true"),n!==""?(a(n,this.dom.container),requestAnimationFrame(()=>{a(s,this.dom.container),requestAnimationFrame(()=>{d(n,this.dom.container)})})):s!==""&&a(s,this.dom.container),e&&this.dom.toggle.dispatchEvent(this._expandEvent)}_collapse(e=!0){const{closeClass:s,openClass:n,transitionClass:i}=this.elements.controlledMenu;this.dom.toggle.setAttribute("aria-expanded","false"),i!==""?(a(i,this.dom.container),requestAnimationFrame(()=>{n!==""&&d(n,this.dom.container),requestAnimationFrame(()=>{s!==""&&a(s,this.dom.container),requestAnimationFrame(()=>{d(i,this.dom.container)})})})):(s!==""&&a(s,this.dom.container),n!==""&&d(n,this.dom.container)),e&&this.dom.toggle.dispatchEvent(this._collapseEvent)}}class K extends F{constructor({menuElement:e,menuItemSelector:s=".nav-item,li",menuLinkSelector:n=".nav-link,.dropdown-item",submenuItemSelector:i=".dropdown",submenuToggleSelector:r=".dropdown-toggle",submenuSelector:h=".dropdown-menu",controllerElement:m=null,containerElement:c=null,openClass:f="show",closeClass:p="collapse",transitionClass:g="transitioning",isTopLevel:M=!0,parentMenu:y=null,hoverType:b="off",hoverDelay:C=250,enterDelay:_=-1,leaveDelay:E=-1,initialize:T=!0}){super({menuElement:e,menuItemSelector:s,menuLinkSelector:n,submenuItemSelector:i,submenuToggleSelector:r,submenuSelector:h,controllerElement:m,containerElement:c,openClass:f,closeClass:p,transitionClass:g,isTopLevel:M,parentMenu:y,hoverType:b,hoverDelay:C,enterDelay:_,leaveDelay:E,initialize:!1});u(this,"_MenuType",K);u(this,"_MenuItemType",se);u(this,"_MenuToggleType",ne);T&&this.initialize()}}class W extends D{constructor({menuItemElement:e,menuLinkElement:s,parentMenu:n,isSubmenuItem:i=!1,childMenu:r=null,toggle:h=null,initialize:m=!0,submenuSibling:c=null}){super({menuItemElement:e,menuLinkElement:s,parentMenu:n,isSubmenuItem:i,childMenu:r,toggle:h});u(this,"_elements",{parentMenu:null,childMenu:null,toggle:null,sibling:null});this._elements.parentMenu=n,this._elements.childMenu=r,this._elements.toggle=h,this._elements.sibling=c,m&&this.initialize()}}class Z extends L{constructor({menuToggleElement:t,parentElement:e,controlledMenu:s,parentMenu:n=null,initialize:i=!0}){super({menuToggleElement:t,parentElement:e,controlledMenu:s,parentMenu:n}),i&&this.initialize()}open(){this.closeSiblings(),super.open()}preview(){this.closeSiblings(),super.preview()}close(){this.isOpen&&this.closeChildren(),super.close()}}class q extends S{constructor({menuElement:e,menuItemSelector:s="li",menuLinkSelector:n="a",submenuItemSelector:i="",submenuToggleSelector:r="button",submenuSelector:h="ul",submenuSubtoggleSelector:m="a",controllerElement:c=null,containerElement:f=null,openClass:p="show",closeClass:g="hide",transitionClass:M="transitioning",isTopLevel:y=!0,parentMenu:b=null,hoverType:C="off",hoverDelay:_=250,enterDelay:E=-1,leaveDelay:T=-1,optionalKeySupport:k=!1,initialize:j=!0}){super({menuElement:e,menuItemSelector:s,menuLinkSelector:n,submenuItemSelector:i,submenuSelector:h,submenuToggleSelector:r,controllerElement:c,containerElement:f,openClass:p,closeClass:g,transitionClass:M,isTopLevel:y,parentMenu:b,hoverType:C,hoverDelay:_,enterDelay:E,leaveDelay:T});u(this,"_MenuType",q);u(this,"_MenuItemType",W);u(this,"_MenuToggleType",Z);u(this,"_currentChild",-1);u(this,"_selectors",{menuItems:"",menuLinks:"",submenuItems:"",submenuToggles:"",submenus:"",submenuSubtoggles:""});u(this,"_optionalSupport",!1);this._optionalSupport=k,this._selectors.menuItems=s,this._selectors.submenuItems=i,this._selectors.submenuToggles=r,this._selectors.submenus=h,this._selectors.submenuSubtoggles=m,this._selectors.menuLinks=[...new Set([n,r])].join(","),j&&this.initialize()}initialize(){try{super.initialize(),this._handleFocus(),this._handleClick(),this._handleHover(),this._handleKeydown(),this._handleKeyup()}catch(e){console.error(e)}}get optionalKeySupport(){return this.isTopLevel?this._optionalSupport:this.elements.rootMenu.optionalKeySupport}set optionalKeySupport(e){v("boolean",{optionalKeySupport:e}),this._optionalSupport=e}_createChildElements(){this.dom.menuItems.forEach(e=>{let s,n;const i=e.querySelector(this.selectors.menuLinks);if(this.dom.submenuItems.includes(e)){const r=e.querySelector(this.selectors.submenuToggles),h=e.querySelector(this.selectors.submenus),m=new this._MenuType({menuElement:h,menuItemSelector:this.selectors.menuItems,menuLinkSelector:this.selectors.menuLinks,submenuItemSelector:this.selectors.submenuItems,submenuToggleSelector:this.selectors.submenuSubtoggles,submenuSelector:this.selectors.submenus,submenuSubtoggleSelector:this.selectors.submenuSubtoggles,openClass:this.openClass,closeClass:this.closeClass,transitionClass:this.transitionClass,isTopLevel:!1,parentMenu:this,hoverType:this.hoverType,hoverDelay:this.hoverDelay,enterDelay:this.enterDelay,leaveDelay:this.leaveDelay}),c=new this._MenuToggleType({menuToggleElement:r,parentElement:e,controlledMenu:m,parentMenu:this});this._elements.submenuToggles.push(c),r!==i?(n=new this._MenuItemType({menuItemElement:e,menuLinkElement:r,parentMenu:this,isSubmenuItem:!0,childMenu:m,toggle:c}),s=new this._MenuItemType({menuItemElement:e,menuLinkElement:i,parentMenu:this,submenuSibling:n})):s=new this._MenuItemType({menuItemElement:e,menuLinkElement:i,parentMenu:this,isSubmenuItem:!0,childMenu:m,toggle:c})}else s=new this._MenuItemType({menuItemElement:e,menuLinkElement:i,parentMenu:this});this._elements.menuItems.push(s),typeof n<"u"&&this._elements.menuItems.push(n)})}_validate(){let e=super._validate();const s=x({submenuSubtoggleSelector:this._selectors.submenuSubtoggles});s.status||(this._errors.push(s.error.message),e=!1);const n=v("boolean",{optionalKeySupport:this._optionalSupport});return n.status||(this._errors.push(n.error.message),e=!1),e}_handleClick(){super._handleClick(),document.addEventListener("pointerup",e=>{this.focusState!=="none"&&(this.currentEvent="mouse",!this.dom.menu.contains(e.target)&&!this.dom.menu!==e.target&&(this.closeChildren(),this.blur(),this.elements.controller&&this.elements.controller.close()))})}_handleHover(){this.elements.menuItems.forEach((e,s)=>{e.dom.link.addEventListener("pointerenter",n=>{if(!(n.pointerType==="pen"||n.pointerType==="touch")){if(this.hoverType==="on"){this.currentEvent="mouse",this.elements.rootMenu.blurChildren(),this.focusChild(s);let i=e.isSubmenuItem?e.elements.toggle:null;if(e.elements.sibling!==null&&(i=e.elements.sibling.elements.toggle),i===null)return;this.enterDelay>0?(clearTimeout(this._hoverTimeout),this._hoverTimeout=setTimeout(()=>{i.preview()},this.enterDelay)):i.preview()}else if(this.hoverType==="dynamic"){const i=this.elements.submenuToggles.some(r=>r.isOpen);if(this.currentChild=s,(!this.isTopLevel||this.focusState!=="none")&&(this.currentEvent="mouse",this.elements.rootMenu.blurChildren(),this.focusCurrentChild()),!this.isTopLevel||i){this.currentEvent="mouse",this.elements.rootMenu.blurChildren(),this.focusCurrentChild();let r=e.isSubmenuItem?e.elements.toggle:null;if(e.elements.sibling!==null&&(r=e.elements.sibling.elements.toggle),r===null)return;this.enterDelay>0?(clearTimeout(this._hoverTimeout),this._hoverTimeout=setTimeout(()=>{r.preview()},this.enterDelay)):r.preview()}}}}),e.isSubmenuItem&&e.dom.item.addEventListener("pointerleave",n=>{n.pointerType==="pen"||n.pointerType==="touch"||(this.hoverType==="on"?this.leaveDelay>0?(clearTimeout(this._hoverTimeout),setTimeout(()=>{this.currentEvent="mouse",e.elements.toggle.close()},this.leaveDelay)):(this.currentEvent="mouse",e.elements.toggle.close()):this.hoverType==="dynamic"&&(this.isTopLevel||(this.leaveDelay>0?(clearTimeout(this._hoverTimeout),setTimeout(()=>{this.currentEvent="mouse",e.elements.toggle.close(),this.focusCurrentChild()},this.leaveDelay)):(this.currentEvent="mouse",e.elements.toggle.close(),this.focusCurrentChild()))))})})}_handleKeydown(){super._handleKeydown(),this.dom.menu.addEventListener("keydown",e=>{this.currentEvent="keyboard";const s=w(e);if(this.focusState==="self"){const n=["Space","Enter"],i=["Escape"],r=["Escape"];this.optionalKeySupport?["ArrowUp","ArrowRight","ArrowDown","ArrowLeft","Home","End"].includes(s)&&l(e):(this.currentMenuItem.isSubmenuItem&&n.includes(s)||this.elements.controller&&i.includes(s)||this.elements.parentMenu&&r.includes(s))&&l(e)}})}_handleKeyup(){super._handleKeyup(),this.dom.menu.addEventListener("keyup",e=>{this.currentEvent="keyboard";const s=w(e);this.focusState==="self"&&(s==="Space"||s==="Enter"?this.currentMenuItem.isSubmenuItem?(l(e),this.currentMenuItem.elements.toggle.isOpen?this.currentMenuItem.elements.toggle.close():this.currentMenuItem.elements.toggle.preview()):this.currentMenuItem.dom.link.click():s==="Escape"?this.elements.submenuToggles.some(i=>i.isOpen)?(l(e),this.closeChildren()):this.elements.parentMenu?(l(e),this.elements.parentMenu.currentEvent=this.currentEvent,this.elements.parentMenu.closeChildren(),this.elements.parentMenu.focusCurrentChild()):this.isTopLevel&&this.elements.controller&&this.elements.controller.isOpen&&(this.elements.controller.close(),this.focusController()):this.optionalKeySupport&&(s==="ArrowDown"||s==="ArrowRight"?(l(e),this.currentMenuItem.isSubmenuItem&&this.currentMenuItem.elements.toggle.isOpen?(this.currentMenuItem.elements.childMenu.currentEvent="keyboard",this.currentMenuItem.elements.childMenu.focusFirstChild()):this.focusNextChild()):s==="ArrowUp"||s==="ArrowLeft"?(l(e),this.focusPreviousChild()):s==="Home"?(l(e),this.focusFirstChild()):s==="End"&&(l(e),this.focusLastChild())))})}}class ie extends W{constructor({menuItemElement:t,menuLinkElement:e,parentMenu:s,isSubmenuItem:n=!1,childMenu:i=null,toggle:r=null,initialize:h=!0,submenuSibling:m=null}){super({menuItemElement:t,menuLinkElement:e,parentMenu:s,isSubmenuItem:n,childMenu:i,toggle:r,initialize:!1,submenuSibling:m}),h&&this.initialize()}}class re extends Z{constructor({menuToggleElement:e,parentElement:s,controlledMenu:n,parentMenu:i=null,initialize:r=!0}){super({menuToggleElement:e,parentElement:s,controlledMenu:n,parentMenu:i,initialize:!1});u(this,"_dom",{toggle:null,parent:null,container:null});this._dom.toggle=e,this._dom.parent=s,this._dom.container=n.isTopLevel?n.dom.container:n.dom.menu,r&&this.initialize()}initialize(){super.initialize(),this.dom.toggle.hasAttribute("data-bs-toggle")&&this.dom.toggle.removeAttribute("data-bs-toggle"),this.dom.toggle.hasAttribute("data-bs-target")&&this.dom.toggle.removeAttribute("data-bs-target")}_expand(e=!0){const{openClass:s,transitionClass:n}=this.elements.controlledMenu;this.dom.toggle.setAttribute("aria-expanded","true"),n!==""?(a(n,this.dom.container),requestAnimationFrame(()=>{a(s,this.dom.container),requestAnimationFrame(()=>{d(n,this.dom.container)})})):s!==""&&a(s,this.dom.container),e&&this.dom.toggle.dispatchEvent(this._expandEvent)}_collapse(e=!0){const{closeClass:s,openClass:n,transitionClass:i}=this.elements.controlledMenu;this.dom.toggle.setAttribute("aria-expanded","false"),i!==""?(a(i,this.dom.container),requestAnimationFrame(()=>{n!==""&&d(n,this.dom.container),requestAnimationFrame(()=>{s!==""&&a(s,this.dom.container),requestAnimationFrame(()=>{d(i,this.dom.container)})})})):(s!==""&&a(s,this.dom.container),n!==""&&d(n,this.dom.container)),e&&this.dom.toggle.dispatchEvent(this._collapseEvent)}}class $ extends q{constructor({menuElement:e,menuItemSelector:s=".nav-item,li",menuLinkSelector:n=".nav-link,.dropdown-item",submenuItemSelector:i=".dropdown",submenuToggleSelector:r=".dropdown-toggle",submenuSelector:h=".dropdown-menu",submenuSubtoggleSelector:m=".dropdown-toggle",controllerElement:c=null,containerElement:f=null,openClass:p="show",closeClass:g="collapse",transitionClass:M="transitioning",isTopLevel:y=!0,parentMenu:b=null,hoverType:C="off",hoverDelay:_=250,enterDelay:E=-1,leaveDelay:T=-1,optionalKeySupport:k=!1,initialize:j=!0}){super({menuElement:e,menuItemSelector:s,menuLinkSelector:n,submenuItemSelector:i,submenuToggleSelector:r,submenuSelector:h,submenuSubtoggleSelector:m,controllerElement:c,containerElement:f,openClass:p,closeClass:g,transitionClass:M,isTopLevel:y,parentMenu:b,hoverType:C,hoverDelay:_,enterDelay:E,leaveDelay:T,optionalKeySupport:k,initialize:!1});u(this,"_MenuType",$);u(this,"_MenuItemType",ie);u(this,"_MenuToggleType",re);j&&this.initialize()}}class G extends D{constructor({menuItemElement:t,menuLinkElement:e,parentMenu:s,isSubmenuItem:n=!1,childMenu:i=null,toggle:r=null,initialize:h=!0}){super({menuItemElement:t,menuLinkElement:e,parentMenu:s,isSubmenuItem:n,childMenu:i,toggle:r}),h&&this.initialize()}initialize(){super.initialize(),this.dom.item.setAttribute("role","none"),this.dom.link.setAttribute("role","treeitem"),this.dom.link.tabIndex=-1}focus(){super.focus(),this.dom.link.tabIndex=0}blur(){super.blur(),this.dom.link.tabIndex=-1}}class J extends L{constructor({menuToggleElement:t,parentElement:e,controlledMenu:s,parentMenu:n=null,initialize:i=!0}){super({menuToggleElement:t,parentElement:e,controlledMenu:s,parentMenu:n}),i&&this.initialize()}}class H extends S{constructor({menuElement:e,menuItemSelector:s="li",menuLinkSelector:n="a",submenuItemSelector:i="",submenuToggleSelector:r="a",submenuSelector:h="ul",controllerElement:m=null,containerElement:c=null,openClass:f="show",closeClass:p="hide",transitionClass:g="transitioning",isTopLevel:M=!0,parentMenu:y=null,hoverType:b="off",hoverDelay:C=250,enterDelay:_=-1,leaveDelay:E=-1,initialize:T=!0}){super({menuElement:e,menuItemSelector:s,menuLinkSelector:n,submenuItemSelector:i,submenuToggleSelector:r,submenuSelector:h,controllerElement:m,containerElement:c,openClass:f,closeClass:p,transitionClass:g,isTopLevel:M,parentMenu:y,hoverType:b,hoverDelay:C,enterDelay:_,leaveDelay:E});u(this,"_MenuType",H);u(this,"_MenuItemType",G);u(this,"_MenuToggleType",J);T&&this.initialize()}initialize(){try{super.initialize(),this.isTopLevel?(this.dom.menu.setAttribute("role","tree"),this.elements.menuItems[0].dom.link.tabIndex=0):this.dom.menu.setAttribute("role","group"),this._handleFocus(),this._handleClick(),this._handleHover(),this._handleKeydown(),this._handleKeyup()}catch(e){console.error(e)}}_handleKeydown(){super._handleKeydown(),this.dom.menu.addEventListener("keydown",e=>{this.currentEvent="keyboard";const s=w(e);if(s==="Tab"&&(this.elements.rootMenu.focusState!=="none"?this.elements.rootMenu.blur():this.elements.rootMenu.focus()),this.focusState==="self"){const n=["Space","ArrowUp","ArrowDown","ArrowLeft","Asterisk","Home","End"],i=["Enter","ArrowRight"],r=["Escape"];(n.includes(s)||this.currentMenuItem.isSubmenuItem&&i.includes(s)||this.elements.controller&&r.includes(s))&&l(e)}})}_handleKeyup(){super._handleKeyup(),this.dom.menu.addEventListener("keyup",e=>{this.currentEvent="keyboard";const s=w(e),{altKey:n,crtlKey:i,metaKey:r}=e;if(s==="Character"&&!(n||i||r))l(e),this.elements.rootMenu.currentEvent="character",this.focusNextNodeWithCharacter(e.key);else if(this.focusState==="self")if(s==="Enter"||s==="Space")l(e),this.currentMenuItem.isSubmenuItem?this.currentMenuItem.elements.toggle.isOpen?this.currentMenuItem.elements.toggle.close():this.currentMenuItem.elements.toggle.preview():this.currentMenuItem.dom.link.click();else if(s==="Escape")this.isTopLevel&&this.elements.controller&&this.elements.controller.isOpen&&(this.elements.controller.close(),this.focusController());else if(s==="ArrowDown")l(e),this.currentMenuItem.isSubmenuItem&&this.currentMenuItem.elements.toggle.isOpen?(this.blurCurrentChild(),this.currentMenuItem.elements.childMenu.currentEvent=this.currentEvent,this.currentMenuItem.elements.childMenu.focusFirstChild()):!this.isTopLevel&&this.currentChild===this.elements.menuItems.length-1?this.focusParentsNextChild():this.focusNextChild();else if(s==="ArrowUp"){l(e);const m=this.elements.menuItems[this.currentChild-1];m&&m.isSubmenuItem&&m.elements.toggle.isOpen?(this.blurCurrentChild(),this.currentChild=this.currentChild-1,this.currentMenuItem.elements.childMenu.currentEvent=this.currentEvent,this.focusChildsLastNode()):!this.isTopLevel&&this.currentChild===0?(this.blurCurrentChild(),this.elements.parentMenu.currentEvent=this.currentEvent,this.elements.parentMenu.focusCurrentChild()):this.focusPreviousChild()}else s==="ArrowRight"?this.currentMenuItem.isSubmenuItem&&(l(e),this.currentMenuItem.elements.toggle.isOpen?(this.blurCurrentChild(),this.currentMenuItem.elements.childMenu.currentEvent=this.currentEvent,this.currentMenuItem.elements.childMenu.focusFirstChild()):this.currentMenuItem.elements.toggle.preview()):s==="ArrowLeft"?(l(e),this.currentMenuItem.isSubmenuItem&&this.currentMenuItem.elements.toggle.isOpen?(this.currentMenuItem.elements.childMenu.blurCurrentChild(),this.currentMenuItem.elements.toggle.close()):this.isTopLevel||(this.blurCurrentChild(),this.elements.parentMenu.currentEvent=this.currentEvent,this.elements.parentMenu.focusCurrentChild())):s==="Home"?(l(e),this.blurCurrentChild(),this.elements.rootMenu.focusFirstChild()):s==="End"?(l(e),this.blurCurrentChild(),this.elements.rootMenu.focusLastNode()):s==="Asterisk"&&(l(e),this.openChildren())})}focusLastNode(){const e=this.elements.menuItems.length-1,s=this.elements.menuItems[e];s.isSubmenuItem&&s.elements.toggle.isOpen?(this.currentChild=e,s.elements.childMenu.currentEvent=this.currentEvent,s.elements.childMenu.focusLastNode()):this.focusLastChild()}openChildren(){this.elements.submenuToggles.forEach(e=>e.preview())}focusNextNodeWithCharacter(e){function s(f){let p=[];return f.elements.menuItems.forEach(g=>{p.push(g),g.isSubmenuItem&&g.elements.toggle.isOpen&&(p=[...p,...s(g.elements.toggle.elements.controlledMenu)])}),p}const n=e.toLowerCase(),i=s(this.elements.rootMenu),r=i.indexOf(this.currentMenuItem)+1,h=[...i.slice(r),...i.slice(0,r)];let m=0,c=!1;for(;!c&&m<h.length;){let f="";if(h[m].dom.item.innerText?f=h[m].dom.item.innerText:f=h[m].dom.item.textContent,f=f.replace(/[\s]/g,"").toLowerCase().charAt(0),f===n){c=!0;const p=h[m].elements.parentMenu,g=p.elements.menuItems.indexOf(h[m]);this.elements.rootMenu.blurChildren(),p.focusChild(g)}m++}}focusParentsNextChild(){this.elements.parentMenu&&(this.elements.parentMenu.currentEvent=this.currentEvent,this.elements.parentMenu.currentChild===this.elements.parentMenu.elements.menuItems.length-1?(this.elements.parentMenu.blurCurrentChild(),this.elements.parentMenu.focusParentsNextChild()):(this.blurChildren(),this.elements.parentMenu.focusNextChild()))}focusChildsLastNode(){this.currentMenuItem.elements.childMenu.currentEvent=this.currentEvent,this.currentMenuItem.elements.childMenu.focusLastChild(),this.currentMenuItem.elements.childMenu.currentMenuItem.isSubmenuItem&&this.currentMenuItem.elements.childMenu.currentMenuItem.elements.toggle.isOpen&&(this.currentMenuItem.elements.childMenu.blurCurrentChild(),this.currentMenuItem.elements.childMenu.focusChildsLastNode())}}class oe extends G{constructor({menuItemElement:t,menuLinkElement:e,parentMenu:s,isSubmenuItem:n=!1,childMenu:i=null,toggle:r=null,initialize:h=!0}){super({menuItemElement:t,menuLinkElement:e,parentMenu:s,isSubmenuItem:n,childMenu:i,toggle:r,initialize:!1}),h&&this.initialize()}}class le extends J{constructor({menuToggleElement:e,parentElement:s,controlledMenu:n,parentMenu:i=null,initialize:r=!0}){super({menuToggleElement:e,parentElement:s,controlledMenu:n,parentMenu:i,initialize:!1});u(this,"_dom",{toggle:null,parent:null,container:null});this._dom.toggle=e,this._dom.parent=s,this._dom.container=n.isTopLevel?n.dom.container:n.dom.menu,r&&this.initialize()}initialize(){super.initialize(),this.dom.toggle.hasAttribute("data-bs-toggle")&&this.dom.toggle.removeAttribute("data-bs-toggle"),this.dom.toggle.hasAttribute("data-bs-target")&&this.dom.toggle.removeAttribute("data-bs-target")}_expand(e=!0){const{openClass:s,transitionClass:n}=this.elements.controlledMenu;this.dom.toggle.setAttribute("aria-expanded","true"),n!==""?(a(n,this.dom.container),requestAnimationFrame(()=>{a(s,this.dom.container),requestAnimationFrame(()=>{d(n,this.dom.container)})})):s!==""&&a(s,this.dom.container),e&&this.dom.toggle.dispatchEvent(this._expandEvent)}_collapse(e=!0){const{closeClass:s,openClass:n,transitionClass:i}=this.elements.controlledMenu;this.dom.toggle.setAttribute("aria-expanded","false"),i!==""?(a(i,this.dom.container),requestAnimationFrame(()=>{n!==""&&d(n,this.dom.container),requestAnimationFrame(()=>{s!==""&&a(s,this.dom.container),requestAnimationFrame(()=>{d(i,this.dom.container)})})})):(s!==""&&a(s,this.dom.container),n!==""&&d(n,this.dom.container)),e&&this.dom.toggle.dispatchEvent(this._collapseEvent)}}class N extends H{constructor({menuElement:e,menuItemSelector:s=".nav-item,li",menuLinkSelector:n=".nav-link,.dropdown-item",submenuItemSelector:i=".dropdown",submenuToggleSelector:r=".dropdown-toggle",submenuSelector:h=".dropdown-menu",controllerElement:m=null,containerElement:c=null,openClass:f="show",closeClass:p="collapse",transitionClass:g="transitioning",isTopLevel:M=!0,parentMenu:y=null,hoverType:b="off",hoverDelay:C=250,enterDelay:_=-1,leaveDelay:E=-1,initialize:T=!0}){super({menuElement:e,menuItemSelector:s,menuLinkSelector:n,submenuItemSelector:i,submenuToggleSelector:r,submenuSelector:h,controllerElement:m,containerElement:c,openClass:f,closeClass:p,transitionClass:g,isTopLevel:M,parentMenu:y,hoverType:b,hoverDelay:C,enterDelay:_,leaveDelay:E,initialize:!1});u(this,"_MenuType",N);u(this,"_MenuItemType",oe);u(this,"_MenuToggleType",le);T&&this.initialize()}}return{Bootstrap5DisclosureMenu:O,Bootstrap5Menubar:K,Bootstrap5TopLinkDisclosureMenu:$,Bootstrap5Treeview:N}}(); |
@@ -1,3 +0,3 @@ | ||
var Bootstrap5DisclosureMenu=function(){"use strict";var P=Object.defineProperty;var U=(u,h,f)=>h in u?P(u,h,{enumerable:!0,configurable:!0,writable:!0,value:f}):u[h]=f;var r=(u,h,f)=>(U(u,typeof h!="symbol"?h+"":h,f),f);function u(n,e){typeof n=="string"?e.classList.add(n):e.classList.add(...n)}function h(n,e){typeof n=="string"?e.classList.remove(n):e.classList.remove(...n)}function f(n,e){try{if(typeof e!="object"){const t=typeof e;throw new TypeError(`Elements given to isValidInstance() must be inside of an object. "${t}" given.`)}for(const t in e)if(!(e[t]instanceof n)){const s=typeof e[t];throw new TypeError(`${t} must be an instance of ${n.name}. "${s}" given.`)}return{status:!0,error:null}}catch(t){return{status:!1,error:t}}}function d(n,e){try{if(typeof e!="object"){const t=typeof e;throw new TypeError(`Values given to isValidType() must be inside of an object. "${t}" given.`)}for(const t in e){const s=typeof e[t];if(s!==n)throw new TypeError(`${t} must be a ${n}. "${s}" given.`)}return{status:!0,error:null}}catch(t){return{status:!1,error:t}}}function k(n){try{if(typeof n!="object"){const e=typeof n;throw new TypeError(`Values given to isCSSSelector() must be inside of an object. "${e}" given.`)}for(const e in n)try{if(n[e]===null)throw new Error;document.querySelector(n[e])}catch{throw new TypeError(`${e} must be a valid CSS selector. "${n[e]}" given.`)}return{status:!0,error:null}}catch(e){return{status:!1,error:e}}}function g(n){try{if(typeof n!="object"||Array.isArray(n)){const e=typeof n;throw new TypeError(`Values given to isValidClassList() must be inside of an object. "${e}" given.`)}for(const e in n){const t=typeof n[e];if(t!=="string")if(Array.isArray(n[e]))n[e].forEach(s=>{if(typeof s!="string")throw new TypeError(`${e} must be a string or an array of strings. An array containing non-strings given.`)});else throw new TypeError(`${e} must be a string or an array of strings. "${t}" given.`);else{const s={};s[e]=n[e],k(s)}}return{status:!0,error:null}}catch(e){return{status:!1,error:e}}}function K(n){try{if(typeof n!="object"){const t=typeof n;throw new TypeError(`Values given to isValidState() must be inside of an object. "${t}" given.`)}const e=["none","self","child"];for(const t in n)if(!e.includes(n[t]))throw new TypeError(`${t} must be one of the following values: ${e.join(", ")}. "${n[t]}" given.`);return{status:!0,error:null}}catch(e){return{status:!1,error:e}}}function V(n){try{if(typeof n!="object"){const t=typeof n;throw new TypeError(`Values given to isValidEvent() must be inside of an object. "${t}" given.`)}const e=["none","mouse","keyboard","character"];for(const t in n)if(!e.includes(n[t]))throw new TypeError(`${t} must be one of the following values: ${e.join(", ")}. "${n[t]}" given.`);return{status:!0,error:null}}catch(e){return{status:!1,error:e}}}function O(n){try{if(typeof n!="object"){const t=typeof n;throw new TypeError(`Values given to isValidHoverType() must be inside of an object. "${t}" given.`)}const e=["off","on","dynamic"];for(const t in n)if(!e.includes(n[t]))throw new TypeError(`${t} must be one of the following values: ${e.join(", ")}. "${n[t]}" given.`);return{status:!0,error:null}}catch(e){return{status:!1,error:e}}}function q(n,e){if(d("string",{tagName:n}).status&&f(HTMLElement,e).status){const t=n.toLowerCase();let s=!0;for(const i in e)e[i].tagName.toLowerCase()!==t&&(s=!1);return s}else return!1}class F{constructor({menuToggleElement:e,parentElement:t,controlledMenu:s,parentMenu:i=null}){r(this,"_dom",{toggle:null,parent:null});r(this,"_elements",{controlledMenu:null,parentMenu:null});r(this,"_open",!1);r(this,"_expandEvent",new CustomEvent("accessibleMenuExpand",{bubbles:!0,detail:{toggle:this}}));r(this,"_collapseEvent",new CustomEvent("accessibleMenuCollapse",{bubbles:!0,detail:{toggle:this}}));this._dom.toggle=e,this._dom.parent=t,this._elements.controlledMenu=s,this._elements.parentMenu=i}initialize(){var e;if(this.dom.toggle.setAttribute("aria-haspopup","true"),this.dom.toggle.setAttribute("aria-expanded","false"),q("button",{toggle:this.dom.toggle})||this.dom.toggle.setAttribute("role","button"),this.dom.toggle.id===""||this.elements.controlledMenu.dom.menu.id===""){const t=Math.random().toString(36).replace(/[^a-z]+/g,"").substr(0,10);let s=((e=this.dom.toggle.innerText)==null?void 0:e.replace(/[^a-zA-Z0-9\s]/g,""))||"",i=t;!s.replace(/\s/g,"").length&&this.dom.toggle.getAttribute("aria-label")&&(s=this.dom.toggle.getAttribute("aria-label").replace(/[^a-zA-Z0-9\s]/g,"")),s.replace(/\s/g,"").length>0&&(s=s.toLowerCase().replace(/\s+/g,"-"),s.startsWith("-")&&(s=s.substring(1)),s.endsWith("-")&&(s=s.slice(0,-1)),i=`${s}-${i}`),this.dom.toggle.id=this.dom.toggle.id||`${i}-menu-button`,this.elements.controlledMenu.dom.menu.id=this.elements.controlledMenu.dom.menu.id||`${i}-menu`}this.elements.controlledMenu.dom.menu.setAttribute("aria-labelledby",this.dom.toggle.id),this.dom.toggle.setAttribute("aria-controls",this.elements.controlledMenu.dom.menu.id),this._collapse(!1)}get dom(){return this._dom}get elements(){return this._elements}get isOpen(){return this._open}set isOpen(e){d("boolean",{value:e}),this._open=e}_expand(e=!0){const{closeClass:t,openClass:s,transitionClass:i}=this.elements.controlledMenu;this.dom.toggle.setAttribute("aria-expanded","true"),i!==""?(u(i,this.elements.controlledMenu.dom.menu),requestAnimationFrame(()=>{t!==""&&h(t,this.elements.controlledMenu.dom.menu),requestAnimationFrame(()=>{s!==""&&u(s,this.elements.controlledMenu.dom.menu),requestAnimationFrame(()=>{h(i,this.elements.controlledMenu.dom.menu)})})})):(s!==""&&u(s,this.elements.controlledMenu.dom.menu),t!==""&&h(t,this.elements.controlledMenu.dom.menu)),e&&this.dom.toggle.dispatchEvent(this._expandEvent)}_collapse(e=!0){const{closeClass:t,openClass:s,transitionClass:i}=this.elements.controlledMenu;this.dom.toggle.setAttribute("aria-expanded","false"),i!==""?(u(i,this.elements.controlledMenu.dom.menu),requestAnimationFrame(()=>{s!==""&&h(s,this.elements.controlledMenu.dom.menu),requestAnimationFrame(()=>{t!==""&&u(t,this.elements.controlledMenu.dom.menu),requestAnimationFrame(()=>{h(i,this.elements.controlledMenu.dom.menu)})})})):(t!==""&&u(t,this.elements.controlledMenu.dom.menu),s!==""&&h(s,this.elements.controlledMenu.dom.menu)),e&&this.dom.toggle.dispatchEvent(this._collapseEvent)}open(){this.elements.controlledMenu.focusState="self",this._expand(),this.isOpen=!0}preview(){this.elements.parentMenu&&(this.elements.parentMenu.focusState="self"),this._expand(),this.isOpen=!0}close(){this.isOpen&&(this.elements.controlledMenu.currentChild=0,this.elements.controlledMenu.blur(),this.elements.parentMenu&&(this.elements.parentMenu.focusState="self"),this._collapse(),this.isOpen=!1)}toggle(){this.isOpen?this.close():this.open()}closeSiblings(){this.elements.parentMenu&&this.elements.parentMenu.elements.submenuToggles.forEach(e=>{e!==this&&e.close()})}closeChildren(){this.elements.controlledMenu.elements.submenuToggles.forEach(e=>e.close())}}class x{constructor({menuItemElement:e,menuLinkElement:t,parentMenu:s,isSubmenuItem:i=!1,childMenu:o=null,toggle:l=null}){r(this,"_dom",{item:null,link:null});r(this,"_elements",{parentMenu:null,childMenu:null,toggle:null});r(this,"_submenu",!1);this._dom.item=e,this._dom.link=t,this._elements.parentMenu=s,this._elements.childMenu=o,this._elements.toggle=l,this._submenu=i}initialize(){}get dom(){return this._dom}get elements(){return this._elements}get isSubmenuItem(){return this._submenu}focus(){this.elements.parentMenu.shouldFocus&&this.dom.link.focus()}blur(){this.elements.parentMenu.shouldFocus&&this.dom.link.blur()}}function w(n){try{const e=n.key||n.keyCode,t={Enter:e==="Enter"||e===13,Space:e===" "||e==="Spacebar"||e===32,Escape:e==="Escape"||e==="Esc"||e===27,ArrowUp:e==="ArrowUp"||e==="Up"||e===38,ArrowRight:e==="ArrowRight"||e==="Right"||e===39,ArrowDown:e==="ArrowDown"||e==="Down"||e===40,ArrowLeft:e==="ArrowLeft"||e==="Left"||e===37,Home:e==="Home"||e===36,End:e==="End"||e===35,Character:isNaN(e)&&!!e.match(/^[a-zA-Z]{1}$/),Tab:e==="Tab"||e===9,Asterisk:e==="*"||e===56};return Object.keys(t).find(s=>t[s]===!0)||""}catch{return""}}function m(n){n.preventDefault(),n.stopPropagation()}class S{constructor({menuElement:e,menuItemSelector:t="li",menuLinkSelector:s="a",submenuItemSelector:i="",submenuToggleSelector:o="a",submenuSelector:l="ul",controllerElement:c=null,containerElement:p=null,openClass:a="show",closeClass:y="hide",transitionClass:b="transitioning",isTopLevel:_=!0,parentMenu:C=null,hoverType:E="off",hoverDelay:M=250,enterDelay:T=-1,leaveDelay:v=-1}){r(this,"_MenuType",S);r(this,"_MenuItemType",x);r(this,"_MenuToggleType",F);r(this,"_dom",{menu:null,menuItems:[],submenuItems:[],submenuToggles:[],submenus:[],controller:null,container:null});r(this,"_selectors",{menuItems:"",menuLinks:"",submenuItems:"",submenuToggles:"",submenus:""});r(this,"_elements",{menuItems:[],submenuToggles:[],controller:null,parentMenu:null,rootMenu:null});r(this,"_openClass","show");r(this,"_closeClass","hide");r(this,"_transitionClass","transitioning");r(this,"_root",!0);r(this,"_currentChild",0);r(this,"_focusState","none");r(this,"_currentEvent","none");r(this,"_hoverType","off");r(this,"_hoverDelay",250);r(this,"_enterDelay",-1);r(this,"_leaveDelay",-1);r(this,"_hoverTimeout",null);r(this,"_errors",[]);this._dom.menu=e,this._dom.controller=c,this._dom.container=p,this._selectors.menuItems=t,this._selectors.menuLinks=s,this._selectors.submenuItems=i,this._selectors.submenuToggles=o,this._selectors.submenus=l,this._elements.menuItems=[],this._elements.submenuToggles=[],this._elements.controller=null,this._elements.parentMenu=C,this._elements.rootMenu=_?this:null,this._openClass=a||"",this._closeClass=y||"",this._transitionClass=b||"",this._root=_,this._hoverType=E,this._hoverDelay=M,this._enterDelay=T,this._leaveDelay=v}initialize(){if(!this._validate())throw new Error(`AccesibleMenu: cannot initialize menu. The following errors have been found: | ||
var Bootstrap5DisclosureMenu=function(){"use strict";var P=Object.defineProperty;var U=(u,h,f)=>h in u?P(u,h,{enumerable:!0,configurable:!0,writable:!0,value:f}):u[h]=f;var r=(u,h,f)=>(U(u,typeof h!="symbol"?h+"":h,f),f);function u(n,e){typeof n=="string"?e.classList.add(n):e.classList.add(...n)}function h(n,e){typeof n=="string"?e.classList.remove(n):e.classList.remove(...n)}function f(n,e){try{if(typeof e!="object"){const t=typeof e;throw new TypeError(`Elements given to isValidInstance() must be inside of an object. "${t}" given.`)}for(const t in e)if(!(e[t]instanceof n)){const s=typeof e[t];throw new TypeError(`${t} must be an instance of ${n.name}. "${s}" given.`)}return{status:!0,error:null}}catch(t){return{status:!1,error:t}}}function d(n,e){try{if(typeof e!="object"){const t=typeof e;throw new TypeError(`Values given to isValidType() must be inside of an object. "${t}" given.`)}for(const t in e){const s=typeof e[t];if(s!==n)throw new TypeError(`${t} must be a ${n}. "${s}" given.`)}return{status:!0,error:null}}catch(t){return{status:!1,error:t}}}function D(n){try{if(typeof n!="object"){const e=typeof n;throw new TypeError(`Values given to isCSSSelector() must be inside of an object. "${e}" given.`)}for(const e in n)try{if(n[e]===null)throw new Error;document.querySelector(n[e])}catch{throw new TypeError(`${e} must be a valid CSS selector. "${n[e]}" given.`)}return{status:!0,error:null}}catch(e){return{status:!1,error:e}}}function g(n){try{if(typeof n!="object"||Array.isArray(n)){const e=typeof n;throw new TypeError(`Values given to isValidClassList() must be inside of an object. "${e}" given.`)}for(const e in n){const t=typeof n[e];if(t!=="string")if(Array.isArray(n[e]))n[e].forEach(s=>{if(typeof s!="string")throw new TypeError(`${e} must be a string or an array of strings. An array containing non-strings given.`)});else throw new TypeError(`${e} must be a string or an array of strings. "${t}" given.`);else{const s={};s[e]=n[e],D(s)}}return{status:!0,error:null}}catch(e){return{status:!1,error:e}}}function K(n){try{if(typeof n!="object"){const t=typeof n;throw new TypeError(`Values given to isValidState() must be inside of an object. "${t}" given.`)}const e=["none","self","child"];for(const t in n)if(!e.includes(n[t]))throw new TypeError(`${t} must be one of the following values: ${e.join(", ")}. "${n[t]}" given.`);return{status:!0,error:null}}catch(e){return{status:!1,error:e}}}function V(n){try{if(typeof n!="object"){const t=typeof n;throw new TypeError(`Values given to isValidEvent() must be inside of an object. "${t}" given.`)}const e=["none","mouse","keyboard","character"];for(const t in n)if(!e.includes(n[t]))throw new TypeError(`${t} must be one of the following values: ${e.join(", ")}. "${n[t]}" given.`);return{status:!0,error:null}}catch(e){return{status:!1,error:e}}}function O(n){try{if(typeof n!="object"){const t=typeof n;throw new TypeError(`Values given to isValidHoverType() must be inside of an object. "${t}" given.`)}const e=["off","on","dynamic"];for(const t in n)if(!e.includes(n[t]))throw new TypeError(`${t} must be one of the following values: ${e.join(", ")}. "${n[t]}" given.`);return{status:!0,error:null}}catch(e){return{status:!1,error:e}}}function q(n,e){if(d("string",{tagName:n}).status&&f(HTMLElement,e).status){const t=n.toLowerCase();let s=!0;for(const i in e)e[i].tagName.toLowerCase()!==t&&(s=!1);return s}else return!1}class F{constructor({menuToggleElement:e,parentElement:t,controlledMenu:s,parentMenu:i=null}){r(this,"_dom",{toggle:null,parent:null});r(this,"_elements",{controlledMenu:null,parentMenu:null});r(this,"_open",!1);r(this,"_expandEvent",new CustomEvent("accessibleMenuExpand",{bubbles:!0,detail:{toggle:this}}));r(this,"_collapseEvent",new CustomEvent("accessibleMenuCollapse",{bubbles:!0,detail:{toggle:this}}));this._dom.toggle=e,this._dom.parent=t,this._elements.controlledMenu=s,this._elements.parentMenu=i}initialize(){var e;if(this.dom.toggle.setAttribute("aria-haspopup","true"),this.dom.toggle.setAttribute("aria-expanded","false"),q("button",{toggle:this.dom.toggle})||this.dom.toggle.setAttribute("role","button"),this.dom.toggle.id===""||this.elements.controlledMenu.dom.menu.id===""){const t=Math.random().toString(36).replace(/[^a-z]+/g,"").substr(0,10);let s=((e=this.dom.toggle.innerText)==null?void 0:e.replace(/[^a-zA-Z0-9\s]/g,""))||"",i=t;!s.replace(/\s/g,"").length&&this.dom.toggle.getAttribute("aria-label")&&(s=this.dom.toggle.getAttribute("aria-label").replace(/[^a-zA-Z0-9\s]/g,"")),s.replace(/\s/g,"").length>0&&(s=s.toLowerCase().replace(/\s+/g,"-"),s.startsWith("-")&&(s=s.substring(1)),s.endsWith("-")&&(s=s.slice(0,-1)),i=`${s}-${i}`),this.dom.toggle.id=this.dom.toggle.id||`${i}-menu-button`,this.elements.controlledMenu.dom.menu.id=this.elements.controlledMenu.dom.menu.id||`${i}-menu`}this.elements.controlledMenu.dom.menu.setAttribute("aria-labelledby",this.dom.toggle.id),this.dom.toggle.setAttribute("aria-controls",this.elements.controlledMenu.dom.menu.id),this._collapse(!1)}get dom(){return this._dom}get elements(){return this._elements}get isOpen(){return this._open}set isOpen(e){d("boolean",{value:e}),this._open=e}_expand(e=!0){const{closeClass:t,openClass:s,transitionClass:i}=this.elements.controlledMenu;this.dom.toggle.setAttribute("aria-expanded","true"),i!==""?(u(i,this.elements.controlledMenu.dom.menu),requestAnimationFrame(()=>{t!==""&&h(t,this.elements.controlledMenu.dom.menu),requestAnimationFrame(()=>{s!==""&&u(s,this.elements.controlledMenu.dom.menu),requestAnimationFrame(()=>{h(i,this.elements.controlledMenu.dom.menu)})})})):(s!==""&&u(s,this.elements.controlledMenu.dom.menu),t!==""&&h(t,this.elements.controlledMenu.dom.menu)),e&&this.dom.toggle.dispatchEvent(this._expandEvent)}_collapse(e=!0){const{closeClass:t,openClass:s,transitionClass:i}=this.elements.controlledMenu;this.dom.toggle.setAttribute("aria-expanded","false"),i!==""?(u(i,this.elements.controlledMenu.dom.menu),requestAnimationFrame(()=>{s!==""&&h(s,this.elements.controlledMenu.dom.menu),requestAnimationFrame(()=>{t!==""&&u(t,this.elements.controlledMenu.dom.menu),requestAnimationFrame(()=>{h(i,this.elements.controlledMenu.dom.menu)})})})):(t!==""&&u(t,this.elements.controlledMenu.dom.menu),s!==""&&h(s,this.elements.controlledMenu.dom.menu)),e&&this.dom.toggle.dispatchEvent(this._collapseEvent)}open(){this.elements.controlledMenu.focusState="self",this._expand(),this.isOpen=!0}preview(){this.elements.parentMenu&&(this.elements.parentMenu.focusState="self"),this._expand(),this.isOpen=!0}close(){this.isOpen&&(this.elements.controlledMenu.blur(),this.elements.parentMenu&&(this.elements.parentMenu.focusState="self"),this._collapse(),this.isOpen=!1)}toggle(){this.isOpen?this.close():this.open()}closeSiblings(){this.elements.parentMenu&&this.elements.parentMenu.elements.submenuToggles.forEach(e=>{e!==this&&e.close()})}closeChildren(){this.elements.controlledMenu.elements.submenuToggles.forEach(e=>e.close())}}class x{constructor({menuItemElement:e,menuLinkElement:t,parentMenu:s,isSubmenuItem:i=!1,childMenu:o=null,toggle:l=null}){r(this,"_dom",{item:null,link:null});r(this,"_elements",{parentMenu:null,childMenu:null,toggle:null});r(this,"_submenu",!1);this._dom.item=e,this._dom.link=t,this._elements.parentMenu=s,this._elements.childMenu=o,this._elements.toggle=l,this._submenu=i}initialize(){}get dom(){return this._dom}get elements(){return this._elements}get isSubmenuItem(){return this._submenu}focus(){this.elements.parentMenu.shouldFocus&&this.dom.link.focus()}blur(){this.elements.parentMenu.shouldFocus&&this.dom.link.blur()}}function w(n){try{const e=n.key||n.keyCode,t={Enter:e==="Enter"||e===13,Space:e===" "||e==="Spacebar"||e===32,Escape:e==="Escape"||e==="Esc"||e===27,ArrowUp:e==="ArrowUp"||e==="Up"||e===38,ArrowRight:e==="ArrowRight"||e==="Right"||e===39,ArrowDown:e==="ArrowDown"||e==="Down"||e===40,ArrowLeft:e==="ArrowLeft"||e==="Left"||e===37,Home:e==="Home"||e===36,End:e==="End"||e===35,Character:isNaN(e)&&!!e.match(/^[a-zA-Z]{1}$/),Tab:e==="Tab"||e===9,Asterisk:e==="*"||e===56};return Object.keys(t).find(s=>t[s]===!0)||""}catch{return""}}function m(n){n.preventDefault(),n.stopPropagation()}class S{constructor({menuElement:e,menuItemSelector:t="li",menuLinkSelector:s="a",submenuItemSelector:i="",submenuToggleSelector:o="a",submenuSelector:l="ul",controllerElement:c=null,containerElement:p=null,openClass:a="show",closeClass:y="hide",transitionClass:b="transitioning",isTopLevel:_=!0,parentMenu:C=null,hoverType:E="off",hoverDelay:M=250,enterDelay:T=-1,leaveDelay:v=-1}){r(this,"_MenuType",S);r(this,"_MenuItemType",x);r(this,"_MenuToggleType",F);r(this,"_dom",{menu:null,menuItems:[],submenuItems:[],submenuToggles:[],submenus:[],controller:null,container:null});r(this,"_selectors",{menuItems:"",menuLinks:"",submenuItems:"",submenuToggles:"",submenus:""});r(this,"_elements",{menuItems:[],submenuToggles:[],controller:null,parentMenu:null,rootMenu:null});r(this,"_openClass","show");r(this,"_closeClass","hide");r(this,"_transitionClass","transitioning");r(this,"_root",!0);r(this,"_currentChild",0);r(this,"_focusState","none");r(this,"_currentEvent","none");r(this,"_hoverType","off");r(this,"_hoverDelay",250);r(this,"_enterDelay",-1);r(this,"_leaveDelay",-1);r(this,"_hoverTimeout",null);r(this,"_errors",[]);this._dom.menu=e,this._dom.controller=c,this._dom.container=p,this._selectors.menuItems=t,this._selectors.menuLinks=s,this._selectors.submenuItems=i,this._selectors.submenuToggles=o,this._selectors.submenus=l,this._elements.menuItems=[],this._elements.submenuToggles=[],this._elements.controller=null,this._elements.parentMenu=C,this._elements.rootMenu=_?this:null,this._openClass=a||"",this._closeClass=y||"",this._transitionClass=b||"",this._root=_,this._hoverType=E,this._hoverDelay=M,this._enterDelay=T,this._leaveDelay=v}initialize(){if(!this._validate())throw new Error(`AccesibleMenu: cannot initialize menu. The following errors have been found: | ||
- ${this.errors.join(` | ||
- `)}`);if(this.elements.rootMenu===null&&this._findRootMenu(this),this._setDOMElements(),this.isTopLevel&&this.dom.controller&&this.dom.container){const e=new this._MenuToggleType({menuToggleElement:this.dom.controller,parentElement:this.dom.container,controlledMenu:this});this._elements.controller=e}this._createChildElements()}get dom(){return this._dom}get selectors(){return this._selectors}get elements(){return this._elements}get isTopLevel(){return this._root}get openClass(){return this.isTopLevel?this._openClass:this.elements.rootMenu.openClass}get closeClass(){return this.isTopLevel?this._closeClass:this.elements.rootMenu.closeClass}get transitionClass(){return this.isTopLevel?this._transitionClass:this.elements.rootMenu.transitionClass}get currentChild(){return this._currentChild}get focusState(){return this._focusState}get currentEvent(){return this._currentEvent}get currentMenuItem(){return this.elements.menuItems[this.currentChild]}get hoverType(){return this._root?this._hoverType:this.elements.rootMenu.hoverType}get hoverDelay(){return this._root?this._hoverDelay:this.elements.rootMenu.hoverDelay}get enterDelay(){return this._enterDelay===-1?this.hoverDelay:this._root?this._enterDelay:this.elements.rootMenu.enterDelay}get leaveDelay(){return this._leaveDelay===-1?this.hoverDelay:this._root?this._leaveDelay:this.elements.rootMenu.leaveDelay}get shouldFocus(){let e=!1;return(this.currentEvent==="keyboard"||this.currentEvent==="character")&&(e=!0),this.currentEvent==="mouse"&&this.hoverType==="dynamic"&&(e=!0),e}get errors(){return this._errors}set openClass(e){g({openClass:e}),this._openClass!==e&&(this._openClass=e)}set closeClass(e){g({closeClass:e}),this._closeClass!==e&&(this._closeClass=e)}set transitionClass(e){g({transitionClass:e}),this._transitionClass!==e&&(this._transitionClass=e)}set currentChild(e){d("number",{value:e});function t(s){if(["mouse","character"].includes(s.currentEvent)&&s.elements.parentMenu){let o=0,l=!1;for(;!l&&o<s.elements.parentMenu.elements.menuItems.length;){const c=s.elements.parentMenu.elements.menuItems[o];c.isSubmenuItem&&c.elements.toggle.elements.controlledMenu===s&&(l=!0,s.elements.parentMenu.currentEvent=s.currentEvent,s.elements.parentMenu.currentChild=o),o++}}}e<-1?(this._currentChild=-1,t(this)):e>=this.elements.menuItems.length?(this._currentChild=this.elements.menuItems.length-1,t(this)):this.focusChild!==e&&(this._currentChild=e,t(this))}set focusState(e){K({value:e}),this._focusState!==e&&(this._focusState=e),this.elements.submenuToggles.length>0&&(e==="self"||e==="none")&&this.elements.submenuToggles.forEach(t=>{t.elements.controlledMenu.focusState="none"}),this.elements.parentMenu&&(e==="self"||e==="child")&&(this.elements.parentMenu.focusState="child")}set currentEvent(e){V({value:e}),this._currentEvent!==e&&(this._currentEvent=e,this.elements.submenuToggles.length>0&&this.elements.submenuToggles.forEach(t=>{t.elements.controlledMenu.currentEvent=e}))}set hoverType(e){O({value:e}),this._hoverType!==e&&(this._hoverType=e)}set hoverDelay(e){d("number",{value:e}),this._hoverDelay!==e&&(this._hoverDelay=e)}set enterDelay(e){d("number",{value:e}),this._enterDelay!==e&&(this._enterDelay=e)}set leaveDelay(e){d("number",{value:e}),this._leaveDelay!==e&&(this._leaveDelay=e)}_validate(){let e=!0,t;this._dom.container!==null||this._dom.controller!==null?t=f(HTMLElement,{menuElement:this._dom.menu,controllerElement:this._dom.controller,containerElement:this._dom.container}):t=f(HTMLElement,{menuElement:this._dom.menu}),t.status||(this._errors.push(t.error.message),e=!1);let s;if(this._selectors.submenuItems!==""?s=k({menuItemSelector:this._selectors.menuItems,menuLinkSelector:this._selectors.menuLinks,submenuItemSelector:this._selectors.submenuItems,submenuToggleSelector:this._selectors.submenuToggles,submenuSelector:this._selectors.submenus}):s=k({menuItemSelector:this._selectors.menuItems,menuLinkSelector:this._selectors.menuLinks}),s.status||(this._errors.push(s.error.message),e=!1),this._openClass!==""){const a=g({openClass:this._openClass});a.status||(this._errors.push(a.error.message),e=!1)}if(this._closeClass!==""){const a=g({closeClass:this._closeClass});a.status||(this._errors.push(a.error.message),e=!1)}if(this._transitionClass!==""){const a=g({transitionClass:this._transitionClass});a.status||(this._errors.push(a.error.message),e=!1)}const i=d("boolean",{isTopLevel:this._root});if(i.status||(this._errors.push(i.error.message),e=!1),this._elements.parentMenu!==null){const a=f(S,{parentMenu:this._elements.parentMenu});a.status||(this._errors.push(a.error.message),e=!1)}const o=O({hoverType:this._hoverType});o.status||(this._errors.push(o.error.message),e=!1);const l=d("number",{hoverDelay:this._hoverDelay});l.status||(this._errors.push(l.error.message),e=!1);const c=d("number",{enterDelay:this._enterDelay});c.status||(this._errors.push(c.error.message),e=!1);const p=d("number",{leaveDelay:this._leaveDelay});return p.status||(this._errors.push(p.error.message),e=!1),e}_setDOMElementType(e,t=this.dom.menu,s=!0){if(typeof this.selectors[e]=="string"){if(!Array.isArray(this.dom[e]))throw new Error(`AccessibleMenu: The "${e}" element cannot be set through _setDOMElementType.`);t!==this.dom.menu&&f(HTMLElement,{base:t});const o=Array.from(t.querySelectorAll(this.selectors[e])).filter(l=>l.parentElement===t);s?this._dom[e]=o:this._dom[e]=[...this._dom[e],...o]}else throw new Error(`AccessibleMenu: "${e}" is not a valid element type within the menu.`)}_resetDOMElementType(e){if(typeof this.dom[e]<"u"){if(!Array.isArray(this.dom[e]))throw new Error(`AccessibleMenu: The "${e}" element cannot be reset through _resetDOMElementType.`);this._dom[e]=[]}else throw new Error(`AccessibleMenu: "${e}" is not a valid element type within the menu.`)}_setDOMElements(){this._setDOMElementType("menuItems"),this.selectors.submenuItems!==""&&(this._setDOMElementType("submenuItems"),this._resetDOMElementType("submenuToggles"),this._resetDOMElementType("submenus"),this.dom.submenuItems.forEach(e=>{this._setDOMElementType("submenuToggles",e,!1),this._setDOMElementType("submenus",e,!1)}))}_findRootMenu(e){if(e.isTopLevel)this._elements.rootMenu=e;else if(e.elements.parentMenu!==null)this._findRootMenu(e.elements.parentMenu);else throw new Error("Cannot find root menu.")}_createChildElements(){this.dom.menuItems.forEach(e=>{let t;if(this.dom.submenuItems.includes(e)){const s=e.querySelector(this.selectors.submenuToggles),i=e.querySelector(this.selectors.submenus),o=new this._MenuType({menuElement:i,menuItemSelector:this.selectors.menuItems,menuLinkSelector:this.selectors.menuLinks,submenuItemSelector:this.selectors.submenuItems,submenuToggleSelector:this.selectors.submenuToggles,submenuSelector:this.selectors.submenus,openClass:this.openClass,closeClass:this.closeClass,isTopLevel:!1,parentMenu:this,hoverType:this.hoverType,hoverDelay:this.hoverDelay}),l=new this._MenuToggleType({menuToggleElement:s,parentElement:e,controlledMenu:o,parentMenu:this});this._elements.submenuToggles.push(l),t=new this._MenuItemType({menuItemElement:e,menuLinkElement:s,parentMenu:this,isSubmenuItem:!0,childMenu:o,toggle:l})}else{const s=e.querySelector(this.selectors.menuLinks);t=new this._MenuItemType({menuItemElement:e,menuLinkElement:s,parentMenu:this})}this._elements.menuItems.push(t)})}_handleFocus(){this.elements.menuItems.forEach((e,t)=>{e.dom.link.addEventListener("focus",()=>{this.focusState="self",this.currentChild=t})})}_handleClick(){function e(t,s,i){m(i),s.toggle(),s.isOpen&&(t.focusState="self",s.elements.controlledMenu.focusState="none")}this.elements.menuItems.forEach((t,s)=>{t.dom.link.addEventListener("pointerdown",()=>{this.currentEvent="mouse",this.elements.rootMenu.blurChildren(),this.focusChild(s)},{passive:!0}),t.isSubmenuItem&&t.elements.toggle.dom.toggle.addEventListener("pointerup",i=>{this.currentEvent="mouse",e(this,t.elements.toggle,i)})}),this.isTopLevel&&this.elements.controller&&this.elements.controller.dom.toggle.addEventListener("pointerup",t=>{this.currentEvent="mouse",e(this,this.elements.controller,t)})}_handleHover(){this.elements.menuItems.forEach((e,t)=>{e.dom.link.addEventListener("pointerenter",s=>{if(!(s.pointerType==="pen"||s.pointerType==="touch")){if(this.hoverType==="on")this.currentEvent="mouse",this.currentChild=t,e.isSubmenuItem&&(this.enterDelay>0?this._hoverTimeout=setTimeout(()=>{e.elements.toggle.preview()},this.enterDelay):e.elements.toggle.preview());else if(this.hoverType==="dynamic"){const i=this.elements.submenuToggles.some(o=>o.isOpen);this.currentChild=t,(!this.isTopLevel||this.focusState!=="none")&&(this.currentEvent="mouse",this.focusCurrentChild()),e.isSubmenuItem&&(!this.isTopLevel||i)&&(this.currentEvent="mouse",this.enterDelay>0?this._hoverTimeout=setTimeout(()=>{e.elements.toggle.preview()},this.enterDelay):e.elements.toggle.preview())}}}),e.isSubmenuItem&&e.dom.item.addEventListener("pointerleave",s=>{s.pointerType==="pen"||s.pointerType==="touch"||(this.hoverType==="on"?this.leaveDelay>0?(clearTimeout(this._hoverTimeout),setTimeout(()=>{this.currentEvent="mouse",e.elements.toggle.close()},this.leaveDelay)):(this.currentEvent="mouse",e.elements.toggle.close()):this.hoverType==="dynamic"&&(this.isTopLevel||(this.leaveDelay>0?(clearTimeout(this._hoverTimeout),setTimeout(()=>{this.currentEvent="mouse",e.elements.toggle.close(),this.focusCurrentChild()},this.leaveDelay)):(this.currentEvent="mouse",e.elements.toggle.close(),this.focusCurrentChild()))))})})}_handleKeydown(){this.isTopLevel&&this.elements.controller&&this.elements.controller.dom.toggle.addEventListener("keydown",e=>{this.currentEvent="keyboard";const t=w(e);(t==="Space"||t==="Enter")&&m(e)})}_handleKeyup(){this.isTopLevel&&this.elements.controller&&this.elements.controller.dom.toggle.addEventListener("keyup",e=>{this.currentEvent="keyboard";const t=w(e);(t==="Space"||t==="Enter")&&(m(e),this.elements.controller.open(),this.focusFirstChild())})}focus(){this.focusState="self",this.shouldFocus&&this.dom.menu.focus()}blur(){this.focusState="none",this.shouldFocus&&this.dom.menu.blur()}focusCurrentChild(){this.focusState="self",this.currentChild!==-1&&this.currentMenuItem.focus()}focusChild(e){this.blurCurrentChild(),this.currentChild=e,this.focusCurrentChild()}focusFirstChild(){this.focusChild(0)}focusLastChild(){this.focusChild(this.elements.menuItems.length-1)}focusNextChild(){this.currentChild<this.elements.menuItems.length-1?this.focusChild(this.currentChild+1):this.focusCurrentChild()}focusPreviousChild(){this.currentChild>0?this.focusChild(this.currentChild-1):this.focusCurrentChild()}blurCurrentChild(){this.focusState="none",this.currentChild!==-1&&this.currentMenuItem.blur()}focusController(){this.dom.controller&&(this.shouldFocus&&this.dom.controller.focus(),this.focusState="none")}focusContainer(){this.dom.container&&(this.shouldFocus&&this.dom.container.focus(),this.focusState="none")}closeChildren(){this.elements.submenuToggles.forEach(e=>e.close())}blurChildren(){this.elements.menuItems.forEach(e=>{e.blur(),e.isSubmenuItem&&e.elements.childMenu.blurChildren()})}}class z extends x{constructor({menuItemElement:e,menuLinkElement:t,parentMenu:s,isSubmenuItem:i=!1,childMenu:o=null,toggle:l=null,initialize:c=!0}){super({menuItemElement:e,menuLinkElement:t,parentMenu:s,isSubmenuItem:i,childMenu:o,toggle:l}),c&&this.initialize()}}class j extends F{constructor({menuToggleElement:e,parentElement:t,controlledMenu:s,parentMenu:i=null,initialize:o=!0}){super({menuToggleElement:e,parentElement:t,controlledMenu:s,parentMenu:i}),o&&this.initialize()}open(){this.closeSiblings(),super.open()}preview(){this.closeSiblings(),super.preview()}close(){this.isOpen&&this.closeChildren(),super.close()}}class D extends S{constructor({menuElement:t,menuItemSelector:s="li",menuLinkSelector:i="a",submenuItemSelector:o="",submenuToggleSelector:l="a",submenuSelector:c="ul",controllerElement:p=null,containerElement:a=null,openClass:y="show",closeClass:b="hide",transitionClass:_="transitioning",isTopLevel:C=!0,parentMenu:E=null,hoverType:M="off",hoverDelay:T=250,enterDelay:v=-1,leaveDelay:I=-1,optionalKeySupport:L=!1,initialize:$=!0}){super({menuElement:t,menuItemSelector:s,menuLinkSelector:i,submenuItemSelector:o,submenuToggleSelector:l,submenuSelector:c,controllerElement:p,containerElement:a,openClass:y,closeClass:b,transitionClass:_,isTopLevel:C,parentMenu:E,hoverType:M,hoverDelay:T,enterDelay:v,leaveDelay:I});r(this,"_MenuType",D);r(this,"_MenuItemType",z);r(this,"_MenuToggleType",j);r(this,"_currentChild",-1);r(this,"_optionalSupport",!1);this._optionalSupport=L,$&&this.initialize()}initialize(){try{super.initialize(),this._handleFocus(),this._handleClick(),this._handleHover(),this._handleKeydown(),this._handleKeyup()}catch(t){console.error(t)}}get optionalKeySupport(){return this.isTopLevel?this._optionalSupport:this.elements.rootMenu.optionalKeySupport}set optionalKeySupport(t){d("boolean",{optionalKeySupport:t}),this._optionalSupport=t}_validate(){let t=super._validate();const s=d("boolean",{optionalKeySupport:this._optionalSupport});return s.status||(this._errors.push(s.error.message),t=!1),t}_handleClick(){super._handleClick(),document.addEventListener("pointerup",t=>{this.focusState!=="none"&&(this.currentEvent="mouse",!this.dom.menu.contains(t.target)&&!this.dom.menu!==t.target&&(this.closeChildren(),this.blur(),this.elements.controller&&this.elements.controller.close()))})}_handleKeydown(){super._handleKeydown(),this.dom.menu.addEventListener("keydown",t=>{this.currentEvent="keyboard";const s=w(t);if(this.focusState==="self"){const i=["Space","Enter"],o=["Escape"],l=["Escape"];this.optionalKeySupport?["ArrowUp","ArrowRight","ArrowDown","ArrowLeft","Home","End"].includes(s)&&m(t):(this.currentMenuItem.isSubmenuItem&&i.includes(s)||this.elements.controller&&o.includes(s)||this.elements.parentMenu&&l.includes(s))&&m(t)}})}_handleKeyup(){super._handleKeyup(),this.dom.menu.addEventListener("keyup",t=>{this.currentEvent="keyboard";const s=w(t);this.focusState==="self"&&(s==="Space"||s==="Enter"?this.currentMenuItem.isSubmenuItem?(m(t),this.currentMenuItem.elements.toggle.isOpen?this.currentMenuItem.elements.toggle.close():this.currentMenuItem.elements.toggle.preview()):this.currentMenuItem.dom.link.click():s==="Escape"?this.elements.submenuToggles.some(o=>o.isOpen)?(m(t),this.closeChildren()):this.elements.parentMenu?(m(t),this.elements.parentMenu.currentEvent=this.currentEvent,this.elements.parentMenu.closeChildren(),this.elements.parentMenu.focusCurrentChild()):this.isTopLevel&&this.elements.controller&&this.elements.controller.isOpen&&(this.elements.controller.close(),this.focusController()):this.optionalKeySupport&&(s==="ArrowDown"||s==="ArrowRight"?(m(t),this.currentMenuItem.isSubmenuItem&&this.currentMenuItem.elements.toggle.isOpen?(this.currentMenuItem.elements.childMenu.currentEvent="keyboard",this.currentMenuItem.elements.childMenu.focusFirstChild()):this.focusNextChild()):s==="ArrowUp"||s==="ArrowLeft"?(m(t),this.focusPreviousChild()):s==="Home"?(m(t),this.focusFirstChild()):s==="End"&&(m(t),this.focusLastChild())))})}}class H extends z{constructor({menuItemElement:e,menuLinkElement:t,parentMenu:s,isSubmenuItem:i=!1,childMenu:o=null,toggle:l=null,initialize:c=!0}){super({menuItemElement:e,menuLinkElement:t,parentMenu:s,isSubmenuItem:i,childMenu:o,toggle:l,initialize:!1}),c&&this.initialize()}}class R extends j{constructor({menuToggleElement:t,parentElement:s,controlledMenu:i,parentMenu:o=null,initialize:l=!0}){super({menuToggleElement:t,parentElement:s,controlledMenu:i,parentMenu:o,initialize:!1});r(this,"_dom",{toggle:null,parent:null,container:null});this._dom.toggle=t,this._dom.parent=s,this._dom.container=i.isTopLevel?i.dom.container:i.dom.menu,l&&this.initialize()}initialize(){super.initialize(),this.dom.toggle.hasAttribute("data-bs-toggle")&&this.dom.toggle.removeAttribute("data-bs-toggle"),this.dom.toggle.hasAttribute("data-bs-target")&&this.dom.toggle.removeAttribute("data-bs-target")}_expand(t=!0){const{openClass:s,transitionClass:i}=this.elements.controlledMenu;this.dom.toggle.setAttribute("aria-expanded","true"),i!==""?(u(i,this.dom.container),requestAnimationFrame(()=>{u(s,this.dom.container),requestAnimationFrame(()=>{h(i,this.dom.container)})})):s!==""&&u(s,this.dom.container),t&&this.dom.toggle.dispatchEvent(this._expandEvent)}_collapse(t=!0){const{closeClass:s,openClass:i,transitionClass:o}=this.elements.controlledMenu;this.dom.toggle.setAttribute("aria-expanded","false"),o!==""?(u(o,this.dom.container),requestAnimationFrame(()=>{i!==""&&h(i,this.dom.container),requestAnimationFrame(()=>{s!==""&&u(s,this.dom.container),requestAnimationFrame(()=>{h(o,this.dom.container)})})})):(s!==""&&u(s,this.dom.container),i!==""&&h(i,this.dom.container)),t&&this.dom.toggle.dispatchEvent(this._collapseEvent)}}class A extends D{constructor({menuElement:t,menuItemSelector:s=".nav-item,li",menuLinkSelector:i=".nav-link,.dropdown-item",submenuItemSelector:o=".dropdown",submenuToggleSelector:l=".dropdown-toggle",submenuSelector:c=".dropdown-menu",controllerElement:p=null,containerElement:a=null,openClass:y="show",closeClass:b="collapse",transitionClass:_="transitioning",isTopLevel:C=!0,parentMenu:E=null,hoverType:M="off",hoverDelay:T=250,enterDelay:v=-1,leaveDelay:I=-1,optionalKeySupport:L=!1,initialize:$=!0}){super({menuElement:t,menuItemSelector:s,menuLinkSelector:i,submenuItemSelector:o,submenuToggleSelector:l,submenuSelector:c,controllerElement:p,containerElement:a,openClass:y,closeClass:b,transitionClass:_,isTopLevel:C,parentMenu:E,hoverType:M,hoverDelay:T,enterDelay:v,leaveDelay:I,optionalKeySupport:L,initialize:!1});r(this,"_MenuType",A);r(this,"_MenuItemType",H);r(this,"_MenuToggleType",R);$&&this.initialize()}}return A}(); | ||
- `)}`);if(this.elements.rootMenu===null&&this._findRootMenu(this),this._setDOMElements(),this.isTopLevel&&this.dom.controller&&this.dom.container){const e=new this._MenuToggleType({menuToggleElement:this.dom.controller,parentElement:this.dom.container,controlledMenu:this});this._elements.controller=e}this._createChildElements()}get dom(){return this._dom}get selectors(){return this._selectors}get elements(){return this._elements}get isTopLevel(){return this._root}get openClass(){return this.isTopLevel?this._openClass:this.elements.rootMenu.openClass}get closeClass(){return this.isTopLevel?this._closeClass:this.elements.rootMenu.closeClass}get transitionClass(){return this.isTopLevel?this._transitionClass:this.elements.rootMenu.transitionClass}get currentChild(){return this._currentChild}get focusState(){return this._focusState}get currentEvent(){return this._currentEvent}get currentMenuItem(){return this.elements.menuItems[this.currentChild]}get hoverType(){return this._root?this._hoverType:this.elements.rootMenu.hoverType}get hoverDelay(){return this._root?this._hoverDelay:this.elements.rootMenu.hoverDelay}get enterDelay(){return this._enterDelay===-1?this.hoverDelay:this._root?this._enterDelay:this.elements.rootMenu.enterDelay}get leaveDelay(){return this._leaveDelay===-1?this.hoverDelay:this._root?this._leaveDelay:this.elements.rootMenu.leaveDelay}get shouldFocus(){let e=!1;return(this.currentEvent==="keyboard"||this.currentEvent==="character")&&(e=!0),this.currentEvent==="mouse"&&this.hoverType==="dynamic"&&(e=!0),e}get errors(){return this._errors}set openClass(e){g({openClass:e}),this._openClass!==e&&(this._openClass=e)}set closeClass(e){g({closeClass:e}),this._closeClass!==e&&(this._closeClass=e)}set transitionClass(e){g({transitionClass:e}),this._transitionClass!==e&&(this._transitionClass=e)}set currentChild(e){d("number",{value:e});function t(s){if(["mouse","character"].includes(s.currentEvent)&&s.elements.parentMenu){let o=0,l=!1;for(;!l&&o<s.elements.parentMenu.elements.menuItems.length;){const c=s.elements.parentMenu.elements.menuItems[o];c.isSubmenuItem&&c.elements.toggle.elements.controlledMenu===s&&(l=!0,s.elements.parentMenu.currentEvent=s.currentEvent,s.elements.parentMenu.currentChild=o),o++}}}e<-1?(this._currentChild=-1,t(this)):e>=this.elements.menuItems.length?(this._currentChild=this.elements.menuItems.length-1,t(this)):this.focusChild!==e&&(this._currentChild=e,t(this))}set focusState(e){K({value:e}),this._focusState!==e&&(this._focusState=e),this.elements.submenuToggles.length>0&&(e==="self"||e==="none")&&this.elements.submenuToggles.forEach(t=>{t.elements.controlledMenu.focusState="none"}),this.elements.parentMenu&&(e==="self"||e==="child")&&(this.elements.parentMenu.focusState="child")}set currentEvent(e){V({value:e}),this._currentEvent!==e&&(this._currentEvent=e,this.elements.submenuToggles.length>0&&this.elements.submenuToggles.forEach(t=>{t.elements.controlledMenu.currentEvent=e}))}set hoverType(e){O({value:e}),this._hoverType!==e&&(this._hoverType=e)}set hoverDelay(e){d("number",{value:e}),this._hoverDelay!==e&&(this._hoverDelay=e)}set enterDelay(e){d("number",{value:e}),this._enterDelay!==e&&(this._enterDelay=e)}set leaveDelay(e){d("number",{value:e}),this._leaveDelay!==e&&(this._leaveDelay=e)}_validate(){let e=!0,t;this._dom.container!==null||this._dom.controller!==null?t=f(HTMLElement,{menuElement:this._dom.menu,controllerElement:this._dom.controller,containerElement:this._dom.container}):t=f(HTMLElement,{menuElement:this._dom.menu}),t.status||(this._errors.push(t.error.message),e=!1);let s;if(this._selectors.submenuItems!==""?s=D({menuItemSelector:this._selectors.menuItems,menuLinkSelector:this._selectors.menuLinks,submenuItemSelector:this._selectors.submenuItems,submenuToggleSelector:this._selectors.submenuToggles,submenuSelector:this._selectors.submenus}):s=D({menuItemSelector:this._selectors.menuItems,menuLinkSelector:this._selectors.menuLinks}),s.status||(this._errors.push(s.error.message),e=!1),this._openClass!==""){const a=g({openClass:this._openClass});a.status||(this._errors.push(a.error.message),e=!1)}if(this._closeClass!==""){const a=g({closeClass:this._closeClass});a.status||(this._errors.push(a.error.message),e=!1)}if(this._transitionClass!==""){const a=g({transitionClass:this._transitionClass});a.status||(this._errors.push(a.error.message),e=!1)}const i=d("boolean",{isTopLevel:this._root});if(i.status||(this._errors.push(i.error.message),e=!1),this._elements.parentMenu!==null){const a=f(S,{parentMenu:this._elements.parentMenu});a.status||(this._errors.push(a.error.message),e=!1)}const o=O({hoverType:this._hoverType});o.status||(this._errors.push(o.error.message),e=!1);const l=d("number",{hoverDelay:this._hoverDelay});l.status||(this._errors.push(l.error.message),e=!1);const c=d("number",{enterDelay:this._enterDelay});c.status||(this._errors.push(c.error.message),e=!1);const p=d("number",{leaveDelay:this._leaveDelay});return p.status||(this._errors.push(p.error.message),e=!1),e}_setDOMElementType(e,t=this.dom.menu,s=!0){if(typeof this.selectors[e]=="string"){if(!Array.isArray(this.dom[e]))throw new Error(`AccessibleMenu: The "${e}" element cannot be set through _setDOMElementType.`);t!==this.dom.menu&&f(HTMLElement,{base:t});const o=Array.from(t.querySelectorAll(this.selectors[e])).filter(l=>l.parentElement===t);s?this._dom[e]=o:this._dom[e]=[...this._dom[e],...o]}else throw new Error(`AccessibleMenu: "${e}" is not a valid element type within the menu.`)}_resetDOMElementType(e){if(typeof this.dom[e]<"u"){if(!Array.isArray(this.dom[e]))throw new Error(`AccessibleMenu: The "${e}" element cannot be reset through _resetDOMElementType.`);this._dom[e]=[]}else throw new Error(`AccessibleMenu: "${e}" is not a valid element type within the menu.`)}_setDOMElements(){this._setDOMElementType("menuItems"),this.selectors.submenuItems!==""&&(this._setDOMElementType("submenuItems"),this._resetDOMElementType("submenuToggles"),this._resetDOMElementType("submenus"),this.dom.submenuItems.forEach(e=>{this._setDOMElementType("submenuToggles",e,!1),this._setDOMElementType("submenus",e,!1)}))}_findRootMenu(e){if(e.isTopLevel)this._elements.rootMenu=e;else if(e.elements.parentMenu!==null)this._findRootMenu(e.elements.parentMenu);else throw new Error("Cannot find root menu.")}_createChildElements(){this.dom.menuItems.forEach(e=>{let t;if(this.dom.submenuItems.includes(e)){const s=e.querySelector(this.selectors.submenuToggles),i=e.querySelector(this.selectors.submenus),o=new this._MenuType({menuElement:i,menuItemSelector:this.selectors.menuItems,menuLinkSelector:this.selectors.menuLinks,submenuItemSelector:this.selectors.submenuItems,submenuToggleSelector:this.selectors.submenuToggles,submenuSelector:this.selectors.submenus,openClass:this.openClass,closeClass:this.closeClass,transitionClass:this.transitionClass,isTopLevel:!1,parentMenu:this,hoverType:this.hoverType,hoverDelay:this.hoverDelay,enterDelay:this.enterDelay,leaveDelay:this.leaveDelay}),l=new this._MenuToggleType({menuToggleElement:s,parentElement:e,controlledMenu:o,parentMenu:this});this._elements.submenuToggles.push(l),t=new this._MenuItemType({menuItemElement:e,menuLinkElement:s,parentMenu:this,isSubmenuItem:!0,childMenu:o,toggle:l})}else{const s=e.querySelector(this.selectors.menuLinks);t=new this._MenuItemType({menuItemElement:e,menuLinkElement:s,parentMenu:this})}this._elements.menuItems.push(t)})}_handleFocus(){this.elements.menuItems.forEach((e,t)=>{e.dom.link.addEventListener("focus",()=>{this.focusState="self",this.currentChild=t})})}_handleClick(){function e(t,s,i){m(i),s.toggle(),s.isOpen&&(t.focusState="self",s.elements.controlledMenu.focusState="none")}this.elements.menuItems.forEach((t,s)=>{t.dom.link.addEventListener("pointerdown",()=>{this.currentEvent="mouse",this.elements.rootMenu.blurChildren(),this.focusChild(s)},{passive:!0}),t.isSubmenuItem&&t.elements.toggle.dom.toggle.addEventListener("pointerup",i=>{this.currentEvent="mouse",e(this,t.elements.toggle,i)})}),this.isTopLevel&&this.elements.controller&&this.elements.controller.dom.toggle.addEventListener("pointerup",t=>{this.currentEvent="mouse",e(this,this.elements.controller,t)})}_handleHover(){this.elements.menuItems.forEach((e,t)=>{e.dom.link.addEventListener("pointerenter",s=>{if(!(s.pointerType==="pen"||s.pointerType==="touch")){if(this.hoverType==="on")this.currentEvent="mouse",this.elements.rootMenu.blurChildren(),this.focusChild(t),e.isSubmenuItem&&(this.enterDelay>0?this._hoverTimeout=setTimeout(()=>{e.elements.toggle.preview()},this.enterDelay):e.elements.toggle.preview());else if(this.hoverType==="dynamic"){const i=this.elements.submenuToggles.some(o=>o.isOpen);this.currentChild=t,(!this.isTopLevel||this.focusState!=="none")&&(this.currentEvent="mouse",this.elements.rootMenu.blurChildren(),this.focusCurrentChild()),e.isSubmenuItem&&(!this.isTopLevel||i)&&(this.currentEvent="mouse",this.elements.rootMenu.blurChildren(),this.focusCurrentChild(),this.enterDelay>0?this._hoverTimeout=setTimeout(()=>{e.elements.toggle.preview()},this.enterDelay):e.elements.toggle.preview())}}}),e.isSubmenuItem&&e.dom.item.addEventListener("pointerleave",s=>{s.pointerType==="pen"||s.pointerType==="touch"||(this.hoverType==="on"?this.leaveDelay>0?(clearTimeout(this._hoverTimeout),setTimeout(()=>{this.currentEvent="mouse",e.elements.toggle.close()},this.leaveDelay)):(this.currentEvent="mouse",e.elements.toggle.close()):this.hoverType==="dynamic"&&(this.isTopLevel||(this.leaveDelay>0?(clearTimeout(this._hoverTimeout),setTimeout(()=>{this.currentEvent="mouse",e.elements.toggle.close(),this.focusCurrentChild()},this.leaveDelay)):(this.currentEvent="mouse",e.elements.toggle.close(),this.focusCurrentChild()))))})})}_handleKeydown(){this.isTopLevel&&this.elements.controller&&this.elements.controller.dom.toggle.addEventListener("keydown",e=>{this.currentEvent="keyboard";const t=w(e);(t==="Space"||t==="Enter")&&m(e)})}_handleKeyup(){this.isTopLevel&&this.elements.controller&&this.elements.controller.dom.toggle.addEventListener("keyup",e=>{this.currentEvent="keyboard";const t=w(e);(t==="Space"||t==="Enter")&&(m(e),this.elements.controller.toggle(),this.elements.controller.isOpen&&this.focusFirstChild())})}focus(){this.focusState="self",this.shouldFocus&&this.dom.menu.focus()}blur(){this.focusState="none",this.shouldFocus&&this.dom.menu.blur()}focusCurrentChild(){this.focusState="self",this.currentChild!==-1&&this.currentMenuItem.focus()}focusChild(e){this.blurCurrentChild(),this.currentChild=e,this.focusCurrentChild()}focusFirstChild(){this.focusChild(0)}focusLastChild(){this.focusChild(this.elements.menuItems.length-1)}focusNextChild(){this.currentChild<this.elements.menuItems.length-1?this.focusChild(this.currentChild+1):this.focusCurrentChild()}focusPreviousChild(){this.currentChild>0?this.focusChild(this.currentChild-1):this.focusCurrentChild()}blurCurrentChild(){this.focusState="none",this.currentChild!==-1&&this.currentMenuItem.blur()}focusController(){this.dom.controller&&(this.shouldFocus&&this.dom.controller.focus(),this.focusState="none")}focusContainer(){this.dom.container&&(this.shouldFocus&&this.dom.container.focus(),this.focusState="none")}closeChildren(){this.elements.submenuToggles.forEach(e=>e.close())}blurChildren(){this.elements.menuItems.forEach(e=>{e.blur(),e.isSubmenuItem&&e.elements.childMenu.blurChildren()})}}class z extends x{constructor({menuItemElement:e,menuLinkElement:t,parentMenu:s,isSubmenuItem:i=!1,childMenu:o=null,toggle:l=null,initialize:c=!0}){super({menuItemElement:e,menuLinkElement:t,parentMenu:s,isSubmenuItem:i,childMenu:o,toggle:l}),c&&this.initialize()}}class j extends F{constructor({menuToggleElement:e,parentElement:t,controlledMenu:s,parentMenu:i=null,initialize:o=!0}){super({menuToggleElement:e,parentElement:t,controlledMenu:s,parentMenu:i}),o&&this.initialize()}open(){this.closeSiblings(),super.open()}preview(){this.closeSiblings(),super.preview()}close(){this.isOpen&&this.closeChildren(),super.close()}}class k extends S{constructor({menuElement:t,menuItemSelector:s="li",menuLinkSelector:i="a",submenuItemSelector:o="",submenuToggleSelector:l="a",submenuSelector:c="ul",controllerElement:p=null,containerElement:a=null,openClass:y="show",closeClass:b="hide",transitionClass:_="transitioning",isTopLevel:C=!0,parentMenu:E=null,hoverType:M="off",hoverDelay:T=250,enterDelay:v=-1,leaveDelay:I=-1,optionalKeySupport:L=!1,initialize:$=!0}){super({menuElement:t,menuItemSelector:s,menuLinkSelector:i,submenuItemSelector:o,submenuToggleSelector:l,submenuSelector:c,controllerElement:p,containerElement:a,openClass:y,closeClass:b,transitionClass:_,isTopLevel:C,parentMenu:E,hoverType:M,hoverDelay:T,enterDelay:v,leaveDelay:I});r(this,"_MenuType",k);r(this,"_MenuItemType",z);r(this,"_MenuToggleType",j);r(this,"_currentChild",-1);r(this,"_optionalSupport",!1);this._optionalSupport=L,$&&this.initialize()}initialize(){try{super.initialize(),this._handleFocus(),this._handleClick(),this._handleHover(),this._handleKeydown(),this._handleKeyup()}catch(t){console.error(t)}}get optionalKeySupport(){return this.isTopLevel?this._optionalSupport:this.elements.rootMenu.optionalKeySupport}set optionalKeySupport(t){d("boolean",{optionalKeySupport:t}),this._optionalSupport=t}_validate(){let t=super._validate();const s=d("boolean",{optionalKeySupport:this._optionalSupport});return s.status||(this._errors.push(s.error.message),t=!1),t}_handleClick(){super._handleClick(),document.addEventListener("pointerup",t=>{this.focusState!=="none"&&(this.currentEvent="mouse",!this.dom.menu.contains(t.target)&&!this.dom.menu!==t.target&&(this.closeChildren(),this.blur(),this.elements.controller&&this.elements.controller.close()))})}_handleKeydown(){super._handleKeydown(),this.dom.menu.addEventListener("keydown",t=>{this.currentEvent="keyboard";const s=w(t);if(this.focusState==="self"){const i=["Space","Enter"],o=["Escape"],l=["Escape"];this.optionalKeySupport?["ArrowUp","ArrowRight","ArrowDown","ArrowLeft","Home","End"].includes(s)&&m(t):(this.currentMenuItem.isSubmenuItem&&i.includes(s)||this.elements.controller&&o.includes(s)||this.elements.parentMenu&&l.includes(s))&&m(t)}})}_handleKeyup(){super._handleKeyup(),this.dom.menu.addEventListener("keyup",t=>{this.currentEvent="keyboard";const s=w(t);this.focusState==="self"&&(s==="Space"||s==="Enter"?this.currentMenuItem.isSubmenuItem?(m(t),this.currentMenuItem.elements.toggle.isOpen?this.currentMenuItem.elements.toggle.close():this.currentMenuItem.elements.toggle.preview()):this.currentMenuItem.dom.link.click():s==="Escape"?this.elements.submenuToggles.some(o=>o.isOpen)?(m(t),this.closeChildren()):this.elements.parentMenu?(m(t),this.elements.parentMenu.currentEvent=this.currentEvent,this.elements.parentMenu.closeChildren(),this.elements.parentMenu.focusCurrentChild()):this.isTopLevel&&this.elements.controller&&this.elements.controller.isOpen&&(this.elements.controller.close(),this.focusController()):this.optionalKeySupport&&(s==="ArrowDown"||s==="ArrowRight"?(m(t),this.currentMenuItem.isSubmenuItem&&this.currentMenuItem.elements.toggle.isOpen?(this.currentMenuItem.elements.childMenu.currentEvent="keyboard",this.currentMenuItem.elements.childMenu.focusFirstChild()):this.focusNextChild()):s==="ArrowUp"||s==="ArrowLeft"?(m(t),this.focusPreviousChild()):s==="Home"?(m(t),this.focusFirstChild()):s==="End"&&(m(t),this.focusLastChild())))})}}class H extends z{constructor({menuItemElement:e,menuLinkElement:t,parentMenu:s,isSubmenuItem:i=!1,childMenu:o=null,toggle:l=null,initialize:c=!0}){super({menuItemElement:e,menuLinkElement:t,parentMenu:s,isSubmenuItem:i,childMenu:o,toggle:l,initialize:!1}),c&&this.initialize()}}class R extends j{constructor({menuToggleElement:t,parentElement:s,controlledMenu:i,parentMenu:o=null,initialize:l=!0}){super({menuToggleElement:t,parentElement:s,controlledMenu:i,parentMenu:o,initialize:!1});r(this,"_dom",{toggle:null,parent:null,container:null});this._dom.toggle=t,this._dom.parent=s,this._dom.container=i.isTopLevel?i.dom.container:i.dom.menu,l&&this.initialize()}initialize(){super.initialize(),this.dom.toggle.hasAttribute("data-bs-toggle")&&this.dom.toggle.removeAttribute("data-bs-toggle"),this.dom.toggle.hasAttribute("data-bs-target")&&this.dom.toggle.removeAttribute("data-bs-target")}_expand(t=!0){const{openClass:s,transitionClass:i}=this.elements.controlledMenu;this.dom.toggle.setAttribute("aria-expanded","true"),i!==""?(u(i,this.dom.container),requestAnimationFrame(()=>{u(s,this.dom.container),requestAnimationFrame(()=>{h(i,this.dom.container)})})):s!==""&&u(s,this.dom.container),t&&this.dom.toggle.dispatchEvent(this._expandEvent)}_collapse(t=!0){const{closeClass:s,openClass:i,transitionClass:o}=this.elements.controlledMenu;this.dom.toggle.setAttribute("aria-expanded","false"),o!==""?(u(o,this.dom.container),requestAnimationFrame(()=>{i!==""&&h(i,this.dom.container),requestAnimationFrame(()=>{s!==""&&u(s,this.dom.container),requestAnimationFrame(()=>{h(o,this.dom.container)})})})):(s!==""&&u(s,this.dom.container),i!==""&&h(i,this.dom.container)),t&&this.dom.toggle.dispatchEvent(this._collapseEvent)}}class A extends k{constructor({menuElement:t,menuItemSelector:s=".nav-item,li",menuLinkSelector:i=".nav-link,.dropdown-item",submenuItemSelector:o=".dropdown",submenuToggleSelector:l=".dropdown-toggle",submenuSelector:c=".dropdown-menu",controllerElement:p=null,containerElement:a=null,openClass:y="show",closeClass:b="collapse",transitionClass:_="transitioning",isTopLevel:C=!0,parentMenu:E=null,hoverType:M="off",hoverDelay:T=250,enterDelay:v=-1,leaveDelay:I=-1,optionalKeySupport:L=!1,initialize:$=!0}){super({menuElement:t,menuItemSelector:s,menuLinkSelector:i,submenuItemSelector:o,submenuToggleSelector:l,submenuSelector:c,controllerElement:p,containerElement:a,openClass:y,closeClass:b,transitionClass:_,isTopLevel:C,parentMenu:E,hoverType:M,hoverDelay:T,enterDelay:v,leaveDelay:I,optionalKeySupport:L,initialize:!1});r(this,"_MenuType",A);r(this,"_MenuItemType",H);r(this,"_MenuToggleType",R);$&&this.initialize()}}return A}(); |
@@ -1,3 +0,3 @@ | ||
var Bootstrap5Menubar=function(){"use strict";var R=Object.defineProperty;var P=(m,c,f)=>c in m?R(m,c,{enumerable:!0,configurable:!0,writable:!0,value:f}):m[c]=f;var o=(m,c,f)=>(P(m,typeof c!="symbol"?c+"":c,f),f);function m(i,e){typeof i=="string"?e.classList.add(i):e.classList.add(...i)}function c(i,e){typeof i=="string"?e.classList.remove(i):e.classList.remove(...i)}function f(i,e){try{if(typeof e!="object"){const t=typeof e;throw new TypeError(`Elements given to isValidInstance() must be inside of an object. "${t}" given.`)}for(const t in e)if(!(e[t]instanceof i)){const s=typeof e[t];throw new TypeError(`${t} must be an instance of ${i.name}. "${s}" given.`)}return{status:!0,error:null}}catch(t){return{status:!1,error:t}}}function p(i,e){try{if(typeof e!="object"){const t=typeof e;throw new TypeError(`Values given to isValidType() must be inside of an object. "${t}" given.`)}for(const t in e){const s=typeof e[t];if(s!==i)throw new TypeError(`${t} must be a ${i}. "${s}" given.`)}return{status:!0,error:null}}catch(t){return{status:!1,error:t}}}function S(i){try{if(typeof i!="object"){const e=typeof i;throw new TypeError(`Values given to isCSSSelector() must be inside of an object. "${e}" given.`)}for(const e in i)try{if(i[e]===null)throw new Error;document.querySelector(i[e])}catch{throw new TypeError(`${e} must be a valid CSS selector. "${i[e]}" given.`)}return{status:!0,error:null}}catch(e){return{status:!1,error:e}}}function g(i){try{if(typeof i!="object"||Array.isArray(i)){const e=typeof i;throw new TypeError(`Values given to isValidClassList() must be inside of an object. "${e}" given.`)}for(const e in i){const t=typeof i[e];if(t!=="string")if(Array.isArray(i[e]))i[e].forEach(s=>{if(typeof s!="string")throw new TypeError(`${e} must be a string or an array of strings. An array containing non-strings given.`)});else throw new TypeError(`${e} must be a string or an array of strings. "${t}" given.`);else{const s={};s[e]=i[e],S(s)}}return{status:!0,error:null}}catch(e){return{status:!1,error:e}}}function q(i){try{if(typeof i!="object"){const t=typeof i;throw new TypeError(`Values given to isValidState() must be inside of an object. "${t}" given.`)}const e=["none","self","child"];for(const t in i)if(!e.includes(i[t]))throw new TypeError(`${t} must be one of the following values: ${e.join(", ")}. "${i[t]}" given.`);return{status:!0,error:null}}catch(e){return{status:!1,error:e}}}function j(i){try{if(typeof i!="object"){const t=typeof i;throw new TypeError(`Values given to isValidEvent() must be inside of an object. "${t}" given.`)}const e=["none","mouse","keyboard","character"];for(const t in i)if(!e.includes(i[t]))throw new TypeError(`${t} must be one of the following values: ${e.join(", ")}. "${i[t]}" given.`);return{status:!0,error:null}}catch(e){return{status:!1,error:e}}}function $(i){try{if(typeof i!="object"){const t=typeof i;throw new TypeError(`Values given to isValidHoverType() must be inside of an object. "${t}" given.`)}const e=["off","on","dynamic"];for(const t in i)if(!e.includes(i[t]))throw new TypeError(`${t} must be one of the following values: ${e.join(", ")}. "${i[t]}" given.`);return{status:!0,error:null}}catch(e){return{status:!1,error:e}}}function V(i,e){if(p("string",{tagName:i}).status&&f(HTMLElement,e).status){const t=i.toLowerCase();let s=!0;for(const n in e)e[n].tagName.toLowerCase()!==t&&(s=!1);return s}else return!1}class x{constructor({menuToggleElement:e,parentElement:t,controlledMenu:s,parentMenu:n=null}){o(this,"_dom",{toggle:null,parent:null});o(this,"_elements",{controlledMenu:null,parentMenu:null});o(this,"_open",!1);o(this,"_expandEvent",new CustomEvent("accessibleMenuExpand",{bubbles:!0,detail:{toggle:this}}));o(this,"_collapseEvent",new CustomEvent("accessibleMenuCollapse",{bubbles:!0,detail:{toggle:this}}));this._dom.toggle=e,this._dom.parent=t,this._elements.controlledMenu=s,this._elements.parentMenu=n}initialize(){var e;if(this.dom.toggle.setAttribute("aria-haspopup","true"),this.dom.toggle.setAttribute("aria-expanded","false"),V("button",{toggle:this.dom.toggle})||this.dom.toggle.setAttribute("role","button"),this.dom.toggle.id===""||this.elements.controlledMenu.dom.menu.id===""){const t=Math.random().toString(36).replace(/[^a-z]+/g,"").substr(0,10);let s=((e=this.dom.toggle.innerText)==null?void 0:e.replace(/[^a-zA-Z0-9\s]/g,""))||"",n=t;!s.replace(/\s/g,"").length&&this.dom.toggle.getAttribute("aria-label")&&(s=this.dom.toggle.getAttribute("aria-label").replace(/[^a-zA-Z0-9\s]/g,"")),s.replace(/\s/g,"").length>0&&(s=s.toLowerCase().replace(/\s+/g,"-"),s.startsWith("-")&&(s=s.substring(1)),s.endsWith("-")&&(s=s.slice(0,-1)),n=`${s}-${n}`),this.dom.toggle.id=this.dom.toggle.id||`${n}-menu-button`,this.elements.controlledMenu.dom.menu.id=this.elements.controlledMenu.dom.menu.id||`${n}-menu`}this.elements.controlledMenu.dom.menu.setAttribute("aria-labelledby",this.dom.toggle.id),this.dom.toggle.setAttribute("aria-controls",this.elements.controlledMenu.dom.menu.id),this._collapse(!1)}get dom(){return this._dom}get elements(){return this._elements}get isOpen(){return this._open}set isOpen(e){p("boolean",{value:e}),this._open=e}_expand(e=!0){const{closeClass:t,openClass:s,transitionClass:n}=this.elements.controlledMenu;this.dom.toggle.setAttribute("aria-expanded","true"),n!==""?(m(n,this.elements.controlledMenu.dom.menu),requestAnimationFrame(()=>{t!==""&&c(t,this.elements.controlledMenu.dom.menu),requestAnimationFrame(()=>{s!==""&&m(s,this.elements.controlledMenu.dom.menu),requestAnimationFrame(()=>{c(n,this.elements.controlledMenu.dom.menu)})})})):(s!==""&&m(s,this.elements.controlledMenu.dom.menu),t!==""&&c(t,this.elements.controlledMenu.dom.menu)),e&&this.dom.toggle.dispatchEvent(this._expandEvent)}_collapse(e=!0){const{closeClass:t,openClass:s,transitionClass:n}=this.elements.controlledMenu;this.dom.toggle.setAttribute("aria-expanded","false"),n!==""?(m(n,this.elements.controlledMenu.dom.menu),requestAnimationFrame(()=>{s!==""&&c(s,this.elements.controlledMenu.dom.menu),requestAnimationFrame(()=>{t!==""&&m(t,this.elements.controlledMenu.dom.menu),requestAnimationFrame(()=>{c(n,this.elements.controlledMenu.dom.menu)})})})):(t!==""&&m(t,this.elements.controlledMenu.dom.menu),s!==""&&c(s,this.elements.controlledMenu.dom.menu)),e&&this.dom.toggle.dispatchEvent(this._collapseEvent)}open(){this.elements.controlledMenu.focusState="self",this._expand(),this.isOpen=!0}preview(){this.elements.parentMenu&&(this.elements.parentMenu.focusState="self"),this._expand(),this.isOpen=!0}close(){this.isOpen&&(this.elements.controlledMenu.currentChild=0,this.elements.controlledMenu.blur(),this.elements.parentMenu&&(this.elements.parentMenu.focusState="self"),this._collapse(),this.isOpen=!1)}toggle(){this.isOpen?this.close():this.open()}closeSiblings(){this.elements.parentMenu&&this.elements.parentMenu.elements.submenuToggles.forEach(e=>{e!==this&&e.close()})}closeChildren(){this.elements.controlledMenu.elements.submenuToggles.forEach(e=>e.close())}}class F{constructor({menuItemElement:e,menuLinkElement:t,parentMenu:s,isSubmenuItem:n=!1,childMenu:r=null,toggle:l=null}){o(this,"_dom",{item:null,link:null});o(this,"_elements",{parentMenu:null,childMenu:null,toggle:null});o(this,"_submenu",!1);this._dom.item=e,this._dom.link=t,this._elements.parentMenu=s,this._elements.childMenu=r,this._elements.toggle=l,this._submenu=n}initialize(){}get dom(){return this._dom}get elements(){return this._elements}get isSubmenuItem(){return this._submenu}focus(){this.elements.parentMenu.shouldFocus&&this.dom.link.focus()}blur(){this.elements.parentMenu.shouldFocus&&this.dom.link.blur()}}function w(i){try{const e=i.key||i.keyCode,t={Enter:e==="Enter"||e===13,Space:e===" "||e==="Spacebar"||e===32,Escape:e==="Escape"||e==="Esc"||e===27,ArrowUp:e==="ArrowUp"||e==="Up"||e===38,ArrowRight:e==="ArrowRight"||e==="Right"||e===39,ArrowDown:e==="ArrowDown"||e==="Down"||e===40,ArrowLeft:e==="ArrowLeft"||e==="Left"||e===37,Home:e==="Home"||e===36,End:e==="End"||e===35,Character:isNaN(e)&&!!e.match(/^[a-zA-Z]{1}$/),Tab:e==="Tab"||e===9,Asterisk:e==="*"||e===56};return Object.keys(t).find(s=>t[s]===!0)||""}catch{return""}}function u(i){i.preventDefault(),i.stopPropagation()}class I{constructor({menuElement:e,menuItemSelector:t="li",menuLinkSelector:s="a",submenuItemSelector:n="",submenuToggleSelector:r="a",submenuSelector:l="ul",controllerElement:a=null,containerElement:d=null,openClass:h="show",closeClass:_="hide",transitionClass:b="transitioning",isTopLevel:y=!0,parentMenu:M=null,hoverType:C="off",hoverDelay:E=250,enterDelay:T=-1,leaveDelay:v=-1}){o(this,"_MenuType",I);o(this,"_MenuItemType",F);o(this,"_MenuToggleType",x);o(this,"_dom",{menu:null,menuItems:[],submenuItems:[],submenuToggles:[],submenus:[],controller:null,container:null});o(this,"_selectors",{menuItems:"",menuLinks:"",submenuItems:"",submenuToggles:"",submenus:""});o(this,"_elements",{menuItems:[],submenuToggles:[],controller:null,parentMenu:null,rootMenu:null});o(this,"_openClass","show");o(this,"_closeClass","hide");o(this,"_transitionClass","transitioning");o(this,"_root",!0);o(this,"_currentChild",0);o(this,"_focusState","none");o(this,"_currentEvent","none");o(this,"_hoverType","off");o(this,"_hoverDelay",250);o(this,"_enterDelay",-1);o(this,"_leaveDelay",-1);o(this,"_hoverTimeout",null);o(this,"_errors",[]);this._dom.menu=e,this._dom.controller=a,this._dom.container=d,this._selectors.menuItems=t,this._selectors.menuLinks=s,this._selectors.submenuItems=n,this._selectors.submenuToggles=r,this._selectors.submenus=l,this._elements.menuItems=[],this._elements.submenuToggles=[],this._elements.controller=null,this._elements.parentMenu=M,this._elements.rootMenu=y?this:null,this._openClass=h||"",this._closeClass=_||"",this._transitionClass=b||"",this._root=y,this._hoverType=C,this._hoverDelay=E,this._enterDelay=T,this._leaveDelay=v}initialize(){if(!this._validate())throw new Error(`AccesibleMenu: cannot initialize menu. The following errors have been found: | ||
var Bootstrap5Menubar=function(){"use strict";var R=Object.defineProperty;var P=(m,c,f)=>c in m?R(m,c,{enumerable:!0,configurable:!0,writable:!0,value:f}):m[c]=f;var o=(m,c,f)=>(P(m,typeof c!="symbol"?c+"":c,f),f);function m(i,e){typeof i=="string"?e.classList.add(i):e.classList.add(...i)}function c(i,e){typeof i=="string"?e.classList.remove(i):e.classList.remove(...i)}function f(i,e){try{if(typeof e!="object"){const t=typeof e;throw new TypeError(`Elements given to isValidInstance() must be inside of an object. "${t}" given.`)}for(const t in e)if(!(e[t]instanceof i)){const s=typeof e[t];throw new TypeError(`${t} must be an instance of ${i.name}. "${s}" given.`)}return{status:!0,error:null}}catch(t){return{status:!1,error:t}}}function p(i,e){try{if(typeof e!="object"){const t=typeof e;throw new TypeError(`Values given to isValidType() must be inside of an object. "${t}" given.`)}for(const t in e){const s=typeof e[t];if(s!==i)throw new TypeError(`${t} must be a ${i}. "${s}" given.`)}return{status:!0,error:null}}catch(t){return{status:!1,error:t}}}function S(i){try{if(typeof i!="object"){const e=typeof i;throw new TypeError(`Values given to isCSSSelector() must be inside of an object. "${e}" given.`)}for(const e in i)try{if(i[e]===null)throw new Error;document.querySelector(i[e])}catch{throw new TypeError(`${e} must be a valid CSS selector. "${i[e]}" given.`)}return{status:!0,error:null}}catch(e){return{status:!1,error:e}}}function g(i){try{if(typeof i!="object"||Array.isArray(i)){const e=typeof i;throw new TypeError(`Values given to isValidClassList() must be inside of an object. "${e}" given.`)}for(const e in i){const t=typeof i[e];if(t!=="string")if(Array.isArray(i[e]))i[e].forEach(s=>{if(typeof s!="string")throw new TypeError(`${e} must be a string or an array of strings. An array containing non-strings given.`)});else throw new TypeError(`${e} must be a string or an array of strings. "${t}" given.`);else{const s={};s[e]=i[e],S(s)}}return{status:!0,error:null}}catch(e){return{status:!1,error:e}}}function q(i){try{if(typeof i!="object"){const t=typeof i;throw new TypeError(`Values given to isValidState() must be inside of an object. "${t}" given.`)}const e=["none","self","child"];for(const t in i)if(!e.includes(i[t]))throw new TypeError(`${t} must be one of the following values: ${e.join(", ")}. "${i[t]}" given.`);return{status:!0,error:null}}catch(e){return{status:!1,error:e}}}function j(i){try{if(typeof i!="object"){const t=typeof i;throw new TypeError(`Values given to isValidEvent() must be inside of an object. "${t}" given.`)}const e=["none","mouse","keyboard","character"];for(const t in i)if(!e.includes(i[t]))throw new TypeError(`${t} must be one of the following values: ${e.join(", ")}. "${i[t]}" given.`);return{status:!0,error:null}}catch(e){return{status:!1,error:e}}}function $(i){try{if(typeof i!="object"){const t=typeof i;throw new TypeError(`Values given to isValidHoverType() must be inside of an object. "${t}" given.`)}const e=["off","on","dynamic"];for(const t in i)if(!e.includes(i[t]))throw new TypeError(`${t} must be one of the following values: ${e.join(", ")}. "${i[t]}" given.`);return{status:!0,error:null}}catch(e){return{status:!1,error:e}}}function V(i,e){if(p("string",{tagName:i}).status&&f(HTMLElement,e).status){const t=i.toLowerCase();let s=!0;for(const n in e)e[n].tagName.toLowerCase()!==t&&(s=!1);return s}else return!1}class x{constructor({menuToggleElement:e,parentElement:t,controlledMenu:s,parentMenu:n=null}){o(this,"_dom",{toggle:null,parent:null});o(this,"_elements",{controlledMenu:null,parentMenu:null});o(this,"_open",!1);o(this,"_expandEvent",new CustomEvent("accessibleMenuExpand",{bubbles:!0,detail:{toggle:this}}));o(this,"_collapseEvent",new CustomEvent("accessibleMenuCollapse",{bubbles:!0,detail:{toggle:this}}));this._dom.toggle=e,this._dom.parent=t,this._elements.controlledMenu=s,this._elements.parentMenu=n}initialize(){var e;if(this.dom.toggle.setAttribute("aria-haspopup","true"),this.dom.toggle.setAttribute("aria-expanded","false"),V("button",{toggle:this.dom.toggle})||this.dom.toggle.setAttribute("role","button"),this.dom.toggle.id===""||this.elements.controlledMenu.dom.menu.id===""){const t=Math.random().toString(36).replace(/[^a-z]+/g,"").substr(0,10);let s=((e=this.dom.toggle.innerText)==null?void 0:e.replace(/[^a-zA-Z0-9\s]/g,""))||"",n=t;!s.replace(/\s/g,"").length&&this.dom.toggle.getAttribute("aria-label")&&(s=this.dom.toggle.getAttribute("aria-label").replace(/[^a-zA-Z0-9\s]/g,"")),s.replace(/\s/g,"").length>0&&(s=s.toLowerCase().replace(/\s+/g,"-"),s.startsWith("-")&&(s=s.substring(1)),s.endsWith("-")&&(s=s.slice(0,-1)),n=`${s}-${n}`),this.dom.toggle.id=this.dom.toggle.id||`${n}-menu-button`,this.elements.controlledMenu.dom.menu.id=this.elements.controlledMenu.dom.menu.id||`${n}-menu`}this.elements.controlledMenu.dom.menu.setAttribute("aria-labelledby",this.dom.toggle.id),this.dom.toggle.setAttribute("aria-controls",this.elements.controlledMenu.dom.menu.id),this._collapse(!1)}get dom(){return this._dom}get elements(){return this._elements}get isOpen(){return this._open}set isOpen(e){p("boolean",{value:e}),this._open=e}_expand(e=!0){const{closeClass:t,openClass:s,transitionClass:n}=this.elements.controlledMenu;this.dom.toggle.setAttribute("aria-expanded","true"),n!==""?(m(n,this.elements.controlledMenu.dom.menu),requestAnimationFrame(()=>{t!==""&&c(t,this.elements.controlledMenu.dom.menu),requestAnimationFrame(()=>{s!==""&&m(s,this.elements.controlledMenu.dom.menu),requestAnimationFrame(()=>{c(n,this.elements.controlledMenu.dom.menu)})})})):(s!==""&&m(s,this.elements.controlledMenu.dom.menu),t!==""&&c(t,this.elements.controlledMenu.dom.menu)),e&&this.dom.toggle.dispatchEvent(this._expandEvent)}_collapse(e=!0){const{closeClass:t,openClass:s,transitionClass:n}=this.elements.controlledMenu;this.dom.toggle.setAttribute("aria-expanded","false"),n!==""?(m(n,this.elements.controlledMenu.dom.menu),requestAnimationFrame(()=>{s!==""&&c(s,this.elements.controlledMenu.dom.menu),requestAnimationFrame(()=>{t!==""&&m(t,this.elements.controlledMenu.dom.menu),requestAnimationFrame(()=>{c(n,this.elements.controlledMenu.dom.menu)})})})):(t!==""&&m(t,this.elements.controlledMenu.dom.menu),s!==""&&c(s,this.elements.controlledMenu.dom.menu)),e&&this.dom.toggle.dispatchEvent(this._collapseEvent)}open(){this.elements.controlledMenu.focusState="self",this._expand(),this.isOpen=!0}preview(){this.elements.parentMenu&&(this.elements.parentMenu.focusState="self"),this._expand(),this.isOpen=!0}close(){this.isOpen&&(this.elements.controlledMenu.blur(),this.elements.parentMenu&&(this.elements.parentMenu.focusState="self"),this._collapse(),this.isOpen=!1)}toggle(){this.isOpen?this.close():this.open()}closeSiblings(){this.elements.parentMenu&&this.elements.parentMenu.elements.submenuToggles.forEach(e=>{e!==this&&e.close()})}closeChildren(){this.elements.controlledMenu.elements.submenuToggles.forEach(e=>e.close())}}class F{constructor({menuItemElement:e,menuLinkElement:t,parentMenu:s,isSubmenuItem:n=!1,childMenu:r=null,toggle:l=null}){o(this,"_dom",{item:null,link:null});o(this,"_elements",{parentMenu:null,childMenu:null,toggle:null});o(this,"_submenu",!1);this._dom.item=e,this._dom.link=t,this._elements.parentMenu=s,this._elements.childMenu=r,this._elements.toggle=l,this._submenu=n}initialize(){}get dom(){return this._dom}get elements(){return this._elements}get isSubmenuItem(){return this._submenu}focus(){this.elements.parentMenu.shouldFocus&&this.dom.link.focus()}blur(){this.elements.parentMenu.shouldFocus&&this.dom.link.blur()}}function w(i){try{const e=i.key||i.keyCode,t={Enter:e==="Enter"||e===13,Space:e===" "||e==="Spacebar"||e===32,Escape:e==="Escape"||e==="Esc"||e===27,ArrowUp:e==="ArrowUp"||e==="Up"||e===38,ArrowRight:e==="ArrowRight"||e==="Right"||e===39,ArrowDown:e==="ArrowDown"||e==="Down"||e===40,ArrowLeft:e==="ArrowLeft"||e==="Left"||e===37,Home:e==="Home"||e===36,End:e==="End"||e===35,Character:isNaN(e)&&!!e.match(/^[a-zA-Z]{1}$/),Tab:e==="Tab"||e===9,Asterisk:e==="*"||e===56};return Object.keys(t).find(s=>t[s]===!0)||""}catch{return""}}function u(i){i.preventDefault(),i.stopPropagation()}class I{constructor({menuElement:e,menuItemSelector:t="li",menuLinkSelector:s="a",submenuItemSelector:n="",submenuToggleSelector:r="a",submenuSelector:l="ul",controllerElement:a=null,containerElement:d=null,openClass:h="show",closeClass:_="hide",transitionClass:b="transitioning",isTopLevel:y=!0,parentMenu:C=null,hoverType:M="off",hoverDelay:E=250,enterDelay:T=-1,leaveDelay:v=-1}){o(this,"_MenuType",I);o(this,"_MenuItemType",F);o(this,"_MenuToggleType",x);o(this,"_dom",{menu:null,menuItems:[],submenuItems:[],submenuToggles:[],submenus:[],controller:null,container:null});o(this,"_selectors",{menuItems:"",menuLinks:"",submenuItems:"",submenuToggles:"",submenus:""});o(this,"_elements",{menuItems:[],submenuToggles:[],controller:null,parentMenu:null,rootMenu:null});o(this,"_openClass","show");o(this,"_closeClass","hide");o(this,"_transitionClass","transitioning");o(this,"_root",!0);o(this,"_currentChild",0);o(this,"_focusState","none");o(this,"_currentEvent","none");o(this,"_hoverType","off");o(this,"_hoverDelay",250);o(this,"_enterDelay",-1);o(this,"_leaveDelay",-1);o(this,"_hoverTimeout",null);o(this,"_errors",[]);this._dom.menu=e,this._dom.controller=a,this._dom.container=d,this._selectors.menuItems=t,this._selectors.menuLinks=s,this._selectors.submenuItems=n,this._selectors.submenuToggles=r,this._selectors.submenus=l,this._elements.menuItems=[],this._elements.submenuToggles=[],this._elements.controller=null,this._elements.parentMenu=C,this._elements.rootMenu=y?this:null,this._openClass=h||"",this._closeClass=_||"",this._transitionClass=b||"",this._root=y,this._hoverType=M,this._hoverDelay=E,this._enterDelay=T,this._leaveDelay=v}initialize(){if(!this._validate())throw new Error(`AccesibleMenu: cannot initialize menu. The following errors have been found: | ||
- ${this.errors.join(` | ||
- `)}`);if(this.elements.rootMenu===null&&this._findRootMenu(this),this._setDOMElements(),this.isTopLevel&&this.dom.controller&&this.dom.container){const e=new this._MenuToggleType({menuToggleElement:this.dom.controller,parentElement:this.dom.container,controlledMenu:this});this._elements.controller=e}this._createChildElements()}get dom(){return this._dom}get selectors(){return this._selectors}get elements(){return this._elements}get isTopLevel(){return this._root}get openClass(){return this.isTopLevel?this._openClass:this.elements.rootMenu.openClass}get closeClass(){return this.isTopLevel?this._closeClass:this.elements.rootMenu.closeClass}get transitionClass(){return this.isTopLevel?this._transitionClass:this.elements.rootMenu.transitionClass}get currentChild(){return this._currentChild}get focusState(){return this._focusState}get currentEvent(){return this._currentEvent}get currentMenuItem(){return this.elements.menuItems[this.currentChild]}get hoverType(){return this._root?this._hoverType:this.elements.rootMenu.hoverType}get hoverDelay(){return this._root?this._hoverDelay:this.elements.rootMenu.hoverDelay}get enterDelay(){return this._enterDelay===-1?this.hoverDelay:this._root?this._enterDelay:this.elements.rootMenu.enterDelay}get leaveDelay(){return this._leaveDelay===-1?this.hoverDelay:this._root?this._leaveDelay:this.elements.rootMenu.leaveDelay}get shouldFocus(){let e=!1;return(this.currentEvent==="keyboard"||this.currentEvent==="character")&&(e=!0),this.currentEvent==="mouse"&&this.hoverType==="dynamic"&&(e=!0),e}get errors(){return this._errors}set openClass(e){g({openClass:e}),this._openClass!==e&&(this._openClass=e)}set closeClass(e){g({closeClass:e}),this._closeClass!==e&&(this._closeClass=e)}set transitionClass(e){g({transitionClass:e}),this._transitionClass!==e&&(this._transitionClass=e)}set currentChild(e){p("number",{value:e});function t(s){if(["mouse","character"].includes(s.currentEvent)&&s.elements.parentMenu){let r=0,l=!1;for(;!l&&r<s.elements.parentMenu.elements.menuItems.length;){const a=s.elements.parentMenu.elements.menuItems[r];a.isSubmenuItem&&a.elements.toggle.elements.controlledMenu===s&&(l=!0,s.elements.parentMenu.currentEvent=s.currentEvent,s.elements.parentMenu.currentChild=r),r++}}}e<-1?(this._currentChild=-1,t(this)):e>=this.elements.menuItems.length?(this._currentChild=this.elements.menuItems.length-1,t(this)):this.focusChild!==e&&(this._currentChild=e,t(this))}set focusState(e){q({value:e}),this._focusState!==e&&(this._focusState=e),this.elements.submenuToggles.length>0&&(e==="self"||e==="none")&&this.elements.submenuToggles.forEach(t=>{t.elements.controlledMenu.focusState="none"}),this.elements.parentMenu&&(e==="self"||e==="child")&&(this.elements.parentMenu.focusState="child")}set currentEvent(e){j({value:e}),this._currentEvent!==e&&(this._currentEvent=e,this.elements.submenuToggles.length>0&&this.elements.submenuToggles.forEach(t=>{t.elements.controlledMenu.currentEvent=e}))}set hoverType(e){$({value:e}),this._hoverType!==e&&(this._hoverType=e)}set hoverDelay(e){p("number",{value:e}),this._hoverDelay!==e&&(this._hoverDelay=e)}set enterDelay(e){p("number",{value:e}),this._enterDelay!==e&&(this._enterDelay=e)}set leaveDelay(e){p("number",{value:e}),this._leaveDelay!==e&&(this._leaveDelay=e)}_validate(){let e=!0,t;this._dom.container!==null||this._dom.controller!==null?t=f(HTMLElement,{menuElement:this._dom.menu,controllerElement:this._dom.controller,containerElement:this._dom.container}):t=f(HTMLElement,{menuElement:this._dom.menu}),t.status||(this._errors.push(t.error.message),e=!1);let s;if(this._selectors.submenuItems!==""?s=S({menuItemSelector:this._selectors.menuItems,menuLinkSelector:this._selectors.menuLinks,submenuItemSelector:this._selectors.submenuItems,submenuToggleSelector:this._selectors.submenuToggles,submenuSelector:this._selectors.submenus}):s=S({menuItemSelector:this._selectors.menuItems,menuLinkSelector:this._selectors.menuLinks}),s.status||(this._errors.push(s.error.message),e=!1),this._openClass!==""){const h=g({openClass:this._openClass});h.status||(this._errors.push(h.error.message),e=!1)}if(this._closeClass!==""){const h=g({closeClass:this._closeClass});h.status||(this._errors.push(h.error.message),e=!1)}if(this._transitionClass!==""){const h=g({transitionClass:this._transitionClass});h.status||(this._errors.push(h.error.message),e=!1)}const n=p("boolean",{isTopLevel:this._root});if(n.status||(this._errors.push(n.error.message),e=!1),this._elements.parentMenu!==null){const h=f(I,{parentMenu:this._elements.parentMenu});h.status||(this._errors.push(h.error.message),e=!1)}const r=$({hoverType:this._hoverType});r.status||(this._errors.push(r.error.message),e=!1);const l=p("number",{hoverDelay:this._hoverDelay});l.status||(this._errors.push(l.error.message),e=!1);const a=p("number",{enterDelay:this._enterDelay});a.status||(this._errors.push(a.error.message),e=!1);const d=p("number",{leaveDelay:this._leaveDelay});return d.status||(this._errors.push(d.error.message),e=!1),e}_setDOMElementType(e,t=this.dom.menu,s=!0){if(typeof this.selectors[e]=="string"){if(!Array.isArray(this.dom[e]))throw new Error(`AccessibleMenu: The "${e}" element cannot be set through _setDOMElementType.`);t!==this.dom.menu&&f(HTMLElement,{base:t});const r=Array.from(t.querySelectorAll(this.selectors[e])).filter(l=>l.parentElement===t);s?this._dom[e]=r:this._dom[e]=[...this._dom[e],...r]}else throw new Error(`AccessibleMenu: "${e}" is not a valid element type within the menu.`)}_resetDOMElementType(e){if(typeof this.dom[e]<"u"){if(!Array.isArray(this.dom[e]))throw new Error(`AccessibleMenu: The "${e}" element cannot be reset through _resetDOMElementType.`);this._dom[e]=[]}else throw new Error(`AccessibleMenu: "${e}" is not a valid element type within the menu.`)}_setDOMElements(){this._setDOMElementType("menuItems"),this.selectors.submenuItems!==""&&(this._setDOMElementType("submenuItems"),this._resetDOMElementType("submenuToggles"),this._resetDOMElementType("submenus"),this.dom.submenuItems.forEach(e=>{this._setDOMElementType("submenuToggles",e,!1),this._setDOMElementType("submenus",e,!1)}))}_findRootMenu(e){if(e.isTopLevel)this._elements.rootMenu=e;else if(e.elements.parentMenu!==null)this._findRootMenu(e.elements.parentMenu);else throw new Error("Cannot find root menu.")}_createChildElements(){this.dom.menuItems.forEach(e=>{let t;if(this.dom.submenuItems.includes(e)){const s=e.querySelector(this.selectors.submenuToggles),n=e.querySelector(this.selectors.submenus),r=new this._MenuType({menuElement:n,menuItemSelector:this.selectors.menuItems,menuLinkSelector:this.selectors.menuLinks,submenuItemSelector:this.selectors.submenuItems,submenuToggleSelector:this.selectors.submenuToggles,submenuSelector:this.selectors.submenus,openClass:this.openClass,closeClass:this.closeClass,isTopLevel:!1,parentMenu:this,hoverType:this.hoverType,hoverDelay:this.hoverDelay}),l=new this._MenuToggleType({menuToggleElement:s,parentElement:e,controlledMenu:r,parentMenu:this});this._elements.submenuToggles.push(l),t=new this._MenuItemType({menuItemElement:e,menuLinkElement:s,parentMenu:this,isSubmenuItem:!0,childMenu:r,toggle:l})}else{const s=e.querySelector(this.selectors.menuLinks);t=new this._MenuItemType({menuItemElement:e,menuLinkElement:s,parentMenu:this})}this._elements.menuItems.push(t)})}_handleFocus(){this.elements.menuItems.forEach((e,t)=>{e.dom.link.addEventListener("focus",()=>{this.focusState="self",this.currentChild=t})})}_handleClick(){function e(t,s,n){u(n),s.toggle(),s.isOpen&&(t.focusState="self",s.elements.controlledMenu.focusState="none")}this.elements.menuItems.forEach((t,s)=>{t.dom.link.addEventListener("pointerdown",()=>{this.currentEvent="mouse",this.elements.rootMenu.blurChildren(),this.focusChild(s)},{passive:!0}),t.isSubmenuItem&&t.elements.toggle.dom.toggle.addEventListener("pointerup",n=>{this.currentEvent="mouse",e(this,t.elements.toggle,n)})}),this.isTopLevel&&this.elements.controller&&this.elements.controller.dom.toggle.addEventListener("pointerup",t=>{this.currentEvent="mouse",e(this,this.elements.controller,t)})}_handleHover(){this.elements.menuItems.forEach((e,t)=>{e.dom.link.addEventListener("pointerenter",s=>{if(!(s.pointerType==="pen"||s.pointerType==="touch")){if(this.hoverType==="on")this.currentEvent="mouse",this.currentChild=t,e.isSubmenuItem&&(this.enterDelay>0?this._hoverTimeout=setTimeout(()=>{e.elements.toggle.preview()},this.enterDelay):e.elements.toggle.preview());else if(this.hoverType==="dynamic"){const n=this.elements.submenuToggles.some(r=>r.isOpen);this.currentChild=t,(!this.isTopLevel||this.focusState!=="none")&&(this.currentEvent="mouse",this.focusCurrentChild()),e.isSubmenuItem&&(!this.isTopLevel||n)&&(this.currentEvent="mouse",this.enterDelay>0?this._hoverTimeout=setTimeout(()=>{e.elements.toggle.preview()},this.enterDelay):e.elements.toggle.preview())}}}),e.isSubmenuItem&&e.dom.item.addEventListener("pointerleave",s=>{s.pointerType==="pen"||s.pointerType==="touch"||(this.hoverType==="on"?this.leaveDelay>0?(clearTimeout(this._hoverTimeout),setTimeout(()=>{this.currentEvent="mouse",e.elements.toggle.close()},this.leaveDelay)):(this.currentEvent="mouse",e.elements.toggle.close()):this.hoverType==="dynamic"&&(this.isTopLevel||(this.leaveDelay>0?(clearTimeout(this._hoverTimeout),setTimeout(()=>{this.currentEvent="mouse",e.elements.toggle.close(),this.focusCurrentChild()},this.leaveDelay)):(this.currentEvent="mouse",e.elements.toggle.close(),this.focusCurrentChild()))))})})}_handleKeydown(){this.isTopLevel&&this.elements.controller&&this.elements.controller.dom.toggle.addEventListener("keydown",e=>{this.currentEvent="keyboard";const t=w(e);(t==="Space"||t==="Enter")&&u(e)})}_handleKeyup(){this.isTopLevel&&this.elements.controller&&this.elements.controller.dom.toggle.addEventListener("keyup",e=>{this.currentEvent="keyboard";const t=w(e);(t==="Space"||t==="Enter")&&(u(e),this.elements.controller.open(),this.focusFirstChild())})}focus(){this.focusState="self",this.shouldFocus&&this.dom.menu.focus()}blur(){this.focusState="none",this.shouldFocus&&this.dom.menu.blur()}focusCurrentChild(){this.focusState="self",this.currentChild!==-1&&this.currentMenuItem.focus()}focusChild(e){this.blurCurrentChild(),this.currentChild=e,this.focusCurrentChild()}focusFirstChild(){this.focusChild(0)}focusLastChild(){this.focusChild(this.elements.menuItems.length-1)}focusNextChild(){this.currentChild<this.elements.menuItems.length-1?this.focusChild(this.currentChild+1):this.focusCurrentChild()}focusPreviousChild(){this.currentChild>0?this.focusChild(this.currentChild-1):this.focusCurrentChild()}blurCurrentChild(){this.focusState="none",this.currentChild!==-1&&this.currentMenuItem.blur()}focusController(){this.dom.controller&&(this.shouldFocus&&this.dom.controller.focus(),this.focusState="none")}focusContainer(){this.dom.container&&(this.shouldFocus&&this.dom.container.focus(),this.focusState="none")}closeChildren(){this.elements.submenuToggles.forEach(e=>e.close())}blurChildren(){this.elements.menuItems.forEach(e=>{e.blur(),e.isSubmenuItem&&e.elements.childMenu.blurChildren()})}}class O extends F{constructor({menuItemElement:e,menuLinkElement:t,parentMenu:s,isSubmenuItem:n=!1,childMenu:r=null,toggle:l=null,initialize:a=!0}){super({menuItemElement:e,menuLinkElement:t,parentMenu:s,isSubmenuItem:n,childMenu:r,toggle:l}),a&&this.initialize()}initialize(){super.initialize(),this.dom.item.setAttribute("role","none"),this.dom.link.setAttribute("role","menuitem"),this.dom.link.tabIndex=-1}focus(){super.focus(),this.elements.parentMenu.isTopLevel&&(this.dom.link.tabIndex=0)}blur(){super.blur(),this.elements.parentMenu.isTopLevel&&(this.dom.link.tabIndex=-1)}}class z extends x{constructor({menuToggleElement:e,parentElement:t,controlledMenu:s,parentMenu:n=null,initialize:r=!0}){super({menuToggleElement:e,parentElement:t,controlledMenu:s,parentMenu:n}),r&&this.initialize()}open(){this.closeSiblings(),super.open()}preview(){this.closeSiblings(),super.preview()}close(){this.isOpen&&this.closeChildren(),super.close()}}class k extends I{constructor({menuElement:t,menuItemSelector:s="li",menuLinkSelector:n="a",submenuItemSelector:r="",submenuToggleSelector:l="a",submenuSelector:a="ul",controllerElement:d=null,containerElement:h=null,openClass:_="show",closeClass:b="hide",transitionClass:y="transitioning",isTopLevel:M=!0,parentMenu:C=null,hoverType:E="off",hoverDelay:T=250,enterDelay:v=-1,leaveDelay:L=-1,initialize:D=!0}){super({menuElement:t,menuItemSelector:s,menuLinkSelector:n,submenuItemSelector:r,submenuToggleSelector:l,submenuSelector:a,controllerElement:d,containerElement:h,openClass:_,closeClass:b,transitionClass:y,isTopLevel:M,parentMenu:C,hoverType:E,hoverDelay:T,enterDelay:v,leaveDelay:L});o(this,"_MenuType",k);o(this,"_MenuItemType",O);o(this,"_MenuToggleType",z);D&&this.initialize()}initialize(){try{super.initialize(),this.dom.menu.setAttribute("role","menubar"),this._handleFocus(),this._handleClick(),this._handleHover(),this._handleKeydown(),this._handleKeyup(),this.isTopLevel&&(this.elements.menuItems[0].dom.link.tabIndex=0)}catch(t){console.error(t)}}_handleClick(){super._handleClick(),document.addEventListener("pointerup",t=>{this.focusState!=="none"&&(this.currentEvent="mouse",!this.dom.menu.contains(t.target)&&!this.dom.menu!==t.target&&(this.closeChildren(),this.blur(),this.elements.controller&&this.elements.controller.close()))})}_handleKeydown(){super._handleKeydown(),this.dom.menu.addEventListener("keydown",t=>{this.currentEvent="keyboard";const s=w(t);if(s==="Tab"&&(this.elements.rootMenu.focusState!=="none"?(this.elements.rootMenu.blur(),this.elements.rootMenu.closeChildren()):this.elements.rootMenu.focus()),s==="Character")u(t);else if(this.isTopLevel){if(this.focusState==="self"){const n=["ArrowRight","ArrowLeft","Home","End"],r=["Space","Enter","ArrowDown","ArrowUp"],l=["Escape"];(n.includes(s)||this.currentMenuItem.isSubmenuItem&&r.includes(s)||this.elements.controller&&l.includes(s))&&u(t)}}else{const n=["Escape","ArrowRight","ArrowLeft","ArrowDown","ArrowUp","Home","End"],r=["Space","Enter"];(n.includes(s)||this.currentMenuItem.isSubmenuItem&&r.includes(s))&&u(t)}})}_handleKeyup(){super._handleKeyup(),this.dom.menu.addEventListener("keyup",t=>{this.currentEvent="keyboard";const s=w(t),{altKey:n,crtlKey:r,metaKey:l}=t;if(s==="Character"&&!(n||r||l))u(t),this.elements.rootMenu.currentEvent="character",this.focusNextChildWithCharacter(t.key);else if(this.isTopLevel){if(this.focusState==="self")if(s==="Space"||s==="Enter")this.currentMenuItem.isSubmenuItem?(u(t),this.currentMenuItem.elements.childMenu.currentEvent="keyboard",this.currentMenuItem.elements.toggle.open(),requestAnimationFrame(()=>{this.currentMenuItem.elements.childMenu.focusFirstChild()})):this.currentMenuItem.dom.link.click();else if(s==="ArrowRight"){u(t);const d=this.currentMenuItem.isSubmenuItem&&this.currentMenuItem.elements.toggle.isOpen;this.focusNextChild(),d&&(this.currentMenuItem.isSubmenuItem?(this.currentMenuItem.elements.childMenu.currentEvent="keyboard",this.currentMenuItem.elements.toggle.preview()):this.closeChildren())}else if(s==="ArrowLeft"){u(t);const d=this.currentMenuItem.isSubmenuItem&&this.currentMenuItem.elements.toggle.isOpen;this.focusPreviousChild(),d&&(this.currentMenuItem.isSubmenuItem?(this.currentMenuItem.elements.childMenu.currentEvent="keyboard",this.currentMenuItem.elements.toggle.preview()):this.closeChildren())}else s==="ArrowDown"?this.currentMenuItem.isSubmenuItem&&(u(t),this.currentMenuItem.elements.childMenu.currentEvent="keyboard",this.currentMenuItem.elements.toggle.open(),requestAnimationFrame(()=>{this.currentMenuItem.elements.childMenu.focusFirstChild()})):s==="ArrowUp"?this.currentMenuItem.isSubmenuItem&&(u(t),this.currentMenuItem.elements.childMenu.currentEvent="keyboard",this.currentMenuItem.elements.toggle.open(),requestAnimationFrame(()=>{this.currentMenuItem.elements.childMenu.focusLastChild()})):s==="Home"?(u(t),this.focusFirstChild()):s==="End"?(u(t),this.focusLastChild()):s==="Escape"&&(this.elements.submenuToggles.some(h=>h.isOpen)?(u(t),this.closeChildren()):this.isTopLevel&&this.elements.controller&&this.elements.controller.isOpen&&(u(t),this.elements.controller.close(),this.focusController()))}else s==="Space"||s==="Enter"?this.currentMenuItem.isSubmenuItem?(u(t),this.currentMenuItem.elements.childMenu.currentEvent="keyboard",this.currentMenuItem.elements.toggle.open(),requestAnimationFrame(()=>{this.currentMenuItem.elements.childMenu.focusFirstChild()})):this.currentMenuItem.dom.link.click():s==="Escape"?(u(t),this.elements.rootMenu.closeChildren(),this.elements.rootMenu.focusCurrentChild()):s==="ArrowRight"?this.currentMenuItem.isSubmenuItem?(u(t),this.currentMenuItem.elements.childMenu.currentEvent="keyboard",this.currentMenuItem.elements.toggle.open(),requestAnimationFrame(()=>{this.currentMenuItem.elements.childMenu.focusFirstChild()})):(u(t),this.elements.rootMenu.closeChildren(),this.elements.rootMenu.focusNextChild(),this.elements.rootMenu.currentMenuItem.isSubmenuItem&&this.elements.rootMenu.currentMenuItem.elements.toggle.preview()):s==="ArrowLeft"?this.elements.parentMenu.currentMenuItem.isSubmenuItem&&(u(t),this.elements.parentMenu.currentMenuItem.elements.toggle.close(),this.elements.parentMenu.focusCurrentChild(),this.elements.parentMenu===this.elements.rootMenu&&(this.elements.rootMenu.closeChildren(),this.elements.rootMenu.focusPreviousChild(),this.elements.rootMenu.currentMenuItem.isSubmenuItem&&(this.elements.rootMenu.currentMenuItem.elements.childMenu.currentEvent="keyboard",this.elements.rootMenu.currentMenuItem.elements.toggle.preview()))):s==="ArrowDown"?(u(t),this.focusNextChild()):s==="ArrowUp"?(u(t),this.focusPreviousChild()):s==="Home"?(u(t),this.focusFirstChild()):s==="End"&&(u(t),this.focusLastChild())})}focusNextChild(){this.currentChild===this.elements.menuItems.length-1?this.focusFirstChild():this.focusChild(this.currentChild+1)}focusPreviousChild(){this.currentChild===0?this.focusLastChild():this.focusChild(this.currentChild-1)}focusNextChildWithCharacter(t){const s=t.toLowerCase();let n=this.currentChild+1,r=!1;for(;!r&&n<this.elements.menuItems.length;){let l="";this.elements.menuItems[n].dom.item.innerText?l=this.elements.menuItems[n].dom.item.innerText:l=this.elements.menuItems[n].dom.item.textContent,l=l.replace(/[\s]/g,"").toLowerCase().charAt(0),l===s&&(r=!0,this.focusChild(n)),n++}}}class H extends O{constructor({menuItemElement:e,menuLinkElement:t,parentMenu:s,isSubmenuItem:n=!1,childMenu:r=null,toggle:l=null,initialize:a=!0}){super({menuItemElement:e,menuLinkElement:t,parentMenu:s,isSubmenuItem:n,childMenu:r,toggle:l,initialize:!1}),a&&this.initialize()}}class K extends z{constructor({menuToggleElement:t,parentElement:s,controlledMenu:n,parentMenu:r=null,initialize:l=!0}){super({menuToggleElement:t,parentElement:s,controlledMenu:n,parentMenu:r,initialize:!1});o(this,"_dom",{toggle:null,parent:null,container:null});this._dom.toggle=t,this._dom.parent=s,this._dom.container=n.isTopLevel?n.dom.container:n.dom.menu,l&&this.initialize()}initialize(){super.initialize(),this.dom.toggle.hasAttribute("data-bs-toggle")&&this.dom.toggle.removeAttribute("data-bs-toggle"),this.dom.toggle.hasAttribute("data-bs-target")&&this.dom.toggle.removeAttribute("data-bs-target")}_expand(t=!0){const{openClass:s,transitionClass:n}=this.elements.controlledMenu;this.dom.toggle.setAttribute("aria-expanded","true"),n!==""?(m(n,this.dom.container),requestAnimationFrame(()=>{m(s,this.dom.container),requestAnimationFrame(()=>{c(n,this.dom.container)})})):s!==""&&m(s,this.dom.container),t&&this.dom.toggle.dispatchEvent(this._expandEvent)}_collapse(t=!0){const{closeClass:s,openClass:n,transitionClass:r}=this.elements.controlledMenu;this.dom.toggle.setAttribute("aria-expanded","false"),r!==""?(m(r,this.dom.container),requestAnimationFrame(()=>{n!==""&&c(n,this.dom.container),requestAnimationFrame(()=>{s!==""&&m(s,this.dom.container),requestAnimationFrame(()=>{c(r,this.dom.container)})})})):(s!==""&&m(s,this.dom.container),n!==""&&c(n,this.dom.container)),t&&this.dom.toggle.dispatchEvent(this._collapseEvent)}}class A extends k{constructor({menuElement:t,menuItemSelector:s=".nav-item,li",menuLinkSelector:n=".nav-link,.dropdown-item",submenuItemSelector:r=".dropdown",submenuToggleSelector:l=".dropdown-toggle",submenuSelector:a=".dropdown-menu",controllerElement:d=null,containerElement:h=null,openClass:_="show",closeClass:b="collapse",transitionClass:y="transitioning",isTopLevel:M=!0,parentMenu:C=null,hoverType:E="off",hoverDelay:T=250,enterDelay:v=-1,leaveDelay:L=-1,initialize:D=!0}){super({menuElement:t,menuItemSelector:s,menuLinkSelector:n,submenuItemSelector:r,submenuToggleSelector:l,submenuSelector:a,controllerElement:d,containerElement:h,openClass:_,closeClass:b,transitionClass:y,isTopLevel:M,parentMenu:C,hoverType:E,hoverDelay:T,enterDelay:v,leaveDelay:L,initialize:!1});o(this,"_MenuType",A);o(this,"_MenuItemType",H);o(this,"_MenuToggleType",K);D&&this.initialize()}}return A}(); | ||
- `)}`);if(this.elements.rootMenu===null&&this._findRootMenu(this),this._setDOMElements(),this.isTopLevel&&this.dom.controller&&this.dom.container){const e=new this._MenuToggleType({menuToggleElement:this.dom.controller,parentElement:this.dom.container,controlledMenu:this});this._elements.controller=e}this._createChildElements()}get dom(){return this._dom}get selectors(){return this._selectors}get elements(){return this._elements}get isTopLevel(){return this._root}get openClass(){return this.isTopLevel?this._openClass:this.elements.rootMenu.openClass}get closeClass(){return this.isTopLevel?this._closeClass:this.elements.rootMenu.closeClass}get transitionClass(){return this.isTopLevel?this._transitionClass:this.elements.rootMenu.transitionClass}get currentChild(){return this._currentChild}get focusState(){return this._focusState}get currentEvent(){return this._currentEvent}get currentMenuItem(){return this.elements.menuItems[this.currentChild]}get hoverType(){return this._root?this._hoverType:this.elements.rootMenu.hoverType}get hoverDelay(){return this._root?this._hoverDelay:this.elements.rootMenu.hoverDelay}get enterDelay(){return this._enterDelay===-1?this.hoverDelay:this._root?this._enterDelay:this.elements.rootMenu.enterDelay}get leaveDelay(){return this._leaveDelay===-1?this.hoverDelay:this._root?this._leaveDelay:this.elements.rootMenu.leaveDelay}get shouldFocus(){let e=!1;return(this.currentEvent==="keyboard"||this.currentEvent==="character")&&(e=!0),this.currentEvent==="mouse"&&this.hoverType==="dynamic"&&(e=!0),e}get errors(){return this._errors}set openClass(e){g({openClass:e}),this._openClass!==e&&(this._openClass=e)}set closeClass(e){g({closeClass:e}),this._closeClass!==e&&(this._closeClass=e)}set transitionClass(e){g({transitionClass:e}),this._transitionClass!==e&&(this._transitionClass=e)}set currentChild(e){p("number",{value:e});function t(s){if(["mouse","character"].includes(s.currentEvent)&&s.elements.parentMenu){let r=0,l=!1;for(;!l&&r<s.elements.parentMenu.elements.menuItems.length;){const a=s.elements.parentMenu.elements.menuItems[r];a.isSubmenuItem&&a.elements.toggle.elements.controlledMenu===s&&(l=!0,s.elements.parentMenu.currentEvent=s.currentEvent,s.elements.parentMenu.currentChild=r),r++}}}e<-1?(this._currentChild=-1,t(this)):e>=this.elements.menuItems.length?(this._currentChild=this.elements.menuItems.length-1,t(this)):this.focusChild!==e&&(this._currentChild=e,t(this))}set focusState(e){q({value:e}),this._focusState!==e&&(this._focusState=e),this.elements.submenuToggles.length>0&&(e==="self"||e==="none")&&this.elements.submenuToggles.forEach(t=>{t.elements.controlledMenu.focusState="none"}),this.elements.parentMenu&&(e==="self"||e==="child")&&(this.elements.parentMenu.focusState="child")}set currentEvent(e){j({value:e}),this._currentEvent!==e&&(this._currentEvent=e,this.elements.submenuToggles.length>0&&this.elements.submenuToggles.forEach(t=>{t.elements.controlledMenu.currentEvent=e}))}set hoverType(e){$({value:e}),this._hoverType!==e&&(this._hoverType=e)}set hoverDelay(e){p("number",{value:e}),this._hoverDelay!==e&&(this._hoverDelay=e)}set enterDelay(e){p("number",{value:e}),this._enterDelay!==e&&(this._enterDelay=e)}set leaveDelay(e){p("number",{value:e}),this._leaveDelay!==e&&(this._leaveDelay=e)}_validate(){let e=!0,t;this._dom.container!==null||this._dom.controller!==null?t=f(HTMLElement,{menuElement:this._dom.menu,controllerElement:this._dom.controller,containerElement:this._dom.container}):t=f(HTMLElement,{menuElement:this._dom.menu}),t.status||(this._errors.push(t.error.message),e=!1);let s;if(this._selectors.submenuItems!==""?s=S({menuItemSelector:this._selectors.menuItems,menuLinkSelector:this._selectors.menuLinks,submenuItemSelector:this._selectors.submenuItems,submenuToggleSelector:this._selectors.submenuToggles,submenuSelector:this._selectors.submenus}):s=S({menuItemSelector:this._selectors.menuItems,menuLinkSelector:this._selectors.menuLinks}),s.status||(this._errors.push(s.error.message),e=!1),this._openClass!==""){const h=g({openClass:this._openClass});h.status||(this._errors.push(h.error.message),e=!1)}if(this._closeClass!==""){const h=g({closeClass:this._closeClass});h.status||(this._errors.push(h.error.message),e=!1)}if(this._transitionClass!==""){const h=g({transitionClass:this._transitionClass});h.status||(this._errors.push(h.error.message),e=!1)}const n=p("boolean",{isTopLevel:this._root});if(n.status||(this._errors.push(n.error.message),e=!1),this._elements.parentMenu!==null){const h=f(I,{parentMenu:this._elements.parentMenu});h.status||(this._errors.push(h.error.message),e=!1)}const r=$({hoverType:this._hoverType});r.status||(this._errors.push(r.error.message),e=!1);const l=p("number",{hoverDelay:this._hoverDelay});l.status||(this._errors.push(l.error.message),e=!1);const a=p("number",{enterDelay:this._enterDelay});a.status||(this._errors.push(a.error.message),e=!1);const d=p("number",{leaveDelay:this._leaveDelay});return d.status||(this._errors.push(d.error.message),e=!1),e}_setDOMElementType(e,t=this.dom.menu,s=!0){if(typeof this.selectors[e]=="string"){if(!Array.isArray(this.dom[e]))throw new Error(`AccessibleMenu: The "${e}" element cannot be set through _setDOMElementType.`);t!==this.dom.menu&&f(HTMLElement,{base:t});const r=Array.from(t.querySelectorAll(this.selectors[e])).filter(l=>l.parentElement===t);s?this._dom[e]=r:this._dom[e]=[...this._dom[e],...r]}else throw new Error(`AccessibleMenu: "${e}" is not a valid element type within the menu.`)}_resetDOMElementType(e){if(typeof this.dom[e]<"u"){if(!Array.isArray(this.dom[e]))throw new Error(`AccessibleMenu: The "${e}" element cannot be reset through _resetDOMElementType.`);this._dom[e]=[]}else throw new Error(`AccessibleMenu: "${e}" is not a valid element type within the menu.`)}_setDOMElements(){this._setDOMElementType("menuItems"),this.selectors.submenuItems!==""&&(this._setDOMElementType("submenuItems"),this._resetDOMElementType("submenuToggles"),this._resetDOMElementType("submenus"),this.dom.submenuItems.forEach(e=>{this._setDOMElementType("submenuToggles",e,!1),this._setDOMElementType("submenus",e,!1)}))}_findRootMenu(e){if(e.isTopLevel)this._elements.rootMenu=e;else if(e.elements.parentMenu!==null)this._findRootMenu(e.elements.parentMenu);else throw new Error("Cannot find root menu.")}_createChildElements(){this.dom.menuItems.forEach(e=>{let t;if(this.dom.submenuItems.includes(e)){const s=e.querySelector(this.selectors.submenuToggles),n=e.querySelector(this.selectors.submenus),r=new this._MenuType({menuElement:n,menuItemSelector:this.selectors.menuItems,menuLinkSelector:this.selectors.menuLinks,submenuItemSelector:this.selectors.submenuItems,submenuToggleSelector:this.selectors.submenuToggles,submenuSelector:this.selectors.submenus,openClass:this.openClass,closeClass:this.closeClass,transitionClass:this.transitionClass,isTopLevel:!1,parentMenu:this,hoverType:this.hoverType,hoverDelay:this.hoverDelay,enterDelay:this.enterDelay,leaveDelay:this.leaveDelay}),l=new this._MenuToggleType({menuToggleElement:s,parentElement:e,controlledMenu:r,parentMenu:this});this._elements.submenuToggles.push(l),t=new this._MenuItemType({menuItemElement:e,menuLinkElement:s,parentMenu:this,isSubmenuItem:!0,childMenu:r,toggle:l})}else{const s=e.querySelector(this.selectors.menuLinks);t=new this._MenuItemType({menuItemElement:e,menuLinkElement:s,parentMenu:this})}this._elements.menuItems.push(t)})}_handleFocus(){this.elements.menuItems.forEach((e,t)=>{e.dom.link.addEventListener("focus",()=>{this.focusState="self",this.currentChild=t})})}_handleClick(){function e(t,s,n){u(n),s.toggle(),s.isOpen&&(t.focusState="self",s.elements.controlledMenu.focusState="none")}this.elements.menuItems.forEach((t,s)=>{t.dom.link.addEventListener("pointerdown",()=>{this.currentEvent="mouse",this.elements.rootMenu.blurChildren(),this.focusChild(s)},{passive:!0}),t.isSubmenuItem&&t.elements.toggle.dom.toggle.addEventListener("pointerup",n=>{this.currentEvent="mouse",e(this,t.elements.toggle,n)})}),this.isTopLevel&&this.elements.controller&&this.elements.controller.dom.toggle.addEventListener("pointerup",t=>{this.currentEvent="mouse",e(this,this.elements.controller,t)})}_handleHover(){this.elements.menuItems.forEach((e,t)=>{e.dom.link.addEventListener("pointerenter",s=>{if(!(s.pointerType==="pen"||s.pointerType==="touch")){if(this.hoverType==="on")this.currentEvent="mouse",this.elements.rootMenu.blurChildren(),this.focusChild(t),e.isSubmenuItem&&(this.enterDelay>0?this._hoverTimeout=setTimeout(()=>{e.elements.toggle.preview()},this.enterDelay):e.elements.toggle.preview());else if(this.hoverType==="dynamic"){const n=this.elements.submenuToggles.some(r=>r.isOpen);this.currentChild=t,(!this.isTopLevel||this.focusState!=="none")&&(this.currentEvent="mouse",this.elements.rootMenu.blurChildren(),this.focusCurrentChild()),e.isSubmenuItem&&(!this.isTopLevel||n)&&(this.currentEvent="mouse",this.elements.rootMenu.blurChildren(),this.focusCurrentChild(),this.enterDelay>0?this._hoverTimeout=setTimeout(()=>{e.elements.toggle.preview()},this.enterDelay):e.elements.toggle.preview())}}}),e.isSubmenuItem&&e.dom.item.addEventListener("pointerleave",s=>{s.pointerType==="pen"||s.pointerType==="touch"||(this.hoverType==="on"?this.leaveDelay>0?(clearTimeout(this._hoverTimeout),setTimeout(()=>{this.currentEvent="mouse",e.elements.toggle.close()},this.leaveDelay)):(this.currentEvent="mouse",e.elements.toggle.close()):this.hoverType==="dynamic"&&(this.isTopLevel||(this.leaveDelay>0?(clearTimeout(this._hoverTimeout),setTimeout(()=>{this.currentEvent="mouse",e.elements.toggle.close(),this.focusCurrentChild()},this.leaveDelay)):(this.currentEvent="mouse",e.elements.toggle.close(),this.focusCurrentChild()))))})})}_handleKeydown(){this.isTopLevel&&this.elements.controller&&this.elements.controller.dom.toggle.addEventListener("keydown",e=>{this.currentEvent="keyboard";const t=w(e);(t==="Space"||t==="Enter")&&u(e)})}_handleKeyup(){this.isTopLevel&&this.elements.controller&&this.elements.controller.dom.toggle.addEventListener("keyup",e=>{this.currentEvent="keyboard";const t=w(e);(t==="Space"||t==="Enter")&&(u(e),this.elements.controller.toggle(),this.elements.controller.isOpen&&this.focusFirstChild())})}focus(){this.focusState="self",this.shouldFocus&&this.dom.menu.focus()}blur(){this.focusState="none",this.shouldFocus&&this.dom.menu.blur()}focusCurrentChild(){this.focusState="self",this.currentChild!==-1&&this.currentMenuItem.focus()}focusChild(e){this.blurCurrentChild(),this.currentChild=e,this.focusCurrentChild()}focusFirstChild(){this.focusChild(0)}focusLastChild(){this.focusChild(this.elements.menuItems.length-1)}focusNextChild(){this.currentChild<this.elements.menuItems.length-1?this.focusChild(this.currentChild+1):this.focusCurrentChild()}focusPreviousChild(){this.currentChild>0?this.focusChild(this.currentChild-1):this.focusCurrentChild()}blurCurrentChild(){this.focusState="none",this.currentChild!==-1&&this.currentMenuItem.blur()}focusController(){this.dom.controller&&(this.shouldFocus&&this.dom.controller.focus(),this.focusState="none")}focusContainer(){this.dom.container&&(this.shouldFocus&&this.dom.container.focus(),this.focusState="none")}closeChildren(){this.elements.submenuToggles.forEach(e=>e.close())}blurChildren(){this.elements.menuItems.forEach(e=>{e.blur(),e.isSubmenuItem&&e.elements.childMenu.blurChildren()})}}class O extends F{constructor({menuItemElement:e,menuLinkElement:t,parentMenu:s,isSubmenuItem:n=!1,childMenu:r=null,toggle:l=null,initialize:a=!0}){super({menuItemElement:e,menuLinkElement:t,parentMenu:s,isSubmenuItem:n,childMenu:r,toggle:l}),a&&this.initialize()}initialize(){super.initialize(),this.dom.item.setAttribute("role","none"),this.dom.link.setAttribute("role","menuitem"),this.dom.link.tabIndex=-1}focus(){super.focus(),this.elements.parentMenu.isTopLevel&&(this.dom.link.tabIndex=0)}blur(){super.blur(),this.elements.parentMenu.isTopLevel&&(this.dom.link.tabIndex=-1)}}class z extends x{constructor({menuToggleElement:e,parentElement:t,controlledMenu:s,parentMenu:n=null,initialize:r=!0}){super({menuToggleElement:e,parentElement:t,controlledMenu:s,parentMenu:n}),r&&this.initialize()}open(){this.closeSiblings(),super.open()}preview(){this.closeSiblings(),super.preview()}close(){this.isOpen&&(this.closeChildren(),this.elements.parentMenu&&this.elements.parentMenu.focusCurrentChild()),super.close()}}class k extends I{constructor({menuElement:t,menuItemSelector:s="li",menuLinkSelector:n="a",submenuItemSelector:r="",submenuToggleSelector:l="a",submenuSelector:a="ul",controllerElement:d=null,containerElement:h=null,openClass:_="show",closeClass:b="hide",transitionClass:y="transitioning",isTopLevel:C=!0,parentMenu:M=null,hoverType:E="off",hoverDelay:T=250,enterDelay:v=-1,leaveDelay:D=-1,initialize:L=!0}){super({menuElement:t,menuItemSelector:s,menuLinkSelector:n,submenuItemSelector:r,submenuToggleSelector:l,submenuSelector:a,controllerElement:d,containerElement:h,openClass:_,closeClass:b,transitionClass:y,isTopLevel:C,parentMenu:M,hoverType:E,hoverDelay:T,enterDelay:v,leaveDelay:D});o(this,"_MenuType",k);o(this,"_MenuItemType",O);o(this,"_MenuToggleType",z);L&&this.initialize()}initialize(){try{super.initialize(),this.isTopLevel?this.dom.menu.setAttribute("role","menubar"):this.dom.menu.setAttribute("role","menu"),this._handleFocus(),this._handleClick(),this._handleHover(),this._handleKeydown(),this._handleKeyup(),this.isTopLevel&&(this.elements.menuItems[0].dom.link.tabIndex=0)}catch(t){console.error(t)}}_handleClick(){super._handleClick(),document.addEventListener("pointerup",t=>{this.focusState!=="none"&&(this.currentEvent="mouse",!this.dom.menu.contains(t.target)&&!this.dom.menu!==t.target&&(this.closeChildren(),this.blur(),this.elements.controller&&this.elements.controller.close()))})}_handleKeydown(){super._handleKeydown(),this.dom.menu.addEventListener("keydown",t=>{this.currentEvent="keyboard";const s=w(t);if(s==="Tab"&&(this.elements.rootMenu.focusState!=="none"?(this.elements.rootMenu.blur(),this.elements.rootMenu.closeChildren()):this.elements.rootMenu.focus()),s==="Character")u(t);else if(this.isTopLevel){if(this.focusState==="self"){const n=["ArrowRight","ArrowLeft","Home","End"],r=["Space","Enter","ArrowDown","ArrowUp"],l=["Escape"];(n.includes(s)||this.currentMenuItem.isSubmenuItem&&r.includes(s)||this.elements.controller&&l.includes(s))&&u(t)}}else{const n=["Escape","ArrowRight","ArrowLeft","ArrowDown","ArrowUp","Home","End"],r=["Space","Enter"];(n.includes(s)||this.currentMenuItem.isSubmenuItem&&r.includes(s))&&u(t)}})}_handleKeyup(){super._handleKeyup(),this.dom.menu.addEventListener("keyup",t=>{this.currentEvent="keyboard";const s=w(t),{altKey:n,crtlKey:r,metaKey:l}=t;if(s==="Character"&&!(n||r||l))u(t),this.elements.rootMenu.currentEvent="character",this.focusNextChildWithCharacter(t.key);else if(this.isTopLevel){if(this.focusState==="self")if(s==="Space"||s==="Enter")this.currentMenuItem.isSubmenuItem?(u(t),this.currentMenuItem.elements.childMenu.currentEvent="keyboard",this.currentMenuItem.elements.toggle.open(),requestAnimationFrame(()=>{this.currentMenuItem.elements.childMenu.focusFirstChild()})):this.currentMenuItem.dom.link.click();else if(s==="ArrowRight"){u(t);const d=this.currentMenuItem.isSubmenuItem&&this.currentMenuItem.elements.toggle.isOpen;this.focusNextChild(),d&&(this.currentMenuItem.isSubmenuItem?(this.currentMenuItem.elements.childMenu.currentEvent="keyboard",this.currentMenuItem.elements.toggle.preview()):this.closeChildren())}else if(s==="ArrowLeft"){u(t);const d=this.currentMenuItem.isSubmenuItem&&this.currentMenuItem.elements.toggle.isOpen;this.focusPreviousChild(),d&&(this.currentMenuItem.isSubmenuItem?(this.currentMenuItem.elements.childMenu.currentEvent="keyboard",this.currentMenuItem.elements.toggle.preview()):this.closeChildren())}else s==="ArrowDown"?this.currentMenuItem.isSubmenuItem&&(u(t),this.currentMenuItem.elements.childMenu.currentEvent="keyboard",this.currentMenuItem.elements.toggle.open(),requestAnimationFrame(()=>{this.currentMenuItem.elements.childMenu.focusFirstChild()})):s==="ArrowUp"?this.currentMenuItem.isSubmenuItem&&(u(t),this.currentMenuItem.elements.childMenu.currentEvent="keyboard",this.currentMenuItem.elements.toggle.open(),requestAnimationFrame(()=>{this.currentMenuItem.elements.childMenu.focusLastChild()})):s==="Home"?(u(t),this.focusFirstChild()):s==="End"?(u(t),this.focusLastChild()):s==="Escape"&&(this.elements.submenuToggles.some(h=>h.isOpen)?(u(t),this.closeChildren()):this.isTopLevel&&this.elements.controller&&this.elements.controller.isOpen&&(u(t),this.elements.controller.close(),this.focusController()))}else s==="Space"||s==="Enter"?this.currentMenuItem.isSubmenuItem?(u(t),this.currentMenuItem.elements.childMenu.currentEvent="keyboard",this.currentMenuItem.elements.toggle.open(),requestAnimationFrame(()=>{this.currentMenuItem.elements.childMenu.focusFirstChild()})):this.currentMenuItem.dom.link.click():s==="Escape"?(u(t),this.elements.rootMenu.closeChildren(),this.elements.rootMenu.focusCurrentChild()):s==="ArrowRight"?this.currentMenuItem.isSubmenuItem?(u(t),this.currentMenuItem.elements.childMenu.currentEvent="keyboard",this.currentMenuItem.elements.toggle.open(),requestAnimationFrame(()=>{this.currentMenuItem.elements.childMenu.focusFirstChild()})):(u(t),this.elements.rootMenu.closeChildren(),this.elements.rootMenu.focusNextChild(),this.elements.rootMenu.currentMenuItem.isSubmenuItem&&this.elements.rootMenu.currentMenuItem.elements.toggle.preview()):s==="ArrowLeft"?this.elements.parentMenu.currentMenuItem.isSubmenuItem&&(u(t),this.elements.parentMenu.currentMenuItem.elements.toggle.close(),this.elements.parentMenu.focusCurrentChild(),this.elements.parentMenu===this.elements.rootMenu&&(this.elements.rootMenu.closeChildren(),this.elements.rootMenu.focusPreviousChild(),this.elements.rootMenu.currentMenuItem.isSubmenuItem&&(this.elements.rootMenu.currentMenuItem.elements.childMenu.currentEvent="keyboard",this.elements.rootMenu.currentMenuItem.elements.toggle.preview()))):s==="ArrowDown"?(u(t),this.focusNextChild()):s==="ArrowUp"?(u(t),this.focusPreviousChild()):s==="Home"?(u(t),this.focusFirstChild()):s==="End"&&(u(t),this.focusLastChild())})}focusNextChild(){this.currentChild===this.elements.menuItems.length-1?this.focusFirstChild():this.focusChild(this.currentChild+1)}focusPreviousChild(){this.currentChild===0?this.focusLastChild():this.focusChild(this.currentChild-1)}focusNextChildWithCharacter(t){const s=t.toLowerCase();let n=this.currentChild+1,r=!1;for(;!r&&n<this.elements.menuItems.length;){let l="";this.elements.menuItems[n].dom.item.innerText?l=this.elements.menuItems[n].dom.item.innerText:l=this.elements.menuItems[n].dom.item.textContent,l=l.replace(/[\s]/g,"").toLowerCase().charAt(0),l===s&&(r=!0,this.focusChild(n)),n++}}}class H extends O{constructor({menuItemElement:e,menuLinkElement:t,parentMenu:s,isSubmenuItem:n=!1,childMenu:r=null,toggle:l=null,initialize:a=!0}){super({menuItemElement:e,menuLinkElement:t,parentMenu:s,isSubmenuItem:n,childMenu:r,toggle:l,initialize:!1}),a&&this.initialize()}}class K extends z{constructor({menuToggleElement:t,parentElement:s,controlledMenu:n,parentMenu:r=null,initialize:l=!0}){super({menuToggleElement:t,parentElement:s,controlledMenu:n,parentMenu:r,initialize:!1});o(this,"_dom",{toggle:null,parent:null,container:null});this._dom.toggle=t,this._dom.parent=s,this._dom.container=n.isTopLevel?n.dom.container:n.dom.menu,l&&this.initialize()}initialize(){super.initialize(),this.dom.toggle.hasAttribute("data-bs-toggle")&&this.dom.toggle.removeAttribute("data-bs-toggle"),this.dom.toggle.hasAttribute("data-bs-target")&&this.dom.toggle.removeAttribute("data-bs-target")}_expand(t=!0){const{openClass:s,transitionClass:n}=this.elements.controlledMenu;this.dom.toggle.setAttribute("aria-expanded","true"),n!==""?(m(n,this.dom.container),requestAnimationFrame(()=>{m(s,this.dom.container),requestAnimationFrame(()=>{c(n,this.dom.container)})})):s!==""&&m(s,this.dom.container),t&&this.dom.toggle.dispatchEvent(this._expandEvent)}_collapse(t=!0){const{closeClass:s,openClass:n,transitionClass:r}=this.elements.controlledMenu;this.dom.toggle.setAttribute("aria-expanded","false"),r!==""?(m(r,this.dom.container),requestAnimationFrame(()=>{n!==""&&c(n,this.dom.container),requestAnimationFrame(()=>{s!==""&&m(s,this.dom.container),requestAnimationFrame(()=>{c(r,this.dom.container)})})})):(s!==""&&m(s,this.dom.container),n!==""&&c(n,this.dom.container)),t&&this.dom.toggle.dispatchEvent(this._collapseEvent)}}class A extends k{constructor({menuElement:t,menuItemSelector:s=".nav-item,li",menuLinkSelector:n=".nav-link,.dropdown-item",submenuItemSelector:r=".dropdown",submenuToggleSelector:l=".dropdown-toggle",submenuSelector:a=".dropdown-menu",controllerElement:d=null,containerElement:h=null,openClass:_="show",closeClass:b="collapse",transitionClass:y="transitioning",isTopLevel:C=!0,parentMenu:M=null,hoverType:E="off",hoverDelay:T=250,enterDelay:v=-1,leaveDelay:D=-1,initialize:L=!0}){super({menuElement:t,menuItemSelector:s,menuLinkSelector:n,submenuItemSelector:r,submenuToggleSelector:l,submenuSelector:a,controllerElement:d,containerElement:h,openClass:_,closeClass:b,transitionClass:y,isTopLevel:C,parentMenu:M,hoverType:E,hoverDelay:T,enterDelay:v,leaveDelay:D,initialize:!1});o(this,"_MenuType",A);o(this,"_MenuItemType",H);o(this,"_MenuToggleType",K);L&&this.initialize()}}return A}(); |
@@ -1,3 +0,3 @@ | ||
var Bootstrap5TopLinkDisclosureMenu=function(){"use strict";var U=Object.defineProperty;var B=(m,a,p)=>a in m?U(m,a,{enumerable:!0,configurable:!0,writable:!0,value:p}):m[a]=p;var l=(m,a,p)=>(B(m,typeof a!="symbol"?a+"":a,p),p);function m(i,e){typeof i=="string"?e.classList.add(i):e.classList.add(...i)}function a(i,e){typeof i=="string"?e.classList.remove(i):e.classList.remove(...i)}function p(i,e){try{if(typeof e!="object"){const t=typeof e;throw new TypeError(`Elements given to isValidInstance() must be inside of an object. "${t}" given.`)}for(const t in e)if(!(e[t]instanceof i)){const s=typeof e[t];throw new TypeError(`${t} must be an instance of ${i.name}. "${s}" given.`)}return{status:!0,error:null}}catch(t){return{status:!1,error:t}}}function f(i,e){try{if(typeof e!="object"){const t=typeof e;throw new TypeError(`Values given to isValidType() must be inside of an object. "${t}" given.`)}for(const t in e){const s=typeof e[t];if(s!==i)throw new TypeError(`${t} must be a ${i}. "${s}" given.`)}return{status:!0,error:null}}catch(t){return{status:!1,error:t}}}function w(i){try{if(typeof i!="object"){const e=typeof i;throw new TypeError(`Values given to isCSSSelector() must be inside of an object. "${e}" given.`)}for(const e in i)try{if(i[e]===null)throw new Error;document.querySelector(i[e])}catch{throw new TypeError(`${e} must be a valid CSS selector. "${i[e]}" given.`)}return{status:!0,error:null}}catch(e){return{status:!1,error:e}}}function g(i){try{if(typeof i!="object"||Array.isArray(i)){const e=typeof i;throw new TypeError(`Values given to isValidClassList() must be inside of an object. "${e}" given.`)}for(const e in i){const t=typeof i[e];if(t!=="string")if(Array.isArray(i[e]))i[e].forEach(s=>{if(typeof s!="string")throw new TypeError(`${e} must be a string or an array of strings. An array containing non-strings given.`)});else throw new TypeError(`${e} must be a string or an array of strings. "${t}" given.`);else{const s={};s[e]=i[e],w(s)}}return{status:!0,error:null}}catch(e){return{status:!1,error:e}}}function K(i){try{if(typeof i!="object"){const t=typeof i;throw new TypeError(`Values given to isValidState() must be inside of an object. "${t}" given.`)}const e=["none","self","child"];for(const t in i)if(!e.includes(i[t]))throw new TypeError(`${t} must be one of the following values: ${e.join(", ")}. "${i[t]}" given.`);return{status:!0,error:null}}catch(e){return{status:!1,error:e}}}function V(i){try{if(typeof i!="object"){const t=typeof i;throw new TypeError(`Values given to isValidEvent() must be inside of an object. "${t}" given.`)}const e=["none","mouse","keyboard","character"];for(const t in i)if(!e.includes(i[t]))throw new TypeError(`${t} must be one of the following values: ${e.join(", ")}. "${i[t]}" given.`);return{status:!0,error:null}}catch(e){return{status:!1,error:e}}}function F(i){try{if(typeof i!="object"){const t=typeof i;throw new TypeError(`Values given to isValidHoverType() must be inside of an object. "${t}" given.`)}const e=["off","on","dynamic"];for(const t in i)if(!e.includes(i[t]))throw new TypeError(`${t} must be one of the following values: ${e.join(", ")}. "${i[t]}" given.`);return{status:!0,error:null}}catch(e){return{status:!1,error:e}}}function H(i,e){if(f("string",{tagName:i}).status&&p(HTMLElement,e).status){const t=i.toLowerCase();let s=!0;for(const n in e)e[n].tagName.toLowerCase()!==t&&(s=!1);return s}else return!1}class j{constructor({menuToggleElement:e,parentElement:t,controlledMenu:s,parentMenu:n=null}){l(this,"_dom",{toggle:null,parent:null});l(this,"_elements",{controlledMenu:null,parentMenu:null});l(this,"_open",!1);l(this,"_expandEvent",new CustomEvent("accessibleMenuExpand",{bubbles:!0,detail:{toggle:this}}));l(this,"_collapseEvent",new CustomEvent("accessibleMenuCollapse",{bubbles:!0,detail:{toggle:this}}));this._dom.toggle=e,this._dom.parent=t,this._elements.controlledMenu=s,this._elements.parentMenu=n}initialize(){var e;if(this.dom.toggle.setAttribute("aria-haspopup","true"),this.dom.toggle.setAttribute("aria-expanded","false"),H("button",{toggle:this.dom.toggle})||this.dom.toggle.setAttribute("role","button"),this.dom.toggle.id===""||this.elements.controlledMenu.dom.menu.id===""){const t=Math.random().toString(36).replace(/[^a-z]+/g,"").substr(0,10);let s=((e=this.dom.toggle.innerText)==null?void 0:e.replace(/[^a-zA-Z0-9\s]/g,""))||"",n=t;!s.replace(/\s/g,"").length&&this.dom.toggle.getAttribute("aria-label")&&(s=this.dom.toggle.getAttribute("aria-label").replace(/[^a-zA-Z0-9\s]/g,"")),s.replace(/\s/g,"").length>0&&(s=s.toLowerCase().replace(/\s+/g,"-"),s.startsWith("-")&&(s=s.substring(1)),s.endsWith("-")&&(s=s.slice(0,-1)),n=`${s}-${n}`),this.dom.toggle.id=this.dom.toggle.id||`${n}-menu-button`,this.elements.controlledMenu.dom.menu.id=this.elements.controlledMenu.dom.menu.id||`${n}-menu`}this.elements.controlledMenu.dom.menu.setAttribute("aria-labelledby",this.dom.toggle.id),this.dom.toggle.setAttribute("aria-controls",this.elements.controlledMenu.dom.menu.id),this._collapse(!1)}get dom(){return this._dom}get elements(){return this._elements}get isOpen(){return this._open}set isOpen(e){f("boolean",{value:e}),this._open=e}_expand(e=!0){const{closeClass:t,openClass:s,transitionClass:n}=this.elements.controlledMenu;this.dom.toggle.setAttribute("aria-expanded","true"),n!==""?(m(n,this.elements.controlledMenu.dom.menu),requestAnimationFrame(()=>{t!==""&&a(t,this.elements.controlledMenu.dom.menu),requestAnimationFrame(()=>{s!==""&&m(s,this.elements.controlledMenu.dom.menu),requestAnimationFrame(()=>{a(n,this.elements.controlledMenu.dom.menu)})})})):(s!==""&&m(s,this.elements.controlledMenu.dom.menu),t!==""&&a(t,this.elements.controlledMenu.dom.menu)),e&&this.dom.toggle.dispatchEvent(this._expandEvent)}_collapse(e=!0){const{closeClass:t,openClass:s,transitionClass:n}=this.elements.controlledMenu;this.dom.toggle.setAttribute("aria-expanded","false"),n!==""?(m(n,this.elements.controlledMenu.dom.menu),requestAnimationFrame(()=>{s!==""&&a(s,this.elements.controlledMenu.dom.menu),requestAnimationFrame(()=>{t!==""&&m(t,this.elements.controlledMenu.dom.menu),requestAnimationFrame(()=>{a(n,this.elements.controlledMenu.dom.menu)})})})):(t!==""&&m(t,this.elements.controlledMenu.dom.menu),s!==""&&a(s,this.elements.controlledMenu.dom.menu)),e&&this.dom.toggle.dispatchEvent(this._collapseEvent)}open(){this.elements.controlledMenu.focusState="self",this._expand(),this.isOpen=!0}preview(){this.elements.parentMenu&&(this.elements.parentMenu.focusState="self"),this._expand(),this.isOpen=!0}close(){this.isOpen&&(this.elements.controlledMenu.currentChild=0,this.elements.controlledMenu.blur(),this.elements.parentMenu&&(this.elements.parentMenu.focusState="self"),this._collapse(),this.isOpen=!1)}toggle(){this.isOpen?this.close():this.open()}closeSiblings(){this.elements.parentMenu&&this.elements.parentMenu.elements.submenuToggles.forEach(e=>{e!==this&&e.close()})}closeChildren(){this.elements.controlledMenu.elements.submenuToggles.forEach(e=>e.close())}}class x{constructor({menuItemElement:e,menuLinkElement:t,parentMenu:s,isSubmenuItem:n=!1,childMenu:o=null,toggle:r=null}){l(this,"_dom",{item:null,link:null});l(this,"_elements",{parentMenu:null,childMenu:null,toggle:null});l(this,"_submenu",!1);this._dom.item=e,this._dom.link=t,this._elements.parentMenu=s,this._elements.childMenu=o,this._elements.toggle=r,this._submenu=n}initialize(){}get dom(){return this._dom}get elements(){return this._elements}get isSubmenuItem(){return this._submenu}focus(){this.elements.parentMenu.shouldFocus&&this.dom.link.focus()}blur(){this.elements.parentMenu.shouldFocus&&this.dom.link.blur()}}function S(i){try{const e=i.key||i.keyCode,t={Enter:e==="Enter"||e===13,Space:e===" "||e==="Spacebar"||e===32,Escape:e==="Escape"||e==="Esc"||e===27,ArrowUp:e==="ArrowUp"||e==="Up"||e===38,ArrowRight:e==="ArrowRight"||e==="Right"||e===39,ArrowDown:e==="ArrowDown"||e==="Down"||e===40,ArrowLeft:e==="ArrowLeft"||e==="Left"||e===37,Home:e==="Home"||e===36,End:e==="End"||e===35,Character:isNaN(e)&&!!e.match(/^[a-zA-Z]{1}$/),Tab:e==="Tab"||e===9,Asterisk:e==="*"||e===56};return Object.keys(t).find(s=>t[s]===!0)||""}catch{return""}}function d(i){i.preventDefault(),i.stopPropagation()}class k{constructor({menuElement:e,menuItemSelector:t="li",menuLinkSelector:s="a",submenuItemSelector:n="",submenuToggleSelector:o="a",submenuSelector:r="ul",controllerElement:h=null,containerElement:c=null,openClass:u="show",closeClass:y="hide",transitionClass:b="transitioning",isTopLevel:_=!0,parentMenu:C=null,hoverType:T="off",hoverDelay:E=250,enterDelay:M=-1,leaveDelay:v=-1}){l(this,"_MenuType",k);l(this,"_MenuItemType",x);l(this,"_MenuToggleType",j);l(this,"_dom",{menu:null,menuItems:[],submenuItems:[],submenuToggles:[],submenus:[],controller:null,container:null});l(this,"_selectors",{menuItems:"",menuLinks:"",submenuItems:"",submenuToggles:"",submenus:""});l(this,"_elements",{menuItems:[],submenuToggles:[],controller:null,parentMenu:null,rootMenu:null});l(this,"_openClass","show");l(this,"_closeClass","hide");l(this,"_transitionClass","transitioning");l(this,"_root",!0);l(this,"_currentChild",0);l(this,"_focusState","none");l(this,"_currentEvent","none");l(this,"_hoverType","off");l(this,"_hoverDelay",250);l(this,"_enterDelay",-1);l(this,"_leaveDelay",-1);l(this,"_hoverTimeout",null);l(this,"_errors",[]);this._dom.menu=e,this._dom.controller=h,this._dom.container=c,this._selectors.menuItems=t,this._selectors.menuLinks=s,this._selectors.submenuItems=n,this._selectors.submenuToggles=o,this._selectors.submenus=r,this._elements.menuItems=[],this._elements.submenuToggles=[],this._elements.controller=null,this._elements.parentMenu=C,this._elements.rootMenu=_?this:null,this._openClass=u||"",this._closeClass=y||"",this._transitionClass=b||"",this._root=_,this._hoverType=T,this._hoverDelay=E,this._enterDelay=M,this._leaveDelay=v}initialize(){if(!this._validate())throw new Error(`AccesibleMenu: cannot initialize menu. The following errors have been found: | ||
var Bootstrap5TopLinkDisclosureMenu=function(){"use strict";var U=Object.defineProperty;var B=(a,m,p)=>m in a?U(a,m,{enumerable:!0,configurable:!0,writable:!0,value:p}):a[m]=p;var l=(a,m,p)=>(B(a,typeof m!="symbol"?m+"":m,p),p);function a(i,e){typeof i=="string"?e.classList.add(i):e.classList.add(...i)}function m(i,e){typeof i=="string"?e.classList.remove(i):e.classList.remove(...i)}function p(i,e){try{if(typeof e!="object"){const t=typeof e;throw new TypeError(`Elements given to isValidInstance() must be inside of an object. "${t}" given.`)}for(const t in e)if(!(e[t]instanceof i)){const s=typeof e[t];throw new TypeError(`${t} must be an instance of ${i.name}. "${s}" given.`)}return{status:!0,error:null}}catch(t){return{status:!1,error:t}}}function f(i,e){try{if(typeof e!="object"){const t=typeof e;throw new TypeError(`Values given to isValidType() must be inside of an object. "${t}" given.`)}for(const t in e){const s=typeof e[t];if(s!==i)throw new TypeError(`${t} must be a ${i}. "${s}" given.`)}return{status:!0,error:null}}catch(t){return{status:!1,error:t}}}function w(i){try{if(typeof i!="object"){const e=typeof i;throw new TypeError(`Values given to isCSSSelector() must be inside of an object. "${e}" given.`)}for(const e in i)try{if(i[e]===null)throw new Error;document.querySelector(i[e])}catch{throw new TypeError(`${e} must be a valid CSS selector. "${i[e]}" given.`)}return{status:!0,error:null}}catch(e){return{status:!1,error:e}}}function g(i){try{if(typeof i!="object"||Array.isArray(i)){const e=typeof i;throw new TypeError(`Values given to isValidClassList() must be inside of an object. "${e}" given.`)}for(const e in i){const t=typeof i[e];if(t!=="string")if(Array.isArray(i[e]))i[e].forEach(s=>{if(typeof s!="string")throw new TypeError(`${e} must be a string or an array of strings. An array containing non-strings given.`)});else throw new TypeError(`${e} must be a string or an array of strings. "${t}" given.`);else{const s={};s[e]=i[e],w(s)}}return{status:!0,error:null}}catch(e){return{status:!1,error:e}}}function K(i){try{if(typeof i!="object"){const t=typeof i;throw new TypeError(`Values given to isValidState() must be inside of an object. "${t}" given.`)}const e=["none","self","child"];for(const t in i)if(!e.includes(i[t]))throw new TypeError(`${t} must be one of the following values: ${e.join(", ")}. "${i[t]}" given.`);return{status:!0,error:null}}catch(e){return{status:!1,error:e}}}function V(i){try{if(typeof i!="object"){const t=typeof i;throw new TypeError(`Values given to isValidEvent() must be inside of an object. "${t}" given.`)}const e=["none","mouse","keyboard","character"];for(const t in i)if(!e.includes(i[t]))throw new TypeError(`${t} must be one of the following values: ${e.join(", ")}. "${i[t]}" given.`);return{status:!0,error:null}}catch(e){return{status:!1,error:e}}}function F(i){try{if(typeof i!="object"){const t=typeof i;throw new TypeError(`Values given to isValidHoverType() must be inside of an object. "${t}" given.`)}const e=["off","on","dynamic"];for(const t in i)if(!e.includes(i[t]))throw new TypeError(`${t} must be one of the following values: ${e.join(", ")}. "${i[t]}" given.`);return{status:!0,error:null}}catch(e){return{status:!1,error:e}}}function H(i,e){if(f("string",{tagName:i}).status&&p(HTMLElement,e).status){const t=i.toLowerCase();let s=!0;for(const n in e)e[n].tagName.toLowerCase()!==t&&(s=!1);return s}else return!1}class j{constructor({menuToggleElement:e,parentElement:t,controlledMenu:s,parentMenu:n=null}){l(this,"_dom",{toggle:null,parent:null});l(this,"_elements",{controlledMenu:null,parentMenu:null});l(this,"_open",!1);l(this,"_expandEvent",new CustomEvent("accessibleMenuExpand",{bubbles:!0,detail:{toggle:this}}));l(this,"_collapseEvent",new CustomEvent("accessibleMenuCollapse",{bubbles:!0,detail:{toggle:this}}));this._dom.toggle=e,this._dom.parent=t,this._elements.controlledMenu=s,this._elements.parentMenu=n}initialize(){var e;if(this.dom.toggle.setAttribute("aria-haspopup","true"),this.dom.toggle.setAttribute("aria-expanded","false"),H("button",{toggle:this.dom.toggle})||this.dom.toggle.setAttribute("role","button"),this.dom.toggle.id===""||this.elements.controlledMenu.dom.menu.id===""){const t=Math.random().toString(36).replace(/[^a-z]+/g,"").substr(0,10);let s=((e=this.dom.toggle.innerText)==null?void 0:e.replace(/[^a-zA-Z0-9\s]/g,""))||"",n=t;!s.replace(/\s/g,"").length&&this.dom.toggle.getAttribute("aria-label")&&(s=this.dom.toggle.getAttribute("aria-label").replace(/[^a-zA-Z0-9\s]/g,"")),s.replace(/\s/g,"").length>0&&(s=s.toLowerCase().replace(/\s+/g,"-"),s.startsWith("-")&&(s=s.substring(1)),s.endsWith("-")&&(s=s.slice(0,-1)),n=`${s}-${n}`),this.dom.toggle.id=this.dom.toggle.id||`${n}-menu-button`,this.elements.controlledMenu.dom.menu.id=this.elements.controlledMenu.dom.menu.id||`${n}-menu`}this.elements.controlledMenu.dom.menu.setAttribute("aria-labelledby",this.dom.toggle.id),this.dom.toggle.setAttribute("aria-controls",this.elements.controlledMenu.dom.menu.id),this._collapse(!1)}get dom(){return this._dom}get elements(){return this._elements}get isOpen(){return this._open}set isOpen(e){f("boolean",{value:e}),this._open=e}_expand(e=!0){const{closeClass:t,openClass:s,transitionClass:n}=this.elements.controlledMenu;this.dom.toggle.setAttribute("aria-expanded","true"),n!==""?(a(n,this.elements.controlledMenu.dom.menu),requestAnimationFrame(()=>{t!==""&&m(t,this.elements.controlledMenu.dom.menu),requestAnimationFrame(()=>{s!==""&&a(s,this.elements.controlledMenu.dom.menu),requestAnimationFrame(()=>{m(n,this.elements.controlledMenu.dom.menu)})})})):(s!==""&&a(s,this.elements.controlledMenu.dom.menu),t!==""&&m(t,this.elements.controlledMenu.dom.menu)),e&&this.dom.toggle.dispatchEvent(this._expandEvent)}_collapse(e=!0){const{closeClass:t,openClass:s,transitionClass:n}=this.elements.controlledMenu;this.dom.toggle.setAttribute("aria-expanded","false"),n!==""?(a(n,this.elements.controlledMenu.dom.menu),requestAnimationFrame(()=>{s!==""&&m(s,this.elements.controlledMenu.dom.menu),requestAnimationFrame(()=>{t!==""&&a(t,this.elements.controlledMenu.dom.menu),requestAnimationFrame(()=>{m(n,this.elements.controlledMenu.dom.menu)})})})):(t!==""&&a(t,this.elements.controlledMenu.dom.menu),s!==""&&m(s,this.elements.controlledMenu.dom.menu)),e&&this.dom.toggle.dispatchEvent(this._collapseEvent)}open(){this.elements.controlledMenu.focusState="self",this._expand(),this.isOpen=!0}preview(){this.elements.parentMenu&&(this.elements.parentMenu.focusState="self"),this._expand(),this.isOpen=!0}close(){this.isOpen&&(this.elements.controlledMenu.blur(),this.elements.parentMenu&&(this.elements.parentMenu.focusState="self"),this._collapse(),this.isOpen=!1)}toggle(){this.isOpen?this.close():this.open()}closeSiblings(){this.elements.parentMenu&&this.elements.parentMenu.elements.submenuToggles.forEach(e=>{e!==this&&e.close()})}closeChildren(){this.elements.controlledMenu.elements.submenuToggles.forEach(e=>e.close())}}class x{constructor({menuItemElement:e,menuLinkElement:t,parentMenu:s,isSubmenuItem:n=!1,childMenu:o=null,toggle:r=null}){l(this,"_dom",{item:null,link:null});l(this,"_elements",{parentMenu:null,childMenu:null,toggle:null});l(this,"_submenu",!1);this._dom.item=e,this._dom.link=t,this._elements.parentMenu=s,this._elements.childMenu=o,this._elements.toggle=r,this._submenu=n}initialize(){}get dom(){return this._dom}get elements(){return this._elements}get isSubmenuItem(){return this._submenu}focus(){this.elements.parentMenu.shouldFocus&&this.dom.link.focus()}blur(){this.elements.parentMenu.shouldFocus&&this.dom.link.blur()}}function S(i){try{const e=i.key||i.keyCode,t={Enter:e==="Enter"||e===13,Space:e===" "||e==="Spacebar"||e===32,Escape:e==="Escape"||e==="Esc"||e===27,ArrowUp:e==="ArrowUp"||e==="Up"||e===38,ArrowRight:e==="ArrowRight"||e==="Right"||e===39,ArrowDown:e==="ArrowDown"||e==="Down"||e===40,ArrowLeft:e==="ArrowLeft"||e==="Left"||e===37,Home:e==="Home"||e===36,End:e==="End"||e===35,Character:isNaN(e)&&!!e.match(/^[a-zA-Z]{1}$/),Tab:e==="Tab"||e===9,Asterisk:e==="*"||e===56};return Object.keys(t).find(s=>t[s]===!0)||""}catch{return""}}function d(i){i.preventDefault(),i.stopPropagation()}class k{constructor({menuElement:e,menuItemSelector:t="li",menuLinkSelector:s="a",submenuItemSelector:n="",submenuToggleSelector:o="a",submenuSelector:r="ul",controllerElement:h=null,containerElement:c=null,openClass:u="show",closeClass:_="hide",transitionClass:b="transitioning",isTopLevel:y=!0,parentMenu:C=null,hoverType:T="off",hoverDelay:E=250,enterDelay:M=-1,leaveDelay:v=-1}){l(this,"_MenuType",k);l(this,"_MenuItemType",x);l(this,"_MenuToggleType",j);l(this,"_dom",{menu:null,menuItems:[],submenuItems:[],submenuToggles:[],submenus:[],controller:null,container:null});l(this,"_selectors",{menuItems:"",menuLinks:"",submenuItems:"",submenuToggles:"",submenus:""});l(this,"_elements",{menuItems:[],submenuToggles:[],controller:null,parentMenu:null,rootMenu:null});l(this,"_openClass","show");l(this,"_closeClass","hide");l(this,"_transitionClass","transitioning");l(this,"_root",!0);l(this,"_currentChild",0);l(this,"_focusState","none");l(this,"_currentEvent","none");l(this,"_hoverType","off");l(this,"_hoverDelay",250);l(this,"_enterDelay",-1);l(this,"_leaveDelay",-1);l(this,"_hoverTimeout",null);l(this,"_errors",[]);this._dom.menu=e,this._dom.controller=h,this._dom.container=c,this._selectors.menuItems=t,this._selectors.menuLinks=s,this._selectors.submenuItems=n,this._selectors.submenuToggles=o,this._selectors.submenus=r,this._elements.menuItems=[],this._elements.submenuToggles=[],this._elements.controller=null,this._elements.parentMenu=C,this._elements.rootMenu=y?this:null,this._openClass=u||"",this._closeClass=_||"",this._transitionClass=b||"",this._root=y,this._hoverType=T,this._hoverDelay=E,this._enterDelay=M,this._leaveDelay=v}initialize(){if(!this._validate())throw new Error(`AccesibleMenu: cannot initialize menu. The following errors have been found: | ||
- ${this.errors.join(` | ||
- `)}`);if(this.elements.rootMenu===null&&this._findRootMenu(this),this._setDOMElements(),this.isTopLevel&&this.dom.controller&&this.dom.container){const e=new this._MenuToggleType({menuToggleElement:this.dom.controller,parentElement:this.dom.container,controlledMenu:this});this._elements.controller=e}this._createChildElements()}get dom(){return this._dom}get selectors(){return this._selectors}get elements(){return this._elements}get isTopLevel(){return this._root}get openClass(){return this.isTopLevel?this._openClass:this.elements.rootMenu.openClass}get closeClass(){return this.isTopLevel?this._closeClass:this.elements.rootMenu.closeClass}get transitionClass(){return this.isTopLevel?this._transitionClass:this.elements.rootMenu.transitionClass}get currentChild(){return this._currentChild}get focusState(){return this._focusState}get currentEvent(){return this._currentEvent}get currentMenuItem(){return this.elements.menuItems[this.currentChild]}get hoverType(){return this._root?this._hoverType:this.elements.rootMenu.hoverType}get hoverDelay(){return this._root?this._hoverDelay:this.elements.rootMenu.hoverDelay}get enterDelay(){return this._enterDelay===-1?this.hoverDelay:this._root?this._enterDelay:this.elements.rootMenu.enterDelay}get leaveDelay(){return this._leaveDelay===-1?this.hoverDelay:this._root?this._leaveDelay:this.elements.rootMenu.leaveDelay}get shouldFocus(){let e=!1;return(this.currentEvent==="keyboard"||this.currentEvent==="character")&&(e=!0),this.currentEvent==="mouse"&&this.hoverType==="dynamic"&&(e=!0),e}get errors(){return this._errors}set openClass(e){g({openClass:e}),this._openClass!==e&&(this._openClass=e)}set closeClass(e){g({closeClass:e}),this._closeClass!==e&&(this._closeClass=e)}set transitionClass(e){g({transitionClass:e}),this._transitionClass!==e&&(this._transitionClass=e)}set currentChild(e){f("number",{value:e});function t(s){if(["mouse","character"].includes(s.currentEvent)&&s.elements.parentMenu){let o=0,r=!1;for(;!r&&o<s.elements.parentMenu.elements.menuItems.length;){const h=s.elements.parentMenu.elements.menuItems[o];h.isSubmenuItem&&h.elements.toggle.elements.controlledMenu===s&&(r=!0,s.elements.parentMenu.currentEvent=s.currentEvent,s.elements.parentMenu.currentChild=o),o++}}}e<-1?(this._currentChild=-1,t(this)):e>=this.elements.menuItems.length?(this._currentChild=this.elements.menuItems.length-1,t(this)):this.focusChild!==e&&(this._currentChild=e,t(this))}set focusState(e){K({value:e}),this._focusState!==e&&(this._focusState=e),this.elements.submenuToggles.length>0&&(e==="self"||e==="none")&&this.elements.submenuToggles.forEach(t=>{t.elements.controlledMenu.focusState="none"}),this.elements.parentMenu&&(e==="self"||e==="child")&&(this.elements.parentMenu.focusState="child")}set currentEvent(e){V({value:e}),this._currentEvent!==e&&(this._currentEvent=e,this.elements.submenuToggles.length>0&&this.elements.submenuToggles.forEach(t=>{t.elements.controlledMenu.currentEvent=e}))}set hoverType(e){F({value:e}),this._hoverType!==e&&(this._hoverType=e)}set hoverDelay(e){f("number",{value:e}),this._hoverDelay!==e&&(this._hoverDelay=e)}set enterDelay(e){f("number",{value:e}),this._enterDelay!==e&&(this._enterDelay=e)}set leaveDelay(e){f("number",{value:e}),this._leaveDelay!==e&&(this._leaveDelay=e)}_validate(){let e=!0,t;this._dom.container!==null||this._dom.controller!==null?t=p(HTMLElement,{menuElement:this._dom.menu,controllerElement:this._dom.controller,containerElement:this._dom.container}):t=p(HTMLElement,{menuElement:this._dom.menu}),t.status||(this._errors.push(t.error.message),e=!1);let s;if(this._selectors.submenuItems!==""?s=w({menuItemSelector:this._selectors.menuItems,menuLinkSelector:this._selectors.menuLinks,submenuItemSelector:this._selectors.submenuItems,submenuToggleSelector:this._selectors.submenuToggles,submenuSelector:this._selectors.submenus}):s=w({menuItemSelector:this._selectors.menuItems,menuLinkSelector:this._selectors.menuLinks}),s.status||(this._errors.push(s.error.message),e=!1),this._openClass!==""){const u=g({openClass:this._openClass});u.status||(this._errors.push(u.error.message),e=!1)}if(this._closeClass!==""){const u=g({closeClass:this._closeClass});u.status||(this._errors.push(u.error.message),e=!1)}if(this._transitionClass!==""){const u=g({transitionClass:this._transitionClass});u.status||(this._errors.push(u.error.message),e=!1)}const n=f("boolean",{isTopLevel:this._root});if(n.status||(this._errors.push(n.error.message),e=!1),this._elements.parentMenu!==null){const u=p(k,{parentMenu:this._elements.parentMenu});u.status||(this._errors.push(u.error.message),e=!1)}const o=F({hoverType:this._hoverType});o.status||(this._errors.push(o.error.message),e=!1);const r=f("number",{hoverDelay:this._hoverDelay});r.status||(this._errors.push(r.error.message),e=!1);const h=f("number",{enterDelay:this._enterDelay});h.status||(this._errors.push(h.error.message),e=!1);const c=f("number",{leaveDelay:this._leaveDelay});return c.status||(this._errors.push(c.error.message),e=!1),e}_setDOMElementType(e,t=this.dom.menu,s=!0){if(typeof this.selectors[e]=="string"){if(!Array.isArray(this.dom[e]))throw new Error(`AccessibleMenu: The "${e}" element cannot be set through _setDOMElementType.`);t!==this.dom.menu&&p(HTMLElement,{base:t});const o=Array.from(t.querySelectorAll(this.selectors[e])).filter(r=>r.parentElement===t);s?this._dom[e]=o:this._dom[e]=[...this._dom[e],...o]}else throw new Error(`AccessibleMenu: "${e}" is not a valid element type within the menu.`)}_resetDOMElementType(e){if(typeof this.dom[e]<"u"){if(!Array.isArray(this.dom[e]))throw new Error(`AccessibleMenu: The "${e}" element cannot be reset through _resetDOMElementType.`);this._dom[e]=[]}else throw new Error(`AccessibleMenu: "${e}" is not a valid element type within the menu.`)}_setDOMElements(){this._setDOMElementType("menuItems"),this.selectors.submenuItems!==""&&(this._setDOMElementType("submenuItems"),this._resetDOMElementType("submenuToggles"),this._resetDOMElementType("submenus"),this.dom.submenuItems.forEach(e=>{this._setDOMElementType("submenuToggles",e,!1),this._setDOMElementType("submenus",e,!1)}))}_findRootMenu(e){if(e.isTopLevel)this._elements.rootMenu=e;else if(e.elements.parentMenu!==null)this._findRootMenu(e.elements.parentMenu);else throw new Error("Cannot find root menu.")}_createChildElements(){this.dom.menuItems.forEach(e=>{let t;if(this.dom.submenuItems.includes(e)){const s=e.querySelector(this.selectors.submenuToggles),n=e.querySelector(this.selectors.submenus),o=new this._MenuType({menuElement:n,menuItemSelector:this.selectors.menuItems,menuLinkSelector:this.selectors.menuLinks,submenuItemSelector:this.selectors.submenuItems,submenuToggleSelector:this.selectors.submenuToggles,submenuSelector:this.selectors.submenus,openClass:this.openClass,closeClass:this.closeClass,isTopLevel:!1,parentMenu:this,hoverType:this.hoverType,hoverDelay:this.hoverDelay}),r=new this._MenuToggleType({menuToggleElement:s,parentElement:e,controlledMenu:o,parentMenu:this});this._elements.submenuToggles.push(r),t=new this._MenuItemType({menuItemElement:e,menuLinkElement:s,parentMenu:this,isSubmenuItem:!0,childMenu:o,toggle:r})}else{const s=e.querySelector(this.selectors.menuLinks);t=new this._MenuItemType({menuItemElement:e,menuLinkElement:s,parentMenu:this})}this._elements.menuItems.push(t)})}_handleFocus(){this.elements.menuItems.forEach((e,t)=>{e.dom.link.addEventListener("focus",()=>{this.focusState="self",this.currentChild=t})})}_handleClick(){function e(t,s,n){d(n),s.toggle(),s.isOpen&&(t.focusState="self",s.elements.controlledMenu.focusState="none")}this.elements.menuItems.forEach((t,s)=>{t.dom.link.addEventListener("pointerdown",()=>{this.currentEvent="mouse",this.elements.rootMenu.blurChildren(),this.focusChild(s)},{passive:!0}),t.isSubmenuItem&&t.elements.toggle.dom.toggle.addEventListener("pointerup",n=>{this.currentEvent="mouse",e(this,t.elements.toggle,n)})}),this.isTopLevel&&this.elements.controller&&this.elements.controller.dom.toggle.addEventListener("pointerup",t=>{this.currentEvent="mouse",e(this,this.elements.controller,t)})}_handleHover(){this.elements.menuItems.forEach((e,t)=>{e.dom.link.addEventListener("pointerenter",s=>{if(!(s.pointerType==="pen"||s.pointerType==="touch")){if(this.hoverType==="on")this.currentEvent="mouse",this.currentChild=t,e.isSubmenuItem&&(this.enterDelay>0?this._hoverTimeout=setTimeout(()=>{e.elements.toggle.preview()},this.enterDelay):e.elements.toggle.preview());else if(this.hoverType==="dynamic"){const n=this.elements.submenuToggles.some(o=>o.isOpen);this.currentChild=t,(!this.isTopLevel||this.focusState!=="none")&&(this.currentEvent="mouse",this.focusCurrentChild()),e.isSubmenuItem&&(!this.isTopLevel||n)&&(this.currentEvent="mouse",this.enterDelay>0?this._hoverTimeout=setTimeout(()=>{e.elements.toggle.preview()},this.enterDelay):e.elements.toggle.preview())}}}),e.isSubmenuItem&&e.dom.item.addEventListener("pointerleave",s=>{s.pointerType==="pen"||s.pointerType==="touch"||(this.hoverType==="on"?this.leaveDelay>0?(clearTimeout(this._hoverTimeout),setTimeout(()=>{this.currentEvent="mouse",e.elements.toggle.close()},this.leaveDelay)):(this.currentEvent="mouse",e.elements.toggle.close()):this.hoverType==="dynamic"&&(this.isTopLevel||(this.leaveDelay>0?(clearTimeout(this._hoverTimeout),setTimeout(()=>{this.currentEvent="mouse",e.elements.toggle.close(),this.focusCurrentChild()},this.leaveDelay)):(this.currentEvent="mouse",e.elements.toggle.close(),this.focusCurrentChild()))))})})}_handleKeydown(){this.isTopLevel&&this.elements.controller&&this.elements.controller.dom.toggle.addEventListener("keydown",e=>{this.currentEvent="keyboard";const t=S(e);(t==="Space"||t==="Enter")&&d(e)})}_handleKeyup(){this.isTopLevel&&this.elements.controller&&this.elements.controller.dom.toggle.addEventListener("keyup",e=>{this.currentEvent="keyboard";const t=S(e);(t==="Space"||t==="Enter")&&(d(e),this.elements.controller.open(),this.focusFirstChild())})}focus(){this.focusState="self",this.shouldFocus&&this.dom.menu.focus()}blur(){this.focusState="none",this.shouldFocus&&this.dom.menu.blur()}focusCurrentChild(){this.focusState="self",this.currentChild!==-1&&this.currentMenuItem.focus()}focusChild(e){this.blurCurrentChild(),this.currentChild=e,this.focusCurrentChild()}focusFirstChild(){this.focusChild(0)}focusLastChild(){this.focusChild(this.elements.menuItems.length-1)}focusNextChild(){this.currentChild<this.elements.menuItems.length-1?this.focusChild(this.currentChild+1):this.focusCurrentChild()}focusPreviousChild(){this.currentChild>0?this.focusChild(this.currentChild-1):this.focusCurrentChild()}blurCurrentChild(){this.focusState="none",this.currentChild!==-1&&this.currentMenuItem.blur()}focusController(){this.dom.controller&&(this.shouldFocus&&this.dom.controller.focus(),this.focusState="none")}focusContainer(){this.dom.container&&(this.shouldFocus&&this.dom.container.focus(),this.focusState="none")}closeChildren(){this.elements.submenuToggles.forEach(e=>e.close())}blurChildren(){this.elements.menuItems.forEach(e=>{e.blur(),e.isSubmenuItem&&e.elements.childMenu.blurChildren()})}}class z extends x{constructor({menuItemElement:t,menuLinkElement:s,parentMenu:n,isSubmenuItem:o=!1,childMenu:r=null,toggle:h=null,initialize:c=!0,submenuSibling:u=null}){super({menuItemElement:t,menuLinkElement:s,parentMenu:n,isSubmenuItem:o,childMenu:r,toggle:h});l(this,"_elements",{parentMenu:null,childMenu:null,toggle:null,sibling:null});this._elements.parentMenu=n,this._elements.childMenu=r,this._elements.toggle=h,this._elements.sibling=u,c&&this.initialize()}}class q extends j{constructor({menuToggleElement:e,parentElement:t,controlledMenu:s,parentMenu:n=null,initialize:o=!0}){super({menuToggleElement:e,parentElement:t,controlledMenu:s,parentMenu:n}),o&&this.initialize()}open(){this.closeSiblings(),super.open()}preview(){this.closeSiblings(),super.preview()}close(){this.isOpen&&this.closeChildren(),super.close()}}class D extends k{constructor({menuElement:t,menuItemSelector:s="li",menuLinkSelector:n="a",submenuItemSelector:o="",submenuToggleSelector:r="button",submenuSelector:h="ul",submenuSubtoggleSelector:c="a",controllerElement:u=null,containerElement:y=null,openClass:b="show",closeClass:_="hide",transitionClass:C="transitioning",isTopLevel:T=!0,parentMenu:E=null,hoverType:M="off",hoverDelay:v=250,enterDelay:I=-1,leaveDelay:A=-1,optionalKeySupport:$=!1,initialize:O=!0}){super({menuElement:t,menuItemSelector:s,menuLinkSelector:n,submenuItemSelector:o,submenuSelector:h,submenuToggleSelector:r,controllerElement:u,containerElement:y,openClass:b,closeClass:_,transitionClass:C,isTopLevel:T,parentMenu:E,hoverType:M,hoverDelay:v,enterDelay:I,leaveDelay:A});l(this,"_MenuType",D);l(this,"_MenuItemType",z);l(this,"_MenuToggleType",q);l(this,"_currentChild",-1);l(this,"_selectors",{menuItems:"",menuLinks:"",submenuItems:"",submenuToggles:"",submenus:"",submenuSubtoggles:""});l(this,"_optionalSupport",!1);this._optionalSupport=$,this._selectors.menuItems=s,this._selectors.submenuItems=o,this._selectors.submenuToggles=r,this._selectors.submenus=h,this._selectors.submenuSubtoggles=c,this._selectors.menuLinks=[...new Set([n,r])].join(","),O&&this.initialize()}initialize(){try{super.initialize(),this._handleFocus(),this._handleClick(),this._handleHover(),this._handleKeydown(),this._handleKeyup()}catch(t){console.error(t)}}get optionalKeySupport(){return this.isTopLevel?this._optionalSupport:this.elements.rootMenu.optionalKeySupport}set optionalKeySupport(t){f("boolean",{optionalKeySupport:t}),this._optionalSupport=t}_createChildElements(){this.dom.menuItems.forEach(t=>{let s,n;const o=t.querySelector(this.selectors.menuLinks);if(this.dom.submenuItems.includes(t)){const r=t.querySelector(this.selectors.submenuToggles),h=t.querySelector(this.selectors.submenus),c=new this._MenuType({menuElement:h,menuItemSelector:this.selectors.menuItems,menuLinkSelector:this.selectors.menuLinks,submenuItemSelector:this.selectors.submenuItems,submenuToggleSelector:this.selectors.submenuSubtoggles,submenuSelector:this.selectors.submenus,submenuSubtoggleSelector:this.selectors.submenuSubtoggles,openClass:this.openClass,closeClass:this.closeClass,isTopLevel:!1,parentMenu:this,hoverType:this.hoverType,hoverDelay:this.hoverDelay}),u=new this._MenuToggleType({menuToggleElement:r,parentElement:t,controlledMenu:c,parentMenu:this});this._elements.submenuToggles.push(u),r!==o?(n=new this._MenuItemType({menuItemElement:t,menuLinkElement:r,parentMenu:this,isSubmenuItem:!0,childMenu:c,toggle:u}),s=new this._MenuItemType({menuItemElement:t,menuLinkElement:o,parentMenu:this,submenuSibling:n})):s=new this._MenuItemType({menuItemElement:t,menuLinkElement:o,parentMenu:this,isSubmenuItem:!0,childMenu:c,toggle:u})}else s=new this._MenuItemType({menuItemElement:t,menuLinkElement:o,parentMenu:this});this._elements.menuItems.push(s),typeof n<"u"&&this._elements.menuItems.push(n)})}_validate(){let t=super._validate();const s=w({submenuSubtoggleSelector:this._selectors.submenuSubtoggles});s.status||(this._errors.push(s.error.message),t=!1);const n=f("boolean",{optionalKeySupport:this._optionalSupport});return n.status||(this._errors.push(n.error.message),t=!1),t}_handleClick(){super._handleClick(),document.addEventListener("pointerup",t=>{this.focusState!=="none"&&(this.currentEvent="mouse",!this.dom.menu.contains(t.target)&&!this.dom.menu!==t.target&&(this.closeChildren(),this.blur(),this.elements.controller&&this.elements.controller.close()))})}_handleHover(){this.elements.menuItems.forEach((t,s)=>{t.dom.link.addEventListener("pointerenter",n=>{if(!(n.pointerType==="pen"||n.pointerType==="touch")){if(this.hoverType==="on"){this.currentEvent="mouse",this.currentChild=s;let o=t.isSubmenuItem?t.elements.toggle:null;if(t.elements.sibling!==null&&(o=t.elements.sibling.elements.toggle),o===null)return;this.enterDelay>0?(clearTimeout(this._hoverTimeout),this._hoverTimeout=setTimeout(()=>{o.preview()},this.enterDelay)):o.preview()}else if(this.hoverType==="dynamic"){const o=this.elements.submenuToggles.some(r=>r.isOpen);if(this.currentChild=s,(!this.isTopLevel||this.focusState!=="none")&&(this.currentEvent="mouse",this.focusCurrentChild()),!this.isTopLevel||o){this.currentEvent="mouse";let r=t.isSubmenuItem?t.elements.toggle:null;if(t.elements.sibling!==null&&(r=t.elements.sibling.elements.toggle),r===null)return;this.enterDelay>0?(clearTimeout(this._hoverTimeout),this._hoverTimeout=setTimeout(()=>{r.preview()},this.enterDelay)):r.preview()}}}}),t.isSubmenuItem&&t.dom.item.addEventListener("pointerleave",n=>{n.pointerType==="pen"||n.pointerType==="touch"||(this.hoverType==="on"?this.leaveDelay>0?(clearTimeout(this._hoverTimeout),setTimeout(()=>{this.currentEvent="mouse",t.elements.toggle.close()},this.leaveDelay)):(this.currentEvent="mouse",t.elements.toggle.close()):this.hoverType==="dynamic"&&(this.isTopLevel||(this.leaveDelay>0?(clearTimeout(this._hoverTimeout),setTimeout(()=>{this.currentEvent="mouse",t.elements.toggle.close(),this.focusCurrentChild()},this.leaveDelay)):(this.currentEvent="mouse",t.elements.toggle.close(),this.focusCurrentChild()))))})})}_handleKeydown(){super._handleKeydown(),this.dom.menu.addEventListener("keydown",t=>{this.currentEvent="keyboard";const s=S(t);if(this.focusState==="self"){const n=["Space","Enter"],o=["Escape"],r=["Escape"];this.optionalKeySupport?["ArrowUp","ArrowRight","ArrowDown","ArrowLeft","Home","End"].includes(s)&&d(t):(this.currentMenuItem.isSubmenuItem&&n.includes(s)||this.elements.controller&&o.includes(s)||this.elements.parentMenu&&r.includes(s))&&d(t)}})}_handleKeyup(){super._handleKeyup(),this.dom.menu.addEventListener("keyup",t=>{this.currentEvent="keyboard";const s=S(t);this.focusState==="self"&&(s==="Space"||s==="Enter"?this.currentMenuItem.isSubmenuItem?(d(t),this.currentMenuItem.elements.toggle.isOpen?this.currentMenuItem.elements.toggle.close():this.currentMenuItem.elements.toggle.preview()):this.currentMenuItem.dom.link.click():s==="Escape"?this.elements.submenuToggles.some(o=>o.isOpen)?(d(t),this.closeChildren()):this.elements.parentMenu?(d(t),this.elements.parentMenu.currentEvent=this.currentEvent,this.elements.parentMenu.closeChildren(),this.elements.parentMenu.focusCurrentChild()):this.isTopLevel&&this.elements.controller&&this.elements.controller.isOpen&&(this.elements.controller.close(),this.focusController()):this.optionalKeySupport&&(s==="ArrowDown"||s==="ArrowRight"?(d(t),this.currentMenuItem.isSubmenuItem&&this.currentMenuItem.elements.toggle.isOpen?(this.currentMenuItem.elements.childMenu.currentEvent="keyboard",this.currentMenuItem.elements.childMenu.focusFirstChild()):this.focusNextChild()):s==="ArrowUp"||s==="ArrowLeft"?(d(t),this.focusPreviousChild()):s==="Home"?(d(t),this.focusFirstChild()):s==="End"&&(d(t),this.focusLastChild())))})}}class R extends z{constructor({menuItemElement:e,menuLinkElement:t,parentMenu:s,isSubmenuItem:n=!1,childMenu:o=null,toggle:r=null,initialize:h=!0,submenuSibling:c=null}){super({menuItemElement:e,menuLinkElement:t,parentMenu:s,isSubmenuItem:n,childMenu:o,toggle:r,initialize:!1,submenuSibling:c}),h&&this.initialize()}}class P extends q{constructor({menuToggleElement:t,parentElement:s,controlledMenu:n,parentMenu:o=null,initialize:r=!0}){super({menuToggleElement:t,parentElement:s,controlledMenu:n,parentMenu:o,initialize:!1});l(this,"_dom",{toggle:null,parent:null,container:null});this._dom.toggle=t,this._dom.parent=s,this._dom.container=n.isTopLevel?n.dom.container:n.dom.menu,r&&this.initialize()}initialize(){super.initialize(),this.dom.toggle.hasAttribute("data-bs-toggle")&&this.dom.toggle.removeAttribute("data-bs-toggle"),this.dom.toggle.hasAttribute("data-bs-target")&&this.dom.toggle.removeAttribute("data-bs-target")}_expand(t=!0){const{openClass:s,transitionClass:n}=this.elements.controlledMenu;this.dom.toggle.setAttribute("aria-expanded","true"),n!==""?(m(n,this.dom.container),requestAnimationFrame(()=>{m(s,this.dom.container),requestAnimationFrame(()=>{a(n,this.dom.container)})})):s!==""&&m(s,this.dom.container),t&&this.dom.toggle.dispatchEvent(this._expandEvent)}_collapse(t=!0){const{closeClass:s,openClass:n,transitionClass:o}=this.elements.controlledMenu;this.dom.toggle.setAttribute("aria-expanded","false"),o!==""?(m(o,this.dom.container),requestAnimationFrame(()=>{n!==""&&a(n,this.dom.container),requestAnimationFrame(()=>{s!==""&&m(s,this.dom.container),requestAnimationFrame(()=>{a(o,this.dom.container)})})})):(s!==""&&m(s,this.dom.container),n!==""&&a(n,this.dom.container)),t&&this.dom.toggle.dispatchEvent(this._collapseEvent)}}class L extends D{constructor({menuElement:t,menuItemSelector:s=".nav-item,li",menuLinkSelector:n=".nav-link,.dropdown-item",submenuItemSelector:o=".dropdown",submenuToggleSelector:r=".dropdown-toggle",submenuSelector:h=".dropdown-menu",submenuSubtoggleSelector:c=".dropdown-toggle",controllerElement:u=null,containerElement:y=null,openClass:b="show",closeClass:_="collapse",transitionClass:C="transitioning",isTopLevel:T=!0,parentMenu:E=null,hoverType:M="off",hoverDelay:v=250,enterDelay:I=-1,leaveDelay:A=-1,optionalKeySupport:$=!1,initialize:O=!0}){super({menuElement:t,menuItemSelector:s,menuLinkSelector:n,submenuItemSelector:o,submenuToggleSelector:r,submenuSelector:h,submenuSubtoggleSelector:c,controllerElement:u,containerElement:y,openClass:b,closeClass:_,transitionClass:C,isTopLevel:T,parentMenu:E,hoverType:M,hoverDelay:v,enterDelay:I,leaveDelay:A,optionalKeySupport:$,initialize:!1});l(this,"_MenuType",L);l(this,"_MenuItemType",R);l(this,"_MenuToggleType",P);O&&this.initialize()}}return L}(); | ||
- `)}`);if(this.elements.rootMenu===null&&this._findRootMenu(this),this._setDOMElements(),this.isTopLevel&&this.dom.controller&&this.dom.container){const e=new this._MenuToggleType({menuToggleElement:this.dom.controller,parentElement:this.dom.container,controlledMenu:this});this._elements.controller=e}this._createChildElements()}get dom(){return this._dom}get selectors(){return this._selectors}get elements(){return this._elements}get isTopLevel(){return this._root}get openClass(){return this.isTopLevel?this._openClass:this.elements.rootMenu.openClass}get closeClass(){return this.isTopLevel?this._closeClass:this.elements.rootMenu.closeClass}get transitionClass(){return this.isTopLevel?this._transitionClass:this.elements.rootMenu.transitionClass}get currentChild(){return this._currentChild}get focusState(){return this._focusState}get currentEvent(){return this._currentEvent}get currentMenuItem(){return this.elements.menuItems[this.currentChild]}get hoverType(){return this._root?this._hoverType:this.elements.rootMenu.hoverType}get hoverDelay(){return this._root?this._hoverDelay:this.elements.rootMenu.hoverDelay}get enterDelay(){return this._enterDelay===-1?this.hoverDelay:this._root?this._enterDelay:this.elements.rootMenu.enterDelay}get leaveDelay(){return this._leaveDelay===-1?this.hoverDelay:this._root?this._leaveDelay:this.elements.rootMenu.leaveDelay}get shouldFocus(){let e=!1;return(this.currentEvent==="keyboard"||this.currentEvent==="character")&&(e=!0),this.currentEvent==="mouse"&&this.hoverType==="dynamic"&&(e=!0),e}get errors(){return this._errors}set openClass(e){g({openClass:e}),this._openClass!==e&&(this._openClass=e)}set closeClass(e){g({closeClass:e}),this._closeClass!==e&&(this._closeClass=e)}set transitionClass(e){g({transitionClass:e}),this._transitionClass!==e&&(this._transitionClass=e)}set currentChild(e){f("number",{value:e});function t(s){if(["mouse","character"].includes(s.currentEvent)&&s.elements.parentMenu){let o=0,r=!1;for(;!r&&o<s.elements.parentMenu.elements.menuItems.length;){const h=s.elements.parentMenu.elements.menuItems[o];h.isSubmenuItem&&h.elements.toggle.elements.controlledMenu===s&&(r=!0,s.elements.parentMenu.currentEvent=s.currentEvent,s.elements.parentMenu.currentChild=o),o++}}}e<-1?(this._currentChild=-1,t(this)):e>=this.elements.menuItems.length?(this._currentChild=this.elements.menuItems.length-1,t(this)):this.focusChild!==e&&(this._currentChild=e,t(this))}set focusState(e){K({value:e}),this._focusState!==e&&(this._focusState=e),this.elements.submenuToggles.length>0&&(e==="self"||e==="none")&&this.elements.submenuToggles.forEach(t=>{t.elements.controlledMenu.focusState="none"}),this.elements.parentMenu&&(e==="self"||e==="child")&&(this.elements.parentMenu.focusState="child")}set currentEvent(e){V({value:e}),this._currentEvent!==e&&(this._currentEvent=e,this.elements.submenuToggles.length>0&&this.elements.submenuToggles.forEach(t=>{t.elements.controlledMenu.currentEvent=e}))}set hoverType(e){F({value:e}),this._hoverType!==e&&(this._hoverType=e)}set hoverDelay(e){f("number",{value:e}),this._hoverDelay!==e&&(this._hoverDelay=e)}set enterDelay(e){f("number",{value:e}),this._enterDelay!==e&&(this._enterDelay=e)}set leaveDelay(e){f("number",{value:e}),this._leaveDelay!==e&&(this._leaveDelay=e)}_validate(){let e=!0,t;this._dom.container!==null||this._dom.controller!==null?t=p(HTMLElement,{menuElement:this._dom.menu,controllerElement:this._dom.controller,containerElement:this._dom.container}):t=p(HTMLElement,{menuElement:this._dom.menu}),t.status||(this._errors.push(t.error.message),e=!1);let s;if(this._selectors.submenuItems!==""?s=w({menuItemSelector:this._selectors.menuItems,menuLinkSelector:this._selectors.menuLinks,submenuItemSelector:this._selectors.submenuItems,submenuToggleSelector:this._selectors.submenuToggles,submenuSelector:this._selectors.submenus}):s=w({menuItemSelector:this._selectors.menuItems,menuLinkSelector:this._selectors.menuLinks}),s.status||(this._errors.push(s.error.message),e=!1),this._openClass!==""){const u=g({openClass:this._openClass});u.status||(this._errors.push(u.error.message),e=!1)}if(this._closeClass!==""){const u=g({closeClass:this._closeClass});u.status||(this._errors.push(u.error.message),e=!1)}if(this._transitionClass!==""){const u=g({transitionClass:this._transitionClass});u.status||(this._errors.push(u.error.message),e=!1)}const n=f("boolean",{isTopLevel:this._root});if(n.status||(this._errors.push(n.error.message),e=!1),this._elements.parentMenu!==null){const u=p(k,{parentMenu:this._elements.parentMenu});u.status||(this._errors.push(u.error.message),e=!1)}const o=F({hoverType:this._hoverType});o.status||(this._errors.push(o.error.message),e=!1);const r=f("number",{hoverDelay:this._hoverDelay});r.status||(this._errors.push(r.error.message),e=!1);const h=f("number",{enterDelay:this._enterDelay});h.status||(this._errors.push(h.error.message),e=!1);const c=f("number",{leaveDelay:this._leaveDelay});return c.status||(this._errors.push(c.error.message),e=!1),e}_setDOMElementType(e,t=this.dom.menu,s=!0){if(typeof this.selectors[e]=="string"){if(!Array.isArray(this.dom[e]))throw new Error(`AccessibleMenu: The "${e}" element cannot be set through _setDOMElementType.`);t!==this.dom.menu&&p(HTMLElement,{base:t});const o=Array.from(t.querySelectorAll(this.selectors[e])).filter(r=>r.parentElement===t);s?this._dom[e]=o:this._dom[e]=[...this._dom[e],...o]}else throw new Error(`AccessibleMenu: "${e}" is not a valid element type within the menu.`)}_resetDOMElementType(e){if(typeof this.dom[e]<"u"){if(!Array.isArray(this.dom[e]))throw new Error(`AccessibleMenu: The "${e}" element cannot be reset through _resetDOMElementType.`);this._dom[e]=[]}else throw new Error(`AccessibleMenu: "${e}" is not a valid element type within the menu.`)}_setDOMElements(){this._setDOMElementType("menuItems"),this.selectors.submenuItems!==""&&(this._setDOMElementType("submenuItems"),this._resetDOMElementType("submenuToggles"),this._resetDOMElementType("submenus"),this.dom.submenuItems.forEach(e=>{this._setDOMElementType("submenuToggles",e,!1),this._setDOMElementType("submenus",e,!1)}))}_findRootMenu(e){if(e.isTopLevel)this._elements.rootMenu=e;else if(e.elements.parentMenu!==null)this._findRootMenu(e.elements.parentMenu);else throw new Error("Cannot find root menu.")}_createChildElements(){this.dom.menuItems.forEach(e=>{let t;if(this.dom.submenuItems.includes(e)){const s=e.querySelector(this.selectors.submenuToggles),n=e.querySelector(this.selectors.submenus),o=new this._MenuType({menuElement:n,menuItemSelector:this.selectors.menuItems,menuLinkSelector:this.selectors.menuLinks,submenuItemSelector:this.selectors.submenuItems,submenuToggleSelector:this.selectors.submenuToggles,submenuSelector:this.selectors.submenus,openClass:this.openClass,closeClass:this.closeClass,transitionClass:this.transitionClass,isTopLevel:!1,parentMenu:this,hoverType:this.hoverType,hoverDelay:this.hoverDelay,enterDelay:this.enterDelay,leaveDelay:this.leaveDelay}),r=new this._MenuToggleType({menuToggleElement:s,parentElement:e,controlledMenu:o,parentMenu:this});this._elements.submenuToggles.push(r),t=new this._MenuItemType({menuItemElement:e,menuLinkElement:s,parentMenu:this,isSubmenuItem:!0,childMenu:o,toggle:r})}else{const s=e.querySelector(this.selectors.menuLinks);t=new this._MenuItemType({menuItemElement:e,menuLinkElement:s,parentMenu:this})}this._elements.menuItems.push(t)})}_handleFocus(){this.elements.menuItems.forEach((e,t)=>{e.dom.link.addEventListener("focus",()=>{this.focusState="self",this.currentChild=t})})}_handleClick(){function e(t,s,n){d(n),s.toggle(),s.isOpen&&(t.focusState="self",s.elements.controlledMenu.focusState="none")}this.elements.menuItems.forEach((t,s)=>{t.dom.link.addEventListener("pointerdown",()=>{this.currentEvent="mouse",this.elements.rootMenu.blurChildren(),this.focusChild(s)},{passive:!0}),t.isSubmenuItem&&t.elements.toggle.dom.toggle.addEventListener("pointerup",n=>{this.currentEvent="mouse",e(this,t.elements.toggle,n)})}),this.isTopLevel&&this.elements.controller&&this.elements.controller.dom.toggle.addEventListener("pointerup",t=>{this.currentEvent="mouse",e(this,this.elements.controller,t)})}_handleHover(){this.elements.menuItems.forEach((e,t)=>{e.dom.link.addEventListener("pointerenter",s=>{if(!(s.pointerType==="pen"||s.pointerType==="touch")){if(this.hoverType==="on")this.currentEvent="mouse",this.elements.rootMenu.blurChildren(),this.focusChild(t),e.isSubmenuItem&&(this.enterDelay>0?this._hoverTimeout=setTimeout(()=>{e.elements.toggle.preview()},this.enterDelay):e.elements.toggle.preview());else if(this.hoverType==="dynamic"){const n=this.elements.submenuToggles.some(o=>o.isOpen);this.currentChild=t,(!this.isTopLevel||this.focusState!=="none")&&(this.currentEvent="mouse",this.elements.rootMenu.blurChildren(),this.focusCurrentChild()),e.isSubmenuItem&&(!this.isTopLevel||n)&&(this.currentEvent="mouse",this.elements.rootMenu.blurChildren(),this.focusCurrentChild(),this.enterDelay>0?this._hoverTimeout=setTimeout(()=>{e.elements.toggle.preview()},this.enterDelay):e.elements.toggle.preview())}}}),e.isSubmenuItem&&e.dom.item.addEventListener("pointerleave",s=>{s.pointerType==="pen"||s.pointerType==="touch"||(this.hoverType==="on"?this.leaveDelay>0?(clearTimeout(this._hoverTimeout),setTimeout(()=>{this.currentEvent="mouse",e.elements.toggle.close()},this.leaveDelay)):(this.currentEvent="mouse",e.elements.toggle.close()):this.hoverType==="dynamic"&&(this.isTopLevel||(this.leaveDelay>0?(clearTimeout(this._hoverTimeout),setTimeout(()=>{this.currentEvent="mouse",e.elements.toggle.close(),this.focusCurrentChild()},this.leaveDelay)):(this.currentEvent="mouse",e.elements.toggle.close(),this.focusCurrentChild()))))})})}_handleKeydown(){this.isTopLevel&&this.elements.controller&&this.elements.controller.dom.toggle.addEventListener("keydown",e=>{this.currentEvent="keyboard";const t=S(e);(t==="Space"||t==="Enter")&&d(e)})}_handleKeyup(){this.isTopLevel&&this.elements.controller&&this.elements.controller.dom.toggle.addEventListener("keyup",e=>{this.currentEvent="keyboard";const t=S(e);(t==="Space"||t==="Enter")&&(d(e),this.elements.controller.toggle(),this.elements.controller.isOpen&&this.focusFirstChild())})}focus(){this.focusState="self",this.shouldFocus&&this.dom.menu.focus()}blur(){this.focusState="none",this.shouldFocus&&this.dom.menu.blur()}focusCurrentChild(){this.focusState="self",this.currentChild!==-1&&this.currentMenuItem.focus()}focusChild(e){this.blurCurrentChild(),this.currentChild=e,this.focusCurrentChild()}focusFirstChild(){this.focusChild(0)}focusLastChild(){this.focusChild(this.elements.menuItems.length-1)}focusNextChild(){this.currentChild<this.elements.menuItems.length-1?this.focusChild(this.currentChild+1):this.focusCurrentChild()}focusPreviousChild(){this.currentChild>0?this.focusChild(this.currentChild-1):this.focusCurrentChild()}blurCurrentChild(){this.focusState="none",this.currentChild!==-1&&this.currentMenuItem.blur()}focusController(){this.dom.controller&&(this.shouldFocus&&this.dom.controller.focus(),this.focusState="none")}focusContainer(){this.dom.container&&(this.shouldFocus&&this.dom.container.focus(),this.focusState="none")}closeChildren(){this.elements.submenuToggles.forEach(e=>e.close())}blurChildren(){this.elements.menuItems.forEach(e=>{e.blur(),e.isSubmenuItem&&e.elements.childMenu.blurChildren()})}}class z extends x{constructor({menuItemElement:t,menuLinkElement:s,parentMenu:n,isSubmenuItem:o=!1,childMenu:r=null,toggle:h=null,initialize:c=!0,submenuSibling:u=null}){super({menuItemElement:t,menuLinkElement:s,parentMenu:n,isSubmenuItem:o,childMenu:r,toggle:h});l(this,"_elements",{parentMenu:null,childMenu:null,toggle:null,sibling:null});this._elements.parentMenu=n,this._elements.childMenu=r,this._elements.toggle=h,this._elements.sibling=u,c&&this.initialize()}}class q extends j{constructor({menuToggleElement:e,parentElement:t,controlledMenu:s,parentMenu:n=null,initialize:o=!0}){super({menuToggleElement:e,parentElement:t,controlledMenu:s,parentMenu:n}),o&&this.initialize()}open(){this.closeSiblings(),super.open()}preview(){this.closeSiblings(),super.preview()}close(){this.isOpen&&this.closeChildren(),super.close()}}class D extends k{constructor({menuElement:t,menuItemSelector:s="li",menuLinkSelector:n="a",submenuItemSelector:o="",submenuToggleSelector:r="button",submenuSelector:h="ul",submenuSubtoggleSelector:c="a",controllerElement:u=null,containerElement:_=null,openClass:b="show",closeClass:y="hide",transitionClass:C="transitioning",isTopLevel:T=!0,parentMenu:E=null,hoverType:M="off",hoverDelay:v=250,enterDelay:I=-1,leaveDelay:A=-1,optionalKeySupport:$=!1,initialize:O=!0}){super({menuElement:t,menuItemSelector:s,menuLinkSelector:n,submenuItemSelector:o,submenuSelector:h,submenuToggleSelector:r,controllerElement:u,containerElement:_,openClass:b,closeClass:y,transitionClass:C,isTopLevel:T,parentMenu:E,hoverType:M,hoverDelay:v,enterDelay:I,leaveDelay:A});l(this,"_MenuType",D);l(this,"_MenuItemType",z);l(this,"_MenuToggleType",q);l(this,"_currentChild",-1);l(this,"_selectors",{menuItems:"",menuLinks:"",submenuItems:"",submenuToggles:"",submenus:"",submenuSubtoggles:""});l(this,"_optionalSupport",!1);this._optionalSupport=$,this._selectors.menuItems=s,this._selectors.submenuItems=o,this._selectors.submenuToggles=r,this._selectors.submenus=h,this._selectors.submenuSubtoggles=c,this._selectors.menuLinks=[...new Set([n,r])].join(","),O&&this.initialize()}initialize(){try{super.initialize(),this._handleFocus(),this._handleClick(),this._handleHover(),this._handleKeydown(),this._handleKeyup()}catch(t){console.error(t)}}get optionalKeySupport(){return this.isTopLevel?this._optionalSupport:this.elements.rootMenu.optionalKeySupport}set optionalKeySupport(t){f("boolean",{optionalKeySupport:t}),this._optionalSupport=t}_createChildElements(){this.dom.menuItems.forEach(t=>{let s,n;const o=t.querySelector(this.selectors.menuLinks);if(this.dom.submenuItems.includes(t)){const r=t.querySelector(this.selectors.submenuToggles),h=t.querySelector(this.selectors.submenus),c=new this._MenuType({menuElement:h,menuItemSelector:this.selectors.menuItems,menuLinkSelector:this.selectors.menuLinks,submenuItemSelector:this.selectors.submenuItems,submenuToggleSelector:this.selectors.submenuSubtoggles,submenuSelector:this.selectors.submenus,submenuSubtoggleSelector:this.selectors.submenuSubtoggles,openClass:this.openClass,closeClass:this.closeClass,transitionClass:this.transitionClass,isTopLevel:!1,parentMenu:this,hoverType:this.hoverType,hoverDelay:this.hoverDelay,enterDelay:this.enterDelay,leaveDelay:this.leaveDelay}),u=new this._MenuToggleType({menuToggleElement:r,parentElement:t,controlledMenu:c,parentMenu:this});this._elements.submenuToggles.push(u),r!==o?(n=new this._MenuItemType({menuItemElement:t,menuLinkElement:r,parentMenu:this,isSubmenuItem:!0,childMenu:c,toggle:u}),s=new this._MenuItemType({menuItemElement:t,menuLinkElement:o,parentMenu:this,submenuSibling:n})):s=new this._MenuItemType({menuItemElement:t,menuLinkElement:o,parentMenu:this,isSubmenuItem:!0,childMenu:c,toggle:u})}else s=new this._MenuItemType({menuItemElement:t,menuLinkElement:o,parentMenu:this});this._elements.menuItems.push(s),typeof n<"u"&&this._elements.menuItems.push(n)})}_validate(){let t=super._validate();const s=w({submenuSubtoggleSelector:this._selectors.submenuSubtoggles});s.status||(this._errors.push(s.error.message),t=!1);const n=f("boolean",{optionalKeySupport:this._optionalSupport});return n.status||(this._errors.push(n.error.message),t=!1),t}_handleClick(){super._handleClick(),document.addEventListener("pointerup",t=>{this.focusState!=="none"&&(this.currentEvent="mouse",!this.dom.menu.contains(t.target)&&!this.dom.menu!==t.target&&(this.closeChildren(),this.blur(),this.elements.controller&&this.elements.controller.close()))})}_handleHover(){this.elements.menuItems.forEach((t,s)=>{t.dom.link.addEventListener("pointerenter",n=>{if(!(n.pointerType==="pen"||n.pointerType==="touch")){if(this.hoverType==="on"){this.currentEvent="mouse",this.elements.rootMenu.blurChildren(),this.focusChild(s);let o=t.isSubmenuItem?t.elements.toggle:null;if(t.elements.sibling!==null&&(o=t.elements.sibling.elements.toggle),o===null)return;this.enterDelay>0?(clearTimeout(this._hoverTimeout),this._hoverTimeout=setTimeout(()=>{o.preview()},this.enterDelay)):o.preview()}else if(this.hoverType==="dynamic"){const o=this.elements.submenuToggles.some(r=>r.isOpen);if(this.currentChild=s,(!this.isTopLevel||this.focusState!=="none")&&(this.currentEvent="mouse",this.elements.rootMenu.blurChildren(),this.focusCurrentChild()),!this.isTopLevel||o){this.currentEvent="mouse",this.elements.rootMenu.blurChildren(),this.focusCurrentChild();let r=t.isSubmenuItem?t.elements.toggle:null;if(t.elements.sibling!==null&&(r=t.elements.sibling.elements.toggle),r===null)return;this.enterDelay>0?(clearTimeout(this._hoverTimeout),this._hoverTimeout=setTimeout(()=>{r.preview()},this.enterDelay)):r.preview()}}}}),t.isSubmenuItem&&t.dom.item.addEventListener("pointerleave",n=>{n.pointerType==="pen"||n.pointerType==="touch"||(this.hoverType==="on"?this.leaveDelay>0?(clearTimeout(this._hoverTimeout),setTimeout(()=>{this.currentEvent="mouse",t.elements.toggle.close()},this.leaveDelay)):(this.currentEvent="mouse",t.elements.toggle.close()):this.hoverType==="dynamic"&&(this.isTopLevel||(this.leaveDelay>0?(clearTimeout(this._hoverTimeout),setTimeout(()=>{this.currentEvent="mouse",t.elements.toggle.close(),this.focusCurrentChild()},this.leaveDelay)):(this.currentEvent="mouse",t.elements.toggle.close(),this.focusCurrentChild()))))})})}_handleKeydown(){super._handleKeydown(),this.dom.menu.addEventListener("keydown",t=>{this.currentEvent="keyboard";const s=S(t);if(this.focusState==="self"){const n=["Space","Enter"],o=["Escape"],r=["Escape"];this.optionalKeySupport?["ArrowUp","ArrowRight","ArrowDown","ArrowLeft","Home","End"].includes(s)&&d(t):(this.currentMenuItem.isSubmenuItem&&n.includes(s)||this.elements.controller&&o.includes(s)||this.elements.parentMenu&&r.includes(s))&&d(t)}})}_handleKeyup(){super._handleKeyup(),this.dom.menu.addEventListener("keyup",t=>{this.currentEvent="keyboard";const s=S(t);this.focusState==="self"&&(s==="Space"||s==="Enter"?this.currentMenuItem.isSubmenuItem?(d(t),this.currentMenuItem.elements.toggle.isOpen?this.currentMenuItem.elements.toggle.close():this.currentMenuItem.elements.toggle.preview()):this.currentMenuItem.dom.link.click():s==="Escape"?this.elements.submenuToggles.some(o=>o.isOpen)?(d(t),this.closeChildren()):this.elements.parentMenu?(d(t),this.elements.parentMenu.currentEvent=this.currentEvent,this.elements.parentMenu.closeChildren(),this.elements.parentMenu.focusCurrentChild()):this.isTopLevel&&this.elements.controller&&this.elements.controller.isOpen&&(this.elements.controller.close(),this.focusController()):this.optionalKeySupport&&(s==="ArrowDown"||s==="ArrowRight"?(d(t),this.currentMenuItem.isSubmenuItem&&this.currentMenuItem.elements.toggle.isOpen?(this.currentMenuItem.elements.childMenu.currentEvent="keyboard",this.currentMenuItem.elements.childMenu.focusFirstChild()):this.focusNextChild()):s==="ArrowUp"||s==="ArrowLeft"?(d(t),this.focusPreviousChild()):s==="Home"?(d(t),this.focusFirstChild()):s==="End"&&(d(t),this.focusLastChild())))})}}class R extends z{constructor({menuItemElement:e,menuLinkElement:t,parentMenu:s,isSubmenuItem:n=!1,childMenu:o=null,toggle:r=null,initialize:h=!0,submenuSibling:c=null}){super({menuItemElement:e,menuLinkElement:t,parentMenu:s,isSubmenuItem:n,childMenu:o,toggle:r,initialize:!1,submenuSibling:c}),h&&this.initialize()}}class P extends q{constructor({menuToggleElement:t,parentElement:s,controlledMenu:n,parentMenu:o=null,initialize:r=!0}){super({menuToggleElement:t,parentElement:s,controlledMenu:n,parentMenu:o,initialize:!1});l(this,"_dom",{toggle:null,parent:null,container:null});this._dom.toggle=t,this._dom.parent=s,this._dom.container=n.isTopLevel?n.dom.container:n.dom.menu,r&&this.initialize()}initialize(){super.initialize(),this.dom.toggle.hasAttribute("data-bs-toggle")&&this.dom.toggle.removeAttribute("data-bs-toggle"),this.dom.toggle.hasAttribute("data-bs-target")&&this.dom.toggle.removeAttribute("data-bs-target")}_expand(t=!0){const{openClass:s,transitionClass:n}=this.elements.controlledMenu;this.dom.toggle.setAttribute("aria-expanded","true"),n!==""?(a(n,this.dom.container),requestAnimationFrame(()=>{a(s,this.dom.container),requestAnimationFrame(()=>{m(n,this.dom.container)})})):s!==""&&a(s,this.dom.container),t&&this.dom.toggle.dispatchEvent(this._expandEvent)}_collapse(t=!0){const{closeClass:s,openClass:n,transitionClass:o}=this.elements.controlledMenu;this.dom.toggle.setAttribute("aria-expanded","false"),o!==""?(a(o,this.dom.container),requestAnimationFrame(()=>{n!==""&&m(n,this.dom.container),requestAnimationFrame(()=>{s!==""&&a(s,this.dom.container),requestAnimationFrame(()=>{m(o,this.dom.container)})})})):(s!==""&&a(s,this.dom.container),n!==""&&m(n,this.dom.container)),t&&this.dom.toggle.dispatchEvent(this._collapseEvent)}}class L extends D{constructor({menuElement:t,menuItemSelector:s=".nav-item,li",menuLinkSelector:n=".nav-link,.dropdown-item",submenuItemSelector:o=".dropdown",submenuToggleSelector:r=".dropdown-toggle",submenuSelector:h=".dropdown-menu",submenuSubtoggleSelector:c=".dropdown-toggle",controllerElement:u=null,containerElement:_=null,openClass:b="show",closeClass:y="collapse",transitionClass:C="transitioning",isTopLevel:T=!0,parentMenu:E=null,hoverType:M="off",hoverDelay:v=250,enterDelay:I=-1,leaveDelay:A=-1,optionalKeySupport:$=!1,initialize:O=!0}){super({menuElement:t,menuItemSelector:s,menuLinkSelector:n,submenuItemSelector:o,submenuToggleSelector:r,submenuSelector:h,submenuSubtoggleSelector:c,controllerElement:u,containerElement:_,openClass:b,closeClass:y,transitionClass:C,isTopLevel:T,parentMenu:E,hoverType:M,hoverDelay:v,enterDelay:I,leaveDelay:A,optionalKeySupport:$,initialize:!1});l(this,"_MenuType",L);l(this,"_MenuItemType",R);l(this,"_MenuToggleType",P);O&&this.initialize()}}return L}(); |
@@ -1,3 +0,3 @@ | ||
var Bootstrap5Treeview=function(){"use strict";var H=Object.defineProperty;var P=(c,a,_)=>a in c?H(c,a,{enumerable:!0,configurable:!0,writable:!0,value:_}):c[a]=_;var o=(c,a,_)=>(P(c,typeof a!="symbol"?a+"":a,_),_);function c(i,e){typeof i=="string"?e.classList.add(i):e.classList.add(...i)}function a(i,e){typeof i=="string"?e.classList.remove(i):e.classList.remove(...i)}function _(i,e){try{if(typeof e!="object"){const t=typeof e;throw new TypeError(`Elements given to isValidInstance() must be inside of an object. "${t}" given.`)}for(const t in e)if(!(e[t]instanceof i)){const s=typeof e[t];throw new TypeError(`${t} must be an instance of ${i.name}. "${s}" given.`)}return{status:!0,error:null}}catch(t){return{status:!1,error:t}}}function y(i,e){try{if(typeof e!="object"){const t=typeof e;throw new TypeError(`Values given to isValidType() must be inside of an object. "${t}" given.`)}for(const t in e){const s=typeof e[t];if(s!==i)throw new TypeError(`${t} must be a ${i}. "${s}" given.`)}return{status:!0,error:null}}catch(t){return{status:!1,error:t}}}function S(i){try{if(typeof i!="object"){const e=typeof i;throw new TypeError(`Values given to isCSSSelector() must be inside of an object. "${e}" given.`)}for(const e in i)try{if(i[e]===null)throw new Error;document.querySelector(i[e])}catch{throw new TypeError(`${e} must be a valid CSS selector. "${i[e]}" given.`)}return{status:!0,error:null}}catch(e){return{status:!1,error:e}}}function C(i){try{if(typeof i!="object"||Array.isArray(i)){const e=typeof i;throw new TypeError(`Values given to isValidClassList() must be inside of an object. "${e}" given.`)}for(const e in i){const t=typeof i[e];if(t!=="string")if(Array.isArray(i[e]))i[e].forEach(s=>{if(typeof s!="string")throw new TypeError(`${e} must be a string or an array of strings. An array containing non-strings given.`)});else throw new TypeError(`${e} must be a string or an array of strings. "${t}" given.`);else{const s={};s[e]=i[e],S(s)}}return{status:!0,error:null}}catch(e){return{status:!1,error:e}}}function j(i){try{if(typeof i!="object"){const t=typeof i;throw new TypeError(`Values given to isValidState() must be inside of an object. "${t}" given.`)}const e=["none","self","child"];for(const t in i)if(!e.includes(i[t]))throw new TypeError(`${t} must be one of the following values: ${e.join(", ")}. "${i[t]}" given.`);return{status:!0,error:null}}catch(e){return{status:!1,error:e}}}function V(i){try{if(typeof i!="object"){const t=typeof i;throw new TypeError(`Values given to isValidEvent() must be inside of an object. "${t}" given.`)}const e=["none","mouse","keyboard","character"];for(const t in i)if(!e.includes(i[t]))throw new TypeError(`${t} must be one of the following values: ${e.join(", ")}. "${i[t]}" given.`);return{status:!0,error:null}}catch(e){return{status:!1,error:e}}}function x(i){try{if(typeof i!="object"){const t=typeof i;throw new TypeError(`Values given to isValidHoverType() must be inside of an object. "${t}" given.`)}const e=["off","on","dynamic"];for(const t in i)if(!e.includes(i[t]))throw new TypeError(`${t} must be one of the following values: ${e.join(", ")}. "${i[t]}" given.`);return{status:!0,error:null}}catch(e){return{status:!1,error:e}}}function q(i,e){if(y("string",{tagName:i}).status&&_(HTMLElement,e).status){const t=i.toLowerCase();let s=!0;for(const n in e)e[n].tagName.toLowerCase()!==t&&(s=!1);return s}else return!1}class ${constructor({menuToggleElement:e,parentElement:t,controlledMenu:s,parentMenu:n=null}){o(this,"_dom",{toggle:null,parent:null});o(this,"_elements",{controlledMenu:null,parentMenu:null});o(this,"_open",!1);o(this,"_expandEvent",new CustomEvent("accessibleMenuExpand",{bubbles:!0,detail:{toggle:this}}));o(this,"_collapseEvent",new CustomEvent("accessibleMenuCollapse",{bubbles:!0,detail:{toggle:this}}));this._dom.toggle=e,this._dom.parent=t,this._elements.controlledMenu=s,this._elements.parentMenu=n}initialize(){var e;if(this.dom.toggle.setAttribute("aria-haspopup","true"),this.dom.toggle.setAttribute("aria-expanded","false"),q("button",{toggle:this.dom.toggle})||this.dom.toggle.setAttribute("role","button"),this.dom.toggle.id===""||this.elements.controlledMenu.dom.menu.id===""){const t=Math.random().toString(36).replace(/[^a-z]+/g,"").substr(0,10);let s=((e=this.dom.toggle.innerText)==null?void 0:e.replace(/[^a-zA-Z0-9\s]/g,""))||"",n=t;!s.replace(/\s/g,"").length&&this.dom.toggle.getAttribute("aria-label")&&(s=this.dom.toggle.getAttribute("aria-label").replace(/[^a-zA-Z0-9\s]/g,"")),s.replace(/\s/g,"").length>0&&(s=s.toLowerCase().replace(/\s+/g,"-"),s.startsWith("-")&&(s=s.substring(1)),s.endsWith("-")&&(s=s.slice(0,-1)),n=`${s}-${n}`),this.dom.toggle.id=this.dom.toggle.id||`${n}-menu-button`,this.elements.controlledMenu.dom.menu.id=this.elements.controlledMenu.dom.menu.id||`${n}-menu`}this.elements.controlledMenu.dom.menu.setAttribute("aria-labelledby",this.dom.toggle.id),this.dom.toggle.setAttribute("aria-controls",this.elements.controlledMenu.dom.menu.id),this._collapse(!1)}get dom(){return this._dom}get elements(){return this._elements}get isOpen(){return this._open}set isOpen(e){y("boolean",{value:e}),this._open=e}_expand(e=!0){const{closeClass:t,openClass:s,transitionClass:n}=this.elements.controlledMenu;this.dom.toggle.setAttribute("aria-expanded","true"),n!==""?(c(n,this.elements.controlledMenu.dom.menu),requestAnimationFrame(()=>{t!==""&&a(t,this.elements.controlledMenu.dom.menu),requestAnimationFrame(()=>{s!==""&&c(s,this.elements.controlledMenu.dom.menu),requestAnimationFrame(()=>{a(n,this.elements.controlledMenu.dom.menu)})})})):(s!==""&&c(s,this.elements.controlledMenu.dom.menu),t!==""&&a(t,this.elements.controlledMenu.dom.menu)),e&&this.dom.toggle.dispatchEvent(this._expandEvent)}_collapse(e=!0){const{closeClass:t,openClass:s,transitionClass:n}=this.elements.controlledMenu;this.dom.toggle.setAttribute("aria-expanded","false"),n!==""?(c(n,this.elements.controlledMenu.dom.menu),requestAnimationFrame(()=>{s!==""&&a(s,this.elements.controlledMenu.dom.menu),requestAnimationFrame(()=>{t!==""&&c(t,this.elements.controlledMenu.dom.menu),requestAnimationFrame(()=>{a(n,this.elements.controlledMenu.dom.menu)})})})):(t!==""&&c(t,this.elements.controlledMenu.dom.menu),s!==""&&a(s,this.elements.controlledMenu.dom.menu)),e&&this.dom.toggle.dispatchEvent(this._collapseEvent)}open(){this.elements.controlledMenu.focusState="self",this._expand(),this.isOpen=!0}preview(){this.elements.parentMenu&&(this.elements.parentMenu.focusState="self"),this._expand(),this.isOpen=!0}close(){this.isOpen&&(this.elements.controlledMenu.currentChild=0,this.elements.controlledMenu.blur(),this.elements.parentMenu&&(this.elements.parentMenu.focusState="self"),this._collapse(),this.isOpen=!1)}toggle(){this.isOpen?this.close():this.open()}closeSiblings(){this.elements.parentMenu&&this.elements.parentMenu.elements.submenuToggles.forEach(e=>{e!==this&&e.close()})}closeChildren(){this.elements.controlledMenu.elements.submenuToggles.forEach(e=>e.close())}}class O{constructor({menuItemElement:e,menuLinkElement:t,parentMenu:s,isSubmenuItem:n=!1,childMenu:r=null,toggle:l=null}){o(this,"_dom",{item:null,link:null});o(this,"_elements",{parentMenu:null,childMenu:null,toggle:null});o(this,"_submenu",!1);this._dom.item=e,this._dom.link=t,this._elements.parentMenu=s,this._elements.childMenu=r,this._elements.toggle=l,this._submenu=n}initialize(){}get dom(){return this._dom}get elements(){return this._elements}get isSubmenuItem(){return this._submenu}focus(){this.elements.parentMenu.shouldFocus&&this.dom.link.focus()}blur(){this.elements.parentMenu.shouldFocus&&this.dom.link.blur()}}function w(i){try{const e=i.key||i.keyCode,t={Enter:e==="Enter"||e===13,Space:e===" "||e==="Spacebar"||e===32,Escape:e==="Escape"||e==="Esc"||e===27,ArrowUp:e==="ArrowUp"||e==="Up"||e===38,ArrowRight:e==="ArrowRight"||e==="Right"||e===39,ArrowDown:e==="ArrowDown"||e==="Down"||e===40,ArrowLeft:e==="ArrowLeft"||e==="Left"||e===37,Home:e==="Home"||e===36,End:e==="End"||e===35,Character:isNaN(e)&&!!e.match(/^[a-zA-Z]{1}$/),Tab:e==="Tab"||e===9,Asterisk:e==="*"||e===56};return Object.keys(t).find(s=>t[s]===!0)||""}catch{return""}}function d(i){i.preventDefault(),i.stopPropagation()}class I{constructor({menuElement:e,menuItemSelector:t="li",menuLinkSelector:s="a",submenuItemSelector:n="",submenuToggleSelector:r="a",submenuSelector:l="ul",controllerElement:u=null,containerElement:h=null,openClass:m="show",closeClass:f="hide",transitionClass:p="transitioning",isTopLevel:g=!0,parentMenu:b=null,hoverType:M="off",hoverDelay:E=250,enterDelay:T=-1,leaveDelay:v=-1}){o(this,"_MenuType",I);o(this,"_MenuItemType",O);o(this,"_MenuToggleType",$);o(this,"_dom",{menu:null,menuItems:[],submenuItems:[],submenuToggles:[],submenus:[],controller:null,container:null});o(this,"_selectors",{menuItems:"",menuLinks:"",submenuItems:"",submenuToggles:"",submenus:""});o(this,"_elements",{menuItems:[],submenuToggles:[],controller:null,parentMenu:null,rootMenu:null});o(this,"_openClass","show");o(this,"_closeClass","hide");o(this,"_transitionClass","transitioning");o(this,"_root",!0);o(this,"_currentChild",0);o(this,"_focusState","none");o(this,"_currentEvent","none");o(this,"_hoverType","off");o(this,"_hoverDelay",250);o(this,"_enterDelay",-1);o(this,"_leaveDelay",-1);o(this,"_hoverTimeout",null);o(this,"_errors",[]);this._dom.menu=e,this._dom.controller=u,this._dom.container=h,this._selectors.menuItems=t,this._selectors.menuLinks=s,this._selectors.submenuItems=n,this._selectors.submenuToggles=r,this._selectors.submenus=l,this._elements.menuItems=[],this._elements.submenuToggles=[],this._elements.controller=null,this._elements.parentMenu=b,this._elements.rootMenu=g?this:null,this._openClass=m||"",this._closeClass=f||"",this._transitionClass=p||"",this._root=g,this._hoverType=M,this._hoverDelay=E,this._enterDelay=T,this._leaveDelay=v}initialize(){if(!this._validate())throw new Error(`AccesibleMenu: cannot initialize menu. The following errors have been found: | ||
var Bootstrap5Treeview=function(){"use strict";var H=Object.defineProperty;var P=(c,a,y)=>a in c?H(c,a,{enumerable:!0,configurable:!0,writable:!0,value:y}):c[a]=y;var o=(c,a,y)=>(P(c,typeof a!="symbol"?a+"":a,y),y);function c(i,e){typeof i=="string"?e.classList.add(i):e.classList.add(...i)}function a(i,e){typeof i=="string"?e.classList.remove(i):e.classList.remove(...i)}function y(i,e){try{if(typeof e!="object"){const t=typeof e;throw new TypeError(`Elements given to isValidInstance() must be inside of an object. "${t}" given.`)}for(const t in e)if(!(e[t]instanceof i)){const s=typeof e[t];throw new TypeError(`${t} must be an instance of ${i.name}. "${s}" given.`)}return{status:!0,error:null}}catch(t){return{status:!1,error:t}}}function _(i,e){try{if(typeof e!="object"){const t=typeof e;throw new TypeError(`Values given to isValidType() must be inside of an object. "${t}" given.`)}for(const t in e){const s=typeof e[t];if(s!==i)throw new TypeError(`${t} must be a ${i}. "${s}" given.`)}return{status:!0,error:null}}catch(t){return{status:!1,error:t}}}function S(i){try{if(typeof i!="object"){const e=typeof i;throw new TypeError(`Values given to isCSSSelector() must be inside of an object. "${e}" given.`)}for(const e in i)try{if(i[e]===null)throw new Error;document.querySelector(i[e])}catch{throw new TypeError(`${e} must be a valid CSS selector. "${i[e]}" given.`)}return{status:!0,error:null}}catch(e){return{status:!1,error:e}}}function C(i){try{if(typeof i!="object"||Array.isArray(i)){const e=typeof i;throw new TypeError(`Values given to isValidClassList() must be inside of an object. "${e}" given.`)}for(const e in i){const t=typeof i[e];if(t!=="string")if(Array.isArray(i[e]))i[e].forEach(s=>{if(typeof s!="string")throw new TypeError(`${e} must be a string or an array of strings. An array containing non-strings given.`)});else throw new TypeError(`${e} must be a string or an array of strings. "${t}" given.`);else{const s={};s[e]=i[e],S(s)}}return{status:!0,error:null}}catch(e){return{status:!1,error:e}}}function j(i){try{if(typeof i!="object"){const t=typeof i;throw new TypeError(`Values given to isValidState() must be inside of an object. "${t}" given.`)}const e=["none","self","child"];for(const t in i)if(!e.includes(i[t]))throw new TypeError(`${t} must be one of the following values: ${e.join(", ")}. "${i[t]}" given.`);return{status:!0,error:null}}catch(e){return{status:!1,error:e}}}function V(i){try{if(typeof i!="object"){const t=typeof i;throw new TypeError(`Values given to isValidEvent() must be inside of an object. "${t}" given.`)}const e=["none","mouse","keyboard","character"];for(const t in i)if(!e.includes(i[t]))throw new TypeError(`${t} must be one of the following values: ${e.join(", ")}. "${i[t]}" given.`);return{status:!0,error:null}}catch(e){return{status:!1,error:e}}}function x(i){try{if(typeof i!="object"){const t=typeof i;throw new TypeError(`Values given to isValidHoverType() must be inside of an object. "${t}" given.`)}const e=["off","on","dynamic"];for(const t in i)if(!e.includes(i[t]))throw new TypeError(`${t} must be one of the following values: ${e.join(", ")}. "${i[t]}" given.`);return{status:!0,error:null}}catch(e){return{status:!1,error:e}}}function q(i,e){if(_("string",{tagName:i}).status&&y(HTMLElement,e).status){const t=i.toLowerCase();let s=!0;for(const n in e)e[n].tagName.toLowerCase()!==t&&(s=!1);return s}else return!1}class O{constructor({menuToggleElement:e,parentElement:t,controlledMenu:s,parentMenu:n=null}){o(this,"_dom",{toggle:null,parent:null});o(this,"_elements",{controlledMenu:null,parentMenu:null});o(this,"_open",!1);o(this,"_expandEvent",new CustomEvent("accessibleMenuExpand",{bubbles:!0,detail:{toggle:this}}));o(this,"_collapseEvent",new CustomEvent("accessibleMenuCollapse",{bubbles:!0,detail:{toggle:this}}));this._dom.toggle=e,this._dom.parent=t,this._elements.controlledMenu=s,this._elements.parentMenu=n}initialize(){var e;if(this.dom.toggle.setAttribute("aria-haspopup","true"),this.dom.toggle.setAttribute("aria-expanded","false"),q("button",{toggle:this.dom.toggle})||this.dom.toggle.setAttribute("role","button"),this.dom.toggle.id===""||this.elements.controlledMenu.dom.menu.id===""){const t=Math.random().toString(36).replace(/[^a-z]+/g,"").substr(0,10);let s=((e=this.dom.toggle.innerText)==null?void 0:e.replace(/[^a-zA-Z0-9\s]/g,""))||"",n=t;!s.replace(/\s/g,"").length&&this.dom.toggle.getAttribute("aria-label")&&(s=this.dom.toggle.getAttribute("aria-label").replace(/[^a-zA-Z0-9\s]/g,"")),s.replace(/\s/g,"").length>0&&(s=s.toLowerCase().replace(/\s+/g,"-"),s.startsWith("-")&&(s=s.substring(1)),s.endsWith("-")&&(s=s.slice(0,-1)),n=`${s}-${n}`),this.dom.toggle.id=this.dom.toggle.id||`${n}-menu-button`,this.elements.controlledMenu.dom.menu.id=this.elements.controlledMenu.dom.menu.id||`${n}-menu`}this.elements.controlledMenu.dom.menu.setAttribute("aria-labelledby",this.dom.toggle.id),this.dom.toggle.setAttribute("aria-controls",this.elements.controlledMenu.dom.menu.id),this._collapse(!1)}get dom(){return this._dom}get elements(){return this._elements}get isOpen(){return this._open}set isOpen(e){_("boolean",{value:e}),this._open=e}_expand(e=!0){const{closeClass:t,openClass:s,transitionClass:n}=this.elements.controlledMenu;this.dom.toggle.setAttribute("aria-expanded","true"),n!==""?(c(n,this.elements.controlledMenu.dom.menu),requestAnimationFrame(()=>{t!==""&&a(t,this.elements.controlledMenu.dom.menu),requestAnimationFrame(()=>{s!==""&&c(s,this.elements.controlledMenu.dom.menu),requestAnimationFrame(()=>{a(n,this.elements.controlledMenu.dom.menu)})})})):(s!==""&&c(s,this.elements.controlledMenu.dom.menu),t!==""&&a(t,this.elements.controlledMenu.dom.menu)),e&&this.dom.toggle.dispatchEvent(this._expandEvent)}_collapse(e=!0){const{closeClass:t,openClass:s,transitionClass:n}=this.elements.controlledMenu;this.dom.toggle.setAttribute("aria-expanded","false"),n!==""?(c(n,this.elements.controlledMenu.dom.menu),requestAnimationFrame(()=>{s!==""&&a(s,this.elements.controlledMenu.dom.menu),requestAnimationFrame(()=>{t!==""&&c(t,this.elements.controlledMenu.dom.menu),requestAnimationFrame(()=>{a(n,this.elements.controlledMenu.dom.menu)})})})):(t!==""&&c(t,this.elements.controlledMenu.dom.menu),s!==""&&a(s,this.elements.controlledMenu.dom.menu)),e&&this.dom.toggle.dispatchEvent(this._collapseEvent)}open(){this.elements.controlledMenu.focusState="self",this._expand(),this.isOpen=!0}preview(){this.elements.parentMenu&&(this.elements.parentMenu.focusState="self"),this._expand(),this.isOpen=!0}close(){this.isOpen&&(this.elements.controlledMenu.blur(),this.elements.parentMenu&&(this.elements.parentMenu.focusState="self"),this._collapse(),this.isOpen=!1)}toggle(){this.isOpen?this.close():this.open()}closeSiblings(){this.elements.parentMenu&&this.elements.parentMenu.elements.submenuToggles.forEach(e=>{e!==this&&e.close()})}closeChildren(){this.elements.controlledMenu.elements.submenuToggles.forEach(e=>e.close())}}class ${constructor({menuItemElement:e,menuLinkElement:t,parentMenu:s,isSubmenuItem:n=!1,childMenu:r=null,toggle:l=null}){o(this,"_dom",{item:null,link:null});o(this,"_elements",{parentMenu:null,childMenu:null,toggle:null});o(this,"_submenu",!1);this._dom.item=e,this._dom.link=t,this._elements.parentMenu=s,this._elements.childMenu=r,this._elements.toggle=l,this._submenu=n}initialize(){}get dom(){return this._dom}get elements(){return this._elements}get isSubmenuItem(){return this._submenu}focus(){this.elements.parentMenu.shouldFocus&&this.dom.link.focus()}blur(){this.elements.parentMenu.shouldFocus&&this.dom.link.blur()}}function w(i){try{const e=i.key||i.keyCode,t={Enter:e==="Enter"||e===13,Space:e===" "||e==="Spacebar"||e===32,Escape:e==="Escape"||e==="Esc"||e===27,ArrowUp:e==="ArrowUp"||e==="Up"||e===38,ArrowRight:e==="ArrowRight"||e==="Right"||e===39,ArrowDown:e==="ArrowDown"||e==="Down"||e===40,ArrowLeft:e==="ArrowLeft"||e==="Left"||e===37,Home:e==="Home"||e===36,End:e==="End"||e===35,Character:isNaN(e)&&!!e.match(/^[a-zA-Z]{1}$/),Tab:e==="Tab"||e===9,Asterisk:e==="*"||e===56};return Object.keys(t).find(s=>t[s]===!0)||""}catch{return""}}function d(i){i.preventDefault(),i.stopPropagation()}class I{constructor({menuElement:e,menuItemSelector:t="li",menuLinkSelector:s="a",submenuItemSelector:n="",submenuToggleSelector:r="a",submenuSelector:l="ul",controllerElement:u=null,containerElement:h=null,openClass:m="show",closeClass:f="hide",transitionClass:p="transitioning",isTopLevel:g=!0,parentMenu:b=null,hoverType:M="off",hoverDelay:E=250,enterDelay:v=-1,leaveDelay:T=-1}){o(this,"_MenuType",I);o(this,"_MenuItemType",$);o(this,"_MenuToggleType",O);o(this,"_dom",{menu:null,menuItems:[],submenuItems:[],submenuToggles:[],submenus:[],controller:null,container:null});o(this,"_selectors",{menuItems:"",menuLinks:"",submenuItems:"",submenuToggles:"",submenus:""});o(this,"_elements",{menuItems:[],submenuToggles:[],controller:null,parentMenu:null,rootMenu:null});o(this,"_openClass","show");o(this,"_closeClass","hide");o(this,"_transitionClass","transitioning");o(this,"_root",!0);o(this,"_currentChild",0);o(this,"_focusState","none");o(this,"_currentEvent","none");o(this,"_hoverType","off");o(this,"_hoverDelay",250);o(this,"_enterDelay",-1);o(this,"_leaveDelay",-1);o(this,"_hoverTimeout",null);o(this,"_errors",[]);this._dom.menu=e,this._dom.controller=u,this._dom.container=h,this._selectors.menuItems=t,this._selectors.menuLinks=s,this._selectors.submenuItems=n,this._selectors.submenuToggles=r,this._selectors.submenus=l,this._elements.menuItems=[],this._elements.submenuToggles=[],this._elements.controller=null,this._elements.parentMenu=b,this._elements.rootMenu=g?this:null,this._openClass=m||"",this._closeClass=f||"",this._transitionClass=p||"",this._root=g,this._hoverType=M,this._hoverDelay=E,this._enterDelay=v,this._leaveDelay=T}initialize(){if(!this._validate())throw new Error(`AccesibleMenu: cannot initialize menu. The following errors have been found: | ||
- ${this.errors.join(` | ||
- `)}`);if(this.elements.rootMenu===null&&this._findRootMenu(this),this._setDOMElements(),this.isTopLevel&&this.dom.controller&&this.dom.container){const e=new this._MenuToggleType({menuToggleElement:this.dom.controller,parentElement:this.dom.container,controlledMenu:this});this._elements.controller=e}this._createChildElements()}get dom(){return this._dom}get selectors(){return this._selectors}get elements(){return this._elements}get isTopLevel(){return this._root}get openClass(){return this.isTopLevel?this._openClass:this.elements.rootMenu.openClass}get closeClass(){return this.isTopLevel?this._closeClass:this.elements.rootMenu.closeClass}get transitionClass(){return this.isTopLevel?this._transitionClass:this.elements.rootMenu.transitionClass}get currentChild(){return this._currentChild}get focusState(){return this._focusState}get currentEvent(){return this._currentEvent}get currentMenuItem(){return this.elements.menuItems[this.currentChild]}get hoverType(){return this._root?this._hoverType:this.elements.rootMenu.hoverType}get hoverDelay(){return this._root?this._hoverDelay:this.elements.rootMenu.hoverDelay}get enterDelay(){return this._enterDelay===-1?this.hoverDelay:this._root?this._enterDelay:this.elements.rootMenu.enterDelay}get leaveDelay(){return this._leaveDelay===-1?this.hoverDelay:this._root?this._leaveDelay:this.elements.rootMenu.leaveDelay}get shouldFocus(){let e=!1;return(this.currentEvent==="keyboard"||this.currentEvent==="character")&&(e=!0),this.currentEvent==="mouse"&&this.hoverType==="dynamic"&&(e=!0),e}get errors(){return this._errors}set openClass(e){C({openClass:e}),this._openClass!==e&&(this._openClass=e)}set closeClass(e){C({closeClass:e}),this._closeClass!==e&&(this._closeClass=e)}set transitionClass(e){C({transitionClass:e}),this._transitionClass!==e&&(this._transitionClass=e)}set currentChild(e){y("number",{value:e});function t(s){if(["mouse","character"].includes(s.currentEvent)&&s.elements.parentMenu){let r=0,l=!1;for(;!l&&r<s.elements.parentMenu.elements.menuItems.length;){const u=s.elements.parentMenu.elements.menuItems[r];u.isSubmenuItem&&u.elements.toggle.elements.controlledMenu===s&&(l=!0,s.elements.parentMenu.currentEvent=s.currentEvent,s.elements.parentMenu.currentChild=r),r++}}}e<-1?(this._currentChild=-1,t(this)):e>=this.elements.menuItems.length?(this._currentChild=this.elements.menuItems.length-1,t(this)):this.focusChild!==e&&(this._currentChild=e,t(this))}set focusState(e){j({value:e}),this._focusState!==e&&(this._focusState=e),this.elements.submenuToggles.length>0&&(e==="self"||e==="none")&&this.elements.submenuToggles.forEach(t=>{t.elements.controlledMenu.focusState="none"}),this.elements.parentMenu&&(e==="self"||e==="child")&&(this.elements.parentMenu.focusState="child")}set currentEvent(e){V({value:e}),this._currentEvent!==e&&(this._currentEvent=e,this.elements.submenuToggles.length>0&&this.elements.submenuToggles.forEach(t=>{t.elements.controlledMenu.currentEvent=e}))}set hoverType(e){x({value:e}),this._hoverType!==e&&(this._hoverType=e)}set hoverDelay(e){y("number",{value:e}),this._hoverDelay!==e&&(this._hoverDelay=e)}set enterDelay(e){y("number",{value:e}),this._enterDelay!==e&&(this._enterDelay=e)}set leaveDelay(e){y("number",{value:e}),this._leaveDelay!==e&&(this._leaveDelay=e)}_validate(){let e=!0,t;this._dom.container!==null||this._dom.controller!==null?t=_(HTMLElement,{menuElement:this._dom.menu,controllerElement:this._dom.controller,containerElement:this._dom.container}):t=_(HTMLElement,{menuElement:this._dom.menu}),t.status||(this._errors.push(t.error.message),e=!1);let s;if(this._selectors.submenuItems!==""?s=S({menuItemSelector:this._selectors.menuItems,menuLinkSelector:this._selectors.menuLinks,submenuItemSelector:this._selectors.submenuItems,submenuToggleSelector:this._selectors.submenuToggles,submenuSelector:this._selectors.submenus}):s=S({menuItemSelector:this._selectors.menuItems,menuLinkSelector:this._selectors.menuLinks}),s.status||(this._errors.push(s.error.message),e=!1),this._openClass!==""){const m=C({openClass:this._openClass});m.status||(this._errors.push(m.error.message),e=!1)}if(this._closeClass!==""){const m=C({closeClass:this._closeClass});m.status||(this._errors.push(m.error.message),e=!1)}if(this._transitionClass!==""){const m=C({transitionClass:this._transitionClass});m.status||(this._errors.push(m.error.message),e=!1)}const n=y("boolean",{isTopLevel:this._root});if(n.status||(this._errors.push(n.error.message),e=!1),this._elements.parentMenu!==null){const m=_(I,{parentMenu:this._elements.parentMenu});m.status||(this._errors.push(m.error.message),e=!1)}const r=x({hoverType:this._hoverType});r.status||(this._errors.push(r.error.message),e=!1);const l=y("number",{hoverDelay:this._hoverDelay});l.status||(this._errors.push(l.error.message),e=!1);const u=y("number",{enterDelay:this._enterDelay});u.status||(this._errors.push(u.error.message),e=!1);const h=y("number",{leaveDelay:this._leaveDelay});return h.status||(this._errors.push(h.error.message),e=!1),e}_setDOMElementType(e,t=this.dom.menu,s=!0){if(typeof this.selectors[e]=="string"){if(!Array.isArray(this.dom[e]))throw new Error(`AccessibleMenu: The "${e}" element cannot be set through _setDOMElementType.`);t!==this.dom.menu&&_(HTMLElement,{base:t});const r=Array.from(t.querySelectorAll(this.selectors[e])).filter(l=>l.parentElement===t);s?this._dom[e]=r:this._dom[e]=[...this._dom[e],...r]}else throw new Error(`AccessibleMenu: "${e}" is not a valid element type within the menu.`)}_resetDOMElementType(e){if(typeof this.dom[e]<"u"){if(!Array.isArray(this.dom[e]))throw new Error(`AccessibleMenu: The "${e}" element cannot be reset through _resetDOMElementType.`);this._dom[e]=[]}else throw new Error(`AccessibleMenu: "${e}" is not a valid element type within the menu.`)}_setDOMElements(){this._setDOMElementType("menuItems"),this.selectors.submenuItems!==""&&(this._setDOMElementType("submenuItems"),this._resetDOMElementType("submenuToggles"),this._resetDOMElementType("submenus"),this.dom.submenuItems.forEach(e=>{this._setDOMElementType("submenuToggles",e,!1),this._setDOMElementType("submenus",e,!1)}))}_findRootMenu(e){if(e.isTopLevel)this._elements.rootMenu=e;else if(e.elements.parentMenu!==null)this._findRootMenu(e.elements.parentMenu);else throw new Error("Cannot find root menu.")}_createChildElements(){this.dom.menuItems.forEach(e=>{let t;if(this.dom.submenuItems.includes(e)){const s=e.querySelector(this.selectors.submenuToggles),n=e.querySelector(this.selectors.submenus),r=new this._MenuType({menuElement:n,menuItemSelector:this.selectors.menuItems,menuLinkSelector:this.selectors.menuLinks,submenuItemSelector:this.selectors.submenuItems,submenuToggleSelector:this.selectors.submenuToggles,submenuSelector:this.selectors.submenus,openClass:this.openClass,closeClass:this.closeClass,isTopLevel:!1,parentMenu:this,hoverType:this.hoverType,hoverDelay:this.hoverDelay}),l=new this._MenuToggleType({menuToggleElement:s,parentElement:e,controlledMenu:r,parentMenu:this});this._elements.submenuToggles.push(l),t=new this._MenuItemType({menuItemElement:e,menuLinkElement:s,parentMenu:this,isSubmenuItem:!0,childMenu:r,toggle:l})}else{const s=e.querySelector(this.selectors.menuLinks);t=new this._MenuItemType({menuItemElement:e,menuLinkElement:s,parentMenu:this})}this._elements.menuItems.push(t)})}_handleFocus(){this.elements.menuItems.forEach((e,t)=>{e.dom.link.addEventListener("focus",()=>{this.focusState="self",this.currentChild=t})})}_handleClick(){function e(t,s,n){d(n),s.toggle(),s.isOpen&&(t.focusState="self",s.elements.controlledMenu.focusState="none")}this.elements.menuItems.forEach((t,s)=>{t.dom.link.addEventListener("pointerdown",()=>{this.currentEvent="mouse",this.elements.rootMenu.blurChildren(),this.focusChild(s)},{passive:!0}),t.isSubmenuItem&&t.elements.toggle.dom.toggle.addEventListener("pointerup",n=>{this.currentEvent="mouse",e(this,t.elements.toggle,n)})}),this.isTopLevel&&this.elements.controller&&this.elements.controller.dom.toggle.addEventListener("pointerup",t=>{this.currentEvent="mouse",e(this,this.elements.controller,t)})}_handleHover(){this.elements.menuItems.forEach((e,t)=>{e.dom.link.addEventListener("pointerenter",s=>{if(!(s.pointerType==="pen"||s.pointerType==="touch")){if(this.hoverType==="on")this.currentEvent="mouse",this.currentChild=t,e.isSubmenuItem&&(this.enterDelay>0?this._hoverTimeout=setTimeout(()=>{e.elements.toggle.preview()},this.enterDelay):e.elements.toggle.preview());else if(this.hoverType==="dynamic"){const n=this.elements.submenuToggles.some(r=>r.isOpen);this.currentChild=t,(!this.isTopLevel||this.focusState!=="none")&&(this.currentEvent="mouse",this.focusCurrentChild()),e.isSubmenuItem&&(!this.isTopLevel||n)&&(this.currentEvent="mouse",this.enterDelay>0?this._hoverTimeout=setTimeout(()=>{e.elements.toggle.preview()},this.enterDelay):e.elements.toggle.preview())}}}),e.isSubmenuItem&&e.dom.item.addEventListener("pointerleave",s=>{s.pointerType==="pen"||s.pointerType==="touch"||(this.hoverType==="on"?this.leaveDelay>0?(clearTimeout(this._hoverTimeout),setTimeout(()=>{this.currentEvent="mouse",e.elements.toggle.close()},this.leaveDelay)):(this.currentEvent="mouse",e.elements.toggle.close()):this.hoverType==="dynamic"&&(this.isTopLevel||(this.leaveDelay>0?(clearTimeout(this._hoverTimeout),setTimeout(()=>{this.currentEvent="mouse",e.elements.toggle.close(),this.focusCurrentChild()},this.leaveDelay)):(this.currentEvent="mouse",e.elements.toggle.close(),this.focusCurrentChild()))))})})}_handleKeydown(){this.isTopLevel&&this.elements.controller&&this.elements.controller.dom.toggle.addEventListener("keydown",e=>{this.currentEvent="keyboard";const t=w(e);(t==="Space"||t==="Enter")&&d(e)})}_handleKeyup(){this.isTopLevel&&this.elements.controller&&this.elements.controller.dom.toggle.addEventListener("keyup",e=>{this.currentEvent="keyboard";const t=w(e);(t==="Space"||t==="Enter")&&(d(e),this.elements.controller.open(),this.focusFirstChild())})}focus(){this.focusState="self",this.shouldFocus&&this.dom.menu.focus()}blur(){this.focusState="none",this.shouldFocus&&this.dom.menu.blur()}focusCurrentChild(){this.focusState="self",this.currentChild!==-1&&this.currentMenuItem.focus()}focusChild(e){this.blurCurrentChild(),this.currentChild=e,this.focusCurrentChild()}focusFirstChild(){this.focusChild(0)}focusLastChild(){this.focusChild(this.elements.menuItems.length-1)}focusNextChild(){this.currentChild<this.elements.menuItems.length-1?this.focusChild(this.currentChild+1):this.focusCurrentChild()}focusPreviousChild(){this.currentChild>0?this.focusChild(this.currentChild-1):this.focusCurrentChild()}blurCurrentChild(){this.focusState="none",this.currentChild!==-1&&this.currentMenuItem.blur()}focusController(){this.dom.controller&&(this.shouldFocus&&this.dom.controller.focus(),this.focusState="none")}focusContainer(){this.dom.container&&(this.shouldFocus&&this.dom.container.focus(),this.focusState="none")}closeChildren(){this.elements.submenuToggles.forEach(e=>e.close())}blurChildren(){this.elements.menuItems.forEach(e=>{e.blur(),e.isSubmenuItem&&e.elements.childMenu.blurChildren()})}}class F extends O{constructor({menuItemElement:e,menuLinkElement:t,parentMenu:s,isSubmenuItem:n=!1,childMenu:r=null,toggle:l=null,initialize:u=!0}){super({menuItemElement:e,menuLinkElement:t,parentMenu:s,isSubmenuItem:n,childMenu:r,toggle:l}),u&&this.initialize()}initialize(){super.initialize(),this.dom.item.setAttribute("role","none"),this.dom.link.setAttribute("role","treeitem"),this.dom.link.tabIndex=-1}focus(){super.focus(),this.dom.link.tabIndex=0}blur(){super.blur(),this.dom.link.tabIndex=-1}}class z extends ${constructor({menuToggleElement:e,parentElement:t,controlledMenu:s,parentMenu:n=null,initialize:r=!0}){super({menuToggleElement:e,parentElement:t,controlledMenu:s,parentMenu:n}),r&&this.initialize()}}class k extends I{constructor({menuElement:t,menuItemSelector:s="li",menuLinkSelector:n="a",submenuItemSelector:r="",submenuToggleSelector:l="a",submenuSelector:u="ul",controllerElement:h=null,containerElement:m=null,openClass:f="show",closeClass:p="hide",transitionClass:g="transitioning",isTopLevel:b=!0,parentMenu:M=null,hoverType:E="off",hoverDelay:T=250,enterDelay:v=-1,leaveDelay:A=-1,initialize:D=!0}){super({menuElement:t,menuItemSelector:s,menuLinkSelector:n,submenuItemSelector:r,submenuToggleSelector:l,submenuSelector:u,controllerElement:h,containerElement:m,openClass:f,closeClass:p,transitionClass:g,isTopLevel:b,parentMenu:M,hoverType:E,hoverDelay:T,enterDelay:v,leaveDelay:A});o(this,"_MenuType",k);o(this,"_MenuItemType",F);o(this,"_MenuToggleType",z);D&&this.initialize()}initialize(){try{super.initialize(),this.isTopLevel?(this.dom.menu.setAttribute("role","tree"),this.elements.menuItems[0].dom.link.tabIndex=0):this.dom.menu.setAttribute("role","group"),this._handleFocus(),this._handleClick(),this._handleHover(),this._handleKeydown(),this._handleKeyup()}catch(t){console.error(t)}}_handleKeydown(){super._handleKeydown(),this.dom.menu.addEventListener("keydown",t=>{this.currentEvent="keyboard";const s=w(t);if(s==="Tab"&&(this.elements.rootMenu.focusState!=="none"?this.elements.rootMenu.blur():this.elements.rootMenu.focus()),this.focusState==="self"){const n=["Space","ArrowUp","ArrowDown","ArrowLeft","Asterisk","Home","End"],r=["Enter","ArrowRight"],l=["Escape"];(n.includes(s)||this.currentMenuItem.isSubmenuItem&&r.includes(s)||this.elements.controller&&l.includes(s))&&d(t)}})}_handleKeyup(){super._handleKeyup(),this.dom.menu.addEventListener("keyup",t=>{this.currentEvent="keyboard";const s=w(t),{altKey:n,crtlKey:r,metaKey:l}=t;if(s==="Character"&&!(n||r||l))d(t),this.elements.rootMenu.currentEvent="character",this.focusNextNodeWithCharacter(t.key);else if(this.focusState==="self")if(s==="Enter"||s==="Space")d(t),this.currentMenuItem.isSubmenuItem?this.currentMenuItem.elements.toggle.isOpen?this.currentMenuItem.elements.toggle.close():this.currentMenuItem.elements.toggle.preview():this.currentMenuItem.dom.link.click();else if(s==="Escape")this.isTopLevel&&this.elements.controller&&this.elements.controller.isOpen&&(this.elements.controller.close(),this.focusController());else if(s==="ArrowDown")d(t),this.currentMenuItem.isSubmenuItem&&this.currentMenuItem.elements.toggle.isOpen?(this.blurCurrentChild(),this.currentMenuItem.elements.childMenu.currentEvent=this.currentEvent,this.currentMenuItem.elements.childMenu.focusFirstChild()):!this.isTopLevel&&this.currentChild===this.elements.menuItems.length-1?this.focusParentsNextChild():this.focusNextChild();else if(s==="ArrowUp"){d(t);const h=this.elements.menuItems[this.currentChild-1];h&&h.isSubmenuItem&&h.elements.toggle.isOpen?(this.blurCurrentChild(),this.currentChild=this.currentChild-1,this.currentMenuItem.elements.childMenu.currentEvent=this.currentEvent,this.focusChildsLastNode()):!this.isTopLevel&&this.currentChild===0?(this.blurCurrentChild(),this.elements.parentMenu.currentEvent=this.currentEvent,this.elements.parentMenu.focusCurrentChild()):this.focusPreviousChild()}else s==="ArrowRight"?this.currentMenuItem.isSubmenuItem&&(d(t),this.currentMenuItem.elements.toggle.isOpen?(this.blurCurrentChild(),this.currentMenuItem.elements.childMenu.currentEvent=this.currentEvent,this.currentMenuItem.elements.childMenu.focusFirstChild()):this.currentMenuItem.elements.toggle.preview()):s==="ArrowLeft"?(d(t),this.currentMenuItem.isSubmenuItem&&this.currentMenuItem.elements.toggle.isOpen?(this.currentMenuItem.elements.childMenu.blurCurrentChild(),this.currentMenuItem.elements.toggle.close()):this.isTopLevel||(this.blurCurrentChild(),this.elements.parentMenu.currentEvent=this.currentEvent,this.elements.parentMenu.focusCurrentChild())):s==="Home"?(d(t),this.blurCurrentChild(),this.elements.rootMenu.focusFirstChild()):s==="End"?(d(t),this.blurCurrentChild(),this.elements.rootMenu.focusLastNode()):s==="Asterisk"&&(d(t),this.openChildren())})}focusLastNode(){const t=this.elements.menuItems.length-1,s=this.elements.menuItems[t];s.isSubmenuItem&&s.elements.toggle.isOpen?(this.currentChild=t,s.elements.childMenu.currentEvent=this.currentEvent,s.elements.childMenu.focusLastNode()):this.focusLastChild()}openChildren(){this.elements.submenuToggles.forEach(t=>t.preview())}focusNextNodeWithCharacter(t){function s(f){let p=[];return f.elements.menuItems.forEach(g=>{p.push(g),g.isSubmenuItem&&g.elements.toggle.isOpen&&(p=[...p,...s(g.elements.toggle.elements.controlledMenu)])}),p}const n=t.toLowerCase(),r=s(this.elements.rootMenu),l=r.indexOf(this.currentMenuItem)+1,u=[...r.slice(l),...r.slice(0,l)];let h=0,m=!1;for(;!m&&h<u.length;){let f="";if(u[h].dom.item.innerText?f=u[h].dom.item.innerText:f=u[h].dom.item.textContent,f=f.replace(/[\s]/g,"").toLowerCase().charAt(0),f===n){m=!0;const p=u[h].elements.parentMenu,g=p.elements.menuItems.indexOf(u[h]);this.elements.rootMenu.blurChildren(),p.focusChild(g)}h++}}focusParentsNextChild(){this.elements.parentMenu&&(this.elements.parentMenu.currentEvent=this.currentEvent,this.elements.parentMenu.currentChild===this.elements.parentMenu.elements.menuItems.length-1?(this.elements.parentMenu.blurCurrentChild(),this.elements.parentMenu.focusParentsNextChild()):(this.blurChildren(),this.elements.parentMenu.focusNextChild()))}focusChildsLastNode(){this.currentMenuItem.elements.childMenu.currentEvent=this.currentEvent,this.currentMenuItem.elements.childMenu.focusLastChild(),this.currentMenuItem.elements.childMenu.currentMenuItem.isSubmenuItem&&this.currentMenuItem.elements.childMenu.currentMenuItem.elements.toggle.isOpen&&(this.currentMenuItem.elements.childMenu.blurCurrentChild(),this.currentMenuItem.elements.childMenu.focusChildsLastNode())}}class N extends F{constructor({menuItemElement:e,menuLinkElement:t,parentMenu:s,isSubmenuItem:n=!1,childMenu:r=null,toggle:l=null,initialize:u=!0}){super({menuItemElement:e,menuLinkElement:t,parentMenu:s,isSubmenuItem:n,childMenu:r,toggle:l,initialize:!1}),u&&this.initialize()}}class K extends z{constructor({menuToggleElement:t,parentElement:s,controlledMenu:n,parentMenu:r=null,initialize:l=!0}){super({menuToggleElement:t,parentElement:s,controlledMenu:n,parentMenu:r,initialize:!1});o(this,"_dom",{toggle:null,parent:null,container:null});this._dom.toggle=t,this._dom.parent=s,this._dom.container=n.isTopLevel?n.dom.container:n.dom.menu,l&&this.initialize()}initialize(){super.initialize(),this.dom.toggle.hasAttribute("data-bs-toggle")&&this.dom.toggle.removeAttribute("data-bs-toggle"),this.dom.toggle.hasAttribute("data-bs-target")&&this.dom.toggle.removeAttribute("data-bs-target")}_expand(t=!0){const{openClass:s,transitionClass:n}=this.elements.controlledMenu;this.dom.toggle.setAttribute("aria-expanded","true"),n!==""?(c(n,this.dom.container),requestAnimationFrame(()=>{c(s,this.dom.container),requestAnimationFrame(()=>{a(n,this.dom.container)})})):s!==""&&c(s,this.dom.container),t&&this.dom.toggle.dispatchEvent(this._expandEvent)}_collapse(t=!0){const{closeClass:s,openClass:n,transitionClass:r}=this.elements.controlledMenu;this.dom.toggle.setAttribute("aria-expanded","false"),r!==""?(c(r,this.dom.container),requestAnimationFrame(()=>{n!==""&&a(n,this.dom.container),requestAnimationFrame(()=>{s!==""&&c(s,this.dom.container),requestAnimationFrame(()=>{a(r,this.dom.container)})})})):(s!==""&&c(s,this.dom.container),n!==""&&a(n,this.dom.container)),t&&this.dom.toggle.dispatchEvent(this._collapseEvent)}}class L extends k{constructor({menuElement:t,menuItemSelector:s=".nav-item,li",menuLinkSelector:n=".nav-link,.dropdown-item",submenuItemSelector:r=".dropdown",submenuToggleSelector:l=".dropdown-toggle",submenuSelector:u=".dropdown-menu",controllerElement:h=null,containerElement:m=null,openClass:f="show",closeClass:p="collapse",transitionClass:g="transitioning",isTopLevel:b=!0,parentMenu:M=null,hoverType:E="off",hoverDelay:T=250,enterDelay:v=-1,leaveDelay:A=-1,initialize:D=!0}){super({menuElement:t,menuItemSelector:s,menuLinkSelector:n,submenuItemSelector:r,submenuToggleSelector:l,submenuSelector:u,controllerElement:h,containerElement:m,openClass:f,closeClass:p,transitionClass:g,isTopLevel:b,parentMenu:M,hoverType:E,hoverDelay:T,enterDelay:v,leaveDelay:A,initialize:!1});o(this,"_MenuType",L);o(this,"_MenuItemType",N);o(this,"_MenuToggleType",K);D&&this.initialize()}}return L}(); | ||
- `)}`);if(this.elements.rootMenu===null&&this._findRootMenu(this),this._setDOMElements(),this.isTopLevel&&this.dom.controller&&this.dom.container){const e=new this._MenuToggleType({menuToggleElement:this.dom.controller,parentElement:this.dom.container,controlledMenu:this});this._elements.controller=e}this._createChildElements()}get dom(){return this._dom}get selectors(){return this._selectors}get elements(){return this._elements}get isTopLevel(){return this._root}get openClass(){return this.isTopLevel?this._openClass:this.elements.rootMenu.openClass}get closeClass(){return this.isTopLevel?this._closeClass:this.elements.rootMenu.closeClass}get transitionClass(){return this.isTopLevel?this._transitionClass:this.elements.rootMenu.transitionClass}get currentChild(){return this._currentChild}get focusState(){return this._focusState}get currentEvent(){return this._currentEvent}get currentMenuItem(){return this.elements.menuItems[this.currentChild]}get hoverType(){return this._root?this._hoverType:this.elements.rootMenu.hoverType}get hoverDelay(){return this._root?this._hoverDelay:this.elements.rootMenu.hoverDelay}get enterDelay(){return this._enterDelay===-1?this.hoverDelay:this._root?this._enterDelay:this.elements.rootMenu.enterDelay}get leaveDelay(){return this._leaveDelay===-1?this.hoverDelay:this._root?this._leaveDelay:this.elements.rootMenu.leaveDelay}get shouldFocus(){let e=!1;return(this.currentEvent==="keyboard"||this.currentEvent==="character")&&(e=!0),this.currentEvent==="mouse"&&this.hoverType==="dynamic"&&(e=!0),e}get errors(){return this._errors}set openClass(e){C({openClass:e}),this._openClass!==e&&(this._openClass=e)}set closeClass(e){C({closeClass:e}),this._closeClass!==e&&(this._closeClass=e)}set transitionClass(e){C({transitionClass:e}),this._transitionClass!==e&&(this._transitionClass=e)}set currentChild(e){_("number",{value:e});function t(s){if(["mouse","character"].includes(s.currentEvent)&&s.elements.parentMenu){let r=0,l=!1;for(;!l&&r<s.elements.parentMenu.elements.menuItems.length;){const u=s.elements.parentMenu.elements.menuItems[r];u.isSubmenuItem&&u.elements.toggle.elements.controlledMenu===s&&(l=!0,s.elements.parentMenu.currentEvent=s.currentEvent,s.elements.parentMenu.currentChild=r),r++}}}e<-1?(this._currentChild=-1,t(this)):e>=this.elements.menuItems.length?(this._currentChild=this.elements.menuItems.length-1,t(this)):this.focusChild!==e&&(this._currentChild=e,t(this))}set focusState(e){j({value:e}),this._focusState!==e&&(this._focusState=e),this.elements.submenuToggles.length>0&&(e==="self"||e==="none")&&this.elements.submenuToggles.forEach(t=>{t.elements.controlledMenu.focusState="none"}),this.elements.parentMenu&&(e==="self"||e==="child")&&(this.elements.parentMenu.focusState="child")}set currentEvent(e){V({value:e}),this._currentEvent!==e&&(this._currentEvent=e,this.elements.submenuToggles.length>0&&this.elements.submenuToggles.forEach(t=>{t.elements.controlledMenu.currentEvent=e}))}set hoverType(e){x({value:e}),this._hoverType!==e&&(this._hoverType=e)}set hoverDelay(e){_("number",{value:e}),this._hoverDelay!==e&&(this._hoverDelay=e)}set enterDelay(e){_("number",{value:e}),this._enterDelay!==e&&(this._enterDelay=e)}set leaveDelay(e){_("number",{value:e}),this._leaveDelay!==e&&(this._leaveDelay=e)}_validate(){let e=!0,t;this._dom.container!==null||this._dom.controller!==null?t=y(HTMLElement,{menuElement:this._dom.menu,controllerElement:this._dom.controller,containerElement:this._dom.container}):t=y(HTMLElement,{menuElement:this._dom.menu}),t.status||(this._errors.push(t.error.message),e=!1);let s;if(this._selectors.submenuItems!==""?s=S({menuItemSelector:this._selectors.menuItems,menuLinkSelector:this._selectors.menuLinks,submenuItemSelector:this._selectors.submenuItems,submenuToggleSelector:this._selectors.submenuToggles,submenuSelector:this._selectors.submenus}):s=S({menuItemSelector:this._selectors.menuItems,menuLinkSelector:this._selectors.menuLinks}),s.status||(this._errors.push(s.error.message),e=!1),this._openClass!==""){const m=C({openClass:this._openClass});m.status||(this._errors.push(m.error.message),e=!1)}if(this._closeClass!==""){const m=C({closeClass:this._closeClass});m.status||(this._errors.push(m.error.message),e=!1)}if(this._transitionClass!==""){const m=C({transitionClass:this._transitionClass});m.status||(this._errors.push(m.error.message),e=!1)}const n=_("boolean",{isTopLevel:this._root});if(n.status||(this._errors.push(n.error.message),e=!1),this._elements.parentMenu!==null){const m=y(I,{parentMenu:this._elements.parentMenu});m.status||(this._errors.push(m.error.message),e=!1)}const r=x({hoverType:this._hoverType});r.status||(this._errors.push(r.error.message),e=!1);const l=_("number",{hoverDelay:this._hoverDelay});l.status||(this._errors.push(l.error.message),e=!1);const u=_("number",{enterDelay:this._enterDelay});u.status||(this._errors.push(u.error.message),e=!1);const h=_("number",{leaveDelay:this._leaveDelay});return h.status||(this._errors.push(h.error.message),e=!1),e}_setDOMElementType(e,t=this.dom.menu,s=!0){if(typeof this.selectors[e]=="string"){if(!Array.isArray(this.dom[e]))throw new Error(`AccessibleMenu: The "${e}" element cannot be set through _setDOMElementType.`);t!==this.dom.menu&&y(HTMLElement,{base:t});const r=Array.from(t.querySelectorAll(this.selectors[e])).filter(l=>l.parentElement===t);s?this._dom[e]=r:this._dom[e]=[...this._dom[e],...r]}else throw new Error(`AccessibleMenu: "${e}" is not a valid element type within the menu.`)}_resetDOMElementType(e){if(typeof this.dom[e]<"u"){if(!Array.isArray(this.dom[e]))throw new Error(`AccessibleMenu: The "${e}" element cannot be reset through _resetDOMElementType.`);this._dom[e]=[]}else throw new Error(`AccessibleMenu: "${e}" is not a valid element type within the menu.`)}_setDOMElements(){this._setDOMElementType("menuItems"),this.selectors.submenuItems!==""&&(this._setDOMElementType("submenuItems"),this._resetDOMElementType("submenuToggles"),this._resetDOMElementType("submenus"),this.dom.submenuItems.forEach(e=>{this._setDOMElementType("submenuToggles",e,!1),this._setDOMElementType("submenus",e,!1)}))}_findRootMenu(e){if(e.isTopLevel)this._elements.rootMenu=e;else if(e.elements.parentMenu!==null)this._findRootMenu(e.elements.parentMenu);else throw new Error("Cannot find root menu.")}_createChildElements(){this.dom.menuItems.forEach(e=>{let t;if(this.dom.submenuItems.includes(e)){const s=e.querySelector(this.selectors.submenuToggles),n=e.querySelector(this.selectors.submenus),r=new this._MenuType({menuElement:n,menuItemSelector:this.selectors.menuItems,menuLinkSelector:this.selectors.menuLinks,submenuItemSelector:this.selectors.submenuItems,submenuToggleSelector:this.selectors.submenuToggles,submenuSelector:this.selectors.submenus,openClass:this.openClass,closeClass:this.closeClass,transitionClass:this.transitionClass,isTopLevel:!1,parentMenu:this,hoverType:this.hoverType,hoverDelay:this.hoverDelay,enterDelay:this.enterDelay,leaveDelay:this.leaveDelay}),l=new this._MenuToggleType({menuToggleElement:s,parentElement:e,controlledMenu:r,parentMenu:this});this._elements.submenuToggles.push(l),t=new this._MenuItemType({menuItemElement:e,menuLinkElement:s,parentMenu:this,isSubmenuItem:!0,childMenu:r,toggle:l})}else{const s=e.querySelector(this.selectors.menuLinks);t=new this._MenuItemType({menuItemElement:e,menuLinkElement:s,parentMenu:this})}this._elements.menuItems.push(t)})}_handleFocus(){this.elements.menuItems.forEach((e,t)=>{e.dom.link.addEventListener("focus",()=>{this.focusState="self",this.currentChild=t})})}_handleClick(){function e(t,s,n){d(n),s.toggle(),s.isOpen&&(t.focusState="self",s.elements.controlledMenu.focusState="none")}this.elements.menuItems.forEach((t,s)=>{t.dom.link.addEventListener("pointerdown",()=>{this.currentEvent="mouse",this.elements.rootMenu.blurChildren(),this.focusChild(s)},{passive:!0}),t.isSubmenuItem&&t.elements.toggle.dom.toggle.addEventListener("pointerup",n=>{this.currentEvent="mouse",e(this,t.elements.toggle,n)})}),this.isTopLevel&&this.elements.controller&&this.elements.controller.dom.toggle.addEventListener("pointerup",t=>{this.currentEvent="mouse",e(this,this.elements.controller,t)})}_handleHover(){this.elements.menuItems.forEach((e,t)=>{e.dom.link.addEventListener("pointerenter",s=>{if(!(s.pointerType==="pen"||s.pointerType==="touch")){if(this.hoverType==="on")this.currentEvent="mouse",this.elements.rootMenu.blurChildren(),this.focusChild(t),e.isSubmenuItem&&(this.enterDelay>0?this._hoverTimeout=setTimeout(()=>{e.elements.toggle.preview()},this.enterDelay):e.elements.toggle.preview());else if(this.hoverType==="dynamic"){const n=this.elements.submenuToggles.some(r=>r.isOpen);this.currentChild=t,(!this.isTopLevel||this.focusState!=="none")&&(this.currentEvent="mouse",this.elements.rootMenu.blurChildren(),this.focusCurrentChild()),e.isSubmenuItem&&(!this.isTopLevel||n)&&(this.currentEvent="mouse",this.elements.rootMenu.blurChildren(),this.focusCurrentChild(),this.enterDelay>0?this._hoverTimeout=setTimeout(()=>{e.elements.toggle.preview()},this.enterDelay):e.elements.toggle.preview())}}}),e.isSubmenuItem&&e.dom.item.addEventListener("pointerleave",s=>{s.pointerType==="pen"||s.pointerType==="touch"||(this.hoverType==="on"?this.leaveDelay>0?(clearTimeout(this._hoverTimeout),setTimeout(()=>{this.currentEvent="mouse",e.elements.toggle.close()},this.leaveDelay)):(this.currentEvent="mouse",e.elements.toggle.close()):this.hoverType==="dynamic"&&(this.isTopLevel||(this.leaveDelay>0?(clearTimeout(this._hoverTimeout),setTimeout(()=>{this.currentEvent="mouse",e.elements.toggle.close(),this.focusCurrentChild()},this.leaveDelay)):(this.currentEvent="mouse",e.elements.toggle.close(),this.focusCurrentChild()))))})})}_handleKeydown(){this.isTopLevel&&this.elements.controller&&this.elements.controller.dom.toggle.addEventListener("keydown",e=>{this.currentEvent="keyboard";const t=w(e);(t==="Space"||t==="Enter")&&d(e)})}_handleKeyup(){this.isTopLevel&&this.elements.controller&&this.elements.controller.dom.toggle.addEventListener("keyup",e=>{this.currentEvent="keyboard";const t=w(e);(t==="Space"||t==="Enter")&&(d(e),this.elements.controller.toggle(),this.elements.controller.isOpen&&this.focusFirstChild())})}focus(){this.focusState="self",this.shouldFocus&&this.dom.menu.focus()}blur(){this.focusState="none",this.shouldFocus&&this.dom.menu.blur()}focusCurrentChild(){this.focusState="self",this.currentChild!==-1&&this.currentMenuItem.focus()}focusChild(e){this.blurCurrentChild(),this.currentChild=e,this.focusCurrentChild()}focusFirstChild(){this.focusChild(0)}focusLastChild(){this.focusChild(this.elements.menuItems.length-1)}focusNextChild(){this.currentChild<this.elements.menuItems.length-1?this.focusChild(this.currentChild+1):this.focusCurrentChild()}focusPreviousChild(){this.currentChild>0?this.focusChild(this.currentChild-1):this.focusCurrentChild()}blurCurrentChild(){this.focusState="none",this.currentChild!==-1&&this.currentMenuItem.blur()}focusController(){this.dom.controller&&(this.shouldFocus&&this.dom.controller.focus(),this.focusState="none")}focusContainer(){this.dom.container&&(this.shouldFocus&&this.dom.container.focus(),this.focusState="none")}closeChildren(){this.elements.submenuToggles.forEach(e=>e.close())}blurChildren(){this.elements.menuItems.forEach(e=>{e.blur(),e.isSubmenuItem&&e.elements.childMenu.blurChildren()})}}class F extends ${constructor({menuItemElement:e,menuLinkElement:t,parentMenu:s,isSubmenuItem:n=!1,childMenu:r=null,toggle:l=null,initialize:u=!0}){super({menuItemElement:e,menuLinkElement:t,parentMenu:s,isSubmenuItem:n,childMenu:r,toggle:l}),u&&this.initialize()}initialize(){super.initialize(),this.dom.item.setAttribute("role","none"),this.dom.link.setAttribute("role","treeitem"),this.dom.link.tabIndex=-1}focus(){super.focus(),this.dom.link.tabIndex=0}blur(){super.blur(),this.dom.link.tabIndex=-1}}class z extends O{constructor({menuToggleElement:e,parentElement:t,controlledMenu:s,parentMenu:n=null,initialize:r=!0}){super({menuToggleElement:e,parentElement:t,controlledMenu:s,parentMenu:n}),r&&this.initialize()}}class k extends I{constructor({menuElement:t,menuItemSelector:s="li",menuLinkSelector:n="a",submenuItemSelector:r="",submenuToggleSelector:l="a",submenuSelector:u="ul",controllerElement:h=null,containerElement:m=null,openClass:f="show",closeClass:p="hide",transitionClass:g="transitioning",isTopLevel:b=!0,parentMenu:M=null,hoverType:E="off",hoverDelay:v=250,enterDelay:T=-1,leaveDelay:L=-1,initialize:A=!0}){super({menuElement:t,menuItemSelector:s,menuLinkSelector:n,submenuItemSelector:r,submenuToggleSelector:l,submenuSelector:u,controllerElement:h,containerElement:m,openClass:f,closeClass:p,transitionClass:g,isTopLevel:b,parentMenu:M,hoverType:E,hoverDelay:v,enterDelay:T,leaveDelay:L});o(this,"_MenuType",k);o(this,"_MenuItemType",F);o(this,"_MenuToggleType",z);A&&this.initialize()}initialize(){try{super.initialize(),this.isTopLevel?(this.dom.menu.setAttribute("role","tree"),this.elements.menuItems[0].dom.link.tabIndex=0):this.dom.menu.setAttribute("role","group"),this._handleFocus(),this._handleClick(),this._handleHover(),this._handleKeydown(),this._handleKeyup()}catch(t){console.error(t)}}_handleKeydown(){super._handleKeydown(),this.dom.menu.addEventListener("keydown",t=>{this.currentEvent="keyboard";const s=w(t);if(s==="Tab"&&(this.elements.rootMenu.focusState!=="none"?this.elements.rootMenu.blur():this.elements.rootMenu.focus()),this.focusState==="self"){const n=["Space","ArrowUp","ArrowDown","ArrowLeft","Asterisk","Home","End"],r=["Enter","ArrowRight"],l=["Escape"];(n.includes(s)||this.currentMenuItem.isSubmenuItem&&r.includes(s)||this.elements.controller&&l.includes(s))&&d(t)}})}_handleKeyup(){super._handleKeyup(),this.dom.menu.addEventListener("keyup",t=>{this.currentEvent="keyboard";const s=w(t),{altKey:n,crtlKey:r,metaKey:l}=t;if(s==="Character"&&!(n||r||l))d(t),this.elements.rootMenu.currentEvent="character",this.focusNextNodeWithCharacter(t.key);else if(this.focusState==="self")if(s==="Enter"||s==="Space")d(t),this.currentMenuItem.isSubmenuItem?this.currentMenuItem.elements.toggle.isOpen?this.currentMenuItem.elements.toggle.close():this.currentMenuItem.elements.toggle.preview():this.currentMenuItem.dom.link.click();else if(s==="Escape")this.isTopLevel&&this.elements.controller&&this.elements.controller.isOpen&&(this.elements.controller.close(),this.focusController());else if(s==="ArrowDown")d(t),this.currentMenuItem.isSubmenuItem&&this.currentMenuItem.elements.toggle.isOpen?(this.blurCurrentChild(),this.currentMenuItem.elements.childMenu.currentEvent=this.currentEvent,this.currentMenuItem.elements.childMenu.focusFirstChild()):!this.isTopLevel&&this.currentChild===this.elements.menuItems.length-1?this.focusParentsNextChild():this.focusNextChild();else if(s==="ArrowUp"){d(t);const h=this.elements.menuItems[this.currentChild-1];h&&h.isSubmenuItem&&h.elements.toggle.isOpen?(this.blurCurrentChild(),this.currentChild=this.currentChild-1,this.currentMenuItem.elements.childMenu.currentEvent=this.currentEvent,this.focusChildsLastNode()):!this.isTopLevel&&this.currentChild===0?(this.blurCurrentChild(),this.elements.parentMenu.currentEvent=this.currentEvent,this.elements.parentMenu.focusCurrentChild()):this.focusPreviousChild()}else s==="ArrowRight"?this.currentMenuItem.isSubmenuItem&&(d(t),this.currentMenuItem.elements.toggle.isOpen?(this.blurCurrentChild(),this.currentMenuItem.elements.childMenu.currentEvent=this.currentEvent,this.currentMenuItem.elements.childMenu.focusFirstChild()):this.currentMenuItem.elements.toggle.preview()):s==="ArrowLeft"?(d(t),this.currentMenuItem.isSubmenuItem&&this.currentMenuItem.elements.toggle.isOpen?(this.currentMenuItem.elements.childMenu.blurCurrentChild(),this.currentMenuItem.elements.toggle.close()):this.isTopLevel||(this.blurCurrentChild(),this.elements.parentMenu.currentEvent=this.currentEvent,this.elements.parentMenu.focusCurrentChild())):s==="Home"?(d(t),this.blurCurrentChild(),this.elements.rootMenu.focusFirstChild()):s==="End"?(d(t),this.blurCurrentChild(),this.elements.rootMenu.focusLastNode()):s==="Asterisk"&&(d(t),this.openChildren())})}focusLastNode(){const t=this.elements.menuItems.length-1,s=this.elements.menuItems[t];s.isSubmenuItem&&s.elements.toggle.isOpen?(this.currentChild=t,s.elements.childMenu.currentEvent=this.currentEvent,s.elements.childMenu.focusLastNode()):this.focusLastChild()}openChildren(){this.elements.submenuToggles.forEach(t=>t.preview())}focusNextNodeWithCharacter(t){function s(f){let p=[];return f.elements.menuItems.forEach(g=>{p.push(g),g.isSubmenuItem&&g.elements.toggle.isOpen&&(p=[...p,...s(g.elements.toggle.elements.controlledMenu)])}),p}const n=t.toLowerCase(),r=s(this.elements.rootMenu),l=r.indexOf(this.currentMenuItem)+1,u=[...r.slice(l),...r.slice(0,l)];let h=0,m=!1;for(;!m&&h<u.length;){let f="";if(u[h].dom.item.innerText?f=u[h].dom.item.innerText:f=u[h].dom.item.textContent,f=f.replace(/[\s]/g,"").toLowerCase().charAt(0),f===n){m=!0;const p=u[h].elements.parentMenu,g=p.elements.menuItems.indexOf(u[h]);this.elements.rootMenu.blurChildren(),p.focusChild(g)}h++}}focusParentsNextChild(){this.elements.parentMenu&&(this.elements.parentMenu.currentEvent=this.currentEvent,this.elements.parentMenu.currentChild===this.elements.parentMenu.elements.menuItems.length-1?(this.elements.parentMenu.blurCurrentChild(),this.elements.parentMenu.focusParentsNextChild()):(this.blurChildren(),this.elements.parentMenu.focusNextChild()))}focusChildsLastNode(){this.currentMenuItem.elements.childMenu.currentEvent=this.currentEvent,this.currentMenuItem.elements.childMenu.focusLastChild(),this.currentMenuItem.elements.childMenu.currentMenuItem.isSubmenuItem&&this.currentMenuItem.elements.childMenu.currentMenuItem.elements.toggle.isOpen&&(this.currentMenuItem.elements.childMenu.blurCurrentChild(),this.currentMenuItem.elements.childMenu.focusChildsLastNode())}}class N extends F{constructor({menuItemElement:e,menuLinkElement:t,parentMenu:s,isSubmenuItem:n=!1,childMenu:r=null,toggle:l=null,initialize:u=!0}){super({menuItemElement:e,menuLinkElement:t,parentMenu:s,isSubmenuItem:n,childMenu:r,toggle:l,initialize:!1}),u&&this.initialize()}}class K extends z{constructor({menuToggleElement:t,parentElement:s,controlledMenu:n,parentMenu:r=null,initialize:l=!0}){super({menuToggleElement:t,parentElement:s,controlledMenu:n,parentMenu:r,initialize:!1});o(this,"_dom",{toggle:null,parent:null,container:null});this._dom.toggle=t,this._dom.parent=s,this._dom.container=n.isTopLevel?n.dom.container:n.dom.menu,l&&this.initialize()}initialize(){super.initialize(),this.dom.toggle.hasAttribute("data-bs-toggle")&&this.dom.toggle.removeAttribute("data-bs-toggle"),this.dom.toggle.hasAttribute("data-bs-target")&&this.dom.toggle.removeAttribute("data-bs-target")}_expand(t=!0){const{openClass:s,transitionClass:n}=this.elements.controlledMenu;this.dom.toggle.setAttribute("aria-expanded","true"),n!==""?(c(n,this.dom.container),requestAnimationFrame(()=>{c(s,this.dom.container),requestAnimationFrame(()=>{a(n,this.dom.container)})})):s!==""&&c(s,this.dom.container),t&&this.dom.toggle.dispatchEvent(this._expandEvent)}_collapse(t=!0){const{closeClass:s,openClass:n,transitionClass:r}=this.elements.controlledMenu;this.dom.toggle.setAttribute("aria-expanded","false"),r!==""?(c(r,this.dom.container),requestAnimationFrame(()=>{n!==""&&a(n,this.dom.container),requestAnimationFrame(()=>{s!==""&&c(s,this.dom.container),requestAnimationFrame(()=>{a(r,this.dom.container)})})})):(s!==""&&c(s,this.dom.container),n!==""&&a(n,this.dom.container)),t&&this.dom.toggle.dispatchEvent(this._collapseEvent)}}class D extends k{constructor({menuElement:t,menuItemSelector:s=".nav-item,li",menuLinkSelector:n=".nav-link,.dropdown-item",submenuItemSelector:r=".dropdown",submenuToggleSelector:l=".dropdown-toggle",submenuSelector:u=".dropdown-menu",controllerElement:h=null,containerElement:m=null,openClass:f="show",closeClass:p="collapse",transitionClass:g="transitioning",isTopLevel:b=!0,parentMenu:M=null,hoverType:E="off",hoverDelay:v=250,enterDelay:T=-1,leaveDelay:L=-1,initialize:A=!0}){super({menuElement:t,menuItemSelector:s,menuLinkSelector:n,submenuItemSelector:r,submenuToggleSelector:l,submenuSelector:u,controllerElement:h,containerElement:m,openClass:f,closeClass:p,transitionClass:g,isTopLevel:b,parentMenu:M,hoverType:E,hoverDelay:v,enterDelay:T,leaveDelay:L,initialize:!1});o(this,"_MenuType",D);o(this,"_MenuItemType",N);o(this,"_MenuToggleType",K);A&&this.initialize()}}return D}(); |
{ | ||
"name": "accessible-menu-bootstrap-5", | ||
"version": "2.0.0-beta.1", | ||
"version": "2.0.0-beta.2", | ||
"description": "A JavaScript library to help you generate WAI-ARIA accessible menus with in the DOM using Bootstrap 5.", | ||
@@ -56,3 +56,3 @@ "main": "index.js", | ||
"dependencies": { | ||
"accessible-menu": "^4.0.0-beta.1" | ||
"accessible-menu": "^4.0.0-beta.4" | ||
}, | ||
@@ -59,0 +59,0 @@ "devDependencies": { |
@@ -49,3 +49,3 @@ # accessible-menu-bootstrap-5 | ||
```html | ||
<script src="https://cdn.jsdelivr.net/npm/accessible-menu-bootstrap-5@2.0.0-beta.1/dist/accessible-menu-bs5.min.js"></script> | ||
<script src="https://cdn.jsdelivr.net/npm/accessible-menu-bootstrap-5@2.0.0-beta.2/dist/accessible-menu-bs5.min.js"></script> | ||
``` | ||
@@ -80,3 +80,3 @@ | ||
```html | ||
<script src="https://cdn.jsdelivr.net/npm/accessible-menu-bootstrap-5@2.0.0-beta.1/dist/accessible-menu-bs5.min.js"></script> | ||
<script src="https://cdn.jsdelivr.net/npm/accessible-menu-bootstrap-5@2.0.0-beta.2/dist/accessible-menu-bs5.min.js"></script> | ||
``` | ||
@@ -109,3 +109,3 @@ | ||
```html | ||
<script src="https://cdn.jsdelivr.net/npm/accessible-menu-bootstrap-5@2.0.0-beta.1/dist/disclosure-menu-bs5.min.js"></script> | ||
<script src="https://cdn.jsdelivr.net/npm/accessible-menu-bootstrap-5@2.0.0-beta.2/dist/disclosure-menu-bs5.min.js"></script> | ||
``` | ||
@@ -130,3 +130,3 @@ | ||
```html | ||
<script src="https://cdn.jsdelivr.net/npm/accessible-menu-bootstrap-5@2.0.0-beta.1/dist/menubar-bs5.min.js"></script> | ||
<script src="https://cdn.jsdelivr.net/npm/accessible-menu-bootstrap-5@2.0.0-beta.2/dist/menubar-bs5.min.js"></script> | ||
``` | ||
@@ -171,3 +171,3 @@ | ||
```html | ||
<script src="https://cdn.jsdelivr.net/npm/accessible-menu-bootstrap-5@2.0.0-beta.1/dist/treeview-bs5.min.js"></script> | ||
<script src="https://cdn.jsdelivr.net/npm/accessible-menu-bootstrap-5@2.0.0-beta.2/dist/treeview-bs5.min.js"></script> | ||
``` | ||
@@ -174,0 +174,0 @@ |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
742107
14806