chrono-phylo-tree 1.0.15 → 1.1.0

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 (66) hide show
  1. package/eslint.config.js +28 -0
  2. package/global.d.ts +26 -0
  3. package/index.html +13 -0
  4. package/package.json +3 -7
  5. package/src/App.css +131 -0
  6. package/src/App.tsx +149 -0
  7. package/src/assets/react.svg +1 -0
  8. package/src/classes/Species.tsx +267 -0
  9. package/src/components/HoverDescription.tsx +27 -0
  10. package/src/components/LanguageSelector.tsx +29 -0
  11. package/src/components/Menu.tsx +348 -0
  12. package/src/components/NavBar.tsx +234 -0
  13. package/src/components/PhTree.tsx +362 -0
  14. package/src/index.css +68 -0
  15. package/src/index.ts +4 -0
  16. package/src/main.tsx +10 -0
  17. package/src/types.d.ts +9 -0
  18. package/src/utils/between.tsx +3 -0
  19. package/src/utils/example.tsx +73 -0
  20. package/src/utils/hexToRGBA.tsx +12 -0
  21. package/src/utils/scientificNotation.tsx +20 -0
  22. package/src/utils/setFromJson.tsx +40 -0
  23. package/src/utils/translate.tsx +68 -0
  24. package/src/utils/updateSpecies.tsx +129 -0
  25. package/src/vite-env.d.ts +1 -0
  26. package/tsconfig.app.json +26 -0
  27. package/tsconfig.json +17 -0
  28. package/tsconfig.node.json +24 -0
  29. package/vite.config.ts +34 -0
  30. package/dist/App.d.ts +0 -3
  31. package/dist/App.d.ts.map +0 -1
  32. package/dist/chrono-phylo-tree.js +0 -1111
  33. package/dist/chrono-phylo-tree.umd.cjs +0 -15
  34. package/dist/classes/Species.d.ts +0 -35
  35. package/dist/classes/Species.d.ts.map +0 -1
  36. package/dist/components/HoverDescription.d.ts +0 -15
  37. package/dist/components/HoverDescription.d.ts.map +0 -1
  38. package/dist/components/LanguageSelector.d.ts +0 -9
  39. package/dist/components/LanguageSelector.d.ts.map +0 -1
  40. package/dist/components/Menu.d.ts +0 -15
  41. package/dist/components/Menu.d.ts.map +0 -1
  42. package/dist/components/NavBar.d.ts +0 -33
  43. package/dist/components/NavBar.d.ts.map +0 -1
  44. package/dist/components/PhTree.d.ts +0 -31
  45. package/dist/components/PhTree.d.ts.map +0 -1
  46. package/dist/index.d.ts +0 -5
  47. package/dist/index.d.ts.map +0 -1
  48. package/dist/main.d.ts +0 -1
  49. package/dist/main.d.ts.map +0 -1
  50. package/dist/utils/between.d.ts +0 -2
  51. package/dist/utils/between.d.ts.map +0 -1
  52. package/dist/utils/example.d.ts +0 -3
  53. package/dist/utils/example.d.ts.map +0 -1
  54. package/dist/utils/hexToRGBA.d.ts +0 -2
  55. package/dist/utils/hexToRGBA.d.ts.map +0 -1
  56. package/dist/utils/scientificNotation.d.ts +0 -2
  57. package/dist/utils/scientificNotation.d.ts.map +0 -1
  58. package/dist/utils/setFromJson.d.ts +0 -3
  59. package/dist/utils/setFromJson.d.ts.map +0 -1
  60. package/dist/utils/translate.d.ts +0 -4
  61. package/dist/utils/translate.d.ts.map +0 -1
  62. package/dist/utils/updateSpecies.d.ts +0 -7
  63. package/dist/utils/updateSpecies.d.ts.map +0 -1
  64. /package/{dist → public}/logo.png +0 -0
  65. /package/{dist → public}/translate.csv +0 -0
  66. /package/{dist → public}/vite.svg +0 -0
