"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var s=require("../../_virtual/jsx-runtime.js"),t=require("react"),_=require("./components/Tab.js"),y=require("../../icons/MoreHorizontal.js"),D=require("../IconButton/index.js"),L=require("./components/OpenTabs.js"),a=require("./styles.js");const z=20;function F({id:W,tabs:i,selectedTab:c,brandColor:I=!0,narrow:l=!1,showExpandButton:T=!1,title:M="",dismissText:w="Dismiss",onChange:u,rtl:f=!1,...d}){var v;const x=t.useRef(null),r=t.useRef(null),[n,k]=t.useState(),[p,h]=t.useState(!1),[g,j]=t.useState(!1),[q,m]=t.useState(!1),[E,O]=t.useState({left:0,width:0}),[b,B]=t.useState(!1),R=r&&r.current&&r.current.offsetWidth;t.useEffect(()=>{const e=r.current;r&&e&&B(e.offsetWidth<e.scrollWidth)},[r.current,l,window.innerWidth]),t.useEffect(()=>{n&&n.current&&O({left:n.current.offsetLeft,width:n.current.offsetWidth})},[x.current,n==null?void 0:n.current,l,i,f]);function H(e){const o=e.currentTarget;o.scrollWidth-o.scrollLeft===o.clientWidth?j(!0):j(!1)}function S(){h(!p),m(!1)}function C(e){e.disabled||(m(!0),u(e),h(!1))}return s.jsxRuntimeExports.jsxs(a.Wrapper,{id:W,ref:x,rtl:f,children:[s.jsxRuntimeExports.jsxs(a.InnerWrapper,{children:[s.jsxRuntimeExports.jsxs(a.TabsContainer,{ref:r,"data-testid":d["data-testid"],"data-trackid":d["data-trackid"],"aria-label":"tabs",role:"tablist",onScroll:H,children:[i.map(e=>s.jsxRuntimeExports.jsx(_.Tab,{tab:e,selected:e.value===c.value,setSelectedRef:k,narrow:l,expandClickFlag:q,onChange:u,disabled:e.disabled,testId:e.testId,trackId:e.trackId},e.value)),s.jsxRuntimeExports.jsx(a.TabIndicator,{width:E.width,left:E.left,brandColor:I})]}),b&&!g&&T&&s.jsxRuntimeExports.jsx(a.ExpandWrapper,{onClick:S,minHeight:((v=r.current)==null?void 0:v.offsetHeight)??0,left:R&&R-z||0,children:s.jsxRuntimeExports.jsx(D.IconButton,{variant:"secondary",size:"small",icon:s.jsxRuntimeExports.jsx(y.default,{})})})]}),s.jsxRuntimeExports.jsx(L.OpenTabs,{showBottomSheet:p,tabs:i,selectedTab:c,dismissText:w,toggleBottomSheet:S,onExpandItemClick:C})]})}exports.Tabs=F;
