"use strict";const x=require("./index.cjs36.js"),n=require("react"),f=require("./index.cjs21.js"),u=t=>{const[a,m]=n.useState(0),c=n.useRef(),s=()=>{let e;return t.context?e=t.context.current:f.isBrowser()&&(e=document.documentElement),e},i=()=>{const e=s();if(e){const{scrollTop:o,clientHeight:l,scrollHeight:r}=e;o+l>=r-t.offset&&t.onBottomReached()}};n.useEffect(()=>{let e;if(t.context?e=t.context.current:f.isBrowser()&&(e=window),!!e)return e.addEventListener("scroll",i),()=>e&&e.removeEventListener("scroll",i)},[t.context]);const d=()=>{let e=!1;const o=s();if(o){const{clientHeight:l,scrollHeight:r}=o;e=r>l}return e};n.useEffect(()=>{if(!d()&&c&&c.current){const{clientHeight:e}=c.current;e>a&&(m(e),t.onBottomReached())}});const h=n.useMemo(()=>t.as||"div",[t.as]);return x.jsxRuntimeExports.jsx(h,{className:t.className,ref:c,children:t.children})};u.defaultProps={offset:0};module.exports=u;
//# sourceMappingURL=index.cjs6.js.map
