import{r as C,b5 as te,ba as L,b as W,c6 as D,aR as n,bm as _,d as ne,_ as ae,c as S,bN as re,f as oe,g as ie}from"./main-crazy-owls-work.js";var le=L.ESC,se=L.TAB;function ce(e){var f=e.visible,r=e.triggerRef,s=e.onVisibleChange,u=e.autoFocus,o=e.overlayRef,a=C.useRef(!1),c=function(){if(f){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}}};C.useEffect(function(){return f?(window.addEventListener("keydown",p),u&&te(h,3),function(){window.removeEventListener("keydown",p),a.current=!1}):function(){a.current=!1}},[f])}var fe=C.forwardRef(function(e,f){var r=e.overlay,s=e.arrow,u=e.prefixCls,o=C.useMemo(function(){var c;return typeof r=="function"?c=r():c=r,c},[r]),a=W(f,D(o));return n.createElement(n.Fragment,null,s&&n.createElement("div",{className:"".concat(u,"-arrow")}),n.cloneElement(o,{ref:_(o)?a:void 0}))}),v={adjustX:1,adjustY:1},d=[0,0],ue={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,f){var r,s=e.arrow,u=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?ue:i,$=e.getPopupContainer,K=e.showAction,B=e.hideAction,H=e.overlayClassName,I=e.overlayStyle,X=e.visible,N=e.trigger,A=N===void 0?["hover"]:N,Y=e.autoFocus,M=e.overlay,y=e.children,w=e.onVisibleChange,q=ne(e,ve),z=n.useState(),E=ae(z,2),G=E[0],x=E[1],R="visible"in e?X:G,P=n.useRef(null),V=n.useRef(null),k=n.useRef(null);n.useImperativeHandle(f,function(){return P.current});var T=function(l){x(l),w==null||w(l)};ce({visible:R,triggerRef:k,onVisibleChange:T,autoFocus:Y,overlayRef:V});var J=function(l){var b=e.onOverlayClick;x(!1),b&&b(l)},F=function(){return n.createElement(fe,{ref:V,overlay:M,prefixCls:a,arrow:u})},Q=function(){return typeof M=="function"?F:F()},U=function(){var l=e.minOverlayWidthMatchTrigger,b=e.alignPoint;return"minOverlayWidthMatchTrigger"in e?l:!b},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},q,{prefixCls:a,ref:P,popupClassName:S(H,ie({},"".concat(a,"-show-arrow"),u)),popupStyle:I,action:A,showAction:K,hideAction:O,popupPlacement:t,popupAlign:p,popupTransitionName:c,popupAnimation:h,popupVisible:R,stretch:U()?"minWidth":"",popup:Q(),onPopupVisibleChange:T,onPopupClick:J,getPopupContainer:$}),ee)}const me=n.forwardRef(de);export{me as D};
