import{createPopper as r}from"../../../../@popperjs/core/lib/popper.js";import{useRef as e,useCallback as t,useEffect as n}from"react";import{innerArrow as o,positionArrow as i,transformOrigin as a,matchWidth as p}from"./modifiers.js";import{cssVars as u,getEventListenerOptions as l}from"./utils.js";import{mergeRefs as s}from"../../../react-utils/dist/esm/refs.js";function f(){return(f=Object.assign||function(r){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(r[n]=t[n])}return r}).apply(this,arguments)}function c(c){void 0===c&&(c={});var{enabled:m=!0,modifiers:v=[],placement:g="bottom",strategy:b="absolute",arrowPadding:w=8,eventListeners:y=!0,offset:h,gutter:O=8,flip:j=!0,boundary:P="clippingParents",preventOverflow:R=!0,matchWidth:x}=c,z=e(null),U=e(null),A=e(null),C=e((()=>{})),L=t((()=>{m&&z.current&&U.current&&(null==C.current||C.current(),A.current=r(z.current,U.current,{placement:g,modifiers:[o,i,a,f({},p,{enabled:!!x}),f({name:"eventListeners"},l(y)),{name:"arrow",options:{padding:w}},{name:"offset",options:{offset:null!=h?h:[0,O]}},{name:"flip",enabled:!!j,options:{padding:8}},{name:"preventOverflow",enabled:!!R,options:{boundary:P}},...v],strategy:b}),A.current.forceUpdate(),C.current=A.current.destroy)}),[m,g,v,x,y,w,h,O,j,R,P,b]);n((()=>()=>{var r;z.current||U.current||(null==(r=A.current)||r.destroy(),A.current=null)}),[]);var W=t((r=>{z.current=r,L()}),[L]),k=t((function(r,e){return void 0===r&&(r={}),void 0===e&&(e=null),f({},r,{ref:s(W,e)})}),[W]),I=t((r=>{U.current=r,L()}),[L]),q=t((function(r,e){return void 0===r&&(r={}),void 0===e&&(e=null),f({},r,{ref:s(I,e),style:f({},r.style,{position:b,minWidth:"max-content",inset:"0 auto auto 0"})})}),[b,I]),B=t((function(r,e){return void 0===r&&(r={}),void 0===e&&(e=null),f({},function(r,e){if(null==r)return{};var t,n,o={},i=Object.keys(r);for(n=0;n<i.length;n++)t=i[n],e.indexOf(t)>=0||(o[t]=r[t]);return o}(r,["size","shadowColor","bg","style"]),{ref:e,"data-popper-arrow":"",style:d(r)})}),[]),D=t((function(r,e){return void 0===r&&(r={}),void 0===e&&(e=null),f({},r,{ref:e,"data-popper-arrow-inner":""})}),[]);return{update(){var r;null==(r=A.current)||r.update()},forceUpdate(){var r;null==(r=A.current)||r.forceUpdate()},transformOrigin:u.transformOrigin.varRef,referenceRef:W,popperRef:I,getPopperProps:q,getArrowProps:B,getArrowInnerProps:D,getReferenceProps:k}}function d(r){var{size:e,shadowColor:t,bg:n,style:o}=r,i=f({},o,{position:"absolute"});return e&&(i["--popper-arrow-size"]=e),t&&(i["--popper-arrow-shadow-color"]=t),n&&(i["--popper-arrow-bg"]=n),i}export{c as usePopper};
//# sourceMappingURL=use-popper.js.map
