import{Ac as T,Bc as C,Cc as v,Dc as y,ac as x,ec as P,id as p,yf as A,zc as S}from"./chunk-MEUY652R.js";import{C as g,Fd as n,Id as F,Vg as u,aa as w,da as d,n as f,oa as D,vd as l,zd as R}from"./chunk-DA3HQ2LG.js";import{g as m}from"./chunk-2AVGQ2MQ.js";var U=m(C()),b=m(P()),h=m(x());var O=(()=>{class c{constructor(t,e){this.http=t,this.translateService=e,this.reloadVirtualDataSource=new D,this.statusTranslations={},this.reportFormData={}}updateReport(t,e){return this.http.put(n.apiUrl+"/report/"+t,e)}updateReportAccess(t){return this.http.put(n.apiUrl+"/report/access",t)}removeReport(t){return this.http.delete(n.apiUrl+"/report/"+t)}getCreateViewModel(){return this.http.get(n.apiUrl+"/report/create-view-model")}getReportDetails(t){return this.http.get(n.apiUrl+"/report/details-view-model/"+t)}getAttendanceListReport(t,e,o){return this.http.get(n.apiUrl+`/report/attendance-list?id=${t}&requestedDay=${e}&showArchivalUsers=${o}`)}getWorktimeSettlementReport(t,e,o){return this.http.get(n.apiUrl+"/report/work-time-settlement",{params:this.getDateParams(e,o).set("id",t)})}getReportVacationPlan(t,e,o){let a=new l().set("id",t).set("year",e).set("formatAsTime",o);return this.http.get(n.apiUrl+"/report/vacation-plan",{params:a})}getNewsEngagementReport(t,e,o,a,r,i){let s=new l().set("id",t);e&&(s=s.set("startDate",e.getTime())),o&&(s=s.set("endDate",o.getTime())),a?.trim()&&(s=s.set("newsTitle",a.trim())),s=s.set("includeAllDepartments",r);for(let k of i??[])s=s.append("departmentIds",k);return this.http.get(n.apiUrl+"/report/news-engagement",{params:s})}getNewsEngagementTitles(t,e,o){let a=new l().set("id",t);return e&&(a=a.set("startDate",e.getTime())),o&&(a=a.set("endDate",o.getTime())),this.http.get(n.apiUrl+"/report/news-engagement-titles",{params:a})}saveReportAsPdf(t,e,o){let a=new v({orientation:t.component.getVisibleColumns().length>4?"landscape":"portrait"});a.addFileToVFS("Roboto-Regular-normal.ttf",y),a.addFont("Roboto-Regular-normal.ttf","Roboto-Regular","normal"),a.setFont("Roboto-Regular"),a.text(e,14,9),S({jsPDFDocument:a,component:t.component,indent:5,customizeCell:r=>{let{gridCell:i,pdfCell:s}=r;(i.rowType==="group"||i.rowType==="header")&&(s.font={name:"Roboto-Regular",size:13},s.textColor="black")}}).then(()=>{a.save(o+".pdf")}).catch(r=>console.error("[ReportService] Failed to export report as PDF",r))}saveReportAsExcel(t,e){let o=new U.Workbook,a=o.addWorksheet("Sheet");T({component:t.component,worksheet:a,autoFilterEnabled:!0}).then(()=>o.xlsx.writeBuffer().then(r=>{(0,b.default)(new Blob([r],{type:"application/octet-stream"}),e+".xlsx")})).catch(r=>console.error("[ReportService] Failed to export report as Excel",r)),t.cancel=!0}getReports(){return this.http.get(n.apiUrl+"/report").pipe(g(t=>(console.error("[ReportService] Failed to load reports",t),f([]))))}getCustomReport(t,e,o){let a=new l().append("reportId",t);return e&&(a=a.append("startDate",(0,h.default)(e).format("YYYY-MM-DD"))),o&&(a=a.append("endDate",(0,h.default)(o).format("YYYY-MM-DD"))),this.http.get(n.apiUrl+"/report/custom",{params:a})}getDelegationReport(t,e,o){return this.http.get(n.apiUrl+"/report/delegation",{params:this.getDateParams(t,e).set("id",o)})}getWorkingTimeAllocationReport(t,e,o){return this.http.get(n.apiUrl+"/report/work-time",{params:this.getDateParams(t,e).set("id",o)})}createReport(t){return this.http.post(n.apiUrl+"/report",t)}getDateParams(t,e){return new l().set("startDate",new Date(t).getTime()).set("endDate",new Date(e).getTime())}translateColumnsInReport(t){let e=t.columns.filter(r=>r.dataField==="-37"),o=t.columns.filter(r=>r.dataField==="-32"),a=t.columns.filter(r=>r.valueType!==u.liczba&&r.valueType!==u.Ulamek);for(let r of t.dataSource){for(let i of a)(r[i.dataField]&&typeof r[i.dataField]=="string"||r[i.dataField]instanceof String)&&(r[i.dataField]=this.translateService.instant(r[i.dataField]));for(let i of e)if(!isNaN(r[i.dataField])){let s=A.mapDelegationStatusToI10nKey(r[i.dataField]);r[i.dataField]=this.translateStatus(s)}for(let i of o)if(!isNaN(r[i.dataField])){let s=this.mapApplicationStatusToI10nKey(r[i.dataField]);r[i.dataField]=this.translateStatus(s)}}}translateStatus(t){if(!t)return"";if(this.statusTranslations[t])return this.statusTranslations[t];let e=this.translateService.instant(t);return this.statusTranslations[t]=e,e}saveReportDataInService(t,e){this.reportFormData[t]=e}getReportDataFromService(t){return this.reportFormData[t]}mapApplicationStatusToI10nKey(t){switch(t){case p.Nowy:return"Nowy";case p.AkceptacjaZastepcy:return"AkceptacjaZastepcy";case p.AkceptacjaPrzelozonego:return"AkceptacjaPrzelozonego";case p.Zaakceptowany:return"Zaakceptowany";case p.Anulowany:return"Anulowany";case p.Odrzucony:return"Odrzucony";default:return""}}static{this.\u0275fac=function(e){return new(e||c)(d(R),d(F))}}static{this.\u0275prov=w({token:c,factory:c.\u0275fac,providedIn:"root"})}}return c})();export{O as a};
