Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

accessible-menu

Package Overview
Dependencies
Maintainers
1
Versions
47
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

accessible-menu - npm Package Compare versions

Comparing version 3.0.0 to 3.0.1

2

dist/accessible-menu.min.js

@@ -1,2 +0,2 @@

var AccessibleMenu=function(){"use strict";function e(t){return(e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(t)}function t(t,n){try{if("object"!==e(n)){var r=e(n);throw new TypeError("AccessibleMenu: Elements given to isValidInstance() must be inside of an object. ".concat(r," given."))}for(var o in n)if(!(n[o]instanceof t)){var u=e(n[o]);throw new TypeError("AccessibleMenu: ".concat(o," must be an instance of ").concat(t.name,". ").concat(u," given."))}return!0}catch(e){return console.error(e),!1}}function n(t,n){try{if("object"!==e(n)){var r=e(n);throw new TypeError("AccessibleMenu: Values given to isValidType() must be inside of an object. ".concat(r," given."))}for(var o in n){var u=e(n[o]);if(u!==t)throw new TypeError("AccessibleMenu: ".concat(o," must be a ").concat(t,". ").concat(u," given."))}return!0}catch(e){return console.error(e),!1}}function r(t){try{if("object"!==e(t)){var n=e(t);throw new TypeError("AccessibleMenu: Values given to isCSSSelector() must be inside of an object. ".concat(n," given."))}for(var r in t)try{if(null===t[r])throw new Error;document.querySelector(t[r])}catch(e){throw new TypeError("AccessibleMenu: ".concat(r,' must be a valid CSS selector. "').concat(t[r],'" given.'))}return!0}catch(e){return console.error(e),!1}}function o(t){try{if("object"!==e(t)||Array.isArray(t)){var n=e(t);throw new TypeError("AccessibleMenu: Values given to isValidClassList() must be inside of an object. ".concat(n," given."))}var o=function(n){var o=e(t[n]);if("string"!==o){if(!Array.isArray(t[n]))throw new TypeError("AccessibleMenu: ".concat(n," must be a string or an array of strings. ").concat(o," given."));t[n].forEach((function(e){if("string"!=typeof e)throw new TypeError("AccessibleMenu: ".concat(n," must be a string or an array of strings. An array containing non-strings given."))}))}else{var u={};u[n]=t[n],r(u)}};for(var u in t)o(u);return!0}catch(e){return console.error(e),!1}}function u(t){try{if("object"!==e(t)){var n=e(t);throw new TypeError("AccessibleMenu: Values given to isValidHoverType() must be inside of an object. ".concat(n," given."))}var r=["off","on","dynamic"];for(var o in t)if(!r.includes(t[o]))throw new TypeError("AccessibleMenu: ".concat(o," must be one of the following values: ").concat(r.join(", "),'. "').concat(t[o],'" given.'));return!0}catch(e){return console.error(e),!1}}function i(e,r){return!(!n("string",{event:e})||!t(HTMLElement,{element:r}))&&void 0!==r["on".concat(e)]}function l(e){return function(e){if(Array.isArray(e))return s(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,t){if(!e)return;if("string"==typeof e)return s(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return s(e,t)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function s(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function c(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function a(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var m=function(){function e(t){var n=t.menuToggleElement,r=t.parentElement,o=t.controlledMenu,u=t.parentMenu,i=void 0===u?null:u;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),a(this,"_dom",{toggle:null,parent:null}),a(this,"_elements",{controlledMenu:null,parentMenu:null}),a(this,"_open",!1),a(this,"_expandEvent",new CustomEvent("accessibleMenuExpand",{bubbles:!0,detail:{toggle:this}})),a(this,"_collapseEvent",new CustomEvent("accessibleMenuCollapse",{bubbles:!0,detail:{toggle:this}})),this._dom.toggle=n,this._dom.parent=r,this._elements.controlledMenu=o,this._elements.parentMenu=i}var r,o,u;return r=e,(o=[{key:"initialize",value:function(){if(this.dom.toggle.setAttribute("aria-haspopup","true"),this.dom.toggle.setAttribute("aria-expanded","false"),function(e,r){if(n("string",{tagName:e})&&t(HTMLElement,r)){var o=e.toLowerCase(),u=!0;for(var i in r)r[i].tagName.toLowerCase()!==o&&(u=!1);return u}return!1}("button",{toggle:this.dom.toggle})||this.dom.toggle.setAttribute("role","button"),""===this.dom.toggle.id||""===this.elements.controlledMenu.dom.menu.id){var e=Math.random().toString(36).replace(/[^a-z]+/g,"").substr(0,10),r=this.dom.toggle.innerText.replace(/[^a-zA-Z0-9\s]/g,""),o=e;!r.replace(/\s/g,"").length&&this.dom.toggle.getAttribute("aria-label")&&(r=this.dom.toggle.getAttribute("aria-label").replace(/[^a-zA-Z0-9\s]/g,"")),r.replace(/\s/g,"").length>0&&((r=r.toLowerCase().replace(/\s+/g,"-")).startsWith("-")&&(r=r.substring(1)),r.endsWith("-")&&(r=r.slice(0,-1)),o="".concat(r,"-").concat(o)),this.dom.toggle.id=this.dom.toggle.id||"".concat(o,"-menu-button"),this.elements.controlledMenu.dom.menu.id=this.elements.controlledMenu.dom.menu.id||"".concat(o,"-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)}},{key:"dom",get:function(){return this._dom}},{key:"elements",get:function(){return this._elements}},{key:"isOpen",get:function(){return this._open},set:function(e){n("boolean",{value:e}),this._open=e}},{key:"_expand",value:function(){var e,t,n=!(arguments.length>0&&void 0!==arguments[0])||arguments[0],r=this.elements.controlledMenu,o=r.closeClass,u=r.openClass;this.dom.toggle.setAttribute("aria-expanded","true"),""!==u&&("string"==typeof u?this.elements.controlledMenu.dom.menu.classList.add(u):(e=this.elements.controlledMenu.dom.menu.classList).add.apply(e,l(u))),""!==o&&("string"==typeof o?this.elements.controlledMenu.dom.menu.classList.remove(o):(t=this.elements.controlledMenu.dom.menu.classList).remove.apply(t,l(o))),n&&this.dom.toggle.dispatchEvent(this._expandEvent)}},{key:"_collapse",value:function(){var e,t,n=!(arguments.length>0&&void 0!==arguments[0])||arguments[0],r=this.elements.controlledMenu,o=r.closeClass,u=r.openClass;this.dom.toggle.setAttribute("aria-expanded","false"),""!==o&&("string"==typeof o?this.elements.controlledMenu.dom.menu.classList.add(o):(e=this.elements.controlledMenu.dom.menu.classList).add.apply(e,l(o))),""!==u&&("string"==typeof u?this.elements.controlledMenu.dom.menu.classList.remove(u):(t=this.elements.controlledMenu.dom.menu.classList).remove.apply(t,l(u))),n&&this.dom.toggle.dispatchEvent(this._collapseEvent)}},{key:"open",value:function(){this.elements.controlledMenu.focusState="self",this._expand(),this.isOpen=!0}},{key:"preview",value:function(){this.elements.parentMenu&&(this.elements.parentMenu.focusState="self"),this._expand(),this.isOpen=!0}},{key:"close",value:function(){this.isOpen&&(this.elements.controlledMenu.currentChild=0,this.elements.controlledMenu.blur(),this.elements.parentMenu&&(this.elements.parentMenu.focusState="self"),this._collapse(),this.isOpen=!1)}},{key:"toggle",value:function(){this.isOpen?this.close():this.open()}},{key:"closeSiblings",value:function(){var e=this;this.elements.parentMenu&&this.elements.parentMenu.elements.submenuToggles.forEach((function(t){t!==e&&t.close()}))}},{key:"closeChildren",value:function(){this.elements.controlledMenu.elements.submenuToggles.forEach((function(e){return e.close()}))}}])&&c(r.prototype,o),u&&c(r,u),e}();function f(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function h(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var p=function(){function e(t){var n=t.menuItemElement,r=t.menuLinkElement,o=t.parentMenu,u=t.isSubmenuItem,i=void 0!==u&&u,l=t.childMenu,s=void 0===l?null:l,c=t.toggle,a=void 0===c?null:c;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),h(this,"_dom",{item:null,link:null}),h(this,"_elements",{parentMenu:null,childMenu:null,toggle:null}),h(this,"_submenu",!1),this._dom.item=n,this._dom.link=r,this._elements.parentMenu=o,this._elements.childMenu=s,this._elements.toggle=a,this._submenu=i}var t,n,r;return t=e,(n=[{key:"initialize",value:function(){}},{key:"dom",get:function(){return this._dom}},{key:"elements",get:function(){return this._elements}},{key:"isSubmenuItem",get:function(){return this._submenu}},{key:"focus",value:function(){this.elements.parentMenu.shouldFocus&&this.dom.link.focus()}},{key:"blur",value:function(){this.elements.parentMenu.shouldFocus&&this.dom.link.blur()}}])&&f(t.prototype,n),r&&f(t,r),e}();function d(e){try{var t=e.key||e.keyCode,n={Enter:"Enter"===t||13===t,Space:" "===t||"Spacebar"===t||32===t,Escape:"Escape"===t||"Esc"===t||27===t,ArrowUp:"ArrowUp"===t||"Up"===t||38===t,ArrowRight:"ArrowRight"===t||"Right"===t||39===t,ArrowDown:"ArrowDown"===t||"Down"===t||40===t,ArrowLeft:"ArrowLeft"===t||"Left"===t||37===t,Home:"Home"===t||36===t,End:"End"===t||35===t,Character:isNaN(t)&&!!t.match(/^[a-zA-Z]{1}$/),Tab:"Tab"===t||9===t,Asterisk:"*"===t||56===t};return Object.keys(n).find((function(e){return!0===n[e]}))||""}catch(e){return""}}function y(e){e.preventDefault(),e.stopPropagation()}function v(e){return function(e){if(Array.isArray(e))return b(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,t){if(!e)return;if("string"==typeof e)return b(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return b(e,t)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function b(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function g(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function M(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var _=function(){function l(e){var t=e.menuElement,n=e.menuItemSelector,r=void 0===n?"li":n,o=e.menuLinkSelector,u=void 0===o?"a":o,i=e.submenuItemSelector,s=void 0===i?"":i,c=e.submenuToggleSelector,a=void 0===c?"a":c,f=e.submenuSelector,h=void 0===f?"ul":f,d=e.controllerElement,y=void 0===d?null:d,v=e.containerElement,b=void 0===v?null:v,g=e.openClass,_=void 0===g?"show":g,E=e.closeClass,w=void 0===E?"hide":E,C=e.isTopLevel,S=void 0===C||C,I=e.parentMenu,k=void 0===I?null:I,T=e.hoverType,O=void 0===T?"off":T,A=e.hoverDelay,L=void 0===A?250:A;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,l),M(this,"_MenuType",l),M(this,"_MenuItemType",p),M(this,"_MenuToggleType",m),M(this,"_dom",{menu:null,menuItems:[],submenuItems:[],submenuToggles:[],submenus:[],controller:null,container:null}),M(this,"_selectors",{menuItems:"",menuLinks:"",submenuItems:"",submenuToggles:"",submenus:""}),M(this,"_elements",{menuItems:[],submenuToggles:[],controller:null,parentMenu:null,rootMenu:null}),M(this,"_openClass","show"),M(this,"_closeClass","hide"),M(this,"_root",!0),M(this,"_currentChild",0),M(this,"_focusState","none"),M(this,"_currentEvent","none"),M(this,"_hoverType","off"),M(this,"_hoverDelay",250),this._dom.menu=t,this._dom.controller=y,this._dom.container=b,this._selectors.menuItems=r,this._selectors.menuLinks=u,this._selectors.submenuItems=s,this._selectors.submenuToggles=a,this._selectors.submenus=h,this._elements.menuItems=[],this._elements.submenuToggles=[],this._elements.controller=null,this._elements.parentMenu=k,this._elements.rootMenu=S?this:null,this._openClass=_||"",this._closeClass=w||"",this._root=S,this._hoverType=O,this._hoverDelay=L}var s,c,a;return s=l,(c=[{key:"initialize",value:function(){if(!this._validate())throw new Error("AccesibleMenu: cannot initialize menu. See other error messages for more information.");if(null===this.elements.rootMenu&&this._findRootMenu(this),this._setDOMElements(),this.isTopLevel&&this.dom.controller&&this.dom.container){var e=new this._MenuToggleType({menuToggleElement:this.dom.controller,parentElement:this.dom.container,controlledMenu:this});this._elements.controller=e}this._createChildElements()}},{key:"dom",get:function(){return this._dom}},{key:"selectors",get:function(){return this._selectors}},{key:"elements",get:function(){return this._elements}},{key:"isTopLevel",get:function(){return this._root}},{key:"openClass",get:function(){return this.isTopLevel?this._openClass:this.elements.rootMenu.openClass},set:function(e){o({openClass:e}),this._openClass!==e&&(this._openClass=e)}},{key:"closeClass",get:function(){return this.isTopLevel?this._closeClass:this.elements.rootMenu.closeClass},set:function(e){o({closeClass:e}),this._closeClass!==e&&(this._closeClass=e)}},{key:"currentChild",get:function(){return this._currentChild},set:function(e){function t(e){if(["mouse","character"].includes(e.currentEvent)&&e.elements.parentMenu)for(var t=0,n=!1;!n&&t<e.elements.parentMenu.elements.menuItems.length;){var r=e.elements.parentMenu.elements.menuItems[t];r.isSubmenuItem&&r.elements.toggle.elements.controlledMenu===e&&(n=!0,e.elements.parentMenu.currentEvent=e.currentEvent,e.elements.parentMenu.currentChild=t),t++}}n("number",{value:e}),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))}},{key:"focusState",get:function(){return this._focusState},set:function(t){!function(t){try{if("object"!==e(t)){var n=e(t);throw new TypeError("AccessibleMenu: Values given to isValidState() must be inside of an object. ".concat(n," given."))}var r=["none","self","child"];for(var o in t)if(!r.includes(t[o]))throw new TypeError("AccessibleMenu: ".concat(o," must be one of the following values: ").concat(r.join(", "),'. "').concat(t[o],'" given.'))}catch(e){return console.error(e),!1}}({value:t}),this._focusState!==t&&(this._focusState=t),this.elements.submenuToggles.length>0&&("self"===t||"none"===t)&&this.elements.submenuToggles.forEach((function(e){e.elements.controlledMenu.focusState="none"})),!this.elements.parentMenu||"self"!==t&&"child"!==t||(this.elements.parentMenu.focusState="child")}},{key:"currentEvent",get:function(){return this._currentEvent},set:function(t){!function(t){try{if("object"!==e(t)){var n=e(t);throw new TypeError("AccessibleMenu: Values given to isValidEvent() must be inside of an object. ".concat(n," given."))}var r=["none","mouse","keyboard","character"];for(var o in t)if(!r.includes(t[o]))throw new TypeError("AccessibleMenu: ".concat(o," must be one of the following values: ").concat(r.join(", "),'. "').concat(t[o],'" given.'))}catch(e){return console.error(e),!1}}({value:t}),this._currentEvent!==t&&(this._currentEvent=t,this.elements.submenuToggles.length>0&&this.elements.submenuToggles.forEach((function(e){e.elements.controlledMenu.currentEvent=t})))}},{key:"currentMenuItem",get:function(){return this.elements.menuItems[this.currentChild]}},{key:"hoverType",get:function(){return this._root?this._hoverType:this.elements.rootMenu.hoverType},set:function(e){u({value:e}),this._hoverType!==e&&(this._hoverType=e)}},{key:"hoverDelay",get:function(){return this._root?this._hoverDelay:this.elements.rootMenu.hoverDelay},set:function(e){n("number",{value:e}),this._hoverDelay!==e&&(this._hoverDelay=e)}},{key:"shouldFocus",get:function(){var e=!1;return"keyboard"!==this.currentEvent&&"character"!==this.currentEvent||(e=!0),"mouse"===this.currentEvent&&"dynamic"===this.hoverType&&(e=!0),e}},{key:"_validate",value:function(){var e=!0;return null!==this._dom.container||null!==this._dom.controller?t(HTMLElement,{menuElement:this._dom.menu,controllerElement:this._dom.controller,containerElement:this._dom.container})||(e=!1):t(HTMLElement,{menuElement:this._dom.menu})||(e=!1),""!==this._selectors.submenuItems?r({menuItemSelector:this._selectors.menuItems,menuLinkSelector:this._selectors.menuLinks,submenuItemSelector:this._selectors.submenuItems,submenuToggleSelector:this._selectors.submenuToggles,submenuSelector:this._selectors.submenus})||(e=!1):r({menuItemSelector:this._selectors.menuItems,menuLinkSelector:this._selectors.menuLinks})||(e=!1),""===this._openClass||o({openClass:this._openClass})||(e=!1),""===this._closeClass||o({closeClass:this._closeClass})||(e=!1),n("boolean",{isTopLevel:this._root})||(e=!1),null===this._elements.parentMenu||t(l,{parentMenu:this._elements.parentMenu})||(e=!1),u({hoverType:this._hoverType})||(e=!1),n("number",{hoverDelay:this._hoverDelay})||(e=!1),e}},{key:"_setDOMElementType",value:function(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.dom.menu,r=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];if("string"!=typeof this.selectors[e])throw new Error('AccessibleMenu: "'.concat(e,'" is not a valid element type within the menu.'));if(!Array.isArray(this.dom[e]))throw new Error('AccessibleMenu: The "'.concat(e,'" element cannot be set through _setDOMElementType.'));n!==this.dom.menu&&t(HTMLElement,{base:n});var o=Array.from(n.querySelectorAll(this.selectors[e])),u=o.filter((function(e){return e.parentElement===n}));this._dom[e]=r?u:[].concat(v(this._dom[e]),v(u))}},{key:"_resetDOMElementType",value:function(e){if(void 0===this.dom[e])throw new Error('AccessibleMenu: "'.concat(e,'" is not a valid element type within the menu.'));if(!Array.isArray(this.dom[e]))throw new Error('AccessibleMenu: The "'.concat(e,'" element cannot be reset through _resetDOMElementType.'));this._dom[e]=[]}},{key:"_setDOMElements",value:function(){var e=this;this._setDOMElementType("menuItems"),""!==this.selectors.submenuItems&&(this._setDOMElementType("submenuItems"),this._resetDOMElementType("submenuToggles"),this._resetDOMElementType("submenus"),this.dom.submenuItems.forEach((function(t){e._setDOMElementType("submenuToggles",t,!1),e._setDOMElementType("submenus",t,!1)})))}},{key:"_findRootMenu",value:function(e){if(e.isTopLevel)this._elements.rootMenu=e;else{if(null===e.elements.parentMenu)throw new Error("Cannot find root menu.");this._findRootMenu(e.elements.parentMenu)}}},{key:"_createChildElements",value:function(){var e=this;this.dom.menuItems.forEach((function(t){var n;if(e.dom.submenuItems.includes(t)){var r=t.querySelector(e.selectors.submenuToggles),o=t.querySelector(e.selectors.submenus),u=new e._MenuType({menuElement:o,menuItemSelector:e.selectors.menuItems,menuLinkSelector:e.selectors.menuLinks,submenuItemSelector:e.selectors.submenuItems,submenuToggleSelector:e.selectors.submenuToggles,submenuSelector:e.selectors.submenus,openClass:e.openClass,closeClass:e.closeClass,isTopLevel:!1,parentMenu:e,hoverType:e.hoverType,hoverDelay:e.hoverDelay}),i=new e._MenuToggleType({menuToggleElement:r,parentElement:t,controlledMenu:u,parentMenu:e});e._elements.submenuToggles.push(i),n=new e._MenuItemType({menuItemElement:t,menuLinkElement:r,parentMenu:e,isSubmenuItem:!0,childMenu:u,toggle:i})}else{var l=t.querySelector(e.selectors.menuLinks);n=new e._MenuItemType({menuItemElement:t,menuLinkElement:l,parentMenu:e})}e._elements.menuItems.push(n)}))}},{key:"_handleFocus",value:function(){var e=this;this.elements.menuItems.forEach((function(t,n){t.dom.link.addEventListener("focus",(function(){e.focusState="self",e.currentChild=n}))}))}},{key:"_handleClick",value:function(){var e=this,t=i("touchstart",this.dom.menu)?"touchstart":"mousedown",n=i("touchend",this.dom.menu)?"touchend":"mouseup";function r(e,t,n){y(n),t.toggle(),t.isOpen&&(e.focusState="self",t.elements.controlledMenu.focusState="none")}this.elements.menuItems.forEach((function(o,u){o.dom.link.addEventListener(t,(function(){e.currentEvent="mouse",e.elements.rootMenu.blurChildren(),e.focusChild(u)})),o.isSubmenuItem&&(o.elements.toggle.dom.toggle["on".concat(n)]=function(t){e.currentEvent="mouse",r(e,o.elements.toggle,t)})})),this.isTopLevel&&this.elements.controller&&(this.elements.controller.dom.toggle["on".concat(n)]=function(t){e.currentEvent="mouse",r(e,e.elements.controller,t)})}},{key:"_handleHover",value:function(){var e=this;this.elements.menuItems.forEach((function(t,n){t.dom.link.addEventListener("mouseenter",(function(){if("on"===e.hoverType)e.currentEvent="mouse",e.currentChild=n,t.isSubmenuItem&&t.elements.toggle.preview();else if("dynamic"===e.hoverType){var r=e.elements.submenuToggles.some((function(e){return e.isOpen}));e.currentChild=n,e.isTopLevel&&"none"===e.focusState||(e.currentEvent="mouse",e.focusCurrentChild()),!t.isSubmenuItem||e.isTopLevel&&!r||(e.currentEvent="mouse",t.elements.toggle.preview())}})),t.isSubmenuItem&&t.dom.item.addEventListener("mouseleave",(function(){"on"===e.hoverType?e.hoverDelay>0?setTimeout((function(){e.currentEvent="mouse",t.elements.toggle.close()}),e.hoverDelay):(e.currentEvent="mouse",t.elements.toggle.close()):"dynamic"===e.hoverType&&(e.isTopLevel||(e.hoverDelay>0?setTimeout((function(){e.currentEvent="mouse",t.elements.toggle.close(),e.focusCurrentChild()}),e.hoverDelay):(e.currentEvent="mouse",t.elements.toggle.close(),e.focusCurrentChild())))}))}))}},{key:"_handleKeydown",value:function(){var e=this;this.isTopLevel&&this.elements.controller&&this.elements.controller.dom.toggle.addEventListener("keydown",(function(t){e.currentEvent="keyboard";var n=d(t);"Space"!==n&&"Enter"!==n||y(t)}))}},{key:"_handleKeyup",value:function(){var e=this;this.isTopLevel&&this.elements.controller&&this.elements.controller.dom.toggle.addEventListener("keyup",(function(t){e.currentEvent="keyboard";var n=d(t);"Space"!==n&&"Enter"!==n||(y(t),e.elements.controller.open(),e.focusFirstChild())}))}},{key:"focus",value:function(){this.focusState="self",this.shouldFocus&&this.dom.menu.focus()}},{key:"blur",value:function(){this.focusState="none",this.shouldFocus&&this.dom.menu.blur()}},{key:"focusCurrentChild",value:function(){this.focusState="self",-1!==this.currentChild&&this.currentMenuItem.focus()}},{key:"focusChild",value:function(e){this.blurCurrentChild(),this.currentChild=e,this.focusCurrentChild()}},{key:"focusFirstChild",value:function(){this.focusChild(0)}},{key:"focusLastChild",value:function(){this.focusChild(this.elements.menuItems.length-1)}},{key:"focusNextChild",value:function(){this.currentChild<this.elements.menuItems.length-1?this.focusChild(this.currentChild+1):this.focusCurrentChild()}},{key:"focusPreviousChild",value:function(){this.currentChild>0?this.focusChild(this.currentChild-1):this.focusCurrentChild()}},{key:"blurCurrentChild",value:function(){this.focusState="none",-1!==this.currentChild&&this.currentMenuItem.blur()}},{key:"focusController",value:function(){this.dom.controller&&(this.shouldFocus&&this.dom.controller.focus(),this.focusState="none")}},{key:"focusContainer",value:function(){this.dom.container&&(this.shouldFocus&&this.dom.container.focus(),this.focusState="none")}},{key:"closeChildren",value:function(){this.elements.submenuToggles.forEach((function(e){return e.close()}))}},{key:"blurChildren",value:function(){this.elements.menuItems.forEach((function(e){e.blur(),e.isSubmenuItem&&e.elements.childMenu.blurChildren()}))}}])&&g(s.prototype,c),a&&g(s,a),l}();function E(e){return(E="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function w(e,t){return(w=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function C(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=I(e);if(t){var o=I(this).constructor;n=Reflect.construct(r,arguments,o)}else n=r.apply(this,arguments);return S(this,n)}}function S(e,t){return!t||"object"!==E(t)&&"function"!=typeof t?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e):t}function I(e){return(I=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}var k=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&w(e,t)}(n,e);var t=C(n);function n(e){var r,o=e.menuItemElement,u=e.menuLinkElement,i=e.parentMenu,l=e.isSubmenuItem,s=void 0!==l&&l,c=e.childMenu,a=void 0===c?null:c,m=e.toggle,f=void 0===m?null:m,h=e.initialize,p=void 0===h||h;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,n),r=t.call(this,{menuItemElement:o,menuLinkElement:u,parentMenu:i,isSubmenuItem:s,childMenu:a,toggle:f}),p&&r.initialize(),r}return n}(p);function T(e){return(T="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function O(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function A(e,t,n){return(A="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(e,t,n){var r=function(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&null!==(e=P(e)););return e}(e,t);if(r){var o=Object.getOwnPropertyDescriptor(r,t);return o.get?o.get.call(n):o.value}})(e,t,n||e)}function L(e,t){return(L=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function j(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=P(e);if(t){var o=P(this).constructor;n=Reflect.construct(r,arguments,o)}else n=r.apply(this,arguments);return R(this,n)}}function R(e,t){return!t||"object"!==T(t)&&"function"!=typeof t?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e):t}function P(e){return(P=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}var x=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&L(e,t)}(u,e);var t,n,r,o=j(u);function u(e){var t,n=e.menuToggleElement,r=e.parentElement,i=e.controlledMenu,l=e.parentMenu,s=void 0===l?null:l,c=e.initialize,a=void 0===c||c;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,u),t=o.call(this,{menuToggleElement:n,parentElement:r,controlledMenu:i,parentMenu:s}),a&&t.initialize(),t}return t=u,(n=[{key:"open",value:function(){this.closeSiblings(),A(P(u.prototype),"open",this).call(this)}},{key:"preview",value:function(){this.closeSiblings(),A(P(u.prototype),"preview",this).call(this)}},{key:"close",value:function(){this.isOpen&&this.closeChildren(),A(P(u.prototype),"close",this).call(this)}}])&&O(t.prototype,n),r&&O(t,r),u}(m);function D(e){return(D="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function z(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function K(e,t,n){return(K="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(e,t,n){var r=function(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&null!==(e=U(e)););return e}(e,t);if(r){var o=Object.getOwnPropertyDescriptor(r,t);return o.get?o.get.call(n):o.value}})(e,t,n||e)}function F(e,t){return(F=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function N(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=U(e);if(t){var o=U(this).constructor;n=Reflect.construct(r,arguments,o)}else n=r.apply(this,arguments);return H(this,n)}}function H(e,t){return!t||"object"!==D(t)&&"function"!=typeof t?B(e):t}function B(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function U(e){return(U=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function V(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var q=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&F(e,t)}(l,e);var t,r,o,u=N(l);function l(e){var t,n=e.menuElement,r=e.menuItemSelector,o=void 0===r?"li":r,i=e.menuLinkSelector,s=void 0===i?"a":i,c=e.submenuItemSelector,a=void 0===c?"":c,m=e.submenuToggleSelector,f=void 0===m?"a":m,h=e.submenuSelector,p=void 0===h?"ul":h,d=e.controllerElement,y=void 0===d?null:d,v=e.containerElement,b=void 0===v?null:v,g=e.openClass,M=void 0===g?"show":g,_=e.closeClass,E=void 0===_?"hide":_,w=e.isTopLevel,C=void 0===w||w,S=e.parentMenu,I=void 0===S?null:S,T=e.hoverType,O=void 0===T?"off":T,A=e.hoverDelay,L=void 0===A?250:A,j=e.optionalKeySupport,R=void 0!==j&&j,P=e.initialize,D=void 0===P||P;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,l),V(B(t=u.call(this,{menuElement:n,menuItemSelector:o,menuLinkSelector:s,submenuItemSelector:a,submenuToggleSelector:f,submenuSelector:p,controllerElement:y,containerElement:b,openClass:M,closeClass:E,isTopLevel:C,parentMenu:I,hoverType:O,hoverDelay:L})),"_MenuType",l),V(B(t),"_MenuItemType",k),V(B(t),"_MenuToggleType",x),V(B(t),"_currentChild",-1),V(B(t),"_optionalSupport",!1),t._optionalSupport=R,D&&t.initialize(),t}return t=l,(r=[{key:"initialize",value:function(){try{K(U(l.prototype),"initialize",this).call(this),this._handleFocus(),this._handleClick(),this._handleHover(),this._handleKeydown(),this._handleKeyup()}catch(e){console.error(e)}}},{key:"optionalKeySupport",get:function(){return this.isTopLevel?this._optionalSupport:this.elements.rootMenu.optionalKeySupport},set:function(e){n("boolean",{optionalKeySupport:e}),this._optionalSupport=e}},{key:"_validate",value:function(){var e=K(U(l.prototype),"_validate",this).call(this);return n("boolean",{optionalKeySupport:this._optionalSupport})||(e=!1),e}},{key:"_handleClick",value:function(){var e=this;K(U(l.prototype),"_handleClick",this).call(this);var t=i("touchend",this.dom.menu)?"touchend":"mouseup";document.addEventListener(t,(function(t){"none"!==e.focusState&&(e.currentEvent="mouse",e.dom.menu.contains(t.target)||!e.dom.menu===t.target||(e.closeChildren(),e.blur(),e.elements.controller&&e.elements.controller.close()))}))}},{key:"_handleKeydown",value:function(){var e=this;K(U(l.prototype),"_handleKeydown",this).call(this),this.dom.menu.addEventListener("keydown",(function(t){e.currentEvent="keyboard";var n=d(t);"self"===e.focusState&&(e.optionalKeySupport?["ArrowUp","ArrowRight","ArrowDown","ArrowLeft","Home","End"].includes(n)&&y(t):(e.currentMenuItem.isSubmenuItem&&["Space","Enter"].includes(n)||e.elements.controller&&["Escape"].includes(n)||e.elements.parentMenu&&["Escape"].includes(n))&&y(t))}))}},{key:"_handleKeyup",value:function(){var e=this;K(U(l.prototype),"_handleKeyup",this).call(this),this.dom.menu.addEventListener("keyup",(function(t){e.currentEvent="keyboard";var n=d(t);"self"===e.focusState&&("Space"===n||"Enter"===n?e.currentMenuItem.isSubmenuItem?(y(t),e.currentMenuItem.elements.toggle.preview()):e.currentMenuItem.dom.link.click():"Escape"===n?e.elements.submenuToggles.some((function(e){return e.isOpen}))?(y(t),e.closeChildren()):e.elements.parentMenu?(y(t),e.elements.parentMenu.currentEvent=e.currentEvent,e.elements.parentMenu.closeChildren(),e.elements.parentMenu.focusCurrentChild()):e.isTopLevel&&e.elements.controller&&e.elements.controller.isOpen&&(e.elements.controller.close(),e.focusController()):e.optionalKeySupport&&("ArrowDown"===n||"ArrowRight"===n?(y(t),e.currentMenuItem.isSubmenuItem&&e.currentMenuItem.elements.toggle.isOpen?(e.currentMenuItem.elements.childMenu.currentEvent="keyboard",e.currentMenuItem.elements.childMenu.focusFirstChild()):e.focusNextChild()):"ArrowUp"===n||"ArrowLeft"===n?(y(t),e.focusPreviousChild()):"Home"===n?(y(t),e.focusFirstChild()):"End"===n&&(y(t),e.focusLastChild())))}))}}])&&z(t.prototype,r),o&&z(t,o),l}(_);function W(e){return(W="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function $(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function Z(e,t,n){return(Z="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(e,t,n){var r=function(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&null!==(e=X(e)););return e}(e,t);if(r){var o=Object.getOwnPropertyDescriptor(r,t);return o.get?o.get.call(n):o.value}})(e,t,n||e)}function G(e,t){return(G=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function J(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=X(e);if(t){var o=X(this).constructor;n=Reflect.construct(r,arguments,o)}else n=r.apply(this,arguments);return Q(this,n)}}function Q(e,t){return!t||"object"!==W(t)&&"function"!=typeof t?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e):t}function X(e){return(X=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}var Y=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&G(e,t)}(u,e);var t,n,r,o=J(u);function u(e){var t,n=e.menuItemElement,r=e.menuLinkElement,i=e.parentMenu,l=e.isSubmenuItem,s=void 0!==l&&l,c=e.childMenu,a=void 0===c?null:c,m=e.toggle,f=void 0===m?null:m,h=e.initialize,p=void 0===h||h;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,u),t=o.call(this,{menuItemElement:n,menuLinkElement:r,parentMenu:i,isSubmenuItem:s,childMenu:a,toggle:f}),p&&t.initialize(),t}return t=u,(n=[{key:"initialize",value:function(){Z(X(u.prototype),"initialize",this).call(this),this.dom.item.setAttribute("role","none"),this.dom.link.setAttribute("role","menuitem"),this.dom.link.tabIndex=-1}},{key:"focus",value:function(){Z(X(u.prototype),"focus",this).call(this),this.elements.parentMenu.isTopLevel&&(this.dom.link.tabIndex=0)}},{key:"blur",value:function(){Z(X(u.prototype),"blur",this).call(this),this.elements.parentMenu.isTopLevel&&(this.dom.link.tabIndex=-1)}}])&&$(t.prototype,n),r&&$(t,r),u}(p);function ee(e){return(ee="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function te(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function ne(e,t,n){return(ne="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(e,t,n){var r=function(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&null!==(e=ie(e)););return e}(e,t);if(r){var o=Object.getOwnPropertyDescriptor(r,t);return o.get?o.get.call(n):o.value}})(e,t,n||e)}function re(e,t){return(re=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function oe(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=ie(e);if(t){var o=ie(this).constructor;n=Reflect.construct(r,arguments,o)}else n=r.apply(this,arguments);return ue(this,n)}}function ue(e,t){return!t||"object"!==ee(t)&&"function"!=typeof t?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e):t}function ie(e){return(ie=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}var le=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&re(e,t)}(u,e);var t,n,r,o=oe(u);function u(e){var t,n=e.menuToggleElement,r=e.parentElement,i=e.controlledMenu,l=e.parentMenu,s=void 0===l?null:l,c=e.initialize,a=void 0===c||c;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,u),t=o.call(this,{menuToggleElement:n,parentElement:r,controlledMenu:i,parentMenu:s}),a&&t.initialize(),t}return t=u,(n=[{key:"open",value:function(){this.closeSiblings(),ne(ie(u.prototype),"open",this).call(this)}},{key:"preview",value:function(){this.closeSiblings(),ne(ie(u.prototype),"preview",this).call(this)}},{key:"close",value:function(){this.isOpen&&this.closeChildren(),ne(ie(u.prototype),"close",this).call(this)}}])&&te(t.prototype,n),r&&te(t,r),u}(m);function se(e){return(se="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function ce(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function ae(e,t,n){return(ae="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(e,t,n){var r=function(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&null!==(e=de(e)););return e}(e,t);if(r){var o=Object.getOwnPropertyDescriptor(r,t);return o.get?o.get.call(n):o.value}})(e,t,n||e)}function me(e,t){return(me=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function fe(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=de(e);if(t){var o=de(this).constructor;n=Reflect.construct(r,arguments,o)}else n=r.apply(this,arguments);return he(this,n)}}function he(e,t){return!t||"object"!==se(t)&&"function"!=typeof t?pe(e):t}function pe(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function de(e){return(de=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function ye(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var ve=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&me(e,t)}(u,e);var t,n,r,o=fe(u);function u(e){var t,n=e.menuElement,r=e.menuItemSelector,i=void 0===r?"li":r,l=e.menuLinkSelector,s=void 0===l?"a":l,c=e.submenuItemSelector,a=void 0===c?"":c,m=e.submenuToggleSelector,f=void 0===m?"a":m,h=e.submenuSelector,p=void 0===h?"ul":h,d=e.controllerElement,y=void 0===d?null:d,v=e.containerElement,b=void 0===v?null:v,g=e.openClass,M=void 0===g?"show":g,_=e.closeClass,E=void 0===_?"hide":_,w=e.isTopLevel,C=void 0===w||w,S=e.parentMenu,I=void 0===S?null:S,k=e.hoverType,T=void 0===k?"off":k,O=e.hoverDelay,A=void 0===O?250:O,L=e.initialize,j=void 0===L||L;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,u),ye(pe(t=o.call(this,{menuElement:n,menuItemSelector:i,menuLinkSelector:s,submenuItemSelector:a,submenuToggleSelector:f,submenuSelector:p,controllerElement:y,containerElement:b,openClass:M,closeClass:E,isTopLevel:C,parentMenu:I,hoverType:T,hoverDelay:A})),"_MenuType",u),ye(pe(t),"_MenuItemType",Y),ye(pe(t),"_MenuToggleType",le),j&&t.initialize(),t}return t=u,(n=[{key:"initialize",value:function(){try{ae(de(u.prototype),"initialize",this).call(this),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)}}},{key:"_handleClick",value:function(){var e=this;ae(de(u.prototype),"_handleClick",this).call(this);var t=i("touchend",this.dom.menu)?"touchend":"mouseup";document.addEventListener(t,(function(t){"none"!==e.focusState&&(e.currentEvent="mouse",e.dom.menu.contains(t.target)||!e.dom.menu===t.target||(e.closeChildren(),e.blur(),e.elements.controller&&e.elements.controller.close()))}))}},{key:"_handleKeydown",value:function(){var e=this;ae(de(u.prototype),"_handleKeydown",this).call(this),this.dom.menu.addEventListener("keydown",(function(t){e.currentEvent="keyboard";var n=d(t);"Tab"===n&&("none"!==e.elements.rootMenu.focusState?(e.elements.rootMenu.blur(),e.elements.rootMenu.closeChildren()):e.elements.rootMenu.focus()),"Character"===n?y(t):e.isTopLevel?"self"===e.focusState&&(["ArrowRight","ArrowLeft","Home","End"].includes(n)||e.currentMenuItem.isSubmenuItem&&["Space","Enter","ArrowDown","ArrowUp"].includes(n)||e.elements.controller&&["Escape"].includes(n))&&y(t):(["Escape","ArrowRight","ArrowLeft","ArrowDown","ArrowUp","Home","End"].includes(n)||e.currentMenuItem.isSubmenuItem&&["Space","Enter"].includes(n))&&y(t)}))}},{key:"_handleKeyup",value:function(){var e=this;ae(de(u.prototype),"_handleKeyup",this).call(this),this.dom.menu.addEventListener("keyup",(function(t){e.currentEvent="keyboard";var n=d(t),r=t.altKey,o=t.crtlKey,u=t.metaKey;if("Character"!==n||r||o||u)if(e.isTopLevel){if("self"===e.focusState)if("Space"===n||"Enter"===n)e.currentMenuItem.isSubmenuItem?(y(t),e.currentMenuItem.elements.childMenu.currentEvent="keyboard",e.currentMenuItem.elements.toggle.open(),requestAnimationFrame((function(){e.currentMenuItem.elements.childMenu.focusFirstChild()}))):e.currentMenuItem.dom.link.click();else if("ArrowRight"===n){y(t);var i=e.currentMenuItem.isSubmenuItem&&e.currentMenuItem.elements.toggle.isOpen;e.focusNextChild(),i&&(e.currentMenuItem.isSubmenuItem?(e.currentMenuItem.elements.childMenu.currentEvent="keyboard",e.currentMenuItem.elements.toggle.preview()):e.closeChildren())}else if("ArrowLeft"===n){y(t);var l=e.currentMenuItem.isSubmenuItem&&e.currentMenuItem.elements.toggle.isOpen;e.focusPreviousChild(),l&&(e.currentMenuItem.isSubmenuItem?(e.currentMenuItem.elements.childMenu.currentEvent="keyboard",e.currentMenuItem.elements.toggle.preview()):e.closeChildren())}else"ArrowDown"===n?e.currentMenuItem.isSubmenuItem&&(y(t),e.currentMenuItem.elements.childMenu.currentEvent="keyboard",e.currentMenuItem.elements.toggle.open(),requestAnimationFrame((function(){e.currentMenuItem.elements.childMenu.focusFirstChild()}))):"ArrowUp"===n?e.currentMenuItem.isSubmenuItem&&(y(t),e.currentMenuItem.elements.childMenu.currentEvent="keyboard",e.currentMenuItem.elements.toggle.open(),requestAnimationFrame((function(){e.currentMenuItem.elements.childMenu.focusLastChild()}))):"Home"===n?(y(t),e.focusFirstChild()):"End"===n?(y(t),e.focusLastChild()):"Escape"===n&&(e.elements.submenuToggles.some((function(e){return e.isOpen}))?(y(t),e.closeChildren()):e.isTopLevel&&e.elements.controller&&e.elements.controller.isOpen&&(y(t),e.elements.controller.close(),e.focusController()))}else"Space"===n||"Enter"===n?e.currentMenuItem.isSubmenuItem&&(y(t),e.currentMenuItem.elements.childMenu.currentEvent="keyboard",e.currentMenuItem.elements.toggle.open(),requestAnimationFrame((function(){e.currentMenuItem.elements.childMenu.focusFirstChild()}))):"Escape"===n?(y(t),e.elements.rootMenu.closeChildren(),e.elements.rootMenu.focusCurrentChild()):"ArrowRight"===n?e.currentMenuItem.isSubmenuItem?(y(t),e.currentMenuItem.elements.childMenu.currentEvent="keyboard",e.currentMenuItem.elements.toggle.open(),requestAnimationFrame((function(){e.currentMenuItem.elements.childMenu.focusFirstChild()}))):(y(t),e.elements.rootMenu.closeChildren(),e.elements.rootMenu.focusNextChild(),e.elements.rootMenu.currentMenuItem.isSubmenuItem&&e.elements.rootMenu.currentMenuItem.elements.toggle.preview()):"ArrowLeft"===n?e.elements.parentMenu.currentMenuItem.isSubmenuItem&&(y(t),e.elements.parentMenu.currentMenuItem.elements.toggle.close(),e.elements.parentMenu.focusCurrentChild(),e.elements.parentMenu===e.elements.rootMenu&&(e.elements.rootMenu.closeChildren(),e.elements.rootMenu.focusPreviousChild(),e.elements.rootMenu.currentMenuItem.isSubmenuItem&&(e.elements.rootMenu.currentMenuItem.elements.childMenu.currentEvent="keyboard",e.elements.rootMenu.currentMenuItem.elements.toggle.preview()))):"ArrowDown"===n?(y(t),e.focusNextChild()):"ArrowUp"===n?(y(t),e.focusPreviousChild()):"Home"===n?(y(t),e.focusFirstChild()):"End"===n&&(y(t),e.focusLastChild());else y(t),e.elements.rootMenu.currentEvent="character",e.focusNextChildWithCharacter(t.key)}))}},{key:"focusNextChild",value:function(){this.currentChild===this.elements.menuItems.length-1?this.focusFirstChild():this.focusChild(this.currentChild+1)}},{key:"focusPreviousChild",value:function(){0===this.currentChild?this.focusLastChild():this.focusChild(this.currentChild-1)}},{key:"focusNextChildWithCharacter",value:function(e){for(var t=e.toLowerCase(),n=this.currentChild+1,r=!1;!r&&n<this.elements.menuItems.length;)(this.elements.menuItems[n].dom.item.innerText?this.elements.menuItems[n].dom.item.innerText:this.elements.menuItems[n].dom.item.textContent).replace(/[\s]/g,"").toLowerCase().charAt(0)===t&&(r=!0,this.focusChild(n)),n++}}])&&ce(t.prototype,n),r&&ce(t,r),u}(_);function be(e){return(be="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function ge(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function Me(e,t,n){return(Me="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(e,t,n){var r=function(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&null!==(e=Ce(e)););return e}(e,t);if(r){var o=Object.getOwnPropertyDescriptor(r,t);return o.get?o.get.call(n):o.value}})(e,t,n||e)}function _e(e,t){return(_e=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function Ee(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=Ce(e);if(t){var o=Ce(this).constructor;n=Reflect.construct(r,arguments,o)}else n=r.apply(this,arguments);return we(this,n)}}function we(e,t){return!t||"object"!==be(t)&&"function"!=typeof t?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e):t}function Ce(e){return(Ce=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}var Se=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&_e(e,t)}(u,e);var t,n,r,o=Ee(u);function u(e){var t,n=e.menuItemElement,r=e.menuLinkElement,i=e.parentMenu,l=e.isSubmenuItem,s=void 0!==l&&l,c=e.childMenu,a=void 0===c?null:c,m=e.toggle,f=void 0===m?null:m,h=e.initialize,p=void 0===h||h;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,u),t=o.call(this,{menuItemElement:n,menuLinkElement:r,parentMenu:i,isSubmenuItem:s,childMenu:a,toggle:f}),p&&t.initialize(),t}return t=u,(n=[{key:"initialize",value:function(){Me(Ce(u.prototype),"initialize",this).call(this),this.dom.item.setAttribute("role","none"),this.dom.link.setAttribute("role","treeitem"),this.dom.link.tabIndex=-1}},{key:"focus",value:function(){Me(Ce(u.prototype),"focus",this).call(this),this.dom.link.tabIndex=0}},{key:"blur",value:function(){Me(Ce(u.prototype),"blur",this).call(this),this.dom.link.tabIndex=-1}}])&&ge(t.prototype,n),r&&ge(t,r),u}(p);function Ie(e){return(Ie="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function ke(e,t){return(ke=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function Te(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=Ae(e);if(t){var o=Ae(this).constructor;n=Reflect.construct(r,arguments,o)}else n=r.apply(this,arguments);return Oe(this,n)}}function Oe(e,t){return!t||"object"!==Ie(t)&&"function"!=typeof t?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e):t}function Ae(e){return(Ae=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}var Le=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&ke(e,t)}(n,e);var t=Te(n);function n(e){var r,o=e.menuToggleElement,u=e.parentElement,i=e.controlledMenu,l=e.parentMenu,s=void 0===l?null:l,c=e.initialize,a=void 0===c||c;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,n),r=t.call(this,{menuToggleElement:o,parentElement:u,controlledMenu:i,parentMenu:s}),a&&r.initialize(),r}return n}(m);function je(e){return(je="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function Re(e){return function(e){if(Array.isArray(e))return Pe(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,t){if(!e)return;if("string"==typeof e)return Pe(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return Pe(e,t)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Pe(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function xe(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function De(e,t,n){return(De="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(e,t,n){var r=function(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&null!==(e=He(e)););return e}(e,t);if(r){var o=Object.getOwnPropertyDescriptor(r,t);return o.get?o.get.call(n):o.value}})(e,t,n||e)}function ze(e,t){return(ze=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function Ke(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=He(e);if(t){var o=He(this).constructor;n=Reflect.construct(r,arguments,o)}else n=r.apply(this,arguments);return Fe(this,n)}}function Fe(e,t){return!t||"object"!==je(t)&&"function"!=typeof t?Ne(e):t}function Ne(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function He(e){return(He=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function Be(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}return{DisclosureMenu:q,Menubar:ve,Treeview:function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&ze(e,t)}(u,e);var t,n,r,o=Ke(u);function u(e){var t,n=e.menuElement,r=e.menuItemSelector,i=void 0===r?"li":r,l=e.menuLinkSelector,s=void 0===l?"a":l,c=e.submenuItemSelector,a=void 0===c?"":c,m=e.submenuToggleSelector,f=void 0===m?"a":m,h=e.submenuSelector,p=void 0===h?"ul":h,d=e.controllerElement,y=void 0===d?null:d,v=e.containerElement,b=void 0===v?null:v,g=e.openClass,M=void 0===g?"show":g,_=e.closeClass,E=void 0===_?"hide":_,w=e.isTopLevel,C=void 0===w||w,S=e.parentMenu,I=void 0===S?null:S,k=e.hoverType,T=void 0===k?"off":k,O=e.hoverDelay,A=void 0===O?250:O,L=e.initialize,j=void 0===L||L;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,u),Be(Ne(t=o.call(this,{menuElement:n,menuItemSelector:i,menuLinkSelector:s,submenuItemSelector:a,submenuToggleSelector:f,submenuSelector:p,controllerElement:y,containerElement:b,openClass:M,closeClass:E,isTopLevel:C,parentMenu:I,hoverType:T,hoverDelay:A})),"_MenuType",u),Be(Ne(t),"_MenuItemType",Se),Be(Ne(t),"_MenuToggleType",Le),j&&t.initialize(),t}return t=u,(n=[{key:"initialize",value:function(){try{De(He(u.prototype),"initialize",this).call(this),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)}}},{key:"_handleKeydown",value:function(){var e=this;De(He(u.prototype),"_handleKeydown",this).call(this),this.dom.menu.addEventListener("keydown",(function(t){e.currentEvent="keyboard";var n=d(t);"Tab"===n&&("none"!==e.elements.rootMenu.focusState?e.elements.rootMenu.blur():e.elements.rootMenu.focus()),"self"===e.focusState&&(["Space","ArrowUp","ArrowDown","ArrowLeft","Asterisk","Home","End"].includes(n)||e.currentMenuItem.isSubmenuItem&&["Enter","ArrowRight"].includes(n)||e.elements.controller&&["Escape"].includes(n))&&y(t)}))}},{key:"_handleKeyup",value:function(){var e=this;De(He(u.prototype),"_handleKeyup",this).call(this),this.dom.menu.addEventListener("keyup",(function(t){e.currentEvent="keyboard";var n=d(t),r=t.altKey,o=t.crtlKey,u=t.metaKey;if("Character"!==n||r||o||u){if("self"===e.focusState)if("Enter"===n||"Space"===n)y(t),e.currentMenuItem.isSubmenuItem?e.currentMenuItem.elements.toggle.isOpen?e.currentMenuItem.elements.toggle.close():e.currentMenuItem.elements.toggle.preview():e.currentMenuItem.dom.link.click();else if("Escape"===n)e.isTopLevel&&e.elements.controller&&e.elements.controller.isOpen&&(e.elements.controller.close(),e.focusController());else if("ArrowDown"===n)y(t),e.currentMenuItem.isSubmenuItem&&e.currentMenuItem.elements.toggle.isOpen?(e.blurCurrentChild(),e.currentMenuItem.elements.childMenu.currentEvent=e.currentEvent,e.currentMenuItem.elements.childMenu.focusFirstChild()):e.isTopLevel||e.currentChild!==e.elements.menuItems.length-1?e.focusNextChild():e.focusParentsNextChild();else if("ArrowUp"===n){y(t);var i=e.elements.menuItems[e.currentChild-1];i&&i.isSubmenuItem&&i.elements.toggle.isOpen?(e.blurCurrentChild(),e.currentChild=e.currentChild-1,e.currentMenuItem.elements.childMenu.currentEvent=e.currentEvent,e.focusChildsLastNode()):e.isTopLevel||0!==e.currentChild?e.focusPreviousChild():(e.blurCurrentChild(),e.elements.parentMenu.currentEvent=e.currentEvent,e.elements.parentMenu.focusCurrentChild())}else"ArrowRight"===n?e.currentMenuItem.isSubmenuItem&&(y(t),e.currentMenuItem.elements.toggle.isOpen?(e.blurCurrentChild(),e.currentMenuItem.elements.childMenu.currentEvent=e.currentEvent,e.currentMenuItem.elements.childMenu.focusFirstChild()):e.currentMenuItem.elements.toggle.preview()):"ArrowLeft"===n?(y(t),e.currentMenuItem.isSubmenuItem&&e.currentMenuItem.elements.toggle.isOpen?(e.currentMenuItem.elements.childMenu.blurCurrentChild(),e.currentMenuItem.elements.toggle.close()):e.isTopLevel||(e.blurCurrentChild(),e.elements.parentMenu.currentEvent=e.currentEvent,e.elements.parentMenu.focusCurrentChild())):"Home"===n?(y(t),e.blurCurrentChild(),e.elements.rootMenu.focusFirstChild()):"End"===n?(y(t),e.blurCurrentChild(),e.elements.rootMenu.focusLastNode()):"Asterisk"===n&&(y(t),e.openChildren())}else y(t),e.elements.rootMenu.currentEvent="character",e.focusNextNodeWithCharacter(t.key)}))}},{key:"focusLastNode",value:function(){var e=this.elements.menuItems.length-1,t=this.elements.menuItems[e];t.isSubmenuItem&&t.elements.toggle.isOpen?(this.currentChild=e,t.elements.childMenu.currentEvent=this.currentEvent,t.elements.childMenu.focusLastNode()):this.focusLastChild()}},{key:"openChildren",value:function(){this.elements.submenuToggles.forEach((function(e){return e.preview()}))}},{key:"focusNextNodeWithCharacter",value:function(e){for(var t=e.toLowerCase(),n=function e(t){var n=[];return t.elements.menuItems.forEach((function(t){n.push(t),t.isSubmenuItem&&t.elements.toggle.isOpen&&(n=[].concat(Re(n),Re(e(t.elements.toggle.elements.controlledMenu))))})),n}(this.elements.rootMenu),r=n.indexOf(this.currentMenuItem)+1,o=[].concat(Re(n.slice(r)),Re(n.slice(0,r))),u=0,i=!1;!i&&u<o.length;){if((o[u].dom.item.innerText?o[u].dom.item.innerText:o[u].dom.item.textContent).replace(/[\s]/g,"").toLowerCase().charAt(0)===t){i=!0;var l=o[u].elements.parentMenu,s=l.elements.menuItems.indexOf(o[u]);this.elements.rootMenu.blurChildren(),l.focusChild(s)}u++}}},{key:"focusParentsNextChild",value:function(){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()))}},{key:"focusChildsLastNode",value:function(){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())}}])&&xe(t.prototype,n),r&&xe(t,r),u}(_)}}();
var AccessibleMenu=function(){"use strict";function e(t){return e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},e(t)}function t(t,n){try{if("object"!==e(n)){var r=e(n);throw new TypeError("AccessibleMenu: Elements given to isValidInstance() must be inside of an object. ".concat(r," given."))}for(var o in n)if(!(n[o]instanceof t)){var u=e(n[o]);throw new TypeError("AccessibleMenu: ".concat(o," must be an instance of ").concat(t.name,". ").concat(u," given."))}return!0}catch(e){return console.error(e),!1}}function n(t,n){try{if("object"!==e(n)){var r=e(n);throw new TypeError("AccessibleMenu: Values given to isValidType() must be inside of an object. ".concat(r," given."))}for(var o in n){var u=e(n[o]);if(u!==t)throw new TypeError("AccessibleMenu: ".concat(o," must be a ").concat(t,". ").concat(u," given."))}return!0}catch(e){return console.error(e),!1}}function r(t){try{if("object"!==e(t)){var n=e(t);throw new TypeError("AccessibleMenu: Values given to isCSSSelector() must be inside of an object. ".concat(n," given."))}for(var r in t)try{if(null===t[r])throw new Error;document.querySelector(t[r])}catch(e){throw new TypeError("AccessibleMenu: ".concat(r,' must be a valid CSS selector. "').concat(t[r],'" given.'))}return!0}catch(e){return console.error(e),!1}}function o(t){try{if("object"!==e(t)||Array.isArray(t)){var n=e(t);throw new TypeError("AccessibleMenu: Values given to isValidClassList() must be inside of an object. ".concat(n," given."))}var o=function(n){var o=e(t[n]);if("string"!==o){if(!Array.isArray(t[n]))throw new TypeError("AccessibleMenu: ".concat(n," must be a string or an array of strings. ").concat(o," given."));t[n].forEach((function(e){if("string"!=typeof e)throw new TypeError("AccessibleMenu: ".concat(n," must be a string or an array of strings. An array containing non-strings given."))}))}else{var u={};u[n]=t[n],r(u)}};for(var u in t)o(u);return!0}catch(e){return console.error(e),!1}}function u(t){try{if("object"!==e(t)){var n=e(t);throw new TypeError("AccessibleMenu: Values given to isValidHoverType() must be inside of an object. ".concat(n," given."))}var r=["off","on","dynamic"];for(var o in t)if(!r.includes(t[o]))throw new TypeError("AccessibleMenu: ".concat(o," must be one of the following values: ").concat(r.join(", "),'. "').concat(t[o],'" given.'));return!0}catch(e){return console.error(e),!1}}function i(e){return function(e){if(Array.isArray(e))return l(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,t){if(!e)return;if("string"==typeof e)return l(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return l(e,t)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function l(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function s(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function c(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var a=function(){function e(t){var n=t.menuToggleElement,r=t.parentElement,o=t.controlledMenu,u=t.parentMenu,i=void 0===u?null:u;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),c(this,"_dom",{toggle:null,parent:null}),c(this,"_elements",{controlledMenu:null,parentMenu:null}),c(this,"_open",!1),c(this,"_expandEvent",new CustomEvent("accessibleMenuExpand",{bubbles:!0,detail:{toggle:this}})),c(this,"_collapseEvent",new CustomEvent("accessibleMenuCollapse",{bubbles:!0,detail:{toggle:this}})),this._dom.toggle=n,this._dom.parent=r,this._elements.controlledMenu=o,this._elements.parentMenu=i}var r,o,u;return r=e,o=[{key:"initialize",value:function(){if(this.dom.toggle.setAttribute("aria-haspopup","true"),this.dom.toggle.setAttribute("aria-expanded","false"),function(e,r){if(n("string",{tagName:e})&&t(HTMLElement,r)){var o=e.toLowerCase(),u=!0;for(var i in r)r[i].tagName.toLowerCase()!==o&&(u=!1);return u}return!1}("button",{toggle:this.dom.toggle})||this.dom.toggle.setAttribute("role","button"),""===this.dom.toggle.id||""===this.elements.controlledMenu.dom.menu.id){var e=Math.random().toString(36).replace(/[^a-z]+/g,"").substr(0,10),r=this.dom.toggle.innerText.replace(/[^a-zA-Z0-9\s]/g,""),o=e;!r.replace(/\s/g,"").length&&this.dom.toggle.getAttribute("aria-label")&&(r=this.dom.toggle.getAttribute("aria-label").replace(/[^a-zA-Z0-9\s]/g,"")),r.replace(/\s/g,"").length>0&&((r=r.toLowerCase().replace(/\s+/g,"-")).startsWith("-")&&(r=r.substring(1)),r.endsWith("-")&&(r=r.slice(0,-1)),o="".concat(r,"-").concat(o)),this.dom.toggle.id=this.dom.toggle.id||"".concat(o,"-menu-button"),this.elements.controlledMenu.dom.menu.id=this.elements.controlledMenu.dom.menu.id||"".concat(o,"-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)}},{key:"dom",get:function(){return this._dom}},{key:"elements",get:function(){return this._elements}},{key:"isOpen",get:function(){return this._open},set:function(e){n("boolean",{value:e}),this._open=e}},{key:"_expand",value:function(){var e,t,n=!(arguments.length>0&&void 0!==arguments[0])||arguments[0],r=this.elements.controlledMenu,o=r.closeClass,u=r.openClass;this.dom.toggle.setAttribute("aria-expanded","true"),""!==u&&("string"==typeof u?this.elements.controlledMenu.dom.menu.classList.add(u):(e=this.elements.controlledMenu.dom.menu.classList).add.apply(e,i(u))),""!==o&&("string"==typeof o?this.elements.controlledMenu.dom.menu.classList.remove(o):(t=this.elements.controlledMenu.dom.menu.classList).remove.apply(t,i(o))),n&&this.dom.toggle.dispatchEvent(this._expandEvent)}},{key:"_collapse",value:function(){var e,t,n=!(arguments.length>0&&void 0!==arguments[0])||arguments[0],r=this.elements.controlledMenu,o=r.closeClass,u=r.openClass;this.dom.toggle.setAttribute("aria-expanded","false"),""!==o&&("string"==typeof o?this.elements.controlledMenu.dom.menu.classList.add(o):(e=this.elements.controlledMenu.dom.menu.classList).add.apply(e,i(o))),""!==u&&("string"==typeof u?this.elements.controlledMenu.dom.menu.classList.remove(u):(t=this.elements.controlledMenu.dom.menu.classList).remove.apply(t,i(u))),n&&this.dom.toggle.dispatchEvent(this._collapseEvent)}},{key:"open",value:function(){this.elements.controlledMenu.focusState="self",this._expand(),this.isOpen=!0}},{key:"preview",value:function(){this.elements.parentMenu&&(this.elements.parentMenu.focusState="self"),this._expand(),this.isOpen=!0}},{key:"close",value:function(){this.isOpen&&(this.elements.controlledMenu.currentChild=0,this.elements.controlledMenu.blur(),this.elements.parentMenu&&(this.elements.parentMenu.focusState="self"),this._collapse(),this.isOpen=!1)}},{key:"toggle",value:function(){this.isOpen?this.close():this.open()}},{key:"closeSiblings",value:function(){var e=this;this.elements.parentMenu&&this.elements.parentMenu.elements.submenuToggles.forEach((function(t){t!==e&&t.close()}))}},{key:"closeChildren",value:function(){this.elements.controlledMenu.elements.submenuToggles.forEach((function(e){return e.close()}))}}],o&&s(r.prototype,o),u&&s(r,u),e}();function m(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function f(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var h=function(){function e(t){var n=t.menuItemElement,r=t.menuLinkElement,o=t.parentMenu,u=t.isSubmenuItem,i=void 0!==u&&u,l=t.childMenu,s=void 0===l?null:l,c=t.toggle,a=void 0===c?null:c;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),f(this,"_dom",{item:null,link:null}),f(this,"_elements",{parentMenu:null,childMenu:null,toggle:null}),f(this,"_submenu",!1),this._dom.item=n,this._dom.link=r,this._elements.parentMenu=o,this._elements.childMenu=s,this._elements.toggle=a,this._submenu=i}var t,n,r;return t=e,(n=[{key:"initialize",value:function(){}},{key:"dom",get:function(){return this._dom}},{key:"elements",get:function(){return this._elements}},{key:"isSubmenuItem",get:function(){return this._submenu}},{key:"focus",value:function(){this.elements.parentMenu.shouldFocus&&this.dom.link.focus()}},{key:"blur",value:function(){this.elements.parentMenu.shouldFocus&&this.dom.link.blur()}}])&&m(t.prototype,n),r&&m(t,r),e}();function p(e){try{var t=e.key||e.keyCode,n={Enter:"Enter"===t||13===t,Space:" "===t||"Spacebar"===t||32===t,Escape:"Escape"===t||"Esc"===t||27===t,ArrowUp:"ArrowUp"===t||"Up"===t||38===t,ArrowRight:"ArrowRight"===t||"Right"===t||39===t,ArrowDown:"ArrowDown"===t||"Down"===t||40===t,ArrowLeft:"ArrowLeft"===t||"Left"===t||37===t,Home:"Home"===t||36===t,End:"End"===t||35===t,Character:isNaN(t)&&!!t.match(/^[a-zA-Z]{1}$/),Tab:"Tab"===t||9===t,Asterisk:"*"===t||56===t};return Object.keys(n).find((function(e){return!0===n[e]}))||""}catch(e){return""}}function d(e){e.preventDefault(),e.stopPropagation()}function y(e){return function(e){if(Array.isArray(e))return v(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,t){if(!e)return;if("string"==typeof e)return v(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return v(e,t)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function v(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function b(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function g(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var M=function(){function i(e){var t=e.menuElement,n=e.menuItemSelector,r=void 0===n?"li":n,o=e.menuLinkSelector,u=void 0===o?"a":o,l=e.submenuItemSelector,s=void 0===l?"":l,c=e.submenuToggleSelector,m=void 0===c?"a":c,f=e.submenuSelector,p=void 0===f?"ul":f,d=e.controllerElement,y=void 0===d?null:d,v=e.containerElement,b=void 0===v?null:v,M=e.openClass,E=void 0===M?"show":M,w=e.closeClass,_=void 0===w?"hide":w,C=e.isTopLevel,S=void 0===C||C,I=e.parentMenu,T=void 0===I?null:I,k=e.hoverType,O=void 0===k?"off":k,A=e.hoverDelay,j=void 0===A?250:A;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,i),g(this,"_MenuType",i),g(this,"_MenuItemType",h),g(this,"_MenuToggleType",a),g(this,"_dom",{menu:null,menuItems:[],submenuItems:[],submenuToggles:[],submenus:[],controller:null,container:null}),g(this,"_selectors",{menuItems:"",menuLinks:"",submenuItems:"",submenuToggles:"",submenus:""}),g(this,"_elements",{menuItems:[],submenuToggles:[],controller:null,parentMenu:null,rootMenu:null}),g(this,"_openClass","show"),g(this,"_closeClass","hide"),g(this,"_root",!0),g(this,"_currentChild",0),g(this,"_focusState","none"),g(this,"_currentEvent","none"),g(this,"_hoverType","off"),g(this,"_hoverDelay",250),this._dom.menu=t,this._dom.controller=y,this._dom.container=b,this._selectors.menuItems=r,this._selectors.menuLinks=u,this._selectors.submenuItems=s,this._selectors.submenuToggles=m,this._selectors.submenus=p,this._elements.menuItems=[],this._elements.submenuToggles=[],this._elements.controller=null,this._elements.parentMenu=T,this._elements.rootMenu=S?this:null,this._openClass=E||"",this._closeClass=_||"",this._root=S,this._hoverType=O,this._hoverDelay=j}var l,s,c;return l=i,s=[{key:"initialize",value:function(){if(!this._validate())throw new Error("AccesibleMenu: cannot initialize menu. See other error messages for more information.");if(null===this.elements.rootMenu&&this._findRootMenu(this),this._setDOMElements(),this.isTopLevel&&this.dom.controller&&this.dom.container){var e=new this._MenuToggleType({menuToggleElement:this.dom.controller,parentElement:this.dom.container,controlledMenu:this});this._elements.controller=e}this._createChildElements()}},{key:"dom",get:function(){return this._dom}},{key:"selectors",get:function(){return this._selectors}},{key:"elements",get:function(){return this._elements}},{key:"isTopLevel",get:function(){return this._root}},{key:"openClass",get:function(){return this.isTopLevel?this._openClass:this.elements.rootMenu.openClass},set:function(e){o({openClass:e}),this._openClass!==e&&(this._openClass=e)}},{key:"closeClass",get:function(){return this.isTopLevel?this._closeClass:this.elements.rootMenu.closeClass},set:function(e){o({closeClass:e}),this._closeClass!==e&&(this._closeClass=e)}},{key:"currentChild",get:function(){return this._currentChild},set:function(e){function t(e){if(["mouse","character"].includes(e.currentEvent)&&e.elements.parentMenu)for(var t=0,n=!1;!n&&t<e.elements.parentMenu.elements.menuItems.length;){var r=e.elements.parentMenu.elements.menuItems[t];r.isSubmenuItem&&r.elements.toggle.elements.controlledMenu===e&&(n=!0,e.elements.parentMenu.currentEvent=e.currentEvent,e.elements.parentMenu.currentChild=t),t++}}n("number",{value:e}),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))}},{key:"focusState",get:function(){return this._focusState},set:function(t){!function(t){try{if("object"!==e(t)){var n=e(t);throw new TypeError("AccessibleMenu: Values given to isValidState() must be inside of an object. ".concat(n," given."))}var r=["none","self","child"];for(var o in t)if(!r.includes(t[o]))throw new TypeError("AccessibleMenu: ".concat(o," must be one of the following values: ").concat(r.join(", "),'. "').concat(t[o],'" given.'))}catch(e){return console.error(e),!1}}({value:t}),this._focusState!==t&&(this._focusState=t),this.elements.submenuToggles.length>0&&("self"===t||"none"===t)&&this.elements.submenuToggles.forEach((function(e){e.elements.controlledMenu.focusState="none"})),!this.elements.parentMenu||"self"!==t&&"child"!==t||(this.elements.parentMenu.focusState="child")}},{key:"currentEvent",get:function(){return this._currentEvent},set:function(t){!function(t){try{if("object"!==e(t)){var n=e(t);throw new TypeError("AccessibleMenu: Values given to isValidEvent() must be inside of an object. ".concat(n," given."))}var r=["none","mouse","keyboard","character"];for(var o in t)if(!r.includes(t[o]))throw new TypeError("AccessibleMenu: ".concat(o," must be one of the following values: ").concat(r.join(", "),'. "').concat(t[o],'" given.'))}catch(e){return console.error(e),!1}}({value:t}),this._currentEvent!==t&&(this._currentEvent=t,this.elements.submenuToggles.length>0&&this.elements.submenuToggles.forEach((function(e){e.elements.controlledMenu.currentEvent=t})))}},{key:"currentMenuItem",get:function(){return this.elements.menuItems[this.currentChild]}},{key:"hoverType",get:function(){return this._root?this._hoverType:this.elements.rootMenu.hoverType},set:function(e){u({value:e}),this._hoverType!==e&&(this._hoverType=e)}},{key:"hoverDelay",get:function(){return this._root?this._hoverDelay:this.elements.rootMenu.hoverDelay},set:function(e){n("number",{value:e}),this._hoverDelay!==e&&(this._hoverDelay=e)}},{key:"shouldFocus",get:function(){var e=!1;return"keyboard"!==this.currentEvent&&"character"!==this.currentEvent||(e=!0),"mouse"===this.currentEvent&&"dynamic"===this.hoverType&&(e=!0),e}},{key:"_validate",value:function(){var e=!0;return null!==this._dom.container||null!==this._dom.controller?t(HTMLElement,{menuElement:this._dom.menu,controllerElement:this._dom.controller,containerElement:this._dom.container})||(e=!1):t(HTMLElement,{menuElement:this._dom.menu})||(e=!1),""!==this._selectors.submenuItems?r({menuItemSelector:this._selectors.menuItems,menuLinkSelector:this._selectors.menuLinks,submenuItemSelector:this._selectors.submenuItems,submenuToggleSelector:this._selectors.submenuToggles,submenuSelector:this._selectors.submenus})||(e=!1):r({menuItemSelector:this._selectors.menuItems,menuLinkSelector:this._selectors.menuLinks})||(e=!1),""===this._openClass||o({openClass:this._openClass})||(e=!1),""===this._closeClass||o({closeClass:this._closeClass})||(e=!1),n("boolean",{isTopLevel:this._root})||(e=!1),null===this._elements.parentMenu||t(i,{parentMenu:this._elements.parentMenu})||(e=!1),u({hoverType:this._hoverType})||(e=!1),n("number",{hoverDelay:this._hoverDelay})||(e=!1),e}},{key:"_setDOMElementType",value:function(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.dom.menu,r=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];if("string"!=typeof this.selectors[e])throw new Error('AccessibleMenu: "'.concat(e,'" is not a valid element type within the menu.'));if(!Array.isArray(this.dom[e]))throw new Error('AccessibleMenu: The "'.concat(e,'" element cannot be set through _setDOMElementType.'));n!==this.dom.menu&&t(HTMLElement,{base:n});var o=Array.from(n.querySelectorAll(this.selectors[e])),u=o.filter((function(e){return e.parentElement===n}));this._dom[e]=r?u:[].concat(y(this._dom[e]),y(u))}},{key:"_resetDOMElementType",value:function(e){if(void 0===this.dom[e])throw new Error('AccessibleMenu: "'.concat(e,'" is not a valid element type within the menu.'));if(!Array.isArray(this.dom[e]))throw new Error('AccessibleMenu: The "'.concat(e,'" element cannot be reset through _resetDOMElementType.'));this._dom[e]=[]}},{key:"_setDOMElements",value:function(){var e=this;this._setDOMElementType("menuItems"),""!==this.selectors.submenuItems&&(this._setDOMElementType("submenuItems"),this._resetDOMElementType("submenuToggles"),this._resetDOMElementType("submenus"),this.dom.submenuItems.forEach((function(t){e._setDOMElementType("submenuToggles",t,!1),e._setDOMElementType("submenus",t,!1)})))}},{key:"_findRootMenu",value:function(e){if(e.isTopLevel)this._elements.rootMenu=e;else{if(null===e.elements.parentMenu)throw new Error("Cannot find root menu.");this._findRootMenu(e.elements.parentMenu)}}},{key:"_createChildElements",value:function(){var e=this;this.dom.menuItems.forEach((function(t){var n;if(e.dom.submenuItems.includes(t)){var r=t.querySelector(e.selectors.submenuToggles),o=t.querySelector(e.selectors.submenus),u=new e._MenuType({menuElement:o,menuItemSelector:e.selectors.menuItems,menuLinkSelector:e.selectors.menuLinks,submenuItemSelector:e.selectors.submenuItems,submenuToggleSelector:e.selectors.submenuToggles,submenuSelector:e.selectors.submenus,openClass:e.openClass,closeClass:e.closeClass,isTopLevel:!1,parentMenu:e,hoverType:e.hoverType,hoverDelay:e.hoverDelay}),i=new e._MenuToggleType({menuToggleElement:r,parentElement:t,controlledMenu:u,parentMenu:e});e._elements.submenuToggles.push(i),n=new e._MenuItemType({menuItemElement:t,menuLinkElement:r,parentMenu:e,isSubmenuItem:!0,childMenu:u,toggle:i})}else{var l=t.querySelector(e.selectors.menuLinks);n=new e._MenuItemType({menuItemElement:t,menuLinkElement:l,parentMenu:e})}e._elements.menuItems.push(n)}))}},{key:"_handleFocus",value:function(){var e=this;this.elements.menuItems.forEach((function(t,n){t.dom.link.addEventListener("focus",(function(){e.focusState="self",e.currentChild=n}))}))}},{key:"_handleClick",value:function(){var e=this;function t(e,t,n){d(n),t.toggle(),t.isOpen&&(e.focusState="self",t.elements.controlledMenu.focusState="none")}this.elements.menuItems.forEach((function(n,r){n.dom.link.addEventListener("pointerdown",(function(){e.currentEvent="mouse",e.elements.rootMenu.blurChildren(),e.focusChild(r)}),{passive:!0}),n.isSubmenuItem&&n.elements.toggle.dom.toggle.addEventListener("pointerup",(function(r){e.currentEvent="mouse",t(e,n.elements.toggle,r)}))})),this.isTopLevel&&this.elements.controller&&this.elements.controller.dom.toggle.addEventListener("pointerup",(function(n){e.currentEvent="mouse",t(e,e.elements.controller,n)}))}},{key:"_handleHover",value:function(){var e=this;this.elements.menuItems.forEach((function(t,n){t.dom.link.addEventListener("mouseenter",(function(){if("on"===e.hoverType)e.currentEvent="mouse",e.currentChild=n,t.isSubmenuItem&&t.elements.toggle.preview();else if("dynamic"===e.hoverType){var r=e.elements.submenuToggles.some((function(e){return e.isOpen}));e.currentChild=n,e.isTopLevel&&"none"===e.focusState||(e.currentEvent="mouse",e.focusCurrentChild()),!t.isSubmenuItem||e.isTopLevel&&!r||(e.currentEvent="mouse",t.elements.toggle.preview())}})),t.isSubmenuItem&&t.dom.item.addEventListener("mouseleave",(function(){"on"===e.hoverType?e.hoverDelay>0?setTimeout((function(){e.currentEvent="mouse",t.elements.toggle.close()}),e.hoverDelay):(e.currentEvent="mouse",t.elements.toggle.close()):"dynamic"===e.hoverType&&(e.isTopLevel||(e.hoverDelay>0?setTimeout((function(){e.currentEvent="mouse",t.elements.toggle.close(),e.focusCurrentChild()}),e.hoverDelay):(e.currentEvent="mouse",t.elements.toggle.close(),e.focusCurrentChild())))}))}))}},{key:"_handleKeydown",value:function(){var e=this;this.isTopLevel&&this.elements.controller&&this.elements.controller.dom.toggle.addEventListener("keydown",(function(t){e.currentEvent="keyboard";var n=p(t);"Space"!==n&&"Enter"!==n||d(t)}))}},{key:"_handleKeyup",value:function(){var e=this;this.isTopLevel&&this.elements.controller&&this.elements.controller.dom.toggle.addEventListener("keyup",(function(t){e.currentEvent="keyboard";var n=p(t);"Space"!==n&&"Enter"!==n||(d(t),e.elements.controller.open(),e.focusFirstChild())}))}},{key:"focus",value:function(){this.focusState="self",this.shouldFocus&&this.dom.menu.focus()}},{key:"blur",value:function(){this.focusState="none",this.shouldFocus&&this.dom.menu.blur()}},{key:"focusCurrentChild",value:function(){this.focusState="self",-1!==this.currentChild&&this.currentMenuItem.focus()}},{key:"focusChild",value:function(e){this.blurCurrentChild(),this.currentChild=e,this.focusCurrentChild()}},{key:"focusFirstChild",value:function(){this.focusChild(0)}},{key:"focusLastChild",value:function(){this.focusChild(this.elements.menuItems.length-1)}},{key:"focusNextChild",value:function(){this.currentChild<this.elements.menuItems.length-1?this.focusChild(this.currentChild+1):this.focusCurrentChild()}},{key:"focusPreviousChild",value:function(){this.currentChild>0?this.focusChild(this.currentChild-1):this.focusCurrentChild()}},{key:"blurCurrentChild",value:function(){this.focusState="none",-1!==this.currentChild&&this.currentMenuItem.blur()}},{key:"focusController",value:function(){this.dom.controller&&(this.shouldFocus&&this.dom.controller.focus(),this.focusState="none")}},{key:"focusContainer",value:function(){this.dom.container&&(this.shouldFocus&&this.dom.container.focus(),this.focusState="none")}},{key:"closeChildren",value:function(){this.elements.submenuToggles.forEach((function(e){return e.close()}))}},{key:"blurChildren",value:function(){this.elements.menuItems.forEach((function(e){e.blur(),e.isSubmenuItem&&e.elements.childMenu.blurChildren()}))}}],s&&b(l.prototype,s),c&&b(l,c),i}();function E(e){return E="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},E(e)}function w(e,t){return w=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},w(e,t)}function _(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=S(e);if(t){var o=S(this).constructor;n=Reflect.construct(r,arguments,o)}else n=r.apply(this,arguments);return C(this,n)}}function C(e,t){if(t&&("object"===E(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}function S(e){return S=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},S(e)}var I=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&w(e,t)}(n,e);var t=_(n);function n(e){var r,o=e.menuItemElement,u=e.menuLinkElement,i=e.parentMenu,l=e.isSubmenuItem,s=void 0!==l&&l,c=e.childMenu,a=void 0===c?null:c,m=e.toggle,f=void 0===m?null:m,h=e.initialize,p=void 0===h||h;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,n),r=t.call(this,{menuItemElement:o,menuLinkElement:u,parentMenu:i,isSubmenuItem:s,childMenu:a,toggle:f}),p&&r.initialize(),r}return n}(h);function T(e){return T="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},T(e)}function k(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function O(e,t,n){return O="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(e,t,n){var r=function(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&null!==(e=R(e)););return e}(e,t);if(r){var o=Object.getOwnPropertyDescriptor(r,t);return o.get?o.get.call(n):o.value}},O(e,t,n||e)}function A(e,t){return A=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},A(e,t)}function j(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=R(e);if(t){var o=R(this).constructor;n=Reflect.construct(r,arguments,o)}else n=r.apply(this,arguments);return L(this,n)}}function L(e,t){if(t&&("object"===T(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}function R(e){return R=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},R(e)}var P=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&A(e,t)}(u,e);var t,n,r,o=j(u);function u(e){var t,n=e.menuToggleElement,r=e.parentElement,i=e.controlledMenu,l=e.parentMenu,s=void 0===l?null:l,c=e.initialize,a=void 0===c||c;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,u),t=o.call(this,{menuToggleElement:n,parentElement:r,controlledMenu:i,parentMenu:s}),a&&t.initialize(),t}return t=u,(n=[{key:"open",value:function(){this.closeSiblings(),O(R(u.prototype),"open",this).call(this)}},{key:"preview",value:function(){this.closeSiblings(),O(R(u.prototype),"preview",this).call(this)}},{key:"close",value:function(){this.isOpen&&this.closeChildren(),O(R(u.prototype),"close",this).call(this)}}])&&k(t.prototype,n),r&&k(t,r),u}(a);function D(e){return D="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},D(e)}function x(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function z(e,t,n){return z="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(e,t,n){var r=function(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&null!==(e=B(e)););return e}(e,t);if(r){var o=Object.getOwnPropertyDescriptor(r,t);return o.get?o.get.call(n):o.value}},z(e,t,n||e)}function K(e,t){return K=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},K(e,t)}function F(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=B(e);if(t){var o=B(this).constructor;n=Reflect.construct(r,arguments,o)}else n=r.apply(this,arguments);return N(this,n)}}function N(e,t){if(t&&("object"===D(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return H(e)}function H(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function B(e){return B=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},B(e)}function U(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var V=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&K(e,t)}(i,e);var t,r,o,u=F(i);function i(e){var t,n=e.menuElement,r=e.menuItemSelector,o=void 0===r?"li":r,l=e.menuLinkSelector,s=void 0===l?"a":l,c=e.submenuItemSelector,a=void 0===c?"":c,m=e.submenuToggleSelector,f=void 0===m?"a":m,h=e.submenuSelector,p=void 0===h?"ul":h,d=e.controllerElement,y=void 0===d?null:d,v=e.containerElement,b=void 0===v?null:v,g=e.openClass,M=void 0===g?"show":g,E=e.closeClass,w=void 0===E?"hide":E,_=e.isTopLevel,C=void 0===_||_,S=e.parentMenu,T=void 0===S?null:S,k=e.hoverType,O=void 0===k?"off":k,A=e.hoverDelay,j=void 0===A?250:A,L=e.optionalKeySupport,R=void 0!==L&&L,D=e.initialize,x=void 0===D||D;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,i),U(H(t=u.call(this,{menuElement:n,menuItemSelector:o,menuLinkSelector:s,submenuItemSelector:a,submenuToggleSelector:f,submenuSelector:p,controllerElement:y,containerElement:b,openClass:M,closeClass:w,isTopLevel:C,parentMenu:T,hoverType:O,hoverDelay:j})),"_MenuType",i),U(H(t),"_MenuItemType",I),U(H(t),"_MenuToggleType",P),U(H(t),"_currentChild",-1),U(H(t),"_optionalSupport",!1),t._optionalSupport=R,x&&t.initialize(),t}return t=i,(r=[{key:"initialize",value:function(){try{z(B(i.prototype),"initialize",this).call(this),this._handleFocus(),this._handleClick(),this._handleHover(),this._handleKeydown(),this._handleKeyup()}catch(e){console.error(e)}}},{key:"optionalKeySupport",get:function(){return this.isTopLevel?this._optionalSupport:this.elements.rootMenu.optionalKeySupport},set:function(e){n("boolean",{optionalKeySupport:e}),this._optionalSupport=e}},{key:"_validate",value:function(){var e=z(B(i.prototype),"_validate",this).call(this);return n("boolean",{optionalKeySupport:this._optionalSupport})||(e=!1),e}},{key:"_handleClick",value:function(){var e=this;z(B(i.prototype),"_handleClick",this).call(this),document.addEventListener("pointerup",(function(t){"none"!==e.focusState&&(e.currentEvent="mouse",e.dom.menu.contains(t.target)||!e.dom.menu===t.target||(e.closeChildren(),e.blur(),e.elements.controller&&e.elements.controller.close()))}))}},{key:"_handleKeydown",value:function(){var e=this;z(B(i.prototype),"_handleKeydown",this).call(this),this.dom.menu.addEventListener("keydown",(function(t){e.currentEvent="keyboard";var n=p(t);"self"===e.focusState&&(e.optionalKeySupport?["ArrowUp","ArrowRight","ArrowDown","ArrowLeft","Home","End"].includes(n)&&d(t):(e.currentMenuItem.isSubmenuItem&&["Space","Enter"].includes(n)||e.elements.controller&&["Escape"].includes(n)||e.elements.parentMenu&&["Escape"].includes(n))&&d(t))}))}},{key:"_handleKeyup",value:function(){var e=this;z(B(i.prototype),"_handleKeyup",this).call(this),this.dom.menu.addEventListener("keyup",(function(t){e.currentEvent="keyboard";var n=p(t);"self"===e.focusState&&("Space"===n||"Enter"===n?e.currentMenuItem.isSubmenuItem?(d(t),e.currentMenuItem.elements.toggle.preview()):e.currentMenuItem.dom.link.click():"Escape"===n?e.elements.submenuToggles.some((function(e){return e.isOpen}))?(d(t),e.closeChildren()):e.elements.parentMenu?(d(t),e.elements.parentMenu.currentEvent=e.currentEvent,e.elements.parentMenu.closeChildren(),e.elements.parentMenu.focusCurrentChild()):e.isTopLevel&&e.elements.controller&&e.elements.controller.isOpen&&(e.elements.controller.close(),e.focusController()):e.optionalKeySupport&&("ArrowDown"===n||"ArrowRight"===n?(d(t),e.currentMenuItem.isSubmenuItem&&e.currentMenuItem.elements.toggle.isOpen?(e.currentMenuItem.elements.childMenu.currentEvent="keyboard",e.currentMenuItem.elements.childMenu.focusFirstChild()):e.focusNextChild()):"ArrowUp"===n||"ArrowLeft"===n?(d(t),e.focusPreviousChild()):"Home"===n?(d(t),e.focusFirstChild()):"End"===n&&(d(t),e.focusLastChild())))}))}}])&&x(t.prototype,r),o&&x(t,o),i}(M);function q(e){return q="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},q(e)}function W(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function $(e,t,n){return $="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(e,t,n){var r=function(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&null!==(e=Q(e)););return e}(e,t);if(r){var o=Object.getOwnPropertyDescriptor(r,t);return o.get?o.get.call(n):o.value}},$(e,t,n||e)}function Z(e,t){return Z=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},Z(e,t)}function G(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=Q(e);if(t){var o=Q(this).constructor;n=Reflect.construct(r,arguments,o)}else n=r.apply(this,arguments);return J(this,n)}}function J(e,t){if(t&&("object"===q(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}function Q(e){return Q=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},Q(e)}var X=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&Z(e,t)}(u,e);var t,n,r,o=G(u);function u(e){var t,n=e.menuItemElement,r=e.menuLinkElement,i=e.parentMenu,l=e.isSubmenuItem,s=void 0!==l&&l,c=e.childMenu,a=void 0===c?null:c,m=e.toggle,f=void 0===m?null:m,h=e.initialize,p=void 0===h||h;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,u),t=o.call(this,{menuItemElement:n,menuLinkElement:r,parentMenu:i,isSubmenuItem:s,childMenu:a,toggle:f}),p&&t.initialize(),t}return t=u,(n=[{key:"initialize",value:function(){$(Q(u.prototype),"initialize",this).call(this),this.dom.item.setAttribute("role","none"),this.dom.link.setAttribute("role","menuitem"),this.dom.link.tabIndex=-1}},{key:"focus",value:function(){$(Q(u.prototype),"focus",this).call(this),this.elements.parentMenu.isTopLevel&&(this.dom.link.tabIndex=0)}},{key:"blur",value:function(){$(Q(u.prototype),"blur",this).call(this),this.elements.parentMenu.isTopLevel&&(this.dom.link.tabIndex=-1)}}])&&W(t.prototype,n),r&&W(t,r),u}(h);function Y(e){return Y="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Y(e)}function ee(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function te(e,t,n){return te="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(e,t,n){var r=function(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&null!==(e=ue(e)););return e}(e,t);if(r){var o=Object.getOwnPropertyDescriptor(r,t);return o.get?o.get.call(n):o.value}},te(e,t,n||e)}function ne(e,t){return ne=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},ne(e,t)}function re(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=ue(e);if(t){var o=ue(this).constructor;n=Reflect.construct(r,arguments,o)}else n=r.apply(this,arguments);return oe(this,n)}}function oe(e,t){if(t&&("object"===Y(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}function ue(e){return ue=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},ue(e)}var ie=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&ne(e,t)}(u,e);var t,n,r,o=re(u);function u(e){var t,n=e.menuToggleElement,r=e.parentElement,i=e.controlledMenu,l=e.parentMenu,s=void 0===l?null:l,c=e.initialize,a=void 0===c||c;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,u),t=o.call(this,{menuToggleElement:n,parentElement:r,controlledMenu:i,parentMenu:s}),a&&t.initialize(),t}return t=u,(n=[{key:"open",value:function(){this.closeSiblings(),te(ue(u.prototype),"open",this).call(this)}},{key:"preview",value:function(){this.closeSiblings(),te(ue(u.prototype),"preview",this).call(this)}},{key:"close",value:function(){this.isOpen&&this.closeChildren(),te(ue(u.prototype),"close",this).call(this)}}])&&ee(t.prototype,n),r&&ee(t,r),u}(a);function le(e){return le="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},le(e)}function se(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function ce(e,t,n){return ce="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(e,t,n){var r=function(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&null!==(e=pe(e)););return e}(e,t);if(r){var o=Object.getOwnPropertyDescriptor(r,t);return o.get?o.get.call(n):o.value}},ce(e,t,n||e)}function ae(e,t){return ae=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},ae(e,t)}function me(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=pe(e);if(t){var o=pe(this).constructor;n=Reflect.construct(r,arguments,o)}else n=r.apply(this,arguments);return fe(this,n)}}function fe(e,t){if(t&&("object"===le(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return he(e)}function he(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function pe(e){return pe=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},pe(e)}function de(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var ye=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&ae(e,t)}(u,e);var t,n,r,o=me(u);function u(e){var t,n=e.menuElement,r=e.menuItemSelector,i=void 0===r?"li":r,l=e.menuLinkSelector,s=void 0===l?"a":l,c=e.submenuItemSelector,a=void 0===c?"":c,m=e.submenuToggleSelector,f=void 0===m?"a":m,h=e.submenuSelector,p=void 0===h?"ul":h,d=e.controllerElement,y=void 0===d?null:d,v=e.containerElement,b=void 0===v?null:v,g=e.openClass,M=void 0===g?"show":g,E=e.closeClass,w=void 0===E?"hide":E,_=e.isTopLevel,C=void 0===_||_,S=e.parentMenu,I=void 0===S?null:S,T=e.hoverType,k=void 0===T?"off":T,O=e.hoverDelay,A=void 0===O?250:O,j=e.initialize,L=void 0===j||j;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,u),de(he(t=o.call(this,{menuElement:n,menuItemSelector:i,menuLinkSelector:s,submenuItemSelector:a,submenuToggleSelector:f,submenuSelector:p,controllerElement:y,containerElement:b,openClass:M,closeClass:w,isTopLevel:C,parentMenu:I,hoverType:k,hoverDelay:A})),"_MenuType",u),de(he(t),"_MenuItemType",X),de(he(t),"_MenuToggleType",ie),L&&t.initialize(),t}return t=u,(n=[{key:"initialize",value:function(){try{ce(pe(u.prototype),"initialize",this).call(this),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)}}},{key:"_handleClick",value:function(){var e=this;ce(pe(u.prototype),"_handleClick",this).call(this),document.addEventListener("pointerup",(function(t){"none"!==e.focusState&&(e.currentEvent="mouse",e.dom.menu.contains(t.target)||!e.dom.menu===t.target||(e.closeChildren(),e.blur(),e.elements.controller&&e.elements.controller.close()))}))}},{key:"_handleKeydown",value:function(){var e=this;ce(pe(u.prototype),"_handleKeydown",this).call(this),this.dom.menu.addEventListener("keydown",(function(t){e.currentEvent="keyboard";var n=p(t);"Tab"===n&&("none"!==e.elements.rootMenu.focusState?(e.elements.rootMenu.blur(),e.elements.rootMenu.closeChildren()):e.elements.rootMenu.focus()),"Character"===n?d(t):e.isTopLevel?"self"===e.focusState&&(["ArrowRight","ArrowLeft","Home","End"].includes(n)||e.currentMenuItem.isSubmenuItem&&["Space","Enter","ArrowDown","ArrowUp"].includes(n)||e.elements.controller&&["Escape"].includes(n))&&d(t):(["Escape","ArrowRight","ArrowLeft","ArrowDown","ArrowUp","Home","End"].includes(n)||e.currentMenuItem.isSubmenuItem&&["Space","Enter"].includes(n))&&d(t)}))}},{key:"_handleKeyup",value:function(){var e=this;ce(pe(u.prototype),"_handleKeyup",this).call(this),this.dom.menu.addEventListener("keyup",(function(t){e.currentEvent="keyboard";var n=p(t),r=t.altKey,o=t.crtlKey,u=t.metaKey;if("Character"!==n||r||o||u)if(e.isTopLevel){if("self"===e.focusState)if("Space"===n||"Enter"===n)e.currentMenuItem.isSubmenuItem?(d(t),e.currentMenuItem.elements.childMenu.currentEvent="keyboard",e.currentMenuItem.elements.toggle.open(),requestAnimationFrame((function(){e.currentMenuItem.elements.childMenu.focusFirstChild()}))):e.currentMenuItem.dom.link.click();else if("ArrowRight"===n){d(t);var i=e.currentMenuItem.isSubmenuItem&&e.currentMenuItem.elements.toggle.isOpen;e.focusNextChild(),i&&(e.currentMenuItem.isSubmenuItem?(e.currentMenuItem.elements.childMenu.currentEvent="keyboard",e.currentMenuItem.elements.toggle.preview()):e.closeChildren())}else if("ArrowLeft"===n){d(t);var l=e.currentMenuItem.isSubmenuItem&&e.currentMenuItem.elements.toggle.isOpen;e.focusPreviousChild(),l&&(e.currentMenuItem.isSubmenuItem?(e.currentMenuItem.elements.childMenu.currentEvent="keyboard",e.currentMenuItem.elements.toggle.preview()):e.closeChildren())}else"ArrowDown"===n?e.currentMenuItem.isSubmenuItem&&(d(t),e.currentMenuItem.elements.childMenu.currentEvent="keyboard",e.currentMenuItem.elements.toggle.open(),requestAnimationFrame((function(){e.currentMenuItem.elements.childMenu.focusFirstChild()}))):"ArrowUp"===n?e.currentMenuItem.isSubmenuItem&&(d(t),e.currentMenuItem.elements.childMenu.currentEvent="keyboard",e.currentMenuItem.elements.toggle.open(),requestAnimationFrame((function(){e.currentMenuItem.elements.childMenu.focusLastChild()}))):"Home"===n?(d(t),e.focusFirstChild()):"End"===n?(d(t),e.focusLastChild()):"Escape"===n&&(e.elements.submenuToggles.some((function(e){return e.isOpen}))?(d(t),e.closeChildren()):e.isTopLevel&&e.elements.controller&&e.elements.controller.isOpen&&(d(t),e.elements.controller.close(),e.focusController()))}else"Space"===n||"Enter"===n?e.currentMenuItem.isSubmenuItem&&(d(t),e.currentMenuItem.elements.childMenu.currentEvent="keyboard",e.currentMenuItem.elements.toggle.open(),requestAnimationFrame((function(){e.currentMenuItem.elements.childMenu.focusFirstChild()}))):"Escape"===n?(d(t),e.elements.rootMenu.closeChildren(),e.elements.rootMenu.focusCurrentChild()):"ArrowRight"===n?e.currentMenuItem.isSubmenuItem?(d(t),e.currentMenuItem.elements.childMenu.currentEvent="keyboard",e.currentMenuItem.elements.toggle.open(),requestAnimationFrame((function(){e.currentMenuItem.elements.childMenu.focusFirstChild()}))):(d(t),e.elements.rootMenu.closeChildren(),e.elements.rootMenu.focusNextChild(),e.elements.rootMenu.currentMenuItem.isSubmenuItem&&e.elements.rootMenu.currentMenuItem.elements.toggle.preview()):"ArrowLeft"===n?e.elements.parentMenu.currentMenuItem.isSubmenuItem&&(d(t),e.elements.parentMenu.currentMenuItem.elements.toggle.close(),e.elements.parentMenu.focusCurrentChild(),e.elements.parentMenu===e.elements.rootMenu&&(e.elements.rootMenu.closeChildren(),e.elements.rootMenu.focusPreviousChild(),e.elements.rootMenu.currentMenuItem.isSubmenuItem&&(e.elements.rootMenu.currentMenuItem.elements.childMenu.currentEvent="keyboard",e.elements.rootMenu.currentMenuItem.elements.toggle.preview()))):"ArrowDown"===n?(d(t),e.focusNextChild()):"ArrowUp"===n?(d(t),e.focusPreviousChild()):"Home"===n?(d(t),e.focusFirstChild()):"End"===n&&(d(t),e.focusLastChild());else d(t),e.elements.rootMenu.currentEvent="character",e.focusNextChildWithCharacter(t.key)}))}},{key:"focusNextChild",value:function(){this.currentChild===this.elements.menuItems.length-1?this.focusFirstChild():this.focusChild(this.currentChild+1)}},{key:"focusPreviousChild",value:function(){0===this.currentChild?this.focusLastChild():this.focusChild(this.currentChild-1)}},{key:"focusNextChildWithCharacter",value:function(e){for(var t=e.toLowerCase(),n=this.currentChild+1,r=!1;!r&&n<this.elements.menuItems.length;)(this.elements.menuItems[n].dom.item.innerText?this.elements.menuItems[n].dom.item.innerText:this.elements.menuItems[n].dom.item.textContent).replace(/[\s]/g,"").toLowerCase().charAt(0)===t&&(r=!0,this.focusChild(n)),n++}}])&&se(t.prototype,n),r&&se(t,r),u}(M);function ve(e){return ve="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},ve(e)}function be(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function ge(e,t,n){return ge="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(e,t,n){var r=function(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&null!==(e=_e(e)););return e}(e,t);if(r){var o=Object.getOwnPropertyDescriptor(r,t);return o.get?o.get.call(n):o.value}},ge(e,t,n||e)}function Me(e,t){return Me=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},Me(e,t)}function Ee(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=_e(e);if(t){var o=_e(this).constructor;n=Reflect.construct(r,arguments,o)}else n=r.apply(this,arguments);return we(this,n)}}function we(e,t){if(t&&("object"===ve(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}function _e(e){return _e=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},_e(e)}var Ce=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&Me(e,t)}(u,e);var t,n,r,o=Ee(u);function u(e){var t,n=e.menuItemElement,r=e.menuLinkElement,i=e.parentMenu,l=e.isSubmenuItem,s=void 0!==l&&l,c=e.childMenu,a=void 0===c?null:c,m=e.toggle,f=void 0===m?null:m,h=e.initialize,p=void 0===h||h;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,u),t=o.call(this,{menuItemElement:n,menuLinkElement:r,parentMenu:i,isSubmenuItem:s,childMenu:a,toggle:f}),p&&t.initialize(),t}return t=u,(n=[{key:"initialize",value:function(){ge(_e(u.prototype),"initialize",this).call(this),this.dom.item.setAttribute("role","none"),this.dom.link.setAttribute("role","treeitem"),this.dom.link.tabIndex=-1}},{key:"focus",value:function(){ge(_e(u.prototype),"focus",this).call(this),this.dom.link.tabIndex=0}},{key:"blur",value:function(){ge(_e(u.prototype),"blur",this).call(this),this.dom.link.tabIndex=-1}}])&&be(t.prototype,n),r&&be(t,r),u}(h);function Se(e){return Se="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Se(e)}function Ie(e,t){return Ie=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},Ie(e,t)}function Te(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=Oe(e);if(t){var o=Oe(this).constructor;n=Reflect.construct(r,arguments,o)}else n=r.apply(this,arguments);return ke(this,n)}}function ke(e,t){if(t&&("object"===Se(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}function Oe(e){return Oe=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},Oe(e)}var Ae=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&Ie(e,t)}(n,e);var t=Te(n);function n(e){var r,o=e.menuToggleElement,u=e.parentElement,i=e.controlledMenu,l=e.parentMenu,s=void 0===l?null:l,c=e.initialize,a=void 0===c||c;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,n),r=t.call(this,{menuToggleElement:o,parentElement:u,controlledMenu:i,parentMenu:s}),a&&r.initialize(),r}return n}(a);function je(e){return je="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},je(e)}function Le(e){return function(e){if(Array.isArray(e))return Re(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,t){if(!e)return;if("string"==typeof e)return Re(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return Re(e,t)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Re(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function Pe(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function De(e,t,n){return De="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(e,t,n){var r=function(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&null!==(e=Ne(e)););return e}(e,t);if(r){var o=Object.getOwnPropertyDescriptor(r,t);return o.get?o.get.call(n):o.value}},De(e,t,n||e)}function xe(e,t){return xe=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},xe(e,t)}function ze(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=Ne(e);if(t){var o=Ne(this).constructor;n=Reflect.construct(r,arguments,o)}else n=r.apply(this,arguments);return Ke(this,n)}}function Ke(e,t){if(t&&("object"===je(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return Fe(e)}function Fe(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function Ne(e){return Ne=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},Ne(e)}function He(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}return{DisclosureMenu:V,Menubar:ye,Treeview:function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&xe(e,t)}(u,e);var t,n,r,o=ze(u);function u(e){var t,n=e.menuElement,r=e.menuItemSelector,i=void 0===r?"li":r,l=e.menuLinkSelector,s=void 0===l?"a":l,c=e.submenuItemSelector,a=void 0===c?"":c,m=e.submenuToggleSelector,f=void 0===m?"a":m,h=e.submenuSelector,p=void 0===h?"ul":h,d=e.controllerElement,y=void 0===d?null:d,v=e.containerElement,b=void 0===v?null:v,g=e.openClass,M=void 0===g?"show":g,E=e.closeClass,w=void 0===E?"hide":E,_=e.isTopLevel,C=void 0===_||_,S=e.parentMenu,I=void 0===S?null:S,T=e.hoverType,k=void 0===T?"off":T,O=e.hoverDelay,A=void 0===O?250:O,j=e.initialize,L=void 0===j||j;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,u),He(Fe(t=o.call(this,{menuElement:n,menuItemSelector:i,menuLinkSelector:s,submenuItemSelector:a,submenuToggleSelector:f,submenuSelector:p,controllerElement:y,containerElement:b,openClass:M,closeClass:w,isTopLevel:C,parentMenu:I,hoverType:k,hoverDelay:A})),"_MenuType",u),He(Fe(t),"_MenuItemType",Ce),He(Fe(t),"_MenuToggleType",Ae),L&&t.initialize(),t}return t=u,(n=[{key:"initialize",value:function(){try{De(Ne(u.prototype),"initialize",this).call(this),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)}}},{key:"_handleKeydown",value:function(){var e=this;De(Ne(u.prototype),"_handleKeydown",this).call(this),this.dom.menu.addEventListener("keydown",(function(t){e.currentEvent="keyboard";var n=p(t);"Tab"===n&&("none"!==e.elements.rootMenu.focusState?e.elements.rootMenu.blur():e.elements.rootMenu.focus()),"self"===e.focusState&&(["Space","ArrowUp","ArrowDown","ArrowLeft","Asterisk","Home","End"].includes(n)||e.currentMenuItem.isSubmenuItem&&["Enter","ArrowRight"].includes(n)||e.elements.controller&&["Escape"].includes(n))&&d(t)}))}},{key:"_handleKeyup",value:function(){var e=this;De(Ne(u.prototype),"_handleKeyup",this).call(this),this.dom.menu.addEventListener("keyup",(function(t){e.currentEvent="keyboard";var n=p(t),r=t.altKey,o=t.crtlKey,u=t.metaKey;if("Character"!==n||r||o||u){if("self"===e.focusState)if("Enter"===n||"Space"===n)d(t),e.currentMenuItem.isSubmenuItem?e.currentMenuItem.elements.toggle.isOpen?e.currentMenuItem.elements.toggle.close():e.currentMenuItem.elements.toggle.preview():e.currentMenuItem.dom.link.click();else if("Escape"===n)e.isTopLevel&&e.elements.controller&&e.elements.controller.isOpen&&(e.elements.controller.close(),e.focusController());else if("ArrowDown"===n)d(t),e.currentMenuItem.isSubmenuItem&&e.currentMenuItem.elements.toggle.isOpen?(e.blurCurrentChild(),e.currentMenuItem.elements.childMenu.currentEvent=e.currentEvent,e.currentMenuItem.elements.childMenu.focusFirstChild()):e.isTopLevel||e.currentChild!==e.elements.menuItems.length-1?e.focusNextChild():e.focusParentsNextChild();else if("ArrowUp"===n){d(t);var i=e.elements.menuItems[e.currentChild-1];i&&i.isSubmenuItem&&i.elements.toggle.isOpen?(e.blurCurrentChild(),e.currentChild=e.currentChild-1,e.currentMenuItem.elements.childMenu.currentEvent=e.currentEvent,e.focusChildsLastNode()):e.isTopLevel||0!==e.currentChild?e.focusPreviousChild():(e.blurCurrentChild(),e.elements.parentMenu.currentEvent=e.currentEvent,e.elements.parentMenu.focusCurrentChild())}else"ArrowRight"===n?e.currentMenuItem.isSubmenuItem&&(d(t),e.currentMenuItem.elements.toggle.isOpen?(e.blurCurrentChild(),e.currentMenuItem.elements.childMenu.currentEvent=e.currentEvent,e.currentMenuItem.elements.childMenu.focusFirstChild()):e.currentMenuItem.elements.toggle.preview()):"ArrowLeft"===n?(d(t),e.currentMenuItem.isSubmenuItem&&e.currentMenuItem.elements.toggle.isOpen?(e.currentMenuItem.elements.childMenu.blurCurrentChild(),e.currentMenuItem.elements.toggle.close()):e.isTopLevel||(e.blurCurrentChild(),e.elements.parentMenu.currentEvent=e.currentEvent,e.elements.parentMenu.focusCurrentChild())):"Home"===n?(d(t),e.blurCurrentChild(),e.elements.rootMenu.focusFirstChild()):"End"===n?(d(t),e.blurCurrentChild(),e.elements.rootMenu.focusLastNode()):"Asterisk"===n&&(d(t),e.openChildren())}else d(t),e.elements.rootMenu.currentEvent="character",e.focusNextNodeWithCharacter(t.key)}))}},{key:"focusLastNode",value:function(){var e=this.elements.menuItems.length-1,t=this.elements.menuItems[e];t.isSubmenuItem&&t.elements.toggle.isOpen?(this.currentChild=e,t.elements.childMenu.currentEvent=this.currentEvent,t.elements.childMenu.focusLastNode()):this.focusLastChild()}},{key:"openChildren",value:function(){this.elements.submenuToggles.forEach((function(e){return e.preview()}))}},{key:"focusNextNodeWithCharacter",value:function(e){for(var t=e.toLowerCase(),n=function e(t){var n=[];return t.elements.menuItems.forEach((function(t){n.push(t),t.isSubmenuItem&&t.elements.toggle.isOpen&&(n=[].concat(Le(n),Le(e(t.elements.toggle.elements.controlledMenu))))})),n}(this.elements.rootMenu),r=n.indexOf(this.currentMenuItem)+1,o=[].concat(Le(n.slice(r)),Le(n.slice(0,r))),u=0,i=!1;!i&&u<o.length;){if((o[u].dom.item.innerText?o[u].dom.item.innerText:o[u].dom.item.textContent).replace(/[\s]/g,"").toLowerCase().charAt(0)===t){i=!0;var l=o[u].elements.parentMenu,s=l.elements.menuItems.indexOf(o[u]);this.elements.rootMenu.blurChildren(),l.focusChild(s)}u++}}},{key:"focusParentsNextChild",value:function(){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()))}},{key:"focusChildsLastNode",value:function(){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())}}])&&Pe(t.prototype,n),r&&Pe(t,r),u}(M)}}();
//# sourceMappingURL=accessible-menu.min.js.map

@@ -109,2 +109,4 @@ function _typeof(obj) {

return call;
} else if (call !== void 0) {
throw new TypeError("Derived constructors may only return object or undefined");
}

@@ -356,14 +358,2 @@

}
function isEventSupported(event, element) {
if (isValidType("string", {
event: event
}) && isValidInstance(HTMLElement, {
element: element
})) {
var eventProp = "on".concat(event);
return typeof element[eventProp] !== "undefined";
} else {
return false;
}
}

@@ -1134,4 +1124,2 @@ var BaseMenuToggle = function () {

var _this4 = this;
var startEventType = isEventSupported("touchstart", this.dom.menu) ? "touchstart" : "mousedown";
var endEventType = isEventSupported("touchend", this.dom.menu) ? "touchend" : "mouseup";
function toggleToggle(menu, toggle, event) {

@@ -1146,19 +1134,21 @@ preventEvent(event);

this.elements.menuItems.forEach(function (item, index) {
item.dom.link.addEventListener(startEventType, function () {
item.dom.link.addEventListener("pointerdown", function () {
_this4.currentEvent = "mouse";
_this4.elements.rootMenu.blurChildren();
_this4.focusChild(index);
}, {
passive: true
});
if (item.isSubmenuItem) {
item.elements.toggle.dom.toggle["on".concat(endEventType)] = function (event) {
item.elements.toggle.dom.toggle.addEventListener("pointerup", function (event) {
_this4.currentEvent = "mouse";
toggleToggle(_this4, item.elements.toggle, event);
};
});
}
});
if (this.isTopLevel && this.elements.controller) {
this.elements.controller.dom.toggle["on".concat(endEventType)] = function (event) {
this.elements.controller.dom.toggle.addEventListener("pointerup", function (event) {
_this4.currentEvent = "mouse";
toggleToggle(_this4, _this4.elements.controller, event);
};
});
}

@@ -1548,4 +1538,3 @@ }

_get(_getPrototypeOf(DisclosureMenu.prototype), "_handleClick", this).call(this);
var endEventType = isEventSupported("touchend", this.dom.menu) ? "touchend" : "mouseup";
document.addEventListener(endEventType, function (event) {
document.addEventListener("pointerup", function (event) {
if (_this2.focusState !== "none") {

@@ -1552,0 +1541,0 @@ _this2.currentEvent = "mouse";

@@ -1,2 +0,2 @@

function e(t){return(e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(t)}function t(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function n(e,t){for(var n=0;n<t.length;n++){var o=t[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}function o(e,t,o){return t&&n(e.prototype,t),o&&n(e,o),e}function s(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function r(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&i(e,t)}function l(e){return(l=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function i(e,t){return(i=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function u(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function c(e,t){return!t||"object"!=typeof t&&"function"!=typeof t?u(e):t}function a(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,o=l(e);if(t){var s=l(this).constructor;n=Reflect.construct(o,arguments,s)}else n=o.apply(this,arguments);return c(this,n)}}function m(e,t,n){return(m="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(e,t,n){var o=function(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&null!==(e=l(e)););return e}(e,t);if(o){var s=Object.getOwnPropertyDescriptor(o,t);return s.get?s.get.call(n):s.value}})(e,t,n||e)}function h(e){return function(e){if(Array.isArray(e))return f(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,t){if(!e)return;if("string"==typeof e)return f(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return f(e,t)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function f(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,o=new Array(t);n<t;n++)o[n]=e[n];return o}function d(t,n){try{if("object"!==e(n)){var o=e(n);throw new TypeError("AccessibleMenu: Elements given to isValidInstance() must be inside of an object. ".concat(o," given."))}for(var s in n)if(!(n[s]instanceof t)){var r=e(n[s]);throw new TypeError("AccessibleMenu: ".concat(s," must be an instance of ").concat(t.name,". ").concat(r," given."))}return!0}catch(e){return console.error(e),!1}}function p(t,n){try{if("object"!==e(n)){var o=e(n);throw new TypeError("AccessibleMenu: Values given to isValidType() must be inside of an object. ".concat(o," given."))}for(var s in n){var r=e(n[s]);if(r!==t)throw new TypeError("AccessibleMenu: ".concat(s," must be a ").concat(t,". ").concat(r," given."))}return!0}catch(e){return console.error(e),!1}}function v(t){try{if("object"!==e(t)){var n=e(t);throw new TypeError("AccessibleMenu: Values given to isCSSSelector() must be inside of an object. ".concat(n," given."))}for(var o in t)try{if(null===t[o])throw new Error;document.querySelector(t[o])}catch(e){throw new TypeError("AccessibleMenu: ".concat(o,' must be a valid CSS selector. "').concat(t[o],'" given.'))}return!0}catch(e){return console.error(e),!1}}function y(t){try{if("object"!==e(t)||Array.isArray(t)){var n=e(t);throw new TypeError("AccessibleMenu: Values given to isValidClassList() must be inside of an object. ".concat(n," given."))}var o=function(n){var o=e(t[n]);if("string"!==o){if(!Array.isArray(t[n]))throw new TypeError("AccessibleMenu: ".concat(n," must be a string or an array of strings. ").concat(o," given."));t[n].forEach((function(e){if("string"!=typeof e)throw new TypeError("AccessibleMenu: ".concat(n," must be a string or an array of strings. An array containing non-strings given."))}))}else{var s={};s[n]=t[n],v(s)}};for(var s in t)o(s);return!0}catch(e){return console.error(e),!1}}function g(t){try{if("object"!==e(t)){var n=e(t);throw new TypeError("AccessibleMenu: Values given to isValidHoverType() must be inside of an object. ".concat(n," given."))}var o=["off","on","dynamic"];for(var s in t)if(!o.includes(t[s]))throw new TypeError("AccessibleMenu: ".concat(s," must be one of the following values: ").concat(o.join(", "),'. "').concat(t[s],'" given.'));return!0}catch(e){return console.error(e),!1}}function b(e,t){return!(!p("string",{event:e})||!d(HTMLElement,{element:t}))&&void 0!==t["on".concat(e)]}var _=function(){function e(n){var o=n.menuToggleElement,r=n.parentElement,l=n.controlledMenu,i=n.parentMenu,u=void 0===i?null:i;t(this,e),s(this,"_dom",{toggle:null,parent:null}),s(this,"_elements",{controlledMenu:null,parentMenu:null}),s(this,"_open",!1),s(this,"_expandEvent",new CustomEvent("accessibleMenuExpand",{bubbles:!0,detail:{toggle:this}})),s(this,"_collapseEvent",new CustomEvent("accessibleMenuCollapse",{bubbles:!0,detail:{toggle:this}})),this._dom.toggle=o,this._dom.parent=r,this._elements.controlledMenu=l,this._elements.parentMenu=u}return o(e,[{key:"initialize",value:function(){if(this.dom.toggle.setAttribute("aria-haspopup","true"),this.dom.toggle.setAttribute("aria-expanded","false"),function(e,t){if(p("string",{tagName:e})&&d(HTMLElement,t)){var n=e.toLowerCase(),o=!0;for(var s in t)t[s].tagName.toLowerCase()!==n&&(o=!1);return o}return!1}("button",{toggle:this.dom.toggle})||this.dom.toggle.setAttribute("role","button"),""===this.dom.toggle.id||""===this.elements.controlledMenu.dom.menu.id){var e=Math.random().toString(36).replace(/[^a-z]+/g,"").substr(0,10),t=this.dom.toggle.innerText.replace(/[^a-zA-Z0-9\s]/g,""),n=e;!t.replace(/\s/g,"").length&&this.dom.toggle.getAttribute("aria-label")&&(t=this.dom.toggle.getAttribute("aria-label").replace(/[^a-zA-Z0-9\s]/g,"")),t.replace(/\s/g,"").length>0&&((t=t.toLowerCase().replace(/\s+/g,"-")).startsWith("-")&&(t=t.substring(1)),t.endsWith("-")&&(t=t.slice(0,-1)),n="".concat(t,"-").concat(n)),this.dom.toggle.id=this.dom.toggle.id||"".concat(n,"-menu-button"),this.elements.controlledMenu.dom.menu.id=this.elements.controlledMenu.dom.menu.id||"".concat(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)}},{key:"dom",get:function(){return this._dom}},{key:"elements",get:function(){return this._elements}},{key:"isOpen",get:function(){return this._open},set:function(e){p("boolean",{value:e}),this._open=e}},{key:"_expand",value:function(){var e,t,n=!(arguments.length>0&&void 0!==arguments[0])||arguments[0],o=this.elements.controlledMenu,s=o.closeClass,r=o.openClass;(this.dom.toggle.setAttribute("aria-expanded","true"),""!==r)&&("string"==typeof r?this.elements.controlledMenu.dom.menu.classList.add(r):(e=this.elements.controlledMenu.dom.menu.classList).add.apply(e,h(r)));""!==s&&("string"==typeof s?this.elements.controlledMenu.dom.menu.classList.remove(s):(t=this.elements.controlledMenu.dom.menu.classList).remove.apply(t,h(s)));n&&this.dom.toggle.dispatchEvent(this._expandEvent)}},{key:"_collapse",value:function(){var e,t,n=!(arguments.length>0&&void 0!==arguments[0])||arguments[0],o=this.elements.controlledMenu,s=o.closeClass,r=o.openClass;(this.dom.toggle.setAttribute("aria-expanded","false"),""!==s)&&("string"==typeof s?this.elements.controlledMenu.dom.menu.classList.add(s):(e=this.elements.controlledMenu.dom.menu.classList).add.apply(e,h(s)));""!==r&&("string"==typeof r?this.elements.controlledMenu.dom.menu.classList.remove(r):(t=this.elements.controlledMenu.dom.menu.classList).remove.apply(t,h(r)));n&&this.dom.toggle.dispatchEvent(this._collapseEvent)}},{key:"open",value:function(){this.elements.controlledMenu.focusState="self",this._expand(),this.isOpen=!0}},{key:"preview",value:function(){this.elements.parentMenu&&(this.elements.parentMenu.focusState="self"),this._expand(),this.isOpen=!0}},{key:"close",value:function(){this.isOpen&&(this.elements.controlledMenu.currentChild=0,this.elements.controlledMenu.blur(),this.elements.parentMenu&&(this.elements.parentMenu.focusState="self"),this._collapse(),this.isOpen=!1)}},{key:"toggle",value:function(){this.isOpen?this.close():this.open()}},{key:"closeSiblings",value:function(){var e=this;this.elements.parentMenu&&this.elements.parentMenu.elements.submenuToggles.forEach((function(t){t!==e&&t.close()}))}},{key:"closeChildren",value:function(){this.elements.controlledMenu.elements.submenuToggles.forEach((function(e){return e.close()}))}}]),e}(),M=function(){function e(n){var o=n.menuItemElement,r=n.menuLinkElement,l=n.parentMenu,i=n.isSubmenuItem,u=void 0!==i&&i,c=n.childMenu,a=void 0===c?null:c,m=n.toggle,h=void 0===m?null:m;t(this,e),s(this,"_dom",{item:null,link:null}),s(this,"_elements",{parentMenu:null,childMenu:null,toggle:null}),s(this,"_submenu",!1),this._dom.item=o,this._dom.link=r,this._elements.parentMenu=l,this._elements.childMenu=a,this._elements.toggle=h,this._submenu=u}return o(e,[{key:"initialize",value:function(){}},{key:"dom",get:function(){return this._dom}},{key:"elements",get:function(){return this._elements}},{key:"isSubmenuItem",get:function(){return this._submenu}},{key:"focus",value:function(){this.elements.parentMenu.shouldFocus&&this.dom.link.focus()}},{key:"blur",value:function(){this.elements.parentMenu.shouldFocus&&this.dom.link.blur()}}]),e}();function E(e){try{var t=e.key||e.keyCode,n={Enter:"Enter"===t||13===t,Space:" "===t||"Spacebar"===t||32===t,Escape:"Escape"===t||"Esc"===t||27===t,ArrowUp:"ArrowUp"===t||"Up"===t||38===t,ArrowRight:"ArrowRight"===t||"Right"===t||39===t,ArrowDown:"ArrowDown"===t||"Down"===t||40===t,ArrowLeft:"ArrowLeft"===t||"Left"===t||37===t,Home:"Home"===t||36===t,End:"End"===t||35===t,Character:isNaN(t)&&!!t.match(/^[a-zA-Z]{1}$/),Tab:"Tab"===t||9===t,Asterisk:"*"===t||56===t};return Object.keys(n).find((function(e){return!0===n[e]}))||""}catch(e){return""}}function C(e){e.preventDefault(),e.stopPropagation()}var T=function(){function n(e){var o=e.menuElement,r=e.menuItemSelector,l=void 0===r?"li":r,i=e.menuLinkSelector,u=void 0===i?"a":i,c=e.submenuItemSelector,a=void 0===c?"":c,m=e.submenuToggleSelector,h=void 0===m?"a":m,f=e.submenuSelector,d=void 0===f?"ul":f,p=e.controllerElement,v=void 0===p?null:p,y=e.containerElement,g=void 0===y?null:y,b=e.openClass,E=void 0===b?"show":b,C=e.closeClass,T=void 0===C?"hide":C,k=e.isTopLevel,w=void 0===k||k,S=e.parentMenu,I=void 0===S?null:S,L=e.hoverType,A=void 0===L?"off":L,O=e.hoverDelay,D=void 0===O?250:O;t(this,n),s(this,"_MenuType",n),s(this,"_MenuItemType",M),s(this,"_MenuToggleType",_),s(this,"_dom",{menu:null,menuItems:[],submenuItems:[],submenuToggles:[],submenus:[],controller:null,container:null}),s(this,"_selectors",{menuItems:"",menuLinks:"",submenuItems:"",submenuToggles:"",submenus:""}),s(this,"_elements",{menuItems:[],submenuToggles:[],controller:null,parentMenu:null,rootMenu:null}),s(this,"_openClass","show"),s(this,"_closeClass","hide"),s(this,"_root",!0),s(this,"_currentChild",0),s(this,"_focusState","none"),s(this,"_currentEvent","none"),s(this,"_hoverType","off"),s(this,"_hoverDelay",250),this._dom.menu=o,this._dom.controller=v,this._dom.container=g,this._selectors.menuItems=l,this._selectors.menuLinks=u,this._selectors.submenuItems=a,this._selectors.submenuToggles=h,this._selectors.submenus=d,this._elements.menuItems=[],this._elements.submenuToggles=[],this._elements.controller=null,this._elements.parentMenu=I,this._elements.rootMenu=w?this:null,this._openClass=E||"",this._closeClass=T||"",this._root=w,this._hoverType=A,this._hoverDelay=D}return o(n,[{key:"initialize",value:function(){if(!this._validate())throw new Error("AccesibleMenu: cannot initialize menu. See other error messages for more information.");if(null===this.elements.rootMenu&&this._findRootMenu(this),this._setDOMElements(),this.isTopLevel&&this.dom.controller&&this.dom.container){var e=new this._MenuToggleType({menuToggleElement:this.dom.controller,parentElement:this.dom.container,controlledMenu:this});this._elements.controller=e}this._createChildElements()}},{key:"dom",get:function(){return this._dom}},{key:"selectors",get:function(){return this._selectors}},{key:"elements",get:function(){return this._elements}},{key:"isTopLevel",get:function(){return this._root}},{key:"openClass",get:function(){return this.isTopLevel?this._openClass:this.elements.rootMenu.openClass},set:function(e){y({openClass:e}),this._openClass!==e&&(this._openClass=e)}},{key:"closeClass",get:function(){return this.isTopLevel?this._closeClass:this.elements.rootMenu.closeClass},set:function(e){y({closeClass:e}),this._closeClass!==e&&(this._closeClass=e)}},{key:"currentChild",get:function(){return this._currentChild},set:function(e){function t(e){if(["mouse","character"].includes(e.currentEvent)&&e.elements.parentMenu)for(var t=0,n=!1;!n&&t<e.elements.parentMenu.elements.menuItems.length;){var o=e.elements.parentMenu.elements.menuItems[t];o.isSubmenuItem&&o.elements.toggle.elements.controlledMenu===e&&(n=!0,e.elements.parentMenu.currentEvent=e.currentEvent,e.elements.parentMenu.currentChild=t),t++}}p("number",{value:e}),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))}},{key:"focusState",get:function(){return this._focusState},set:function(t){!function(t){try{if("object"!==e(t)){var n=e(t);throw new TypeError("AccessibleMenu: Values given to isValidState() must be inside of an object. ".concat(n," given."))}var o=["none","self","child"];for(var s in t)if(!o.includes(t[s]))throw new TypeError("AccessibleMenu: ".concat(s," must be one of the following values: ").concat(o.join(", "),'. "').concat(t[s],'" given.'))}catch(e){return console.error(e),!1}}({value:t}),this._focusState!==t&&(this._focusState=t),this.elements.submenuToggles.length>0&&("self"===t||"none"===t)&&this.elements.submenuToggles.forEach((function(e){e.elements.controlledMenu.focusState="none"})),!this.elements.parentMenu||"self"!==t&&"child"!==t||(this.elements.parentMenu.focusState="child")}},{key:"currentEvent",get:function(){return this._currentEvent},set:function(t){!function(t){try{if("object"!==e(t)){var n=e(t);throw new TypeError("AccessibleMenu: Values given to isValidEvent() must be inside of an object. ".concat(n," given."))}var o=["none","mouse","keyboard","character"];for(var s in t)if(!o.includes(t[s]))throw new TypeError("AccessibleMenu: ".concat(s," must be one of the following values: ").concat(o.join(", "),'. "').concat(t[s],'" given.'))}catch(e){return console.error(e),!1}}({value:t}),this._currentEvent!==t&&(this._currentEvent=t,this.elements.submenuToggles.length>0&&this.elements.submenuToggles.forEach((function(e){e.elements.controlledMenu.currentEvent=t})))}},{key:"currentMenuItem",get:function(){return this.elements.menuItems[this.currentChild]}},{key:"hoverType",get:function(){return this._root?this._hoverType:this.elements.rootMenu.hoverType},set:function(e){g({value:e}),this._hoverType!==e&&(this._hoverType=e)}},{key:"hoverDelay",get:function(){return this._root?this._hoverDelay:this.elements.rootMenu.hoverDelay},set:function(e){p("number",{value:e}),this._hoverDelay!==e&&(this._hoverDelay=e)}},{key:"shouldFocus",get:function(){var e=!1;return"keyboard"!==this.currentEvent&&"character"!==this.currentEvent||(e=!0),"mouse"===this.currentEvent&&"dynamic"===this.hoverType&&(e=!0),e}},{key:"_validate",value:function(){var e=!0;return null!==this._dom.container||null!==this._dom.controller?d(HTMLElement,{menuElement:this._dom.menu,controllerElement:this._dom.controller,containerElement:this._dom.container})||(e=!1):d(HTMLElement,{menuElement:this._dom.menu})||(e=!1),""!==this._selectors.submenuItems?v({menuItemSelector:this._selectors.menuItems,menuLinkSelector:this._selectors.menuLinks,submenuItemSelector:this._selectors.submenuItems,submenuToggleSelector:this._selectors.submenuToggles,submenuSelector:this._selectors.submenus})||(e=!1):v({menuItemSelector:this._selectors.menuItems,menuLinkSelector:this._selectors.menuLinks})||(e=!1),""===this._openClass||y({openClass:this._openClass})||(e=!1),""===this._closeClass||y({closeClass:this._closeClass})||(e=!1),p("boolean",{isTopLevel:this._root})||(e=!1),null===this._elements.parentMenu||d(n,{parentMenu:this._elements.parentMenu})||(e=!1),g({hoverType:this._hoverType})||(e=!1),p("number",{hoverDelay:this._hoverDelay})||(e=!1),e}},{key:"_setDOMElementType",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.dom.menu,n=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];if("string"!=typeof this.selectors[e])throw new Error('AccessibleMenu: "'.concat(e,'" is not a valid element type within the menu.'));if(!Array.isArray(this.dom[e]))throw new Error('AccessibleMenu: The "'.concat(e,'" element cannot be set through _setDOMElementType.'));t!==this.dom.menu&&d(HTMLElement,{base:t});var o=Array.from(t.querySelectorAll(this.selectors[e])),s=o.filter((function(e){return e.parentElement===t}));this._dom[e]=n?s:[].concat(h(this._dom[e]),h(s))}},{key:"_resetDOMElementType",value:function(e){if(void 0===this.dom[e])throw new Error('AccessibleMenu: "'.concat(e,'" is not a valid element type within the menu.'));if(!Array.isArray(this.dom[e]))throw new Error('AccessibleMenu: The "'.concat(e,'" element cannot be reset through _resetDOMElementType.'));this._dom[e]=[]}},{key:"_setDOMElements",value:function(){var e=this;this._setDOMElementType("menuItems"),""!==this.selectors.submenuItems&&(this._setDOMElementType("submenuItems"),this._resetDOMElementType("submenuToggles"),this._resetDOMElementType("submenus"),this.dom.submenuItems.forEach((function(t){e._setDOMElementType("submenuToggles",t,!1),e._setDOMElementType("submenus",t,!1)})))}},{key:"_findRootMenu",value:function(e){if(e.isTopLevel)this._elements.rootMenu=e;else{if(null===e.elements.parentMenu)throw new Error("Cannot find root menu.");this._findRootMenu(e.elements.parentMenu)}}},{key:"_createChildElements",value:function(){var e=this;this.dom.menuItems.forEach((function(t){var n;if(e.dom.submenuItems.includes(t)){var o=t.querySelector(e.selectors.submenuToggles),s=t.querySelector(e.selectors.submenus),r=new e._MenuType({menuElement:s,menuItemSelector:e.selectors.menuItems,menuLinkSelector:e.selectors.menuLinks,submenuItemSelector:e.selectors.submenuItems,submenuToggleSelector:e.selectors.submenuToggles,submenuSelector:e.selectors.submenus,openClass:e.openClass,closeClass:e.closeClass,isTopLevel:!1,parentMenu:e,hoverType:e.hoverType,hoverDelay:e.hoverDelay}),l=new e._MenuToggleType({menuToggleElement:o,parentElement:t,controlledMenu:r,parentMenu:e});e._elements.submenuToggles.push(l),n=new e._MenuItemType({menuItemElement:t,menuLinkElement:o,parentMenu:e,isSubmenuItem:!0,childMenu:r,toggle:l})}else{var i=t.querySelector(e.selectors.menuLinks);n=new e._MenuItemType({menuItemElement:t,menuLinkElement:i,parentMenu:e})}e._elements.menuItems.push(n)}))}},{key:"_handleFocus",value:function(){var e=this;this.elements.menuItems.forEach((function(t,n){t.dom.link.addEventListener("focus",(function(){e.focusState="self",e.currentChild=n}))}))}},{key:"_handleClick",value:function(){var e=this,t=b("touchstart",this.dom.menu)?"touchstart":"mousedown",n=b("touchend",this.dom.menu)?"touchend":"mouseup";function o(e,t,n){C(n),t.toggle(),t.isOpen&&(e.focusState="self",t.elements.controlledMenu.focusState="none")}this.elements.menuItems.forEach((function(s,r){s.dom.link.addEventListener(t,(function(){e.currentEvent="mouse",e.elements.rootMenu.blurChildren(),e.focusChild(r)})),s.isSubmenuItem&&(s.elements.toggle.dom.toggle["on".concat(n)]=function(t){e.currentEvent="mouse",o(e,s.elements.toggle,t)})})),this.isTopLevel&&this.elements.controller&&(this.elements.controller.dom.toggle["on".concat(n)]=function(t){e.currentEvent="mouse",o(e,e.elements.controller,t)})}},{key:"_handleHover",value:function(){var e=this;this.elements.menuItems.forEach((function(t,n){t.dom.link.addEventListener("mouseenter",(function(){if("on"===e.hoverType)e.currentEvent="mouse",e.currentChild=n,t.isSubmenuItem&&t.elements.toggle.preview();else if("dynamic"===e.hoverType){var o=e.elements.submenuToggles.some((function(e){return e.isOpen}));e.currentChild=n,e.isTopLevel&&"none"===e.focusState||(e.currentEvent="mouse",e.focusCurrentChild()),!t.isSubmenuItem||e.isTopLevel&&!o||(e.currentEvent="mouse",t.elements.toggle.preview())}})),t.isSubmenuItem&&t.dom.item.addEventListener("mouseleave",(function(){"on"===e.hoverType?e.hoverDelay>0?setTimeout((function(){e.currentEvent="mouse",t.elements.toggle.close()}),e.hoverDelay):(e.currentEvent="mouse",t.elements.toggle.close()):"dynamic"===e.hoverType&&(e.isTopLevel||(e.hoverDelay>0?setTimeout((function(){e.currentEvent="mouse",t.elements.toggle.close(),e.focusCurrentChild()}),e.hoverDelay):(e.currentEvent="mouse",t.elements.toggle.close(),e.focusCurrentChild())))}))}))}},{key:"_handleKeydown",value:function(){var e=this;this.isTopLevel&&this.elements.controller&&this.elements.controller.dom.toggle.addEventListener("keydown",(function(t){e.currentEvent="keyboard";var n=E(t);"Space"!==n&&"Enter"!==n||C(t)}))}},{key:"_handleKeyup",value:function(){var e=this;this.isTopLevel&&this.elements.controller&&this.elements.controller.dom.toggle.addEventListener("keyup",(function(t){e.currentEvent="keyboard";var n=E(t);"Space"!==n&&"Enter"!==n||(C(t),e.elements.controller.open(),e.focusFirstChild())}))}},{key:"focus",value:function(){this.focusState="self",this.shouldFocus&&this.dom.menu.focus()}},{key:"blur",value:function(){this.focusState="none",this.shouldFocus&&this.dom.menu.blur()}},{key:"focusCurrentChild",value:function(){this.focusState="self",-1!==this.currentChild&&this.currentMenuItem.focus()}},{key:"focusChild",value:function(e){this.blurCurrentChild(),this.currentChild=e,this.focusCurrentChild()}},{key:"focusFirstChild",value:function(){this.focusChild(0)}},{key:"focusLastChild",value:function(){this.focusChild(this.elements.menuItems.length-1)}},{key:"focusNextChild",value:function(){this.currentChild<this.elements.menuItems.length-1?this.focusChild(this.currentChild+1):this.focusCurrentChild()}},{key:"focusPreviousChild",value:function(){this.currentChild>0?this.focusChild(this.currentChild-1):this.focusCurrentChild()}},{key:"blurCurrentChild",value:function(){this.focusState="none",-1!==this.currentChild&&this.currentMenuItem.blur()}},{key:"focusController",value:function(){this.dom.controller&&(this.shouldFocus&&this.dom.controller.focus(),this.focusState="none")}},{key:"focusContainer",value:function(){this.dom.container&&(this.shouldFocus&&this.dom.container.focus(),this.focusState="none")}},{key:"closeChildren",value:function(){this.elements.submenuToggles.forEach((function(e){return e.close()}))}},{key:"blurChildren",value:function(){this.elements.menuItems.forEach((function(e){e.blur(),e.isSubmenuItem&&e.elements.childMenu.blurChildren()}))}}]),n}(),k=function(e){r(o,M);var n=a(o);function o(e){var s,r=e.menuItemElement,l=e.menuLinkElement,i=e.parentMenu,u=e.isSubmenuItem,c=void 0!==u&&u,a=e.childMenu,m=void 0===a?null:a,h=e.toggle,f=void 0===h?null:h,d=e.initialize,p=void 0===d||d;return t(this,o),s=n.call(this,{menuItemElement:r,menuLinkElement:l,parentMenu:i,isSubmenuItem:c,childMenu:m,toggle:f}),p&&s.initialize(),s}return o}(),w=function(e){r(s,_);var n=a(s);function s(e){var o,r=e.menuToggleElement,l=e.parentElement,i=e.controlledMenu,u=e.parentMenu,c=void 0===u?null:u,a=e.initialize,m=void 0===a||a;return t(this,s),o=n.call(this,{menuToggleElement:r,parentElement:l,controlledMenu:i,parentMenu:c}),m&&o.initialize(),o}return o(s,[{key:"open",value:function(){this.closeSiblings(),m(l(s.prototype),"open",this).call(this)}},{key:"preview",value:function(){this.closeSiblings(),m(l(s.prototype),"preview",this).call(this)}},{key:"close",value:function(){this.isOpen&&this.closeChildren(),m(l(s.prototype),"close",this).call(this)}}]),s}(),S=function(e){r(i,T);var n=a(i);function i(e){var o,r=e.menuElement,l=e.menuItemSelector,c=void 0===l?"li":l,a=e.menuLinkSelector,m=void 0===a?"a":a,h=e.submenuItemSelector,f=void 0===h?"":h,d=e.submenuToggleSelector,p=void 0===d?"a":d,v=e.submenuSelector,y=void 0===v?"ul":v,g=e.controllerElement,b=void 0===g?null:g,_=e.containerElement,M=void 0===_?null:_,E=e.openClass,C=void 0===E?"show":E,T=e.closeClass,S=void 0===T?"hide":T,I=e.isTopLevel,L=void 0===I||I,A=e.parentMenu,O=void 0===A?null:A,D=e.hoverType,j=void 0===D?"off":D,R=e.hoverDelay,z=void 0===R?250:R,x=e.optionalKeySupport,K=void 0!==x&&x,F=e.initialize,H=void 0===F||F;return t(this,i),s(u(o=n.call(this,{menuElement:r,menuItemSelector:c,menuLinkSelector:m,submenuItemSelector:f,submenuToggleSelector:p,submenuSelector:y,controllerElement:b,containerElement:M,openClass:C,closeClass:S,isTopLevel:L,parentMenu:O,hoverType:j,hoverDelay:z})),"_MenuType",i),s(u(o),"_MenuItemType",k),s(u(o),"_MenuToggleType",w),s(u(o),"_currentChild",-1),s(u(o),"_optionalSupport",!1),o._optionalSupport=K,H&&o.initialize(),o}return o(i,[{key:"initialize",value:function(){try{m(l(i.prototype),"initialize",this).call(this),this._handleFocus(),this._handleClick(),this._handleHover(),this._handleKeydown(),this._handleKeyup()}catch(e){console.error(e)}}},{key:"optionalKeySupport",get:function(){return this.isTopLevel?this._optionalSupport:this.elements.rootMenu.optionalKeySupport},set:function(e){p("boolean",{optionalKeySupport:e}),this._optionalSupport=e}},{key:"_validate",value:function(){var e=m(l(i.prototype),"_validate",this).call(this);return p("boolean",{optionalKeySupport:this._optionalSupport})||(e=!1),e}},{key:"_handleClick",value:function(){var e=this;m(l(i.prototype),"_handleClick",this).call(this);var t=b("touchend",this.dom.menu)?"touchend":"mouseup";document.addEventListener(t,(function(t){"none"!==e.focusState&&(e.currentEvent="mouse",e.dom.menu.contains(t.target)||!e.dom.menu===t.target||(e.closeChildren(),e.blur(),e.elements.controller&&e.elements.controller.close()))}))}},{key:"_handleKeydown",value:function(){var e=this;m(l(i.prototype),"_handleKeydown",this).call(this),this.dom.menu.addEventListener("keydown",(function(t){e.currentEvent="keyboard";var n=E(t);if("self"===e.focusState){if(e.optionalKeySupport){["ArrowUp","ArrowRight","ArrowDown","ArrowLeft","Home","End"].includes(n)&&C(t)}else(e.currentMenuItem.isSubmenuItem&&["Space","Enter"].includes(n)||e.elements.controller&&["Escape"].includes(n)||e.elements.parentMenu&&["Escape"].includes(n))&&C(t)}}))}},{key:"_handleKeyup",value:function(){var e=this;m(l(i.prototype),"_handleKeyup",this).call(this),this.dom.menu.addEventListener("keyup",(function(t){e.currentEvent="keyboard";var n=E(t);if("self"===e.focusState)if("Space"===n||"Enter"===n)e.currentMenuItem.isSubmenuItem?(C(t),e.currentMenuItem.elements.toggle.preview()):e.currentMenuItem.dom.link.click();else if("Escape"===n){e.elements.submenuToggles.some((function(e){return e.isOpen}))?(C(t),e.closeChildren()):e.elements.parentMenu?(C(t),e.elements.parentMenu.currentEvent=e.currentEvent,e.elements.parentMenu.closeChildren(),e.elements.parentMenu.focusCurrentChild()):e.isTopLevel&&e.elements.controller&&e.elements.controller.isOpen&&(e.elements.controller.close(),e.focusController())}else e.optionalKeySupport&&("ArrowDown"===n||"ArrowRight"===n?(C(t),e.currentMenuItem.isSubmenuItem&&e.currentMenuItem.elements.toggle.isOpen?(e.currentMenuItem.elements.childMenu.currentEvent="keyboard",e.currentMenuItem.elements.childMenu.focusFirstChild()):e.focusNextChild()):"ArrowUp"===n||"ArrowLeft"===n?(C(t),e.focusPreviousChild()):"Home"===n?(C(t),e.focusFirstChild()):"End"===n&&(C(t),e.focusLastChild()))}))}}]),i}();export{S as default};
function e(t){return e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},e(t)}function t(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function n(e,t){for(var n=0;n<t.length;n++){var o=t[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}function o(e,t,o){return t&&n(e.prototype,t),o&&n(e,o),e}function s(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function r(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&l(e,t)}function i(e){return i=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},i(e)}function l(e,t){return l=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},l(e,t)}function u(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function c(e,t){if(t&&("object"==typeof t||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return u(e)}function a(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,o=i(e);if(t){var s=i(this).constructor;n=Reflect.construct(o,arguments,s)}else n=o.apply(this,arguments);return c(this,n)}}function m(e,t,n){return m="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(e,t,n){var o=function(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&null!==(e=i(e)););return e}(e,t);if(o){var s=Object.getOwnPropertyDescriptor(o,t);return s.get?s.get.call(n):s.value}},m(e,t,n||e)}function h(e){return function(e){if(Array.isArray(e))return f(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,t){if(!e)return;if("string"==typeof e)return f(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return f(e,t)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function f(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,o=new Array(t);n<t;n++)o[n]=e[n];return o}function d(t,n){try{if("object"!==e(n)){var o=e(n);throw new TypeError("AccessibleMenu: Elements given to isValidInstance() must be inside of an object. ".concat(o," given."))}for(var s in n)if(!(n[s]instanceof t)){var r=e(n[s]);throw new TypeError("AccessibleMenu: ".concat(s," must be an instance of ").concat(t.name,". ").concat(r," given."))}return!0}catch(e){return console.error(e),!1}}function p(t,n){try{if("object"!==e(n)){var o=e(n);throw new TypeError("AccessibleMenu: Values given to isValidType() must be inside of an object. ".concat(o," given."))}for(var s in n){var r=e(n[s]);if(r!==t)throw new TypeError("AccessibleMenu: ".concat(s," must be a ").concat(t,". ").concat(r," given."))}return!0}catch(e){return console.error(e),!1}}function v(t){try{if("object"!==e(t)){var n=e(t);throw new TypeError("AccessibleMenu: Values given to isCSSSelector() must be inside of an object. ".concat(n," given."))}for(var o in t)try{if(null===t[o])throw new Error;document.querySelector(t[o])}catch(e){throw new TypeError("AccessibleMenu: ".concat(o,' must be a valid CSS selector. "').concat(t[o],'" given.'))}return!0}catch(e){return console.error(e),!1}}function y(t){try{if("object"!==e(t)||Array.isArray(t)){var n=e(t);throw new TypeError("AccessibleMenu: Values given to isValidClassList() must be inside of an object. ".concat(n," given."))}var o=function(n){var o=e(t[n]);if("string"!==o){if(!Array.isArray(t[n]))throw new TypeError("AccessibleMenu: ".concat(n," must be a string or an array of strings. ").concat(o," given."));t[n].forEach((function(e){if("string"!=typeof e)throw new TypeError("AccessibleMenu: ".concat(n," must be a string or an array of strings. An array containing non-strings given."))}))}else{var s={};s[n]=t[n],v(s)}};for(var s in t)o(s);return!0}catch(e){return console.error(e),!1}}function g(t){try{if("object"!==e(t)){var n=e(t);throw new TypeError("AccessibleMenu: Values given to isValidHoverType() must be inside of an object. ".concat(n," given."))}var o=["off","on","dynamic"];for(var s in t)if(!o.includes(t[s]))throw new TypeError("AccessibleMenu: ".concat(s," must be one of the following values: ").concat(o.join(", "),'. "').concat(t[s],'" given.'));return!0}catch(e){return console.error(e),!1}}var b=function(){function e(n){var o=n.menuToggleElement,r=n.parentElement,i=n.controlledMenu,l=n.parentMenu,u=void 0===l?null:l;t(this,e),s(this,"_dom",{toggle:null,parent:null}),s(this,"_elements",{controlledMenu:null,parentMenu:null}),s(this,"_open",!1),s(this,"_expandEvent",new CustomEvent("accessibleMenuExpand",{bubbles:!0,detail:{toggle:this}})),s(this,"_collapseEvent",new CustomEvent("accessibleMenuCollapse",{bubbles:!0,detail:{toggle:this}})),this._dom.toggle=o,this._dom.parent=r,this._elements.controlledMenu=i,this._elements.parentMenu=u}return o(e,[{key:"initialize",value:function(){if(this.dom.toggle.setAttribute("aria-haspopup","true"),this.dom.toggle.setAttribute("aria-expanded","false"),function(e,t){if(p("string",{tagName:e})&&d(HTMLElement,t)){var n=e.toLowerCase(),o=!0;for(var s in t)t[s].tagName.toLowerCase()!==n&&(o=!1);return o}return!1}("button",{toggle:this.dom.toggle})||this.dom.toggle.setAttribute("role","button"),""===this.dom.toggle.id||""===this.elements.controlledMenu.dom.menu.id){var e=Math.random().toString(36).replace(/[^a-z]+/g,"").substr(0,10),t=this.dom.toggle.innerText.replace(/[^a-zA-Z0-9\s]/g,""),n=e;!t.replace(/\s/g,"").length&&this.dom.toggle.getAttribute("aria-label")&&(t=this.dom.toggle.getAttribute("aria-label").replace(/[^a-zA-Z0-9\s]/g,"")),t.replace(/\s/g,"").length>0&&((t=t.toLowerCase().replace(/\s+/g,"-")).startsWith("-")&&(t=t.substring(1)),t.endsWith("-")&&(t=t.slice(0,-1)),n="".concat(t,"-").concat(n)),this.dom.toggle.id=this.dom.toggle.id||"".concat(n,"-menu-button"),this.elements.controlledMenu.dom.menu.id=this.elements.controlledMenu.dom.menu.id||"".concat(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)}},{key:"dom",get:function(){return this._dom}},{key:"elements",get:function(){return this._elements}},{key:"isOpen",get:function(){return this._open},set:function(e){p("boolean",{value:e}),this._open=e}},{key:"_expand",value:function(){var e,t,n=!(arguments.length>0&&void 0!==arguments[0])||arguments[0],o=this.elements.controlledMenu,s=o.closeClass,r=o.openClass;(this.dom.toggle.setAttribute("aria-expanded","true"),""!==r)&&("string"==typeof r?this.elements.controlledMenu.dom.menu.classList.add(r):(e=this.elements.controlledMenu.dom.menu.classList).add.apply(e,h(r)));""!==s&&("string"==typeof s?this.elements.controlledMenu.dom.menu.classList.remove(s):(t=this.elements.controlledMenu.dom.menu.classList).remove.apply(t,h(s)));n&&this.dom.toggle.dispatchEvent(this._expandEvent)}},{key:"_collapse",value:function(){var e,t,n=!(arguments.length>0&&void 0!==arguments[0])||arguments[0],o=this.elements.controlledMenu,s=o.closeClass,r=o.openClass;(this.dom.toggle.setAttribute("aria-expanded","false"),""!==s)&&("string"==typeof s?this.elements.controlledMenu.dom.menu.classList.add(s):(e=this.elements.controlledMenu.dom.menu.classList).add.apply(e,h(s)));""!==r&&("string"==typeof r?this.elements.controlledMenu.dom.menu.classList.remove(r):(t=this.elements.controlledMenu.dom.menu.classList).remove.apply(t,h(r)));n&&this.dom.toggle.dispatchEvent(this._collapseEvent)}},{key:"open",value:function(){this.elements.controlledMenu.focusState="self",this._expand(),this.isOpen=!0}},{key:"preview",value:function(){this.elements.parentMenu&&(this.elements.parentMenu.focusState="self"),this._expand(),this.isOpen=!0}},{key:"close",value:function(){this.isOpen&&(this.elements.controlledMenu.currentChild=0,this.elements.controlledMenu.blur(),this.elements.parentMenu&&(this.elements.parentMenu.focusState="self"),this._collapse(),this.isOpen=!1)}},{key:"toggle",value:function(){this.isOpen?this.close():this.open()}},{key:"closeSiblings",value:function(){var e=this;this.elements.parentMenu&&this.elements.parentMenu.elements.submenuToggles.forEach((function(t){t!==e&&t.close()}))}},{key:"closeChildren",value:function(){this.elements.controlledMenu.elements.submenuToggles.forEach((function(e){return e.close()}))}}]),e}(),_=function(){function e(n){var o=n.menuItemElement,r=n.menuLinkElement,i=n.parentMenu,l=n.isSubmenuItem,u=void 0!==l&&l,c=n.childMenu,a=void 0===c?null:c,m=n.toggle,h=void 0===m?null:m;t(this,e),s(this,"_dom",{item:null,link:null}),s(this,"_elements",{parentMenu:null,childMenu:null,toggle:null}),s(this,"_submenu",!1),this._dom.item=o,this._dom.link=r,this._elements.parentMenu=i,this._elements.childMenu=a,this._elements.toggle=h,this._submenu=u}return o(e,[{key:"initialize",value:function(){}},{key:"dom",get:function(){return this._dom}},{key:"elements",get:function(){return this._elements}},{key:"isSubmenuItem",get:function(){return this._submenu}},{key:"focus",value:function(){this.elements.parentMenu.shouldFocus&&this.dom.link.focus()}},{key:"blur",value:function(){this.elements.parentMenu.shouldFocus&&this.dom.link.blur()}}]),e}();function E(e){try{var t=e.key||e.keyCode,n={Enter:"Enter"===t||13===t,Space:" "===t||"Spacebar"===t||32===t,Escape:"Escape"===t||"Esc"===t||27===t,ArrowUp:"ArrowUp"===t||"Up"===t||38===t,ArrowRight:"ArrowRight"===t||"Right"===t||39===t,ArrowDown:"ArrowDown"===t||"Down"===t||40===t,ArrowLeft:"ArrowLeft"===t||"Left"===t||37===t,Home:"Home"===t||36===t,End:"End"===t||35===t,Character:isNaN(t)&&!!t.match(/^[a-zA-Z]{1}$/),Tab:"Tab"===t||9===t,Asterisk:"*"===t||56===t};return Object.keys(n).find((function(e){return!0===n[e]}))||""}catch(e){return""}}function M(e){e.preventDefault(),e.stopPropagation()}var C=function(){function n(e){var o=e.menuElement,r=e.menuItemSelector,i=void 0===r?"li":r,l=e.menuLinkSelector,u=void 0===l?"a":l,c=e.submenuItemSelector,a=void 0===c?"":c,m=e.submenuToggleSelector,h=void 0===m?"a":m,f=e.submenuSelector,d=void 0===f?"ul":f,p=e.controllerElement,v=void 0===p?null:p,y=e.containerElement,g=void 0===y?null:y,E=e.openClass,M=void 0===E?"show":E,C=e.closeClass,T=void 0===C?"hide":C,w=e.isTopLevel,k=void 0===w||w,S=e.parentMenu,I=void 0===S?null:S,L=e.hoverType,A=void 0===L?"off":L,O=e.hoverDelay,D=void 0===O?250:O;t(this,n),s(this,"_MenuType",n),s(this,"_MenuItemType",_),s(this,"_MenuToggleType",b),s(this,"_dom",{menu:null,menuItems:[],submenuItems:[],submenuToggles:[],submenus:[],controller:null,container:null}),s(this,"_selectors",{menuItems:"",menuLinks:"",submenuItems:"",submenuToggles:"",submenus:""}),s(this,"_elements",{menuItems:[],submenuToggles:[],controller:null,parentMenu:null,rootMenu:null}),s(this,"_openClass","show"),s(this,"_closeClass","hide"),s(this,"_root",!0),s(this,"_currentChild",0),s(this,"_focusState","none"),s(this,"_currentEvent","none"),s(this,"_hoverType","off"),s(this,"_hoverDelay",250),this._dom.menu=o,this._dom.controller=v,this._dom.container=g,this._selectors.menuItems=i,this._selectors.menuLinks=u,this._selectors.submenuItems=a,this._selectors.submenuToggles=h,this._selectors.submenus=d,this._elements.menuItems=[],this._elements.submenuToggles=[],this._elements.controller=null,this._elements.parentMenu=I,this._elements.rootMenu=k?this:null,this._openClass=M||"",this._closeClass=T||"",this._root=k,this._hoverType=A,this._hoverDelay=D}return o(n,[{key:"initialize",value:function(){if(!this._validate())throw new Error("AccesibleMenu: cannot initialize menu. See other error messages for more information.");if(null===this.elements.rootMenu&&this._findRootMenu(this),this._setDOMElements(),this.isTopLevel&&this.dom.controller&&this.dom.container){var e=new this._MenuToggleType({menuToggleElement:this.dom.controller,parentElement:this.dom.container,controlledMenu:this});this._elements.controller=e}this._createChildElements()}},{key:"dom",get:function(){return this._dom}},{key:"selectors",get:function(){return this._selectors}},{key:"elements",get:function(){return this._elements}},{key:"isTopLevel",get:function(){return this._root}},{key:"openClass",get:function(){return this.isTopLevel?this._openClass:this.elements.rootMenu.openClass},set:function(e){y({openClass:e}),this._openClass!==e&&(this._openClass=e)}},{key:"closeClass",get:function(){return this.isTopLevel?this._closeClass:this.elements.rootMenu.closeClass},set:function(e){y({closeClass:e}),this._closeClass!==e&&(this._closeClass=e)}},{key:"currentChild",get:function(){return this._currentChild},set:function(e){function t(e){if(["mouse","character"].includes(e.currentEvent)&&e.elements.parentMenu)for(var t=0,n=!1;!n&&t<e.elements.parentMenu.elements.menuItems.length;){var o=e.elements.parentMenu.elements.menuItems[t];o.isSubmenuItem&&o.elements.toggle.elements.controlledMenu===e&&(n=!0,e.elements.parentMenu.currentEvent=e.currentEvent,e.elements.parentMenu.currentChild=t),t++}}p("number",{value:e}),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))}},{key:"focusState",get:function(){return this._focusState},set:function(t){!function(t){try{if("object"!==e(t)){var n=e(t);throw new TypeError("AccessibleMenu: Values given to isValidState() must be inside of an object. ".concat(n," given."))}var o=["none","self","child"];for(var s in t)if(!o.includes(t[s]))throw new TypeError("AccessibleMenu: ".concat(s," must be one of the following values: ").concat(o.join(", "),'. "').concat(t[s],'" given.'))}catch(e){return console.error(e),!1}}({value:t}),this._focusState!==t&&(this._focusState=t),this.elements.submenuToggles.length>0&&("self"===t||"none"===t)&&this.elements.submenuToggles.forEach((function(e){e.elements.controlledMenu.focusState="none"})),!this.elements.parentMenu||"self"!==t&&"child"!==t||(this.elements.parentMenu.focusState="child")}},{key:"currentEvent",get:function(){return this._currentEvent},set:function(t){!function(t){try{if("object"!==e(t)){var n=e(t);throw new TypeError("AccessibleMenu: Values given to isValidEvent() must be inside of an object. ".concat(n," given."))}var o=["none","mouse","keyboard","character"];for(var s in t)if(!o.includes(t[s]))throw new TypeError("AccessibleMenu: ".concat(s," must be one of the following values: ").concat(o.join(", "),'. "').concat(t[s],'" given.'))}catch(e){return console.error(e),!1}}({value:t}),this._currentEvent!==t&&(this._currentEvent=t,this.elements.submenuToggles.length>0&&this.elements.submenuToggles.forEach((function(e){e.elements.controlledMenu.currentEvent=t})))}},{key:"currentMenuItem",get:function(){return this.elements.menuItems[this.currentChild]}},{key:"hoverType",get:function(){return this._root?this._hoverType:this.elements.rootMenu.hoverType},set:function(e){g({value:e}),this._hoverType!==e&&(this._hoverType=e)}},{key:"hoverDelay",get:function(){return this._root?this._hoverDelay:this.elements.rootMenu.hoverDelay},set:function(e){p("number",{value:e}),this._hoverDelay!==e&&(this._hoverDelay=e)}},{key:"shouldFocus",get:function(){var e=!1;return"keyboard"!==this.currentEvent&&"character"!==this.currentEvent||(e=!0),"mouse"===this.currentEvent&&"dynamic"===this.hoverType&&(e=!0),e}},{key:"_validate",value:function(){var e=!0;return null!==this._dom.container||null!==this._dom.controller?d(HTMLElement,{menuElement:this._dom.menu,controllerElement:this._dom.controller,containerElement:this._dom.container})||(e=!1):d(HTMLElement,{menuElement:this._dom.menu})||(e=!1),""!==this._selectors.submenuItems?v({menuItemSelector:this._selectors.menuItems,menuLinkSelector:this._selectors.menuLinks,submenuItemSelector:this._selectors.submenuItems,submenuToggleSelector:this._selectors.submenuToggles,submenuSelector:this._selectors.submenus})||(e=!1):v({menuItemSelector:this._selectors.menuItems,menuLinkSelector:this._selectors.menuLinks})||(e=!1),""===this._openClass||y({openClass:this._openClass})||(e=!1),""===this._closeClass||y({closeClass:this._closeClass})||(e=!1),p("boolean",{isTopLevel:this._root})||(e=!1),null===this._elements.parentMenu||d(n,{parentMenu:this._elements.parentMenu})||(e=!1),g({hoverType:this._hoverType})||(e=!1),p("number",{hoverDelay:this._hoverDelay})||(e=!1),e}},{key:"_setDOMElementType",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.dom.menu,n=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];if("string"!=typeof this.selectors[e])throw new Error('AccessibleMenu: "'.concat(e,'" is not a valid element type within the menu.'));if(!Array.isArray(this.dom[e]))throw new Error('AccessibleMenu: The "'.concat(e,'" element cannot be set through _setDOMElementType.'));t!==this.dom.menu&&d(HTMLElement,{base:t});var o=Array.from(t.querySelectorAll(this.selectors[e])),s=o.filter((function(e){return e.parentElement===t}));this._dom[e]=n?s:[].concat(h(this._dom[e]),h(s))}},{key:"_resetDOMElementType",value:function(e){if(void 0===this.dom[e])throw new Error('AccessibleMenu: "'.concat(e,'" is not a valid element type within the menu.'));if(!Array.isArray(this.dom[e]))throw new Error('AccessibleMenu: The "'.concat(e,'" element cannot be reset through _resetDOMElementType.'));this._dom[e]=[]}},{key:"_setDOMElements",value:function(){var e=this;this._setDOMElementType("menuItems"),""!==this.selectors.submenuItems&&(this._setDOMElementType("submenuItems"),this._resetDOMElementType("submenuToggles"),this._resetDOMElementType("submenus"),this.dom.submenuItems.forEach((function(t){e._setDOMElementType("submenuToggles",t,!1),e._setDOMElementType("submenus",t,!1)})))}},{key:"_findRootMenu",value:function(e){if(e.isTopLevel)this._elements.rootMenu=e;else{if(null===e.elements.parentMenu)throw new Error("Cannot find root menu.");this._findRootMenu(e.elements.parentMenu)}}},{key:"_createChildElements",value:function(){var e=this;this.dom.menuItems.forEach((function(t){var n;if(e.dom.submenuItems.includes(t)){var o=t.querySelector(e.selectors.submenuToggles),s=t.querySelector(e.selectors.submenus),r=new e._MenuType({menuElement:s,menuItemSelector:e.selectors.menuItems,menuLinkSelector:e.selectors.menuLinks,submenuItemSelector:e.selectors.submenuItems,submenuToggleSelector:e.selectors.submenuToggles,submenuSelector:e.selectors.submenus,openClass:e.openClass,closeClass:e.closeClass,isTopLevel:!1,parentMenu:e,hoverType:e.hoverType,hoverDelay:e.hoverDelay}),i=new e._MenuToggleType({menuToggleElement:o,parentElement:t,controlledMenu:r,parentMenu:e});e._elements.submenuToggles.push(i),n=new e._MenuItemType({menuItemElement:t,menuLinkElement:o,parentMenu:e,isSubmenuItem:!0,childMenu:r,toggle:i})}else{var l=t.querySelector(e.selectors.menuLinks);n=new e._MenuItemType({menuItemElement:t,menuLinkElement:l,parentMenu:e})}e._elements.menuItems.push(n)}))}},{key:"_handleFocus",value:function(){var e=this;this.elements.menuItems.forEach((function(t,n){t.dom.link.addEventListener("focus",(function(){e.focusState="self",e.currentChild=n}))}))}},{key:"_handleClick",value:function(){var e=this;function t(e,t,n){M(n),t.toggle(),t.isOpen&&(e.focusState="self",t.elements.controlledMenu.focusState="none")}this.elements.menuItems.forEach((function(n,o){n.dom.link.addEventListener("pointerdown",(function(){e.currentEvent="mouse",e.elements.rootMenu.blurChildren(),e.focusChild(o)}),{passive:!0}),n.isSubmenuItem&&n.elements.toggle.dom.toggle.addEventListener("pointerup",(function(o){e.currentEvent="mouse",t(e,n.elements.toggle,o)}))})),this.isTopLevel&&this.elements.controller&&this.elements.controller.dom.toggle.addEventListener("pointerup",(function(n){e.currentEvent="mouse",t(e,e.elements.controller,n)}))}},{key:"_handleHover",value:function(){var e=this;this.elements.menuItems.forEach((function(t,n){t.dom.link.addEventListener("mouseenter",(function(){if("on"===e.hoverType)e.currentEvent="mouse",e.currentChild=n,t.isSubmenuItem&&t.elements.toggle.preview();else if("dynamic"===e.hoverType){var o=e.elements.submenuToggles.some((function(e){return e.isOpen}));e.currentChild=n,e.isTopLevel&&"none"===e.focusState||(e.currentEvent="mouse",e.focusCurrentChild()),!t.isSubmenuItem||e.isTopLevel&&!o||(e.currentEvent="mouse",t.elements.toggle.preview())}})),t.isSubmenuItem&&t.dom.item.addEventListener("mouseleave",(function(){"on"===e.hoverType?e.hoverDelay>0?setTimeout((function(){e.currentEvent="mouse",t.elements.toggle.close()}),e.hoverDelay):(e.currentEvent="mouse",t.elements.toggle.close()):"dynamic"===e.hoverType&&(e.isTopLevel||(e.hoverDelay>0?setTimeout((function(){e.currentEvent="mouse",t.elements.toggle.close(),e.focusCurrentChild()}),e.hoverDelay):(e.currentEvent="mouse",t.elements.toggle.close(),e.focusCurrentChild())))}))}))}},{key:"_handleKeydown",value:function(){var e=this;this.isTopLevel&&this.elements.controller&&this.elements.controller.dom.toggle.addEventListener("keydown",(function(t){e.currentEvent="keyboard";var n=E(t);"Space"!==n&&"Enter"!==n||M(t)}))}},{key:"_handleKeyup",value:function(){var e=this;this.isTopLevel&&this.elements.controller&&this.elements.controller.dom.toggle.addEventListener("keyup",(function(t){e.currentEvent="keyboard";var n=E(t);"Space"!==n&&"Enter"!==n||(M(t),e.elements.controller.open(),e.focusFirstChild())}))}},{key:"focus",value:function(){this.focusState="self",this.shouldFocus&&this.dom.menu.focus()}},{key:"blur",value:function(){this.focusState="none",this.shouldFocus&&this.dom.menu.blur()}},{key:"focusCurrentChild",value:function(){this.focusState="self",-1!==this.currentChild&&this.currentMenuItem.focus()}},{key:"focusChild",value:function(e){this.blurCurrentChild(),this.currentChild=e,this.focusCurrentChild()}},{key:"focusFirstChild",value:function(){this.focusChild(0)}},{key:"focusLastChild",value:function(){this.focusChild(this.elements.menuItems.length-1)}},{key:"focusNextChild",value:function(){this.currentChild<this.elements.menuItems.length-1?this.focusChild(this.currentChild+1):this.focusCurrentChild()}},{key:"focusPreviousChild",value:function(){this.currentChild>0?this.focusChild(this.currentChild-1):this.focusCurrentChild()}},{key:"blurCurrentChild",value:function(){this.focusState="none",-1!==this.currentChild&&this.currentMenuItem.blur()}},{key:"focusController",value:function(){this.dom.controller&&(this.shouldFocus&&this.dom.controller.focus(),this.focusState="none")}},{key:"focusContainer",value:function(){this.dom.container&&(this.shouldFocus&&this.dom.container.focus(),this.focusState="none")}},{key:"closeChildren",value:function(){this.elements.submenuToggles.forEach((function(e){return e.close()}))}},{key:"blurChildren",value:function(){this.elements.menuItems.forEach((function(e){e.blur(),e.isSubmenuItem&&e.elements.childMenu.blurChildren()}))}}]),n}(),T=function(e){r(o,_);var n=a(o);function o(e){var s,r=e.menuItemElement,i=e.menuLinkElement,l=e.parentMenu,u=e.isSubmenuItem,c=void 0!==u&&u,a=e.childMenu,m=void 0===a?null:a,h=e.toggle,f=void 0===h?null:h,d=e.initialize,p=void 0===d||d;return t(this,o),s=n.call(this,{menuItemElement:r,menuLinkElement:i,parentMenu:l,isSubmenuItem:c,childMenu:m,toggle:f}),p&&s.initialize(),s}return o}(),w=function(e){r(s,b);var n=a(s);function s(e){var o,r=e.menuToggleElement,i=e.parentElement,l=e.controlledMenu,u=e.parentMenu,c=void 0===u?null:u,a=e.initialize,m=void 0===a||a;return t(this,s),o=n.call(this,{menuToggleElement:r,parentElement:i,controlledMenu:l,parentMenu:c}),m&&o.initialize(),o}return o(s,[{key:"open",value:function(){this.closeSiblings(),m(i(s.prototype),"open",this).call(this)}},{key:"preview",value:function(){this.closeSiblings(),m(i(s.prototype),"preview",this).call(this)}},{key:"close",value:function(){this.isOpen&&this.closeChildren(),m(i(s.prototype),"close",this).call(this)}}]),s}(),k=function(e){r(l,C);var n=a(l);function l(e){var o,r=e.menuElement,i=e.menuItemSelector,c=void 0===i?"li":i,a=e.menuLinkSelector,m=void 0===a?"a":a,h=e.submenuItemSelector,f=void 0===h?"":h,d=e.submenuToggleSelector,p=void 0===d?"a":d,v=e.submenuSelector,y=void 0===v?"ul":v,g=e.controllerElement,b=void 0===g?null:g,_=e.containerElement,E=void 0===_?null:_,M=e.openClass,C=void 0===M?"show":M,k=e.closeClass,S=void 0===k?"hide":k,I=e.isTopLevel,L=void 0===I||I,A=e.parentMenu,O=void 0===A?null:A,D=e.hoverType,j=void 0===D?"off":D,R=e.hoverDelay,z=void 0===R?250:R,x=e.optionalKeySupport,K=void 0!==x&&x,F=e.initialize,P=void 0===F||F;return t(this,l),s(u(o=n.call(this,{menuElement:r,menuItemSelector:c,menuLinkSelector:m,submenuItemSelector:f,submenuToggleSelector:p,submenuSelector:y,controllerElement:b,containerElement:E,openClass:C,closeClass:S,isTopLevel:L,parentMenu:O,hoverType:j,hoverDelay:z})),"_MenuType",l),s(u(o),"_MenuItemType",T),s(u(o),"_MenuToggleType",w),s(u(o),"_currentChild",-1),s(u(o),"_optionalSupport",!1),o._optionalSupport=K,P&&o.initialize(),o}return o(l,[{key:"initialize",value:function(){try{m(i(l.prototype),"initialize",this).call(this),this._handleFocus(),this._handleClick(),this._handleHover(),this._handleKeydown(),this._handleKeyup()}catch(e){console.error(e)}}},{key:"optionalKeySupport",get:function(){return this.isTopLevel?this._optionalSupport:this.elements.rootMenu.optionalKeySupport},set:function(e){p("boolean",{optionalKeySupport:e}),this._optionalSupport=e}},{key:"_validate",value:function(){var e=m(i(l.prototype),"_validate",this).call(this);return p("boolean",{optionalKeySupport:this._optionalSupport})||(e=!1),e}},{key:"_handleClick",value:function(){var e=this;m(i(l.prototype),"_handleClick",this).call(this),document.addEventListener("pointerup",(function(t){"none"!==e.focusState&&(e.currentEvent="mouse",e.dom.menu.contains(t.target)||!e.dom.menu===t.target||(e.closeChildren(),e.blur(),e.elements.controller&&e.elements.controller.close()))}))}},{key:"_handleKeydown",value:function(){var e=this;m(i(l.prototype),"_handleKeydown",this).call(this),this.dom.menu.addEventListener("keydown",(function(t){e.currentEvent="keyboard";var n=E(t);if("self"===e.focusState){if(e.optionalKeySupport){["ArrowUp","ArrowRight","ArrowDown","ArrowLeft","Home","End"].includes(n)&&M(t)}else(e.currentMenuItem.isSubmenuItem&&["Space","Enter"].includes(n)||e.elements.controller&&["Escape"].includes(n)||e.elements.parentMenu&&["Escape"].includes(n))&&M(t)}}))}},{key:"_handleKeyup",value:function(){var e=this;m(i(l.prototype),"_handleKeyup",this).call(this),this.dom.menu.addEventListener("keyup",(function(t){e.currentEvent="keyboard";var n=E(t);if("self"===e.focusState)if("Space"===n||"Enter"===n)e.currentMenuItem.isSubmenuItem?(M(t),e.currentMenuItem.elements.toggle.preview()):e.currentMenuItem.dom.link.click();else if("Escape"===n){e.elements.submenuToggles.some((function(e){return e.isOpen}))?(M(t),e.closeChildren()):e.elements.parentMenu?(M(t),e.elements.parentMenu.currentEvent=e.currentEvent,e.elements.parentMenu.closeChildren(),e.elements.parentMenu.focusCurrentChild()):e.isTopLevel&&e.elements.controller&&e.elements.controller.isOpen&&(e.elements.controller.close(),e.focusController())}else e.optionalKeySupport&&("ArrowDown"===n||"ArrowRight"===n?(M(t),e.currentMenuItem.isSubmenuItem&&e.currentMenuItem.elements.toggle.isOpen?(e.currentMenuItem.elements.childMenu.currentEvent="keyboard",e.currentMenuItem.elements.childMenu.focusFirstChild()):e.focusNextChild()):"ArrowUp"===n||"ArrowLeft"===n?(M(t),e.focusPreviousChild()):"Home"===n?(M(t),e.focusFirstChild()):"End"===n&&(M(t),e.focusLastChild()))}))}}]),l}();export{k as default};
//# sourceMappingURL=disclosure-menu.esm.min.js.map

@@ -112,2 +112,4 @@ var DisclosureMenu = (function () {

return call;
} else if (call !== void 0) {
throw new TypeError("Derived constructors may only return object or undefined");
}

@@ -359,14 +361,2 @@

}
function isEventSupported(event, element) {
if (isValidType("string", {
event: event
}) && isValidInstance(HTMLElement, {
element: element
})) {
var eventProp = "on".concat(event);
return typeof element[eventProp] !== "undefined";
} else {
return false;
}
}

@@ -1137,4 +1127,2 @@ var BaseMenuToggle = function () {

var _this4 = this;
var startEventType = isEventSupported("touchstart", this.dom.menu) ? "touchstart" : "mousedown";
var endEventType = isEventSupported("touchend", this.dom.menu) ? "touchend" : "mouseup";
function toggleToggle(menu, toggle, event) {

@@ -1149,19 +1137,21 @@ preventEvent(event);

this.elements.menuItems.forEach(function (item, index) {
item.dom.link.addEventListener(startEventType, function () {
item.dom.link.addEventListener("pointerdown", function () {
_this4.currentEvent = "mouse";
_this4.elements.rootMenu.blurChildren();
_this4.focusChild(index);
}, {
passive: true
});
if (item.isSubmenuItem) {
item.elements.toggle.dom.toggle["on".concat(endEventType)] = function (event) {
item.elements.toggle.dom.toggle.addEventListener("pointerup", function (event) {
_this4.currentEvent = "mouse";
toggleToggle(_this4, item.elements.toggle, event);
};
});
}
});
if (this.isTopLevel && this.elements.controller) {
this.elements.controller.dom.toggle["on".concat(endEventType)] = function (event) {
this.elements.controller.dom.toggle.addEventListener("pointerup", function (event) {
_this4.currentEvent = "mouse";
toggleToggle(_this4, _this4.elements.controller, event);
};
});
}

@@ -1551,4 +1541,3 @@ }

_get(_getPrototypeOf(DisclosureMenu.prototype), "_handleClick", this).call(this);
var endEventType = isEventSupported("touchend", this.dom.menu) ? "touchend" : "mouseup";
document.addEventListener(endEventType, function (event) {
document.addEventListener("pointerup", function (event) {
if (_this2.focusState !== "none") {

@@ -1654,3 +1643,3 @@ _this2.currentEvent = "mouse";

}());
})();
//# sourceMappingURL=disclosure-menu.js.map

@@ -1,2 +0,2 @@

var DisclosureMenu=function(){"use strict";function e(t){return(e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(t)}function t(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function n(e,t){for(var n=0;n<t.length;n++){var o=t[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}function o(e,t,o){return t&&n(e.prototype,t),o&&n(e,o),e}function s(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function r(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&i(e,t)}function l(e){return(l=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function i(e,t){return(i=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function u(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function c(e,t){return!t||"object"!=typeof t&&"function"!=typeof t?u(e):t}function a(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,o=l(e);if(t){var s=l(this).constructor;n=Reflect.construct(o,arguments,s)}else n=o.apply(this,arguments);return c(this,n)}}function m(e,t,n){return(m="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(e,t,n){var o=function(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&null!==(e=l(e)););return e}(e,t);if(o){var s=Object.getOwnPropertyDescriptor(o,t);return s.get?s.get.call(n):s.value}})(e,t,n||e)}function h(e){return function(e){if(Array.isArray(e))return f(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,t){if(!e)return;if("string"==typeof e)return f(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return f(e,t)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function f(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,o=new Array(t);n<t;n++)o[n]=e[n];return o}function d(t,n){try{if("object"!==e(n)){var o=e(n);throw new TypeError("AccessibleMenu: Elements given to isValidInstance() must be inside of an object. ".concat(o," given."))}for(var s in n)if(!(n[s]instanceof t)){var r=e(n[s]);throw new TypeError("AccessibleMenu: ".concat(s," must be an instance of ").concat(t.name,". ").concat(r," given."))}return!0}catch(e){return console.error(e),!1}}function p(t,n){try{if("object"!==e(n)){var o=e(n);throw new TypeError("AccessibleMenu: Values given to isValidType() must be inside of an object. ".concat(o," given."))}for(var s in n){var r=e(n[s]);if(r!==t)throw new TypeError("AccessibleMenu: ".concat(s," must be a ").concat(t,". ").concat(r," given."))}return!0}catch(e){return console.error(e),!1}}function v(t){try{if("object"!==e(t)){var n=e(t);throw new TypeError("AccessibleMenu: Values given to isCSSSelector() must be inside of an object. ".concat(n," given."))}for(var o in t)try{if(null===t[o])throw new Error;document.querySelector(t[o])}catch(e){throw new TypeError("AccessibleMenu: ".concat(o,' must be a valid CSS selector. "').concat(t[o],'" given.'))}return!0}catch(e){return console.error(e),!1}}function y(t){try{if("object"!==e(t)||Array.isArray(t)){var n=e(t);throw new TypeError("AccessibleMenu: Values given to isValidClassList() must be inside of an object. ".concat(n," given."))}var o=function(n){var o=e(t[n]);if("string"!==o){if(!Array.isArray(t[n]))throw new TypeError("AccessibleMenu: ".concat(n," must be a string or an array of strings. ").concat(o," given."));t[n].forEach((function(e){if("string"!=typeof e)throw new TypeError("AccessibleMenu: ".concat(n," must be a string or an array of strings. An array containing non-strings given."))}))}else{var s={};s[n]=t[n],v(s)}};for(var s in t)o(s);return!0}catch(e){return console.error(e),!1}}function g(t){try{if("object"!==e(t)){var n=e(t);throw new TypeError("AccessibleMenu: Values given to isValidHoverType() must be inside of an object. ".concat(n," given."))}var o=["off","on","dynamic"];for(var s in t)if(!o.includes(t[s]))throw new TypeError("AccessibleMenu: ".concat(s," must be one of the following values: ").concat(o.join(", "),'. "').concat(t[s],'" given.'));return!0}catch(e){return console.error(e),!1}}function b(e,t){return!(!p("string",{event:e})||!d(HTMLElement,{element:t}))&&void 0!==t["on".concat(e)]}var _=function(){function e(n){var o=n.menuToggleElement,r=n.parentElement,l=n.controlledMenu,i=n.parentMenu,u=void 0===i?null:i;t(this,e),s(this,"_dom",{toggle:null,parent:null}),s(this,"_elements",{controlledMenu:null,parentMenu:null}),s(this,"_open",!1),s(this,"_expandEvent",new CustomEvent("accessibleMenuExpand",{bubbles:!0,detail:{toggle:this}})),s(this,"_collapseEvent",new CustomEvent("accessibleMenuCollapse",{bubbles:!0,detail:{toggle:this}})),this._dom.toggle=o,this._dom.parent=r,this._elements.controlledMenu=l,this._elements.parentMenu=u}return o(e,[{key:"initialize",value:function(){if(this.dom.toggle.setAttribute("aria-haspopup","true"),this.dom.toggle.setAttribute("aria-expanded","false"),function(e,t){if(p("string",{tagName:e})&&d(HTMLElement,t)){var n=e.toLowerCase(),o=!0;for(var s in t)t[s].tagName.toLowerCase()!==n&&(o=!1);return o}return!1}("button",{toggle:this.dom.toggle})||this.dom.toggle.setAttribute("role","button"),""===this.dom.toggle.id||""===this.elements.controlledMenu.dom.menu.id){var e=Math.random().toString(36).replace(/[^a-z]+/g,"").substr(0,10),t=this.dom.toggle.innerText.replace(/[^a-zA-Z0-9\s]/g,""),n=e;!t.replace(/\s/g,"").length&&this.dom.toggle.getAttribute("aria-label")&&(t=this.dom.toggle.getAttribute("aria-label").replace(/[^a-zA-Z0-9\s]/g,"")),t.replace(/\s/g,"").length>0&&((t=t.toLowerCase().replace(/\s+/g,"-")).startsWith("-")&&(t=t.substring(1)),t.endsWith("-")&&(t=t.slice(0,-1)),n="".concat(t,"-").concat(n)),this.dom.toggle.id=this.dom.toggle.id||"".concat(n,"-menu-button"),this.elements.controlledMenu.dom.menu.id=this.elements.controlledMenu.dom.menu.id||"".concat(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)}},{key:"dom",get:function(){return this._dom}},{key:"elements",get:function(){return this._elements}},{key:"isOpen",get:function(){return this._open},set:function(e){p("boolean",{value:e}),this._open=e}},{key:"_expand",value:function(){var e,t,n=!(arguments.length>0&&void 0!==arguments[0])||arguments[0],o=this.elements.controlledMenu,s=o.closeClass,r=o.openClass;(this.dom.toggle.setAttribute("aria-expanded","true"),""!==r)&&("string"==typeof r?this.elements.controlledMenu.dom.menu.classList.add(r):(e=this.elements.controlledMenu.dom.menu.classList).add.apply(e,h(r)));""!==s&&("string"==typeof s?this.elements.controlledMenu.dom.menu.classList.remove(s):(t=this.elements.controlledMenu.dom.menu.classList).remove.apply(t,h(s)));n&&this.dom.toggle.dispatchEvent(this._expandEvent)}},{key:"_collapse",value:function(){var e,t,n=!(arguments.length>0&&void 0!==arguments[0])||arguments[0],o=this.elements.controlledMenu,s=o.closeClass,r=o.openClass;(this.dom.toggle.setAttribute("aria-expanded","false"),""!==s)&&("string"==typeof s?this.elements.controlledMenu.dom.menu.classList.add(s):(e=this.elements.controlledMenu.dom.menu.classList).add.apply(e,h(s)));""!==r&&("string"==typeof r?this.elements.controlledMenu.dom.menu.classList.remove(r):(t=this.elements.controlledMenu.dom.menu.classList).remove.apply(t,h(r)));n&&this.dom.toggle.dispatchEvent(this._collapseEvent)}},{key:"open",value:function(){this.elements.controlledMenu.focusState="self",this._expand(),this.isOpen=!0}},{key:"preview",value:function(){this.elements.parentMenu&&(this.elements.parentMenu.focusState="self"),this._expand(),this.isOpen=!0}},{key:"close",value:function(){this.isOpen&&(this.elements.controlledMenu.currentChild=0,this.elements.controlledMenu.blur(),this.elements.parentMenu&&(this.elements.parentMenu.focusState="self"),this._collapse(),this.isOpen=!1)}},{key:"toggle",value:function(){this.isOpen?this.close():this.open()}},{key:"closeSiblings",value:function(){var e=this;this.elements.parentMenu&&this.elements.parentMenu.elements.submenuToggles.forEach((function(t){t!==e&&t.close()}))}},{key:"closeChildren",value:function(){this.elements.controlledMenu.elements.submenuToggles.forEach((function(e){return e.close()}))}}]),e}(),M=function(){function e(n){var o=n.menuItemElement,r=n.menuLinkElement,l=n.parentMenu,i=n.isSubmenuItem,u=void 0!==i&&i,c=n.childMenu,a=void 0===c?null:c,m=n.toggle,h=void 0===m?null:m;t(this,e),s(this,"_dom",{item:null,link:null}),s(this,"_elements",{parentMenu:null,childMenu:null,toggle:null}),s(this,"_submenu",!1),this._dom.item=o,this._dom.link=r,this._elements.parentMenu=l,this._elements.childMenu=a,this._elements.toggle=h,this._submenu=u}return o(e,[{key:"initialize",value:function(){}},{key:"dom",get:function(){return this._dom}},{key:"elements",get:function(){return this._elements}},{key:"isSubmenuItem",get:function(){return this._submenu}},{key:"focus",value:function(){this.elements.parentMenu.shouldFocus&&this.dom.link.focus()}},{key:"blur",value:function(){this.elements.parentMenu.shouldFocus&&this.dom.link.blur()}}]),e}();function E(e){try{var t=e.key||e.keyCode,n={Enter:"Enter"===t||13===t,Space:" "===t||"Spacebar"===t||32===t,Escape:"Escape"===t||"Esc"===t||27===t,ArrowUp:"ArrowUp"===t||"Up"===t||38===t,ArrowRight:"ArrowRight"===t||"Right"===t||39===t,ArrowDown:"ArrowDown"===t||"Down"===t||40===t,ArrowLeft:"ArrowLeft"===t||"Left"===t||37===t,Home:"Home"===t||36===t,End:"End"===t||35===t,Character:isNaN(t)&&!!t.match(/^[a-zA-Z]{1}$/),Tab:"Tab"===t||9===t,Asterisk:"*"===t||56===t};return Object.keys(n).find((function(e){return!0===n[e]}))||""}catch(e){return""}}function C(e){e.preventDefault(),e.stopPropagation()}var T=function(){function n(e){var o=e.menuElement,r=e.menuItemSelector,l=void 0===r?"li":r,i=e.menuLinkSelector,u=void 0===i?"a":i,c=e.submenuItemSelector,a=void 0===c?"":c,m=e.submenuToggleSelector,h=void 0===m?"a":m,f=e.submenuSelector,d=void 0===f?"ul":f,p=e.controllerElement,v=void 0===p?null:p,y=e.containerElement,g=void 0===y?null:y,b=e.openClass,E=void 0===b?"show":b,C=e.closeClass,T=void 0===C?"hide":C,k=e.isTopLevel,w=void 0===k||k,S=e.parentMenu,I=void 0===S?null:S,L=e.hoverType,A=void 0===L?"off":L,O=e.hoverDelay,D=void 0===O?250:O;t(this,n),s(this,"_MenuType",n),s(this,"_MenuItemType",M),s(this,"_MenuToggleType",_),s(this,"_dom",{menu:null,menuItems:[],submenuItems:[],submenuToggles:[],submenus:[],controller:null,container:null}),s(this,"_selectors",{menuItems:"",menuLinks:"",submenuItems:"",submenuToggles:"",submenus:""}),s(this,"_elements",{menuItems:[],submenuToggles:[],controller:null,parentMenu:null,rootMenu:null}),s(this,"_openClass","show"),s(this,"_closeClass","hide"),s(this,"_root",!0),s(this,"_currentChild",0),s(this,"_focusState","none"),s(this,"_currentEvent","none"),s(this,"_hoverType","off"),s(this,"_hoverDelay",250),this._dom.menu=o,this._dom.controller=v,this._dom.container=g,this._selectors.menuItems=l,this._selectors.menuLinks=u,this._selectors.submenuItems=a,this._selectors.submenuToggles=h,this._selectors.submenus=d,this._elements.menuItems=[],this._elements.submenuToggles=[],this._elements.controller=null,this._elements.parentMenu=I,this._elements.rootMenu=w?this:null,this._openClass=E||"",this._closeClass=T||"",this._root=w,this._hoverType=A,this._hoverDelay=D}return o(n,[{key:"initialize",value:function(){if(!this._validate())throw new Error("AccesibleMenu: cannot initialize menu. See other error messages for more information.");if(null===this.elements.rootMenu&&this._findRootMenu(this),this._setDOMElements(),this.isTopLevel&&this.dom.controller&&this.dom.container){var e=new this._MenuToggleType({menuToggleElement:this.dom.controller,parentElement:this.dom.container,controlledMenu:this});this._elements.controller=e}this._createChildElements()}},{key:"dom",get:function(){return this._dom}},{key:"selectors",get:function(){return this._selectors}},{key:"elements",get:function(){return this._elements}},{key:"isTopLevel",get:function(){return this._root}},{key:"openClass",get:function(){return this.isTopLevel?this._openClass:this.elements.rootMenu.openClass},set:function(e){y({openClass:e}),this._openClass!==e&&(this._openClass=e)}},{key:"closeClass",get:function(){return this.isTopLevel?this._closeClass:this.elements.rootMenu.closeClass},set:function(e){y({closeClass:e}),this._closeClass!==e&&(this._closeClass=e)}},{key:"currentChild",get:function(){return this._currentChild},set:function(e){function t(e){if(["mouse","character"].includes(e.currentEvent)&&e.elements.parentMenu)for(var t=0,n=!1;!n&&t<e.elements.parentMenu.elements.menuItems.length;){var o=e.elements.parentMenu.elements.menuItems[t];o.isSubmenuItem&&o.elements.toggle.elements.controlledMenu===e&&(n=!0,e.elements.parentMenu.currentEvent=e.currentEvent,e.elements.parentMenu.currentChild=t),t++}}p("number",{value:e}),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))}},{key:"focusState",get:function(){return this._focusState},set:function(t){!function(t){try{if("object"!==e(t)){var n=e(t);throw new TypeError("AccessibleMenu: Values given to isValidState() must be inside of an object. ".concat(n," given."))}var o=["none","self","child"];for(var s in t)if(!o.includes(t[s]))throw new TypeError("AccessibleMenu: ".concat(s," must be one of the following values: ").concat(o.join(", "),'. "').concat(t[s],'" given.'))}catch(e){return console.error(e),!1}}({value:t}),this._focusState!==t&&(this._focusState=t),this.elements.submenuToggles.length>0&&("self"===t||"none"===t)&&this.elements.submenuToggles.forEach((function(e){e.elements.controlledMenu.focusState="none"})),!this.elements.parentMenu||"self"!==t&&"child"!==t||(this.elements.parentMenu.focusState="child")}},{key:"currentEvent",get:function(){return this._currentEvent},set:function(t){!function(t){try{if("object"!==e(t)){var n=e(t);throw new TypeError("AccessibleMenu: Values given to isValidEvent() must be inside of an object. ".concat(n," given."))}var o=["none","mouse","keyboard","character"];for(var s in t)if(!o.includes(t[s]))throw new TypeError("AccessibleMenu: ".concat(s," must be one of the following values: ").concat(o.join(", "),'. "').concat(t[s],'" given.'))}catch(e){return console.error(e),!1}}({value:t}),this._currentEvent!==t&&(this._currentEvent=t,this.elements.submenuToggles.length>0&&this.elements.submenuToggles.forEach((function(e){e.elements.controlledMenu.currentEvent=t})))}},{key:"currentMenuItem",get:function(){return this.elements.menuItems[this.currentChild]}},{key:"hoverType",get:function(){return this._root?this._hoverType:this.elements.rootMenu.hoverType},set:function(e){g({value:e}),this._hoverType!==e&&(this._hoverType=e)}},{key:"hoverDelay",get:function(){return this._root?this._hoverDelay:this.elements.rootMenu.hoverDelay},set:function(e){p("number",{value:e}),this._hoverDelay!==e&&(this._hoverDelay=e)}},{key:"shouldFocus",get:function(){var e=!1;return"keyboard"!==this.currentEvent&&"character"!==this.currentEvent||(e=!0),"mouse"===this.currentEvent&&"dynamic"===this.hoverType&&(e=!0),e}},{key:"_validate",value:function(){var e=!0;return null!==this._dom.container||null!==this._dom.controller?d(HTMLElement,{menuElement:this._dom.menu,controllerElement:this._dom.controller,containerElement:this._dom.container})||(e=!1):d(HTMLElement,{menuElement:this._dom.menu})||(e=!1),""!==this._selectors.submenuItems?v({menuItemSelector:this._selectors.menuItems,menuLinkSelector:this._selectors.menuLinks,submenuItemSelector:this._selectors.submenuItems,submenuToggleSelector:this._selectors.submenuToggles,submenuSelector:this._selectors.submenus})||(e=!1):v({menuItemSelector:this._selectors.menuItems,menuLinkSelector:this._selectors.menuLinks})||(e=!1),""===this._openClass||y({openClass:this._openClass})||(e=!1),""===this._closeClass||y({closeClass:this._closeClass})||(e=!1),p("boolean",{isTopLevel:this._root})||(e=!1),null===this._elements.parentMenu||d(n,{parentMenu:this._elements.parentMenu})||(e=!1),g({hoverType:this._hoverType})||(e=!1),p("number",{hoverDelay:this._hoverDelay})||(e=!1),e}},{key:"_setDOMElementType",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.dom.menu,n=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];if("string"!=typeof this.selectors[e])throw new Error('AccessibleMenu: "'.concat(e,'" is not a valid element type within the menu.'));if(!Array.isArray(this.dom[e]))throw new Error('AccessibleMenu: The "'.concat(e,'" element cannot be set through _setDOMElementType.'));t!==this.dom.menu&&d(HTMLElement,{base:t});var o=Array.from(t.querySelectorAll(this.selectors[e])),s=o.filter((function(e){return e.parentElement===t}));this._dom[e]=n?s:[].concat(h(this._dom[e]),h(s))}},{key:"_resetDOMElementType",value:function(e){if(void 0===this.dom[e])throw new Error('AccessibleMenu: "'.concat(e,'" is not a valid element type within the menu.'));if(!Array.isArray(this.dom[e]))throw new Error('AccessibleMenu: The "'.concat(e,'" element cannot be reset through _resetDOMElementType.'));this._dom[e]=[]}},{key:"_setDOMElements",value:function(){var e=this;this._setDOMElementType("menuItems"),""!==this.selectors.submenuItems&&(this._setDOMElementType("submenuItems"),this._resetDOMElementType("submenuToggles"),this._resetDOMElementType("submenus"),this.dom.submenuItems.forEach((function(t){e._setDOMElementType("submenuToggles",t,!1),e._setDOMElementType("submenus",t,!1)})))}},{key:"_findRootMenu",value:function(e){if(e.isTopLevel)this._elements.rootMenu=e;else{if(null===e.elements.parentMenu)throw new Error("Cannot find root menu.");this._findRootMenu(e.elements.parentMenu)}}},{key:"_createChildElements",value:function(){var e=this;this.dom.menuItems.forEach((function(t){var n;if(e.dom.submenuItems.includes(t)){var o=t.querySelector(e.selectors.submenuToggles),s=t.querySelector(e.selectors.submenus),r=new e._MenuType({menuElement:s,menuItemSelector:e.selectors.menuItems,menuLinkSelector:e.selectors.menuLinks,submenuItemSelector:e.selectors.submenuItems,submenuToggleSelector:e.selectors.submenuToggles,submenuSelector:e.selectors.submenus,openClass:e.openClass,closeClass:e.closeClass,isTopLevel:!1,parentMenu:e,hoverType:e.hoverType,hoverDelay:e.hoverDelay}),l=new e._MenuToggleType({menuToggleElement:o,parentElement:t,controlledMenu:r,parentMenu:e});e._elements.submenuToggles.push(l),n=new e._MenuItemType({menuItemElement:t,menuLinkElement:o,parentMenu:e,isSubmenuItem:!0,childMenu:r,toggle:l})}else{var i=t.querySelector(e.selectors.menuLinks);n=new e._MenuItemType({menuItemElement:t,menuLinkElement:i,parentMenu:e})}e._elements.menuItems.push(n)}))}},{key:"_handleFocus",value:function(){var e=this;this.elements.menuItems.forEach((function(t,n){t.dom.link.addEventListener("focus",(function(){e.focusState="self",e.currentChild=n}))}))}},{key:"_handleClick",value:function(){var e=this,t=b("touchstart",this.dom.menu)?"touchstart":"mousedown",n=b("touchend",this.dom.menu)?"touchend":"mouseup";function o(e,t,n){C(n),t.toggle(),t.isOpen&&(e.focusState="self",t.elements.controlledMenu.focusState="none")}this.elements.menuItems.forEach((function(s,r){s.dom.link.addEventListener(t,(function(){e.currentEvent="mouse",e.elements.rootMenu.blurChildren(),e.focusChild(r)})),s.isSubmenuItem&&(s.elements.toggle.dom.toggle["on".concat(n)]=function(t){e.currentEvent="mouse",o(e,s.elements.toggle,t)})})),this.isTopLevel&&this.elements.controller&&(this.elements.controller.dom.toggle["on".concat(n)]=function(t){e.currentEvent="mouse",o(e,e.elements.controller,t)})}},{key:"_handleHover",value:function(){var e=this;this.elements.menuItems.forEach((function(t,n){t.dom.link.addEventListener("mouseenter",(function(){if("on"===e.hoverType)e.currentEvent="mouse",e.currentChild=n,t.isSubmenuItem&&t.elements.toggle.preview();else if("dynamic"===e.hoverType){var o=e.elements.submenuToggles.some((function(e){return e.isOpen}));e.currentChild=n,e.isTopLevel&&"none"===e.focusState||(e.currentEvent="mouse",e.focusCurrentChild()),!t.isSubmenuItem||e.isTopLevel&&!o||(e.currentEvent="mouse",t.elements.toggle.preview())}})),t.isSubmenuItem&&t.dom.item.addEventListener("mouseleave",(function(){"on"===e.hoverType?e.hoverDelay>0?setTimeout((function(){e.currentEvent="mouse",t.elements.toggle.close()}),e.hoverDelay):(e.currentEvent="mouse",t.elements.toggle.close()):"dynamic"===e.hoverType&&(e.isTopLevel||(e.hoverDelay>0?setTimeout((function(){e.currentEvent="mouse",t.elements.toggle.close(),e.focusCurrentChild()}),e.hoverDelay):(e.currentEvent="mouse",t.elements.toggle.close(),e.focusCurrentChild())))}))}))}},{key:"_handleKeydown",value:function(){var e=this;this.isTopLevel&&this.elements.controller&&this.elements.controller.dom.toggle.addEventListener("keydown",(function(t){e.currentEvent="keyboard";var n=E(t);"Space"!==n&&"Enter"!==n||C(t)}))}},{key:"_handleKeyup",value:function(){var e=this;this.isTopLevel&&this.elements.controller&&this.elements.controller.dom.toggle.addEventListener("keyup",(function(t){e.currentEvent="keyboard";var n=E(t);"Space"!==n&&"Enter"!==n||(C(t),e.elements.controller.open(),e.focusFirstChild())}))}},{key:"focus",value:function(){this.focusState="self",this.shouldFocus&&this.dom.menu.focus()}},{key:"blur",value:function(){this.focusState="none",this.shouldFocus&&this.dom.menu.blur()}},{key:"focusCurrentChild",value:function(){this.focusState="self",-1!==this.currentChild&&this.currentMenuItem.focus()}},{key:"focusChild",value:function(e){this.blurCurrentChild(),this.currentChild=e,this.focusCurrentChild()}},{key:"focusFirstChild",value:function(){this.focusChild(0)}},{key:"focusLastChild",value:function(){this.focusChild(this.elements.menuItems.length-1)}},{key:"focusNextChild",value:function(){this.currentChild<this.elements.menuItems.length-1?this.focusChild(this.currentChild+1):this.focusCurrentChild()}},{key:"focusPreviousChild",value:function(){this.currentChild>0?this.focusChild(this.currentChild-1):this.focusCurrentChild()}},{key:"blurCurrentChild",value:function(){this.focusState="none",-1!==this.currentChild&&this.currentMenuItem.blur()}},{key:"focusController",value:function(){this.dom.controller&&(this.shouldFocus&&this.dom.controller.focus(),this.focusState="none")}},{key:"focusContainer",value:function(){this.dom.container&&(this.shouldFocus&&this.dom.container.focus(),this.focusState="none")}},{key:"closeChildren",value:function(){this.elements.submenuToggles.forEach((function(e){return e.close()}))}},{key:"blurChildren",value:function(){this.elements.menuItems.forEach((function(e){e.blur(),e.isSubmenuItem&&e.elements.childMenu.blurChildren()}))}}]),n}(),k=function(e){r(o,e);var n=a(o);function o(e){var s,r=e.menuItemElement,l=e.menuLinkElement,i=e.parentMenu,u=e.isSubmenuItem,c=void 0!==u&&u,a=e.childMenu,m=void 0===a?null:a,h=e.toggle,f=void 0===h?null:h,d=e.initialize,p=void 0===d||d;return t(this,o),s=n.call(this,{menuItemElement:r,menuLinkElement:l,parentMenu:i,isSubmenuItem:c,childMenu:m,toggle:f}),p&&s.initialize(),s}return o}(M),w=function(e){r(s,e);var n=a(s);function s(e){var o,r=e.menuToggleElement,l=e.parentElement,i=e.controlledMenu,u=e.parentMenu,c=void 0===u?null:u,a=e.initialize,m=void 0===a||a;return t(this,s),o=n.call(this,{menuToggleElement:r,parentElement:l,controlledMenu:i,parentMenu:c}),m&&o.initialize(),o}return o(s,[{key:"open",value:function(){this.closeSiblings(),m(l(s.prototype),"open",this).call(this)}},{key:"preview",value:function(){this.closeSiblings(),m(l(s.prototype),"preview",this).call(this)}},{key:"close",value:function(){this.isOpen&&this.closeChildren(),m(l(s.prototype),"close",this).call(this)}}]),s}(_);return function(e){r(i,e);var n=a(i);function i(e){var o,r=e.menuElement,l=e.menuItemSelector,c=void 0===l?"li":l,a=e.menuLinkSelector,m=void 0===a?"a":a,h=e.submenuItemSelector,f=void 0===h?"":h,d=e.submenuToggleSelector,p=void 0===d?"a":d,v=e.submenuSelector,y=void 0===v?"ul":v,g=e.controllerElement,b=void 0===g?null:g,_=e.containerElement,M=void 0===_?null:_,E=e.openClass,C=void 0===E?"show":E,T=e.closeClass,S=void 0===T?"hide":T,I=e.isTopLevel,L=void 0===I||I,A=e.parentMenu,O=void 0===A?null:A,D=e.hoverType,j=void 0===D?"off":D,R=e.hoverDelay,z=void 0===R?250:R,K=e.optionalKeySupport,x=void 0!==K&&K,F=e.initialize,H=void 0===F||F;return t(this,i),s(u(o=n.call(this,{menuElement:r,menuItemSelector:c,menuLinkSelector:m,submenuItemSelector:f,submenuToggleSelector:p,submenuSelector:y,controllerElement:b,containerElement:M,openClass:C,closeClass:S,isTopLevel:L,parentMenu:O,hoverType:j,hoverDelay:z})),"_MenuType",i),s(u(o),"_MenuItemType",k),s(u(o),"_MenuToggleType",w),s(u(o),"_currentChild",-1),s(u(o),"_optionalSupport",!1),o._optionalSupport=x,H&&o.initialize(),o}return o(i,[{key:"initialize",value:function(){try{m(l(i.prototype),"initialize",this).call(this),this._handleFocus(),this._handleClick(),this._handleHover(),this._handleKeydown(),this._handleKeyup()}catch(e){console.error(e)}}},{key:"optionalKeySupport",get:function(){return this.isTopLevel?this._optionalSupport:this.elements.rootMenu.optionalKeySupport},set:function(e){p("boolean",{optionalKeySupport:e}),this._optionalSupport=e}},{key:"_validate",value:function(){var e=m(l(i.prototype),"_validate",this).call(this);return p("boolean",{optionalKeySupport:this._optionalSupport})||(e=!1),e}},{key:"_handleClick",value:function(){var e=this;m(l(i.prototype),"_handleClick",this).call(this);var t=b("touchend",this.dom.menu)?"touchend":"mouseup";document.addEventListener(t,(function(t){"none"!==e.focusState&&(e.currentEvent="mouse",e.dom.menu.contains(t.target)||!e.dom.menu===t.target||(e.closeChildren(),e.blur(),e.elements.controller&&e.elements.controller.close()))}))}},{key:"_handleKeydown",value:function(){var e=this;m(l(i.prototype),"_handleKeydown",this).call(this),this.dom.menu.addEventListener("keydown",(function(t){e.currentEvent="keyboard";var n=E(t);if("self"===e.focusState){if(e.optionalKeySupport){["ArrowUp","ArrowRight","ArrowDown","ArrowLeft","Home","End"].includes(n)&&C(t)}else(e.currentMenuItem.isSubmenuItem&&["Space","Enter"].includes(n)||e.elements.controller&&["Escape"].includes(n)||e.elements.parentMenu&&["Escape"].includes(n))&&C(t)}}))}},{key:"_handleKeyup",value:function(){var e=this;m(l(i.prototype),"_handleKeyup",this).call(this),this.dom.menu.addEventListener("keyup",(function(t){e.currentEvent="keyboard";var n=E(t);if("self"===e.focusState)if("Space"===n||"Enter"===n)e.currentMenuItem.isSubmenuItem?(C(t),e.currentMenuItem.elements.toggle.preview()):e.currentMenuItem.dom.link.click();else if("Escape"===n){e.elements.submenuToggles.some((function(e){return e.isOpen}))?(C(t),e.closeChildren()):e.elements.parentMenu?(C(t),e.elements.parentMenu.currentEvent=e.currentEvent,e.elements.parentMenu.closeChildren(),e.elements.parentMenu.focusCurrentChild()):e.isTopLevel&&e.elements.controller&&e.elements.controller.isOpen&&(e.elements.controller.close(),e.focusController())}else e.optionalKeySupport&&("ArrowDown"===n||"ArrowRight"===n?(C(t),e.currentMenuItem.isSubmenuItem&&e.currentMenuItem.elements.toggle.isOpen?(e.currentMenuItem.elements.childMenu.currentEvent="keyboard",e.currentMenuItem.elements.childMenu.focusFirstChild()):e.focusNextChild()):"ArrowUp"===n||"ArrowLeft"===n?(C(t),e.focusPreviousChild()):"Home"===n?(C(t),e.focusFirstChild()):"End"===n&&(C(t),e.focusLastChild()))}))}}]),i}(T)}();
var DisclosureMenu=function(){"use strict";function e(t){return e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},e(t)}function t(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function n(e,t){for(var n=0;n<t.length;n++){var o=t[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}function o(e,t,o){return t&&n(e.prototype,t),o&&n(e,o),e}function s(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function r(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&l(e,t)}function i(e){return i=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},i(e)}function l(e,t){return l=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},l(e,t)}function u(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function c(e,t){if(t&&("object"==typeof t||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return u(e)}function a(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,o=i(e);if(t){var s=i(this).constructor;n=Reflect.construct(o,arguments,s)}else n=o.apply(this,arguments);return c(this,n)}}function m(e,t,n){return m="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(e,t,n){var o=function(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&null!==(e=i(e)););return e}(e,t);if(o){var s=Object.getOwnPropertyDescriptor(o,t);return s.get?s.get.call(n):s.value}},m(e,t,n||e)}function h(e){return function(e){if(Array.isArray(e))return f(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,t){if(!e)return;if("string"==typeof e)return f(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return f(e,t)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function f(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,o=new Array(t);n<t;n++)o[n]=e[n];return o}function d(t,n){try{if("object"!==e(n)){var o=e(n);throw new TypeError("AccessibleMenu: Elements given to isValidInstance() must be inside of an object. ".concat(o," given."))}for(var s in n)if(!(n[s]instanceof t)){var r=e(n[s]);throw new TypeError("AccessibleMenu: ".concat(s," must be an instance of ").concat(t.name,". ").concat(r," given."))}return!0}catch(e){return console.error(e),!1}}function p(t,n){try{if("object"!==e(n)){var o=e(n);throw new TypeError("AccessibleMenu: Values given to isValidType() must be inside of an object. ".concat(o," given."))}for(var s in n){var r=e(n[s]);if(r!==t)throw new TypeError("AccessibleMenu: ".concat(s," must be a ").concat(t,". ").concat(r," given."))}return!0}catch(e){return console.error(e),!1}}function v(t){try{if("object"!==e(t)){var n=e(t);throw new TypeError("AccessibleMenu: Values given to isCSSSelector() must be inside of an object. ".concat(n," given."))}for(var o in t)try{if(null===t[o])throw new Error;document.querySelector(t[o])}catch(e){throw new TypeError("AccessibleMenu: ".concat(o,' must be a valid CSS selector. "').concat(t[o],'" given.'))}return!0}catch(e){return console.error(e),!1}}function y(t){try{if("object"!==e(t)||Array.isArray(t)){var n=e(t);throw new TypeError("AccessibleMenu: Values given to isValidClassList() must be inside of an object. ".concat(n," given."))}var o=function(n){var o=e(t[n]);if("string"!==o){if(!Array.isArray(t[n]))throw new TypeError("AccessibleMenu: ".concat(n," must be a string or an array of strings. ").concat(o," given."));t[n].forEach((function(e){if("string"!=typeof e)throw new TypeError("AccessibleMenu: ".concat(n," must be a string or an array of strings. An array containing non-strings given."))}))}else{var s={};s[n]=t[n],v(s)}};for(var s in t)o(s);return!0}catch(e){return console.error(e),!1}}function g(t){try{if("object"!==e(t)){var n=e(t);throw new TypeError("AccessibleMenu: Values given to isValidHoverType() must be inside of an object. ".concat(n," given."))}var o=["off","on","dynamic"];for(var s in t)if(!o.includes(t[s]))throw new TypeError("AccessibleMenu: ".concat(s," must be one of the following values: ").concat(o.join(", "),'. "').concat(t[s],'" given.'));return!0}catch(e){return console.error(e),!1}}var b=function(){function e(n){var o=n.menuToggleElement,r=n.parentElement,i=n.controlledMenu,l=n.parentMenu,u=void 0===l?null:l;t(this,e),s(this,"_dom",{toggle:null,parent:null}),s(this,"_elements",{controlledMenu:null,parentMenu:null}),s(this,"_open",!1),s(this,"_expandEvent",new CustomEvent("accessibleMenuExpand",{bubbles:!0,detail:{toggle:this}})),s(this,"_collapseEvent",new CustomEvent("accessibleMenuCollapse",{bubbles:!0,detail:{toggle:this}})),this._dom.toggle=o,this._dom.parent=r,this._elements.controlledMenu=i,this._elements.parentMenu=u}return o(e,[{key:"initialize",value:function(){if(this.dom.toggle.setAttribute("aria-haspopup","true"),this.dom.toggle.setAttribute("aria-expanded","false"),function(e,t){if(p("string",{tagName:e})&&d(HTMLElement,t)){var n=e.toLowerCase(),o=!0;for(var s in t)t[s].tagName.toLowerCase()!==n&&(o=!1);return o}return!1}("button",{toggle:this.dom.toggle})||this.dom.toggle.setAttribute("role","button"),""===this.dom.toggle.id||""===this.elements.controlledMenu.dom.menu.id){var e=Math.random().toString(36).replace(/[^a-z]+/g,"").substr(0,10),t=this.dom.toggle.innerText.replace(/[^a-zA-Z0-9\s]/g,""),n=e;!t.replace(/\s/g,"").length&&this.dom.toggle.getAttribute("aria-label")&&(t=this.dom.toggle.getAttribute("aria-label").replace(/[^a-zA-Z0-9\s]/g,"")),t.replace(/\s/g,"").length>0&&((t=t.toLowerCase().replace(/\s+/g,"-")).startsWith("-")&&(t=t.substring(1)),t.endsWith("-")&&(t=t.slice(0,-1)),n="".concat(t,"-").concat(n)),this.dom.toggle.id=this.dom.toggle.id||"".concat(n,"-menu-button"),this.elements.controlledMenu.dom.menu.id=this.elements.controlledMenu.dom.menu.id||"".concat(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)}},{key:"dom",get:function(){return this._dom}},{key:"elements",get:function(){return this._elements}},{key:"isOpen",get:function(){return this._open},set:function(e){p("boolean",{value:e}),this._open=e}},{key:"_expand",value:function(){var e,t,n=!(arguments.length>0&&void 0!==arguments[0])||arguments[0],o=this.elements.controlledMenu,s=o.closeClass,r=o.openClass;(this.dom.toggle.setAttribute("aria-expanded","true"),""!==r)&&("string"==typeof r?this.elements.controlledMenu.dom.menu.classList.add(r):(e=this.elements.controlledMenu.dom.menu.classList).add.apply(e,h(r)));""!==s&&("string"==typeof s?this.elements.controlledMenu.dom.menu.classList.remove(s):(t=this.elements.controlledMenu.dom.menu.classList).remove.apply(t,h(s)));n&&this.dom.toggle.dispatchEvent(this._expandEvent)}},{key:"_collapse",value:function(){var e,t,n=!(arguments.length>0&&void 0!==arguments[0])||arguments[0],o=this.elements.controlledMenu,s=o.closeClass,r=o.openClass;(this.dom.toggle.setAttribute("aria-expanded","false"),""!==s)&&("string"==typeof s?this.elements.controlledMenu.dom.menu.classList.add(s):(e=this.elements.controlledMenu.dom.menu.classList).add.apply(e,h(s)));""!==r&&("string"==typeof r?this.elements.controlledMenu.dom.menu.classList.remove(r):(t=this.elements.controlledMenu.dom.menu.classList).remove.apply(t,h(r)));n&&this.dom.toggle.dispatchEvent(this._collapseEvent)}},{key:"open",value:function(){this.elements.controlledMenu.focusState="self",this._expand(),this.isOpen=!0}},{key:"preview",value:function(){this.elements.parentMenu&&(this.elements.parentMenu.focusState="self"),this._expand(),this.isOpen=!0}},{key:"close",value:function(){this.isOpen&&(this.elements.controlledMenu.currentChild=0,this.elements.controlledMenu.blur(),this.elements.parentMenu&&(this.elements.parentMenu.focusState="self"),this._collapse(),this.isOpen=!1)}},{key:"toggle",value:function(){this.isOpen?this.close():this.open()}},{key:"closeSiblings",value:function(){var e=this;this.elements.parentMenu&&this.elements.parentMenu.elements.submenuToggles.forEach((function(t){t!==e&&t.close()}))}},{key:"closeChildren",value:function(){this.elements.controlledMenu.elements.submenuToggles.forEach((function(e){return e.close()}))}}]),e}(),_=function(){function e(n){var o=n.menuItemElement,r=n.menuLinkElement,i=n.parentMenu,l=n.isSubmenuItem,u=void 0!==l&&l,c=n.childMenu,a=void 0===c?null:c,m=n.toggle,h=void 0===m?null:m;t(this,e),s(this,"_dom",{item:null,link:null}),s(this,"_elements",{parentMenu:null,childMenu:null,toggle:null}),s(this,"_submenu",!1),this._dom.item=o,this._dom.link=r,this._elements.parentMenu=i,this._elements.childMenu=a,this._elements.toggle=h,this._submenu=u}return o(e,[{key:"initialize",value:function(){}},{key:"dom",get:function(){return this._dom}},{key:"elements",get:function(){return this._elements}},{key:"isSubmenuItem",get:function(){return this._submenu}},{key:"focus",value:function(){this.elements.parentMenu.shouldFocus&&this.dom.link.focus()}},{key:"blur",value:function(){this.elements.parentMenu.shouldFocus&&this.dom.link.blur()}}]),e}();function E(e){try{var t=e.key||e.keyCode,n={Enter:"Enter"===t||13===t,Space:" "===t||"Spacebar"===t||32===t,Escape:"Escape"===t||"Esc"===t||27===t,ArrowUp:"ArrowUp"===t||"Up"===t||38===t,ArrowRight:"ArrowRight"===t||"Right"===t||39===t,ArrowDown:"ArrowDown"===t||"Down"===t||40===t,ArrowLeft:"ArrowLeft"===t||"Left"===t||37===t,Home:"Home"===t||36===t,End:"End"===t||35===t,Character:isNaN(t)&&!!t.match(/^[a-zA-Z]{1}$/),Tab:"Tab"===t||9===t,Asterisk:"*"===t||56===t};return Object.keys(n).find((function(e){return!0===n[e]}))||""}catch(e){return""}}function M(e){e.preventDefault(),e.stopPropagation()}var C=function(){function n(e){var o=e.menuElement,r=e.menuItemSelector,i=void 0===r?"li":r,l=e.menuLinkSelector,u=void 0===l?"a":l,c=e.submenuItemSelector,a=void 0===c?"":c,m=e.submenuToggleSelector,h=void 0===m?"a":m,f=e.submenuSelector,d=void 0===f?"ul":f,p=e.controllerElement,v=void 0===p?null:p,y=e.containerElement,g=void 0===y?null:y,E=e.openClass,M=void 0===E?"show":E,C=e.closeClass,T=void 0===C?"hide":C,w=e.isTopLevel,k=void 0===w||w,S=e.parentMenu,I=void 0===S?null:S,L=e.hoverType,A=void 0===L?"off":L,O=e.hoverDelay,D=void 0===O?250:O;t(this,n),s(this,"_MenuType",n),s(this,"_MenuItemType",_),s(this,"_MenuToggleType",b),s(this,"_dom",{menu:null,menuItems:[],submenuItems:[],submenuToggles:[],submenus:[],controller:null,container:null}),s(this,"_selectors",{menuItems:"",menuLinks:"",submenuItems:"",submenuToggles:"",submenus:""}),s(this,"_elements",{menuItems:[],submenuToggles:[],controller:null,parentMenu:null,rootMenu:null}),s(this,"_openClass","show"),s(this,"_closeClass","hide"),s(this,"_root",!0),s(this,"_currentChild",0),s(this,"_focusState","none"),s(this,"_currentEvent","none"),s(this,"_hoverType","off"),s(this,"_hoverDelay",250),this._dom.menu=o,this._dom.controller=v,this._dom.container=g,this._selectors.menuItems=i,this._selectors.menuLinks=u,this._selectors.submenuItems=a,this._selectors.submenuToggles=h,this._selectors.submenus=d,this._elements.menuItems=[],this._elements.submenuToggles=[],this._elements.controller=null,this._elements.parentMenu=I,this._elements.rootMenu=k?this:null,this._openClass=M||"",this._closeClass=T||"",this._root=k,this._hoverType=A,this._hoverDelay=D}return o(n,[{key:"initialize",value:function(){if(!this._validate())throw new Error("AccesibleMenu: cannot initialize menu. See other error messages for more information.");if(null===this.elements.rootMenu&&this._findRootMenu(this),this._setDOMElements(),this.isTopLevel&&this.dom.controller&&this.dom.container){var e=new this._MenuToggleType({menuToggleElement:this.dom.controller,parentElement:this.dom.container,controlledMenu:this});this._elements.controller=e}this._createChildElements()}},{key:"dom",get:function(){return this._dom}},{key:"selectors",get:function(){return this._selectors}},{key:"elements",get:function(){return this._elements}},{key:"isTopLevel",get:function(){return this._root}},{key:"openClass",get:function(){return this.isTopLevel?this._openClass:this.elements.rootMenu.openClass},set:function(e){y({openClass:e}),this._openClass!==e&&(this._openClass=e)}},{key:"closeClass",get:function(){return this.isTopLevel?this._closeClass:this.elements.rootMenu.closeClass},set:function(e){y({closeClass:e}),this._closeClass!==e&&(this._closeClass=e)}},{key:"currentChild",get:function(){return this._currentChild},set:function(e){function t(e){if(["mouse","character"].includes(e.currentEvent)&&e.elements.parentMenu)for(var t=0,n=!1;!n&&t<e.elements.parentMenu.elements.menuItems.length;){var o=e.elements.parentMenu.elements.menuItems[t];o.isSubmenuItem&&o.elements.toggle.elements.controlledMenu===e&&(n=!0,e.elements.parentMenu.currentEvent=e.currentEvent,e.elements.parentMenu.currentChild=t),t++}}p("number",{value:e}),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))}},{key:"focusState",get:function(){return this._focusState},set:function(t){!function(t){try{if("object"!==e(t)){var n=e(t);throw new TypeError("AccessibleMenu: Values given to isValidState() must be inside of an object. ".concat(n," given."))}var o=["none","self","child"];for(var s in t)if(!o.includes(t[s]))throw new TypeError("AccessibleMenu: ".concat(s," must be one of the following values: ").concat(o.join(", "),'. "').concat(t[s],'" given.'))}catch(e){return console.error(e),!1}}({value:t}),this._focusState!==t&&(this._focusState=t),this.elements.submenuToggles.length>0&&("self"===t||"none"===t)&&this.elements.submenuToggles.forEach((function(e){e.elements.controlledMenu.focusState="none"})),!this.elements.parentMenu||"self"!==t&&"child"!==t||(this.elements.parentMenu.focusState="child")}},{key:"currentEvent",get:function(){return this._currentEvent},set:function(t){!function(t){try{if("object"!==e(t)){var n=e(t);throw new TypeError("AccessibleMenu: Values given to isValidEvent() must be inside of an object. ".concat(n," given."))}var o=["none","mouse","keyboard","character"];for(var s in t)if(!o.includes(t[s]))throw new TypeError("AccessibleMenu: ".concat(s," must be one of the following values: ").concat(o.join(", "),'. "').concat(t[s],'" given.'))}catch(e){return console.error(e),!1}}({value:t}),this._currentEvent!==t&&(this._currentEvent=t,this.elements.submenuToggles.length>0&&this.elements.submenuToggles.forEach((function(e){e.elements.controlledMenu.currentEvent=t})))}},{key:"currentMenuItem",get:function(){return this.elements.menuItems[this.currentChild]}},{key:"hoverType",get:function(){return this._root?this._hoverType:this.elements.rootMenu.hoverType},set:function(e){g({value:e}),this._hoverType!==e&&(this._hoverType=e)}},{key:"hoverDelay",get:function(){return this._root?this._hoverDelay:this.elements.rootMenu.hoverDelay},set:function(e){p("number",{value:e}),this._hoverDelay!==e&&(this._hoverDelay=e)}},{key:"shouldFocus",get:function(){var e=!1;return"keyboard"!==this.currentEvent&&"character"!==this.currentEvent||(e=!0),"mouse"===this.currentEvent&&"dynamic"===this.hoverType&&(e=!0),e}},{key:"_validate",value:function(){var e=!0;return null!==this._dom.container||null!==this._dom.controller?d(HTMLElement,{menuElement:this._dom.menu,controllerElement:this._dom.controller,containerElement:this._dom.container})||(e=!1):d(HTMLElement,{menuElement:this._dom.menu})||(e=!1),""!==this._selectors.submenuItems?v({menuItemSelector:this._selectors.menuItems,menuLinkSelector:this._selectors.menuLinks,submenuItemSelector:this._selectors.submenuItems,submenuToggleSelector:this._selectors.submenuToggles,submenuSelector:this._selectors.submenus})||(e=!1):v({menuItemSelector:this._selectors.menuItems,menuLinkSelector:this._selectors.menuLinks})||(e=!1),""===this._openClass||y({openClass:this._openClass})||(e=!1),""===this._closeClass||y({closeClass:this._closeClass})||(e=!1),p("boolean",{isTopLevel:this._root})||(e=!1),null===this._elements.parentMenu||d(n,{parentMenu:this._elements.parentMenu})||(e=!1),g({hoverType:this._hoverType})||(e=!1),p("number",{hoverDelay:this._hoverDelay})||(e=!1),e}},{key:"_setDOMElementType",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.dom.menu,n=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];if("string"!=typeof this.selectors[e])throw new Error('AccessibleMenu: "'.concat(e,'" is not a valid element type within the menu.'));if(!Array.isArray(this.dom[e]))throw new Error('AccessibleMenu: The "'.concat(e,'" element cannot be set through _setDOMElementType.'));t!==this.dom.menu&&d(HTMLElement,{base:t});var o=Array.from(t.querySelectorAll(this.selectors[e])),s=o.filter((function(e){return e.parentElement===t}));this._dom[e]=n?s:[].concat(h(this._dom[e]),h(s))}},{key:"_resetDOMElementType",value:function(e){if(void 0===this.dom[e])throw new Error('AccessibleMenu: "'.concat(e,'" is not a valid element type within the menu.'));if(!Array.isArray(this.dom[e]))throw new Error('AccessibleMenu: The "'.concat(e,'" element cannot be reset through _resetDOMElementType.'));this._dom[e]=[]}},{key:"_setDOMElements",value:function(){var e=this;this._setDOMElementType("menuItems"),""!==this.selectors.submenuItems&&(this._setDOMElementType("submenuItems"),this._resetDOMElementType("submenuToggles"),this._resetDOMElementType("submenus"),this.dom.submenuItems.forEach((function(t){e._setDOMElementType("submenuToggles",t,!1),e._setDOMElementType("submenus",t,!1)})))}},{key:"_findRootMenu",value:function(e){if(e.isTopLevel)this._elements.rootMenu=e;else{if(null===e.elements.parentMenu)throw new Error("Cannot find root menu.");this._findRootMenu(e.elements.parentMenu)}}},{key:"_createChildElements",value:function(){var e=this;this.dom.menuItems.forEach((function(t){var n;if(e.dom.submenuItems.includes(t)){var o=t.querySelector(e.selectors.submenuToggles),s=t.querySelector(e.selectors.submenus),r=new e._MenuType({menuElement:s,menuItemSelector:e.selectors.menuItems,menuLinkSelector:e.selectors.menuLinks,submenuItemSelector:e.selectors.submenuItems,submenuToggleSelector:e.selectors.submenuToggles,submenuSelector:e.selectors.submenus,openClass:e.openClass,closeClass:e.closeClass,isTopLevel:!1,parentMenu:e,hoverType:e.hoverType,hoverDelay:e.hoverDelay}),i=new e._MenuToggleType({menuToggleElement:o,parentElement:t,controlledMenu:r,parentMenu:e});e._elements.submenuToggles.push(i),n=new e._MenuItemType({menuItemElement:t,menuLinkElement:o,parentMenu:e,isSubmenuItem:!0,childMenu:r,toggle:i})}else{var l=t.querySelector(e.selectors.menuLinks);n=new e._MenuItemType({menuItemElement:t,menuLinkElement:l,parentMenu:e})}e._elements.menuItems.push(n)}))}},{key:"_handleFocus",value:function(){var e=this;this.elements.menuItems.forEach((function(t,n){t.dom.link.addEventListener("focus",(function(){e.focusState="self",e.currentChild=n}))}))}},{key:"_handleClick",value:function(){var e=this;function t(e,t,n){M(n),t.toggle(),t.isOpen&&(e.focusState="self",t.elements.controlledMenu.focusState="none")}this.elements.menuItems.forEach((function(n,o){n.dom.link.addEventListener("pointerdown",(function(){e.currentEvent="mouse",e.elements.rootMenu.blurChildren(),e.focusChild(o)}),{passive:!0}),n.isSubmenuItem&&n.elements.toggle.dom.toggle.addEventListener("pointerup",(function(o){e.currentEvent="mouse",t(e,n.elements.toggle,o)}))})),this.isTopLevel&&this.elements.controller&&this.elements.controller.dom.toggle.addEventListener("pointerup",(function(n){e.currentEvent="mouse",t(e,e.elements.controller,n)}))}},{key:"_handleHover",value:function(){var e=this;this.elements.menuItems.forEach((function(t,n){t.dom.link.addEventListener("mouseenter",(function(){if("on"===e.hoverType)e.currentEvent="mouse",e.currentChild=n,t.isSubmenuItem&&t.elements.toggle.preview();else if("dynamic"===e.hoverType){var o=e.elements.submenuToggles.some((function(e){return e.isOpen}));e.currentChild=n,e.isTopLevel&&"none"===e.focusState||(e.currentEvent="mouse",e.focusCurrentChild()),!t.isSubmenuItem||e.isTopLevel&&!o||(e.currentEvent="mouse",t.elements.toggle.preview())}})),t.isSubmenuItem&&t.dom.item.addEventListener("mouseleave",(function(){"on"===e.hoverType?e.hoverDelay>0?setTimeout((function(){e.currentEvent="mouse",t.elements.toggle.close()}),e.hoverDelay):(e.currentEvent="mouse",t.elements.toggle.close()):"dynamic"===e.hoverType&&(e.isTopLevel||(e.hoverDelay>0?setTimeout((function(){e.currentEvent="mouse",t.elements.toggle.close(),e.focusCurrentChild()}),e.hoverDelay):(e.currentEvent="mouse",t.elements.toggle.close(),e.focusCurrentChild())))}))}))}},{key:"_handleKeydown",value:function(){var e=this;this.isTopLevel&&this.elements.controller&&this.elements.controller.dom.toggle.addEventListener("keydown",(function(t){e.currentEvent="keyboard";var n=E(t);"Space"!==n&&"Enter"!==n||M(t)}))}},{key:"_handleKeyup",value:function(){var e=this;this.isTopLevel&&this.elements.controller&&this.elements.controller.dom.toggle.addEventListener("keyup",(function(t){e.currentEvent="keyboard";var n=E(t);"Space"!==n&&"Enter"!==n||(M(t),e.elements.controller.open(),e.focusFirstChild())}))}},{key:"focus",value:function(){this.focusState="self",this.shouldFocus&&this.dom.menu.focus()}},{key:"blur",value:function(){this.focusState="none",this.shouldFocus&&this.dom.menu.blur()}},{key:"focusCurrentChild",value:function(){this.focusState="self",-1!==this.currentChild&&this.currentMenuItem.focus()}},{key:"focusChild",value:function(e){this.blurCurrentChild(),this.currentChild=e,this.focusCurrentChild()}},{key:"focusFirstChild",value:function(){this.focusChild(0)}},{key:"focusLastChild",value:function(){this.focusChild(this.elements.menuItems.length-1)}},{key:"focusNextChild",value:function(){this.currentChild<this.elements.menuItems.length-1?this.focusChild(this.currentChild+1):this.focusCurrentChild()}},{key:"focusPreviousChild",value:function(){this.currentChild>0?this.focusChild(this.currentChild-1):this.focusCurrentChild()}},{key:"blurCurrentChild",value:function(){this.focusState="none",-1!==this.currentChild&&this.currentMenuItem.blur()}},{key:"focusController",value:function(){this.dom.controller&&(this.shouldFocus&&this.dom.controller.focus(),this.focusState="none")}},{key:"focusContainer",value:function(){this.dom.container&&(this.shouldFocus&&this.dom.container.focus(),this.focusState="none")}},{key:"closeChildren",value:function(){this.elements.submenuToggles.forEach((function(e){return e.close()}))}},{key:"blurChildren",value:function(){this.elements.menuItems.forEach((function(e){e.blur(),e.isSubmenuItem&&e.elements.childMenu.blurChildren()}))}}]),n}(),T=function(e){r(o,e);var n=a(o);function o(e){var s,r=e.menuItemElement,i=e.menuLinkElement,l=e.parentMenu,u=e.isSubmenuItem,c=void 0!==u&&u,a=e.childMenu,m=void 0===a?null:a,h=e.toggle,f=void 0===h?null:h,d=e.initialize,p=void 0===d||d;return t(this,o),s=n.call(this,{menuItemElement:r,menuLinkElement:i,parentMenu:l,isSubmenuItem:c,childMenu:m,toggle:f}),p&&s.initialize(),s}return o}(_),w=function(e){r(s,e);var n=a(s);function s(e){var o,r=e.menuToggleElement,i=e.parentElement,l=e.controlledMenu,u=e.parentMenu,c=void 0===u?null:u,a=e.initialize,m=void 0===a||a;return t(this,s),o=n.call(this,{menuToggleElement:r,parentElement:i,controlledMenu:l,parentMenu:c}),m&&o.initialize(),o}return o(s,[{key:"open",value:function(){this.closeSiblings(),m(i(s.prototype),"open",this).call(this)}},{key:"preview",value:function(){this.closeSiblings(),m(i(s.prototype),"preview",this).call(this)}},{key:"close",value:function(){this.isOpen&&this.closeChildren(),m(i(s.prototype),"close",this).call(this)}}]),s}(b);return function(e){r(l,e);var n=a(l);function l(e){var o,r=e.menuElement,i=e.menuItemSelector,c=void 0===i?"li":i,a=e.menuLinkSelector,m=void 0===a?"a":a,h=e.submenuItemSelector,f=void 0===h?"":h,d=e.submenuToggleSelector,p=void 0===d?"a":d,v=e.submenuSelector,y=void 0===v?"ul":v,g=e.controllerElement,b=void 0===g?null:g,_=e.containerElement,E=void 0===_?null:_,M=e.openClass,C=void 0===M?"show":M,k=e.closeClass,S=void 0===k?"hide":k,I=e.isTopLevel,L=void 0===I||I,A=e.parentMenu,O=void 0===A?null:A,D=e.hoverType,j=void 0===D?"off":D,R=e.hoverDelay,z=void 0===R?250:R,K=e.optionalKeySupport,x=void 0!==K&&K,F=e.initialize,P=void 0===F||F;return t(this,l),s(u(o=n.call(this,{menuElement:r,menuItemSelector:c,menuLinkSelector:m,submenuItemSelector:f,submenuToggleSelector:p,submenuSelector:y,controllerElement:b,containerElement:E,openClass:C,closeClass:S,isTopLevel:L,parentMenu:O,hoverType:j,hoverDelay:z})),"_MenuType",l),s(u(o),"_MenuItemType",T),s(u(o),"_MenuToggleType",w),s(u(o),"_currentChild",-1),s(u(o),"_optionalSupport",!1),o._optionalSupport=x,P&&o.initialize(),o}return o(l,[{key:"initialize",value:function(){try{m(i(l.prototype),"initialize",this).call(this),this._handleFocus(),this._handleClick(),this._handleHover(),this._handleKeydown(),this._handleKeyup()}catch(e){console.error(e)}}},{key:"optionalKeySupport",get:function(){return this.isTopLevel?this._optionalSupport:this.elements.rootMenu.optionalKeySupport},set:function(e){p("boolean",{optionalKeySupport:e}),this._optionalSupport=e}},{key:"_validate",value:function(){var e=m(i(l.prototype),"_validate",this).call(this);return p("boolean",{optionalKeySupport:this._optionalSupport})||(e=!1),e}},{key:"_handleClick",value:function(){var e=this;m(i(l.prototype),"_handleClick",this).call(this),document.addEventListener("pointerup",(function(t){"none"!==e.focusState&&(e.currentEvent="mouse",e.dom.menu.contains(t.target)||!e.dom.menu===t.target||(e.closeChildren(),e.blur(),e.elements.controller&&e.elements.controller.close()))}))}},{key:"_handleKeydown",value:function(){var e=this;m(i(l.prototype),"_handleKeydown",this).call(this),this.dom.menu.addEventListener("keydown",(function(t){e.currentEvent="keyboard";var n=E(t);if("self"===e.focusState){if(e.optionalKeySupport){["ArrowUp","ArrowRight","ArrowDown","ArrowLeft","Home","End"].includes(n)&&M(t)}else(e.currentMenuItem.isSubmenuItem&&["Space","Enter"].includes(n)||e.elements.controller&&["Escape"].includes(n)||e.elements.parentMenu&&["Escape"].includes(n))&&M(t)}}))}},{key:"_handleKeyup",value:function(){var e=this;m(i(l.prototype),"_handleKeyup",this).call(this),this.dom.menu.addEventListener("keyup",(function(t){e.currentEvent="keyboard";var n=E(t);if("self"===e.focusState)if("Space"===n||"Enter"===n)e.currentMenuItem.isSubmenuItem?(M(t),e.currentMenuItem.elements.toggle.preview()):e.currentMenuItem.dom.link.click();else if("Escape"===n){e.elements.submenuToggles.some((function(e){return e.isOpen}))?(M(t),e.closeChildren()):e.elements.parentMenu?(M(t),e.elements.parentMenu.currentEvent=e.currentEvent,e.elements.parentMenu.closeChildren(),e.elements.parentMenu.focusCurrentChild()):e.isTopLevel&&e.elements.controller&&e.elements.controller.isOpen&&(e.elements.controller.close(),e.focusController())}else e.optionalKeySupport&&("ArrowDown"===n||"ArrowRight"===n?(M(t),e.currentMenuItem.isSubmenuItem&&e.currentMenuItem.elements.toggle.isOpen?(e.currentMenuItem.elements.childMenu.currentEvent="keyboard",e.currentMenuItem.elements.childMenu.focusFirstChild()):e.focusNextChild()):"ArrowUp"===n||"ArrowLeft"===n?(M(t),e.focusPreviousChild()):"Home"===n?(M(t),e.focusFirstChild()):"End"===n&&(M(t),e.focusLastChild()))}))}}]),l}(C)}();
//# sourceMappingURL=disclosure-menu.min.js.map

@@ -109,2 +109,4 @@ function _typeof(obj) {

return call;
} else if (call !== void 0) {
throw new TypeError("Derived constructors may only return object or undefined");
}

@@ -356,14 +358,2 @@

}
function isEventSupported(event, element) {
if (isValidType("string", {
event: event
}) && isValidInstance(HTMLElement, {
element: element
})) {
var eventProp = "on".concat(event);
return typeof element[eventProp] !== "undefined";
} else {
return false;
}
}

@@ -1134,4 +1124,2 @@ var BaseMenuToggle = function () {

var _this4 = this;
var startEventType = isEventSupported("touchstart", this.dom.menu) ? "touchstart" : "mousedown";
var endEventType = isEventSupported("touchend", this.dom.menu) ? "touchend" : "mouseup";
function toggleToggle(menu, toggle, event) {

@@ -1146,19 +1134,21 @@ preventEvent(event);

this.elements.menuItems.forEach(function (item, index) {
item.dom.link.addEventListener(startEventType, function () {
item.dom.link.addEventListener("pointerdown", function () {
_this4.currentEvent = "mouse";
_this4.elements.rootMenu.blurChildren();
_this4.focusChild(index);
}, {
passive: true
});
if (item.isSubmenuItem) {
item.elements.toggle.dom.toggle["on".concat(endEventType)] = function (event) {
item.elements.toggle.dom.toggle.addEventListener("pointerup", function (event) {
_this4.currentEvent = "mouse";
toggleToggle(_this4, item.elements.toggle, event);
};
});
}
});
if (this.isTopLevel && this.elements.controller) {
this.elements.controller.dom.toggle["on".concat(endEventType)] = function (event) {
this.elements.controller.dom.toggle.addEventListener("pointerup", function (event) {
_this4.currentEvent = "mouse";
toggleToggle(_this4, _this4.elements.controller, event);
};
});
}

@@ -1550,4 +1540,3 @@ }

_get(_getPrototypeOf(Menubar.prototype), "_handleClick", this).call(this);
var endEventType = isEventSupported("touchend", this.dom.menu) ? "touchend" : "mouseup";
document.addEventListener(endEventType, function (event) {
document.addEventListener("pointerup", function (event) {
if (_this2.focusState !== "none") {

@@ -1554,0 +1543,0 @@ _this2.currentEvent = "mouse";

@@ -1,2 +0,2 @@

function e(t){return(e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(t)}function t(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function n(e,t){for(var n=0;n<t.length;n++){var o=t[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}function o(e,t,o){return t&&n(e.prototype,t),o&&n(e,o),e}function s(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function r(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&l(e,t)}function i(e){return(i=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function l(e,t){return(l=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function u(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function c(e,t){return!t||"object"!=typeof t&&"function"!=typeof t?u(e):t}function m(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,o=i(e);if(t){var s=i(this).constructor;n=Reflect.construct(o,arguments,s)}else n=o.apply(this,arguments);return c(this,n)}}function a(e,t,n){return(a="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(e,t,n){var o=function(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&null!==(e=i(e)););return e}(e,t);if(o){var s=Object.getOwnPropertyDescriptor(o,t);return s.get?s.get.call(n):s.value}})(e,t,n||e)}function h(e){return function(e){if(Array.isArray(e))return d(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,t){if(!e)return;if("string"==typeof e)return d(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return d(e,t)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function d(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,o=new Array(t);n<t;n++)o[n]=e[n];return o}function f(t,n){try{if("object"!==e(n)){var o=e(n);throw new TypeError("AccessibleMenu: Elements given to isValidInstance() must be inside of an object. ".concat(o," given."))}for(var s in n)if(!(n[s]instanceof t)){var r=e(n[s]);throw new TypeError("AccessibleMenu: ".concat(s," must be an instance of ").concat(t.name,". ").concat(r," given."))}return!0}catch(e){return console.error(e),!1}}function v(t,n){try{if("object"!==e(n)){var o=e(n);throw new TypeError("AccessibleMenu: Values given to isValidType() must be inside of an object. ".concat(o," given."))}for(var s in n){var r=e(n[s]);if(r!==t)throw new TypeError("AccessibleMenu: ".concat(s," must be a ").concat(t,". ").concat(r," given."))}return!0}catch(e){return console.error(e),!1}}function p(t){try{if("object"!==e(t)){var n=e(t);throw new TypeError("AccessibleMenu: Values given to isCSSSelector() must be inside of an object. ".concat(n," given."))}for(var o in t)try{if(null===t[o])throw new Error;document.querySelector(t[o])}catch(e){throw new TypeError("AccessibleMenu: ".concat(o,' must be a valid CSS selector. "').concat(t[o],'" given.'))}return!0}catch(e){return console.error(e),!1}}function g(t){try{if("object"!==e(t)||Array.isArray(t)){var n=e(t);throw new TypeError("AccessibleMenu: Values given to isValidClassList() must be inside of an object. ".concat(n," given."))}var o=function(n){var o=e(t[n]);if("string"!==o){if(!Array.isArray(t[n]))throw new TypeError("AccessibleMenu: ".concat(n," must be a string or an array of strings. ").concat(o," given."));t[n].forEach((function(e){if("string"!=typeof e)throw new TypeError("AccessibleMenu: ".concat(n," must be a string or an array of strings. An array containing non-strings given."))}))}else{var s={};s[n]=t[n],p(s)}};for(var s in t)o(s);return!0}catch(e){return console.error(e),!1}}function y(t){try{if("object"!==e(t)){var n=e(t);throw new TypeError("AccessibleMenu: Values given to isValidHoverType() must be inside of an object. ".concat(n," given."))}var o=["off","on","dynamic"];for(var s in t)if(!o.includes(t[s]))throw new TypeError("AccessibleMenu: ".concat(s," must be one of the following values: ").concat(o.join(", "),'. "').concat(t[s],'" given.'));return!0}catch(e){return console.error(e),!1}}function b(e,t){return!(!v("string",{event:e})||!f(HTMLElement,{element:t}))&&void 0!==t["on".concat(e)]}var M=function(){function e(n){var o=n.menuToggleElement,r=n.parentElement,i=n.controlledMenu,l=n.parentMenu,u=void 0===l?null:l;t(this,e),s(this,"_dom",{toggle:null,parent:null}),s(this,"_elements",{controlledMenu:null,parentMenu:null}),s(this,"_open",!1),s(this,"_expandEvent",new CustomEvent("accessibleMenuExpand",{bubbles:!0,detail:{toggle:this}})),s(this,"_collapseEvent",new CustomEvent("accessibleMenuCollapse",{bubbles:!0,detail:{toggle:this}})),this._dom.toggle=o,this._dom.parent=r,this._elements.controlledMenu=i,this._elements.parentMenu=u}return o(e,[{key:"initialize",value:function(){if(this.dom.toggle.setAttribute("aria-haspopup","true"),this.dom.toggle.setAttribute("aria-expanded","false"),function(e,t){if(v("string",{tagName:e})&&f(HTMLElement,t)){var n=e.toLowerCase(),o=!0;for(var s in t)t[s].tagName.toLowerCase()!==n&&(o=!1);return o}return!1}("button",{toggle:this.dom.toggle})||this.dom.toggle.setAttribute("role","button"),""===this.dom.toggle.id||""===this.elements.controlledMenu.dom.menu.id){var e=Math.random().toString(36).replace(/[^a-z]+/g,"").substr(0,10),t=this.dom.toggle.innerText.replace(/[^a-zA-Z0-9\s]/g,""),n=e;!t.replace(/\s/g,"").length&&this.dom.toggle.getAttribute("aria-label")&&(t=this.dom.toggle.getAttribute("aria-label").replace(/[^a-zA-Z0-9\s]/g,"")),t.replace(/\s/g,"").length>0&&((t=t.toLowerCase().replace(/\s+/g,"-")).startsWith("-")&&(t=t.substring(1)),t.endsWith("-")&&(t=t.slice(0,-1)),n="".concat(t,"-").concat(n)),this.dom.toggle.id=this.dom.toggle.id||"".concat(n,"-menu-button"),this.elements.controlledMenu.dom.menu.id=this.elements.controlledMenu.dom.menu.id||"".concat(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)}},{key:"dom",get:function(){return this._dom}},{key:"elements",get:function(){return this._elements}},{key:"isOpen",get:function(){return this._open},set:function(e){v("boolean",{value:e}),this._open=e}},{key:"_expand",value:function(){var e,t,n=!(arguments.length>0&&void 0!==arguments[0])||arguments[0],o=this.elements.controlledMenu,s=o.closeClass,r=o.openClass;(this.dom.toggle.setAttribute("aria-expanded","true"),""!==r)&&("string"==typeof r?this.elements.controlledMenu.dom.menu.classList.add(r):(e=this.elements.controlledMenu.dom.menu.classList).add.apply(e,h(r)));""!==s&&("string"==typeof s?this.elements.controlledMenu.dom.menu.classList.remove(s):(t=this.elements.controlledMenu.dom.menu.classList).remove.apply(t,h(s)));n&&this.dom.toggle.dispatchEvent(this._expandEvent)}},{key:"_collapse",value:function(){var e,t,n=!(arguments.length>0&&void 0!==arguments[0])||arguments[0],o=this.elements.controlledMenu,s=o.closeClass,r=o.openClass;(this.dom.toggle.setAttribute("aria-expanded","false"),""!==s)&&("string"==typeof s?this.elements.controlledMenu.dom.menu.classList.add(s):(e=this.elements.controlledMenu.dom.menu.classList).add.apply(e,h(s)));""!==r&&("string"==typeof r?this.elements.controlledMenu.dom.menu.classList.remove(r):(t=this.elements.controlledMenu.dom.menu.classList).remove.apply(t,h(r)));n&&this.dom.toggle.dispatchEvent(this._collapseEvent)}},{key:"open",value:function(){this.elements.controlledMenu.focusState="self",this._expand(),this.isOpen=!0}},{key:"preview",value:function(){this.elements.parentMenu&&(this.elements.parentMenu.focusState="self"),this._expand(),this.isOpen=!0}},{key:"close",value:function(){this.isOpen&&(this.elements.controlledMenu.currentChild=0,this.elements.controlledMenu.blur(),this.elements.parentMenu&&(this.elements.parentMenu.focusState="self"),this._collapse(),this.isOpen=!1)}},{key:"toggle",value:function(){this.isOpen?this.close():this.open()}},{key:"closeSiblings",value:function(){var e=this;this.elements.parentMenu&&this.elements.parentMenu.elements.submenuToggles.forEach((function(t){t!==e&&t.close()}))}},{key:"closeChildren",value:function(){this.elements.controlledMenu.elements.submenuToggles.forEach((function(e){return e.close()}))}}]),e}(),_=function(){function e(n){var o=n.menuItemElement,r=n.menuLinkElement,i=n.parentMenu,l=n.isSubmenuItem,u=void 0!==l&&l,c=n.childMenu,m=void 0===c?null:c,a=n.toggle,h=void 0===a?null:a;t(this,e),s(this,"_dom",{item:null,link:null}),s(this,"_elements",{parentMenu:null,childMenu:null,toggle:null}),s(this,"_submenu",!1),this._dom.item=o,this._dom.link=r,this._elements.parentMenu=i,this._elements.childMenu=m,this._elements.toggle=h,this._submenu=u}return o(e,[{key:"initialize",value:function(){}},{key:"dom",get:function(){return this._dom}},{key:"elements",get:function(){return this._elements}},{key:"isSubmenuItem",get:function(){return this._submenu}},{key:"focus",value:function(){this.elements.parentMenu.shouldFocus&&this.dom.link.focus()}},{key:"blur",value:function(){this.elements.parentMenu.shouldFocus&&this.dom.link.blur()}}]),e}();function E(e){try{var t=e.key||e.keyCode,n={Enter:"Enter"===t||13===t,Space:" "===t||"Spacebar"===t||32===t,Escape:"Escape"===t||"Esc"===t||27===t,ArrowUp:"ArrowUp"===t||"Up"===t||38===t,ArrowRight:"ArrowRight"===t||"Right"===t||39===t,ArrowDown:"ArrowDown"===t||"Down"===t||40===t,ArrowLeft:"ArrowLeft"===t||"Left"===t||37===t,Home:"Home"===t||36===t,End:"End"===t||35===t,Character:isNaN(t)&&!!t.match(/^[a-zA-Z]{1}$/),Tab:"Tab"===t||9===t,Asterisk:"*"===t||56===t};return Object.keys(n).find((function(e){return!0===n[e]}))||""}catch(e){return""}}function C(e){e.preventDefault(),e.stopPropagation()}var I=function(){function n(e){var o=e.menuElement,r=e.menuItemSelector,i=void 0===r?"li":r,l=e.menuLinkSelector,u=void 0===l?"a":l,c=e.submenuItemSelector,m=void 0===c?"":c,a=e.submenuToggleSelector,h=void 0===a?"a":a,d=e.submenuSelector,f=void 0===d?"ul":d,v=e.controllerElement,p=void 0===v?null:v,g=e.containerElement,y=void 0===g?null:g,b=e.openClass,E=void 0===b?"show":b,C=e.closeClass,I=void 0===C?"hide":C,T=e.isTopLevel,k=void 0===T||T,w=e.parentMenu,S=void 0===w?null:w,A=e.hoverType,L=void 0===A?"off":A,O=e.hoverDelay,D=void 0===O?250:O;t(this,n),s(this,"_MenuType",n),s(this,"_MenuItemType",_),s(this,"_MenuToggleType",M),s(this,"_dom",{menu:null,menuItems:[],submenuItems:[],submenuToggles:[],submenus:[],controller:null,container:null}),s(this,"_selectors",{menuItems:"",menuLinks:"",submenuItems:"",submenuToggles:"",submenus:""}),s(this,"_elements",{menuItems:[],submenuToggles:[],controller:null,parentMenu:null,rootMenu:null}),s(this,"_openClass","show"),s(this,"_closeClass","hide"),s(this,"_root",!0),s(this,"_currentChild",0),s(this,"_focusState","none"),s(this,"_currentEvent","none"),s(this,"_hoverType","off"),s(this,"_hoverDelay",250),this._dom.menu=o,this._dom.controller=p,this._dom.container=y,this._selectors.menuItems=i,this._selectors.menuLinks=u,this._selectors.submenuItems=m,this._selectors.submenuToggles=h,this._selectors.submenus=f,this._elements.menuItems=[],this._elements.submenuToggles=[],this._elements.controller=null,this._elements.parentMenu=S,this._elements.rootMenu=k?this:null,this._openClass=E||"",this._closeClass=I||"",this._root=k,this._hoverType=L,this._hoverDelay=D}return o(n,[{key:"initialize",value:function(){if(!this._validate())throw new Error("AccesibleMenu: cannot initialize menu. See other error messages for more information.");if(null===this.elements.rootMenu&&this._findRootMenu(this),this._setDOMElements(),this.isTopLevel&&this.dom.controller&&this.dom.container){var e=new this._MenuToggleType({menuToggleElement:this.dom.controller,parentElement:this.dom.container,controlledMenu:this});this._elements.controller=e}this._createChildElements()}},{key:"dom",get:function(){return this._dom}},{key:"selectors",get:function(){return this._selectors}},{key:"elements",get:function(){return this._elements}},{key:"isTopLevel",get:function(){return this._root}},{key:"openClass",get:function(){return this.isTopLevel?this._openClass:this.elements.rootMenu.openClass},set:function(e){g({openClass:e}),this._openClass!==e&&(this._openClass=e)}},{key:"closeClass",get:function(){return this.isTopLevel?this._closeClass:this.elements.rootMenu.closeClass},set:function(e){g({closeClass:e}),this._closeClass!==e&&(this._closeClass=e)}},{key:"currentChild",get:function(){return this._currentChild},set:function(e){function t(e){if(["mouse","character"].includes(e.currentEvent)&&e.elements.parentMenu)for(var t=0,n=!1;!n&&t<e.elements.parentMenu.elements.menuItems.length;){var o=e.elements.parentMenu.elements.menuItems[t];o.isSubmenuItem&&o.elements.toggle.elements.controlledMenu===e&&(n=!0,e.elements.parentMenu.currentEvent=e.currentEvent,e.elements.parentMenu.currentChild=t),t++}}v("number",{value:e}),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))}},{key:"focusState",get:function(){return this._focusState},set:function(t){!function(t){try{if("object"!==e(t)){var n=e(t);throw new TypeError("AccessibleMenu: Values given to isValidState() must be inside of an object. ".concat(n," given."))}var o=["none","self","child"];for(var s in t)if(!o.includes(t[s]))throw new TypeError("AccessibleMenu: ".concat(s," must be one of the following values: ").concat(o.join(", "),'. "').concat(t[s],'" given.'))}catch(e){return console.error(e),!1}}({value:t}),this._focusState!==t&&(this._focusState=t),this.elements.submenuToggles.length>0&&("self"===t||"none"===t)&&this.elements.submenuToggles.forEach((function(e){e.elements.controlledMenu.focusState="none"})),!this.elements.parentMenu||"self"!==t&&"child"!==t||(this.elements.parentMenu.focusState="child")}},{key:"currentEvent",get:function(){return this._currentEvent},set:function(t){!function(t){try{if("object"!==e(t)){var n=e(t);throw new TypeError("AccessibleMenu: Values given to isValidEvent() must be inside of an object. ".concat(n," given."))}var o=["none","mouse","keyboard","character"];for(var s in t)if(!o.includes(t[s]))throw new TypeError("AccessibleMenu: ".concat(s," must be one of the following values: ").concat(o.join(", "),'. "').concat(t[s],'" given.'))}catch(e){return console.error(e),!1}}({value:t}),this._currentEvent!==t&&(this._currentEvent=t,this.elements.submenuToggles.length>0&&this.elements.submenuToggles.forEach((function(e){e.elements.controlledMenu.currentEvent=t})))}},{key:"currentMenuItem",get:function(){return this.elements.menuItems[this.currentChild]}},{key:"hoverType",get:function(){return this._root?this._hoverType:this.elements.rootMenu.hoverType},set:function(e){y({value:e}),this._hoverType!==e&&(this._hoverType=e)}},{key:"hoverDelay",get:function(){return this._root?this._hoverDelay:this.elements.rootMenu.hoverDelay},set:function(e){v("number",{value:e}),this._hoverDelay!==e&&(this._hoverDelay=e)}},{key:"shouldFocus",get:function(){var e=!1;return"keyboard"!==this.currentEvent&&"character"!==this.currentEvent||(e=!0),"mouse"===this.currentEvent&&"dynamic"===this.hoverType&&(e=!0),e}},{key:"_validate",value:function(){var e=!0;return null!==this._dom.container||null!==this._dom.controller?f(HTMLElement,{menuElement:this._dom.menu,controllerElement:this._dom.controller,containerElement:this._dom.container})||(e=!1):f(HTMLElement,{menuElement:this._dom.menu})||(e=!1),""!==this._selectors.submenuItems?p({menuItemSelector:this._selectors.menuItems,menuLinkSelector:this._selectors.menuLinks,submenuItemSelector:this._selectors.submenuItems,submenuToggleSelector:this._selectors.submenuToggles,submenuSelector:this._selectors.submenus})||(e=!1):p({menuItemSelector:this._selectors.menuItems,menuLinkSelector:this._selectors.menuLinks})||(e=!1),""===this._openClass||g({openClass:this._openClass})||(e=!1),""===this._closeClass||g({closeClass:this._closeClass})||(e=!1),v("boolean",{isTopLevel:this._root})||(e=!1),null===this._elements.parentMenu||f(n,{parentMenu:this._elements.parentMenu})||(e=!1),y({hoverType:this._hoverType})||(e=!1),v("number",{hoverDelay:this._hoverDelay})||(e=!1),e}},{key:"_setDOMElementType",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.dom.menu,n=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];if("string"!=typeof this.selectors[e])throw new Error('AccessibleMenu: "'.concat(e,'" is not a valid element type within the menu.'));if(!Array.isArray(this.dom[e]))throw new Error('AccessibleMenu: The "'.concat(e,'" element cannot be set through _setDOMElementType.'));t!==this.dom.menu&&f(HTMLElement,{base:t});var o=Array.from(t.querySelectorAll(this.selectors[e])),s=o.filter((function(e){return e.parentElement===t}));this._dom[e]=n?s:[].concat(h(this._dom[e]),h(s))}},{key:"_resetDOMElementType",value:function(e){if(void 0===this.dom[e])throw new Error('AccessibleMenu: "'.concat(e,'" is not a valid element type within the menu.'));if(!Array.isArray(this.dom[e]))throw new Error('AccessibleMenu: The "'.concat(e,'" element cannot be reset through _resetDOMElementType.'));this._dom[e]=[]}},{key:"_setDOMElements",value:function(){var e=this;this._setDOMElementType("menuItems"),""!==this.selectors.submenuItems&&(this._setDOMElementType("submenuItems"),this._resetDOMElementType("submenuToggles"),this._resetDOMElementType("submenus"),this.dom.submenuItems.forEach((function(t){e._setDOMElementType("submenuToggles",t,!1),e._setDOMElementType("submenus",t,!1)})))}},{key:"_findRootMenu",value:function(e){if(e.isTopLevel)this._elements.rootMenu=e;else{if(null===e.elements.parentMenu)throw new Error("Cannot find root menu.");this._findRootMenu(e.elements.parentMenu)}}},{key:"_createChildElements",value:function(){var e=this;this.dom.menuItems.forEach((function(t){var n;if(e.dom.submenuItems.includes(t)){var o=t.querySelector(e.selectors.submenuToggles),s=t.querySelector(e.selectors.submenus),r=new e._MenuType({menuElement:s,menuItemSelector:e.selectors.menuItems,menuLinkSelector:e.selectors.menuLinks,submenuItemSelector:e.selectors.submenuItems,submenuToggleSelector:e.selectors.submenuToggles,submenuSelector:e.selectors.submenus,openClass:e.openClass,closeClass:e.closeClass,isTopLevel:!1,parentMenu:e,hoverType:e.hoverType,hoverDelay:e.hoverDelay}),i=new e._MenuToggleType({menuToggleElement:o,parentElement:t,controlledMenu:r,parentMenu:e});e._elements.submenuToggles.push(i),n=new e._MenuItemType({menuItemElement:t,menuLinkElement:o,parentMenu:e,isSubmenuItem:!0,childMenu:r,toggle:i})}else{var l=t.querySelector(e.selectors.menuLinks);n=new e._MenuItemType({menuItemElement:t,menuLinkElement:l,parentMenu:e})}e._elements.menuItems.push(n)}))}},{key:"_handleFocus",value:function(){var e=this;this.elements.menuItems.forEach((function(t,n){t.dom.link.addEventListener("focus",(function(){e.focusState="self",e.currentChild=n}))}))}},{key:"_handleClick",value:function(){var e=this,t=b("touchstart",this.dom.menu)?"touchstart":"mousedown",n=b("touchend",this.dom.menu)?"touchend":"mouseup";function o(e,t,n){C(n),t.toggle(),t.isOpen&&(e.focusState="self",t.elements.controlledMenu.focusState="none")}this.elements.menuItems.forEach((function(s,r){s.dom.link.addEventListener(t,(function(){e.currentEvent="mouse",e.elements.rootMenu.blurChildren(),e.focusChild(r)})),s.isSubmenuItem&&(s.elements.toggle.dom.toggle["on".concat(n)]=function(t){e.currentEvent="mouse",o(e,s.elements.toggle,t)})})),this.isTopLevel&&this.elements.controller&&(this.elements.controller.dom.toggle["on".concat(n)]=function(t){e.currentEvent="mouse",o(e,e.elements.controller,t)})}},{key:"_handleHover",value:function(){var e=this;this.elements.menuItems.forEach((function(t,n){t.dom.link.addEventListener("mouseenter",(function(){if("on"===e.hoverType)e.currentEvent="mouse",e.currentChild=n,t.isSubmenuItem&&t.elements.toggle.preview();else if("dynamic"===e.hoverType){var o=e.elements.submenuToggles.some((function(e){return e.isOpen}));e.currentChild=n,e.isTopLevel&&"none"===e.focusState||(e.currentEvent="mouse",e.focusCurrentChild()),!t.isSubmenuItem||e.isTopLevel&&!o||(e.currentEvent="mouse",t.elements.toggle.preview())}})),t.isSubmenuItem&&t.dom.item.addEventListener("mouseleave",(function(){"on"===e.hoverType?e.hoverDelay>0?setTimeout((function(){e.currentEvent="mouse",t.elements.toggle.close()}),e.hoverDelay):(e.currentEvent="mouse",t.elements.toggle.close()):"dynamic"===e.hoverType&&(e.isTopLevel||(e.hoverDelay>0?setTimeout((function(){e.currentEvent="mouse",t.elements.toggle.close(),e.focusCurrentChild()}),e.hoverDelay):(e.currentEvent="mouse",t.elements.toggle.close(),e.focusCurrentChild())))}))}))}},{key:"_handleKeydown",value:function(){var e=this;this.isTopLevel&&this.elements.controller&&this.elements.controller.dom.toggle.addEventListener("keydown",(function(t){e.currentEvent="keyboard";var n=E(t);"Space"!==n&&"Enter"!==n||C(t)}))}},{key:"_handleKeyup",value:function(){var e=this;this.isTopLevel&&this.elements.controller&&this.elements.controller.dom.toggle.addEventListener("keyup",(function(t){e.currentEvent="keyboard";var n=E(t);"Space"!==n&&"Enter"!==n||(C(t),e.elements.controller.open(),e.focusFirstChild())}))}},{key:"focus",value:function(){this.focusState="self",this.shouldFocus&&this.dom.menu.focus()}},{key:"blur",value:function(){this.focusState="none",this.shouldFocus&&this.dom.menu.blur()}},{key:"focusCurrentChild",value:function(){this.focusState="self",-1!==this.currentChild&&this.currentMenuItem.focus()}},{key:"focusChild",value:function(e){this.blurCurrentChild(),this.currentChild=e,this.focusCurrentChild()}},{key:"focusFirstChild",value:function(){this.focusChild(0)}},{key:"focusLastChild",value:function(){this.focusChild(this.elements.menuItems.length-1)}},{key:"focusNextChild",value:function(){this.currentChild<this.elements.menuItems.length-1?this.focusChild(this.currentChild+1):this.focusCurrentChild()}},{key:"focusPreviousChild",value:function(){this.currentChild>0?this.focusChild(this.currentChild-1):this.focusCurrentChild()}},{key:"blurCurrentChild",value:function(){this.focusState="none",-1!==this.currentChild&&this.currentMenuItem.blur()}},{key:"focusController",value:function(){this.dom.controller&&(this.shouldFocus&&this.dom.controller.focus(),this.focusState="none")}},{key:"focusContainer",value:function(){this.dom.container&&(this.shouldFocus&&this.dom.container.focus(),this.focusState="none")}},{key:"closeChildren",value:function(){this.elements.submenuToggles.forEach((function(e){return e.close()}))}},{key:"blurChildren",value:function(){this.elements.menuItems.forEach((function(e){e.blur(),e.isSubmenuItem&&e.elements.childMenu.blurChildren()}))}}]),n}(),T=function(e){r(s,_);var n=m(s);function s(e){var o,r=e.menuItemElement,i=e.menuLinkElement,l=e.parentMenu,u=e.isSubmenuItem,c=void 0!==u&&u,m=e.childMenu,a=void 0===m?null:m,h=e.toggle,d=void 0===h?null:h,f=e.initialize,v=void 0===f||f;return t(this,s),o=n.call(this,{menuItemElement:r,menuLinkElement:i,parentMenu:l,isSubmenuItem:c,childMenu:a,toggle:d}),v&&o.initialize(),o}return o(s,[{key:"initialize",value:function(){a(i(s.prototype),"initialize",this).call(this),this.dom.item.setAttribute("role","none"),this.dom.link.setAttribute("role","menuitem"),this.dom.link.tabIndex=-1}},{key:"focus",value:function(){a(i(s.prototype),"focus",this).call(this),this.elements.parentMenu.isTopLevel&&(this.dom.link.tabIndex=0)}},{key:"blur",value:function(){a(i(s.prototype),"blur",this).call(this),this.elements.parentMenu.isTopLevel&&(this.dom.link.tabIndex=-1)}}]),s}(),k=function(e){r(s,M);var n=m(s);function s(e){var o,r=e.menuToggleElement,i=e.parentElement,l=e.controlledMenu,u=e.parentMenu,c=void 0===u?null:u,m=e.initialize,a=void 0===m||m;return t(this,s),o=n.call(this,{menuToggleElement:r,parentElement:i,controlledMenu:l,parentMenu:c}),a&&o.initialize(),o}return o(s,[{key:"open",value:function(){this.closeSiblings(),a(i(s.prototype),"open",this).call(this)}},{key:"preview",value:function(){this.closeSiblings(),a(i(s.prototype),"preview",this).call(this)}},{key:"close",value:function(){this.isOpen&&this.closeChildren(),a(i(s.prototype),"close",this).call(this)}}]),s}(),w=function(e){r(l,I);var n=m(l);function l(e){var o,r=e.menuElement,i=e.menuItemSelector,c=void 0===i?"li":i,m=e.menuLinkSelector,a=void 0===m?"a":m,h=e.submenuItemSelector,d=void 0===h?"":h,f=e.submenuToggleSelector,v=void 0===f?"a":f,p=e.submenuSelector,g=void 0===p?"ul":p,y=e.controllerElement,b=void 0===y?null:y,M=e.containerElement,_=void 0===M?null:M,E=e.openClass,C=void 0===E?"show":E,I=e.closeClass,w=void 0===I?"hide":I,S=e.isTopLevel,A=void 0===S||S,L=e.parentMenu,O=void 0===L?null:L,D=e.hoverType,j=void 0===D?"off":D,x=e.hoverDelay,F=void 0===x?250:x,R=e.initialize,z=void 0===R||R;return t(this,l),s(u(o=n.call(this,{menuElement:r,menuItemSelector:c,menuLinkSelector:a,submenuItemSelector:d,submenuToggleSelector:v,submenuSelector:g,controllerElement:b,containerElement:_,openClass:C,closeClass:w,isTopLevel:A,parentMenu:O,hoverType:j,hoverDelay:F})),"_MenuType",l),s(u(o),"_MenuItemType",T),s(u(o),"_MenuToggleType",k),z&&o.initialize(),o}return o(l,[{key:"initialize",value:function(){try{a(i(l.prototype),"initialize",this).call(this),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)}}},{key:"_handleClick",value:function(){var e=this;a(i(l.prototype),"_handleClick",this).call(this);var t=b("touchend",this.dom.menu)?"touchend":"mouseup";document.addEventListener(t,(function(t){"none"!==e.focusState&&(e.currentEvent="mouse",e.dom.menu.contains(t.target)||!e.dom.menu===t.target||(e.closeChildren(),e.blur(),e.elements.controller&&e.elements.controller.close()))}))}},{key:"_handleKeydown",value:function(){var e=this;a(i(l.prototype),"_handleKeydown",this).call(this),this.dom.menu.addEventListener("keydown",(function(t){e.currentEvent="keyboard";var n=E(t);if("Tab"===n&&("none"!==e.elements.rootMenu.focusState?(e.elements.rootMenu.blur(),e.elements.rootMenu.closeChildren()):e.elements.rootMenu.focus()),"Character"===n)C(t);else if(e.isTopLevel){if("self"===e.focusState){(["ArrowRight","ArrowLeft","Home","End"].includes(n)||e.currentMenuItem.isSubmenuItem&&["Space","Enter","ArrowDown","ArrowUp"].includes(n)||e.elements.controller&&["Escape"].includes(n))&&C(t)}}else{(["Escape","ArrowRight","ArrowLeft","ArrowDown","ArrowUp","Home","End"].includes(n)||e.currentMenuItem.isSubmenuItem&&["Space","Enter"].includes(n))&&C(t)}}))}},{key:"_handleKeyup",value:function(){var e=this;a(i(l.prototype),"_handleKeyup",this).call(this),this.dom.menu.addEventListener("keyup",(function(t){e.currentEvent="keyboard";var n=E(t),o=t.altKey,s=t.crtlKey,r=t.metaKey;if("Character"!==n||(o||s||r))if(e.isTopLevel){if("self"===e.focusState)if("Space"===n||"Enter"===n)e.currentMenuItem.isSubmenuItem?(C(t),e.currentMenuItem.elements.childMenu.currentEvent="keyboard",e.currentMenuItem.elements.toggle.open(),requestAnimationFrame((function(){e.currentMenuItem.elements.childMenu.focusFirstChild()}))):e.currentMenuItem.dom.link.click();else if("ArrowRight"===n){C(t);var i=e.currentMenuItem.isSubmenuItem&&e.currentMenuItem.elements.toggle.isOpen;e.focusNextChild(),i&&(e.currentMenuItem.isSubmenuItem?(e.currentMenuItem.elements.childMenu.currentEvent="keyboard",e.currentMenuItem.elements.toggle.preview()):e.closeChildren())}else if("ArrowLeft"===n){C(t);var l=e.currentMenuItem.isSubmenuItem&&e.currentMenuItem.elements.toggle.isOpen;e.focusPreviousChild(),l&&(e.currentMenuItem.isSubmenuItem?(e.currentMenuItem.elements.childMenu.currentEvent="keyboard",e.currentMenuItem.elements.toggle.preview()):e.closeChildren())}else if("ArrowDown"===n)e.currentMenuItem.isSubmenuItem&&(C(t),e.currentMenuItem.elements.childMenu.currentEvent="keyboard",e.currentMenuItem.elements.toggle.open(),requestAnimationFrame((function(){e.currentMenuItem.elements.childMenu.focusFirstChild()})));else if("ArrowUp"===n)e.currentMenuItem.isSubmenuItem&&(C(t),e.currentMenuItem.elements.childMenu.currentEvent="keyboard",e.currentMenuItem.elements.toggle.open(),requestAnimationFrame((function(){e.currentMenuItem.elements.childMenu.focusLastChild()})));else if("Home"===n)C(t),e.focusFirstChild();else if("End"===n)C(t),e.focusLastChild();else if("Escape"===n){e.elements.submenuToggles.some((function(e){return e.isOpen}))?(C(t),e.closeChildren()):e.isTopLevel&&e.elements.controller&&e.elements.controller.isOpen&&(C(t),e.elements.controller.close(),e.focusController())}}else"Space"===n||"Enter"===n?e.currentMenuItem.isSubmenuItem&&(C(t),e.currentMenuItem.elements.childMenu.currentEvent="keyboard",e.currentMenuItem.elements.toggle.open(),requestAnimationFrame((function(){e.currentMenuItem.elements.childMenu.focusFirstChild()}))):"Escape"===n?(C(t),e.elements.rootMenu.closeChildren(),e.elements.rootMenu.focusCurrentChild()):"ArrowRight"===n?e.currentMenuItem.isSubmenuItem?(C(t),e.currentMenuItem.elements.childMenu.currentEvent="keyboard",e.currentMenuItem.elements.toggle.open(),requestAnimationFrame((function(){e.currentMenuItem.elements.childMenu.focusFirstChild()}))):(C(t),e.elements.rootMenu.closeChildren(),e.elements.rootMenu.focusNextChild(),e.elements.rootMenu.currentMenuItem.isSubmenuItem&&e.elements.rootMenu.currentMenuItem.elements.toggle.preview()):"ArrowLeft"===n?e.elements.parentMenu.currentMenuItem.isSubmenuItem&&(C(t),e.elements.parentMenu.currentMenuItem.elements.toggle.close(),e.elements.parentMenu.focusCurrentChild(),e.elements.parentMenu===e.elements.rootMenu&&(e.elements.rootMenu.closeChildren(),e.elements.rootMenu.focusPreviousChild(),e.elements.rootMenu.currentMenuItem.isSubmenuItem&&(e.elements.rootMenu.currentMenuItem.elements.childMenu.currentEvent="keyboard",e.elements.rootMenu.currentMenuItem.elements.toggle.preview()))):"ArrowDown"===n?(C(t),e.focusNextChild()):"ArrowUp"===n?(C(t),e.focusPreviousChild()):"Home"===n?(C(t),e.focusFirstChild()):"End"===n&&(C(t),e.focusLastChild());else C(t),e.elements.rootMenu.currentEvent="character",e.focusNextChildWithCharacter(t.key)}))}},{key:"focusNextChild",value:function(){this.currentChild===this.elements.menuItems.length-1?this.focusFirstChild():this.focusChild(this.currentChild+1)}},{key:"focusPreviousChild",value:function(){0===this.currentChild?this.focusLastChild():this.focusChild(this.currentChild-1)}},{key:"focusNextChildWithCharacter",value:function(e){for(var t=e.toLowerCase(),n=this.currentChild+1,o=!1;!o&&n<this.elements.menuItems.length;){(this.elements.menuItems[n].dom.item.innerText?this.elements.menuItems[n].dom.item.innerText:this.elements.menuItems[n].dom.item.textContent).replace(/[\s]/g,"").toLowerCase().charAt(0)===t&&(o=!0,this.focusChild(n)),n++}}}]),l}();export{w as default};
function e(t){return e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},e(t)}function t(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function n(e,t){for(var n=0;n<t.length;n++){var o=t[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}function o(e,t,o){return t&&n(e.prototype,t),o&&n(e,o),e}function s(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function r(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&l(e,t)}function i(e){return i=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},i(e)}function l(e,t){return l=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},l(e,t)}function u(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function c(e,t){if(t&&("object"==typeof t||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return u(e)}function m(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,o=i(e);if(t){var s=i(this).constructor;n=Reflect.construct(o,arguments,s)}else n=o.apply(this,arguments);return c(this,n)}}function a(e,t,n){return a="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(e,t,n){var o=function(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&null!==(e=i(e)););return e}(e,t);if(o){var s=Object.getOwnPropertyDescriptor(o,t);return s.get?s.get.call(n):s.value}},a(e,t,n||e)}function h(e){return function(e){if(Array.isArray(e))return d(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,t){if(!e)return;if("string"==typeof e)return d(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return d(e,t)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function d(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,o=new Array(t);n<t;n++)o[n]=e[n];return o}function f(t,n){try{if("object"!==e(n)){var o=e(n);throw new TypeError("AccessibleMenu: Elements given to isValidInstance() must be inside of an object. ".concat(o," given."))}for(var s in n)if(!(n[s]instanceof t)){var r=e(n[s]);throw new TypeError("AccessibleMenu: ".concat(s," must be an instance of ").concat(t.name,". ").concat(r," given."))}return!0}catch(e){return console.error(e),!1}}function v(t,n){try{if("object"!==e(n)){var o=e(n);throw new TypeError("AccessibleMenu: Values given to isValidType() must be inside of an object. ".concat(o," given."))}for(var s in n){var r=e(n[s]);if(r!==t)throw new TypeError("AccessibleMenu: ".concat(s," must be a ").concat(t,". ").concat(r," given."))}return!0}catch(e){return console.error(e),!1}}function p(t){try{if("object"!==e(t)){var n=e(t);throw new TypeError("AccessibleMenu: Values given to isCSSSelector() must be inside of an object. ".concat(n," given."))}for(var o in t)try{if(null===t[o])throw new Error;document.querySelector(t[o])}catch(e){throw new TypeError("AccessibleMenu: ".concat(o,' must be a valid CSS selector. "').concat(t[o],'" given.'))}return!0}catch(e){return console.error(e),!1}}function g(t){try{if("object"!==e(t)||Array.isArray(t)){var n=e(t);throw new TypeError("AccessibleMenu: Values given to isValidClassList() must be inside of an object. ".concat(n," given."))}var o=function(n){var o=e(t[n]);if("string"!==o){if(!Array.isArray(t[n]))throw new TypeError("AccessibleMenu: ".concat(n," must be a string or an array of strings. ").concat(o," given."));t[n].forEach((function(e){if("string"!=typeof e)throw new TypeError("AccessibleMenu: ".concat(n," must be a string or an array of strings. An array containing non-strings given."))}))}else{var s={};s[n]=t[n],p(s)}};for(var s in t)o(s);return!0}catch(e){return console.error(e),!1}}function y(t){try{if("object"!==e(t)){var n=e(t);throw new TypeError("AccessibleMenu: Values given to isValidHoverType() must be inside of an object. ".concat(n," given."))}var o=["off","on","dynamic"];for(var s in t)if(!o.includes(t[s]))throw new TypeError("AccessibleMenu: ".concat(s," must be one of the following values: ").concat(o.join(", "),'. "').concat(t[s],'" given.'));return!0}catch(e){return console.error(e),!1}}var b=function(){function e(n){var o=n.menuToggleElement,r=n.parentElement,i=n.controlledMenu,l=n.parentMenu,u=void 0===l?null:l;t(this,e),s(this,"_dom",{toggle:null,parent:null}),s(this,"_elements",{controlledMenu:null,parentMenu:null}),s(this,"_open",!1),s(this,"_expandEvent",new CustomEvent("accessibleMenuExpand",{bubbles:!0,detail:{toggle:this}})),s(this,"_collapseEvent",new CustomEvent("accessibleMenuCollapse",{bubbles:!0,detail:{toggle:this}})),this._dom.toggle=o,this._dom.parent=r,this._elements.controlledMenu=i,this._elements.parentMenu=u}return o(e,[{key:"initialize",value:function(){if(this.dom.toggle.setAttribute("aria-haspopup","true"),this.dom.toggle.setAttribute("aria-expanded","false"),function(e,t){if(v("string",{tagName:e})&&f(HTMLElement,t)){var n=e.toLowerCase(),o=!0;for(var s in t)t[s].tagName.toLowerCase()!==n&&(o=!1);return o}return!1}("button",{toggle:this.dom.toggle})||this.dom.toggle.setAttribute("role","button"),""===this.dom.toggle.id||""===this.elements.controlledMenu.dom.menu.id){var e=Math.random().toString(36).replace(/[^a-z]+/g,"").substr(0,10),t=this.dom.toggle.innerText.replace(/[^a-zA-Z0-9\s]/g,""),n=e;!t.replace(/\s/g,"").length&&this.dom.toggle.getAttribute("aria-label")&&(t=this.dom.toggle.getAttribute("aria-label").replace(/[^a-zA-Z0-9\s]/g,"")),t.replace(/\s/g,"").length>0&&((t=t.toLowerCase().replace(/\s+/g,"-")).startsWith("-")&&(t=t.substring(1)),t.endsWith("-")&&(t=t.slice(0,-1)),n="".concat(t,"-").concat(n)),this.dom.toggle.id=this.dom.toggle.id||"".concat(n,"-menu-button"),this.elements.controlledMenu.dom.menu.id=this.elements.controlledMenu.dom.menu.id||"".concat(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)}},{key:"dom",get:function(){return this._dom}},{key:"elements",get:function(){return this._elements}},{key:"isOpen",get:function(){return this._open},set:function(e){v("boolean",{value:e}),this._open=e}},{key:"_expand",value:function(){var e,t,n=!(arguments.length>0&&void 0!==arguments[0])||arguments[0],o=this.elements.controlledMenu,s=o.closeClass,r=o.openClass;(this.dom.toggle.setAttribute("aria-expanded","true"),""!==r)&&("string"==typeof r?this.elements.controlledMenu.dom.menu.classList.add(r):(e=this.elements.controlledMenu.dom.menu.classList).add.apply(e,h(r)));""!==s&&("string"==typeof s?this.elements.controlledMenu.dom.menu.classList.remove(s):(t=this.elements.controlledMenu.dom.menu.classList).remove.apply(t,h(s)));n&&this.dom.toggle.dispatchEvent(this._expandEvent)}},{key:"_collapse",value:function(){var e,t,n=!(arguments.length>0&&void 0!==arguments[0])||arguments[0],o=this.elements.controlledMenu,s=o.closeClass,r=o.openClass;(this.dom.toggle.setAttribute("aria-expanded","false"),""!==s)&&("string"==typeof s?this.elements.controlledMenu.dom.menu.classList.add(s):(e=this.elements.controlledMenu.dom.menu.classList).add.apply(e,h(s)));""!==r&&("string"==typeof r?this.elements.controlledMenu.dom.menu.classList.remove(r):(t=this.elements.controlledMenu.dom.menu.classList).remove.apply(t,h(r)));n&&this.dom.toggle.dispatchEvent(this._collapseEvent)}},{key:"open",value:function(){this.elements.controlledMenu.focusState="self",this._expand(),this.isOpen=!0}},{key:"preview",value:function(){this.elements.parentMenu&&(this.elements.parentMenu.focusState="self"),this._expand(),this.isOpen=!0}},{key:"close",value:function(){this.isOpen&&(this.elements.controlledMenu.currentChild=0,this.elements.controlledMenu.blur(),this.elements.parentMenu&&(this.elements.parentMenu.focusState="self"),this._collapse(),this.isOpen=!1)}},{key:"toggle",value:function(){this.isOpen?this.close():this.open()}},{key:"closeSiblings",value:function(){var e=this;this.elements.parentMenu&&this.elements.parentMenu.elements.submenuToggles.forEach((function(t){t!==e&&t.close()}))}},{key:"closeChildren",value:function(){this.elements.controlledMenu.elements.submenuToggles.forEach((function(e){return e.close()}))}}]),e}(),M=function(){function e(n){var o=n.menuItemElement,r=n.menuLinkElement,i=n.parentMenu,l=n.isSubmenuItem,u=void 0!==l&&l,c=n.childMenu,m=void 0===c?null:c,a=n.toggle,h=void 0===a?null:a;t(this,e),s(this,"_dom",{item:null,link:null}),s(this,"_elements",{parentMenu:null,childMenu:null,toggle:null}),s(this,"_submenu",!1),this._dom.item=o,this._dom.link=r,this._elements.parentMenu=i,this._elements.childMenu=m,this._elements.toggle=h,this._submenu=u}return o(e,[{key:"initialize",value:function(){}},{key:"dom",get:function(){return this._dom}},{key:"elements",get:function(){return this._elements}},{key:"isSubmenuItem",get:function(){return this._submenu}},{key:"focus",value:function(){this.elements.parentMenu.shouldFocus&&this.dom.link.focus()}},{key:"blur",value:function(){this.elements.parentMenu.shouldFocus&&this.dom.link.blur()}}]),e}();function _(e){try{var t=e.key||e.keyCode,n={Enter:"Enter"===t||13===t,Space:" "===t||"Spacebar"===t||32===t,Escape:"Escape"===t||"Esc"===t||27===t,ArrowUp:"ArrowUp"===t||"Up"===t||38===t,ArrowRight:"ArrowRight"===t||"Right"===t||39===t,ArrowDown:"ArrowDown"===t||"Down"===t||40===t,ArrowLeft:"ArrowLeft"===t||"Left"===t||37===t,Home:"Home"===t||36===t,End:"End"===t||35===t,Character:isNaN(t)&&!!t.match(/^[a-zA-Z]{1}$/),Tab:"Tab"===t||9===t,Asterisk:"*"===t||56===t};return Object.keys(n).find((function(e){return!0===n[e]}))||""}catch(e){return""}}function E(e){e.preventDefault(),e.stopPropagation()}var C=function(){function n(e){var o=e.menuElement,r=e.menuItemSelector,i=void 0===r?"li":r,l=e.menuLinkSelector,u=void 0===l?"a":l,c=e.submenuItemSelector,m=void 0===c?"":c,a=e.submenuToggleSelector,h=void 0===a?"a":a,d=e.submenuSelector,f=void 0===d?"ul":d,v=e.controllerElement,p=void 0===v?null:v,g=e.containerElement,y=void 0===g?null:g,_=e.openClass,E=void 0===_?"show":_,C=e.closeClass,I=void 0===C?"hide":C,T=e.isTopLevel,k=void 0===T||T,w=e.parentMenu,S=void 0===w?null:w,A=e.hoverType,L=void 0===A?"off":A,O=e.hoverDelay,D=void 0===O?250:O;t(this,n),s(this,"_MenuType",n),s(this,"_MenuItemType",M),s(this,"_MenuToggleType",b),s(this,"_dom",{menu:null,menuItems:[],submenuItems:[],submenuToggles:[],submenus:[],controller:null,container:null}),s(this,"_selectors",{menuItems:"",menuLinks:"",submenuItems:"",submenuToggles:"",submenus:""}),s(this,"_elements",{menuItems:[],submenuToggles:[],controller:null,parentMenu:null,rootMenu:null}),s(this,"_openClass","show"),s(this,"_closeClass","hide"),s(this,"_root",!0),s(this,"_currentChild",0),s(this,"_focusState","none"),s(this,"_currentEvent","none"),s(this,"_hoverType","off"),s(this,"_hoverDelay",250),this._dom.menu=o,this._dom.controller=p,this._dom.container=y,this._selectors.menuItems=i,this._selectors.menuLinks=u,this._selectors.submenuItems=m,this._selectors.submenuToggles=h,this._selectors.submenus=f,this._elements.menuItems=[],this._elements.submenuToggles=[],this._elements.controller=null,this._elements.parentMenu=S,this._elements.rootMenu=k?this:null,this._openClass=E||"",this._closeClass=I||"",this._root=k,this._hoverType=L,this._hoverDelay=D}return o(n,[{key:"initialize",value:function(){if(!this._validate())throw new Error("AccesibleMenu: cannot initialize menu. See other error messages for more information.");if(null===this.elements.rootMenu&&this._findRootMenu(this),this._setDOMElements(),this.isTopLevel&&this.dom.controller&&this.dom.container){var e=new this._MenuToggleType({menuToggleElement:this.dom.controller,parentElement:this.dom.container,controlledMenu:this});this._elements.controller=e}this._createChildElements()}},{key:"dom",get:function(){return this._dom}},{key:"selectors",get:function(){return this._selectors}},{key:"elements",get:function(){return this._elements}},{key:"isTopLevel",get:function(){return this._root}},{key:"openClass",get:function(){return this.isTopLevel?this._openClass:this.elements.rootMenu.openClass},set:function(e){g({openClass:e}),this._openClass!==e&&(this._openClass=e)}},{key:"closeClass",get:function(){return this.isTopLevel?this._closeClass:this.elements.rootMenu.closeClass},set:function(e){g({closeClass:e}),this._closeClass!==e&&(this._closeClass=e)}},{key:"currentChild",get:function(){return this._currentChild},set:function(e){function t(e){if(["mouse","character"].includes(e.currentEvent)&&e.elements.parentMenu)for(var t=0,n=!1;!n&&t<e.elements.parentMenu.elements.menuItems.length;){var o=e.elements.parentMenu.elements.menuItems[t];o.isSubmenuItem&&o.elements.toggle.elements.controlledMenu===e&&(n=!0,e.elements.parentMenu.currentEvent=e.currentEvent,e.elements.parentMenu.currentChild=t),t++}}v("number",{value:e}),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))}},{key:"focusState",get:function(){return this._focusState},set:function(t){!function(t){try{if("object"!==e(t)){var n=e(t);throw new TypeError("AccessibleMenu: Values given to isValidState() must be inside of an object. ".concat(n," given."))}var o=["none","self","child"];for(var s in t)if(!o.includes(t[s]))throw new TypeError("AccessibleMenu: ".concat(s," must be one of the following values: ").concat(o.join(", "),'. "').concat(t[s],'" given.'))}catch(e){return console.error(e),!1}}({value:t}),this._focusState!==t&&(this._focusState=t),this.elements.submenuToggles.length>0&&("self"===t||"none"===t)&&this.elements.submenuToggles.forEach((function(e){e.elements.controlledMenu.focusState="none"})),!this.elements.parentMenu||"self"!==t&&"child"!==t||(this.elements.parentMenu.focusState="child")}},{key:"currentEvent",get:function(){return this._currentEvent},set:function(t){!function(t){try{if("object"!==e(t)){var n=e(t);throw new TypeError("AccessibleMenu: Values given to isValidEvent() must be inside of an object. ".concat(n," given."))}var o=["none","mouse","keyboard","character"];for(var s in t)if(!o.includes(t[s]))throw new TypeError("AccessibleMenu: ".concat(s," must be one of the following values: ").concat(o.join(", "),'. "').concat(t[s],'" given.'))}catch(e){return console.error(e),!1}}({value:t}),this._currentEvent!==t&&(this._currentEvent=t,this.elements.submenuToggles.length>0&&this.elements.submenuToggles.forEach((function(e){e.elements.controlledMenu.currentEvent=t})))}},{key:"currentMenuItem",get:function(){return this.elements.menuItems[this.currentChild]}},{key:"hoverType",get:function(){return this._root?this._hoverType:this.elements.rootMenu.hoverType},set:function(e){y({value:e}),this._hoverType!==e&&(this._hoverType=e)}},{key:"hoverDelay",get:function(){return this._root?this._hoverDelay:this.elements.rootMenu.hoverDelay},set:function(e){v("number",{value:e}),this._hoverDelay!==e&&(this._hoverDelay=e)}},{key:"shouldFocus",get:function(){var e=!1;return"keyboard"!==this.currentEvent&&"character"!==this.currentEvent||(e=!0),"mouse"===this.currentEvent&&"dynamic"===this.hoverType&&(e=!0),e}},{key:"_validate",value:function(){var e=!0;return null!==this._dom.container||null!==this._dom.controller?f(HTMLElement,{menuElement:this._dom.menu,controllerElement:this._dom.controller,containerElement:this._dom.container})||(e=!1):f(HTMLElement,{menuElement:this._dom.menu})||(e=!1),""!==this._selectors.submenuItems?p({menuItemSelector:this._selectors.menuItems,menuLinkSelector:this._selectors.menuLinks,submenuItemSelector:this._selectors.submenuItems,submenuToggleSelector:this._selectors.submenuToggles,submenuSelector:this._selectors.submenus})||(e=!1):p({menuItemSelector:this._selectors.menuItems,menuLinkSelector:this._selectors.menuLinks})||(e=!1),""===this._openClass||g({openClass:this._openClass})||(e=!1),""===this._closeClass||g({closeClass:this._closeClass})||(e=!1),v("boolean",{isTopLevel:this._root})||(e=!1),null===this._elements.parentMenu||f(n,{parentMenu:this._elements.parentMenu})||(e=!1),y({hoverType:this._hoverType})||(e=!1),v("number",{hoverDelay:this._hoverDelay})||(e=!1),e}},{key:"_setDOMElementType",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.dom.menu,n=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];if("string"!=typeof this.selectors[e])throw new Error('AccessibleMenu: "'.concat(e,'" is not a valid element type within the menu.'));if(!Array.isArray(this.dom[e]))throw new Error('AccessibleMenu: The "'.concat(e,'" element cannot be set through _setDOMElementType.'));t!==this.dom.menu&&f(HTMLElement,{base:t});var o=Array.from(t.querySelectorAll(this.selectors[e])),s=o.filter((function(e){return e.parentElement===t}));this._dom[e]=n?s:[].concat(h(this._dom[e]),h(s))}},{key:"_resetDOMElementType",value:function(e){if(void 0===this.dom[e])throw new Error('AccessibleMenu: "'.concat(e,'" is not a valid element type within the menu.'));if(!Array.isArray(this.dom[e]))throw new Error('AccessibleMenu: The "'.concat(e,'" element cannot be reset through _resetDOMElementType.'));this._dom[e]=[]}},{key:"_setDOMElements",value:function(){var e=this;this._setDOMElementType("menuItems"),""!==this.selectors.submenuItems&&(this._setDOMElementType("submenuItems"),this._resetDOMElementType("submenuToggles"),this._resetDOMElementType("submenus"),this.dom.submenuItems.forEach((function(t){e._setDOMElementType("submenuToggles",t,!1),e._setDOMElementType("submenus",t,!1)})))}},{key:"_findRootMenu",value:function(e){if(e.isTopLevel)this._elements.rootMenu=e;else{if(null===e.elements.parentMenu)throw new Error("Cannot find root menu.");this._findRootMenu(e.elements.parentMenu)}}},{key:"_createChildElements",value:function(){var e=this;this.dom.menuItems.forEach((function(t){var n;if(e.dom.submenuItems.includes(t)){var o=t.querySelector(e.selectors.submenuToggles),s=t.querySelector(e.selectors.submenus),r=new e._MenuType({menuElement:s,menuItemSelector:e.selectors.menuItems,menuLinkSelector:e.selectors.menuLinks,submenuItemSelector:e.selectors.submenuItems,submenuToggleSelector:e.selectors.submenuToggles,submenuSelector:e.selectors.submenus,openClass:e.openClass,closeClass:e.closeClass,isTopLevel:!1,parentMenu:e,hoverType:e.hoverType,hoverDelay:e.hoverDelay}),i=new e._MenuToggleType({menuToggleElement:o,parentElement:t,controlledMenu:r,parentMenu:e});e._elements.submenuToggles.push(i),n=new e._MenuItemType({menuItemElement:t,menuLinkElement:o,parentMenu:e,isSubmenuItem:!0,childMenu:r,toggle:i})}else{var l=t.querySelector(e.selectors.menuLinks);n=new e._MenuItemType({menuItemElement:t,menuLinkElement:l,parentMenu:e})}e._elements.menuItems.push(n)}))}},{key:"_handleFocus",value:function(){var e=this;this.elements.menuItems.forEach((function(t,n){t.dom.link.addEventListener("focus",(function(){e.focusState="self",e.currentChild=n}))}))}},{key:"_handleClick",value:function(){var e=this;function t(e,t,n){E(n),t.toggle(),t.isOpen&&(e.focusState="self",t.elements.controlledMenu.focusState="none")}this.elements.menuItems.forEach((function(n,o){n.dom.link.addEventListener("pointerdown",(function(){e.currentEvent="mouse",e.elements.rootMenu.blurChildren(),e.focusChild(o)}),{passive:!0}),n.isSubmenuItem&&n.elements.toggle.dom.toggle.addEventListener("pointerup",(function(o){e.currentEvent="mouse",t(e,n.elements.toggle,o)}))})),this.isTopLevel&&this.elements.controller&&this.elements.controller.dom.toggle.addEventListener("pointerup",(function(n){e.currentEvent="mouse",t(e,e.elements.controller,n)}))}},{key:"_handleHover",value:function(){var e=this;this.elements.menuItems.forEach((function(t,n){t.dom.link.addEventListener("mouseenter",(function(){if("on"===e.hoverType)e.currentEvent="mouse",e.currentChild=n,t.isSubmenuItem&&t.elements.toggle.preview();else if("dynamic"===e.hoverType){var o=e.elements.submenuToggles.some((function(e){return e.isOpen}));e.currentChild=n,e.isTopLevel&&"none"===e.focusState||(e.currentEvent="mouse",e.focusCurrentChild()),!t.isSubmenuItem||e.isTopLevel&&!o||(e.currentEvent="mouse",t.elements.toggle.preview())}})),t.isSubmenuItem&&t.dom.item.addEventListener("mouseleave",(function(){"on"===e.hoverType?e.hoverDelay>0?setTimeout((function(){e.currentEvent="mouse",t.elements.toggle.close()}),e.hoverDelay):(e.currentEvent="mouse",t.elements.toggle.close()):"dynamic"===e.hoverType&&(e.isTopLevel||(e.hoverDelay>0?setTimeout((function(){e.currentEvent="mouse",t.elements.toggle.close(),e.focusCurrentChild()}),e.hoverDelay):(e.currentEvent="mouse",t.elements.toggle.close(),e.focusCurrentChild())))}))}))}},{key:"_handleKeydown",value:function(){var e=this;this.isTopLevel&&this.elements.controller&&this.elements.controller.dom.toggle.addEventListener("keydown",(function(t){e.currentEvent="keyboard";var n=_(t);"Space"!==n&&"Enter"!==n||E(t)}))}},{key:"_handleKeyup",value:function(){var e=this;this.isTopLevel&&this.elements.controller&&this.elements.controller.dom.toggle.addEventListener("keyup",(function(t){e.currentEvent="keyboard";var n=_(t);"Space"!==n&&"Enter"!==n||(E(t),e.elements.controller.open(),e.focusFirstChild())}))}},{key:"focus",value:function(){this.focusState="self",this.shouldFocus&&this.dom.menu.focus()}},{key:"blur",value:function(){this.focusState="none",this.shouldFocus&&this.dom.menu.blur()}},{key:"focusCurrentChild",value:function(){this.focusState="self",-1!==this.currentChild&&this.currentMenuItem.focus()}},{key:"focusChild",value:function(e){this.blurCurrentChild(),this.currentChild=e,this.focusCurrentChild()}},{key:"focusFirstChild",value:function(){this.focusChild(0)}},{key:"focusLastChild",value:function(){this.focusChild(this.elements.menuItems.length-1)}},{key:"focusNextChild",value:function(){this.currentChild<this.elements.menuItems.length-1?this.focusChild(this.currentChild+1):this.focusCurrentChild()}},{key:"focusPreviousChild",value:function(){this.currentChild>0?this.focusChild(this.currentChild-1):this.focusCurrentChild()}},{key:"blurCurrentChild",value:function(){this.focusState="none",-1!==this.currentChild&&this.currentMenuItem.blur()}},{key:"focusController",value:function(){this.dom.controller&&(this.shouldFocus&&this.dom.controller.focus(),this.focusState="none")}},{key:"focusContainer",value:function(){this.dom.container&&(this.shouldFocus&&this.dom.container.focus(),this.focusState="none")}},{key:"closeChildren",value:function(){this.elements.submenuToggles.forEach((function(e){return e.close()}))}},{key:"blurChildren",value:function(){this.elements.menuItems.forEach((function(e){e.blur(),e.isSubmenuItem&&e.elements.childMenu.blurChildren()}))}}]),n}(),I=function(e){r(s,M);var n=m(s);function s(e){var o,r=e.menuItemElement,i=e.menuLinkElement,l=e.parentMenu,u=e.isSubmenuItem,c=void 0!==u&&u,m=e.childMenu,a=void 0===m?null:m,h=e.toggle,d=void 0===h?null:h,f=e.initialize,v=void 0===f||f;return t(this,s),o=n.call(this,{menuItemElement:r,menuLinkElement:i,parentMenu:l,isSubmenuItem:c,childMenu:a,toggle:d}),v&&o.initialize(),o}return o(s,[{key:"initialize",value:function(){a(i(s.prototype),"initialize",this).call(this),this.dom.item.setAttribute("role","none"),this.dom.link.setAttribute("role","menuitem"),this.dom.link.tabIndex=-1}},{key:"focus",value:function(){a(i(s.prototype),"focus",this).call(this),this.elements.parentMenu.isTopLevel&&(this.dom.link.tabIndex=0)}},{key:"blur",value:function(){a(i(s.prototype),"blur",this).call(this),this.elements.parentMenu.isTopLevel&&(this.dom.link.tabIndex=-1)}}]),s}(),T=function(e){r(s,b);var n=m(s);function s(e){var o,r=e.menuToggleElement,i=e.parentElement,l=e.controlledMenu,u=e.parentMenu,c=void 0===u?null:u,m=e.initialize,a=void 0===m||m;return t(this,s),o=n.call(this,{menuToggleElement:r,parentElement:i,controlledMenu:l,parentMenu:c}),a&&o.initialize(),o}return o(s,[{key:"open",value:function(){this.closeSiblings(),a(i(s.prototype),"open",this).call(this)}},{key:"preview",value:function(){this.closeSiblings(),a(i(s.prototype),"preview",this).call(this)}},{key:"close",value:function(){this.isOpen&&this.closeChildren(),a(i(s.prototype),"close",this).call(this)}}]),s}(),k=function(e){r(l,C);var n=m(l);function l(e){var o,r=e.menuElement,i=e.menuItemSelector,c=void 0===i?"li":i,m=e.menuLinkSelector,a=void 0===m?"a":m,h=e.submenuItemSelector,d=void 0===h?"":h,f=e.submenuToggleSelector,v=void 0===f?"a":f,p=e.submenuSelector,g=void 0===p?"ul":p,y=e.controllerElement,b=void 0===y?null:y,M=e.containerElement,_=void 0===M?null:M,E=e.openClass,C=void 0===E?"show":E,k=e.closeClass,w=void 0===k?"hide":k,S=e.isTopLevel,A=void 0===S||S,L=e.parentMenu,O=void 0===L?null:L,D=e.hoverType,j=void 0===D?"off":D,x=e.hoverDelay,F=void 0===x?250:x,R=e.initialize,z=void 0===R||R;return t(this,l),s(u(o=n.call(this,{menuElement:r,menuItemSelector:c,menuLinkSelector:a,submenuItemSelector:d,submenuToggleSelector:v,submenuSelector:g,controllerElement:b,containerElement:_,openClass:C,closeClass:w,isTopLevel:A,parentMenu:O,hoverType:j,hoverDelay:F})),"_MenuType",l),s(u(o),"_MenuItemType",I),s(u(o),"_MenuToggleType",T),z&&o.initialize(),o}return o(l,[{key:"initialize",value:function(){try{a(i(l.prototype),"initialize",this).call(this),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)}}},{key:"_handleClick",value:function(){var e=this;a(i(l.prototype),"_handleClick",this).call(this),document.addEventListener("pointerup",(function(t){"none"!==e.focusState&&(e.currentEvent="mouse",e.dom.menu.contains(t.target)||!e.dom.menu===t.target||(e.closeChildren(),e.blur(),e.elements.controller&&e.elements.controller.close()))}))}},{key:"_handleKeydown",value:function(){var e=this;a(i(l.prototype),"_handleKeydown",this).call(this),this.dom.menu.addEventListener("keydown",(function(t){e.currentEvent="keyboard";var n=_(t);if("Tab"===n&&("none"!==e.elements.rootMenu.focusState?(e.elements.rootMenu.blur(),e.elements.rootMenu.closeChildren()):e.elements.rootMenu.focus()),"Character"===n)E(t);else if(e.isTopLevel){if("self"===e.focusState){(["ArrowRight","ArrowLeft","Home","End"].includes(n)||e.currentMenuItem.isSubmenuItem&&["Space","Enter","ArrowDown","ArrowUp"].includes(n)||e.elements.controller&&["Escape"].includes(n))&&E(t)}}else{(["Escape","ArrowRight","ArrowLeft","ArrowDown","ArrowUp","Home","End"].includes(n)||e.currentMenuItem.isSubmenuItem&&["Space","Enter"].includes(n))&&E(t)}}))}},{key:"_handleKeyup",value:function(){var e=this;a(i(l.prototype),"_handleKeyup",this).call(this),this.dom.menu.addEventListener("keyup",(function(t){e.currentEvent="keyboard";var n=_(t),o=t.altKey,s=t.crtlKey,r=t.metaKey;if("Character"!==n||(o||s||r))if(e.isTopLevel){if("self"===e.focusState)if("Space"===n||"Enter"===n)e.currentMenuItem.isSubmenuItem?(E(t),e.currentMenuItem.elements.childMenu.currentEvent="keyboard",e.currentMenuItem.elements.toggle.open(),requestAnimationFrame((function(){e.currentMenuItem.elements.childMenu.focusFirstChild()}))):e.currentMenuItem.dom.link.click();else if("ArrowRight"===n){E(t);var i=e.currentMenuItem.isSubmenuItem&&e.currentMenuItem.elements.toggle.isOpen;e.focusNextChild(),i&&(e.currentMenuItem.isSubmenuItem?(e.currentMenuItem.elements.childMenu.currentEvent="keyboard",e.currentMenuItem.elements.toggle.preview()):e.closeChildren())}else if("ArrowLeft"===n){E(t);var l=e.currentMenuItem.isSubmenuItem&&e.currentMenuItem.elements.toggle.isOpen;e.focusPreviousChild(),l&&(e.currentMenuItem.isSubmenuItem?(e.currentMenuItem.elements.childMenu.currentEvent="keyboard",e.currentMenuItem.elements.toggle.preview()):e.closeChildren())}else if("ArrowDown"===n)e.currentMenuItem.isSubmenuItem&&(E(t),e.currentMenuItem.elements.childMenu.currentEvent="keyboard",e.currentMenuItem.elements.toggle.open(),requestAnimationFrame((function(){e.currentMenuItem.elements.childMenu.focusFirstChild()})));else if("ArrowUp"===n)e.currentMenuItem.isSubmenuItem&&(E(t),e.currentMenuItem.elements.childMenu.currentEvent="keyboard",e.currentMenuItem.elements.toggle.open(),requestAnimationFrame((function(){e.currentMenuItem.elements.childMenu.focusLastChild()})));else if("Home"===n)E(t),e.focusFirstChild();else if("End"===n)E(t),e.focusLastChild();else if("Escape"===n){e.elements.submenuToggles.some((function(e){return e.isOpen}))?(E(t),e.closeChildren()):e.isTopLevel&&e.elements.controller&&e.elements.controller.isOpen&&(E(t),e.elements.controller.close(),e.focusController())}}else"Space"===n||"Enter"===n?e.currentMenuItem.isSubmenuItem&&(E(t),e.currentMenuItem.elements.childMenu.currentEvent="keyboard",e.currentMenuItem.elements.toggle.open(),requestAnimationFrame((function(){e.currentMenuItem.elements.childMenu.focusFirstChild()}))):"Escape"===n?(E(t),e.elements.rootMenu.closeChildren(),e.elements.rootMenu.focusCurrentChild()):"ArrowRight"===n?e.currentMenuItem.isSubmenuItem?(E(t),e.currentMenuItem.elements.childMenu.currentEvent="keyboard",e.currentMenuItem.elements.toggle.open(),requestAnimationFrame((function(){e.currentMenuItem.elements.childMenu.focusFirstChild()}))):(E(t),e.elements.rootMenu.closeChildren(),e.elements.rootMenu.focusNextChild(),e.elements.rootMenu.currentMenuItem.isSubmenuItem&&e.elements.rootMenu.currentMenuItem.elements.toggle.preview()):"ArrowLeft"===n?e.elements.parentMenu.currentMenuItem.isSubmenuItem&&(E(t),e.elements.parentMenu.currentMenuItem.elements.toggle.close(),e.elements.parentMenu.focusCurrentChild(),e.elements.parentMenu===e.elements.rootMenu&&(e.elements.rootMenu.closeChildren(),e.elements.rootMenu.focusPreviousChild(),e.elements.rootMenu.currentMenuItem.isSubmenuItem&&(e.elements.rootMenu.currentMenuItem.elements.childMenu.currentEvent="keyboard",e.elements.rootMenu.currentMenuItem.elements.toggle.preview()))):"ArrowDown"===n?(E(t),e.focusNextChild()):"ArrowUp"===n?(E(t),e.focusPreviousChild()):"Home"===n?(E(t),e.focusFirstChild()):"End"===n&&(E(t),e.focusLastChild());else E(t),e.elements.rootMenu.currentEvent="character",e.focusNextChildWithCharacter(t.key)}))}},{key:"focusNextChild",value:function(){this.currentChild===this.elements.menuItems.length-1?this.focusFirstChild():this.focusChild(this.currentChild+1)}},{key:"focusPreviousChild",value:function(){0===this.currentChild?this.focusLastChild():this.focusChild(this.currentChild-1)}},{key:"focusNextChildWithCharacter",value:function(e){for(var t=e.toLowerCase(),n=this.currentChild+1,o=!1;!o&&n<this.elements.menuItems.length;){(this.elements.menuItems[n].dom.item.innerText?this.elements.menuItems[n].dom.item.innerText:this.elements.menuItems[n].dom.item.textContent).replace(/[\s]/g,"").toLowerCase().charAt(0)===t&&(o=!0,this.focusChild(n)),n++}}}]),l}();export{k as default};
//# sourceMappingURL=menubar.esm.min.js.map

@@ -1,2 +0,2 @@

var Menubar=function(){"use strict";function e(t){return(e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(t)}function t(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function n(e,t){for(var n=0;n<t.length;n++){var o=t[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}function o(e,t,o){return t&&n(e.prototype,t),o&&n(e,o),e}function s(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function r(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&l(e,t)}function i(e){return(i=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function l(e,t){return(l=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function u(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function c(e,t){return!t||"object"!=typeof t&&"function"!=typeof t?u(e):t}function m(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,o=i(e);if(t){var s=i(this).constructor;n=Reflect.construct(o,arguments,s)}else n=o.apply(this,arguments);return c(this,n)}}function a(e,t,n){return(a="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(e,t,n){var o=function(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&null!==(e=i(e)););return e}(e,t);if(o){var s=Object.getOwnPropertyDescriptor(o,t);return s.get?s.get.call(n):s.value}})(e,t,n||e)}function h(e){return function(e){if(Array.isArray(e))return d(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,t){if(!e)return;if("string"==typeof e)return d(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return d(e,t)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function d(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,o=new Array(t);n<t;n++)o[n]=e[n];return o}function f(t,n){try{if("object"!==e(n)){var o=e(n);throw new TypeError("AccessibleMenu: Elements given to isValidInstance() must be inside of an object. ".concat(o," given."))}for(var s in n)if(!(n[s]instanceof t)){var r=e(n[s]);throw new TypeError("AccessibleMenu: ".concat(s," must be an instance of ").concat(t.name,". ").concat(r," given."))}return!0}catch(e){return console.error(e),!1}}function v(t,n){try{if("object"!==e(n)){var o=e(n);throw new TypeError("AccessibleMenu: Values given to isValidType() must be inside of an object. ".concat(o," given."))}for(var s in n){var r=e(n[s]);if(r!==t)throw new TypeError("AccessibleMenu: ".concat(s," must be a ").concat(t,". ").concat(r," given."))}return!0}catch(e){return console.error(e),!1}}function p(t){try{if("object"!==e(t)){var n=e(t);throw new TypeError("AccessibleMenu: Values given to isCSSSelector() must be inside of an object. ".concat(n," given."))}for(var o in t)try{if(null===t[o])throw new Error;document.querySelector(t[o])}catch(e){throw new TypeError("AccessibleMenu: ".concat(o,' must be a valid CSS selector. "').concat(t[o],'" given.'))}return!0}catch(e){return console.error(e),!1}}function g(t){try{if("object"!==e(t)||Array.isArray(t)){var n=e(t);throw new TypeError("AccessibleMenu: Values given to isValidClassList() must be inside of an object. ".concat(n," given."))}var o=function(n){var o=e(t[n]);if("string"!==o){if(!Array.isArray(t[n]))throw new TypeError("AccessibleMenu: ".concat(n," must be a string or an array of strings. ").concat(o," given."));t[n].forEach((function(e){if("string"!=typeof e)throw new TypeError("AccessibleMenu: ".concat(n," must be a string or an array of strings. An array containing non-strings given."))}))}else{var s={};s[n]=t[n],p(s)}};for(var s in t)o(s);return!0}catch(e){return console.error(e),!1}}function y(t){try{if("object"!==e(t)){var n=e(t);throw new TypeError("AccessibleMenu: Values given to isValidHoverType() must be inside of an object. ".concat(n," given."))}var o=["off","on","dynamic"];for(var s in t)if(!o.includes(t[s]))throw new TypeError("AccessibleMenu: ".concat(s," must be one of the following values: ").concat(o.join(", "),'. "').concat(t[s],'" given.'));return!0}catch(e){return console.error(e),!1}}function b(e,t){return!(!v("string",{event:e})||!f(HTMLElement,{element:t}))&&void 0!==t["on".concat(e)]}var M=function(){function e(n){var o=n.menuToggleElement,r=n.parentElement,i=n.controlledMenu,l=n.parentMenu,u=void 0===l?null:l;t(this,e),s(this,"_dom",{toggle:null,parent:null}),s(this,"_elements",{controlledMenu:null,parentMenu:null}),s(this,"_open",!1),s(this,"_expandEvent",new CustomEvent("accessibleMenuExpand",{bubbles:!0,detail:{toggle:this}})),s(this,"_collapseEvent",new CustomEvent("accessibleMenuCollapse",{bubbles:!0,detail:{toggle:this}})),this._dom.toggle=o,this._dom.parent=r,this._elements.controlledMenu=i,this._elements.parentMenu=u}return o(e,[{key:"initialize",value:function(){if(this.dom.toggle.setAttribute("aria-haspopup","true"),this.dom.toggle.setAttribute("aria-expanded","false"),function(e,t){if(v("string",{tagName:e})&&f(HTMLElement,t)){var n=e.toLowerCase(),o=!0;for(var s in t)t[s].tagName.toLowerCase()!==n&&(o=!1);return o}return!1}("button",{toggle:this.dom.toggle})||this.dom.toggle.setAttribute("role","button"),""===this.dom.toggle.id||""===this.elements.controlledMenu.dom.menu.id){var e=Math.random().toString(36).replace(/[^a-z]+/g,"").substr(0,10),t=this.dom.toggle.innerText.replace(/[^a-zA-Z0-9\s]/g,""),n=e;!t.replace(/\s/g,"").length&&this.dom.toggle.getAttribute("aria-label")&&(t=this.dom.toggle.getAttribute("aria-label").replace(/[^a-zA-Z0-9\s]/g,"")),t.replace(/\s/g,"").length>0&&((t=t.toLowerCase().replace(/\s+/g,"-")).startsWith("-")&&(t=t.substring(1)),t.endsWith("-")&&(t=t.slice(0,-1)),n="".concat(t,"-").concat(n)),this.dom.toggle.id=this.dom.toggle.id||"".concat(n,"-menu-button"),this.elements.controlledMenu.dom.menu.id=this.elements.controlledMenu.dom.menu.id||"".concat(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)}},{key:"dom",get:function(){return this._dom}},{key:"elements",get:function(){return this._elements}},{key:"isOpen",get:function(){return this._open},set:function(e){v("boolean",{value:e}),this._open=e}},{key:"_expand",value:function(){var e,t,n=!(arguments.length>0&&void 0!==arguments[0])||arguments[0],o=this.elements.controlledMenu,s=o.closeClass,r=o.openClass;(this.dom.toggle.setAttribute("aria-expanded","true"),""!==r)&&("string"==typeof r?this.elements.controlledMenu.dom.menu.classList.add(r):(e=this.elements.controlledMenu.dom.menu.classList).add.apply(e,h(r)));""!==s&&("string"==typeof s?this.elements.controlledMenu.dom.menu.classList.remove(s):(t=this.elements.controlledMenu.dom.menu.classList).remove.apply(t,h(s)));n&&this.dom.toggle.dispatchEvent(this._expandEvent)}},{key:"_collapse",value:function(){var e,t,n=!(arguments.length>0&&void 0!==arguments[0])||arguments[0],o=this.elements.controlledMenu,s=o.closeClass,r=o.openClass;(this.dom.toggle.setAttribute("aria-expanded","false"),""!==s)&&("string"==typeof s?this.elements.controlledMenu.dom.menu.classList.add(s):(e=this.elements.controlledMenu.dom.menu.classList).add.apply(e,h(s)));""!==r&&("string"==typeof r?this.elements.controlledMenu.dom.menu.classList.remove(r):(t=this.elements.controlledMenu.dom.menu.classList).remove.apply(t,h(r)));n&&this.dom.toggle.dispatchEvent(this._collapseEvent)}},{key:"open",value:function(){this.elements.controlledMenu.focusState="self",this._expand(),this.isOpen=!0}},{key:"preview",value:function(){this.elements.parentMenu&&(this.elements.parentMenu.focusState="self"),this._expand(),this.isOpen=!0}},{key:"close",value:function(){this.isOpen&&(this.elements.controlledMenu.currentChild=0,this.elements.controlledMenu.blur(),this.elements.parentMenu&&(this.elements.parentMenu.focusState="self"),this._collapse(),this.isOpen=!1)}},{key:"toggle",value:function(){this.isOpen?this.close():this.open()}},{key:"closeSiblings",value:function(){var e=this;this.elements.parentMenu&&this.elements.parentMenu.elements.submenuToggles.forEach((function(t){t!==e&&t.close()}))}},{key:"closeChildren",value:function(){this.elements.controlledMenu.elements.submenuToggles.forEach((function(e){return e.close()}))}}]),e}(),_=function(){function e(n){var o=n.menuItemElement,r=n.menuLinkElement,i=n.parentMenu,l=n.isSubmenuItem,u=void 0!==l&&l,c=n.childMenu,m=void 0===c?null:c,a=n.toggle,h=void 0===a?null:a;t(this,e),s(this,"_dom",{item:null,link:null}),s(this,"_elements",{parentMenu:null,childMenu:null,toggle:null}),s(this,"_submenu",!1),this._dom.item=o,this._dom.link=r,this._elements.parentMenu=i,this._elements.childMenu=m,this._elements.toggle=h,this._submenu=u}return o(e,[{key:"initialize",value:function(){}},{key:"dom",get:function(){return this._dom}},{key:"elements",get:function(){return this._elements}},{key:"isSubmenuItem",get:function(){return this._submenu}},{key:"focus",value:function(){this.elements.parentMenu.shouldFocus&&this.dom.link.focus()}},{key:"blur",value:function(){this.elements.parentMenu.shouldFocus&&this.dom.link.blur()}}]),e}();function E(e){try{var t=e.key||e.keyCode,n={Enter:"Enter"===t||13===t,Space:" "===t||"Spacebar"===t||32===t,Escape:"Escape"===t||"Esc"===t||27===t,ArrowUp:"ArrowUp"===t||"Up"===t||38===t,ArrowRight:"ArrowRight"===t||"Right"===t||39===t,ArrowDown:"ArrowDown"===t||"Down"===t||40===t,ArrowLeft:"ArrowLeft"===t||"Left"===t||37===t,Home:"Home"===t||36===t,End:"End"===t||35===t,Character:isNaN(t)&&!!t.match(/^[a-zA-Z]{1}$/),Tab:"Tab"===t||9===t,Asterisk:"*"===t||56===t};return Object.keys(n).find((function(e){return!0===n[e]}))||""}catch(e){return""}}function C(e){e.preventDefault(),e.stopPropagation()}var I=function(){function n(e){var o=e.menuElement,r=e.menuItemSelector,i=void 0===r?"li":r,l=e.menuLinkSelector,u=void 0===l?"a":l,c=e.submenuItemSelector,m=void 0===c?"":c,a=e.submenuToggleSelector,h=void 0===a?"a":a,d=e.submenuSelector,f=void 0===d?"ul":d,v=e.controllerElement,p=void 0===v?null:v,g=e.containerElement,y=void 0===g?null:g,b=e.openClass,E=void 0===b?"show":b,C=e.closeClass,I=void 0===C?"hide":C,T=e.isTopLevel,k=void 0===T||T,w=e.parentMenu,S=void 0===w?null:w,A=e.hoverType,L=void 0===A?"off":A,O=e.hoverDelay,D=void 0===O?250:O;t(this,n),s(this,"_MenuType",n),s(this,"_MenuItemType",_),s(this,"_MenuToggleType",M),s(this,"_dom",{menu:null,menuItems:[],submenuItems:[],submenuToggles:[],submenus:[],controller:null,container:null}),s(this,"_selectors",{menuItems:"",menuLinks:"",submenuItems:"",submenuToggles:"",submenus:""}),s(this,"_elements",{menuItems:[],submenuToggles:[],controller:null,parentMenu:null,rootMenu:null}),s(this,"_openClass","show"),s(this,"_closeClass","hide"),s(this,"_root",!0),s(this,"_currentChild",0),s(this,"_focusState","none"),s(this,"_currentEvent","none"),s(this,"_hoverType","off"),s(this,"_hoverDelay",250),this._dom.menu=o,this._dom.controller=p,this._dom.container=y,this._selectors.menuItems=i,this._selectors.menuLinks=u,this._selectors.submenuItems=m,this._selectors.submenuToggles=h,this._selectors.submenus=f,this._elements.menuItems=[],this._elements.submenuToggles=[],this._elements.controller=null,this._elements.parentMenu=S,this._elements.rootMenu=k?this:null,this._openClass=E||"",this._closeClass=I||"",this._root=k,this._hoverType=L,this._hoverDelay=D}return o(n,[{key:"initialize",value:function(){if(!this._validate())throw new Error("AccesibleMenu: cannot initialize menu. See other error messages for more information.");if(null===this.elements.rootMenu&&this._findRootMenu(this),this._setDOMElements(),this.isTopLevel&&this.dom.controller&&this.dom.container){var e=new this._MenuToggleType({menuToggleElement:this.dom.controller,parentElement:this.dom.container,controlledMenu:this});this._elements.controller=e}this._createChildElements()}},{key:"dom",get:function(){return this._dom}},{key:"selectors",get:function(){return this._selectors}},{key:"elements",get:function(){return this._elements}},{key:"isTopLevel",get:function(){return this._root}},{key:"openClass",get:function(){return this.isTopLevel?this._openClass:this.elements.rootMenu.openClass},set:function(e){g({openClass:e}),this._openClass!==e&&(this._openClass=e)}},{key:"closeClass",get:function(){return this.isTopLevel?this._closeClass:this.elements.rootMenu.closeClass},set:function(e){g({closeClass:e}),this._closeClass!==e&&(this._closeClass=e)}},{key:"currentChild",get:function(){return this._currentChild},set:function(e){function t(e){if(["mouse","character"].includes(e.currentEvent)&&e.elements.parentMenu)for(var t=0,n=!1;!n&&t<e.elements.parentMenu.elements.menuItems.length;){var o=e.elements.parentMenu.elements.menuItems[t];o.isSubmenuItem&&o.elements.toggle.elements.controlledMenu===e&&(n=!0,e.elements.parentMenu.currentEvent=e.currentEvent,e.elements.parentMenu.currentChild=t),t++}}v("number",{value:e}),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))}},{key:"focusState",get:function(){return this._focusState},set:function(t){!function(t){try{if("object"!==e(t)){var n=e(t);throw new TypeError("AccessibleMenu: Values given to isValidState() must be inside of an object. ".concat(n," given."))}var o=["none","self","child"];for(var s in t)if(!o.includes(t[s]))throw new TypeError("AccessibleMenu: ".concat(s," must be one of the following values: ").concat(o.join(", "),'. "').concat(t[s],'" given.'))}catch(e){return console.error(e),!1}}({value:t}),this._focusState!==t&&(this._focusState=t),this.elements.submenuToggles.length>0&&("self"===t||"none"===t)&&this.elements.submenuToggles.forEach((function(e){e.elements.controlledMenu.focusState="none"})),!this.elements.parentMenu||"self"!==t&&"child"!==t||(this.elements.parentMenu.focusState="child")}},{key:"currentEvent",get:function(){return this._currentEvent},set:function(t){!function(t){try{if("object"!==e(t)){var n=e(t);throw new TypeError("AccessibleMenu: Values given to isValidEvent() must be inside of an object. ".concat(n," given."))}var o=["none","mouse","keyboard","character"];for(var s in t)if(!o.includes(t[s]))throw new TypeError("AccessibleMenu: ".concat(s," must be one of the following values: ").concat(o.join(", "),'. "').concat(t[s],'" given.'))}catch(e){return console.error(e),!1}}({value:t}),this._currentEvent!==t&&(this._currentEvent=t,this.elements.submenuToggles.length>0&&this.elements.submenuToggles.forEach((function(e){e.elements.controlledMenu.currentEvent=t})))}},{key:"currentMenuItem",get:function(){return this.elements.menuItems[this.currentChild]}},{key:"hoverType",get:function(){return this._root?this._hoverType:this.elements.rootMenu.hoverType},set:function(e){y({value:e}),this._hoverType!==e&&(this._hoverType=e)}},{key:"hoverDelay",get:function(){return this._root?this._hoverDelay:this.elements.rootMenu.hoverDelay},set:function(e){v("number",{value:e}),this._hoverDelay!==e&&(this._hoverDelay=e)}},{key:"shouldFocus",get:function(){var e=!1;return"keyboard"!==this.currentEvent&&"character"!==this.currentEvent||(e=!0),"mouse"===this.currentEvent&&"dynamic"===this.hoverType&&(e=!0),e}},{key:"_validate",value:function(){var e=!0;return null!==this._dom.container||null!==this._dom.controller?f(HTMLElement,{menuElement:this._dom.menu,controllerElement:this._dom.controller,containerElement:this._dom.container})||(e=!1):f(HTMLElement,{menuElement:this._dom.menu})||(e=!1),""!==this._selectors.submenuItems?p({menuItemSelector:this._selectors.menuItems,menuLinkSelector:this._selectors.menuLinks,submenuItemSelector:this._selectors.submenuItems,submenuToggleSelector:this._selectors.submenuToggles,submenuSelector:this._selectors.submenus})||(e=!1):p({menuItemSelector:this._selectors.menuItems,menuLinkSelector:this._selectors.menuLinks})||(e=!1),""===this._openClass||g({openClass:this._openClass})||(e=!1),""===this._closeClass||g({closeClass:this._closeClass})||(e=!1),v("boolean",{isTopLevel:this._root})||(e=!1),null===this._elements.parentMenu||f(n,{parentMenu:this._elements.parentMenu})||(e=!1),y({hoverType:this._hoverType})||(e=!1),v("number",{hoverDelay:this._hoverDelay})||(e=!1),e}},{key:"_setDOMElementType",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.dom.menu,n=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];if("string"!=typeof this.selectors[e])throw new Error('AccessibleMenu: "'.concat(e,'" is not a valid element type within the menu.'));if(!Array.isArray(this.dom[e]))throw new Error('AccessibleMenu: The "'.concat(e,'" element cannot be set through _setDOMElementType.'));t!==this.dom.menu&&f(HTMLElement,{base:t});var o=Array.from(t.querySelectorAll(this.selectors[e])),s=o.filter((function(e){return e.parentElement===t}));this._dom[e]=n?s:[].concat(h(this._dom[e]),h(s))}},{key:"_resetDOMElementType",value:function(e){if(void 0===this.dom[e])throw new Error('AccessibleMenu: "'.concat(e,'" is not a valid element type within the menu.'));if(!Array.isArray(this.dom[e]))throw new Error('AccessibleMenu: The "'.concat(e,'" element cannot be reset through _resetDOMElementType.'));this._dom[e]=[]}},{key:"_setDOMElements",value:function(){var e=this;this._setDOMElementType("menuItems"),""!==this.selectors.submenuItems&&(this._setDOMElementType("submenuItems"),this._resetDOMElementType("submenuToggles"),this._resetDOMElementType("submenus"),this.dom.submenuItems.forEach((function(t){e._setDOMElementType("submenuToggles",t,!1),e._setDOMElementType("submenus",t,!1)})))}},{key:"_findRootMenu",value:function(e){if(e.isTopLevel)this._elements.rootMenu=e;else{if(null===e.elements.parentMenu)throw new Error("Cannot find root menu.");this._findRootMenu(e.elements.parentMenu)}}},{key:"_createChildElements",value:function(){var e=this;this.dom.menuItems.forEach((function(t){var n;if(e.dom.submenuItems.includes(t)){var o=t.querySelector(e.selectors.submenuToggles),s=t.querySelector(e.selectors.submenus),r=new e._MenuType({menuElement:s,menuItemSelector:e.selectors.menuItems,menuLinkSelector:e.selectors.menuLinks,submenuItemSelector:e.selectors.submenuItems,submenuToggleSelector:e.selectors.submenuToggles,submenuSelector:e.selectors.submenus,openClass:e.openClass,closeClass:e.closeClass,isTopLevel:!1,parentMenu:e,hoverType:e.hoverType,hoverDelay:e.hoverDelay}),i=new e._MenuToggleType({menuToggleElement:o,parentElement:t,controlledMenu:r,parentMenu:e});e._elements.submenuToggles.push(i),n=new e._MenuItemType({menuItemElement:t,menuLinkElement:o,parentMenu:e,isSubmenuItem:!0,childMenu:r,toggle:i})}else{var l=t.querySelector(e.selectors.menuLinks);n=new e._MenuItemType({menuItemElement:t,menuLinkElement:l,parentMenu:e})}e._elements.menuItems.push(n)}))}},{key:"_handleFocus",value:function(){var e=this;this.elements.menuItems.forEach((function(t,n){t.dom.link.addEventListener("focus",(function(){e.focusState="self",e.currentChild=n}))}))}},{key:"_handleClick",value:function(){var e=this,t=b("touchstart",this.dom.menu)?"touchstart":"mousedown",n=b("touchend",this.dom.menu)?"touchend":"mouseup";function o(e,t,n){C(n),t.toggle(),t.isOpen&&(e.focusState="self",t.elements.controlledMenu.focusState="none")}this.elements.menuItems.forEach((function(s,r){s.dom.link.addEventListener(t,(function(){e.currentEvent="mouse",e.elements.rootMenu.blurChildren(),e.focusChild(r)})),s.isSubmenuItem&&(s.elements.toggle.dom.toggle["on".concat(n)]=function(t){e.currentEvent="mouse",o(e,s.elements.toggle,t)})})),this.isTopLevel&&this.elements.controller&&(this.elements.controller.dom.toggle["on".concat(n)]=function(t){e.currentEvent="mouse",o(e,e.elements.controller,t)})}},{key:"_handleHover",value:function(){var e=this;this.elements.menuItems.forEach((function(t,n){t.dom.link.addEventListener("mouseenter",(function(){if("on"===e.hoverType)e.currentEvent="mouse",e.currentChild=n,t.isSubmenuItem&&t.elements.toggle.preview();else if("dynamic"===e.hoverType){var o=e.elements.submenuToggles.some((function(e){return e.isOpen}));e.currentChild=n,e.isTopLevel&&"none"===e.focusState||(e.currentEvent="mouse",e.focusCurrentChild()),!t.isSubmenuItem||e.isTopLevel&&!o||(e.currentEvent="mouse",t.elements.toggle.preview())}})),t.isSubmenuItem&&t.dom.item.addEventListener("mouseleave",(function(){"on"===e.hoverType?e.hoverDelay>0?setTimeout((function(){e.currentEvent="mouse",t.elements.toggle.close()}),e.hoverDelay):(e.currentEvent="mouse",t.elements.toggle.close()):"dynamic"===e.hoverType&&(e.isTopLevel||(e.hoverDelay>0?setTimeout((function(){e.currentEvent="mouse",t.elements.toggle.close(),e.focusCurrentChild()}),e.hoverDelay):(e.currentEvent="mouse",t.elements.toggle.close(),e.focusCurrentChild())))}))}))}},{key:"_handleKeydown",value:function(){var e=this;this.isTopLevel&&this.elements.controller&&this.elements.controller.dom.toggle.addEventListener("keydown",(function(t){e.currentEvent="keyboard";var n=E(t);"Space"!==n&&"Enter"!==n||C(t)}))}},{key:"_handleKeyup",value:function(){var e=this;this.isTopLevel&&this.elements.controller&&this.elements.controller.dom.toggle.addEventListener("keyup",(function(t){e.currentEvent="keyboard";var n=E(t);"Space"!==n&&"Enter"!==n||(C(t),e.elements.controller.open(),e.focusFirstChild())}))}},{key:"focus",value:function(){this.focusState="self",this.shouldFocus&&this.dom.menu.focus()}},{key:"blur",value:function(){this.focusState="none",this.shouldFocus&&this.dom.menu.blur()}},{key:"focusCurrentChild",value:function(){this.focusState="self",-1!==this.currentChild&&this.currentMenuItem.focus()}},{key:"focusChild",value:function(e){this.blurCurrentChild(),this.currentChild=e,this.focusCurrentChild()}},{key:"focusFirstChild",value:function(){this.focusChild(0)}},{key:"focusLastChild",value:function(){this.focusChild(this.elements.menuItems.length-1)}},{key:"focusNextChild",value:function(){this.currentChild<this.elements.menuItems.length-1?this.focusChild(this.currentChild+1):this.focusCurrentChild()}},{key:"focusPreviousChild",value:function(){this.currentChild>0?this.focusChild(this.currentChild-1):this.focusCurrentChild()}},{key:"blurCurrentChild",value:function(){this.focusState="none",-1!==this.currentChild&&this.currentMenuItem.blur()}},{key:"focusController",value:function(){this.dom.controller&&(this.shouldFocus&&this.dom.controller.focus(),this.focusState="none")}},{key:"focusContainer",value:function(){this.dom.container&&(this.shouldFocus&&this.dom.container.focus(),this.focusState="none")}},{key:"closeChildren",value:function(){this.elements.submenuToggles.forEach((function(e){return e.close()}))}},{key:"blurChildren",value:function(){this.elements.menuItems.forEach((function(e){e.blur(),e.isSubmenuItem&&e.elements.childMenu.blurChildren()}))}}]),n}(),T=function(e){r(s,e);var n=m(s);function s(e){var o,r=e.menuItemElement,i=e.menuLinkElement,l=e.parentMenu,u=e.isSubmenuItem,c=void 0!==u&&u,m=e.childMenu,a=void 0===m?null:m,h=e.toggle,d=void 0===h?null:h,f=e.initialize,v=void 0===f||f;return t(this,s),o=n.call(this,{menuItemElement:r,menuLinkElement:i,parentMenu:l,isSubmenuItem:c,childMenu:a,toggle:d}),v&&o.initialize(),o}return o(s,[{key:"initialize",value:function(){a(i(s.prototype),"initialize",this).call(this),this.dom.item.setAttribute("role","none"),this.dom.link.setAttribute("role","menuitem"),this.dom.link.tabIndex=-1}},{key:"focus",value:function(){a(i(s.prototype),"focus",this).call(this),this.elements.parentMenu.isTopLevel&&(this.dom.link.tabIndex=0)}},{key:"blur",value:function(){a(i(s.prototype),"blur",this).call(this),this.elements.parentMenu.isTopLevel&&(this.dom.link.tabIndex=-1)}}]),s}(_),k=function(e){r(s,e);var n=m(s);function s(e){var o,r=e.menuToggleElement,i=e.parentElement,l=e.controlledMenu,u=e.parentMenu,c=void 0===u?null:u,m=e.initialize,a=void 0===m||m;return t(this,s),o=n.call(this,{menuToggleElement:r,parentElement:i,controlledMenu:l,parentMenu:c}),a&&o.initialize(),o}return o(s,[{key:"open",value:function(){this.closeSiblings(),a(i(s.prototype),"open",this).call(this)}},{key:"preview",value:function(){this.closeSiblings(),a(i(s.prototype),"preview",this).call(this)}},{key:"close",value:function(){this.isOpen&&this.closeChildren(),a(i(s.prototype),"close",this).call(this)}}]),s}(M);return function(e){r(l,e);var n=m(l);function l(e){var o,r=e.menuElement,i=e.menuItemSelector,c=void 0===i?"li":i,m=e.menuLinkSelector,a=void 0===m?"a":m,h=e.submenuItemSelector,d=void 0===h?"":h,f=e.submenuToggleSelector,v=void 0===f?"a":f,p=e.submenuSelector,g=void 0===p?"ul":p,y=e.controllerElement,b=void 0===y?null:y,M=e.containerElement,_=void 0===M?null:M,E=e.openClass,C=void 0===E?"show":E,I=e.closeClass,w=void 0===I?"hide":I,S=e.isTopLevel,A=void 0===S||S,L=e.parentMenu,O=void 0===L?null:L,D=e.hoverType,j=void 0===D?"off":D,x=e.hoverDelay,F=void 0===x?250:x,R=e.initialize,z=void 0===R||R;return t(this,l),s(u(o=n.call(this,{menuElement:r,menuItemSelector:c,menuLinkSelector:a,submenuItemSelector:d,submenuToggleSelector:v,submenuSelector:g,controllerElement:b,containerElement:_,openClass:C,closeClass:w,isTopLevel:A,parentMenu:O,hoverType:j,hoverDelay:F})),"_MenuType",l),s(u(o),"_MenuItemType",T),s(u(o),"_MenuToggleType",k),z&&o.initialize(),o}return o(l,[{key:"initialize",value:function(){try{a(i(l.prototype),"initialize",this).call(this),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)}}},{key:"_handleClick",value:function(){var e=this;a(i(l.prototype),"_handleClick",this).call(this);var t=b("touchend",this.dom.menu)?"touchend":"mouseup";document.addEventListener(t,(function(t){"none"!==e.focusState&&(e.currentEvent="mouse",e.dom.menu.contains(t.target)||!e.dom.menu===t.target||(e.closeChildren(),e.blur(),e.elements.controller&&e.elements.controller.close()))}))}},{key:"_handleKeydown",value:function(){var e=this;a(i(l.prototype),"_handleKeydown",this).call(this),this.dom.menu.addEventListener("keydown",(function(t){e.currentEvent="keyboard";var n=E(t);if("Tab"===n&&("none"!==e.elements.rootMenu.focusState?(e.elements.rootMenu.blur(),e.elements.rootMenu.closeChildren()):e.elements.rootMenu.focus()),"Character"===n)C(t);else if(e.isTopLevel){if("self"===e.focusState){(["ArrowRight","ArrowLeft","Home","End"].includes(n)||e.currentMenuItem.isSubmenuItem&&["Space","Enter","ArrowDown","ArrowUp"].includes(n)||e.elements.controller&&["Escape"].includes(n))&&C(t)}}else{(["Escape","ArrowRight","ArrowLeft","ArrowDown","ArrowUp","Home","End"].includes(n)||e.currentMenuItem.isSubmenuItem&&["Space","Enter"].includes(n))&&C(t)}}))}},{key:"_handleKeyup",value:function(){var e=this;a(i(l.prototype),"_handleKeyup",this).call(this),this.dom.menu.addEventListener("keyup",(function(t){e.currentEvent="keyboard";var n=E(t),o=t.altKey,s=t.crtlKey,r=t.metaKey;if("Character"!==n||(o||s||r))if(e.isTopLevel){if("self"===e.focusState)if("Space"===n||"Enter"===n)e.currentMenuItem.isSubmenuItem?(C(t),e.currentMenuItem.elements.childMenu.currentEvent="keyboard",e.currentMenuItem.elements.toggle.open(),requestAnimationFrame((function(){e.currentMenuItem.elements.childMenu.focusFirstChild()}))):e.currentMenuItem.dom.link.click();else if("ArrowRight"===n){C(t);var i=e.currentMenuItem.isSubmenuItem&&e.currentMenuItem.elements.toggle.isOpen;e.focusNextChild(),i&&(e.currentMenuItem.isSubmenuItem?(e.currentMenuItem.elements.childMenu.currentEvent="keyboard",e.currentMenuItem.elements.toggle.preview()):e.closeChildren())}else if("ArrowLeft"===n){C(t);var l=e.currentMenuItem.isSubmenuItem&&e.currentMenuItem.elements.toggle.isOpen;e.focusPreviousChild(),l&&(e.currentMenuItem.isSubmenuItem?(e.currentMenuItem.elements.childMenu.currentEvent="keyboard",e.currentMenuItem.elements.toggle.preview()):e.closeChildren())}else if("ArrowDown"===n)e.currentMenuItem.isSubmenuItem&&(C(t),e.currentMenuItem.elements.childMenu.currentEvent="keyboard",e.currentMenuItem.elements.toggle.open(),requestAnimationFrame((function(){e.currentMenuItem.elements.childMenu.focusFirstChild()})));else if("ArrowUp"===n)e.currentMenuItem.isSubmenuItem&&(C(t),e.currentMenuItem.elements.childMenu.currentEvent="keyboard",e.currentMenuItem.elements.toggle.open(),requestAnimationFrame((function(){e.currentMenuItem.elements.childMenu.focusLastChild()})));else if("Home"===n)C(t),e.focusFirstChild();else if("End"===n)C(t),e.focusLastChild();else if("Escape"===n){e.elements.submenuToggles.some((function(e){return e.isOpen}))?(C(t),e.closeChildren()):e.isTopLevel&&e.elements.controller&&e.elements.controller.isOpen&&(C(t),e.elements.controller.close(),e.focusController())}}else"Space"===n||"Enter"===n?e.currentMenuItem.isSubmenuItem&&(C(t),e.currentMenuItem.elements.childMenu.currentEvent="keyboard",e.currentMenuItem.elements.toggle.open(),requestAnimationFrame((function(){e.currentMenuItem.elements.childMenu.focusFirstChild()}))):"Escape"===n?(C(t),e.elements.rootMenu.closeChildren(),e.elements.rootMenu.focusCurrentChild()):"ArrowRight"===n?e.currentMenuItem.isSubmenuItem?(C(t),e.currentMenuItem.elements.childMenu.currentEvent="keyboard",e.currentMenuItem.elements.toggle.open(),requestAnimationFrame((function(){e.currentMenuItem.elements.childMenu.focusFirstChild()}))):(C(t),e.elements.rootMenu.closeChildren(),e.elements.rootMenu.focusNextChild(),e.elements.rootMenu.currentMenuItem.isSubmenuItem&&e.elements.rootMenu.currentMenuItem.elements.toggle.preview()):"ArrowLeft"===n?e.elements.parentMenu.currentMenuItem.isSubmenuItem&&(C(t),e.elements.parentMenu.currentMenuItem.elements.toggle.close(),e.elements.parentMenu.focusCurrentChild(),e.elements.parentMenu===e.elements.rootMenu&&(e.elements.rootMenu.closeChildren(),e.elements.rootMenu.focusPreviousChild(),e.elements.rootMenu.currentMenuItem.isSubmenuItem&&(e.elements.rootMenu.currentMenuItem.elements.childMenu.currentEvent="keyboard",e.elements.rootMenu.currentMenuItem.elements.toggle.preview()))):"ArrowDown"===n?(C(t),e.focusNextChild()):"ArrowUp"===n?(C(t),e.focusPreviousChild()):"Home"===n?(C(t),e.focusFirstChild()):"End"===n&&(C(t),e.focusLastChild());else C(t),e.elements.rootMenu.currentEvent="character",e.focusNextChildWithCharacter(t.key)}))}},{key:"focusNextChild",value:function(){this.currentChild===this.elements.menuItems.length-1?this.focusFirstChild():this.focusChild(this.currentChild+1)}},{key:"focusPreviousChild",value:function(){0===this.currentChild?this.focusLastChild():this.focusChild(this.currentChild-1)}},{key:"focusNextChildWithCharacter",value:function(e){for(var t=e.toLowerCase(),n=this.currentChild+1,o=!1;!o&&n<this.elements.menuItems.length;){(this.elements.menuItems[n].dom.item.innerText?this.elements.menuItems[n].dom.item.innerText:this.elements.menuItems[n].dom.item.textContent).replace(/[\s]/g,"").toLowerCase().charAt(0)===t&&(o=!0,this.focusChild(n)),n++}}}]),l}(I)}();
var Menubar=function(){"use strict";function e(t){return e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},e(t)}function t(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function n(e,t){for(var n=0;n<t.length;n++){var o=t[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}function o(e,t,o){return t&&n(e.prototype,t),o&&n(e,o),e}function s(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function r(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&l(e,t)}function i(e){return i=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},i(e)}function l(e,t){return l=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},l(e,t)}function u(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function c(e,t){if(t&&("object"==typeof t||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return u(e)}function m(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,o=i(e);if(t){var s=i(this).constructor;n=Reflect.construct(o,arguments,s)}else n=o.apply(this,arguments);return c(this,n)}}function a(e,t,n){return a="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(e,t,n){var o=function(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&null!==(e=i(e)););return e}(e,t);if(o){var s=Object.getOwnPropertyDescriptor(o,t);return s.get?s.get.call(n):s.value}},a(e,t,n||e)}function h(e){return function(e){if(Array.isArray(e))return d(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,t){if(!e)return;if("string"==typeof e)return d(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return d(e,t)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function d(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,o=new Array(t);n<t;n++)o[n]=e[n];return o}function f(t,n){try{if("object"!==e(n)){var o=e(n);throw new TypeError("AccessibleMenu: Elements given to isValidInstance() must be inside of an object. ".concat(o," given."))}for(var s in n)if(!(n[s]instanceof t)){var r=e(n[s]);throw new TypeError("AccessibleMenu: ".concat(s," must be an instance of ").concat(t.name,". ").concat(r," given."))}return!0}catch(e){return console.error(e),!1}}function v(t,n){try{if("object"!==e(n)){var o=e(n);throw new TypeError("AccessibleMenu: Values given to isValidType() must be inside of an object. ".concat(o," given."))}for(var s in n){var r=e(n[s]);if(r!==t)throw new TypeError("AccessibleMenu: ".concat(s," must be a ").concat(t,". ").concat(r," given."))}return!0}catch(e){return console.error(e),!1}}function p(t){try{if("object"!==e(t)){var n=e(t);throw new TypeError("AccessibleMenu: Values given to isCSSSelector() must be inside of an object. ".concat(n," given."))}for(var o in t)try{if(null===t[o])throw new Error;document.querySelector(t[o])}catch(e){throw new TypeError("AccessibleMenu: ".concat(o,' must be a valid CSS selector. "').concat(t[o],'" given.'))}return!0}catch(e){return console.error(e),!1}}function g(t){try{if("object"!==e(t)||Array.isArray(t)){var n=e(t);throw new TypeError("AccessibleMenu: Values given to isValidClassList() must be inside of an object. ".concat(n," given."))}var o=function(n){var o=e(t[n]);if("string"!==o){if(!Array.isArray(t[n]))throw new TypeError("AccessibleMenu: ".concat(n," must be a string or an array of strings. ").concat(o," given."));t[n].forEach((function(e){if("string"!=typeof e)throw new TypeError("AccessibleMenu: ".concat(n," must be a string or an array of strings. An array containing non-strings given."))}))}else{var s={};s[n]=t[n],p(s)}};for(var s in t)o(s);return!0}catch(e){return console.error(e),!1}}function y(t){try{if("object"!==e(t)){var n=e(t);throw new TypeError("AccessibleMenu: Values given to isValidHoverType() must be inside of an object. ".concat(n," given."))}var o=["off","on","dynamic"];for(var s in t)if(!o.includes(t[s]))throw new TypeError("AccessibleMenu: ".concat(s," must be one of the following values: ").concat(o.join(", "),'. "').concat(t[s],'" given.'));return!0}catch(e){return console.error(e),!1}}var b=function(){function e(n){var o=n.menuToggleElement,r=n.parentElement,i=n.controlledMenu,l=n.parentMenu,u=void 0===l?null:l;t(this,e),s(this,"_dom",{toggle:null,parent:null}),s(this,"_elements",{controlledMenu:null,parentMenu:null}),s(this,"_open",!1),s(this,"_expandEvent",new CustomEvent("accessibleMenuExpand",{bubbles:!0,detail:{toggle:this}})),s(this,"_collapseEvent",new CustomEvent("accessibleMenuCollapse",{bubbles:!0,detail:{toggle:this}})),this._dom.toggle=o,this._dom.parent=r,this._elements.controlledMenu=i,this._elements.parentMenu=u}return o(e,[{key:"initialize",value:function(){if(this.dom.toggle.setAttribute("aria-haspopup","true"),this.dom.toggle.setAttribute("aria-expanded","false"),function(e,t){if(v("string",{tagName:e})&&f(HTMLElement,t)){var n=e.toLowerCase(),o=!0;for(var s in t)t[s].tagName.toLowerCase()!==n&&(o=!1);return o}return!1}("button",{toggle:this.dom.toggle})||this.dom.toggle.setAttribute("role","button"),""===this.dom.toggle.id||""===this.elements.controlledMenu.dom.menu.id){var e=Math.random().toString(36).replace(/[^a-z]+/g,"").substr(0,10),t=this.dom.toggle.innerText.replace(/[^a-zA-Z0-9\s]/g,""),n=e;!t.replace(/\s/g,"").length&&this.dom.toggle.getAttribute("aria-label")&&(t=this.dom.toggle.getAttribute("aria-label").replace(/[^a-zA-Z0-9\s]/g,"")),t.replace(/\s/g,"").length>0&&((t=t.toLowerCase().replace(/\s+/g,"-")).startsWith("-")&&(t=t.substring(1)),t.endsWith("-")&&(t=t.slice(0,-1)),n="".concat(t,"-").concat(n)),this.dom.toggle.id=this.dom.toggle.id||"".concat(n,"-menu-button"),this.elements.controlledMenu.dom.menu.id=this.elements.controlledMenu.dom.menu.id||"".concat(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)}},{key:"dom",get:function(){return this._dom}},{key:"elements",get:function(){return this._elements}},{key:"isOpen",get:function(){return this._open},set:function(e){v("boolean",{value:e}),this._open=e}},{key:"_expand",value:function(){var e,t,n=!(arguments.length>0&&void 0!==arguments[0])||arguments[0],o=this.elements.controlledMenu,s=o.closeClass,r=o.openClass;(this.dom.toggle.setAttribute("aria-expanded","true"),""!==r)&&("string"==typeof r?this.elements.controlledMenu.dom.menu.classList.add(r):(e=this.elements.controlledMenu.dom.menu.classList).add.apply(e,h(r)));""!==s&&("string"==typeof s?this.elements.controlledMenu.dom.menu.classList.remove(s):(t=this.elements.controlledMenu.dom.menu.classList).remove.apply(t,h(s)));n&&this.dom.toggle.dispatchEvent(this._expandEvent)}},{key:"_collapse",value:function(){var e,t,n=!(arguments.length>0&&void 0!==arguments[0])||arguments[0],o=this.elements.controlledMenu,s=o.closeClass,r=o.openClass;(this.dom.toggle.setAttribute("aria-expanded","false"),""!==s)&&("string"==typeof s?this.elements.controlledMenu.dom.menu.classList.add(s):(e=this.elements.controlledMenu.dom.menu.classList).add.apply(e,h(s)));""!==r&&("string"==typeof r?this.elements.controlledMenu.dom.menu.classList.remove(r):(t=this.elements.controlledMenu.dom.menu.classList).remove.apply(t,h(r)));n&&this.dom.toggle.dispatchEvent(this._collapseEvent)}},{key:"open",value:function(){this.elements.controlledMenu.focusState="self",this._expand(),this.isOpen=!0}},{key:"preview",value:function(){this.elements.parentMenu&&(this.elements.parentMenu.focusState="self"),this._expand(),this.isOpen=!0}},{key:"close",value:function(){this.isOpen&&(this.elements.controlledMenu.currentChild=0,this.elements.controlledMenu.blur(),this.elements.parentMenu&&(this.elements.parentMenu.focusState="self"),this._collapse(),this.isOpen=!1)}},{key:"toggle",value:function(){this.isOpen?this.close():this.open()}},{key:"closeSiblings",value:function(){var e=this;this.elements.parentMenu&&this.elements.parentMenu.elements.submenuToggles.forEach((function(t){t!==e&&t.close()}))}},{key:"closeChildren",value:function(){this.elements.controlledMenu.elements.submenuToggles.forEach((function(e){return e.close()}))}}]),e}(),M=function(){function e(n){var o=n.menuItemElement,r=n.menuLinkElement,i=n.parentMenu,l=n.isSubmenuItem,u=void 0!==l&&l,c=n.childMenu,m=void 0===c?null:c,a=n.toggle,h=void 0===a?null:a;t(this,e),s(this,"_dom",{item:null,link:null}),s(this,"_elements",{parentMenu:null,childMenu:null,toggle:null}),s(this,"_submenu",!1),this._dom.item=o,this._dom.link=r,this._elements.parentMenu=i,this._elements.childMenu=m,this._elements.toggle=h,this._submenu=u}return o(e,[{key:"initialize",value:function(){}},{key:"dom",get:function(){return this._dom}},{key:"elements",get:function(){return this._elements}},{key:"isSubmenuItem",get:function(){return this._submenu}},{key:"focus",value:function(){this.elements.parentMenu.shouldFocus&&this.dom.link.focus()}},{key:"blur",value:function(){this.elements.parentMenu.shouldFocus&&this.dom.link.blur()}}]),e}();function _(e){try{var t=e.key||e.keyCode,n={Enter:"Enter"===t||13===t,Space:" "===t||"Spacebar"===t||32===t,Escape:"Escape"===t||"Esc"===t||27===t,ArrowUp:"ArrowUp"===t||"Up"===t||38===t,ArrowRight:"ArrowRight"===t||"Right"===t||39===t,ArrowDown:"ArrowDown"===t||"Down"===t||40===t,ArrowLeft:"ArrowLeft"===t||"Left"===t||37===t,Home:"Home"===t||36===t,End:"End"===t||35===t,Character:isNaN(t)&&!!t.match(/^[a-zA-Z]{1}$/),Tab:"Tab"===t||9===t,Asterisk:"*"===t||56===t};return Object.keys(n).find((function(e){return!0===n[e]}))||""}catch(e){return""}}function E(e){e.preventDefault(),e.stopPropagation()}var C=function(){function n(e){var o=e.menuElement,r=e.menuItemSelector,i=void 0===r?"li":r,l=e.menuLinkSelector,u=void 0===l?"a":l,c=e.submenuItemSelector,m=void 0===c?"":c,a=e.submenuToggleSelector,h=void 0===a?"a":a,d=e.submenuSelector,f=void 0===d?"ul":d,v=e.controllerElement,p=void 0===v?null:v,g=e.containerElement,y=void 0===g?null:g,_=e.openClass,E=void 0===_?"show":_,C=e.closeClass,I=void 0===C?"hide":C,T=e.isTopLevel,k=void 0===T||T,w=e.parentMenu,S=void 0===w?null:w,A=e.hoverType,L=void 0===A?"off":A,O=e.hoverDelay,D=void 0===O?250:O;t(this,n),s(this,"_MenuType",n),s(this,"_MenuItemType",M),s(this,"_MenuToggleType",b),s(this,"_dom",{menu:null,menuItems:[],submenuItems:[],submenuToggles:[],submenus:[],controller:null,container:null}),s(this,"_selectors",{menuItems:"",menuLinks:"",submenuItems:"",submenuToggles:"",submenus:""}),s(this,"_elements",{menuItems:[],submenuToggles:[],controller:null,parentMenu:null,rootMenu:null}),s(this,"_openClass","show"),s(this,"_closeClass","hide"),s(this,"_root",!0),s(this,"_currentChild",0),s(this,"_focusState","none"),s(this,"_currentEvent","none"),s(this,"_hoverType","off"),s(this,"_hoverDelay",250),this._dom.menu=o,this._dom.controller=p,this._dom.container=y,this._selectors.menuItems=i,this._selectors.menuLinks=u,this._selectors.submenuItems=m,this._selectors.submenuToggles=h,this._selectors.submenus=f,this._elements.menuItems=[],this._elements.submenuToggles=[],this._elements.controller=null,this._elements.parentMenu=S,this._elements.rootMenu=k?this:null,this._openClass=E||"",this._closeClass=I||"",this._root=k,this._hoverType=L,this._hoverDelay=D}return o(n,[{key:"initialize",value:function(){if(!this._validate())throw new Error("AccesibleMenu: cannot initialize menu. See other error messages for more information.");if(null===this.elements.rootMenu&&this._findRootMenu(this),this._setDOMElements(),this.isTopLevel&&this.dom.controller&&this.dom.container){var e=new this._MenuToggleType({menuToggleElement:this.dom.controller,parentElement:this.dom.container,controlledMenu:this});this._elements.controller=e}this._createChildElements()}},{key:"dom",get:function(){return this._dom}},{key:"selectors",get:function(){return this._selectors}},{key:"elements",get:function(){return this._elements}},{key:"isTopLevel",get:function(){return this._root}},{key:"openClass",get:function(){return this.isTopLevel?this._openClass:this.elements.rootMenu.openClass},set:function(e){g({openClass:e}),this._openClass!==e&&(this._openClass=e)}},{key:"closeClass",get:function(){return this.isTopLevel?this._closeClass:this.elements.rootMenu.closeClass},set:function(e){g({closeClass:e}),this._closeClass!==e&&(this._closeClass=e)}},{key:"currentChild",get:function(){return this._currentChild},set:function(e){function t(e){if(["mouse","character"].includes(e.currentEvent)&&e.elements.parentMenu)for(var t=0,n=!1;!n&&t<e.elements.parentMenu.elements.menuItems.length;){var o=e.elements.parentMenu.elements.menuItems[t];o.isSubmenuItem&&o.elements.toggle.elements.controlledMenu===e&&(n=!0,e.elements.parentMenu.currentEvent=e.currentEvent,e.elements.parentMenu.currentChild=t),t++}}v("number",{value:e}),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))}},{key:"focusState",get:function(){return this._focusState},set:function(t){!function(t){try{if("object"!==e(t)){var n=e(t);throw new TypeError("AccessibleMenu: Values given to isValidState() must be inside of an object. ".concat(n," given."))}var o=["none","self","child"];for(var s in t)if(!o.includes(t[s]))throw new TypeError("AccessibleMenu: ".concat(s," must be one of the following values: ").concat(o.join(", "),'. "').concat(t[s],'" given.'))}catch(e){return console.error(e),!1}}({value:t}),this._focusState!==t&&(this._focusState=t),this.elements.submenuToggles.length>0&&("self"===t||"none"===t)&&this.elements.submenuToggles.forEach((function(e){e.elements.controlledMenu.focusState="none"})),!this.elements.parentMenu||"self"!==t&&"child"!==t||(this.elements.parentMenu.focusState="child")}},{key:"currentEvent",get:function(){return this._currentEvent},set:function(t){!function(t){try{if("object"!==e(t)){var n=e(t);throw new TypeError("AccessibleMenu: Values given to isValidEvent() must be inside of an object. ".concat(n," given."))}var o=["none","mouse","keyboard","character"];for(var s in t)if(!o.includes(t[s]))throw new TypeError("AccessibleMenu: ".concat(s," must be one of the following values: ").concat(o.join(", "),'. "').concat(t[s],'" given.'))}catch(e){return console.error(e),!1}}({value:t}),this._currentEvent!==t&&(this._currentEvent=t,this.elements.submenuToggles.length>0&&this.elements.submenuToggles.forEach((function(e){e.elements.controlledMenu.currentEvent=t})))}},{key:"currentMenuItem",get:function(){return this.elements.menuItems[this.currentChild]}},{key:"hoverType",get:function(){return this._root?this._hoverType:this.elements.rootMenu.hoverType},set:function(e){y({value:e}),this._hoverType!==e&&(this._hoverType=e)}},{key:"hoverDelay",get:function(){return this._root?this._hoverDelay:this.elements.rootMenu.hoverDelay},set:function(e){v("number",{value:e}),this._hoverDelay!==e&&(this._hoverDelay=e)}},{key:"shouldFocus",get:function(){var e=!1;return"keyboard"!==this.currentEvent&&"character"!==this.currentEvent||(e=!0),"mouse"===this.currentEvent&&"dynamic"===this.hoverType&&(e=!0),e}},{key:"_validate",value:function(){var e=!0;return null!==this._dom.container||null!==this._dom.controller?f(HTMLElement,{menuElement:this._dom.menu,controllerElement:this._dom.controller,containerElement:this._dom.container})||(e=!1):f(HTMLElement,{menuElement:this._dom.menu})||(e=!1),""!==this._selectors.submenuItems?p({menuItemSelector:this._selectors.menuItems,menuLinkSelector:this._selectors.menuLinks,submenuItemSelector:this._selectors.submenuItems,submenuToggleSelector:this._selectors.submenuToggles,submenuSelector:this._selectors.submenus})||(e=!1):p({menuItemSelector:this._selectors.menuItems,menuLinkSelector:this._selectors.menuLinks})||(e=!1),""===this._openClass||g({openClass:this._openClass})||(e=!1),""===this._closeClass||g({closeClass:this._closeClass})||(e=!1),v("boolean",{isTopLevel:this._root})||(e=!1),null===this._elements.parentMenu||f(n,{parentMenu:this._elements.parentMenu})||(e=!1),y({hoverType:this._hoverType})||(e=!1),v("number",{hoverDelay:this._hoverDelay})||(e=!1),e}},{key:"_setDOMElementType",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.dom.menu,n=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];if("string"!=typeof this.selectors[e])throw new Error('AccessibleMenu: "'.concat(e,'" is not a valid element type within the menu.'));if(!Array.isArray(this.dom[e]))throw new Error('AccessibleMenu: The "'.concat(e,'" element cannot be set through _setDOMElementType.'));t!==this.dom.menu&&f(HTMLElement,{base:t});var o=Array.from(t.querySelectorAll(this.selectors[e])),s=o.filter((function(e){return e.parentElement===t}));this._dom[e]=n?s:[].concat(h(this._dom[e]),h(s))}},{key:"_resetDOMElementType",value:function(e){if(void 0===this.dom[e])throw new Error('AccessibleMenu: "'.concat(e,'" is not a valid element type within the menu.'));if(!Array.isArray(this.dom[e]))throw new Error('AccessibleMenu: The "'.concat(e,'" element cannot be reset through _resetDOMElementType.'));this._dom[e]=[]}},{key:"_setDOMElements",value:function(){var e=this;this._setDOMElementType("menuItems"),""!==this.selectors.submenuItems&&(this._setDOMElementType("submenuItems"),this._resetDOMElementType("submenuToggles"),this._resetDOMElementType("submenus"),this.dom.submenuItems.forEach((function(t){e._setDOMElementType("submenuToggles",t,!1),e._setDOMElementType("submenus",t,!1)})))}},{key:"_findRootMenu",value:function(e){if(e.isTopLevel)this._elements.rootMenu=e;else{if(null===e.elements.parentMenu)throw new Error("Cannot find root menu.");this._findRootMenu(e.elements.parentMenu)}}},{key:"_createChildElements",value:function(){var e=this;this.dom.menuItems.forEach((function(t){var n;if(e.dom.submenuItems.includes(t)){var o=t.querySelector(e.selectors.submenuToggles),s=t.querySelector(e.selectors.submenus),r=new e._MenuType({menuElement:s,menuItemSelector:e.selectors.menuItems,menuLinkSelector:e.selectors.menuLinks,submenuItemSelector:e.selectors.submenuItems,submenuToggleSelector:e.selectors.submenuToggles,submenuSelector:e.selectors.submenus,openClass:e.openClass,closeClass:e.closeClass,isTopLevel:!1,parentMenu:e,hoverType:e.hoverType,hoverDelay:e.hoverDelay}),i=new e._MenuToggleType({menuToggleElement:o,parentElement:t,controlledMenu:r,parentMenu:e});e._elements.submenuToggles.push(i),n=new e._MenuItemType({menuItemElement:t,menuLinkElement:o,parentMenu:e,isSubmenuItem:!0,childMenu:r,toggle:i})}else{var l=t.querySelector(e.selectors.menuLinks);n=new e._MenuItemType({menuItemElement:t,menuLinkElement:l,parentMenu:e})}e._elements.menuItems.push(n)}))}},{key:"_handleFocus",value:function(){var e=this;this.elements.menuItems.forEach((function(t,n){t.dom.link.addEventListener("focus",(function(){e.focusState="self",e.currentChild=n}))}))}},{key:"_handleClick",value:function(){var e=this;function t(e,t,n){E(n),t.toggle(),t.isOpen&&(e.focusState="self",t.elements.controlledMenu.focusState="none")}this.elements.menuItems.forEach((function(n,o){n.dom.link.addEventListener("pointerdown",(function(){e.currentEvent="mouse",e.elements.rootMenu.blurChildren(),e.focusChild(o)}),{passive:!0}),n.isSubmenuItem&&n.elements.toggle.dom.toggle.addEventListener("pointerup",(function(o){e.currentEvent="mouse",t(e,n.elements.toggle,o)}))})),this.isTopLevel&&this.elements.controller&&this.elements.controller.dom.toggle.addEventListener("pointerup",(function(n){e.currentEvent="mouse",t(e,e.elements.controller,n)}))}},{key:"_handleHover",value:function(){var e=this;this.elements.menuItems.forEach((function(t,n){t.dom.link.addEventListener("mouseenter",(function(){if("on"===e.hoverType)e.currentEvent="mouse",e.currentChild=n,t.isSubmenuItem&&t.elements.toggle.preview();else if("dynamic"===e.hoverType){var o=e.elements.submenuToggles.some((function(e){return e.isOpen}));e.currentChild=n,e.isTopLevel&&"none"===e.focusState||(e.currentEvent="mouse",e.focusCurrentChild()),!t.isSubmenuItem||e.isTopLevel&&!o||(e.currentEvent="mouse",t.elements.toggle.preview())}})),t.isSubmenuItem&&t.dom.item.addEventListener("mouseleave",(function(){"on"===e.hoverType?e.hoverDelay>0?setTimeout((function(){e.currentEvent="mouse",t.elements.toggle.close()}),e.hoverDelay):(e.currentEvent="mouse",t.elements.toggle.close()):"dynamic"===e.hoverType&&(e.isTopLevel||(e.hoverDelay>0?setTimeout((function(){e.currentEvent="mouse",t.elements.toggle.close(),e.focusCurrentChild()}),e.hoverDelay):(e.currentEvent="mouse",t.elements.toggle.close(),e.focusCurrentChild())))}))}))}},{key:"_handleKeydown",value:function(){var e=this;this.isTopLevel&&this.elements.controller&&this.elements.controller.dom.toggle.addEventListener("keydown",(function(t){e.currentEvent="keyboard";var n=_(t);"Space"!==n&&"Enter"!==n||E(t)}))}},{key:"_handleKeyup",value:function(){var e=this;this.isTopLevel&&this.elements.controller&&this.elements.controller.dom.toggle.addEventListener("keyup",(function(t){e.currentEvent="keyboard";var n=_(t);"Space"!==n&&"Enter"!==n||(E(t),e.elements.controller.open(),e.focusFirstChild())}))}},{key:"focus",value:function(){this.focusState="self",this.shouldFocus&&this.dom.menu.focus()}},{key:"blur",value:function(){this.focusState="none",this.shouldFocus&&this.dom.menu.blur()}},{key:"focusCurrentChild",value:function(){this.focusState="self",-1!==this.currentChild&&this.currentMenuItem.focus()}},{key:"focusChild",value:function(e){this.blurCurrentChild(),this.currentChild=e,this.focusCurrentChild()}},{key:"focusFirstChild",value:function(){this.focusChild(0)}},{key:"focusLastChild",value:function(){this.focusChild(this.elements.menuItems.length-1)}},{key:"focusNextChild",value:function(){this.currentChild<this.elements.menuItems.length-1?this.focusChild(this.currentChild+1):this.focusCurrentChild()}},{key:"focusPreviousChild",value:function(){this.currentChild>0?this.focusChild(this.currentChild-1):this.focusCurrentChild()}},{key:"blurCurrentChild",value:function(){this.focusState="none",-1!==this.currentChild&&this.currentMenuItem.blur()}},{key:"focusController",value:function(){this.dom.controller&&(this.shouldFocus&&this.dom.controller.focus(),this.focusState="none")}},{key:"focusContainer",value:function(){this.dom.container&&(this.shouldFocus&&this.dom.container.focus(),this.focusState="none")}},{key:"closeChildren",value:function(){this.elements.submenuToggles.forEach((function(e){return e.close()}))}},{key:"blurChildren",value:function(){this.elements.menuItems.forEach((function(e){e.blur(),e.isSubmenuItem&&e.elements.childMenu.blurChildren()}))}}]),n}(),I=function(e){r(s,e);var n=m(s);function s(e){var o,r=e.menuItemElement,i=e.menuLinkElement,l=e.parentMenu,u=e.isSubmenuItem,c=void 0!==u&&u,m=e.childMenu,a=void 0===m?null:m,h=e.toggle,d=void 0===h?null:h,f=e.initialize,v=void 0===f||f;return t(this,s),o=n.call(this,{menuItemElement:r,menuLinkElement:i,parentMenu:l,isSubmenuItem:c,childMenu:a,toggle:d}),v&&o.initialize(),o}return o(s,[{key:"initialize",value:function(){a(i(s.prototype),"initialize",this).call(this),this.dom.item.setAttribute("role","none"),this.dom.link.setAttribute("role","menuitem"),this.dom.link.tabIndex=-1}},{key:"focus",value:function(){a(i(s.prototype),"focus",this).call(this),this.elements.parentMenu.isTopLevel&&(this.dom.link.tabIndex=0)}},{key:"blur",value:function(){a(i(s.prototype),"blur",this).call(this),this.elements.parentMenu.isTopLevel&&(this.dom.link.tabIndex=-1)}}]),s}(M),T=function(e){r(s,e);var n=m(s);function s(e){var o,r=e.menuToggleElement,i=e.parentElement,l=e.controlledMenu,u=e.parentMenu,c=void 0===u?null:u,m=e.initialize,a=void 0===m||m;return t(this,s),o=n.call(this,{menuToggleElement:r,parentElement:i,controlledMenu:l,parentMenu:c}),a&&o.initialize(),o}return o(s,[{key:"open",value:function(){this.closeSiblings(),a(i(s.prototype),"open",this).call(this)}},{key:"preview",value:function(){this.closeSiblings(),a(i(s.prototype),"preview",this).call(this)}},{key:"close",value:function(){this.isOpen&&this.closeChildren(),a(i(s.prototype),"close",this).call(this)}}]),s}(b);return function(e){r(l,e);var n=m(l);function l(e){var o,r=e.menuElement,i=e.menuItemSelector,c=void 0===i?"li":i,m=e.menuLinkSelector,a=void 0===m?"a":m,h=e.submenuItemSelector,d=void 0===h?"":h,f=e.submenuToggleSelector,v=void 0===f?"a":f,p=e.submenuSelector,g=void 0===p?"ul":p,y=e.controllerElement,b=void 0===y?null:y,M=e.containerElement,_=void 0===M?null:M,E=e.openClass,C=void 0===E?"show":E,k=e.closeClass,w=void 0===k?"hide":k,S=e.isTopLevel,A=void 0===S||S,L=e.parentMenu,O=void 0===L?null:L,D=e.hoverType,j=void 0===D?"off":D,x=e.hoverDelay,F=void 0===x?250:x,R=e.initialize,z=void 0===R||R;return t(this,l),s(u(o=n.call(this,{menuElement:r,menuItemSelector:c,menuLinkSelector:a,submenuItemSelector:d,submenuToggleSelector:v,submenuSelector:g,controllerElement:b,containerElement:_,openClass:C,closeClass:w,isTopLevel:A,parentMenu:O,hoverType:j,hoverDelay:F})),"_MenuType",l),s(u(o),"_MenuItemType",I),s(u(o),"_MenuToggleType",T),z&&o.initialize(),o}return o(l,[{key:"initialize",value:function(){try{a(i(l.prototype),"initialize",this).call(this),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)}}},{key:"_handleClick",value:function(){var e=this;a(i(l.prototype),"_handleClick",this).call(this),document.addEventListener("pointerup",(function(t){"none"!==e.focusState&&(e.currentEvent="mouse",e.dom.menu.contains(t.target)||!e.dom.menu===t.target||(e.closeChildren(),e.blur(),e.elements.controller&&e.elements.controller.close()))}))}},{key:"_handleKeydown",value:function(){var e=this;a(i(l.prototype),"_handleKeydown",this).call(this),this.dom.menu.addEventListener("keydown",(function(t){e.currentEvent="keyboard";var n=_(t);if("Tab"===n&&("none"!==e.elements.rootMenu.focusState?(e.elements.rootMenu.blur(),e.elements.rootMenu.closeChildren()):e.elements.rootMenu.focus()),"Character"===n)E(t);else if(e.isTopLevel){if("self"===e.focusState){(["ArrowRight","ArrowLeft","Home","End"].includes(n)||e.currentMenuItem.isSubmenuItem&&["Space","Enter","ArrowDown","ArrowUp"].includes(n)||e.elements.controller&&["Escape"].includes(n))&&E(t)}}else{(["Escape","ArrowRight","ArrowLeft","ArrowDown","ArrowUp","Home","End"].includes(n)||e.currentMenuItem.isSubmenuItem&&["Space","Enter"].includes(n))&&E(t)}}))}},{key:"_handleKeyup",value:function(){var e=this;a(i(l.prototype),"_handleKeyup",this).call(this),this.dom.menu.addEventListener("keyup",(function(t){e.currentEvent="keyboard";var n=_(t),o=t.altKey,s=t.crtlKey,r=t.metaKey;if("Character"!==n||(o||s||r))if(e.isTopLevel){if("self"===e.focusState)if("Space"===n||"Enter"===n)e.currentMenuItem.isSubmenuItem?(E(t),e.currentMenuItem.elements.childMenu.currentEvent="keyboard",e.currentMenuItem.elements.toggle.open(),requestAnimationFrame((function(){e.currentMenuItem.elements.childMenu.focusFirstChild()}))):e.currentMenuItem.dom.link.click();else if("ArrowRight"===n){E(t);var i=e.currentMenuItem.isSubmenuItem&&e.currentMenuItem.elements.toggle.isOpen;e.focusNextChild(),i&&(e.currentMenuItem.isSubmenuItem?(e.currentMenuItem.elements.childMenu.currentEvent="keyboard",e.currentMenuItem.elements.toggle.preview()):e.closeChildren())}else if("ArrowLeft"===n){E(t);var l=e.currentMenuItem.isSubmenuItem&&e.currentMenuItem.elements.toggle.isOpen;e.focusPreviousChild(),l&&(e.currentMenuItem.isSubmenuItem?(e.currentMenuItem.elements.childMenu.currentEvent="keyboard",e.currentMenuItem.elements.toggle.preview()):e.closeChildren())}else if("ArrowDown"===n)e.currentMenuItem.isSubmenuItem&&(E(t),e.currentMenuItem.elements.childMenu.currentEvent="keyboard",e.currentMenuItem.elements.toggle.open(),requestAnimationFrame((function(){e.currentMenuItem.elements.childMenu.focusFirstChild()})));else if("ArrowUp"===n)e.currentMenuItem.isSubmenuItem&&(E(t),e.currentMenuItem.elements.childMenu.currentEvent="keyboard",e.currentMenuItem.elements.toggle.open(),requestAnimationFrame((function(){e.currentMenuItem.elements.childMenu.focusLastChild()})));else if("Home"===n)E(t),e.focusFirstChild();else if("End"===n)E(t),e.focusLastChild();else if("Escape"===n){e.elements.submenuToggles.some((function(e){return e.isOpen}))?(E(t),e.closeChildren()):e.isTopLevel&&e.elements.controller&&e.elements.controller.isOpen&&(E(t),e.elements.controller.close(),e.focusController())}}else"Space"===n||"Enter"===n?e.currentMenuItem.isSubmenuItem&&(E(t),e.currentMenuItem.elements.childMenu.currentEvent="keyboard",e.currentMenuItem.elements.toggle.open(),requestAnimationFrame((function(){e.currentMenuItem.elements.childMenu.focusFirstChild()}))):"Escape"===n?(E(t),e.elements.rootMenu.closeChildren(),e.elements.rootMenu.focusCurrentChild()):"ArrowRight"===n?e.currentMenuItem.isSubmenuItem?(E(t),e.currentMenuItem.elements.childMenu.currentEvent="keyboard",e.currentMenuItem.elements.toggle.open(),requestAnimationFrame((function(){e.currentMenuItem.elements.childMenu.focusFirstChild()}))):(E(t),e.elements.rootMenu.closeChildren(),e.elements.rootMenu.focusNextChild(),e.elements.rootMenu.currentMenuItem.isSubmenuItem&&e.elements.rootMenu.currentMenuItem.elements.toggle.preview()):"ArrowLeft"===n?e.elements.parentMenu.currentMenuItem.isSubmenuItem&&(E(t),e.elements.parentMenu.currentMenuItem.elements.toggle.close(),e.elements.parentMenu.focusCurrentChild(),e.elements.parentMenu===e.elements.rootMenu&&(e.elements.rootMenu.closeChildren(),e.elements.rootMenu.focusPreviousChild(),e.elements.rootMenu.currentMenuItem.isSubmenuItem&&(e.elements.rootMenu.currentMenuItem.elements.childMenu.currentEvent="keyboard",e.elements.rootMenu.currentMenuItem.elements.toggle.preview()))):"ArrowDown"===n?(E(t),e.focusNextChild()):"ArrowUp"===n?(E(t),e.focusPreviousChild()):"Home"===n?(E(t),e.focusFirstChild()):"End"===n&&(E(t),e.focusLastChild());else E(t),e.elements.rootMenu.currentEvent="character",e.focusNextChildWithCharacter(t.key)}))}},{key:"focusNextChild",value:function(){this.currentChild===this.elements.menuItems.length-1?this.focusFirstChild():this.focusChild(this.currentChild+1)}},{key:"focusPreviousChild",value:function(){0===this.currentChild?this.focusLastChild():this.focusChild(this.currentChild-1)}},{key:"focusNextChildWithCharacter",value:function(e){for(var t=e.toLowerCase(),n=this.currentChild+1,o=!1;!o&&n<this.elements.menuItems.length;){(this.elements.menuItems[n].dom.item.innerText?this.elements.menuItems[n].dom.item.innerText:this.elements.menuItems[n].dom.item.textContent).replace(/[\s]/g,"").toLowerCase().charAt(0)===t&&(o=!0,this.focusChild(n)),n++}}}]),l}(C)}();
//# sourceMappingURL=menubar.min.js.map

@@ -109,2 +109,4 @@ function _typeof(obj) {

return call;
} else if (call !== void 0) {
throw new TypeError("Derived constructors may only return object or undefined");
}

@@ -356,14 +358,2 @@

}
function isEventSupported(event, element) {
if (isValidType("string", {
event: event
}) && isValidInstance(HTMLElement, {
element: element
})) {
var eventProp = "on".concat(event);
return typeof element[eventProp] !== "undefined";
} else {
return false;
}
}

@@ -1134,4 +1124,2 @@ var BaseMenuToggle = function () {

var _this4 = this;
var startEventType = isEventSupported("touchstart", this.dom.menu) ? "touchstart" : "mousedown";
var endEventType = isEventSupported("touchend", this.dom.menu) ? "touchend" : "mouseup";
function toggleToggle(menu, toggle, event) {

@@ -1146,19 +1134,21 @@ preventEvent(event);

this.elements.menuItems.forEach(function (item, index) {
item.dom.link.addEventListener(startEventType, function () {
item.dom.link.addEventListener("pointerdown", function () {
_this4.currentEvent = "mouse";
_this4.elements.rootMenu.blurChildren();
_this4.focusChild(index);
}, {
passive: true
});
if (item.isSubmenuItem) {
item.elements.toggle.dom.toggle["on".concat(endEventType)] = function (event) {
item.elements.toggle.dom.toggle.addEventListener("pointerup", function (event) {
_this4.currentEvent = "mouse";
toggleToggle(_this4, item.elements.toggle, event);
};
});
}
});
if (this.isTopLevel && this.elements.controller) {
this.elements.controller.dom.toggle["on".concat(endEventType)] = function (event) {
this.elements.controller.dom.toggle.addEventListener("pointerup", function (event) {
_this4.currentEvent = "mouse";
toggleToggle(_this4, _this4.elements.controller, event);
};
});
}

@@ -1165,0 +1155,0 @@ }

@@ -1,2 +0,2 @@

function e(t){return(e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(t)}function t(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function n(e,t){for(var n=0;n<t.length;n++){var o=t[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}function o(e,t,o){return t&&n(e.prototype,t),o&&n(e,o),e}function s(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function r(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&u(e,t)}function l(e){return(l=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function u(e,t){return(u=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function i(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function c(e,t){return!t||"object"!=typeof t&&"function"!=typeof t?i(e):t}function m(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,o=l(e);if(t){var s=l(this).constructor;n=Reflect.construct(o,arguments,s)}else n=o.apply(this,arguments);return c(this,n)}}function a(e,t,n){return(a="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(e,t,n){var o=function(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&null!==(e=l(e)););return e}(e,t);if(o){var s=Object.getOwnPropertyDescriptor(o,t);return s.get?s.get.call(n):s.value}})(e,t,n||e)}function h(e){return function(e){if(Array.isArray(e))return d(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,t){if(!e)return;if("string"==typeof e)return d(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return d(e,t)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function d(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,o=new Array(t);n<t;n++)o[n]=e[n];return o}function f(t,n){try{if("object"!==e(n)){var o=e(n);throw new TypeError("AccessibleMenu: Elements given to isValidInstance() must be inside of an object. ".concat(o," given."))}for(var s in n)if(!(n[s]instanceof t)){var r=e(n[s]);throw new TypeError("AccessibleMenu: ".concat(s," must be an instance of ").concat(t.name,". ").concat(r," given."))}return!0}catch(e){return console.error(e),!1}}function v(t,n){try{if("object"!==e(n)){var o=e(n);throw new TypeError("AccessibleMenu: Values given to isValidType() must be inside of an object. ".concat(o," given."))}for(var s in n){var r=e(n[s]);if(r!==t)throw new TypeError("AccessibleMenu: ".concat(s," must be a ").concat(t,". ").concat(r," given."))}return!0}catch(e){return console.error(e),!1}}function p(t){try{if("object"!==e(t)){var n=e(t);throw new TypeError("AccessibleMenu: Values given to isCSSSelector() must be inside of an object. ".concat(n," given."))}for(var o in t)try{if(null===t[o])throw new Error;document.querySelector(t[o])}catch(e){throw new TypeError("AccessibleMenu: ".concat(o,' must be a valid CSS selector. "').concat(t[o],'" given.'))}return!0}catch(e){return console.error(e),!1}}function g(t){try{if("object"!==e(t)||Array.isArray(t)){var n=e(t);throw new TypeError("AccessibleMenu: Values given to isValidClassList() must be inside of an object. ".concat(n," given."))}var o=function(n){var o=e(t[n]);if("string"!==o){if(!Array.isArray(t[n]))throw new TypeError("AccessibleMenu: ".concat(n," must be a string or an array of strings. ").concat(o," given."));t[n].forEach((function(e){if("string"!=typeof e)throw new TypeError("AccessibleMenu: ".concat(n," must be a string or an array of strings. An array containing non-strings given."))}))}else{var s={};s[n]=t[n],p(s)}};for(var s in t)o(s);return!0}catch(e){return console.error(e),!1}}function y(t){try{if("object"!==e(t)){var n=e(t);throw new TypeError("AccessibleMenu: Values given to isValidHoverType() must be inside of an object. ".concat(n," given."))}var o=["off","on","dynamic"];for(var s in t)if(!o.includes(t[s]))throw new TypeError("AccessibleMenu: ".concat(s," must be one of the following values: ").concat(o.join(", "),'. "').concat(t[s],'" given.'));return!0}catch(e){return console.error(e),!1}}function b(e,t){return!(!v("string",{event:e})||!f(HTMLElement,{element:t}))&&void 0!==t["on".concat(e)]}var M=function(){function e(n){var o=n.menuToggleElement,r=n.parentElement,l=n.controlledMenu,u=n.parentMenu,i=void 0===u?null:u;t(this,e),s(this,"_dom",{toggle:null,parent:null}),s(this,"_elements",{controlledMenu:null,parentMenu:null}),s(this,"_open",!1),s(this,"_expandEvent",new CustomEvent("accessibleMenuExpand",{bubbles:!0,detail:{toggle:this}})),s(this,"_collapseEvent",new CustomEvent("accessibleMenuCollapse",{bubbles:!0,detail:{toggle:this}})),this._dom.toggle=o,this._dom.parent=r,this._elements.controlledMenu=l,this._elements.parentMenu=i}return o(e,[{key:"initialize",value:function(){if(this.dom.toggle.setAttribute("aria-haspopup","true"),this.dom.toggle.setAttribute("aria-expanded","false"),function(e,t){if(v("string",{tagName:e})&&f(HTMLElement,t)){var n=e.toLowerCase(),o=!0;for(var s in t)t[s].tagName.toLowerCase()!==n&&(o=!1);return o}return!1}("button",{toggle:this.dom.toggle})||this.dom.toggle.setAttribute("role","button"),""===this.dom.toggle.id||""===this.elements.controlledMenu.dom.menu.id){var e=Math.random().toString(36).replace(/[^a-z]+/g,"").substr(0,10),t=this.dom.toggle.innerText.replace(/[^a-zA-Z0-9\s]/g,""),n=e;!t.replace(/\s/g,"").length&&this.dom.toggle.getAttribute("aria-label")&&(t=this.dom.toggle.getAttribute("aria-label").replace(/[^a-zA-Z0-9\s]/g,"")),t.replace(/\s/g,"").length>0&&((t=t.toLowerCase().replace(/\s+/g,"-")).startsWith("-")&&(t=t.substring(1)),t.endsWith("-")&&(t=t.slice(0,-1)),n="".concat(t,"-").concat(n)),this.dom.toggle.id=this.dom.toggle.id||"".concat(n,"-menu-button"),this.elements.controlledMenu.dom.menu.id=this.elements.controlledMenu.dom.menu.id||"".concat(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)}},{key:"dom",get:function(){return this._dom}},{key:"elements",get:function(){return this._elements}},{key:"isOpen",get:function(){return this._open},set:function(e){v("boolean",{value:e}),this._open=e}},{key:"_expand",value:function(){var e,t,n=!(arguments.length>0&&void 0!==arguments[0])||arguments[0],o=this.elements.controlledMenu,s=o.closeClass,r=o.openClass;(this.dom.toggle.setAttribute("aria-expanded","true"),""!==r)&&("string"==typeof r?this.elements.controlledMenu.dom.menu.classList.add(r):(e=this.elements.controlledMenu.dom.menu.classList).add.apply(e,h(r)));""!==s&&("string"==typeof s?this.elements.controlledMenu.dom.menu.classList.remove(s):(t=this.elements.controlledMenu.dom.menu.classList).remove.apply(t,h(s)));n&&this.dom.toggle.dispatchEvent(this._expandEvent)}},{key:"_collapse",value:function(){var e,t,n=!(arguments.length>0&&void 0!==arguments[0])||arguments[0],o=this.elements.controlledMenu,s=o.closeClass,r=o.openClass;(this.dom.toggle.setAttribute("aria-expanded","false"),""!==s)&&("string"==typeof s?this.elements.controlledMenu.dom.menu.classList.add(s):(e=this.elements.controlledMenu.dom.menu.classList).add.apply(e,h(s)));""!==r&&("string"==typeof r?this.elements.controlledMenu.dom.menu.classList.remove(r):(t=this.elements.controlledMenu.dom.menu.classList).remove.apply(t,h(r)));n&&this.dom.toggle.dispatchEvent(this._collapseEvent)}},{key:"open",value:function(){this.elements.controlledMenu.focusState="self",this._expand(),this.isOpen=!0}},{key:"preview",value:function(){this.elements.parentMenu&&(this.elements.parentMenu.focusState="self"),this._expand(),this.isOpen=!0}},{key:"close",value:function(){this.isOpen&&(this.elements.controlledMenu.currentChild=0,this.elements.controlledMenu.blur(),this.elements.parentMenu&&(this.elements.parentMenu.focusState="self"),this._collapse(),this.isOpen=!1)}},{key:"toggle",value:function(){this.isOpen?this.close():this.open()}},{key:"closeSiblings",value:function(){var e=this;this.elements.parentMenu&&this.elements.parentMenu.elements.submenuToggles.forEach((function(t){t!==e&&t.close()}))}},{key:"closeChildren",value:function(){this.elements.controlledMenu.elements.submenuToggles.forEach((function(e){return e.close()}))}}]),e}(),_=function(){function e(n){var o=n.menuItemElement,r=n.menuLinkElement,l=n.parentMenu,u=n.isSubmenuItem,i=void 0!==u&&u,c=n.childMenu,m=void 0===c?null:c,a=n.toggle,h=void 0===a?null:a;t(this,e),s(this,"_dom",{item:null,link:null}),s(this,"_elements",{parentMenu:null,childMenu:null,toggle:null}),s(this,"_submenu",!1),this._dom.item=o,this._dom.link=r,this._elements.parentMenu=l,this._elements.childMenu=m,this._elements.toggle=h,this._submenu=i}return o(e,[{key:"initialize",value:function(){}},{key:"dom",get:function(){return this._dom}},{key:"elements",get:function(){return this._elements}},{key:"isSubmenuItem",get:function(){return this._submenu}},{key:"focus",value:function(){this.elements.parentMenu.shouldFocus&&this.dom.link.focus()}},{key:"blur",value:function(){this.elements.parentMenu.shouldFocus&&this.dom.link.blur()}}]),e}();function E(e){try{var t=e.key||e.keyCode,n={Enter:"Enter"===t||13===t,Space:" "===t||"Spacebar"===t||32===t,Escape:"Escape"===t||"Esc"===t||27===t,ArrowUp:"ArrowUp"===t||"Up"===t||38===t,ArrowRight:"ArrowRight"===t||"Right"===t||39===t,ArrowDown:"ArrowDown"===t||"Down"===t||40===t,ArrowLeft:"ArrowLeft"===t||"Left"===t||37===t,Home:"Home"===t||36===t,End:"End"===t||35===t,Character:isNaN(t)&&!!t.match(/^[a-zA-Z]{1}$/),Tab:"Tab"===t||9===t,Asterisk:"*"===t||56===t};return Object.keys(n).find((function(e){return!0===n[e]}))||""}catch(e){return""}}function C(e){e.preventDefault(),e.stopPropagation()}var T=function(){function n(e){var o=e.menuElement,r=e.menuItemSelector,l=void 0===r?"li":r,u=e.menuLinkSelector,i=void 0===u?"a":u,c=e.submenuItemSelector,m=void 0===c?"":c,a=e.submenuToggleSelector,h=void 0===a?"a":a,d=e.submenuSelector,f=void 0===d?"ul":d,v=e.controllerElement,p=void 0===v?null:v,g=e.containerElement,y=void 0===g?null:g,b=e.openClass,E=void 0===b?"show":b,C=e.closeClass,T=void 0===C?"hide":C,I=e.isTopLevel,k=void 0===I||I,w=e.parentMenu,S=void 0===w?null:w,L=e.hoverType,A=void 0===L?"off":L,O=e.hoverDelay,D=void 0===O?250:O;t(this,n),s(this,"_MenuType",n),s(this,"_MenuItemType",_),s(this,"_MenuToggleType",M),s(this,"_dom",{menu:null,menuItems:[],submenuItems:[],submenuToggles:[],submenus:[],controller:null,container:null}),s(this,"_selectors",{menuItems:"",menuLinks:"",submenuItems:"",submenuToggles:"",submenus:""}),s(this,"_elements",{menuItems:[],submenuToggles:[],controller:null,parentMenu:null,rootMenu:null}),s(this,"_openClass","show"),s(this,"_closeClass","hide"),s(this,"_root",!0),s(this,"_currentChild",0),s(this,"_focusState","none"),s(this,"_currentEvent","none"),s(this,"_hoverType","off"),s(this,"_hoverDelay",250),this._dom.menu=o,this._dom.controller=p,this._dom.container=y,this._selectors.menuItems=l,this._selectors.menuLinks=i,this._selectors.submenuItems=m,this._selectors.submenuToggles=h,this._selectors.submenus=f,this._elements.menuItems=[],this._elements.submenuToggles=[],this._elements.controller=null,this._elements.parentMenu=S,this._elements.rootMenu=k?this:null,this._openClass=E||"",this._closeClass=T||"",this._root=k,this._hoverType=A,this._hoverDelay=D}return o(n,[{key:"initialize",value:function(){if(!this._validate())throw new Error("AccesibleMenu: cannot initialize menu. See other error messages for more information.");if(null===this.elements.rootMenu&&this._findRootMenu(this),this._setDOMElements(),this.isTopLevel&&this.dom.controller&&this.dom.container){var e=new this._MenuToggleType({menuToggleElement:this.dom.controller,parentElement:this.dom.container,controlledMenu:this});this._elements.controller=e}this._createChildElements()}},{key:"dom",get:function(){return this._dom}},{key:"selectors",get:function(){return this._selectors}},{key:"elements",get:function(){return this._elements}},{key:"isTopLevel",get:function(){return this._root}},{key:"openClass",get:function(){return this.isTopLevel?this._openClass:this.elements.rootMenu.openClass},set:function(e){g({openClass:e}),this._openClass!==e&&(this._openClass=e)}},{key:"closeClass",get:function(){return this.isTopLevel?this._closeClass:this.elements.rootMenu.closeClass},set:function(e){g({closeClass:e}),this._closeClass!==e&&(this._closeClass=e)}},{key:"currentChild",get:function(){return this._currentChild},set:function(e){function t(e){if(["mouse","character"].includes(e.currentEvent)&&e.elements.parentMenu)for(var t=0,n=!1;!n&&t<e.elements.parentMenu.elements.menuItems.length;){var o=e.elements.parentMenu.elements.menuItems[t];o.isSubmenuItem&&o.elements.toggle.elements.controlledMenu===e&&(n=!0,e.elements.parentMenu.currentEvent=e.currentEvent,e.elements.parentMenu.currentChild=t),t++}}v("number",{value:e}),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))}},{key:"focusState",get:function(){return this._focusState},set:function(t){!function(t){try{if("object"!==e(t)){var n=e(t);throw new TypeError("AccessibleMenu: Values given to isValidState() must be inside of an object. ".concat(n," given."))}var o=["none","self","child"];for(var s in t)if(!o.includes(t[s]))throw new TypeError("AccessibleMenu: ".concat(s," must be one of the following values: ").concat(o.join(", "),'. "').concat(t[s],'" given.'))}catch(e){return console.error(e),!1}}({value:t}),this._focusState!==t&&(this._focusState=t),this.elements.submenuToggles.length>0&&("self"===t||"none"===t)&&this.elements.submenuToggles.forEach((function(e){e.elements.controlledMenu.focusState="none"})),!this.elements.parentMenu||"self"!==t&&"child"!==t||(this.elements.parentMenu.focusState="child")}},{key:"currentEvent",get:function(){return this._currentEvent},set:function(t){!function(t){try{if("object"!==e(t)){var n=e(t);throw new TypeError("AccessibleMenu: Values given to isValidEvent() must be inside of an object. ".concat(n," given."))}var o=["none","mouse","keyboard","character"];for(var s in t)if(!o.includes(t[s]))throw new TypeError("AccessibleMenu: ".concat(s," must be one of the following values: ").concat(o.join(", "),'. "').concat(t[s],'" given.'))}catch(e){return console.error(e),!1}}({value:t}),this._currentEvent!==t&&(this._currentEvent=t,this.elements.submenuToggles.length>0&&this.elements.submenuToggles.forEach((function(e){e.elements.controlledMenu.currentEvent=t})))}},{key:"currentMenuItem",get:function(){return this.elements.menuItems[this.currentChild]}},{key:"hoverType",get:function(){return this._root?this._hoverType:this.elements.rootMenu.hoverType},set:function(e){y({value:e}),this._hoverType!==e&&(this._hoverType=e)}},{key:"hoverDelay",get:function(){return this._root?this._hoverDelay:this.elements.rootMenu.hoverDelay},set:function(e){v("number",{value:e}),this._hoverDelay!==e&&(this._hoverDelay=e)}},{key:"shouldFocus",get:function(){var e=!1;return"keyboard"!==this.currentEvent&&"character"!==this.currentEvent||(e=!0),"mouse"===this.currentEvent&&"dynamic"===this.hoverType&&(e=!0),e}},{key:"_validate",value:function(){var e=!0;return null!==this._dom.container||null!==this._dom.controller?f(HTMLElement,{menuElement:this._dom.menu,controllerElement:this._dom.controller,containerElement:this._dom.container})||(e=!1):f(HTMLElement,{menuElement:this._dom.menu})||(e=!1),""!==this._selectors.submenuItems?p({menuItemSelector:this._selectors.menuItems,menuLinkSelector:this._selectors.menuLinks,submenuItemSelector:this._selectors.submenuItems,submenuToggleSelector:this._selectors.submenuToggles,submenuSelector:this._selectors.submenus})||(e=!1):p({menuItemSelector:this._selectors.menuItems,menuLinkSelector:this._selectors.menuLinks})||(e=!1),""===this._openClass||g({openClass:this._openClass})||(e=!1),""===this._closeClass||g({closeClass:this._closeClass})||(e=!1),v("boolean",{isTopLevel:this._root})||(e=!1),null===this._elements.parentMenu||f(n,{parentMenu:this._elements.parentMenu})||(e=!1),y({hoverType:this._hoverType})||(e=!1),v("number",{hoverDelay:this._hoverDelay})||(e=!1),e}},{key:"_setDOMElementType",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.dom.menu,n=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];if("string"!=typeof this.selectors[e])throw new Error('AccessibleMenu: "'.concat(e,'" is not a valid element type within the menu.'));if(!Array.isArray(this.dom[e]))throw new Error('AccessibleMenu: The "'.concat(e,'" element cannot be set through _setDOMElementType.'));t!==this.dom.menu&&f(HTMLElement,{base:t});var o=Array.from(t.querySelectorAll(this.selectors[e])),s=o.filter((function(e){return e.parentElement===t}));this._dom[e]=n?s:[].concat(h(this._dom[e]),h(s))}},{key:"_resetDOMElementType",value:function(e){if(void 0===this.dom[e])throw new Error('AccessibleMenu: "'.concat(e,'" is not a valid element type within the menu.'));if(!Array.isArray(this.dom[e]))throw new Error('AccessibleMenu: The "'.concat(e,'" element cannot be reset through _resetDOMElementType.'));this._dom[e]=[]}},{key:"_setDOMElements",value:function(){var e=this;this._setDOMElementType("menuItems"),""!==this.selectors.submenuItems&&(this._setDOMElementType("submenuItems"),this._resetDOMElementType("submenuToggles"),this._resetDOMElementType("submenus"),this.dom.submenuItems.forEach((function(t){e._setDOMElementType("submenuToggles",t,!1),e._setDOMElementType("submenus",t,!1)})))}},{key:"_findRootMenu",value:function(e){if(e.isTopLevel)this._elements.rootMenu=e;else{if(null===e.elements.parentMenu)throw new Error("Cannot find root menu.");this._findRootMenu(e.elements.parentMenu)}}},{key:"_createChildElements",value:function(){var e=this;this.dom.menuItems.forEach((function(t){var n;if(e.dom.submenuItems.includes(t)){var o=t.querySelector(e.selectors.submenuToggles),s=t.querySelector(e.selectors.submenus),r=new e._MenuType({menuElement:s,menuItemSelector:e.selectors.menuItems,menuLinkSelector:e.selectors.menuLinks,submenuItemSelector:e.selectors.submenuItems,submenuToggleSelector:e.selectors.submenuToggles,submenuSelector:e.selectors.submenus,openClass:e.openClass,closeClass:e.closeClass,isTopLevel:!1,parentMenu:e,hoverType:e.hoverType,hoverDelay:e.hoverDelay}),l=new e._MenuToggleType({menuToggleElement:o,parentElement:t,controlledMenu:r,parentMenu:e});e._elements.submenuToggles.push(l),n=new e._MenuItemType({menuItemElement:t,menuLinkElement:o,parentMenu:e,isSubmenuItem:!0,childMenu:r,toggle:l})}else{var u=t.querySelector(e.selectors.menuLinks);n=new e._MenuItemType({menuItemElement:t,menuLinkElement:u,parentMenu:e})}e._elements.menuItems.push(n)}))}},{key:"_handleFocus",value:function(){var e=this;this.elements.menuItems.forEach((function(t,n){t.dom.link.addEventListener("focus",(function(){e.focusState="self",e.currentChild=n}))}))}},{key:"_handleClick",value:function(){var e=this,t=b("touchstart",this.dom.menu)?"touchstart":"mousedown",n=b("touchend",this.dom.menu)?"touchend":"mouseup";function o(e,t,n){C(n),t.toggle(),t.isOpen&&(e.focusState="self",t.elements.controlledMenu.focusState="none")}this.elements.menuItems.forEach((function(s,r){s.dom.link.addEventListener(t,(function(){e.currentEvent="mouse",e.elements.rootMenu.blurChildren(),e.focusChild(r)})),s.isSubmenuItem&&(s.elements.toggle.dom.toggle["on".concat(n)]=function(t){e.currentEvent="mouse",o(e,s.elements.toggle,t)})})),this.isTopLevel&&this.elements.controller&&(this.elements.controller.dom.toggle["on".concat(n)]=function(t){e.currentEvent="mouse",o(e,e.elements.controller,t)})}},{key:"_handleHover",value:function(){var e=this;this.elements.menuItems.forEach((function(t,n){t.dom.link.addEventListener("mouseenter",(function(){if("on"===e.hoverType)e.currentEvent="mouse",e.currentChild=n,t.isSubmenuItem&&t.elements.toggle.preview();else if("dynamic"===e.hoverType){var o=e.elements.submenuToggles.some((function(e){return e.isOpen}));e.currentChild=n,e.isTopLevel&&"none"===e.focusState||(e.currentEvent="mouse",e.focusCurrentChild()),!t.isSubmenuItem||e.isTopLevel&&!o||(e.currentEvent="mouse",t.elements.toggle.preview())}})),t.isSubmenuItem&&t.dom.item.addEventListener("mouseleave",(function(){"on"===e.hoverType?e.hoverDelay>0?setTimeout((function(){e.currentEvent="mouse",t.elements.toggle.close()}),e.hoverDelay):(e.currentEvent="mouse",t.elements.toggle.close()):"dynamic"===e.hoverType&&(e.isTopLevel||(e.hoverDelay>0?setTimeout((function(){e.currentEvent="mouse",t.elements.toggle.close(),e.focusCurrentChild()}),e.hoverDelay):(e.currentEvent="mouse",t.elements.toggle.close(),e.focusCurrentChild())))}))}))}},{key:"_handleKeydown",value:function(){var e=this;this.isTopLevel&&this.elements.controller&&this.elements.controller.dom.toggle.addEventListener("keydown",(function(t){e.currentEvent="keyboard";var n=E(t);"Space"!==n&&"Enter"!==n||C(t)}))}},{key:"_handleKeyup",value:function(){var e=this;this.isTopLevel&&this.elements.controller&&this.elements.controller.dom.toggle.addEventListener("keyup",(function(t){e.currentEvent="keyboard";var n=E(t);"Space"!==n&&"Enter"!==n||(C(t),e.elements.controller.open(),e.focusFirstChild())}))}},{key:"focus",value:function(){this.focusState="self",this.shouldFocus&&this.dom.menu.focus()}},{key:"blur",value:function(){this.focusState="none",this.shouldFocus&&this.dom.menu.blur()}},{key:"focusCurrentChild",value:function(){this.focusState="self",-1!==this.currentChild&&this.currentMenuItem.focus()}},{key:"focusChild",value:function(e){this.blurCurrentChild(),this.currentChild=e,this.focusCurrentChild()}},{key:"focusFirstChild",value:function(){this.focusChild(0)}},{key:"focusLastChild",value:function(){this.focusChild(this.elements.menuItems.length-1)}},{key:"focusNextChild",value:function(){this.currentChild<this.elements.menuItems.length-1?this.focusChild(this.currentChild+1):this.focusCurrentChild()}},{key:"focusPreviousChild",value:function(){this.currentChild>0?this.focusChild(this.currentChild-1):this.focusCurrentChild()}},{key:"blurCurrentChild",value:function(){this.focusState="none",-1!==this.currentChild&&this.currentMenuItem.blur()}},{key:"focusController",value:function(){this.dom.controller&&(this.shouldFocus&&this.dom.controller.focus(),this.focusState="none")}},{key:"focusContainer",value:function(){this.dom.container&&(this.shouldFocus&&this.dom.container.focus(),this.focusState="none")}},{key:"closeChildren",value:function(){this.elements.submenuToggles.forEach((function(e){return e.close()}))}},{key:"blurChildren",value:function(){this.elements.menuItems.forEach((function(e){e.blur(),e.isSubmenuItem&&e.elements.childMenu.blurChildren()}))}}]),n}(),I=function(e){r(s,_);var n=m(s);function s(e){var o,r=e.menuItemElement,l=e.menuLinkElement,u=e.parentMenu,i=e.isSubmenuItem,c=void 0!==i&&i,m=e.childMenu,a=void 0===m?null:m,h=e.toggle,d=void 0===h?null:h,f=e.initialize,v=void 0===f||f;return t(this,s),o=n.call(this,{menuItemElement:r,menuLinkElement:l,parentMenu:u,isSubmenuItem:c,childMenu:a,toggle:d}),v&&o.initialize(),o}return o(s,[{key:"initialize",value:function(){a(l(s.prototype),"initialize",this).call(this),this.dom.item.setAttribute("role","none"),this.dom.link.setAttribute("role","treeitem"),this.dom.link.tabIndex=-1}},{key:"focus",value:function(){a(l(s.prototype),"focus",this).call(this),this.dom.link.tabIndex=0}},{key:"blur",value:function(){a(l(s.prototype),"blur",this).call(this),this.dom.link.tabIndex=-1}}]),s}(),k=function(e){r(o,M);var n=m(o);function o(e){var s,r=e.menuToggleElement,l=e.parentElement,u=e.controlledMenu,i=e.parentMenu,c=void 0===i?null:i,m=e.initialize,a=void 0===m||m;return t(this,o),s=n.call(this,{menuToggleElement:r,parentElement:l,controlledMenu:u,parentMenu:c}),a&&s.initialize(),s}return o}(),w=function(e){r(u,T);var n=m(u);function u(e){var o,r=e.menuElement,l=e.menuItemSelector,c=void 0===l?"li":l,m=e.menuLinkSelector,a=void 0===m?"a":m,h=e.submenuItemSelector,d=void 0===h?"":h,f=e.submenuToggleSelector,v=void 0===f?"a":f,p=e.submenuSelector,g=void 0===p?"ul":p,y=e.controllerElement,b=void 0===y?null:y,M=e.containerElement,_=void 0===M?null:M,E=e.openClass,C=void 0===E?"show":E,T=e.closeClass,w=void 0===T?"hide":T,S=e.isTopLevel,L=void 0===S||S,A=e.parentMenu,O=void 0===A?null:A,D=e.hoverType,j=void 0===D?"off":D,x=e.hoverDelay,N=void 0===x?250:x,z=e.initialize,R=void 0===z||z;return t(this,u),s(i(o=n.call(this,{menuElement:r,menuItemSelector:c,menuLinkSelector:a,submenuItemSelector:d,submenuToggleSelector:v,submenuSelector:g,controllerElement:b,containerElement:_,openClass:C,closeClass:w,isTopLevel:L,parentMenu:O,hoverType:j,hoverDelay:N})),"_MenuType",u),s(i(o),"_MenuItemType",I),s(i(o),"_MenuToggleType",k),R&&o.initialize(),o}return o(u,[{key:"initialize",value:function(){try{a(l(u.prototype),"initialize",this).call(this),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)}}},{key:"_handleKeydown",value:function(){var e=this;a(l(u.prototype),"_handleKeydown",this).call(this),this.dom.menu.addEventListener("keydown",(function(t){e.currentEvent="keyboard";var n=E(t);if("Tab"===n&&("none"!==e.elements.rootMenu.focusState?e.elements.rootMenu.blur():e.elements.rootMenu.focus()),"self"===e.focusState){(["Space","ArrowUp","ArrowDown","ArrowLeft","Asterisk","Home","End"].includes(n)||e.currentMenuItem.isSubmenuItem&&["Enter","ArrowRight"].includes(n)||e.elements.controller&&["Escape"].includes(n))&&C(t)}}))}},{key:"_handleKeyup",value:function(){var e=this;a(l(u.prototype),"_handleKeyup",this).call(this),this.dom.menu.addEventListener("keyup",(function(t){e.currentEvent="keyboard";var n=E(t),o=t.altKey,s=t.crtlKey,r=t.metaKey;if("Character"!==n||(o||s||r)){if("self"===e.focusState)if("Enter"===n||"Space"===n)C(t),e.currentMenuItem.isSubmenuItem?e.currentMenuItem.elements.toggle.isOpen?e.currentMenuItem.elements.toggle.close():e.currentMenuItem.elements.toggle.preview():e.currentMenuItem.dom.link.click();else if("Escape"===n)e.isTopLevel&&e.elements.controller&&e.elements.controller.isOpen&&(e.elements.controller.close(),e.focusController());else if("ArrowDown"===n)C(t),e.currentMenuItem.isSubmenuItem&&e.currentMenuItem.elements.toggle.isOpen?(e.blurCurrentChild(),e.currentMenuItem.elements.childMenu.currentEvent=e.currentEvent,e.currentMenuItem.elements.childMenu.focusFirstChild()):e.isTopLevel||e.currentChild!==e.elements.menuItems.length-1?e.focusNextChild():e.focusParentsNextChild();else if("ArrowUp"===n){C(t);var l=e.elements.menuItems[e.currentChild-1];l&&l.isSubmenuItem&&l.elements.toggle.isOpen?(e.blurCurrentChild(),e.currentChild=e.currentChild-1,e.currentMenuItem.elements.childMenu.currentEvent=e.currentEvent,e.focusChildsLastNode()):e.isTopLevel||0!==e.currentChild?e.focusPreviousChild():(e.blurCurrentChild(),e.elements.parentMenu.currentEvent=e.currentEvent,e.elements.parentMenu.focusCurrentChild())}else"ArrowRight"===n?e.currentMenuItem.isSubmenuItem&&(C(t),e.currentMenuItem.elements.toggle.isOpen?(e.blurCurrentChild(),e.currentMenuItem.elements.childMenu.currentEvent=e.currentEvent,e.currentMenuItem.elements.childMenu.focusFirstChild()):e.currentMenuItem.elements.toggle.preview()):"ArrowLeft"===n?(C(t),e.currentMenuItem.isSubmenuItem&&e.currentMenuItem.elements.toggle.isOpen?(e.currentMenuItem.elements.childMenu.blurCurrentChild(),e.currentMenuItem.elements.toggle.close()):e.isTopLevel||(e.blurCurrentChild(),e.elements.parentMenu.currentEvent=e.currentEvent,e.elements.parentMenu.focusCurrentChild())):"Home"===n?(C(t),e.blurCurrentChild(),e.elements.rootMenu.focusFirstChild()):"End"===n?(C(t),e.blurCurrentChild(),e.elements.rootMenu.focusLastNode()):"Asterisk"===n&&(C(t),e.openChildren())}else C(t),e.elements.rootMenu.currentEvent="character",e.focusNextNodeWithCharacter(t.key)}))}},{key:"focusLastNode",value:function(){var e=this.elements.menuItems.length-1,t=this.elements.menuItems[e];t.isSubmenuItem&&t.elements.toggle.isOpen?(this.currentChild=e,t.elements.childMenu.currentEvent=this.currentEvent,t.elements.childMenu.focusLastNode()):this.focusLastChild()}},{key:"openChildren",value:function(){this.elements.submenuToggles.forEach((function(e){return e.preview()}))}},{key:"focusNextNodeWithCharacter",value:function(e){for(var t=e.toLowerCase(),n=function e(t){var n=[];return t.elements.menuItems.forEach((function(t){n.push(t),t.isSubmenuItem&&t.elements.toggle.isOpen&&(n=[].concat(h(n),h(e(t.elements.toggle.elements.controlledMenu))))})),n}(this.elements.rootMenu),o=n.indexOf(this.currentMenuItem)+1,s=[].concat(h(n.slice(o)),h(n.slice(0,o))),r=0,l=!1;!l&&r<s.length;){if((s[r].dom.item.innerText?s[r].dom.item.innerText:s[r].dom.item.textContent).replace(/[\s]/g,"").toLowerCase().charAt(0)===t){l=!0;var u=s[r].elements.parentMenu,i=u.elements.menuItems.indexOf(s[r]);this.elements.rootMenu.blurChildren(),u.focusChild(i)}r++}}},{key:"focusParentsNextChild",value:function(){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()))}},{key:"focusChildsLastNode",value:function(){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())}}]),u}();export{w as default};
function e(t){return e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},e(t)}function t(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function n(e,t){for(var n=0;n<t.length;n++){var s=t[n];s.enumerable=s.enumerable||!1,s.configurable=!0,"value"in s&&(s.writable=!0),Object.defineProperty(e,s.key,s)}}function s(e,t,s){return t&&n(e.prototype,t),s&&n(e,s),e}function o(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function r(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&i(e,t)}function l(e){return l=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},l(e)}function i(e,t){return i=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},i(e,t)}function u(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function c(e,t){if(t&&("object"==typeof t||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return u(e)}function m(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,s=l(e);if(t){var o=l(this).constructor;n=Reflect.construct(s,arguments,o)}else n=s.apply(this,arguments);return c(this,n)}}function a(e,t,n){return a="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(e,t,n){var s=function(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&null!==(e=l(e)););return e}(e,t);if(s){var o=Object.getOwnPropertyDescriptor(s,t);return o.get?o.get.call(n):o.value}},a(e,t,n||e)}function h(e){return function(e){if(Array.isArray(e))return d(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,t){if(!e)return;if("string"==typeof e)return d(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return d(e,t)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function d(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,s=new Array(t);n<t;n++)s[n]=e[n];return s}function f(t,n){try{if("object"!==e(n)){var s=e(n);throw new TypeError("AccessibleMenu: Elements given to isValidInstance() must be inside of an object. ".concat(s," given."))}for(var o in n)if(!(n[o]instanceof t)){var r=e(n[o]);throw new TypeError("AccessibleMenu: ".concat(o," must be an instance of ").concat(t.name,". ").concat(r," given."))}return!0}catch(e){return console.error(e),!1}}function v(t,n){try{if("object"!==e(n)){var s=e(n);throw new TypeError("AccessibleMenu: Values given to isValidType() must be inside of an object. ".concat(s," given."))}for(var o in n){var r=e(n[o]);if(r!==t)throw new TypeError("AccessibleMenu: ".concat(o," must be a ").concat(t,". ").concat(r," given."))}return!0}catch(e){return console.error(e),!1}}function p(t){try{if("object"!==e(t)){var n=e(t);throw new TypeError("AccessibleMenu: Values given to isCSSSelector() must be inside of an object. ".concat(n," given."))}for(var s in t)try{if(null===t[s])throw new Error;document.querySelector(t[s])}catch(e){throw new TypeError("AccessibleMenu: ".concat(s,' must be a valid CSS selector. "').concat(t[s],'" given.'))}return!0}catch(e){return console.error(e),!1}}function g(t){try{if("object"!==e(t)||Array.isArray(t)){var n=e(t);throw new TypeError("AccessibleMenu: Values given to isValidClassList() must be inside of an object. ".concat(n," given."))}var s=function(n){var s=e(t[n]);if("string"!==s){if(!Array.isArray(t[n]))throw new TypeError("AccessibleMenu: ".concat(n," must be a string or an array of strings. ").concat(s," given."));t[n].forEach((function(e){if("string"!=typeof e)throw new TypeError("AccessibleMenu: ".concat(n," must be a string or an array of strings. An array containing non-strings given."))}))}else{var o={};o[n]=t[n],p(o)}};for(var o in t)s(o);return!0}catch(e){return console.error(e),!1}}function y(t){try{if("object"!==e(t)){var n=e(t);throw new TypeError("AccessibleMenu: Values given to isValidHoverType() must be inside of an object. ".concat(n," given."))}var s=["off","on","dynamic"];for(var o in t)if(!s.includes(t[o]))throw new TypeError("AccessibleMenu: ".concat(o," must be one of the following values: ").concat(s.join(", "),'. "').concat(t[o],'" given.'));return!0}catch(e){return console.error(e),!1}}var b=function(){function e(n){var s=n.menuToggleElement,r=n.parentElement,l=n.controlledMenu,i=n.parentMenu,u=void 0===i?null:i;t(this,e),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=s,this._dom.parent=r,this._elements.controlledMenu=l,this._elements.parentMenu=u}return s(e,[{key:"initialize",value:function(){if(this.dom.toggle.setAttribute("aria-haspopup","true"),this.dom.toggle.setAttribute("aria-expanded","false"),function(e,t){if(v("string",{tagName:e})&&f(HTMLElement,t)){var n=e.toLowerCase(),s=!0;for(var o in t)t[o].tagName.toLowerCase()!==n&&(s=!1);return s}return!1}("button",{toggle:this.dom.toggle})||this.dom.toggle.setAttribute("role","button"),""===this.dom.toggle.id||""===this.elements.controlledMenu.dom.menu.id){var e=Math.random().toString(36).replace(/[^a-z]+/g,"").substr(0,10),t=this.dom.toggle.innerText.replace(/[^a-zA-Z0-9\s]/g,""),n=e;!t.replace(/\s/g,"").length&&this.dom.toggle.getAttribute("aria-label")&&(t=this.dom.toggle.getAttribute("aria-label").replace(/[^a-zA-Z0-9\s]/g,"")),t.replace(/\s/g,"").length>0&&((t=t.toLowerCase().replace(/\s+/g,"-")).startsWith("-")&&(t=t.substring(1)),t.endsWith("-")&&(t=t.slice(0,-1)),n="".concat(t,"-").concat(n)),this.dom.toggle.id=this.dom.toggle.id||"".concat(n,"-menu-button"),this.elements.controlledMenu.dom.menu.id=this.elements.controlledMenu.dom.menu.id||"".concat(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)}},{key:"dom",get:function(){return this._dom}},{key:"elements",get:function(){return this._elements}},{key:"isOpen",get:function(){return this._open},set:function(e){v("boolean",{value:e}),this._open=e}},{key:"_expand",value:function(){var e,t,n=!(arguments.length>0&&void 0!==arguments[0])||arguments[0],s=this.elements.controlledMenu,o=s.closeClass,r=s.openClass;(this.dom.toggle.setAttribute("aria-expanded","true"),""!==r)&&("string"==typeof r?this.elements.controlledMenu.dom.menu.classList.add(r):(e=this.elements.controlledMenu.dom.menu.classList).add.apply(e,h(r)));""!==o&&("string"==typeof o?this.elements.controlledMenu.dom.menu.classList.remove(o):(t=this.elements.controlledMenu.dom.menu.classList).remove.apply(t,h(o)));n&&this.dom.toggle.dispatchEvent(this._expandEvent)}},{key:"_collapse",value:function(){var e,t,n=!(arguments.length>0&&void 0!==arguments[0])||arguments[0],s=this.elements.controlledMenu,o=s.closeClass,r=s.openClass;(this.dom.toggle.setAttribute("aria-expanded","false"),""!==o)&&("string"==typeof o?this.elements.controlledMenu.dom.menu.classList.add(o):(e=this.elements.controlledMenu.dom.menu.classList).add.apply(e,h(o)));""!==r&&("string"==typeof r?this.elements.controlledMenu.dom.menu.classList.remove(r):(t=this.elements.controlledMenu.dom.menu.classList).remove.apply(t,h(r)));n&&this.dom.toggle.dispatchEvent(this._collapseEvent)}},{key:"open",value:function(){this.elements.controlledMenu.focusState="self",this._expand(),this.isOpen=!0}},{key:"preview",value:function(){this.elements.parentMenu&&(this.elements.parentMenu.focusState="self"),this._expand(),this.isOpen=!0}},{key:"close",value:function(){this.isOpen&&(this.elements.controlledMenu.currentChild=0,this.elements.controlledMenu.blur(),this.elements.parentMenu&&(this.elements.parentMenu.focusState="self"),this._collapse(),this.isOpen=!1)}},{key:"toggle",value:function(){this.isOpen?this.close():this.open()}},{key:"closeSiblings",value:function(){var e=this;this.elements.parentMenu&&this.elements.parentMenu.elements.submenuToggles.forEach((function(t){t!==e&&t.close()}))}},{key:"closeChildren",value:function(){this.elements.controlledMenu.elements.submenuToggles.forEach((function(e){return e.close()}))}}]),e}(),M=function(){function e(n){var s=n.menuItemElement,r=n.menuLinkElement,l=n.parentMenu,i=n.isSubmenuItem,u=void 0!==i&&i,c=n.childMenu,m=void 0===c?null:c,a=n.toggle,h=void 0===a?null:a;t(this,e),o(this,"_dom",{item:null,link:null}),o(this,"_elements",{parentMenu:null,childMenu:null,toggle:null}),o(this,"_submenu",!1),this._dom.item=s,this._dom.link=r,this._elements.parentMenu=l,this._elements.childMenu=m,this._elements.toggle=h,this._submenu=u}return s(e,[{key:"initialize",value:function(){}},{key:"dom",get:function(){return this._dom}},{key:"elements",get:function(){return this._elements}},{key:"isSubmenuItem",get:function(){return this._submenu}},{key:"focus",value:function(){this.elements.parentMenu.shouldFocus&&this.dom.link.focus()}},{key:"blur",value:function(){this.elements.parentMenu.shouldFocus&&this.dom.link.blur()}}]),e}();function E(e){try{var t=e.key||e.keyCode,n={Enter:"Enter"===t||13===t,Space:" "===t||"Spacebar"===t||32===t,Escape:"Escape"===t||"Esc"===t||27===t,ArrowUp:"ArrowUp"===t||"Up"===t||38===t,ArrowRight:"ArrowRight"===t||"Right"===t||39===t,ArrowDown:"ArrowDown"===t||"Down"===t||40===t,ArrowLeft:"ArrowLeft"===t||"Left"===t||37===t,Home:"Home"===t||36===t,End:"End"===t||35===t,Character:isNaN(t)&&!!t.match(/^[a-zA-Z]{1}$/),Tab:"Tab"===t||9===t,Asterisk:"*"===t||56===t};return Object.keys(n).find((function(e){return!0===n[e]}))||""}catch(e){return""}}function _(e){e.preventDefault(),e.stopPropagation()}var C=function(){function n(e){var s=e.menuElement,r=e.menuItemSelector,l=void 0===r?"li":r,i=e.menuLinkSelector,u=void 0===i?"a":i,c=e.submenuItemSelector,m=void 0===c?"":c,a=e.submenuToggleSelector,h=void 0===a?"a":a,d=e.submenuSelector,f=void 0===d?"ul":d,v=e.controllerElement,p=void 0===v?null:v,g=e.containerElement,y=void 0===g?null:g,E=e.openClass,_=void 0===E?"show":E,C=e.closeClass,T=void 0===C?"hide":C,I=e.isTopLevel,k=void 0===I||I,w=e.parentMenu,S=void 0===w?null:w,L=e.hoverType,A=void 0===L?"off":L,O=e.hoverDelay,D=void 0===O?250:O;t(this,n),o(this,"_MenuType",n),o(this,"_MenuItemType",M),o(this,"_MenuToggleType",b),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,"_root",!0),o(this,"_currentChild",0),o(this,"_focusState","none"),o(this,"_currentEvent","none"),o(this,"_hoverType","off"),o(this,"_hoverDelay",250),this._dom.menu=s,this._dom.controller=p,this._dom.container=y,this._selectors.menuItems=l,this._selectors.menuLinks=u,this._selectors.submenuItems=m,this._selectors.submenuToggles=h,this._selectors.submenus=f,this._elements.menuItems=[],this._elements.submenuToggles=[],this._elements.controller=null,this._elements.parentMenu=S,this._elements.rootMenu=k?this:null,this._openClass=_||"",this._closeClass=T||"",this._root=k,this._hoverType=A,this._hoverDelay=D}return s(n,[{key:"initialize",value:function(){if(!this._validate())throw new Error("AccesibleMenu: cannot initialize menu. See other error messages for more information.");if(null===this.elements.rootMenu&&this._findRootMenu(this),this._setDOMElements(),this.isTopLevel&&this.dom.controller&&this.dom.container){var e=new this._MenuToggleType({menuToggleElement:this.dom.controller,parentElement:this.dom.container,controlledMenu:this});this._elements.controller=e}this._createChildElements()}},{key:"dom",get:function(){return this._dom}},{key:"selectors",get:function(){return this._selectors}},{key:"elements",get:function(){return this._elements}},{key:"isTopLevel",get:function(){return this._root}},{key:"openClass",get:function(){return this.isTopLevel?this._openClass:this.elements.rootMenu.openClass},set:function(e){g({openClass:e}),this._openClass!==e&&(this._openClass=e)}},{key:"closeClass",get:function(){return this.isTopLevel?this._closeClass:this.elements.rootMenu.closeClass},set:function(e){g({closeClass:e}),this._closeClass!==e&&(this._closeClass=e)}},{key:"currentChild",get:function(){return this._currentChild},set:function(e){function t(e){if(["mouse","character"].includes(e.currentEvent)&&e.elements.parentMenu)for(var t=0,n=!1;!n&&t<e.elements.parentMenu.elements.menuItems.length;){var s=e.elements.parentMenu.elements.menuItems[t];s.isSubmenuItem&&s.elements.toggle.elements.controlledMenu===e&&(n=!0,e.elements.parentMenu.currentEvent=e.currentEvent,e.elements.parentMenu.currentChild=t),t++}}v("number",{value:e}),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))}},{key:"focusState",get:function(){return this._focusState},set:function(t){!function(t){try{if("object"!==e(t)){var n=e(t);throw new TypeError("AccessibleMenu: Values given to isValidState() must be inside of an object. ".concat(n," given."))}var s=["none","self","child"];for(var o in t)if(!s.includes(t[o]))throw new TypeError("AccessibleMenu: ".concat(o," must be one of the following values: ").concat(s.join(", "),'. "').concat(t[o],'" given.'))}catch(e){return console.error(e),!1}}({value:t}),this._focusState!==t&&(this._focusState=t),this.elements.submenuToggles.length>0&&("self"===t||"none"===t)&&this.elements.submenuToggles.forEach((function(e){e.elements.controlledMenu.focusState="none"})),!this.elements.parentMenu||"self"!==t&&"child"!==t||(this.elements.parentMenu.focusState="child")}},{key:"currentEvent",get:function(){return this._currentEvent},set:function(t){!function(t){try{if("object"!==e(t)){var n=e(t);throw new TypeError("AccessibleMenu: Values given to isValidEvent() must be inside of an object. ".concat(n," given."))}var s=["none","mouse","keyboard","character"];for(var o in t)if(!s.includes(t[o]))throw new TypeError("AccessibleMenu: ".concat(o," must be one of the following values: ").concat(s.join(", "),'. "').concat(t[o],'" given.'))}catch(e){return console.error(e),!1}}({value:t}),this._currentEvent!==t&&(this._currentEvent=t,this.elements.submenuToggles.length>0&&this.elements.submenuToggles.forEach((function(e){e.elements.controlledMenu.currentEvent=t})))}},{key:"currentMenuItem",get:function(){return this.elements.menuItems[this.currentChild]}},{key:"hoverType",get:function(){return this._root?this._hoverType:this.elements.rootMenu.hoverType},set:function(e){y({value:e}),this._hoverType!==e&&(this._hoverType=e)}},{key:"hoverDelay",get:function(){return this._root?this._hoverDelay:this.elements.rootMenu.hoverDelay},set:function(e){v("number",{value:e}),this._hoverDelay!==e&&(this._hoverDelay=e)}},{key:"shouldFocus",get:function(){var e=!1;return"keyboard"!==this.currentEvent&&"character"!==this.currentEvent||(e=!0),"mouse"===this.currentEvent&&"dynamic"===this.hoverType&&(e=!0),e}},{key:"_validate",value:function(){var e=!0;return null!==this._dom.container||null!==this._dom.controller?f(HTMLElement,{menuElement:this._dom.menu,controllerElement:this._dom.controller,containerElement:this._dom.container})||(e=!1):f(HTMLElement,{menuElement:this._dom.menu})||(e=!1),""!==this._selectors.submenuItems?p({menuItemSelector:this._selectors.menuItems,menuLinkSelector:this._selectors.menuLinks,submenuItemSelector:this._selectors.submenuItems,submenuToggleSelector:this._selectors.submenuToggles,submenuSelector:this._selectors.submenus})||(e=!1):p({menuItemSelector:this._selectors.menuItems,menuLinkSelector:this._selectors.menuLinks})||(e=!1),""===this._openClass||g({openClass:this._openClass})||(e=!1),""===this._closeClass||g({closeClass:this._closeClass})||(e=!1),v("boolean",{isTopLevel:this._root})||(e=!1),null===this._elements.parentMenu||f(n,{parentMenu:this._elements.parentMenu})||(e=!1),y({hoverType:this._hoverType})||(e=!1),v("number",{hoverDelay:this._hoverDelay})||(e=!1),e}},{key:"_setDOMElementType",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.dom.menu,n=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];if("string"!=typeof this.selectors[e])throw new Error('AccessibleMenu: "'.concat(e,'" is not a valid element type within the menu.'));if(!Array.isArray(this.dom[e]))throw new Error('AccessibleMenu: The "'.concat(e,'" element cannot be set through _setDOMElementType.'));t!==this.dom.menu&&f(HTMLElement,{base:t});var s=Array.from(t.querySelectorAll(this.selectors[e])),o=s.filter((function(e){return e.parentElement===t}));this._dom[e]=n?o:[].concat(h(this._dom[e]),h(o))}},{key:"_resetDOMElementType",value:function(e){if(void 0===this.dom[e])throw new Error('AccessibleMenu: "'.concat(e,'" is not a valid element type within the menu.'));if(!Array.isArray(this.dom[e]))throw new Error('AccessibleMenu: The "'.concat(e,'" element cannot be reset through _resetDOMElementType.'));this._dom[e]=[]}},{key:"_setDOMElements",value:function(){var e=this;this._setDOMElementType("menuItems"),""!==this.selectors.submenuItems&&(this._setDOMElementType("submenuItems"),this._resetDOMElementType("submenuToggles"),this._resetDOMElementType("submenus"),this.dom.submenuItems.forEach((function(t){e._setDOMElementType("submenuToggles",t,!1),e._setDOMElementType("submenus",t,!1)})))}},{key:"_findRootMenu",value:function(e){if(e.isTopLevel)this._elements.rootMenu=e;else{if(null===e.elements.parentMenu)throw new Error("Cannot find root menu.");this._findRootMenu(e.elements.parentMenu)}}},{key:"_createChildElements",value:function(){var e=this;this.dom.menuItems.forEach((function(t){var n;if(e.dom.submenuItems.includes(t)){var s=t.querySelector(e.selectors.submenuToggles),o=t.querySelector(e.selectors.submenus),r=new e._MenuType({menuElement:o,menuItemSelector:e.selectors.menuItems,menuLinkSelector:e.selectors.menuLinks,submenuItemSelector:e.selectors.submenuItems,submenuToggleSelector:e.selectors.submenuToggles,submenuSelector:e.selectors.submenus,openClass:e.openClass,closeClass:e.closeClass,isTopLevel:!1,parentMenu:e,hoverType:e.hoverType,hoverDelay:e.hoverDelay}),l=new e._MenuToggleType({menuToggleElement:s,parentElement:t,controlledMenu:r,parentMenu:e});e._elements.submenuToggles.push(l),n=new e._MenuItemType({menuItemElement:t,menuLinkElement:s,parentMenu:e,isSubmenuItem:!0,childMenu:r,toggle:l})}else{var i=t.querySelector(e.selectors.menuLinks);n=new e._MenuItemType({menuItemElement:t,menuLinkElement:i,parentMenu:e})}e._elements.menuItems.push(n)}))}},{key:"_handleFocus",value:function(){var e=this;this.elements.menuItems.forEach((function(t,n){t.dom.link.addEventListener("focus",(function(){e.focusState="self",e.currentChild=n}))}))}},{key:"_handleClick",value:function(){var e=this;function t(e,t,n){_(n),t.toggle(),t.isOpen&&(e.focusState="self",t.elements.controlledMenu.focusState="none")}this.elements.menuItems.forEach((function(n,s){n.dom.link.addEventListener("pointerdown",(function(){e.currentEvent="mouse",e.elements.rootMenu.blurChildren(),e.focusChild(s)}),{passive:!0}),n.isSubmenuItem&&n.elements.toggle.dom.toggle.addEventListener("pointerup",(function(s){e.currentEvent="mouse",t(e,n.elements.toggle,s)}))})),this.isTopLevel&&this.elements.controller&&this.elements.controller.dom.toggle.addEventListener("pointerup",(function(n){e.currentEvent="mouse",t(e,e.elements.controller,n)}))}},{key:"_handleHover",value:function(){var e=this;this.elements.menuItems.forEach((function(t,n){t.dom.link.addEventListener("mouseenter",(function(){if("on"===e.hoverType)e.currentEvent="mouse",e.currentChild=n,t.isSubmenuItem&&t.elements.toggle.preview();else if("dynamic"===e.hoverType){var s=e.elements.submenuToggles.some((function(e){return e.isOpen}));e.currentChild=n,e.isTopLevel&&"none"===e.focusState||(e.currentEvent="mouse",e.focusCurrentChild()),!t.isSubmenuItem||e.isTopLevel&&!s||(e.currentEvent="mouse",t.elements.toggle.preview())}})),t.isSubmenuItem&&t.dom.item.addEventListener("mouseleave",(function(){"on"===e.hoverType?e.hoverDelay>0?setTimeout((function(){e.currentEvent="mouse",t.elements.toggle.close()}),e.hoverDelay):(e.currentEvent="mouse",t.elements.toggle.close()):"dynamic"===e.hoverType&&(e.isTopLevel||(e.hoverDelay>0?setTimeout((function(){e.currentEvent="mouse",t.elements.toggle.close(),e.focusCurrentChild()}),e.hoverDelay):(e.currentEvent="mouse",t.elements.toggle.close(),e.focusCurrentChild())))}))}))}},{key:"_handleKeydown",value:function(){var e=this;this.isTopLevel&&this.elements.controller&&this.elements.controller.dom.toggle.addEventListener("keydown",(function(t){e.currentEvent="keyboard";var n=E(t);"Space"!==n&&"Enter"!==n||_(t)}))}},{key:"_handleKeyup",value:function(){var e=this;this.isTopLevel&&this.elements.controller&&this.elements.controller.dom.toggle.addEventListener("keyup",(function(t){e.currentEvent="keyboard";var n=E(t);"Space"!==n&&"Enter"!==n||(_(t),e.elements.controller.open(),e.focusFirstChild())}))}},{key:"focus",value:function(){this.focusState="self",this.shouldFocus&&this.dom.menu.focus()}},{key:"blur",value:function(){this.focusState="none",this.shouldFocus&&this.dom.menu.blur()}},{key:"focusCurrentChild",value:function(){this.focusState="self",-1!==this.currentChild&&this.currentMenuItem.focus()}},{key:"focusChild",value:function(e){this.blurCurrentChild(),this.currentChild=e,this.focusCurrentChild()}},{key:"focusFirstChild",value:function(){this.focusChild(0)}},{key:"focusLastChild",value:function(){this.focusChild(this.elements.menuItems.length-1)}},{key:"focusNextChild",value:function(){this.currentChild<this.elements.menuItems.length-1?this.focusChild(this.currentChild+1):this.focusCurrentChild()}},{key:"focusPreviousChild",value:function(){this.currentChild>0?this.focusChild(this.currentChild-1):this.focusCurrentChild()}},{key:"blurCurrentChild",value:function(){this.focusState="none",-1!==this.currentChild&&this.currentMenuItem.blur()}},{key:"focusController",value:function(){this.dom.controller&&(this.shouldFocus&&this.dom.controller.focus(),this.focusState="none")}},{key:"focusContainer",value:function(){this.dom.container&&(this.shouldFocus&&this.dom.container.focus(),this.focusState="none")}},{key:"closeChildren",value:function(){this.elements.submenuToggles.forEach((function(e){return e.close()}))}},{key:"blurChildren",value:function(){this.elements.menuItems.forEach((function(e){e.blur(),e.isSubmenuItem&&e.elements.childMenu.blurChildren()}))}}]),n}(),T=function(e){r(o,M);var n=m(o);function o(e){var s,r=e.menuItemElement,l=e.menuLinkElement,i=e.parentMenu,u=e.isSubmenuItem,c=void 0!==u&&u,m=e.childMenu,a=void 0===m?null:m,h=e.toggle,d=void 0===h?null:h,f=e.initialize,v=void 0===f||f;return t(this,o),s=n.call(this,{menuItemElement:r,menuLinkElement:l,parentMenu:i,isSubmenuItem:c,childMenu:a,toggle:d}),v&&s.initialize(),s}return s(o,[{key:"initialize",value:function(){a(l(o.prototype),"initialize",this).call(this),this.dom.item.setAttribute("role","none"),this.dom.link.setAttribute("role","treeitem"),this.dom.link.tabIndex=-1}},{key:"focus",value:function(){a(l(o.prototype),"focus",this).call(this),this.dom.link.tabIndex=0}},{key:"blur",value:function(){a(l(o.prototype),"blur",this).call(this),this.dom.link.tabIndex=-1}}]),o}(),I=function(e){r(s,b);var n=m(s);function s(e){var o,r=e.menuToggleElement,l=e.parentElement,i=e.controlledMenu,u=e.parentMenu,c=void 0===u?null:u,m=e.initialize,a=void 0===m||m;return t(this,s),o=n.call(this,{menuToggleElement:r,parentElement:l,controlledMenu:i,parentMenu:c}),a&&o.initialize(),o}return s}(),k=function(e){r(i,C);var n=m(i);function i(e){var s,r=e.menuElement,l=e.menuItemSelector,c=void 0===l?"li":l,m=e.menuLinkSelector,a=void 0===m?"a":m,h=e.submenuItemSelector,d=void 0===h?"":h,f=e.submenuToggleSelector,v=void 0===f?"a":f,p=e.submenuSelector,g=void 0===p?"ul":p,y=e.controllerElement,b=void 0===y?null:y,M=e.containerElement,E=void 0===M?null:M,_=e.openClass,C=void 0===_?"show":_,k=e.closeClass,w=void 0===k?"hide":k,S=e.isTopLevel,L=void 0===S||S,A=e.parentMenu,O=void 0===A?null:A,D=e.hoverType,j=void 0===D?"off":D,x=e.hoverDelay,N=void 0===x?250:x,z=e.initialize,R=void 0===z||z;return t(this,i),o(u(s=n.call(this,{menuElement:r,menuItemSelector:c,menuLinkSelector:a,submenuItemSelector:d,submenuToggleSelector:v,submenuSelector:g,controllerElement:b,containerElement:E,openClass:C,closeClass:w,isTopLevel:L,parentMenu:O,hoverType:j,hoverDelay:N})),"_MenuType",i),o(u(s),"_MenuItemType",T),o(u(s),"_MenuToggleType",I),R&&s.initialize(),s}return s(i,[{key:"initialize",value:function(){try{a(l(i.prototype),"initialize",this).call(this),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)}}},{key:"_handleKeydown",value:function(){var e=this;a(l(i.prototype),"_handleKeydown",this).call(this),this.dom.menu.addEventListener("keydown",(function(t){e.currentEvent="keyboard";var n=E(t);if("Tab"===n&&("none"!==e.elements.rootMenu.focusState?e.elements.rootMenu.blur():e.elements.rootMenu.focus()),"self"===e.focusState){(["Space","ArrowUp","ArrowDown","ArrowLeft","Asterisk","Home","End"].includes(n)||e.currentMenuItem.isSubmenuItem&&["Enter","ArrowRight"].includes(n)||e.elements.controller&&["Escape"].includes(n))&&_(t)}}))}},{key:"_handleKeyup",value:function(){var e=this;a(l(i.prototype),"_handleKeyup",this).call(this),this.dom.menu.addEventListener("keyup",(function(t){e.currentEvent="keyboard";var n=E(t),s=t.altKey,o=t.crtlKey,r=t.metaKey;if("Character"!==n||(s||o||r)){if("self"===e.focusState)if("Enter"===n||"Space"===n)_(t),e.currentMenuItem.isSubmenuItem?e.currentMenuItem.elements.toggle.isOpen?e.currentMenuItem.elements.toggle.close():e.currentMenuItem.elements.toggle.preview():e.currentMenuItem.dom.link.click();else if("Escape"===n)e.isTopLevel&&e.elements.controller&&e.elements.controller.isOpen&&(e.elements.controller.close(),e.focusController());else if("ArrowDown"===n)_(t),e.currentMenuItem.isSubmenuItem&&e.currentMenuItem.elements.toggle.isOpen?(e.blurCurrentChild(),e.currentMenuItem.elements.childMenu.currentEvent=e.currentEvent,e.currentMenuItem.elements.childMenu.focusFirstChild()):e.isTopLevel||e.currentChild!==e.elements.menuItems.length-1?e.focusNextChild():e.focusParentsNextChild();else if("ArrowUp"===n){_(t);var l=e.elements.menuItems[e.currentChild-1];l&&l.isSubmenuItem&&l.elements.toggle.isOpen?(e.blurCurrentChild(),e.currentChild=e.currentChild-1,e.currentMenuItem.elements.childMenu.currentEvent=e.currentEvent,e.focusChildsLastNode()):e.isTopLevel||0!==e.currentChild?e.focusPreviousChild():(e.blurCurrentChild(),e.elements.parentMenu.currentEvent=e.currentEvent,e.elements.parentMenu.focusCurrentChild())}else"ArrowRight"===n?e.currentMenuItem.isSubmenuItem&&(_(t),e.currentMenuItem.elements.toggle.isOpen?(e.blurCurrentChild(),e.currentMenuItem.elements.childMenu.currentEvent=e.currentEvent,e.currentMenuItem.elements.childMenu.focusFirstChild()):e.currentMenuItem.elements.toggle.preview()):"ArrowLeft"===n?(_(t),e.currentMenuItem.isSubmenuItem&&e.currentMenuItem.elements.toggle.isOpen?(e.currentMenuItem.elements.childMenu.blurCurrentChild(),e.currentMenuItem.elements.toggle.close()):e.isTopLevel||(e.blurCurrentChild(),e.elements.parentMenu.currentEvent=e.currentEvent,e.elements.parentMenu.focusCurrentChild())):"Home"===n?(_(t),e.blurCurrentChild(),e.elements.rootMenu.focusFirstChild()):"End"===n?(_(t),e.blurCurrentChild(),e.elements.rootMenu.focusLastNode()):"Asterisk"===n&&(_(t),e.openChildren())}else _(t),e.elements.rootMenu.currentEvent="character",e.focusNextNodeWithCharacter(t.key)}))}},{key:"focusLastNode",value:function(){var e=this.elements.menuItems.length-1,t=this.elements.menuItems[e];t.isSubmenuItem&&t.elements.toggle.isOpen?(this.currentChild=e,t.elements.childMenu.currentEvent=this.currentEvent,t.elements.childMenu.focusLastNode()):this.focusLastChild()}},{key:"openChildren",value:function(){this.elements.submenuToggles.forEach((function(e){return e.preview()}))}},{key:"focusNextNodeWithCharacter",value:function(e){for(var t=e.toLowerCase(),n=function e(t){var n=[];return t.elements.menuItems.forEach((function(t){n.push(t),t.isSubmenuItem&&t.elements.toggle.isOpen&&(n=[].concat(h(n),h(e(t.elements.toggle.elements.controlledMenu))))})),n}(this.elements.rootMenu),s=n.indexOf(this.currentMenuItem)+1,o=[].concat(h(n.slice(s)),h(n.slice(0,s))),r=0,l=!1;!l&&r<o.length;){if((o[r].dom.item.innerText?o[r].dom.item.innerText:o[r].dom.item.textContent).replace(/[\s]/g,"").toLowerCase().charAt(0)===t){l=!0;var i=o[r].elements.parentMenu,u=i.elements.menuItems.indexOf(o[r]);this.elements.rootMenu.blurChildren(),i.focusChild(u)}r++}}},{key:"focusParentsNextChild",value:function(){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()))}},{key:"focusChildsLastNode",value:function(){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())}}]),i}();export{k as default};
//# sourceMappingURL=treeview.esm.min.js.map

@@ -112,2 +112,4 @@ var Treeview = (function () {

return call;
} else if (call !== void 0) {
throw new TypeError("Derived constructors may only return object or undefined");
}

@@ -359,14 +361,2 @@

}
function isEventSupported(event, element) {
if (isValidType("string", {
event: event
}) && isValidInstance(HTMLElement, {
element: element
})) {
var eventProp = "on".concat(event);
return typeof element[eventProp] !== "undefined";
} else {
return false;
}
}

@@ -1137,4 +1127,2 @@ var BaseMenuToggle = function () {

var _this4 = this;
var startEventType = isEventSupported("touchstart", this.dom.menu) ? "touchstart" : "mousedown";
var endEventType = isEventSupported("touchend", this.dom.menu) ? "touchend" : "mouseup";
function toggleToggle(menu, toggle, event) {

@@ -1149,19 +1137,21 @@ preventEvent(event);

this.elements.menuItems.forEach(function (item, index) {
item.dom.link.addEventListener(startEventType, function () {
item.dom.link.addEventListener("pointerdown", function () {
_this4.currentEvent = "mouse";
_this4.elements.rootMenu.blurChildren();
_this4.focusChild(index);
}, {
passive: true
});
if (item.isSubmenuItem) {
item.elements.toggle.dom.toggle["on".concat(endEventType)] = function (event) {
item.elements.toggle.dom.toggle.addEventListener("pointerup", function (event) {
_this4.currentEvent = "mouse";
toggleToggle(_this4, item.elements.toggle, event);
};
});
}
});
if (this.isTopLevel && this.elements.controller) {
this.elements.controller.dom.toggle["on".concat(endEventType)] = function (event) {
this.elements.controller.dom.toggle.addEventListener("pointerup", function (event) {
_this4.currentEvent = "mouse";
toggleToggle(_this4, _this4.elements.controller, event);
};
});
}

@@ -1735,3 +1725,3 @@ }

}());
})();
//# sourceMappingURL=treeview.js.map

@@ -1,2 +0,2 @@

var Treeview=function(){"use strict";function e(t){return(e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(t)}function t(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function n(e,t){for(var n=0;n<t.length;n++){var o=t[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}function o(e,t,o){return t&&n(e.prototype,t),o&&n(e,o),e}function s(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function r(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&u(e,t)}function l(e){return(l=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function u(e,t){return(u=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function i(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function c(e,t){return!t||"object"!=typeof t&&"function"!=typeof t?i(e):t}function m(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,o=l(e);if(t){var s=l(this).constructor;n=Reflect.construct(o,arguments,s)}else n=o.apply(this,arguments);return c(this,n)}}function a(e,t,n){return(a="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(e,t,n){var o=function(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&null!==(e=l(e)););return e}(e,t);if(o){var s=Object.getOwnPropertyDescriptor(o,t);return s.get?s.get.call(n):s.value}})(e,t,n||e)}function h(e){return function(e){if(Array.isArray(e))return d(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,t){if(!e)return;if("string"==typeof e)return d(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return d(e,t)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function d(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,o=new Array(t);n<t;n++)o[n]=e[n];return o}function f(t,n){try{if("object"!==e(n)){var o=e(n);throw new TypeError("AccessibleMenu: Elements given to isValidInstance() must be inside of an object. ".concat(o," given."))}for(var s in n)if(!(n[s]instanceof t)){var r=e(n[s]);throw new TypeError("AccessibleMenu: ".concat(s," must be an instance of ").concat(t.name,". ").concat(r," given."))}return!0}catch(e){return console.error(e),!1}}function v(t,n){try{if("object"!==e(n)){var o=e(n);throw new TypeError("AccessibleMenu: Values given to isValidType() must be inside of an object. ".concat(o," given."))}for(var s in n){var r=e(n[s]);if(r!==t)throw new TypeError("AccessibleMenu: ".concat(s," must be a ").concat(t,". ").concat(r," given."))}return!0}catch(e){return console.error(e),!1}}function p(t){try{if("object"!==e(t)){var n=e(t);throw new TypeError("AccessibleMenu: Values given to isCSSSelector() must be inside of an object. ".concat(n," given."))}for(var o in t)try{if(null===t[o])throw new Error;document.querySelector(t[o])}catch(e){throw new TypeError("AccessibleMenu: ".concat(o,' must be a valid CSS selector. "').concat(t[o],'" given.'))}return!0}catch(e){return console.error(e),!1}}function g(t){try{if("object"!==e(t)||Array.isArray(t)){var n=e(t);throw new TypeError("AccessibleMenu: Values given to isValidClassList() must be inside of an object. ".concat(n," given."))}var o=function(n){var o=e(t[n]);if("string"!==o){if(!Array.isArray(t[n]))throw new TypeError("AccessibleMenu: ".concat(n," must be a string or an array of strings. ").concat(o," given."));t[n].forEach((function(e){if("string"!=typeof e)throw new TypeError("AccessibleMenu: ".concat(n," must be a string or an array of strings. An array containing non-strings given."))}))}else{var s={};s[n]=t[n],p(s)}};for(var s in t)o(s);return!0}catch(e){return console.error(e),!1}}function y(t){try{if("object"!==e(t)){var n=e(t);throw new TypeError("AccessibleMenu: Values given to isValidHoverType() must be inside of an object. ".concat(n," given."))}var o=["off","on","dynamic"];for(var s in t)if(!o.includes(t[s]))throw new TypeError("AccessibleMenu: ".concat(s," must be one of the following values: ").concat(o.join(", "),'. "').concat(t[s],'" given.'));return!0}catch(e){return console.error(e),!1}}function b(e,t){return!(!v("string",{event:e})||!f(HTMLElement,{element:t}))&&void 0!==t["on".concat(e)]}var M=function(){function e(n){var o=n.menuToggleElement,r=n.parentElement,l=n.controlledMenu,u=n.parentMenu,i=void 0===u?null:u;t(this,e),s(this,"_dom",{toggle:null,parent:null}),s(this,"_elements",{controlledMenu:null,parentMenu:null}),s(this,"_open",!1),s(this,"_expandEvent",new CustomEvent("accessibleMenuExpand",{bubbles:!0,detail:{toggle:this}})),s(this,"_collapseEvent",new CustomEvent("accessibleMenuCollapse",{bubbles:!0,detail:{toggle:this}})),this._dom.toggle=o,this._dom.parent=r,this._elements.controlledMenu=l,this._elements.parentMenu=i}return o(e,[{key:"initialize",value:function(){if(this.dom.toggle.setAttribute("aria-haspopup","true"),this.dom.toggle.setAttribute("aria-expanded","false"),function(e,t){if(v("string",{tagName:e})&&f(HTMLElement,t)){var n=e.toLowerCase(),o=!0;for(var s in t)t[s].tagName.toLowerCase()!==n&&(o=!1);return o}return!1}("button",{toggle:this.dom.toggle})||this.dom.toggle.setAttribute("role","button"),""===this.dom.toggle.id||""===this.elements.controlledMenu.dom.menu.id){var e=Math.random().toString(36).replace(/[^a-z]+/g,"").substr(0,10),t=this.dom.toggle.innerText.replace(/[^a-zA-Z0-9\s]/g,""),n=e;!t.replace(/\s/g,"").length&&this.dom.toggle.getAttribute("aria-label")&&(t=this.dom.toggle.getAttribute("aria-label").replace(/[^a-zA-Z0-9\s]/g,"")),t.replace(/\s/g,"").length>0&&((t=t.toLowerCase().replace(/\s+/g,"-")).startsWith("-")&&(t=t.substring(1)),t.endsWith("-")&&(t=t.slice(0,-1)),n="".concat(t,"-").concat(n)),this.dom.toggle.id=this.dom.toggle.id||"".concat(n,"-menu-button"),this.elements.controlledMenu.dom.menu.id=this.elements.controlledMenu.dom.menu.id||"".concat(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)}},{key:"dom",get:function(){return this._dom}},{key:"elements",get:function(){return this._elements}},{key:"isOpen",get:function(){return this._open},set:function(e){v("boolean",{value:e}),this._open=e}},{key:"_expand",value:function(){var e,t,n=!(arguments.length>0&&void 0!==arguments[0])||arguments[0],o=this.elements.controlledMenu,s=o.closeClass,r=o.openClass;(this.dom.toggle.setAttribute("aria-expanded","true"),""!==r)&&("string"==typeof r?this.elements.controlledMenu.dom.menu.classList.add(r):(e=this.elements.controlledMenu.dom.menu.classList).add.apply(e,h(r)));""!==s&&("string"==typeof s?this.elements.controlledMenu.dom.menu.classList.remove(s):(t=this.elements.controlledMenu.dom.menu.classList).remove.apply(t,h(s)));n&&this.dom.toggle.dispatchEvent(this._expandEvent)}},{key:"_collapse",value:function(){var e,t,n=!(arguments.length>0&&void 0!==arguments[0])||arguments[0],o=this.elements.controlledMenu,s=o.closeClass,r=o.openClass;(this.dom.toggle.setAttribute("aria-expanded","false"),""!==s)&&("string"==typeof s?this.elements.controlledMenu.dom.menu.classList.add(s):(e=this.elements.controlledMenu.dom.menu.classList).add.apply(e,h(s)));""!==r&&("string"==typeof r?this.elements.controlledMenu.dom.menu.classList.remove(r):(t=this.elements.controlledMenu.dom.menu.classList).remove.apply(t,h(r)));n&&this.dom.toggle.dispatchEvent(this._collapseEvent)}},{key:"open",value:function(){this.elements.controlledMenu.focusState="self",this._expand(),this.isOpen=!0}},{key:"preview",value:function(){this.elements.parentMenu&&(this.elements.parentMenu.focusState="self"),this._expand(),this.isOpen=!0}},{key:"close",value:function(){this.isOpen&&(this.elements.controlledMenu.currentChild=0,this.elements.controlledMenu.blur(),this.elements.parentMenu&&(this.elements.parentMenu.focusState="self"),this._collapse(),this.isOpen=!1)}},{key:"toggle",value:function(){this.isOpen?this.close():this.open()}},{key:"closeSiblings",value:function(){var e=this;this.elements.parentMenu&&this.elements.parentMenu.elements.submenuToggles.forEach((function(t){t!==e&&t.close()}))}},{key:"closeChildren",value:function(){this.elements.controlledMenu.elements.submenuToggles.forEach((function(e){return e.close()}))}}]),e}(),_=function(){function e(n){var o=n.menuItemElement,r=n.menuLinkElement,l=n.parentMenu,u=n.isSubmenuItem,i=void 0!==u&&u,c=n.childMenu,m=void 0===c?null:c,a=n.toggle,h=void 0===a?null:a;t(this,e),s(this,"_dom",{item:null,link:null}),s(this,"_elements",{parentMenu:null,childMenu:null,toggle:null}),s(this,"_submenu",!1),this._dom.item=o,this._dom.link=r,this._elements.parentMenu=l,this._elements.childMenu=m,this._elements.toggle=h,this._submenu=i}return o(e,[{key:"initialize",value:function(){}},{key:"dom",get:function(){return this._dom}},{key:"elements",get:function(){return this._elements}},{key:"isSubmenuItem",get:function(){return this._submenu}},{key:"focus",value:function(){this.elements.parentMenu.shouldFocus&&this.dom.link.focus()}},{key:"blur",value:function(){this.elements.parentMenu.shouldFocus&&this.dom.link.blur()}}]),e}();function E(e){try{var t=e.key||e.keyCode,n={Enter:"Enter"===t||13===t,Space:" "===t||"Spacebar"===t||32===t,Escape:"Escape"===t||"Esc"===t||27===t,ArrowUp:"ArrowUp"===t||"Up"===t||38===t,ArrowRight:"ArrowRight"===t||"Right"===t||39===t,ArrowDown:"ArrowDown"===t||"Down"===t||40===t,ArrowLeft:"ArrowLeft"===t||"Left"===t||37===t,Home:"Home"===t||36===t,End:"End"===t||35===t,Character:isNaN(t)&&!!t.match(/^[a-zA-Z]{1}$/),Tab:"Tab"===t||9===t,Asterisk:"*"===t||56===t};return Object.keys(n).find((function(e){return!0===n[e]}))||""}catch(e){return""}}function C(e){e.preventDefault(),e.stopPropagation()}var T=function(){function n(e){var o=e.menuElement,r=e.menuItemSelector,l=void 0===r?"li":r,u=e.menuLinkSelector,i=void 0===u?"a":u,c=e.submenuItemSelector,m=void 0===c?"":c,a=e.submenuToggleSelector,h=void 0===a?"a":a,d=e.submenuSelector,f=void 0===d?"ul":d,v=e.controllerElement,p=void 0===v?null:v,g=e.containerElement,y=void 0===g?null:g,b=e.openClass,E=void 0===b?"show":b,C=e.closeClass,T=void 0===C?"hide":C,I=e.isTopLevel,k=void 0===I||I,w=e.parentMenu,S=void 0===w?null:w,L=e.hoverType,A=void 0===L?"off":L,O=e.hoverDelay,D=void 0===O?250:O;t(this,n),s(this,"_MenuType",n),s(this,"_MenuItemType",_),s(this,"_MenuToggleType",M),s(this,"_dom",{menu:null,menuItems:[],submenuItems:[],submenuToggles:[],submenus:[],controller:null,container:null}),s(this,"_selectors",{menuItems:"",menuLinks:"",submenuItems:"",submenuToggles:"",submenus:""}),s(this,"_elements",{menuItems:[],submenuToggles:[],controller:null,parentMenu:null,rootMenu:null}),s(this,"_openClass","show"),s(this,"_closeClass","hide"),s(this,"_root",!0),s(this,"_currentChild",0),s(this,"_focusState","none"),s(this,"_currentEvent","none"),s(this,"_hoverType","off"),s(this,"_hoverDelay",250),this._dom.menu=o,this._dom.controller=p,this._dom.container=y,this._selectors.menuItems=l,this._selectors.menuLinks=i,this._selectors.submenuItems=m,this._selectors.submenuToggles=h,this._selectors.submenus=f,this._elements.menuItems=[],this._elements.submenuToggles=[],this._elements.controller=null,this._elements.parentMenu=S,this._elements.rootMenu=k?this:null,this._openClass=E||"",this._closeClass=T||"",this._root=k,this._hoverType=A,this._hoverDelay=D}return o(n,[{key:"initialize",value:function(){if(!this._validate())throw new Error("AccesibleMenu: cannot initialize menu. See other error messages for more information.");if(null===this.elements.rootMenu&&this._findRootMenu(this),this._setDOMElements(),this.isTopLevel&&this.dom.controller&&this.dom.container){var e=new this._MenuToggleType({menuToggleElement:this.dom.controller,parentElement:this.dom.container,controlledMenu:this});this._elements.controller=e}this._createChildElements()}},{key:"dom",get:function(){return this._dom}},{key:"selectors",get:function(){return this._selectors}},{key:"elements",get:function(){return this._elements}},{key:"isTopLevel",get:function(){return this._root}},{key:"openClass",get:function(){return this.isTopLevel?this._openClass:this.elements.rootMenu.openClass},set:function(e){g({openClass:e}),this._openClass!==e&&(this._openClass=e)}},{key:"closeClass",get:function(){return this.isTopLevel?this._closeClass:this.elements.rootMenu.closeClass},set:function(e){g({closeClass:e}),this._closeClass!==e&&(this._closeClass=e)}},{key:"currentChild",get:function(){return this._currentChild},set:function(e){function t(e){if(["mouse","character"].includes(e.currentEvent)&&e.elements.parentMenu)for(var t=0,n=!1;!n&&t<e.elements.parentMenu.elements.menuItems.length;){var o=e.elements.parentMenu.elements.menuItems[t];o.isSubmenuItem&&o.elements.toggle.elements.controlledMenu===e&&(n=!0,e.elements.parentMenu.currentEvent=e.currentEvent,e.elements.parentMenu.currentChild=t),t++}}v("number",{value:e}),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))}},{key:"focusState",get:function(){return this._focusState},set:function(t){!function(t){try{if("object"!==e(t)){var n=e(t);throw new TypeError("AccessibleMenu: Values given to isValidState() must be inside of an object. ".concat(n," given."))}var o=["none","self","child"];for(var s in t)if(!o.includes(t[s]))throw new TypeError("AccessibleMenu: ".concat(s," must be one of the following values: ").concat(o.join(", "),'. "').concat(t[s],'" given.'))}catch(e){return console.error(e),!1}}({value:t}),this._focusState!==t&&(this._focusState=t),this.elements.submenuToggles.length>0&&("self"===t||"none"===t)&&this.elements.submenuToggles.forEach((function(e){e.elements.controlledMenu.focusState="none"})),!this.elements.parentMenu||"self"!==t&&"child"!==t||(this.elements.parentMenu.focusState="child")}},{key:"currentEvent",get:function(){return this._currentEvent},set:function(t){!function(t){try{if("object"!==e(t)){var n=e(t);throw new TypeError("AccessibleMenu: Values given to isValidEvent() must be inside of an object. ".concat(n," given."))}var o=["none","mouse","keyboard","character"];for(var s in t)if(!o.includes(t[s]))throw new TypeError("AccessibleMenu: ".concat(s," must be one of the following values: ").concat(o.join(", "),'. "').concat(t[s],'" given.'))}catch(e){return console.error(e),!1}}({value:t}),this._currentEvent!==t&&(this._currentEvent=t,this.elements.submenuToggles.length>0&&this.elements.submenuToggles.forEach((function(e){e.elements.controlledMenu.currentEvent=t})))}},{key:"currentMenuItem",get:function(){return this.elements.menuItems[this.currentChild]}},{key:"hoverType",get:function(){return this._root?this._hoverType:this.elements.rootMenu.hoverType},set:function(e){y({value:e}),this._hoverType!==e&&(this._hoverType=e)}},{key:"hoverDelay",get:function(){return this._root?this._hoverDelay:this.elements.rootMenu.hoverDelay},set:function(e){v("number",{value:e}),this._hoverDelay!==e&&(this._hoverDelay=e)}},{key:"shouldFocus",get:function(){var e=!1;return"keyboard"!==this.currentEvent&&"character"!==this.currentEvent||(e=!0),"mouse"===this.currentEvent&&"dynamic"===this.hoverType&&(e=!0),e}},{key:"_validate",value:function(){var e=!0;return null!==this._dom.container||null!==this._dom.controller?f(HTMLElement,{menuElement:this._dom.menu,controllerElement:this._dom.controller,containerElement:this._dom.container})||(e=!1):f(HTMLElement,{menuElement:this._dom.menu})||(e=!1),""!==this._selectors.submenuItems?p({menuItemSelector:this._selectors.menuItems,menuLinkSelector:this._selectors.menuLinks,submenuItemSelector:this._selectors.submenuItems,submenuToggleSelector:this._selectors.submenuToggles,submenuSelector:this._selectors.submenus})||(e=!1):p({menuItemSelector:this._selectors.menuItems,menuLinkSelector:this._selectors.menuLinks})||(e=!1),""===this._openClass||g({openClass:this._openClass})||(e=!1),""===this._closeClass||g({closeClass:this._closeClass})||(e=!1),v("boolean",{isTopLevel:this._root})||(e=!1),null===this._elements.parentMenu||f(n,{parentMenu:this._elements.parentMenu})||(e=!1),y({hoverType:this._hoverType})||(e=!1),v("number",{hoverDelay:this._hoverDelay})||(e=!1),e}},{key:"_setDOMElementType",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.dom.menu,n=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];if("string"!=typeof this.selectors[e])throw new Error('AccessibleMenu: "'.concat(e,'" is not a valid element type within the menu.'));if(!Array.isArray(this.dom[e]))throw new Error('AccessibleMenu: The "'.concat(e,'" element cannot be set through _setDOMElementType.'));t!==this.dom.menu&&f(HTMLElement,{base:t});var o=Array.from(t.querySelectorAll(this.selectors[e])),s=o.filter((function(e){return e.parentElement===t}));this._dom[e]=n?s:[].concat(h(this._dom[e]),h(s))}},{key:"_resetDOMElementType",value:function(e){if(void 0===this.dom[e])throw new Error('AccessibleMenu: "'.concat(e,'" is not a valid element type within the menu.'));if(!Array.isArray(this.dom[e]))throw new Error('AccessibleMenu: The "'.concat(e,'" element cannot be reset through _resetDOMElementType.'));this._dom[e]=[]}},{key:"_setDOMElements",value:function(){var e=this;this._setDOMElementType("menuItems"),""!==this.selectors.submenuItems&&(this._setDOMElementType("submenuItems"),this._resetDOMElementType("submenuToggles"),this._resetDOMElementType("submenus"),this.dom.submenuItems.forEach((function(t){e._setDOMElementType("submenuToggles",t,!1),e._setDOMElementType("submenus",t,!1)})))}},{key:"_findRootMenu",value:function(e){if(e.isTopLevel)this._elements.rootMenu=e;else{if(null===e.elements.parentMenu)throw new Error("Cannot find root menu.");this._findRootMenu(e.elements.parentMenu)}}},{key:"_createChildElements",value:function(){var e=this;this.dom.menuItems.forEach((function(t){var n;if(e.dom.submenuItems.includes(t)){var o=t.querySelector(e.selectors.submenuToggles),s=t.querySelector(e.selectors.submenus),r=new e._MenuType({menuElement:s,menuItemSelector:e.selectors.menuItems,menuLinkSelector:e.selectors.menuLinks,submenuItemSelector:e.selectors.submenuItems,submenuToggleSelector:e.selectors.submenuToggles,submenuSelector:e.selectors.submenus,openClass:e.openClass,closeClass:e.closeClass,isTopLevel:!1,parentMenu:e,hoverType:e.hoverType,hoverDelay:e.hoverDelay}),l=new e._MenuToggleType({menuToggleElement:o,parentElement:t,controlledMenu:r,parentMenu:e});e._elements.submenuToggles.push(l),n=new e._MenuItemType({menuItemElement:t,menuLinkElement:o,parentMenu:e,isSubmenuItem:!0,childMenu:r,toggle:l})}else{var u=t.querySelector(e.selectors.menuLinks);n=new e._MenuItemType({menuItemElement:t,menuLinkElement:u,parentMenu:e})}e._elements.menuItems.push(n)}))}},{key:"_handleFocus",value:function(){var e=this;this.elements.menuItems.forEach((function(t,n){t.dom.link.addEventListener("focus",(function(){e.focusState="self",e.currentChild=n}))}))}},{key:"_handleClick",value:function(){var e=this,t=b("touchstart",this.dom.menu)?"touchstart":"mousedown",n=b("touchend",this.dom.menu)?"touchend":"mouseup";function o(e,t,n){C(n),t.toggle(),t.isOpen&&(e.focusState="self",t.elements.controlledMenu.focusState="none")}this.elements.menuItems.forEach((function(s,r){s.dom.link.addEventListener(t,(function(){e.currentEvent="mouse",e.elements.rootMenu.blurChildren(),e.focusChild(r)})),s.isSubmenuItem&&(s.elements.toggle.dom.toggle["on".concat(n)]=function(t){e.currentEvent="mouse",o(e,s.elements.toggle,t)})})),this.isTopLevel&&this.elements.controller&&(this.elements.controller.dom.toggle["on".concat(n)]=function(t){e.currentEvent="mouse",o(e,e.elements.controller,t)})}},{key:"_handleHover",value:function(){var e=this;this.elements.menuItems.forEach((function(t,n){t.dom.link.addEventListener("mouseenter",(function(){if("on"===e.hoverType)e.currentEvent="mouse",e.currentChild=n,t.isSubmenuItem&&t.elements.toggle.preview();else if("dynamic"===e.hoverType){var o=e.elements.submenuToggles.some((function(e){return e.isOpen}));e.currentChild=n,e.isTopLevel&&"none"===e.focusState||(e.currentEvent="mouse",e.focusCurrentChild()),!t.isSubmenuItem||e.isTopLevel&&!o||(e.currentEvent="mouse",t.elements.toggle.preview())}})),t.isSubmenuItem&&t.dom.item.addEventListener("mouseleave",(function(){"on"===e.hoverType?e.hoverDelay>0?setTimeout((function(){e.currentEvent="mouse",t.elements.toggle.close()}),e.hoverDelay):(e.currentEvent="mouse",t.elements.toggle.close()):"dynamic"===e.hoverType&&(e.isTopLevel||(e.hoverDelay>0?setTimeout((function(){e.currentEvent="mouse",t.elements.toggle.close(),e.focusCurrentChild()}),e.hoverDelay):(e.currentEvent="mouse",t.elements.toggle.close(),e.focusCurrentChild())))}))}))}},{key:"_handleKeydown",value:function(){var e=this;this.isTopLevel&&this.elements.controller&&this.elements.controller.dom.toggle.addEventListener("keydown",(function(t){e.currentEvent="keyboard";var n=E(t);"Space"!==n&&"Enter"!==n||C(t)}))}},{key:"_handleKeyup",value:function(){var e=this;this.isTopLevel&&this.elements.controller&&this.elements.controller.dom.toggle.addEventListener("keyup",(function(t){e.currentEvent="keyboard";var n=E(t);"Space"!==n&&"Enter"!==n||(C(t),e.elements.controller.open(),e.focusFirstChild())}))}},{key:"focus",value:function(){this.focusState="self",this.shouldFocus&&this.dom.menu.focus()}},{key:"blur",value:function(){this.focusState="none",this.shouldFocus&&this.dom.menu.blur()}},{key:"focusCurrentChild",value:function(){this.focusState="self",-1!==this.currentChild&&this.currentMenuItem.focus()}},{key:"focusChild",value:function(e){this.blurCurrentChild(),this.currentChild=e,this.focusCurrentChild()}},{key:"focusFirstChild",value:function(){this.focusChild(0)}},{key:"focusLastChild",value:function(){this.focusChild(this.elements.menuItems.length-1)}},{key:"focusNextChild",value:function(){this.currentChild<this.elements.menuItems.length-1?this.focusChild(this.currentChild+1):this.focusCurrentChild()}},{key:"focusPreviousChild",value:function(){this.currentChild>0?this.focusChild(this.currentChild-1):this.focusCurrentChild()}},{key:"blurCurrentChild",value:function(){this.focusState="none",-1!==this.currentChild&&this.currentMenuItem.blur()}},{key:"focusController",value:function(){this.dom.controller&&(this.shouldFocus&&this.dom.controller.focus(),this.focusState="none")}},{key:"focusContainer",value:function(){this.dom.container&&(this.shouldFocus&&this.dom.container.focus(),this.focusState="none")}},{key:"closeChildren",value:function(){this.elements.submenuToggles.forEach((function(e){return e.close()}))}},{key:"blurChildren",value:function(){this.elements.menuItems.forEach((function(e){e.blur(),e.isSubmenuItem&&e.elements.childMenu.blurChildren()}))}}]),n}(),I=function(e){r(s,e);var n=m(s);function s(e){var o,r=e.menuItemElement,l=e.menuLinkElement,u=e.parentMenu,i=e.isSubmenuItem,c=void 0!==i&&i,m=e.childMenu,a=void 0===m?null:m,h=e.toggle,d=void 0===h?null:h,f=e.initialize,v=void 0===f||f;return t(this,s),o=n.call(this,{menuItemElement:r,menuLinkElement:l,parentMenu:u,isSubmenuItem:c,childMenu:a,toggle:d}),v&&o.initialize(),o}return o(s,[{key:"initialize",value:function(){a(l(s.prototype),"initialize",this).call(this),this.dom.item.setAttribute("role","none"),this.dom.link.setAttribute("role","treeitem"),this.dom.link.tabIndex=-1}},{key:"focus",value:function(){a(l(s.prototype),"focus",this).call(this),this.dom.link.tabIndex=0}},{key:"blur",value:function(){a(l(s.prototype),"blur",this).call(this),this.dom.link.tabIndex=-1}}]),s}(_),k=function(e){r(o,e);var n=m(o);function o(e){var s,r=e.menuToggleElement,l=e.parentElement,u=e.controlledMenu,i=e.parentMenu,c=void 0===i?null:i,m=e.initialize,a=void 0===m||m;return t(this,o),s=n.call(this,{menuToggleElement:r,parentElement:l,controlledMenu:u,parentMenu:c}),a&&s.initialize(),s}return o}(M);return function(e){r(u,e);var n=m(u);function u(e){var o,r=e.menuElement,l=e.menuItemSelector,c=void 0===l?"li":l,m=e.menuLinkSelector,a=void 0===m?"a":m,h=e.submenuItemSelector,d=void 0===h?"":h,f=e.submenuToggleSelector,v=void 0===f?"a":f,p=e.submenuSelector,g=void 0===p?"ul":p,y=e.controllerElement,b=void 0===y?null:y,M=e.containerElement,_=void 0===M?null:M,E=e.openClass,C=void 0===E?"show":E,T=e.closeClass,w=void 0===T?"hide":T,S=e.isTopLevel,L=void 0===S||S,A=e.parentMenu,O=void 0===A?null:A,D=e.hoverType,j=void 0===D?"off":D,x=e.hoverDelay,N=void 0===x?250:x,z=e.initialize,R=void 0===z||z;return t(this,u),s(i(o=n.call(this,{menuElement:r,menuItemSelector:c,menuLinkSelector:a,submenuItemSelector:d,submenuToggleSelector:v,submenuSelector:g,controllerElement:b,containerElement:_,openClass:C,closeClass:w,isTopLevel:L,parentMenu:O,hoverType:j,hoverDelay:N})),"_MenuType",u),s(i(o),"_MenuItemType",I),s(i(o),"_MenuToggleType",k),R&&o.initialize(),o}return o(u,[{key:"initialize",value:function(){try{a(l(u.prototype),"initialize",this).call(this),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)}}},{key:"_handleKeydown",value:function(){var e=this;a(l(u.prototype),"_handleKeydown",this).call(this),this.dom.menu.addEventListener("keydown",(function(t){e.currentEvent="keyboard";var n=E(t);if("Tab"===n&&("none"!==e.elements.rootMenu.focusState?e.elements.rootMenu.blur():e.elements.rootMenu.focus()),"self"===e.focusState){(["Space","ArrowUp","ArrowDown","ArrowLeft","Asterisk","Home","End"].includes(n)||e.currentMenuItem.isSubmenuItem&&["Enter","ArrowRight"].includes(n)||e.elements.controller&&["Escape"].includes(n))&&C(t)}}))}},{key:"_handleKeyup",value:function(){var e=this;a(l(u.prototype),"_handleKeyup",this).call(this),this.dom.menu.addEventListener("keyup",(function(t){e.currentEvent="keyboard";var n=E(t),o=t.altKey,s=t.crtlKey,r=t.metaKey;if("Character"!==n||(o||s||r)){if("self"===e.focusState)if("Enter"===n||"Space"===n)C(t),e.currentMenuItem.isSubmenuItem?e.currentMenuItem.elements.toggle.isOpen?e.currentMenuItem.elements.toggle.close():e.currentMenuItem.elements.toggle.preview():e.currentMenuItem.dom.link.click();else if("Escape"===n)e.isTopLevel&&e.elements.controller&&e.elements.controller.isOpen&&(e.elements.controller.close(),e.focusController());else if("ArrowDown"===n)C(t),e.currentMenuItem.isSubmenuItem&&e.currentMenuItem.elements.toggle.isOpen?(e.blurCurrentChild(),e.currentMenuItem.elements.childMenu.currentEvent=e.currentEvent,e.currentMenuItem.elements.childMenu.focusFirstChild()):e.isTopLevel||e.currentChild!==e.elements.menuItems.length-1?e.focusNextChild():e.focusParentsNextChild();else if("ArrowUp"===n){C(t);var l=e.elements.menuItems[e.currentChild-1];l&&l.isSubmenuItem&&l.elements.toggle.isOpen?(e.blurCurrentChild(),e.currentChild=e.currentChild-1,e.currentMenuItem.elements.childMenu.currentEvent=e.currentEvent,e.focusChildsLastNode()):e.isTopLevel||0!==e.currentChild?e.focusPreviousChild():(e.blurCurrentChild(),e.elements.parentMenu.currentEvent=e.currentEvent,e.elements.parentMenu.focusCurrentChild())}else"ArrowRight"===n?e.currentMenuItem.isSubmenuItem&&(C(t),e.currentMenuItem.elements.toggle.isOpen?(e.blurCurrentChild(),e.currentMenuItem.elements.childMenu.currentEvent=e.currentEvent,e.currentMenuItem.elements.childMenu.focusFirstChild()):e.currentMenuItem.elements.toggle.preview()):"ArrowLeft"===n?(C(t),e.currentMenuItem.isSubmenuItem&&e.currentMenuItem.elements.toggle.isOpen?(e.currentMenuItem.elements.childMenu.blurCurrentChild(),e.currentMenuItem.elements.toggle.close()):e.isTopLevel||(e.blurCurrentChild(),e.elements.parentMenu.currentEvent=e.currentEvent,e.elements.parentMenu.focusCurrentChild())):"Home"===n?(C(t),e.blurCurrentChild(),e.elements.rootMenu.focusFirstChild()):"End"===n?(C(t),e.blurCurrentChild(),e.elements.rootMenu.focusLastNode()):"Asterisk"===n&&(C(t),e.openChildren())}else C(t),e.elements.rootMenu.currentEvent="character",e.focusNextNodeWithCharacter(t.key)}))}},{key:"focusLastNode",value:function(){var e=this.elements.menuItems.length-1,t=this.elements.menuItems[e];t.isSubmenuItem&&t.elements.toggle.isOpen?(this.currentChild=e,t.elements.childMenu.currentEvent=this.currentEvent,t.elements.childMenu.focusLastNode()):this.focusLastChild()}},{key:"openChildren",value:function(){this.elements.submenuToggles.forEach((function(e){return e.preview()}))}},{key:"focusNextNodeWithCharacter",value:function(e){for(var t=e.toLowerCase(),n=function e(t){var n=[];return t.elements.menuItems.forEach((function(t){n.push(t),t.isSubmenuItem&&t.elements.toggle.isOpen&&(n=[].concat(h(n),h(e(t.elements.toggle.elements.controlledMenu))))})),n}(this.elements.rootMenu),o=n.indexOf(this.currentMenuItem)+1,s=[].concat(h(n.slice(o)),h(n.slice(0,o))),r=0,l=!1;!l&&r<s.length;){if((s[r].dom.item.innerText?s[r].dom.item.innerText:s[r].dom.item.textContent).replace(/[\s]/g,"").toLowerCase().charAt(0)===t){l=!0;var u=s[r].elements.parentMenu,i=u.elements.menuItems.indexOf(s[r]);this.elements.rootMenu.blurChildren(),u.focusChild(i)}r++}}},{key:"focusParentsNextChild",value:function(){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()))}},{key:"focusChildsLastNode",value:function(){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())}}]),u}(T)}();
var Treeview=function(){"use strict";function e(t){return e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},e(t)}function t(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function n(e,t){for(var n=0;n<t.length;n++){var s=t[n];s.enumerable=s.enumerable||!1,s.configurable=!0,"value"in s&&(s.writable=!0),Object.defineProperty(e,s.key,s)}}function s(e,t,s){return t&&n(e.prototype,t),s&&n(e,s),e}function o(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function r(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&i(e,t)}function l(e){return l=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},l(e)}function i(e,t){return i=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},i(e,t)}function u(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function c(e,t){if(t&&("object"==typeof t||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return u(e)}function m(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,s=l(e);if(t){var o=l(this).constructor;n=Reflect.construct(s,arguments,o)}else n=s.apply(this,arguments);return c(this,n)}}function a(e,t,n){return a="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(e,t,n){var s=function(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&null!==(e=l(e)););return e}(e,t);if(s){var o=Object.getOwnPropertyDescriptor(s,t);return o.get?o.get.call(n):o.value}},a(e,t,n||e)}function h(e){return function(e){if(Array.isArray(e))return d(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,t){if(!e)return;if("string"==typeof e)return d(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return d(e,t)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function d(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,s=new Array(t);n<t;n++)s[n]=e[n];return s}function f(t,n){try{if("object"!==e(n)){var s=e(n);throw new TypeError("AccessibleMenu: Elements given to isValidInstance() must be inside of an object. ".concat(s," given."))}for(var o in n)if(!(n[o]instanceof t)){var r=e(n[o]);throw new TypeError("AccessibleMenu: ".concat(o," must be an instance of ").concat(t.name,". ").concat(r," given."))}return!0}catch(e){return console.error(e),!1}}function v(t,n){try{if("object"!==e(n)){var s=e(n);throw new TypeError("AccessibleMenu: Values given to isValidType() must be inside of an object. ".concat(s," given."))}for(var o in n){var r=e(n[o]);if(r!==t)throw new TypeError("AccessibleMenu: ".concat(o," must be a ").concat(t,". ").concat(r," given."))}return!0}catch(e){return console.error(e),!1}}function p(t){try{if("object"!==e(t)){var n=e(t);throw new TypeError("AccessibleMenu: Values given to isCSSSelector() must be inside of an object. ".concat(n," given."))}for(var s in t)try{if(null===t[s])throw new Error;document.querySelector(t[s])}catch(e){throw new TypeError("AccessibleMenu: ".concat(s,' must be a valid CSS selector. "').concat(t[s],'" given.'))}return!0}catch(e){return console.error(e),!1}}function g(t){try{if("object"!==e(t)||Array.isArray(t)){var n=e(t);throw new TypeError("AccessibleMenu: Values given to isValidClassList() must be inside of an object. ".concat(n," given."))}var s=function(n){var s=e(t[n]);if("string"!==s){if(!Array.isArray(t[n]))throw new TypeError("AccessibleMenu: ".concat(n," must be a string or an array of strings. ").concat(s," given."));t[n].forEach((function(e){if("string"!=typeof e)throw new TypeError("AccessibleMenu: ".concat(n," must be a string or an array of strings. An array containing non-strings given."))}))}else{var o={};o[n]=t[n],p(o)}};for(var o in t)s(o);return!0}catch(e){return console.error(e),!1}}function y(t){try{if("object"!==e(t)){var n=e(t);throw new TypeError("AccessibleMenu: Values given to isValidHoverType() must be inside of an object. ".concat(n," given."))}var s=["off","on","dynamic"];for(var o in t)if(!s.includes(t[o]))throw new TypeError("AccessibleMenu: ".concat(o," must be one of the following values: ").concat(s.join(", "),'. "').concat(t[o],'" given.'));return!0}catch(e){return console.error(e),!1}}var b=function(){function e(n){var s=n.menuToggleElement,r=n.parentElement,l=n.controlledMenu,i=n.parentMenu,u=void 0===i?null:i;t(this,e),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=s,this._dom.parent=r,this._elements.controlledMenu=l,this._elements.parentMenu=u}return s(e,[{key:"initialize",value:function(){if(this.dom.toggle.setAttribute("aria-haspopup","true"),this.dom.toggle.setAttribute("aria-expanded","false"),function(e,t){if(v("string",{tagName:e})&&f(HTMLElement,t)){var n=e.toLowerCase(),s=!0;for(var o in t)t[o].tagName.toLowerCase()!==n&&(s=!1);return s}return!1}("button",{toggle:this.dom.toggle})||this.dom.toggle.setAttribute("role","button"),""===this.dom.toggle.id||""===this.elements.controlledMenu.dom.menu.id){var e=Math.random().toString(36).replace(/[^a-z]+/g,"").substr(0,10),t=this.dom.toggle.innerText.replace(/[^a-zA-Z0-9\s]/g,""),n=e;!t.replace(/\s/g,"").length&&this.dom.toggle.getAttribute("aria-label")&&(t=this.dom.toggle.getAttribute("aria-label").replace(/[^a-zA-Z0-9\s]/g,"")),t.replace(/\s/g,"").length>0&&((t=t.toLowerCase().replace(/\s+/g,"-")).startsWith("-")&&(t=t.substring(1)),t.endsWith("-")&&(t=t.slice(0,-1)),n="".concat(t,"-").concat(n)),this.dom.toggle.id=this.dom.toggle.id||"".concat(n,"-menu-button"),this.elements.controlledMenu.dom.menu.id=this.elements.controlledMenu.dom.menu.id||"".concat(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)}},{key:"dom",get:function(){return this._dom}},{key:"elements",get:function(){return this._elements}},{key:"isOpen",get:function(){return this._open},set:function(e){v("boolean",{value:e}),this._open=e}},{key:"_expand",value:function(){var e,t,n=!(arguments.length>0&&void 0!==arguments[0])||arguments[0],s=this.elements.controlledMenu,o=s.closeClass,r=s.openClass;(this.dom.toggle.setAttribute("aria-expanded","true"),""!==r)&&("string"==typeof r?this.elements.controlledMenu.dom.menu.classList.add(r):(e=this.elements.controlledMenu.dom.menu.classList).add.apply(e,h(r)));""!==o&&("string"==typeof o?this.elements.controlledMenu.dom.menu.classList.remove(o):(t=this.elements.controlledMenu.dom.menu.classList).remove.apply(t,h(o)));n&&this.dom.toggle.dispatchEvent(this._expandEvent)}},{key:"_collapse",value:function(){var e,t,n=!(arguments.length>0&&void 0!==arguments[0])||arguments[0],s=this.elements.controlledMenu,o=s.closeClass,r=s.openClass;(this.dom.toggle.setAttribute("aria-expanded","false"),""!==o)&&("string"==typeof o?this.elements.controlledMenu.dom.menu.classList.add(o):(e=this.elements.controlledMenu.dom.menu.classList).add.apply(e,h(o)));""!==r&&("string"==typeof r?this.elements.controlledMenu.dom.menu.classList.remove(r):(t=this.elements.controlledMenu.dom.menu.classList).remove.apply(t,h(r)));n&&this.dom.toggle.dispatchEvent(this._collapseEvent)}},{key:"open",value:function(){this.elements.controlledMenu.focusState="self",this._expand(),this.isOpen=!0}},{key:"preview",value:function(){this.elements.parentMenu&&(this.elements.parentMenu.focusState="self"),this._expand(),this.isOpen=!0}},{key:"close",value:function(){this.isOpen&&(this.elements.controlledMenu.currentChild=0,this.elements.controlledMenu.blur(),this.elements.parentMenu&&(this.elements.parentMenu.focusState="self"),this._collapse(),this.isOpen=!1)}},{key:"toggle",value:function(){this.isOpen?this.close():this.open()}},{key:"closeSiblings",value:function(){var e=this;this.elements.parentMenu&&this.elements.parentMenu.elements.submenuToggles.forEach((function(t){t!==e&&t.close()}))}},{key:"closeChildren",value:function(){this.elements.controlledMenu.elements.submenuToggles.forEach((function(e){return e.close()}))}}]),e}(),M=function(){function e(n){var s=n.menuItemElement,r=n.menuLinkElement,l=n.parentMenu,i=n.isSubmenuItem,u=void 0!==i&&i,c=n.childMenu,m=void 0===c?null:c,a=n.toggle,h=void 0===a?null:a;t(this,e),o(this,"_dom",{item:null,link:null}),o(this,"_elements",{parentMenu:null,childMenu:null,toggle:null}),o(this,"_submenu",!1),this._dom.item=s,this._dom.link=r,this._elements.parentMenu=l,this._elements.childMenu=m,this._elements.toggle=h,this._submenu=u}return s(e,[{key:"initialize",value:function(){}},{key:"dom",get:function(){return this._dom}},{key:"elements",get:function(){return this._elements}},{key:"isSubmenuItem",get:function(){return this._submenu}},{key:"focus",value:function(){this.elements.parentMenu.shouldFocus&&this.dom.link.focus()}},{key:"blur",value:function(){this.elements.parentMenu.shouldFocus&&this.dom.link.blur()}}]),e}();function E(e){try{var t=e.key||e.keyCode,n={Enter:"Enter"===t||13===t,Space:" "===t||"Spacebar"===t||32===t,Escape:"Escape"===t||"Esc"===t||27===t,ArrowUp:"ArrowUp"===t||"Up"===t||38===t,ArrowRight:"ArrowRight"===t||"Right"===t||39===t,ArrowDown:"ArrowDown"===t||"Down"===t||40===t,ArrowLeft:"ArrowLeft"===t||"Left"===t||37===t,Home:"Home"===t||36===t,End:"End"===t||35===t,Character:isNaN(t)&&!!t.match(/^[a-zA-Z]{1}$/),Tab:"Tab"===t||9===t,Asterisk:"*"===t||56===t};return Object.keys(n).find((function(e){return!0===n[e]}))||""}catch(e){return""}}function _(e){e.preventDefault(),e.stopPropagation()}var C=function(){function n(e){var s=e.menuElement,r=e.menuItemSelector,l=void 0===r?"li":r,i=e.menuLinkSelector,u=void 0===i?"a":i,c=e.submenuItemSelector,m=void 0===c?"":c,a=e.submenuToggleSelector,h=void 0===a?"a":a,d=e.submenuSelector,f=void 0===d?"ul":d,v=e.controllerElement,p=void 0===v?null:v,g=e.containerElement,y=void 0===g?null:g,E=e.openClass,_=void 0===E?"show":E,C=e.closeClass,T=void 0===C?"hide":C,I=e.isTopLevel,k=void 0===I||I,w=e.parentMenu,S=void 0===w?null:w,L=e.hoverType,A=void 0===L?"off":L,O=e.hoverDelay,D=void 0===O?250:O;t(this,n),o(this,"_MenuType",n),o(this,"_MenuItemType",M),o(this,"_MenuToggleType",b),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,"_root",!0),o(this,"_currentChild",0),o(this,"_focusState","none"),o(this,"_currentEvent","none"),o(this,"_hoverType","off"),o(this,"_hoverDelay",250),this._dom.menu=s,this._dom.controller=p,this._dom.container=y,this._selectors.menuItems=l,this._selectors.menuLinks=u,this._selectors.submenuItems=m,this._selectors.submenuToggles=h,this._selectors.submenus=f,this._elements.menuItems=[],this._elements.submenuToggles=[],this._elements.controller=null,this._elements.parentMenu=S,this._elements.rootMenu=k?this:null,this._openClass=_||"",this._closeClass=T||"",this._root=k,this._hoverType=A,this._hoverDelay=D}return s(n,[{key:"initialize",value:function(){if(!this._validate())throw new Error("AccesibleMenu: cannot initialize menu. See other error messages for more information.");if(null===this.elements.rootMenu&&this._findRootMenu(this),this._setDOMElements(),this.isTopLevel&&this.dom.controller&&this.dom.container){var e=new this._MenuToggleType({menuToggleElement:this.dom.controller,parentElement:this.dom.container,controlledMenu:this});this._elements.controller=e}this._createChildElements()}},{key:"dom",get:function(){return this._dom}},{key:"selectors",get:function(){return this._selectors}},{key:"elements",get:function(){return this._elements}},{key:"isTopLevel",get:function(){return this._root}},{key:"openClass",get:function(){return this.isTopLevel?this._openClass:this.elements.rootMenu.openClass},set:function(e){g({openClass:e}),this._openClass!==e&&(this._openClass=e)}},{key:"closeClass",get:function(){return this.isTopLevel?this._closeClass:this.elements.rootMenu.closeClass},set:function(e){g({closeClass:e}),this._closeClass!==e&&(this._closeClass=e)}},{key:"currentChild",get:function(){return this._currentChild},set:function(e){function t(e){if(["mouse","character"].includes(e.currentEvent)&&e.elements.parentMenu)for(var t=0,n=!1;!n&&t<e.elements.parentMenu.elements.menuItems.length;){var s=e.elements.parentMenu.elements.menuItems[t];s.isSubmenuItem&&s.elements.toggle.elements.controlledMenu===e&&(n=!0,e.elements.parentMenu.currentEvent=e.currentEvent,e.elements.parentMenu.currentChild=t),t++}}v("number",{value:e}),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))}},{key:"focusState",get:function(){return this._focusState},set:function(t){!function(t){try{if("object"!==e(t)){var n=e(t);throw new TypeError("AccessibleMenu: Values given to isValidState() must be inside of an object. ".concat(n," given."))}var s=["none","self","child"];for(var o in t)if(!s.includes(t[o]))throw new TypeError("AccessibleMenu: ".concat(o," must be one of the following values: ").concat(s.join(", "),'. "').concat(t[o],'" given.'))}catch(e){return console.error(e),!1}}({value:t}),this._focusState!==t&&(this._focusState=t),this.elements.submenuToggles.length>0&&("self"===t||"none"===t)&&this.elements.submenuToggles.forEach((function(e){e.elements.controlledMenu.focusState="none"})),!this.elements.parentMenu||"self"!==t&&"child"!==t||(this.elements.parentMenu.focusState="child")}},{key:"currentEvent",get:function(){return this._currentEvent},set:function(t){!function(t){try{if("object"!==e(t)){var n=e(t);throw new TypeError("AccessibleMenu: Values given to isValidEvent() must be inside of an object. ".concat(n," given."))}var s=["none","mouse","keyboard","character"];for(var o in t)if(!s.includes(t[o]))throw new TypeError("AccessibleMenu: ".concat(o," must be one of the following values: ").concat(s.join(", "),'. "').concat(t[o],'" given.'))}catch(e){return console.error(e),!1}}({value:t}),this._currentEvent!==t&&(this._currentEvent=t,this.elements.submenuToggles.length>0&&this.elements.submenuToggles.forEach((function(e){e.elements.controlledMenu.currentEvent=t})))}},{key:"currentMenuItem",get:function(){return this.elements.menuItems[this.currentChild]}},{key:"hoverType",get:function(){return this._root?this._hoverType:this.elements.rootMenu.hoverType},set:function(e){y({value:e}),this._hoverType!==e&&(this._hoverType=e)}},{key:"hoverDelay",get:function(){return this._root?this._hoverDelay:this.elements.rootMenu.hoverDelay},set:function(e){v("number",{value:e}),this._hoverDelay!==e&&(this._hoverDelay=e)}},{key:"shouldFocus",get:function(){var e=!1;return"keyboard"!==this.currentEvent&&"character"!==this.currentEvent||(e=!0),"mouse"===this.currentEvent&&"dynamic"===this.hoverType&&(e=!0),e}},{key:"_validate",value:function(){var e=!0;return null!==this._dom.container||null!==this._dom.controller?f(HTMLElement,{menuElement:this._dom.menu,controllerElement:this._dom.controller,containerElement:this._dom.container})||(e=!1):f(HTMLElement,{menuElement:this._dom.menu})||(e=!1),""!==this._selectors.submenuItems?p({menuItemSelector:this._selectors.menuItems,menuLinkSelector:this._selectors.menuLinks,submenuItemSelector:this._selectors.submenuItems,submenuToggleSelector:this._selectors.submenuToggles,submenuSelector:this._selectors.submenus})||(e=!1):p({menuItemSelector:this._selectors.menuItems,menuLinkSelector:this._selectors.menuLinks})||(e=!1),""===this._openClass||g({openClass:this._openClass})||(e=!1),""===this._closeClass||g({closeClass:this._closeClass})||(e=!1),v("boolean",{isTopLevel:this._root})||(e=!1),null===this._elements.parentMenu||f(n,{parentMenu:this._elements.parentMenu})||(e=!1),y({hoverType:this._hoverType})||(e=!1),v("number",{hoverDelay:this._hoverDelay})||(e=!1),e}},{key:"_setDOMElementType",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.dom.menu,n=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];if("string"!=typeof this.selectors[e])throw new Error('AccessibleMenu: "'.concat(e,'" is not a valid element type within the menu.'));if(!Array.isArray(this.dom[e]))throw new Error('AccessibleMenu: The "'.concat(e,'" element cannot be set through _setDOMElementType.'));t!==this.dom.menu&&f(HTMLElement,{base:t});var s=Array.from(t.querySelectorAll(this.selectors[e])),o=s.filter((function(e){return e.parentElement===t}));this._dom[e]=n?o:[].concat(h(this._dom[e]),h(o))}},{key:"_resetDOMElementType",value:function(e){if(void 0===this.dom[e])throw new Error('AccessibleMenu: "'.concat(e,'" is not a valid element type within the menu.'));if(!Array.isArray(this.dom[e]))throw new Error('AccessibleMenu: The "'.concat(e,'" element cannot be reset through _resetDOMElementType.'));this._dom[e]=[]}},{key:"_setDOMElements",value:function(){var e=this;this._setDOMElementType("menuItems"),""!==this.selectors.submenuItems&&(this._setDOMElementType("submenuItems"),this._resetDOMElementType("submenuToggles"),this._resetDOMElementType("submenus"),this.dom.submenuItems.forEach((function(t){e._setDOMElementType("submenuToggles",t,!1),e._setDOMElementType("submenus",t,!1)})))}},{key:"_findRootMenu",value:function(e){if(e.isTopLevel)this._elements.rootMenu=e;else{if(null===e.elements.parentMenu)throw new Error("Cannot find root menu.");this._findRootMenu(e.elements.parentMenu)}}},{key:"_createChildElements",value:function(){var e=this;this.dom.menuItems.forEach((function(t){var n;if(e.dom.submenuItems.includes(t)){var s=t.querySelector(e.selectors.submenuToggles),o=t.querySelector(e.selectors.submenus),r=new e._MenuType({menuElement:o,menuItemSelector:e.selectors.menuItems,menuLinkSelector:e.selectors.menuLinks,submenuItemSelector:e.selectors.submenuItems,submenuToggleSelector:e.selectors.submenuToggles,submenuSelector:e.selectors.submenus,openClass:e.openClass,closeClass:e.closeClass,isTopLevel:!1,parentMenu:e,hoverType:e.hoverType,hoverDelay:e.hoverDelay}),l=new e._MenuToggleType({menuToggleElement:s,parentElement:t,controlledMenu:r,parentMenu:e});e._elements.submenuToggles.push(l),n=new e._MenuItemType({menuItemElement:t,menuLinkElement:s,parentMenu:e,isSubmenuItem:!0,childMenu:r,toggle:l})}else{var i=t.querySelector(e.selectors.menuLinks);n=new e._MenuItemType({menuItemElement:t,menuLinkElement:i,parentMenu:e})}e._elements.menuItems.push(n)}))}},{key:"_handleFocus",value:function(){var e=this;this.elements.menuItems.forEach((function(t,n){t.dom.link.addEventListener("focus",(function(){e.focusState="self",e.currentChild=n}))}))}},{key:"_handleClick",value:function(){var e=this;function t(e,t,n){_(n),t.toggle(),t.isOpen&&(e.focusState="self",t.elements.controlledMenu.focusState="none")}this.elements.menuItems.forEach((function(n,s){n.dom.link.addEventListener("pointerdown",(function(){e.currentEvent="mouse",e.elements.rootMenu.blurChildren(),e.focusChild(s)}),{passive:!0}),n.isSubmenuItem&&n.elements.toggle.dom.toggle.addEventListener("pointerup",(function(s){e.currentEvent="mouse",t(e,n.elements.toggle,s)}))})),this.isTopLevel&&this.elements.controller&&this.elements.controller.dom.toggle.addEventListener("pointerup",(function(n){e.currentEvent="mouse",t(e,e.elements.controller,n)}))}},{key:"_handleHover",value:function(){var e=this;this.elements.menuItems.forEach((function(t,n){t.dom.link.addEventListener("mouseenter",(function(){if("on"===e.hoverType)e.currentEvent="mouse",e.currentChild=n,t.isSubmenuItem&&t.elements.toggle.preview();else if("dynamic"===e.hoverType){var s=e.elements.submenuToggles.some((function(e){return e.isOpen}));e.currentChild=n,e.isTopLevel&&"none"===e.focusState||(e.currentEvent="mouse",e.focusCurrentChild()),!t.isSubmenuItem||e.isTopLevel&&!s||(e.currentEvent="mouse",t.elements.toggle.preview())}})),t.isSubmenuItem&&t.dom.item.addEventListener("mouseleave",(function(){"on"===e.hoverType?e.hoverDelay>0?setTimeout((function(){e.currentEvent="mouse",t.elements.toggle.close()}),e.hoverDelay):(e.currentEvent="mouse",t.elements.toggle.close()):"dynamic"===e.hoverType&&(e.isTopLevel||(e.hoverDelay>0?setTimeout((function(){e.currentEvent="mouse",t.elements.toggle.close(),e.focusCurrentChild()}),e.hoverDelay):(e.currentEvent="mouse",t.elements.toggle.close(),e.focusCurrentChild())))}))}))}},{key:"_handleKeydown",value:function(){var e=this;this.isTopLevel&&this.elements.controller&&this.elements.controller.dom.toggle.addEventListener("keydown",(function(t){e.currentEvent="keyboard";var n=E(t);"Space"!==n&&"Enter"!==n||_(t)}))}},{key:"_handleKeyup",value:function(){var e=this;this.isTopLevel&&this.elements.controller&&this.elements.controller.dom.toggle.addEventListener("keyup",(function(t){e.currentEvent="keyboard";var n=E(t);"Space"!==n&&"Enter"!==n||(_(t),e.elements.controller.open(),e.focusFirstChild())}))}},{key:"focus",value:function(){this.focusState="self",this.shouldFocus&&this.dom.menu.focus()}},{key:"blur",value:function(){this.focusState="none",this.shouldFocus&&this.dom.menu.blur()}},{key:"focusCurrentChild",value:function(){this.focusState="self",-1!==this.currentChild&&this.currentMenuItem.focus()}},{key:"focusChild",value:function(e){this.blurCurrentChild(),this.currentChild=e,this.focusCurrentChild()}},{key:"focusFirstChild",value:function(){this.focusChild(0)}},{key:"focusLastChild",value:function(){this.focusChild(this.elements.menuItems.length-1)}},{key:"focusNextChild",value:function(){this.currentChild<this.elements.menuItems.length-1?this.focusChild(this.currentChild+1):this.focusCurrentChild()}},{key:"focusPreviousChild",value:function(){this.currentChild>0?this.focusChild(this.currentChild-1):this.focusCurrentChild()}},{key:"blurCurrentChild",value:function(){this.focusState="none",-1!==this.currentChild&&this.currentMenuItem.blur()}},{key:"focusController",value:function(){this.dom.controller&&(this.shouldFocus&&this.dom.controller.focus(),this.focusState="none")}},{key:"focusContainer",value:function(){this.dom.container&&(this.shouldFocus&&this.dom.container.focus(),this.focusState="none")}},{key:"closeChildren",value:function(){this.elements.submenuToggles.forEach((function(e){return e.close()}))}},{key:"blurChildren",value:function(){this.elements.menuItems.forEach((function(e){e.blur(),e.isSubmenuItem&&e.elements.childMenu.blurChildren()}))}}]),n}(),T=function(e){r(o,e);var n=m(o);function o(e){var s,r=e.menuItemElement,l=e.menuLinkElement,i=e.parentMenu,u=e.isSubmenuItem,c=void 0!==u&&u,m=e.childMenu,a=void 0===m?null:m,h=e.toggle,d=void 0===h?null:h,f=e.initialize,v=void 0===f||f;return t(this,o),s=n.call(this,{menuItemElement:r,menuLinkElement:l,parentMenu:i,isSubmenuItem:c,childMenu:a,toggle:d}),v&&s.initialize(),s}return s(o,[{key:"initialize",value:function(){a(l(o.prototype),"initialize",this).call(this),this.dom.item.setAttribute("role","none"),this.dom.link.setAttribute("role","treeitem"),this.dom.link.tabIndex=-1}},{key:"focus",value:function(){a(l(o.prototype),"focus",this).call(this),this.dom.link.tabIndex=0}},{key:"blur",value:function(){a(l(o.prototype),"blur",this).call(this),this.dom.link.tabIndex=-1}}]),o}(M),I=function(e){r(s,e);var n=m(s);function s(e){var o,r=e.menuToggleElement,l=e.parentElement,i=e.controlledMenu,u=e.parentMenu,c=void 0===u?null:u,m=e.initialize,a=void 0===m||m;return t(this,s),o=n.call(this,{menuToggleElement:r,parentElement:l,controlledMenu:i,parentMenu:c}),a&&o.initialize(),o}return s}(b);return function(e){r(i,e);var n=m(i);function i(e){var s,r=e.menuElement,l=e.menuItemSelector,c=void 0===l?"li":l,m=e.menuLinkSelector,a=void 0===m?"a":m,h=e.submenuItemSelector,d=void 0===h?"":h,f=e.submenuToggleSelector,v=void 0===f?"a":f,p=e.submenuSelector,g=void 0===p?"ul":p,y=e.controllerElement,b=void 0===y?null:y,M=e.containerElement,E=void 0===M?null:M,_=e.openClass,C=void 0===_?"show":_,k=e.closeClass,w=void 0===k?"hide":k,S=e.isTopLevel,L=void 0===S||S,A=e.parentMenu,O=void 0===A?null:A,D=e.hoverType,j=void 0===D?"off":D,x=e.hoverDelay,N=void 0===x?250:x,z=e.initialize,R=void 0===z||z;return t(this,i),o(u(s=n.call(this,{menuElement:r,menuItemSelector:c,menuLinkSelector:a,submenuItemSelector:d,submenuToggleSelector:v,submenuSelector:g,controllerElement:b,containerElement:E,openClass:C,closeClass:w,isTopLevel:L,parentMenu:O,hoverType:j,hoverDelay:N})),"_MenuType",i),o(u(s),"_MenuItemType",T),o(u(s),"_MenuToggleType",I),R&&s.initialize(),s}return s(i,[{key:"initialize",value:function(){try{a(l(i.prototype),"initialize",this).call(this),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)}}},{key:"_handleKeydown",value:function(){var e=this;a(l(i.prototype),"_handleKeydown",this).call(this),this.dom.menu.addEventListener("keydown",(function(t){e.currentEvent="keyboard";var n=E(t);if("Tab"===n&&("none"!==e.elements.rootMenu.focusState?e.elements.rootMenu.blur():e.elements.rootMenu.focus()),"self"===e.focusState){(["Space","ArrowUp","ArrowDown","ArrowLeft","Asterisk","Home","End"].includes(n)||e.currentMenuItem.isSubmenuItem&&["Enter","ArrowRight"].includes(n)||e.elements.controller&&["Escape"].includes(n))&&_(t)}}))}},{key:"_handleKeyup",value:function(){var e=this;a(l(i.prototype),"_handleKeyup",this).call(this),this.dom.menu.addEventListener("keyup",(function(t){e.currentEvent="keyboard";var n=E(t),s=t.altKey,o=t.crtlKey,r=t.metaKey;if("Character"!==n||(s||o||r)){if("self"===e.focusState)if("Enter"===n||"Space"===n)_(t),e.currentMenuItem.isSubmenuItem?e.currentMenuItem.elements.toggle.isOpen?e.currentMenuItem.elements.toggle.close():e.currentMenuItem.elements.toggle.preview():e.currentMenuItem.dom.link.click();else if("Escape"===n)e.isTopLevel&&e.elements.controller&&e.elements.controller.isOpen&&(e.elements.controller.close(),e.focusController());else if("ArrowDown"===n)_(t),e.currentMenuItem.isSubmenuItem&&e.currentMenuItem.elements.toggle.isOpen?(e.blurCurrentChild(),e.currentMenuItem.elements.childMenu.currentEvent=e.currentEvent,e.currentMenuItem.elements.childMenu.focusFirstChild()):e.isTopLevel||e.currentChild!==e.elements.menuItems.length-1?e.focusNextChild():e.focusParentsNextChild();else if("ArrowUp"===n){_(t);var l=e.elements.menuItems[e.currentChild-1];l&&l.isSubmenuItem&&l.elements.toggle.isOpen?(e.blurCurrentChild(),e.currentChild=e.currentChild-1,e.currentMenuItem.elements.childMenu.currentEvent=e.currentEvent,e.focusChildsLastNode()):e.isTopLevel||0!==e.currentChild?e.focusPreviousChild():(e.blurCurrentChild(),e.elements.parentMenu.currentEvent=e.currentEvent,e.elements.parentMenu.focusCurrentChild())}else"ArrowRight"===n?e.currentMenuItem.isSubmenuItem&&(_(t),e.currentMenuItem.elements.toggle.isOpen?(e.blurCurrentChild(),e.currentMenuItem.elements.childMenu.currentEvent=e.currentEvent,e.currentMenuItem.elements.childMenu.focusFirstChild()):e.currentMenuItem.elements.toggle.preview()):"ArrowLeft"===n?(_(t),e.currentMenuItem.isSubmenuItem&&e.currentMenuItem.elements.toggle.isOpen?(e.currentMenuItem.elements.childMenu.blurCurrentChild(),e.currentMenuItem.elements.toggle.close()):e.isTopLevel||(e.blurCurrentChild(),e.elements.parentMenu.currentEvent=e.currentEvent,e.elements.parentMenu.focusCurrentChild())):"Home"===n?(_(t),e.blurCurrentChild(),e.elements.rootMenu.focusFirstChild()):"End"===n?(_(t),e.blurCurrentChild(),e.elements.rootMenu.focusLastNode()):"Asterisk"===n&&(_(t),e.openChildren())}else _(t),e.elements.rootMenu.currentEvent="character",e.focusNextNodeWithCharacter(t.key)}))}},{key:"focusLastNode",value:function(){var e=this.elements.menuItems.length-1,t=this.elements.menuItems[e];t.isSubmenuItem&&t.elements.toggle.isOpen?(this.currentChild=e,t.elements.childMenu.currentEvent=this.currentEvent,t.elements.childMenu.focusLastNode()):this.focusLastChild()}},{key:"openChildren",value:function(){this.elements.submenuToggles.forEach((function(e){return e.preview()}))}},{key:"focusNextNodeWithCharacter",value:function(e){for(var t=e.toLowerCase(),n=function e(t){var n=[];return t.elements.menuItems.forEach((function(t){n.push(t),t.isSubmenuItem&&t.elements.toggle.isOpen&&(n=[].concat(h(n),h(e(t.elements.toggle.elements.controlledMenu))))})),n}(this.elements.rootMenu),s=n.indexOf(this.currentMenuItem)+1,o=[].concat(h(n.slice(s)),h(n.slice(0,s))),r=0,l=!1;!l&&r<o.length;){if((o[r].dom.item.innerText?o[r].dom.item.innerText:o[r].dom.item.textContent).replace(/[\s]/g,"").toLowerCase().charAt(0)===t){l=!0;var i=o[r].elements.parentMenu,u=i.elements.menuItems.indexOf(o[r]);this.elements.rootMenu.blurChildren(),i.focusChild(u)}r++}}},{key:"focusParentsNextChild",value:function(){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()))}},{key:"focusChildsLastNode",value:function(){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())}}]),i}(C)}();
//# sourceMappingURL=treeview.min.js.map
{
"name": "accessible-menu",
"version": "3.0.0",
"version": "3.0.1",
"description": "A JavaScript library to help you generate WCAG accessible menus in the DOM.",

@@ -65,6 +65,6 @@ "main": "index.js",

"eslint-plugin-promise": "^5.1.0",
"eslint-plugin-standard": "^5.0.0",
"husky": "^7.0.1",
"husky": "^7.0.2",
"jest": "^27.0.4",
"jest-extended": "^0.11.5",
"jest-environment-jsdom-latest": "^26.6.2",
"jest-extended": "^1.0.0",
"jsdoc": "^3.6.7",

@@ -71,0 +71,0 @@ "jsdoc-typeof-plugin": "^1.0.0",

@@ -5,3 +5,4 @@ # accessible-menu

[![License](https://img.shields.io/github/license/NickDJM/accessible-menu?style=for-the-badge)](/LICENSE)
[![Build and tests](https://img.shields.io/github/workflow/status/nickdjm/accessible-menu/Tests/3.x?style=for-the-badge)](https://github.com/NickDJM/accessible-menu/actions)
[![Jest tests](https://img.shields.io/github/workflow/status/nickdjm/accessible-menu/Tests/3.x?label=Tests&style=for-the-badge)](https://github.com/NickDJM/accessible-menu/actions/workflows/test.yml)
[![GitHub CodeQL](https://img.shields.io/github/workflow/status/nickdjm/accessible-menu/CodeQL/3.x?label=CodeQL&style=for-the-badge)](https://github.com/NickDJM/accessible-menu/actions/workflows/codeql-analysis.yml)

@@ -8,0 +9,0 @@ A JavaScript library to help you generate WCAG accessible menus in the DOM.

@@ -11,3 +11,2 @@ import BaseMenuToggle from "./_baseMenuToggle.js";

isValidHoverType,
isEventSupported,
} from "./validate.js";

@@ -893,13 +892,8 @@ import { preventEvent, keyPress } from "./eventHandlers.js";

*
* Depending on what is supported either `touchstart` and `touchend` or
* `mousedown` and `mouseup` will be used for all "click" event handling.
*
* - Adds a `touchend`/`mouseup` listener to the document so if the user clicks
* outside of the menu when it is open, the menu will close.
* - Adds a `touchstart`/`mousedown` listener to every menu item that will blur
* - Adds a `pointerdown` listener to every menu item that will blur
* all menu items in the entire menu structure (starting at the root menu) and
* then properly focus the clicked item.
* - Adds a `touchend`/`mouseup` listener to every submenu item that will properly
* - Adds a `pointerup` listener to every submenu item that will properly
* toggle the submenu open/closed.
* - Adds a `touchend`/`mouseup` listener to the menu's controller
* - Adds a `pointerup` listener to the menu's controller
* (if the menu is the root menu) so when it is clicked it will properly

@@ -911,10 +905,2 @@ * toggle open/closed.

_handleClick() {
// Use touch over mouse events when supported.
const startEventType = isEventSupported("touchstart", this.dom.menu)
? "touchstart"
: "mousedown";
const endEventType = isEventSupported("touchend", this.dom.menu)
? "touchend"
: "mouseup";
/**

@@ -940,14 +926,21 @@ * Toggles a toggle element.

// Properly focus the current menu item.
item.dom.link.addEventListener(startEventType, () => {
this.currentEvent = "mouse";
this.elements.rootMenu.blurChildren();
this.focusChild(index);
});
item.dom.link.addEventListener(
"pointerdown",
() => {
this.currentEvent = "mouse";
this.elements.rootMenu.blurChildren();
this.focusChild(index);
},
{ passive: true }
);
// Properly toggle submenus open and closed.
if (item.isSubmenuItem) {
item.elements.toggle.dom.toggle[`on${endEventType}`] = (event) => {
this.currentEvent = "mouse";
toggleToggle(this, item.elements.toggle, event);
};
item.elements.toggle.dom.toggle.addEventListener(
"pointerup",
(event) => {
this.currentEvent = "mouse";
toggleToggle(this, item.elements.toggle, event);
}
);
}

@@ -958,6 +951,9 @@ });

if (this.isTopLevel && this.elements.controller) {
this.elements.controller.dom.toggle[`on${endEventType}`] = (event) => {
this.currentEvent = "mouse";
toggleToggle(this, this.elements.controller, event);
};
this.elements.controller.dom.toggle.addEventListener(
"pointerup",
(event) => {
this.currentEvent = "mouse";
toggleToggle(this, this.elements.controller, event);
}
);
}

@@ -964,0 +960,0 @@ }

@@ -5,3 +5,3 @@ import BaseMenu from "./_baseMenu.js";

import { preventEvent, keyPress } from "./eventHandlers.js";
import { isValidType, isEventSupported } from "./validate.js";
import { isValidType } from "./validate.js";

@@ -208,8 +208,5 @@ /**

*
* Depending on what is supported either `touchstart` and `touchend` or
* `mousedown` and `mouseup` will be used for all "click" event handling.
*
* - Adds all event listeners listed in
* {@link BaseMenu#_handleClick|BaseMenu's _handleClick method}, and
* - adds a `touchend`/`mouseup` listener to the `document` so if the user
* - adds a `pointerup` listener to the `document` so if the user
* clicks outside of the menu it will close if it is open.

@@ -222,9 +219,4 @@ *

// Use touch over mouse events when supported.
const endEventType = isEventSupported("touchend", this.dom.menu)
? "touchend"
: "mouseup";
// Close the menu if a click event happens outside of it.
document.addEventListener(endEventType, (event) => {
document.addEventListener("pointerup", (event) => {
if (this.focusState !== "none") {

@@ -231,0 +223,0 @@ this.currentEvent = "mouse";

@@ -5,3 +5,2 @@ import BaseMenu from "./_baseMenu.js";

import { keyPress, preventEvent } from "./eventHandlers.js";
import { isEventSupported } from "./validate.js";

@@ -155,8 +154,5 @@ /**

*
* Depending on what is supported either `touchstart` and `touchend` or
* `mousedown` and `mouseup` will be used for all "click" event handling.
*
* - Adds all event listeners listed in
* {@link BaseMenu#_handleClick|BaseMenu's _handleClick method}, and
* - adds a `touchend`/`mouseup` listener to the `document` so if the user
* - adds a `pointerup` listener to the `document` so if the user
* clicks outside of the menu it will close if it is open.

@@ -169,9 +165,4 @@ *

// Use touch over mouse events when supported.
const endEventType = isEventSupported("touchend", this.dom.menu)
? "touchend"
: "mouseup";
// Close the menu if a click event happens outside of it.
document.addEventListener(endEventType, (event) => {
document.addEventListener("pointerup", (event) => {
if (this.focusState !== "none") {

@@ -178,0 +169,0 @@ this.currentEvent = "mouse";

@@ -333,2 +333,4 @@ /**

* @return {boolean} - The result.
*
* @deprecated Will be removed in v4 unless there is a new found need for it.
*/

@@ -335,0 +337,0 @@ export function isEventSupported(event, element) {

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc