import{__exports as e}from"../../../../_virtual/use-intersection.js_commonjs-exports";export{__exports as default}from"../../../../_virtual/use-intersection.js_commonjs-exports";import t from"react";import"./request-idle-callback.js";import{__exports as r}from"../../../../_virtual/request-idle-callback.js_commonjs-exports";e.__esModule=!0,e.useIntersection=function({rootMargin:e,disabled:t}){const r=t||!o,i=(0,n.useRef)(),[a,u]=(0,n.useState)(!1),l=(0,n.useCallback)((t=>{i.current&&(i.current(),i.current=void 0),r||a||t&&t.tagName&&(i.current=function(e,t,r){const{id:n,observer:s,elements:o}=function(e){const t=e.rootMargin||"";let r=c.get(t);if(r)return r;const n=new Map,s=new IntersectionObserver((e=>{e.forEach((e=>{const t=n.get(e.target),r=e.isIntersecting||e.intersectionRatio>0;t&&r&&t(r)}))}),e);return c.set(t,r={id:t,observer:s,elements:n}),r}(r);return o.set(e,t),s.observe(e),function(){o.delete(e),s.unobserve(e),0===o.size&&(s.disconnect(),c.delete(n))}}(t,(e=>e&&u(e)),{rootMargin:e}))}),[r,e,a]);return(0,n.useEffect)((()=>{if(!o&&!a){const e=(0,s.requestIdleCallback)((()=>u(!0)));return()=>(0,s.cancelIdleCallback)(e)}}),[a]),[l,a]};var n=t,s=r;const o="undefined"!=typeof IntersectionObserver;const c=new Map;
//# sourceMappingURL=use-intersection.js.map
