import{u as w,N,h as S}from"./OdysseyThemeProvider-Bh0Bu-2o.js";import{r as o}from"./index-NdkWRN8K.js";import{M as q}from"./Box-1mvP3NLW.js";import{u as H}from"./useUniqueId-Bsgqe1tm.js";import{M as A}from"./BaseButton-DYZHKnV3.js";import{M as F}from"./MenuContext-DKMyPMNY.js";import{j as e}from"./jsx-runtime-CnH95YSl.js";import{M as R}from"./More-DLQ2RjWn.js";import{M as U,P as G}from"./Menu-K9lpVvDG.js";const se=["left","right"],re=["start","end"],J=S("div",{shouldForwardProp:n=>n!=="hasVerticalDivider"&&n!=="odysseyDesignTokens"&&n!=="verticalDividerAlignment"})(({hasVerticalDivider:n,odysseyDesignTokens:s,verticalDividerAlignment:r})=>({position:"relative",...n&&{display:"inline-block","&:before":{position:"absolute",top:"50%",left:0,width:1,height:s.Spacing6,backgroundColor:s.HueNeutral300,content:'""',transform:"translate3d(0, -50%, 0)",transition:"opacity 200ms",...r==="end"&&{left:"unset",right:0}},":has(> button:hover)":{"&:before":{opacity:0}},":dir(rtl)":{"&:before":{left:"unset",right:0,...r==="end"&&{right:"unset",left:0}}}}})),K=({ariaLabel:n,ariaLabelledBy:s,ariaDescribedBy:r,buttonChildren:v,buttonLabel:x="",buttonVariant:y="secondary",children:c,popoverContent:m,endIcon:p,hasVerticalDivider:B=!1,id:j,isDisabled:D,isOverflow:k,menuAlignment:i="left",omitEndIcon:z=!1,shouldCloseOnSelect:f=!0,size:C,testId:E,tooltipText:I,translate:O,verticalDividerAlignment:P="start"})=>{const h=w(),[d,M]=o.useState(null),a=!!d,l=o.useCallback(()=>{M(null)},[]),u=o.useCallback($=>{M($.currentTarget)},[]),t=H(j),T=o.useMemo(()=>({"aria-labelledby":`${t}-button`}),[t]),V=o.useMemo(()=>({closeMenu:l,openMenu:u,shouldCloseOnSelect:f}),[l,u,f]),L=z?void 0:p||(k?e.jsx(R,{}):e.jsx(N,{})),b=o.useMemo(()=>({horizontal:i,vertical:"bottom"}),[i]),g=o.useMemo(()=>({horizontal:i,vertical:"top"}),[i]);return e.jsxs(J,{hasVerticalDivider:B,odysseyDesignTokens:h,verticalDividerAlignment:P,children:[e.jsx(A,{ariaControls:a?`${t}-menu`:void 0,ariaDescribedBy:r,ariaExpanded:a?"true":void 0,ariaHasPopup:"true",ariaLabel:n,ariaLabelledBy:s,children:v,endIcon:L,id:`${t}-button`,isDisabled:D,label:x,onClick:u,size:C,testId:E,tooltipText:I,translate:O,variant:y}),c&&e.jsx(U,{anchorEl:d,anchorOrigin:b,id:`${t}-menu`,MenuListProps:T,onClose:l,open:a,transformOrigin:g,children:e.jsx(F.Provider,{value:V,children:c})}),m&&e.jsx(G,{anchorEl:d,anchorOrigin:b,onClose:l,open:a,transformOrigin:g,children:e.jsx(q,{sx:{padding:h.Spacing4},children:m})})]})},Q=o.memo(K);Q.displayName="BaseMenuButton";export{Q as M,se as m,re as v};
