@bigbinary/neeto-molecules 3.2.1 → 3.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (61) hide show
  1. package/dist/BrowserSupport.js +2 -1
  2. package/dist/BrowserSupport.js.map +1 -1
  3. package/dist/DownloadMobileAppCallout.js +2 -1
  4. package/dist/DownloadMobileAppCallout.js.map +1 -1
  5. package/dist/EmailForm.js +2 -1
  6. package/dist/EmailForm.js.map +1 -1
  7. package/dist/FloatingActionMenu.js +2 -1
  8. package/dist/FloatingActionMenu.js.map +1 -1
  9. package/dist/IconPicker.js +916 -4
  10. package/dist/IconPicker.js.map +1 -1
  11. package/dist/IpRestriction.js +3093 -7
  12. package/dist/IpRestriction.js.map +1 -1
  13. package/dist/KeyboardShortcuts.js +2 -1
  14. package/dist/KeyboardShortcuts.js.map +1 -1
  15. package/dist/MenuBar.js +1804 -12
  16. package/dist/MenuBar.js.map +1 -1
  17. package/dist/NeetoWidget.js +1957 -3
  18. package/dist/NeetoWidget.js.map +1 -1
  19. package/dist/PhoneNumber.js +12 -4
  20. package/dist/PhoneNumber.js.map +1 -1
  21. package/dist/SendToFields.js +1919 -1
  22. package/dist/SendToFields.js.map +1 -1
  23. package/dist/ShareViaEmail.js +2 -1
  24. package/dist/ShareViaEmail.js.map +1 -1
  25. package/dist/ShareViaLink.js +860 -2
  26. package/dist/ShareViaLink.js.map +1 -1
  27. package/dist/_commonjsHelpers-1c8beb5f.js +4 -0
  28. package/dist/_commonjsHelpers-1c8beb5f.js.map +1 -0
  29. package/dist/cjs/BrowserSupport.js +3 -3
  30. package/dist/cjs/BrowserSupport.js.map +1 -1
  31. package/dist/cjs/DownloadMobileAppCallout.js +3 -3
  32. package/dist/cjs/DownloadMobileAppCallout.js.map +1 -1
  33. package/dist/cjs/EmailForm.js +2 -1
  34. package/dist/cjs/EmailForm.js.map +1 -1
  35. package/dist/cjs/FloatingActionMenu.js +2 -1
  36. package/dist/cjs/FloatingActionMenu.js.map +1 -1
  37. package/dist/cjs/IconPicker.js +920 -5
  38. package/dist/cjs/IconPicker.js.map +1 -1
  39. package/dist/cjs/IpRestriction.js +3101 -15
  40. package/dist/cjs/IpRestriction.js.map +1 -1
  41. package/dist/cjs/KeyboardShortcuts.js +3 -3
  42. package/dist/cjs/KeyboardShortcuts.js.map +1 -1
  43. package/dist/cjs/MenuBar.js +1807 -10
  44. package/dist/cjs/MenuBar.js.map +1 -1
  45. package/dist/cjs/NeetoWidget.js +1958 -5
  46. package/dist/cjs/NeetoWidget.js.map +1 -1
  47. package/dist/cjs/PhoneNumber.js +12 -4
  48. package/dist/cjs/PhoneNumber.js.map +1 -1
  49. package/dist/cjs/SendToFields.js +1921 -3
  50. package/dist/cjs/SendToFields.js.map +1 -1
  51. package/dist/cjs/ShareViaEmail.js +2 -1
  52. package/dist/cjs/ShareViaEmail.js.map +1 -1
  53. package/dist/cjs/ShareViaLink.js +860 -3
  54. package/dist/cjs/ShareViaLink.js.map +1 -1
  55. package/dist/cjs/_commonjsHelpers-68cdf74f.js +6 -0
  56. package/dist/cjs/_commonjsHelpers-68cdf74f.js.map +1 -0
  57. package/dist/cjs/platform-628b3bd8.js +1252 -0
  58. package/dist/cjs/platform-628b3bd8.js.map +1 -0
  59. package/dist/platform-e221afea.js +1250 -0
  60. package/dist/platform-e221afea.js.map +1 -0
  61. package/package.json +16 -17
@@ -16,7 +16,8 @@ import withT from '@bigbinary/neeto-commons-frontend/react-utils/withT';
16
16
  import Download from '@bigbinary/neeto-icons/Download';
17
17
  import Callout from '@bigbinary/neetoui/Callout';
18
18
  import { t } from 'i18next';
19
- import Papa from 'papaparse';
19
+ import { c as commonjsGlobal } from './_commonjsHelpers-1c8beb5f.js';
20
+ import require$$0 from 'stream';
20
21
  import { prop } from 'ramda';
21
22
  import { string } from 'yup';
22
23
 
@@ -150,6 +151,1923 @@ var BulkUploadPane = function BulkUploadPane(_ref) {
150
151
  }))));
151
152
  };
152
153
 
