"use strict";var stringUtil=require("./stringUtil-dea69be9.js"),React=require("react"),ReactDOM=require("react-dom"),reactUse=require("react-use");function _interopDefaultLegacy(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var React__default=_interopDefaultLegacy(React);function useContextMenu(e){var t=e.triggerElement,i=e.menuRender,n=e.disabled,a=void 0!==n&&n,n=e.triggerByChild,u=void 0===n||n,n=e.wrapperClassName,d=e.getPopupContainer,o=e.getMenuPosition,l=e.blackList,e=stringUtil.__read(reactUse.useMeasure(),2),f=e[0],e=e[1],m=e.width,g=e.height,v=React.useRef(null),e=stringUtil.__read(React.useState(!1),2),r=e[0],s=e[1],e=stringUtil.__read(React.useState(0),2),p=e[0],_=e[1],e=stringUtil.__read(React.useState(0),2),R=e[0],x=e[1],e=React.useMemo(function(){return{position:"fixed",left:t&&r?p:"-".concat(window.outerWidth+1e3,"px"),top:t&&r?R:"-".concat(window.outerHeight+1e3,"px"),zIndex:9999}},[r,t,p,R]),C=React.useCallback(function(e){f(e),v.current=e},[f]),c=(reactUse.useClickAway(v,function(){s(!1)}),React.useCallback(function(e){var t=e.target,n=e.currentTarget;if(t&&n&&t instanceof Element&&n instanceof Element&&(!u||n.contains(t))&&(u||n===t)){if(l)for(var a=l.length,r=t;r;){for(var c=0;c<a;c++)if(r.classList.contains(l[c])||r.tagName===l[c])return;r=r.parentElement}if(e.preventDefault(),s(!0),o)return t=(n=stringUtil.__read(o(e),2))[0],n=n[1],_(t),void x(n);var t=e.clientX,n=void 0===t?0:t,t=e.clientY,e=void 0===t?0:t,t=document.documentElement,i=t.clientWidth,t=t.clientHeight,i=n+m-i,t=e+g-t;_(0<i?n-i:n),x(0<t?e-t:e)}},[l,o,g,u,m])),h=React.useCallback(function(){s(!1)},[]);return React.useEffect(function(){return a?null!=t&&t.removeEventListener("contextmenu",c):null!=t&&t.addEventListener("contextmenu",c),function(){null!=t&&t.removeEventListener("contextmenu",c)}},[h,c,t,a]),a?null:ReactDOM.createPortal(React__default.default.createElement("div",{className:n,ref:C,style:e,onClick:h},i()),(null==d?void 0:d())||document.body)}function compact(e){for(var t=-1,n=null==e?0:e.length,a=0,r=[];++t<n;){var c=e[t];c&&(r[a++]=c)}return r}var compact_1=compact;exports.compact_1=compact_1,exports.useContextMenu=useContextMenu;
