import{Dg as v,H as f,M as b,P as p,T as d,Ta as O,aa as a,n as h,nc as w,ra as S,s as u,sa as n,ta as g,x as o}from"./chunk-7XZKA4JV.js";import{i as c}from"./chunk-ROL33JP2.js";var E=(()=>{let i=class i{peertubeRouter=a(v);el=a(g);percentLimit=n(70);onItself=n(!1,{transform:w});dataObservable=n(void 0);nearOfBottom=S();decimalLimit=0;lastCurrentBottom=-1;scrollDownSub;container;checkScroll=!1;constructor(){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},r=this.onItself()?this.container:window,I=u(r,"scroll").pipe(p(!0),d(200,void 0,t),h(()=>this.getScrollInfo()),f((e,s)=>e.current===s.current),b());this.scrollDownSub=I.pipe(o(({current:e})=>this.isScrollingDown(e)),o(({current:e,maximumScroll:s})=>e/s>this.decimalLimit)).subscribe(()=>{this.nearOfBottom.emit()});let m=this.dataObservable();m&&m.pipe(o(e=>e.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 r=this.lastCurrentBottom<t;return this.lastCurrentBottom=t,r}};c(i,"\u0275fac",function(r){return new(r||i)}),c(i,"\u0275dir",O({type:i,selectors:[["","myInfiniteScroller",""]],inputs:{percentLimit:[1,"percentLimit"],onItself:[1,"onItself"],dataObservable:[1,"dataObservable"]},outputs:{nearOfBottom:"nearOfBottom"}}));let l=i;return l})();export{E as a};
/**i18n:37786acc6a78281d9fbe29f0e76f79a0df01fc58cd74a91d2d29106b1f1580b1*/
//# sourceMappingURL=chunk-K57X56UD.js.map
