import{y as e}from"./utils-BakkG8Vx.js";import{d as t,f as n,m as r,s as i,t as a}from"./hooks.module-5xe-uC6c.js";import{wt as o}from"./content_renderer-CoENEE63.js";import{t as s}from"./jsxRuntime.module--xb8gfv5.js";import{H as c,Y as l}from"./hooks-CSTgmcXO.js";t();function u({id:t,className:u,buttonClassName:d,isStatic:f,children:p,title:m,text:h,dropdownContainerStyle:g,dropdownContainerClassName:_,dropdownContainerRef:v,hideToggleArrow:y,iconAction:b,disabled:x,noSelectButtonStyle:S,noDropdownListStyle:C,forceShown:w,onShown:T,onHidden:E,dropdownOptions:D,buttonProps:O,dropdownRef:k,titlePosition:A,titleOptions:j,mobileBackdrop:M}){let N=a(null),P=a(null),F=a(null),{showTooltip:I,hideTooltip:L}=c(N,{...j,placement:A??`bottom`,fallbackPlacements:[A??`bottom`],trigger:`manual`}),[R,z]=i(!1);r(()=>{if(!P.current||!F.current)return;let e=o.getOrCreateInstance(P.current,D);k&&(k.current=e),w&&(e.show(),z(!0));let t=new ResizeObserver(()=>e.update());return t.observe(F.current),()=>{t.disconnect(),e.dispose()}},[]);let B=n(()=>{z(!0),T?.(),L(),M&&e()&&document.getElementById(`context-menu-cover`)?.classList.add(`show`,`global-menu-cover`)},[L,M]),V=n(()=>{z(!1),E?.(),M&&e()&&document.getElementById(`context-menu-cover`)?.classList.remove(`show`,`global-menu-cover`)},[M]);r(()=>{if(!N.current)return;v&&(v.current=N.current);let e=$(N.current);return e.on(`show.bs.dropdown`,e=>{e.stopPropagation(),B()}),e.on(`hide.bs.dropdown`,e=>{e.stopPropagation(),V()}),()=>{e.off(`show.bs.dropdown`,B),e.off(`hide.bs.dropdown`,V)}},[B,V]);let H=l(`button`);return s(`div`,{ref:N,class:`dropdown ${u??``}`,style:{display:`flex`},title:m,children:[s(`button`,{className:`${b?`icon-action`:`btn`} ${S?``:`select-button`} ${d??``} ${y?``:`dropdown-toggle`}`,ref:P,type:`button`,"data-bs-toggle":`dropdown`,"data-bs-display":f?`static`:void 0,"aria-haspopup":`true`,"aria-expanded":`false`,id:t??H,disabled:x,onMouseEnter:I,onMouseLeave:L,...O,children:[h,s(`span`,{className:`caret`})]}),s(`ul`,{class:`dropdown-menu tn-dropdown-menu ${f?`static`:``} ${_??``} ${C?``:`tn-dropdown-list`}`,style:g,"aria-labelledby":H,ref:F,onClick:e=>{e.target===F.current&&e.stopPropagation()},children:R&&p})]})}export{u as t};