import{r as s,h as t,H as a,g as i}from"./p-db677b4c.js";const e=":host{--panel-margin-top:0;--panel-padding:0;--gap-md:var(--pine-spacing-md);--gap-xs:var(--pine-spacing-xs);--gap-sm:16px var(--pine-spacing-sm);--outline:2px solid var(--pine-color-primary-200);display:block}*:focus{outline:var(--outline)}.pds-tabs__tablist{display:-ms-flexbox;display:flex;-ms-flex-wrap:wrap;flex-wrap:wrap;gap:var(--gap-md)}:host(.pds-tabs--availability) .pds-tabs__tablist{gap:var(--gap-xs)}:host(.pds-tabs--filter) .pds-tabs__tablist{gap:var(--gap-sm)}";const n=e;const r=class{constructor(t){s(this,t);this.tablistLabel=undefined;this.componentId=undefined;this.variant=undefined;this.activeTabName=undefined;this.activeTabIndex=undefined}tabClickHandler(s){if(this.componentId===s.detail[1]){this.activeTabIndex=s.detail[0];this.activeTabName=this.tabs[this.activeTabIndex].name}}handleKeyDown(s){const t=["ArrowLeft","ArrowRight","Home","End"];if(t.includes(s.key)){s.preventDefault();this.moveActiveTab(s.key)}}moveActiveTab(s){const t=0;const a=this.tabs.length-1;let i=null;switch(s){case"ArrowLeft":i=this.activeTabIndex===t?a:this.activeTabIndex+-1;break;case"ArrowRight":i=this.activeTabIndex===a?t:this.activeTabIndex+1;break;case"Home":i=t;break;case"End":i=a;break}this.tabs[i].children[0].focus();this.activeTabName=this.tabs[i].name;this.activeTabIndex=i}findAllChildren(){this.tabs=this.el.querySelectorAll("pds-tab");this.tabPanels=this.el.querySelectorAll("pds-tabpanel")}propGeneration(s,t=0){s.parentComponentId=this.componentId.toString();s.variant=this.variant.toString();s.selected=this.activeTabName===s.name?true:false;s["index"]=t}passPropsToChildren(){this.tabs.forEach(((s,t)=>{if(this.activeTabName===s.name)this.activeTabIndex=t;this.propGeneration(s,t)}));this.tabPanels.forEach((s=>{this.propGeneration(s)}))}classNames(){let s=`pds-tabs`;if(this.variant&&this.variant!="primary"){const t=`pds-tabs--${this.variant}`;s+=" "+t}return s}componentWillLoad(){this.findAllChildren()}componentWillRender(){this.passPropsToChildren()}render(){return t(a,{key:"230c4abd9bf8632802f34df2a517ca2c1cc029bd","active-tab-name":this.activeTabName,class:this.classNames(),id:this.componentId},t("div",{key:"ad7935e2494c8fa731abaf17979f61ffa70d8ac3",class:"pds-tabs__tablist",role:"tablist","aria-label":this.tablistLabel},t("slot",{key:"3e3b604d8aa3391b23539914cd91bd6cafcfc4c9",name:"tabs"})),t("slot",{key:"7d8a5ee7b1b147816bedf6be0b24f8a57b422fe7",name:"tabpanels"}))}get el(){return i(this)}};r.style=n;export{r as pds_tabs};
//# sourceMappingURL=p-f329268a.entry.js.map