import{a as P,b as Q}from"./chunk-4CERJ67S.js";import{D as f,E as z}from"./chunk-I7GW4F3B.js";import{B as m,D as c,I as C}from"./chunk-HTXYTVN4.js";import{b as S,c as F}from"./chunk-YBNTOQCK.js";import{Jb as a,Nc as u,Oc as p,Pc as l,Sb as h,Ub as d,Wa as g,be as O}from"./chunk-WL5U2YIT.js";import{a as n,e as y}from"./chunk-ADEKKGI2.js";var b,N,x,v=y(()=>{Q();O();F();C();z();b=["dt"],N=[10,20,50,100],x=(()=>{let r=class r extends P{constructor(e,t,s,i){super(),this.translatorService=e,this.route=t,this.router=s,this.currentUserService=i,this.items=[],this.lazyLoadOnInit=!0,this.pageSizeOptions=[],this.selectedSortOrder=1,this.defaultSortFieldName="name",this.defaultSortParamName="name",this.useQueryParams=!0,this.initializeColumns()}ngOnInit(){this.initializePageSizeOptions(),this.first=this.getFirst()}ngOnChanges(e){e.paging&&(this.tableOptions.defaultSortField=this.sortParamToField(this.paging.sortField),this.tableOptions.defaultSortOrder=this.paging.sortOrder),this.first=this.getFirst()}lazyLoad(e){this.selectedSortField=this.arrayOrStringToString(e.sortField),this.selectedSortOrder=e.sortOrder,this.updateQueryParameters()}onPageSizeOptionsChange(){this.paging.pageNumber=1,this.updateQueryParameters()}onPageChange(e){this.paging.pageNumber=e.first/e.rows+1,this.updateQueryParameters()}onSort(e){this.selectedSortField=e.field,this.selectedSortOrder=e.order,this.updateQueryParameters()}onParametersChange(e){this.parameters=e,this.paging.pageNumber=1,this.updateQueryParameters()}getFirst(){return(this.paging.pageNumber-1)*this.paging.pageSize}updateParameters(){this.updatePagingParameters()}fieldToSortParam(e){let t=this.findColumn(e);return t?.sortParam||t?.field||this.defaultSortParamName}initializePageSizeOptions(){this.pageSizeOptions=N}updateQueryParameters(){this.useQueryParams?this.router.navigate([this.url],{queryParams:n(n({},this.getPagingQueryParameters()),this.getQueryParameters())}):this.updateParameters()}getPagingQueryParameters(){let e={pagenumber:this.paging?.pageNumber.toString(),pagesize:this.paging?.pageSize.toString()};return this.paging?.pageNumber>1&&(e.pagenumber=this.paging.pageNumber.toString()),this.paging?.pageSize!==this.defaultPageSize&&(e.pagesize=this.paging.pageSize.toString()),this.selectedSortField&&(e.sortfield=this.fieldToSortParam(this.selectedSortField)),this.selectedSortOrder&&(e.sortorder=this.selectedSortOrder.toString()),e}sortParamToField(e){return this.findColumn(e)?.field||this.defaultSortFieldName}findColumn(e){if(!e)return null;let t=e.toLowerCase(),s=i=>i&&i.toLowerCase()===t;return this.cols.find(i=>s(i.field)||s(i.sortParam))}updatePagingParameters(){this.selectedSortField&&(this.paging.sortField=this.fieldToSortParam(this.selectedSortField)),this.selectedSortOrder&&(this.paging.sortOrder=this.selectedSortOrder)}arrayOrStringToString(e){return Array.isArray(e)?e[0].toString():e}};r.\u0275fac=function(t){return new(t||r)(a(S),a(m),a(c),a(f))},r.\u0275dir=h({type:r,viewQuery:function(t,s){if(t&1&&u(b,5),t&2){let i;p(i=l())&&(s.table=i.first)}},inputs:{paging:"paging",items:"items",totalCount:"totalCount",parameters:"parameters"},features:[d,g]});let o=r;return o})()});export{N as a,x as b,v as c};
