"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@babel/runtime/helpers/defineProperty"),r=require("react/jsx-runtime"),n=require("react"),o=require("@material-ui/core"),t=require("classnames"),c=require("../Popper/Popper.js"),i=require("../Paper/Paper.js"),a=require("./utils.js"),l=require("./Popover.scss.js");function s(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var u=s(e),p=s(t);function d(e,r){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);r&&(o=o.filter((function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable}))),n.push.apply(n,o)}return n}function f(e){for(var r=1;r<arguments.length;r++){var n=null!=arguments[r]?arguments[r]:{};r%2?d(Object(n),!0).forEach((function(r){u.default(e,r,n[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):d(Object(n)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))}))}return e}var v=n.forwardRef((function(e,t){var s=e.children,u=e.open,d=e.onClose,v=e.className,b=e.closeOnBackdropClick,m=void 0===b||b,y=e.closeOnEscape,j=void 0===y||y,O=e.backdrop,P=void 0===O||O,E=e.anchorEl,h=e.preventScroll,w=void 0===h||h,k=e.placement,g=void 0===k?"bottom-start":k,x=e.onMouseLeave,q=e.onMouseEnter,M=e.flip,C=void 0===M||M,N=e.preventOverflow,R=void 0===N||N,S=e.container,D=e.animate,L=void 0===D||D,A=e.type,_=void 0===A?"popover":A,z=n.useRef(null),B=n.useRef(new ResizeObserver((function(){var e;null===(e=z.current)||void 0===e||e.scheduleUpdate()}))),F=n.useCallback((function(){d&&m&&d("backdropClick")}),[d,m]);n.useEffect((function(){var e=function(e){"Escape"!==e.key&&"Esc"!==e.key||null==d||d("escapeKey")};return u&&j?(document.addEventListener("keydown",e),function(){document.removeEventListener("keydown",e)}):function(){}}),[d,j,u]),n.useEffect((function(){return u&&w?a.disableScroll(document.body):function(){}}),[u,w]);var G=n.useMemo((function(){return{preventOverflow:{enabled:R,padding:20,boundariesElement:"viewport"},flip:{enabled:C}}}),[C,R]);return r.jsxs(r.Fragment,{children:[P&&r.jsx(c.Popper,{open:u,className:l.root,container:S,children:r.jsx("div",{className:l.backdrop,onClick:F})}),r.jsx(c.Popper,{open:u,anchorEl:E,placement:g,className:l.root,transition:!0,popperRef:z,modifiers:G,container:S,children:function(e){var n=e.TransitionProps;return r.jsx(o.Grow,f(f({},n),{},{timeout:L?"auto":0,disableStrictModeCompat:!0,onEntered:function(){for(var e,r=arguments.length,o=new Array(r),t=0;t<r;t++)o[t]=arguments[t];null==n||null===(e=n.onEntered)||void 0===e||e.call.apply(e,[n].concat(o)),B.current.observe(o[0])},onExit:function(){for(var e,r=arguments.length,o=new Array(r),t=0;t<r;t++)o[t]=arguments[t];null==n||null===(e=n.onExit)||void 0===e||e.call.apply(e,[n].concat(o)),B.current.disconnect()},children:r.jsx(i.Paper,{className:p.default(l.paper,v),onMouseEnter:q,onMouseLeave:x,ref:t,type:_,children:s})}))}})]})}));exports.Popover=v;
//# sourceMappingURL=Popover.js.map
