"use strict";!function(e,t){"function"==typeof define&&define.amd?define(t):"object"==typeof exports?module.exports=t():e.Accordion=t()}(window,function(){return function(n,i){let o=[];i=(()=>{var t={expand:(e,t)=>{t.style.maxHeight=t.scrollHeight+"px"},collapse:(e,t)=>{t.style.maxHeight=0},transitionEnd:e=>{"max-height"!==e.propertyName||e.currentTarget.classList.contains("accordion--expanded")||e.currentTarget.setAttribute("hidden","hidden")},resizeEvent:(e,t)=>{for(let e=t.length;e--;)i.expand(null,t[e])},init:!0,buttonSelector:"button.accordion--button",accordionExpandedClass:"accordion--expanded"},r=Object.keys(t);i=i||{};for(let e=r.length;e--;)i[r[e]]=i[r[e]]||t[r[e]];return i})();const a=n.querySelectorAll(i.buttonSelector),d=e=>{e.preventDefault();e=e.currentTarget;e.setAttribute("aria-expanded","true"===e.getAttribute("aria-expanded")?"false":"true"),l(e)},s=t=>{var e=t.keyCode||t.which;let r=(()=>{for(let e=a.length;e--;)if(a[e]===t.currentTarget)return e})();switch(e){case 40:t.preventDefault(),r===a.length-1&&(r=-1),a[r+1].focus();break;case 38:t.preventDefault(),0===r&&(r=a.length),a[r-1].focus();break;case 36:t.preventDefault(),a[0].focus();break;case 35:t.preventDefault(),a[a.length-1].focus()}},l=(e,t)=>{const r=n.querySelector("#"+e.getAttribute("aria-controls"));r&&("true"===e.getAttribute("aria-expanded")?(r.classList.add(i.accordionExpandedClass),r.setAttribute("aria-hidden","false"),r.removeAttribute("hidden"),o.push(r),i.expand(e,r)):(r.classList.remove(i.accordionExpandedClass),r.setAttribute("aria-hidden","true"),t&&r.setAttribute("hidden","hidden"),o.filter(e=>e!==r),i.collapse(e,r)))};window.onclick=function(e){if(!e.target.matches(".dropdown button"))for(var t=document.getElementsByClassName("dropdown"),r=0;r<t.length;r++){var n=t[r].querySelector("button");if("false"===n.getAttribute("aria-expanded"))return;const a=t[r].querySelector("#"+n.getAttribute("aria-controls"));if(!a)return;a.classList.remove(i.accordionExpandedClass),a.setAttribute("aria-hidden","true"),a.setAttribute("hidden","hidden"),o.filter(e=>e!==a),i.collapse(n,a),n.setAttribute("aria-expanded","false")}};const r=e=>{e.setAttribute("aria-expanded","true"),l(e)};const e=()=>{var e=window.location.hash.replace("#","");if(e)try{var t=n.querySelector(`[aria-controls=${e}]`);t&&(r(t),t.focus())}catch(e){}};var t=()=>{for(let e=a.length;e--;)l(a[e],!0);var t=e=>{i.resizeEvent(e,o)};for(let e=a.length;e--;){var r=a[e];r.addEventListener("click",d),r.addEventListener("keydown",s),n.querySelector("#"+r.getAttribute("aria-controls")).addEventListener("transitionend",i.transitionEnd),i.resizeEvent&&window.addEventListener("resize",t)}window.addEventListener("hashchange",e),e()};return!1!==i.init&&t(),{init:t,closeAll:()=>{for(let e=a.length;e--;)(t=a[e]).setAttribute("aria-expanded","false"),l(t);var t},openAll:()=>{for(let e=a.length;e--;)r(a[e])}}}});