import{defineComponent as M,computed as a,createVNode as i}from"vue";import{RightOutlined as b}from"@antsoo-lib/icons";import w from"../_util/classNames.mjs";import L from"../_util/omit.mjs";import R from"../_util/placements.mjs";import{isValidElement as y}from"../_util/props-util/index.mjs";import{cloneElement as C}from"../_util/vnode.mjs";import S from"../config-provider/hooks/useConfigInject.mjs";import{useProvideOverride as B}from"../menu/src/OverrideContext.mjs";import T from"../vc-dropdown/Dropdown.mjs";import h from"../vc-util/devWarning.mjs";import k from"./dropdown-button.mjs";import{dropdownProps as z}from"./props.mjs";import U from"./style/index.mjs";import W from"../_util/props-util/initDefaultProps.mjs";const Y=M({compatConfig:{MODE:3},name:"ADropdown",inheritAttrs:!1,props:W(z(),{mouseEnterDelay:.15,mouseLeaveDelay:.1,placement:"bottomLeft",trigger:"hover"}),slots:Object,setup(n,{slots:p,attrs:x,emit:s}){const{prefixCls:t,rootPrefixCls:v,direction:u,getPopupContainer:$}=S("dropdown",n),[P,D]=U(t),N=a(()=>{const{placement:e="",transitionName:o}=n;return o!==void 0?o:e.includes("top")?`${v.value}-slide-down`:`${v.value}-slide-up`});B({prefixCls:a(()=>`${t.value}-menu`),expandIcon:a(()=>i("span",{class:`${t.value}-menu-submenu-arrow`},[i(b,{class:`${t.value}-menu-submenu-arrow-icon`},null)])),mode:a(()=>"vertical"),selectable:a(()=>!1),onClick:()=>{},validator:({mode:e})=>{}});const O=()=>{const e=n.overlay||p.overlay?.(),o=Array.isArray(e)?e[0]:e;if(!o)return null;const r=o.props||{};h(!r.mode||r.mode==="vertical","Dropdown",`mode="${r.mode}" is not supported for Dropdown's Menu.`);const{selectable:m=!1,expandIcon:l=o.children?.expandIcon?.()}=r,c=typeof l<"u"&&y(l)?l:i("span",{class:`${t.value}-menu-submenu-arrow`},[i(b,{class:`${t.value}-menu-submenu-arrow-icon`},null)]);return y(o)?C(o,{mode:"vertical",selectable:m,expandIcon:()=>c}):o},A=a(()=>{const e=n.placement;if(!e)return u.value==="rtl"?"bottomRight":"bottomLeft";if(e.includes("Center")){const o=e.slice(0,e.indexOf("Center"));return h(!e.includes("Center"),"Dropdown",`You are using '${e}' placement in Dropdown, which is deprecated. Try to use '${o}' instead.`),o}return e}),I=a(()=>typeof n.visible=="boolean"?n.visible:n.open),j=e=>{s("update:visible",e),s("visibleChange",e),s("update:open",e),s("openChange",e)};return()=>{const{arrow:e,trigger:o,disabled:r,overlayClassName:m}=n,l=p.default?.()[0],c=C(l,Object.assign({class:w(l?.props?.class,{[`${t.value}-rtl`]:u.value==="rtl"},`${t.value}-trigger`)},r?{disabled:r}:{})),f=w(m,D.value,{[`${t.value}-rtl`]:u.value==="rtl"}),d=r?[]:o;let g;d&&d.includes("contextmenu")&&(g=!0);const E=R({arrowPointAtCenter:typeof e=="object"&&e.pointAtCenter,autoAdjustOverflow:!0}),V=L({...n,...x,visible:I.value,builtinPlacements:E,overlayClassName:f,arrow:!!e,alignPoint:g,prefixCls:t.value,getPopupContainer:$?.value,transitionName:N.value,trigger:d,onVisibleChange:j,placement:A.value},["overlay","onUpdate:visible"]);return P(i(T,V,{default:()=>[c],overlay:O}))}}});Y.Button=k;export{Y as default};
