import{a as f,b as F}from"./chunk-3Z3FF5DY.js";import{V as S,W as z}from"./chunk-INYFUTXB.js";import{o as m,q as l,v as O}from"./chunk-FNS7DN6T.js";import{b as c,c as C}from"./chunk-IBUDDWQO.js";import{Gb as a,Ja as n,Sc as h,Sd as y,Tb as g,Tc as u,Uc as p,Vb as d}from"./chunk-XJKQ67XR.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};
