@loaders.gl/csv 4.2.0-alpha.3 → 4.2.0-alpha.5

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.
package/dist/dist.dev.js CHANGED
@@ -2,14 +2,19 @@
2
2
  if (typeof exports === 'object' && typeof module === 'object')
3
3
  module.exports = factory();
4
4
  else if (typeof define === 'function' && define.amd) define([], factory);
5
- else if (typeof exports === 'object') exports['loader'] = factory();
6
- else root['loader'] = factory();})(globalThis, function () {
5
+ else if (typeof exports === 'object') exports['loaders'] = factory();
6
+ else root['loaders'] = factory();})(globalThis, function () {
7
7
  "use strict";
8
8
  var __exports__ = (() => {
9
+ var __create = Object.create;
9
10
  var __defProp = Object.defineProperty;
10
11
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
11
12
  var __getOwnPropNames = Object.getOwnPropertyNames;
13
+ var __getProtoOf = Object.getPrototypeOf;
12
14
  var __hasOwnProp = Object.prototype.hasOwnProperty;
15
+ var __commonJS = (cb, mod) => function __require() {
16
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
17
+ };
13
18
  var __export = (target, all) => {
14
19
  for (var name in all)
15
20
  __defProp(target, name, { get: all[name], enumerable: true });
@@ -22,23 +27,40 @@ var __exports__ = (() => {
22
27
  }
23
28
  return to;
24
29
  };
30
+ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
31
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
32
+ // If the importer is in node compatibility mode or this is not an ESM
33
+ // file that has been converted to a CommonJS file using a Babel-
34
+ // compatible transform (i.e. "__esModule" has not been set), then set
35
+ // "default" to the CommonJS "module.exports" for node compatibility.
36
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
37
+ mod
38
+ ));
25
39
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
26
40
 
27
- // src/index.ts
28
- var src_exports = {};
29
- __export(src_exports, {
41
+ // external-global-plugin:@loaders.gl/core
42
+ var require_core = __commonJS({
43
+ "external-global-plugin:@loaders.gl/core"(exports, module) {
44
+ module.exports = globalThis.loaders;
45
+ }
46
+ });
47
+
48
+ // bundle.ts
49
+ var bundle_exports = {};
50
+ __export(bundle_exports, {
30
51
  CSVLoader: () => CSVLoader,
31
52
  CSVWriter: () => CSVWriter
32
53
  });
54
+ __reExport(bundle_exports, __toESM(require_core(), 1));
33
55
 
34
56
  // ../schema/src/lib/table/batches/base-table-batch-aggregator.ts
35
57
  var DEFAULT_ROW_COUNT = 100;
36
58
  var BaseTableBatchAggregator = class {
37
- length = 0;
38
- rows = null;
39
- cursor = 0;
40
- _headers = [];
41
59
  constructor(schema, options) {
60
+ this.length = 0;
61
+ this.rows = null;
62
+ this.cursor = 0;
63
+ this._headers = [];
42
64
  this.options = options;
43
65
  this.schema = schema;
44
66
  if (!Array.isArray(schema)) {
@@ -134,12 +156,12 @@ var __exports__ = (() => {
134
156
  // ../schema/src/lib/table/batches/row-table-batch-aggregator.ts
135
157
  var DEFAULT_ROW_COUNT2 = 100;
136
158
  var RowTableBatchAggregator = class {
137
- length = 0;
138
- objectRows = null;
139
- arrayRows = null;
140
- cursor = 0;
141
- _headers = null;
142
159
  constructor(schema, options) {
160
+ this.length = 0;
161
+ this.objectRows = null;
162
+ this.arrayRows = null;
163
+ this.cursor = 0;
164
+ this._headers = null;
143
165
  this.options = options;
144
166
  this.schema = schema;
145
167
  if (schema) {
@@ -199,6 +221,7 @@ var __exports__ = (() => {
199
221
  batchType: "data",
200
222
  data: rows,
201
223
  length: this.length,
224
+ // @ts-expect-error we should infer a schema
202
225
  schema: this.schema,
203
226
  cursor: this.cursor
204
227
  };
@@ -208,10 +231,10 @@ var __exports__ = (() => {
208
231
  // ../schema/src/lib/table/batches/columnar-table-batch-aggregator.ts
209
232
  var DEFAULT_ROW_COUNT3 = 100;
210
233
  var ColumnarTableBatchAggregator = class {
211
- length = 0;
212
- allocated = 0;
213
- columns = {};
214
234
  constructor(schema, options) {
235
+ this.length = 0;
236
+ this.allocated = 0;
237
+ this.columns = {};
215
238
  this.schema = schema;
216
239
  this._reallocateColumns();
217
240
  }
@@ -252,6 +275,7 @@ var __exports__ = (() => {
252
275
  };
253
276
  return batch;
254
277
  }
278
+ // HELPERS
255
279
  _reallocateColumns() {
256
280
  if (this.length < this.allocated) {
257
281
  return;
@@ -291,20 +315,17 @@ var __exports__ = (() => {
291
315
  };
292
316
  var ERR_MESSAGE = "TableBatchBuilder";
293
317
  var TableBatchBuilder = class {
294
- aggregator = null;
295
- batchCount = 0;
296
- bytesUsed = 0;
297
- isChunkComplete = false;
298
- lastBatchEmittedMs = Date.now();
299
- totalLength = 0;
300
- totalBytes = 0;
301
- rowBytes = 0;
302
318
  constructor(schema, options) {
319
+ this.aggregator = null;
320
+ this.batchCount = 0;
321
+ this.bytesUsed = 0;
322
+ this.isChunkComplete = false;
323
+ this.lastBatchEmittedMs = Date.now();
324
+ this.totalLength = 0;
325
+ this.totalBytes = 0;
326
+ this.rowBytes = 0;
303
327
  this.schema = schema;
304
- this.options = {
305
- ...DEFAULT_OPTIONS,
306
- ...options
307
- };
328
+ this.options = { ...DEFAULT_OPTIONS, ...options };
308
329
  }
309
330
  limitReached() {
310
331
  if (Boolean(this.options?.limit) && this.totalLength >= this.options.limit) {
@@ -315,6 +336,7 @@ var __exports__ = (() => {
315
336
  }
316
337
  return false;
317
338
  }
339
+ /** @deprecated Use addArrayRow or addObjectRow */
318
340
  addRow(row) {
319
341
  if (this.limitReached()) {
320
342
  return;
@@ -328,6 +350,7 @@ var __exports__ = (() => {
328
350
  this.addObjectRow(row);
329
351
  }
330
352
  }
353
+ /** Add one row to the batch */
331
354
  addArrayRow(row) {
332
355
  if (!this.aggregator) {
333
356
  const TableBatchType = this._getTableBatchType();
@@ -335,6 +358,7 @@ var __exports__ = (() => {
335
358
  }
336
359
  this.aggregator.addArrayRow(row);
337
360
  }
361
+ /** Add one row to the batch */
338
362
  addObjectRow(row) {
339
363
  if (!this.aggregator) {
340
364
  const TableBatchType = this._getTableBatchType();
@@ -342,6 +366,7 @@ var __exports__ = (() => {
342
366
  }
343
367
  this.aggregator.addObjectRow(row);
344
368
  }
369
+ /** Mark an incoming raw memory chunk has completed */
345
370
  chunkComplete(chunk) {
346
371
  if (chunk instanceof ArrayBuffer) {
347
372
  this.bytesUsed += chunk.byteLength;
@@ -357,6 +382,7 @@ var __exports__ = (() => {
357
382
  getFinalBatch(options) {
358
383
  return this._getBatch(options);
359
384
  }
385
+ // INTERNAL
360
386
  _estimateRowMB(row) {
361
387
  return Array.isArray(row) ? row.length * 8 : Object.keys(row).length * 8;
362
388
  }
@@ -378,6 +404,9 @@ var __exports__ = (() => {
378
404
  this.lastBatchEmittedMs = Date.now();
379
405
  return true;
380
406
  }
407
+ /**
408
+ * bytesUsed can be set via chunkComplete or via getBatch*
409
+ */
381
410
  _getBatch(options) {
382
411
  if (!this.aggregator) {
383
412
  return null;
@@ -529,9 +558,7 @@ var __exports__ = (() => {
529
558
  }
530
559
  close() {
531
560
  while (this._settlers.length > 0) {
532
- this._settlers.dequeue().resolve({
533
- done: true
534
- });
561
+ this._settlers.dequeue().resolve({ done: true });
535
562
  }
536
563
  this._closed = true;
537
564
  }
@@ -550,37 +577,31 @@ var __exports__ = (() => {
550
577
  if (value instanceof Error) {
551
578
  settler.reject(value);
552
579
  } else {
553
- settler.resolve({
554
- value
555
- });
580
+ settler.resolve({ value });
556
581
  }
557
582
  } else {
558
583
  this._values.enqueue(value);
559
584
  }
560
585
  }
586
+ /**
587
+ * @returns a Promise for an IteratorResult
588
+ */
561
589
  next() {
562
590
  if (this._values.length > 0) {
563
591
  const value = this._values.dequeue();
564
592
  if (value instanceof Error) {
565
593
  return Promise.reject(value);
566
594
  }
567
- return Promise.resolve({
568
- value
569
- });
595
+ return Promise.resolve({ value });
570
596
  }
571
597
  if (this._closed) {
572
598
  if (this._settlers.length > 0) {
573
599
  throw new Error("Illegal internal state");
574
600
  }
575
- return Promise.resolve({
576
- done: true
577
- });
601
+ return Promise.resolve({ done: true });
578
602
  }
579
603
  return new Promise((resolve, reject) => {
580
- this._settlers.enqueue({
581
- resolve,
582
- reject
583
- });
604
+ this._settlers.enqueue({ resolve, reject });
584
605
  });
585
606
  }
586
607
  };
@@ -595,12 +616,19 @@ var __exports__ = (() => {
595
616
  BYTE_ORDER_MARK,
596
617
  BAD_DELIMITERS: ["\r", "\n", '"', BYTE_ORDER_MARK],
597
618
  WORKERS_SUPPORTED: false,
619
+ // !IS_WORKER && !!globalThis.Worker
598
620
  NODE_STREAM_INPUT: 1,
621
+ // Configurable chunk sizes for local and remote files, respectively
599
622
  LocalChunkSize: 1024 * 1024 * 10,
623
+ // 10 M,
600
624
  RemoteChunkSize: 1024 * 1024 * 5,
625
+ // 5 M,
601
626
  DefaultDelimiter: ",",
627
+ // Used if not specified and detection fail,
628
+ // Exposed for testing and development only
602
629
  Parser,
603
630
  ParserHandle,
631
+ // BEGIN FORK
604
632
  ChunkStreamer,
605
633
  StringStreamer
606
634
  };
@@ -874,6 +902,7 @@ var __exports__ = (() => {
874
902
  var _delimiterError;
875
903
  var _fields = [];
876
904
  var _results = {
905
+ // The last results returned from the parser
877
906
  data: [],
878
907
  errors: [],
879
908
  meta: {}
@@ -902,7 +931,13 @@ var __exports__ = (() => {
902
931
  _config.newline = guessLineEndings(input, quoteChar);
903
932
  _delimiterError = false;
904
933
  if (!_config.delimiter) {
905
- var delimGuess = guessDelimiter(input, _config.newline, _config.skipEmptyLines, _config.comments, _config.delimitersToGuess);
934
+ var delimGuess = guessDelimiter(
935
+ input,
936
+ _config.newline,
937
+ _config.skipEmptyLines,
938
+ _config.comments,
939
+ _config.delimitersToGuess
940
+ );
906
941
  if (delimGuess.successful)
907
942
  _config.delimiter = delimGuess.bestDelimiter;
908
943
  else {
@@ -921,15 +956,7 @@ var __exports__ = (() => {
921
956
  _parser = new Parser(parserConfig);
922
957
  _results = _parser.parse(_input, baseIndex, ignoreLastRow);
923
958
  processResults();
924
- return _paused ? {
925
- meta: {
926
- paused: true
927
- }
928
- } : _results || {
929
- meta: {
930
- paused: false
931
- }
932
- };
959
+ return _paused ? { meta: { paused: true } } : _results || { meta: { paused: false } };
933
960
  };
934
961
  this.paused = function() {
935
962
  return _paused;
@@ -959,7 +986,11 @@ var __exports__ = (() => {
959
986
  }
960
987
  function processResults() {
961
988
  if (_results && _delimiterError) {
962
- addError("Delimiter", "UndetectableDelimiter", "Unable to auto-detect delimiting character; defaulted to '" + Papa.DefaultDelimiter + "'");
989
+ addError(
990
+ "Delimiter",
991
+ "UndetectableDelimiter",
992
+ "Unable to auto-detect delimiting character; defaulted to '" + Papa.DefaultDelimiter + "'"
993
+ );
963
994
  _delimiterError = false;
964
995
  }
965
996
  if (_config.skipEmptyLines) {
@@ -1032,9 +1063,19 @@ var __exports__ = (() => {
1032
1063
  }
1033
1064
  if (_config.header) {
1034
1065
  if (j > _fields.length)
1035
- addError("FieldMismatch", "TooManyFields", "Too many fields: expected " + _fields.length + " fields but parsed " + j, _rowCounter + i);
1066
+ addError(
1067
+ "FieldMismatch",
1068
+ "TooManyFields",
1069
+ "Too many fields: expected " + _fields.length + " fields but parsed " + j,
1070
+ _rowCounter + i
1071
+ );
1036
1072
  else if (j < _fields.length)
1037
- addError("FieldMismatch", "TooFewFields", "Too few fields: expected " + _fields.length + " fields but parsed " + j, _rowCounter + i);
1073
+ addError(
1074
+ "FieldMismatch",
1075
+ "TooFewFields",
1076
+ "Too few fields: expected " + _fields.length + " fields but parsed " + j,
1077
+ _rowCounter + i
1078
+ );
1038
1079
  }
1039
1080
  return row;
1040
1081
  }
@@ -1200,6 +1241,7 @@ var __exports__ = (() => {
1200
1241
  code: "MissingQuotes",
1201
1242
  message: "Quoted field unterminated",
1202
1243
  row: data.length,
1244
+ // row has yet to be inserted
1203
1245
  index: cursor
1204
1246
  });
1205
1247
  }
@@ -1251,6 +1293,7 @@ var __exports__ = (() => {
1251
1293
  code: "InvalidQuotes",
1252
1294
  message: "Trailing quote on quoted field is malformed",
1253
1295
  row: data.length,
1296
+ // row has yet to be inserted
1254
1297
  index: cursor
1255
1298
  });
1256
1299
  quoteSearch++;
@@ -1366,9 +1409,7 @@ var __exports__ = (() => {
1366
1409
  }
1367
1410
 
1368
1411
  // src/papaparse/async-iterator-streamer.ts
1369
- var {
1370
- ChunkStreamer: ChunkStreamer2
1371
- } = papaparse_default;
1412
+ var { ChunkStreamer: ChunkStreamer2 } = papaparse_default;
1372
1413
  function AsyncIteratorStreamer(config) {
1373
1414
  config = config || {};
1374
1415
  ChunkStreamer2.call(this, config);
@@ -1388,16 +1429,14 @@ var __exports__ = (() => {
1388
1429
  this._nextChunk = function nextChunk() {
1389
1430
  };
1390
1431
  this.getStringChunk = function(chunk) {
1391
- return typeof chunk === "string" ? chunk : this.textDecoder.decode(chunk, {
1392
- stream: true
1393
- });
1432
+ return typeof chunk === "string" ? chunk : this.textDecoder.decode(chunk, { stream: true });
1394
1433
  };
1395
1434
  }
1396
1435
  AsyncIteratorStreamer.prototype = Object.create(ChunkStreamer2.prototype);
1397
1436
  AsyncIteratorStreamer.prototype.constructor = AsyncIteratorStreamer;
1398
1437
 
1399
1438
  // src/csv-loader.ts
1400
- var VERSION = true ? "4.2.0-alpha.3" : "latest";
1439
+ var VERSION = typeof __VERSION__ !== "undefined" ? __VERSION__ : "latest";
1401
1440
  var DEFAULT_CSV_SHAPE = "object-row-table";
1402
1441
  var CSVLoader = {
1403
1442
  id: "csv",
@@ -1410,33 +1449,40 @@ var __exports__ = (() => {
1410
1449
  parse: async (arrayBuffer, options) => parseCSV(new TextDecoder().decode(arrayBuffer), options),
1411
1450
  parseText: (text, options) => parseCSV(text, options),
1412
1451
  parseInBatches: parseCSVInBatches,
1452
+ // @ts-ignore
1453
+ // testText: null,
1413
1454
  options: {
1414
1455
  csv: {
1415
1456
  shape: DEFAULT_CSV_SHAPE,
1457
+ // 'object-row-table'
1416
1458
  optimizeMemoryUsage: false,
1459
+ // CSV options
1417
1460
  header: "auto",
1418
1461
  columnPrefix: "column",
1462
+ // delimiter: auto
1463
+ // newline: auto
1419
1464
  quoteChar: '"',
1420
1465
  escapeChar: '"',
1421
1466
  dynamicTyping: true,
1422
1467
  comments: false,
1423
1468
  skipEmptyLines: true,
1469
+ // transform: null?
1424
1470
  delimitersToGuess: [",", " ", "|", ";"]
1471
+ // fastMode: auto
1425
1472
  }
1426
1473
  }
1427
1474
  };
1428
1475
  async function parseCSV(csvText, options) {
1429
- const csvOptions = {
1430
- ...CSVLoader.options.csv,
1431
- ...options?.csv
1432
- };
1476
+ const csvOptions = { ...CSVLoader.options.csv, ...options?.csv };
1433
1477
  const firstRow = readFirstRow(csvText);
1434
1478
  const header = csvOptions.header === "auto" ? isHeaderRow(firstRow) : Boolean(csvOptions.header);
1435
1479
  const parseWithHeader = header;
1436
1480
  const papaparseConfig = {
1481
+ // dynamicTyping: true,
1437
1482
  ...csvOptions,
1438
1483
  header: parseWithHeader,
1439
1484
  download: false,
1485
+ // We handle loading, no need for papaparse to do it for us
1440
1486
  transformHeader: parseWithHeader ? duplicateColumnTransformer() : void 0,
1441
1487
  error: (e) => {
1442
1488
  throw new Error(e);
@@ -1462,27 +1508,35 @@ var __exports__ = (() => {
1462
1508
  }
1463
1509
  }
1464
1510
  function parseCSVInBatches(asyncIterator, options) {
1465
- options = {
1466
- ...options
1467
- };
1511
+ options = { ...options };
1468
1512
  if (options.batchSize === "auto") {
1469
1513
  options.batchSize = 4e3;
1470
1514
  }
1471
- const csvOptions = {
1472
- ...CSVLoader.options.csv,
1473
- ...options?.csv
1474
- };
1515
+ const csvOptions = { ...CSVLoader.options.csv, ...options?.csv };
1475
1516
  const asyncQueue = new AsyncQueue();
1476
1517
  let isFirstRow = true;
1477
1518
  let headerRow = null;
1478
1519
  let tableBatchBuilder = null;
1479
1520
  let schema = null;
1480
1521
  const config = {
1522
+ // dynamicTyping: true, // Convert numbers and boolean values in rows from strings,
1481
1523
  ...csvOptions,
1482
1524
  header: false,
1525
+ // Unfortunately, header detection is not automatic and does not infer shapes
1483
1526
  download: false,
1527
+ // We handle loading, no need for papaparse to do it for us
1528
+ // chunkSize is set to 5MB explicitly (same as Papaparse default) due to a bug where the
1529
+ // streaming parser gets stuck if skipEmptyLines and a step callback are both supplied.
1530
+ // See https://github.com/mholt/PapaParse/issues/465
1484
1531
  chunkSize: 1024 * 1024 * 5,
1532
+ // skipEmptyLines is set to a boolean value if supplied. Greedy is set to true
1533
+ // skipEmptyLines is handled manually given two bugs where the streaming parser gets stuck if
1534
+ // both of the skipEmptyLines and step callback options are provided:
1535
+ // - true doesn't work unless chunkSize is set: https://github.com/mholt/PapaParse/issues/465
1536
+ // - greedy doesn't work: https://github.com/mholt/PapaParse/issues/825
1485
1537
  skipEmptyLines: false,
1538
+ // step is called on every row
1539
+ // eslint-disable-next-line complexity, max-statements
1486
1540
  step(results) {
1487
1541
  let row = results.data;
1488
1542
  if (csvOptions.skipEmptyLines) {
@@ -1510,15 +1564,17 @@ var __exports__ = (() => {
1510
1564
  row = JSON.parse(JSON.stringify(row));
1511
1565
  }
1512
1566
  const shape = csvOptions.shape || DEFAULT_CSV_SHAPE;
1513
- tableBatchBuilder = tableBatchBuilder || new TableBatchBuilder(schema, {
1514
- shape,
1515
- ...options
1516
- });
1567
+ tableBatchBuilder = tableBatchBuilder || new TableBatchBuilder(
1568
+ // @ts-expect-error TODO this is not a proper schema
1569
+ schema,
1570
+ {
1571
+ shape,
1572
+ ...options
1573
+ }
1574
+ );
1517
1575
  try {
1518
1576
  tableBatchBuilder.addRow(row);
1519
- const batch = tableBatchBuilder && tableBatchBuilder.getFullBatch({
1520
- bytesUsed
1521
- });
1577
+ const batch = tableBatchBuilder && tableBatchBuilder.getFullBatch({ bytesUsed });
1522
1578
  if (batch) {
1523
1579
  asyncQueue.enqueue(batch);
1524
1580
  }
@@ -1526,12 +1582,11 @@ var __exports__ = (() => {
1526
1582
  asyncQueue.enqueue(error);
1527
1583
  }
1528
1584
  },
1585
+ // complete is called when all rows have been read
1529
1586
  complete(results) {
1530
1587
  try {
1531
1588
  const bytesUsed = results.meta.cursor;
1532
- const batch = tableBatchBuilder && tableBatchBuilder.getFinalBatch({
1533
- bytesUsed
1534
- });
1589
+ const batch = tableBatchBuilder && tableBatchBuilder.getFinalBatch({ bytesUsed });
1535
1590
  if (batch) {
1536
1591
  asyncQueue.enqueue(batch);
1537
1592
  }
@@ -1583,19 +1638,11 @@ var __exports__ = (() => {
1583
1638
  switch (typeof value) {
1584
1639
  case "number":
1585
1640
  case "boolean":
1586
- schema[columnName] = {
1587
- name: String(columnName),
1588
- index: i,
1589
- type: Float32Array
1590
- };
1641
+ schema[columnName] = { name: String(columnName), index: i, type: Float32Array };
1591
1642
  break;
1592
1643
  case "string":
1593
1644
  default:
1594
- schema[columnName] = {
1595
- name: String(columnName),
1596
- index: i,
1597
- type: Array
1598
- };
1645
+ schema[columnName] = { name: String(columnName), index: i, type: Array };
1599
1646
  }
1600
1647
  }
1601
1648
  return schema;
@@ -1748,11 +1795,7 @@ var __exports__ = (() => {
1748
1795
  var csvFormatValue = csv.formatValue;
1749
1796
 
1750
1797
  // src/lib/encoders/encode-csv.ts
1751
- function encodeTableAsCSV(table, options = {
1752
- csv: {
1753
- useDisplayNames: true
1754
- }
1755
- }) {
1798
+ function encodeTableAsCSV(table, options = { csv: { useDisplayNames: true } }) {
1756
1799
  const useDisplayNames = options.useDisplayNames || options.csv?.useDisplayNames;
1757
1800
  const fields = table.schema?.fields || [];
1758
1801
  const columnNames = fields.map((f) => {
@@ -1800,7 +1843,7 @@ var __exports__ = (() => {
1800
1843
  encode: async (table, options) => new TextEncoder().encode(encodeTableAsCSV(table, options)).buffer,
1801
1844
  encodeTextSync: (table, options) => encodeTableAsCSV(table, options)
1802
1845
  };
1803
- return __toCommonJS(src_exports);
1846
+ return __toCommonJS(bundle_exports);
1804
1847
  })();
1805
1848
  /* @license
1806
1849
  Papa Parse
@@ -0,0 +1,28 @@
1
+ (function webpackUniversalModuleDefinition(root, factory) {
2
+ if (typeof exports === 'object' && typeof module === 'object')
3
+ module.exports = factory();
4
+ else if (typeof define === 'function' && define.amd) define([], factory);
5
+ else if (typeof exports === 'object') exports['loaders'] = factory();
6
+ else root['loaders'] = factory();})(globalThis, function () {
7
+ "use strict";var __exports__=(()=>{var Pe=Object.create;var se=Object.defineProperty;var qe=Object.getOwnPropertyDescriptor;var ze=Object.getOwnPropertyNames;var He=Object.getPrototypeOf,Ve=Object.prototype.hasOwnProperty;var We=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),Je=(t,e)=>{for(var r in e)se(t,r,{get:e[r],enumerable:!0})},re=(t,e,r,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of ze(e))!Ve.call(t,o)&&o!==r&&se(t,o,{get:()=>e[o],enumerable:!(s=qe(e,o))||s.enumerable});return t},ae=(t,e,r)=>(re(t,e,"default"),r&&re(r,e,"default")),$e=(t,e,r)=>(r=t!=null?Pe(He(t)):{},re(e||!t||!t.__esModule?se(r,"default",{value:t,enumerable:!0}):r,t)),Ze=t=>re(se({},"__esModule",{value:!0}),t);var Re=We((mt,Te)=>{Te.exports=globalThis.loaders});var ee={};Je(ee,{CSVLoader:()=>le,CSVWriter:()=>Le});ae(ee,$e(Re(),1));var ne=class{constructor(e,r){if(this.length=0,this.rows=null,this.cursor=0,this._headers=[],this.options=r,this.schema=e,!Array.isArray(e)){this._headers=[];for(let s in e)this._headers[e[s].index]=e[s].name}}rowCount(){return this.length}addArrayRow(e,r){Number.isFinite(r)&&(this.cursor=r),this.shape="array-row-table",this.rows=this.rows||new Array(100),this.rows[this.length]=e,this.length++}addObjectRow(e,r){Number.isFinite(r)&&(this.cursor=r),this.shape="object-row-table",this.rows=this.rows||new Array(100),this.rows[this.length]=e,this.length++}getBatch(){let e=this.rows;return e?(e=e.slice(0,this.length),this.rows=null,{shape:this.shape||"array-row-table",batchType:"data",data:e,length:this.length,schema:this.schema,cursor:this.cursor}):null}};function Q(t,e){if(!t)throw new Error("null row");let r={};if(e)for(let s=0;s<e.length;s++)r[e[s]]=t[s];else for(let s=0;s<t.length;s++){let o=`column-${s}`;r[o]=t[s]}return r}function Y(t,e){if(!t)throw new Error("null row");if(e){let r=new Array(e.length);for(let s=0;s<e.length;s++)r[s]=t[e[s]];return r}return Object.values(t)}function Ae(t){let e=[];for(let r=0;r<t.length;r++){let s=`column-${r}`;e.push(s)}return e}function Ce(t){return Object.keys(t)}var xe=100,oe=class{constructor(e,r){if(this.length=0,this.objectRows=null,this.arrayRows=null,this.cursor=0,this._headers=null,this.options=r,this.schema=e,e){this._headers=[];for(let s in e)this._headers[e[s].index]=e[s].name}}rowCount(){return this.length}addArrayRow(e,r){switch(Number.isFinite(r)&&(this.cursor=r),this._headers||(this._headers=Ae(e)),this.options.shape){case"object-row-table":let s=Q(e,this._headers);this.addObjectRow(s,r);break;case"array-row-table":this.arrayRows=this.arrayRows||new Array(xe),this.arrayRows[this.length]=e,this.length++;break}}addObjectRow(e,r){switch(Number.isFinite(r)&&(this.cursor=r),this._headers||(this._headers=Ce(e)),this.options.shape){case"array-row-table":let s=Y(e,this._headers);this.addArrayRow(s,r);break;case"object-row-table":this.objectRows=this.objectRows||new Array(xe),this.objectRows[this.length]=e,this.length++;break}}getBatch(){let e=this.arrayRows||this.objectRows;return e?(e=e.slice(0,this.length),this.arrayRows=null,this.objectRows=null,{shape:this.options.shape,batchType:"data",data:e,length:this.length,schema:this.schema,cursor:this.cursor}):null}};var ie=class{constructor(e,r){this.length=0,this.allocated=0,this.columns={},this.schema=e,this._reallocateColumns()}rowCount(){return this.length}addArrayRow(e){this._reallocateColumns();let r=0;for(let s in this.columns)this.columns[s][this.length]=e[r++];this.length++}addObjectRow(e){this._reallocateColumns();for(let r in e)this.columns[r][this.length]=e[r];this.length++}getBatch(){this._pruneColumns();let e=Array.isArray(this.schema)?this.columns:{};if(!Array.isArray(this.schema))for(let s in this.schema){let o=this.schema[s];e[o.name]=this.columns[o.index]}return this.columns={},{shape:"columnar-table",batchType:"data",data:e,schema:this.schema,length:this.length}}_reallocateColumns(){if(!(this.length<this.allocated)){this.allocated=this.allocated>0?this.allocated*=2:100,this.columns={};for(let e in this.schema){let r=this.schema[e],s=r.type||Float32Array,o=this.columns[r.index];if(o&&ArrayBuffer.isView(o)){let c=new s(this.allocated);c.set(o),this.columns[r.index]=c}else o?(o.length=this.allocated,this.columns[r.index]=o):this.columns[r.index]=new s(this.allocated)}}}_pruneColumns(){for(let[e,r]of Object.entries(this.columns))this.columns[e]=r.slice(0,this.length)}};var Ke={shape:void 0,batchSize:"auto",batchDebounceMs:0,limit:0,_limitMB:0},Qe="TableBatchBuilder",_=class{constructor(e,r){this.aggregator=null,this.batchCount=0,this.bytesUsed=0,this.isChunkComplete=!1,this.lastBatchEmittedMs=Date.now(),this.totalLength=0,this.totalBytes=0,this.rowBytes=0,this.schema=e,this.options={...Ke,...r}}limitReached(){return!!(Boolean(this.options?.limit)&&this.totalLength>=this.options.limit||Boolean(this.options?._limitMB)&&this.totalBytes/1e6>=this.options._limitMB)}addRow(e){this.limitReached()||(this.totalLength++,this.rowBytes=this.rowBytes||this._estimateRowMB(e),this.totalBytes+=this.rowBytes,Array.isArray(e)?this.addArrayRow(e):this.addObjectRow(e))}addArrayRow(e){if(!this.aggregator){let r=this._getTableBatchType();this.aggregator=new r(this.schema,this.options)}this.aggregator.addArrayRow(e)}addObjectRow(e){if(!this.aggregator){let r=this._getTableBatchType();this.aggregator=new r(this.schema,this.options)}this.aggregator.addObjectRow(e)}chunkComplete(e){e instanceof ArrayBuffer&&(this.bytesUsed+=e.byteLength),typeof e=="string"&&(this.bytesUsed+=e.length),this.isChunkComplete=!0}getFullBatch(e){return this._isFull()?this._getBatch(e):null}getFinalBatch(e){return this._getBatch(e)}_estimateRowMB(e){return Array.isArray(e)?e.length*8:Object.keys(e).length*8}_isFull(){if(!this.aggregator||this.aggregator.rowCount()===0)return!1;if(this.options.batchSize==="auto"){if(!this.isChunkComplete)return!1}else if(this.options.batchSize>this.aggregator.rowCount())return!1;return this.options.batchDebounceMs>Date.now()-this.lastBatchEmittedMs?!1:(this.isChunkComplete=!1,this.lastBatchEmittedMs=Date.now(),!0)}_getBatch(e){if(!this.aggregator)return null;e?.bytesUsed&&(this.bytesUsed=e.bytesUsed);let r=this.aggregator.getBatch();return r.count=this.batchCount,r.bytesUsed=this.bytesUsed,Object.assign(r,e),this.batchCount++,this.aggregator=null,r}_getTableBatchType(){switch(this.options.shape){case"array-row-table":case"object-row-table":return oe;case"columnar-table":return ie;case"arrow-table":if(!_.ArrowBatch)throw new Error(Qe);return _.ArrowBatch;default:return ne}}};function ce(t){switch(t.shape){case"array-row-table":case"object-row-table":return t.data.length;case"geojson-table":return t.features.length;case"arrow-table":return t.data.numRows;case"columnar-table":for(let r of Object.values(t.data))return r.length||0;return 0;default:throw new Error("table")}}function ue(t){if(t.schema)return t.schema.fields.length;if(ce(t)===0)throw new Error("empty table");switch(t.shape){case"array-row-table":return t.data[0].length;case"object-row-table":return Object.keys(t.data[0]).length;case"geojson-table":return Object.keys(t.features[0]).length;case"columnar-table":return Object.keys(t.data).length;case"arrow-table":return t.data.numCols;default:throw new Error("table")}}function Ee(t,e,r,s){switch(t.shape){case"array-row-table":return s?Array.from(t.data[e]):t.data[e];case"object-row-table":if(t.schema){let u=r||[];for(let n=0;n<t.schema.fields.length;n++)u[n]=t.data[e][t.schema.fields[n].name];return u}return Object.values(t.data[e]);case"geojson-table":if(t.schema){let u=r||[];for(let n=0;n<t.schema.fields.length;n++)u[n]=t.features[e][t.schema.fields[n].name];return u}return Object.values(t.features[e]);case"columnar-table":if(t.schema){let u=r||[];for(let n=0;n<t.schema.fields.length;n++)u[n]=t.data[t.schema.fields[n].name][e];return u}else{let u=r||[],n=0;for(let y of Object.values(t.data))u[n]=y[e],n++;return u}case"arrow-table":let o=t.data,c=r||[],l=o.get(e),d=o.schema;for(let u=0;u<d.fields.length;u++)c[u]=l?.[d.fields[u].name];return c;default:throw new Error("shape")}}function*fe(t,e=[]){let r=ce(t);for(let s=0;s<r;s++)yield Ee(t,s,e)}var he=class extends Array{enqueue(e){return this.push(e)}dequeue(){return this.shift()}},V=class{constructor(){this._values=new he,this._settlers=new he,this._closed=!1}close(){for(;this._settlers.length>0;)this._settlers.dequeue().resolve({done:!0});this._closed=!0}[Symbol.asyncIterator](){return this}enqueue(e){if(this._closed)throw new Error("Closed");if(this._settlers.length>0){if(this._values.length>0)throw new Error("Illegal internal state");let r=this._settlers.dequeue();e instanceof Error?r.reject(e):r.resolve({value:e})}else this._values.enqueue(e)}next(){if(this._values.length>0){let e=this._values.dequeue();return e instanceof Error?Promise.reject(e):Promise.resolve({value:e})}if(this._closed){if(this._settlers.length>0)throw new Error("Illegal internal state");return Promise.resolve({done:!0})}return new Promise((e,r)=>{this._settlers.enqueue({resolve:e,reject:r})})}};var je="\uFEFF",M={parse:Ye,unparse:Xe,RECORD_SEP:String.fromCharCode(30),UNIT_SEP:String.fromCharCode(31),BYTE_ORDER_MARK:je,BAD_DELIMITERS:["\r",`
8
+ `,'"',je],WORKERS_SUPPORTED:!1,NODE_STREAM_INPUT:1,LocalChunkSize:10485760,RemoteChunkSize:5242880,DefaultDelimiter:",",Parser:de,ParserHandle:Se,ChunkStreamer:Oe,StringStreamer:W},J=M;function Ye(t,e,r){e=e||{};var s=e.dynamicTyping||!1;if(N(s)&&(e.dynamicTypingFunction=s,s={}),e.dynamicTyping=s,e.transform=N(e.transform)?e.transform:!1,e.worker&&M.WORKERS_SUPPORTED){var o=newWorker();o.userStep=e.step,o.userChunk=e.chunk,o.userComplete=e.complete,o.userError=e.error,e.step=N(e.step),e.chunk=N(e.chunk),e.complete=N(e.complete),e.error=N(e.error),delete e.worker,o.postMessage({input:t,config:e,workerId:o.id});return}var c=null;return typeof t=="string"&&(c=new W(e)),c||(c=new r(e)),c.stream(t)}function Xe(t,e){var r=!1,s=!0,o=",",c=`\r
9
+ `,l='"',d=l+l,u=!1,n=null;a();var y=new RegExp(X(l),"g");if(typeof t=="string"&&(t=JSON.parse(t)),Array.isArray(t)){if(!t.length||Array.isArray(t[0]))return v(null,t,u);if(typeof t[0]=="object")return v(n||i(t[0]),t,u)}else if(typeof t=="object")return typeof t.data=="string"&&(t.data=JSON.parse(t.data)),Array.isArray(t.data)&&(t.fields||(t.fields=t.meta&&t.meta.fields),t.fields||(t.fields=Array.isArray(t.data[0])?t.fields:i(t.data[0])),!Array.isArray(t.data[0])&&typeof t.data[0]!="object"&&(t.data=[t.data])),v(t.fields||[],t.data||[],u);throw new Error("Unable to serialize unrecognized input");function a(){if(typeof e=="object"){if(typeof e.delimiter=="string"&&!M.BAD_DELIMITERS.filter(function(f){return e.delimiter.indexOf(f)!==-1}).length&&(o=e.delimiter),(typeof e.quotes=="boolean"||Array.isArray(e.quotes))&&(r=e.quotes),(typeof e.skipEmptyLines=="boolean"||typeof e.skipEmptyLines=="string")&&(u=e.skipEmptyLines),typeof e.newline=="string"&&(c=e.newline),typeof e.quoteChar=="string"&&(l=e.quoteChar),typeof e.header=="boolean"&&(s=e.header),Array.isArray(e.columns)){if(e.columns.length===0)throw new Error("Option columns is empty");n=e.columns}e.escapeChar!==void 0&&(d=e.escapeChar+l)}}function i(f){if(typeof f!="object")return[];var w=[];for(var T in f)w.push(T);return w}function v(f,w,T){var b="";typeof f=="string"&&(f=JSON.parse(f)),typeof w=="string"&&(w=JSON.parse(w));var D=Array.isArray(f)&&f.length>0,C=!Array.isArray(w[0]);if(D&&s){for(var B=0;B<f.length;B++)B>0&&(b+=o),b+=j(f[B],B);w.length>0&&(b+=c)}for(var x=0;x<w.length;x++){var h=D?f.length:w[x].length,m=!1,g=D?Object.keys(w[x]).length===0:w[x].length===0;if(T&&!D&&(m=T==="greedy"?w[x].join("").trim()==="":w[x].length===1&&w[x][0].length===0),T==="greedy"&&D){for(var S=[],p=0;p<h;p++){var R=C?f[p]:p;S.push(w[x][R])}m=S.join("").trim()===""}if(!m){for(var E=0;E<h;E++){E>0&&!g&&(b+=o);var k=D&&C?f[E]:E;b+=j(w[x][k],E)}x<w.length-1&&(!T||h>0&&!g)&&(b+=c)}}return b}function j(f,w){if(typeof f>"u"||f===null)return"";if(f.constructor===Date)return JSON.stringify(f).slice(1,25);f=f.toString().replace(y,d);var T=typeof r=="boolean"&&r||Array.isArray(r)&&r[w]||A(f,M.BAD_DELIMITERS)||f.indexOf(o)>-1||f.charAt(0)===" "||f.charAt(f.length-1)===" ";return T?l+f+l:f}function A(f,w){for(var T=0;T<w.length;T++)if(f.indexOf(w[T])>-1)return!0;return!1}}function Oe(t){this._handle=null,this._finished=!1,this._completed=!1,this._input=null,this._baseIndex=0,this._partialLine="",this._rowCount=0,this._start=0,this._nextChunk=null,this.isFirstChunk=!0,this._completeResults={data:[],errors:[],meta:{}},e.call(this,t),this.parseChunk=function(r,s){if(this.isFirstChunk&&N(this._config.beforeFirstChunk)){var o=this._config.beforeFirstChunk(r);o!==void 0&&(r=o)}this.isFirstChunk=!1;var c=this._partialLine+r;this._partialLine="";var l=this._handle.parse(c,this._baseIndex,!this._finished);if(!(this._handle.paused()||this._handle.aborted())){var d=l.meta.cursor;this._finished||(this._partialLine=c.substring(d-this._baseIndex),this._baseIndex=d),l&&l.data&&(this._rowCount+=l.data.length);var u=this._finished||this._config.preview&&this._rowCount>=this._config.preview;if(N(this._config.chunk)&&!s){if(this._config.chunk(l,this._handle),this._handle.paused()||this._handle.aborted())return;l=void 0,this._completeResults=void 0}return!this._config.step&&!this._config.chunk&&(this._completeResults.data=this._completeResults.data.concat(l.data),this._completeResults.errors=this._completeResults.errors.concat(l.errors),this._completeResults.meta=l.meta),!this._completed&&u&&N(this._config.complete)&&(!l||!l.meta.aborted)&&(this._config.complete(this._completeResults,this._input),this._completed=!0),!u&&(!l||!l.meta.paused)&&this._nextChunk(),l}},this._sendError=function(r){N(this._config.error)&&this._config.error(r)};function e(r){var s=me(r);s.chunkSize=parseInt(s.chunkSize),!r.step&&!r.chunk&&(s.chunkSize=null),this._handle=new Se(s),this._handle.streamer=this,this._config=s}}function W(t){t=t||{},Oe.call(this,t);var e;this.stream=function(r){return e=r,this._nextChunk()},this._nextChunk=function(){if(!this._finished){var r=this._config.chunkSize,s=r?e.substr(0,r):e;return e=r?e.substr(r):"",this._finished=!e,this.parseChunk(s)}}}W.prototype=Object.create(W.prototype);W.prototype.constructor=W;function Se(t){var e=/^\s*-?(\d*\.?\d+|\d+\.?\d*)(e[-+]?\d+)?\s*$/i,r=/(\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))/,s=this,o=0,c=0,l,d,u=!1,n=!1,y,a=[],i={data:[],errors:[],meta:{}};if(N(t.step)){var v=t.step;t.step=function(h){if(i=h,f())A();else{if(A(),!i.data||i.data.length===0)return;o+=h.data.length,t.preview&&o>t.preview?d.abort():v(i,s)}}}this.parse=function(h,m,g){var S=t.quoteChar||'"';if(t.newline||(t.newline=B(h,S)),y=!1,t.delimiter)N(t.delimiter)&&(t.delimiter=t.delimiter(h),i.meta.delimiter=t.delimiter);else{var p=C(h,t.newline,t.skipEmptyLines,t.comments,t.delimitersToGuess);p.successful?t.delimiter=p.bestDelimiter:(y=!0,t.delimiter=M.DefaultDelimiter),i.meta.delimiter=t.delimiter}var R=me(t);return t.preview&&t.header&&R.preview++,l=h,d=new de(R),i=d.parse(l,m,g),A(),u?{meta:{paused:!0}}:i||{meta:{paused:!1}}},this.paused=function(){return u},this.pause=function(){u=!0,d.abort(),l=l.substr(d.getCharIndex())},this.resume=function(){u=!1,s.streamer.parseChunk(l,!0)},this.aborted=function(){return n},this.abort=function(){n=!0,d.abort(),i.meta.aborted=!0,N(t.complete)&&t.complete(i),l=""};function j(h){return t.skipEmptyLines==="greedy"?h.join("").trim()==="":h.length===1&&h[0].length===0}function A(){if(i&&y&&(x("Delimiter","UndetectableDelimiter","Unable to auto-detect delimiting character; defaulted to '"+M.DefaultDelimiter+"'"),y=!1),t.skipEmptyLines)for(var h=0;h<i.data.length;h++)j(i.data[h])&&i.data.splice(h--,1);return f()&&w(),D()}function f(){return t.header&&a.length===0}function w(){if(!i)return;function h(g){N(t.transformHeader)&&(g=t.transformHeader(g)),a.push(g)}if(Array.isArray(i.data[0])){for(var m=0;f()&&m<i.data.length;m++)i.data[m].forEach(h);i.data.splice(0,1)}else i.data.forEach(h)}function T(h){return t.dynamicTypingFunction&&t.dynamicTyping[h]===void 0&&(t.dynamicTyping[h]=t.dynamicTypingFunction(h)),(t.dynamicTyping[h]||t.dynamicTyping)===!0}function b(h,m){return T(h)?m==="true"||m==="TRUE"?!0:m==="false"||m==="FALSE"?!1:e.test(m)?parseFloat(m):r.test(m)?new Date(m):m===""?null:m:m}function D(){if(!i||!i.data||!t.header&&!t.dynamicTyping&&!t.transform)return i;function h(g,S){var p=t.header?{}:[],R;for(R=0;R<g.length;R++){var E=R,k=g[R];t.header&&(E=R>=a.length?"__parsed_extra":a[R]),t.transform&&(k=t.transform(k,E)),k=b(E,k),E==="__parsed_extra"?(p[E]=p[E]||[],p[E].push(k)):p[E]=k}return t.header&&(R>a.length?x("FieldMismatch","TooManyFields","Too many fields: expected "+a.length+" fields but parsed "+R,c+S):R<a.length&&x("FieldMismatch","TooFewFields","Too few fields: expected "+a.length+" fields but parsed "+R,c+S)),p}var m=1;return!i.data[0]||Array.isArray(i.data[0])?(i.data=i.data.map(h),m=i.data.length):i.data=h(i.data,0),t.header&&i.meta&&(i.meta.fields=a),c+=m,i}function C(h,m,g,S,p){var R,E,k;p=p||[","," ","|",";",M.RECORD_SEP,M.UNIT_SEP];for(var z=0;z<p.length;z++){var L=p[z],H=0,P=0,Z=0;k=void 0;for(var O=new de({comments:S,delimiter:L,newline:m,preview:10}).parse(h),I=0;I<O.data.length;I++){if(g&&j(O.data[I])){Z++;continue}var F=O.data[I].length;if(P+=F,typeof k>"u"){k=0;continue}else F>1&&(H+=Math.abs(F-k),k=F)}O.data.length>0&&(P/=O.data.length-Z),(typeof E>"u"||H>E)&&P>1.99&&(E=H,R=L)}return t.delimiter=R,{successful:!!R,bestDelimiter:R}}function B(h,m){h=h.substr(0,1024*1024);var g=new RegExp(X(m)+"([^]*?)"+X(m),"gm");h=h.replace(g,"");var S=h.split("\r"),p=h.split(`
10
+ `),R=p.length>1&&p[0].length<S[0].length;if(S.length===1||R)return`
11
+ `;for(var E=0,k=0;k<S.length;k++)S[k][0]===`
12
+ `&&E++;return E>=S.length/2?`\r
13
+ `:"\r"}function x(h,m,g,S){i.errors.push({type:h,code:m,message:g,row:S})}}function X(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function de(t){t=t||{};var e=t.delimiter,r=t.newline,s=t.comments,o=t.step,c=t.preview,l=t.fastMode,d;t.quoteChar===void 0?d='"':d=t.quoteChar;var u=d;if(t.escapeChar!==void 0&&(u=t.escapeChar),(typeof e!="string"||M.BAD_DELIMITERS.indexOf(e)>-1)&&(e=","),s===e)throw new Error("Comment character same as delimiter");s===!0?s="#":(typeof s!="string"||M.BAD_DELIMITERS.indexOf(s)>-1)&&(s=!1),r!==`
14
+ `&&r!=="\r"&&r!==`\r
15
+ `&&(r=`
16
+ `);var n=0,y=!1;this.parse=function(a,i,v){if(typeof a!="string")throw new Error("Input must be a string");var j=a.length,A=e.length,f=r.length,w=s.length,T=N(o);n=0;var b=[],D=[],C=[],B=0;if(!a)return O();if(l||l!==!1&&a.indexOf(d)===-1){for(var x=a.split(r),h=0;h<x.length;h++){if(C=x[h],n+=C.length,h!==x.length-1)n+=r.length;else if(v)return O();if(!(s&&C.substr(0,w)===s)){if(T){if(b=[],L(C.split(e)),I(),y)return O()}else L(C.split(e));if(c&&h>=c)return b=b.slice(0,c),O(!0)}}return O()}for(var m=a.indexOf(e,n),g=a.indexOf(r,n),S=new RegExp(X(u)+X(d),"g"),p;;){if(a[n]===d){for(p=n,n++;;){if(p=a.indexOf(d,p+1),p===-1)return v||D.push({type:"Quotes",code:"MissingQuotes",message:"Quoted field unterminated",row:b.length,index:n}),P();if(p===j-1){var R=a.substring(n,p).replace(S,d);return P(R)}if(d===u&&a[p+1]===u){p++;continue}if(!(d!==u&&p!==0&&a[p-1]===u)){var E=g===-1?m:Math.min(m,g),k=H(E);if(a[p+1+k]===e){if(C.push(a.substring(n,p).replace(S,d)),n=p+1+k+A,m=a.indexOf(e,n),g=a.indexOf(r,n),T&&(I(),y))return O();if(c&&b.length>=c)return O(!0);break}var z=H(g);if(a.substr(p+1+z,f)===r){if(C.push(a.substring(n,p).replace(S,d)),Z(p+1+z+f),m=a.indexOf(e,n),T&&(I(),y))return O();if(c&&b.length>=c)return O(!0);break}D.push({type:"Quotes",code:"InvalidQuotes",message:"Trailing quote on quoted field is malformed",row:b.length,index:n}),p++}}if(T&&(I(),y))return O();if(c&&b.length>=c)return O(!0);continue}if(s&&C.length===0&&a.substr(n,w)===s){if(g===-1)return O();n=g+f,g=a.indexOf(r,n),m=a.indexOf(e,n);continue}if(m!==-1&&(m<g||g===-1)){C.push(a.substring(n,m)),n=m+A,m=a.indexOf(e,n);continue}if(g!==-1){if(C.push(a.substring(n,g)),Z(g+f),T&&(I(),y))return O();if(c&&b.length>=c)return O(!0);continue}break}return P();function L(F){b.push(F),B=n}function H(F){var te=0;if(F!==-1){var K=a.substring(p+1,F);K&&K.trim()===""&&(te=K.length)}return te}function P(F){return v||(typeof F>"u"&&(F=a.substr(n)),C.push(F),n=j,L(C),T&&I()),O()}function Z(F){n=F,L(C),C=[],g=a.indexOf(r,n)}function O(F,te){var K=te||!1;return{data:K?b[0]:b,errors:D,meta:{delimiter:e,linebreak:r,aborted:y,truncated:!!F,cursor:B+(i||0)}}}function I(){o(O(void 0,!0)),b=[],D=[]}},this.abort=function(){y=!0},this.getCharIndex=function(){return n}}function me(t){if(typeof t!="object"||t===null)return t;var e=Array.isArray(t)?[]:{};for(var r in t)e[r]=me(t[r]);return e}function N(t){return typeof t=="function"}var{ChunkStreamer:ke}=J;function $(t){t=t||{},ke.call(this,t),this.textDecoder=new TextDecoder(this._config.encoding),this.stream=async function(e){this._input=e;try{for await(let r of e)this.parseChunk(this.getStringChunk(r));this._finished=!0,this.parseChunk("")}catch(r){this._sendError(r)}},this._nextChunk=function(){},this.getStringChunk=function(e){return typeof e=="string"?e:this.textDecoder.decode(e,{stream:!0})}}$.prototype=Object.create(ke.prototype);$.prototype.constructor=$;var Ge="4.2.0-alpha.4",pe="object-row-table",le={id:"csv",module:"csv",name:"CSV",version:Ge,extensions:["csv","tsv","dsv"],mimeTypes:["text/csv","text/tab-separated-values","text/dsv"],category:"table",parse:async(t,e)=>Fe(new TextDecoder().decode(t),e),parseText:(t,e)=>Fe(t,e),parseInBatches:et,options:{csv:{shape:pe,optimizeMemoryUsage:!1,header:"auto",columnPrefix:"column",quoteChar:'"',escapeChar:'"',dynamicTyping:!0,comments:!1,skipEmptyLines:!0,delimitersToGuess:[","," ","|",";"]}}};async function Fe(t,e){let r={...le.options.csv,...e?.csv},s=tt(t),c=r.header==="auto"?De(s):Boolean(r.header),l={...r,header:c,download:!1,transformHeader:c?Be():void 0,error:a=>{throw new Error(a)}},d=J.parse(t,l),u=d.data,n=d.meta.fields||Ne(r.columnPrefix,s.length),y=r.shape||pe;switch(y){case"object-row-table":return{shape:"object-row-table",data:u.map(a=>Array.isArray(a)?Q(a,n):a)};case"array-row-table":return{shape:"array-row-table",data:u.map(a=>Array.isArray(a)?a:Y(a,n))};default:throw new Error(y)}}function et(t,e){e={...e},e.batchSize==="auto"&&(e.batchSize=4e3);let r={...le.options.csv,...e?.csv},s=new V,o=!0,c=null,l=null,d=null,u={...r,header:!1,download:!1,chunkSize:1024*1024*5,skipEmptyLines:!1,step(n){let y=n.data;if(r.skipEmptyLines&&y.flat().join("").trim()==="")return;let a=n.meta.cursor;if(o&&!c&&(r.header==="auto"?De(y):Boolean(r.header))){c=y.map(Be());return}o&&(o=!1,c||(c=Ne(r.columnPrefix,y.length)),d=rt(y,c)),r.optimizeMemoryUsage&&(y=JSON.parse(JSON.stringify(y)));let i=r.shape||pe;l=l||new _(d,{shape:i,...e});try{l.addRow(y);let v=l&&l.getFullBatch({bytesUsed:a});v&&s.enqueue(v)}catch(v){s.enqueue(v)}},complete(n){try{let y=n.meta.cursor,a=l&&l.getFinalBatch({bytesUsed:y});a&&s.enqueue(a)}catch(y){s.enqueue(y)}s.close()}};return J.parse(t,u,$),s}function De(t){return t&&t.every(e=>typeof e=="string")}function tt(t){return J.parse(t,{download:!1,dynamicTyping:!0,preview:1}).data[0]}function Be(){let t=new Set;return e=>{let r=e,s=1;for(;t.has(r);)r=`${e}.${s}`,s++;return t.add(r),r}}function Ne(t,e=0){let r=[];for(let s=0;s<e;s++)r.push(`${t}${s+1}`);return r}function rt(t,e){let r=e?{}:[];for(let s=0;s<t.length;s++){let o=e&&e[s]||s;switch(typeof t[s]){case"number":case"boolean":r[o]={name:String(o),index:s,type:Float32Array};break;case"string":default:r[o]={name:String(o),index:s,type:Array}}}return r}var Ue={},ye={},we=34,G=10,ge=13;function Me(t){return new Function("d","return {"+t.map(function(e,r){return JSON.stringify(e)+": d["+r+'] || ""'}).join(",")+"}")}function st(t,e){var r=Me(t);return function(s,o){return e(r(s),o,t)}}function Ie(t){var e=Object.create(null),r=[];return t.forEach(function(s){for(var o in s)o in e||r.push(e[o]=o)}),r}function U(t,e){var r=t+"",s=r.length;return s<e?new Array(e-s+1).join(0)+r:r}function at(t){return t<0?"-"+U(-t,6):t>9999?"+"+U(t,6):U(t,4)}function nt(t){var e=t.getUTCHours(),r=t.getUTCMinutes(),s=t.getUTCSeconds(),o=t.getUTCMilliseconds();return isNaN(t)?"Invalid Date":at(t.getUTCFullYear(),4)+"-"+U(t.getUTCMonth()+1,2)+"-"+U(t.getUTCDate(),2)+(o?"T"+U(e,2)+":"+U(r,2)+":"+U(s,2)+"."+U(o,3)+"Z":s?"T"+U(e,2)+":"+U(r,2)+":"+U(s,2)+"Z":r||e?"T"+U(e,2)+":"+U(r,2)+"Z":"")}function _e(t){var e=new RegExp('["'+t+`
17
+ \r]`),r=t.charCodeAt(0);function s(a,i){var v,j,A=o(a,function(f,w){if(v)return v(f,w-1);j=f,v=i?st(f,i):Me(f)});return A.columns=j||[],A}function o(a,i){var v=[],j=a.length,A=0,f=0,w,T=j<=0,b=!1;a.charCodeAt(j-1)===G&&--j,a.charCodeAt(j-1)===ge&&--j;function D(){if(T)return ye;if(b)return b=!1,Ue;var B,x=A,h;if(a.charCodeAt(x)===we){for(;A++<j&&a.charCodeAt(A)!==we||a.charCodeAt(++A)===we;);return(B=A)>=j?T=!0:(h=a.charCodeAt(A++))===G?b=!0:h===ge&&(b=!0,a.charCodeAt(A)===G&&++A),a.slice(x+1,B-1).replace(/""/g,'"')}for(;A<j;){if((h=a.charCodeAt(B=A++))===G)b=!0;else if(h===ge)b=!0,a.charCodeAt(A)===G&&++A;else if(h!==r)continue;return a.slice(x,B)}return T=!0,a.slice(x,j)}for(;(w=D())!==ye;){for(var C=[];w!==Ue&&w!==ye;)C.push(w),w=D();i&&(C=i(C,f++))==null||v.push(C)}return v}function c(a,i){return a.map(function(v){return i.map(function(j){return y(v[j])}).join(t)})}function l(a,i){return i==null&&(i=Ie(a)),[i.map(y).join(t)].concat(c(a,i)).join(`
18
+ `)}function d(a,i){return i==null&&(i=Ie(a)),c(a,i).join(`
19
+ `)}function u(a){return a.map(n).join(`
20
+ `)}function n(a){return a.map(y).join(t)}function y(a){return a==null?"":a instanceof Date?nt(a):e.test(a+="")?'"'+a.replace(/"/g,'""')+'"':a}return{parse:s,parseRows:o,format:l,formatBody:d,formatRows:u,formatRow:n,formatValue:y}}var q=_e(","),ot=q.parse,it=q.parseRows,ht=q.format,lt=q.formatBody,be=q.formatRows,ct=q.formatRow,ut=q.formatValue;function ve(t,e={csv:{useDisplayNames:!0}}){let r=e.useDisplayNames||e.csv?.useDisplayNames,c=[(t.schema?.fields||[]).map(l=>{let d=l.metadata?.displayName;return r&&typeof d=="string"?d:l.name})];for(let l of fe(t)){let d=[];for(let u=0;u<ue(t);++u){let n=l[u];d[u]=ft(n)}c.push(d)}return be(c)}var ft=t=>t==null?null:t instanceof Date?t.toISOString():typeof t=="object"?JSON.stringify(t):String(t);var Le={id:"csv",version:"latest",module:"csv",name:"CSV",extensions:["csv"],mimeTypes:["text/csv"],options:{csv:{useDisplayNames:!1}},text:!0,encode:async(t,e)=>new TextEncoder().encode(ve(t,e)).buffer,encodeTextSync:(t,e)=>ve(t,e)};return Ze(ee);})();
21
+ /* @license
22
+ Papa Parse
23
+ v5.0.0-beta.0
24
+ https://github.com/mholt/PapaParse
25
+ License: MIT
26
+ */
27
+ return __exports__;
28
+ });