import{r as i,af as E,M as p,j as e,aB as m,bb as C,bc as I,bd as L,be as v,O as f,bf as A}from"./index-DR3HTfO6.js";import{B as z}from"./ButtonGroup-BjIAZaBg.js";function P(t,s){i.useEffect(()=>{function r(o){!t||!t.current||t.current.contains(o.target)||s(o)}return document.addEventListener("click",r,!0),()=>{document.removeEventListener("click",r,!0)}},[t,s])}function w({...t}){const{size:s="medium",color:r="primary",menu:o=[],children:c=null,variant:x="contained",onClick:h=E,menuButtonProps:g={},...j}=t,[b,l]=i.useState(!1),a=i.useRef(null),u=i.useRef(null),k=Array.isArray(o)?o.map((n,B)=>i.isValidElement(n)?n:i.createElement(p,{...n,key:B})):o,y=()=>{l(n=>!n)},d=n=>{a.current&&a.current.contains(n.target)||l(!1)};P(u,d);const M=n=>{n.target.closest(".MuiMenuItem-root")&&l(!1)};return e.jsxs(e.Fragment,{children:[e.jsxs(R,{variant:x,size:s,color:r,ref:a,...j,children:[typeof c=="function"?c():e.jsx(m,{onClick:h,color:r,children:c}),e.jsx(m,{onClick:y,color:r,...g,"aria-label":"more functions",children:e.jsx(C,{})})]}),e.jsx(O,{open:b,anchorEl:a.current,placement:"bottom-end",disablePortal:!1,children:e.jsx(I,{ref:u,children:e.jsx(L,{onClickAway:d,children:e.jsx(v,{onClick:M,children:k})})})})]})}w.Item=p;const R=f(z)`
  > .MuiButtonBase-root:last-of-type {
    min-width: 2em;
    padding-left: 0;
    padding-right: 0;
  }
`,O=f(A)`
  z-index: ${t=>t.theme.zIndex.tooltip};
  .MuiList-root {
    padding: 4px 0;
  }
  .MuiListItem-root {
    padding-top: 4px;
    padding-bottom: 4px;
  }
`;export{w as O};
