import{r as t,h as i}from"./p-47897087.js";var l={equals:function(t,i){return t===i},compare:function(t,i){return t<i?-1:t>i?1:0}};const a=class{constructor(i){t(this,i),this.activeTabIndex=0,this.onKeyboardNavigateTabs=t=>{const i="ArrowRight"===t.key?1:"ArrowLeft"===t.key?-1:0,a=(e=function(t){return function(i,l){return 1===t.compare(i,l)?l:i}}(s=l),n=function(t){return function(i,l){return-1===t.compare(i,l)?l:i}}(s),function(t,i){return function(l){return n(e(l,i),t)}})(0,this.tabs.length-1);var s,e,n;this.selectTab(a(this.activeTabIndex+i))}}selectTab(t){this.activeTabIndex=t}render(){return i("ul",{role:"tablist",onKeyDown:this.onKeyboardNavigateTabs},this.tabs.map(((t,l)=>i("stencila-tab",{isSelected:!0===t.isSelected||void 0===t.isSelected&&l===this.activeTabIndex,label:t.label,onClick:i=>{i.preventDefault(),this.selectTab(l),t.onClick&&t.onClick(i)},tabIndex:l===this.activeTabIndex?0:-1}))))}};a.elementName="stencila-tab-list",a.style={default:"stencila-tab-list.sc-stencila-tab-list-default{display:block}.sc-stencila-tab-list-default-h ul.sc-stencila-tab-list-default,stencila-tab-list.sc-stencila-tab-list-default ul.sc-stencila-tab-list-default,ul[role=tablist].sc-stencila-tab-list-default{display:-ms-flexbox;display:flex;-ms-flex-direction:row;flex-direction:row;padding:0;margin:0;background-color:#f7fafc;background-color:var(--color-neutral-100,#f7fafc)}",material:"stencila-tab-list.sc-stencila-tab-list-material{display:block}.sc-stencila-tab-list-material-h ul.sc-stencila-tab-list-material,ul[role=tablist].sc-stencila-tab-list-material{display:-ms-flexbox;display:flex;-ms-flex-direction:row;flex-direction:row;padding:0;margin:0}"};export{a as stencila_tab_list}