import{Ea as a,H as h,N as f,Na as O,Q as b,U as p,da as d,ec as c,m as u,rg as I,s as m,sg as v,ta as S,va as g,x as n}from"./chunk-QXV2GR6R.js";import{i as t}from"./chunk-JJ4RDTEF.js";var x=(()=>{let s=class s{constructor(e,i){t(this,"peertubeRouter");t(this,"el");t(this,"percentLimit",70);t(this,"onItself",!1);t(this,"dataObservable");t(this,"setAngularState");t(this,"parentDisabled",!1);t(this,"nearOfBottom",new S);t(this,"decimalLimit",0);t(this,"lastCurrentBottom",-1);t(this,"scrollDownSub");t(this,"container");t(this,"checkScroll",!1);this.peertubeRouter=e,this.el=i,this.decimalLimit=this.percentLimit/100}ngAfterViewChecked(){this.checkScroll&&(this.checkScroll=!1,setTimeout(()=>{this.hasScroll()===!1&&this.nearOfBottom.emit()}))}ngOnInit(){this.initialize()}ngOnDestroy(){this.scrollDownSub&&this.scrollDownSub.unsubscribe()}initialize(){this.container=this.onItself?this.el.nativeElement:document.documentElement;let e={leading:!0,trailing:!0},i=this.onItself?this.container:window,w=m(i,"scroll").pipe(b(!0),p(200,void 0,e),u(()=>this.getScrollInfo()),h((r,l)=>r.current===l.current),f());this.scrollDownSub=w.pipe(n(({current:r})=>this.isScrollingDown(r)),n(({current:r,maximumScroll:l})=>r/l>this.decimalLimit)).subscribe(()=>{this.setAngularState&&!this.parentDisabled&&this.setScrollRouteParams(),this.nearOfBottom.emit()}),this.dataObservable&&this.dataObservable.pipe(n(r=>r.length!==0)).subscribe(()=>this.checkScroll=!0)}getScrollInfo(){return{current:this.container.scrollTop,maximumScroll:this.getMaximumScroll()}}getMaximumScroll(){let e=this.onItself?this.container.clientHeight:window.innerHeight;return this.container.scrollHeight-e}hasScroll(){return this.getMaximumScroll()>0}isScrollingDown(e){let i=this.lastCurrentBottom<e;return this.lastCurrentBottom=e,i}setScrollRouteParams(){this.peertubeRouter.addRouteSetting(I.REUSE_COMPONENT)}};t(s,"\u0275fac",function(i){return new(i||s)(a(v),a(g))}),t(s,"\u0275dir",d({type:s,selectors:[["","myInfiniteScroller",""]],inputs:{percentLimit:"percentLimit",onItself:[2,"onItself","onItself",c],dataObservable:"dataObservable",setAngularState:[2,"setAngularState","setAngularState",c],parentDisabled:"parentDisabled"},outputs:{nearOfBottom:"nearOfBottom"},standalone:!0,features:[O]}));let o=s;return o})();export{x as a};
/**i18n:224bcada6943fe8b17ea60808c2d370cec9507c3bd670ebe71692d099a3befa1*/
//# sourceMappingURL=chunk-CNNMPU7W.js.map
