document-ir 0.0.15 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (54) hide show
  1. package/{esm → dist}/ArrayCollapseTransformer.d.ts +2 -2
  2. package/{script → dist}/DocumentThinningTransformer.d.ts +2 -2
  3. package/dist/ExampleDocument.d.ts +2 -0
  4. package/{esm → dist}/IdentityTransformer.d.ts +1 -1
  5. package/{esm → dist}/NodeVisitor.d.ts +1 -1
  6. package/{esm → dist}/TextCollapseTransformer.d.ts +2 -2
  7. package/{script → dist}/TextVisitor.d.ts +2 -2
  8. package/{script → dist}/WhitespaceStretchingTransformer.d.ts +2 -2
  9. package/{script → dist}/WhitespaceTransformer.d.ts +2 -2
  10. package/{script → dist}/WordCountTransformer.d.ts +2 -2
  11. package/{script → dist}/WordCounterVisitor.d.ts +2 -2
  12. package/dist/index.d.ts +11 -0
  13. package/dist/index.js +1378 -0
  14. package/package.json +40 -11
  15. package/esm/ArrayCollapseTransformer.js +0 -18
  16. package/esm/DocumentThinningTransformer.d.ts +0 -16
  17. package/esm/DocumentThinningTransformer.js +0 -246
  18. package/esm/IdentityTransformer.js +0 -866
  19. package/esm/NodeVisitor.js +0 -414
  20. package/esm/TextCollapseTransformer.js +0 -36
  21. package/esm/TextVisitor.d.ts +0 -15
  22. package/esm/TextVisitor.js +0 -55
  23. package/esm/WhitespaceStretchingTransformer.d.ts +0 -26
  24. package/esm/WhitespaceStretchingTransformer.js +0 -121
  25. package/esm/WhitespaceTransformer.d.ts +0 -12
  26. package/esm/WhitespaceTransformer.js +0 -75
  27. package/esm/WordCountTransformer.d.ts +0 -6
  28. package/esm/WordCountTransformer.js +0 -83
  29. package/esm/WordCounterVisitor.d.ts +0 -13
  30. package/esm/WordCounterVisitor.js +0 -43
  31. package/esm/index.d.ts +0 -11
  32. package/esm/index.js +0 -11
  33. package/esm/package.json +0 -3
  34. package/esm/types.js +0 -1
  35. package/script/ArrayCollapseTransformer.d.ts +0 -5
  36. package/script/ArrayCollapseTransformer.js +0 -22
  37. package/script/DocumentThinningTransformer.js +0 -250
  38. package/script/IdentityTransformer.d.ts +0 -59
  39. package/script/IdentityTransformer.js +0 -870
  40. package/script/NodeVisitor.d.ts +0 -59
  41. package/script/NodeVisitor.js +0 -418
  42. package/script/TextCollapseTransformer.d.ts +0 -5
  43. package/script/TextCollapseTransformer.js +0 -40
  44. package/script/TextVisitor.js +0 -59
  45. package/script/WhitespaceStretchingTransformer.js +0 -125
  46. package/script/WhitespaceTransformer.js +0 -79
  47. package/script/WordCountTransformer.js +0 -87
  48. package/script/WordCounterVisitor.js +0 -47
  49. package/script/index.d.ts +0 -11
  50. package/script/index.js +0 -38
  51. package/script/package.json +0 -3
  52. package/script/types.d.ts +0 -351
  53. package/script/types.js +0 -2
  54. /package/{esm → dist}/types.d.ts +0 -0
