import{r as registerInstance,h}from"./index-7f9476af.js";function compare(t,a){return t<a?-1:t>a?1:0}function strictEqual(t,a){return t===a}var ordNumber={equals:strictEqual,compare:compare};function min(t){return function(a,e){return t.compare(a,e)===1?e:a}}function max(t){return function(a,e){return t.compare(a,e)===-1?e:a}}function clamp(t){var a=min(t);var e=max(t);return function(t,i){return function(l){return e(a(l,i),t)}}}var defaultTabListCss="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)}";var tabListMaterialCss="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}";var TabList=function(){function t(t){var a=this;registerInstance(this,t);this.activeTabIndex=0;this.onKeyboardNavigateTabs=function(t){var e=t.key==="ArrowRight"?1:t.key==="ArrowLeft"?-1:0;var i=clamp(ordNumber)(0,a.tabs.length-1);a.selectTab(i(a.activeTabIndex+e))}}t.prototype.selectTab=function(t){this.activeTabIndex=t};t.prototype.render=function(){var t=this;return h("ul",{role:"tablist",onKeyDown:this.onKeyboardNavigateTabs},this.tabs.map((function(a,e){return h("stencila-tab",{isSelected:a.isSelected===true||a.isSelected===undefined&&e===t.activeTabIndex,label:a.label,onClick:function(i){i.preventDefault();t.selectTab(e);a.onClick&&a.onClick(i)},tabIndex:e===t.activeTabIndex?0:-1})})))};return t}();TabList.elementName="stencila-tab-list";TabList.style={default:defaultTabListCss,material:tabListMaterialCss};export{TabList as stencila_tab_list};