import{r as t,h as i}from"./p-a881e3a2.js";var l={equals:function(t,i){return t===i},compare:function(t,i){return t<i?-1:t>i?1:0}};let 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 i===l||t.compare(i,l)<1?i:l}}(s=l),n=function(t){return function(i,l){return i===l||t.compare(i,l)>-1?i:l}}(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))},this.clickHandler=(t,i)=>l=>{var a;l.preventDefault(),this.selectTab(i),null===(a=t.onClick)||void 0===a||a.call(t,l)}}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:this.clickHandler(t,l),tabIndex:l===this.activeTabIndex?0:-1}))))}};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{background-color:#e9eaf1;background-color:var(--color-neutral-50,#e9eaf1);display:-ms-flexbox;display:flex;-ms-flex-direction:row;flex-direction:row;margin:0;padding:0}",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;margin:0;padding:0}"};export{a as stencila_tab_list}