154
+ var papaparse = {exports: {}};
155
+
156
+ /* @license
157
+ Papa Parse
158
+ v5.4.1
159
+ https://github.com/mholt/PapaParse
160
+ License: MIT
161
+ */
162
+
163
+ (function (module, exports) {
164
+ (function(root, factory)
165
+ {
166
+ /* globals define */
167
+ {
168
+ // Node. Does not work with strict CommonJS, but
169
+ // only CommonJS-like environments that support module.exports,
170
+ // like Node.
171
+ module.exports = factory();
172
+ }
173
+ // in strict mode we cannot access arguments.callee, so we need a named reference to
174
+ // stringify the factory method for the blob worker
175
+ // eslint-disable-next-line func-name
176
+ }(commonjsGlobal, function moduleFactory()
177
+ {
178
+
179
+ var global = (function() {
180
+ // alternative method, similar to `Function('return this')()`
181
+ // but without using `eval` (which is disabled when
182
+ // using Content Security Policy).
183
+
184
+ if (typeof self !== 'undefined') { return self; }
185
+ if (typeof window !== 'undefined') { return window; }
186
+ if (typeof global !== 'undefined') { return global; }
187
+
188
+ // When running tests none of the above have been defined
189
+ return {};
190
+ })();
191
+
192
+
193
+ function getWorkerBlob() {
194
+ var URL = global.URL || global.webkitURL || null;
195
+ var code = moduleFactory.toString();
196
+ return Papa.BLOB_URL || (Papa.BLOB_URL = URL.createObjectURL(new Blob(["var global = (function() { if (typeof self !== 'undefined') { return self; } if (typeof window !== 'undefined') { return window; } if (typeof global !== 'undefined') { return global; } return {}; })(); global.IS_PAPA_WORKER=true; ", '(', code, ')();'], {type: 'text/javascript'})));
197
+ }
198
+
199
+ var IS_WORKER = !global.document && !!global.postMessage,
200
+ IS_PAPA_WORKER = global.IS_PAPA_WORKER || false;
201
+
202
+ var workers = {}, workerIdCounter = 0;
203
+
204
+ var Papa = {};
205
+
206
+ Papa.parse = CsvToJson;
207
+ Papa.unparse = JsonToCsv;
208
+
209
+ Papa.RECORD_SEP = String.fromCharCode(30);
210
+ Papa.UNIT_SEP = String.fromCharCode(31);
211
+ Papa.BYTE_ORDER_MARK = '\ufeff';
212
+ Papa.BAD_DELIMITERS = ['\r', '\n', '"', Papa.BYTE_ORDER_MARK];
213
+ Papa.WORKERS_SUPPORTED = !IS_WORKER && !!global.Worker;
214
+ Papa.NODE_STREAM_INPUT = 1;
215
+
216
+ // Configurable chunk sizes for local and remote files, respectively
217
+ Papa.LocalChunkSize = 1024 * 1024 * 10; // 10 MB
218
+ Papa.RemoteChunkSize = 1024 * 1024 * 5; // 5 MB
219
+ Papa.DefaultDelimiter = ','; // Used if not specified and detection fails
220
+
221
+ // Exposed for testing and development only
222
+ Papa.Parser = Parser;
223
+ Papa.ParserHandle = ParserHandle;
224
+ Papa.NetworkStreamer = NetworkStreamer;
225
+ Papa.FileStreamer = FileStreamer;
226
+ Papa.StringStreamer = StringStreamer;
227
+ Papa.ReadableStreamStreamer = ReadableStreamStreamer;
228
+ if (typeof PAPA_BROWSER_CONTEXT === 'undefined') {
229
+ Papa.DuplexStreamStreamer = DuplexStreamStreamer;
230
+ }
231
+
232
+ if (global.jQuery)
233
+ {
234
+ var $ = global.jQuery;
235
+ $.fn.parse = function(options)
236
+ {
237
+ var config = options.config || {};
238
+ var queue = [];
239
+
240
+ this.each(function(idx)
241
+ {
242
+ var supported = $(this).prop('tagName').toUpperCase() === 'INPUT'
243
+ && $(this).attr('type').toLowerCase() === 'file'
244
+ && global.FileReader;
245
+
246
+ if (!supported || !this.files || this.files.length === 0)
247
+ return true; // continue to next input element
248
+
249
+ for (var i = 0; i < this.files.length; i++)
250
+ {
251
+ queue.push({
252
+ file: this.files[i],
253
+ inputElem: this,
254
+ instanceConfig: $.extend({}, config)
255
+ });
256
+ }
257
+ });
258
+
259
+ parseNextFile(); // begin parsing
260
+ return this; // maintains chainability
261
+
262
+
263
+ function parseNextFile()
264
+ {
265
+ if (queue.length === 0)
266
+ {
267
+ if (isFunction(options.complete))
268
+ options.complete();
269
+ return;
270
+ }
271
+
272
+ var f = queue[0];
273
+
274
+ if (isFunction(options.before))
275
+ {
276
+ var returned = options.before(f.file, f.inputElem);
277
+
278
+ if (typeof returned === 'object')
279
+ {
280
+ if (returned.action === 'abort')
281
+ {
282
+ error('AbortError', f.file, f.inputElem, returned.reason);
283
+ return; // Aborts all queued files immediately
284
+ }
285
+ else if (returned.action === 'skip')
286
+ {
287
+ fileComplete(); // parse the next file in the queue, if any
288
+ return;
289
+ }
290
+ else if (typeof returned.config === 'object')
291
+ f.instanceConfig = $.extend(f.instanceConfig, returned.config);
292
+ }
293
+ else if (returned === 'skip')
294
+ {
295
+ fileComplete(); // parse the next file in the queue, if any
296
+ return;
297
+ }
298
+ }
299
+
300
+ // Wrap up the user's complete callback, if any, so that ours also gets executed
301
+ var userCompleteFunc = f.instanceConfig.complete;
302
+ f.instanceConfig.complete = function(results)
303
+ {
304
+ if (isFunction(userCompleteFunc))
305
+ userCompleteFunc(results, f.file, f.inputElem);
306
+ fileComplete();
307
+ };
308
+
309
+ Papa.parse(f.file, f.instanceConfig);
310
+ }
311
+
312
+ function error(name, file, elem, reason)
313
+ {
314
+ if (isFunction(options.error))
315
+ options.error({name: name}, file, elem, reason);
316
+ }
317
+
318
+ function fileComplete()
319
+ {
320
+ queue.splice(0, 1);
321
+ parseNextFile();
322
+ }
323
+ };
324
+ }
325
+
326
+
327
+ if (IS_PAPA_WORKER)
328
+ {
329
+ global.onmessage = workerThreadReceivedMessage;
330
+ }
331
+
332
+
333
+
334
+
335
+ function CsvToJson(_input, _config)
336
+ {
337
+ _config = _config || {};
338
+ var dynamicTyping = _config.dynamicTyping || false;
339
+ if (isFunction(dynamicTyping)) {
340
+ _config.dynamicTypingFunction = dynamicTyping;
341
+ // Will be filled on first row call
342
+ dynamicTyping = {};
343
+ }
344
+ _config.dynamicTyping = dynamicTyping;
345
+
346
+ _config.transform = isFunction(_config.transform) ? _config.transform : false;
347
+
348
+ if (_config.worker && Papa.WORKERS_SUPPORTED)
349
+ {
350
+ var w = newWorker();
351
+
352
+ w.userStep = _config.step;
353
+ w.userChunk = _config.chunk;
354
+ w.userComplete = _config.complete;
355
+ w.userError = _config.error;
356
+
357
+ _config.step = isFunction(_config.step);
358
+ _config.chunk = isFunction(_config.chunk);
359
+ _config.complete = isFunction(_config.complete);
360
+ _config.error = isFunction(_config.error);
361
+ delete _config.worker; // prevent infinite loop
362
+
363
+ w.postMessage({
364
+ input: _input,
365
+ config: _config,
366
+ workerId: w.id
367
+ });
368
+
369
+ return;
370
+ }
371
+
372
+ var streamer = null;
373
+ if (_input === Papa.NODE_STREAM_INPUT && typeof PAPA_BROWSER_CONTEXT === 'undefined')
374
+ {
375
+ // create a node Duplex stream for use
376
+ // with .pipe
377
+ streamer = new DuplexStreamStreamer(_config);
378
+ return streamer.getStream();
379
+ }
380
+ else if (typeof _input === 'string')
381
+ {
382
+ _input = stripBom(_input);
383
+ if (_config.download)
384
+ streamer = new NetworkStreamer(_config);
385
+ else
386
+ streamer = new StringStreamer(_config);
387
+ }
388
+ else if (_input.readable === true && isFunction(_input.read) && isFunction(_input.on))
389
+ {
390
+ streamer = new ReadableStreamStreamer(_config);
391
+ }
392
+ else if ((global.File && _input instanceof File) || _input instanceof Object) // ...Safari. (see issue #106)
393
+ streamer = new FileStreamer(_config);
394
+
395
+ return streamer.stream(_input);
396
+
397
+ // Strip character from UTF-8 BOM encoded files that cause issue parsing the file
398
+ function stripBom(string) {
399
+ if (string.charCodeAt(0) === 0xfeff) {
400
+ return string.slice(1);
401
+ }
402
+ return string;
403
+ }
404
+ }
405
+
406
+
407
+
408
+
409
+
410
+
411
+ function JsonToCsv(_input, _config)
412
+ {
413
+ // Default configuration
414
+
415
+ /** whether to surround every datum with quotes */
416
+ var _quotes = false;
417
+
418
+ /** whether to write headers */
419
+ var _writeHeader = true;
420
+
421
+ /** delimiting character(s) */
422
+ var _delimiter = ',';
423
+
424
+ /** newline character(s) */
425
+ var _newline = '\r\n';
426
+
427
+ /** quote character */
428
+ var _quoteChar = '"';
429
+
430
+ /** escaped quote character, either "" or <config.escapeChar>" */
431
+ var _escapedQuote = _quoteChar + _quoteChar;
432
+
433
+ /** whether to skip empty lines */
434
+ var _skipEmptyLines = false;
435
+
436
+ /** the columns (keys) we expect when we unparse objects */
437
+ var _columns = null;
438
+
439
+ /** whether to prevent outputting cells that can be parsed as formulae by spreadsheet software (Excel and LibreOffice) */
440
+ var _escapeFormulae = false;
441
+
442
+ unpackConfig();
443
+
444
+ var quoteCharRegex = new RegExp(escapeRegExp(_quoteChar), 'g');
445
+
446
+ if (typeof _input === 'string')
447
+ _input = JSON.parse(_input);
448
+
449
+ if (Array.isArray(_input))
450
+ {
451
+ if (!_input.length || Array.isArray(_input[0]))
452
+ return serialize(null, _input, _skipEmptyLines);
453
+ else if (typeof _input[0] === 'object')
454
+ return serialize(_columns || Object.keys(_input[0]), _input, _skipEmptyLines);
455
+ }
456
+ else if (typeof _input === 'object')
457
+ {
458
+ if (typeof _input.data === 'string')
459
+ _input.data = JSON.parse(_input.data);
460
+
461
+ if (Array.isArray(_input.data))
462
+ {
463
+ if (!_input.fields)
464
+ _input.fields = _input.meta && _input.meta.fields || _columns;
465
+
466
+ if (!_input.fields)
467
+ _input.fields = Array.isArray(_input.data[0])
468
+ ? _input.fields
469
+ : typeof _input.data[0] === 'object'
470
+ ? Object.keys(_input.data[0])
471
+ : [];
472
+
473
+ if (!(Array.isArray(_input.data[0])) && typeof _input.data[0] !== 'object')
474
+ _input.data = [_input.data]; // handles input like [1,2,3] or ['asdf']
475
+ }
476
+
477
+ return serialize(_input.fields || [], _input.data || [], _skipEmptyLines);
478
+ }
479
+
480
+ // Default (any valid paths should return before this)
481
+ throw new Error('Unable to serialize unrecognized input');
482
+
483
+
484
+ function unpackConfig()
485
+ {
486
+ if (typeof _config !== 'object')
487
+ return;
488
+
489
+ if (typeof _config.delimiter === 'string'
490
+ && !Papa.BAD_DELIMITERS.filter(function(value) { return _config.delimiter.indexOf(value) !== -1; }).length)
491
+ {
492
+ _delimiter = _config.delimiter;
493
+ }
494
+
495
+ if (typeof _config.quotes === 'boolean'
496
+ || typeof _config.quotes === 'function'
497
+ || Array.isArray(_config.quotes))
498
+ _quotes = _config.quotes;
499
+
500
+ if (typeof _config.skipEmptyLines === 'boolean'
501
+ || typeof _config.skipEmptyLines === 'string')
502
+ _skipEmptyLines = _config.skipEmptyLines;
503
+
504
+ if (typeof _config.newline === 'string')
505
+ _newline = _config.newline;
506
+
507
+ if (typeof _config.quoteChar === 'string')
508
+ _quoteChar = _config.quoteChar;
509
+
510
+ if (typeof _config.header === 'boolean')
511
+ _writeHeader = _config.header;
512
+
513
+ if (Array.isArray(_config.columns)) {
514
+
515
+ if (_config.columns.length === 0) throw new Error('Option columns is empty');
516
+
517
+ _columns = _config.columns;
518
+ }
519
+
520
+ if (_config.escapeChar !== undefined) {
521
+ _escapedQuote = _config.escapeChar + _quoteChar;
522
+ }
523
+
524
+ if (typeof _config.escapeFormulae === 'boolean' || _config.escapeFormulae instanceof RegExp) {
525
+ _escapeFormulae = _config.escapeFormulae instanceof RegExp ? _config.escapeFormulae : /^[=+\-@\t\r].*$/;
526
+ }
527
+ }
528
+
529
+ /** The double for loop that iterates the data and writes out a CSV string including header row */
530
+ function serialize(fields, data, skipEmptyLines)
531
+ {
532
+ var csv = '';
533
+
534
+ if (typeof fields === 'string')
535
+ fields = JSON.parse(fields);
536
+ if (typeof data === 'string')
537
+ data = JSON.parse(data);
538
+
539
+ var hasHeader = Array.isArray(fields) && fields.length > 0;
540
+ var dataKeyedByField = !(Array.isArray(data[0]));
541
+
542
+ // If there a header row, write it first
543
+ if (hasHeader && _writeHeader)
544
+ {
545
+ for (var i = 0; i < fields.length; i++)
546
+ {
547
+ if (i > 0)
548
+ csv += _delimiter;
549
+ csv += safe(fields[i], i);
550
+ }
551
+ if (data.length > 0)
552
+ csv += _newline;
553
+ }
554
+
555
+ // Then write out the data
556
+ for (var row = 0; row < data.length; row++)
557
+ {
558
+ var maxCol = hasHeader ? fields.length : data[row].length;
559
+
560
+ var emptyLine = false;
561
+ var nullLine = hasHeader ? Object.keys(data[row]).length === 0 : data[row].length === 0;
562
+ if (skipEmptyLines && !hasHeader)
563
+ {
564
+ emptyLine = skipEmptyLines === 'greedy' ? data[row].join('').trim() === '' : data[row].length === 1 && data[row][0].length === 0;
565
+ }
566
+ if (skipEmptyLines === 'greedy' && hasHeader) {
567
+ var line = [];
568
+ for (var c = 0; c < maxCol; c++) {
569
+ var cx = dataKeyedByField ? fields[c] : c;
570
+ line.push(data[row][cx]);
571
+ }
572
+ emptyLine = line.join('').trim() === '';
573
+ }
574
+ if (!emptyLine)
575
+ {
576
+ for (var col = 0; col < maxCol; col++)
577
+ {
578
+ if (col > 0 && !nullLine)
579
+ csv += _delimiter;
580
+ var colIdx = hasHeader && dataKeyedByField ? fields[col] : col;
581
+ csv += safe(data[row][colIdx], col);
582
+ }
583
+ if (row < data.length - 1 && (!skipEmptyLines || (maxCol > 0 && !nullLine)))
584
+ {
585
+ csv += _newline;
586
+ }
587
+ }
588
+ }
589
+ return csv;
590
+ }
591
+
592
+ /** Encloses a value around quotes if needed (makes a value safe for CSV insertion) */
593
+ function safe(str, col)
594
+ {
595
+ if (typeof str === 'undefined' || str === null)
596
+ return '';
597
+
598
+ if (str.constructor === Date)
599
+ return JSON.stringify(str).slice(1, 25);
600
+
601
+ var needsQuotes = false;
602
+
603
+ if (_escapeFormulae && typeof str === "string" && _escapeFormulae.test(str)) {
604
+ str = "'" + str;
605
+ needsQuotes = true;
606
+ }
607
+
608
+ var escapedQuoteStr = str.toString().replace(quoteCharRegex, _escapedQuote);
609
+
610
+ needsQuotes = needsQuotes
611
+ || _quotes === true
612
+ || (typeof _quotes === 'function' && _quotes(str, col))
613
+ || (Array.isArray(_quotes) && _quotes[col])
614
+ || hasAny(escapedQuoteStr, Papa.BAD_DELIMITERS)
615
+ || escapedQuoteStr.indexOf(_delimiter) > -1
616
+ || escapedQuoteStr.charAt(0) === ' '
617
+ || escapedQuoteStr.charAt(escapedQuoteStr.length - 1) === ' ';
618
+
619
+ return needsQuotes ? _quoteChar + escapedQuoteStr + _quoteChar : escapedQuoteStr;
620
+ }
621
+
622
+ function hasAny(str, substrings)
623
+ {
624
+ for (var i = 0; i < substrings.length; i++)
625
+ if (str.indexOf(substrings[i]) > -1)
626
+ return true;
627
+ return false;
628
+ }
629
+ }
630
+
631
+ /** ChunkStreamer is the base prototype for various streamer implementations. */
632
+ function ChunkStreamer(config)
633
+ {
634
+ this._handle = null;
635
+ this._finished = false;
636
+ this._completed = false;
637
+ this._halted = false;
638
+ this._input = null;
639
+ this._baseIndex = 0;
640
+ this._partialLine = '';
641
+ this._rowCount = 0;
642
+ this._start = 0;
643
+ this._nextChunk = null;
644
+ this.isFirstChunk = true;
645
+ this._completeResults = {
646
+ data: [],
647
+ errors: [],
648
+ meta: {}
649
+ };
650
+ replaceConfig.call(this, config);
651
+
652
+ this.parseChunk = function(chunk, isFakeChunk)
653
+ {
654
+ // First chunk pre-processing
655
+ if (this.isFirstChunk && isFunction(this._config.beforeFirstChunk))
656
+ {
657
+ var modifiedChunk = this._config.beforeFirstChunk(chunk);
658
+ if (modifiedChunk !== undefined)
659
+ chunk = modifiedChunk;
660
+ }
661
+ this.isFirstChunk = false;
662
+ this._halted = false;
663
+
664
+ // Rejoin the line we likely just split in two by chunking the file
665
+ var aggregate = this._partialLine + chunk;
666
+ this._partialLine = '';
667
+
668
+ var results = this._handle.parse(aggregate, this._baseIndex, !this._finished);
669
+
670
+ if (this._handle.paused() || this._handle.aborted()) {
671
+ this._halted = true;
672
+ return;
673
+ }
674
+
675
+ var lastIndex = results.meta.cursor;
676
+
677
+ if (!this._finished)
678
+ {
679
+ this._partialLine = aggregate.substring(lastIndex - this._baseIndex);
680
+ this._baseIndex = lastIndex;
681
+ }
682
+
683
+ if (results && results.data)
684
+ this._rowCount += results.data.length;
685
+
686
+ var finishedIncludingPreview = this._finished || (this._config.preview && this._rowCount >= this._config.preview);
687
+
688
+ if (IS_PAPA_WORKER)
689
+ {
690
+ global.postMessage({
691
+ results: results,
692
+ workerId: Papa.WORKER_ID,
693
+ finished: finishedIncludingPreview
694
+ });
695
+ }
696
+ else if (isFunction(this._config.chunk) && !isFakeChunk)
697
+ {
698
+ this._config.chunk(results, this._handle);
699
+ if (this._handle.paused() || this._handle.aborted()) {
700
+ this._halted = true;
701
+ return;
702
+ }
703
+ results = undefined;
704
+ this._completeResults = undefined;
705
+ }
706
+
707
+ if (!this._config.step && !this._config.chunk) {
708
+ this._completeResults.data = this._completeResults.data.concat(results.data);
709
+ this._completeResults.errors = this._completeResults.errors.concat(results.errors);
710
+ this._completeResults.meta = results.meta;
711
+ }
712
+
713
+ if (!this._completed && finishedIncludingPreview && isFunction(this._config.complete) && (!results || !results.meta.aborted)) {
714
+ this._config.complete(this._completeResults, this._input);
715
+ this._completed = true;
716
+ }
717
+
718
+ if (!finishedIncludingPreview && (!results || !results.meta.paused))
719
+ this._nextChunk();
720
+
721
+ return results;
722
+ };
723
+
724
+ this._sendError = function(error)
725
+ {
726
+ if (isFunction(this._config.error))
727
+ this._config.error(error);
728
+ else if (IS_PAPA_WORKER && this._config.error)
729
+ {
730
+ global.postMessage({
731
+ workerId: Papa.WORKER_ID,
732
+ error: error,
733
+ finished: false
734
+ });
735
+ }
736
+ };
737
+
738
+ function replaceConfig(config)
739
+ {
740
+ // Deep-copy the config so we can edit it
741
+ var configCopy = copy(config);
742
+ configCopy.chunkSize = parseInt(configCopy.chunkSize); // parseInt VERY important so we don't concatenate strings!
743
+ if (!config.step && !config.chunk)
744
+ configCopy.chunkSize = null; // disable Range header if not streaming; bad values break IIS - see issue #196
745
+ this._handle = new ParserHandle(configCopy);
746
+ this._handle.streamer = this;
747
+ this._config = configCopy; // persist the copy to the caller
748
+ }
749
+ }
750
+
751
+
752
+ function NetworkStreamer(config)
753
+ {
754
+ config = config || {};
755
+ if (!config.chunkSize)
756
+ config.chunkSize = Papa.RemoteChunkSize;
757
+ ChunkStreamer.call(this, config);
758
+
759
+ var xhr;
760
+
761
+ if (IS_WORKER)
762
+ {
763
+ this._nextChunk = function()
764
+ {
765
+ this._readChunk();
766
+ this._chunkLoaded();
767
+ };
768
+ }
769
+ else
770
+ {
771
+ this._nextChunk = function()
772
+ {
773
+ this._readChunk();
774
+ };
775
+ }
776
+
777
+ this.stream = function(url)
778
+ {
779
+ this._input = url;
780
+ this._nextChunk(); // Starts streaming
781
+ };
782
+
783
+ this._readChunk = function()
784
+ {
785
+ if (this._finished)
786
+ {
787
+ this._chunkLoaded();
788
+ return;
789
+ }
790
+
791
+ xhr = new XMLHttpRequest();
792
+
793
+ if (this._config.withCredentials)
794
+ {
795
+ xhr.withCredentials = this._config.withCredentials;
796
+ }
797
+
798
+ if (!IS_WORKER)
799
+ {
800
+ xhr.onload = bindFunction(this._chunkLoaded, this);
801
+ xhr.onerror = bindFunction(this._chunkError, this);
802
+ }
803
+
804
+ xhr.open(this._config.downloadRequestBody ? 'POST' : 'GET', this._input, !IS_WORKER);
805
+ // Headers can only be set when once the request state is OPENED
806
+ if (this._config.downloadRequestHeaders)
807
+ {
808
+ var headers = this._config.downloadRequestHeaders;
809
+
810
+ for (var headerName in headers)
811
+ {
812
+ xhr.setRequestHeader(headerName, headers[headerName]);
813
+ }
814
+ }
815
+
816
+ if (this._config.chunkSize)
817
+ {
818
+ var end = this._start + this._config.chunkSize - 1; // minus one because byte range is inclusive
819
+ xhr.setRequestHeader('Range', 'bytes=' + this._start + '-' + end);
820
+ }
821
+
822
+ try {
823
+ xhr.send(this._config.downloadRequestBody);
824
+ }
825
+ catch (err) {
826
+ this._chunkError(err.message);
827
+ }
828
+
829
+ if (IS_WORKER && xhr.status === 0)
830
+ this._chunkError();
831
+ };
832
+
833
+ this._chunkLoaded = function()
834
+ {
835
+ if (xhr.readyState !== 4)
836
+ return;
837
+
838
+ if (xhr.status < 200 || xhr.status >= 400)
839
+ {
840
+ this._chunkError();
841
+ return;
842
+ }
843
+
844
+ // Use chunckSize as it may be a diference on reponse lentgh due to characters with more than 1 byte
845
+ this._start += this._config.chunkSize ? this._config.chunkSize : xhr.responseText.length;
846
+ this._finished = !this._config.chunkSize || this._start >= getFileSize(xhr);
847
+ this.parseChunk(xhr.responseText);
848
+ };
849
+
850
+ this._chunkError = function(errorMessage)
851
+ {
852
+ var errorText = xhr.statusText || errorMessage;
853
+ this._sendError(new Error(errorText));
854
+ };
855
+
856
+ function getFileSize(xhr)
857
+ {
858
+ var contentRange = xhr.getResponseHeader('Content-Range');
859
+ if (contentRange === null) { // no content range, then finish!
860
+ return -1;
861
+ }
862
+ return parseInt(contentRange.substring(contentRange.lastIndexOf('/') + 1));
863
+ }
864
+ }
865
+ NetworkStreamer.prototype = Object.create(ChunkStreamer.prototype);
866
+ NetworkStreamer.prototype.constructor = NetworkStreamer;
867
+
868
+
869
+ function FileStreamer(config)
870
+ {
871
+ config = config || {};
872
+ if (!config.chunkSize)
873
+ config.chunkSize = Papa.LocalChunkSize;
874
+ ChunkStreamer.call(this, config);
875
+
876
+ var reader, slice;
877
+
878
+ // FileReader is better than FileReaderSync (even in worker) - see http://stackoverflow.com/q/24708649/1048862
879
+ // But Firefox is a pill, too - see issue #76: https://github.com/mholt/PapaParse/issues/76
880
+ var usingAsyncReader = typeof FileReader !== 'undefined'; // Safari doesn't consider it a function - see issue #105
881
+
882
+ this.stream = function(file)
883
+ {
884
+ this._input = file;
885
+ slice = file.slice || file.webkitSlice || file.mozSlice;
886
+
887
+ if (usingAsyncReader)
888
+ {
889
+ reader = new FileReader(); // Preferred method of reading files, even in workers
890
+ reader.onload = bindFunction(this._chunkLoaded, this);
891
+ reader.onerror = bindFunction(this._chunkError, this);
892
+ }
893
+ else
894
+ reader = new FileReaderSync(); // Hack for running in a web worker in Firefox
895
+
896
+ this._nextChunk(); // Starts streaming
897
+ };
898
+
899
+ this._nextChunk = function()
900
+ {
901
+ if (!this._finished && (!this._config.preview || this._rowCount < this._config.preview))
902
+ this._readChunk();
903
+ };
904
+
905
+ this._readChunk = function()
906
+ {
907
+ var input = this._input;
908
+ if (this._config.chunkSize)
909
+ {
910
+ var end = Math.min(this._start + this._config.chunkSize, this._input.size);
911
+ input = slice.call(input, this._start, end);
912
+ }
913
+ var txt = reader.readAsText(input, this._config.encoding);
914
+ if (!usingAsyncReader)
915
+ this._chunkLoaded({ target: { result: txt } }); // mimic the async signature
916
+ };
917
+
918
+ this._chunkLoaded = function(event)
919
+ {
920
+ // Very important to increment start each time before handling results
921
+ this._start += this._config.chunkSize;
922
+ this._finished = !this._config.chunkSize || this._start >= this._input.size;
923
+ this.parseChunk(event.target.result);
924
+ };
925
+
926
+ this._chunkError = function()
927
+ {
928
+ this._sendError(reader.error);
929
+ };
930
+
931
+ }
932
+ FileStreamer.prototype = Object.create(ChunkStreamer.prototype);
933
+ FileStreamer.prototype.constructor = FileStreamer;
934
+
935
+
936
+ function StringStreamer(config)
937
+ {
938
+ config = config || {};
939
+ ChunkStreamer.call(this, config);
940
+
941
+ var remaining;
942
+ this.stream = function(s)
943
+ {
944
+ remaining = s;
945
+ return this._nextChunk();
946
+ };
947
+ this._nextChunk = function()
948
+ {
949
+ if (this._finished) return;
950
+ var size = this._config.chunkSize;
951
+ var chunk;
952
+ if(size) {
953
+ chunk = remaining.substring(0, size);
954
+ remaining = remaining.substring(size);
955
+ } else {
956
+ chunk = remaining;
957
+ remaining = '';
958
+ }
959
+ this._finished = !remaining;
960
+ return this.parseChunk(chunk);
961
+ };
962
+ }
963
+ StringStreamer.prototype = Object.create(StringStreamer.prototype);
964
+ StringStreamer.prototype.constructor = StringStreamer;
965
+
966
+
967
+ function ReadableStreamStreamer(config)
968
+ {
969
+ config = config || {};
970
+
971
+ ChunkStreamer.call(this, config);
972
+
973
+ var queue = [];
974
+ var parseOnData = true;
975
+ var streamHasEnded = false;
976
+
977
+ this.pause = function()
978
+ {
979
+ ChunkStreamer.prototype.pause.apply(this, arguments);
980
+ this._input.pause();
981
+ };
982
+
983
+ this.resume = function()
984
+ {
985
+ ChunkStreamer.prototype.resume.apply(this, arguments);
986
+ this._input.resume();
987
+ };
988
+
989
+ this.stream = function(stream)
990
+ {
991
+ this._input = stream;
992
+
993
+ this._input.on('data', this._streamData);
994
+ this._input.on('end', this._streamEnd);
995
+ this._input.on('error', this._streamError);
996
+ };
997
+
998
+ this._checkIsFinished = function()
999
+ {
1000
+ if (streamHasEnded && queue.length === 1) {
1001
+ this._finished = true;
1002
+ }
1003
+ };
1004
+
1005
+ this._nextChunk = function()
1006
+ {
1007
+ this._checkIsFinished();
1008
+ if (queue.length)
1009
+ {
1010
+ this.parseChunk(queue.shift());
1011
+ }
1012
+ else
1013
+ {
1014
+ parseOnData = true;
1015
+ }
1016
+ };
1017
+
1018
+ this._streamData = bindFunction(function(chunk)
1019
+ {
1020
+ try
1021
+ {
1022
+ queue.push(typeof chunk === 'string' ? chunk : chunk.toString(this._config.encoding));
1023
+
1024
+ if (parseOnData)
1025
+ {
1026
+ parseOnData = false;
1027
+ this._checkIsFinished();
1028
+ this.parseChunk(queue.shift());
1029
+ }
1030
+ }
1031
+ catch (error)
1032
+ {
1033
+ this._streamError(error);
1034
+ }
1035
+ }, this);
1036
+
1037
+ this._streamError = bindFunction(function(error)
1038
+ {
1039
+ this._streamCleanUp();
1040
+ this._sendError(error);
1041
+ }, this);
1042
+
1043
+ this._streamEnd = bindFunction(function()
1044
+ {
1045
+ this._streamCleanUp();
1046
+ streamHasEnded = true;
1047
+ this._streamData('');
1048
+ }, this);
1049
+
1050
+ this._streamCleanUp = bindFunction(function()
1051
+ {
1052
+ this._input.removeListener('data', this._streamData);
1053
+ this._input.removeListener('end', this._streamEnd);
1054
+ this._input.removeListener('error', this._streamError);
1055
+ }, this);
1056
+ }
1057
+ ReadableStreamStreamer.prototype = Object.create(ChunkStreamer.prototype);
1058
+ ReadableStreamStreamer.prototype.constructor = ReadableStreamStreamer;
1059
+
1060
+
1061
+ function DuplexStreamStreamer(_config) {
1062
+ var Duplex = require$$0.Duplex;
1063
+ var config = copy(_config);
1064
+ var parseOnWrite = true;
1065
+ var writeStreamHasFinished = false;
1066
+ var parseCallbackQueue = [];
1067
+ var stream = null;
1068
+
1069
+ this._onCsvData = function(results)
1070
+ {
1071
+ var data = results.data;
1072
+ if (!stream.push(data) && !this._handle.paused()) {
1073
+ // the writeable consumer buffer has filled up
1074
+ // so we need to pause until more items
1075
+ // can be processed
1076
+ this._handle.pause();
1077
+ }
1078
+ };
1079
+
1080
+ this._onCsvComplete = function()
1081
+ {
1082
+ // node will finish the read stream when
1083
+ // null is pushed
1084
+ stream.push(null);
1085
+ };
1086
+
1087
+ config.step = bindFunction(this._onCsvData, this);
1088
+ config.complete = bindFunction(this._onCsvComplete, this);
1089
+ ChunkStreamer.call(this, config);
1090
+
1091
+ this._nextChunk = function()
1092
+ {
1093
+ if (writeStreamHasFinished && parseCallbackQueue.length === 1) {
1094
+ this._finished = true;
1095
+ }
1096
+ if (parseCallbackQueue.length) {
1097
+ parseCallbackQueue.shift()();
1098
+ } else {
1099
+ parseOnWrite = true;
1100
+ }
1101
+ };
1102
+
1103
+ this._addToParseQueue = function(chunk, callback)
1104
+ {
1105
+ // add to queue so that we can indicate
1106
+ // completion via callback
1107
+ // node will automatically pause the incoming stream
1108
+ // when too many items have been added without their
1109
+ // callback being invoked
1110
+ parseCallbackQueue.push(bindFunction(function() {
1111
+ this.parseChunk(typeof chunk === 'string' ? chunk : chunk.toString(config.encoding));
1112
+ if (isFunction(callback)) {
1113
+ return callback();
1114
+ }
1115
+ }, this));
1116
+ if (parseOnWrite) {
1117
+ parseOnWrite = false;
1118
+ this._nextChunk();
1119
+ }
1120
+ };
1121
+
1122
+ this._onRead = function()
1123
+ {
1124
+ if (this._handle.paused()) {
1125
+ // the writeable consumer can handle more data
1126
+ // so resume the chunk parsing
1127
+ this._handle.resume();
1128
+ }
1129
+ };
1130
+
1131
+ this._onWrite = function(chunk, encoding, callback)
1132
+ {
1133
+ this._addToParseQueue(chunk, callback);
1134
+ };
1135
+
1136
+ this._onWriteComplete = function()
1137
+ {
1138
+ writeStreamHasFinished = true;
1139
+ // have to write empty string
1140
+ // so parser knows its done
1141
+ this._addToParseQueue('');
1142
+ };
1143
+
1144
+ this.getStream = function()
1145
+ {
1146
+ return stream;
1147
+ };
1148
+ stream = new Duplex({
1149
+ readableObjectMode: true,
1150
+ decodeStrings: false,
1151
+ read: bindFunction(this._onRead, this),
1152
+ write: bindFunction(this._onWrite, this)
1153
+ });
1154
+ stream.once('finish', bindFunction(this._onWriteComplete, this));
1155
+ }
1156
+ if (typeof PAPA_BROWSER_CONTEXT === 'undefined') {
1157
+ DuplexStreamStreamer.prototype = Object.create(ChunkStreamer.prototype);
1158
+ DuplexStreamStreamer.prototype.constructor = DuplexStreamStreamer;
1159
+ }
1160
+
1161
+
1162
+ // Use one ParserHandle per entire CSV file or string
1163
+ function ParserHandle(_config)
1164
+ {
1165
+ // One goal is to minimize the use of regular expressions...
1166
+ var MAX_FLOAT = Math.pow(2, 53);
1167
+ var MIN_FLOAT = -MAX_FLOAT;
1168
+ var FLOAT = /^\s*-?(\d+\.?|\.\d+|\d+\.\d+)([eE][-+]?\d+)?\s*$/;
1169
+ var ISO_DATE = /^((\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d\.\d+([+-][0-2]\d:[0-5]\d|Z))|(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d([+-][0-2]\d:[0-5]\d|Z))|(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d([+-][0-2]\d:[0-5]\d|Z)))$/;
1170
+ var self = this;
1171
+ var _stepCounter = 0; // Number of times step was called (number of rows parsed)
1172
+ var _rowCounter = 0; // Number of rows that have been parsed so far
1173
+ var _input; // The input being parsed
1174
+ var _parser; // The core parser being used
1175
+ var _paused = false; // Whether we are paused or not
1176
+ var _aborted = false; // Whether the parser has aborted or not
1177
+ var _delimiterError; // Temporary state between delimiter detection and processing results
1178
+ var _fields = []; // Fields are from the header row of the input, if there is one
1179
+ var _results = { // The last results returned from the parser
1180
+ data: [],
1181
+ errors: [],
1182
+ meta: {}
1183
+ };
1184
+
1185
+ if (isFunction(_config.step))
1186
+ {
1187
+ var userStep = _config.step;
1188
+ _config.step = function(results)
1189
+ {
1190
+ _results = results;
1191
+
1192
+ if (needsHeaderRow())
1193
+ processResults();
1194
+ else // only call user's step function after header row
1195
+ {
1196
+ processResults();
1197
+
1198
+ // It's possbile that this line was empty and there's no row here after all
1199
+ if (_results.data.length === 0)
1200
+ return;
1201
+
1202
+ _stepCounter += results.data.length;
1203
+ if (_config.preview && _stepCounter > _config.preview)
1204
+ _parser.abort();
1205
+ else {
1206
+ _results.data = _results.data[0];
1207
+ userStep(_results, self);
1208
+ }
1209
+ }
1210
+ };
1211
+ }
1212
+
1213
+ /**
1214
+ * Parses input. Most users won't need, and shouldn't mess with, the baseIndex
1215
+ * and ignoreLastRow parameters. They are used by streamers (wrapper functions)
1216
+ * when an input comes in multiple chunks, like from a file.
1217
+ */
1218
+ this.parse = function(input, baseIndex, ignoreLastRow)
1219
+ {
1220
+ var quoteChar = _config.quoteChar || '"';
1221
+ if (!_config.newline)
1222
+ _config.newline = guessLineEndings(input, quoteChar);
1223
+
1224
+ _delimiterError = false;
1225
+ if (!_config.delimiter)
1226
+ {
1227
+ var delimGuess = guessDelimiter(input, _config.newline, _config.skipEmptyLines, _config.comments, _config.delimitersToGuess);
1228
+ if (delimGuess.successful)
1229
+ _config.delimiter = delimGuess.bestDelimiter;
1230
+ else
1231
+ {
1232
+ _delimiterError = true; // add error after parsing (otherwise it would be overwritten)
1233
+ _config.delimiter = Papa.DefaultDelimiter;
1234
+ }
1235
+ _results.meta.delimiter = _config.delimiter;
1236
+ }
1237
+ else if(isFunction(_config.delimiter))
1238
+ {
1239
+ _config.delimiter = _config.delimiter(input);
1240
+ _results.meta.delimiter = _config.delimiter;
1241
+ }
1242
+
1243
+ var parserConfig = copy(_config);
1244
+ if (_config.preview && _config.header)
1245
+ parserConfig.preview++; // to compensate for header row
1246
+
1247
+ _input = input;
1248
+ _parser = new Parser(parserConfig);
1249
+ _results = _parser.parse(_input, baseIndex, ignoreLastRow);
1250
+ processResults();
1251
+ return _paused ? { meta: { paused: true } } : (_results || { meta: { paused: false } });
1252
+ };
1253
+
1254
+ this.paused = function()
1255
+ {
1256
+ return _paused;
1257
+ };
1258
+
1259
+ this.pause = function()
1260
+ {
1261
+ _paused = true;
1262
+ _parser.abort();
1263
+
1264
+ // If it is streaming via "chunking", the reader will start appending correctly already so no need to substring,
1265
+ // otherwise we can get duplicate content within a row
1266
+ _input = isFunction(_config.chunk) ? "" : _input.substring(_parser.getCharIndex());
1267
+ };
1268
+
1269
+ this.resume = function()
1270
+ {
1271
+ if(self.streamer._halted) {
1272
+ _paused = false;
1273
+ self.streamer.parseChunk(_input, true);
1274
+ } else {
1275
+ // Bugfix: #636 In case the processing hasn't halted yet
1276
+ // wait for it to halt in order to resume
1277
+ setTimeout(self.resume, 3);
1278
+ }
1279
+ };
1280
+
1281
+ this.aborted = function()
1282
+ {
1283
+ return _aborted;
1284
+ };
1285
+
1286
+ this.abort = function()
1287
+ {
1288
+ _aborted = true;
1289
+ _parser.abort();
1290
+ _results.meta.aborted = true;
1291
+ if (isFunction(_config.complete))
1292
+ _config.complete(_results);
1293
+ _input = '';
1294
+ };
1295
+
1296
+ function testEmptyLine(s) {
1297
+ return _config.skipEmptyLines === 'greedy' ? s.join('').trim() === '' : s.length === 1 && s[0].length === 0;
1298
+ }
1299
+
1300
+ function testFloat(s) {
1301
+ if (FLOAT.test(s)) {
1302
+ var floatValue = parseFloat(s);
1303
+ if (floatValue > MIN_FLOAT && floatValue < MAX_FLOAT) {
1304
+ return true;
1305
+ }
1306
+ }
1307
+ return false;
1308
+ }
1309
+
1310
+ function processResults()
1311
+ {
1312
+ if (_results && _delimiterError)
1313
+ {
1314
+ addError('Delimiter', 'UndetectableDelimiter', 'Unable to auto-detect delimiting character; defaulted to \'' + Papa.DefaultDelimiter + '\'');
1315
+ _delimiterError = false;
1316
+ }
1317
+
1318
+ if (_config.skipEmptyLines)
1319
+ {
1320
+ _results.data = _results.data.filter(function(d) {
1321
+ return !testEmptyLine(d);
1322
+ });
1323
+ }
1324
+
1325
+ if (needsHeaderRow())
1326
+ fillHeaderFields();
1327
+
1328
+ return applyHeaderAndDynamicTypingAndTransformation();
1329
+ }
1330
+
1331
+ function needsHeaderRow()
1332
+ {
1333
+ return _config.header && _fields.length === 0;
1334
+ }
1335
+
1336
+ function fillHeaderFields()
1337
+ {
1338
+ if (!_results)
1339
+ return;
1340
+
1341
+ function addHeader(header, i)
1342
+ {
1343
+ if (isFunction(_config.transformHeader))
1344
+ header = _config.transformHeader(header, i);
1345
+
1346
+ _fields.push(header);
1347
+ }
1348
+
1349
+ if (Array.isArray(_results.data[0]))
1350
+ {
1351
+ for (var i = 0; needsHeaderRow() && i < _results.data.length; i++)
1352
+ _results.data[i].forEach(addHeader);
1353
+
1354
+ _results.data.splice(0, 1);
1355
+ }
1356
+ // if _results.data[0] is not an array, we are in a step where _results.data is the row.
1357
+ else
1358
+ _results.data.forEach(addHeader);
1359
+ }
1360
+
1361
+ function shouldApplyDynamicTyping(field) {
1362
+ // Cache function values to avoid calling it for each row
1363
+ if (_config.dynamicTypingFunction && _config.dynamicTyping[field] === undefined) {
1364
+ _config.dynamicTyping[field] = _config.dynamicTypingFunction(field);
1365
+ }
1366
+ return (_config.dynamicTyping[field] || _config.dynamicTyping) === true;
1367
+ }
1368
+
1369
+ function parseDynamic(field, value)
1370
+ {
1371
+ if (shouldApplyDynamicTyping(field))
1372
+ {
1373
+ if (value === 'true' || value === 'TRUE')
1374
+ return true;
1375
+ else if (value === 'false' || value === 'FALSE')
1376
+ return false;
1377
+ else if (testFloat(value))
1378
+ return parseFloat(value);
1379
+ else if (ISO_DATE.test(value))
1380
+ return new Date(value);
1381
+ else
1382
+ return (value === '' ? null : value);
1383
+ }
1384
+ return value;
1385
+ }
1386
+
1387
+ function applyHeaderAndDynamicTypingAndTransformation()
1388
+ {
1389
+ if (!_results || (!_config.header && !_config.dynamicTyping && !_config.transform))
1390
+ return _results;
1391
+
1392
+ function processRow(rowSource, i)
1393
+ {
1394
+ var row = _config.header ? {} : [];
1395
+
1396
+ var j;
1397
+ for (j = 0; j < rowSource.length; j++)
1398
+ {
1399
+ var field = j;
1400
+ var value = rowSource[j];
1401
+
1402
+ if (_config.header)
1403
+ field = j >= _fields.length ? '__parsed_extra' : _fields[j];
1404
+
1405
+ if (_config.transform)
1406
+ value = _config.transform(value,field);
1407
+
1408
+ value = parseDynamic(field, value);
1409
+
1410
+ if (field === '__parsed_extra')
1411
+ {
1412
+ row[field] = row[field] || [];
1413
+ row[field].push(value);
1414
+ }
1415
+ else
1416
+ row[field] = value;
1417
+ }
1418
+
1419
+
1420
+ if (_config.header)
1421
+ {
1422
+ if (j > _fields.length)
1423
+ addError('FieldMismatch', 'TooManyFields', 'Too many fields: expected ' + _fields.length + ' fields but parsed ' + j, _rowCounter + i);
1424
+ else if (j < _fields.length)
1425
+ addError('FieldMismatch', 'TooFewFields', 'Too few fields: expected ' + _fields.length + ' fields but parsed ' + j, _rowCounter + i);
1426
+ }
1427
+
1428
+ return row;
1429
+ }
1430
+
1431
+ var incrementBy = 1;
1432
+ if (!_results.data.length || Array.isArray(_results.data[0]))
1433
+ {
1434
+ _results.data = _results.data.map(processRow);
1435
+ incrementBy = _results.data.length;
1436
+ }
1437
+ else
1438
+ _results.data = processRow(_results.data, 0);
1439
+
1440
+
1441
+ if (_config.header && _results.meta)
1442
+ _results.meta.fields = _fields;
1443
+
1444
+ _rowCounter += incrementBy;
1445
+ return _results;
1446
+ }
1447
+
1448
+ function guessDelimiter(input, newline, skipEmptyLines, comments, delimitersToGuess) {
1449
+ var bestDelim, bestDelta, fieldCountPrevRow, maxFieldCount;
1450
+
1451
+ delimitersToGuess = delimitersToGuess || [',', '\t', '|', ';', Papa.RECORD_SEP, Papa.UNIT_SEP];
1452
+
1453
+ for (var i = 0; i < delimitersToGuess.length; i++) {
1454
+ var delim = delimitersToGuess[i];
1455
+ var delta = 0, avgFieldCount = 0, emptyLinesCount = 0;
1456
+ fieldCountPrevRow = undefined;
1457
+
1458
+ var preview = new Parser({
1459
+ comments: comments,
1460
+ delimiter: delim,
1461
+ newline: newline,
1462
+ preview: 10
1463
+ }).parse(input);
1464
+
1465
+ for (var j = 0; j < preview.data.length; j++) {
1466
+ if (skipEmptyLines && testEmptyLine(preview.data[j])) {
1467
+ emptyLinesCount++;
1468
+ continue;
1469
+ }
1470
+ var fieldCount = preview.data[j].length;
1471
+ avgFieldCount += fieldCount;
1472
+
1473
+ if (typeof fieldCountPrevRow === 'undefined') {
1474
+ fieldCountPrevRow = fieldCount;
1475
+ continue;
1476
+ }
1477
+ else if (fieldCount > 0) {
1478
+ delta += Math.abs(fieldCount - fieldCountPrevRow);
1479
+ fieldCountPrevRow = fieldCount;
1480
+ }
1481
+ }
1482
+
1483
+ if (preview.data.length > 0)
1484
+ avgFieldCount /= (preview.data.length - emptyLinesCount);
1485
+
1486
+ if ((typeof bestDelta === 'undefined' || delta <= bestDelta)
1487
+ && (typeof maxFieldCount === 'undefined' || avgFieldCount > maxFieldCount) && avgFieldCount > 1.99) {
1488
+ bestDelta = delta;
1489
+ bestDelim = delim;
1490
+ maxFieldCount = avgFieldCount;
1491
+ }
1492
+ }
1493
+
1494
+ _config.delimiter = bestDelim;
1495
+
1496
+ return {
1497
+ successful: !!bestDelim,
1498
+ bestDelimiter: bestDelim
1499
+ };
1500
+ }
1501
+
1502
+ function guessLineEndings(input, quoteChar)
1503
+ {
1504
+ input = input.substring(0, 1024 * 1024); // max length 1 MB
1505
+ // Replace all the text inside quotes
1506
+ var re = new RegExp(escapeRegExp(quoteChar) + '([^]*?)' + escapeRegExp(quoteChar), 'gm');
1507
+ input = input.replace(re, '');
1508
+
1509
+ var r = input.split('\r');
1510
+
1511
+ var n = input.split('\n');
1512
+
1513
+ var nAppearsFirst = (n.length > 1 && n[0].length < r[0].length);
1514
+
1515
+ if (r.length === 1 || nAppearsFirst)
1516
+ return '\n';
1517
+
1518
+ var numWithN = 0;
1519
+ for (var i = 0; i < r.length; i++)
1520
+ {
1521
+ if (r[i][0] === '\n')
1522
+ numWithN++;
1523
+ }
1524
+
1525
+ return numWithN >= r.length / 2 ? '\r\n' : '\r';
1526
+ }
1527
+
1528
+ function addError(type, code, msg, row)
1529
+ {
1530
+ var error = {
1531
+ type: type,
1532
+ code: code,
1533
+ message: msg
1534
+ };
1535
+ if(row !== undefined) {
1536
+ error.row = row;
1537
+ }
1538
+ _results.errors.push(error);
1539
+ }
1540
+ }
1541
+
1542
+ /** https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions */
1543
+ function escapeRegExp(string)
1544
+ {
1545
+ return string.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); // $& means the whole matched string
1546
+ }
1547
+
1548
+ /** The core parser implements speedy and correct CSV parsing */
1549
+ function Parser(config)
1550
+ {
1551
+ // Unpack the config object
1552
+ config = config || {};
1553
+ var delim = config.delimiter;
1554
+ var newline = config.newline;
1555
+ var comments = config.comments;
1556
+ var step = config.step;
1557
+ var preview = config.preview;
1558
+ var fastMode = config.fastMode;
1559
+ var quoteChar;
1560
+ if (config.quoteChar === undefined || config.quoteChar === null) {
1561
+ quoteChar = '"';
1562
+ } else {
1563
+ quoteChar = config.quoteChar;
1564
+ }
1565
+ var escapeChar = quoteChar;
1566
+ if (config.escapeChar !== undefined) {
1567
+ escapeChar = config.escapeChar;
1568
+ }
1569
+
1570
+ // Delimiter must be valid
1571
+ if (typeof delim !== 'string'
1572
+ || Papa.BAD_DELIMITERS.indexOf(delim) > -1)
1573
+ delim = ',';
1574
+
1575
+ // Comment character must be valid
1576
+ if (comments === delim)
1577
+ throw new Error('Comment character same as delimiter');
1578
+ else if (comments === true)
1579
+ comments = '#';
1580
+ else if (typeof comments !== 'string'
1581
+ || Papa.BAD_DELIMITERS.indexOf(comments) > -1)
1582
+ comments = false;
1583
+
1584
+ // Newline must be valid: \r, \n, or \r\n
1585
+ if (newline !== '\n' && newline !== '\r' && newline !== '\r\n')
1586
+ newline = '\n';
1587
+
1588
+ // We're gonna need these at the Parser scope
1589
+ var cursor = 0;
1590
+ var aborted = false;
1591
+
1592
+ this.parse = function(input, baseIndex, ignoreLastRow)
1593
+ {
1594
+ // For some reason, in Chrome, this speeds things up (!?)
1595
+ if (typeof input !== 'string')
1596
+ throw new Error('Input must be a string');
1597
+
1598
+ // We don't need to compute some of these every time parse() is called,
1599
+ // but having them in a more local scope seems to perform better
1600
+ var inputLen = input.length,
1601
+ delimLen = delim.length,
1602
+ newlineLen = newline.length,
1603
+ commentsLen = comments.length;
1604
+ var stepIsFunction = isFunction(step);
1605
+
1606
+ // Establish starting state
1607
+ cursor = 0;
1608
+ var data = [], errors = [], row = [], lastCursor = 0;
1609
+
1610
+ if (!input)
1611
+ return returnable();
1612
+
1613
+ // Rename headers if there are duplicates
1614
+ if (config.header && !baseIndex)
1615
+ {
1616
+ var firstLine = input.split(newline)[0];
1617
+ var headers = firstLine.split(delim);
1618
+ var separator = '_';
1619
+ var headerMap = [];
1620
+ var headerCount = {};
1621
+ var duplicateHeaders = false;
1622
+
1623
+ for (var j in headers) {
1624
+ var header = headers[j];
1625
+ if (isFunction(config.transformHeader))
1626
+ header = config.transformHeader(header, j);
1627
+ var headerName = header;
1628
+
1629
+ var count = headerCount[header] || 0;
1630
+ if (count > 0) {
1631
+ duplicateHeaders = true;
1632
+ headerName = header + separator + count;
1633
+ }
1634
+ headerCount[header] = count + 1;
1635
+ // In case it already exists, we add more separtors
1636
+ while (headerMap.includes(headerName)) {
1637
+ headerName = headerName + separator + count;
1638
+ }
1639
+ headerMap.push(headerName);
1640
+ }
1641
+ if (duplicateHeaders) {
1642
+ var editedInput = input.split(newline);
1643
+ editedInput[0] = headerMap.join(delim);
1644
+ input = editedInput.join(newline);
1645
+ }
1646
+ }
1647
+ if (fastMode || (fastMode !== false && input.indexOf(quoteChar) === -1))
1648
+ {
1649
+ var rows = input.split(newline);
1650
+ for (var i = 0; i < rows.length; i++)
1651
+ {
1652
+ row = rows[i];
1653
+ cursor += row.length;
1654
+ if (i !== rows.length - 1)
1655
+ cursor += newline.length;
1656
+ else if (ignoreLastRow)
1657
+ return returnable();
1658
+ if (comments && row.substring(0, commentsLen) === comments)
1659
+ continue;
1660
+ if (stepIsFunction)
1661
+ {
1662
+ data = [];
1663
+ pushRow(row.split(delim));
1664
+ doStep();
1665
+ if (aborted)
1666
+ return returnable();
1667
+ }
1668
+ else
1669
+ pushRow(row.split(delim));
1670
+ if (preview && i >= preview)
1671
+ {
1672
+ data = data.slice(0, preview);
1673
+ return returnable(true);
1674
+ }
1675
+ }
1676
+ return returnable();
1677
+ }
1678
+
1679
+ var nextDelim = input.indexOf(delim, cursor);
1680
+ var nextNewline = input.indexOf(newline, cursor);
1681
+ var quoteCharRegex = new RegExp(escapeRegExp(escapeChar) + escapeRegExp(quoteChar), 'g');
1682
+ var quoteSearch = input.indexOf(quoteChar, cursor);
1683
+
1684
+ // Parser loop
1685
+ for (;;)
1686
+ {
1687
+ // Field has opening quote
1688
+ if (input[cursor] === quoteChar)
1689
+ {
1690
+ // Start our search for the closing quote where the cursor is
1691
+ quoteSearch = cursor;
1692
+
1693
+ // Skip the opening quote
1694
+ cursor++;
1695
+
1696
+ for (;;)
1697
+ {
1698
+ // Find closing quote
1699
+ quoteSearch = input.indexOf(quoteChar, quoteSearch + 1);
1700
+
1701
+ //No other quotes are found - no other delimiters
1702
+ if (quoteSearch === -1)
1703
+ {
1704
+ if (!ignoreLastRow) {
1705
+ // No closing quote... what a pity
1706
+ errors.push({
1707
+ type: 'Quotes',
1708
+ code: 'MissingQuotes',
1709
+ message: 'Quoted field unterminated',
1710
+ row: data.length, // row has yet to be inserted
1711
+ index: cursor
1712
+ });
1713
+ }
1714
+ return finish();
1715
+ }
1716
+
1717
+ // Closing quote at EOF
1718
+ if (quoteSearch === inputLen - 1)
1719
+ {
1720
+ var value = input.substring(cursor, quoteSearch).replace(quoteCharRegex, quoteChar);
1721
+ return finish(value);
1722
+ }
1723
+
1724
+ // If this quote is escaped, it's part of the data; skip it
1725
+ // If the quote character is the escape character, then check if the next character is the escape character
1726
+ if (quoteChar === escapeChar && input[quoteSearch + 1] === escapeChar)
1727
+ {
1728
+ quoteSearch++;
1729
+ continue;
1730
+ }
1731
+
1732
+ // If the quote character is not the escape character, then check if the previous character was the escape character
1733
+ if (quoteChar !== escapeChar && quoteSearch !== 0 && input[quoteSearch - 1] === escapeChar)
1734
+ {
1735
+ continue;
1736
+ }
1737
+
1738
+ if(nextDelim !== -1 && nextDelim < (quoteSearch + 1)) {
1739
+ nextDelim = input.indexOf(delim, (quoteSearch + 1));
1740
+ }
1741
+ if(nextNewline !== -1 && nextNewline < (quoteSearch + 1)) {
1742
+ nextNewline = input.indexOf(newline, (quoteSearch + 1));
1743
+ }
1744
+ // Check up to nextDelim or nextNewline, whichever is closest
1745
+ var checkUpTo = nextNewline === -1 ? nextDelim : Math.min(nextDelim, nextNewline);
1746
+ var spacesBetweenQuoteAndDelimiter = extraSpaces(checkUpTo);
1747
+
1748
+ // Closing quote followed by delimiter or 'unnecessary spaces + delimiter'
1749
+ if (input.substr(quoteSearch + 1 + spacesBetweenQuoteAndDelimiter, delimLen) === delim)
1750
+ {
1751
+ row.push(input.substring(cursor, quoteSearch).replace(quoteCharRegex, quoteChar));
1752
+ cursor = quoteSearch + 1 + spacesBetweenQuoteAndDelimiter + delimLen;
1753
+
1754
+ // If char after following delimiter is not quoteChar, we find next quote char position
1755
+ if (input[quoteSearch + 1 + spacesBetweenQuoteAndDelimiter + delimLen] !== quoteChar)
1756
+ {
1757
+ quoteSearch = input.indexOf(quoteChar, cursor);
1758
+ }
1759
+ nextDelim = input.indexOf(delim, cursor);
1760
+ nextNewline = input.indexOf(newline, cursor);
1761
+ break;
1762
+ }
1763
+
1764
+ var spacesBetweenQuoteAndNewLine = extraSpaces(nextNewline);
1765
+
1766
+ // Closing quote followed by newline or 'unnecessary spaces + newLine'
1767
+ if (input.substring(quoteSearch + 1 + spacesBetweenQuoteAndNewLine, quoteSearch + 1 + spacesBetweenQuoteAndNewLine + newlineLen) === newline)
1768
+ {
1769
+ row.push(input.substring(cursor, quoteSearch).replace(quoteCharRegex, quoteChar));
1770
+ saveRow(quoteSearch + 1 + spacesBetweenQuoteAndNewLine + newlineLen);
1771
+ nextDelim = input.indexOf(delim, cursor); // because we may have skipped the nextDelim in the quoted field
1772
+ quoteSearch = input.indexOf(quoteChar, cursor); // we search for first quote in next line
1773
+
1774
+ if (stepIsFunction)
1775
+ {
1776
+ doStep();
1777
+ if (aborted)
1778
+ return returnable();
1779
+ }
1780
+
1781
+ if (preview && data.length >= preview)
1782
+ return returnable(true);
1783
+
1784
+ break;
1785
+ }
1786
+
1787
+
1788
+ // Checks for valid closing quotes are complete (escaped quotes or quote followed by EOF/delimiter/newline) -- assume these quotes are part of an invalid text string
1789
+ errors.push({
1790
+ type: 'Quotes',
1791
+ code: 'InvalidQuotes',
1792
+ message: 'Trailing quote on quoted field is malformed',
1793
+ row: data.length, // row has yet to be inserted
1794
+ index: cursor
1795
+ });
1796
+
1797
+ quoteSearch++;
1798
+ continue;
1799
+
1800
+ }
1801
+
1802
+ continue;
1803
+ }
1804
+
1805
+ // Comment found at start of new line
1806
+ if (comments && row.length === 0 && input.substring(cursor, cursor + commentsLen) === comments)
1807
+ {
1808
+ if (nextNewline === -1) // Comment ends at EOF
1809
+ return returnable();
1810
+ cursor = nextNewline + newlineLen;
1811
+ nextNewline = input.indexOf(newline, cursor);
1812
+ nextDelim = input.indexOf(delim, cursor);
1813
+ continue;
1814
+ }
1815
+
1816
+ // Next delimiter comes before next newline, so we've reached end of field
1817
+ if (nextDelim !== -1 && (nextDelim < nextNewline || nextNewline === -1))
1818
+ {
1819
+ row.push(input.substring(cursor, nextDelim));
1820
+ cursor = nextDelim + delimLen;
1821
+ // we look for next delimiter char
1822
+ nextDelim = input.indexOf(delim, cursor);
1823
+ continue;
1824
+ }
1825
+
1826
+ // End of row
1827
+ if (nextNewline !== -1)
1828
+ {
1829
+ row.push(input.substring(cursor, nextNewline));
1830
+ saveRow(nextNewline + newlineLen);
1831
+
1832
+ if (stepIsFunction)
1833
+ {
1834
+ doStep();
1835
+ if (aborted)
1836
+ return returnable();
1837
+ }
1838
+
1839
+ if (preview && data.length >= preview)
1840
+ return returnable(true);
1841
+
1842
+ continue;
1843
+ }
1844
+
1845
+ break;
1846
+ }
1847
+
1848
+
1849
+ return finish();
1850
+
1851
+
1852
+ function pushRow(row)
1853
+ {
1854
+ data.push(row);
1855
+ lastCursor = cursor;
1856
+ }
1857
+
1858
+ /**
1859
+ * checks if there are extra spaces after closing quote and given index without any text
1860
+ * if Yes, returns the number of spaces
1861
+ */
1862
+ function extraSpaces(index) {
1863
+ var spaceLength = 0;
1864
+ if (index !== -1) {
1865
+ var textBetweenClosingQuoteAndIndex = input.substring(quoteSearch + 1, index);
1866
+ if (textBetweenClosingQuoteAndIndex && textBetweenClosingQuoteAndIndex.trim() === '') {
1867
+ spaceLength = textBetweenClosingQuoteAndIndex.length;
1868
+ }
1869
+ }
1870
+ return spaceLength;
1871
+ }
1872
+
1873
+ /**
1874
+ * Appends the remaining input from cursor to the end into
1875
+ * row, saves the row, calls step, and returns the results.
1876
+ */
1877
+ function finish(value)
1878
+ {
1879
+ if (ignoreLastRow)
1880
+ return returnable();
1881
+ if (typeof value === 'undefined')
1882
+ value = input.substring(cursor);
1883
+ row.push(value);
1884
+ cursor = inputLen; // important in case parsing is paused
1885
+ pushRow(row);
1886
+ if (stepIsFunction)
1887
+ doStep();
1888
+ return returnable();
1889
+ }
1890
+
1891
+ /**
1892
+ * Appends the current row to the results. It sets the cursor
1893
+ * to newCursor and finds the nextNewline. The caller should
1894
+ * take care to execute user's step function and check for
1895
+ * preview and end parsing if necessary.
1896
+ */
1897
+ function saveRow(newCursor)
1898
+ {
1899
+ cursor = newCursor;
1900
+ pushRow(row);
1901
+ row = [];
1902
+ nextNewline = input.indexOf(newline, cursor);
1903
+ }
1904
+
1905
+ /** Returns an object with the results, errors, and meta. */
1906
+ function returnable(stopped)
1907
+ {
1908
+ return {
1909
+ data: data,
1910
+ errors: errors,
1911
+ meta: {
1912
+ delimiter: delim,
1913
+ linebreak: newline,
1914
+ aborted: aborted,
1915
+ truncated: !!stopped,
1916
+ cursor: lastCursor + (baseIndex || 0)
1917
+ }
1918
+ };
1919
+ }
1920
+
1921
+ /** Executes the user's step function and resets data & errors. */
1922
+ function doStep()
1923
+ {
1924
+ step(returnable());
1925
+ data = [];
1926
+ errors = [];
1927
+ }
1928
+ };
1929
+
1930
+ /** Sets the abort flag */
1931
+ this.abort = function()
1932
+ {
1933
+ aborted = true;
1934
+ };
1935
+
1936
+ /** Gets the cursor position */
1937
+ this.getCharIndex = function()
1938
+ {
1939
+ return cursor;
1940
+ };
1941
+ }
1942
+
1943
+
1944
+ function newWorker()
1945
+ {
1946
+ if (!Papa.WORKERS_SUPPORTED)
1947
+ return false;
1948
+
1949
+ var workerUrl = getWorkerBlob();
1950
+ var w = new global.Worker(workerUrl);
1951
+ w.onmessage = mainThreadReceivedMessage;
1952
+ w.id = workerIdCounter++;
1953
+ workers[w.id] = w;
1954
+ return w;
1955
+ }
1956
+
1957
+ /** Callback when main thread receives a message */
1958
+ function mainThreadReceivedMessage(e)
1959
+ {
1960
+ var msg = e.data;
1961
+ var worker = workers[msg.workerId];
1962
+ var aborted = false;
1963
+
1964
+ if (msg.error)
1965
+ worker.userError(msg.error, msg.file);
1966
+ else if (msg.results && msg.results.data)
1967
+ {
1968
+ var abort = function() {
1969
+ aborted = true;
1970
+ completeWorker(msg.workerId, { data: [], errors: [], meta: { aborted: true } });
1971
+ };
1972
+
1973
+ var handle = {
1974
+ abort: abort,
1975
+ pause: notImplemented,
1976
+ resume: notImplemented
1977
+ };
1978
+
1979
+ if (isFunction(worker.userStep))
1980
+ {
1981
+ for (var i = 0; i < msg.results.data.length; i++)
1982
+ {
1983
+ worker.userStep({
1984
+ data: msg.results.data[i],
1985
+ errors: msg.results.errors,
1986
+ meta: msg.results.meta
1987
+ }, handle);
1988
+ if (aborted)
1989
+ break;
1990
+ }
1991
+ delete msg.results; // free memory ASAP
1992
+ }
1993
+ else if (isFunction(worker.userChunk))
1994
+ {
1995
+ worker.userChunk(msg.results, handle, msg.file);
1996
+ delete msg.results;
1997
+ }
1998
+ }
1999
+
2000
+ if (msg.finished && !aborted)
2001
+ completeWorker(msg.workerId, msg.results);
2002
+ }
2003
+
2004
+ function completeWorker(workerId, results) {
2005
+ var worker = workers[workerId];
2006
+ if (isFunction(worker.userComplete))
2007
+ worker.userComplete(results);
2008
+ worker.terminate();
2009
+ delete workers[workerId];
2010
+ }
2011
+
2012
+ function notImplemented() {
2013
+ throw new Error('Not implemented.');
2014
+ }
2015
+
2016
+ /** Callback when worker thread receives a message */
2017
+ function workerThreadReceivedMessage(e)
2018
+ {
2019
+ var msg = e.data;
2020
+
2021
+ if (typeof Papa.WORKER_ID === 'undefined' && msg)
2022
+ Papa.WORKER_ID = msg.workerId;
2023
+
2024
+ if (typeof msg.input === 'string')
2025
+ {
2026
+ global.postMessage({
2027
+ workerId: Papa.WORKER_ID,
2028
+ results: Papa.parse(msg.input, msg.config),
2029
+ finished: true
2030
+ });
2031
+ }
2032
+ else if ((global.File && msg.input instanceof File) || msg.input instanceof Object) // thank you, Safari (see issue #106)
2033
+ {
2034
+ var results = Papa.parse(msg.input, msg.config);
2035
+ if (results)
2036
+ global.postMessage({
2037
+ workerId: Papa.WORKER_ID,
2038
+ results: results,
2039
+ finished: true
2040
+ });
2041
+ }
2042
+ }
2043
+
2044
+ /** Makes a deep copy of an array or object (mostly) */
2045
+ function copy(obj)
2046
+ {
2047
+ if (typeof obj !== 'object' || obj === null)
2048
+ return obj;
2049
+ var cpy = Array.isArray(obj) ? [] : {};
2050
+ for (var key in obj)
2051
+ cpy[key] = copy(obj[key]);
2052
+ return cpy;
2053
+ }
2054
+
2055
+ function bindFunction(f, self)
2056
+ {
2057
+ return function() { f.apply(self, arguments); };
2058
+ }
2059
+
2060
+ function isFunction(func)
2061
+ {
2062
+ return typeof func === 'function';
2063
+ }
2064
+
2065
+ return Papa;
2066
+ }));
2067
+ } (papaparse));
2068
+
2069
+ var Papa = papaparse.exports;
2070
+
153
2071
  var isValidEmail = function isValidEmail(email) {
154
2072
  return string().email().isValidSync(email);
155
2073
  };