import{C as W,H as v,Ib as p,La as h,Ma as b,Qb as M,Ta as K,Wa as P,ja as d,ka as O,p as C,v as u,x as E}from"./chunk-O7RN3KYY.js";import{a as H}from"./chunk-ZE2KCNEA.js";import{a as y,b as D}from"./chunk-CEWFFWI2.js";H();function z(t,e,o,i){let n=window&&!!window.document&&window.document.documentElement,l=n&&e?window:o;if(t&&(l=t&&n&&typeof t=="string"?R(t,o.nativeElement,i):t,!l))throw new Error("ngx-infinite-scroll {resolveContainerElement()}: selector for");return l}function R(t,e,o){return(o?window.document:e).querySelector(t)}function g(t){return t&&!t.firstChange}function Y(){return typeof window<"u"}var j={clientHeight:"clientHeight",offsetHeight:"offsetHeight",scrollHeight:"scrollHeight",pageYOffset:"pageYOffset",offsetTop:"offsetTop",scrollTop:"scrollTop",top:"top"},V={clientHeight:"clientWidth",offsetHeight:"offsetWidth",scrollHeight:"scrollWidth",pageYOffset:"pageXOffset",offsetTop:"offsetLeft",scrollTop:"scrollLeft",top:"left"},S=class{constructor(e=!0){this.vertical=e,this.propsMap=e?j:V}clientHeightKey(){return this.propsMap.clientHeight}offsetHeightKey(){return this.propsMap.offsetHeight}scrollHeightKey(){return this.propsMap.scrollHeight}pageYOffsetKey(){return this.propsMap.pageYOffset}offsetTopKey(){return this.propsMap.offsetTop}scrollTopKey(){return this.propsMap.scrollTop}topKey(){return this.propsMap.top}};function A(t,e,o){return!!(t&&e||!o&&e)}function B({windowElement:t,axis:e}){return X({axis:e,isWindow:x(t)},t)}function X(t,e){let o=t.isWindow||e&&!e.nativeElement?e:e.nativeElement;return D(y({},t),{container:o})}function x(t){return["Window","global"].some(o=>Object.prototype.toString.call(t).includes(o))}function m(t,e){return t?e.document.documentElement:null}function N(t,e){let o=q(e);return e.isWindow?G(o,t,e):L(o,t,e)}function G(t,e,o){let{axis:i,container:n,isWindow:l}=o,{offsetHeightKey:r,clientHeightKey:c}=I(i),a=t+F(m(l,n),i,l),s=U(e.nativeElement,l,r,c),f=Z(e.nativeElement,i,l)+s;return{height:t,scrolled:a,totalToScroll:f,isWindow:l}}function L(t,e,o){let{axis:i,container:n}=o,l=n[i.scrollTopKey()],r=n[i.scrollHeightKey()];return{height:t,scrolled:l,totalToScroll:r,isWindow:!1}}function I(t){return{offsetHeightKey:t.offsetHeightKey(),clientHeightKey:t.clientHeightKey()}}function q({container:t,isWindow:e,axis:o}){let{offsetHeightKey:i,clientHeightKey:n}=I(o);return U(t,e,i,n)}function U(t,e,o,i){if(isNaN(t[o])){let n=m(e,t);return n?n[i]:0}else return t[o]}function Z(t,e,o){let i=e.topKey();if(t.getBoundingClientRect)return t.getBoundingClientRect()[i]+F(t,e,o)}function F(t,e,o){let i=e.pageYOffsetKey(),n=e.scrollTopKey(),l=e.offsetTopKey();return isNaN(window.pageYOffset)?m(o,t)[n]:t.ownerDocument?t.ownerDocument.defaultView[i]:t[l]}function J(t,e={down:0,up:0},o){let i,n;if(t.totalToScroll<=0)return!1;let l=t.isWindow?t.scrolled:t.height+t.scrolled;if(o)i=(t.totalToScroll-l)/t.totalToScroll,n=(e?.down?e.down:0)/10;else{let c=t.scrolled+(t.totalToScroll-l);i=t.scrolled/c,n=(e?.up?e.up:0)/10}return i<=n}function Q(t,e){return tC(N(i,l))),u(s=>et(r.lastScrollPosition,s,a)),d(({stats:s})=>r.updateScroll(s.scrolled,s.totalToScroll)),v(({fire:s,scrollDown:f,stats:{totalToScroll:k}})=>A(t.alwaysCallback,s,r.isTriggeredScroll(k,f))),d(({scrollDown:s,stats:{totalToScroll:f}})=>{r.updateTriggeredFlag(f,s)}),u(ot))}function tt(t){let e=W(t.container,"scroll");return t.throttle&&(e=e.pipe(O(t.throttle,void 0,{leading:!0,trailing:!0}))),e}function et(t,e,o){let{scrollDown:i,fire:n}=_(t,e,o);return{scrollDown:i,fire:n,stats:e}}var T={DOWN:"[NGX_ISE] DOWN",UP:"[NGX_ISE] UP"};function ot(t){let{scrollDown:e,stats:{scrolled:o}}=t;return{type:e?T.DOWN:T.UP,payload:{currentScrollPosition:o}}}var pt=(()=>{class t{constructor(o,i){this.element=o,this.zone=i,this.scrolled=new h,this.scrolledUp=new h,this.infiniteScrollDistance=2,this.infiniteScrollUpDistance=1.5,this.infiniteScrollThrottle=150,this.infiniteScrollDisabled=!1,this.infiniteScrollContainer=null,this.scrollWindow=!0,this.immediateCheck=!1,this.horizontal=!1,this.alwaysCallback=!1,this.fromRoot=!1}ngAfterViewInit(){this.infiniteScrollDisabled||this.setup()}ngOnChanges({infiniteScrollContainer:o,infiniteScrollDisabled:i,infiniteScrollDistance:n}){let l=g(o),r=g(i),c=g(n),a=!r&&!this.infiniteScrollDisabled||r&&!i.currentValue||c;(l||r||c)&&(this.destroyScroller(),a&&this.setup())}ngOnDestroy(){this.destroyScroller()}setup(){Y()&&this.zone.runOutsideAngular(()=>{this.disposeScroller=$({fromRoot:this.fromRoot,alwaysCallback:this.alwaysCallback,disable:this.infiniteScrollDisabled,downDistance:this.infiniteScrollDistance,element:this.element,horizontal:this.horizontal,scrollContainer:this.infiniteScrollContainer,scrollWindow:this.scrollWindow,throttle:this.infiniteScrollThrottle,upDistance:this.infiniteScrollUpDistance}).subscribe(o=>this.handleOnScroll(o))})}handleOnScroll({type:o,payload:i}){let n=o===T.DOWN?this.scrolled:this.scrolledUp;it(n)&&this.zone.run(()=>n.emit(i))}destroyScroller(){this.disposeScroller&&this.disposeScroller.unsubscribe()}static{this.\u0275fac=function(i){return new(i||t)(p(P),p(b))}}static{this.\u0275dir=M({type:t,selectors:[["","infiniteScroll",""],["","infinite-scroll",""],["","data-infinite-scroll",""]],inputs:{infiniteScrollDistance:"infiniteScrollDistance",infiniteScrollUpDistance:"infiniteScrollUpDistance",infiniteScrollThrottle:"infiniteScrollThrottle",infiniteScrollDisabled:"infiniteScrollDisabled",infiniteScrollContainer:"infiniteScrollContainer",scrollWindow:"scrollWindow",immediateCheck:"immediateCheck",horizontal:"horizontal",alwaysCallback:"alwaysCallback",fromRoot:"fromRoot"},outputs:{scrolled:"scrolled",scrolledUp:"scrolledUp"},features:[K]})}}return t})();function it(t){return t.observed}export{pt as a};