define(['exports', 'preact/jsx-runtime', 'preact', 'preact/hooks', './classNames-08d99695', './TabBar-92bac52f', './UNSAFE_OverflowTabBar/themes/OverflowTabBarStyles.css', './useDetectHorizontalOverflow-5882ed4b', './TabBarLinkItem-944b1e8d', './RemovableTabBarItem-9ae273fe', './TabBarItem-a39c5de3', './OverflowTabBarItem-0aa39512'], (function(e,a,t,l,r,s,i,o,n,m,c,d){"use strict";e.OverflowTabBar=function({items:e,layout:b="stretch",display:u="standard",size:y="md",edge:f="top",selection:v,truncation:I,onSelect:g,onRemove:B,"aria-label":K,"aria-labelledby":T,contextMenuConfig:h,testId:x}){const p="stacked"===u?{display:u}:{display:u,size:y},w=l.useRef(null),R=t.createRef(),[O,j]=l.useState(!1),M=l.useRef(!1),k=l.useCallback((e=>{"more"===e.value?M.current?j(!1):j(!0):g?.(e),M.current=!1}),[g]),S=l.useMemo((()=>e.map((e=>e.itemKey))),[e]),{visibleItemKeys:z,overflowItemKeys:C,maxWidths:W}=o.useDetectHorizontalOverflow({rootRef:R,keysArray:S,isTruncationDisabled:!(I&&"progressive"===I)}),A=r.classNames([i.styles.overflowTabBarBase]);return a.jsx("div",{ref:w,class:A,children:a.jsxs(s.TabBar,{ref:R,selection:v,onSelect:k,...p,layout:b,edge:f,onRemove:B,"aria-label":K,"aria-labelledby":T,testId:x,contextMenuConfig:h,children:[null!=z&&z.length>0&&e.filter((e=>z?.includes(e.itemKey))).map((e=>null!=e.href?a.jsx(n.TabBarLinkItem,{href:e.href,itemKey:e.itemKey,label:e.label,icon:e.icon,badge:e.badge,metadata:e.metadata,severity:e.severity,"aria-controls":e.tabPanelId,labelMaxWidth:W?.get(e.itemKey)}):e.isRemovable?a.jsx(m.RemovableTabBarItem,{itemKey:e.itemKey,label:e.label,icon:e.icon,badge:e.badge,metadata:e.metadata,severity:e.severity,"aria-controls":e.tabPanelId,labelMaxWidth:W?.get(e.itemKey)}):a.jsx(c.TabBarItem,{itemKey:e.itemKey,label:e.label,icon:e.icon,badge:e.badge,metadata:e.metadata,severity:e.severity,"aria-controls":e.tabPanelId,labelMaxWidth:W?.get(e.itemKey)}))),null!=C&&C.length>0&&a.jsx(d.OverflowTabBarItem,{isOpen:O,onClose:e=>{R.current&&["itemAction","dismissed"].includes(e.reason)&&R?.current?.focus(),"outsideMousedown"===e.reason&&(M.current=!0),j(!1)},overflowItemKey:"more",overflowItems:e.filter((e=>C?.includes(e.itemKey)))})]})})}}));
//# sourceMappingURL=OverflowTabBar-f8bf9356.js.map
