define(["exports","./../../dom.js","./../emby-button/emby-button.js"],function(_exports,_dom,_embyButton){function setState(button,expanded,animate){var collapseContent=button.parentNode.querySelector(".collapseContent");(collapseContent.expanded=expanded)?function(button,elem,animate){elem.classList.remove("hide"),elem.classList.add("expanded"),elem.style.height="auto",animate&&(animate=elem.offsetHeight+"px",elem.style.height="0",elem.offsetHeight,elem.style.height=animate,setTimeout(function(){elem.classList.contains("expanded")?elem.classList.remove("hide"):elem.classList.add("hide"),elem.style.height="auto"},400)),button.querySelector("i").classList.add("emby-collapse-expandIconExpanded"),button.classList.remove("emby-collapsible-button-collapsed")}(button,collapseContent,!1!==animate):function(button,elem){elem.style.height=elem.offsetHeight+"px",elem.offsetHeight,elem.classList.remove("expanded"),elem.style.height="0",setTimeout(function(){button.classList.add("emby-collapsible-button-collapsed"),elem.classList.contains("expanded")?elem.classList.remove("hide"):elem.classList.add("hide")},400),button.querySelector("i").classList.remove("emby-collapse-expandIconExpanded")}(button,collapseContent)}function onButtonClick(e,animate){var collapseContent=this.parentNode.querySelector(".collapseContent");setState(this,!0!==collapseContent.expanded,animate)}function onInit(){this.hasInit||(this.hasInit=!0)}function onButtonDragEnter(e){this.parentNode.querySelector(".collapseContent").expanded||this.click()}Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.default=void 0,require(["css!modules/emby-elements/emby-collapse/emby-collapse.css"]);var EmbyCollapse=function(_HTMLDivElement){babelHelpers.inherits(EmbyCollapse,_HTMLDivElement);var _super=_createSuper(EmbyCollapse);function EmbyCollapse(){babelHelpers.classCallCheck(this,EmbyCollapse);var _this,self=_this=_super.call(this);return onInit.call(self),babelHelpers.possibleConstructorReturn(_this,self)}return babelHelpers.createClass(EmbyCollapse,[{key:"expand",value:function(){var button=this.querySelector(".emby-collapsible-button");button&&setState(button,!0,!1)}},{key:"collapse",value:function(){var button=this.querySelector(".emby-collapsible-button");button&&setState(button,!1,!1)}},{key:"connectedCallback",value:function(){onInit.call(this),function(){var collapseContent,headerClass,iconClass,buttonClass;this.classList.contains("emby-collapse")||(this.classList.add("emby-collapse"),(collapseContent=this.querySelector(".collapseContent"))&&collapseContent.classList.add("hide"),collapseContent=this.getAttribute("title"),this.title="",headerClass=((this.getAttribute("data-headerclass")||"")+" emby-collapsible-title").trim(),buttonClass=((this.getAttribute("data-buttonclass")||"")+" emby-collapsible-button").trim(),iconClass=((this.getAttribute("data-iconclass")||"")+" md-icon emby-collapse-expandIcon").trim(),this.insertAdjacentHTML("afterbegin",'<button is="emby-button" type="button" on-click="toggleExpand" class="'+buttonClass+'"><h3 class="'+headerClass+'" title="'+collapseContent+'" aria-label="'+collapseContent+'">'+collapseContent+'</h3><i class="'+iconClass+'">expand_more</i></button>'),(buttonClass=this.querySelector(".emby-collapsible-button")).addEventListener("click",onButtonClick),"true"===this.getAttribute("data-expanded")?setState(buttonClass,!0,!1):buttonClass.classList.add("emby-collapsible-button-collapsed"),_dom.default.addEventListener(buttonClass,"dragenter",onButtonDragEnter,{passive:!0}))}.call(this)}}]),EmbyCollapse}(babelHelpers.wrapNativeSuper(HTMLDivElement));customElements.define("emby-collapse",EmbyCollapse,{extends:"div"}),_exports.default=EmbyCollapse});