"use strict";(self.webpackChunkimperial_wallboard_admin=self.webpackChunkimperial_wallboard_admin||[]).push([[578],{8578:(x,a,n)=>{n.r(a),n.d(a,{ExcelComponent:()=>b,ExcelModule:()=>M,ExcelRoutingModule:()=>m});var u=n(6489),h=n(7575),r=n(2288),t=n(4438),l=n(4090),_=n(9110),f=n(177);let b=(()=>{class o{constructor(s,e,i){this.api=s,this.es=e,this.location=i,this.subs=new h.a}ngOnInit(){this.subs.sink=this.es.exportInfo$.subscribe({next:s=>{s.url&&this.api.get(s.url,{...s.filters,allSelected:s.allSelected,included:s.included,excluded:s.excluded}).subscribe({next:({data:e})=>{e?.length&&(console.log(s,"info"),console.log(e,"data"),this.exportExcel(this.formatData(s.headers,e,s.extraExportKeys),s.filename))},error:()=>this.location.back()})}})}ngOnDestroy(){this.subs.unsubscribe()}formatData(s,e,i){const p=[];for(const d of e){const E={};for(const c of s)c.visible&&(E[c.title]=c.formatter?c.formatter(d,c):d[c.name]);if(i)for(const c of i)E[c.title]=d[c.key];p.push(E)}return p}exportExcel(s,e="excel"){const i=r.Wp.json_to_sheet(s),p=r.Wp.book_new();r.Wp.book_append_sheet(p,i,e),r._h(p,`${e}.xlsx`),this.location.back()}static{this.\u0275fac=function(e){return new(e||o)(t.rXU(l.G),t.rXU(_.V),t.rXU(f.aZ))}}static{this.\u0275cmp=t.VBU({type:o,selectors:[["excel-component"]],decls:2,vars:0,template:function(e,i){1&e&&(t.j41(0,"p"),t.EFF(1,"Loading..."),t.k0s())},encapsulation:2})}}return o})();const D=[{path:"",component:b}];let m=(()=>{class o{static{this.\u0275fac=function(e){return new(e||o)}}static{this.\u0275mod=t.$C({type:o})}static{this.\u0275inj=t.G2t({imports:[u.iI.forChild(D),u.iI]})}}return o})(),M=(()=>{class o{static{this.\u0275fac=function(e){return new(e||o)}}static{this.\u0275mod=t.$C({type:o})}static{this.\u0275inj=t.G2t({imports:[m]})}}return o})()},9110:(x,a,n)=>{n.d(a,{V:()=>r});var u=n(4412),h=n(4438);let r=(()=>{class t{constructor(){this.exportInfo=new u.t({url:"",filename:"",filters:{},headers:[],extraExportKeys:[]}),this.exportInfo$=this.exportInfo.asObservable()}updateExportInfo(_){this.exportInfo.next({..._})}static{this.\u0275fac=function(f){return new(f||t)}}static{this.\u0275prov=h.jDH({token:t,factory:t.\u0275fac,providedIn:"root"})}}return t})()},7575:(x,a,n)=>{n.d(a,{a:()=>h});var h=function(){function r(){this._subs=[]}return r.prototype.add=function(){for(var t=[],l=0;l<arguments.length;l++)t[l]=arguments[l];this._subs=this._subs.concat(t)},Object.defineProperty(r.prototype,"sink",{set:function(t){this._subs.push(t)},enumerable:!0,configurable:!0}),r.prototype.unsubscribe=function(){this._subs.forEach(function(t){return t&&function(r){return"function"==typeof r}(t.unsubscribe)&&t.unsubscribe()}),this._subs=[]},r}()}}]);