import{Ga as a,I as h,Na as g,O as f,R as b,Ra as O,V as p,fc as c,lg as I,mg as v,n as u,qa as S,sa as d,t as m,y as s}from"./chunk-4JM6MIZ5.js";import{i as l}from"./chunk-QJQRWPYR.js";var x=(()=>{let r=class r{peertubeRouter;el;percentLimit=70;onItself=!1;dataObservable;setAngularState;parentDisabled=!1;nearOfBottom=new S;decimalLimit=0;lastCurrentBottom=-1;scrollDownSub;container;checkScroll=!1;constructor(t,e){this.peertubeRouter=t,this.el=e,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 t={leading:!0,trailing:!0},e=this.onItself?this.container:window,w=m(e,"scroll").pipe(b(!0),p(200,void 0,t),u(()=>this.getScrollInfo()),h((i,o)=>i.current===o.current),f());this.scrollDownSub=w.pipe(s(({current:i})=>this.isScrollingDown(i)),s(({current:i,maximumScroll:o})=>i/o>this.decimalLimit)).subscribe(()=>{this.setAngularState&&!this.parentDisabled&&this.setScrollRouteParams(),this.nearOfBottom.emit()}),this.dataObservable&&this.dataObservable.pipe(s(i=>i.length!==0)).subscribe(()=>this.checkScroll=!0)}getScrollInfo(){return{current:this.container.scrollTop,maximumScroll:this.getMaximumScroll()}}getMaximumScroll(){let t=this.onItself?this.container.clientHeight:window.innerHeight;return this.container.scrollHeight-t}hasScroll(){return this.getMaximumScroll()>0}isScrollingDown(t){let e=this.lastCurrentBottom<t;return this.lastCurrentBottom=t,e}setScrollRouteParams(){this.peertubeRouter.addRouteSetting(I.REUSE_COMPONENT)}};l(r,"\u0275fac",function(e){return new(e||r)(a(v),a(d))}),l(r,"\u0275dir",g({type:r,selectors:[["","myInfiniteScroller",""]],inputs:{percentLimit:"percentLimit",onItself:[2,"onItself","onItself",c],dataObservable:"dataObservable",setAngularState:[2,"setAngularState","setAngularState",c],parentDisabled:"parentDisabled"},outputs:{nearOfBottom:"nearOfBottom"},features:[O]}));let n=r;return n})();export{x as a};
/**i18n:68865f44f2a527c44cf5136a17c76a0ff8308c2bae5c7c8d50070a5fb9847c44*/
//# sourceMappingURL=chunk-TP3WH7UR.js.map