@@ -1,1111 +0,0 @@
1
- import { jsx as g, jsxs as X, Fragment as wt } from "react/jsx-runtime";
2
- import { useState as P, useEffect as Et } from "react";
3
- const Ct = (r, ...n) => r.sort(
4
- (o, a) => {
5
- for (const h of n) {
6
- const [c, l] = [o, a].map((m) => h(m));
7
- if (c !== l) return c - l;
8
- }
9
- return 0;
10
- }
11
- );
12
- class pt {
13
- constructor(n = "", o = 0, a = 0, h = void 0, c = [], l = void 0, m = void 0) {
14
- if (this.name = "", this.apparition = 0, this.duration = 0, this.ancestor = void 0, this.descendants = [], this.description = void 0, this.display = !0, this.image = void 0, a <= 0)
15
- throw new Error("The duration of the species must be greater than 0");
16
- this.name = n, this.apparition = o, this.duration = a, this.ancestor = h, this.descendants = c, this.description = l === "" ? void 0 : l, this.image = m === "" ? void 0 : m;
17
- }
18
- onPosition(n = !0) {
19
- return n && this.firstAncestor().stepsUntil(this) % 2 === 0;
20
- }
21
- copy() {
22
- const n = this.firstAncestor(), o = n.allDescendants(!1).indexOf(this);
23
- return pt.fromJSON(n.toJSON()).allDescendants(!1)[o];
24
- }
25
- unlinkAncestor() {
26
- if (!this.ancestor)
27
- return;
28
- this.ancestor.descendants = this.ancestor.descendants.filter((o) => o !== this);
29
- const n = this.ancestor;
30
- return this.ancestor = void 0, [n.firstAncestor(), this];
31
- }
32
- unlinkDescendant(n) {
33
- if (this.descendants.includes(n))
34
- return this.descendants = this.descendants.filter((o) => o !== n), n.ancestor = void 0, [this.firstAncestor(), n];
35
- }
36
- linkAncestor(n) {
37
- if (!(this.ancestor === n && n.descendants.includes(this))) {
38
- if (n.apparition > this.apparition)
39
- throw new Error(`The ancestor's apparition (${n.apparition}) must be before or equal the descendant's apparition (${this.apparition})`);
40
- if (n.extinction() < this.apparition)
41
- throw new Error(`The ancestor's extinction (${n.extinction()}) must be after or equal the descendant's apparition (${this.apparition})`);
42
- this.ancestor !== n && this.unlinkAncestor(), this.ancestor = n, n.descendants.push(this);
43
- }
44
- }
45
- linkDescendant(n) {
46
- if (!(n.ancestor === this && this.descendants.includes(n))) {
47
- if (n.apparition < this.apparition)
48
- throw new Error(`The descendant's apparition (${n.apparition}) must be after or equal the ancestor's apparition (${this.apparition})`);
49
- if (n.extinction() > this.extinction())
50
- throw new Error(`The descendant's extinction (${n.extinction()}) must be before or equal the ancestor's extinction (${this.extinction()})`);
51
- this.descendants.includes(n) || (n.ancestor && n.unlinkAncestor(), this.descendants.push(n), n.ancestor = this);
52
- }
53
- }
54
- linkDescendants(n) {
55
- for (const o of n)
56
- try {
57
- this.linkDescendant(o);
58
- } catch (a) {
59
- console.error(`Error linking descendant ${o.name} to ancestor ${this.name}:`, a);
60
- }
61
- }
62
- addDescendant(n = "", o = 0, a = 0, h = void 0, c = void 0, l = !1) {
63
- if (o < 0 || o > this.duration)
64
- throw new Error(`The apparition of the descendant must be between the apparition (${this.apparition}) and the extinction (${this.extinction()}) of the ancestor`);
65
- const m = l ? this.copy() : this, w = new pt(
66
- n,
67
- m.apparition + Math.max(o, 0),
68
- Math.max(a, 0),
69
- void 0,
70
- [],
71
- h,
72
- c
73
- );
74
- return w.linkAncestor(m), l ? m : w;
75
- }
76
- removeDescendant(n) {
77
- this.descendants = this.descendants.filter((o) => o !== n);
78
- }
79
- addAncestor(n = "", o = 0, a = 0, h = void 0, c = void 0, l = !0, m = !1) {
80
- if (o < 0)
81
- throw new Error(`The apparition of the ancestor must be before or equal the apparition (${this.apparition}) of the descendant`);
82
- if (a < o)
83
- throw new Error(`The extiction of the ancestor must be after or equal the apparition (${this.apparition}) of the descendant`);
84
- const w = m ? this.copy() : this, s = new pt(
85
- n,
86
- w.apparition - Math.max(o, 0),
87
- a,
88
- void 0,
89
- [],
90
- h,
91
- c
92
- );
93
- return s.display = l, w.linkAncestor(s), m ? w : s;
94
- }
95
- extinction() {
96
- return this.apparition + this.duration;
97
- }
98
- absoluteExtinction() {
99
- return this.descendants.length > 0 ? Math.max(...this.allDescendants(!1).map((n) => n.extinction())) : this.extinction();
100
- }
101
- absoluteDuration() {
102
- return this.absoluteExtinction() - this.apparition;
103
- }
104
- firstAncestor(n = !1) {
105
- return this.ancestor ? this.ancestor.display || n ? this.ancestor.firstAncestor() : this : this;
106
- }
107
- cousinsExtinction() {
108
- return this.firstAncestor().absoluteExtinction();
109
- }
110
- allDescendants(n = !0) {
111
- const o = n ? Ct(this.descendants, (s) => -s.apparition, (s) => -s.absoluteExtinction()) : this.descendants;
112
- if (o.length === 0)
113
- return [this];
114
- const a = o.filter((s) => s.apparition >= this.extinction()), h = o.filter((s) => a.indexOf(s) === -1), l = (this.onPosition(n) ? Math.ceil : Math.floor)(a.length / 2), m = a.slice(0, l), w = a.slice(l);
115
- return m.flatMap((s) => s.allDescendants(n)).concat([this]).concat(w.flatMap((s) => s.allDescendants(n))).concat(h.flatMap((s) => s.allDescendants(n)));
116
- }
117
- stepsChain(n, o = !1) {
118
- var a;
119
- return this.allDescendants(!1).includes(n) ? [this].concat(((a = this.descendants.find((h) => h.allDescendants(!1).includes(n))) == null ? void 0 : a.stepsChain(n)) ?? []).filter((h) => h.display || o) : [];
120
- }
121
- stepsUntil(n, o = !1) {
122
- if (this.allDescendants(!1).includes(n))
123
- return this.stepsChain(n, o).length - 1;
124
- }
125
- stepsUntilLastDescendant(n = !1) {
126
- return this.descendants.length === 0 ? 0 : Math.max(...this.allDescendants(!1).filter((o) => o.descendants.length === 0).map((o) => this.stepsUntil(o, n) ?? 0));
127
- }
128
- toJSON() {
129
- return {
130
- name: this.name,
131
- apparition: this.ancestor ? void 0 : this.apparition,
132
- afterApparition: this.ancestor ? this.apparition - this.ancestor.apparition : void 0,
133
- description: this.description,
134
- duration: this.duration,
135
- descendants: this.descendants.length > 0 ? this.descendants.map((n) => n.toJSON()) : void 0,
136
- image: this.image
137
- };
138
- }
139
- async saveJSON(n = void 0) {
140
- try {
141
- const o = JSON.stringify(this.toJSON(), null, 2), a = new Blob([o], { type: "application/json" }), h = URL.createObjectURL(a), c = document.createElement("a");
142
- c.href = h, c.download = n ?? `${this.name}.json`, c.click(), URL.revokeObjectURL(h);
143
- } catch (o) {
144
- console.error("Error saving file:", o);
145
- }
146
- }
147
- static fromJSON(n, o) {
148
- const a = n.afterApparition ?? 0, h = o ? o.apparition : n.apparition ?? 0, c = new pt(n.name ?? "", h + a, n.duration ?? 0, o, [], n.description, n.image);
149
- if (n.descendants)
150
- for (const l of n.descendants)
151
- c.descendants.push(pt.fromJSON(l, c));
152
- return c;
153
- }
154
- }
155
- const Jt = ({
156
- speciesList: r,
157
- width: n = 1e3,
158
- height: o = 50,
159
- padding: a = 0,
160
- stroke: h = "grey",
161
- format: c = (v) => v.toString(),
162
- chronoScale: l = !0,
163
- showImages: m = !0,
164
- presentTime: w,
165
- handleMouseMove: s,
166
- children: b
167
- }) => {
168
- const v = r.map((N) => N.copy()), A = Math.min(...v.map((N) => N.apparition)), L = Math.max(...v.map((N) => N.apparition - A)), C = new pt(
169
- "",
170
- A,
171
- L,
172
- void 0,
173
- []
174
- );
175
- return C.display = !1, C.linkDescendants(v), /* @__PURE__ */ g(
176
- Mt,
177
- {
178
- commonAncestor: C,
179
- width: n,
180
- height: o,
181
- padding: a,
182
- stroke: h,
183
- format: c,
184
- chronoScale: l,
185
- showImages: m,
186
- presentTime: w,
187
- handleMouseMove: s,
188
- children: (N, T, B, V) => b == null ? void 0 : b(N, T, B, V)
189
- }
190
- );
191
- }, Mt = ({
192
- commonAncestor: r,
193
- width: n = 1e3,
194
- height: o = 50,
195
- padding: a = 0,
196
- stroke: h = "grey",
197
- format: c = (v) => v.toString(),
198
- chronoScale: l = !0,
199
- showImages: m = !0,
200
- presentTime: w,
201
- handleMouseMove: s,
202
- children: b
203
- }) => {
204
- const [v, A] = P(!1), [L, C] = P(void 0), [N, T] = P(void 0), [B, V] = P(r.allDescendants().reduce((t, e) => t.set(e, !0), /* @__PURE__ */ new Map()));
205
- Et(() => {
206
- V(r.allDescendants().reduce((t, e) => t.set(e, !0), /* @__PURE__ */ new Map()));
207
- }, [r]);
208
- const Z = (t) => {
209
- C(v ? void 0 : t), A(!v);
210
- }, rt = (t) => {
211
- const e = new Map(B);
212
- e.set(t, !B.get(t)), V(e);
213
- }, et = (t) => {
214
- T(t);
215
- }, K = w !== void 0 && l, p = (t) => m ? t.map((e) => e.image ? 2 : 1).reduce((e, i) => e + i) : t.length;
216
- return /* @__PURE__ */ X(wt, { children: [
217
- /* @__PURE__ */ g(
218
- "svg",
219
- {
220
- width: n * (K ? (Math.min(w, r.absoluteExtinction()) - r.apparition) / r.absoluteDuration() : 1),
221
- height: o * p(K ? r.allDescendants().filter((t) => t.apparition < w) : r.allDescendants()),
222
- onMouseMove: (t) => {
223
- s == null || s(t.clientX, t.clientY);
224
- },
225
- children: /* @__PURE__ */ g(
226
- St,
227
- {
228
- commonAncestor: r,
229
- species: r,
230
- y: -1,
231
- scaleX: n / (l ? r.absoluteDuration() : Math.max(0, r.stepsUntilLastDescendant()) + 1),
232
- scaleY: o,
233
- padding: a,
234
- stroke: h,
235
- format: c,
236
- chronoScale: l,
237
- showImages: m,
238
- presentTime: w,
239
- toggleShowMenu: Z,
240
- hoverShowMenu: et,
241
- showDesc: B,
242
- changeShowDesc: rt
243
- }
244
- )
245
- }
246
- ),
247
- b == null ? void 0 : b(L, v, Z, N)
248
- ] });
249
- }, St = ({
250
- commonAncestor: r,
251
- species: n,
252
- y: o,
253
- scaleX: a,
254
- scaleY: h,
255
- padding: c = 0,
256
- stroke: l = "grey",
257
- format: m = (N) => N.toString(),
258
- chronoScale: w = !0,
259
- showImages: s = !0,
260
- presentTime: b = void 0,
261
- toggleShowMenu: v,
262
- hoverShowMenu: A,
263
- showDesc: L,
264
- changeShowDesc: C
265
- }) => {
266
- const N = b !== void 0 && w, T = r.allDescendants().filter((p) => N ? p.apparition < b : !0), B = T.indexOf(n), V = (w ? n.apparition - r.apparition : r.stepsUntil(n) ?? 0) * a, Z = V + (w ? Math.min(L.get(n) ? n.duration : n.absoluteDuration(), N ? b - n.apparition : n.absoluteDuration()) : 1) * a, rt = s && B > 0 ? [...Array(B).keys()].map((p) => T[p]).map((p) => (p.image ? 2 : 1) * h).reduce((p, t) => p + t) : B * h, et = n.descendants.filter((p) => N ? p.apparition < b : !0), K = et.length > 0 ? V + (Math.min(...et.map((p) => p.apparition)) - n.apparition) * a : Z;
267
- return /* @__PURE__ */ X("g", { children: [
268
- o >= 0 && /* @__PURE__ */ g(
269
- "line",
270
- {
271
- x1: V,
272
- y1: o,
273
- x2: V,
274
- y2: rt,
275
- stroke: l
276
- }
277
- ),
278
- n.display && /* @__PURE__ */ g(
279
- Lt,
280
- {
281
- commonAncestor: r,
282
- species: n,
283
- height: h,
284
- x1: V,
285
- x2: Z,
286
- x0: K,
287
- y: rt,
288
- stroke: l,
289
- changeShowDesc: () => C(n),
290
- showDesc: L.get(n),
291
- padding: c,
292
- format: m,
293
- chronoScale: w,
294
- showImages: s,
295
- presentTime: b,
296
- toggleShowMenu: v,
297
- hoverShowMenu: A
298
- }
299
- ),
300
- n.descendants.map((p, t) => /* @__PURE__ */ g("g", { className: L.get(n) && et.includes(p) ? "block" : "hidden", children: /* @__PURE__ */ g(
301
- St,
302
- {
303
- commonAncestor: r,
304
- species: p,
305
- y: p.display ? rt : -1,
306
- scaleX: a,
307
- scaleY: h,
308
- padding: c,
309
- stroke: l,
310
- format: m,
311
- chronoScale: w,
312
- showImages: s,
313
- presentTime: b,
314
- toggleShowMenu: v,
315
- showDesc: L,
316
- changeShowDesc: C,
317
- hoverShowMenu: A
318
- }
319
- ) }, T.length + t))
320
- ] }, B);
321
- }, Lt = ({
322
- commonAncestor: r,
323
- species: n,
324
- height: o,
325
- x1: a,
326
- x2: h,
327
- x0: c,
328
- y: l,
329
- stroke: m,
330
- showDesc: w = !0,
331
- changeShowDesc: s = () => {
332
- },
333
- padding: b = 0,
334
- format: v = (Z) => Z.toString(),
335
- chronoScale: A = !0,
336
- showImages: L = !0,
337
- presentTime: C,
338
- toggleShowMenu: N,
339
- hoverShowMenu: T,
340
- className: B,
341
- buttonClassName: V
342
- }) => {
343
- const Z = C !== void 0, rt = r.allDescendants().filter((i) => Z ? i.apparition < C : !0), et = (i) => rt.indexOf(i), K = n.ancestor && et(n) > et(n.ancestor) ? -3 : 1, p = n.descendants.filter((i) => Z ? i.apparition < C : !0), t = p.filter((i) => i.apparition === n.extinction()).length === 0, e = v(Math.min(w ? n.extinction() : n.absoluteExtinction(), Z ? C : n.absoluteExtinction()));
344
- return /* @__PURE__ */ X("g", { children: [
345
- /* @__PURE__ */ g(
346
- "line",
347
- {
348
- x1: a,
349
- y1: l,
350
- x2: h,
351
- y2: l,
352
- stroke: m
353
- }
354
- ),
355
- /* @__PURE__ */ g(
356
- "foreignObject",
357
- {
358
- x: a + b,
359
- y: l + b * K,
360
- width: (A ? c ?? h : h) - a - 2 * b,
361
- height: o + (L && n.image ? o : 0),
362
- children: /* @__PURE__ */ X("div", { className: `flex flex-row justify-between w-full ${B ?? ""}`, children: [
363
- /* @__PURE__ */ g("div", { children: A ? v(n.apparition) : "" }),
364
- /* @__PURE__ */ X(
365
- "button",
366
- {
367
- className: `p-0.625 justify-center flex flex-col items-center ${V ?? ""}`,
368
- onClick: () => N(n),
369
- onMouseEnter: () => T(n),
370
- onMouseLeave: () => T(void 0),
371
- children: [
372
- n.name,
373
- n.image && L && /* @__PURE__ */ g(
374
- "img",
375
- {
376
- src: n.image,
377
- alt: n.name,
378
- style: { height: o }
379
- }
380
- )
381
- ]
382
- }
383
- ),
384
- p.length > 0 ? /* @__PURE__ */ g("button", { onClick: s, className: "h-1", style: { maxWidth: 4 }, children: (t || !w) && (!c || c === h) ? e : "" }) : /* @__PURE__ */ g("div", { children: A ? e : "" })
385
- ] })
386
- }
387
- ),
388
- A && c && c < h && /* @__PURE__ */ g(
389
- "foreignObject",
390
- {
391
- x: c + b,
392
- y: l + b * K,
393
- width: h - c - 2 * b,
394
- height: o,
395
- children: /* @__PURE__ */ g("div", { className: "flex flex-row justify-end w-full", children: (t || !w) && A ? e : "" })
396
- }
397
- )
398
- ] });
399
- }, Tt = (r, n, o) => r < n ? n : r > o ? o : r;
400
- function It(r) {
401
- return r && r.__esModule && Object.prototype.hasOwnProperty.call(r, "default") ? r.default : r;
402
- }
403
- var bt = { exports: {} };
404
- /* @license
405
- Papa Parse
406
- v5.5.2
407
- https://github.com/mholt/PapaParse
408
- License: MIT
409
- */
410
- var Ft = bt.exports, Rt;
411
- function Nt() {
412
- return Rt || (Rt = 1, function(r, n) {
413
- ((o, a) => {
414
- r.exports = a();
415
- })(Ft, function o() {
416
- var a = typeof self < "u" ? self : typeof window < "u" ? window : a !== void 0 ? a : {}, h, c = !a.document && !!a.postMessage, l = a.IS_PAPA_WORKER || !1, m = {}, w = 0, s = {};
417
- function b(t) {
418
- this._handle = null, this._finished = !1, this._completed = !1, this._halted = !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: {} }, (function(e) {
419
- var i = et(e);
420
- i.chunkSize = parseInt(i.chunkSize), e.step || e.chunk || (i.chunkSize = null), this._handle = new N(i), (this._handle.streamer = this)._config = i;
421
- }).call(this, t), this.parseChunk = function(e, i) {
422
- var d = parseInt(this._config.skipFirstNLines) || 0;
423
- if (this.isFirstChunk && 0 < d) {
424
- let E = this._config.newline;
425
- E || (u = this._config.quoteChar || '"', E = this._handle.guessLineEndings(e, u)), e = [...e.split(E).slice(d)].join(E);
426
- }
427
- this.isFirstChunk && p(this._config.beforeFirstChunk) && (u = this._config.beforeFirstChunk(e)) !== void 0 && (e = u), this.isFirstChunk = !1, this._halted = !1;
428
- var d = this._partialLine + e, u = (this._partialLine = "", this._handle.parse(d, this._baseIndex, !this._finished));
429
- if (!this._handle.paused() && !this._handle.aborted()) {
430
- if (e = u.meta.cursor, d = (this._finished || (this._partialLine = d.substring(e - this._baseIndex), this._baseIndex = e), u && u.data && (this._rowCount += u.data.length), this._finished || this._config.preview && this._rowCount >= this._config.preview), l) a.postMessage({ results: u, workerId: s.WORKER_ID, finished: d });
431
- else if (p(this._config.chunk) && !i) {
432
- if (this._config.chunk(u, this._handle), this._handle.paused() || this._handle.aborted()) return void (this._halted = !0);
433
- this._completeResults = u = void 0;
434
- }
435
- return this._config.step || this._config.chunk || (this._completeResults.data = this._completeResults.data.concat(u.data), this._completeResults.errors = this._completeResults.errors.concat(u.errors), this._completeResults.meta = u.meta), this._completed || !d || !p(this._config.complete) || u && u.meta.aborted || (this._config.complete(this._completeResults, this._input), this._completed = !0), d || u && u.meta.paused || this._nextChunk(), u;
436
- }
437
- this._halted = !0;
438
- }, this._sendError = function(e) {
439
- p(this._config.error) ? this._config.error(e) : l && this._config.error && a.postMessage({ workerId: s.WORKER_ID, error: e, finished: !1 });
440
- };
441
- }
442
- function v(t) {
443
- var e;
444
- (t = t || {}).chunkSize || (t.chunkSize = s.RemoteChunkSize), b.call(this, t), this._nextChunk = c ? function() {
445
- this._readChunk(), this._chunkLoaded();
446
- } : function() {
447
- this._readChunk();
448
- }, this.stream = function(i) {
449
- this._input = i, this._nextChunk();
450
- }, this._readChunk = function() {
451
- if (this._finished) this._chunkLoaded();
452
- else {
453
- if (e = new XMLHttpRequest(), this._config.withCredentials && (e.withCredentials = this._config.withCredentials), c || (e.onload = K(this._chunkLoaded, this), e.onerror = K(this._chunkError, this)), e.open(this._config.downloadRequestBody ? "POST" : "GET", this._input, !c), this._config.downloadRequestHeaders) {
454
- var i, d = this._config.downloadRequestHeaders;
455
- for (i in d) e.setRequestHeader(i, d[i]);
456
- }
457
- var u;
458
- this._config.chunkSize && (u = this._start + this._config.chunkSize - 1, e.setRequestHeader("Range", "bytes=" + this._start + "-" + u));
459
- try {
460
- e.send(this._config.downloadRequestBody);
461
- } catch (E) {
462
- this._chunkError(E.message);
463
- }
464
- c && e.status === 0 && this._chunkError();
465
- }
466
- }, this._chunkLoaded = function() {
467
- e.readyState === 4 && (e.status < 200 || 400 <= e.status ? this._chunkError() : (this._start += this._config.chunkSize || e.responseText.length, this._finished = !this._config.chunkSize || this._start >= ((i) => (i = i.getResponseHeader("Content-Range")) !== null ? parseInt(i.substring(i.lastIndexOf("/") + 1)) : -1)(e), this.parseChunk(e.responseText)));
468
- }, this._chunkError = function(i) {
469
- i = e.statusText || i, this._sendError(new Error(i));
470
- };
471
- }
472
- function A(t) {
473
- (t = t || {}).chunkSize || (t.chunkSize = s.LocalChunkSize), b.call(this, t);
474
- var e, i, d = typeof FileReader < "u";
475
- this.stream = function(u) {
476
- this._input = u, i = u.slice || u.webkitSlice || u.mozSlice, d ? ((e = new FileReader()).onload = K(this._chunkLoaded, this), e.onerror = K(this._chunkError, this)) : e = new FileReaderSync(), this._nextChunk();
477
- }, this._nextChunk = function() {
478
- this._finished || this._config.preview && !(this._rowCount < this._config.preview) || this._readChunk();
479
- }, this._readChunk = function() {
480
- var u = this._input, E = (this._config.chunkSize && (E = Math.min(this._start + this._config.chunkSize, this._input.size), u = i.call(u, this._start, E)), e.readAsText(u, this._config.encoding));
481
- d || this._chunkLoaded({ target: { result: E } });
482
- }, this._chunkLoaded = function(u) {
483
- this._start += this._config.chunkSize, this._finished = !this._config.chunkSize || this._start >= this._input.size, this.parseChunk(u.target.result);
484
- }, this._chunkError = function() {
485
- this._sendError(e.error);
486
- };
487
- }
488
- function L(t) {
489
- var e;
490
- b.call(this, t = t || {}), this.stream = function(i) {
491
- return e = i, this._nextChunk();
492
- }, this._nextChunk = function() {
493
- var i, d;
494
- if (!this._finished) return i = this._config.chunkSize, e = i ? (d = e.substring(0, i), e.substring(i)) : (d = e, ""), this._finished = !e, this.parseChunk(d);
495
- };
496
- }
497
- function C(t) {
498
- b.call(this, t = t || {});
499
- var e = [], i = !0, d = !1;
500
- this.pause = function() {
501
- b.prototype.pause.apply(this, arguments), this._input.pause();
502
- }, this.resume = function() {
503
- b.prototype.resume.apply(this, arguments), this._input.resume();
504
- }, this.stream = function(u) {
505
- this._input = u, this._input.on("data", this._streamData), this._input.on("end", this._streamEnd), this._input.on("error", this._streamError);
506
- }, this._checkIsFinished = function() {
507
- d && e.length === 1 && (this._finished = !0);
508
- }, this._nextChunk = function() {
509
- this._checkIsFinished(), e.length ? this.parseChunk(e.shift()) : i = !0;
510
- }, this._streamData = K(function(u) {
511
- try {
512
- e.push(typeof u == "string" ? u : u.toString(this._config.encoding)), i && (i = !1, this._checkIsFinished(), this.parseChunk(e.shift()));
513
- } catch (E) {
514
- this._streamError(E);
515
- }
516
- }, this), this._streamError = K(function(u) {
517
- this._streamCleanUp(), this._sendError(u);
518
- }, this), this._streamEnd = K(function() {
519
- this._streamCleanUp(), d = !0, this._streamData("");
520
- }, this), this._streamCleanUp = K(function() {
521
- this._input.removeListener("data", this._streamData), this._input.removeListener("end", this._streamEnd), this._input.removeListener("error", this._streamError);
522
- }, this);
523
- }
524
- function N(t) {
525
- var e, i, d, u, E = Math.pow(2, 53), H = -E, at = /^\s*-?(\d+\.?|\.\d+|\d+\.\d+)([eE][-+]?\d+)?\s*$/, st = /^((\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)))$/, D = this, U = 0, _ = 0, Y = !1, k = !1, O = [], f = { data: [], errors: [], meta: {} };
526
- function J(R) {
527
- return t.skipEmptyLines === "greedy" ? R.join("").trim() === "" : R.length === 1 && R[0].length === 0;
528
- }
529
- function $() {
530
- if (f && d && (ot("Delimiter", "UndetectableDelimiter", "Unable to auto-detect delimiting character; defaulted to '" + s.DefaultDelimiter + "'"), d = !1), t.skipEmptyLines && (f.data = f.data.filter(function(y) {
531
- return !J(y);
532
- })), G()) {
533
- let y = function(z, W) {
534
- p(t.transformHeader) && (z = t.transformHeader(z, W)), O.push(z);
535
- };
536
- if (f) if (Array.isArray(f.data[0])) {
537
- for (var R = 0; G() && R < f.data.length; R++) f.data[R].forEach(y);
538
- f.data.splice(0, 1);
539
- } else f.data.forEach(y);
540
- }
541
- function M(y, z) {
542
- for (var W = t.header ? {} : [], I = 0; I < y.length; I++) {
543
- var F = I, S = y[I], S = ((dt, x) => ((j) => (t.dynamicTypingFunction && t.dynamicTyping[j] === void 0 && (t.dynamicTyping[j] = t.dynamicTypingFunction(j)), (t.dynamicTyping[j] || t.dynamicTyping) === !0))(dt) ? x === "true" || x === "TRUE" || x !== "false" && x !== "FALSE" && (((j) => {
544
- if (at.test(j) && (j = parseFloat(j), H < j && j < E))
545
- return 1;
546
- })(x) ? parseFloat(x) : st.test(x) ? new Date(x) : x === "" ? null : x) : x)(F = t.header ? I >= O.length ? "__parsed_extra" : O[I] : F, S = t.transform ? t.transform(S, F) : S);
547
- F === "__parsed_extra" ? (W[F] = W[F] || [], W[F].push(S)) : W[F] = S;
548
- }
549
- return t.header && (I > O.length ? ot("FieldMismatch", "TooManyFields", "Too many fields: expected " + O.length + " fields but parsed " + I, _ + z) : I < O.length && ot("FieldMismatch", "TooFewFields", "Too few fields: expected " + O.length + " fields but parsed " + I, _ + z)), W;
550
- }
551
- var q;
552
- f && (t.header || t.dynamicTyping || t.transform) && (q = 1, !f.data.length || Array.isArray(f.data[0]) ? (f.data = f.data.map(M), q = f.data.length) : f.data = M(f.data, 0), t.header && f.meta && (f.meta.fields = O), _ += q);
553
- }
554
- function G() {
555
- return t.header && O.length === 0;
556
- }
557
- function ot(R, M, q, y) {
558
- R = { type: R, code: M, message: q }, y !== void 0 && (R.row = y), f.errors.push(R);
559
- }
560
- p(t.step) && (u = t.step, t.step = function(R) {
561
- f = R, G() ? $() : ($(), f.data.length !== 0 && (U += R.data.length, t.preview && U > t.preview ? i.abort() : (f.data = f.data[0], u(f, D))));
562
- }), this.parse = function(R, M, q) {
563
- var y = t.quoteChar || '"', y = (t.newline || (t.newline = this.guessLineEndings(R, y)), d = !1, t.delimiter ? p(t.delimiter) && (t.delimiter = t.delimiter(R), f.meta.delimiter = t.delimiter) : ((y = ((z, W, I, F, S) => {
564
- var dt, x, j, ft;
565
- S = S || [",", " ", "|", ";", s.RECORD_SEP, s.UNIT_SEP];
566
- for (var gt = 0; gt < S.length; gt++) {
567
- for (var ut, _t = S[gt], tt = 0, ht = 0, Q = 0, nt = (j = void 0, new B({ comments: F, delimiter: _t, newline: W, preview: 10 }).parse(z)), ct = 0; ct < nt.data.length; ct++) I && J(nt.data[ct]) ? Q++ : (ut = nt.data[ct].length, ht += ut, j === void 0 ? j = ut : 0 < ut && (tt += Math.abs(ut - j), j = ut));
568
- 0 < nt.data.length && (ht /= nt.data.length - Q), (x === void 0 || tt <= x) && (ft === void 0 || ft < ht) && 1.99 < ht && (x = tt, dt = _t, ft = ht);
569
- }
570
- return { successful: !!(t.delimiter = dt), bestDelimiter: dt };
571
- })(R, t.newline, t.skipEmptyLines, t.comments, t.delimitersToGuess)).successful ? t.delimiter = y.bestDelimiter : (d = !0, t.delimiter = s.DefaultDelimiter), f.meta.delimiter = t.delimiter), et(t));
572
- return t.preview && t.header && y.preview++, e = R, i = new B(y), f = i.parse(e, M, q), $(), Y ? { meta: { paused: !0 } } : f || { meta: { paused: !1 } };
573
- }, this.paused = function() {
574
- return Y;
575
- }, this.pause = function() {
576
- Y = !0, i.abort(), e = p(t.chunk) ? "" : e.substring(i.getCharIndex());
577
- }, this.resume = function() {
578
- D.streamer._halted ? (Y = !1, D.streamer.parseChunk(e, !0)) : setTimeout(D.resume, 3);
579
- }, this.aborted = function() {
580
- return k;
581
- }, this.abort = function() {
582
- k = !0, i.abort(), f.meta.aborted = !0, p(t.complete) && t.complete(f), e = "";
583
- }, this.guessLineEndings = function(z, y) {
584
- z = z.substring(0, 1048576);
585
- var y = new RegExp(T(y) + "([^]*?)" + T(y), "gm"), q = (z = z.replace(y, "")).split("\r"), y = z.split(`
586
- `), z = 1 < y.length && y[0].length < q[0].length;
587
- if (q.length === 1 || z) return `
588
- `;
589
- for (var W = 0, I = 0; I < q.length; I++) q[I][0] === `
590
- ` && W++;
591
- return W >= q.length / 2 ? `\r
592
- ` : "\r";
593
- };
594
- }
595
- function T(t) {
596
- return t.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
597
- }
598
- function B(t) {
599
- var e = (t = t || {}).delimiter, i = t.newline, d = t.comments, u = t.step, E = t.preview, H = t.fastMode, at = null, st = !1, D = t.quoteChar == null ? '"' : t.quoteChar, U = D;
600
- if (t.escapeChar !== void 0 && (U = t.escapeChar), (typeof e != "string" || -1 < s.BAD_DELIMITERS.indexOf(e)) && (e = ","), d === e) throw new Error("Comment character same as delimiter");
601
- d === !0 ? d = "#" : (typeof d != "string" || -1 < s.BAD_DELIMITERS.indexOf(d)) && (d = !1), i !== `
602
- ` && i !== "\r" && i !== `\r
603
- ` && (i = `
604
- `);
605
- var _ = 0, Y = !1;
606
- this.parse = function(k, O, f) {
607
- if (typeof k != "string") throw new Error("Input must be a string");
608
- var J = k.length, $ = e.length, G = i.length, ot = d.length, R = p(u), M = [], q = [], y = [], z = _ = 0;
609
- if (!k) return tt();
610
- if (H || H !== !1 && k.indexOf(D) === -1) {
611
- for (var W = k.split(i), I = 0; I < W.length; I++) {
612
- if (y = W[I], _ += y.length, I !== W.length - 1) _ += i.length;
613
- else if (f) return tt();
614
- if (!d || y.substring(0, ot) !== d) {
615
- if (R) {
616
- if (M = [], ft(y.split(e)), ht(), Y) return tt();
617
- } else ft(y.split(e));
618
- if (E && E <= I) return M = M.slice(0, E), tt(!0);
619
- }
620
- }
621
- return tt();
622
- }
623
- for (var F = k.indexOf(e, _), S = k.indexOf(i, _), dt = new RegExp(T(U) + T(D), "g"), x = k.indexOf(D, _); ; ) if (k[_] === D) for (x = _, _++; ; ) {
624
- if ((x = k.indexOf(D, x + 1)) === -1) return f || q.push({ type: "Quotes", code: "MissingQuotes", message: "Quoted field unterminated", row: M.length, index: _ }), ut();
625
- if (x === J - 1) return ut(k.substring(_, x).replace(dt, D));
626
- if (D === U && k[x + 1] === U) x++;
627
- else if (D === U || x === 0 || k[x - 1] !== U) {
628
- F !== -1 && F < x + 1 && (F = k.indexOf(e, x + 1));
629
- var j = gt((S = S !== -1 && S < x + 1 ? k.indexOf(i, x + 1) : S) === -1 ? F : Math.min(F, S));
630
- if (k.substr(x + 1 + j, $) === e) {
631
- y.push(k.substring(_, x).replace(dt, D)), k[_ = x + 1 + j + $] !== D && (x = k.indexOf(D, _)), F = k.indexOf(e, _), S = k.indexOf(i, _);
632
- break;
633
- }
634
- if (j = gt(S), k.substring(x + 1 + j, x + 1 + j + G) === i) {
635
- if (y.push(k.substring(_, x).replace(dt, D)), _t(x + 1 + j + G), F = k.indexOf(e, _), x = k.indexOf(D, _), R && (ht(), Y)) return tt();
636
- if (E && M.length >= E) return tt(!0);
637
- break;
638
- }
639
- q.push({ type: "Quotes", code: "InvalidQuotes", message: "Trailing quote on quoted field is malformed", row: M.length, index: _ }), x++;
640
- }
641
- }
642
- else if (d && y.length === 0 && k.substring(_, _ + ot) === d) {
643
- if (S === -1) return tt();
644
- _ = S + G, S = k.indexOf(i, _), F = k.indexOf(e, _);
645
- } else if (F !== -1 && (F < S || S === -1)) y.push(k.substring(_, F)), _ = F + $, F = k.indexOf(e, _);
646
- else {
647
- if (S === -1) break;
648
- if (y.push(k.substring(_, S)), _t(S + G), R && (ht(), Y)) return tt();
649
- if (E && M.length >= E) return tt(!0);
650
- }
651
- return ut();
652
- function ft(Q) {
653
- M.push(Q), z = _;
654
- }
655
- function gt(Q) {
656
- var nt = 0;
657
- return nt = Q !== -1 && (Q = k.substring(x + 1, Q)) && Q.trim() === "" ? Q.length : nt;
658
- }
659
- function ut(Q) {
660
- return f || (Q === void 0 && (Q = k.substring(_)), y.push(Q), _ = J, ft(y), R && ht()), tt();
661
- }
662
- function _t(Q) {
663
- _ = Q, ft(y), y = [], S = k.indexOf(i, _);
664
- }
665
- function tt(Q) {
666
- if (t.header && !O && M.length && !st) {
667
- var nt = M[0], ct = {}, xt = new Set(nt);
668
- let Dt = !1;
669
- for (let mt = 0; mt < nt.length; mt++) {
670
- let lt = nt[mt];
671
- if (ct[lt = p(t.transformHeader) ? t.transformHeader(lt, mt) : lt]) {
672
- let yt, Ot = ct[lt];
673
- for (; yt = lt + "_" + Ot, Ot++, xt.has(yt); ) ;
674
- xt.add(yt), nt[mt] = yt, ct[lt]++, Dt = !0, (at = at === null ? {} : at)[yt] = lt;
675
- } else ct[lt] = 1, nt[mt] = lt;
676
- xt.add(lt);
677
- }
678
- Dt && console.warn("Duplicate headers found and renamed."), st = !0;
679
- }
680
- return { data: M, errors: q, meta: { delimiter: e, linebreak: i, aborted: Y, truncated: !!Q, cursor: z + (O || 0), renamedHeaders: at } };
681
- }
682
- function ht() {
683
- u(tt()), M = [], q = [];
684
- }
685
- }, this.abort = function() {
686
- Y = !0;
687
- }, this.getCharIndex = function() {
688
- return _;
689
- };
690
- }
691
- function V(t) {
692
- var e = t.data, i = m[e.workerId], d = !1;
693
- if (e.error) i.userError(e.error, e.file);
694
- else if (e.results && e.results.data) {
695
- var u = { abort: function() {
696
- d = !0, Z(e.workerId, { data: [], errors: [], meta: { aborted: !0 } });
697
- }, pause: rt, resume: rt };
698
- if (p(i.userStep)) {
699
- for (var E = 0; E < e.results.data.length && (i.userStep({ data: e.results.data[E], errors: e.results.errors, meta: e.results.meta }, u), !d); E++) ;
700
- delete e.results;
701
- } else p(i.userChunk) && (i.userChunk(e.results, u, e.file), delete e.results);
702
- }
703
- e.finished && !d && Z(e.workerId, e.results);
704
- }
705
- function Z(t, e) {
706
- var i = m[t];
707
- p(i.userComplete) && i.userComplete(e), i.terminate(), delete m[t];
708
- }
709
- function rt() {
710
- throw new Error("Not implemented.");
711
- }
712
- function et(t) {
713
- if (typeof t != "object" || t === null) return t;
714
- var e, i = Array.isArray(t) ? [] : {};
715
- for (e in t) i[e] = et(t[e]);
716
- return i;
717
- }
718
- function K(t, e) {
719
- return function() {
720
- t.apply(e, arguments);
721
- };
722
- }
723
- function p(t) {
724
- return typeof t == "function";
725
- }
726
- return s.parse = function(t, e) {
727
- var i = (e = e || {}).dynamicTyping || !1;
728
- if (p(i) && (e.dynamicTypingFunction = i, i = {}), e.dynamicTyping = i, e.transform = !!p(e.transform) && e.transform, !e.worker || !s.WORKERS_SUPPORTED) return i = null, s.NODE_STREAM_INPUT, typeof t == "string" ? (t = ((d) => d.charCodeAt(0) !== 65279 ? d : d.slice(1))(t), i = new (e.download ? v : L)(e)) : t.readable === !0 && p(t.read) && p(t.on) ? i = new C(e) : (a.File && t instanceof File || t instanceof Object) && (i = new A(e)), i.stream(t);
729
- (i = (() => {
730
- var d;
731
- return !!s.WORKERS_SUPPORTED && (d = (() => {
732
- var u = a.URL || a.webkitURL || null, E = o.toString();
733
- return s.BLOB_URL || (s.BLOB_URL = u.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; ", "(", E, ")();"], { type: "text/javascript" })));
734
- })(), (d = new a.Worker(d)).onmessage = V, d.id = w++, m[d.id] = d);
735
- })()).userStep = e.step, i.userChunk = e.chunk, i.userComplete = e.complete, i.userError = e.error, e.step = p(e.step), e.chunk = p(e.chunk), e.complete = p(e.complete), e.error = p(e.error), delete e.worker, i.postMessage({ input: t, config: e, workerId: i.id });
736
- }, s.unparse = function(t, e) {
737
- var i = !1, d = !0, u = ",", E = `\r
738
- `, H = '"', at = H + H, st = !1, D = null, U = !1, _ = ((() => {
739
- if (typeof e == "object") {
740
- if (typeof e.delimiter != "string" || s.BAD_DELIMITERS.filter(function(O) {
741
- return e.delimiter.indexOf(O) !== -1;
742
- }).length || (u = e.delimiter), typeof e.quotes != "boolean" && typeof e.quotes != "function" && !Array.isArray(e.quotes) || (i = e.quotes), typeof e.skipEmptyLines != "boolean" && typeof e.skipEmptyLines != "string" || (st = e.skipEmptyLines), typeof e.newline == "string" && (E = e.newline), typeof e.quoteChar == "string" && (H = e.quoteChar), typeof e.header == "boolean" && (d = e.header), Array.isArray(e.columns)) {
743
- if (e.columns.length === 0) throw new Error("Option columns is empty");
744
- D = e.columns;
745
- }
746
- e.escapeChar !== void 0 && (at = e.escapeChar + H), e.escapeFormulae instanceof RegExp ? U = e.escapeFormulae : typeof e.escapeFormulae == "boolean" && e.escapeFormulae && (U = /^[=+\-@\t\r].*$/);
747
- }
748
- })(), new RegExp(T(H), "g"));
749
- if (typeof t == "string" && (t = JSON.parse(t)), Array.isArray(t)) {
750
- if (!t.length || Array.isArray(t[0])) return Y(null, t, st);
751
- if (typeof t[0] == "object") return Y(D || Object.keys(t[0]), t, st);
752
- } 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 || D), t.fields || (t.fields = Array.isArray(t.data[0]) ? t.fields : typeof t.data[0] == "object" ? Object.keys(t.data[0]) : []), Array.isArray(t.data[0]) || typeof t.data[0] == "object" || (t.data = [t.data])), Y(t.fields || [], t.data || [], st);
753
- throw new Error("Unable to serialize unrecognized input");
754
- function Y(O, f, J) {
755
- var $ = "", G = (typeof O == "string" && (O = JSON.parse(O)), typeof f == "string" && (f = JSON.parse(f)), Array.isArray(O) && 0 < O.length), ot = !Array.isArray(f[0]);
756
- if (G && d) {
757
- for (var R = 0; R < O.length; R++) 0 < R && ($ += u), $ += k(O[R], R);
758
- 0 < f.length && ($ += E);
759
- }
760
- for (var M = 0; M < f.length; M++) {
761
- var q = (G ? O : f[M]).length, y = !1, z = G ? Object.keys(f[M]).length === 0 : f[M].length === 0;
762
- if (J && !G && (y = J === "greedy" ? f[M].join("").trim() === "" : f[M].length === 1 && f[M][0].length === 0), J === "greedy" && G) {
763
- for (var W = [], I = 0; I < q; I++) {
764
- var F = ot ? O[I] : I;
765
- W.push(f[M][F]);
766
- }
767
- y = W.join("").trim() === "";
768
- }
769
- if (!y) {
770
- for (var S = 0; S < q; S++) {
771
- 0 < S && !z && ($ += u);
772
- var dt = G && ot ? O[S] : S;
773
- $ += k(f[M][dt], S);
774
- }
775
- M < f.length - 1 && (!J || 0 < q && !z) && ($ += E);
776
- }
777
- }
778
- return $;
779
- }
780
- function k(O, f) {
781
- var J, $;
782
- return O == null ? "" : O.constructor === Date ? JSON.stringify(O).slice(1, 25) : ($ = !1, U && typeof O == "string" && U.test(O) && (O = "'" + O, $ = !0), J = O.toString().replace(_, at), ($ = $ || i === !0 || typeof i == "function" && i(O, f) || Array.isArray(i) && i[f] || ((G, ot) => {
783
- for (var R = 0; R < ot.length; R++) if (-1 < G.indexOf(ot[R])) return !0;
784
- return !1;
785
- })(J, s.BAD_DELIMITERS) || -1 < J.indexOf(u) || J.charAt(0) === " " || J.charAt(J.length - 1) === " ") ? H + J + H : J);
786
- }
787
- }, s.RECORD_SEP = "", s.UNIT_SEP = "", s.BYTE_ORDER_MARK = "\uFEFF", s.BAD_DELIMITERS = ["\r", `
788
- `, '"', s.BYTE_ORDER_MARK], s.WORKERS_SUPPORTED = !c && !!a.Worker, s.NODE_STREAM_INPUT = 1, s.LocalChunkSize = 10485760, s.RemoteChunkSize = 5242880, s.DefaultDelimiter = ",", s.Parser = B, s.ParserHandle = N, s.NetworkStreamer = v, s.FileStreamer = A, s.StringStreamer = L, s.ReadableStreamStreamer = C, a.jQuery && ((h = a.jQuery).fn.parse = function(t) {
789
- var e = t.config || {}, i = [];
790
- return this.each(function(E) {
791
- if (!(h(this).prop("tagName").toUpperCase() === "INPUT" && h(this).attr("type").toLowerCase() === "file" && a.FileReader) || !this.files || this.files.length === 0) return !0;
792
- for (var H = 0; H < this.files.length; H++) i.push({ file: this.files[H], inputElem: this, instanceConfig: h.extend({}, e) });
793
- }), d(), this;
794
- function d() {
795
- if (i.length === 0) p(t.complete) && t.complete();
796
- else {
797
- var E, H, at, st, D = i[0];
798
- if (p(t.before)) {
799
- var U = t.before(D.file, D.inputElem);
800
- if (typeof U == "object") {
801
- if (U.action === "abort") return E = "AbortError", H = D.file, at = D.inputElem, st = U.reason, void (p(t.error) && t.error({ name: E }, H, at, st));
802
- if (U.action === "skip") return void u();
803
- typeof U.config == "object" && (D.instanceConfig = h.extend(D.instanceConfig, U.config));
804
- } else if (U === "skip") return void u();
805
- }
806
- var _ = D.instanceConfig.complete;
807
- D.instanceConfig.complete = function(Y) {
808
- p(_) && _(Y, D.file, D.inputElem), u();
809
- }, s.parse(D.file, D.instanceConfig);
810
- }
811
- }
812
- function u() {
813
- i.splice(0, 1), d();
814
- }
815
- }), l && (a.onmessage = function(t) {
816
- t = t.data, s.WORKER_ID === void 0 && t && (s.WORKER_ID = t.workerId), typeof t.input == "string" ? a.postMessage({ workerId: s.WORKER_ID, results: s.parse(t.input, t.config), finished: !0 }) : (a.File && t.input instanceof File || t.input instanceof Object) && (t = s.parse(t.input, t.config)) && a.postMessage({ workerId: s.WORKER_ID, results: t, finished: !0 });
817
- }), (v.prototype = Object.create(b.prototype)).constructor = v, (A.prototype = Object.create(b.prototype)).constructor = A, (L.prototype = Object.create(L.prototype)).constructor = L, (C.prototype = Object.create(b.prototype)).constructor = C, s;
818
- });
819
- }(bt)), bt.exports;
820
- }
821
- var jt = Nt();
822
- const Pt = /* @__PURE__ */ It(jt);
823
- let At = [];
824
- const kt = async (r) => {
825
- const a = await (await fetch(r)).body.getReader().read(), c = new TextDecoder("utf-8").decode(a.value), { data: l } = Pt.parse(c, {
826
- header: !0,
827
- dynamicTyping: !0,
828
- delimiter: ";"
829
- });
830
- return l;
831
- }, Ut = (r = "/translate.csv") => (async (n = "/translate.csv") => {
832
- At = await kt(n);
833
- })(r), it = (r, n, o = [], a = "/translate.csv") => {
834
- const [h, c] = P([]);
835
- Et(() => {
836
- kt(a).then(c), Ut(a);
837
- }, [n]);
838
- const l = h.find((m) => m.code === r) ?? At.find((m) => m.code === r);
839
- try {
840
- const m = l[n];
841
- return o.reduce((s, b, v) => s.replace(`{${v}}`, b), m);
842
- } catch {
843
- return;
844
- }
845
- }, Wt = async (r, n, o = [], a = "/translate.csv") => {
846
- const c = (await kt(a)).find((l) => l.code === r);
847
- try {
848
- const l = c[n];
849
- return o.reduce((m, w, s) => m.replace(`{${s}}`, w), l);
850
- } catch {
851
- return "";
852
- }
853
- }, Kt = (r = "/translate.csv") => {
854
- const [n, o] = P(/* @__PURE__ */ new Map());
855
- return Et(() => {
856
- (async () => {
857
- const c = (await kt(r)).find((l) => l.code === "lan");
858
- if (c) {
859
- delete c.code;
860
- const l = new Map(Object.entries(c));
861
- o(l);
862
- }
863
- })();
864
- }, []), n;
865
- }, Qt = ({ species: r, language: n, open: o, onClose: a, saveSpecies: h, createDescendant: c, createAncestor: l, deleteAncestor: m, deleteSpecies: w }) => {
866
- const [s, b] = P(r.name), [v, A] = P(r.apparition), [L, C] = P(r.duration), [N, T] = P(r.description ?? ""), [B, V] = P(!1), [Z, rt] = P(!1), [et, K] = P(r.image ?? ""), p = () => {
867
- V(!B);
868
- }, t = () => {
869
- rt(!Z);
870
- }, e = (i) => i.ancestor ? i.ancestor.descendants.length === 1 && e(i.ancestor) : !0;
871
- return /* @__PURE__ */ g($t, { open: o, onClose: a, children: /* @__PURE__ */ g("form", { style: { backgroundColor: "grey" }, className: "flex flex-col text-start w-auto fixed p-2.5", children: /* @__PURE__ */ X(
872
- vt,
873
- {
874
- name: s,
875
- setName: b,
876
- apparition: v,
877
- setApparition: (i) => {
878
- A(r.ancestor ? Tt(i, r.ancestor.apparition, r.ancestor.extinction()) : i), C(r.descendants.length > 0 ? Math.max(Math.max(...r.descendants.map((d) => d.apparition)) - v, L) : L);
879
- },
880
- minApparition: r.ancestor ? r.ancestor.apparition : void 0,
881
- maxApparition: r.ancestor ? r.ancestor.extinction() : void 0,
882
- duration: L,
883
- setDuration: C,
884
- minDuration: r.descendants.length > 0 ? Math.max(...r.descendants.map((i) => i.apparition)) - v : void 0,
885
- maxDuration: r.descendants.length > 0 ? Math.max(...r.descendants.map((i) => i.apparition)) - v : void 0,
886
- description: N,
887
- setDescription: T,
888
- image: et,
889
- setImage: K,
890
- language: n,
891
- children: [
892
- /* @__PURE__ */ g("button", { onClick: async () => {
893
- try {
894
- await (h == null ? void 0 : h(r, s, v, L, N, et)), a == null || a();
895
- } catch (i) {
896
- console.error(i);
897
- }
898
- }, children: it("spbtn00", n ?? "") }),
899
- /* @__PURE__ */ g("button", { type: "button", onClick: w, children: it("spbtn01", n ?? "") }),
900
- /* @__PURE__ */ g("button", { type: "button", onClick: p, children: it("spbtn02", n ?? "") }),
901
- B && /* @__PURE__ */ g(
902
- qt,
903
- {
904
- species: r,
905
- language: n,
906
- onClose: a,
907
- createDescendant: c
908
- }
909
- ),
910
- r.ancestor ? e(r) && /* @__PURE__ */ g("button", { type: "button", onClick: async () => {
911
- try {
912
- await (m == null ? void 0 : m()), a == null || a();
913
- } catch (i) {
914
- console.error(i);
915
- }
916
- }, children: it("spbtn04" + (r.ancestor.ancestor ? "_0" : ""), n ?? "") }) : /* @__PURE__ */ g("button", { type: "button", onClick: t, children: it("spbtn03", n ?? "") }),
917
- Z && /* @__PURE__ */ g(
918
- zt,
919
- {
920
- species: r,
921
- language: n,
922
- onClose: a,
923
- createAncestor: l
924
- }
925
- ),
926
- /* @__PURE__ */ g("button", { type: "button", onClick: a, children: it("spbtn05", n ?? "") })
927
- ]
928
- }
929
- ) }) });
930
- }, vt = ({
931
- name: r,
932
- setName: n,
933
- apparition: o,
934
- setApparition: a,
935
- minApparition: h,
936
- maxApparition: c,
937
- duration: l,
938
- setDuration: m,
939
- minDuration: w,
940
- maxDuration: s,
941
- description: b,
942
- setDescription: v,
943
- language: A,
944
- image: L,
945
- setImage: C,
946
- children: N
947
- }) => /* @__PURE__ */ X(wt, { children: [
948
- /* @__PURE__ */ g("table", { children: /* @__PURE__ */ X("tbody", { children: [
949
- /* @__PURE__ */ X("tr", { children: [
950
- /* @__PURE__ */ X("td", { children: [
951
- it("splbl00", A ?? ""),
952
- ":"
953
- ] }),
954
- /* @__PURE__ */ g("td", { children: /* @__PURE__ */ g(
955
- "input",
956
- {
957
- type: "text",
958
- value: r,
959
- onChange: (T) => n(T.target.value)
960
- }
961
- ) })
962
- ] }),
963
- /* @__PURE__ */ X("tr", { children: [
964
- /* @__PURE__ */ X("td", { children: [
965
- it("splbl01", A ?? ""),
966
- ":"
967
- ] }),
968
- /* @__PURE__ */ g("td", { children: /* @__PURE__ */ g(
969
- "input",
970
- {
971
- type: "number",
972
- min: h,
973
- max: c,
974
- value: o,
975
- onChange: (T) => a(Number(T.target.value))
976
- }
977
- ) })
978
- ] }),
979
- /* @__PURE__ */ X("tr", { children: [
980
- /* @__PURE__ */ X("td", { children: [
981
- it("splbl02", A ?? ""),
982
- ":"
983
- ] }),
984
- /* @__PURE__ */ g("td", { children: /* @__PURE__ */ g(
985
- "input",
986
- {
987
- type: "number",
988
- min: w,
989
- max: s,
990
- value: l,
991
- onChange: (T) => m(Number(T.target.value))
992
- }
993
- ) })
994
- ] }),
995
- /* @__PURE__ */ X("tr", { children: [
996
- /* @__PURE__ */ X("td", { children: [
997
- it("splbl03", A ?? ""),
998
- ":"
999
- ] }),
1000
- /* @__PURE__ */ g("td", { children: /* @__PURE__ */ g(
1001
- "textarea",
1002
- {
1003
- value: b,
1004
- onChange: (T) => v(T.target.value)
1005
- }
1006
- ) })
1007
- ] }),
1008
- /* @__PURE__ */ X("tr", { children: [
1009
- /* @__PURE__ */ X("td", { children: [
1010
- it("splbl04", A ?? ""),
1011
- ":"
1012
- ] }),
1013
- /* @__PURE__ */ g("td", { children: /* @__PURE__ */ g(
1014
- "input",
1015
- {
1016
- type: "text",
1017
- value: L,
1018
- onChange: (T) => C(T.target.value)
1019
- }
1020
- ) })
1021
- ] }),
1022
- /* @__PURE__ */ g("tr", { children: /* @__PURE__ */ g("td", { colSpan: 2, children: /* @__PURE__ */ g(
1023
- "img",
1024
- {
1025
- src: L,
1026
- style: { height: "100px" }
1027
- }
1028
- ) }) })
1029
- ] }) }),
1030
- N
1031
- ] }), qt = ({ species: r, language: n, onClose: o, createDescendant: a }) => {
1032
- const [h, c] = P(""), [l, m] = P(r.duration), [w, s] = P(r.duration), [b, v] = P(""), [A, L] = P("");
1033
- return /* @__PURE__ */ g(wt, { children: /* @__PURE__ */ g(
1034
- vt,
1035
- {
1036
- name: h,
1037
- setName: c,
1038
- apparition: r.apparition + l,
1039
- setApparition: (C) => m(C - r.apparition),
1040
- minApparition: r.apparition,
1041
- maxApparition: r.extinction(),
1042
- duration: w,
1043
- setDuration: s,
1044
- description: b,
1045
- setDescription: v,
1046
- image: A,
1047
- setImage: L,
1048
- language: n,
1049
- children: /* @__PURE__ */ g("button", { type: "button", onClick: async () => {
1050
- try {
1051
- await (a == null ? void 0 : a(r, h, l, w, b, A)), o == null || o();
1052
- } catch (C) {
1053
- console.error(C);
1054
- }
1055
- }, children: it("cdbtn00", n ?? "") })
1056
- }
1057
- ) });
1058
- }, zt = ({ species: r, language: n, onClose: o, createAncestor: a }) => {
1059
- const [h, c] = P(""), [l, m] = P(r.duration), [w, s] = P(r.duration), [b, v] = P(""), [A, L] = P("");
1060
- return /* @__PURE__ */ g(wt, { children: /* @__PURE__ */ g(
1061
- vt,
1062
- {
1063
- name: h,
1064
- setName: c,
1065
- apparition: r.apparition - l,
1066
- setApparition: (C) => {
1067
- m(r.apparition - C), s(Math.max(r.apparition - C, w));
1068
- },
1069
- maxApparition: r.apparition,
1070
- duration: w,
1071
- setDuration: s,
1072
- minDuration: l,
1073
- description: b,
1074
- setDescription: v,
1075
- image: A,
1076
- setImage: L,
1077
- language: n,
1078
- children: /* @__PURE__ */ g("button", { type: "button", onClick: async () => {
1079
- try {
1080
- await (a == null ? void 0 : a(r, h, l, w, b, A)), o == null || o();
1081
- } catch (C) {
1082
- console.error(C);
1083
- }
1084
- }, children: it("cdbtn00", n ?? "") })
1085
- }
1086
- ) });
1087
- }, $t = ({ open: r, onClose: n, children: o }) => /* @__PURE__ */ g(
1088
- "div",
1089
- {
1090
- style: { backgroundColor: r ? "rgba(0, 0, 0, 0.2)" : "rgba(0, 0, 0, 0)" },
1091
- className: `flex fixed inset-0 justify-center items-center transition-colors duration-300 ease-in-out ${r ? "visible" : "hidden"}`,
1092
- onClick: n,
1093
- children: /* @__PURE__ */ g(
1094
- "div",
1095
- {
1096
- onClick: (a) => a.stopPropagation(),
1097
- className: "flex justify-center items-center",
1098
- children: o
1099
- }
1100
- )
1101
- }
1102
- );
1103
- export {
1104
- Qt as Menu,
1105
- Jt as MultiplePhTrees,
1106
- Mt as PhTree,
1107
- pt as Species,
1108
- it as codeText,
1109
- Wt as codeTextAlt,
1110
- Kt as getLanguageOptions
1111
- };