import{o as e}from"./chunk.DuxOD-Sk.js";import{r as t}from"./emotion-is-prop-valid.esm.DV_OErv-.js";import{c as n,l as r,t as i}from"./emotion-styled.browser.esm.CEYoudG7.js";import"./loglevel.H4SN4KQm.js";import"./isLength.Dot76Eow.js";import"./getColors.Llt-1DRT.js";import"./protobuf.GnXEZo24.js";import{A as a,It as o,Lt as s,Ot as c,Rt as l,_t as u,bt as d,ft as f,vt as p,w as m,xt as h}from"./src.CIyydb94.js";import{t as g}from"./useEmotionTheme.BJ0dpv2U.js";import"./utils.C1Nidt8_.js";import{l as _}from"./utils.VFl7c69J.js";import"./ErrorElement.K-kvHExv.js";import"./v4.C6ecLp5d.js";import"./utils.B6lSy2ZF.js";import{n as v,t as y}from"./DynamicIcon.6EyHIksX.js";import"./UriUtil.BJr0dLQG.js";import{c as b,n as x,u as S}from"./useCopyToClipboard.CUBg6ZxJ.js";import"./useWindowDimensionsContext.jnKliU5K.js";import"./katex.min.DyoqhKgf.js";var C=e(t()),w=i(`div`,{target:`e1cb2q0m0`})(({theme:e})=>({display:`flex`,alignItems:`center`,gap:e.spacing.threeXS,marginRight:`calc(-${e.iconSizes.lg} * 0.25)`})),T=i(`div`,{target:`e1cb2q0m1`})(({theme:e})=>({display:`inline-flex`,marginTop:e.spacing.threeXS})),E=i(`div`,{target:`e1cb2q0m2`})(({theme:e})=>({display:`flex`,alignItems:`center`,gap:e.spacing.sm,whiteSpace:`nowrap`})),D=i(`span`,{target:`e1cb2q0m3`})(({theme:e})=>({display:`inline-flex`,alignItems:`center`,justifyContent:`center`,flexShrink:0,width:e.iconSizes.md,color:e.colors.bodyText})),O=i(`li`,{target:`e1cb2q0m4`})(({theme:e})=>({display:`flex`,alignItems:`center`,marginTop:e.spacing.twoXS,marginBottom:e.spacing.twoXS,padding:0,background:`transparent`,cursor:`pointer`,listStyle:`none`,minWidth:e.sizes.minMenuWidth})),k={primary:s.PRIMARY,secondary:s.SECONDARY,tertiary:s.TERTIARY},A=(0,C.memo)(function({item:e,$isHighlighted:t,onClick:i,onMouseEnter:a,onKeyDown:o,$disabled:s,$isFocused:c,$size:l,resetMenu:u,renderAll:d,...f}){let{icon:p,text:g}=v(e.label);return n(O,{...f,role:`menuitem`,onClick:i,onMouseEnter:a,onKeyDown:o,children:n(m,{$isHighlighted:t,children:r(E,{children:[p&&n(D,{"aria-hidden":`true`,children:n(y,{iconValue:p,size:`md`})}),n(h,{source:g,allowHTML:!1,isLabel:!0,largerLabel:!1,disableLinks:!0})]})})})});function j(e){let{disabled:t,element:i,widgetMgr:m,fragmentId:h}=e,[v,E]=(0,C.useState)(!1),D=(0,C.useContext)(c),O=g(),j=k[i.type]??s.SECONDARY,M=(0,C.useMemo)(()=>i.options.map(e=>({label:e,value:e})),[i.options]),N=t||i.disabled||i.options.length===0,P=(0,C.useCallback)(e=>{E(!1),!N&&m.setStringTriggerValue(i,e.item.value,{fromUi:!0},h)},[N,i,m,h]);return n(p,{className:`stMenuButton`,"data-testid":`stMenuButton`,children:n(x,{triggerType:S.click,placement:b.bottomLeft,isOpen:v,onClickOutside:()=>E(!1),onEsc:()=>E(!1),ignoreBoundary:D,popoverMargin:_(O.spacing.twoXS),renderAll:!0,content:()=>n(a,{items:M,onItemSelect:P,overrides:{List:{props:{role:`menu`},style:{backgroundColor:O.colors.bgColor,paddingTop:O.spacing.threeXS,paddingBottom:O.spacing.threeXS,paddingLeft:O.spacing.xs,paddingRight:O.spacing.xs,boxShadow:`none`,outline:`none`}},Option:{component:A}}}),overrides:{Body:{props:{"data-testid":`stMenuButtonBody`},style:()=>({...d(O),borderTopLeftRadius:O.radii.xl,borderTopRightRadius:O.radii.xl,borderBottomRightRadius:O.radii.xl,borderBottomLeftRadius:O.radii.xl,marginRight:O.spacing.lg,marginBottom:O.spacing.lg,maxHeight:`70vh`,overflow:`auto`})}},children:n(`div`,{children:n(u,{help:i.help,containerWidth:!0,children:n(o,{"data-testid":`stMenuButtonButton`,kind:j,size:l.SMALL,disabled:N,containerWidth:!0,onClick:()=>E(!v),"aria-haspopup":`menu`,"aria-expanded":v,children:r(w,{children:[n(f,{icon:i.icon,label:i.label}),n(T,{"aria-hidden":`true`,children:n(y,{iconValue:v?`:material/expand_less:`:`:material/expand_more:`,size:`lg`})})]})})})})})})}var M=(0,C.memo)(j);export{M as default};