;(function(e){"use strict";functionn(e){e.delimeter=e.delimiter||t.delimiter;e.header=typeofe.header==="undefined"?t.header:e.header;e.dynamicTyping=typeofe.dynamicTyping==="undefined"?t.dynamicTyping:e.dynamicTyping;if(e.delimiter=='"'||e.delimiter=="\n")e.delimiter=t.delimiter;if(e.delimiter.length>1)e.delimiter=e.delimiter[0];returne}functionr(e,t){functionu(e){returne?{fields:[],rows:[]}:[[]]}functiona(){return{i:0,line:1,field:0,fieldVal:"",ch:"",inQuotes:false,parsed:u(t.header)}}functionf(){vare=o.i>0&&p(r[o.i-1])||o.i==0;vart=o.i<r.length-1&&p(r[o.i+1])||o.i==r.length-1;varn=o.i<r.length-1&&r[o.i+1]=='"';if(o.inQuotes&&n){o.fieldVal+='"';o.i++}elseif(e||t){o.inQuotes=!o.inQuotes}else{b("Unexpected quotes")}}functionl(){c()}functionc(){o.fieldVal+=o.ch}functionh(){if(o.ch==i.delimiter){d()}elseif(o.ch=="\n"){d();v()}else{c()}}functionp(e){returne==i.delimiter||e=="\n"}functiond(){if(i.header){if(o.line==1){o.parsed.fields.push(o.fieldVal)}else{vare=o.parsed.rows[o.parsed.rows.length-1];vart=o.parsed.fields[o.field];if(t){if(i.dynamicTyping)o.fieldVal=m(o.fieldVal);e[t]=o.fieldVal}else{if(typeofe.__parsed_extra==="undefined")e.__parsed_extra=[];e.__parsed_extra.push(o.fieldVal);b("Too many fields; expected "+o.parsed.fields.length+" fields, found extra value: '"+o.fieldVal+"'")}}}else{if(i.dynamicTyping)o.fieldVal=m(o.fieldVal);o.parsed[o.parsed.length-1].push(o.fieldVal)}o.fieldVal="";o.field++}functionv(){g();if(i.header){y();if(o.line>0)o.parsed.rows.push({})}elseo.parsed.push([]);o.line++;o.field=0}functionm(e){vart=/^-?\d+(\.\d+)?$/.test(e);returnt?parseFloat(e):e}functiong(){if(i.header){if(o.line==1){if(o.parsed.fields.length==1&&o.parsed.fields[0].length==0){o.parsed.fields=[];o.line--}}else{vare=o.parsed.rows[o.parsed.rows.length-1];if(!e[o.parsed.fields[0]])o.parsed.rows.splice(o.parsed.rows.length-1,1)}}else{vare=o.parsed[o.parsed.length-1];if(e.length==0||e[0].length==0)o.parsed.splice(o.parsed.length-1,1)}}functiony(){if(!i.header)returntrue;if(o.parsed.rows.length==0)returntrue;vare=o.parsed.fields.length;vart=0;varn=o.parsed.rows[o.parsed.rows.length-1];for(varrinn)if(n.hasOwnProperty(r))t++;if(e!=t)returnb("Too few fields; expected "+e+" fields, parsed "+t);returntrue}functionb(e){s.push({message:e,line:o.line,row:i.header?o.parsed.rows.length-1:o.parsed.length-1,index:o.i});returnfalse}varn=this;varr=e;vari=t;vars=[];varo=a();this.parse=function(e){if(typeofe==="object")n.setConfig(e);elseif(typeofe==="string")n.setInput(e);s=[];o=a();for(o.i=0;o.i<r.length;o.i++){o.ch=r[o.i];if(o.ch=='"')f();elseif(o.inQuotes)l();elseh()}d();g();y();if(o.inQuotes)b("Unescaped or mismatched quotes");returnn.getParsed()};this.getDelimiter=function(){returnt.delimiter};this.setDelimiter=function(e){vart=",";e=e?e=='"'||e=="\n"?t:e:t;i.delimiter=e[0]};this.setConfig=function(e){if(typeofe.header!=="undefined"&&e.header!=t.header||typeofe.delimiter!=="undefined"&&e.delimiter!=t.delimiter){o.parsed=u(e.header)}i=e};this.getInput=function(){returnr};this.setInput=function(e){r=e};this.getParsed=function(){returno.parsed};this.getErrors=function(){returns}}vart={delimiter:",",header:true,dynamicTyping:false};e.parse=function(e,t){t=n(t);vari=newr(e,t);return{results:i.parse(),errors:i.getErrors()}}})(jQuery);
;(function(e){"use strict";functionn(e){e.delimiter=e.delimiter||t.delimiter;e.header=typeofe.header==="undefined"?t.header:e.header;e.dynamicTyping=typeofe.dynamicTyping==="undefined"?t.dynamicTyping:e.dynamicTyping;if(e.delimiter=='"'||e.delimiter=="\n")e.delimiter=t.delimiter;if(e.delimiter.length>1)e.delimiter=e.delimiter[0];returne}functionr(e,t){functionu(e){returne?{fields:[],rows:[]}:[[]]}functiona(){return{i:0,line:1,field:0,fieldVal:"",ch:"",inQuotes:false,parsed:u(t.header)}}functionf(){vare=o.i>0&&p(r[o.i-1])||o.i==0;vart=o.i<r.length-1&&p(r[o.i+1])||o.i==r.length-1;varn=o.i<r.length-1&&r[o.i+1]=='"';if(o.inQuotes&&n){o.fieldVal+='"';o.i++}elseif(e||t){o.inQuotes=!o.inQuotes}else{b("Unexpected quotes")}}functionl(){c()}functionc(){o.fieldVal+=o.ch}functionh(){if(o.ch==i.delimiter){d()}elseif(o.ch=="\n"){d();v()}else{c()}}functionp(e){returne==i.delimiter||e=="\n"}functiond(){if(i.header){if(o.line==1){o.parsed.fields.push(o.fieldVal)}else{vare=o.parsed.rows[o.parsed.rows.length-1];vart=o.parsed.fields[o.field];if(t){if(i.dynamicTyping)o.fieldVal=m(o.fieldVal);e[t]=o.fieldVal}else{if(typeofe.__parsed_extra==="undefined")e.__parsed_extra=[];e.__parsed_extra.push(o.fieldVal);b("Too many fields; expected "+o.parsed.fields.length+" fields, found extra value: '"+o.fieldVal+"'")}}}else{if(i.dynamicTyping)o.fieldVal=m(o.fieldVal);o.parsed[o.parsed.length-1].push(o.fieldVal)}o.fieldVal="";o.field++}functionv(){g();if(i.header){y();if(o.line>0)o.parsed.rows.push({})}elseo.parsed.push([]);o.line++;o.field=0}functionm(e){vart=/^-?\d+(\.\d+)?$/.test(e);returnt?parseFloat(e):e}functiong(){if(i.header){if(o.line==1){if(o.parsed.fields.length==1&&o.parsed.fields[0].length==0){o.parsed.fields=[];o.line--}}else{vare=o.parsed.rows[o.parsed.rows.length-1];if(!e[o.parsed.fields[0]])o.parsed.rows.splice(o.parsed.rows.length-1,1)}}else{vare=o.parsed[o.parsed.length-1];if(e.length==0||e[0].length==0)o.parsed.splice(o.parsed.length-1,1)}}functiony(){if(!i.header)returntrue;if(o.parsed.rows.length==0)returntrue;vare=o.parsed.fields.length;vart=0;varn=o.parsed.rows[o.parsed.rows.length-1];for(varrinn)if(n.hasOwnProperty(r))t++;if(e!=t)returnb("Too few fields; expected "+e+" fields, parsed "+t);returntrue}functionb(e){s.push({message:e,line:o.line,row:i.header?o.parsed.rows.length-1:o.parsed.length-1,index:o.i});returnfalse}varn=this;varr=e;vari=t;vars=[];varo=a();this.parse=function(e){if(typeofe==="object")n.setConfig(e);elseif(typeofe==="string")n.setInput(e);s=[];o=a();for(o.i=0;o.i<r.length;o.i++){o.ch=r[o.i];if(o.ch=='"')f();elseif(o.inQuotes)l();elseh()}d();g();y();if(o.inQuotes)b("Unescaped or mismatched quotes");returnn.getParsed()};this.getDelimiter=function(){returnt.delimiter};this.setDelimiter=function(e){vart=",";e=e?e=='"'||e=="\n"?t:e:t;i.delimiter=e[0]};this.setConfig=function(e){if(typeofe.header!=="undefined"&&e.header!=t.header||typeofe.delimiter!=="undefined"&&e.delimiter!=t.delimiter){o.parsed=u(e.header)}i=e};this.getInput=function(){returnr};this.setInput=function(e){r=e};this.getParsed=function(){returno.parsed};this.getErrors=function(){returns}}vart={delimiter:",",header:true,dynamicTyping:false};e.parse=function(e,t){t=n(t);vari=newr(e,t);return{results:i.parse(),errors:i.getErrors()}}})(jQuery);