import{r as a,b0 as L,c as b,j as d,L as R,cq as E,a$ as S,ac as z}from"./main-TIUJvpaR.js";const h=a.createContext(null);function P({index:e,className:t,isDisabled:r,children:c,padding:i,elementType:n,to:o,relative:l,width:f="min-w-min",height:u}){const{selectedTab:x,setSelectedTab:y,tabsRef:v,size:p="md",id:w}=a.useContext(h),$=e===x,s=L(),T=i||(p==="sm"?"px-12":"px-18"),N=b("tracking-wide overflow-hidden capitalize text-sm flex items-center justify-center outline-none transition-colors","focus-visible:ring focus-visible:ring-2 ring-inset rounded whitespace-nowrap cursor-pointer",f,A({isDisabled:r,isSelected:$}),t,p==="md"&&`${T} ${u||"h-48"}`,p==="sm"&&`${T} ${u||"h-32"}`,r&&"pointer-events-none"),j=m=>{switch(m.key){case"ArrowLeft":s==null||s.focusPrevious();break;case"ArrowRight":s==null||s.focusNext();break;case"Home":s==null||s.focusFirst();break;case"End":s==null||s.focusLast();break}},C=$?0:-1,k=o?R:n??"button";return d.jsx(k,{disabled:r,id:`${w}-${e}-tab`,"aria-controls":`${w}-${e}-tabpanel`,type:"button",role:"tab","aria-selected":$,tabIndex:r?void 0:C,onKeyDown:j,onClick:()=>{y(e)},to:o,relative:l,className:N,ref:m=>{v.current&&m&&(v.current[e]=m)},children:c})}function A({isDisabled:e,isSelected:t}){return e?"text-disabled cursor-default":t?"text-primary":"text-muted hover:text-main"}function g(){const{tabsRef:e,selectedTab:t}=a.useContext(h),r=a.useRef(-1),[c,i]=a.useState({width:void 0,transform:void 0,className:void 0});return E(()=>{if(t!=null&&e.current&&t!==r.current){const n=e.current[t];if(!n)return;i(o=>({width:`${n.offsetWidth}px`,transform:`translateX(${n.offsetLeft}px)`,className:o.width===void 0?"":"transition-all"})),r.current=t}},[i,t,e]),d.jsx("div",{className:b("absolute bottom-0 left-0 h-2 bg-primary",c.className),role:"presentation",style:{width:c.width,transform:c.transform}})}function V({children:e,center:t,expand:r,className:c,border:i="border-b"}){const n=a.Children.toArray(e);return d.jsx(S,{children:d.jsxs("div",{className:b("max-sm:hidden-scrollbar md:compact-scrollbar relative flex max-w-full overflow-auto",i,c),role:"tablist","aria-orientation":"horizontal",children:[n.map((o,l)=>a.isValidElement(o)?a.cloneElement(o,{index:l,className:b(o.props.className,r&&"flex-auto",t&&l===0&&"ml-auto",t&&l===n.length-1&&"mr-auto")}):null),d.jsx(g,{})]})})}function q(e){const{size:t="md",children:r,className:c,isLazy:i,overflow:n="overflow-hidden"}=e,o=a.useRef([]),l=a.useId(),[f,u]=z(e.selectedTab,e.defaultSelectedTab||0,e.onTabChange),x=a.useMemo(()=>({selectedTab:f,setSelectedTab:u,tabsRef:o,size:t,isLazy:i,id:l}),[f,l,i,u,t]);return d.jsx(h.Provider,{value:x,children:d.jsx("div",{className:b(c,n,"max-w-full flex-shrink-0"),children:r})})}export{q as T,V as a,P as b};