package/dist/index.js ADDED
@@ -0,0 +1,1378 @@
1
+ var y = Object.defineProperty;
2
+ var k = (c, t, e) => t in c ? y(c, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : c[t] = e;
3
+ var h = (c, t, e) => k(c, typeof t != "symbol" ? t + "" : t, e);
4
+ class l {
5
+ async beforeBlock() {
6
+ }
7
+ async afterBlock() {
8
+ }
9
+ async beforeInline() {
10
+ }
11
+ async afterInline() {
12
+ }
13
+ async chooseChildren(t) {
14
+ const e = [];
15
+ for (const i of t) {
16
+ const r = await this.choose(i);
17
+ r && e.push(r);
18
+ }
19
+ return e;
20
+ }
21
+ async block(t) {
22
+ await this.beforeBlock();
23
+ const e = await this.chooseChildren(t.content);
24
+ return await this.afterBlock(), {
25
+ type: "block",
26
+ content: e
27
+ };
28
+ }
29
+ async blockQuote(t) {
30
+ await this.beforeBlock();
31
+ const e = await this.chooseChildren(t.content);
32
+ return await this.afterBlock(), {
33
+ type: "block-quote",
34
+ content: e
35
+ };
36
+ }
37
+ async bold(t) {
38
+ await this.beforeInline();
39
+ const e = await this.chooseChildren(t.content);
40
+ return await this.afterInline(), {
41
+ type: "bold",
42
+ content: e
43
+ };
44
+ }
45
+ async break_(t) {
46
+ return await this.beforeBlock(), await this.afterBlock(), {
47
+ type: "break"
48
+ };
49
+ }
50
+ async bubble(t) {
51
+ await this.beforeBlock();
52
+ const e = await this.chooseChildren(t.content);
53
+ return await this.afterBlock(), {
54
+ type: "bubble",
55
+ orientation: t.orientation || "left",
56
+ content: e
57
+ };
58
+ }
59
+ async center(t) {
60
+ await this.beforeBlock();
61
+ const e = await this.chooseChildren(t.content);
62
+ return await this.afterBlock(), {
63
+ type: "center",
64
+ content: e
65
+ };
66
+ }
67
+ async code(t) {
68
+ await this.beforeInline();
69
+ const e = await this.chooseChildren(t.content);
70
+ return await this.afterInline(), {
71
+ type: "code",
72
+ content: e
73
+ };
74
+ }
75
+ async columns(t) {
76
+ const e = [];
77
+ for (const i of t.columns)
78
+ await this.beforeBlock(), e.push(await this.chooseChildren(i)), await this.afterBlock();
79
+ return {
80
+ type: "columns",
81
+ columns: e,
82
+ "column-count": t["column-count"]
83
+ };
84
+ }
85
+ async definition(t) {
86
+ await this.beforeBlock();
87
+ const e = await this.chooseChildren(t.abbreviation);
88
+ await this.afterBlock(), await this.beforeBlock();
89
+ const i = await this.chooseChildren(t.title);
90
+ await this.afterBlock(), await this.beforeBlock();
91
+ const r = await this.chooseChildren(t.content);
92
+ return await this.afterBlock(), {
93
+ type: "definition",
94
+ abbreviation: e,
95
+ title: i,
96
+ content: r,
97
+ key: t.key
98
+ };
99
+ }
100
+ async definitionList(t) {
101
+ await this.beforeBlock();
102
+ const e = [];
103
+ for (const i of t.content) {
104
+ const r = await this.definition(i);
105
+ r && e.push(r);
106
+ }
107
+ return await this.afterBlock(), {
108
+ type: "definition-list",
109
+ content: e
110
+ };
111
+ }
112
+ async definitionReference(t) {
113
+ await this.beforeInline();
114
+ const e = await this.chooseChildren(
115
+ t.definition.abbreviation
116
+ );
117
+ return await this.afterInline(), {
118
+ type: "definition-reference",
119
+ definition: {
120
+ abbreviation: e,
121
+ key: t.definition.key
122
+ },
123
+ content: await this.chooseChildren(t.content)
124
+ };
125
+ }
126
+ async embed(t) {
127
+ return {
128
+ type: "embed",
129
+ content: {
130
+ ...t.content
131
+ }
132
+ };
133
+ }
134
+ async emoji(t) {
135
+ return {
136
+ type: "emoji",
137
+ url: t.url,
138
+ alt: t.alt
139
+ };
140
+ }
141
+ async figure(t) {
142
+ await this.beforeBlock();
143
+ const e = await this.chooseChildren(t.content);
144
+ return await this.afterBlock(), {
145
+ type: "figure",
146
+ content: e
147
+ };
148
+ }
149
+ async figureCaption(t) {
150
+ await this.beforeBlock();
151
+ const e = await this.chooseChildren(t.content);
152
+ return await this.afterBlock(), {
153
+ type: "figure-caption",
154
+ content: e
155
+ };
156
+ }
157
+ async figureImage(t) {
158
+ await this.beforeBlock();
159
+ const e = await this.chooseChildren(t.content);
160
+ await this.afterBlock();
161
+ const i = {
162
+ type: "figure-image",
163
+ alt: t.alt || "",
164
+ url: t.url,
165
+ content: e
166
+ };
167
+ return t.blurhash && (i.blurhash = t.blurhash), t.height && (i.height = t.height), t.width && (i.width = t.width), t.hero && (i.hero = t.hero), t.image && (i.image = t.image), i;
168
+ }
169
+ async formattedText(t) {
170
+ return await this.beforeBlock(), await this.afterBlock(), {
171
+ type: "formatted-text",
172
+ text: t.text || "",
173
+ language: t.language
174
+ };
175
+ }
176
+ async header(t) {
177
+ await this.beforeBlock();
178
+ const e = await this.chooseChildren(t.content);
179
+ await this.afterBlock();
180
+ const i = {
181
+ type: "header",
182
+ content: e,
183
+ level: t.level || 2
184
+ };
185
+ return t.htmlId && (i.htmlId = t.htmlId), i;
186
+ }
187
+ async highTechAlert(t) {
188
+ await this.beforeBlock();
189
+ const e = await this.chooseChildren(t.content);
190
+ await this.afterBlock(), await this.beforeBlock();
191
+ const i = await this.chooseChildren(t.warning);
192
+ return await this.afterBlock(), {
193
+ type: "high-tech-alert",
194
+ content: e,
195
+ warning: i
196
+ };
197
+ }
198
+ async horizontalRule(t) {
199
+ return await this.beforeBlock(), await this.afterBlock(), {
200
+ type: "horizontal-rule"
201
+ };
202
+ }
203
+ async image(t) {
204
+ await this.beforeBlock(), await this.afterBlock();
205
+ const e = {
206
+ type: "image",
207
+ alt: t.alt || "",
208
+ url: t.url
209
+ };
210
+ return t.hero && (e.hero = t.hero), t.blurhash && (e.blurhash = t.blurhash), t.height && (e.height = t.height), t.width && (e.width = t.width), t.image && (e.image = t.image), e;
211
+ }
212
+ async italic(t) {
213
+ await this.beforeInline();
214
+ const e = await this.chooseChildren(t.content);
215
+ return await this.afterInline(), {
216
+ type: "italic",
217
+ content: e
218
+ };
219
+ }
220
+ async link(t) {
221
+ await this.beforeInline();
222
+ const e = await this.chooseChildren(t.content);
223
+ await this.afterInline();
224
+ const i = {
225
+ type: "link",
226
+ content: e,
227
+ url: t.url
228
+ };
229
+ return t.title && (i.title = t.title), t.target && (i.target = t.target), t.userGeneratedContent && (i.userGeneratedContent = t.userGeneratedContent), t.noReferrer && (i.noReferrer = t.noReferrer), t.noFollow && (i.noFollow = t.noFollow), t.noOpener && (i.noOpener = t.noOpener), i;
230
+ }
231
+ async array(t) {
232
+ return {
233
+ type: "array",
234
+ content: await this.chooseChildren(t.content)
235
+ };
236
+ }
237
+ async note(t) {
238
+ await this.beforeBlock();
239
+ const e = await this.chooseChildren(t.content);
240
+ return await this.afterBlock(), {
241
+ type: "note",
242
+ content: e
243
+ };
244
+ }
245
+ async list(t) {
246
+ const e = [];
247
+ for (const i of t.content) {
248
+ await this.beforeBlock();
249
+ const r = await this.chooseChildren(i.content);
250
+ await this.afterBlock(), r && r.length > 0 && e.push({
251
+ type: "list-item",
252
+ content: r
253
+ });
254
+ }
255
+ return {
256
+ type: "list",
257
+ style: t.style || "unordered",
258
+ content: e
259
+ };
260
+ }
261
+ async paragraph(t) {
262
+ await this.beforeBlock();
263
+ const e = await this.chooseChildren(t.content);
264
+ return await this.afterBlock(), {
265
+ type: "paragraph",
266
+ content: e
267
+ };
268
+ }
269
+ async quote(t) {
270
+ await this.beforeBlock();
271
+ const e = await this.chooseChildren(t.content);
272
+ await this.afterBlock();
273
+ const i = {
274
+ type: "quote",
275
+ icon: t.icon,
276
+ name: t.name,
277
+ content: e,
278
+ url: t.url
279
+ };
280
+ return t.orientation && (i.orientation = t.orientation), i;
281
+ }
282
+ async redacted(t) {
283
+ t.style == "block" ? await this.beforeBlock() : await this.beforeInline();
284
+ const e = await this.chooseChildren(t.content);
285
+ return t.style == "block" ? await this.afterBlock() : await this.afterInline(), {
286
+ type: "redacted",
287
+ style: t.style,
288
+ content: e
289
+ };
290
+ }
291
+ async region(t) {
292
+ await this.beforeBlock();
293
+ const e = await this.chooseChildren(t.content);
294
+ return await this.afterBlock(), {
295
+ type: "region",
296
+ mode: t.mode,
297
+ regions: t.regions,
298
+ content: e
299
+ };
300
+ }
301
+ async script(t) {
302
+ return {
303
+ type: "script",
304
+ "mime-type": t["mime-type"] || "text/javascript",
305
+ source: t.source
306
+ };
307
+ }
308
+ async secret(t) {
309
+ await this.beforeInline();
310
+ const e = await this.chooseChildren(t.content);
311
+ return await this.afterInline(), {
312
+ type: "secret",
313
+ content: e
314
+ };
315
+ }
316
+ async smaller(t) {
317
+ await this.beforeInline();
318
+ const e = await this.chooseChildren(t.content);
319
+ return await this.afterInline(), {
320
+ type: "smaller",
321
+ content: e
322
+ };
323
+ }
324
+ async sticker(t) {
325
+ await this.beforeBlock();
326
+ const e = await this.chooseChildren(t.content);
327
+ await this.afterBlock();
328
+ const i = {
329
+ type: "sticker",
330
+ orientation: t.orientation,
331
+ character: t.character,
332
+ name: t.name,
333
+ content: e
334
+ };
335
+ return t.size && (i.size = t.size), t.width && (i.width = t.width), t.height && (i.height = t.height), i;
336
+ }
337
+ async strikeThrough(t) {
338
+ await this.beforeInline();
339
+ const e = await this.chooseChildren(t.content);
340
+ return await this.afterInline(), {
341
+ type: "strike-through",
342
+ content: e
343
+ };
344
+ }
345
+ async text(t) {
346
+ return {
347
+ type: "text",
348
+ text: t.text
349
+ };
350
+ }
351
+ async table(t) {
352
+ const e = [];
353
+ for (const i of t.content) {
354
+ const r = [];
355
+ let s = 0;
356
+ for (const n of i) {
357
+ await this.beforeBlock();
358
+ const a = await this.chooseChildren(n.content);
359
+ await this.afterBlock(), a && a.length == 0 && s++;
360
+ const o = {
361
+ type: "table-cell",
362
+ span: [n.span[0] || 1, n.span[1] || 1],
363
+ content: a
364
+ };
365
+ n.header && (o.header = n.header), r.push(o);
366
+ }
367
+ r.length > 0 && s != r.length && e.push(r);
368
+ }
369
+ return {
370
+ type: "table",
371
+ content: e
372
+ };
373
+ }
374
+ async social(t) {
375
+ return await this.beforeBlock(), await this.afterBlock(), {
376
+ type: t.type,
377
+ id: t.id
378
+ };
379
+ }
380
+ async underline(t) {
381
+ await this.beforeInline();
382
+ const e = await this.chooseChildren(t.content);
383
+ return await this.afterInline(), {
384
+ type: "underline",
385
+ content: e
386
+ };
387
+ }
388
+ async video(t) {
389
+ await this.beforeBlock();
390
+ const e = t.content && await this.chooseChildren(t.content);
391
+ await this.afterBlock();
392
+ const i = {
393
+ type: "video",
394
+ alt: t.alt,
395
+ mp4: t.mp4,
396
+ poster: t.poster
397
+ };
398
+ return t.autoplay && (i.autoplay = t.autoplay), t.blurhash && (i.blurhash = t.blurhash), e && (i.content = e), t.controls && (i.controls = t.controls), t.height && (i.height = t.height), t.width && (i.width = t.width), t.loop && (i.loop = t.loop), t.muted && (i.muted = t.muted), t.webm && (i.webm = t.webm), i;
399
+ }
400
+ async warning(t) {
401
+ await this.beforeBlock();
402
+ const e = await this.chooseChildren(t.content);
403
+ return await this.afterBlock(), {
404
+ type: "warning",
405
+ content: e
406
+ };
407
+ }
408
+ async card(t) {
409
+ let e;
410
+ if (t.content) {
411
+ await this.beforeBlock();
412
+ const n = await this.chooseChildren(t.content.content);
413
+ n && n.length > 0 && (e = {
414
+ type: "card-content",
415
+ content: n
416
+ }), await this.afterBlock();
417
+ }
418
+ let i;
419
+ if (t.attribution && (i = {
420
+ type: "card-attribution"
421
+ }, t.attribution.archiveUrl && (i.archiveUrl = t.attribution.archiveUrl), t.attribution.url && (i.url = t.attribution.url), t.attribution.date && (i.date = t.attribution.date), t.attribution.title)) {
422
+ await this.beforeBlock();
423
+ const n = await this.chooseChildren(t.attribution.title);
424
+ await this.afterBlock(), i.title = n;
425
+ }
426
+ let r;
427
+ if (t.header) {
428
+ await this.beforeBlock();
429
+ const n = await this.chooseChildren(t.header.title);
430
+ await this.afterBlock(), r = {
431
+ type: "card-header",
432
+ title: n,
433
+ backgroundBlurhash: t.header.backgroundBlurhash,
434
+ backgroundColor: t.header.backgroundColor,
435
+ backgroundImage: t.header.backgroundImage,
436
+ imageUrl: t.header.imageUrl,
437
+ imageBlurhash: t.header.imageBlurhash
438
+ }, t.header.url && (r.url = t.header.url), t.header.username && (r.username = t.header.username), t.header.usernameDomain && (r.usernameDomain = t.header.usernameDomain);
439
+ }
440
+ let s;
441
+ if (t.media) {
442
+ const n = [];
443
+ for (const a of t.media.content) {
444
+ await this.beforeBlock();
445
+ const o = await this.choose(a);
446
+ o && (o.type == "image" || o.type == "video" || o.type == "embed") && n.push(o), await this.afterBlock();
447
+ }
448
+ n.length > 0 && (s = {
449
+ type: "card-media",
450
+ content: n
451
+ });
452
+ }
453
+ return {
454
+ type: "card",
455
+ content: e,
456
+ attribution: i,
457
+ header: r,
458
+ media: s,
459
+ original: t.original
460
+ };
461
+ }
462
+ async date(t) {
463
+ await this.beforeInline();
464
+ const e = t.content && await this.chooseChildren(t.content);
465
+ return await this.afterInline(), {
466
+ type: "date",
467
+ isoDate: t.isoDate,
468
+ content: e
469
+ };
470
+ }
471
+ async time(t) {
472
+ await this.beforeInline();
473
+ const e = t.content && await this.chooseChildren(t.content);
474
+ return await this.afterInline(), {
475
+ type: "time",
476
+ isoTime: t.isoTime,
477
+ content: e
478
+ };
479
+ }
480
+ async datetime(t) {
481
+ await this.beforeInline();
482
+ const e = t.content && await this.chooseChildren(t.content);
483
+ return await this.afterInline(), {
484
+ type: "datetime",
485
+ iso8601: t.iso8601,
486
+ content: e
487
+ };
488
+ }
489
+ async subText(t) {
490
+ await this.beforeInline();
491
+ const e = t.content && await this.chooseChildren(t.content);
492
+ return await this.afterInline(), {
493
+ type: "sub",
494
+ content: e
495
+ };
496
+ }
497
+ async superText(t) {
498
+ await this.beforeInline();
499
+ const e = t.content && await this.chooseChildren(t.content);
500
+ return await this.afterInline(), {
501
+ type: "super",
502
+ content: e
503
+ };
504
+ }
505
+ async toc(t) {
506
+ await this.beforeBlock();
507
+ const e = await this.chooseChildren(t.content), i = t.date && await this.choose(t.date);
508
+ await this.afterBlock(), await this.beforeBlock();
509
+ const r = await this.chooseChildren(t.children);
510
+ await this.afterBlock();
511
+ const s = r.filter(
512
+ (a) => a.type == "toc"
513
+ ), n = {
514
+ type: "toc",
515
+ content: e,
516
+ children: s
517
+ };
518
+ return i && (i.type == "date" || i.type == "time" || i.type == "datetime") && (n.date = i), t.href && (n.href = t.href), t.hrefHtmlId && (n.hrefHtmlId = t.hrefHtmlId), n;
519
+ }
520
+ async choose(t) {
521
+ if (!t || !t.type)
522
+ throw new Error(`Unexpected node, no type: ${JSON.stringify(t)}`);
523
+ try {
524
+ switch (t.type) {
525
+ case "block":
526
+ return await this.block(t);
527
+ case "block-quote":
528
+ return await this.blockQuote(t);
529
+ case "bold":
530
+ return await this.bold(t);
531
+ case "break":
532
+ return await this.break_(t);
533
+ case "bubble":
534
+ return await this.bubble(t);
535
+ case "card":
536
+ return await this.card(t);
537
+ case "center":
538
+ return await this.center(t);
539
+ case "code":
540
+ return await this.code(t);
541
+ case "columns":
542
+ return await this.columns(t);
543
+ case "definition":
544
+ return await this.definition(t);
545
+ case "definition-list":
546
+ return await this.definitionList(t);
547
+ case "definition-reference":
548
+ return await this.definitionReference(t);
549
+ case "embed":
550
+ return await this.embed(t);
551
+ case "emoji":
552
+ return await this.emoji(t);
553
+ case "figure":
554
+ return await this.figure(t);
555
+ case "figure-caption":
556
+ return await this.figureCaption(t);
557
+ case "figure-image":
558
+ return await this.figureImage(t);
559
+ case "formatted-text":
560
+ return await this.formattedText(t);
561
+ case "header":
562
+ return await this.header(t);
563
+ case "high-tech-alert":
564
+ return await this.highTechAlert(t);
565
+ case "horizontal-rule":
566
+ return await this.horizontalRule(t);
567
+ case "image":
568
+ return await this.image(t);
569
+ case "italic":
570
+ return await this.italic(t);
571
+ case "link":
572
+ return await this.link(t);
573
+ case "array":
574
+ return await this.array(t);
575
+ case "note":
576
+ return await this.note(t);
577
+ case "list":
578
+ return await this.list(t);
579
+ case "paragraph":
580
+ return await this.paragraph(t);
581
+ case "quote":
582
+ return await this.quote(t);
583
+ case "redacted":
584
+ return await this.redacted(t);
585
+ case "region":
586
+ return await this.region(t);
587
+ case "script":
588
+ return await this.script(t);
589
+ case "secret":
590
+ return await this.secret(t);
591
+ case "smaller":
592
+ return await this.smaller(t);
593
+ case "sticker":
594
+ return await this.sticker(t);
595
+ case "strike-through":
596
+ return await this.strikeThrough(t);
597
+ case "table":
598
+ return await this.table(t);
599
+ case "text":
600
+ return await this.text(t);
601
+ case "toot":
602
+ case "tweet":
603
+ case "vimeo":
604
+ case "youtube":
605
+ return await this.social(t);
606
+ case "underline":
607
+ return await this.underline(t);
608
+ case "video":
609
+ return await this.video(t);
610
+ case "warning":
611
+ return await this.warning(t);
612
+ case "date":
613
+ return await this.date(t);
614
+ case "time":
615
+ return await this.time(t);
616
+ case "datetime":
617
+ return await this.datetime(t);
618
+ case "super":
619
+ return await this.superText(t);
620
+ case "sub":
621
+ return await this.subText(t);
622
+ case "toc":
623
+ return await this.toc(t);
624
+ }
625
+ } catch (e) {
626
+ throw console.log(
627
+ `Got exception while processing node: ${JSON.stringify(t)}`
628
+ ), e;
629
+ }
630
+ return console.error(`Unsupported type ${t.type}`), null;
631
+ }
632
+ async document(t) {
633
+ await this.beforeBlock();
634
+ const e = await this.chooseChildren(t.content);
635
+ await this.afterBlock(), await this.beforeBlock();
636
+ const i = t.definitions && (await this.chooseChildren(t.definitions)).filter(
637
+ (n) => n.type == "definition"
638
+ ), r = t.hierarchy;
639
+ await this.afterBlock();
640
+ const s = {
641
+ type: "document",
642
+ title: t.title,
643
+ content: e,
644
+ url: t.url
645
+ };
646
+ return t.image && (s.image = t.image), t.guid && (s.guid = t.guid), t["pub-date"] && (s["pub-date"] = t["pub-date"]), t.description && (s.description = t.description), t.date && (s.date = t.date), r && (s.hierarchy = r), i && (s.definitions = i), t.noindex && (s.noindex = t.noindex), t.author && (s.author = t.author), t.hidden && (s.hidden = t.hidden), t.readingDifficultyMultiplier && (s.readingDifficultyMultiplier = t.readingDifficultyMultiplier), t.contentDigest && (s.contentDigest = t.contentDigest), s;
647
+ }
648
+ async transform(t) {
649
+ return await this.document(t);
650
+ }
651
+ }
652
+ class g extends l {
653
+ async chooseChildren(t) {
654
+ const e = await super.chooseChildren(t), i = [];
655
+ for (const r of e)
656
+ if (r.type == "array")
657
+ for (const s of r.content)
658
+ i.push(s);
659
+ else
660
+ i.push(r);
661
+ return i;
662
+ }
663
+ }
664
+ class I extends l {
665
+ async chooseChildren(t) {
666
+ const e = await super.chooseChildren(t), i = [];
667
+ let r = null;
668
+ for (const s of e)
669
+ s.type == "text" ? r != null ? r = `${r}${s.text}` : r = s.text : (r != null && (i.push({
670
+ type: "text",
671
+ text: r
672
+ }), r = null), i.push(s));
673
+ return r != null && (i.push({
674
+ type: "text",
675
+ text: r
676
+ }), r = null), i;
677
+ }
678
+ }
679
+ class m extends l {
680
+ async text(t) {
681
+ return t.text == "" ? null : t;
682
+ }
683
+ }
684
+ class T extends l {
685
+ constructor() {
686
+ super();
687
+ h(this, "stripWhitespace");
688
+ h(this, "lastText");
689
+ this.stripWhitespace = !0, this.lastText = null;
690
+ }
691
+ async text(e) {
692
+ let i = "";
693
+ for (const s of e.text)
694
+ s == " " || s == `
695
+ ` || s == " " || s == "\r" ? this.stripWhitespace || (i += " ", this.stripWhitespace = !0) : (i += s, this.stripWhitespace = !1);
696
+ if (i.length == 0)
697
+ return null;
698
+ const r = {
699
+ type: "text",
700
+ text: i
701
+ };
702
+ return this.lastText = r, r;
703
+ }
704
+ stripLastText() {
705
+ this.lastText && (this.lastText.text.endsWith(" ") && (this.lastText.text = this.lastText.text.slice(0, -1)), this.lastText = null), this.stripWhitespace = !0;
706
+ }
707
+ async beforeBlock() {
708
+ this.stripLastText();
709
+ }
710
+ async afterBlock() {
711
+ this.stripLastText();
712
+ }
713
+ async transform(e) {
714
+ const i = await super.transform(e);
715
+ return await new m().transform(i);
716
+ }
717
+ }
718
+ class v extends l {
719
+ constructor() {
720
+ super();
721
+ h(this, "root");
722
+ h(this, "cursor");
723
+ this.root = {
724
+ type: "_block",
725
+ content: [],
726
+ parent: null
727
+ }, this.cursor = this.root;
728
+ }
729
+ async beforeBlock() {
730
+ const e = this.cursor, i = {
731
+ type: "_block",
732
+ content: [],
733
+ parent: e
734
+ };
735
+ e.content.push(i), this.cursor = i;
736
+ }
737
+ async afterBlock() {
738
+ this.cursor.parent && (this.cursor = this.cursor.parent);
739
+ }
740
+ async beforeInline() {
741
+ const e = this.cursor, i = {
742
+ type: "_inline",
743
+ content: [],
744
+ parent: e
745
+ };
746
+ e.content.push(i), this.cursor = i;
747
+ }
748
+ async afterInline() {
749
+ this.cursor.parent && (this.cursor = this.cursor.parent);
750
+ }
751
+ reviewBlock(e) {
752
+ const i = [], r = (s, n) => {
753
+ if (s.type == "text")
754
+ i.push({
755
+ node: s,
756
+ level: n
757
+ });
758
+ else if (s.type == "_block")
759
+ this.reviewBlock(s), i.push({ node: null, level: n });
760
+ else
761
+ for (const a of s.content)
762
+ r(a, n + 1);
763
+ };
764
+ for (const s of e.content)
765
+ r(s, 0);
766
+ for (let s = 0; s < i.length; s++) {
767
+ const n = i[s], a = s + 1 < i.length ? i[s + 1] : { node: null, level: 0 };
768
+ !n.node || !a.node || n.level != a.level && (n.level < a.level ? a.node.text.startsWith(" ") && (a.node.text = a.node.text.slice(1), n.node.text += " ") : n.level > a.level && n.node.text.endsWith(" ") && (n.node.text = n.node.text.slice(0, -1), a.node.text = ` ${a.node.text}`));
769
+ }
770
+ }
771
+ async text(e) {
772
+ const i = {
773
+ type: "text",
774
+ text: `${e.text}`
775
+ };
776
+ return this.cursor.content.push(i), i;
777
+ }
778
+ async transform(e) {
779
+ const i = await super.transform(e);
780
+ return this.reviewBlock(this.root), i;
781
+ }
782
+ }
783
+ class w {
784
+ beforeBlock() {
785
+ }
786
+ afterBlock() {
787
+ }
788
+ beforeInline() {
789
+ }
790
+ afterInline() {
791
+ }
792
+ chooseChildren(t) {
793
+ for (const e of t)
794
+ this.choose(e);
795
+ }
796
+ block(t) {
797
+ this.beforeBlock(), this.chooseChildren(t.content), this.afterBlock();
798
+ }
799
+ blockQuote(t) {
800
+ this.beforeBlock(), this.chooseChildren(t.content), this.afterBlock();
801
+ }
802
+ bold(t) {
803
+ this.beforeInline(), this.chooseChildren(t.content), this.afterInline();
804
+ }
805
+ break_(t) {
806
+ this.beforeBlock(), this.afterBlock();
807
+ }
808
+ bubble(t) {
809
+ this.beforeBlock(), this.chooseChildren(t.content), this.afterBlock();
810
+ }
811
+ center(t) {
812
+ this.beforeBlock(), this.chooseChildren(t.content), this.afterBlock();
813
+ }
814
+ code(t) {
815
+ this.beforeInline(), this.chooseChildren(t.content), this.afterInline();
816
+ }
817
+ columns(t) {
818
+ for (const e of t.columns)
819
+ this.beforeBlock(), this.chooseChildren(e), this.afterBlock();
820
+ }
821
+ definition(t) {
822
+ this.beforeBlock(), this.chooseChildren(t.abbreviation), this.afterBlock(), this.beforeBlock(), this.chooseChildren(t.title), this.afterBlock(), this.beforeBlock(), this.chooseChildren(t.content), this.afterBlock();
823
+ }
824
+ definitionList(t) {
825
+ this.beforeBlock();
826
+ for (const e of t.content)
827
+ this.definition(e);
828
+ this.afterBlock();
829
+ }
830
+ definitionReference(t) {
831
+ this.beforeInline(), this.chooseChildren(t.definition.abbreviation), this.afterInline(), this.chooseChildren(t.content);
832
+ }
833
+ embed(t) {
834
+ }
835
+ emoji(t) {
836
+ }
837
+ figure(t) {
838
+ this.beforeBlock(), this.chooseChildren(t.content), this.afterBlock();
839
+ }
840
+ figureCaption(t) {
841
+ this.beforeBlock(), this.chooseChildren(t.content), this.afterBlock();
842
+ }
843
+ figureImage(t) {
844
+ this.beforeBlock(), this.chooseChildren(t.content), this.afterBlock();
845
+ }
846
+ formattedText(t) {
847
+ }
848
+ header(t) {
849
+ this.beforeBlock(), this.chooseChildren(t.content), this.afterBlock();
850
+ }
851
+ highTechAlert(t) {
852
+ this.beforeBlock(), this.chooseChildren(t.content), this.afterBlock(), this.beforeBlock(), this.chooseChildren(t.warning), this.afterBlock();
853
+ }
854
+ horizontalRule(t) {
855
+ }
856
+ image(t) {
857
+ }
858
+ italic(t) {
859
+ this.beforeInline(), this.chooseChildren(t.content), this.afterInline();
860
+ }
861
+ link(t) {
862
+ this.beforeInline(), this.chooseChildren(t.content), this.afterInline();
863
+ }
864
+ array(t) {
865
+ this.chooseChildren(t.content);
866
+ }
867
+ note(t) {
868
+ this.beforeBlock(), this.chooseChildren(t.content), this.afterBlock();
869
+ }
870
+ list(t) {
871
+ for (const e of t.content)
872
+ this.beforeBlock(), this.chooseChildren(e.content), this.afterBlock();
873
+ }
874
+ paragraph(t) {
875
+ this.beforeBlock(), this.chooseChildren(t.content), this.afterBlock();
876
+ }
877
+ quote(t) {
878
+ this.beforeBlock(), this.chooseChildren(t.content), this.afterBlock();
879
+ }
880
+ redacted(t) {
881
+ t.style == "block" ? this.beforeBlock() : this.beforeInline(), this.chooseChildren(t.content), t.style == "block" ? this.afterBlock() : this.afterInline();
882
+ }
883
+ region(t) {
884
+ this.beforeBlock(), this.chooseChildren(t.content), this.afterBlock();
885
+ }
886
+ script(t) {
887
+ }
888
+ secret(t) {
889
+ this.beforeInline(), this.chooseChildren(t.content), this.afterInline();
890
+ }
891
+ smaller(t) {
892
+ this.beforeInline(), this.chooseChildren(t.content), this.afterInline();
893
+ }
894
+ sticker(t) {
895
+ this.beforeBlock(), this.chooseChildren(t.content), this.afterBlock();
896
+ }
897
+ strikeThrough(t) {
898
+ this.beforeInline(), this.chooseChildren(t.content), this.afterInline();
899
+ }
900
+ text(t) {
901
+ }
902
+ table(t) {
903
+ for (const e of t.content)
904
+ for (const i of e)
905
+ this.beforeBlock(), this.chooseChildren(i.content), this.afterBlock();
906
+ }
907
+ social(t) {
908
+ }
909
+ underline(t) {
910
+ this.beforeInline(), this.chooseChildren(t.content), this.afterInline();
911
+ }
912
+ video(t) {
913
+ this.beforeBlock(), t.content && this.chooseChildren(t.content), this.afterBlock();
914
+ }
915
+ warning(t) {
916
+ this.beforeBlock(), this.chooseChildren(t.content), this.afterBlock();
917
+ }
918
+ card(t) {
919
+ if (t.content && (this.beforeBlock(), this.chooseChildren(t.content.content), this.afterBlock()), t.attribution && t.attribution.title && (this.beforeBlock(), this.chooseChildren(t.attribution.title), this.afterBlock()), t.header && (this.beforeBlock(), this.chooseChildren(t.header.title), this.afterBlock()), t.media)
920
+ for (const e of t.media.content)
921
+ this.beforeBlock(), this.choose(e), this.afterBlock();
922
+ }
923
+ date(t) {
924
+ this.beforeInline(), this.chooseChildren(t.content), this.afterInline();
925
+ }
926
+ time(t) {
927
+ this.beforeInline(), this.chooseChildren(t.content), this.afterInline();
928
+ }
929
+ datetime(t) {
930
+ this.beforeInline(), this.chooseChildren(t.content), this.afterInline();
931
+ }
932
+ subText(t) {
933
+ this.beforeInline(), this.chooseChildren(t.content), this.afterInline();
934
+ }
935
+ superText(t) {
936
+ this.beforeInline(), this.chooseChildren(t.content), this.afterInline();
937
+ }
938
+ toc(t) {
939
+ this.beforeBlock(), this.chooseChildren(t.content), this.afterBlock(), this.beforeBlock(), this.chooseChildren(t.children), this.afterBlock();
940
+ }
941
+ choose(t) {
942
+ if (!t || !t.type)
943
+ throw new Error(`Unexpected node, no type: ${JSON.stringify(t)}`);
944
+ try {
945
+ switch (t.type) {
946
+ case "block":
947
+ return this.block(t);
948
+ case "block-quote":
949
+ return this.blockQuote(t);
950
+ case "bold":
951
+ return this.bold(t);
952
+ case "break":
953
+ return this.break_(t);
954
+ case "bubble":
955
+ return this.bubble(t);
956
+ case "card":
957
+ return this.card(t);
958
+ case "center":
959
+ return this.center(t);
960
+ case "code":
961
+ return this.code(t);
962
+ case "columns":
963
+ return this.columns(t);
964
+ case "definition":
965
+ return this.definition(t);
966
+ case "definition-list":
967
+ return this.definitionList(t);
968
+ case "definition-reference":
969
+ return this.definitionReference(t);
970
+ case "embed":
971
+ return this.embed(t);
972
+ case "emoji":
973
+ return this.emoji(t);
974
+ case "figure":
975
+ return this.figure(t);
976
+ case "figure-caption":
977
+ return this.figureCaption(t);
978
+ case "figure-image":
979
+ return this.figureImage(t);
980
+ case "formatted-text":
981
+ return this.formattedText(t);
982
+ case "header":
983
+ return this.header(t);
984
+ case "high-tech-alert":
985
+ return this.highTechAlert(t);
986
+ case "horizontal-rule":
987
+ return this.horizontalRule(t);
988
+ case "image":
989
+ return this.image(t);
990
+ case "italic":
991
+ return this.italic(t);
992
+ case "link":
993
+ return this.link(t);
994
+ case "array":
995
+ return this.array(t);
996
+ case "note":
997
+ return this.note(t);
998
+ case "list":
999
+ return this.list(t);
1000
+ case "paragraph":
1001
+ return this.paragraph(t);
1002
+ case "quote":
1003
+ return this.quote(t);
1004
+ case "redacted":
1005
+ return this.redacted(t);
1006
+ case "region":
1007
+ return this.region(t);
1008
+ case "script":
1009
+ return this.script(t);
1010
+ case "secret":
1011
+ return this.secret(t);
1012
+ case "smaller":
1013
+ return this.smaller(t);
1014
+ case "sticker":
1015
+ return this.sticker(t);
1016
+ case "strike-through":
1017
+ return this.strikeThrough(t);
1018
+ case "table":
1019
+ return this.table(t);
1020
+ case "text":
1021
+ return this.text(t);
1022
+ case "toot":
1023
+ case "tweet":
1024
+ case "vimeo":
1025
+ case "youtube":
1026
+ return this.social(t);
1027
+ case "underline":
1028
+ return this.underline(t);
1029
+ case "video":
1030
+ return this.video(t);
1031
+ case "warning":
1032
+ return this.warning(t);
1033
+ case "date":
1034
+ return this.date(t);
1035
+ case "time":
1036
+ return this.time(t);
1037
+ case "datetime":
1038
+ return this.datetime(t);
1039
+ case "sub":
1040
+ return this.subText(t);
1041
+ case "super":
1042
+ return this.superText(t);
1043
+ case "toc":
1044
+ return this.toc(t);
1045
+ }
1046
+ } catch (e) {
1047
+ throw console.log(
1048
+ `Got exception while processing node: ${JSON.stringify(t)}`
1049
+ ), e;
1050
+ }
1051
+ console.error(`Unsupported type ${t.type}`);
1052
+ }
1053
+ document(t) {
1054
+ this.beforeBlock(), this.chooseChildren(t.content), this.afterBlock(), this.beforeBlock(), t.definitions && this.chooseChildren(t.definitions), this.afterBlock();
1055
+ }
1056
+ visit(t) {
1057
+ t.type == "document" ? this.document(t) : this.choose(t);
1058
+ }
1059
+ }
1060
+ class d extends w {
1061
+ constructor() {
1062
+ super();
1063
+ h(this, "textList");
1064
+ this.textList = [];
1065
+ }
1066
+ text(e) {
1067
+ this.textList.push(e.text), super.text(e);
1068
+ }
1069
+ video(e) {
1070
+ this.textList.push(e.alt), super.video(e);
1071
+ }
1072
+ image(e) {
1073
+ this.textList.push(e.alt), super.image(e);
1074
+ }
1075
+ emoji(e) {
1076
+ this.textList.push(e.alt), super.emoji(e);
1077
+ }
1078
+ figureImage(e) {
1079
+ this.textList.push(e.alt), super.figureImage(e);
1080
+ }
1081
+ definitionReference(e) {
1082
+ this.chooseChildren(e.content);
1083
+ }
1084
+ definition(e) {
1085
+ this.chooseChildren(e.title), this.textList.push(" ("), this.chooseChildren(e.abbreviation), this.textList.push("): "), this.chooseChildren(e.content);
1086
+ }
1087
+ toc(e) {
1088
+ e.date && (this.choose(e.date), this.textList.push(" ")), this.chooseChildren(e.content), this.textList.push(`
1089
+ `), this.chooseChildren(e.children);
1090
+ }
1091
+ getText() {
1092
+ return this.textList.join("");
1093
+ }
1094
+ }
1095
+ class B extends g {
1096
+ async sticker(t) {
1097
+ if (t.content.length == 0)
1098
+ return null;
1099
+ const e = await this.chooseChildren(t.content);
1100
+ return e ? {
1101
+ type: "paragraph",
1102
+ content: e
1103
+ } : null;
1104
+ }
1105
+ async bubble(t) {
1106
+ if (t.content.length == 0)
1107
+ return null;
1108
+ const e = await this.chooseChildren(t.content);
1109
+ return e ? {
1110
+ type: "paragraph",
1111
+ content: e
1112
+ } : null;
1113
+ }
1114
+ async highTechAlert(t) {
1115
+ if (t.content.length == 0)
1116
+ return null;
1117
+ const e = await this.chooseChildren(t.content);
1118
+ return e ? {
1119
+ type: "array",
1120
+ content: e
1121
+ } : null;
1122
+ }
1123
+ async columns(t) {
1124
+ const e = t.columns.flat();
1125
+ if (e.length == 0)
1126
+ return null;
1127
+ const i = await this.chooseChildren(e);
1128
+ return i ? {
1129
+ type: "array",
1130
+ content: i
1131
+ } : null;
1132
+ }
1133
+ async quote(t) {
1134
+ if (t.content.length == 0)
1135
+ return null;
1136
+ const e = await this.chooseChildren(t.content);
1137
+ return e ? {
1138
+ type: "array",
1139
+ content: e
1140
+ } : null;
1141
+ }
1142
+ image(t) {
1143
+ return Promise.resolve({
1144
+ type: "paragraph",
1145
+ content: [{
1146
+ type: "text",
1147
+ text: "inline image: "
1148
+ }, {
1149
+ type: "text",
1150
+ text: t.alt
1151
+ }]
1152
+ });
1153
+ }
1154
+ async figureImage(t) {
1155
+ const e = {
1156
+ type: "paragraph",
1157
+ content: [{
1158
+ type: "text",
1159
+ text: "inline image: "
1160
+ }, {
1161
+ type: "text",
1162
+ text: t.alt
1163
+ }]
1164
+ };
1165
+ if (t.content) {
1166
+ const i = await this.chooseChildren(t.content);
1167
+ return {
1168
+ type: "array",
1169
+ content: [
1170
+ e,
1171
+ ...i
1172
+ ]
1173
+ };
1174
+ } else
1175
+ return e;
1176
+ }
1177
+ async video(t) {
1178
+ const e = {
1179
+ type: "paragraph",
1180
+ content: [{
1181
+ type: "text",
1182
+ text: "inline video: "
1183
+ }, {
1184
+ type: "text",
1185
+ text: t.alt
1186
+ }]
1187
+ };
1188
+ if (t.content) {
1189
+ const i = await this.chooseChildren(t.content);
1190
+ return {
1191
+ type: "array",
1192
+ content: [
1193
+ e,
1194
+ ...i
1195
+ ]
1196
+ };
1197
+ } else
1198
+ return e;
1199
+ }
1200
+ async definitionList(t) {
1201
+ const e = [];
1202
+ for (const i of t.content) {
1203
+ const r = [], s = await this.chooseChildren(i.title);
1204
+ if (s)
1205
+ for (const a of s)
1206
+ r.push(a);
1207
+ r.push({ type: "text", text: " " });
1208
+ const n = await this.chooseChildren(i.abbreviation);
1209
+ if (n)
1210
+ for (const a of n)
1211
+ r.push(a);
1212
+ if (i.content.length > 0 && i.content[0].type != "paragraph") {
1213
+ r.push({ type: "text", text: " " });
1214
+ const a = await this.chooseChildren(i.content);
1215
+ if (a)
1216
+ for (const o of a)
1217
+ r.push(o);
1218
+ }
1219
+ if (e.push({
1220
+ type: "paragraph",
1221
+ content: r
1222
+ }), i.content.length > 0 && i.content[0].type == "paragraph") {
1223
+ const a = await this.chooseChildren(i.content);
1224
+ if (a)
1225
+ for (const o of a)
1226
+ e.push(o);
1227
+ }
1228
+ }
1229
+ return {
1230
+ type: "array",
1231
+ content: e
1232
+ };
1233
+ }
1234
+ async redacted(t) {
1235
+ return null;
1236
+ }
1237
+ async note(t) {
1238
+ if (t.content.length == 0)
1239
+ return null;
1240
+ const e = await this.chooseChildren(t.content);
1241
+ return e ? {
1242
+ type: "paragraph",
1243
+ content: [
1244
+ { type: "text", text: "Note: " },
1245
+ ...e
1246
+ ]
1247
+ } : null;
1248
+ }
1249
+ async card(t) {
1250
+ const e = [];
1251
+ if (t.header) {
1252
+ const i = await this.chooseChildren(t.header.title);
1253
+ i.length > 0 && e.push({
1254
+ type: "paragraph",
1255
+ content: i
1256
+ });
1257
+ }
1258
+ if (t.content) {
1259
+ const i = await this.chooseChildren(t.content.content);
1260
+ for (const r of i)
1261
+ e.push(r);
1262
+ }
1263
+ if (t.media)
1264
+ for (const i of t.media.content) {
1265
+ const r = await this.choose(i);
1266
+ r && e.push(r);
1267
+ }
1268
+ if (t.attribution) {
1269
+ const i = [];
1270
+ if (t.attribution.title) {
1271
+ const r = await this.chooseChildren(t.attribution.title);
1272
+ for (const s of r)
1273
+ e.push(s);
1274
+ }
1275
+ t.attribution.date && (e.length > 0 && e.push({ type: "text", text: " " }), e.push({ type: "text", text: `${t.attribution.date}` })), i.length > 0 && e.push({
1276
+ type: "paragraph",
1277
+ content: i
1278
+ });
1279
+ }
1280
+ return {
1281
+ type: "array",
1282
+ content: e
1283
+ };
1284
+ }
1285
+ }
1286
+ class x extends w {
1287
+ constructor() {
1288
+ super();
1289
+ h(this, "count");
1290
+ h(this, "texts");
1291
+ this.count = 0, this.texts = [];
1292
+ }
1293
+ countText() {
1294
+ this.texts.length > 0 && (this.count += this.texts.join("").split(" ").length, this.texts = []);
1295
+ }
1296
+ beforeBlock() {
1297
+ this.countText();
1298
+ }
1299
+ afterBlock() {
1300
+ this.countText();
1301
+ }
1302
+ text(e) {
1303
+ this.texts.push(e.text);
1304
+ }
1305
+ document(e) {
1306
+ super.document(e), this.countText();
1307
+ }
1308
+ getCount() {
1309
+ return this.countText(), this.count;
1310
+ }
1311
+ }
1312
+ function b(c) {
1313
+ const t = {
1314
+ headerText: c.header,
1315
+ headerId: c.headerId,
1316
+ words: 0,
1317
+ totalWords: 0,
1318
+ children: []
1319
+ }, e = new x();
1320
+ for (const i of c.nodes)
1321
+ e.visit(i);
1322
+ t.words = e.getCount(), t.totalWords = t.words;
1323
+ for (const i of c.children) {
1324
+ const r = b(i);
1325
+ t.children.push(r), t.totalWords += r.totalWords;
1326
+ }
1327
+ return t;
1328
+ }
1329
+ class L extends l {
1330
+ constructor() {
1331
+ super();
1332
+ }
1333
+ async transform(t) {
1334
+ const e = JSON.parse(JSON.stringify(t)), i = await new B().transform(e), r = [], s = {
1335
+ header: t.title,
1336
+ headerId: "title",
1337
+ nodes: [],
1338
+ children: [],
1339
+ depth: 1
1340
+ };
1341
+ r.push(s);
1342
+ let n = 1;
1343
+ for (const o of i.content)
1344
+ if (o.type == "header") {
1345
+ if (o.level == 1)
1346
+ continue;
1347
+ if (o.level <= n)
1348
+ for (let u = r.length - 1; u > 0; u--)
1349
+ r[u].depth >= o.level && r.pop();
1350
+ const p = new d();
1351
+ p.visit(o);
1352
+ const f = {
1353
+ header: p.getText(),
1354
+ depth: o.level,
1355
+ children: [],
1356
+ nodes: []
1357
+ };
1358
+ o.htmlId && (f.headerId = o.htmlId), r[r.length - 1].children.push(f), r.push(f), n = o.level;
1359
+ } else
1360
+ r[r.length - 1].nodes.push(o);
1361
+ const a = {
1362
+ ...t
1363
+ };
1364
+ return a.hierarchy = b(s), a;
1365
+ }
1366
+ }
1367
+ export {
1368
+ g as ArrayCollapseTransformer,
1369
+ B as DocumentThinningTransformer,
1370
+ l as IdentityTransformer,
1371
+ w as NodeVisitor,
1372
+ I as TextCollapseTransformer,
1373
+ d as TextVisitor,
1374
+ v as WhitespaceStretchingTransformer,
1375
+ T as WhitespaceTransformer,
1376
+ L as WordCounterTransformer,
1377
+ x as WordCounterVisitor
1378
+ };