import{a as g}from"./chunk-G5QQX4VN.js";import{Fa as p,Ha as h,e as l}from"./chunk-GJDGQISV.js";var u=class extends g{constructor(t,e,s,i,n,a,r,o,c="post",D="post"){super(t,e,s,i,n,a,r,c,D);this.httpService=e;this.toastrService=n;this.route=a;this.cdr=o;this.dataMethod=c;this.loaderMethod=D;o&&h(()=>{this.infiniteListSignal(),this.cdr.markForCheck()})}toastrCount=0;nextPageDisabled=!1;extendData=!1;goToLast=!1;listTotal=0;_infiniteList$=new l([]);infiniteListSignal=p([]);get infiniteList(){return this._infiniteList$.value}set infiniteList(t){this._infiniteList$.next(t),this.infiniteListSignal.set(t)}originalData=[];StoreRowsCountAPIResult(t,e=!1){this.httpService.post("/api/"+t,this.pageData.Filter).subscribe(s=>{this.listTotal=s.Count,this.pageData.HideStoreApiCount=!0,e&&(this.pageData.Filter.RowCount=this.listTotal,this.goToLast=!0,this.pageData.Filter.PageNumber=1,this.getListData()),this.cdr&&this.cdr.markForCheck()})}NextPage(t){this.pageData.Filter.PageNumber=this.pageData.Filter.PageNumber||1,this.pageData.Filter.PageNumber+=1,this.extendData=t,this.getListData()}postInit(t){t?.Data?.length>0&&(this.toastrCount=0),t?.Data?.length===0&&this.toastrCount===0&&(this.toastrService?.info("No more data to load","Info"),this.toastrCount=1);let e=Array.isArray(t.Data?.hits),s=Array.isArray(t.Data?.[0]?.Variants),i=[...this.infiniteList];if(this.extendData){let a=i.at(-1),r=t.Data.find(o=>o.ID===a?.ID);if(s&&a)if(r){let o=t.Data.filter(c=>c.ID!==a?.ID);a.Variants=a.Variants.concat(r.Variants||[]),i=i.concat(o)}else i=i.concat(t.Data);else i=i.concat(e?t.Data.hits:t.Data);this.postExtendData(t),this.extendData=!1}else i=e?t.Data.hits:t.Data,this.assignAggregate(t);this.infiniteList=i,this.originalData=[...i];let n=e?t.Data.hits.length:t.Data.length;this.nextPageDisabled=n<this.pageData.Filter.RowCount,this.menuData.H=this.data.PageTitle||this.menuData.H,this.afterPostInit(t),this.cdr?.markForCheck?.()}afterPostInit(t){}preSearchFromPageOne(){this.goToLast=!1}postExtendData(t){}assignAggregate(t){}onSelectAllData(t){super.onSelectAllData(t),this.infiniteList=this.infiniteList.map(e=>(e.selected=t,e))}};export{u as a};
