import{n as u}from"./chunk-TKVDP62Z.js";import{d as f,na as d,qa as b}from"./chunk-GJDGQISV.js";var v=class p{constructor(e){this.toastr=e}subject$=new f;onFileLoad(e){let s=e.target.result,o=!1,i=[],n=[],l=0;for(let a of s.split(/[\r\n]+/))if(o){let r={};for(let c=0;c<l;c++)r[n[c]]=a.split(",")[c];i.push(r)}else{for(let r=0;r<a.split(",").length;r++)l=a.split(",").length,n.push(a.split(",")[r].replace(/ /g,""));o=!0}return i.splice(-1),i}convert(e){let t=e.files,s=["csv"];if(t&&t.length){let o=e.files[0].name.split(".").pop().toLowerCase();if(s.indexOf(o)>-1){let n=t[0],l=new FileReader;return l.onload=a=>{let r=this.onFileLoad(a);this.subject$.next(r)},l.readAsText(n,"UTF-8"),this.subject$.asObservable()}else this.toastr.error("Invalid File Type","Failed")}}convertFile(e){let t=e,s=new FileReader;return s.onload=o=>{let i=this.onFileLoad(o);this.subject$.next(i)},s.readAsText(t,"UTF-8"),this.subject$.asObservable()}static \u0275fac=function(t){return new(t||p)(b(u))};static \u0275prov=d({token:p,factory:p.\u0275fac,providedIn:"root"})};export{v as a};
