import{a as f,b as F}from"./chunk-O7MF4VXY.js";import{P as S,Q as z}from"./chunk-DCSOZT4N.js";import{h as m,j as l,o as O}from"./chunk-HO2J6YLX.js";import{b as c,c as C}from"./chunk-IOINCEV4.js";import{Eb as a,Gd as y,Ia as n,Jc as h,Kc as u,Lc as p,Qb as g,Sb as d}from"./chunk-JSJB5BKT.js";import{a as o,e as P}from"./chunk-SZAW6ZBW.js";var Q,b,j,L=P(()=>{F();y();C();O();z();Q=["dt"],b=[10,20,50,100],j=(()=>{class s extends f{constructor(e,t,r,i){super(),this.translatorService=e,this.route=t,this.router=r,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=b}updateQueryParameters(){this.useQueryParams?this.router.navigate([this.url],{queryParams:o(o({},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(),r=i=>i&&i.toLowerCase()===t;return this.cols.find(i=>r(i.field)||r(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}static{this.\u0275fac=function(t){return new(t||s)(a(c),a(m),a(l),a(S))}}static{this.\u0275dir=g({type:s,viewQuery:function(t,r){if(t&1&&h(Q,5),t&2){let i;u(i=p())&&(r.table=i.first)}},inputs:{paging:"paging",items:"items",totalCount:"totalCount",parameters:"parameters"},features:[d,n]})}}return s})()});export{b as a,j as b,L as c};
