import{r as b,az as te,K as L,B as W,c8 as D,R as n,bc as _,b as ne,_ as ae,c as S,bU as re,d as oe,a as ie}from"./main-fine-mails-rush.js";var le=L.ESC,se=L.TAB;function ce(e){var u=e.visible,r=e.triggerRef,s=e.onVisibleChange,f=e.autoFocus,o=e.overlayRef,a=b.useRef(!1),c=function(){if(u){var t,i;(t=r.current)===null||t===void 0||(i=t.focus)===null||i===void 0||i.call(t),s==null||s(!1)}},h=function(){var t;return(t=o.current)!==null&&t!==void 0&&t.focus?(o.current.focus(),a.current=!0,!0):!1},p=function(t){switch(t.keyCode){case le:c();break;case se:{var i=!1;a.current||(i=h()),i?t.preventDefault():c();break}}};b.useEffect(function(){return u?(window.addEventListener("keydown",p),f&&te(h,3),function(){window.removeEventListener("keydown",p),a.current=!1}):function(){a.current=!1}},[u])}var ue=b.forwardRef(function(e,u){var r=e.overlay,s=e.arrow,f=e.prefixCls,o=b.useMemo(function(){var c;return typeof r=="function"?c=r():c=r,c},[r]),a=W(u,D(o));return n.createElement(n.Fragment,null,s&&n.createElement("div",{className:"".concat(f,"-arrow")}),n.cloneElement(o,{ref:_(o)?a:void 0}))}),v={adjustX:1,adjustY:1},d=[0,0],fe={topLeft:{points:["bl","tl"],overflow:v,offset:[0,-4],targetOffset:d},top:{points:["bc","tc"],overflow:v,offset:[0,-4],targetOffset:d},topRight:{points:["br","tr"],overflow:v,offset:[0,-4],targetOffset:d},bottomLeft:{points:["tl","bl"],overflow:v,offset:[0,4],targetOffset:d},bottom:{points:["tc","bc"],overflow:v,offset:[0,4],targetOffset:d},bottomRight:{points:["tr","br"],overflow:v,offset:[0,4],targetOffset:d}},ve=["arrow","prefixCls","transitionName","animation","align","placement","placements","getPopupContainer","showAction","hideAction","overlayClassName","overlayStyle","visible","trigger","autoFocus","overlay","children","onVisibleChange"];function de(e,u){var r,s=e.arrow,f=s===void 0?!1:s,o=e.prefixCls,a=o===void 0?"rc-dropdown":o,c=e.transitionName,h=e.animation,p=e.align,g=e.placement,t=g===void 0?"bottomLeft":g,i=e.placements,j=i===void 0?fe:i,K=e.getPopupContainer,$=e.showAction,B=e.hideAction,H=e.overlayClassName,z=e.overlayStyle,I=e.visible,N=e.trigger,A=N===void 0?["hover"]:N,U=e.autoFocus,M=e.overlay,y=e.children,w=e.onVisibleChange,X=ne(e,ve),Y=n.useState(),E=ae(Y,2),q=E[0],x=E[1],R="visible"in e?I:q,P=n.useRef(null),V=n.useRef(null),k=n.useRef(null);n.useImperativeHandle(u,function(){return P.current});var T=function(l){x(l),w==null||w(l)};ce({visible:R,triggerRef:k,onVisibleChange:T,autoFocus:U,overlayRef:V});var G=function(l){var C=e.onOverlayClick;x(!1),C&&C(l)},F=function(){return n.createElement(ue,{ref:V,overlay:M,prefixCls:a,arrow:f})},J=function(){return typeof M=="function"?F:F()},Q=function(){var l=e.minOverlayWidthMatchTrigger,C=e.alignPoint;return"minOverlayWidthMatchTrigger"in e?l:!C},Z=function(){var l=e.openClassName;return l!==void 0?l:"".concat(a,"-open")},ee=n.cloneElement(y,{className:S((r=y.props)===null||r===void 0?void 0:r.className,R&&Z()),ref:_(y)?W(k,D(y)):void 0}),O=B;return!O&&A.indexOf("contextMenu")!==-1&&(O=["click"]),n.createElement(re,oe({builtinPlacements:j},X,{prefixCls:a,ref:P,popupClassName:S(H,ie({},"".concat(a,"-show-arrow"),f)),popupStyle:z,action:A,showAction:$,hideAction:O,popupPlacement:t,popupAlign:p,popupTransitionName:c,popupAnimation:h,popupVisible:R,stretch:Q()?"minWidth":"",popup:J(),onPopupVisibleChange:T,onPopupClick:G,getPopupContainer:K}),ee)}const me=n.forwardRef(de);export{me as D};
