'use client';
"use strict";var React=require("react");function useInView({triggerOnce:e,skip:t,addRootMargin:n=0,initialInView:r,onChange:i}={}){let c=React.useRef(),[o,u]=React.useState({inView:!!r}),s=React.useRef(),w=React.useCallback(r=>{if(void 0!==c.current&&(c.current(),c.current=void 0,s.current=void 0),t||!r)return;let w=()=>{s.current||(s.current=requestAnimationFrame(()=>{let t=r.getBoundingClientRect(),a=-n,d=(window.innerHeight||document.documentElement.clientHeight)+n,v=t.top<=a&&t.bottom>=a||t.top>=a&&t.bottom<=d||t.top<=d&&t.bottom>=d;v!==o.inView&&(u({inView:v}),i&&i(v,r),v&&e&&c.current&&(window.removeEventListener("scroll",w),window.removeEventListener("resize",w),s.current&&cancelAnimationFrame(s.current),c.current=void 0,s.current=void 0)),s.current=void 0}))};window.addEventListener("scroll",w),window.addEventListener("resize",w),w(),c.current=()=>{window.removeEventListener("scroll",w),window.removeEventListener("resize",w),s.current&&cancelAnimationFrame(s.current),s.current=void 0}},[t,n,o.inView,i,e]);React.useEffect(()=>{c.current||!o.entry||e||t||u({inView:!!r})},[o.entry,e,t,r]);let a=[w,o.inView,o.entry];return a.ref=a[0],a.inView=a[1],a.entry=a[2],a}exports.useInView=useInView;
