!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.AceAccordion=e():t.AceAccordion=e()}(window,function(){return function(t){var e={};function i(n){if(e[n])return e[n].exports;var o=e[n]={i:n,l:!1,exports:{}};return t[n].call(o.exports,o,o.exports,i),o.l=!0,o.exports}return i.m=t,i.c=e,i.d=function(t,e,n){i.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},i.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},i.t=function(t,e){if(1&e&&(t=i(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(i.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var o in t)i.d(n,o,function(e){return t[e]}.bind(null,o));return n},i.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return i.d(e,"a",e),e},i.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},i.p="",i(i.s=0)}([function(t,e,i){const n=i(1),o=i(2);void 0!==t&&t.exports&&(t.exports=class{static get options_default(){return{selectors:{accordion:".accordion",item:".accordion__item",heading:".accordion__item__heading",content:".accordion__item__content",content_inner:".accordion__item__content__inner"},close_nested_items:!1,default_open_items:null,heading_trigger_selector:null,multiple_open_items:!0,trigger_on_hover:!1,callbacks:{accordion:{initialize:{before:null,after:null}},item:{initialize:{before:null,after:null},open:{},close:{}}},debug:!1}}static get constants(){return{id_attribute:"data-ace-instance-id"}}get accordion_elements(){return Array.from(document.querySelectorAll(this.options.selectors.accordion))}static addInstance(t,e,i,n){const o=t[e];return t[e]++,t[i][o]=n,o}addAceAccordion(){return"number"!=typeof this.constructor.ace_accordion_count&&(this.constructor.ace_accordion_count=0),"object"!=typeof this.constructor.ace_accordions&&(this.constructor.ace_accordions={}),this.constructor.addInstance(this.constructor,"ace_accordion_count","ace_accordions",this)}addAccordion(t){"function"==typeof this.options.callbacks.accordion.initialize.before&&this.options.callbacks.accordion.initialize.before.call(null,t);const e=this.accordion_count,i=new o(this,e,t);i&&this.constructor.addInstance(this,"accordion_count","accordions",i),"function"==typeof this.options.callbacks.accordion.initialize.after&&this.options.callbacks.accordion.initialize.after.call(i,t)}constructor(t){if(this.options=n([{},this.constructor.options_default,t],!0),this.id=this.addAceAccordion(),this.selector="["+this.constructor.constants.id_attribute+'="'+this.id+'"]',this.accordion_count=0,this.accordions={},this.accordion_elements.length>0)for(let t=0;t{const i=(t,e,n)=>{for(let o in e)if("object"==typeof e[o]&&null!==e[o]&&n){if(e[o]instanceof Window||e[o]instanceof HTMLDocument||e[o]instanceof Element){t[o]=e[o];continue}Array.isArray(e[o])||e[o]instanceof NodeList?(e[o]instanceof NodeList&&(e[o]=Array.from(e[o])),t[o]=[]):"object"==typeof t[o]&&null!==t[o]||(t[o]={}),i(t[o],e[o],n)}else t[o]=e[o];return t};if(t.length>1)for(let n=1;n "+this.options.selectors.item))}addItem(t){"function"==typeof this.options.callbacks.item.initialize.before&&this.options.callbacks.item.initialize.before.call(null,t);const e=this.item_count,i=new n(this,e,t);i&&this.wrapper_ace_accordion.constructor.addInstance(this,"item_count","items",i),"function"==typeof this.options.callbacks.item.initialize.after&&this.options.callbacks.item.initialize.after.call(i,t)}constructor(t,e,i){if(this.wrapper_ace_accordion=t,this.element=i,this.element.ace_object=this,this.id=e,this.element.setAttribute(this.wrapper_ace_accordion.constructor.constants.id_attribute,this.wrapper_ace_accordion.id),this.element.setAttribute(this.constructor.constants.id_attribute,this.id),this.selector=this.wrapper_ace_accordion.selector+"["+this.constructor.constants.id_attribute+'="'+this.id+'"]',this.item_count=0,this.items={},this.item_elements.length>0)for(let t=0;t=0&&this.index===t)return!0}else if("string"==typeof t){if(this.element.matches(t))return!0}else if(t instanceof Element&&this.element===t)return!0;return!1}open(t,e=!1){if("opened"!==this.state&&"opening"!==this.state){if(this.controller=t,!1===this.options.multiple_open_items){let t=this.wrapper_accordion.items;for(let e in t)this.element!==t[e].element&&t[e].close(null,!1)}if(this.heading.trigger_element.setAttribute("aria-expanded","true"),this.content.element.setAttribute("aria-hidden","false"),this.content.hasHeightTransition()&&!e){const t=this.content.getComputedHeight();this.content.element.style.height=t+"px",this.state="opening";const e=this.content.inner_element.offsetHeight;this.content.element.style.height=e+"px"}else this.open_finish()}}open_finish(){this.state="opened",this.content.element.style.height=""}close(t,e=!1){if("closed"!==this.state&&"closing"!==this.state&&(t===this.controller||null===this.controller||null===t))if(this.content.hasHeightTransition()&&!e){const t=this.content.getComputedHeight();this.content.element.style.height=t+"px",this.state="closing",this.content.element.offsetHeight,this.content.element.style.height="0px"}else this.close_finish()}close_finish(){if(this.heading.trigger_element.setAttribute("aria-expanded","false"),this.content.element.setAttribute("aria-hidden","true"),this.state="closed",this.content.element.style.height="",this.controller=null,!0===this.options.close_nested_items){const t=this.immediateChildAccordions;let e;for(let i=0;i ["+this.constructor.constants.id_attribute+'="'+this.id+'"]';let s="closed";!1===this.options.default_open_items&&null===this.options.default_open_items&&void 0===this.options.default_open_items||this.matches(this.options.default_open_items)&&(s="opened"),this.state=s;const r=this.element.querySelector(this.selector+" > "+this.options.selectors.content),c=this.element.querySelector(this.selector+" > "+this.options.selectors.content+" > "+this.options.selectors.content_inner);r&&c&&(this.content=new o(this,r,c));const a=this.element.querySelector(this.selector+" > "+this.options.selectors.heading);return a&&(this.heading=new n(this,a)),this.transitionendListener=this.content.element.addEventListener("transitionend",this.handleTransitionEnd),this.transitionendListener=this.element.addEventListener("mouseenter",this.handleMouseEnter),this.transitionendListener=this.element.addEventListener("mouseleave",this.handleMouseLeave),this}destroy(){}}},function(t,e){t.exports=class{get options(){return this.wrapper_item.wrapper_accordion.wrapper_ace_accordion.options}static get constants(){return{ace_attribute:"data-ace-heading"}}determineTriggerElement(t){if("string"==typeof t){const e=this.element.querySelector(t);if(e)return e}return this.element}handleClick(t){this.ace_object.wrapper_item.toggle("click",!1)}handleKeyDown(t){const e=t.target.ace_object;switch(t.keyCode){case 38:e.wrapper_item.focusTrigger("previous");break;case 40:e.wrapper_item.focusTrigger("next")}}constructor(t,e){this.wrapper_item=t,this.element=e,this.trigger_element=this.determineTriggerElement(this.options.heading_trigger_selector),this.element.ace_object=this,this.trigger_element.ace_object=this,this.element.setAttribute(this.constructor.constants.ace_attribute,""),this.trigger_element.setAttribute("aria-controls",this.wrapper_item.content.element.id);let i=!1;return"opened"===this.wrapper_item.state&&(i=!0),this.trigger_element.setAttribute("aria-expanded",i),this.trigger_element.addEventListener("click",this.handleClick),this.trigger_element.addEventListener("keydown",this.handleKeyDown),this}destroy(){this.element.ace_object=void 0,this.trigger_element.ace_object=void 0,this.trigger_element.removeAttribute("aria-controls"),this.trigger_element.removeAttribute("aria-expanded"),this.trigger_element.removeEventListener("click",this.handleClick),this.trigger_element.removeEventListener("keydown",this.handleKeyDown),this.wrapper_item.heading=void 0}}},function(t,e){t.exports=class{static get constants(){return{ace_attribute:"data-ace-content",ace_attribute_inner:"data-ace-content-inner"}}get options(){return this.wrapper_item.wrapper_accordion.wrapper_ace_accordion.options}generateId(){return"accordion-content-"+this.wrapper_item.wrapper_accordion.wrapper_ace_accordion.id+"-"+this.wrapper_item.wrapper_accordion.id+"-"+this.wrapper_item.id}hasHeightTransition(t){return t||(t=window.getComputedStyle(this.element)),t.transitionProperty.split(", ").indexOf("height")>=0}getComputedHeight(t){return t||(t=window.getComputedStyle(this.element)),t.height.slice(0,-2)}constructor(t,e,i){this.wrapper_item=t,this.element=e,this.element.setAttribute(this.constructor.constants.ace_attribute,""),this.element.ace_object=this,this.inner_element=i,this.inner_element.setAttribute(this.constructor.constants.ace_attribute_inner,""),this.initial_id=this.element.id,""!==this.initial_id||(this.element.id=this.generateId());let n=!0;return"opened"===this.wrapper_item.state&&(n=!1),this.element.setAttribute("aria-hidden",n),this}destroy(){this.element.ace_object=void 0,this.element.id===this.initial_id||this.element.setAttribute("id",this.initial_id),this.element.removeAttribute("aria-hidden"),this.wrapper_item.content=void 0}}}])});