function x(e){return e()}function O(e){e.forEach(x)}const r=[],p=[],l=[],b=[],g=Promise.resolve();let f=!1;function k(){f||(f=!0,g.then(I))}function y(){return k(),g}function C(e){l.push(e)}const d=new Set;let a=0;function I(){do{for(;anew CustomEvent(e,{detail:t});function M(e,t={}){const{root:u,rootMargin:w,threshold:_,unobserveOnEnter:E}=Object.assign(Object.assign({},z),t);let h={x:void 0,y:void 0},s={vertical:void 0,horizontal:void 0};if(typeof IntersectionObserver<"u"&&e){const o=new IntersectionObserver((m,v)=>{m.forEach(i=>{h.y>i.boundingClientRect.y?s.vertical="up":s.vertical="down",h.x>i.boundingClientRect.x?s.horizontal="left":s.horizontal="right",h={y:i.boundingClientRect.y,x:i.boundingClientRect.x};const c={inView:i.isIntersecting,entry:i,scrollDirection:s,node:e,observer:v};e.dispatchEvent(n("inview_change",c)),e.dispatchEvent(n("change",c)),i.isIntersecting?(e.dispatchEvent(n("inview_enter",c)),e.dispatchEvent(n("enter",c)),E&&v.unobserve(e)):(e.dispatchEvent(n("inview_leave",c)),e.dispatchEvent(n("leave",c)))})},{root:u,rootMargin:w,threshold:_});return y().then(()=>{e.dispatchEvent(n("inview_init",{observer:o,node:e})),e.dispatchEvent(n("init",{observer:o,node:e}))}),o.observe(e),{destroy(){o.unobserve(e)}}}}const V={unobserveOnEnter:!0,rootMargin:"-20%"},j=e=>t=>{const{inView:u}=t.detail;e.set(u)};export{V as a,M as i,j as o};