var __awaiter=this&&this.__awaiter||function(e,t,n,i){function s(e){return e instanceof n?e:new n((function(t){t(e)}))}return new(n||(n=Promise))((function(n,a){function o(e){try{c(i.next(e))}catch(e){a(e)}}function r(e){try{c(i["throw"](e))}catch(e){a(e)}}function c(e){e.done?n(e.value):s(e.value).then(o,r)}c((i=i.apply(e,t||[])).next())}))};var __generator=this&&this.__generator||function(e,t){var n={label:0,sent:function(){if(a[0]&1)throw a[1];return a[1]},trys:[],ops:[]},i,s,a,o;return o={next:r(0),throw:r(1),return:r(2)},typeof Symbol==="function"&&(o[Symbol.iterator]=function(){return this}),o;function r(e){return function(t){return c([e,t])}}function c(r){if(i)throw new TypeError("Generator is already executing.");while(o&&(o=0,r[0]&&(n=0)),n)try{if(i=1,s&&(a=r[0]&2?s["return"]:r[0]?s["throw"]||((a=s["return"])&&a.call(s),0):s.next)&&!(a=a.call(s,r[1])).done)return a;if(s=0,a)r=[r[0]&2,a.value];switch(r[0]){case 0:case 1:a=r;break;case 4:n.label++;return{value:r[1],done:false};case 5:n.label++;s=r[1];r=[0];continue;case 7:r=n.ops.pop();n.trys.pop();continue;default:if(!(a=n.trys,a=a.length>0&&a[a.length-1])&&(r[0]===6||r[0]===2)){n=0;continue}if(r[0]===3&&(!a||r[1]>a[0]&&r[1]<a[3])){n.label=r[1];break}if(r[0]===6&&n.label<a[1]){n.label=a[1];a=r;break}if(a&&n.label<a[2]){n.label=a[2];n.ops.push(r);break}if(a[2])n.ops.pop();n.trys.pop();continue}r=t.call(e,n)}catch(e){r=[6,e];s=0}finally{i=a=0}if(r[0]&5)throw r[1];return{value:r[0]?r[1]:void 0,done:true}}};import{r as registerInstance,h,H as Host,g as getElement}from"./index-aed5ae27.js";import{c as cls}from"./helpers-ea9d01ce.js";var styleCss="x-collapse{display:block;position:relative;-webkit-transition:0.3s;transition:0.3s}.is-dark-mode x-collapse{color:var(--color-text-light, #FEFEFE)}x-collapse .collapse-header{position:relative;padding:0.5rem 0;line-height:1em;cursor:pointer;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}x-collapse .collapse-header:hover:after{-webkit-animation:0.75s fadeBreathe infinite;animation:0.75s fadeBreathe infinite}x-collapse .collapse-header h4{margin:0}x-collapse .collapse-header .collapse-action{position:absolute;top:calc(50% - 0.5rem);right:0.75rem}x-collapse .collapse-container{overflow:hidden;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;-webkit-transition:0.3s;transition:0.3s;max-height:0;opacity:0;-webkit-transition:max-height 0.2s ease-out, opacity 0.2s;transition:max-height 0.2s ease-out, opacity 0.2s}x-collapse.collapse-expanded .collapse-container{opacity:1}";var XCollapseStyle0=styleCss;var XCollapse=function(){function e(e){registerInstance(this,e);this.header=undefined;this.show=false;this.expanded=false}e.prototype.toggle=function(){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(e){this.toggleCollapse();return[2]}))}))};e.prototype.onExpandedChange=function(){this.updateCollapse()};e.prototype.componentDidLoad=function(){this.container=this.el.querySelector(".collapse-container");if(this.show){this.expanded=true}};e.prototype.toggleCollapse=function(){this.expanded=!this.expanded};e.prototype.updateCollapse=function(){var e=this.el.querySelector(".collapse-container");if(e.style.maxHeight){this.hideCollapseContainer()}else{this.showCollapseContainer()}};e.prototype.hideCollapseContainer=function(){this.container.style.maxHeight=null;this.container.style.overflow="hidden"};e.prototype.showCollapseContainer=function(){var e=this;this.container.style.maxHeight="".concat(this.container.scrollHeight,"px");setTimeout((function(){e.container.style.overflow="auto"}),200)};e.prototype.render=function(){var e=this;var t;return h(Host,{key:"7f82133dbd9c70004069c1f6e503ee4d6a788f19",class:cls({"collapse-expanded":this.expanded})},h("div",{key:"1ceb013efd40159150183b40893504a264f17bf2",class:"collapse-header",onClick:function(){return e.toggleCollapse()}},((t=this.header)===null||t===void 0?void 0:t.length)?h("h4",null,this.header):h("slot",{name:"header"}),h("span",{key:"32242dc53d6781dd69aff01377cc41304c784100",class:"collapse-action"},h("x-icon",{key:"ffd81c8f6ce3bf39a0ca1e5906bbe5b0894e6d0b",name:this.expanded?"minus":"dropdown"}))),h("div",{key:"9ac6e4dbaef9f2b84bbeaaa5fc237757dcdc9d77",class:"collapse-container"},h("slot",{key:"7e1f59ac30e5bfb50c335f5bdf1fff5bf94b3db4"})))};Object.defineProperty(e.prototype,"el",{get:function(){return getElement(this)},enumerable:false,configurable:true});Object.defineProperty(e,"watchers",{get:function(){return{expanded:["onExpandedChange"]}},enumerable:false,configurable:true});return e}();XCollapse.style=XCollapseStyle0;export{XCollapse as x_collapse};