;(function(e){"use strict";functiont(e){returntypeofe==="function"}functionn(e){returntypeofe!=="undefined"}functionr(e){functionu(e){if(typeofe.delimiter!=="string"||e.delimiter.length!=1)e.delimiter=s.delimiter;if(e.delimiter=='"'||e.delimiter=="\n")e.delimiter=s.delimiter;if(typeofe.header!=="boolean")e.header=s.header;if(typeofe.dynamicTyping!=="boolean")e.dynamicTyping=s.dynamicTyping;returne}functiona(){return{i:0,lineNum:1,field:0,fieldVal:"",line:"",ch:"",inQuotes:false,parsed:r.header?{fields:[],rows:[]}:[[]],errors:{length:0}}}functionf(){vare=i.i>0&&p(i.i-1)||i.i==0;vart=i.i<n.length-1&&p(i.i+1)||i.i==n.length-1;varr=i.i<n.length-1&&n[i.i+1]=='"';if(i.inQuotes&&r){i.fieldVal+='"';i.i++}elseif(e||t)i.inQuotes=!i.inQuotes;elseE("Quotes","UnexpectedQuotes","Unexpected quotes")}functionl(){c()}functionc(){i.fieldVal+=i.ch}functionh(){if(i.ch==r.delimiter)v();elseif(i.ch=="\r"&&i.i<n.length-1&&n[i.i+1]=="\n"){m();i.i++}elseif(i.ch=="\n")m();elsec()}functionp(e){if(e>=n.length)returnfalse;vart=n[e];if(t==r.delimiter||t=="\n"||t=="\r"&&e<n.length-1&&n[e+1]=="\n")returntrue;elsereturnfalse}functiond(e){if(e>=n.length)returnfalse;if(e<n.length-1)returnn[e]=="\n"||n[e]=="\r"&&n[e+1]=="\n";elsereturnn[e]=="\n"}functionv(){if(r.header){if(i.lineNum==1)i.parsed.fields.push(i.fieldVal);else{vare=i.parsed.rows[i.parsed.rows.length-1];vart=i.parsed.fields[i.field];if(t){if(r.dynamicTyping)i.fieldVal=y(i.fieldVal);e[t]=i.fieldVal}else{if(typeofe.__parsed_extra==="undefined")e.__parsed_extra=[];e.__parsed_extra.push(i.fieldVal)}}}else{if(r.dynamicTyping)i.fieldVal=y(i.fieldVal);i.parsed[i.parsed.length-1].push(i.fieldVal)}i.fieldVal="";i.field++}functionm(){g();if(r.header&&i.lineNum>0)i.parsed.rows.push({});elsei.parsed.push([]);i.lineNum++;i.line="";i.field=0}functiong(){v();vare=b();if(!e&&r.header)w()}functiony(e){vart=o.floats.test(e);returnt?parseFloat(e):e}functionb(){if(o.empty.test(i.line)){if(r.header){if(i.lineNum==1){i.parsed.fields=[];i.lineNum--}elsei.parsed.rows.splice(i.parsed.rows.length-1,1)}elsei.parsed.splice(i.parsed.length-1,1);returntrue}returnfalse}functionw(){if(!r.header)returntrue;if(i.parsed.rows.length==0)returntrue;vare=i.parsed.fields.length;vart=0;varn=i.parsed.rows[i.parsed.rows.length-1];for(varsinn)if(n.hasOwnProperty(s))t++;if(t<e)returnE("FieldMismatch","TooFewFields","Too few fields: expected "+e+" fields but parsed "+t);elseif(t>e)returnE("FieldMismatch","TooManyFields","Too many fields: expected "+e+" fields but parsed "+t);returntrue}functionE(e,t,n){vars=r.header?i.parsed.rows.length-1:i.parsed.length-1;if(typeofi.errors[s]==="undefined")i.errors[s]=[];i.errors[s].push({type:e,code:t,message:n,line:i.lineNum,row:s,index:i.i});i.errors.length++;returnfalse}functionS(){return{results:i.parsed,errors:i.errors}}functionx(e){i=a();n=e}vart=this;varn="";varr={};vari=a();vars={delimiter:",",header:true,dynamicTyping:true};varo={floats:/^\s*-?(\d*\.?\d+|\d+\.?\d*)(e[-+]?\d+)?\s*$/i,empty:/^\s*$/};this.setOptions=function(e){e=u(e);r={delimiter:e.delimiter,header:e.header,dynamicTyping:e.dynamicTyping}};this.getOptions=function(){return{delimiter:r.delimiter,header:r.header,dynamicTyping:r.dynamicTyping}};this.parse=function(e){if(typeofe!=="string")returnS();x(e);for(i.i=0;i.i<n.length;i.i++){i.ch=n[i.i];i.line+=i.ch;if(i.ch=='"')f();elseif(i.inQuotes)l();elseh()}g();if(i.inQuotes)E("Quotes","MissingQuotes","Unescaped or mismatched quotes");returnS()};this.setOptions(e)}e.fn.parse=function(r){functioni(e,n,i){if(t(r.error))r.error({name:e},n,i)}vars=n(r.config)?r.config:{};this.each(function(o){varu=e(this).prop("tagName").toUpperCase()=="INPUT"&&e(this).attr("type")=="file"&&window.FileReader;if(!u)returntrue;vara={delimiter:s.delimiter,header:s.header,dynamicTyping:s.dynamicTyping};if(!this.files||this.files.length==0){i("NoFileError",undefined,this);returntrue}for(varf=0;f<this.files.length;f++){varl=this.files[f];if(l.type.indexOf("text")<0){i("TypeMismatchError",l,this);continue}if(t(r.before)){varc