"use strict";const H=require("./utils-yMPNzXQX.cjs.js"),P=require("./useGlobalListeners-CwGh-cDn.cjs.js"),a=require("react");let l=!1,d=0;function g(){l=!0,setTimeout(()=>{l=!1},50)}function h(f){f.pointerType==="touch"&&g()}function M(){if(!(typeof document>"u"))return d===0&&(typeof PointerEvent<"u"?document.addEventListener("pointerup",h):process.env.NODE_ENV==="test"&&document.addEventListener("touchend",g)),d++,()=>{d--,!(d>0)&&(typeof PointerEvent<"u"?document.removeEventListener("pointerup",h):process.env.NODE_ENV==="test"&&document.removeEventListener("touchend",g))}}function G(f){let{onHoverStart:v,onHoverChange:s,onHoverEnd:p,isDisabled:r}=f,[T,E]=a.useState(!1),t=a.useRef({isHovered:!1,ignoreEmulatedMouseEvents:!1,pointerType:"",target:null}).current;a.useEffect(M,[]);let{addGlobalListener:$,removeAllGlobalListeners:b}=P.$03deb23ff14920c4$export$4eaf04e54aa8eed6(),{hoverProps:y,triggerHoverEnd:L}=a.useMemo(()=>{let m=(e,n)=>{if(t.pointerType=n,r||n==="touch"||t.isHovered||!e.currentTarget.contains(e.target))return;t.isHovered=!0;let i=e.currentTarget;t.target=i,$(H.$431fbd86ca7dc216$export$b204af158042fbac(e.target),"pointerover",c=>{t.isHovered&&t.target&&!H.$d4ee10de306f2510$export$4282f70798064fe0(t.target,c.target)&&u(c,c.pointerType)},{capture:!0}),v&&v({type:"hoverstart",target:i,pointerType:n}),s&&s(!0),E(!0)},u=(e,n)=>{let i=t.target;t.pointerType="",t.target=null,!(n==="touch"||!t.isHovered||!i)&&(t.isHovered=!1,b(),p&&p({type:"hoverend",target:i,pointerType:n}),s&&s(!1),E(!1))},o={};return typeof PointerEvent<"u"?(o.onPointerEnter=e=>{l&&e.pointerType==="mouse"||m(e,e.pointerType)},o.onPointerLeave=e=>{!r&&e.currentTarget.contains(e.target)&&u(e,e.pointerType)}):process.env.NODE_ENV==="test"&&(o.onTouchStart=()=>{t.ignoreEmulatedMouseEvents=!0},o.onMouseEnter=e=>{!t.ignoreEmulatedMouseEvents&&!l&&m(e,"mouse"),t.ignoreEmulatedMouseEvents=!1},o.onMouseLeave=e=>{!r&&e.currentTarget.contains(e.target)&&u(e,"mouse")}),{hoverProps:o,triggerHoverEnd:u}},[v,s,p,r,t,$,b]);return a.useEffect(()=>{r&&L({currentTarget:t.target},t.pointerType)},[r]),{hoverProps:y,isHovered:T}}exports.$6179b936705e76d3$export$ae780daf29e6d456=G;
//# sourceMappingURL=useHover-BCGp55jR.cjs.js.map
