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