@pretextbook/import 0.5.0 → 0.7.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.
@@ -1,4787 +0,0 @@
1
- import { formatPretext as He } from "@pretextbook/format";
2
- import { latexToPretext as Ke } from "@pretextbook/latex-pretext";
3
- import { markdownToPretext as Ye } from "@pretextbook/remark-pretext";
4
- const Ve = [
5
- "\\documentclass",
6
- "\\begin{document}",
7
- "\\begin{",
8
- "\\section",
9
- "\\chapter",
10
- "\\title",
11
- "\\author"
12
- ], Je = ["# ", "## ", "### ", "#### "];
13
- function Xt(n) {
14
- const r = n.trim();
15
- return !r || r.startsWith("<") ? "pretext" : Ve.some((t) => r.includes(t)) ? "latex" : Je.some((t) => r.startsWith(t)) ? "markdown" : "pretext";
16
- }
17
- const qe = [
18
- {
19
- kind: "presentation",
20
- category: "latex_fonts",
21
- macros: ["textrm", "textit", "textbf", "textsc", "texttt"]
22
- }
23
- ], ie = {
24
- kind: "presentation",
25
- category: "tex_fonts",
26
- pairs: [
27
- { from: "rm", to: "textrm" },
28
- { from: "em", to: "emph" },
29
- { from: "it", to: "textit" },
30
- { from: "itshape", to: "textit" },
31
- { from: "bf", to: "textbf" },
32
- { from: "bfseries", to: "textbf" },
33
- { from: "sf", to: "textsf" },
34
- { from: "sffamily", to: "textss" },
35
- { from: "textsl", to: "testsl" }
36
- ]
37
- }, Qe = [
38
- {
39
- kind: "accessibility",
40
- category: "consistency",
41
- macros: ["renewcommand"]
42
- }
43
- ], tn = [
44
- {
45
- kind: "unused",
46
- category: "conditionals",
47
- macros: ["if", "fi", "iffalse", "then", "else", "loop", "repeat"]
48
- },
49
- {
50
- kind: "presentation",
51
- category: "font_size",
52
- macros: [
53
- "tiny",
54
- "scriptsize",
55
- "footnotesize",
56
- "small",
57
- "normalsize",
58
- "large",
59
- "Large",
60
- "LARGE",
61
- "huge",
62
- "Huge",
63
- "normalfont"
64
- ]
65
- },
66
- {
67
- kind: "presentation",
68
- category: "spacing_vertical",
69
- macros: ["smallskip", "medskip", "bigskip", "vfil", "vfill"]
70
- },
71
- {
72
- kind: "presentation",
73
- category: "archaic_tex",
74
- macros: ["centerline", "centering", "noindent", "par", "linebreak"]
75
- },
76
- {
77
- kind: "mistake",
78
- category: "nonstructural",
79
- macros: ["ensuremath"]
80
- },
81
- {
82
- kind: "archaic",
83
- category: "low_level_tex",
84
- macros: [
85
- "relax",
86
- "makeatletter",
87
- "makeatother",
88
- "csname",
89
- "endcsname",
90
- "shipout",
91
- "noexpand",
92
- "expandafter",
93
- "clearpage"
94
- ]
95
- },
96
- {
97
- kind: "archaic",
98
- category: "file_manipulation",
99
- macros: [
100
- "newwrite",
101
- "newread",
102
- "immediate",
103
- "write",
104
- "write18",
105
- "read",
106
- "readline",
107
- "readfile",
108
- "openin",
109
- "openout",
110
- "jobname"
111
- ]
112
- }
113
- ], en = [
114
- {
115
- kind: "archaic",
116
- category: "low_level_tex",
117
- macros: ["catcode", "newtheorem", "maketitle", "setlength"]
118
- }
119
- ], nn = [
120
- {
121
- kind: "publisher",
122
- category: "zzzzz",
123
- macros: [
124
- "theoremstyle",
125
- "makeindex",
126
- "allowdisplaybreaks",
127
- "frontmatter",
128
- "mainmatter",
129
- "appendix",
130
- "numberwithin",
131
- "setcounter",
132
- "tableofcontents",
133
- "FloatBarrier"
134
- ]
135
- }
136
- ], rn = [
137
- {
138
- kind: "archaic",
139
- category: "use_newcommand_only",
140
- macros: ["def", "let", "edef", "gdef", "xdef", "global", "long"]
141
- }
142
- ], sn = [
143
- {
144
- kind: "presentation",
145
- category: "spacing_horizontal",
146
- macros: [{ name: "hspace", arity: 1 }]
147
- },
148
- {
149
- kind: "other",
150
- category: "other",
151
- macros: [{ name: "date", arity: 1 }]
152
- },
153
- {
154
- kind: "accessibility",
155
- category: "colors",
156
- macros: [
157
- { name: "color", arity: 1 },
158
- { name: "textcolor", arity: 1 },
159
- { name: "mathcolor", arity: 1 },
160
- { name: "definecolor", arity: 3 }
161
- ]
162
- }
163
- ], an = [
164
- {
165
- kind: "presentation",
166
- category: "nonstructural",
167
- environments: ["center", "minipage"]
168
- }
169
- ];
170
- function se(n) {
171
- return n.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
172
- }
173
- function ae(n, r) {
174
- let t = n;
175
- const l = [];
176
- for (const { from: s, to: i } of r.pairs) {
177
- let e, o;
178
- r.category === "tex_fonts" ? (e = `\\{ *\\\\${se(s)}\\b *`, o = `\\${i}{`) : (e = `\\\\${se(s)}\\b *`, o = `\\${i}`);
179
- const c = new RegExp(e, "g"), d = t.match(c);
180
- d && (l.push({
181
- action: "replace",
182
- severity: "info",
183
- kind: r.kind,
184
- category: r.category,
185
- macro: s,
186
- replacement: i,
187
- occurrences: d.length
188
- }), t = t.replace(c, o));
189
- }
190
- return { output: t, warnings: l };
191
- }
192
- function on(n) {
193
- let r = n;
194
- const t = [], l = r.match(/\(\\ref\{([^{}]+)\}\)/g);
195
- l && (t.push({
196
- action: "rewrite",
197
- severity: "info",
198
- kind: "presentation",
199
- category: "math_refs",
200
- macro: "(\\ref{...})",
201
- replacement: "\\eqref{...}",
202
- occurrences: l.length
203
- }), r = r.replace(/\(\\ref\{([^{}]+)\}\)/g, "\\eqref{$1}")), r = r.replace(/(\\vfil)l\b/g, "$1"), r = r.replace(/(\\vfil)(\s*\\vfil\b)+\b/g, "$1");
204
- const s = r.match(/(\\vfil)\b/g);
205
- return s && (t.push({
206
- action: "rewrite",
207
- severity: "info",
208
- kind: "presentation",
209
- category: "spacing_vertical",
210
- macro: "vfil",
211
- replacement: "\\vspace{1in}",
212
- occurrences: s.length
213
- }), r = r.replace(/(\\vfil)\b/g, "\\vspace{1in}")), r = r.replace(
214
- /\\vskip\*? *([0-9]+|-) *([a-zA-Z]+).*/g,
215
- "\\vspace{$1$2}"
216
- ), r = r.replace(/(\\vspace)\*? */g, "$1"), r = r.replace(
217
- /(\\vspace) *\{([0-9]+|-) *([a-zA-Z]+).*?\}/g,
218
- "$1{$2$3}"
219
- ), { output: r, warnings: t };
220
- }
221
- function cn(n) {
222
- const r = n.split("\\begin{document}");
223
- if (r.length < 2)
224
- return { preamble: "", body: n, bibliography: "" };
225
- const t = r[0];
226
- let l = r.slice(1).join("\\begin{document}"), s = "";
227
- if (/\\begin\{thebibliography\}/.test(l)) {
228
- const [i, ...e] = l.split("\\begin{thebibliography}");
229
- l = i, s = e.join("\\begin{thebibliography}");
230
- }
231
- return { preamble: t, body: l, bibliography: s };
232
- }
233
- function we(n) {
234
- return n.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
235
- }
236
- function ln(n, r, t) {
237
- const l = we(n);
238
- if (r === "hasarg") {
239
- let s = `\\\\${l}\\b\\*?`;
240
- for (let i = 0; i < t; i += 1)
241
- s += "\\{[^{}]*\\}";
242
- return new RegExp(`(${s})`, "g");
243
- }
244
- return r === "line" ? new RegExp(`(\\\\${l}\\b.*)`, "g") : new RegExp(`(\\\\${l}\\b)`, "g");
245
- }
246
- function ut(n, r, t, l) {
247
- const { type: s = "", action: i = "mark", extra: e = "", save: o = !1 } = t;
248
- "macros" in r && r.macros[0];
249
- let c = n;
250
- const d = r.macros;
251
- for (const _ of d) {
252
- const m = typeof _ == "string" ? _ : _.name, v = typeof _ == "string" ? 0 : _.arity, h = ln(m, s, v), b = c.match(h);
253
- !b || b.length === 0 || (o && l.push({
254
- action: "save",
255
- severity: "warning",
256
- kind: r.kind,
257
- category: r.category,
258
- macro: m,
259
- occurrences: b.length,
260
- examples: b.slice(0, 5),
261
- message: e || void 0
262
- }), i === "delete" ? (l.push({
263
- action: "delete",
264
- severity: "info",
265
- kind: r.kind,
266
- category: r.category,
267
- macro: m,
268
- occurrences: b.length,
269
- message: e || void 0
270
- }), c = c.replace(h, "")) : l.push({
271
- action: "anomaly",
272
- severity: "warning",
273
- kind: r.kind,
274
- category: r.category,
275
- macro: m,
276
- occurrences: b.length,
277
- message: e || void 0,
278
- examples: b.slice(0, 5)
279
- }));
280
- }
281
- return c;
282
- }
283
- function un(n, r, t) {
284
- let l = n;
285
- for (const s of r.environments) {
286
- const i = we(s), e = new RegExp(`(\\\\(begin|end)\\{\\s*${i}\\})`, "g"), o = l.match(e);
287
- o && o.length > 0 && (t.push({
288
- action: "delete",
289
- severity: "info",
290
- kind: r.kind,
291
- category: r.category,
292
- macro: s,
293
- occurrences: o.length
294
- }), l = l.replace(e, ""));
295
- }
296
- return l;
297
- }
298
- function fn(n) {
299
- const r = [], t = cn(n);
300
- let { preamble: l, body: s } = t;
301
- const { bibliography: i } = t;
302
- for (const d of tn)
303
- l = ut(l, d, { action: "delete" }, r), s = ut(s, d, { action: "delete" }, r);
304
- for (const d of Qe)
305
- l = ut(
306
- l,
307
- d,
308
- { type: "line", action: "delete", extra: "in the preamble", save: !0 },
309
- r
310
- ), s = ut(
311
- s,
312
- d,
313
- { type: "line", action: "delete", extra: "in the main text", save: !0 },
314
- r
315
- );
316
- for (const d of rn)
317
- l = ut(
318
- l,
319
- d,
320
- { type: "line", action: "delete", extra: "in the preamble", save: !0 },
321
- r
322
- ), s = ut(
323
- s,
324
- d,
325
- { type: "line", action: "delete", extra: "in the main text", save: !0 },
326
- r
327
- );
328
- for (const d of sn)
329
- l = ut(
330
- l,
331
- d,
332
- { type: "hasarg", action: "delete" },
333
- r
334
- ), s = ut(
335
- s,
336
- d,
337
- { type: "hasarg", action: "delete" },
338
- r
339
- );
340
- for (const d of en)
341
- l = ut(
342
- l,
343
- d,
344
- { type: "line", action: "delete" },
345
- r
346
- ), s = ut(
347
- s,
348
- d,
349
- { type: "line", action: "delete" },
350
- r
351
- );
352
- for (const d of nn)
353
- l = ut(
354
- l,
355
- d,
356
- {
357
- type: "line",
358
- action: "delete",
359
- extra: "this is a publisher choice in PreTeXt"
360
- },
361
- r
362
- ), s = ut(
363
- s,
364
- d,
365
- {
366
- type: "line",
367
- action: "delete",
368
- extra: "this is a publisher choice in PreTeXt"
369
- },
370
- r
371
- );
372
- for (const d of qe)
373
- s = ut(s, d, { action: "mark" }, r);
374
- for (const d of an)
375
- s = un(s, d, r);
376
- const e = n.includes("\\begin{document}"), o = i.length > 0;
377
- let c = l;
378
- return e ? c += `\\begin{document}
379
- ` + s : c = s, o && (c += `\\begin{thebibliography}
380
- ` + i), { output: c, warnings: r };
381
- }
382
- function dn(n) {
383
- let r = n;
384
- return r = r.replace(/\s+%.*/g, ""), r = r.replace(/([^\\])%.*/g, "$1"), r = r.replace(/^%.*/, ""), r;
385
- }
386
- function hn(n) {
387
- return n.replace(/(.*\{)([^{}]+)(\}.*)/, (r, t, l, s) => {
388
- const i = String(l).replace(/\s/g, "_").replace(/[^a-zA-Z0-9_]/g, "-");
389
- return `${t}${i}${s}`;
390
- });
391
- }
392
- function pn(n) {
393
- let r = n;
394
- return r = r.replace(/> */g, "\\gt "), r = r.replace(/< */g, "\\lt "), r = r.replace(
395
- /(\\(ref|eqref|cref|Cref|label)\{([^{}]+)\})/g,
396
- hn
397
- ), r;
398
- }
399
- function mn(n) {
400
- let r = n;
401
- return r = r.replace(/\\begin +/g, "\\begin"), r = r.replace(/\\chapter +/g, "\\chapter"), r = r.replace(/\\section +/g, "\\section"), r = r.replace(/\\section\*/g, "\\section"), r = dn(r), r = pn(r), r = r.replace(/\\end\{document\}.*/s, ""), r = r.replace(/^\s+/, ""), r = r.replace(/\n{3,}/g, `
402
-
403
- `), r;
404
- }
405
- function oe(n, r = 0, t = "{", l = "}") {
406
- let s = n.trimStart();
407
- if (!s)
408
- return ["", ""];
409
- let i = "", e = "", o = r;
410
- if (o === 0 && s[0] !== t)
411
- return ["", s];
412
- for (o === 0 && (e = t, o = 1, s = s.substring(1)); o > 0 && s; ) {
413
- const c = s[0];
414
- c === t && i !== "\\" ? o += 1 : c === l && i !== "\\" && (o -= 1), e += c, i === "\\" && c === "\\" ? i = `
415
- ` : i = c, s = s.substring(1);
416
- }
417
- return o === 0 ? [e, s] : ["", e.substring(1)];
418
- }
419
- function gn(n) {
420
- const r = [];
421
- let t = mn(n).replace(/(\n *){3,}/g, `
422
-
423
- `);
424
- const l = on(t);
425
- t = l.output, r.push(...l.warnings);
426
- const s = ae(t, ie);
427
- t = s.output, r.push(...s.warnings);
428
- const i = ae(t, ie);
429
- t = i.output, r.push(...i.warnings);
430
- const e = fn(t);
431
- return t = e.output.replace(/(\n *){3,}/g, `
432
-
433
- `), r.push(...e.warnings), { output: t, warnings: r };
434
- }
435
- function zt(n) {
436
- const r = "\\begin{document}", t = "\\end{document}", l = n.indexOf(r);
437
- if (l === -1)
438
- return { preamble: "", body: n };
439
- const s = n.slice(0, l).trim(), i = n.slice(l + r.length), e = i.indexOf(t), o = (e === -1 ? i : i.slice(0, e)).trim();
440
- return { preamble: s, body: o };
441
- }
442
- function Pt(n, r) {
443
- const l = new RegExp(`\\\\${r}(?![a-zA-Z])`).exec(n);
444
- if (!l) return "";
445
- let s = n.slice(l.index + l[0].length).trimStart();
446
- if (s.startsWith("[")) {
447
- const [e, o] = oe(s, 0, "[", "]");
448
- e && (s = o.trimStart());
449
- }
450
- const [i] = oe(s);
451
- return i ? i.slice(1, -1).trim() : "";
452
- }
453
- const _n = /^[ \t]*(\\(?:new|renew|provide)command\*?|\\DeclareMathOperator\*?|\\newenvironment\*?)\b/;
454
- function ce(n) {
455
- let r = 0;
456
- for (let t = 0; t < n.length; t++) {
457
- if (n[t] === "\\") {
458
- t++;
459
- continue;
460
- }
461
- n[t] === "{" ? r++ : n[t] === "}" && r--;
462
- }
463
- return r;
464
- }
465
- function xe(n) {
466
- const r = n.split(`
467
- `), t = [];
468
- let l = 0;
469
- for (; l < r.length; ) {
470
- if (!_n.test(r[l])) {
471
- l++;
472
- continue;
473
- }
474
- let s = r[l], i = ce(r[l]);
475
- for (l++; i > 0 && l < r.length; )
476
- s += `
477
- ` + r[l], i += ce(r[l]), l++;
478
- t.push(s.trim());
479
- }
480
- return t.join(`
481
- `);
482
- }
483
- function bn(n) {
484
- const r = /\\documentclass(?:\[[^\]]*\])?\{([^}]+)\}/.exec(n);
485
- return r ? r[1].trim() : "article";
486
- }
487
- function yn(n) {
488
- const r = n.replace(/(^|[^\\])%[^\n]*/gm, "$1");
489
- return {
490
- documentClass: bn(r),
491
- title: Pt(r, "title"),
492
- author: Pt(r, "author"),
493
- macros: xe(r)
494
- };
495
- }
496
- function vn(n) {
497
- if (typeof n == "string")
498
- return n;
499
- if (typeof n == "object" && n !== null && "value" in n) {
500
- const r = n.value;
501
- if (typeof r == "string")
502
- return r;
503
- if (r != null)
504
- return String(r);
505
- }
506
- return String(n);
507
- }
508
- function ke(n) {
509
- return n.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
510
- }
511
- function Se(n) {
512
- return n.replace(/\\LaTeX\b/g, "LaTeX").replace(/\\TeX\b/g, "TeX").replace(/\\thanks\{[^{}]*(?:\{[^{}]*\}[^{}]*)?\}/g, "").replace(/\\inst\{[^{}]*\}/g, "").replace(/\\email\{[^{}]*\}/g, "").replace(/\\[a-zA-Z]+\{([^{}]*)\}/g, "$1").replace(/\\\s/g, " ").replace(/~/g, " ").replace(/\s+/g, " ").trim();
513
- }
514
- function wn(n) {
515
- const r = [];
516
- if (n.macros) {
517
- const t = n.macros.split(`
518
- `).map((l) => ` ${l}`).join(`
519
- `);
520
- r.push(` <macros>
521
- ${t}
522
- </macros>`);
523
- }
524
- if (n.author) {
525
- const t = n.author.split(/\s+\\and\s+/)[0].trim(), l = ke(Se(t));
526
- l && r.push(
527
- ` <author>
528
- <personname>${l}</personname>
529
- </author>`
530
- );
531
- }
532
- return r.length === 0 ? "" : `<docinfo>
533
- ${r.join(`
534
- `)}
535
- </docinfo>`;
536
- }
537
- function xn(n, r) {
538
- const t = n.replace(/^\s*<p\s*\/>\s*/g, "").replace(/^\s*<p>\s*<\/p>\s*/g, "").trim();
539
- if (!t) return "";
540
- const s = /<chapter[\s>]/.test(t) ? "book" : "article", i = wn(r), e = r.title ? ` <title>${ke(Se(r.title))}</title>
541
- ` : "", o = `<${s}>
542
- ${e}${t}
543
- </${s}>`;
544
- return `<pretext>
545
- ${[i, o].filter(Boolean).join(`
546
- `)}
547
- </pretext>`;
548
- }
549
- function Vt(n) {
550
- const r = n.trim();
551
- return r ? He(r) : "";
552
- }
553
- function kn(n) {
554
- const r = n.trim();
555
- if (!r)
556
- return { pretext: "", cleanedLatex: "", warnings: [] };
557
- const { preamble: t, body: l } = zt(r), s = yn(t), i = l ? [
558
- `\\documentclass{${s.documentClass}}`,
559
- s.macros,
560
- "\\begin{document}",
561
- l,
562
- "\\end{document}"
563
- ].filter(Boolean).join(`
564
- `) : r, { output: e, warnings: o } = gn(i);
565
- if (!e.trim())
566
- return { pretext: "", cleanedLatex: e, warnings: o };
567
- const c = l ? e + `
568
- \\end{document}` : e, d = vn(
569
- Ke(c)
570
- ).trim();
571
- if (!d)
572
- return { pretext: "", cleanedLatex: e, warnings: o };
573
- const _ = xn(d, s);
574
- return { pretext: _ ? Vt(_) : "", cleanedLatex: e, warnings: o };
575
- }
576
- function Sn(n) {
577
- const r = n.trim();
578
- if (!r)
579
- return { pretext: "", cleanedMarkdown: "" };
580
- const t = String(Ye(r)).trim();
581
- return { pretext: t ? Vt(t) : "", cleanedMarkdown: r };
582
- }
583
- function En(n) {
584
- return n instanceof Error && n.message.trim() ? n.message.trim() : "Could not convert source content to PreTeXt.";
585
- }
586
- function zn(n, r) {
587
- const t = Xt(n), l = r ?? t;
588
- try {
589
- if (l === "pretext")
590
- return {
591
- sourceFormat: l,
592
- detectedSourceFormat: t,
593
- pretextSource: Vt(n),
594
- warnings: []
595
- };
596
- if (l === "markdown") {
597
- const { pretext: o, cleanedMarkdown: c } = Sn(n);
598
- return {
599
- sourceFormat: l,
600
- detectedSourceFormat: t,
601
- pretextSource: o,
602
- cleanedNativeSource: c,
603
- warnings: []
604
- };
605
- }
606
- const { pretext: s, cleanedLatex: i, warnings: e } = kn(n);
607
- return {
608
- sourceFormat: l,
609
- detectedSourceFormat: t,
610
- pretextSource: s,
611
- cleanedNativeSource: i,
612
- warnings: e
613
- };
614
- } catch (s) {
615
- return {
616
- sourceFormat: l,
617
- detectedSourceFormat: t,
618
- pretextError: En(s),
619
- warnings: []
620
- };
621
- }
622
- }
623
- var It = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {};
624
- function Cn(n) {
625
- return n && n.__esModule && Object.prototype.hasOwnProperty.call(n, "default") ? n.default : n;
626
- }
627
- function Ot(n) {
628
- throw new Error('Could not dynamically require "' + n + '". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.');
629
- }
630
- var Ut = { exports: {} };
631
- var le;
632
- function An() {
633
- return le || (le = 1, (function(n, r) {
634
- (function(t) {
635
- n.exports = t();
636
- })(function() {
637
- return (function t(l, s, i) {
638
- function e(d, _) {
639
- if (!s[d]) {
640
- if (!l[d]) {
641
- var m = typeof Ot == "function" && Ot;
642
- if (!_ && m) return m(d, !0);
643
- if (o) return o(d, !0);
644
- var v = new Error("Cannot find module '" + d + "'");
645
- throw v.code = "MODULE_NOT_FOUND", v;
646
- }
647
- var h = s[d] = { exports: {} };
648
- l[d][0].call(h.exports, function(b) {
649
- var f = l[d][1][b];
650
- return e(f || b);
651
- }, h, h.exports, t, l, s, i);
652
- }
653
- return s[d].exports;
654
- }
655
- for (var o = typeof Ot == "function" && Ot, c = 0; c < i.length; c++) e(i[c]);
656
- return e;
657
- })({ 1: [function(t, l, s) {
658
- var i = t("./utils"), e = t("./support"), o = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
659
- s.encode = function(c) {
660
- for (var d, _, m, v, h, b, f, g = [], p = 0, w = c.length, S = w, E = i.getTypeOf(c) !== "string"; p < c.length; ) S = w - p, m = E ? (d = c[p++], _ = p < w ? c[p++] : 0, p < w ? c[p++] : 0) : (d = c.charCodeAt(p++), _ = p < w ? c.charCodeAt(p++) : 0, p < w ? c.charCodeAt(p++) : 0), v = d >> 2, h = (3 & d) << 4 | _ >> 4, b = 1 < S ? (15 & _) << 2 | m >> 6 : 64, f = 2 < S ? 63 & m : 64, g.push(o.charAt(v) + o.charAt(h) + o.charAt(b) + o.charAt(f));
661
- return g.join("");
662
- }, s.decode = function(c) {
663
- var d, _, m, v, h, b, f = 0, g = 0, p = "data:";
664
- if (c.substr(0, p.length) === p) throw new Error("Invalid base64 input, it looks like a data url.");
665
- var w, S = 3 * (c = c.replace(/[^A-Za-z0-9+/=]/g, "")).length / 4;
666
- if (c.charAt(c.length - 1) === o.charAt(64) && S--, c.charAt(c.length - 2) === o.charAt(64) && S--, S % 1 != 0) throw new Error("Invalid base64 input, bad content length.");
667
- for (w = e.uint8array ? new Uint8Array(0 | S) : new Array(0 | S); f < c.length; ) d = o.indexOf(c.charAt(f++)) << 2 | (v = o.indexOf(c.charAt(f++))) >> 4, _ = (15 & v) << 4 | (h = o.indexOf(c.charAt(f++))) >> 2, m = (3 & h) << 6 | (b = o.indexOf(c.charAt(f++))), w[g++] = d, h !== 64 && (w[g++] = _), b !== 64 && (w[g++] = m);
668
- return w;
669
- };
670
- }, { "./support": 30, "./utils": 32 }], 2: [function(t, l, s) {
671
- var i = t("./external"), e = t("./stream/DataWorker"), o = t("./stream/Crc32Probe"), c = t("./stream/DataLengthProbe");
672
- function d(_, m, v, h, b) {
673
- this.compressedSize = _, this.uncompressedSize = m, this.crc32 = v, this.compression = h, this.compressedContent = b;
674
- }
675
- d.prototype = { getContentWorker: function() {
676
- var _ = new e(i.Promise.resolve(this.compressedContent)).pipe(this.compression.uncompressWorker()).pipe(new c("data_length")), m = this;
677
- return _.on("end", function() {
678
- if (this.streamInfo.data_length !== m.uncompressedSize) throw new Error("Bug : uncompressed data size mismatch");
679
- }), _;
680
- }, getCompressedWorker: function() {
681
- return new e(i.Promise.resolve(this.compressedContent)).withStreamInfo("compressedSize", this.compressedSize).withStreamInfo("uncompressedSize", this.uncompressedSize).withStreamInfo("crc32", this.crc32).withStreamInfo("compression", this.compression);
682
- } }, d.createWorkerFrom = function(_, m, v) {
683
- return _.pipe(new o()).pipe(new c("uncompressedSize")).pipe(m.compressWorker(v)).pipe(new c("compressedSize")).withStreamInfo("compression", m);
684
- }, l.exports = d;
685
- }, { "./external": 6, "./stream/Crc32Probe": 25, "./stream/DataLengthProbe": 26, "./stream/DataWorker": 27 }], 3: [function(t, l, s) {
686
- var i = t("./stream/GenericWorker");
687
- s.STORE = { magic: "\0\0", compressWorker: function() {
688
- return new i("STORE compression");
689
- }, uncompressWorker: function() {
690
- return new i("STORE decompression");
691
- } }, s.DEFLATE = t("./flate");
692
- }, { "./flate": 7, "./stream/GenericWorker": 28 }], 4: [function(t, l, s) {
693
- var i = t("./utils"), e = (function() {
694
- for (var o, c = [], d = 0; d < 256; d++) {
695
- o = d;
696
- for (var _ = 0; _ < 8; _++) o = 1 & o ? 3988292384 ^ o >>> 1 : o >>> 1;
697
- c[d] = o;
698
- }
699
- return c;
700
- })();
701
- l.exports = function(o, c) {
702
- return o !== void 0 && o.length ? i.getTypeOf(o) !== "string" ? (function(d, _, m, v) {
703
- var h = e, b = v + m;
704
- d ^= -1;
705
- for (var f = v; f < b; f++) d = d >>> 8 ^ h[255 & (d ^ _[f])];
706
- return -1 ^ d;
707
- })(0 | c, o, o.length, 0) : (function(d, _, m, v) {
708
- var h = e, b = v + m;
709
- d ^= -1;
710
- for (var f = v; f < b; f++) d = d >>> 8 ^ h[255 & (d ^ _.charCodeAt(f))];
711
- return -1 ^ d;
712
- })(0 | c, o, o.length, 0) : 0;
713
- };
714
- }, { "./utils": 32 }], 5: [function(t, l, s) {
715
- s.base64 = !1, s.binary = !1, s.dir = !1, s.createFolders = !0, s.date = null, s.compression = null, s.compressionOptions = null, s.comment = null, s.unixPermissions = null, s.dosPermissions = null;
716
- }, {}], 6: [function(t, l, s) {
717
- var i = null;
718
- i = typeof Promise < "u" ? Promise : t("lie"), l.exports = { Promise: i };
719
- }, { lie: 37 }], 7: [function(t, l, s) {
720
- var i = typeof Uint8Array < "u" && typeof Uint16Array < "u" && typeof Uint32Array < "u", e = t("pako"), o = t("./utils"), c = t("./stream/GenericWorker"), d = i ? "uint8array" : "array";
721
- function _(m, v) {
722
- c.call(this, "FlateWorker/" + m), this._pako = null, this._pakoAction = m, this._pakoOptions = v, this.meta = {};
723
- }
724
- s.magic = "\b\0", o.inherits(_, c), _.prototype.processChunk = function(m) {
725
- this.meta = m.meta, this._pako === null && this._createPako(), this._pako.push(o.transformTo(d, m.data), !1);
726
- }, _.prototype.flush = function() {
727
- c.prototype.flush.call(this), this._pako === null && this._createPako(), this._pako.push([], !0);
728
- }, _.prototype.cleanUp = function() {
729
- c.prototype.cleanUp.call(this), this._pako = null;
730
- }, _.prototype._createPako = function() {
731
- this._pako = new e[this._pakoAction]({ raw: !0, level: this._pakoOptions.level || -1 });
732
- var m = this;
733
- this._pako.onData = function(v) {
734
- m.push({ data: v, meta: m.meta });
735
- };
736
- }, s.compressWorker = function(m) {
737
- return new _("Deflate", m);
738
- }, s.uncompressWorker = function() {
739
- return new _("Inflate", {});
740
- };
741
- }, { "./stream/GenericWorker": 28, "./utils": 32, pako: 38 }], 8: [function(t, l, s) {
742
- function i(h, b) {
743
- var f, g = "";
744
- for (f = 0; f < b; f++) g += String.fromCharCode(255 & h), h >>>= 8;
745
- return g;
746
- }
747
- function e(h, b, f, g, p, w) {
748
- var S, E, z = h.file, P = h.compression, D = w !== d.utf8encode, N = o.transformTo("string", w(z.name)), R = o.transformTo("string", d.utf8encode(z.name)), M = z.comment, V = o.transformTo("string", w(M)), k = o.transformTo("string", d.utf8encode(M)), j = R.length !== z.name.length, u = k.length !== M.length, I = "", H = "", $ = "", tt = z.dir, W = z.date, Q = { crc32: 0, compressedSize: 0, uncompressedSize: 0 };
749
- b && !f || (Q.crc32 = h.crc32, Q.compressedSize = h.compressedSize, Q.uncompressedSize = h.uncompressedSize);
750
- var O = 0;
751
- b && (O |= 8), D || !j && !u || (O |= 2048);
752
- var T = 0, q = 0;
753
- tt && (T |= 16), p === "UNIX" ? (q = 798, T |= (function(G, st) {
754
- var lt = G;
755
- return G || (lt = st ? 16893 : 33204), (65535 & lt) << 16;
756
- })(z.unixPermissions, tt)) : (q = 20, T |= (function(G) {
757
- return 63 & (G || 0);
758
- })(z.dosPermissions)), S = W.getUTCHours(), S <<= 6, S |= W.getUTCMinutes(), S <<= 5, S |= W.getUTCSeconds() / 2, E = W.getUTCFullYear() - 1980, E <<= 4, E |= W.getUTCMonth() + 1, E <<= 5, E |= W.getUTCDate(), j && (H = i(1, 1) + i(_(N), 4) + R, I += "up" + i(H.length, 2) + H), u && ($ = i(1, 1) + i(_(V), 4) + k, I += "uc" + i($.length, 2) + $);
759
- var K = "";
760
- return K += `
761
- \0`, K += i(O, 2), K += P.magic, K += i(S, 2), K += i(E, 2), K += i(Q.crc32, 4), K += i(Q.compressedSize, 4), K += i(Q.uncompressedSize, 4), K += i(N.length, 2), K += i(I.length, 2), { fileRecord: m.LOCAL_FILE_HEADER + K + N + I, dirRecord: m.CENTRAL_FILE_HEADER + i(q, 2) + K + i(V.length, 2) + "\0\0\0\0" + i(T, 4) + i(g, 4) + N + I + V };
762
- }
763
- var o = t("../utils"), c = t("../stream/GenericWorker"), d = t("../utf8"), _ = t("../crc32"), m = t("../signature");
764
- function v(h, b, f, g) {
765
- c.call(this, "ZipFileWorker"), this.bytesWritten = 0, this.zipComment = b, this.zipPlatform = f, this.encodeFileName = g, this.streamFiles = h, this.accumulate = !1, this.contentBuffer = [], this.dirRecords = [], this.currentSourceOffset = 0, this.entriesCount = 0, this.currentFile = null, this._sources = [];
766
- }
767
- o.inherits(v, c), v.prototype.push = function(h) {
768
- var b = h.meta.percent || 0, f = this.entriesCount, g = this._sources.length;
769
- this.accumulate ? this.contentBuffer.push(h) : (this.bytesWritten += h.data.length, c.prototype.push.call(this, { data: h.data, meta: { currentFile: this.currentFile, percent: f ? (b + 100 * (f - g - 1)) / f : 100 } }));
770
- }, v.prototype.openedSource = function(h) {
771
- this.currentSourceOffset = this.bytesWritten, this.currentFile = h.file.name;
772
- var b = this.streamFiles && !h.file.dir;
773
- if (b) {
774
- var f = e(h, b, !1, this.currentSourceOffset, this.zipPlatform, this.encodeFileName);
775
- this.push({ data: f.fileRecord, meta: { percent: 0 } });
776
- } else this.accumulate = !0;
777
- }, v.prototype.closedSource = function(h) {
778
- this.accumulate = !1;
779
- var b = this.streamFiles && !h.file.dir, f = e(h, b, !0, this.currentSourceOffset, this.zipPlatform, this.encodeFileName);
780
- if (this.dirRecords.push(f.dirRecord), b) this.push({ data: (function(g) {
781
- return m.DATA_DESCRIPTOR + i(g.crc32, 4) + i(g.compressedSize, 4) + i(g.uncompressedSize, 4);
782
- })(h), meta: { percent: 100 } });
783
- else for (this.push({ data: f.fileRecord, meta: { percent: 0 } }); this.contentBuffer.length; ) this.push(this.contentBuffer.shift());
784
- this.currentFile = null;
785
- }, v.prototype.flush = function() {
786
- for (var h = this.bytesWritten, b = 0; b < this.dirRecords.length; b++) this.push({ data: this.dirRecords[b], meta: { percent: 100 } });
787
- var f = this.bytesWritten - h, g = (function(p, w, S, E, z) {
788
- var P = o.transformTo("string", z(E));
789
- return m.CENTRAL_DIRECTORY_END + "\0\0\0\0" + i(p, 2) + i(p, 2) + i(w, 4) + i(S, 4) + i(P.length, 2) + P;
790
- })(this.dirRecords.length, f, h, this.zipComment, this.encodeFileName);
791
- this.push({ data: g, meta: { percent: 100 } });
792
- }, v.prototype.prepareNextSource = function() {
793
- this.previous = this._sources.shift(), this.openedSource(this.previous.streamInfo), this.isPaused ? this.previous.pause() : this.previous.resume();
794
- }, v.prototype.registerPrevious = function(h) {
795
- this._sources.push(h);
796
- var b = this;
797
- return h.on("data", function(f) {
798
- b.processChunk(f);
799
- }), h.on("end", function() {
800
- b.closedSource(b.previous.streamInfo), b._sources.length ? b.prepareNextSource() : b.end();
801
- }), h.on("error", function(f) {
802
- b.error(f);
803
- }), this;
804
- }, v.prototype.resume = function() {
805
- return !!c.prototype.resume.call(this) && (!this.previous && this._sources.length ? (this.prepareNextSource(), !0) : this.previous || this._sources.length || this.generatedError ? void 0 : (this.end(), !0));
806
- }, v.prototype.error = function(h) {
807
- var b = this._sources;
808
- if (!c.prototype.error.call(this, h)) return !1;
809
- for (var f = 0; f < b.length; f++) try {
810
- b[f].error(h);
811
- } catch {
812
- }
813
- return !0;
814
- }, v.prototype.lock = function() {
815
- c.prototype.lock.call(this);
816
- for (var h = this._sources, b = 0; b < h.length; b++) h[b].lock();
817
- }, l.exports = v;
818
- }, { "../crc32": 4, "../signature": 23, "../stream/GenericWorker": 28, "../utf8": 31, "../utils": 32 }], 9: [function(t, l, s) {
819
- var i = t("../compressions"), e = t("./ZipFileWorker");
820
- s.generateWorker = function(o, c, d) {
821
- var _ = new e(c.streamFiles, d, c.platform, c.encodeFileName), m = 0;
822
- try {
823
- o.forEach(function(v, h) {
824
- m++;
825
- var b = (function(w, S) {
826
- var E = w || S, z = i[E];
827
- if (!z) throw new Error(E + " is not a valid compression method !");
828
- return z;
829
- })(h.options.compression, c.compression), f = h.options.compressionOptions || c.compressionOptions || {}, g = h.dir, p = h.date;
830
- h._compressWorker(b, f).withStreamInfo("file", { name: v, dir: g, date: p, comment: h.comment || "", unixPermissions: h.unixPermissions, dosPermissions: h.dosPermissions }).pipe(_);
831
- }), _.entriesCount = m;
832
- } catch (v) {
833
- _.error(v);
834
- }
835
- return _;
836
- };
837
- }, { "../compressions": 3, "./ZipFileWorker": 8 }], 10: [function(t, l, s) {
838
- function i() {
839
- if (!(this instanceof i)) return new i();
840
- if (arguments.length) throw new Error("The constructor with parameters has been removed in JSZip 3.0, please check the upgrade guide.");
841
- this.files = /* @__PURE__ */ Object.create(null), this.comment = null, this.root = "", this.clone = function() {
842
- var e = new i();
843
- for (var o in this) typeof this[o] != "function" && (e[o] = this[o]);
844
- return e;
845
- };
846
- }
847
- (i.prototype = t("./object")).loadAsync = t("./load"), i.support = t("./support"), i.defaults = t("./defaults"), i.version = "3.10.1", i.loadAsync = function(e, o) {
848
- return new i().loadAsync(e, o);
849
- }, i.external = t("./external"), l.exports = i;
850
- }, { "./defaults": 5, "./external": 6, "./load": 11, "./object": 15, "./support": 30 }], 11: [function(t, l, s) {
851
- var i = t("./utils"), e = t("./external"), o = t("./utf8"), c = t("./zipEntries"), d = t("./stream/Crc32Probe"), _ = t("./nodejsUtils");
852
- function m(v) {
853
- return new e.Promise(function(h, b) {
854
- var f = v.decompressed.getContentWorker().pipe(new d());
855
- f.on("error", function(g) {
856
- b(g);
857
- }).on("end", function() {
858
- f.streamInfo.crc32 !== v.decompressed.crc32 ? b(new Error("Corrupted zip : CRC32 mismatch")) : h();
859
- }).resume();
860
- });
861
- }
862
- l.exports = function(v, h) {
863
- var b = this;
864
- return h = i.extend(h || {}, { base64: !1, checkCRC32: !1, optimizedBinaryString: !1, createFolders: !1, decodeFileName: o.utf8decode }), _.isNode && _.isStream(v) ? e.Promise.reject(new Error("JSZip can't accept a stream when loading a zip file.")) : i.prepareContent("the loaded zip file", v, !0, h.optimizedBinaryString, h.base64).then(function(f) {
865
- var g = new c(h);
866
- return g.load(f), g;
867
- }).then(function(f) {
868
- var g = [e.Promise.resolve(f)], p = f.files;
869
- if (h.checkCRC32) for (var w = 0; w < p.length; w++) g.push(m(p[w]));
870
- return e.Promise.all(g);
871
- }).then(function(f) {
872
- for (var g = f.shift(), p = g.files, w = 0; w < p.length; w++) {
873
- var S = p[w], E = S.fileNameStr, z = i.resolve(S.fileNameStr);
874
- b.file(z, S.decompressed, { binary: !0, optimizedBinaryString: !0, date: S.date, dir: S.dir, comment: S.fileCommentStr.length ? S.fileCommentStr : null, unixPermissions: S.unixPermissions, dosPermissions: S.dosPermissions, createFolders: h.createFolders }), S.dir || (b.file(z).unsafeOriginalName = E);
875
- }
876
- return g.zipComment.length && (b.comment = g.zipComment), b;
877
- });
878
- };
879
- }, { "./external": 6, "./nodejsUtils": 14, "./stream/Crc32Probe": 25, "./utf8": 31, "./utils": 32, "./zipEntries": 33 }], 12: [function(t, l, s) {
880
- var i = t("../utils"), e = t("../stream/GenericWorker");
881
- function o(c, d) {
882
- e.call(this, "Nodejs stream input adapter for " + c), this._upstreamEnded = !1, this._bindStream(d);
883
- }
884
- i.inherits(o, e), o.prototype._bindStream = function(c) {
885
- var d = this;
886
- (this._stream = c).pause(), c.on("data", function(_) {
887
- d.push({ data: _, meta: { percent: 0 } });
888
- }).on("error", function(_) {
889
- d.isPaused ? this.generatedError = _ : d.error(_);
890
- }).on("end", function() {
891
- d.isPaused ? d._upstreamEnded = !0 : d.end();
892
- });
893
- }, o.prototype.pause = function() {
894
- return !!e.prototype.pause.call(this) && (this._stream.pause(), !0);
895
- }, o.prototype.resume = function() {
896
- return !!e.prototype.resume.call(this) && (this._upstreamEnded ? this.end() : this._stream.resume(), !0);
897
- }, l.exports = o;
898
- }, { "../stream/GenericWorker": 28, "../utils": 32 }], 13: [function(t, l, s) {
899
- var i = t("readable-stream").Readable;
900
- function e(o, c, d) {
901
- i.call(this, c), this._helper = o;
902
- var _ = this;
903
- o.on("data", function(m, v) {
904
- _.push(m) || _._helper.pause(), d && d(v);
905
- }).on("error", function(m) {
906
- _.emit("error", m);
907
- }).on("end", function() {
908
- _.push(null);
909
- });
910
- }
911
- t("../utils").inherits(e, i), e.prototype._read = function() {
912
- this._helper.resume();
913
- }, l.exports = e;
914
- }, { "../utils": 32, "readable-stream": 16 }], 14: [function(t, l, s) {
915
- l.exports = { isNode: typeof Buffer < "u", newBufferFrom: function(i, e) {
916
- if (Buffer.from && Buffer.from !== Uint8Array.from) return Buffer.from(i, e);
917
- if (typeof i == "number") throw new Error('The "data" argument must not be a number');
918
- return new Buffer(i, e);
919
- }, allocBuffer: function(i) {
920
- if (Buffer.alloc) return Buffer.alloc(i);
921
- var e = new Buffer(i);
922
- return e.fill(0), e;
923
- }, isBuffer: function(i) {
924
- return Buffer.isBuffer(i);
925
- }, isStream: function(i) {
926
- return i && typeof i.on == "function" && typeof i.pause == "function" && typeof i.resume == "function";
927
- } };
928
- }, {}], 15: [function(t, l, s) {
929
- function i(z, P, D) {
930
- var N, R = o.getTypeOf(P), M = o.extend(D || {}, _);
931
- M.date = M.date || /* @__PURE__ */ new Date(), M.compression !== null && (M.compression = M.compression.toUpperCase()), typeof M.unixPermissions == "string" && (M.unixPermissions = parseInt(M.unixPermissions, 8)), M.unixPermissions && 16384 & M.unixPermissions && (M.dir = !0), M.dosPermissions && 16 & M.dosPermissions && (M.dir = !0), M.dir && (z = p(z)), M.createFolders && (N = g(z)) && w.call(this, N, !0);
932
- var V = R === "string" && M.binary === !1 && M.base64 === !1;
933
- D && D.binary !== void 0 || (M.binary = !V), (P instanceof m && P.uncompressedSize === 0 || M.dir || !P || P.length === 0) && (M.base64 = !1, M.binary = !0, P = "", M.compression = "STORE", R = "string");
934
- var k = null;
935
- k = P instanceof m || P instanceof c ? P : b.isNode && b.isStream(P) ? new f(z, P) : o.prepareContent(z, P, M.binary, M.optimizedBinaryString, M.base64);
936
- var j = new v(z, k, M);
937
- this.files[z] = j;
938
- }
939
- var e = t("./utf8"), o = t("./utils"), c = t("./stream/GenericWorker"), d = t("./stream/StreamHelper"), _ = t("./defaults"), m = t("./compressedObject"), v = t("./zipObject"), h = t("./generate"), b = t("./nodejsUtils"), f = t("./nodejs/NodejsStreamInputAdapter"), g = function(z) {
940
- z.slice(-1) === "/" && (z = z.substring(0, z.length - 1));
941
- var P = z.lastIndexOf("/");
942
- return 0 < P ? z.substring(0, P) : "";
943
- }, p = function(z) {
944
- return z.slice(-1) !== "/" && (z += "/"), z;
945
- }, w = function(z, P) {
946
- return P = P !== void 0 ? P : _.createFolders, z = p(z), this.files[z] || i.call(this, z, null, { dir: !0, createFolders: P }), this.files[z];
947
- };
948
- function S(z) {
949
- return Object.prototype.toString.call(z) === "[object RegExp]";
950
- }
951
- var E = { load: function() {
952
- throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.");
953
- }, forEach: function(z) {
954
- var P, D, N;
955
- for (P in this.files) N = this.files[P], (D = P.slice(this.root.length, P.length)) && P.slice(0, this.root.length) === this.root && z(D, N);
956
- }, filter: function(z) {
957
- var P = [];
958
- return this.forEach(function(D, N) {
959
- z(D, N) && P.push(N);
960
- }), P;
961
- }, file: function(z, P, D) {
962
- if (arguments.length !== 1) return z = this.root + z, i.call(this, z, P, D), this;
963
- if (S(z)) {
964
- var N = z;
965
- return this.filter(function(M, V) {
966
- return !V.dir && N.test(M);
967
- });
968
- }
969
- var R = this.files[this.root + z];
970
- return R && !R.dir ? R : null;
971
- }, folder: function(z) {
972
- if (!z) return this;
973
- if (S(z)) return this.filter(function(R, M) {
974
- return M.dir && z.test(R);
975
- });
976
- var P = this.root + z, D = w.call(this, P), N = this.clone();
977
- return N.root = D.name, N;
978
- }, remove: function(z) {
979
- z = this.root + z;
980
- var P = this.files[z];
981
- if (P || (z.slice(-1) !== "/" && (z += "/"), P = this.files[z]), P && !P.dir) delete this.files[z];
982
- else for (var D = this.filter(function(R, M) {
983
- return M.name.slice(0, z.length) === z;
984
- }), N = 0; N < D.length; N++) delete this.files[D[N].name];
985
- return this;
986
- }, generate: function() {
987
- throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.");
988
- }, generateInternalStream: function(z) {
989
- var P, D = {};
990
- try {
991
- if ((D = o.extend(z || {}, { streamFiles: !1, compression: "STORE", compressionOptions: null, type: "", platform: "DOS", comment: null, mimeType: "application/zip", encodeFileName: e.utf8encode })).type = D.type.toLowerCase(), D.compression = D.compression.toUpperCase(), D.type === "binarystring" && (D.type = "string"), !D.type) throw new Error("No output type specified.");
992
- o.checkSupport(D.type), D.platform !== "darwin" && D.platform !== "freebsd" && D.platform !== "linux" && D.platform !== "sunos" || (D.platform = "UNIX"), D.platform === "win32" && (D.platform = "DOS");
993
- var N = D.comment || this.comment || "";
994
- P = h.generateWorker(this, D, N);
995
- } catch (R) {
996
- (P = new c("error")).error(R);
997
- }
998
- return new d(P, D.type || "string", D.mimeType);
999
- }, generateAsync: function(z, P) {
1000
- return this.generateInternalStream(z).accumulate(P);
1001
- }, generateNodeStream: function(z, P) {
1002
- return (z = z || {}).type || (z.type = "nodebuffer"), this.generateInternalStream(z).toNodejsStream(P);
1003
- } };
1004
- l.exports = E;
1005
- }, { "./compressedObject": 2, "./defaults": 5, "./generate": 9, "./nodejs/NodejsStreamInputAdapter": 12, "./nodejsUtils": 14, "./stream/GenericWorker": 28, "./stream/StreamHelper": 29, "./utf8": 31, "./utils": 32, "./zipObject": 35 }], 16: [function(t, l, s) {
1006
- l.exports = t("stream");
1007
- }, { stream: void 0 }], 17: [function(t, l, s) {
1008
- var i = t("./DataReader");
1009
- function e(o) {
1010
- i.call(this, o);
1011
- for (var c = 0; c < this.data.length; c++) o[c] = 255 & o[c];
1012
- }
1013
- t("../utils").inherits(e, i), e.prototype.byteAt = function(o) {
1014
- return this.data[this.zero + o];
1015
- }, e.prototype.lastIndexOfSignature = function(o) {
1016
- for (var c = o.charCodeAt(0), d = o.charCodeAt(1), _ = o.charCodeAt(2), m = o.charCodeAt(3), v = this.length - 4; 0 <= v; --v) if (this.data[v] === c && this.data[v + 1] === d && this.data[v + 2] === _ && this.data[v + 3] === m) return v - this.zero;
1017
- return -1;
1018
- }, e.prototype.readAndCheckSignature = function(o) {
1019
- var c = o.charCodeAt(0), d = o.charCodeAt(1), _ = o.charCodeAt(2), m = o.charCodeAt(3), v = this.readData(4);
1020
- return c === v[0] && d === v[1] && _ === v[2] && m === v[3];
1021
- }, e.prototype.readData = function(o) {
1022
- if (this.checkOffset(o), o === 0) return [];
1023
- var c = this.data.slice(this.zero + this.index, this.zero + this.index + o);
1024
- return this.index += o, c;
1025
- }, l.exports = e;
1026
- }, { "../utils": 32, "./DataReader": 18 }], 18: [function(t, l, s) {
1027
- var i = t("../utils");
1028
- function e(o) {
1029
- this.data = o, this.length = o.length, this.index = 0, this.zero = 0;
1030
- }
1031
- e.prototype = { checkOffset: function(o) {
1032
- this.checkIndex(this.index + o);
1033
- }, checkIndex: function(o) {
1034
- if (this.length < this.zero + o || o < 0) throw new Error("End of data reached (data length = " + this.length + ", asked index = " + o + "). Corrupted zip ?");
1035
- }, setIndex: function(o) {
1036
- this.checkIndex(o), this.index = o;
1037
- }, skip: function(o) {
1038
- this.setIndex(this.index + o);
1039
- }, byteAt: function() {
1040
- }, readInt: function(o) {
1041
- var c, d = 0;
1042
- for (this.checkOffset(o), c = this.index + o - 1; c >= this.index; c--) d = (d << 8) + this.byteAt(c);
1043
- return this.index += o, d;
1044
- }, readString: function(o) {
1045
- return i.transformTo("string", this.readData(o));
1046
- }, readData: function() {
1047
- }, lastIndexOfSignature: function() {
1048
- }, readAndCheckSignature: function() {
1049
- }, readDate: function() {
1050
- var o = this.readInt(4);
1051
- return new Date(Date.UTC(1980 + (o >> 25 & 127), (o >> 21 & 15) - 1, o >> 16 & 31, o >> 11 & 31, o >> 5 & 63, (31 & o) << 1));
1052
- } }, l.exports = e;
1053
- }, { "../utils": 32 }], 19: [function(t, l, s) {
1054
- var i = t("./Uint8ArrayReader");
1055
- function e(o) {
1056
- i.call(this, o);
1057
- }
1058
- t("../utils").inherits(e, i), e.prototype.readData = function(o) {
1059
- this.checkOffset(o);
1060
- var c = this.data.slice(this.zero + this.index, this.zero + this.index + o);
1061
- return this.index += o, c;
1062
- }, l.exports = e;
1063
- }, { "../utils": 32, "./Uint8ArrayReader": 21 }], 20: [function(t, l, s) {
1064
- var i = t("./DataReader");
1065
- function e(o) {
1066
- i.call(this, o);
1067
- }
1068
- t("../utils").inherits(e, i), e.prototype.byteAt = function(o) {
1069
- return this.data.charCodeAt(this.zero + o);
1070
- }, e.prototype.lastIndexOfSignature = function(o) {
1071
- return this.data.lastIndexOf(o) - this.zero;
1072
- }, e.prototype.readAndCheckSignature = function(o) {
1073
- return o === this.readData(4);
1074
- }, e.prototype.readData = function(o) {
1075
- this.checkOffset(o);
1076
- var c = this.data.slice(this.zero + this.index, this.zero + this.index + o);
1077
- return this.index += o, c;
1078
- }, l.exports = e;
1079
- }, { "../utils": 32, "./DataReader": 18 }], 21: [function(t, l, s) {
1080
- var i = t("./ArrayReader");
1081
- function e(o) {
1082
- i.call(this, o);
1083
- }
1084
- t("../utils").inherits(e, i), e.prototype.readData = function(o) {
1085
- if (this.checkOffset(o), o === 0) return new Uint8Array(0);
1086
- var c = this.data.subarray(this.zero + this.index, this.zero + this.index + o);
1087
- return this.index += o, c;
1088
- }, l.exports = e;
1089
- }, { "../utils": 32, "./ArrayReader": 17 }], 22: [function(t, l, s) {
1090
- var i = t("../utils"), e = t("../support"), o = t("./ArrayReader"), c = t("./StringReader"), d = t("./NodeBufferReader"), _ = t("./Uint8ArrayReader");
1091
- l.exports = function(m) {
1092
- var v = i.getTypeOf(m);
1093
- return i.checkSupport(v), v !== "string" || e.uint8array ? v === "nodebuffer" ? new d(m) : e.uint8array ? new _(i.transformTo("uint8array", m)) : new o(i.transformTo("array", m)) : new c(m);
1094
- };
1095
- }, { "../support": 30, "../utils": 32, "./ArrayReader": 17, "./NodeBufferReader": 19, "./StringReader": 20, "./Uint8ArrayReader": 21 }], 23: [function(t, l, s) {
1096
- s.LOCAL_FILE_HEADER = "PK", s.CENTRAL_FILE_HEADER = "PK", s.CENTRAL_DIRECTORY_END = "PK", s.ZIP64_CENTRAL_DIRECTORY_LOCATOR = "PK\x07", s.ZIP64_CENTRAL_DIRECTORY_END = "PK", s.DATA_DESCRIPTOR = "PK\x07\b";
1097
- }, {}], 24: [function(t, l, s) {
1098
- var i = t("./GenericWorker"), e = t("../utils");
1099
- function o(c) {
1100
- i.call(this, "ConvertWorker to " + c), this.destType = c;
1101
- }
1102
- e.inherits(o, i), o.prototype.processChunk = function(c) {
1103
- this.push({ data: e.transformTo(this.destType, c.data), meta: c.meta });
1104
- }, l.exports = o;
1105
- }, { "../utils": 32, "./GenericWorker": 28 }], 25: [function(t, l, s) {
1106
- var i = t("./GenericWorker"), e = t("../crc32");
1107
- function o() {
1108
- i.call(this, "Crc32Probe"), this.withStreamInfo("crc32", 0);
1109
- }
1110
- t("../utils").inherits(o, i), o.prototype.processChunk = function(c) {
1111
- this.streamInfo.crc32 = e(c.data, this.streamInfo.crc32 || 0), this.push(c);
1112
- }, l.exports = o;
1113
- }, { "../crc32": 4, "../utils": 32, "./GenericWorker": 28 }], 26: [function(t, l, s) {
1114
- var i = t("../utils"), e = t("./GenericWorker");
1115
- function o(c) {
1116
- e.call(this, "DataLengthProbe for " + c), this.propName = c, this.withStreamInfo(c, 0);
1117
- }
1118
- i.inherits(o, e), o.prototype.processChunk = function(c) {
1119
- if (c) {
1120
- var d = this.streamInfo[this.propName] || 0;
1121
- this.streamInfo[this.propName] = d + c.data.length;
1122
- }
1123
- e.prototype.processChunk.call(this, c);
1124
- }, l.exports = o;
1125
- }, { "../utils": 32, "./GenericWorker": 28 }], 27: [function(t, l, s) {
1126
- var i = t("../utils"), e = t("./GenericWorker");
1127
- function o(c) {
1128
- e.call(this, "DataWorker");
1129
- var d = this;
1130
- this.dataIsReady = !1, this.index = 0, this.max = 0, this.data = null, this.type = "", this._tickScheduled = !1, c.then(function(_) {
1131
- d.dataIsReady = !0, d.data = _, d.max = _ && _.length || 0, d.type = i.getTypeOf(_), d.isPaused || d._tickAndRepeat();
1132
- }, function(_) {
1133
- d.error(_);
1134
- });
1135
- }
1136
- i.inherits(o, e), o.prototype.cleanUp = function() {
1137
- e.prototype.cleanUp.call(this), this.data = null;
1138
- }, o.prototype.resume = function() {
1139
- return !!e.prototype.resume.call(this) && (!this._tickScheduled && this.dataIsReady && (this._tickScheduled = !0, i.delay(this._tickAndRepeat, [], this)), !0);
1140
- }, o.prototype._tickAndRepeat = function() {
1141
- this._tickScheduled = !1, this.isPaused || this.isFinished || (this._tick(), this.isFinished || (i.delay(this._tickAndRepeat, [], this), this._tickScheduled = !0));
1142
- }, o.prototype._tick = function() {
1143
- if (this.isPaused || this.isFinished) return !1;
1144
- var c = null, d = Math.min(this.max, this.index + 16384);
1145
- if (this.index >= this.max) return this.end();
1146
- switch (this.type) {
1147
- case "string":
1148
- c = this.data.substring(this.index, d);
1149
- break;
1150
- case "uint8array":
1151
- c = this.data.subarray(this.index, d);
1152
- break;
1153
- case "array":
1154
- case "nodebuffer":
1155
- c = this.data.slice(this.index, d);
1156
- }
1157
- return this.index = d, this.push({ data: c, meta: { percent: this.max ? this.index / this.max * 100 : 0 } });
1158
- }, l.exports = o;
1159
- }, { "../utils": 32, "./GenericWorker": 28 }], 28: [function(t, l, s) {
1160
- function i(e) {
1161
- this.name = e || "default", this.streamInfo = {}, this.generatedError = null, this.extraStreamInfo = {}, this.isPaused = !0, this.isFinished = !1, this.isLocked = !1, this._listeners = { data: [], end: [], error: [] }, this.previous = null;
1162
- }
1163
- i.prototype = { push: function(e) {
1164
- this.emit("data", e);
1165
- }, end: function() {
1166
- if (this.isFinished) return !1;
1167
- this.flush();
1168
- try {
1169
- this.emit("end"), this.cleanUp(), this.isFinished = !0;
1170
- } catch (e) {
1171
- this.emit("error", e);
1172
- }
1173
- return !0;
1174
- }, error: function(e) {
1175
- return !this.isFinished && (this.isPaused ? this.generatedError = e : (this.isFinished = !0, this.emit("error", e), this.previous && this.previous.error(e), this.cleanUp()), !0);
1176
- }, on: function(e, o) {
1177
- return this._listeners[e].push(o), this;
1178
- }, cleanUp: function() {
1179
- this.streamInfo = this.generatedError = this.extraStreamInfo = null, this._listeners = [];
1180
- }, emit: function(e, o) {
1181
- if (this._listeners[e]) for (var c = 0; c < this._listeners[e].length; c++) this._listeners[e][c].call(this, o);
1182
- }, pipe: function(e) {
1183
- return e.registerPrevious(this);
1184
- }, registerPrevious: function(e) {
1185
- if (this.isLocked) throw new Error("The stream '" + this + "' has already been used.");
1186
- this.streamInfo = e.streamInfo, this.mergeStreamInfo(), this.previous = e;
1187
- var o = this;
1188
- return e.on("data", function(c) {
1189
- o.processChunk(c);
1190
- }), e.on("end", function() {
1191
- o.end();
1192
- }), e.on("error", function(c) {
1193
- o.error(c);
1194
- }), this;
1195
- }, pause: function() {
1196
- return !this.isPaused && !this.isFinished && (this.isPaused = !0, this.previous && this.previous.pause(), !0);
1197
- }, resume: function() {
1198
- if (!this.isPaused || this.isFinished) return !1;
1199
- var e = this.isPaused = !1;
1200
- return this.generatedError && (this.error(this.generatedError), e = !0), this.previous && this.previous.resume(), !e;
1201
- }, flush: function() {
1202
- }, processChunk: function(e) {
1203
- this.push(e);
1204
- }, withStreamInfo: function(e, o) {
1205
- return this.extraStreamInfo[e] = o, this.mergeStreamInfo(), this;
1206
- }, mergeStreamInfo: function() {
1207
- for (var e in this.extraStreamInfo) Object.prototype.hasOwnProperty.call(this.extraStreamInfo, e) && (this.streamInfo[e] = this.extraStreamInfo[e]);
1208
- }, lock: function() {
1209
- if (this.isLocked) throw new Error("The stream '" + this + "' has already been used.");
1210
- this.isLocked = !0, this.previous && this.previous.lock();
1211
- }, toString: function() {
1212
- var e = "Worker " + this.name;
1213
- return this.previous ? this.previous + " -> " + e : e;
1214
- } }, l.exports = i;
1215
- }, {}], 29: [function(t, l, s) {
1216
- var i = t("../utils"), e = t("./ConvertWorker"), o = t("./GenericWorker"), c = t("../base64"), d = t("../support"), _ = t("../external"), m = null;
1217
- if (d.nodestream) try {
1218
- m = t("../nodejs/NodejsStreamOutputAdapter");
1219
- } catch {
1220
- }
1221
- function v(b, f) {
1222
- return new _.Promise(function(g, p) {
1223
- var w = [], S = b._internalType, E = b._outputType, z = b._mimeType;
1224
- b.on("data", function(P, D) {
1225
- w.push(P), f && f(D);
1226
- }).on("error", function(P) {
1227
- w = [], p(P);
1228
- }).on("end", function() {
1229
- try {
1230
- var P = (function(D, N, R) {
1231
- switch (D) {
1232
- case "blob":
1233
- return i.newBlob(i.transformTo("arraybuffer", N), R);
1234
- case "base64":
1235
- return c.encode(N);
1236
- default:
1237
- return i.transformTo(D, N);
1238
- }
1239
- })(E, (function(D, N) {
1240
- var R, M = 0, V = null, k = 0;
1241
- for (R = 0; R < N.length; R++) k += N[R].length;
1242
- switch (D) {
1243
- case "string":
1244
- return N.join("");
1245
- case "array":
1246
- return Array.prototype.concat.apply([], N);
1247
- case "uint8array":
1248
- for (V = new Uint8Array(k), R = 0; R < N.length; R++) V.set(N[R], M), M += N[R].length;
1249
- return V;
1250
- case "nodebuffer":
1251
- return Buffer.concat(N);
1252
- default:
1253
- throw new Error("concat : unsupported type '" + D + "'");
1254
- }
1255
- })(S, w), z);
1256
- g(P);
1257
- } catch (D) {
1258
- p(D);
1259
- }
1260
- w = [];
1261
- }).resume();
1262
- });
1263
- }
1264
- function h(b, f, g) {
1265
- var p = f;
1266
- switch (f) {
1267
- case "blob":
1268
- case "arraybuffer":
1269
- p = "uint8array";
1270
- break;
1271
- case "base64":
1272
- p = "string";
1273
- }
1274
- try {
1275
- this._internalType = p, this._outputType = f, this._mimeType = g, i.checkSupport(p), this._worker = b.pipe(new e(p)), b.lock();
1276
- } catch (w) {
1277
- this._worker = new o("error"), this._worker.error(w);
1278
- }
1279
- }
1280
- h.prototype = { accumulate: function(b) {
1281
- return v(this, b);
1282
- }, on: function(b, f) {
1283
- var g = this;
1284
- return b === "data" ? this._worker.on(b, function(p) {
1285
- f.call(g, p.data, p.meta);
1286
- }) : this._worker.on(b, function() {
1287
- i.delay(f, arguments, g);
1288
- }), this;
1289
- }, resume: function() {
1290
- return i.delay(this._worker.resume, [], this._worker), this;
1291
- }, pause: function() {
1292
- return this._worker.pause(), this;
1293
- }, toNodejsStream: function(b) {
1294
- if (i.checkSupport("nodestream"), this._outputType !== "nodebuffer") throw new Error(this._outputType + " is not supported by this method");
1295
- return new m(this, { objectMode: this._outputType !== "nodebuffer" }, b);
1296
- } }, l.exports = h;
1297
- }, { "../base64": 1, "../external": 6, "../nodejs/NodejsStreamOutputAdapter": 13, "../support": 30, "../utils": 32, "./ConvertWorker": 24, "./GenericWorker": 28 }], 30: [function(t, l, s) {
1298
- if (s.base64 = !0, s.array = !0, s.string = !0, s.arraybuffer = typeof ArrayBuffer < "u" && typeof Uint8Array < "u", s.nodebuffer = typeof Buffer < "u", s.uint8array = typeof Uint8Array < "u", typeof ArrayBuffer > "u") s.blob = !1;
1299
- else {
1300
- var i = new ArrayBuffer(0);
1301
- try {
1302
- s.blob = new Blob([i], { type: "application/zip" }).size === 0;
1303
- } catch {
1304
- try {
1305
- var e = new (self.BlobBuilder || self.WebKitBlobBuilder || self.MozBlobBuilder || self.MSBlobBuilder)();
1306
- e.append(i), s.blob = e.getBlob("application/zip").size === 0;
1307
- } catch {
1308
- s.blob = !1;
1309
- }
1310
- }
1311
- }
1312
- try {
1313
- s.nodestream = !!t("readable-stream").Readable;
1314
- } catch {
1315
- s.nodestream = !1;
1316
- }
1317
- }, { "readable-stream": 16 }], 31: [function(t, l, s) {
1318
- for (var i = t("./utils"), e = t("./support"), o = t("./nodejsUtils"), c = t("./stream/GenericWorker"), d = new Array(256), _ = 0; _ < 256; _++) d[_] = 252 <= _ ? 6 : 248 <= _ ? 5 : 240 <= _ ? 4 : 224 <= _ ? 3 : 192 <= _ ? 2 : 1;
1319
- d[254] = d[254] = 1;
1320
- function m() {
1321
- c.call(this, "utf-8 decode"), this.leftOver = null;
1322
- }
1323
- function v() {
1324
- c.call(this, "utf-8 encode");
1325
- }
1326
- s.utf8encode = function(h) {
1327
- return e.nodebuffer ? o.newBufferFrom(h, "utf-8") : (function(b) {
1328
- var f, g, p, w, S, E = b.length, z = 0;
1329
- for (w = 0; w < E; w++) (64512 & (g = b.charCodeAt(w))) == 55296 && w + 1 < E && (64512 & (p = b.charCodeAt(w + 1))) == 56320 && (g = 65536 + (g - 55296 << 10) + (p - 56320), w++), z += g < 128 ? 1 : g < 2048 ? 2 : g < 65536 ? 3 : 4;
1330
- for (f = e.uint8array ? new Uint8Array(z) : new Array(z), w = S = 0; S < z; w++) (64512 & (g = b.charCodeAt(w))) == 55296 && w + 1 < E && (64512 & (p = b.charCodeAt(w + 1))) == 56320 && (g = 65536 + (g - 55296 << 10) + (p - 56320), w++), g < 128 ? f[S++] = g : (g < 2048 ? f[S++] = 192 | g >>> 6 : (g < 65536 ? f[S++] = 224 | g >>> 12 : (f[S++] = 240 | g >>> 18, f[S++] = 128 | g >>> 12 & 63), f[S++] = 128 | g >>> 6 & 63), f[S++] = 128 | 63 & g);
1331
- return f;
1332
- })(h);
1333
- }, s.utf8decode = function(h) {
1334
- return e.nodebuffer ? i.transformTo("nodebuffer", h).toString("utf-8") : (function(b) {
1335
- var f, g, p, w, S = b.length, E = new Array(2 * S);
1336
- for (f = g = 0; f < S; ) if ((p = b[f++]) < 128) E[g++] = p;
1337
- else if (4 < (w = d[p])) E[g++] = 65533, f += w - 1;
1338
- else {
1339
- for (p &= w === 2 ? 31 : w === 3 ? 15 : 7; 1 < w && f < S; ) p = p << 6 | 63 & b[f++], w--;
1340
- 1 < w ? E[g++] = 65533 : p < 65536 ? E[g++] = p : (p -= 65536, E[g++] = 55296 | p >> 10 & 1023, E[g++] = 56320 | 1023 & p);
1341
- }
1342
- return E.length !== g && (E.subarray ? E = E.subarray(0, g) : E.length = g), i.applyFromCharCode(E);
1343
- })(h = i.transformTo(e.uint8array ? "uint8array" : "array", h));
1344
- }, i.inherits(m, c), m.prototype.processChunk = function(h) {
1345
- var b = i.transformTo(e.uint8array ? "uint8array" : "array", h.data);
1346
- if (this.leftOver && this.leftOver.length) {
1347
- if (e.uint8array) {
1348
- var f = b;
1349
- (b = new Uint8Array(f.length + this.leftOver.length)).set(this.leftOver, 0), b.set(f, this.leftOver.length);
1350
- } else b = this.leftOver.concat(b);
1351
- this.leftOver = null;
1352
- }
1353
- var g = (function(w, S) {
1354
- var E;
1355
- for ((S = S || w.length) > w.length && (S = w.length), E = S - 1; 0 <= E && (192 & w[E]) == 128; ) E--;
1356
- return E < 0 || E === 0 ? S : E + d[w[E]] > S ? E : S;
1357
- })(b), p = b;
1358
- g !== b.length && (e.uint8array ? (p = b.subarray(0, g), this.leftOver = b.subarray(g, b.length)) : (p = b.slice(0, g), this.leftOver = b.slice(g, b.length))), this.push({ data: s.utf8decode(p), meta: h.meta });
1359
- }, m.prototype.flush = function() {
1360
- this.leftOver && this.leftOver.length && (this.push({ data: s.utf8decode(this.leftOver), meta: {} }), this.leftOver = null);
1361
- }, s.Utf8DecodeWorker = m, i.inherits(v, c), v.prototype.processChunk = function(h) {
1362
- this.push({ data: s.utf8encode(h.data), meta: h.meta });
1363
- }, s.Utf8EncodeWorker = v;
1364
- }, { "./nodejsUtils": 14, "./stream/GenericWorker": 28, "./support": 30, "./utils": 32 }], 32: [function(t, l, s) {
1365
- var i = t("./support"), e = t("./base64"), o = t("./nodejsUtils"), c = t("./external");
1366
- function d(f) {
1367
- return f;
1368
- }
1369
- function _(f, g) {
1370
- for (var p = 0; p < f.length; ++p) g[p] = 255 & f.charCodeAt(p);
1371
- return g;
1372
- }
1373
- t("setimmediate"), s.newBlob = function(f, g) {
1374
- s.checkSupport("blob");
1375
- try {
1376
- return new Blob([f], { type: g });
1377
- } catch {
1378
- try {
1379
- var p = new (self.BlobBuilder || self.WebKitBlobBuilder || self.MozBlobBuilder || self.MSBlobBuilder)();
1380
- return p.append(f), p.getBlob(g);
1381
- } catch {
1382
- throw new Error("Bug : can't construct the Blob.");
1383
- }
1384
- }
1385
- };
1386
- var m = { stringifyByChunk: function(f, g, p) {
1387
- var w = [], S = 0, E = f.length;
1388
- if (E <= p) return String.fromCharCode.apply(null, f);
1389
- for (; S < E; ) g === "array" || g === "nodebuffer" ? w.push(String.fromCharCode.apply(null, f.slice(S, Math.min(S + p, E)))) : w.push(String.fromCharCode.apply(null, f.subarray(S, Math.min(S + p, E)))), S += p;
1390
- return w.join("");
1391
- }, stringifyByChar: function(f) {
1392
- for (var g = "", p = 0; p < f.length; p++) g += String.fromCharCode(f[p]);
1393
- return g;
1394
- }, applyCanBeUsed: { uint8array: (function() {
1395
- try {
1396
- return i.uint8array && String.fromCharCode.apply(null, new Uint8Array(1)).length === 1;
1397
- } catch {
1398
- return !1;
1399
- }
1400
- })(), nodebuffer: (function() {
1401
- try {
1402
- return i.nodebuffer && String.fromCharCode.apply(null, o.allocBuffer(1)).length === 1;
1403
- } catch {
1404
- return !1;
1405
- }
1406
- })() } };
1407
- function v(f) {
1408
- var g = 65536, p = s.getTypeOf(f), w = !0;
1409
- if (p === "uint8array" ? w = m.applyCanBeUsed.uint8array : p === "nodebuffer" && (w = m.applyCanBeUsed.nodebuffer), w) for (; 1 < g; ) try {
1410
- return m.stringifyByChunk(f, p, g);
1411
- } catch {
1412
- g = Math.floor(g / 2);
1413
- }
1414
- return m.stringifyByChar(f);
1415
- }
1416
- function h(f, g) {
1417
- for (var p = 0; p < f.length; p++) g[p] = f[p];
1418
- return g;
1419
- }
1420
- s.applyFromCharCode = v;
1421
- var b = {};
1422
- b.string = { string: d, array: function(f) {
1423
- return _(f, new Array(f.length));
1424
- }, arraybuffer: function(f) {
1425
- return b.string.uint8array(f).buffer;
1426
- }, uint8array: function(f) {
1427
- return _(f, new Uint8Array(f.length));
1428
- }, nodebuffer: function(f) {
1429
- return _(f, o.allocBuffer(f.length));
1430
- } }, b.array = { string: v, array: d, arraybuffer: function(f) {
1431
- return new Uint8Array(f).buffer;
1432
- }, uint8array: function(f) {
1433
- return new Uint8Array(f);
1434
- }, nodebuffer: function(f) {
1435
- return o.newBufferFrom(f);
1436
- } }, b.arraybuffer = { string: function(f) {
1437
- return v(new Uint8Array(f));
1438
- }, array: function(f) {
1439
- return h(new Uint8Array(f), new Array(f.byteLength));
1440
- }, arraybuffer: d, uint8array: function(f) {
1441
- return new Uint8Array(f);
1442
- }, nodebuffer: function(f) {
1443
- return o.newBufferFrom(new Uint8Array(f));
1444
- } }, b.uint8array = { string: v, array: function(f) {
1445
- return h(f, new Array(f.length));
1446
- }, arraybuffer: function(f) {
1447
- return f.buffer;
1448
- }, uint8array: d, nodebuffer: function(f) {
1449
- return o.newBufferFrom(f);
1450
- } }, b.nodebuffer = { string: v, array: function(f) {
1451
- return h(f, new Array(f.length));
1452
- }, arraybuffer: function(f) {
1453
- return b.nodebuffer.uint8array(f).buffer;
1454
- }, uint8array: function(f) {
1455
- return h(f, new Uint8Array(f.length));
1456
- }, nodebuffer: d }, s.transformTo = function(f, g) {
1457
- if (g = g || "", !f) return g;
1458
- s.checkSupport(f);
1459
- var p = s.getTypeOf(g);
1460
- return b[p][f](g);
1461
- }, s.resolve = function(f) {
1462
- for (var g = f.split("/"), p = [], w = 0; w < g.length; w++) {
1463
- var S = g[w];
1464
- S === "." || S === "" && w !== 0 && w !== g.length - 1 || (S === ".." ? p.pop() : p.push(S));
1465
- }
1466
- return p.join("/");
1467
- }, s.getTypeOf = function(f) {
1468
- return typeof f == "string" ? "string" : Object.prototype.toString.call(f) === "[object Array]" ? "array" : i.nodebuffer && o.isBuffer(f) ? "nodebuffer" : i.uint8array && f instanceof Uint8Array ? "uint8array" : i.arraybuffer && f instanceof ArrayBuffer ? "arraybuffer" : void 0;
1469
- }, s.checkSupport = function(f) {
1470
- if (!i[f.toLowerCase()]) throw new Error(f + " is not supported by this platform");
1471
- }, s.MAX_VALUE_16BITS = 65535, s.MAX_VALUE_32BITS = -1, s.pretty = function(f) {
1472
- var g, p, w = "";
1473
- for (p = 0; p < (f || "").length; p++) w += "\\x" + ((g = f.charCodeAt(p)) < 16 ? "0" : "") + g.toString(16).toUpperCase();
1474
- return w;
1475
- }, s.delay = function(f, g, p) {
1476
- setImmediate(function() {
1477
- f.apply(p || null, g || []);
1478
- });
1479
- }, s.inherits = function(f, g) {
1480
- function p() {
1481
- }
1482
- p.prototype = g.prototype, f.prototype = new p();
1483
- }, s.extend = function() {
1484
- var f, g, p = {};
1485
- for (f = 0; f < arguments.length; f++) for (g in arguments[f]) Object.prototype.hasOwnProperty.call(arguments[f], g) && p[g] === void 0 && (p[g] = arguments[f][g]);
1486
- return p;
1487
- }, s.prepareContent = function(f, g, p, w, S) {
1488
- return c.Promise.resolve(g).then(function(E) {
1489
- return i.blob && (E instanceof Blob || ["[object File]", "[object Blob]"].indexOf(Object.prototype.toString.call(E)) !== -1) && typeof FileReader < "u" ? new c.Promise(function(z, P) {
1490
- var D = new FileReader();
1491
- D.onload = function(N) {
1492
- z(N.target.result);
1493
- }, D.onerror = function(N) {
1494
- P(N.target.error);
1495
- }, D.readAsArrayBuffer(E);
1496
- }) : E;
1497
- }).then(function(E) {
1498
- var z = s.getTypeOf(E);
1499
- return z ? (z === "arraybuffer" ? E = s.transformTo("uint8array", E) : z === "string" && (S ? E = e.decode(E) : p && w !== !0 && (E = (function(P) {
1500
- return _(P, i.uint8array ? new Uint8Array(P.length) : new Array(P.length));
1501
- })(E))), E) : c.Promise.reject(new Error("Can't read the data of '" + f + "'. Is it in a supported JavaScript type (String, Blob, ArrayBuffer, etc) ?"));
1502
- });
1503
- };
1504
- }, { "./base64": 1, "./external": 6, "./nodejsUtils": 14, "./support": 30, setimmediate: 54 }], 33: [function(t, l, s) {
1505
- var i = t("./reader/readerFor"), e = t("./utils"), o = t("./signature"), c = t("./zipEntry"), d = t("./support");
1506
- function _(m) {
1507
- this.files = [], this.loadOptions = m;
1508
- }
1509
- _.prototype = { checkSignature: function(m) {
1510
- if (!this.reader.readAndCheckSignature(m)) {
1511
- this.reader.index -= 4;
1512
- var v = this.reader.readString(4);
1513
- throw new Error("Corrupted zip or bug: unexpected signature (" + e.pretty(v) + ", expected " + e.pretty(m) + ")");
1514
- }
1515
- }, isSignature: function(m, v) {
1516
- var h = this.reader.index;
1517
- this.reader.setIndex(m);
1518
- var b = this.reader.readString(4) === v;
1519
- return this.reader.setIndex(h), b;
1520
- }, readBlockEndOfCentral: function() {
1521
- this.diskNumber = this.reader.readInt(2), this.diskWithCentralDirStart = this.reader.readInt(2), this.centralDirRecordsOnThisDisk = this.reader.readInt(2), this.centralDirRecords = this.reader.readInt(2), this.centralDirSize = this.reader.readInt(4), this.centralDirOffset = this.reader.readInt(4), this.zipCommentLength = this.reader.readInt(2);
1522
- var m = this.reader.readData(this.zipCommentLength), v = d.uint8array ? "uint8array" : "array", h = e.transformTo(v, m);
1523
- this.zipComment = this.loadOptions.decodeFileName(h);
1524
- }, readBlockZip64EndOfCentral: function() {
1525
- this.zip64EndOfCentralSize = this.reader.readInt(8), this.reader.skip(4), this.diskNumber = this.reader.readInt(4), this.diskWithCentralDirStart = this.reader.readInt(4), this.centralDirRecordsOnThisDisk = this.reader.readInt(8), this.centralDirRecords = this.reader.readInt(8), this.centralDirSize = this.reader.readInt(8), this.centralDirOffset = this.reader.readInt(8), this.zip64ExtensibleData = {};
1526
- for (var m, v, h, b = this.zip64EndOfCentralSize - 44; 0 < b; ) m = this.reader.readInt(2), v = this.reader.readInt(4), h = this.reader.readData(v), this.zip64ExtensibleData[m] = { id: m, length: v, value: h };
1527
- }, readBlockZip64EndOfCentralLocator: function() {
1528
- if (this.diskWithZip64CentralDirStart = this.reader.readInt(4), this.relativeOffsetEndOfZip64CentralDir = this.reader.readInt(8), this.disksCount = this.reader.readInt(4), 1 < this.disksCount) throw new Error("Multi-volumes zip are not supported");
1529
- }, readLocalFiles: function() {
1530
- var m, v;
1531
- for (m = 0; m < this.files.length; m++) v = this.files[m], this.reader.setIndex(v.localHeaderOffset), this.checkSignature(o.LOCAL_FILE_HEADER), v.readLocalPart(this.reader), v.handleUTF8(), v.processAttributes();
1532
- }, readCentralDir: function() {
1533
- var m;
1534
- for (this.reader.setIndex(this.centralDirOffset); this.reader.readAndCheckSignature(o.CENTRAL_FILE_HEADER); ) (m = new c({ zip64: this.zip64 }, this.loadOptions)).readCentralPart(this.reader), this.files.push(m);
1535
- if (this.centralDirRecords !== this.files.length && this.centralDirRecords !== 0 && this.files.length === 0) throw new Error("Corrupted zip or bug: expected " + this.centralDirRecords + " records in central dir, got " + this.files.length);
1536
- }, readEndOfCentral: function() {
1537
- var m = this.reader.lastIndexOfSignature(o.CENTRAL_DIRECTORY_END);
1538
- if (m < 0) throw this.isSignature(0, o.LOCAL_FILE_HEADER) ? new Error("Corrupted zip: can't find end of central directory") : new Error("Can't find end of central directory : is this a zip file ? If it is, see https://stuk.github.io/jszip/documentation/howto/read_zip.html");
1539
- this.reader.setIndex(m);
1540
- var v = m;
1541
- if (this.checkSignature(o.CENTRAL_DIRECTORY_END), this.readBlockEndOfCentral(), this.diskNumber === e.MAX_VALUE_16BITS || this.diskWithCentralDirStart === e.MAX_VALUE_16BITS || this.centralDirRecordsOnThisDisk === e.MAX_VALUE_16BITS || this.centralDirRecords === e.MAX_VALUE_16BITS || this.centralDirSize === e.MAX_VALUE_32BITS || this.centralDirOffset === e.MAX_VALUE_32BITS) {
1542
- if (this.zip64 = !0, (m = this.reader.lastIndexOfSignature(o.ZIP64_CENTRAL_DIRECTORY_LOCATOR)) < 0) throw new Error("Corrupted zip: can't find the ZIP64 end of central directory locator");
1543
- if (this.reader.setIndex(m), this.checkSignature(o.ZIP64_CENTRAL_DIRECTORY_LOCATOR), this.readBlockZip64EndOfCentralLocator(), !this.isSignature(this.relativeOffsetEndOfZip64CentralDir, o.ZIP64_CENTRAL_DIRECTORY_END) && (this.relativeOffsetEndOfZip64CentralDir = this.reader.lastIndexOfSignature(o.ZIP64_CENTRAL_DIRECTORY_END), this.relativeOffsetEndOfZip64CentralDir < 0)) throw new Error("Corrupted zip: can't find the ZIP64 end of central directory");
1544
- this.reader.setIndex(this.relativeOffsetEndOfZip64CentralDir), this.checkSignature(o.ZIP64_CENTRAL_DIRECTORY_END), this.readBlockZip64EndOfCentral();
1545
- }
1546
- var h = this.centralDirOffset + this.centralDirSize;
1547
- this.zip64 && (h += 20, h += 12 + this.zip64EndOfCentralSize);
1548
- var b = v - h;
1549
- if (0 < b) this.isSignature(v, o.CENTRAL_FILE_HEADER) || (this.reader.zero = b);
1550
- else if (b < 0) throw new Error("Corrupted zip: missing " + Math.abs(b) + " bytes.");
1551
- }, prepareReader: function(m) {
1552
- this.reader = i(m);
1553
- }, load: function(m) {
1554
- this.prepareReader(m), this.readEndOfCentral(), this.readCentralDir(), this.readLocalFiles();
1555
- } }, l.exports = _;
1556
- }, { "./reader/readerFor": 22, "./signature": 23, "./support": 30, "./utils": 32, "./zipEntry": 34 }], 34: [function(t, l, s) {
1557
- var i = t("./reader/readerFor"), e = t("./utils"), o = t("./compressedObject"), c = t("./crc32"), d = t("./utf8"), _ = t("./compressions"), m = t("./support");
1558
- function v(h, b) {
1559
- this.options = h, this.loadOptions = b;
1560
- }
1561
- v.prototype = { isEncrypted: function() {
1562
- return (1 & this.bitFlag) == 1;
1563
- }, useUTF8: function() {
1564
- return (2048 & this.bitFlag) == 2048;
1565
- }, readLocalPart: function(h) {
1566
- var b, f;
1567
- if (h.skip(22), this.fileNameLength = h.readInt(2), f = h.readInt(2), this.fileName = h.readData(this.fileNameLength), h.skip(f), this.compressedSize === -1 || this.uncompressedSize === -1) throw new Error("Bug or corrupted zip : didn't get enough information from the central directory (compressedSize === -1 || uncompressedSize === -1)");
1568
- if ((b = (function(g) {
1569
- for (var p in _) if (Object.prototype.hasOwnProperty.call(_, p) && _[p].magic === g) return _[p];
1570
- return null;
1571
- })(this.compressionMethod)) === null) throw new Error("Corrupted zip : compression " + e.pretty(this.compressionMethod) + " unknown (inner file : " + e.transformTo("string", this.fileName) + ")");
1572
- this.decompressed = new o(this.compressedSize, this.uncompressedSize, this.crc32, b, h.readData(this.compressedSize));
1573
- }, readCentralPart: function(h) {
1574
- this.versionMadeBy = h.readInt(2), h.skip(2), this.bitFlag = h.readInt(2), this.compressionMethod = h.readString(2), this.date = h.readDate(), this.crc32 = h.readInt(4), this.compressedSize = h.readInt(4), this.uncompressedSize = h.readInt(4);
1575
- var b = h.readInt(2);
1576
- if (this.extraFieldsLength = h.readInt(2), this.fileCommentLength = h.readInt(2), this.diskNumberStart = h.readInt(2), this.internalFileAttributes = h.readInt(2), this.externalFileAttributes = h.readInt(4), this.localHeaderOffset = h.readInt(4), this.isEncrypted()) throw new Error("Encrypted zip are not supported");
1577
- h.skip(b), this.readExtraFields(h), this.parseZIP64ExtraField(h), this.fileComment = h.readData(this.fileCommentLength);
1578
- }, processAttributes: function() {
1579
- this.unixPermissions = null, this.dosPermissions = null;
1580
- var h = this.versionMadeBy >> 8;
1581
- this.dir = !!(16 & this.externalFileAttributes), h == 0 && (this.dosPermissions = 63 & this.externalFileAttributes), h == 3 && (this.unixPermissions = this.externalFileAttributes >> 16 & 65535), this.dir || this.fileNameStr.slice(-1) !== "/" || (this.dir = !0);
1582
- }, parseZIP64ExtraField: function() {
1583
- if (this.extraFields[1]) {
1584
- var h = i(this.extraFields[1].value);
1585
- this.uncompressedSize === e.MAX_VALUE_32BITS && (this.uncompressedSize = h.readInt(8)), this.compressedSize === e.MAX_VALUE_32BITS && (this.compressedSize = h.readInt(8)), this.localHeaderOffset === e.MAX_VALUE_32BITS && (this.localHeaderOffset = h.readInt(8)), this.diskNumberStart === e.MAX_VALUE_32BITS && (this.diskNumberStart = h.readInt(4));
1586
- }
1587
- }, readExtraFields: function(h) {
1588
- var b, f, g, p = h.index + this.extraFieldsLength;
1589
- for (this.extraFields || (this.extraFields = {}); h.index + 4 < p; ) b = h.readInt(2), f = h.readInt(2), g = h.readData(f), this.extraFields[b] = { id: b, length: f, value: g };
1590
- h.setIndex(p);
1591
- }, handleUTF8: function() {
1592
- var h = m.uint8array ? "uint8array" : "array";
1593
- if (this.useUTF8()) this.fileNameStr = d.utf8decode(this.fileName), this.fileCommentStr = d.utf8decode(this.fileComment);
1594
- else {
1595
- var b = this.findExtraFieldUnicodePath();
1596
- if (b !== null) this.fileNameStr = b;
1597
- else {
1598
- var f = e.transformTo(h, this.fileName);
1599
- this.fileNameStr = this.loadOptions.decodeFileName(f);
1600
- }
1601
- var g = this.findExtraFieldUnicodeComment();
1602
- if (g !== null) this.fileCommentStr = g;
1603
- else {
1604
- var p = e.transformTo(h, this.fileComment);
1605
- this.fileCommentStr = this.loadOptions.decodeFileName(p);
1606
- }
1607
- }
1608
- }, findExtraFieldUnicodePath: function() {
1609
- var h = this.extraFields[28789];
1610
- if (h) {
1611
- var b = i(h.value);
1612
- return b.readInt(1) !== 1 || c(this.fileName) !== b.readInt(4) ? null : d.utf8decode(b.readData(h.length - 5));
1613
- }
1614
- return null;
1615
- }, findExtraFieldUnicodeComment: function() {
1616
- var h = this.extraFields[25461];
1617
- if (h) {
1618
- var b = i(h.value);
1619
- return b.readInt(1) !== 1 || c(this.fileComment) !== b.readInt(4) ? null : d.utf8decode(b.readData(h.length - 5));
1620
- }
1621
- return null;
1622
- } }, l.exports = v;
1623
- }, { "./compressedObject": 2, "./compressions": 3, "./crc32": 4, "./reader/readerFor": 22, "./support": 30, "./utf8": 31, "./utils": 32 }], 35: [function(t, l, s) {
1624
- function i(b, f, g) {
1625
- this.name = b, this.dir = g.dir, this.date = g.date, this.comment = g.comment, this.unixPermissions = g.unixPermissions, this.dosPermissions = g.dosPermissions, this._data = f, this._dataBinary = g.binary, this.options = { compression: g.compression, compressionOptions: g.compressionOptions };
1626
- }
1627
- var e = t("./stream/StreamHelper"), o = t("./stream/DataWorker"), c = t("./utf8"), d = t("./compressedObject"), _ = t("./stream/GenericWorker");
1628
- i.prototype = { internalStream: function(b) {
1629
- var f = null, g = "string";
1630
- try {
1631
- if (!b) throw new Error("No output type specified.");
1632
- var p = (g = b.toLowerCase()) === "string" || g === "text";
1633
- g !== "binarystring" && g !== "text" || (g = "string"), f = this._decompressWorker();
1634
- var w = !this._dataBinary;
1635
- w && !p && (f = f.pipe(new c.Utf8EncodeWorker())), !w && p && (f = f.pipe(new c.Utf8DecodeWorker()));
1636
- } catch (S) {
1637
- (f = new _("error")).error(S);
1638
- }
1639
- return new e(f, g, "");
1640
- }, async: function(b, f) {
1641
- return this.internalStream(b).accumulate(f);
1642
- }, nodeStream: function(b, f) {
1643
- return this.internalStream(b || "nodebuffer").toNodejsStream(f);
1644
- }, _compressWorker: function(b, f) {
1645
- if (this._data instanceof d && this._data.compression.magic === b.magic) return this._data.getCompressedWorker();
1646
- var g = this._decompressWorker();
1647
- return this._dataBinary || (g = g.pipe(new c.Utf8EncodeWorker())), d.createWorkerFrom(g, b, f);
1648
- }, _decompressWorker: function() {
1649
- return this._data instanceof d ? this._data.getContentWorker() : this._data instanceof _ ? this._data : new o(this._data);
1650
- } };
1651
- for (var m = ["asText", "asBinary", "asNodeBuffer", "asUint8Array", "asArrayBuffer"], v = function() {
1652
- throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.");
1653
- }, h = 0; h < m.length; h++) i.prototype[m[h]] = v;
1654
- l.exports = i;
1655
- }, { "./compressedObject": 2, "./stream/DataWorker": 27, "./stream/GenericWorker": 28, "./stream/StreamHelper": 29, "./utf8": 31 }], 36: [function(t, l, s) {
1656
- (function(i) {
1657
- var e, o, c = i.MutationObserver || i.WebKitMutationObserver;
1658
- if (c) {
1659
- var d = 0, _ = new c(b), m = i.document.createTextNode("");
1660
- _.observe(m, { characterData: !0 }), e = function() {
1661
- m.data = d = ++d % 2;
1662
- };
1663
- } else if (i.setImmediate || i.MessageChannel === void 0) e = "document" in i && "onreadystatechange" in i.document.createElement("script") ? function() {
1664
- var f = i.document.createElement("script");
1665
- f.onreadystatechange = function() {
1666
- b(), f.onreadystatechange = null, f.parentNode.removeChild(f), f = null;
1667
- }, i.document.documentElement.appendChild(f);
1668
- } : function() {
1669
- setTimeout(b, 0);
1670
- };
1671
- else {
1672
- var v = new i.MessageChannel();
1673
- v.port1.onmessage = b, e = function() {
1674
- v.port2.postMessage(0);
1675
- };
1676
- }
1677
- var h = [];
1678
- function b() {
1679
- var f, g;
1680
- o = !0;
1681
- for (var p = h.length; p; ) {
1682
- for (g = h, h = [], f = -1; ++f < p; ) g[f]();
1683
- p = h.length;
1684
- }
1685
- o = !1;
1686
- }
1687
- l.exports = function(f) {
1688
- h.push(f) !== 1 || o || e();
1689
- };
1690
- }).call(this, typeof It < "u" ? It : typeof self < "u" ? self : typeof window < "u" ? window : {});
1691
- }, {}], 37: [function(t, l, s) {
1692
- var i = t("immediate");
1693
- function e() {
1694
- }
1695
- var o = {}, c = ["REJECTED"], d = ["FULFILLED"], _ = ["PENDING"];
1696
- function m(p) {
1697
- if (typeof p != "function") throw new TypeError("resolver must be a function");
1698
- this.state = _, this.queue = [], this.outcome = void 0, p !== e && f(this, p);
1699
- }
1700
- function v(p, w, S) {
1701
- this.promise = p, typeof w == "function" && (this.onFulfilled = w, this.callFulfilled = this.otherCallFulfilled), typeof S == "function" && (this.onRejected = S, this.callRejected = this.otherCallRejected);
1702
- }
1703
- function h(p, w, S) {
1704
- i(function() {
1705
- var E;
1706
- try {
1707
- E = w(S);
1708
- } catch (z) {
1709
- return o.reject(p, z);
1710
- }
1711
- E === p ? o.reject(p, new TypeError("Cannot resolve promise with itself")) : o.resolve(p, E);
1712
- });
1713
- }
1714
- function b(p) {
1715
- var w = p && p.then;
1716
- if (p && (typeof p == "object" || typeof p == "function") && typeof w == "function") return function() {
1717
- w.apply(p, arguments);
1718
- };
1719
- }
1720
- function f(p, w) {
1721
- var S = !1;
1722
- function E(D) {
1723
- S || (S = !0, o.reject(p, D));
1724
- }
1725
- function z(D) {
1726
- S || (S = !0, o.resolve(p, D));
1727
- }
1728
- var P = g(function() {
1729
- w(z, E);
1730
- });
1731
- P.status === "error" && E(P.value);
1732
- }
1733
- function g(p, w) {
1734
- var S = {};
1735
- try {
1736
- S.value = p(w), S.status = "success";
1737
- } catch (E) {
1738
- S.status = "error", S.value = E;
1739
- }
1740
- return S;
1741
- }
1742
- (l.exports = m).prototype.finally = function(p) {
1743
- if (typeof p != "function") return this;
1744
- var w = this.constructor;
1745
- return this.then(function(S) {
1746
- return w.resolve(p()).then(function() {
1747
- return S;
1748
- });
1749
- }, function(S) {
1750
- return w.resolve(p()).then(function() {
1751
- throw S;
1752
- });
1753
- });
1754
- }, m.prototype.catch = function(p) {
1755
- return this.then(null, p);
1756
- }, m.prototype.then = function(p, w) {
1757
- if (typeof p != "function" && this.state === d || typeof w != "function" && this.state === c) return this;
1758
- var S = new this.constructor(e);
1759
- return this.state !== _ ? h(S, this.state === d ? p : w, this.outcome) : this.queue.push(new v(S, p, w)), S;
1760
- }, v.prototype.callFulfilled = function(p) {
1761
- o.resolve(this.promise, p);
1762
- }, v.prototype.otherCallFulfilled = function(p) {
1763
- h(this.promise, this.onFulfilled, p);
1764
- }, v.prototype.callRejected = function(p) {
1765
- o.reject(this.promise, p);
1766
- }, v.prototype.otherCallRejected = function(p) {
1767
- h(this.promise, this.onRejected, p);
1768
- }, o.resolve = function(p, w) {
1769
- var S = g(b, w);
1770
- if (S.status === "error") return o.reject(p, S.value);
1771
- var E = S.value;
1772
- if (E) f(p, E);
1773
- else {
1774
- p.state = d, p.outcome = w;
1775
- for (var z = -1, P = p.queue.length; ++z < P; ) p.queue[z].callFulfilled(w);
1776
- }
1777
- return p;
1778
- }, o.reject = function(p, w) {
1779
- p.state = c, p.outcome = w;
1780
- for (var S = -1, E = p.queue.length; ++S < E; ) p.queue[S].callRejected(w);
1781
- return p;
1782
- }, m.resolve = function(p) {
1783
- return p instanceof this ? p : o.resolve(new this(e), p);
1784
- }, m.reject = function(p) {
1785
- var w = new this(e);
1786
- return o.reject(w, p);
1787
- }, m.all = function(p) {
1788
- var w = this;
1789
- if (Object.prototype.toString.call(p) !== "[object Array]") return this.reject(new TypeError("must be an array"));
1790
- var S = p.length, E = !1;
1791
- if (!S) return this.resolve([]);
1792
- for (var z = new Array(S), P = 0, D = -1, N = new this(e); ++D < S; ) R(p[D], D);
1793
- return N;
1794
- function R(M, V) {
1795
- w.resolve(M).then(function(k) {
1796
- z[V] = k, ++P !== S || E || (E = !0, o.resolve(N, z));
1797
- }, function(k) {
1798
- E || (E = !0, o.reject(N, k));
1799
- });
1800
- }
1801
- }, m.race = function(p) {
1802
- var w = this;
1803
- if (Object.prototype.toString.call(p) !== "[object Array]") return this.reject(new TypeError("must be an array"));
1804
- var S = p.length, E = !1;
1805
- if (!S) return this.resolve([]);
1806
- for (var z = -1, P = new this(e); ++z < S; ) D = p[z], w.resolve(D).then(function(N) {
1807
- E || (E = !0, o.resolve(P, N));
1808
- }, function(N) {
1809
- E || (E = !0, o.reject(P, N));
1810
- });
1811
- var D;
1812
- return P;
1813
- };
1814
- }, { immediate: 36 }], 38: [function(t, l, s) {
1815
- var i = {};
1816
- (0, t("./lib/utils/common").assign)(i, t("./lib/deflate"), t("./lib/inflate"), t("./lib/zlib/constants")), l.exports = i;
1817
- }, { "./lib/deflate": 39, "./lib/inflate": 40, "./lib/utils/common": 41, "./lib/zlib/constants": 44 }], 39: [function(t, l, s) {
1818
- var i = t("./zlib/deflate"), e = t("./utils/common"), o = t("./utils/strings"), c = t("./zlib/messages"), d = t("./zlib/zstream"), _ = Object.prototype.toString, m = 0, v = -1, h = 0, b = 8;
1819
- function f(p) {
1820
- if (!(this instanceof f)) return new f(p);
1821
- this.options = e.assign({ level: v, method: b, chunkSize: 16384, windowBits: 15, memLevel: 8, strategy: h, to: "" }, p || {});
1822
- var w = this.options;
1823
- w.raw && 0 < w.windowBits ? w.windowBits = -w.windowBits : w.gzip && 0 < w.windowBits && w.windowBits < 16 && (w.windowBits += 16), this.err = 0, this.msg = "", this.ended = !1, this.chunks = [], this.strm = new d(), this.strm.avail_out = 0;
1824
- var S = i.deflateInit2(this.strm, w.level, w.method, w.windowBits, w.memLevel, w.strategy);
1825
- if (S !== m) throw new Error(c[S]);
1826
- if (w.header && i.deflateSetHeader(this.strm, w.header), w.dictionary) {
1827
- var E;
1828
- if (E = typeof w.dictionary == "string" ? o.string2buf(w.dictionary) : _.call(w.dictionary) === "[object ArrayBuffer]" ? new Uint8Array(w.dictionary) : w.dictionary, (S = i.deflateSetDictionary(this.strm, E)) !== m) throw new Error(c[S]);
1829
- this._dict_set = !0;
1830
- }
1831
- }
1832
- function g(p, w) {
1833
- var S = new f(w);
1834
- if (S.push(p, !0), S.err) throw S.msg || c[S.err];
1835
- return S.result;
1836
- }
1837
- f.prototype.push = function(p, w) {
1838
- var S, E, z = this.strm, P = this.options.chunkSize;
1839
- if (this.ended) return !1;
1840
- E = w === ~~w ? w : w === !0 ? 4 : 0, typeof p == "string" ? z.input = o.string2buf(p) : _.call(p) === "[object ArrayBuffer]" ? z.input = new Uint8Array(p) : z.input = p, z.next_in = 0, z.avail_in = z.input.length;
1841
- do {
1842
- if (z.avail_out === 0 && (z.output = new e.Buf8(P), z.next_out = 0, z.avail_out = P), (S = i.deflate(z, E)) !== 1 && S !== m) return this.onEnd(S), !(this.ended = !0);
1843
- z.avail_out !== 0 && (z.avail_in !== 0 || E !== 4 && E !== 2) || (this.options.to === "string" ? this.onData(o.buf2binstring(e.shrinkBuf(z.output, z.next_out))) : this.onData(e.shrinkBuf(z.output, z.next_out)));
1844
- } while ((0 < z.avail_in || z.avail_out === 0) && S !== 1);
1845
- return E === 4 ? (S = i.deflateEnd(this.strm), this.onEnd(S), this.ended = !0, S === m) : E !== 2 || (this.onEnd(m), !(z.avail_out = 0));
1846
- }, f.prototype.onData = function(p) {
1847
- this.chunks.push(p);
1848
- }, f.prototype.onEnd = function(p) {
1849
- p === m && (this.options.to === "string" ? this.result = this.chunks.join("") : this.result = e.flattenChunks(this.chunks)), this.chunks = [], this.err = p, this.msg = this.strm.msg;
1850
- }, s.Deflate = f, s.deflate = g, s.deflateRaw = function(p, w) {
1851
- return (w = w || {}).raw = !0, g(p, w);
1852
- }, s.gzip = function(p, w) {
1853
- return (w = w || {}).gzip = !0, g(p, w);
1854
- };
1855
- }, { "./utils/common": 41, "./utils/strings": 42, "./zlib/deflate": 46, "./zlib/messages": 51, "./zlib/zstream": 53 }], 40: [function(t, l, s) {
1856
- var i = t("./zlib/inflate"), e = t("./utils/common"), o = t("./utils/strings"), c = t("./zlib/constants"), d = t("./zlib/messages"), _ = t("./zlib/zstream"), m = t("./zlib/gzheader"), v = Object.prototype.toString;
1857
- function h(f) {
1858
- if (!(this instanceof h)) return new h(f);
1859
- this.options = e.assign({ chunkSize: 16384, windowBits: 0, to: "" }, f || {});
1860
- var g = this.options;
1861
- g.raw && 0 <= g.windowBits && g.windowBits < 16 && (g.windowBits = -g.windowBits, g.windowBits === 0 && (g.windowBits = -15)), !(0 <= g.windowBits && g.windowBits < 16) || f && f.windowBits || (g.windowBits += 32), 15 < g.windowBits && g.windowBits < 48 && (15 & g.windowBits) == 0 && (g.windowBits |= 15), this.err = 0, this.msg = "", this.ended = !1, this.chunks = [], this.strm = new _(), this.strm.avail_out = 0;
1862
- var p = i.inflateInit2(this.strm, g.windowBits);
1863
- if (p !== c.Z_OK) throw new Error(d[p]);
1864
- this.header = new m(), i.inflateGetHeader(this.strm, this.header);
1865
- }
1866
- function b(f, g) {
1867
- var p = new h(g);
1868
- if (p.push(f, !0), p.err) throw p.msg || d[p.err];
1869
- return p.result;
1870
- }
1871
- h.prototype.push = function(f, g) {
1872
- var p, w, S, E, z, P, D = this.strm, N = this.options.chunkSize, R = this.options.dictionary, M = !1;
1873
- if (this.ended) return !1;
1874
- w = g === ~~g ? g : g === !0 ? c.Z_FINISH : c.Z_NO_FLUSH, typeof f == "string" ? D.input = o.binstring2buf(f) : v.call(f) === "[object ArrayBuffer]" ? D.input = new Uint8Array(f) : D.input = f, D.next_in = 0, D.avail_in = D.input.length;
1875
- do {
1876
- if (D.avail_out === 0 && (D.output = new e.Buf8(N), D.next_out = 0, D.avail_out = N), (p = i.inflate(D, c.Z_NO_FLUSH)) === c.Z_NEED_DICT && R && (P = typeof R == "string" ? o.string2buf(R) : v.call(R) === "[object ArrayBuffer]" ? new Uint8Array(R) : R, p = i.inflateSetDictionary(this.strm, P)), p === c.Z_BUF_ERROR && M === !0 && (p = c.Z_OK, M = !1), p !== c.Z_STREAM_END && p !== c.Z_OK) return this.onEnd(p), !(this.ended = !0);
1877
- D.next_out && (D.avail_out !== 0 && p !== c.Z_STREAM_END && (D.avail_in !== 0 || w !== c.Z_FINISH && w !== c.Z_SYNC_FLUSH) || (this.options.to === "string" ? (S = o.utf8border(D.output, D.next_out), E = D.next_out - S, z = o.buf2string(D.output, S), D.next_out = E, D.avail_out = N - E, E && e.arraySet(D.output, D.output, S, E, 0), this.onData(z)) : this.onData(e.shrinkBuf(D.output, D.next_out)))), D.avail_in === 0 && D.avail_out === 0 && (M = !0);
1878
- } while ((0 < D.avail_in || D.avail_out === 0) && p !== c.Z_STREAM_END);
1879
- return p === c.Z_STREAM_END && (w = c.Z_FINISH), w === c.Z_FINISH ? (p = i.inflateEnd(this.strm), this.onEnd(p), this.ended = !0, p === c.Z_OK) : w !== c.Z_SYNC_FLUSH || (this.onEnd(c.Z_OK), !(D.avail_out = 0));
1880
- }, h.prototype.onData = function(f) {
1881
- this.chunks.push(f);
1882
- }, h.prototype.onEnd = function(f) {
1883
- f === c.Z_OK && (this.options.to === "string" ? this.result = this.chunks.join("") : this.result = e.flattenChunks(this.chunks)), this.chunks = [], this.err = f, this.msg = this.strm.msg;
1884
- }, s.Inflate = h, s.inflate = b, s.inflateRaw = function(f, g) {
1885
- return (g = g || {}).raw = !0, b(f, g);
1886
- }, s.ungzip = b;
1887
- }, { "./utils/common": 41, "./utils/strings": 42, "./zlib/constants": 44, "./zlib/gzheader": 47, "./zlib/inflate": 49, "./zlib/messages": 51, "./zlib/zstream": 53 }], 41: [function(t, l, s) {
1888
- var i = typeof Uint8Array < "u" && typeof Uint16Array < "u" && typeof Int32Array < "u";
1889
- s.assign = function(c) {
1890
- for (var d = Array.prototype.slice.call(arguments, 1); d.length; ) {
1891
- var _ = d.shift();
1892
- if (_) {
1893
- if (typeof _ != "object") throw new TypeError(_ + "must be non-object");
1894
- for (var m in _) _.hasOwnProperty(m) && (c[m] = _[m]);
1895
- }
1896
- }
1897
- return c;
1898
- }, s.shrinkBuf = function(c, d) {
1899
- return c.length === d ? c : c.subarray ? c.subarray(0, d) : (c.length = d, c);
1900
- };
1901
- var e = { arraySet: function(c, d, _, m, v) {
1902
- if (d.subarray && c.subarray) c.set(d.subarray(_, _ + m), v);
1903
- else for (var h = 0; h < m; h++) c[v + h] = d[_ + h];
1904
- }, flattenChunks: function(c) {
1905
- var d, _, m, v, h, b;
1906
- for (d = m = 0, _ = c.length; d < _; d++) m += c[d].length;
1907
- for (b = new Uint8Array(m), d = v = 0, _ = c.length; d < _; d++) h = c[d], b.set(h, v), v += h.length;
1908
- return b;
1909
- } }, o = { arraySet: function(c, d, _, m, v) {
1910
- for (var h = 0; h < m; h++) c[v + h] = d[_ + h];
1911
- }, flattenChunks: function(c) {
1912
- return [].concat.apply([], c);
1913
- } };
1914
- s.setTyped = function(c) {
1915
- c ? (s.Buf8 = Uint8Array, s.Buf16 = Uint16Array, s.Buf32 = Int32Array, s.assign(s, e)) : (s.Buf8 = Array, s.Buf16 = Array, s.Buf32 = Array, s.assign(s, o));
1916
- }, s.setTyped(i);
1917
- }, {}], 42: [function(t, l, s) {
1918
- var i = t("./common"), e = !0, o = !0;
1919
- try {
1920
- String.fromCharCode.apply(null, [0]);
1921
- } catch {
1922
- e = !1;
1923
- }
1924
- try {
1925
- String.fromCharCode.apply(null, new Uint8Array(1));
1926
- } catch {
1927
- o = !1;
1928
- }
1929
- for (var c = new i.Buf8(256), d = 0; d < 256; d++) c[d] = 252 <= d ? 6 : 248 <= d ? 5 : 240 <= d ? 4 : 224 <= d ? 3 : 192 <= d ? 2 : 1;
1930
- function _(m, v) {
1931
- if (v < 65537 && (m.subarray && o || !m.subarray && e)) return String.fromCharCode.apply(null, i.shrinkBuf(m, v));
1932
- for (var h = "", b = 0; b < v; b++) h += String.fromCharCode(m[b]);
1933
- return h;
1934
- }
1935
- c[254] = c[254] = 1, s.string2buf = function(m) {
1936
- var v, h, b, f, g, p = m.length, w = 0;
1937
- for (f = 0; f < p; f++) (64512 & (h = m.charCodeAt(f))) == 55296 && f + 1 < p && (64512 & (b = m.charCodeAt(f + 1))) == 56320 && (h = 65536 + (h - 55296 << 10) + (b - 56320), f++), w += h < 128 ? 1 : h < 2048 ? 2 : h < 65536 ? 3 : 4;
1938
- for (v = new i.Buf8(w), f = g = 0; g < w; f++) (64512 & (h = m.charCodeAt(f))) == 55296 && f + 1 < p && (64512 & (b = m.charCodeAt(f + 1))) == 56320 && (h = 65536 + (h - 55296 << 10) + (b - 56320), f++), h < 128 ? v[g++] = h : (h < 2048 ? v[g++] = 192 | h >>> 6 : (h < 65536 ? v[g++] = 224 | h >>> 12 : (v[g++] = 240 | h >>> 18, v[g++] = 128 | h >>> 12 & 63), v[g++] = 128 | h >>> 6 & 63), v[g++] = 128 | 63 & h);
1939
- return v;
1940
- }, s.buf2binstring = function(m) {
1941
- return _(m, m.length);
1942
- }, s.binstring2buf = function(m) {
1943
- for (var v = new i.Buf8(m.length), h = 0, b = v.length; h < b; h++) v[h] = m.charCodeAt(h);
1944
- return v;
1945
- }, s.buf2string = function(m, v) {
1946
- var h, b, f, g, p = v || m.length, w = new Array(2 * p);
1947
- for (h = b = 0; h < p; ) if ((f = m[h++]) < 128) w[b++] = f;
1948
- else if (4 < (g = c[f])) w[b++] = 65533, h += g - 1;
1949
- else {
1950
- for (f &= g === 2 ? 31 : g === 3 ? 15 : 7; 1 < g && h < p; ) f = f << 6 | 63 & m[h++], g--;
1951
- 1 < g ? w[b++] = 65533 : f < 65536 ? w[b++] = f : (f -= 65536, w[b++] = 55296 | f >> 10 & 1023, w[b++] = 56320 | 1023 & f);
1952
- }
1953
- return _(w, b);
1954
- }, s.utf8border = function(m, v) {
1955
- var h;
1956
- for ((v = v || m.length) > m.length && (v = m.length), h = v - 1; 0 <= h && (192 & m[h]) == 128; ) h--;
1957
- return h < 0 || h === 0 ? v : h + c[m[h]] > v ? h : v;
1958
- };
1959
- }, { "./common": 41 }], 43: [function(t, l, s) {
1960
- l.exports = function(i, e, o, c) {
1961
- for (var d = 65535 & i | 0, _ = i >>> 16 & 65535 | 0, m = 0; o !== 0; ) {
1962
- for (o -= m = 2e3 < o ? 2e3 : o; _ = _ + (d = d + e[c++] | 0) | 0, --m; ) ;
1963
- d %= 65521, _ %= 65521;
1964
- }
1965
- return d | _ << 16 | 0;
1966
- };
1967
- }, {}], 44: [function(t, l, s) {
1968
- l.exports = { Z_NO_FLUSH: 0, Z_PARTIAL_FLUSH: 1, Z_SYNC_FLUSH: 2, Z_FULL_FLUSH: 3, Z_FINISH: 4, Z_BLOCK: 5, Z_TREES: 6, Z_OK: 0, Z_STREAM_END: 1, Z_NEED_DICT: 2, Z_ERRNO: -1, Z_STREAM_ERROR: -2, Z_DATA_ERROR: -3, Z_BUF_ERROR: -5, Z_NO_COMPRESSION: 0, Z_BEST_SPEED: 1, Z_BEST_COMPRESSION: 9, Z_DEFAULT_COMPRESSION: -1, Z_FILTERED: 1, Z_HUFFMAN_ONLY: 2, Z_RLE: 3, Z_FIXED: 4, Z_DEFAULT_STRATEGY: 0, Z_BINARY: 0, Z_TEXT: 1, Z_UNKNOWN: 2, Z_DEFLATED: 8 };
1969
- }, {}], 45: [function(t, l, s) {
1970
- var i = (function() {
1971
- for (var e, o = [], c = 0; c < 256; c++) {
1972
- e = c;
1973
- for (var d = 0; d < 8; d++) e = 1 & e ? 3988292384 ^ e >>> 1 : e >>> 1;
1974
- o[c] = e;
1975
- }
1976
- return o;
1977
- })();
1978
- l.exports = function(e, o, c, d) {
1979
- var _ = i, m = d + c;
1980
- e ^= -1;
1981
- for (var v = d; v < m; v++) e = e >>> 8 ^ _[255 & (e ^ o[v])];
1982
- return -1 ^ e;
1983
- };
1984
- }, {}], 46: [function(t, l, s) {
1985
- var i, e = t("../utils/common"), o = t("./trees"), c = t("./adler32"), d = t("./crc32"), _ = t("./messages"), m = 0, v = 4, h = 0, b = -2, f = -1, g = 4, p = 2, w = 8, S = 9, E = 286, z = 30, P = 19, D = 2 * E + 1, N = 15, R = 3, M = 258, V = M + R + 1, k = 42, j = 113, u = 1, I = 2, H = 3, $ = 4;
1986
- function tt(a, B) {
1987
- return a.msg = _[B], B;
1988
- }
1989
- function W(a) {
1990
- return (a << 1) - (4 < a ? 9 : 0);
1991
- }
1992
- function Q(a) {
1993
- for (var B = a.length; 0 <= --B; ) a[B] = 0;
1994
- }
1995
- function O(a) {
1996
- var B = a.state, F = B.pending;
1997
- F > a.avail_out && (F = a.avail_out), F !== 0 && (e.arraySet(a.output, B.pending_buf, B.pending_out, F, a.next_out), a.next_out += F, B.pending_out += F, a.total_out += F, a.avail_out -= F, B.pending -= F, B.pending === 0 && (B.pending_out = 0));
1998
- }
1999
- function T(a, B) {
2000
- o._tr_flush_block(a, 0 <= a.block_start ? a.block_start : -1, a.strstart - a.block_start, B), a.block_start = a.strstart, O(a.strm);
2001
- }
2002
- function q(a, B) {
2003
- a.pending_buf[a.pending++] = B;
2004
- }
2005
- function K(a, B) {
2006
- a.pending_buf[a.pending++] = B >>> 8 & 255, a.pending_buf[a.pending++] = 255 & B;
2007
- }
2008
- function G(a, B) {
2009
- var F, x, y = a.max_chain_length, C = a.strstart, L = a.prev_length, U = a.nice_match, A = a.strstart > a.w_size - V ? a.strstart - (a.w_size - V) : 0, Z = a.window, Y = a.w_mask, X = a.prev, J = a.strstart + M, it = Z[C + L - 1], nt = Z[C + L];
2010
- a.prev_length >= a.good_match && (y >>= 2), U > a.lookahead && (U = a.lookahead);
2011
- do
2012
- if (Z[(F = B) + L] === nt && Z[F + L - 1] === it && Z[F] === Z[C] && Z[++F] === Z[C + 1]) {
2013
- C += 2, F++;
2014
- do
2015
- ;
2016
- while (Z[++C] === Z[++F] && Z[++C] === Z[++F] && Z[++C] === Z[++F] && Z[++C] === Z[++F] && Z[++C] === Z[++F] && Z[++C] === Z[++F] && Z[++C] === Z[++F] && Z[++C] === Z[++F] && C < J);
2017
- if (x = M - (J - C), C = J - M, L < x) {
2018
- if (a.match_start = B, U <= (L = x)) break;
2019
- it = Z[C + L - 1], nt = Z[C + L];
2020
- }
2021
- }
2022
- while ((B = X[B & Y]) > A && --y != 0);
2023
- return L <= a.lookahead ? L : a.lookahead;
2024
- }
2025
- function st(a) {
2026
- var B, F, x, y, C, L, U, A, Z, Y, X = a.w_size;
2027
- do {
2028
- if (y = a.window_size - a.lookahead - a.strstart, a.strstart >= X + (X - V)) {
2029
- for (e.arraySet(a.window, a.window, X, X, 0), a.match_start -= X, a.strstart -= X, a.block_start -= X, B = F = a.hash_size; x = a.head[--B], a.head[B] = X <= x ? x - X : 0, --F; ) ;
2030
- for (B = F = X; x = a.prev[--B], a.prev[B] = X <= x ? x - X : 0, --F; ) ;
2031
- y += X;
2032
- }
2033
- if (a.strm.avail_in === 0) break;
2034
- if (L = a.strm, U = a.window, A = a.strstart + a.lookahead, Z = y, Y = void 0, Y = L.avail_in, Z < Y && (Y = Z), F = Y === 0 ? 0 : (L.avail_in -= Y, e.arraySet(U, L.input, L.next_in, Y, A), L.state.wrap === 1 ? L.adler = c(L.adler, U, Y, A) : L.state.wrap === 2 && (L.adler = d(L.adler, U, Y, A)), L.next_in += Y, L.total_in += Y, Y), a.lookahead += F, a.lookahead + a.insert >= R) for (C = a.strstart - a.insert, a.ins_h = a.window[C], a.ins_h = (a.ins_h << a.hash_shift ^ a.window[C + 1]) & a.hash_mask; a.insert && (a.ins_h = (a.ins_h << a.hash_shift ^ a.window[C + R - 1]) & a.hash_mask, a.prev[C & a.w_mask] = a.head[a.ins_h], a.head[a.ins_h] = C, C++, a.insert--, !(a.lookahead + a.insert < R)); ) ;
2035
- } while (a.lookahead < V && a.strm.avail_in !== 0);
2036
- }
2037
- function lt(a, B) {
2038
- for (var F, x; ; ) {
2039
- if (a.lookahead < V) {
2040
- if (st(a), a.lookahead < V && B === m) return u;
2041
- if (a.lookahead === 0) break;
2042
- }
2043
- if (F = 0, a.lookahead >= R && (a.ins_h = (a.ins_h << a.hash_shift ^ a.window[a.strstart + R - 1]) & a.hash_mask, F = a.prev[a.strstart & a.w_mask] = a.head[a.ins_h], a.head[a.ins_h] = a.strstart), F !== 0 && a.strstart - F <= a.w_size - V && (a.match_length = G(a, F)), a.match_length >= R) if (x = o._tr_tally(a, a.strstart - a.match_start, a.match_length - R), a.lookahead -= a.match_length, a.match_length <= a.max_lazy_match && a.lookahead >= R) {
2044
- for (a.match_length--; a.strstart++, a.ins_h = (a.ins_h << a.hash_shift ^ a.window[a.strstart + R - 1]) & a.hash_mask, F = a.prev[a.strstart & a.w_mask] = a.head[a.ins_h], a.head[a.ins_h] = a.strstart, --a.match_length != 0; ) ;
2045
- a.strstart++;
2046
- } else a.strstart += a.match_length, a.match_length = 0, a.ins_h = a.window[a.strstart], a.ins_h = (a.ins_h << a.hash_shift ^ a.window[a.strstart + 1]) & a.hash_mask;
2047
- else x = o._tr_tally(a, 0, a.window[a.strstart]), a.lookahead--, a.strstart++;
2048
- if (x && (T(a, !1), a.strm.avail_out === 0)) return u;
2049
- }
2050
- return a.insert = a.strstart < R - 1 ? a.strstart : R - 1, B === v ? (T(a, !0), a.strm.avail_out === 0 ? H : $) : a.last_lit && (T(a, !1), a.strm.avail_out === 0) ? u : I;
2051
- }
2052
- function et(a, B) {
2053
- for (var F, x, y; ; ) {
2054
- if (a.lookahead < V) {
2055
- if (st(a), a.lookahead < V && B === m) return u;
2056
- if (a.lookahead === 0) break;
2057
- }
2058
- if (F = 0, a.lookahead >= R && (a.ins_h = (a.ins_h << a.hash_shift ^ a.window[a.strstart + R - 1]) & a.hash_mask, F = a.prev[a.strstart & a.w_mask] = a.head[a.ins_h], a.head[a.ins_h] = a.strstart), a.prev_length = a.match_length, a.prev_match = a.match_start, a.match_length = R - 1, F !== 0 && a.prev_length < a.max_lazy_match && a.strstart - F <= a.w_size - V && (a.match_length = G(a, F), a.match_length <= 5 && (a.strategy === 1 || a.match_length === R && 4096 < a.strstart - a.match_start) && (a.match_length = R - 1)), a.prev_length >= R && a.match_length <= a.prev_length) {
2059
- for (y = a.strstart + a.lookahead - R, x = o._tr_tally(a, a.strstart - 1 - a.prev_match, a.prev_length - R), a.lookahead -= a.prev_length - 1, a.prev_length -= 2; ++a.strstart <= y && (a.ins_h = (a.ins_h << a.hash_shift ^ a.window[a.strstart + R - 1]) & a.hash_mask, F = a.prev[a.strstart & a.w_mask] = a.head[a.ins_h], a.head[a.ins_h] = a.strstart), --a.prev_length != 0; ) ;
2060
- if (a.match_available = 0, a.match_length = R - 1, a.strstart++, x && (T(a, !1), a.strm.avail_out === 0)) return u;
2061
- } else if (a.match_available) {
2062
- if ((x = o._tr_tally(a, 0, a.window[a.strstart - 1])) && T(a, !1), a.strstart++, a.lookahead--, a.strm.avail_out === 0) return u;
2063
- } else a.match_available = 1, a.strstart++, a.lookahead--;
2064
- }
2065
- return a.match_available && (x = o._tr_tally(a, 0, a.window[a.strstart - 1]), a.match_available = 0), a.insert = a.strstart < R - 1 ? a.strstart : R - 1, B === v ? (T(a, !0), a.strm.avail_out === 0 ? H : $) : a.last_lit && (T(a, !1), a.strm.avail_out === 0) ? u : I;
2066
- }
2067
- function rt(a, B, F, x, y) {
2068
- this.good_length = a, this.max_lazy = B, this.nice_length = F, this.max_chain = x, this.func = y;
2069
- }
2070
- function ct() {
2071
- this.strm = null, this.status = 0, this.pending_buf = null, this.pending_buf_size = 0, this.pending_out = 0, this.pending = 0, this.wrap = 0, this.gzhead = null, this.gzindex = 0, this.method = w, this.last_flush = -1, this.w_size = 0, this.w_bits = 0, this.w_mask = 0, this.window = null, this.window_size = 0, this.prev = null, this.head = null, this.ins_h = 0, this.hash_size = 0, this.hash_bits = 0, this.hash_mask = 0, this.hash_shift = 0, this.block_start = 0, this.match_length = 0, this.prev_match = 0, this.match_available = 0, this.strstart = 0, this.match_start = 0, this.lookahead = 0, this.prev_length = 0, this.max_chain_length = 0, this.max_lazy_match = 0, this.level = 0, this.strategy = 0, this.good_match = 0, this.nice_match = 0, this.dyn_ltree = new e.Buf16(2 * D), this.dyn_dtree = new e.Buf16(2 * (2 * z + 1)), this.bl_tree = new e.Buf16(2 * (2 * P + 1)), Q(this.dyn_ltree), Q(this.dyn_dtree), Q(this.bl_tree), this.l_desc = null, this.d_desc = null, this.bl_desc = null, this.bl_count = new e.Buf16(N + 1), this.heap = new e.Buf16(2 * E + 1), Q(this.heap), this.heap_len = 0, this.heap_max = 0, this.depth = new e.Buf16(2 * E + 1), Q(this.depth), this.l_buf = 0, this.lit_bufsize = 0, this.last_lit = 0, this.d_buf = 0, this.opt_len = 0, this.static_len = 0, this.matches = 0, this.insert = 0, this.bi_buf = 0, this.bi_valid = 0;
2072
- }
2073
- function at(a) {
2074
- var B;
2075
- return a && a.state ? (a.total_in = a.total_out = 0, a.data_type = p, (B = a.state).pending = 0, B.pending_out = 0, B.wrap < 0 && (B.wrap = -B.wrap), B.status = B.wrap ? k : j, a.adler = B.wrap === 2 ? 0 : 1, B.last_flush = m, o._tr_init(B), h) : tt(a, b);
2076
- }
2077
- function mt(a) {
2078
- var B = at(a);
2079
- return B === h && (function(F) {
2080
- F.window_size = 2 * F.w_size, Q(F.head), F.max_lazy_match = i[F.level].max_lazy, F.good_match = i[F.level].good_length, F.nice_match = i[F.level].nice_length, F.max_chain_length = i[F.level].max_chain, F.strstart = 0, F.block_start = 0, F.lookahead = 0, F.insert = 0, F.match_length = F.prev_length = R - 1, F.match_available = 0, F.ins_h = 0;
2081
- })(a.state), B;
2082
- }
2083
- function pt(a, B, F, x, y, C) {
2084
- if (!a) return b;
2085
- var L = 1;
2086
- if (B === f && (B = 6), x < 0 ? (L = 0, x = -x) : 15 < x && (L = 2, x -= 16), y < 1 || S < y || F !== w || x < 8 || 15 < x || B < 0 || 9 < B || C < 0 || g < C) return tt(a, b);
2087
- x === 8 && (x = 9);
2088
- var U = new ct();
2089
- return (a.state = U).strm = a, U.wrap = L, U.gzhead = null, U.w_bits = x, U.w_size = 1 << U.w_bits, U.w_mask = U.w_size - 1, U.hash_bits = y + 7, U.hash_size = 1 << U.hash_bits, U.hash_mask = U.hash_size - 1, U.hash_shift = ~~((U.hash_bits + R - 1) / R), U.window = new e.Buf8(2 * U.w_size), U.head = new e.Buf16(U.hash_size), U.prev = new e.Buf16(U.w_size), U.lit_bufsize = 1 << y + 6, U.pending_buf_size = 4 * U.lit_bufsize, U.pending_buf = new e.Buf8(U.pending_buf_size), U.d_buf = 1 * U.lit_bufsize, U.l_buf = 3 * U.lit_bufsize, U.level = B, U.strategy = C, U.method = F, mt(a);
2090
- }
2091
- i = [new rt(0, 0, 0, 0, function(a, B) {
2092
- var F = 65535;
2093
- for (F > a.pending_buf_size - 5 && (F = a.pending_buf_size - 5); ; ) {
2094
- if (a.lookahead <= 1) {
2095
- if (st(a), a.lookahead === 0 && B === m) return u;
2096
- if (a.lookahead === 0) break;
2097
- }
2098
- a.strstart += a.lookahead, a.lookahead = 0;
2099
- var x = a.block_start + F;
2100
- if ((a.strstart === 0 || a.strstart >= x) && (a.lookahead = a.strstart - x, a.strstart = x, T(a, !1), a.strm.avail_out === 0) || a.strstart - a.block_start >= a.w_size - V && (T(a, !1), a.strm.avail_out === 0)) return u;
2101
- }
2102
- return a.insert = 0, B === v ? (T(a, !0), a.strm.avail_out === 0 ? H : $) : (a.strstart > a.block_start && (T(a, !1), a.strm.avail_out), u);
2103
- }), new rt(4, 4, 8, 4, lt), new rt(4, 5, 16, 8, lt), new rt(4, 6, 32, 32, lt), new rt(4, 4, 16, 16, et), new rt(8, 16, 32, 32, et), new rt(8, 16, 128, 128, et), new rt(8, 32, 128, 256, et), new rt(32, 128, 258, 1024, et), new rt(32, 258, 258, 4096, et)], s.deflateInit = function(a, B) {
2104
- return pt(a, B, w, 15, 8, 0);
2105
- }, s.deflateInit2 = pt, s.deflateReset = mt, s.deflateResetKeep = at, s.deflateSetHeader = function(a, B) {
2106
- return a && a.state ? a.state.wrap !== 2 ? b : (a.state.gzhead = B, h) : b;
2107
- }, s.deflate = function(a, B) {
2108
- var F, x, y, C;
2109
- if (!a || !a.state || 5 < B || B < 0) return a ? tt(a, b) : b;
2110
- if (x = a.state, !a.output || !a.input && a.avail_in !== 0 || x.status === 666 && B !== v) return tt(a, a.avail_out === 0 ? -5 : b);
2111
- if (x.strm = a, F = x.last_flush, x.last_flush = B, x.status === k) if (x.wrap === 2) a.adler = 0, q(x, 31), q(x, 139), q(x, 8), x.gzhead ? (q(x, (x.gzhead.text ? 1 : 0) + (x.gzhead.hcrc ? 2 : 0) + (x.gzhead.extra ? 4 : 0) + (x.gzhead.name ? 8 : 0) + (x.gzhead.comment ? 16 : 0)), q(x, 255 & x.gzhead.time), q(x, x.gzhead.time >> 8 & 255), q(x, x.gzhead.time >> 16 & 255), q(x, x.gzhead.time >> 24 & 255), q(x, x.level === 9 ? 2 : 2 <= x.strategy || x.level < 2 ? 4 : 0), q(x, 255 & x.gzhead.os), x.gzhead.extra && x.gzhead.extra.length && (q(x, 255 & x.gzhead.extra.length), q(x, x.gzhead.extra.length >> 8 & 255)), x.gzhead.hcrc && (a.adler = d(a.adler, x.pending_buf, x.pending, 0)), x.gzindex = 0, x.status = 69) : (q(x, 0), q(x, 0), q(x, 0), q(x, 0), q(x, 0), q(x, x.level === 9 ? 2 : 2 <= x.strategy || x.level < 2 ? 4 : 0), q(x, 3), x.status = j);
2112
- else {
2113
- var L = w + (x.w_bits - 8 << 4) << 8;
2114
- L |= (2 <= x.strategy || x.level < 2 ? 0 : x.level < 6 ? 1 : x.level === 6 ? 2 : 3) << 6, x.strstart !== 0 && (L |= 32), L += 31 - L % 31, x.status = j, K(x, L), x.strstart !== 0 && (K(x, a.adler >>> 16), K(x, 65535 & a.adler)), a.adler = 1;
2115
- }
2116
- if (x.status === 69) if (x.gzhead.extra) {
2117
- for (y = x.pending; x.gzindex < (65535 & x.gzhead.extra.length) && (x.pending !== x.pending_buf_size || (x.gzhead.hcrc && x.pending > y && (a.adler = d(a.adler, x.pending_buf, x.pending - y, y)), O(a), y = x.pending, x.pending !== x.pending_buf_size)); ) q(x, 255 & x.gzhead.extra[x.gzindex]), x.gzindex++;
2118
- x.gzhead.hcrc && x.pending > y && (a.adler = d(a.adler, x.pending_buf, x.pending - y, y)), x.gzindex === x.gzhead.extra.length && (x.gzindex = 0, x.status = 73);
2119
- } else x.status = 73;
2120
- if (x.status === 73) if (x.gzhead.name) {
2121
- y = x.pending;
2122
- do {
2123
- if (x.pending === x.pending_buf_size && (x.gzhead.hcrc && x.pending > y && (a.adler = d(a.adler, x.pending_buf, x.pending - y, y)), O(a), y = x.pending, x.pending === x.pending_buf_size)) {
2124
- C = 1;
2125
- break;
2126
- }
2127
- C = x.gzindex < x.gzhead.name.length ? 255 & x.gzhead.name.charCodeAt(x.gzindex++) : 0, q(x, C);
2128
- } while (C !== 0);
2129
- x.gzhead.hcrc && x.pending > y && (a.adler = d(a.adler, x.pending_buf, x.pending - y, y)), C === 0 && (x.gzindex = 0, x.status = 91);
2130
- } else x.status = 91;
2131
- if (x.status === 91) if (x.gzhead.comment) {
2132
- y = x.pending;
2133
- do {
2134
- if (x.pending === x.pending_buf_size && (x.gzhead.hcrc && x.pending > y && (a.adler = d(a.adler, x.pending_buf, x.pending - y, y)), O(a), y = x.pending, x.pending === x.pending_buf_size)) {
2135
- C = 1;
2136
- break;
2137
- }
2138
- C = x.gzindex < x.gzhead.comment.length ? 255 & x.gzhead.comment.charCodeAt(x.gzindex++) : 0, q(x, C);
2139
- } while (C !== 0);
2140
- x.gzhead.hcrc && x.pending > y && (a.adler = d(a.adler, x.pending_buf, x.pending - y, y)), C === 0 && (x.status = 103);
2141
- } else x.status = 103;
2142
- if (x.status === 103 && (x.gzhead.hcrc ? (x.pending + 2 > x.pending_buf_size && O(a), x.pending + 2 <= x.pending_buf_size && (q(x, 255 & a.adler), q(x, a.adler >> 8 & 255), a.adler = 0, x.status = j)) : x.status = j), x.pending !== 0) {
2143
- if (O(a), a.avail_out === 0) return x.last_flush = -1, h;
2144
- } else if (a.avail_in === 0 && W(B) <= W(F) && B !== v) return tt(a, -5);
2145
- if (x.status === 666 && a.avail_in !== 0) return tt(a, -5);
2146
- if (a.avail_in !== 0 || x.lookahead !== 0 || B !== m && x.status !== 666) {
2147
- var U = x.strategy === 2 ? (function(A, Z) {
2148
- for (var Y; ; ) {
2149
- if (A.lookahead === 0 && (st(A), A.lookahead === 0)) {
2150
- if (Z === m) return u;
2151
- break;
2152
- }
2153
- if (A.match_length = 0, Y = o._tr_tally(A, 0, A.window[A.strstart]), A.lookahead--, A.strstart++, Y && (T(A, !1), A.strm.avail_out === 0)) return u;
2154
- }
2155
- return A.insert = 0, Z === v ? (T(A, !0), A.strm.avail_out === 0 ? H : $) : A.last_lit && (T(A, !1), A.strm.avail_out === 0) ? u : I;
2156
- })(x, B) : x.strategy === 3 ? (function(A, Z) {
2157
- for (var Y, X, J, it, nt = A.window; ; ) {
2158
- if (A.lookahead <= M) {
2159
- if (st(A), A.lookahead <= M && Z === m) return u;
2160
- if (A.lookahead === 0) break;
2161
- }
2162
- if (A.match_length = 0, A.lookahead >= R && 0 < A.strstart && (X = nt[J = A.strstart - 1]) === nt[++J] && X === nt[++J] && X === nt[++J]) {
2163
- it = A.strstart + M;
2164
- do
2165
- ;
2166
- while (X === nt[++J] && X === nt[++J] && X === nt[++J] && X === nt[++J] && X === nt[++J] && X === nt[++J] && X === nt[++J] && X === nt[++J] && J < it);
2167
- A.match_length = M - (it - J), A.match_length > A.lookahead && (A.match_length = A.lookahead);
2168
- }
2169
- if (A.match_length >= R ? (Y = o._tr_tally(A, 1, A.match_length - R), A.lookahead -= A.match_length, A.strstart += A.match_length, A.match_length = 0) : (Y = o._tr_tally(A, 0, A.window[A.strstart]), A.lookahead--, A.strstart++), Y && (T(A, !1), A.strm.avail_out === 0)) return u;
2170
- }
2171
- return A.insert = 0, Z === v ? (T(A, !0), A.strm.avail_out === 0 ? H : $) : A.last_lit && (T(A, !1), A.strm.avail_out === 0) ? u : I;
2172
- })(x, B) : i[x.level].func(x, B);
2173
- if (U !== H && U !== $ || (x.status = 666), U === u || U === H) return a.avail_out === 0 && (x.last_flush = -1), h;
2174
- if (U === I && (B === 1 ? o._tr_align(x) : B !== 5 && (o._tr_stored_block(x, 0, 0, !1), B === 3 && (Q(x.head), x.lookahead === 0 && (x.strstart = 0, x.block_start = 0, x.insert = 0))), O(a), a.avail_out === 0)) return x.last_flush = -1, h;
2175
- }
2176
- return B !== v ? h : x.wrap <= 0 ? 1 : (x.wrap === 2 ? (q(x, 255 & a.adler), q(x, a.adler >> 8 & 255), q(x, a.adler >> 16 & 255), q(x, a.adler >> 24 & 255), q(x, 255 & a.total_in), q(x, a.total_in >> 8 & 255), q(x, a.total_in >> 16 & 255), q(x, a.total_in >> 24 & 255)) : (K(x, a.adler >>> 16), K(x, 65535 & a.adler)), O(a), 0 < x.wrap && (x.wrap = -x.wrap), x.pending !== 0 ? h : 1);
2177
- }, s.deflateEnd = function(a) {
2178
- var B;
2179
- return a && a.state ? (B = a.state.status) !== k && B !== 69 && B !== 73 && B !== 91 && B !== 103 && B !== j && B !== 666 ? tt(a, b) : (a.state = null, B === j ? tt(a, -3) : h) : b;
2180
- }, s.deflateSetDictionary = function(a, B) {
2181
- var F, x, y, C, L, U, A, Z, Y = B.length;
2182
- if (!a || !a.state || (C = (F = a.state).wrap) === 2 || C === 1 && F.status !== k || F.lookahead) return b;
2183
- for (C === 1 && (a.adler = c(a.adler, B, Y, 0)), F.wrap = 0, Y >= F.w_size && (C === 0 && (Q(F.head), F.strstart = 0, F.block_start = 0, F.insert = 0), Z = new e.Buf8(F.w_size), e.arraySet(Z, B, Y - F.w_size, F.w_size, 0), B = Z, Y = F.w_size), L = a.avail_in, U = a.next_in, A = a.input, a.avail_in = Y, a.next_in = 0, a.input = B, st(F); F.lookahead >= R; ) {
2184
- for (x = F.strstart, y = F.lookahead - (R - 1); F.ins_h = (F.ins_h << F.hash_shift ^ F.window[x + R - 1]) & F.hash_mask, F.prev[x & F.w_mask] = F.head[F.ins_h], F.head[F.ins_h] = x, x++, --y; ) ;
2185
- F.strstart = x, F.lookahead = R - 1, st(F);
2186
- }
2187
- return F.strstart += F.lookahead, F.block_start = F.strstart, F.insert = F.lookahead, F.lookahead = 0, F.match_length = F.prev_length = R - 1, F.match_available = 0, a.next_in = U, a.input = A, a.avail_in = L, F.wrap = C, h;
2188
- }, s.deflateInfo = "pako deflate (from Nodeca project)";
2189
- }, { "../utils/common": 41, "./adler32": 43, "./crc32": 45, "./messages": 51, "./trees": 52 }], 47: [function(t, l, s) {
2190
- l.exports = function() {
2191
- this.text = 0, this.time = 0, this.xflags = 0, this.os = 0, this.extra = null, this.extra_len = 0, this.name = "", this.comment = "", this.hcrc = 0, this.done = !1;
2192
- };
2193
- }, {}], 48: [function(t, l, s) {
2194
- l.exports = function(i, e) {
2195
- var o, c, d, _, m, v, h, b, f, g, p, w, S, E, z, P, D, N, R, M, V, k, j, u, I;
2196
- o = i.state, c = i.next_in, u = i.input, d = c + (i.avail_in - 5), _ = i.next_out, I = i.output, m = _ - (e - i.avail_out), v = _ + (i.avail_out - 257), h = o.dmax, b = o.wsize, f = o.whave, g = o.wnext, p = o.window, w = o.hold, S = o.bits, E = o.lencode, z = o.distcode, P = (1 << o.lenbits) - 1, D = (1 << o.distbits) - 1;
2197
- t: do {
2198
- S < 15 && (w += u[c++] << S, S += 8, w += u[c++] << S, S += 8), N = E[w & P];
2199
- e: for (; ; ) {
2200
- if (w >>>= R = N >>> 24, S -= R, (R = N >>> 16 & 255) === 0) I[_++] = 65535 & N;
2201
- else {
2202
- if (!(16 & R)) {
2203
- if ((64 & R) == 0) {
2204
- N = E[(65535 & N) + (w & (1 << R) - 1)];
2205
- continue e;
2206
- }
2207
- if (32 & R) {
2208
- o.mode = 12;
2209
- break t;
2210
- }
2211
- i.msg = "invalid literal/length code", o.mode = 30;
2212
- break t;
2213
- }
2214
- M = 65535 & N, (R &= 15) && (S < R && (w += u[c++] << S, S += 8), M += w & (1 << R) - 1, w >>>= R, S -= R), S < 15 && (w += u[c++] << S, S += 8, w += u[c++] << S, S += 8), N = z[w & D];
2215
- n: for (; ; ) {
2216
- if (w >>>= R = N >>> 24, S -= R, !(16 & (R = N >>> 16 & 255))) {
2217
- if ((64 & R) == 0) {
2218
- N = z[(65535 & N) + (w & (1 << R) - 1)];
2219
- continue n;
2220
- }
2221
- i.msg = "invalid distance code", o.mode = 30;
2222
- break t;
2223
- }
2224
- if (V = 65535 & N, S < (R &= 15) && (w += u[c++] << S, (S += 8) < R && (w += u[c++] << S, S += 8)), h < (V += w & (1 << R) - 1)) {
2225
- i.msg = "invalid distance too far back", o.mode = 30;
2226
- break t;
2227
- }
2228
- if (w >>>= R, S -= R, (R = _ - m) < V) {
2229
- if (f < (R = V - R) && o.sane) {
2230
- i.msg = "invalid distance too far back", o.mode = 30;
2231
- break t;
2232
- }
2233
- if (j = p, (k = 0) === g) {
2234
- if (k += b - R, R < M) {
2235
- for (M -= R; I[_++] = p[k++], --R; ) ;
2236
- k = _ - V, j = I;
2237
- }
2238
- } else if (g < R) {
2239
- if (k += b + g - R, (R -= g) < M) {
2240
- for (M -= R; I[_++] = p[k++], --R; ) ;
2241
- if (k = 0, g < M) {
2242
- for (M -= R = g; I[_++] = p[k++], --R; ) ;
2243
- k = _ - V, j = I;
2244
- }
2245
- }
2246
- } else if (k += g - R, R < M) {
2247
- for (M -= R; I[_++] = p[k++], --R; ) ;
2248
- k = _ - V, j = I;
2249
- }
2250
- for (; 2 < M; ) I[_++] = j[k++], I[_++] = j[k++], I[_++] = j[k++], M -= 3;
2251
- M && (I[_++] = j[k++], 1 < M && (I[_++] = j[k++]));
2252
- } else {
2253
- for (k = _ - V; I[_++] = I[k++], I[_++] = I[k++], I[_++] = I[k++], 2 < (M -= 3); ) ;
2254
- M && (I[_++] = I[k++], 1 < M && (I[_++] = I[k++]));
2255
- }
2256
- break;
2257
- }
2258
- }
2259
- break;
2260
- }
2261
- } while (c < d && _ < v);
2262
- c -= M = S >> 3, w &= (1 << (S -= M << 3)) - 1, i.next_in = c, i.next_out = _, i.avail_in = c < d ? d - c + 5 : 5 - (c - d), i.avail_out = _ < v ? v - _ + 257 : 257 - (_ - v), o.hold = w, o.bits = S;
2263
- };
2264
- }, {}], 49: [function(t, l, s) {
2265
- var i = t("../utils/common"), e = t("./adler32"), o = t("./crc32"), c = t("./inffast"), d = t("./inftrees"), _ = 1, m = 2, v = 0, h = -2, b = 1, f = 852, g = 592;
2266
- function p(k) {
2267
- return (k >>> 24 & 255) + (k >>> 8 & 65280) + ((65280 & k) << 8) + ((255 & k) << 24);
2268
- }
2269
- function w() {
2270
- this.mode = 0, this.last = !1, this.wrap = 0, this.havedict = !1, this.flags = 0, this.dmax = 0, this.check = 0, this.total = 0, this.head = null, this.wbits = 0, this.wsize = 0, this.whave = 0, this.wnext = 0, this.window = null, this.hold = 0, this.bits = 0, this.length = 0, this.offset = 0, this.extra = 0, this.lencode = null, this.distcode = null, this.lenbits = 0, this.distbits = 0, this.ncode = 0, this.nlen = 0, this.ndist = 0, this.have = 0, this.next = null, this.lens = new i.Buf16(320), this.work = new i.Buf16(288), this.lendyn = null, this.distdyn = null, this.sane = 0, this.back = 0, this.was = 0;
2271
- }
2272
- function S(k) {
2273
- var j;
2274
- return k && k.state ? (j = k.state, k.total_in = k.total_out = j.total = 0, k.msg = "", j.wrap && (k.adler = 1 & j.wrap), j.mode = b, j.last = 0, j.havedict = 0, j.dmax = 32768, j.head = null, j.hold = 0, j.bits = 0, j.lencode = j.lendyn = new i.Buf32(f), j.distcode = j.distdyn = new i.Buf32(g), j.sane = 1, j.back = -1, v) : h;
2275
- }
2276
- function E(k) {
2277
- var j;
2278
- return k && k.state ? ((j = k.state).wsize = 0, j.whave = 0, j.wnext = 0, S(k)) : h;
2279
- }
2280
- function z(k, j) {
2281
- var u, I;
2282
- return k && k.state ? (I = k.state, j < 0 ? (u = 0, j = -j) : (u = 1 + (j >> 4), j < 48 && (j &= 15)), j && (j < 8 || 15 < j) ? h : (I.window !== null && I.wbits !== j && (I.window = null), I.wrap = u, I.wbits = j, E(k))) : h;
2283
- }
2284
- function P(k, j) {
2285
- var u, I;
2286
- return k ? (I = new w(), (k.state = I).window = null, (u = z(k, j)) !== v && (k.state = null), u) : h;
2287
- }
2288
- var D, N, R = !0;
2289
- function M(k) {
2290
- if (R) {
2291
- var j;
2292
- for (D = new i.Buf32(512), N = new i.Buf32(32), j = 0; j < 144; ) k.lens[j++] = 8;
2293
- for (; j < 256; ) k.lens[j++] = 9;
2294
- for (; j < 280; ) k.lens[j++] = 7;
2295
- for (; j < 288; ) k.lens[j++] = 8;
2296
- for (d(_, k.lens, 0, 288, D, 0, k.work, { bits: 9 }), j = 0; j < 32; ) k.lens[j++] = 5;
2297
- d(m, k.lens, 0, 32, N, 0, k.work, { bits: 5 }), R = !1;
2298
- }
2299
- k.lencode = D, k.lenbits = 9, k.distcode = N, k.distbits = 5;
2300
- }
2301
- function V(k, j, u, I) {
2302
- var H, $ = k.state;
2303
- return $.window === null && ($.wsize = 1 << $.wbits, $.wnext = 0, $.whave = 0, $.window = new i.Buf8($.wsize)), I >= $.wsize ? (i.arraySet($.window, j, u - $.wsize, $.wsize, 0), $.wnext = 0, $.whave = $.wsize) : (I < (H = $.wsize - $.wnext) && (H = I), i.arraySet($.window, j, u - I, H, $.wnext), (I -= H) ? (i.arraySet($.window, j, u - I, I, 0), $.wnext = I, $.whave = $.wsize) : ($.wnext += H, $.wnext === $.wsize && ($.wnext = 0), $.whave < $.wsize && ($.whave += H))), 0;
2304
- }
2305
- s.inflateReset = E, s.inflateReset2 = z, s.inflateResetKeep = S, s.inflateInit = function(k) {
2306
- return P(k, 15);
2307
- }, s.inflateInit2 = P, s.inflate = function(k, j) {
2308
- var u, I, H, $, tt, W, Q, O, T, q, K, G, st, lt, et, rt, ct, at, mt, pt, a, B, F, x, y = 0, C = new i.Buf8(4), L = [16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15];
2309
- if (!k || !k.state || !k.output || !k.input && k.avail_in !== 0) return h;
2310
- (u = k.state).mode === 12 && (u.mode = 13), tt = k.next_out, H = k.output, Q = k.avail_out, $ = k.next_in, I = k.input, W = k.avail_in, O = u.hold, T = u.bits, q = W, K = Q, B = v;
2311
- t: for (; ; ) switch (u.mode) {
2312
- case b:
2313
- if (u.wrap === 0) {
2314
- u.mode = 13;
2315
- break;
2316
- }
2317
- for (; T < 16; ) {
2318
- if (W === 0) break t;
2319
- W--, O += I[$++] << T, T += 8;
2320
- }
2321
- if (2 & u.wrap && O === 35615) {
2322
- C[u.check = 0] = 255 & O, C[1] = O >>> 8 & 255, u.check = o(u.check, C, 2, 0), T = O = 0, u.mode = 2;
2323
- break;
2324
- }
2325
- if (u.flags = 0, u.head && (u.head.done = !1), !(1 & u.wrap) || (((255 & O) << 8) + (O >> 8)) % 31) {
2326
- k.msg = "incorrect header check", u.mode = 30;
2327
- break;
2328
- }
2329
- if ((15 & O) != 8) {
2330
- k.msg = "unknown compression method", u.mode = 30;
2331
- break;
2332
- }
2333
- if (T -= 4, a = 8 + (15 & (O >>>= 4)), u.wbits === 0) u.wbits = a;
2334
- else if (a > u.wbits) {
2335
- k.msg = "invalid window size", u.mode = 30;
2336
- break;
2337
- }
2338
- u.dmax = 1 << a, k.adler = u.check = 1, u.mode = 512 & O ? 10 : 12, T = O = 0;
2339
- break;
2340
- case 2:
2341
- for (; T < 16; ) {
2342
- if (W === 0) break t;
2343
- W--, O += I[$++] << T, T += 8;
2344
- }
2345
- if (u.flags = O, (255 & u.flags) != 8) {
2346
- k.msg = "unknown compression method", u.mode = 30;
2347
- break;
2348
- }
2349
- if (57344 & u.flags) {
2350
- k.msg = "unknown header flags set", u.mode = 30;
2351
- break;
2352
- }
2353
- u.head && (u.head.text = O >> 8 & 1), 512 & u.flags && (C[0] = 255 & O, C[1] = O >>> 8 & 255, u.check = o(u.check, C, 2, 0)), T = O = 0, u.mode = 3;
2354
- case 3:
2355
- for (; T < 32; ) {
2356
- if (W === 0) break t;
2357
- W--, O += I[$++] << T, T += 8;
2358
- }
2359
- u.head && (u.head.time = O), 512 & u.flags && (C[0] = 255 & O, C[1] = O >>> 8 & 255, C[2] = O >>> 16 & 255, C[3] = O >>> 24 & 255, u.check = o(u.check, C, 4, 0)), T = O = 0, u.mode = 4;
2360
- case 4:
2361
- for (; T < 16; ) {
2362
- if (W === 0) break t;
2363
- W--, O += I[$++] << T, T += 8;
2364
- }
2365
- u.head && (u.head.xflags = 255 & O, u.head.os = O >> 8), 512 & u.flags && (C[0] = 255 & O, C[1] = O >>> 8 & 255, u.check = o(u.check, C, 2, 0)), T = O = 0, u.mode = 5;
2366
- case 5:
2367
- if (1024 & u.flags) {
2368
- for (; T < 16; ) {
2369
- if (W === 0) break t;
2370
- W--, O += I[$++] << T, T += 8;
2371
- }
2372
- u.length = O, u.head && (u.head.extra_len = O), 512 & u.flags && (C[0] = 255 & O, C[1] = O >>> 8 & 255, u.check = o(u.check, C, 2, 0)), T = O = 0;
2373
- } else u.head && (u.head.extra = null);
2374
- u.mode = 6;
2375
- case 6:
2376
- if (1024 & u.flags && (W < (G = u.length) && (G = W), G && (u.head && (a = u.head.extra_len - u.length, u.head.extra || (u.head.extra = new Array(u.head.extra_len)), i.arraySet(u.head.extra, I, $, G, a)), 512 & u.flags && (u.check = o(u.check, I, G, $)), W -= G, $ += G, u.length -= G), u.length)) break t;
2377
- u.length = 0, u.mode = 7;
2378
- case 7:
2379
- if (2048 & u.flags) {
2380
- if (W === 0) break t;
2381
- for (G = 0; a = I[$ + G++], u.head && a && u.length < 65536 && (u.head.name += String.fromCharCode(a)), a && G < W; ) ;
2382
- if (512 & u.flags && (u.check = o(u.check, I, G, $)), W -= G, $ += G, a) break t;
2383
- } else u.head && (u.head.name = null);
2384
- u.length = 0, u.mode = 8;
2385
- case 8:
2386
- if (4096 & u.flags) {
2387
- if (W === 0) break t;
2388
- for (G = 0; a = I[$ + G++], u.head && a && u.length < 65536 && (u.head.comment += String.fromCharCode(a)), a && G < W; ) ;
2389
- if (512 & u.flags && (u.check = o(u.check, I, G, $)), W -= G, $ += G, a) break t;
2390
- } else u.head && (u.head.comment = null);
2391
- u.mode = 9;
2392
- case 9:
2393
- if (512 & u.flags) {
2394
- for (; T < 16; ) {
2395
- if (W === 0) break t;
2396
- W--, O += I[$++] << T, T += 8;
2397
- }
2398
- if (O !== (65535 & u.check)) {
2399
- k.msg = "header crc mismatch", u.mode = 30;
2400
- break;
2401
- }
2402
- T = O = 0;
2403
- }
2404
- u.head && (u.head.hcrc = u.flags >> 9 & 1, u.head.done = !0), k.adler = u.check = 0, u.mode = 12;
2405
- break;
2406
- case 10:
2407
- for (; T < 32; ) {
2408
- if (W === 0) break t;
2409
- W--, O += I[$++] << T, T += 8;
2410
- }
2411
- k.adler = u.check = p(O), T = O = 0, u.mode = 11;
2412
- case 11:
2413
- if (u.havedict === 0) return k.next_out = tt, k.avail_out = Q, k.next_in = $, k.avail_in = W, u.hold = O, u.bits = T, 2;
2414
- k.adler = u.check = 1, u.mode = 12;
2415
- case 12:
2416
- if (j === 5 || j === 6) break t;
2417
- case 13:
2418
- if (u.last) {
2419
- O >>>= 7 & T, T -= 7 & T, u.mode = 27;
2420
- break;
2421
- }
2422
- for (; T < 3; ) {
2423
- if (W === 0) break t;
2424
- W--, O += I[$++] << T, T += 8;
2425
- }
2426
- switch (u.last = 1 & O, T -= 1, 3 & (O >>>= 1)) {
2427
- case 0:
2428
- u.mode = 14;
2429
- break;
2430
- case 1:
2431
- if (M(u), u.mode = 20, j !== 6) break;
2432
- O >>>= 2, T -= 2;
2433
- break t;
2434
- case 2:
2435
- u.mode = 17;
2436
- break;
2437
- case 3:
2438
- k.msg = "invalid block type", u.mode = 30;
2439
- }
2440
- O >>>= 2, T -= 2;
2441
- break;
2442
- case 14:
2443
- for (O >>>= 7 & T, T -= 7 & T; T < 32; ) {
2444
- if (W === 0) break t;
2445
- W--, O += I[$++] << T, T += 8;
2446
- }
2447
- if ((65535 & O) != (O >>> 16 ^ 65535)) {
2448
- k.msg = "invalid stored block lengths", u.mode = 30;
2449
- break;
2450
- }
2451
- if (u.length = 65535 & O, T = O = 0, u.mode = 15, j === 6) break t;
2452
- case 15:
2453
- u.mode = 16;
2454
- case 16:
2455
- if (G = u.length) {
2456
- if (W < G && (G = W), Q < G && (G = Q), G === 0) break t;
2457
- i.arraySet(H, I, $, G, tt), W -= G, $ += G, Q -= G, tt += G, u.length -= G;
2458
- break;
2459
- }
2460
- u.mode = 12;
2461
- break;
2462
- case 17:
2463
- for (; T < 14; ) {
2464
- if (W === 0) break t;
2465
- W--, O += I[$++] << T, T += 8;
2466
- }
2467
- if (u.nlen = 257 + (31 & O), O >>>= 5, T -= 5, u.ndist = 1 + (31 & O), O >>>= 5, T -= 5, u.ncode = 4 + (15 & O), O >>>= 4, T -= 4, 286 < u.nlen || 30 < u.ndist) {
2468
- k.msg = "too many length or distance symbols", u.mode = 30;
2469
- break;
2470
- }
2471
- u.have = 0, u.mode = 18;
2472
- case 18:
2473
- for (; u.have < u.ncode; ) {
2474
- for (; T < 3; ) {
2475
- if (W === 0) break t;
2476
- W--, O += I[$++] << T, T += 8;
2477
- }
2478
- u.lens[L[u.have++]] = 7 & O, O >>>= 3, T -= 3;
2479
- }
2480
- for (; u.have < 19; ) u.lens[L[u.have++]] = 0;
2481
- if (u.lencode = u.lendyn, u.lenbits = 7, F = { bits: u.lenbits }, B = d(0, u.lens, 0, 19, u.lencode, 0, u.work, F), u.lenbits = F.bits, B) {
2482
- k.msg = "invalid code lengths set", u.mode = 30;
2483
- break;
2484
- }
2485
- u.have = 0, u.mode = 19;
2486
- case 19:
2487
- for (; u.have < u.nlen + u.ndist; ) {
2488
- for (; rt = (y = u.lencode[O & (1 << u.lenbits) - 1]) >>> 16 & 255, ct = 65535 & y, !((et = y >>> 24) <= T); ) {
2489
- if (W === 0) break t;
2490
- W--, O += I[$++] << T, T += 8;
2491
- }
2492
- if (ct < 16) O >>>= et, T -= et, u.lens[u.have++] = ct;
2493
- else {
2494
- if (ct === 16) {
2495
- for (x = et + 2; T < x; ) {
2496
- if (W === 0) break t;
2497
- W--, O += I[$++] << T, T += 8;
2498
- }
2499
- if (O >>>= et, T -= et, u.have === 0) {
2500
- k.msg = "invalid bit length repeat", u.mode = 30;
2501
- break;
2502
- }
2503
- a = u.lens[u.have - 1], G = 3 + (3 & O), O >>>= 2, T -= 2;
2504
- } else if (ct === 17) {
2505
- for (x = et + 3; T < x; ) {
2506
- if (W === 0) break t;
2507
- W--, O += I[$++] << T, T += 8;
2508
- }
2509
- T -= et, a = 0, G = 3 + (7 & (O >>>= et)), O >>>= 3, T -= 3;
2510
- } else {
2511
- for (x = et + 7; T < x; ) {
2512
- if (W === 0) break t;
2513
- W--, O += I[$++] << T, T += 8;
2514
- }
2515
- T -= et, a = 0, G = 11 + (127 & (O >>>= et)), O >>>= 7, T -= 7;
2516
- }
2517
- if (u.have + G > u.nlen + u.ndist) {
2518
- k.msg = "invalid bit length repeat", u.mode = 30;
2519
- break;
2520
- }
2521
- for (; G--; ) u.lens[u.have++] = a;
2522
- }
2523
- }
2524
- if (u.mode === 30) break;
2525
- if (u.lens[256] === 0) {
2526
- k.msg = "invalid code -- missing end-of-block", u.mode = 30;
2527
- break;
2528
- }
2529
- if (u.lenbits = 9, F = { bits: u.lenbits }, B = d(_, u.lens, 0, u.nlen, u.lencode, 0, u.work, F), u.lenbits = F.bits, B) {
2530
- k.msg = "invalid literal/lengths set", u.mode = 30;
2531
- break;
2532
- }
2533
- if (u.distbits = 6, u.distcode = u.distdyn, F = { bits: u.distbits }, B = d(m, u.lens, u.nlen, u.ndist, u.distcode, 0, u.work, F), u.distbits = F.bits, B) {
2534
- k.msg = "invalid distances set", u.mode = 30;
2535
- break;
2536
- }
2537
- if (u.mode = 20, j === 6) break t;
2538
- case 20:
2539
- u.mode = 21;
2540
- case 21:
2541
- if (6 <= W && 258 <= Q) {
2542
- k.next_out = tt, k.avail_out = Q, k.next_in = $, k.avail_in = W, u.hold = O, u.bits = T, c(k, K), tt = k.next_out, H = k.output, Q = k.avail_out, $ = k.next_in, I = k.input, W = k.avail_in, O = u.hold, T = u.bits, u.mode === 12 && (u.back = -1);
2543
- break;
2544
- }
2545
- for (u.back = 0; rt = (y = u.lencode[O & (1 << u.lenbits) - 1]) >>> 16 & 255, ct = 65535 & y, !((et = y >>> 24) <= T); ) {
2546
- if (W === 0) break t;
2547
- W--, O += I[$++] << T, T += 8;
2548
- }
2549
- if (rt && (240 & rt) == 0) {
2550
- for (at = et, mt = rt, pt = ct; rt = (y = u.lencode[pt + ((O & (1 << at + mt) - 1) >> at)]) >>> 16 & 255, ct = 65535 & y, !(at + (et = y >>> 24) <= T); ) {
2551
- if (W === 0) break t;
2552
- W--, O += I[$++] << T, T += 8;
2553
- }
2554
- O >>>= at, T -= at, u.back += at;
2555
- }
2556
- if (O >>>= et, T -= et, u.back += et, u.length = ct, rt === 0) {
2557
- u.mode = 26;
2558
- break;
2559
- }
2560
- if (32 & rt) {
2561
- u.back = -1, u.mode = 12;
2562
- break;
2563
- }
2564
- if (64 & rt) {
2565
- k.msg = "invalid literal/length code", u.mode = 30;
2566
- break;
2567
- }
2568
- u.extra = 15 & rt, u.mode = 22;
2569
- case 22:
2570
- if (u.extra) {
2571
- for (x = u.extra; T < x; ) {
2572
- if (W === 0) break t;
2573
- W--, O += I[$++] << T, T += 8;
2574
- }
2575
- u.length += O & (1 << u.extra) - 1, O >>>= u.extra, T -= u.extra, u.back += u.extra;
2576
- }
2577
- u.was = u.length, u.mode = 23;
2578
- case 23:
2579
- for (; rt = (y = u.distcode[O & (1 << u.distbits) - 1]) >>> 16 & 255, ct = 65535 & y, !((et = y >>> 24) <= T); ) {
2580
- if (W === 0) break t;
2581
- W--, O += I[$++] << T, T += 8;
2582
- }
2583
- if ((240 & rt) == 0) {
2584
- for (at = et, mt = rt, pt = ct; rt = (y = u.distcode[pt + ((O & (1 << at + mt) - 1) >> at)]) >>> 16 & 255, ct = 65535 & y, !(at + (et = y >>> 24) <= T); ) {
2585
- if (W === 0) break t;
2586
- W--, O += I[$++] << T, T += 8;
2587
- }
2588
- O >>>= at, T -= at, u.back += at;
2589
- }
2590
- if (O >>>= et, T -= et, u.back += et, 64 & rt) {
2591
- k.msg = "invalid distance code", u.mode = 30;
2592
- break;
2593
- }
2594
- u.offset = ct, u.extra = 15 & rt, u.mode = 24;
2595
- case 24:
2596
- if (u.extra) {
2597
- for (x = u.extra; T < x; ) {
2598
- if (W === 0) break t;
2599
- W--, O += I[$++] << T, T += 8;
2600
- }
2601
- u.offset += O & (1 << u.extra) - 1, O >>>= u.extra, T -= u.extra, u.back += u.extra;
2602
- }
2603
- if (u.offset > u.dmax) {
2604
- k.msg = "invalid distance too far back", u.mode = 30;
2605
- break;
2606
- }
2607
- u.mode = 25;
2608
- case 25:
2609
- if (Q === 0) break t;
2610
- if (G = K - Q, u.offset > G) {
2611
- if ((G = u.offset - G) > u.whave && u.sane) {
2612
- k.msg = "invalid distance too far back", u.mode = 30;
2613
- break;
2614
- }
2615
- st = G > u.wnext ? (G -= u.wnext, u.wsize - G) : u.wnext - G, G > u.length && (G = u.length), lt = u.window;
2616
- } else lt = H, st = tt - u.offset, G = u.length;
2617
- for (Q < G && (G = Q), Q -= G, u.length -= G; H[tt++] = lt[st++], --G; ) ;
2618
- u.length === 0 && (u.mode = 21);
2619
- break;
2620
- case 26:
2621
- if (Q === 0) break t;
2622
- H[tt++] = u.length, Q--, u.mode = 21;
2623
- break;
2624
- case 27:
2625
- if (u.wrap) {
2626
- for (; T < 32; ) {
2627
- if (W === 0) break t;
2628
- W--, O |= I[$++] << T, T += 8;
2629
- }
2630
- if (K -= Q, k.total_out += K, u.total += K, K && (k.adler = u.check = u.flags ? o(u.check, H, K, tt - K) : e(u.check, H, K, tt - K)), K = Q, (u.flags ? O : p(O)) !== u.check) {
2631
- k.msg = "incorrect data check", u.mode = 30;
2632
- break;
2633
- }
2634
- T = O = 0;
2635
- }
2636
- u.mode = 28;
2637
- case 28:
2638
- if (u.wrap && u.flags) {
2639
- for (; T < 32; ) {
2640
- if (W === 0) break t;
2641
- W--, O += I[$++] << T, T += 8;
2642
- }
2643
- if (O !== (4294967295 & u.total)) {
2644
- k.msg = "incorrect length check", u.mode = 30;
2645
- break;
2646
- }
2647
- T = O = 0;
2648
- }
2649
- u.mode = 29;
2650
- case 29:
2651
- B = 1;
2652
- break t;
2653
- case 30:
2654
- B = -3;
2655
- break t;
2656
- case 31:
2657
- return -4;
2658
- default:
2659
- return h;
2660
- }
2661
- return k.next_out = tt, k.avail_out = Q, k.next_in = $, k.avail_in = W, u.hold = O, u.bits = T, (u.wsize || K !== k.avail_out && u.mode < 30 && (u.mode < 27 || j !== 4)) && V(k, k.output, k.next_out, K - k.avail_out) ? (u.mode = 31, -4) : (q -= k.avail_in, K -= k.avail_out, k.total_in += q, k.total_out += K, u.total += K, u.wrap && K && (k.adler = u.check = u.flags ? o(u.check, H, K, k.next_out - K) : e(u.check, H, K, k.next_out - K)), k.data_type = u.bits + (u.last ? 64 : 0) + (u.mode === 12 ? 128 : 0) + (u.mode === 20 || u.mode === 15 ? 256 : 0), (q == 0 && K === 0 || j === 4) && B === v && (B = -5), B);
2662
- }, s.inflateEnd = function(k) {
2663
- if (!k || !k.state) return h;
2664
- var j = k.state;
2665
- return j.window && (j.window = null), k.state = null, v;
2666
- }, s.inflateGetHeader = function(k, j) {
2667
- var u;
2668
- return k && k.state ? (2 & (u = k.state).wrap) == 0 ? h : ((u.head = j).done = !1, v) : h;
2669
- }, s.inflateSetDictionary = function(k, j) {
2670
- var u, I = j.length;
2671
- return k && k.state ? (u = k.state).wrap !== 0 && u.mode !== 11 ? h : u.mode === 11 && e(1, j, I, 0) !== u.check ? -3 : V(k, j, I, I) ? (u.mode = 31, -4) : (u.havedict = 1, v) : h;
2672
- }, s.inflateInfo = "pako inflate (from Nodeca project)";
2673
- }, { "../utils/common": 41, "./adler32": 43, "./crc32": 45, "./inffast": 48, "./inftrees": 50 }], 50: [function(t, l, s) {
2674
- var i = t("../utils/common"), e = [3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31, 35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0], o = [16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 18, 18, 18, 18, 19, 19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 16, 72, 78], c = [1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193, 257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145, 8193, 12289, 16385, 24577, 0, 0], d = [16, 16, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22, 23, 23, 24, 24, 25, 25, 26, 26, 27, 27, 28, 28, 29, 29, 64, 64];
2675
- l.exports = function(_, m, v, h, b, f, g, p) {
2676
- var w, S, E, z, P, D, N, R, M, V = p.bits, k = 0, j = 0, u = 0, I = 0, H = 0, $ = 0, tt = 0, W = 0, Q = 0, O = 0, T = null, q = 0, K = new i.Buf16(16), G = new i.Buf16(16), st = null, lt = 0;
2677
- for (k = 0; k <= 15; k++) K[k] = 0;
2678
- for (j = 0; j < h; j++) K[m[v + j]]++;
2679
- for (H = V, I = 15; 1 <= I && K[I] === 0; I--) ;
2680
- if (I < H && (H = I), I === 0) return b[f++] = 20971520, b[f++] = 20971520, p.bits = 1, 0;
2681
- for (u = 1; u < I && K[u] === 0; u++) ;
2682
- for (H < u && (H = u), k = W = 1; k <= 15; k++) if (W <<= 1, (W -= K[k]) < 0) return -1;
2683
- if (0 < W && (_ === 0 || I !== 1)) return -1;
2684
- for (G[1] = 0, k = 1; k < 15; k++) G[k + 1] = G[k] + K[k];
2685
- for (j = 0; j < h; j++) m[v + j] !== 0 && (g[G[m[v + j]]++] = j);
2686
- if (D = _ === 0 ? (T = st = g, 19) : _ === 1 ? (T = e, q -= 257, st = o, lt -= 257, 256) : (T = c, st = d, -1), k = u, P = f, tt = j = O = 0, E = -1, z = (Q = 1 << ($ = H)) - 1, _ === 1 && 852 < Q || _ === 2 && 592 < Q) return 1;
2687
- for (; ; ) {
2688
- for (N = k - tt, M = g[j] < D ? (R = 0, g[j]) : g[j] > D ? (R = st[lt + g[j]], T[q + g[j]]) : (R = 96, 0), w = 1 << k - tt, u = S = 1 << $; b[P + (O >> tt) + (S -= w)] = N << 24 | R << 16 | M | 0, S !== 0; ) ;
2689
- for (w = 1 << k - 1; O & w; ) w >>= 1;
2690
- if (w !== 0 ? (O &= w - 1, O += w) : O = 0, j++, --K[k] == 0) {
2691
- if (k === I) break;
2692
- k = m[v + g[j]];
2693
- }
2694
- if (H < k && (O & z) !== E) {
2695
- for (tt === 0 && (tt = H), P += u, W = 1 << ($ = k - tt); $ + tt < I && !((W -= K[$ + tt]) <= 0); ) $++, W <<= 1;
2696
- if (Q += 1 << $, _ === 1 && 852 < Q || _ === 2 && 592 < Q) return 1;
2697
- b[E = O & z] = H << 24 | $ << 16 | P - f | 0;
2698
- }
2699
- }
2700
- return O !== 0 && (b[P + O] = k - tt << 24 | 64 << 16 | 0), p.bits = H, 0;
2701
- };
2702
- }, { "../utils/common": 41 }], 51: [function(t, l, s) {
2703
- l.exports = { 2: "need dictionary", 1: "stream end", 0: "", "-1": "file error", "-2": "stream error", "-3": "data error", "-4": "insufficient memory", "-5": "buffer error", "-6": "incompatible version" };
2704
- }, {}], 52: [function(t, l, s) {
2705
- var i = t("../utils/common"), e = 0, o = 1;
2706
- function c(y) {
2707
- for (var C = y.length; 0 <= --C; ) y[C] = 0;
2708
- }
2709
- var d = 0, _ = 29, m = 256, v = m + 1 + _, h = 30, b = 19, f = 2 * v + 1, g = 15, p = 16, w = 7, S = 256, E = 16, z = 17, P = 18, D = [0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 0], N = [0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13], R = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 3, 7], M = [16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15], V = new Array(2 * (v + 2));
2710
- c(V);
2711
- var k = new Array(2 * h);
2712
- c(k);
2713
- var j = new Array(512);
2714
- c(j);
2715
- var u = new Array(256);
2716
- c(u);
2717
- var I = new Array(_);
2718
- c(I);
2719
- var H, $, tt, W = new Array(h);
2720
- function Q(y, C, L, U, A) {
2721
- this.static_tree = y, this.extra_bits = C, this.extra_base = L, this.elems = U, this.max_length = A, this.has_stree = y && y.length;
2722
- }
2723
- function O(y, C) {
2724
- this.dyn_tree = y, this.max_code = 0, this.stat_desc = C;
2725
- }
2726
- function T(y) {
2727
- return y < 256 ? j[y] : j[256 + (y >>> 7)];
2728
- }
2729
- function q(y, C) {
2730
- y.pending_buf[y.pending++] = 255 & C, y.pending_buf[y.pending++] = C >>> 8 & 255;
2731
- }
2732
- function K(y, C, L) {
2733
- y.bi_valid > p - L ? (y.bi_buf |= C << y.bi_valid & 65535, q(y, y.bi_buf), y.bi_buf = C >> p - y.bi_valid, y.bi_valid += L - p) : (y.bi_buf |= C << y.bi_valid & 65535, y.bi_valid += L);
2734
- }
2735
- function G(y, C, L) {
2736
- K(y, L[2 * C], L[2 * C + 1]);
2737
- }
2738
- function st(y, C) {
2739
- for (var L = 0; L |= 1 & y, y >>>= 1, L <<= 1, 0 < --C; ) ;
2740
- return L >>> 1;
2741
- }
2742
- function lt(y, C, L) {
2743
- var U, A, Z = new Array(g + 1), Y = 0;
2744
- for (U = 1; U <= g; U++) Z[U] = Y = Y + L[U - 1] << 1;
2745
- for (A = 0; A <= C; A++) {
2746
- var X = y[2 * A + 1];
2747
- X !== 0 && (y[2 * A] = st(Z[X]++, X));
2748
- }
2749
- }
2750
- function et(y) {
2751
- var C;
2752
- for (C = 0; C < v; C++) y.dyn_ltree[2 * C] = 0;
2753
- for (C = 0; C < h; C++) y.dyn_dtree[2 * C] = 0;
2754
- for (C = 0; C < b; C++) y.bl_tree[2 * C] = 0;
2755
- y.dyn_ltree[2 * S] = 1, y.opt_len = y.static_len = 0, y.last_lit = y.matches = 0;
2756
- }
2757
- function rt(y) {
2758
- 8 < y.bi_valid ? q(y, y.bi_buf) : 0 < y.bi_valid && (y.pending_buf[y.pending++] = y.bi_buf), y.bi_buf = 0, y.bi_valid = 0;
2759
- }
2760
- function ct(y, C, L, U) {
2761
- var A = 2 * C, Z = 2 * L;
2762
- return y[A] < y[Z] || y[A] === y[Z] && U[C] <= U[L];
2763
- }
2764
- function at(y, C, L) {
2765
- for (var U = y.heap[L], A = L << 1; A <= y.heap_len && (A < y.heap_len && ct(C, y.heap[A + 1], y.heap[A], y.depth) && A++, !ct(C, U, y.heap[A], y.depth)); ) y.heap[L] = y.heap[A], L = A, A <<= 1;
2766
- y.heap[L] = U;
2767
- }
2768
- function mt(y, C, L) {
2769
- var U, A, Z, Y, X = 0;
2770
- if (y.last_lit !== 0) for (; U = y.pending_buf[y.d_buf + 2 * X] << 8 | y.pending_buf[y.d_buf + 2 * X + 1], A = y.pending_buf[y.l_buf + X], X++, U === 0 ? G(y, A, C) : (G(y, (Z = u[A]) + m + 1, C), (Y = D[Z]) !== 0 && K(y, A -= I[Z], Y), G(y, Z = T(--U), L), (Y = N[Z]) !== 0 && K(y, U -= W[Z], Y)), X < y.last_lit; ) ;
2771
- G(y, S, C);
2772
- }
2773
- function pt(y, C) {
2774
- var L, U, A, Z = C.dyn_tree, Y = C.stat_desc.static_tree, X = C.stat_desc.has_stree, J = C.stat_desc.elems, it = -1;
2775
- for (y.heap_len = 0, y.heap_max = f, L = 0; L < J; L++) Z[2 * L] !== 0 ? (y.heap[++y.heap_len] = it = L, y.depth[L] = 0) : Z[2 * L + 1] = 0;
2776
- for (; y.heap_len < 2; ) Z[2 * (A = y.heap[++y.heap_len] = it < 2 ? ++it : 0)] = 1, y.depth[A] = 0, y.opt_len--, X && (y.static_len -= Y[2 * A + 1]);
2777
- for (C.max_code = it, L = y.heap_len >> 1; 1 <= L; L--) at(y, Z, L);
2778
- for (A = J; L = y.heap[1], y.heap[1] = y.heap[y.heap_len--], at(y, Z, 1), U = y.heap[1], y.heap[--y.heap_max] = L, y.heap[--y.heap_max] = U, Z[2 * A] = Z[2 * L] + Z[2 * U], y.depth[A] = (y.depth[L] >= y.depth[U] ? y.depth[L] : y.depth[U]) + 1, Z[2 * L + 1] = Z[2 * U + 1] = A, y.heap[1] = A++, at(y, Z, 1), 2 <= y.heap_len; ) ;
2779
- y.heap[--y.heap_max] = y.heap[1], (function(nt, dt) {
2780
- var xt, gt, kt, ot, At, Nt, _t = dt.dyn_tree, ne = dt.max_code, Ze = dt.stat_desc.static_tree, Xe = dt.stat_desc.has_stree, Ge = dt.stat_desc.extra_bits, re = dt.stat_desc.extra_base, St = dt.stat_desc.max_length, Tt = 0;
2781
- for (ot = 0; ot <= g; ot++) nt.bl_count[ot] = 0;
2782
- for (_t[2 * nt.heap[nt.heap_max] + 1] = 0, xt = nt.heap_max + 1; xt < f; xt++) St < (ot = _t[2 * _t[2 * (gt = nt.heap[xt]) + 1] + 1] + 1) && (ot = St, Tt++), _t[2 * gt + 1] = ot, ne < gt || (nt.bl_count[ot]++, At = 0, re <= gt && (At = Ge[gt - re]), Nt = _t[2 * gt], nt.opt_len += Nt * (ot + At), Xe && (nt.static_len += Nt * (Ze[2 * gt + 1] + At)));
2783
- if (Tt !== 0) {
2784
- do {
2785
- for (ot = St - 1; nt.bl_count[ot] === 0; ) ot--;
2786
- nt.bl_count[ot]--, nt.bl_count[ot + 1] += 2, nt.bl_count[St]--, Tt -= 2;
2787
- } while (0 < Tt);
2788
- for (ot = St; ot !== 0; ot--) for (gt = nt.bl_count[ot]; gt !== 0; ) ne < (kt = nt.heap[--xt]) || (_t[2 * kt + 1] !== ot && (nt.opt_len += (ot - _t[2 * kt + 1]) * _t[2 * kt], _t[2 * kt + 1] = ot), gt--);
2789
- }
2790
- })(y, C), lt(Z, it, y.bl_count);
2791
- }
2792
- function a(y, C, L) {
2793
- var U, A, Z = -1, Y = C[1], X = 0, J = 7, it = 4;
2794
- for (Y === 0 && (J = 138, it = 3), C[2 * (L + 1) + 1] = 65535, U = 0; U <= L; U++) A = Y, Y = C[2 * (U + 1) + 1], ++X < J && A === Y || (X < it ? y.bl_tree[2 * A] += X : A !== 0 ? (A !== Z && y.bl_tree[2 * A]++, y.bl_tree[2 * E]++) : X <= 10 ? y.bl_tree[2 * z]++ : y.bl_tree[2 * P]++, Z = A, it = (X = 0) === Y ? (J = 138, 3) : A === Y ? (J = 6, 3) : (J = 7, 4));
2795
- }
2796
- function B(y, C, L) {
2797
- var U, A, Z = -1, Y = C[1], X = 0, J = 7, it = 4;
2798
- for (Y === 0 && (J = 138, it = 3), U = 0; U <= L; U++) if (A = Y, Y = C[2 * (U + 1) + 1], !(++X < J && A === Y)) {
2799
- if (X < it) for (; G(y, A, y.bl_tree), --X != 0; ) ;
2800
- else A !== 0 ? (A !== Z && (G(y, A, y.bl_tree), X--), G(y, E, y.bl_tree), K(y, X - 3, 2)) : X <= 10 ? (G(y, z, y.bl_tree), K(y, X - 3, 3)) : (G(y, P, y.bl_tree), K(y, X - 11, 7));
2801
- Z = A, it = (X = 0) === Y ? (J = 138, 3) : A === Y ? (J = 6, 3) : (J = 7, 4);
2802
- }
2803
- }
2804
- c(W);
2805
- var F = !1;
2806
- function x(y, C, L, U) {
2807
- K(y, (d << 1) + (U ? 1 : 0), 3), (function(A, Z, Y, X) {
2808
- rt(A), q(A, Y), q(A, ~Y), i.arraySet(A.pending_buf, A.window, Z, Y, A.pending), A.pending += Y;
2809
- })(y, C, L);
2810
- }
2811
- s._tr_init = function(y) {
2812
- F || ((function() {
2813
- var C, L, U, A, Z, Y = new Array(g + 1);
2814
- for (A = U = 0; A < _ - 1; A++) for (I[A] = U, C = 0; C < 1 << D[A]; C++) u[U++] = A;
2815
- for (u[U - 1] = A, A = Z = 0; A < 16; A++) for (W[A] = Z, C = 0; C < 1 << N[A]; C++) j[Z++] = A;
2816
- for (Z >>= 7; A < h; A++) for (W[A] = Z << 7, C = 0; C < 1 << N[A] - 7; C++) j[256 + Z++] = A;
2817
- for (L = 0; L <= g; L++) Y[L] = 0;
2818
- for (C = 0; C <= 143; ) V[2 * C + 1] = 8, C++, Y[8]++;
2819
- for (; C <= 255; ) V[2 * C + 1] = 9, C++, Y[9]++;
2820
- for (; C <= 279; ) V[2 * C + 1] = 7, C++, Y[7]++;
2821
- for (; C <= 287; ) V[2 * C + 1] = 8, C++, Y[8]++;
2822
- for (lt(V, v + 1, Y), C = 0; C < h; C++) k[2 * C + 1] = 5, k[2 * C] = st(C, 5);
2823
- H = new Q(V, D, m + 1, v, g), $ = new Q(k, N, 0, h, g), tt = new Q(new Array(0), R, 0, b, w);
2824
- })(), F = !0), y.l_desc = new O(y.dyn_ltree, H), y.d_desc = new O(y.dyn_dtree, $), y.bl_desc = new O(y.bl_tree, tt), y.bi_buf = 0, y.bi_valid = 0, et(y);
2825
- }, s._tr_stored_block = x, s._tr_flush_block = function(y, C, L, U) {
2826
- var A, Z, Y = 0;
2827
- 0 < y.level ? (y.strm.data_type === 2 && (y.strm.data_type = (function(X) {
2828
- var J, it = 4093624447;
2829
- for (J = 0; J <= 31; J++, it >>>= 1) if (1 & it && X.dyn_ltree[2 * J] !== 0) return e;
2830
- if (X.dyn_ltree[18] !== 0 || X.dyn_ltree[20] !== 0 || X.dyn_ltree[26] !== 0) return o;
2831
- for (J = 32; J < m; J++) if (X.dyn_ltree[2 * J] !== 0) return o;
2832
- return e;
2833
- })(y)), pt(y, y.l_desc), pt(y, y.d_desc), Y = (function(X) {
2834
- var J;
2835
- for (a(X, X.dyn_ltree, X.l_desc.max_code), a(X, X.dyn_dtree, X.d_desc.max_code), pt(X, X.bl_desc), J = b - 1; 3 <= J && X.bl_tree[2 * M[J] + 1] === 0; J--) ;
2836
- return X.opt_len += 3 * (J + 1) + 5 + 5 + 4, J;
2837
- })(y), A = y.opt_len + 3 + 7 >>> 3, (Z = y.static_len + 3 + 7 >>> 3) <= A && (A = Z)) : A = Z = L + 5, L + 4 <= A && C !== -1 ? x(y, C, L, U) : y.strategy === 4 || Z === A ? (K(y, 2 + (U ? 1 : 0), 3), mt(y, V, k)) : (K(y, 4 + (U ? 1 : 0), 3), (function(X, J, it, nt) {
2838
- var dt;
2839
- for (K(X, J - 257, 5), K(X, it - 1, 5), K(X, nt - 4, 4), dt = 0; dt < nt; dt++) K(X, X.bl_tree[2 * M[dt] + 1], 3);
2840
- B(X, X.dyn_ltree, J - 1), B(X, X.dyn_dtree, it - 1);
2841
- })(y, y.l_desc.max_code + 1, y.d_desc.max_code + 1, Y + 1), mt(y, y.dyn_ltree, y.dyn_dtree)), et(y), U && rt(y);
2842
- }, s._tr_tally = function(y, C, L) {
2843
- return y.pending_buf[y.d_buf + 2 * y.last_lit] = C >>> 8 & 255, y.pending_buf[y.d_buf + 2 * y.last_lit + 1] = 255 & C, y.pending_buf[y.l_buf + y.last_lit] = 255 & L, y.last_lit++, C === 0 ? y.dyn_ltree[2 * L]++ : (y.matches++, C--, y.dyn_ltree[2 * (u[L] + m + 1)]++, y.dyn_dtree[2 * T(C)]++), y.last_lit === y.lit_bufsize - 1;
2844
- }, s._tr_align = function(y) {
2845
- K(y, 2, 3), G(y, S, V), (function(C) {
2846
- C.bi_valid === 16 ? (q(C, C.bi_buf), C.bi_buf = 0, C.bi_valid = 0) : 8 <= C.bi_valid && (C.pending_buf[C.pending++] = 255 & C.bi_buf, C.bi_buf >>= 8, C.bi_valid -= 8);
2847
- })(y);
2848
- };
2849
- }, { "../utils/common": 41 }], 53: [function(t, l, s) {
2850
- l.exports = function() {
2851
- this.input = null, this.next_in = 0, this.avail_in = 0, this.total_in = 0, this.output = null, this.next_out = 0, this.avail_out = 0, this.total_out = 0, this.msg = "", this.state = null, this.data_type = 2, this.adler = 0;
2852
- };
2853
- }, {}], 54: [function(t, l, s) {
2854
- (function(i) {
2855
- (function(e, o) {
2856
- if (!e.setImmediate) {
2857
- var c, d, _, m, v = 1, h = {}, b = !1, f = e.document, g = Object.getPrototypeOf && Object.getPrototypeOf(e);
2858
- g = g && g.setTimeout ? g : e, c = {}.toString.call(e.process) === "[object process]" ? function(E) {
2859
- process.nextTick(function() {
2860
- w(E);
2861
- });
2862
- } : (function() {
2863
- if (e.postMessage && !e.importScripts) {
2864
- var E = !0, z = e.onmessage;
2865
- return e.onmessage = function() {
2866
- E = !1;
2867
- }, e.postMessage("", "*"), e.onmessage = z, E;
2868
- }
2869
- })() ? (m = "setImmediate$" + Math.random() + "$", e.addEventListener ? e.addEventListener("message", S, !1) : e.attachEvent("onmessage", S), function(E) {
2870
- e.postMessage(m + E, "*");
2871
- }) : e.MessageChannel ? ((_ = new MessageChannel()).port1.onmessage = function(E) {
2872
- w(E.data);
2873
- }, function(E) {
2874
- _.port2.postMessage(E);
2875
- }) : f && "onreadystatechange" in f.createElement("script") ? (d = f.documentElement, function(E) {
2876
- var z = f.createElement("script");
2877
- z.onreadystatechange = function() {
2878
- w(E), z.onreadystatechange = null, d.removeChild(z), z = null;
2879
- }, d.appendChild(z);
2880
- }) : function(E) {
2881
- setTimeout(w, 0, E);
2882
- }, g.setImmediate = function(E) {
2883
- typeof E != "function" && (E = new Function("" + E));
2884
- for (var z = new Array(arguments.length - 1), P = 0; P < z.length; P++) z[P] = arguments[P + 1];
2885
- var D = { callback: E, args: z };
2886
- return h[v] = D, c(v), v++;
2887
- }, g.clearImmediate = p;
2888
- }
2889
- function p(E) {
2890
- delete h[E];
2891
- }
2892
- function w(E) {
2893
- if (b) setTimeout(w, 0, E);
2894
- else {
2895
- var z = h[E];
2896
- if (z) {
2897
- b = !0;
2898
- try {
2899
- (function(P) {
2900
- var D = P.callback, N = P.args;
2901
- switch (N.length) {
2902
- case 0:
2903
- D();
2904
- break;
2905
- case 1:
2906
- D(N[0]);
2907
- break;
2908
- case 2:
2909
- D(N[0], N[1]);
2910
- break;
2911
- case 3:
2912
- D(N[0], N[1], N[2]);
2913
- break;
2914
- default:
2915
- D.apply(o, N);
2916
- }
2917
- })(z);
2918
- } finally {
2919
- p(E), b = !1;
2920
- }
2921
- }
2922
- }
2923
- }
2924
- function S(E) {
2925
- E.source === e && typeof E.data == "string" && E.data.indexOf(m) === 0 && w(+E.data.slice(m.length));
2926
- }
2927
- })(typeof self > "u" ? i === void 0 ? this : i : self);
2928
- }).call(this, typeof It < "u" ? It : typeof self < "u" ? self : typeof window < "u" ? window : {});
2929
- }, {}] }, {}, [10])(10);
2930
- });
2931
- })(Ut)), Ut.exports;
2932
- }
2933
- var Tn = An();
2934
- const In = /* @__PURE__ */ Cn(Tn);
2935
- function ft(n) {
2936
- const r = n.replace(/\\/g, "/"), t = r.startsWith("/"), l = [];
2937
- for (const s of r.split("/"))
2938
- if (!(s === "" || s === ".")) {
2939
- if (s === "..") {
2940
- l.length > 0 && l[l.length - 1] !== ".." ? l.pop() : t || l.push("..");
2941
- continue;
2942
- }
2943
- l.push(s);
2944
- }
2945
- return (t ? "/" : "") + l.join("/");
2946
- }
2947
- function Jt(n) {
2948
- const r = n.lastIndexOf("/");
2949
- return r >= 0 ? n.slice(0, r) : "";
2950
- }
2951
- function yt(n) {
2952
- return n.split("/").pop() ?? n;
2953
- }
2954
- function vt(n) {
2955
- const r = yt(n).toLowerCase().match(/\.([^.]+)$/);
2956
- return r ? r[1] : "";
2957
- }
2958
- function Dt(n) {
2959
- return yt(n).replace(/\.[^.]+$/, "");
2960
- }
2961
- function bt(...n) {
2962
- return ft(n.filter((r) => !!r).join("/"));
2963
- }
2964
- function On(n, r) {
2965
- if (!n)
2966
- return r;
2967
- const t = n.endsWith("/") ? n : `${n}/`;
2968
- return r.startsWith(t) ? r.slice(t.length) : r;
2969
- }
2970
- const Gt = /(\\(input|include) *\{([^{}]+)\})/g;
2971
- function qt(n, r, t) {
2972
- const l = Jt(r);
2973
- return [
2974
- n,
2975
- `${n}.tex`,
2976
- l ? bt(l, n) : n,
2977
- l ? bt(l, `${n}.tex`) : `${n}.tex`
2978
- ].map(ft).find((i) => i in t) ?? null;
2979
- }
2980
- function ue(n, r, t, l = 3) {
2981
- let s = 0;
2982
- const i = [], e = /* @__PURE__ */ new Set(), o = (d) => {
2983
- let _ = !1;
2984
- return { output: d.replace(
2985
- Gt,
2986
- (v, h, b, f) => {
2987
- const g = qt(f, r, t);
2988
- return g ? e.has(g) ? "" : (_ = !0, s += 1, e.add(g), t[g]) : (i.includes(f) || i.push(f), v);
2989
- }
2990
- ), changed: _ };
2991
- };
2992
- let c = n;
2993
- for (let d = 0; d < l; d += 1) {
2994
- const { output: _, changed: m } = o(c);
2995
- if (c = _, !m)
2996
- break;
2997
- }
2998
- return {
2999
- expandedText: c,
3000
- expandedCount: s,
3001
- missingInputs: i,
3002
- consumedPaths: [...e]
3003
- };
3004
- }
3005
- function Rn(n) {
3006
- const r = /* @__PURE__ */ new Set();
3007
- for (const [t, l] of Object.entries(n)) {
3008
- Gt.lastIndex = 0;
3009
- let s;
3010
- for (; (s = Gt.exec(l)) !== null; ) {
3011
- const i = qt(s[3], t, n);
3012
- i && i !== t && r.add(i);
3013
- }
3014
- }
3015
- return r;
3016
- }
3017
- const Ee = String.raw`<xi:include\b[^>]*\bhref\s*=\s*(?:"([^"]+)"|'([^']+)')[^>]*\/>`, fe = new RegExp(Ee, "g");
3018
- function ze(n, r, t) {
3019
- const l = Jt(r), s = [
3020
- n,
3021
- `${n}.ptx`,
3022
- `${n}.xml`,
3023
- l ? bt(l, n) : null,
3024
- l ? bt(l, `${n}.ptx`) : `${n}.ptx`,
3025
- l ? bt(l, `${n}.xml`) : `${n}.xml`
3026
- ].filter((i) => i !== null);
3027
- for (const i of s) {
3028
- const e = ft(i);
3029
- if (e in t)
3030
- return e;
3031
- }
3032
- return null;
3033
- }
3034
- function Fn(n) {
3035
- return n.replace(/^\s*<\?xml[^?]*\?>\s*/, "");
3036
- }
3037
- function Pn(n, r, t, l = 5) {
3038
- let s = 0;
3039
- const i = [], e = [r], o = /* @__PURE__ */ new Set(), c = (_, m) => _.replace(
3040
- new RegExp(Ee, "g"),
3041
- (v, h, b) => {
3042
- const f = h ?? b ?? "", g = e[e.length - 1], p = ze(f, g, t);
3043
- if (!p)
3044
- return i.includes(f) || i.push(f), v;
3045
- if (e.includes(p) || m >= l)
3046
- return v;
3047
- s += 1, o.add(p), e.push(p);
3048
- const w = c(Fn(t[p]), m + 1);
3049
- return e.pop(), w;
3050
- }
3051
- );
3052
- return {
3053
- expandedText: c(n, 1),
3054
- expandedCount: s,
3055
- missingIncludes: i,
3056
- consumedPaths: [...o]
3057
- };
3058
- }
3059
- function Dn(n) {
3060
- const r = /* @__PURE__ */ new Set();
3061
- for (const [t, l] of Object.entries(n)) {
3062
- fe.lastIndex = 0;
3063
- let s;
3064
- for (; (s = fe.exec(l)) !== null; ) {
3065
- const i = s[1] ?? s[2] ?? "", e = ze(i, t, n);
3066
- e && e !== t && r.add(e);
3067
- }
3068
- }
3069
- return r;
3070
- }
3071
- function jn(n) {
3072
- const { mainSource: r, publication: t, outputBase: l = "output" } = n;
3073
- return `<?xml version="1.0" encoding="UTF-8"?>
3074
- <project ptx-version="2">
3075
- <targets>
3076
- <target name="web">
3077
- <format>html</format>
3078
- <source>${r}</source>
3079
- <publication>${t}</publication>
3080
- <output-dir>${l}/web</output-dir>
3081
- </target>
3082
- <target name="print">
3083
- <format>pdf</format>
3084
- <source>${r}</source>
3085
- <publication>${t}</publication>
3086
- <output-dir>${l}/print</output-dir>
3087
- </target>
3088
- </targets>
3089
- </project>
3090
- `;
3091
- }
3092
- function Ce() {
3093
- return `<?xml version="1.0" encoding="UTF-8"?>
3094
- <publication>
3095
- <source>
3096
- <directories external="external" generated="generated"/>
3097
- </source>
3098
- <common>
3099
- <chunking level="1"/>
3100
- </common>
3101
- </publication>
3102
- `;
3103
- }
3104
- function Bn() {
3105
- return `<?xml version="1.0" encoding="UTF-8"?>
3106
- `;
3107
- }
3108
- const de = /([a-zA-Z_:][\w:.-]*)\s*=\s*(?:"([^"]*)"|'([^']*)')/g;
3109
- function jt(n) {
3110
- const r = {};
3111
- let t;
3112
- for (de.lastIndex = 0; (t = de.exec(n)) !== null; )
3113
- r[t[1]] = t[2] ?? t[3] ?? "";
3114
- return r;
3115
- }
3116
- function Ae(n) {
3117
- const r = [];
3118
- let t = 0;
3119
- const l = n.length;
3120
- for (; t < l; ) {
3121
- const s = n.indexOf("<", t);
3122
- if (s < 0) break;
3123
- if (n.startsWith("<!--", s)) {
3124
- const f = n.indexOf("-->", s + 4);
3125
- t = f < 0 ? l : f + 3;
3126
- continue;
3127
- }
3128
- if (n.startsWith("<![CDATA[", s)) {
3129
- const f = n.indexOf("]]>", s + 9);
3130
- t = f < 0 ? l : f + 3;
3131
- continue;
3132
- }
3133
- if (n.startsWith("<?", s)) {
3134
- const f = n.indexOf("?>", s + 2);
3135
- t = f < 0 ? l : f + 2;
3136
- continue;
3137
- }
3138
- if (n.startsWith("<!", s)) {
3139
- const f = n.indexOf(">", s + 2);
3140
- t = f < 0 ? l : f + 1;
3141
- continue;
3142
- }
3143
- let i = s + 1, e = !1;
3144
- n[i] === "/" && (e = !0, i += 1);
3145
- const o = /^[a-zA-Z_:][\w:.-]*/.exec(n.slice(i));
3146
- if (!o) {
3147
- t = s + 1;
3148
- continue;
3149
- }
3150
- const c = o[0];
3151
- i += c.length;
3152
- let d = i, _ = null;
3153
- for (; i < l; ) {
3154
- const f = n[i];
3155
- if (_) {
3156
- f === _ && (_ = null), i += 1;
3157
- continue;
3158
- }
3159
- if (f === '"' || f === "'") {
3160
- _ = f, i += 1;
3161
- continue;
3162
- }
3163
- if (f === ">")
3164
- break;
3165
- i += 1;
3166
- }
3167
- if (i >= l) break;
3168
- const m = i + 1, v = n.slice(d, i), h = !e && v.trimEnd().endsWith("/"), b = h ? v.replace(/\/\s*$/, "") : v;
3169
- e ? r.push({ kind: "close", name: c, pos: s, end: m }) : h ? r.push({ kind: "selfclose", name: c, attrs: b, pos: s, end: m }) : r.push({ kind: "open", name: c, attrs: b, pos: s, end: m }), t = m;
3170
- }
3171
- return r;
3172
- }
3173
- function Te(n, r) {
3174
- return Ie(n, (t) => t === r);
3175
- }
3176
- function Ie(n, r) {
3177
- const t = Ae(n), l = [];
3178
- let s = 0, i = null;
3179
- for (const e of t) {
3180
- if (e.kind === "selfclose") {
3181
- s === 0 && r(e.name) && l.push({
3182
- name: e.name,
3183
- start: e.pos,
3184
- startTagEnd: e.end,
3185
- contentEnd: e.end,
3186
- end: e.end,
3187
- inner: "",
3188
- outer: n.slice(e.pos, e.end),
3189
- attributes: jt(e.attrs)
3190
- });
3191
- continue;
3192
- }
3193
- if (e.kind === "open") {
3194
- s === 0 && r(e.name) && !i && (i = e), s += 1;
3195
- continue;
3196
- }
3197
- s -= 1, s < 0 && (s = 0), i && s === 0 && e.name === i.name && (l.push({
3198
- name: i.name,
3199
- start: i.pos,
3200
- startTagEnd: i.end,
3201
- contentEnd: e.pos,
3202
- end: e.end,
3203
- inner: n.slice(i.end, e.pos),
3204
- outer: n.slice(i.pos, e.end),
3205
- attributes: jt(i.attrs)
3206
- }), i = null);
3207
- }
3208
- return l;
3209
- }
3210
- function ht(n, r) {
3211
- return Te(n, r)[0] ?? null;
3212
- }
3213
- function Rt(n, r) {
3214
- const t = Ae(n);
3215
- let l = 0, s = null, i = -1;
3216
- for (const e of t) {
3217
- if (e.kind === "selfclose") {
3218
- if (!s && e.name === r)
3219
- return {
3220
- name: r,
3221
- start: e.pos,
3222
- startTagEnd: e.end,
3223
- contentEnd: e.end,
3224
- end: e.end,
3225
- inner: "",
3226
- outer: n.slice(e.pos, e.end),
3227
- attributes: jt(e.attrs)
3228
- };
3229
- continue;
3230
- }
3231
- if (e.kind === "open") {
3232
- !s && e.name === r && (s = e, i = l), l += 1;
3233
- continue;
3234
- }
3235
- if (l -= 1, l < 0 && (l = 0), s && e.name === r && l === i) {
3236
- const o = s.attrs;
3237
- return {
3238
- name: r,
3239
- start: s.pos,
3240
- startTagEnd: s.end,
3241
- contentEnd: e.pos,
3242
- end: e.end,
3243
- inner: n.slice(s.end, e.pos),
3244
- outer: n.slice(s.pos, e.end),
3245
- attributes: jt(o)
3246
- };
3247
- }
3248
- }
3249
- return null;
3250
- }
3251
- function $n(n) {
3252
- return Rt(n, "book") ? "book" : Rt(n, "article") ? "article" : Rt(n, "chapter") ? "book" : "article";
3253
- }
3254
- const Ln = "http://www.w3.org/2001/XInclude";
3255
- function Oe(n) {
3256
- return n.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "").slice(0, 60);
3257
- }
3258
- function Ct(n, r) {
3259
- const t = String(r).length;
3260
- return String(n).padStart(Math.max(t, 2), "0");
3261
- }
3262
- function Nn(n, r) {
3263
- const t = [...r].sort((i, e) => i.start - e.start);
3264
- let l = "", s = 0;
3265
- for (const i of t)
3266
- l += n.slice(s, i.start), l += i.replacement, s = i.end;
3267
- return l += n.slice(s), l;
3268
- }
3269
- function he(n) {
3270
- return n.replace(
3271
- /<([a-zA-Z_][\w:.-]*)\b([^>]*)>/,
3272
- (r, t, l) => /\bxmlns:xi\s*=/.test(l) ? r : `<${t}${l} xmlns:xi="${Ln}">`
3273
- );
3274
- }
3275
- function pe(n) {
3276
- return n.startsWith("<?xml") ? n : Bn() + n;
3277
- }
3278
- const ti = ["book", "article"], Un = [
3279
- "frontmatter",
3280
- "preface",
3281
- "acknowledgement",
3282
- "dedication",
3283
- "biography",
3284
- "contributors",
3285
- "part",
3286
- "introduction",
3287
- "chapter",
3288
- "section",
3289
- "subsection",
3290
- "subsubsection",
3291
- "conclusion",
3292
- "exercises",
3293
- "worksheet",
3294
- "handout",
3295
- "reading-questions",
3296
- "references",
3297
- "solutions",
3298
- "glossary",
3299
- "backmatter",
3300
- "appendix",
3301
- "index",
3302
- "colophon"
3303
- ], Mn = new Set(Un);
3304
- function Wn(n) {
3305
- return Mn.has(n);
3306
- }
3307
- const Zn = {
3308
- chapter: "ch",
3309
- section: "sec",
3310
- subsection: "subsec",
3311
- subsubsection: "subsubsec",
3312
- appendix: "app"
3313
- };
3314
- function Re(n) {
3315
- return Zn[n] ?? n;
3316
- }
3317
- const Xn = /* @__PURE__ */ new Set([
3318
- "frontmatter",
3319
- "backmatter",
3320
- "preface",
3321
- "acknowledgement",
3322
- "dedication",
3323
- "biography",
3324
- "contributors",
3325
- "colophon",
3326
- "glossary",
3327
- "index"
3328
- ]);
3329
- function Gn(n) {
3330
- return Xn.has(n);
3331
- }
3332
- function Qt(n) {
3333
- return n.trim().replace(/[^a-zA-Z0-9\-_]+/g, "-").replace(/^[^a-zA-Z_]+/, "").replace(/-+$/, "");
3334
- }
3335
- class te {
3336
- used = /* @__PURE__ */ new Set();
3337
- claim(r) {
3338
- let t = r, l = 2;
3339
- for (; this.used.has(t); )
3340
- t = `${r}-${l}`, l += 1;
3341
- return this.used.add(t), t;
3342
- }
3343
- has(r) {
3344
- return this.used.has(r);
3345
- }
3346
- }
3347
- function Ht(n, r, t) {
3348
- if (n) {
3349
- const l = Qt(n) || t, s = r.claim(l);
3350
- return s !== n ? { ref: s, renamedFrom: n, generated: !1 } : { ref: s, generated: !1 };
3351
- }
3352
- return { ref: r.claim(t), generated: !0 };
3353
- }
3354
- function Bt(n, r, t, l) {
3355
- r.renamedFrom !== void 0 ? n.push({
3356
- action: "anomaly",
3357
- severity: "warning",
3358
- kind: "structure",
3359
- category: "renamed_xml_id",
3360
- macro: t,
3361
- occurrences: 1,
3362
- message: `${t} id \`${r.renamedFrom}\` is not a valid ref (or collides with another); renamed to \`${r.ref}\`. Cross-references to the old id will break.`
3363
- }) : r.generated && n.push({
3364
- action: "anomaly",
3365
- severity: "info",
3366
- kind: "structure",
3367
- category: "missing_xml_id",
3368
- macro: t,
3369
- occurrences: 1,
3370
- message: `${t} at position ${l} has no id; assigned \`${r.ref}\`.`
3371
- });
3372
- }
3373
- function $t(n, r) {
3374
- return Object.entries(n).map(([t, l]) => {
3375
- const s = t.split("/").pop() ?? t, i = s.replace(/\.[^.]+$/, "");
3376
- return { ref: r.claim(Qt(i) || "asset"), fileName: s, data: l };
3377
- });
3378
- }
3379
- function Hn(n, r) {
3380
- return n.splitLevel !== void 0 ? Math.max(0, n.splitLevel) : n.splitChapters === !1 ? 0 : n.splitSections ? r === "book" ? 2 : 1 : r === "book" ? 1 : 0;
3381
- }
3382
- function Fe(n, r, t) {
3383
- const l = n.slice(0, r), s = n.slice(r);
3384
- return /\bxml:id\s*=\s*(?:"[^"]*"|'[^']*')/.test(l) ? l.replace(
3385
- /\bxml:id\s*=\s*(?:"[^"]*"|'[^']*')/,
3386
- `xml:id="${t}"`
3387
- ) + s : l.replace(/^<([a-zA-Z_:][\w:.-]*)/, `<$1 xml:id="${t}"`) + s;
3388
- }
3389
- function Pe(n) {
3390
- const r = ht(n, "title");
3391
- return r ? r.inner.replace(/<[^>]+>/g, "").replace(/\s+/g, " ").trim() : "";
3392
- }
3393
- function De(n, r, t) {
3394
- return Ht(n.attributes["xml:id"], r, t);
3395
- }
3396
- function je(n, r) {
3397
- const t = n.outer.slice(0, n.startTagEnd - n.start), l = n.outer.slice(n.contentEnd - n.start);
3398
- return t + r + l;
3399
- }
3400
- function Be(n, r, t, l) {
3401
- if (t > l.maxDepth)
3402
- return n;
3403
- const s = Ie(n, Wn);
3404
- if (s.length === 0)
3405
- return n;
3406
- const i = s.map((e, o) => {
3407
- const c = o + 1, _ = `${Re(e.name)}-${Ct(c, s.length)}`, m = t === 1 ? _ : `${r}-${_}`, v = De(e, l.refs, m);
3408
- Bt(l.warnings, v, e.name, c);
3409
- const h = Be(
3410
- e.inner,
3411
- v.ref,
3412
- t + 1,
3413
- l
3414
- );
3415
- return l.divisions.push({
3416
- xmlId: v.ref,
3417
- type: e.name,
3418
- title: Pe(e.inner),
3419
- sourceFormat: "pretext",
3420
- content: Fe(
3421
- je(e, h),
3422
- e.startTagEnd - e.start,
3423
- v.ref
3424
- ),
3425
- isRoot: !1
3426
- }), {
3427
- start: e.start,
3428
- end: e.end,
3429
- replacement: `<plus:${e.name} ref="${v.ref}"/>`
3430
- };
3431
- });
3432
- return Nn(n, i);
3433
- }
3434
- function Kn(n, r = {}) {
3435
- const t = [], l = r.documentKind ?? $n(n), s = Hn(r, l), i = Rt(n, "pretext"), e = i ? i.inner : n, o = ht(e, "docinfo"), c = o?.outer.trim() ?? "";
3436
- let d = ht(e, "book") ?? ht(e, "article");
3437
- if (!d) {
3438
- const p = l === "book" ? "book" : "article", w = (o ? e.slice(0, o.start) + e.slice(o.end) : e).trim();
3439
- d = ht(
3440
- `<${p}>
3441
- ${w}
3442
- </${p}>`,
3443
- p
3444
- );
3445
- }
3446
- if (!d)
3447
- throw new Error("Could not locate a root element for the division pool.");
3448
- l === "book" && d.name !== "book" && t.push({
3449
- action: "anomaly",
3450
- severity: "warning",
3451
- kind: "structure",
3452
- category: "missing_root",
3453
- macro: "book",
3454
- occurrences: 1,
3455
- message: "Document was treated as a book but no <book> element found; importing with the existing root."
3456
- });
3457
- const _ = new te(), m = [], v = De(d, _, "document");
3458
- v.renamedFrom !== void 0 && Bt(t, v, d.name, 1);
3459
- const h = Pe(d.inner), b = Be(d.inner, v.ref, 1, {
3460
- refs: _,
3461
- divisions: m,
3462
- warnings: t,
3463
- maxDepth: s
3464
- }), f = {
3465
- xmlId: v.ref,
3466
- type: d.name === "book" ? "book" : "article",
3467
- title: h,
3468
- sourceFormat: "pretext",
3469
- content: Fe(
3470
- je(d, b),
3471
- d.startTagEnd - d.start,
3472
- v.ref
3473
- ),
3474
- isRoot: !0
3475
- };
3476
- m.unshift(f);
3477
- const g = $t(r.assets ?? {}, _);
3478
- return {
3479
- project: {
3480
- title: h,
3481
- docinfo: c,
3482
- documentKind: l,
3483
- divisions: m,
3484
- assets: g
3485
- },
3486
- warnings: t
3487
- };
3488
- }
3489
- function Yn(n, r, t = {}) {
3490
- return r === "latex" ? Qn(n, t) : er(n, t);
3491
- }
3492
- function me(n) {
3493
- return Qt(Oe(n));
3494
- }
3495
- function Lt(n, r, t, l, s, i, e) {
3496
- if (n) {
3497
- const d = Ht(
3498
- n,
3499
- t,
3500
- me(r) || l
3501
- );
3502
- return Bt(e, d, s, i), d.ref;
3503
- }
3504
- const o = me(r);
3505
- if (o)
3506
- return t.claim(o);
3507
- const c = Ht(void 0, t, l);
3508
- return Bt(e, c, s, i), c.ref;
3509
- }
3510
- function $e(n) {
3511
- return n.replace(/\\[a-zA-Z]+\{([^{}]*)\}/g, "$1").replace(/\\[a-zA-Z]+/g, "").replace(/[{}]/g, "").replace(/\s+/g, " ").trim();
3512
- }
3513
- function Vn(n, r) {
3514
- let t = r;
3515
- for (; t < n.length && /\s/.test(n[t]); ) t++;
3516
- if (n[t] !== "{") return null;
3517
- const l = t;
3518
- let s = 0;
3519
- for (; t < n.length; t++) {
3520
- const i = n[t];
3521
- if (i === "\\") {
3522
- t++;
3523
- continue;
3524
- }
3525
- if (i === "{") s++;
3526
- else if (i === "}" && (s--, s === 0))
3527
- return { inner: n.slice(l + 1, t), end: t + 1 };
3528
- }
3529
- return null;
3530
- }
3531
- function Jn(n, r) {
3532
- let t = r;
3533
- for (; t < n.length && /\s/.test(n[t]); ) t++;
3534
- if (n[t] !== "[") return r;
3535
- let l = 0;
3536
- for (; t < n.length; t++) {
3537
- const s = n[t];
3538
- if (s === "\\") {
3539
- t++;
3540
- continue;
3541
- }
3542
- if (s === "[") l++;
3543
- else if (s === "]" && (l--, l === 0))
3544
- return t + 1;
3545
- }
3546
- return r;
3547
- }
3548
- function qn(n, r) {
3549
- let t = 0;
3550
- for (let l = 0; l < r; l++) {
3551
- const s = n[l];
3552
- if (s === "\\") {
3553
- l++;
3554
- continue;
3555
- }
3556
- s === "{" ? t++ : s === "}" && t--;
3557
- }
3558
- return t;
3559
- }
3560
- function Le(n, r) {
3561
- const t = [], l = new RegExp(`\\\\${r}\\*?(?![a-zA-Z])`, "g");
3562
- let s;
3563
- for (; (s = l.exec(n)) !== null; ) {
3564
- const i = s.index;
3565
- if (qn(n, i) !== 0) continue;
3566
- const e = Vn(
3567
- n,
3568
- Jn(n, i + s[0].length)
3569
- );
3570
- if (!e) continue;
3571
- let o = e.end, c;
3572
- const d = /^\s*\\label\s*\{([^{}]*)\}/.exec(n.slice(e.end));
3573
- d && (c = d[1].trim(), o = e.end + d[0].length), t.push({ start: i, rawTitle: e.inner, contentStart: o, labelId: c });
3574
- }
3575
- return t;
3576
- }
3577
- function Qn(n, r) {
3578
- const t = [], { body: l } = zt(n), s = (l || n).trim(), i = Le(s, "chapter"), e = r.documentKind ?? (i.length > 0 ? "book" : "article"), o = r.splitChapters ?? e === "book", c = r.splitSections ?? !1, d = new te(), _ = d.claim("document"), m = [];
3579
- let v = s;
3580
- if (o && e === "book" && i.length > 0) {
3581
- const g = [s.slice(0, i[0].start)];
3582
- i.forEach((p, w) => {
3583
- const S = i[w + 1]?.start ?? s.length, E = $e(p.rawTitle), z = Lt(
3584
- p.labelId,
3585
- E,
3586
- d,
3587
- `ch-${Ct(w + 1, i.length)}`,
3588
- "chapter",
3589
- w + 1,
3590
- t
3591
- );
3592
- let P = s.slice(p.contentStart, S);
3593
- c && (P = tr(
3594
- P,
3595
- z,
3596
- d,
3597
- m,
3598
- t
3599
- )), m.push({
3600
- xmlId: z,
3601
- type: "chapter",
3602
- title: E,
3603
- sourceFormat: "latex",
3604
- content: `\\chapter{${p.rawTitle}}\\label{${z}}
3605
- ${P.trim()}`,
3606
- isRoot: !1
3607
- }), g.push(`\\plus{chapter}{${z}}`);
3608
- }), v = g.join(`
3609
-
3610
- `).trim();
3611
- }
3612
- const h = e === "book" ? "book" : "article", b = r.title ?? "", f = `\\${h}{${b}}\\label{${_}}`;
3613
- return m.unshift({
3614
- xmlId: _,
3615
- type: h,
3616
- title: b,
3617
- sourceFormat: "latex",
3618
- content: v ? `${f}
3619
- ${v}` : f,
3620
- isRoot: !0
3621
- }), {
3622
- project: {
3623
- title: r.title ?? "",
3624
- docinfo: r.docinfo ?? "",
3625
- documentKind: e,
3626
- divisions: m,
3627
- assets: $t(r.assets ?? {}, d)
3628
- },
3629
- warnings: t
3630
- };
3631
- }
3632
- function tr(n, r, t, l, s) {
3633
- const i = Le(n, "section");
3634
- if (i.length === 0) return n;
3635
- const e = [n.slice(0, i[0].start)];
3636
- return i.forEach((o, c) => {
3637
- const d = i[c + 1]?.start ?? n.length, _ = $e(o.rawTitle), m = Lt(
3638
- o.labelId,
3639
- _,
3640
- t,
3641
- `${r}-sec-${Ct(c + 1, i.length)}`,
3642
- "section",
3643
- c + 1,
3644
- s
3645
- ), v = n.slice(o.contentStart, d).trim();
3646
- l.push({
3647
- xmlId: m,
3648
- type: "section",
3649
- title: _,
3650
- sourceFormat: "latex",
3651
- content: `\\section{${o.rawTitle}}\\label{${m}}
3652
- ${v}`,
3653
- isRoot: !1
3654
- }), e.push(`\\plus{section}{${m}}`);
3655
- }), e.join(`
3656
-
3657
- `).trim();
3658
- }
3659
- function Ne(n, r) {
3660
- const t = new RegExp(`^#{${r}}\\s+(.*)$`), l = [], s = [];
3661
- let i = null, e = !1, o = "";
3662
- for (const c of n.split(`
3663
- `)) {
3664
- const d = /^\s*(```+|~~~+)/.exec(c);
3665
- if (d) {
3666
- const m = d[1][0];
3667
- e ? m === o && (e = !1) : (e = !0, o = m), (i ? i.bodyLines : s).push(c);
3668
- continue;
3669
- }
3670
- const _ = e ? null : t.exec(c);
3671
- _ ? (i && l.push(i), i = { headingText: _[1].trim(), bodyLines: [] }) : (i ? i.bodyLines : s).push(c);
3672
- }
3673
- return i && l.push(i), {
3674
- preamble: s.join(`
3675
- `).trim(),
3676
- sections: l.map((c) => ({
3677
- headingText: c.headingText,
3678
- body: c.bodyLines.join(`
3679
- `).trim()
3680
- }))
3681
- };
3682
- }
3683
- function Ft(n) {
3684
- return `---
3685
- ${Object.entries(n).map(([t, l]) => `${t}: ${l}`).join(`
3686
- `)}
3687
- ---`;
3688
- }
3689
- function er(n, r) {
3690
- const t = [], l = n.trim(), s = r.documentKind ?? "article", i = r.splitChapters ?? s === "book", e = r.splitSections ?? !1, o = new te(), c = o.claim("document"), d = [];
3691
- if (!(i && s === "book"))
3692
- return d.push({
3693
- xmlId: c,
3694
- type: s === "book" ? "book" : "article",
3695
- title: r.title ?? "",
3696
- sourceFormat: "markdown",
3697
- content: `${Ft({
3698
- division: s,
3699
- id: c,
3700
- title: r.title ?? ""
3701
- })}
3702
-
3703
- ${l}`.trim(),
3704
- isRoot: !0
3705
- }), {
3706
- project: {
3707
- title: r.title ?? "",
3708
- docinfo: r.docinfo ?? "",
3709
- documentKind: s,
3710
- divisions: d,
3711
- assets: $t(r.assets ?? {}, o)
3712
- },
3713
- warnings: t
3714
- };
3715
- const { preamble: _, sections: m } = Ne(l, 1), v = _ ? [_] : [];
3716
- return m.forEach((h, b) => {
3717
- const f = Lt(
3718
- void 0,
3719
- h.headingText,
3720
- o,
3721
- `ch-${Ct(b + 1, m.length)}`,
3722
- "chapter",
3723
- b + 1,
3724
- t
3725
- );
3726
- let g = h.body;
3727
- e && (g = nr(
3728
- h.body,
3729
- f,
3730
- o,
3731
- d,
3732
- t
3733
- )), d.push({
3734
- xmlId: f,
3735
- type: "chapter",
3736
- title: h.headingText,
3737
- sourceFormat: "markdown",
3738
- content: `${Ft({
3739
- division: "chapter",
3740
- id: f,
3741
- title: h.headingText
3742
- })}
3743
-
3744
- # ${h.headingText}
3745
-
3746
- ${g}`.trim(),
3747
- isRoot: !1
3748
- }), v.push(`::chapter{ref="${f}"}`);
3749
- }), d.unshift({
3750
- xmlId: c,
3751
- type: "book",
3752
- title: r.title ?? "",
3753
- sourceFormat: "markdown",
3754
- content: `${Ft({
3755
- division: "book",
3756
- id: c,
3757
- title: r.title ?? ""
3758
- })}
3759
-
3760
- ${v.join(`
3761
-
3762
- `)}`.trim(),
3763
- isRoot: !0
3764
- }), {
3765
- project: {
3766
- title: r.title ?? "",
3767
- docinfo: r.docinfo ?? "",
3768
- documentKind: s,
3769
- divisions: d,
3770
- assets: $t(r.assets ?? {}, o)
3771
- },
3772
- warnings: t
3773
- };
3774
- }
3775
- function nr(n, r, t, l, s) {
3776
- const { preamble: i, sections: e } = Ne(n, 2);
3777
- if (e.length === 0) return n;
3778
- const o = i ? [i] : [];
3779
- return e.forEach((c, d) => {
3780
- const _ = Lt(
3781
- void 0,
3782
- c.headingText,
3783
- t,
3784
- `${r}-sec-${Ct(d + 1, e.length)}`,
3785
- "section",
3786
- d + 1,
3787
- s
3788
- );
3789
- l.push({
3790
- xmlId: _,
3791
- type: "section",
3792
- title: c.headingText,
3793
- sourceFormat: "markdown",
3794
- content: `${Ft({
3795
- division: "section",
3796
- id: _,
3797
- title: c.headingText
3798
- })}
3799
-
3800
- # ${c.headingText}
3801
-
3802
- ${c.body}`.trim(),
3803
- isRoot: !1
3804
- }), o.push(`::section{ref="${_}"}`);
3805
- }), o.join(`
3806
-
3807
- `).trim();
3808
- }
3809
- const Mt = {
3810
- mainSourcePath: "source/main.ptx",
3811
- publicationPath: "publication/publication.ptx",
3812
- projectFilePath: "project.ptx"
3813
- }, Kt = /<plus:([a-zA-Z][a-zA-Z-]*)\s+ref="([^"]+)"\s*\/>/g;
3814
- function Wt(n) {
3815
- const r = [];
3816
- Kt.lastIndex = 0;
3817
- let t;
3818
- for (; (t = Kt.exec(n)) !== null; )
3819
- r.push(t[2]);
3820
- return r;
3821
- }
3822
- function rr(n, r) {
3823
- const t = Oe(n) || "division";
3824
- return t.startsWith(`${r}-`) ? t : `${r}-${t}`;
3825
- }
3826
- function ir(n, r) {
3827
- let t = r, l = 2;
3828
- for (; n.has(t); )
3829
- t = `${r}-${l}`, l += 1;
3830
- return n.add(t), t;
3831
- }
3832
- function sr(n, r) {
3833
- const t = `${r}-`;
3834
- return n.startsWith(t) ? n.slice(t.length) : n;
3835
- }
3836
- function ge(n, r) {
3837
- return n.replace(
3838
- Kt,
3839
- (t, l, s) => {
3840
- const i = r.get(s);
3841
- return i ? `<xi:include href="${i}"/>` : t;
3842
- }
3843
- );
3844
- }
3845
- function ar(n, r = {}) {
3846
- const t = r.mainSourcePath ?? Mt.mainSourcePath, l = r.publicationPath ?? Mt.publicationPath, s = r.projectFilePath ?? Mt.projectFilePath, i = r.includeScaffold ?? !0, e = {}, o = new Map(
3847
- n.divisions.map((E) => [E.xmlId, E])
3848
- ), c = n.divisions.find((E) => E.isRoot);
3849
- if (!c)
3850
- throw new Error("Division pool has no root division.");
3851
- const d = /* @__PURE__ */ new Map(), _ = t.includes("/") ? t.slice(0, t.lastIndexOf("/") + 1) : "", m = [], v = /* @__PURE__ */ new Set(), h = /* @__PURE__ */ new Map();
3852
- function b(E, z) {
3853
- let P = h.get(E);
3854
- return P || (P = /* @__PURE__ */ new Set(), h.set(E, P)), ir(P, z);
3855
- }
3856
- function f(E, z, P, D) {
3857
- if (v.has(E.xmlId))
3858
- return;
3859
- v.add(E.xmlId);
3860
- const N = b(
3861
- z,
3862
- Gn(E.type) ? E.type : rr(
3863
- sr(E.xmlId, D),
3864
- Re(E.type)
3865
- )
3866
- );
3867
- d.set(E.xmlId, `${P}${N}.ptx`), m.push({ division: E, filePath: `${z}${N}.ptx` });
3868
- for (const R of Wt(E.content)) {
3869
- const M = o.get(R);
3870
- M && f(M, `${z}${N}/`, `${N}/`, E.xmlId);
3871
- }
3872
- }
3873
- for (const E of Wt(c.content)) {
3874
- const z = o.get(E);
3875
- z && f(z, _, "", c.xmlId);
3876
- }
3877
- const g = /* @__PURE__ */ new Set();
3878
- for (const E of n.divisions)
3879
- for (const z of Wt(E.content))
3880
- g.add(z);
3881
- for (const E of n.divisions)
3882
- E.isRoot || g.has(E.xmlId) || f(E, _, "", c.xmlId);
3883
- for (const { division: E, filePath: z } of m) {
3884
- const P = ge(E.content, d), D = P === E.content ? P : he(P);
3885
- e[z] = pe(D);
3886
- }
3887
- const p = ge(c.content, d), S = `<pretext>
3888
- ${n.docinfo ? `${n.docinfo}
3889
- ` : ""}${p}
3890
- </pretext>`;
3891
- return e[t] = pe(
3892
- p === c.content ? S : he(S)
3893
- ), i && (e[s] = jn({
3894
- mainSource: t,
3895
- publication: l
3896
- }), e[l] = Ce()), { files: e };
3897
- }
3898
- const or = "source", cr = "publication", _e = "main.ptx";
3899
- function Et(n, r) {
3900
- const t = ht(n.inner, r);
3901
- if (!t)
3902
- return;
3903
- const l = t.inner.trim();
3904
- return l.length > 0 ? l : void 0;
3905
- }
3906
- function Zt(n, r, t) {
3907
- const l = Et(n, r);
3908
- if (l !== void 0)
3909
- return ft(l);
3910
- const s = n.attributes[r];
3911
- if (s !== void 0 && s.trim().length > 0)
3912
- return bt(t, s.trim());
3913
- }
3914
- function lr(n, r) {
3915
- const t = ht(n, "project");
3916
- if (!t)
3917
- return null;
3918
- const l = Jt(ft(r)), s = t.attributes.source?.trim() || or, i = t.attributes.publication?.trim() || cr, e = t.attributes.output?.trim() || "output", o = {
3919
- manifestPath: ft(r),
3920
- projectRoot: l,
3921
- ptxVersion: t.attributes["ptx-version"],
3922
- sourceDir: s,
3923
- publicationDir: i,
3924
- targets: []
3925
- }, c = ht(t.inner, "targets"), d = c ? Te(c.inner, "target") : [];
3926
- for (const _ of d)
3927
- o.targets.push({
3928
- name: _.attributes.name ?? "",
3929
- // v2 manifests carry the format as an attribute; legacy v1 manifests
3930
- // use a `<format>` child element.
3931
- format: _.attributes.format ?? Et(_, "format") ?? "",
3932
- source: Zt(_, "source", s) ?? bt(s, _e),
3933
- publication: Zt(_, "publication", i),
3934
- outputDir: Zt(_, "output-dir", e),
3935
- standalone: _.attributes.standalone !== void 0 && _.attributes.standalone !== "no"
3936
- });
3937
- if (o.targets.length === 0) {
3938
- const _ = Et(t, "source");
3939
- o.targets.push({
3940
- name: "default",
3941
- format: Et(t, "format") ?? "",
3942
- source: _ ? ft(_) : bt(s, _e),
3943
- publication: Et(t, "publication"),
3944
- standalone: !1
3945
- });
3946
- }
3947
- return o;
3948
- }
3949
- function ur(n) {
3950
- const r = Object.keys(n).filter((t) => yt(t).toLowerCase() === "project.ptx").sort((t, l) => {
3951
- const s = t.split("/").length - l.split("/").length;
3952
- return s !== 0 ? s : t.localeCompare(l);
3953
- });
3954
- for (const t of r) {
3955
- const l = lr(n[t], t);
3956
- if (l)
3957
- return l;
3958
- }
3959
- return null;
3960
- }
3961
- function fr(n) {
3962
- return n.targets.find((r) => !r.standalone) ?? n.targets[0];
3963
- }
3964
- const dr = /* @__PURE__ */ new Set(["md", "markdown"]), hr = /* @__PURE__ */ new Set(["ptx", "xml"]), pr = /* @__PURE__ */ new Set([
3965
- "readme",
3966
- "changelog",
3967
- "contributing",
3968
- "license"
3969
- ]), be = [
3970
- "main",
3971
- "book",
3972
- "index",
3973
- "root",
3974
- "master",
3975
- "thesis",
3976
- "dissertation",
3977
- "article",
3978
- "paper"
3979
- ];
3980
- function ee(n, r) {
3981
- return Object.fromEntries(
3982
- Object.entries(n).filter(([t]) => r.has(vt(t)))
3983
- );
3984
- }
3985
- function Ue(n) {
3986
- const r = ht(n, "pretext") ?? ht(n, "book") ?? ht(n, "article"), t = r ? r.inner : n;
3987
- return ht(t, "title")?.inner.replace(/<[^>]+>/g, "").replace(/\s+/g, " ").trim() || void 0;
3988
- }
3989
- function mr(n) {
3990
- const r = /^#\s+(.+)$/m.exec(n);
3991
- return r ? r[1].trim() : void 0;
3992
- }
3993
- function ye(n) {
3994
- return Pt(n, "title") || void 0;
3995
- }
3996
- function gr(n) {
3997
- return /\\documentclass\b/.test(n) || /\\begin *\{document\}/.test(n);
3998
- }
3999
- const _r = /<(pretext|book|article)\b/;
4000
- function br(n, r) {
4001
- const t = fr(n), l = t ? [t, ...n.targets.filter((e) => e !== t)] : n.targets, s = /* @__PURE__ */ new Set(), i = [];
4002
- for (const e of l) {
4003
- const o = bt(n.projectRoot, e.source);
4004
- s.has(o) || !(o in r) || (s.add(o), i.push({
4005
- path: o,
4006
- format: "pretext",
4007
- reason: "manifest-target",
4008
- title: Ue(r[o]),
4009
- targetName: e.name,
4010
- targetFormat: e.format
4011
- }));
4012
- }
4013
- return i;
4014
- }
4015
- function yr(n) {
4016
- const r = ee(n, /* @__PURE__ */ new Set(["tex", "ltx"])), t = Rn(r), l = Object.keys(r).filter((c) => !t.has(c) && gr(r[c])).sort(), s = (c) => {
4017
- let d = 0;
4018
- const _ = r[c].match(/\\(input|include) *\{[^{}]+\}/g) ?? [];
4019
- for (const m of _) {
4020
- const v = /\{([^{}]+)\}/.exec(m)?.[1];
4021
- v && qt(v, c, r) && (d += 1);
4022
- }
4023
- return d;
4024
- }, i = (c) => {
4025
- const d = be.indexOf(Dt(c).toLowerCase());
4026
- return d >= 0 ? d : be.length;
4027
- }, o = [...l].sort((c, d) => {
4028
- const _ = +!/\\documentclass\b/.test(r[c]) - +!/\\documentclass\b/.test(r[d]);
4029
- if (_ !== 0) return _;
4030
- const m = i(c) - i(d);
4031
- if (m !== 0) return m;
4032
- const v = s(d) - s(c);
4033
- return v !== 0 ? v : c.localeCompare(d);
4034
- }).map((c) => ({
4035
- path: c,
4036
- format: "latex",
4037
- reason: "latex-root",
4038
- title: ye(r[c])
4039
- }));
4040
- return o.length > 0 ? o : Object.keys(r).sort().map((c) => ({
4041
- path: c,
4042
- format: "latex",
4043
- reason: "fallback",
4044
- title: ye(r[c])
4045
- }));
4046
- }
4047
- function vr(n) {
4048
- const r = ee(n, dr), t = Object.keys(r).sort(), l = (e) => pr.has(Dt(e).toLowerCase()), s = ["main", "index", "book", "article"], i = (e) => l(e) ? 2 : s.indexOf(Dt(e).toLowerCase()) >= 0 ? 0 : 1;
4049
- return [...t].sort((e, o) => i(e) - i(o) || e.localeCompare(o)).map((e) => ({
4050
- path: e,
4051
- format: "markdown",
4052
- reason: "markdown-root",
4053
- title: mr(r[e])
4054
- }));
4055
- }
4056
- function wr(n) {
4057
- const r = ee(n, hr), t = Dn(r);
4058
- return Object.keys(r).filter(
4059
- (s) => !t.has(s) && _r.test(r[s]) && yt(s).toLowerCase() !== "project.ptx" && yt(s).toLowerCase() !== "publication.ptx"
4060
- ).sort().map((s) => ({
4061
- path: s,
4062
- format: "pretext",
4063
- reason: "pretext-root",
4064
- title: Ue(r[s])
4065
- }));
4066
- }
4067
- function xr(n, r = {}) {
4068
- const t = ur(n), l = [
4069
- ...t ? br(t, n) : [],
4070
- ...yr(n),
4071
- ...vr(n),
4072
- ...wr(n)
4073
- ], s = [], i = /* @__PURE__ */ new Set();
4074
- for (const m of l)
4075
- i.has(m.path) || (i.add(m.path), s.push(m));
4076
- const e = r.sourceFormat ? s.filter((m) => m.format === r.sourceFormat) : s, o = [];
4077
- for (const m of s)
4078
- o.includes(m.format) || o.push(m.format);
4079
- let c = e[0] ?? null;
4080
- if (r.mainFile) {
4081
- const m = r.mainFile;
4082
- c = e.find((v) => v.path === m) ?? s.find((v) => v.path === m) ?? (m in n ? {
4083
- path: m,
4084
- format: r.sourceFormat ?? Xt(n[m]),
4085
- reason: "fallback"
4086
- } : c);
4087
- }
4088
- if (!c) {
4089
- const m = Object.keys(n).sort()[0];
4090
- c = m ? {
4091
- path: m,
4092
- format: r.sourceFormat ?? Xt(n[m]),
4093
- reason: "fallback"
4094
- } : null;
4095
- }
4096
- const d = c, _ = d && (d.format === "latex" || d.format === "markdown") ? e.filter(
4097
- (m) => m.path !== d.path && m.format === d.format && m.reason !== "manifest-target"
4098
- ) : [];
4099
- return { manifest: t, candidates: e, formats: o, primary: c, extraRoots: _ };
4100
- }
4101
- const ve = "\\begin{document}", kr = "\\end{document}", Sr = /\\documentclass\s*(?:\[[^\]]*\])?\s*\{(book|report|memoir|scrbook|scrreprt|amsbook)\}/;
4102
- function Me(n) {
4103
- return Dt(n).replace(/[-_]+/g, " ").replace(/\s+/g, " ").trim().replace(/\b\w/g, (r) => r.toUpperCase()) || "Untitled";
4104
- }
4105
- function Yt(n, r) {
4106
- return {
4107
- action: "anomaly",
4108
- severity: "info",
4109
- kind: "structure",
4110
- category: "attached_root",
4111
- macro: n.level,
4112
- occurrences: 1,
4113
- message: r
4114
- };
4115
- }
4116
- function Er(n) {
4117
- const { preamble: r, body: t } = zt(n);
4118
- return Sr.test(r) || /\\chapter\b/.test(t) ? "chapter" : "section";
4119
- }
4120
- function zr(n, r) {
4121
- const t = n.replace(/^\s*(%[^\n]*\n\s*)*/, "");
4122
- return r === "chapter" ? /^\\(chapter|part)\b/.test(t) : /^\\(section|chapter|part)\b/.test(t);
4123
- }
4124
- function Cr(n, r, t) {
4125
- const l = r.filter((b) => b.include !== !1);
4126
- if (l.length === 0)
4127
- return { source: n, attached: [], warnings: [] };
4128
- const s = n.includes(ve), { preamble: i, body: e } = zt(n), o = Er(n), c = [], d = [], _ = [], m = [];
4129
- for (const b of l) {
4130
- const f = t[b.path];
4131
- if (f === void 0) {
4132
- d.push({
4133
- action: "anomaly",
4134
- severity: "warning",
4135
- kind: "structure",
4136
- category: "attached_root_missing",
4137
- macro: b.path,
4138
- occurrences: 1,
4139
- message: `Cannot attach \`${b.path}\`: it is not among the uploaded files.`
4140
- });
4141
- continue;
4142
- }
4143
- const g = b.level ?? o, p = b.title || Pt(f, "title") || Me(b.path), w = {
4144
- path: b.path,
4145
- title: p,
4146
- level: g
4147
- }, S = zt(f), E = xe(S.preamble);
4148
- E && _.push(E);
4149
- const z = S.body.trim();
4150
- if (!z) {
4151
- d.push(
4152
- Yt(w, `\`${b.path}\` is empty; skipped.`)
4153
- );
4154
- continue;
4155
- }
4156
- m.push(
4157
- zr(z, g) ? z : `\\${g}{${p}}
4158
-
4159
- ${z}`
4160
- ), c.push(w), d.push(
4161
- Yt(
4162
- w,
4163
- `Attached \`${b.path}\` as a ${g}: “${p}”.`
4164
- )
4165
- );
4166
- }
4167
- if (m.length === 0)
4168
- return { source: n, attached: c, warnings: d };
4169
- const v = [e.trim(), ...m].filter(Boolean).join(`
4170
-
4171
- `);
4172
- return s ? { source: [
4173
- [i, ..._].filter(Boolean).join(`
4174
- `),
4175
- ve,
4176
- v,
4177
- kr
4178
- ].join(`
4179
- `), attached: c, warnings: d } : {
4180
- source: [i, ..._, v].filter(Boolean).join(`
4181
-
4182
- `),
4183
- attached: c,
4184
- warnings: d
4185
- };
4186
- }
4187
- function Ar(n, r, t) {
4188
- const l = r.filter((o) => o.include !== !1), s = [], i = [], e = [];
4189
- for (const o of l) {
4190
- const c = t[o.path];
4191
- if (c === void 0) {
4192
- i.push({
4193
- action: "anomaly",
4194
- severity: "warning",
4195
- kind: "structure",
4196
- category: "attached_root_missing",
4197
- macro: o.path,
4198
- occurrences: 1,
4199
- message: `Cannot attach \`${o.path}\`: it is not among the uploaded files.`
4200
- });
4201
- continue;
4202
- }
4203
- const d = c.trim();
4204
- if (!d)
4205
- continue;
4206
- const _ = /^#\s+(.+)$/m.exec(d), m = o.title || _?.[1]?.trim() || Me(o.path), v = {
4207
- path: o.path,
4208
- title: m,
4209
- level: o.level ?? "chapter"
4210
- };
4211
- e.push(d.startsWith("# ") ? d : `# ${m}
4212
-
4213
- ${d}`), s.push(v), i.push(
4214
- Yt(v, `Attached \`${o.path}\`: “${m}”.`)
4215
- );
4216
- }
4217
- return e.length === 0 ? { source: n, attached: s, warnings: i } : {
4218
- source: [n.trim(), ...e].filter(Boolean).join(`
4219
-
4220
- `),
4221
- attached: s,
4222
- warnings: i
4223
- };
4224
- }
4225
- const Tr = [
4226
- "output",
4227
- ".git",
4228
- ".github/workflows/.cache",
4229
- "node_modules",
4230
- ".ptx",
4231
- "__pycache__",
4232
- ".venv",
4233
- "__MACOSX"
4234
- ];
4235
- function Ir(n, r) {
4236
- const t = n.toLowerCase();
4237
- return [...Tr, ...r].some(
4238
- (l) => l.length > 0 && t.startsWith(`${l.toLowerCase()}/`)
4239
- );
4240
- }
4241
- function Or(n) {
4242
- const { manifest: r, files: t, assets: l } = n, s = r.projectRoot, i = new Set(n.consumedPaths), e = [
4243
- ...new Set(
4244
- r.targets.map((d) => d.outputDir?.split("/")[0]).filter((d) => !!d)
4245
- )
4246
- ], o = { files: {}, assets: {}, skipped: [] }, c = (d, _) => {
4247
- if (s && !d.startsWith(`${s}/`))
4248
- return;
4249
- const m = On(s, d);
4250
- if (!(i.has(d) || d === r.manifestPath)) {
4251
- if (Ir(m, e)) {
4252
- o.skipped.push(m);
4253
- return;
4254
- }
4255
- _(m);
4256
- }
4257
- };
4258
- for (const [d, _] of Object.entries(t))
4259
- c(d, (m) => {
4260
- o.files[m] = _;
4261
- });
4262
- for (const [d, _] of Object.entries(l))
4263
- c(d, (m) => {
4264
- o.assets[m] = _;
4265
- });
4266
- return o;
4267
- }
4268
- function Rr(n, r, t) {
4269
- return `<?xml version="1.0" encoding="UTF-8"?>
4270
- <project ptx-version="2">
4271
- <targets>
4272
- ${n.targets.map((s) => {
4273
- const i = s.source === r.source, e = i ? t.mainSource : s.source, o = i ? t.publication ?? s.publication : s.publication;
4274
- return [
4275
- ` <target name="${s.name}"${s.standalone ? ' standalone="yes"' : ""}>`,
4276
- s.format ? ` <format>${s.format}</format>` : "",
4277
- ` <source>${e}</source>`,
4278
- o ? ` <publication>${o}</publication>` : "",
4279
- s.outputDir ? ` <output-dir>${s.outputDir}</output-dir>` : "",
4280
- " </target>"
4281
- ].filter(Boolean).join(`
4282
- `);
4283
- }).join(`
4284
- `)}
4285
- </targets>
4286
- </project>
4287
- `;
4288
- }
4289
- const Fr = /\.(tex|zip|md|markdown|ptx|xml|tar\.gz|tgz)$/i, Pr = [
4290
- "tex",
4291
- "md",
4292
- "markdown",
4293
- "ptx",
4294
- "xml",
4295
- "bib",
4296
- "sty",
4297
- "txt",
4298
- "pdf",
4299
- "eps",
4300
- "png",
4301
- "ps",
4302
- "bbl"
4303
- ], Dr = /* @__PURE__ */ new Set([
4304
- "png",
4305
- "jpg",
4306
- "jpeg",
4307
- "gif",
4308
- "pdf",
4309
- "eps",
4310
- "ps",
4311
- "bmp",
4312
- "tiff",
4313
- "tif",
4314
- "webp",
4315
- "ico"
4316
- ]), jr = /* @__PURE__ */ new Set([
4317
- "png",
4318
- "jpg",
4319
- "jpeg",
4320
- "gif",
4321
- "svg",
4322
- "bmp",
4323
- "tiff",
4324
- "tif",
4325
- "webp",
4326
- "ico",
4327
- "pdf",
4328
- "eps",
4329
- "ps"
4330
- ]);
4331
- function We(n) {
4332
- return Dr.has(n.toLowerCase());
4333
- }
4334
- function Br(n) {
4335
- const r = yt(n), t = vt(r);
4336
- return jr.has(t) ? `source/assets/${r}` : null;
4337
- }
4338
- function $r(n) {
4339
- const r = yt(n);
4340
- return vt(r) === "bib" ? `source/${r}` : null;
4341
- }
4342
- function wt(n) {
4343
- return n.replace(/\r\n?/g, `
4344
- `).replace(/(\n *){3,}/g, `
4345
-
4346
- `);
4347
- }
4348
- function Lr(n) {
4349
- const r = n.toLowerCase();
4350
- return r.endsWith(".tar.gz") || r.endsWith(".tgz") ? "tar.gz" : r.endsWith(".zip") ? "zip" : r.endsWith(".tex") ? "tex" : r.endsWith(".md") || r.endsWith(".markdown") ? "markdown" : r.endsWith(".ptx") || r.endsWith(".xml") ? "pretext" : null;
4351
- }
4352
- function Nr(n) {
4353
- const r = (t, l) => new TextDecoder().decode(n.slice(t, l)).split("\0")[0];
4354
- return {
4355
- name: r(0, 100),
4356
- size: parseInt(r(124, 136), 8) || 0,
4357
- type: r(156, 157)
4358
- };
4359
- }
4360
- async function Ur(n) {
4361
- if (typeof DecompressionStream > "u")
4362
- throw new Error("This runtime does not support gzip decompression.");
4363
- const l = new ReadableStream({
4364
- start(c) {
4365
- c.enqueue(new Uint8Array(n)), c.close();
4366
- }
4367
- }).pipeThrough(
4368
- new DecompressionStream("gzip")
4369
- ).getReader(), s = [];
4370
- for (; ; ) {
4371
- const { done: c, value: d } = await l.read();
4372
- if (c)
4373
- break;
4374
- s.push(d);
4375
- }
4376
- const i = s.reduce((c, d) => c + d.length, 0), e = new Uint8Array(i);
4377
- let o = 0;
4378
- for (const c of s)
4379
- e.set(c, o), o += c.length;
4380
- return e.buffer;
4381
- }
4382
- function Mr(n) {
4383
- const r = {}, t = {};
4384
- let l = 0;
4385
- for (; l < n.length && !(l + 512 > n.length); ) {
4386
- const s = n.slice(l, l + 512), i = Nr(s);
4387
- if (!i.name)
4388
- break;
4389
- l += 512;
4390
- const e = i.size, o = Math.ceil(e / 512) * 512;
4391
- if (i.type === "0" || i.type === "") {
4392
- const c = n.slice(l, l + e), d = ft(i.name);
4393
- if (We(vt(d)))
4394
- t[d] = c;
4395
- else {
4396
- const _ = new TextDecoder().decode(c);
4397
- r[d] = wt(_);
4398
- }
4399
- }
4400
- l += o;
4401
- }
4402
- return { files: r, assets: t };
4403
- }
4404
- async function Wr(n) {
4405
- const r = Lr(n.name);
4406
- if (!r)
4407
- throw new Error(
4408
- "File format not supported: please upload .tex, .md, .ptx, .xml, .zip, or .tar.gz."
4409
- );
4410
- if (r === "tex" || r === "markdown" || r === "pretext") {
4411
- const s = await n.text();
4412
- return {
4413
- files: { [ft(n.name)]: wt(s) },
4414
- assets: {}
4415
- };
4416
- }
4417
- if (r === "zip") {
4418
- const i = await new In().loadAsync(n), e = {}, o = {};
4419
- for (const [c, d] of Object.entries(i.files)) {
4420
- if (d.dir)
4421
- continue;
4422
- const _ = ft(c);
4423
- if (We(vt(_)))
4424
- o[_] = await d.async("uint8array");
4425
- else {
4426
- const m = await d.async("string");
4427
- e[_] = wt(m);
4428
- }
4429
- }
4430
- return { files: e, assets: o };
4431
- }
4432
- const t = await n.arrayBuffer(), l = await Ur(t);
4433
- return Mr(new Uint8Array(l));
4434
- }
4435
- function Zr(n) {
4436
- const r = { other: 0 };
4437
- for (const t of Pr)
4438
- r[t] = 0;
4439
- for (const t of Object.keys(n)) {
4440
- const l = vt(t);
4441
- l in r ? r[l] += 1 : r.other += 1;
4442
- }
4443
- return r;
4444
- }
4445
- function Xr(n, r) {
4446
- const t = Zr(r);
4447
- n.push({ type: "success", message: "File types:" });
4448
- for (const l of Object.keys(t).sort())
4449
- t[l] && n.push({ type: "success", message: `${l}: ${t[l]}` });
4450
- }
4451
- function Gr(n) {
4452
- return n === "latex" ? "tex" : n === "markdown" ? "markdown" : "pretext";
4453
- }
4454
- function Hr(n, r) {
4455
- return n.targets.find(
4456
- (t) => t.source === r
4457
- );
4458
- }
4459
- function Kr(n, r) {
4460
- return n === !1 ? [] : Array.isArray(n) ? n.filter((t) => t.include !== !1) : r.extraRoots.map((t) => ({ path: t.path }));
4461
- }
4462
- function Yr(n) {
4463
- if (n.reason === "manifest-target") {
4464
- const r = n.targetName ? ` (target \`${n.targetName}\`)` : "";
4465
- return `Main source file: ${n.path}${r}`;
4466
- }
4467
- return `Main source file: ${n.path}`;
4468
- }
4469
- function Vr(n, r = {}) {
4470
- const t = [];
4471
- try {
4472
- const l = Object.fromEntries(
4473
- Object.entries(n).map(([I, H]) => [
4474
- ft(I),
4475
- wt(H)
4476
- ])
4477
- ), s = Object.keys(l).length;
4478
- t.push({
4479
- type: "success",
4480
- message: `Found ${s} file${s === 1 ? "" : "s"}.`
4481
- }), Xr(t, l);
4482
- const i = xr(l, {
4483
- sourceFormat: r.sourceFormat,
4484
- mainFile: r.mainFile ? ft(r.mainFile) : void 0
4485
- }), e = i.primary;
4486
- if (!e)
4487
- throw new Error("No files were found in the uploaded source.");
4488
- const o = e.path, c = Gr(e.format);
4489
- let d = l[o] ?? "";
4490
- const _ = /* @__PURE__ */ new Set([o]);
4491
- if (i.manifest) {
4492
- const I = i.manifest.targets.length;
4493
- t.push({
4494
- type: "success",
4495
- message: `Found ${i.manifest.manifestPath} with ${I} target${I === 1 ? "" : "s"}: ${i.manifest.targets.map((H) => H.name).join(", ")}.`
4496
- });
4497
- }
4498
- const m = Kr(r.attachRoots, i);
4499
- let v = [];
4500
- const h = [], b = [];
4501
- if (e.format === "latex") {
4502
- const I = Object.fromEntries(
4503
- Object.entries(l).filter(
4504
- ([$]) => vt($) === "tex"
4505
- )
4506
- ), H = ue(d, o, I);
4507
- if (d = wt(H.expandedText), H.consumedPaths.forEach(($) => _.add($)), H.expandedCount > 0 && t.push({
4508
- type: "success",
4509
- message: `Expanded ${H.expandedCount} input/include reference${H.expandedCount === 1 ? "" : "s"}.`
4510
- }), H.missingInputs.length > 0 && t.push({
4511
- type: "error",
4512
- message: `Missing input/include files: ${H.missingInputs.join(", ")}.`
4513
- }), m.length > 0) {
4514
- const $ = {};
4515
- for (const W of m) {
4516
- const Q = l[W.path];
4517
- if (Q === void 0)
4518
- continue;
4519
- const O = ue(
4520
- Q,
4521
- W.path,
4522
- I
4523
- );
4524
- $[W.path] = O.expandedText, O.consumedPaths.forEach(
4525
- (T) => _.add(T)
4526
- ), _.add(W.path);
4527
- }
4528
- const tt = Cr(d, m, $);
4529
- d = wt(tt.source), v = tt.attached, h.push(...tt.warnings);
4530
- }
4531
- } else if (e.format === "markdown") {
4532
- if (m.length > 0) {
4533
- const I = Ar(
4534
- d,
4535
- m,
4536
- l
4537
- );
4538
- d = wt(I.source), v = I.attached, h.push(...I.warnings), v.forEach((H) => _.add(H.path));
4539
- }
4540
- } else {
4541
- const I = Object.fromEntries(
4542
- Object.entries(l).filter(([$]) => {
4543
- const tt = vt($);
4544
- return tt === "ptx" || tt === "xml";
4545
- })
4546
- ), H = Pn(d, o, I);
4547
- d = H.expandedText, H.consumedPaths.forEach(($) => _.add($)), H.expandedCount > 0 && t.push({
4548
- type: "success",
4549
- message: `Expanded ${H.expandedCount} xi:include reference${H.expandedCount === 1 ? "" : "s"}.`
4550
- }), H.missingIncludes.length > 0 && (t.push({
4551
- type: "error",
4552
- message: `Missing xi:include targets: ${H.missingIncludes.join(", ")}.`
4553
- }), b.push({
4554
- action: "anomaly",
4555
- severity: "error",
4556
- kind: "structure",
4557
- category: "missing_include",
4558
- macro: "xi:include",
4559
- occurrences: H.missingIncludes.length,
4560
- examples: H.missingIncludes,
4561
- message: `Missing xi:include targets: ${H.missingIncludes.join(", ")}. This content is missing from the import.`
4562
- }));
4563
- }
4564
- t.push({ type: "success", message: Yr(e) });
4565
- for (const I of v)
4566
- t.push({
4567
- type: "success",
4568
- message: `Attached ${I.path} as a ${I.level}: ${I.title}`
4569
- });
4570
- const f = zn(d, e.format);
4571
- if ("pretextError" in f)
4572
- return {
4573
- pretextError: f.pretextError,
4574
- statusMessages: t,
4575
- warnings: [
4576
- ...f.warnings,
4577
- ...h,
4578
- ...b
4579
- ]
4580
- };
4581
- const {
4582
- buildLayout: g = !0,
4583
- assets: p = {},
4584
- ...w
4585
- } = r, S = i.manifest, E = S && e.reason === "manifest-target" ? Hr(
4586
- S,
4587
- e.path.slice(
4588
- S.projectRoot ? S.projectRoot.length + 1 : 0
4589
- )
4590
- ) : void 0, z = g && S !== null && E !== void 0 && (r.preserveProjectLayout ?? !0), P = {
4591
- mainSourcePath: w.mainSourcePath ?? (z && E ? E.source : "source/main.ptx"),
4592
- publicationPath: w.publicationPath ?? (z && E?.publication ? E.publication : "publication/publication.ptx"),
4593
- projectFilePath: w.projectFilePath ?? "project.ptx",
4594
- preserved: z
4595
- }, D = {}, N = {}, R = {};
4596
- if (z && S && E) {
4597
- const I = Or({
4598
- manifest: S,
4599
- target: E,
4600
- files: l,
4601
- assets: p,
4602
- consumedPaths: _
4603
- });
4604
- Object.assign(R, I.files), Object.assign(D, I.assets);
4605
- for (const [H, $] of Object.entries(p))
4606
- N[H] = $;
4607
- t.push({
4608
- type: "success",
4609
- message: `Carried over ${Object.keys(I.files).length} project file${Object.keys(I.files).length === 1 ? "" : "s"} and ${Object.keys(I.assets).length} asset${Object.keys(I.assets).length === 1 ? "" : "s"} unchanged.`
4610
- }), I.skipped.length > 0 && t.push({
4611
- type: "success",
4612
- message: `Skipped build output: ${I.skipped.length} file${I.skipped.length === 1 ? "" : "s"}.`
4613
- });
4614
- } else
4615
- for (const [I, H] of Object.entries(p)) {
4616
- const $ = Br(I);
4617
- $ && (D[$] = H, N[I] = H);
4618
- }
4619
- const M = Kn(f.pretextSource, {
4620
- documentKind: w.documentKind,
4621
- splitLevel: g ? w.splitLevel : 0,
4622
- splitChapters: g ? w.splitChapters : !1,
4623
- splitSections: g ? w.splitSections : !1,
4624
- assets: N
4625
- });
4626
- g ? (Object.assign(
4627
- R,
4628
- ar(M.project, {
4629
- mainSourcePath: P.mainSourcePath,
4630
- publicationPath: P.publicationPath,
4631
- projectFilePath: P.projectFilePath,
4632
- // A preserved project brings its own publication file; only the
4633
- // manifest is regenerated, from the original targets.
4634
- includeScaffold: !z
4635
- }).files
4636
- ), z && S && E && (R[P.projectFilePath] = Rr(S, E, {
4637
- mainSource: P.mainSourcePath,
4638
- publication: P.publicationPath
4639
- }), P.publicationPath in R || (R[P.publicationPath] = Ce()))) : R["source/main.ptx"] = f.pretextSource;
4640
- for (const [I, H] of Object.entries(l)) {
4641
- const $ = $r(I);
4642
- $ && !($ in R) && (R[$] = H);
4643
- }
4644
- const V = M.project.documentKind, k = [
4645
- ...f.warnings,
4646
- ...h,
4647
- ...b,
4648
- ...M.warnings
4649
- ];
4650
- let j, u;
4651
- return f.cleanedNativeSource !== void 0 && f.cleanedNativeSource.length > 0 && (f.sourceFormat === "latex" || f.sourceFormat === "markdown") && (j = {
4652
- [f.sourceFormat === "latex" ? "source/main.tex" : "source/main.md"]: f.cleanedNativeSource
4653
- }, u = Yn(
4654
- f.cleanedNativeSource,
4655
- f.sourceFormat,
4656
- {
4657
- documentKind: V,
4658
- splitChapters: g ? w.splitChapters : !1,
4659
- splitSections: g ? w.splitSections : !1,
4660
- title: M.project.title,
4661
- docinfo: M.project.docinfo,
4662
- assets: N
4663
- }
4664
- ).project), Object.keys(p).length > 0 && t.push({
4665
- type: "success",
4666
- message: `Routed ${Object.keys(D).length} binary asset${Object.keys(D).length === 1 ? "" : "s"}.`
4667
- }), {
4668
- ...f,
4669
- warnings: k,
4670
- sourcePath: o,
4671
- sourceName: yt(o),
4672
- sourceType: c,
4673
- analysis: i,
4674
- attachedRoots: v,
4675
- projectLayout: P,
4676
- project: M.project,
4677
- nativeProject: u,
4678
- files: l,
4679
- assets: p,
4680
- outputFiles: R,
4681
- outputAssets: D,
4682
- nativeOutputFiles: j,
4683
- documentKind: V,
4684
- statusMessages: t
4685
- };
4686
- } catch (l) {
4687
- const s = l instanceof Error ? l.message : String(l);
4688
- return t.push({ type: "error", message: s }), {
4689
- pretextError: s,
4690
- statusMessages: t,
4691
- warnings: []
4692
- };
4693
- }
4694
- }
4695
- async function ei(n, r = {}) {
4696
- const t = [], l = ft(n.name);
4697
- if (!Fr.test(l.toLowerCase()))
4698
- return {
4699
- pretextError: "File format not supported: please upload .tex, .md, .ptx, .xml, .zip, or .tar.gz.",
4700
- statusMessages: [
4701
- {
4702
- type: "error",
4703
- message: "File format not supported: please upload .tex, .md, .ptx, .xml, .zip, or .tar.gz."
4704
- }
4705
- ],
4706
- warnings: []
4707
- };
4708
- t.push({
4709
- type: "loading",
4710
- message: `Processing ${l}...`
4711
- });
4712
- try {
4713
- const { files: s, assets: i } = await Wr(n), e = Vr(s, { ...r, assets: i });
4714
- return {
4715
- ...e,
4716
- statusMessages: [...t, ...e.statusMessages]
4717
- };
4718
- } catch (s) {
4719
- const i = s instanceof Error ? s.message : String(s);
4720
- return {
4721
- pretextError: i,
4722
- statusMessages: [...t, { type: "error", message: i }],
4723
- warnings: []
4724
- };
4725
- }
4726
- }
4727
- function ni(n, r) {
4728
- return r === "native" ? n.nativeProject ?? n.project : n.project;
4729
- }
4730
- function ri(n, r) {
4731
- return r === "converted" ? n.outputFiles : n.nativeOutputFiles ?? n.files;
4732
- }
4733
- function ii(n, r) {
4734
- return r === "converted" ? n.outputAssets : n.assets;
4735
- }
4736
- function si(n) {
4737
- const r = n.action === "replace" || n.action === "rewrite" ? `replaced with \`${n.replacement}\`` : n.message ?? n.action, t = n.occurrences > 1 ? ` (x${n.occurrences})` : "";
4738
- return `[${n.severity}] ${n.macro}: ${r}${t}`;
4739
- }
4740
- export {
4741
- Pn as A,
4742
- Wr as B,
4743
- Re as C,
4744
- ri as D,
4745
- ur as E,
4746
- si as F,
4747
- En as G,
4748
- ei as H,
4749
- Vr as I,
4750
- Wn as J,
4751
- Vt as K,
4752
- Ve as L,
4753
- Je as M,
4754
- lr as N,
4755
- ni as O,
4756
- Un as P,
4757
- Rr as Q,
4758
- Hn as R,
4759
- Qt as S,
4760
- ar as T,
4761
- Ce as a,
4762
- Te as b,
4763
- Oe as c,
4764
- $n as d,
4765
- he as e,
4766
- Rt as f,
4767
- ti as g,
4768
- xr as h,
4769
- ii as i,
4770
- Cr as j,
4771
- Ar as k,
4772
- Kn as l,
4773
- Yn as m,
4774
- Or as n,
4775
- gn as o,
4776
- Ct as p,
4777
- kn as q,
4778
- jn as r,
4779
- Nn as s,
4780
- Sn as t,
4781
- zn as u,
4782
- Er as v,
4783
- pe as w,
4784
- fr as x,
4785
- Xt as y,
4786
- Wt as z
4787
- };