const e=window.webcomponents.h;import"./chunk-de721f0a.js";import{e as t}from"./chunk-f9f1602a.js";class s{constructor(){this.isSelected=!1}getChild(){return{select:this.select.bind(this),unselect:this.unselect.bind(this),name:this.name}}unselect(){this.isSelected=!1}select(){this.isSelected=!0}render(){return e("div",{class:{"ema-tab-content":!0,"ema-tab-content-selected":this.isSelected}},e("slot",null))}static get is(){return"ema-tab-content"}static get properties(){return{getChild:{method:!0},isSelected:{state:!0},name:{type:String,attr:"name"}}}static get style(){return".ema-tab-content{display:none}.ema-tab-content-selected{display:block}"}}class a{constructor(){this.id=t.getUUID(),this.isSelected=!1}getChild(){return{select:this.select.bind(this),unselect:this.unselect.bind(this),name:this.name,id:this.id}}unselect(){this.isSelected=!1}select(){this.isSelected=!0}onClick(){this.onSelect.emit(this.getChild())}render(){return[e("div",{class:{"ema-tab-header":!0,"ema-tab-header-selected":this.isSelected},onClick:this.onClick.bind(this)},e("slot",null))]}static get is(){return"ema-tab-header"}static get properties(){return{getChild:{method:!0},isSelected:{state:!0},name:{type:String,attr:"name"}}}static get events(){return[{name:"onSelect",method:"onSelect",bubbles:!0,cancelable:!0,composed:!0}]}static get style(){return".ema-tab-header{min-height:40px;min-width:150px;padding:5px;cursor:pointer;display:-ms-flexbox;display:flex;-ms-flex-pack:center;justify-content:center;-ms-flex-align:center;align-items:center;border-bottom:2px solid transparent}\@media (max-width:599px){.ema-tab-header{min-width:100px}}.ema-tab-header-selected{border-bottom:2px solid var(--ema-primary,#807b7e)}"}}class n{componentDidLoad(){this.createGroup();const[e]=this.tabGroup;this.selectGroup(e),this.selectedIndex&&(this.activeIndex=Number(this.selectedIndex)-1)}componentDidUpdate(){this.selectedIndex&&(this.activeIndex=Number(this.selectedIndex)-1)}onSelectedTab(e){const t=this.tabGroup.find(t=>t.header.id===e.detail.id);this.selectGroup(t)}createGroup(){const e=Array.from(this.host.querySelectorAll("ema-tab-header"));this.tabsHeader=e.map(e=>e.getChild());const t=Array.from(this.host.querySelectorAll("ema-tab-content"));this.tabsContent=t.map(e=>e.getChild()),this.tabGroup=this.tabsHeader.map(e=>{const t=this.tabsContent.find(t=>t.name===e.name);return{header:e,content:t}})}selectGroup(e){this.tabGroup.forEach(e=>{e.header.unselect(),e.content.unselect()}),e.header.select(),e.content.select()}set activeIndex(e){let t=0;this.tabGroup.forEach(s=>{t==e?(s.header.select(),s.content.select()):(s.header.unselect(),s.content.unselect()),t++})}render(){return[e("div",{class:"ema-tabs-header"},e("slot",{name:"header"})),e("div",{class:"ema-tabs-content"},e("slot",{name:"content"}))]}static get is(){return"ema-tabs"}static get properties(){return{host:{elementRef:!0},selectedIndex:{type:Number,attr:"selected-index"}}}static get listeners(){return[{name:"onSelect",method:"onSelectedTab"}]}static get style(){return".ema-tabs-header{display:-ms-flexbox;display:flex;border-bottom:1px solid rgba(0,0,0,.3)}.ema-tabs-content{padding:10px}"}}export{s as EmaTabContent,a as EmaTabHeader,n as EmaTabs};