import{r as t,c as s,h as e}from"./p-1a7a8b00.js";import{z as i}from"./p-19cd3f24.js";const r=class{constructor(e){t(this,e),this.tabChanged=s(this,"tabChanged",7),this.updateIndex=t=>{t>=this.tabs.length&&(t=this.tabs.length-1),t<0&&(t=0),this.groupIndex=t},this.onKeyboard=t=>{switch(t.key){case"ArrowLeft":this.updateIndex(this.groupIndex-1);break;case"ArrowRight":this.updateIndex(this.groupIndex+1)}},this.onTabSelect=t=>()=>this.updateIndex(t),this.code="",this.tabs=[],this.groupIndex=0,this.useExternal=!1}resetState(){}connectedCallback(){this.resetState()}componentWillLoad(){this.useExternal=!!customElements.get("bp-sdk-external-tab-group"),customElements.whenDefined("bp-sdk-external-tab-group").then((()=>{this.useExternal=!0}))}render(){return[this.useExternal&&this.renderExternal(),!this.useExternal&&this.renderInternal()]}renderExternal(){return e("bp-sdk-external-tab-group",{code:this.code,tabs:this.tabs,groupIndex:this.groupIndex},this.tabs.map((t=>e("slot",{name:`${this.code}-${t}`}))))}onIndexChanged(t){this.tabChanged.emit(t)}renderInternal(){return e("div",{id:`${this.code}-tab-container`,class:"bp-sdk-tab__container"},e("ul",{class:"bp-sdk-tab__list",role:"tablist",tabindex:"1",onKeyUp:this.onKeyboard},this.tabs.map(((t,s)=>e("li",{role:"tab",id:`bp-sdk-tab__list-item-${this.code}-${t}`,"aria-selected":s===this.groupIndex,tabindex:"-1",class:i("bp-sdk-tab__list-item bp-sdk-tab",{"bp-sdk-tab__list-item--selected":s===this.groupIndex}),onClick:this.onTabSelect(s),onKeyUp:this.onTabSelect(s)},t)))),this.tabs.map(((t,s)=>e("div",{id:`bp-sdk-tab__group-panel-${this.code}-${t}`,class:i("bp-sdk-tab-group-panel",{"bp-sdk-visually-hidden":s!==this.groupIndex}),"aria-labelledby":`bp-sdk-tab__list-item-${this.code}-${t}`,role:"tabpanel","aria-hidden":s!==this.groupIndex},e("slot",{name:`${this.code}-${t}`},"No content")))))}static get watchers(){return{groupIndex:["onIndexChanged"]}}};r.style=".bp-sdk-tab__container{padding:1rem}.bp-sdk-tab__list{list-style-type:none;padding-inline-start:0;margin-block-end:0}.bp-sdk-tab__list-item{align-items:flex-end;appearance:button;border-left:1px solid var(--border-color);border-right:1px solid var(--border-color);border-top:1px solid var(--border-color);color:var(--light--font-color);cursor:pointer;display:inline-flex;min-height:1rem;min-width:3rem;padding:0.5rem;user-select:none}.bp-sdk-tab__list-item[aria-selected]{border-color:var(--selected-border-color);color:var(--font-color)}.bp-sdk-tab__group-panel[role='tabpanel']{border:1px solid var(--border-color);padding:1rem}";export{r as bp_sdk_tab_group}