@vectojs/markdown 0.16.0 → 0.17.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.
package/dist/index.js CHANGED
@@ -35,6 +35,7 @@ __export(index_exports, {
35
35
  CodeBlock: () => CodeBlock,
36
36
  Markdown: () => Markdown,
37
37
  MathBlock: () => MathBlock,
38
+ PRESET_THEMES: () => PRESET_THEMES,
38
39
  codeAtlas: () => codeAtlas,
39
40
  codeAtlasStats: () => codeAtlasStats,
40
41
  escapeCsvField: () => escapeCsvField,
@@ -42,9 +43,11 @@ __export(index_exports, {
42
43
  extensionForLanguage: () => extensionForLanguage,
43
44
  footnoteMarker: () => footnoteMarker,
44
45
  isMathJaxReady: () => isMathJaxReady,
46
+ isPresetName: () => isPresetName,
45
47
  mimeForLanguage: () => mimeForLanguage,
46
48
  parseFrontMatterFields: () => parseFrontMatterFields,
47
49
  preloadMathJax: () => preloadMathJax,
50
+ resolvePresetTheme: () => resolvePresetTheme,
48
51
  scanFrontMatter: () => scanFrontMatter,
49
52
  tableContentOf: () => tableContentOf,
50
53
  tableToCsv: () => tableToCsv,
@@ -509,6 +512,59 @@ var MarkdownContainer = class extends import_core.Entity {
509
512
  render(_r) {
510
513
  }
511
514
  };
515
+ var ContainerBackground = class extends import_core.Entity {
516
+ color;
517
+ radius;
518
+ constructor(w, h, color, radius) {
519
+ super();
520
+ this.width = w;
521
+ this.height = h;
522
+ this.color = color;
523
+ this.radius = radius;
524
+ }
525
+ isPointInside() {
526
+ return false;
527
+ }
528
+ render(r) {
529
+ r.beginPath();
530
+ r.roundRect(0, 0, this.width, this.height, this.radius);
531
+ r.fill(this.color);
532
+ }
533
+ };
534
+
535
+ // src/markdown-abbr.ts
536
+ var DEF_RE = /^ {0,3}\*\[([^\]\n]+)\]:[ \t]*([^\n]*)(?:\n|$)/;
537
+ var ABBR_EXTENSIONS = [
538
+ {
539
+ name: "abbrDef",
540
+ level: "block",
541
+ tokenizer(src) {
542
+ const match = DEF_RE.exec(src);
543
+ if (match) {
544
+ return {
545
+ type: "abbrDef",
546
+ raw: match[0],
547
+ term: match[1],
548
+ definition: match[2]
549
+ };
550
+ }
551
+ return void 0;
552
+ },
553
+ renderer(token) {
554
+ return token.raw;
555
+ }
556
+ }
557
+ ];
558
+ function collectAbbreviations(tokens) {
559
+ const map = /* @__PURE__ */ new Map();
560
+ for (const token of tokens) {
561
+ if (token.type === "abbrDef") {
562
+ const t = token;
563
+ map.set(t.term, t.definition);
564
+ }
565
+ }
566
+ return map;
567
+ }
512
568
 
513
569
  // src/markdown-code.ts
514
570
  var import_core2 = require("@vectojs/core");
@@ -516,6 +572,7 @@ var import_ui = require("@vectojs/ui");
516
572
 
517
573
  // src/theme.ts
518
574
  var DEFAULT_THEME = {
575
+ typographer: false,
519
576
  textColor: "#e2e8f0",
520
577
  headingColor: "#f8fafc",
521
578
  codeColor: "#a5f3fc",
@@ -528,6 +585,17 @@ var DEFAULT_THEME = {
528
585
  linkColor: "#38bdf8",
529
586
  footnoteColor: "#38bdf8",
530
587
  mathFallbackColor: "#fcd34d",
588
+ markHighlightColor: "rgba(250, 204, 21, 0.35)",
589
+ containerColors: {
590
+ note: "#38bdf8",
591
+ info: "#38bdf8",
592
+ tip: "#4ade80",
593
+ warning: "#fbbf24",
594
+ danger: "#f87171",
595
+ caution: "#f87171"
596
+ },
597
+ containerDefaultColor: "#94a3b8",
598
+ containerBgColor: "rgba(148, 163, 184, 0.08)",
531
599
  syntaxKeywordColor: "#c084fc",
532
600
  syntaxStringColor: "#86efac",
533
601
  syntaxCommentColor: "#64748b",
@@ -539,6 +607,10 @@ var DEFAULT_THEME = {
539
607
  codeFontSize: 15,
540
608
  tableFontSize: 14,
541
609
  footnoteMarkerScale: 0.75,
610
+ subscriptScale: 0.75,
611
+ subscriptShift: -0.15,
612
+ superscriptScale: 0.75,
613
+ superscriptShift: 0.2,
542
614
  codeLineHeight: 24,
543
615
  bodyLineHeight: 24,
544
616
  blockGap: 16,
@@ -549,6 +621,10 @@ var DEFAULT_THEME = {
549
621
  quoteIndent: 16,
550
622
  quoteBorderWidth: 4,
551
623
  quoteInnerGap: 8,
624
+ containerIndent: 16,
625
+ containerBorderWidth: 4,
626
+ containerInnerGap: 8,
627
+ containerRadius: 8,
552
628
  imageRadius: 8,
553
629
  inlineImageScale: 1.15
554
630
  };
@@ -571,6 +647,171 @@ function headingSize(theme, depth) {
571
647
  const idx = Math.min(Math.max(depth, 1) - 1, sizes.length - 1);
572
648
  return sizes[idx] ?? theme.fontSize;
573
649
  }
650
+ function containerColor(theme, kind) {
651
+ if (kind === void 0) return theme.containerDefaultColor;
652
+ return theme.containerColors[kind.toLowerCase()] ?? theme.containerDefaultColor;
653
+ }
654
+
655
+ // src/markdown-presets.ts
656
+ var GITHUB_DARK = {
657
+ textColor: "#e6edf3",
658
+ headingColor: "#e6edf3",
659
+ codeColor: "#a5d6ff",
660
+ // Solid dark panel — not a translucent overlay since the canvas bg is dark.
661
+ codeBgColor: "#161b22",
662
+ quoteBorderColor: "#30363d",
663
+ hrColor: "#30363d",
664
+ tableBgColor: "#010409",
665
+ tableHeaderBgColor: "#161b22",
666
+ linkColor: "#58a6ff",
667
+ mathFallbackColor: "#e3b341",
668
+ markHighlightColor: "rgba(187, 128, 9, 0.4)",
669
+ containerColors: {
670
+ note: "#58a6ff",
671
+ info: "#58a6ff",
672
+ tip: "#3fb950",
673
+ warning: "#d29922",
674
+ danger: "#f85149",
675
+ caution: "#f85149"
676
+ },
677
+ containerDefaultColor: "#8b949e",
678
+ containerBgColor: "rgba(139, 148, 158, 0.08)",
679
+ // GitHub Dark Default syntax (Primer primitives / rouge github dark palette):
680
+ // keyword = P_RED_3 #ff7b72, string = P_BLUE_1 #a5d6ff,
681
+ // comment = P_GRAY_3 #8b949e, number = P_BLUE_2 #79c0ff.
682
+ syntaxKeywordColor: "#ff7b72",
683
+ syntaxStringColor: "#a5d6ff",
684
+ syntaxCommentColor: "#8b949e",
685
+ syntaxNumberColor: "#79c0ff"
686
+ };
687
+ var GITHUB_LIGHT = {
688
+ textColor: "#1f2328",
689
+ headingColor: "#1f2328",
690
+ codeColor: "#0550ae",
691
+ codeBgColor: "#f6f8fa",
692
+ quoteBorderColor: "#0969da",
693
+ hrColor: "#d0d7de",
694
+ tableBgColor: "#ffffff",
695
+ tableHeaderBgColor: "#eaeef2",
696
+ linkColor: "#0969da",
697
+ mathFallbackColor: "#9a6700",
698
+ markHighlightColor: "rgba(210, 153, 34, 0.25)",
699
+ containerColors: {
700
+ note: "#0969da",
701
+ info: "#0969da",
702
+ tip: "#1a7f37",
703
+ warning: "#9a6700",
704
+ danger: "#cf222e",
705
+ caution: "#cf222e"
706
+ },
707
+ containerDefaultColor: "#59636e",
708
+ containerBgColor: "rgba(208, 215, 222, 0.2)",
709
+ // GitHub Light Default syntax (Primer primitives / rouge github light palette):
710
+ // keyword = P_RED_5 #cf222e, string = P_BLUE_8 #0a3069,
711
+ // comment = P_GRAY_5 #6e7781, number = P_BLUE_6 #0550ae.
712
+ syntaxKeywordColor: "#cf222e",
713
+ syntaxStringColor: "#0a3069",
714
+ syntaxCommentColor: "#6e7781",
715
+ syntaxNumberColor: "#0550ae"
716
+ };
717
+ var DRACULA = {
718
+ textColor: "#f8f8f2",
719
+ headingColor: "#bd93f9",
720
+ codeColor: "#50fa7b",
721
+ codeBgColor: "#282a36",
722
+ quoteBorderColor: "#6272a4",
723
+ hrColor: "rgba(98, 114, 164, 0.4)",
724
+ tableBgColor: "rgba(40, 42, 54, 0.6)",
725
+ tableHeaderBgColor: "rgba(68, 71, 90, 0.5)",
726
+ linkColor: "#8be9fd",
727
+ mathFallbackColor: "#ffb86c",
728
+ markHighlightColor: "rgba(241, 250, 140, 0.3)",
729
+ containerColors: {
730
+ note: "#8be9fd",
731
+ info: "#8be9fd",
732
+ tip: "#50fa7b",
733
+ warning: "#ffb86c",
734
+ danger: "#ff5555",
735
+ caution: "#ff5555"
736
+ },
737
+ containerDefaultColor: "#6272a4",
738
+ containerBgColor: "rgba(98, 114, 164, 0.1)",
739
+ // Dracula syntax: keywords=Pink (#ff79c6), strings=Yellow (#f1fa8c),
740
+ // comments=Comment (#6272a4), numbers/constants=Orange (#ffb86c).
741
+ syntaxKeywordColor: "#ff79c6",
742
+ syntaxStringColor: "#f1fa8c",
743
+ syntaxCommentColor: "#6272a4",
744
+ syntaxNumberColor: "#ffb86c"
745
+ };
746
+ var SOLARIZED_DARK = {
747
+ textColor: "#839496",
748
+ headingColor: "#93a1a1",
749
+ codeColor: "#2aa198",
750
+ codeBgColor: "#073642",
751
+ quoteBorderColor: "#6c71c4",
752
+ hrColor: "rgba(88, 110, 117, 0.4)",
753
+ tableBgColor: "rgba(0, 43, 54, 0.6)",
754
+ tableHeaderBgColor: "rgba(7, 54, 66, 0.8)",
755
+ linkColor: "#268bd2",
756
+ mathFallbackColor: "#b58900",
757
+ markHighlightColor: "rgba(181, 137, 0, 0.3)",
758
+ containerColors: {
759
+ note: "#268bd2",
760
+ info: "#268bd2",
761
+ tip: "#859900",
762
+ warning: "#b58900",
763
+ danger: "#dc322f",
764
+ caution: "#dc322f"
765
+ },
766
+ containerDefaultColor: "#586e75",
767
+ containerBgColor: "rgba(88, 110, 117, 0.1)",
768
+ syntaxKeywordColor: "#859900",
769
+ syntaxStringColor: "#2aa198",
770
+ syntaxCommentColor: "#586e75",
771
+ syntaxNumberColor: "#b58900"
772
+ };
773
+ var SOLARIZED_LIGHT = {
774
+ textColor: "#657b83",
775
+ headingColor: "#586e75",
776
+ codeColor: "#2aa198",
777
+ codeBgColor: "#eee8d5",
778
+ quoteBorderColor: "#6c71c4",
779
+ hrColor: "rgba(147, 161, 161, 0.5)",
780
+ tableBgColor: "#fdf6e3",
781
+ tableHeaderBgColor: "#e0dac9",
782
+ linkColor: "#268bd2",
783
+ mathFallbackColor: "#cb4b16",
784
+ markHighlightColor: "rgba(181, 137, 0, 0.2)",
785
+ containerColors: {
786
+ note: "#268bd2",
787
+ info: "#268bd2",
788
+ tip: "#859900",
789
+ warning: "#b58900",
790
+ danger: "#dc322f",
791
+ caution: "#dc322f"
792
+ },
793
+ containerDefaultColor: "#93a1a1",
794
+ containerBgColor: "rgba(147, 161, 161, 0.15)",
795
+ // Syntax accent colors are identical in light and dark Solarized.
796
+ syntaxKeywordColor: "#859900",
797
+ syntaxStringColor: "#2aa198",
798
+ syntaxCommentColor: "#93a1a1",
799
+ syntaxNumberColor: "#b58900"
800
+ };
801
+ var PRESET_THEMES = {
802
+ githubDark: GITHUB_DARK,
803
+ githubLight: GITHUB_LIGHT,
804
+ dracula: DRACULA,
805
+ solarizedDark: SOLARIZED_DARK,
806
+ solarizedLight: SOLARIZED_LIGHT
807
+ };
808
+ function isPresetName(value) {
809
+ return typeof value === "string" && Object.prototype.hasOwnProperty.call(PRESET_THEMES, value);
810
+ }
811
+ function resolvePresetTheme(theme) {
812
+ if (isPresetName(theme)) return resolveTheme(PRESET_THEMES[theme]);
813
+ return resolveTheme(theme);
814
+ }
574
815
 
575
816
  // src/markdown-code.ts
576
817
  var KEYWORD_SETS = {
@@ -843,16 +1084,19 @@ var CodeBlock = class extends import_ui.UIComponent {
843
1084
  codeFont;
844
1085
  selectable;
845
1086
  /**
846
- * @param theme Any subset of {@link MarkdownTheme}; missing keys fall back to
847
- * `DEFAULT_THEME` in `./theme`. Accepting a partial theme keeps callers that were
848
- * written against an earlier, smaller `MarkdownTheme` working — this class
849
- * is public API, and a hand-built theme literal would otherwise start
850
- * throwing `lineHeight must be a positive finite number` the moment a new
851
- * size key was added.
1087
+ * @param theme Any subset of {@link MarkdownTheme}, or the name of a built-in
1088
+ * preset (see {@link MarkdownThemePresetName}). Accepting a partial theme
1089
+ * keeps callers that were written against an earlier, smaller
1090
+ * `MarkdownTheme` working — this class is public API, and a hand-built
1091
+ * theme literal would otherwise start throwing
1092
+ * `lineHeight must be a positive finite number` the moment a new size key
1093
+ * was added. Resolved through {@link resolvePresetTheme} so `CodeBlock` can
1094
+ * be constructed directly with a preset name without going through
1095
+ * `Markdown`.
852
1096
  */
853
1097
  constructor(code, lang, maxWidth, theme, selectable = true) {
854
1098
  super();
855
- const resolved = resolveTheme(theme);
1099
+ const resolved = resolvePresetTheme(theme);
856
1100
  this.source = code;
857
1101
  this.lang = lang;
858
1102
  this.theme = resolved;
@@ -1069,10 +1313,295 @@ function codeAtlas() {
1069
1313
  return lastCodeAtlas;
1070
1314
  }
1071
1315
 
1316
+ // src/markdown-container.ts
1317
+ var OPEN_RE = /^ {0,3}:::([A-Za-z][\w-]*)?[ \t]*(?:\n|$)/;
1318
+ var FENCE_LINE_RE = /^ {0,3}:::([A-Za-z][\w-]*)?[ \t]*$/;
1319
+ function findBodyEnd(text) {
1320
+ let depth = 1;
1321
+ let offset = 0;
1322
+ while (offset < text.length) {
1323
+ const lineEnd = text.indexOf("\n", offset);
1324
+ const line = lineEnd === -1 ? text.slice(offset) : text.slice(offset, lineEnd);
1325
+ const match = FENCE_LINE_RE.exec(line);
1326
+ if (match) {
1327
+ if (match[1] !== void 0) {
1328
+ depth++;
1329
+ } else {
1330
+ depth--;
1331
+ if (depth === 0) return offset;
1332
+ }
1333
+ }
1334
+ if (lineEnd === -1) break;
1335
+ offset = lineEnd + 1;
1336
+ }
1337
+ return -1;
1338
+ }
1339
+ var CONTAINER_EXTENSIONS = [
1340
+ {
1341
+ name: "container",
1342
+ level: "block",
1343
+ tokenizer(src) {
1344
+ const open = OPEN_RE.exec(src);
1345
+ if (!open) return void 0;
1346
+ const afterOpen = src.slice(open[0].length);
1347
+ const bodyEnd = findBodyEnd(afterOpen);
1348
+ if (bodyEnd < 0) return void 0;
1349
+ const body = afterOpen.slice(0, bodyEnd);
1350
+ const closeLineEnd = afterOpen.indexOf("\n", bodyEnd);
1351
+ const closeEnd = closeLineEnd === -1 ? afterOpen.length : closeLineEnd + 1;
1352
+ const raw = open[0] + afterOpen.slice(0, closeEnd);
1353
+ const tokens = this.lexer.blockTokens(body, []);
1354
+ return {
1355
+ type: "container",
1356
+ raw,
1357
+ kind: open[1],
1358
+ tokens
1359
+ };
1360
+ },
1361
+ renderer(token) {
1362
+ return token.raw;
1363
+ }
1364
+ }
1365
+ ];
1366
+
1367
+ // src/markdown-emoji.ts
1368
+ var EMOJI_MAP = Object.freeze({
1369
+ // Smileys
1370
+ grinning: "\u{1F600}",
1371
+ smiley: "\u{1F603}",
1372
+ smile: "\u{1F604}",
1373
+ grin: "\u{1F601}",
1374
+ laughing: "\u{1F606}",
1375
+ satisfied: "\u{1F606}",
1376
+ sweat_smile: "\u{1F605}",
1377
+ rofl: "\u{1F923}",
1378
+ joy: "\u{1F602}",
1379
+ slightly_smiling_face: "\u{1F642}",
1380
+ upside_down_face: "\u{1F643}",
1381
+ wink: "\u{1F609}",
1382
+ blush: "\u{1F60A}",
1383
+ innocent: "\u{1F607}",
1384
+ heart_eyes: "\u{1F60D}",
1385
+ star_struck: "\u{1F929}",
1386
+ kissing_heart: "\u{1F618}",
1387
+ yum: "\u{1F60B}",
1388
+ stuck_out_tongue: "\u{1F61B}",
1389
+ stuck_out_tongue_winking_eye: "\u{1F61C}",
1390
+ stuck_out_tongue_closed_eyes: "\u{1F61D}",
1391
+ hugs: "\u{1F917}",
1392
+ thinking: "\u{1F914}",
1393
+ neutral_face: "\u{1F610}",
1394
+ expressionless: "\u{1F611}",
1395
+ no_mouth: "\u{1F636}",
1396
+ smirk: "\u{1F60F}",
1397
+ unamused: "\u{1F612}",
1398
+ roll_eyes: "\u{1F644}",
1399
+ grimacing: "\u{1F62C}",
1400
+ relieved: "\u{1F60C}",
1401
+ pensive: "\u{1F614}",
1402
+ sleepy: "\u{1F62A}",
1403
+ sleeping: "\u{1F634}",
1404
+ mask: "\u{1F637}",
1405
+ dizzy_face: "\u{1F635}",
1406
+ sunglasses: "\u{1F60E}",
1407
+ nerd_face: "\u{1F913}",
1408
+ confused: "\u{1F615}",
1409
+ worried: "\u{1F61F}",
1410
+ open_mouth: "\u{1F62E}",
1411
+ hushed: "\u{1F62F}",
1412
+ astonished: "\u{1F632}",
1413
+ flushed: "\u{1F633}",
1414
+ pleading_face: "\u{1F97A}",
1415
+ fearful: "\u{1F628}",
1416
+ cold_sweat: "\u{1F630}",
1417
+ cry: "\u{1F622}",
1418
+ sob: "\u{1F62D}",
1419
+ scream: "\u{1F631}",
1420
+ disappointed: "\u{1F61E}",
1421
+ sweat: "\u{1F613}",
1422
+ weary: "\u{1F629}",
1423
+ tired_face: "\u{1F62B}",
1424
+ triumph: "\u{1F624}",
1425
+ rage: "\u{1F621}",
1426
+ angry: "\u{1F620}",
1427
+ smiling_imp: "\u{1F608}",
1428
+ imp: "\u{1F47F}",
1429
+ skull: "\u{1F480}",
1430
+ clown_face: "\u{1F921}",
1431
+ poop: "\u{1F4A9}",
1432
+ ghost: "\u{1F47B}",
1433
+ alien: "\u{1F47D}",
1434
+ robot: "\u{1F916}",
1435
+ // Gestures / body
1436
+ thumbsup: "\u{1F44D}",
1437
+ "+1": "\u{1F44D}",
1438
+ thumbsdown: "\u{1F44E}",
1439
+ "-1": "\u{1F44E}",
1440
+ punch: "\u{1F44A}",
1441
+ fist: "\u270A",
1442
+ clap: "\u{1F44F}",
1443
+ raised_hands: "\u{1F64C}",
1444
+ open_hands: "\u{1F450}",
1445
+ handshake: "\u{1F91D}",
1446
+ pray: "\u{1F64F}",
1447
+ muscle: "\u{1F4AA}",
1448
+ eyes: "\u{1F440}",
1449
+ wave: "\u{1F44B}",
1450
+ point_up: "\u261D\uFE0F",
1451
+ point_down: "\u{1F447}",
1452
+ point_left: "\u{1F448}",
1453
+ point_right: "\u{1F449}",
1454
+ ok_hand: "\u{1F44C}",
1455
+ v: "\u270C\uFE0F",
1456
+ crossed_fingers: "\u{1F91E}",
1457
+ // Hearts / symbols
1458
+ heart: "\u2764\uFE0F",
1459
+ broken_heart: "\u{1F494}",
1460
+ two_hearts: "\u{1F495}",
1461
+ sparkling_heart: "\u{1F496}",
1462
+ heartpulse: "\u{1F497}",
1463
+ blue_heart: "\u{1F499}",
1464
+ green_heart: "\u{1F49A}",
1465
+ yellow_heart: "\u{1F49B}",
1466
+ orange_heart: "\u{1F9E1}",
1467
+ purple_heart: "\u{1F49C}",
1468
+ black_heart: "\u{1F5A4}",
1469
+ white_heart: "\u{1F90D}",
1470
+ 100: "\u{1F4AF}",
1471
+ boom: "\u{1F4A5}",
1472
+ collision: "\u{1F4A5}",
1473
+ dizzy: "\u{1F4AB}",
1474
+ sweat_drops: "\u{1F4A6}",
1475
+ dash: "\u{1F4A8}",
1476
+ zzz: "\u{1F4A4}",
1477
+ fire: "\u{1F525}",
1478
+ sparkles: "\u2728",
1479
+ star: "\u2B50",
1480
+ star2: "\u{1F31F}",
1481
+ tada: "\u{1F389}",
1482
+ confetti_ball: "\u{1F38A}",
1483
+ balloon: "\u{1F388}",
1484
+ gift: "\u{1F381}",
1485
+ rocket: "\u{1F680}",
1486
+ dart: "\u{1F3AF}",
1487
+ trophy: "\u{1F3C6}",
1488
+ warning: "\u26A0\uFE0F",
1489
+ no_entry_sign: "\u{1F6AB}",
1490
+ white_check_mark: "\u2705",
1491
+ x: "\u274C",
1492
+ heavy_check_mark: "\u2714\uFE0F",
1493
+ question: "\u2753",
1494
+ exclamation: "\u2757",
1495
+ bulb: "\u{1F4A1}",
1496
+ bell: "\u{1F514}",
1497
+ // Tech / objects
1498
+ computer: "\u{1F4BB}",
1499
+ iphone: "\u{1F4F1}",
1500
+ link: "\u{1F517}",
1501
+ lock: "\u{1F512}",
1502
+ unlock: "\u{1F513}",
1503
+ key: "\u{1F511}",
1504
+ mag: "\u{1F50D}",
1505
+ bug: "\u{1F41B}",
1506
+ package: "\u{1F4E6}",
1507
+ memo: "\u{1F4DD}",
1508
+ pencil2: "\u270F\uFE0F",
1509
+ book: "\u{1F4D6}",
1510
+ books: "\u{1F4DA}",
1511
+ pushpin: "\u{1F4CC}",
1512
+ paperclip: "\u{1F4CE}",
1513
+ calendar: "\u{1F4C5}",
1514
+ file_folder: "\u{1F4C1}",
1515
+ hammer: "\u{1F528}",
1516
+ wrench: "\u{1F527}",
1517
+ gear: "\u2699\uFE0F",
1518
+ chart_with_upwards_trend: "\u{1F4C8}",
1519
+ chart_with_downwards_trend: "\u{1F4C9}",
1520
+ bar_chart: "\u{1F4CA}",
1521
+ construction: "\u{1F6A7}",
1522
+ hourglass: "\u23F3",
1523
+ stopwatch: "\u23F1\uFE0F",
1524
+ // Food / nature / misc
1525
+ pizza: "\u{1F355}",
1526
+ coffee: "\u2615",
1527
+ beer: "\u{1F37A}",
1528
+ cake: "\u{1F382}",
1529
+ birthday: "\u{1F382}",
1530
+ apple: "\u{1F34E}",
1531
+ rainbow: "\u{1F308}",
1532
+ sun_with_face: "\u{1F31E}",
1533
+ crescent_moon: "\u{1F319}",
1534
+ earth_americas: "\u{1F30E}",
1535
+ dog: "\u{1F436}",
1536
+ cat: "\u{1F431}",
1537
+ fox_face: "\u{1F98A}",
1538
+ bear: "\u{1F43B}",
1539
+ panda_face: "\u{1F43C}",
1540
+ monkey_face: "\u{1F435}",
1541
+ see_no_evil: "\u{1F648}",
1542
+ hear_no_evil: "\u{1F649}",
1543
+ speak_no_evil: "\u{1F64A}"
1544
+ });
1545
+ var EMOJI_RE = /^:([A-Za-z0-9_+-]+):/;
1546
+ var EMOJI_EXTENSIONS = [
1547
+ {
1548
+ name: "emoji",
1549
+ level: "inline",
1550
+ // Without `start()`, marked's plain-text fallback tokenizer (`inlineText`)
1551
+ // never stops at `:` — see `markdown-superscript.ts`'s identical note for
1552
+ // `^`, which applies here verbatim.
1553
+ start(src) {
1554
+ return src.match(/:/)?.index;
1555
+ },
1556
+ tokenizer(src) {
1557
+ const match = EMOJI_RE.exec(src);
1558
+ if (!match) return void 0;
1559
+ const resolved = EMOJI_MAP[match[1]];
1560
+ if (resolved === void 0) return void 0;
1561
+ return {
1562
+ type: "emoji",
1563
+ raw: match[0],
1564
+ text: resolved
1565
+ };
1566
+ },
1567
+ renderer(token) {
1568
+ return token.raw;
1569
+ }
1570
+ }
1571
+ ];
1572
+
1072
1573
  // src/markdown-footnote.ts
1073
1574
  var LABEL = "([^\\]\\s]+)";
1074
1575
  var REF_RE = new RegExp(`^\\[\\^${LABEL}\\]`);
1075
- var DEF_RE = new RegExp(`^ {0,3}\\[\\^${LABEL}\\]:[ \\t]*([^\\n]*)(?:\\n|$)`);
1576
+ var HEADER_RE = new RegExp(`^ {0,3}\\[\\^${LABEL}\\]:[ \\t]*([^\\n]*)\\n?`);
1577
+ function isBlankLine(line) {
1578
+ return /^[ \t]*$/.test(line);
1579
+ }
1580
+ var CONT_LINE_RE = /^(?: {4}| {0,3}\t)/;
1581
+ function consumeContinuation(rest) {
1582
+ let offset = 0;
1583
+ for (; ; ) {
1584
+ let probe = offset;
1585
+ for (; ; ) {
1586
+ const lineEnd2 = rest.indexOf("\n", probe);
1587
+ if (lineEnd2 === -1) return finalize(offset, true);
1588
+ const line2 = rest.slice(probe, lineEnd2);
1589
+ if (!isBlankLine(line2)) break;
1590
+ probe = lineEnd2 + 1;
1591
+ }
1592
+ const lineEnd = rest.indexOf("\n", probe);
1593
+ const lineWithNl = lineEnd === -1 ? rest.slice(probe) : rest.slice(probe, lineEnd + 1);
1594
+ const line = lineEnd === -1 ? rest.slice(probe) : rest.slice(probe, lineEnd);
1595
+ if (!CONT_LINE_RE.test(line)) return finalize(offset, false);
1596
+ offset = probe + lineWithNl.length;
1597
+ if (lineEnd === -1) return finalize(offset, true);
1598
+ }
1599
+ function finalize(end, open) {
1600
+ const committedRaw = rest.slice(0, end);
1601
+ const body = committedRaw.split("\n").map((line) => isBlankLine(line) ? "" : line.replace(CONT_LINE_RE, "")).join("\n");
1602
+ return { raw: committedRaw, body, open };
1603
+ }
1604
+ }
1076
1605
  var FOOTNOTE_EXTENSIONS = [
1077
1606
  {
1078
1607
  name: "footnoteRef",
@@ -1096,13 +1625,112 @@ var FOOTNOTE_EXTENSIONS = [
1096
1625
  name: "footnoteDef",
1097
1626
  level: "block",
1098
1627
  tokenizer(src) {
1099
- const match = DEF_RE.exec(src);
1628
+ const header = HEADER_RE.exec(src);
1629
+ if (!header) return void 0;
1630
+ const rest = src.slice(header[0].length);
1631
+ const cont = consumeContinuation(rest);
1632
+ const tokens = cont.body.trim() ? this.lexer.blockTokens(cont.body, []) : [];
1633
+ return {
1634
+ type: "footnoteDef",
1635
+ raw: header[0] + cont.raw,
1636
+ label: header[1],
1637
+ body: header[2],
1638
+ tokens
1639
+ };
1640
+ },
1641
+ renderer(token) {
1642
+ return token.raw;
1643
+ }
1644
+ }
1645
+ ];
1646
+ function footnoteMarker(label) {
1647
+ return `[${label}]`;
1648
+ }
1649
+
1650
+ // src/markdown-ins-mark.ts
1651
+ var INS_RE = /^\+\+(?!\s)((?:\\[\s\S]|(?!\+\+)[\s\S])+?)(?<!\s)\+\+/;
1652
+ var MARK_RE = /^==(?!\s)((?:\\[\s\S]|(?!==)[\s\S])+?)(?<!\s)==/;
1653
+ var INS_MARK_EXTENSIONS = [
1654
+ {
1655
+ name: "ins",
1656
+ level: "inline",
1657
+ // Without `start()`, marked's plain-text fallback tokenizer (`inlineText`)
1658
+ // never stops at `+` — see `markdown-superscript.ts`'s identical note for
1659
+ // `^`, which applies here verbatim.
1660
+ start(src) {
1661
+ return src.match(/(?<!\\)\+\+(?!\s)/)?.index;
1662
+ },
1663
+ tokenizer(src) {
1664
+ const match = INS_RE.exec(src);
1665
+ if (match) {
1666
+ return {
1667
+ type: "ins",
1668
+ raw: match[0],
1669
+ // Unescape `\x` -> `x`, the same reason `SUP_RE`'s tokenizer does:
1670
+ // `collectSpans`' `decodeEntities` only resolves HTML entities, not
1671
+ // backslash escapes.
1672
+ text: match[1].replace(/\\(.)/g, "$1")
1673
+ };
1674
+ }
1675
+ return void 0;
1676
+ },
1677
+ renderer(token) {
1678
+ return token.raw;
1679
+ }
1680
+ },
1681
+ {
1682
+ name: "mark",
1683
+ level: "inline",
1684
+ start(src) {
1685
+ return src.match(/(?<!\\)==(?!\s)/)?.index;
1686
+ },
1687
+ tokenizer(src) {
1688
+ const match = MARK_RE.exec(src);
1100
1689
  if (match) {
1101
1690
  return {
1102
- type: "footnoteDef",
1691
+ type: "mark",
1103
1692
  raw: match[0],
1104
- label: match[1],
1105
- body: match[2]
1693
+ text: match[1].replace(/\\(.)/g, "$1")
1694
+ };
1695
+ }
1696
+ return void 0;
1697
+ },
1698
+ renderer(token) {
1699
+ return token.raw;
1700
+ }
1701
+ }
1702
+ ];
1703
+
1704
+ // src/markdown-superscript.ts
1705
+ var SUP_RE = /^\^((?:\\[\s\S]|[^\s^\\])+)\^/;
1706
+ var SUPERSCRIPT_EXTENSIONS = [
1707
+ {
1708
+ name: "sup",
1709
+ level: "inline",
1710
+ // Without `start()`, marked's plain-text fallback tokenizer (`inlineText`)
1711
+ // never stops at `^` — it is not one of the characters its own regex treats
1712
+ // as a boundary, unlike `[` (link) or `` ` `` (codespan) — so it swallows an
1713
+ // entire `19^th^ century` as one `text` token before this extension is ever
1714
+ // tried at the right offset. `inlineMath` hits the identical problem for `$`
1715
+ // and solves it the same way; verified against marked@18.0.7 that inline
1716
+ // `start()` only clips the span handed to `inlineText`, not paragraph
1717
+ // grouping — the hazard `DEC-01KZDGCP` documents is specific to a *block*
1718
+ // `start()` retroactively re-grouping paragraphs, which does not apply here.
1719
+ start(src) {
1720
+ return src.match(/(?<!\\)\^(?!\s)/)?.index;
1721
+ },
1722
+ tokenizer(src) {
1723
+ const match = SUP_RE.exec(src);
1724
+ if (match) {
1725
+ return {
1726
+ type: "sup",
1727
+ raw: match[0],
1728
+ // Unescape `\x` -> `x` for any character (the content regex admits
1729
+ // `\` followed by anything) so `x^a\^b^` carries a literal caret
1730
+ // rather than a visible backslash. `collectSpans`' `decodeEntities`
1731
+ // only handles HTML entities, not backslash escapes, so this token
1732
+ // resolves its own before `text` is set.
1733
+ text: match[1].replace(/\\(.)/g, "$1")
1106
1734
  };
1107
1735
  }
1108
1736
  return void 0;
@@ -1112,9 +1740,6 @@ var FOOTNOTE_EXTENSIONS = [
1112
1740
  }
1113
1741
  }
1114
1742
  ];
1115
- function footnoteMarker(label) {
1116
- return `[${label}]`;
1117
- }
1118
1743
 
1119
1744
  // src/markdown-math.ts
1120
1745
  var mathConverter = null;
@@ -1414,42 +2039,90 @@ function expectedImageParagraphChildren(tokens) {
1414
2039
  function decodeEntities(text) {
1415
2040
  return text.replace(/&lt;/g, "<").replace(/&gt;/g, ">").replace(/&quot;/g, '"').replace(/&#39;/g, "'").replace(/&amp;/g, "&");
1416
2041
  }
1417
- function collectSpans(tokens, inherited, theme, out, blockFontSize) {
2042
+ function applyTypography(text) {
2043
+ let out = text;
2044
+ out = out.replace(/\(tm\)/gi, "\u2122");
2045
+ out = out.replace(/\(c\)/gi, "\xA9");
2046
+ out = out.replace(/\(r\)/gi, "\xAE");
2047
+ out = out.replace(/---/g, "\u2014");
2048
+ out = out.replace(/--/g, "\u2013");
2049
+ out = out.replace(/\.{3}/g, "\u2026");
2050
+ out = out.replace(/([A-Za-z])'([A-Za-z])/g, "$1\u2019$2");
2051
+ out = out.replace(/"([^"\n]*)"/g, "\u201C$1\u201D");
2052
+ out = out.replace(/'([^'\n]*)'/g, "\u2018$1\u2019");
2053
+ return out;
2054
+ }
2055
+ function decodeProse(text, theme) {
2056
+ const decoded = decodeEntities(text);
2057
+ return theme.typographer ? applyTypography(decoded) : decoded;
2058
+ }
2059
+ var NO_ABBREVIATIONS = /* @__PURE__ */ new Map();
2060
+ function emitProse(text, style, abbr, out) {
2061
+ if (!text) return;
2062
+ if (abbr.size === 0) {
2063
+ out.push({ text, style });
2064
+ return;
2065
+ }
2066
+ const terms = [...abbr.keys()].sort((a, b) => b.length - a.length);
2067
+ const pattern = terms.map((t) => t.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")).join("|");
2068
+ const re = new RegExp(`\\b(?:${pattern})\\b`, "g");
2069
+ let last = 0;
2070
+ for (let match = re.exec(text); match !== null; match = re.exec(text)) {
2071
+ if (match.index > last) out.push({ text: text.slice(last, match.index), style });
2072
+ out.push({ text: match[0], style: { ...style, abbrTitle: abbr.get(match[0]) } });
2073
+ last = match.index + match[0].length;
2074
+ }
2075
+ if (last < text.length) out.push({ text: text.slice(last), style });
2076
+ }
2077
+ function collectSpans(tokens, inherited, theme, out, blockFontSize, abbr = NO_ABBREVIATIONS) {
1418
2078
  for (const token of tokens) {
1419
2079
  switch (token.type) {
1420
2080
  case "strong": {
1421
2081
  const t = token;
1422
2082
  if (t.tokens) {
1423
- collectSpans(t.tokens, { ...inherited, bold: true }, theme, out, blockFontSize);
2083
+ collectSpans(t.tokens, { ...inherited, bold: true }, theme, out, blockFontSize, abbr);
1424
2084
  } else {
1425
- out.push({
1426
- text: decodeEntities(t.text),
1427
- style: { ...inherited, bold: true }
1428
- });
2085
+ emitProse(decodeProse(t.text, theme), { ...inherited, bold: true }, abbr, out);
1429
2086
  }
1430
2087
  break;
1431
2088
  }
1432
2089
  case "em": {
1433
2090
  const t = token;
1434
2091
  if (t.tokens) {
1435
- collectSpans(t.tokens, { ...inherited, italic: true }, theme, out, blockFontSize);
2092
+ collectSpans(t.tokens, { ...inherited, italic: true }, theme, out, blockFontSize, abbr);
1436
2093
  } else {
1437
- out.push({
1438
- text: decodeEntities(t.text),
1439
- style: { ...inherited, italic: true }
1440
- });
2094
+ emitProse(decodeProse(t.text, theme), { ...inherited, italic: true }, abbr, out);
1441
2095
  }
1442
2096
  break;
1443
2097
  }
1444
2098
  case "del": {
1445
2099
  const t = token;
2100
+ const isStrikethrough = t.raw?.startsWith("~~") ?? true;
2101
+ if (!isStrikethrough) {
2102
+ const runSize = inherited.fontSize ?? blockFontSize ?? theme.fontSize;
2103
+ const subStyle = {
2104
+ ...inherited,
2105
+ fontSize: runSize * theme.subscriptScale,
2106
+ baselineShift: runSize * theme.subscriptShift
2107
+ };
2108
+ if (t.tokens) {
2109
+ collectSpans(t.tokens, subStyle, theme, out, blockFontSize, abbr);
2110
+ } else {
2111
+ emitProse(decodeProse(t.text, theme), subStyle, abbr, out);
2112
+ }
2113
+ break;
2114
+ }
1446
2115
  if (t.tokens) {
1447
- collectSpans(t.tokens, { ...inherited, lineThrough: true }, theme, out, blockFontSize);
2116
+ collectSpans(
2117
+ t.tokens,
2118
+ { ...inherited, lineThrough: true },
2119
+ theme,
2120
+ out,
2121
+ blockFontSize,
2122
+ abbr
2123
+ );
1448
2124
  } else {
1449
- out.push({
1450
- text: decodeEntities(t.text),
1451
- style: { ...inherited, lineThrough: true }
1452
- });
2125
+ emitProse(decodeProse(t.text, theme), { ...inherited, lineThrough: true }, abbr, out);
1453
2126
  }
1454
2127
  break;
1455
2128
  }
@@ -1549,11 +2222,48 @@ function collectSpans(tokens, inherited, theme, out, blockFontSize) {
1549
2222
  style: {
1550
2223
  ...inherited,
1551
2224
  fontSize: runSize * theme.footnoteMarkerScale,
2225
+ baselineShift: runSize * theme.superscriptShift,
1552
2226
  color: theme.footnoteColor
1553
2227
  }
1554
2228
  });
1555
2229
  break;
1556
2230
  }
2231
+ case "sup": {
2232
+ const t = token;
2233
+ const runSize = inherited.fontSize ?? blockFontSize ?? theme.fontSize;
2234
+ emitProse(
2235
+ decodeProse(t.text, theme),
2236
+ {
2237
+ ...inherited,
2238
+ fontSize: runSize * theme.superscriptScale,
2239
+ baselineShift: runSize * theme.superscriptShift
2240
+ },
2241
+ abbr,
2242
+ out
2243
+ );
2244
+ break;
2245
+ }
2246
+ case "ins": {
2247
+ const t = token;
2248
+ emitProse(decodeProse(t.text, theme), { ...inherited, underline: true }, abbr, out);
2249
+ break;
2250
+ }
2251
+ case "mark": {
2252
+ const t = token;
2253
+ emitProse(
2254
+ decodeProse(t.text, theme),
2255
+ { ...inherited, highlightColor: theme.markHighlightColor },
2256
+ abbr,
2257
+ out
2258
+ );
2259
+ break;
2260
+ }
2261
+ case "emoji": {
2262
+ const t = token;
2263
+ const style = Object.keys(inherited).length > 0 ? inherited : void 0;
2264
+ out.push({ text: t.text, style });
2265
+ break;
2266
+ }
1557
2267
  case "link": {
1558
2268
  const t = token;
1559
2269
  const linkStyle = {
@@ -1561,33 +2271,32 @@ function collectSpans(tokens, inherited, theme, out, blockFontSize) {
1561
2271
  href: t.href,
1562
2272
  color: theme.linkColor
1563
2273
  };
1564
- if (t.tokens && t.tokens.length > 0) {
1565
- collectSpans(t.tokens, linkStyle, theme, out, blockFontSize);
2274
+ const isAutolink = !("title" in t);
2275
+ if (isAutolink) {
2276
+ out.push({ text: t.text, style: linkStyle });
2277
+ } else if (t.tokens && t.tokens.length > 0) {
2278
+ collectSpans(t.tokens, linkStyle, theme, out, blockFontSize, abbr);
1566
2279
  } else {
1567
- out.push({ text: decodeEntities(t.text), style: linkStyle });
2280
+ emitProse(decodeProse(t.text, theme), linkStyle, abbr, out);
1568
2281
  }
1569
2282
  break;
1570
2283
  }
1571
2284
  case "text": {
1572
2285
  const t = token;
1573
2286
  if ("tokens" in t && t.tokens?.length) {
1574
- collectSpans(t.tokens, inherited, theme, out, blockFontSize);
2287
+ collectSpans(t.tokens, inherited, theme, out, blockFontSize, abbr);
1575
2288
  } else {
1576
- const decoded = decodeEntities(t.text);
1577
- if (decoded) {
1578
- const style = Object.keys(inherited).length > 0 ? inherited : void 0;
1579
- out.push({ text: decoded, style });
1580
- }
2289
+ const decoded = decodeProse(t.text, theme);
2290
+ const style = Object.keys(inherited).length > 0 ? inherited : void 0;
2291
+ emitProse(decoded, style, abbr, out);
1581
2292
  }
1582
2293
  break;
1583
2294
  }
1584
2295
  default: {
1585
2296
  if ("text" in token) {
1586
- const decoded = decodeEntities(token.text);
1587
- if (decoded) {
1588
- const style = Object.keys(inherited).length > 0 ? inherited : void 0;
1589
- out.push({ text: decoded, style });
1590
- }
2297
+ const decoded = decodeProse(token.text, theme);
2298
+ const style = Object.keys(inherited).length > 0 ? inherited : void 0;
2299
+ emitProse(decoded, style, abbr, out);
1591
2300
  }
1592
2301
  break;
1593
2302
  }
@@ -1621,10 +2330,10 @@ function findUnclosedInline(text) {
1621
2330
  }
1622
2331
  return best;
1623
2332
  }
1624
- function renderInlineToRichText(tokens, fallbackText, font, color, maxWidth, theme, selectable, onLinkClick) {
2333
+ function renderInlineToRichText(tokens, fallbackText, font, color, maxWidth, theme, selectable, onLinkClick, abbr = NO_ABBREVIATIONS) {
1625
2334
  const spans = [];
1626
2335
  if (tokens && tokens.length > 0) {
1627
- collectSpans(tokens, {}, theme, spans, fontSizeFromFont(font));
2336
+ collectSpans(tokens, {}, theme, spans, fontSizeFromFont(font), abbr);
1628
2337
  }
1629
2338
  if (spans.length === 0) {
1630
2339
  spans.push({ text: decodeEntities(fallbackText) });
@@ -1887,7 +2596,7 @@ function tableContentOf(token) {
1887
2596
  }
1888
2597
 
1889
2598
  // src/frontMatter.ts
1890
- var OPEN_RE = /^---[ \t]*\r?\n/;
2599
+ var OPEN_RE2 = /^---[ \t]*\r?\n/;
1891
2600
  var OPENER_PREFIX_RE = /^(?:-|--|---[ \t]*\r?)$/;
1892
2601
  var KEY_RE = /^[^\s:#][^:]*:(?:[ \t].*)?$/;
1893
2602
  var CLOSE_RE = /^(?:---|\.\.\.)[ \t]*$/;
@@ -1896,7 +2605,7 @@ var NONE = { kind: "none" };
1896
2605
  var PENDING = { kind: "pending" };
1897
2606
  function scanFrontMatter(text, complete) {
1898
2607
  if (text.length === 0) return PENDING;
1899
- const open = OPEN_RE.exec(text);
2608
+ const open = OPEN_RE2.exec(text);
1900
2609
  if (!open) {
1901
2610
  return !complete && OPENER_PREFIX_RE.test(text) ? PENDING : NONE;
1902
2611
  }
@@ -1948,10 +2657,17 @@ function unquote(value) {
1948
2657
  }
1949
2658
 
1950
2659
  // src/MarkdownWorkerSource.ts
1951
- var WORKER_SOURCE_STRING = '"use strict";(()=>{function V(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var _=V();function ke(t){_=t}var C={exec:()=>null};function E(t){let e=[];return n=>{let s=Math.max(0,Math.min(3,n-1)),r=e[s];return r||(r=t(s),e[s]=r),r}}function k(t,e=""){let n=typeof t=="string"?t:t.source,s={replace:(r,i)=>{let a=typeof i=="string"?i:i.source;return a=a.replace(x.caret,"$1"),n=n.replace(r,a),s},getRegex:()=>new RegExp(n,e)};return s}var Pe=((t="")=>{try{return!!new RegExp("(?<=1)(?<!1)"+t)}catch{return!1}})(),x={codeRemoveIndent:/^(?: {1,4}| {0,3}\\t)/gm,outputLinkReplace:/\\\\([\\[\\]])/g,indentCodeCompensation:/^(\\s+)(?:```)/,beginningSpace:/^\\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\\n/g,tabCharGlobal:/\\t/g,multipleSpaceGlobal:/\\s+/g,blankLine:/^[ \\t]*$/,doubleBlankLine:/\\n[ \\t]*\\n[ \\t]*$/,blockquoteStart:/^ {0,3}>/,blockquoteSetextReplace:/\\n {0,3}((?:=+|-+) *)(?=\\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \\t]?/gm,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\\[[ xX]\\] +\\S/,listReplaceTask:/^\\[[ xX]\\] +/,listTaskCheckbox:/\\[[ xX]\\]/,anyLine:/\\n.*\\n/,hrefBrackets:/^<(.*)>$/,tableDelimiter:/[:|]/,tableAlignChars:/^\\||\\| *$/g,tableRowBlankLine:/\\n[ \\t]*$/,tableAlignRight:/^ *-+: *$/,tableAlignCenter:/^ *:-+: *$/,tableAlignLeft:/^ *:-+ *$/,startATag:/^<a /i,endATag:/^<\\/a>/i,startPreScriptTag:/^<(pre|code|kbd|script)(\\s|>)/i,endPreScriptTag:/^<\\/(pre|code|kbd|script)(\\s|>)/i,startAngleBracket:/^</,endAngleBracket:/>$/,pedanticHrefTitle:/^([^\'"]*[^\\s])\\s+([\'"])(.*)\\2/,unicodeAlphaNumeric:/[\\p{L}\\p{N}]/u,escapeTest:/[&<>"\']/,escapeReplace:/[&<>"\']/g,escapeTestNoEncode:/[<>"\']|&(?!(#\\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\\w+);)/,escapeReplaceNoEncode:/[<>"\']|&(?!(#\\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\\w+);)/g,caret:/(^|[^\\[])\\^/g,percentDecode:/%25/g,findPipe:/\\|/g,splitPipe:/ \\|/,slashPipe:/\\\\\\|/g,carriageReturn:/\\r\\n|\\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\\S*/,endingNewline:/\\n$/,listItemRegex:t=>new RegExp(`^( {0,3}${t})((?:[ ][^\\\\n]*)?(?:\\\\n|$))`),nextBulletRegex:E(t=>new RegExp(`^ {0,${t}}(?:[*+-]|\\\\d{1,9}[.)])((?:[ ][^\\\\n]*)?(?:\\\\n|$))`)),hrRegex:E(t=>new RegExp(`^ {0,${t}}((?:- *){3,}|(?:_ *){3,}|(?:\\\\* *){3,})(?:\\\\n+|$)`)),fencesBeginRegex:E(t=>new RegExp(`^ {0,${t}}(?:\\`\\`\\`|~~~)`)),headingBeginRegex:E(t=>new RegExp(`^ {0,${t}}#`)),htmlBeginRegex:E(t=>new RegExp(`^ {0,${t}}<(?:[a-z].*>|!--)`,"i")),blockquoteBeginRegex:E(t=>new RegExp(`^ {0,${t}}>`))},Me=/^(?:[ \\t]*(?:\\n|$))+/,Be=/^((?: {4}| {0,3}\\t)[^\\n]+(?:\\n(?:[ \\t]*(?:\\n|$))*)?)+/,qe=/^ {0,3}(`{3,}(?=[^`\\n]*(?:\\n|$))|~{3,})([^\\n]*)(?:\\n|$)(?:|([\\s\\S]*?)(?:\\n|$))(?: {0,3}\\1[~`]* *(?=\\n|$)|$)/,v=/^ {0,3}((?:-[\\t ]*){3,}|(?:_[ \\t]*){3,}|(?:\\*[ \\t]*){3,})(?:\\n+|$)/,ve=/^ {0,3}(#{1,6})(?=\\s|$)(.*)(?:\\n+|$)/,K=/ {0,3}(?:[*+-]|\\d{1,9}[.)])/,fe=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\\n(?!\\s*?\\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\\n {0,3}(=+|-+) *(?:\\n+|$)/,de=k(fe).replace(/bull/g,K).replace(/blockCode/g,/(?: {4}| {0,3}\\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}(?:\\s|$)/).replace(/html/g,/ {0,3}<[^\\n>]+>\\n/).replace(/\\|table/g,"").getRegex(),De=k(fe).replace(/bull/g,K).replace(/blockCode/g,/(?: {4}| {0,3}\\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}(?:\\s|$)/).replace(/html/g,/ {0,3}<[^\\n>]+>\\n/).replace(/table/g,/ {0,3}\\|?(?:[:\\- ]*\\|)+[\\:\\- ]*\\n/).getRegex(),J=/^([^\\n]+(?:\\n(?!hr|heading|lheading|blockquote|fences|list|html|table|[ \\t]+\\n)[^\\n]+)*)/,Oe=/^[^\\n]+/,Y=/(?!\\s*\\])(?:\\\\[\\s\\S]|[^\\[\\]\\\\])+/,Ze=k(/^ {0,3}\\[(label)\\]: *(?:\\n[ \\t]*)?([^<\\s][^\\s]*|<.*?>)(?:(?: +(?:\\n[ \\t]*)?| *\\n[ \\t]*)(title))? *(?:\\n+|$)/).replace("label",Y).replace("title",/(?:"(?:\\\\"?|[^"\\\\])*"|\'[^\'\\n]*(?:\\n[^\'\\n]+)*\\n?\'|\\([^()]*\\))/).getRegex(),Ne=k(/^(bull)([ \\t][^\\n]*?)?(?:\\n|$)/).replace(/bull/g,K).getRegex(),Q="address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul",ee=/<!--(?:-?>|[\\s\\S]*?(?:-->|$))/,Qe=k("^ {0,3}(?:<(script|pre|style|textarea)[\\\\s>][\\\\s\\\\S]*?(?:</\\\\1>[^\\\\n]*\\\\n*|$)|comment[^\\\\n]*(\\\\n+|$)|<\\\\?[\\\\s\\\\S]*?(?:\\\\?>[^\\\\n]*\\\\n*|$)|<![A-Z][\\\\s\\\\S]*?(?:>[^\\\\n]*\\\\n*|$)|<!\\\\[CDATA\\\\[[\\\\s\\\\S]*?(?:\\\\]\\\\]>[^\\\\n]*\\\\n*|$)|</?(tag)(?: +|\\\\n|/?>)[\\\\s\\\\S]*?(?:(?:\\\\n[ ]*)+\\\\n|$)|<(?!script|pre|style|textarea)([a-z][\\\\w-]*)(?:attribute)*? */?>(?=[ \\\\t]*(?:\\\\n|$))[\\\\s\\\\S]*?(?:(?:\\\\n[ ]*)+\\\\n|$)|</(?!script|pre|style|textarea)[a-z][\\\\w-]*\\\\s*>(?=[ \\\\t]*(?:\\\\n|$))[\\\\s\\\\S]*?(?:(?:\\\\n[ ]*)+\\\\n|$))","i").replace("comment",ee).replace("tag",Q).replace("attribute",/ +[a-zA-Z:_][\\w.:-]*(?: *= *"[^"\\n]*"| *= *\'[^\'\\n]*\'| *= *[^\\s"\'=<>`]+)?/).getRegex(),xe=t=>k(J).replace("hr",v).replace("heading"," {0,3}#{1,6}(?:\\\\s|$)").replace("|lheading","").replace("|table","").replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\\\n]*\\\\n)|~~~)[^\\\\n]*\\\\n").replace("list",t).replace("html","</?(?:tag)(?: +|\\\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",Q).getRegex(),Fe=xe(/ {0,3}(?:[*+-]|1[.)])[ \\t]+[^ \\t\\n]/),He=xe(/ {0,3}(?:[*+-]|\\d{1,9}[.)])(?:[ \\t]|\\n|$)/),je=k(/^( {0,3}> ?(paragraph|[^\\n]*)(?:\\n|$))+/).replace("paragraph",He).getRegex(),te={blockquote:je,code:Be,def:Ze,fences:qe,heading:ve,hr:v,html:Qe,lheading:de,list:Ne,newline:Me,paragraph:Fe,table:C,text:Oe},ae=k("^ *([^\\\\n ].*)\\\\n {0,3}((?:\\\\| *)?:?-+:? *(?:\\\\| *:?-+:? *)*(?:\\\\| *)?)(?:\\\\n((?:(?! *\\\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\\\n|$))*)\\\\n*|$)").replace("hr",v).replace("heading"," {0,3}#{1,6}(?:\\\\s|$)").replace("blockquote"," {0,3}>").replace("code","(?: {4}| {0,3} )[^\\\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\\\n]*\\\\n)|~~~)[^\\\\n]*\\\\n").replace("list"," {0,3}(?:[*+-]|1[.)])[ \\\\t]").replace("html","</?(?:tag)(?: +|\\\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",Q).getRegex(),Ge={...te,lheading:De,table:ae,paragraph:k(J).replace("hr",v).replace("heading"," {0,3}#{1,6}(?:\\\\s|$)").replace("|lheading","").replace("table",ae).replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\\\n]*\\\\n)|~~~)[^\\\\n]*\\\\n").replace("list"," {0,3}(?:[*+-]|1[.)])[ \\\\t]+[^ \\\\t\\\\n]").replace("html","</?(?:tag)(?: +|\\\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",Q).getRegex()},We={...te,html:k(`^ *(?:comment *(?:\\\\n|\\\\s*$)|<(tag)[\\\\s\\\\S]+?</\\\\1> *(?:\\\\n{2,}|\\\\s*$)|<tag(?:"[^"]*"|\'[^\']*\'|\\\\s[^\'"/>\\\\s]*)*?/?> *(?:\\\\n{2,}|\\\\s*$))`).replace("comment",ee).replace(/tag/g,"(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\\\b)\\\\w+(?!:|[^\\\\w\\\\s@]*@)\\\\b").getRegex(),def:/^ *\\[([^\\]]+)\\]: *<?([^\\s>]+)>?(?: +(["(][^\\n]+[")]))? *(?:\\n+|$)/,heading:/^(#{1,6})(.*)(?:\\n+|$)/,fences:C,lheading:/^(.+?)\\n {0,3}(=+|-+) *(?:\\n+|$)/,paragraph:k(J).replace("hr",v).replace("heading",` *#{1,6} *[^\n]`).replace("lheading",de).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},Xe=/^\\\\([!"#$%&\'()*+,\\-./:;<=>?@\\[\\]\\\\^_`{|}~])/,Ue=/^(`+)([^`]|[^`][\\s\\S]*?[^`])\\1(?!`)/,be=/^( {2,}|\\\\)\\n(?!\\s*$)/,Ve=/^(`+|[^`])(?:(?= {2,}\\n)|[\\s\\S]*?(?:(?=[\\\\<!\\[`*_]|\\b_|$)|[^ ](?= {2,}\\n)))/,P=/[\\p{P}\\p{S}]/u,F=/[\\s\\p{P}\\p{S}]/u,ne=/[^\\s\\p{P}\\p{S}]/u,Ke=k(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,F).getRegex(),me=/(?!~)[\\p{P}\\p{S}]/u,Je=/(?!~)[\\s\\p{P}\\p{S}]/u,Ye=/(?:[^\\s\\p{P}\\p{S}]|~)/u,et=k(/link|precode-code|html/,"g").replace("link",/\\[(?:[^\\[\\]`]|(?<a>`+)[^`]+\\k<a>(?!`))*?\\]\\((?:\\\\[\\s\\S]|[^\\\\\\(\\)]|\\((?:\\\\[\\s\\S]|[^\\\\\\(\\)])*\\))*\\)/).replace("precode-",Pe?"(?<!`)()":"(^^|[^`])").replace("code",/(?<b>`+)[^`]+\\k<b>(?!`)/).replace("html",/<(?! )[^<>]*?>/).getRegex(),we=/^(?:\\*+(?:((?!\\*)punct)|([^\\s*]))?)|^_+(?:((?!_)punct)|([^\\s_]))?/,tt=k(we,"u").replace(/punct/g,P).getRegex(),nt=k(we,"u").replace(/punct/g,me).getRegex(),ye="^[^_*]*?__[^_*]*?\\\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\\\*)punct(\\\\*+)(?=[\\\\s]|$)|notPunctSpace(\\\\*+)(?!\\\\*)(?=punctSpace|$)|(?!\\\\*)punctSpace(\\\\*+)(?=notPunctSpace)|[\\\\s](\\\\*+)(?!\\\\*)(?=punct)|(?!\\\\*)punct(\\\\*+)(?!\\\\*)(?=punct)|notPunctSpace(\\\\*+)(?=notPunctSpace)",rt=k(ye,"gu").replace(/notPunctSpace/g,ne).replace(/punctSpace/g,F).replace(/punct/g,P).getRegex(),st=k(ye,"gu").replace(/notPunctSpace/g,Ye).replace(/punctSpace/g,Je).replace(/punct/g,me).getRegex(),it=k("^[^_*]*?\\\\*\\\\*[^_*]*?_[^_*]*?(?=\\\\*\\\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,ne).replace(/punctSpace/g,F).replace(/punct/g,P).getRegex(),lt=k(/^~~?(?:((?!~)punct)|[^\\s~])/,"u").replace(/punct/g,P).getRegex(),at="^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)",ot=k(at,"gu").replace(/notPunctSpace/g,ne).replace(/punctSpace/g,F).replace(/punct/g,P).getRegex(),ct=k(/\\\\(punct)/,"gu").replace(/punct/g,P).getRegex(),ht=k(/^<(scheme:[^\\s\\x00-\\x1f<>]*|email)>/).replace("scheme",/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace("email",/[a-zA-Z0-9.!#$%&\'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex(),ut=k(ee).replace("(?:-->|$)","-->").getRegex(),pt=k("^comment|^</[a-zA-Z][\\\\w:-]*\\\\s*>|^<[a-zA-Z][\\\\w-]*(?:attribute)*?\\\\s*/?>|^<\\\\?[\\\\s\\\\S]*?\\\\?>|^<![a-zA-Z]+\\\\s[\\\\s\\\\S]*?>|^<!\\\\[CDATA\\\\[[\\\\s\\\\S]*?\\\\]\\\\]>").replace("comment",ut).replace("attribute",/\\s+[a-zA-Z:_][\\w.:-]*(?:\\s*=\\s*"[^"]*"|\\s*=\\s*\'[^\']*\'|\\s*=\\s*[^\\s"\'=<>`]+)?/).getRegex(),O=/(?:\\[(?:\\\\[\\s\\S]|[^\\[\\]\\\\])*\\]|\\\\[\\s\\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\\])|[^\\[\\]\\\\`])*?/,gt=k(/^!?\\[(label)\\]\\(\\s*(href)(?:(?:[ \\t]+(?:\\n[ \\t]*)?|\\n[ \\t]*)(title))?\\s*\\)/).replace("label",O).replace("href",/<(?:\\\\.|[^\\n<>\\\\])+>|[^ \\t\\n\\x00-\\x1f]+|(?=\\))/).replace("title",/"(?:\\\\"?|[^"\\\\])*"|\'(?:\\\\\'?|[^\'\\\\])*\'|\\((?:\\\\\\)?|[^)\\\\])*\\)/).getRegex(),Re=k(/^!?\\[(label)\\]\\[(ref)\\]/).replace("label",O).replace("ref",Y).getRegex(),$e=k(/^!?\\[(ref)\\](?:\\[\\])?/).replace("ref",Y).getRegex(),kt=k("reflink|nolink(?!\\\\()","g").replace("reflink",Re).replace("nolink",$e).getRegex(),oe=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,re={_backpedal:C,anyPunctuation:ct,autolink:ht,blockSkip:et,br:be,code:Ue,del:C,delLDelim:C,delRDelim:C,emStrongLDelim:tt,emStrongRDelimAst:rt,emStrongRDelimUnd:it,escape:Xe,link:gt,nolink:$e,punctuation:Ke,reflink:Re,reflinkSearch:kt,tag:pt,text:Ve,url:C},ft={...re,link:k(/^!?\\[(label)\\]\\((.*?)\\)/).replace("label",O).getRegex(),reflink:k(/^!?\\[(label)\\]\\s*\\[([^\\]]*)\\]/).replace("label",O).getRegex()},W={...re,emStrongRDelimAst:st,emStrongLDelim:nt,delLDelim:lt,delRDelim:ot,url:k(/^((?:protocol):\\/\\/|www\\.)(?:[a-zA-Z0-9\\-]+\\.?)+[^\\s<]*|^email/).replace("protocol",oe).replace("email",/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(),_backpedal:/(?:[^?!.,:;*_\'"~()&]+|\\([^)]*\\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_\'"~)]+(?!$))+/,del:/^(~~?)(?=[^\\s~])((?:\\\\[\\s\\S]|[^\\\\])*?(?:\\\\[\\s\\S]|[^\\s~\\\\]))\\1(?=[^~]|$)/,text:k(/^(`+|~+|[^`~])(?:(?=[`~])|(?= {2,}\\n)|(?=[a-zA-Z0-9.!#$%&\'*+\\/=?_`{\\|}~-]+@)|[\\s\\S]*?(?:(?=[\\\\<!\\[`*~_]|\\b_|protocol:\\/\\/|www\\.|$)|[^ ](?= {2,}\\n)|[^a-zA-Z0-9.!#$%&\'*+\\/=?_`{\\|}~-](?=[a-zA-Z0-9.!#$%&\'*+\\/=?_`{\\|}~-]+@)))/).replace("protocol",oe).getRegex()},dt={...W,br:k(be).replace("{2,}","*").getRegex(),text:k(W.text).replace("\\\\b_","\\\\b_| {2,}\\\\n").replace(/\\{2,\\}/g,"*").getRegex()},D={normal:te,gfm:Ge,pedantic:We},B={normal:re,gfm:W,breaks:dt,pedantic:ft},xt={"&":"&amp;","<":"&lt;",">":"&gt;",\'"\':"&quot;","\'":"&#39;"},ce=t=>xt[t];function S(t,e){if(e){if(x.escapeTest.test(t))return t.replace(x.escapeReplace,ce)}else if(x.escapeTestNoEncode.test(t))return t.replace(x.escapeReplaceNoEncode,ce);return t}function he(t){try{t=encodeURI(t).replace(x.percentDecode,"%")}catch{return null}return t}function ue(t,e){let n=t.replace(x.findPipe,(i,a,l)=>{let o=!1,c=a;for(;--c>=0&&l[c]==="\\\\";)o=!o;return o?"|":" |"}),s=n.split(x.splitPipe),r=0;if(s[0].trim()||s.shift(),s.length>0&&!s.at(-1)?.trim()&&s.pop(),e)if(s.length>e)s.splice(e);else for(;s.length<e;)s.push("");for(;r<s.length;r++)s[r]=s[r].trim().replace(x.slashPipe,"|");return s}function z(t,e,n){let s=t.length;if(s===0)return"";let r=0;for(;r<s;){let i=t.charAt(s-r-1);if(i===e&&!n)r++;else if(i!==e&&n)r++;else break}return t.slice(0,s-r)}function pe(t){let e=t.split(`\n`),n=e.length-1;for(;n>=0&&x.blankLine.test(e[n]);)n--;return e.length-n<=2?t:e.slice(0,n+1).join(`\n`)}function bt(t,e){if(t.indexOf(e[1])===-1)return-1;let n=0;for(let s=0;s<t.length;s++)if(t[s]==="\\\\")s++;else if(t[s]===e[0])n++;else if(t[s]===e[1]&&(n--,n<0))return s;return n>0?-2:-1}function mt(t,e=0){let n=e,s="";for(let r of t)if(r===" "){let i=4-n%4;s+=" ".repeat(i),n+=i}else s+=r,n++;return s}function ge(t,e,n,s,r){let i=e.href,a=e.title||null,l=t[1].replace(r.other.outputLinkReplace,"$1");s.state.inLink=!0;let o={type:t[0].charAt(0)==="!"?"image":"link",raw:n,href:i,title:a,text:l,tokens:s.inlineTokens(l)};return s.state.inLink=!1,o}function wt(t,e,n){let s=t.match(n.other.indentCodeCompensation);if(s===null)return e;let r=s[1];return e.split(`\n`).map(i=>{let a=i.match(n.other.beginningSpace);if(a===null)return i;let[l]=a;return l.length>=r.length?i.slice(r.length):i}).join(`\n`)}var Z=class{options;rules;lexer;constructor(t){this.options=t||_}space(t){let e=this.rules.block.newline.exec(t);if(e&&e[0].length>0)return{type:"space",raw:e[0]}}code(t){let e=this.rules.block.code.exec(t);if(e){let n=this.options.pedantic?e[0]:pe(e[0]),s=n.replace(this.rules.other.codeRemoveIndent,"");return{type:"code",raw:n,codeBlockStyle:"indented",text:s}}}fences(t){let e=this.rules.block.fences.exec(t);if(e){let n=e[0],s=wt(n,e[3]||"",this.rules);return{type:"code",raw:n,lang:e[2]?e[2].trim().replace(this.rules.inline.anyPunctuation,"$1"):e[2],text:s}}}heading(t){let e=this.rules.block.heading.exec(t);if(e){let n=e[2].trim();if(this.rules.other.endingHash.test(n)){let s=z(n,"#");(this.options.pedantic||!s||this.rules.other.endingSpaceChar.test(s))&&(n=s.trim())}return{type:"heading",raw:z(e[0],`\n`),depth:e[1].length,text:n,tokens:this.lexer.inline(n)}}}hr(t){let e=this.rules.block.hr.exec(t);if(e)return{type:"hr",raw:z(e[0],`\n`)}}blockquote(t){let e=this.rules.block.blockquote.exec(t);if(e){let n=z(e[0],`\n`).split(`\n`),s="",r="",i=[];for(;n.length>0;){let a=!1,l=[],o;for(o=0;o<n.length;o++)if(this.rules.other.blockquoteStart.test(n[o]))l.push(n[o]),a=!0;else if(!a)l.push(n[o]);else break;n=n.slice(o);let c=l.join(`\n`),u=c.replace(this.rules.other.blockquoteSetextReplace,`\n $1`).replace(this.rules.other.blockquoteSetextReplace2,"");s=s?`${s}\n${c}`:c,r=r?`${r}\n${u}`:u;let h=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTokens(u,i,!0),this.lexer.state.top=h,n.length===0)break;let p=i.at(-1);if(p?.type==="code")break;if(p?.type==="blockquote"){let d=p,f=d.raw+`\n`+n.join(`\n`),m=this.blockquote(f);i[i.length-1]=m,s=s.substring(0,s.length-d.raw.length)+m.raw,r=r.substring(0,r.length-d.text.length)+m.text;break}else if(p?.type==="list"){let d=p,f=d.raw+`\n`+n.join(`\n`),m=this.list(f);i[i.length-1]=m,s=s.substring(0,s.length-p.raw.length)+m.raw,r=r.substring(0,r.length-d.raw.length)+m.raw,n=f.substring(i.at(-1).raw.length).split(`\n`);continue}}return{type:"blockquote",raw:s,tokens:i,text:r}}}list(t){let e=this.rules.block.list.exec(t);if(e){let n=e[1].trim(),s=n.length>1,r={type:"list",raw:"",ordered:s,start:s?+n.slice(0,-1):"",loose:!1,items:[]};n=s?`\\\\d{1,9}\\\\${n.slice(-1)}`:`\\\\${n}`,this.options.pedantic&&(n=s?n:"[*+-]");let i=this.rules.other.listItemRegex(n),a=!1;for(;t;){let o=!1,c="",u="";if(!(e=i.exec(t))||this.rules.block.hr.test(t))break;c=e[0],t=t.substring(c.length);let h=mt(e[2].split(`\n`,1)[0],e[1].length),p=t.split(`\n`,1)[0],d=!h.trim(),f=0;if(this.options.pedantic?(f=2,u=h.trimStart()):d?f=e[1].length+1:(f=h.search(this.rules.other.nonSpaceChar),f=f>4?1:f,u=h.slice(f),f+=e[1].length),d&&this.rules.other.blankLine.test(p)&&(c+=p+`\n`,t=t.substring(p.length+1),o=!0),!o){let m=this.rules.other.nextBulletRegex(f),w=this.rules.other.hrRegex(f),y=this.rules.other.fencesBeginRegex(f),L=this.rules.other.headingBeginRegex(f),G=this.rules.other.htmlBeginRegex(f),A=this.rules.other.blockquoteBeginRegex(f);for(;t;){let b=t.split(`\n`,1)[0],T;if(p=b,this.options.pedantic?(p=p.replace(this.rules.other.listReplaceNesting," "),T=p):T=p.replace(this.rules.other.tabCharGlobal," "),y.test(p)||L.test(p)||G.test(p)||A.test(p)||m.test(p)||w.test(p))break;if(T.search(this.rules.other.nonSpaceChar)>=f||!p.trim())u+=`\n`+T.slice(f);else{if(d||h.replace(this.rules.other.tabCharGlobal," ").search(this.rules.other.nonSpaceChar)>=4||y.test(h)||L.test(h)||w.test(h))break;u+=`\n`+p}d=!p.trim(),c+=b+`\n`,t=t.substring(b.length+1),h=T.slice(f)}}r.loose||(a?r.loose=!0:this.rules.other.doubleBlankLine.test(c)&&(a=!0)),r.items.push({type:"list_item",raw:c,task:!!this.options.gfm&&this.rules.other.listIsTask.test(u),loose:!1,text:u,tokens:[]}),r.raw+=c}let l=r.items.at(-1);if(l)l.raw=l.raw.trimEnd(),l.text=l.text.trimEnd();else return;r.raw=r.raw.trimEnd();for(let o of r.items){this.lexer.state.top=!1,o.tokens=this.lexer.blockTokens(o.text,[]);let c=o.tokens[0];if(o.task&&(c?.type==="text"||c?.type==="paragraph")){o.text=o.text.replace(this.rules.other.listReplaceTask,""),c.raw=c.raw.replace(this.rules.other.listReplaceTask,""),c.text=c.text.replace(this.rules.other.listReplaceTask,"");for(let h=this.lexer.inlineQueue.length-1;h>=0;h--)if(this.rules.other.listIsTask.test(this.lexer.inlineQueue[h].src)){this.lexer.inlineQueue[h].src=this.lexer.inlineQueue[h].src.replace(this.rules.other.listReplaceTask,"");break}let u=this.rules.other.listTaskCheckbox.exec(o.raw);if(u){let h={type:"checkbox",raw:u[0]+" ",checked:u[0]!=="[ ]"};o.checked=h.checked,r.loose?o.tokens[0]&&["paragraph","text"].includes(o.tokens[0].type)&&"tokens"in o.tokens[0]&&o.tokens[0].tokens?(o.tokens[0].raw=h.raw+o.tokens[0].raw,o.tokens[0].text=h.raw+o.tokens[0].text,o.tokens[0].tokens.unshift(h)):o.tokens.unshift({type:"paragraph",raw:h.raw,text:h.raw,tokens:[h]}):o.tokens.unshift(h)}}else o.task&&(o.task=!1);if(!r.loose){let u=o.tokens.filter(p=>p.type==="space"),h=u.length>0&&u.some(p=>this.rules.other.anyLine.test(p.raw));r.loose=h}}if(r.loose)for(let o of r.items){o.loose=!0;for(let c of o.tokens)c.type==="text"&&(c.type="paragraph")}return r}}html(t){let e=this.rules.block.html.exec(t);if(e){let n=pe(e[0]);return{type:"html",block:!0,raw:n,pre:e[1]==="pre"||e[1]==="script"||e[1]==="style",text:n}}}def(t){let e=this.rules.block.def.exec(t);if(e){let n=e[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal," "),s=e[2]?e[2].replace(this.rules.other.hrefBrackets,"$1").replace(this.rules.inline.anyPunctuation,"$1"):"",r=e[3]?e[3].substring(1,e[3].length-1).replace(this.rules.inline.anyPunctuation,"$1"):e[3];return{type:"def",tag:n,raw:z(e[0],`\n`),href:s,title:r}}}table(t){let e=this.rules.block.table.exec(t);if(!e||!this.rules.other.tableDelimiter.test(e[2]))return;let n=ue(e[1]),s=e[2].replace(this.rules.other.tableAlignChars,"").split("|"),r=e[3]?.trim()?e[3].replace(this.rules.other.tableRowBlankLine,"").split(`\n`):[],i={type:"table",raw:z(e[0],`\n`),header:[],align:[],rows:[]};if(n.length===s.length){for(let a of s)this.rules.other.tableAlignRight.test(a)?i.align.push("right"):this.rules.other.tableAlignCenter.test(a)?i.align.push("center"):this.rules.other.tableAlignLeft.test(a)?i.align.push("left"):i.align.push(null);for(let a=0;a<n.length;a++)i.header.push({text:n[a],tokens:this.lexer.inline(n[a]),header:!0,align:i.align[a]});for(let a of r)i.rows.push(ue(a,i.header.length).map((l,o)=>({text:l,tokens:this.lexer.inline(l),header:!1,align:i.align[o]})));return i}}lheading(t){let e=this.rules.block.lheading.exec(t);if(e){let n=e[1].trim();return{type:"heading",raw:z(e[0],`\n`),depth:e[2].charAt(0)==="="?1:2,text:n,tokens:this.lexer.inline(n)}}}paragraph(t){let e=this.rules.block.paragraph.exec(t);if(e){let n=e[1].charAt(e[1].length-1)===`\n`?e[1].slice(0,-1):e[1];return{type:"paragraph",raw:e[0],text:n,tokens:this.lexer.inline(n)}}}text(t){let e=this.rules.block.text.exec(t);if(e)return{type:"text",raw:e[0],text:e[0],tokens:this.lexer.inline(e[0])}}escape(t){let e=this.rules.inline.escape.exec(t);if(e)return{type:"escape",raw:e[0],text:e[1]}}tag(t){let e=this.rules.inline.tag.exec(t);if(e)return!this.lexer.state.inLink&&this.rules.other.startATag.test(e[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&this.rules.other.endATag.test(e[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&this.rules.other.startPreScriptTag.test(e[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&this.rules.other.endPreScriptTag.test(e[0])&&(this.lexer.state.inRawBlock=!1),{type:"html",raw:e[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:e[0]}}link(t){let e=this.rules.inline.link.exec(t);if(e){let n=e[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(n)){if(!this.rules.other.endAngleBracket.test(n))return;let i=z(n.slice(0,-1),"\\\\");if((n.length-i.length)%2===0)return}else{let i=bt(e[2],"()");if(i===-2)return;if(i>-1){let a=(e[0].indexOf("!")===0?5:4)+e[1].length+i;e[2]=e[2].substring(0,i),e[0]=e[0].substring(0,a).trim(),e[3]=""}}let s=e[2],r="";if(this.options.pedantic){let i=this.rules.other.pedanticHrefTitle.exec(s);i&&(s=i[1],r=i[3])}else r=e[3]?e[3].slice(1,-1):"";return s=s.trim(),this.rules.other.startAngleBracket.test(s)&&(this.options.pedantic&&!this.rules.other.endAngleBracket.test(n)?s=s.slice(1):s=s.slice(1,-1)),ge(e,{href:s&&s.replace(this.rules.inline.anyPunctuation,"$1"),title:r&&r.replace(this.rules.inline.anyPunctuation,"$1")},e[0],this.lexer,this.rules)}}reflink(t,e){let n;if((n=this.rules.inline.reflink.exec(t))||(n=this.rules.inline.nolink.exec(t))){let s=(n[2]||n[1]).replace(this.rules.other.multipleSpaceGlobal," "),r=e[s.toLowerCase()];if(!r){let i=n[0].charAt(0);return{type:"text",raw:i,text:i}}return ge(n,r,n[0],this.lexer,this.rules)}}emStrong(t,e,n=""){let s=this.rules.inline.emStrongLDelim.exec(t);if(!(!s||!s[1]&&!s[2]&&!s[3]&&!s[4]||s[4]&&n.match(this.rules.other.unicodeAlphaNumeric))&&(!(s[1]||s[3])||!n||this.rules.inline.punctuation.exec(n))){let r=[...s[0]].length-1,i,a,l=r,o=0,c=s[0][0]==="*"?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(c.lastIndex=0,e=e.slice(-1*t.length+r);(s=c.exec(e))!==null;){if(i=s[1]||s[2]||s[3]||s[4]||s[5]||s[6],!i)continue;if(a=[...i].length,s[3]||s[4]){l+=a;continue}else if((s[5]||s[6])&&r%3&&!((r+a)%3)){o+=a;continue}if(l-=a,l>0)continue;a=Math.min(a,a+l+o);let u=[...s[0]][0].length,h=t.slice(0,r+s.index+u+a);if(Math.min(r,a)%2){let d=h.slice(1,-1);return{type:"em",raw:h,text:d,tokens:this.lexer.inlineTokens(d)}}let p=h.slice(2,-2);return{type:"strong",raw:h,text:p,tokens:this.lexer.inlineTokens(p)}}}}codespan(t){let e=this.rules.inline.code.exec(t);if(e){let n=e[2].replace(this.rules.other.newLineCharGlobal," "),s=this.rules.other.nonSpaceChar.test(n),r=this.rules.other.startingSpaceChar.test(n)&&this.rules.other.endingSpaceChar.test(n);return s&&r&&(n=n.substring(1,n.length-1)),{type:"codespan",raw:e[0],text:n}}}br(t){let e=this.rules.inline.br.exec(t);if(e)return{type:"br",raw:e[0]}}del(t,e,n=""){let s=this.rules.inline.delLDelim.exec(t);if(s&&(!s[1]||!n||this.rules.inline.punctuation.exec(n))){let r=[...s[0]].length-1,i,a,l=r,o=this.rules.inline.delRDelim;for(o.lastIndex=0,e=e.slice(-1*t.length+r);(s=o.exec(e))!==null;){if(i=s[1]||s[2]||s[3]||s[4]||s[5]||s[6],!i||(a=[...i].length,a!==r))continue;if(s[3]||s[4]){l+=a;continue}if(l-=a,l>0)continue;a=Math.min(a,a+l);let c=[...s[0]][0].length,u=t.slice(0,r+s.index+c+a),h=u.slice(r,-r);return{type:"del",raw:u,text:h,tokens:this.lexer.inlineTokens(h)}}}}autolink(t){let e=this.rules.inline.autolink.exec(t);if(e){let n,s;return e[2]==="@"?(n=e[1],s="mailto:"+n):(n=e[1],s=n),{type:"link",raw:e[0],text:n,href:s,tokens:[{type:"text",raw:n,text:n}]}}}url(t){let e;if(e=this.rules.inline.url.exec(t)){let n,s;if(e[2]==="@")n=e[0],s="mailto:"+n;else{let r;do r=e[0],e[0]=this.rules.inline._backpedal.exec(e[0])?.[0]??"";while(r!==e[0]);n=e[0],e[1]==="www."?s="http://"+e[0]:s=e[0]}return{type:"link",raw:e[0],text:n,href:s,tokens:[{type:"text",raw:n,text:n}]}}}inlineText(t){let e=this.rules.inline.text.exec(t);if(e){let n=this.lexer.state.inRawBlock;return{type:"text",raw:e[0],text:e[0],escaped:n}}}},R=class X{tokens;options;state;inlineQueue;tokenizer;constructor(e){this.tokens=[],this.tokens.links=Object.create(null),this.options=e||_,this.options.tokenizer=this.options.tokenizer||new Z,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,top:!0};let n={other:x,block:D.normal,inline:B.normal};this.options.pedantic?(n.block=D.pedantic,n.inline=B.pedantic):this.options.gfm&&(n.block=D.gfm,this.options.breaks?n.inline=B.breaks:n.inline=B.gfm),this.tokenizer.rules=n}static get rules(){return{block:D,inline:B}}static lex(e,n){return new X(n).lex(e)}static lexInline(e,n){return new X(n).inlineTokens(e)}lex(e){e=e.replace(x.carriageReturn,`\n`),this.blockTokens(e,this.tokens);for(let n=0;n<this.inlineQueue.length;n++){let s=this.inlineQueue[n];this.inlineTokens(s.src,s.tokens)}return this.inlineQueue=[],this.tokens}blockTokens(e,n=[],s=!1){this.tokenizer.lexer=this,this.options.pedantic&&(e=e.replace(x.tabCharGlobal," ").replace(x.spaceLine,""));let r=1/0;for(;e;){if(e.length<r)r=e.length;else{this.infiniteLoopError(e.charCodeAt(0));break}let i;if(this.options.extensions?.block?.some(l=>(i=l.call({lexer:this},e,n))?(e=e.substring(i.raw.length),n.push(i),!0):!1))continue;if(i=this.tokenizer.space(e)){e=e.substring(i.raw.length);let l=n.at(-1);i.raw.length===1&&l!==void 0?l.raw+=`\n`:n.push(i);continue}if(i=this.tokenizer.code(e)){e=e.substring(i.raw.length);let l=n.at(-1);l?.type==="paragraph"||l?.type==="text"?(l.raw+=(l.raw.endsWith(`\n`)?"":`\n`)+i.raw,l.text+=`\n`+i.text,this.inlineQueue.at(-1).src=l.text):n.push(i);continue}if(i=this.tokenizer.fences(e)){e=e.substring(i.raw.length),n.push(i);continue}if(i=this.tokenizer.heading(e)){e=e.substring(i.raw.length),n.push(i);continue}if(i=this.tokenizer.hr(e)){e=e.substring(i.raw.length),n.push(i);continue}if(i=this.tokenizer.blockquote(e)){e=e.substring(i.raw.length),n.push(i);continue}if(i=this.tokenizer.list(e)){e=e.substring(i.raw.length),n.push(i);continue}if(i=this.tokenizer.html(e)){e=e.substring(i.raw.length),n.push(i);continue}if(i=this.tokenizer.def(e)){e=e.substring(i.raw.length);let l=n.at(-1);l?.type==="paragraph"||l?.type==="text"?(l.raw+=(l.raw.endsWith(`\n`)?"":`\n`)+i.raw,l.text+=`\n`+i.raw,this.inlineQueue.at(-1).src=l.text):this.tokens.links[i.tag]||(this.tokens.links[i.tag]={href:i.href,title:i.title},n.push(i));continue}if(i=this.tokenizer.table(e)){e=e.substring(i.raw.length),n.push(i);continue}if(i=this.tokenizer.lheading(e)){e=e.substring(i.raw.length),n.push(i);continue}let a=e;if(this.options.extensions?.startBlock){let l=1/0,o=e.slice(1),c;this.options.extensions.startBlock.forEach(u=>{c=u.call({lexer:this},o),typeof c=="number"&&c>=0&&(l=Math.min(l,c))}),l<1/0&&l>=0&&(a=e.substring(0,l+1))}if(this.state.top&&(i=this.tokenizer.paragraph(a))){let l=n.at(-1);s&&l?.type==="paragraph"?(l.raw+=(l.raw.endsWith(`\n`)?"":`\n`)+i.raw,l.text+=`\n`+i.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=l.text):n.push(i),s=a.length!==e.length,e=e.substring(i.raw.length);continue}if(i=this.tokenizer.text(e)){e=e.substring(i.raw.length);let l=n.at(-1);l?.type==="text"?(l.raw+=(l.raw.endsWith(`\n`)?"":`\n`)+i.raw,l.text+=`\n`+i.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=l.text):n.push(i);continue}if(e){this.infiniteLoopError(e.charCodeAt(0));break}}return this.state.top=!0,n}inline(e,n=[]){return this.inlineQueue.push({src:e,tokens:n}),n}inlineTokens(e,n=[]){this.tokenizer.lexer=this;let s=e;if(this.tokens.links){let l=Object.keys(this.tokens.links);l.length>0&&(s=s.replace(this.tokenizer.rules.inline.reflinkSearch,o=>l.includes(o.slice(o.lastIndexOf("[")+1,-1))?"["+"a".repeat(o.length-2)+"]":o))}s=s.replace(this.tokenizer.rules.inline.anyPunctuation,"++"),s=s.replace(this.tokenizer.rules.inline.blockSkip,(l,o,c)=>{let u=c?c.length:0;return l.slice(0,u)+"["+"a".repeat(l.length-u-2)+"]"}),s=this.options.hooks?.emStrongMask?.call({lexer:this},s)??s;let r=!1,i="",a=1/0;for(;e;){if(e.length<a)a=e.length;else{this.infiniteLoopError(e.charCodeAt(0));break}r||(i=""),r=!1;let l;if(this.options.extensions?.inline?.some(c=>(l=c.call({lexer:this},e,n))?(e=e.substring(l.raw.length),n.push(l),!0):!1))continue;if(l=this.tokenizer.escape(e)){e=e.substring(l.raw.length),n.push(l);continue}if(l=this.tokenizer.tag(e)){e=e.substring(l.raw.length),n.push(l);continue}if(l=this.tokenizer.link(e)){e=e.substring(l.raw.length),n.push(l);continue}if(l=this.tokenizer.reflink(e,this.tokens.links)){e=e.substring(l.raw.length);let c=n.at(-1);l.type==="text"&&c?.type==="text"?(c.raw+=l.raw,c.text+=l.text):n.push(l);continue}if(l=this.tokenizer.emStrong(e,s,i)){e=e.substring(l.raw.length),n.push(l);continue}if(l=this.tokenizer.codespan(e)){e=e.substring(l.raw.length),n.push(l);continue}if(l=this.tokenizer.br(e)){e=e.substring(l.raw.length),n.push(l);continue}if(l=this.tokenizer.del(e,s,i)){e=e.substring(l.raw.length),n.push(l);continue}if(l=this.tokenizer.autolink(e)){e=e.substring(l.raw.length),n.push(l);continue}if(!this.state.inLink&&(l=this.tokenizer.url(e))){e=e.substring(l.raw.length),n.push(l);continue}let o=e;if(this.options.extensions?.startInline){let c=1/0,u=e.slice(1),h;this.options.extensions.startInline.forEach(p=>{h=p.call({lexer:this},u),typeof h=="number"&&h>=0&&(c=Math.min(c,h))}),c<1/0&&c>=0&&(o=e.substring(0,c+1))}if(l=this.tokenizer.inlineText(o)){e=e.substring(l.raw.length),l.raw.slice(-1)!=="_"&&(i=l.raw.slice(-1)),r=!0;let c=n.at(-1);c?.type==="text"?(c.raw+=l.raw,c.text+=l.text):n.push(l);continue}if(e){this.infiniteLoopError(e.charCodeAt(0));break}}return n}infiniteLoopError(e){let n="Infinite loop on byte: "+e;if(this.options.silent)console.error(n);else throw new Error(n)}},N=class{options;parser;constructor(t){this.options=t||_}space(t){return""}code({text:t,lang:e,escaped:n}){let s=(e||"").match(x.notSpaceStart)?.[0],r=t.replace(x.endingNewline,"")+`\n`;return s?\'<pre><code class="language-\'+S(s)+\'">\'+(n?r:S(r,!0))+`</code></pre>\n`:"<pre><code>"+(n?r:S(r,!0))+`</code></pre>\n`}blockquote({tokens:t}){return`<blockquote>\n${this.parser.parse(t)}</blockquote>\n`}html({text:t}){return t}def(t){return""}heading({tokens:t,depth:e}){return`<h${e}>${this.parser.parseInline(t)}</h${e}>\n`}hr(t){return`<hr>\n`}list(t){let e=t.ordered,n=t.start,s="";for(let a=0;a<t.items.length;a++){let l=t.items[a];s+=this.listitem(l)}let r=e?"ol":"ul",i=e&&n!==1?\' start="\'+n+\'"\':"";return"<"+r+i+`>\n`+s+"</"+r+`>\n`}listitem(t){return`<li>${this.parser.parse(t.tokens)}</li>\n`}checkbox({checked:t}){return"<input "+(t?\'checked="" \':"")+\'disabled="" type="checkbox"> \'}paragraph({tokens:t}){return`<p>${this.parser.parseInline(t)}</p>\n`}table(t){let e="",n="";for(let r=0;r<t.header.length;r++)n+=this.tablecell(t.header[r]);e+=this.tablerow({text:n});let s="";for(let r=0;r<t.rows.length;r++){let i=t.rows[r];n="";for(let a=0;a<i.length;a++)n+=this.tablecell(i[a]);s+=this.tablerow({text:n})}return s&&(s=`<tbody>${s}</tbody>`),`<table>\n<thead>\n`+e+`</thead>\n`+s+`</table>\n`}tablerow({text:t}){return`<tr>\n${t}</tr>\n`}tablecell(t){let e=this.parser.parseInline(t.tokens),n=t.header?"th":"td";return(t.align?`<${n} align="${t.align}">`:`<${n}>`)+e+`</${n}>\n`}strong({tokens:t}){return`<strong>${this.parser.parseInline(t)}</strong>`}em({tokens:t}){return`<em>${this.parser.parseInline(t)}</em>`}codespan({text:t}){return`<code>${S(t,!0)}</code>`}br(t){return"<br>"}del({tokens:t}){return`<del>${this.parser.parseInline(t)}</del>`}link({href:t,title:e,tokens:n}){let s=this.parser.parseInline(n),r=he(t);if(r===null)return s;t=r;let i=\'<a href="\'+t+\'"\';return e&&(i+=\' title="\'+S(e)+\'"\'),i+=">"+s+"</a>",i}image({href:t,title:e,text:n,tokens:s}){s&&(n=this.parser.parseInline(s,this.parser.textRenderer));let r=he(t);if(r===null)return S(n);t=r;let i=`<img src="${t}" alt="${S(n)}"`;return e&&(i+=` title="${S(e)}"`),i+=">",i}text(t){return"tokens"in t&&t.tokens?this.parser.parseInline(t.tokens):"escaped"in t&&t.escaped?t.text:S(t.text)}},se=class{strong({text:t}){return t}em({text:t}){return t}codespan({text:t}){return t}del({text:t}){return t}html({text:t}){return t}text({text:t}){return t}link({text:t}){return""+t}image({text:t}){return""+t}br(){return""}checkbox({raw:t}){return t}},$=class U{options;renderer;textRenderer;constructor(e){this.options=e||_,this.options.renderer=this.options.renderer||new N,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new se}static parse(e,n){return new U(n).parse(e)}static parseInline(e,n){return new U(n).parseInline(e)}parse(e){this.renderer.parser=this;let n="";for(let s=0;s<e.length;s++){let r=e[s];if(this.options.extensions?.renderers?.[r.type]){let a=r,l=this.options.extensions.renderers[a.type].call({parser:this},a);if(l!==!1||!["space","hr","heading","code","table","blockquote","list","html","def","paragraph","text"].includes(a.type)){n+=l||"";continue}}let i=r;switch(i.type){case"space":{n+=this.renderer.space(i);break}case"hr":{n+=this.renderer.hr(i);break}case"heading":{n+=this.renderer.heading(i);break}case"code":{n+=this.renderer.code(i);break}case"table":{n+=this.renderer.table(i);break}case"blockquote":{n+=this.renderer.blockquote(i);break}case"list":{n+=this.renderer.list(i);break}case"checkbox":{n+=this.renderer.checkbox(i);break}case"html":{n+=this.renderer.html(i);break}case"def":{n+=this.renderer.def(i);break}case"paragraph":{n+=this.renderer.paragraph(i);break}case"text":{n+=this.renderer.text(i);break}default:{let a=\'Token with "\'+i.type+\'" type was not found.\';if(this.options.silent)return console.error(a),"";throw new Error(a)}}}return n}parseInline(e,n=this.renderer){this.renderer.parser=this;let s="";for(let r=0;r<e.length;r++){let i=e[r];if(this.options.extensions?.renderers?.[i.type]){let l=this.options.extensions.renderers[i.type].call({parser:this},i);if(l!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(i.type)){s+=l||"";continue}}let a=i;switch(a.type){case"escape":{s+=n.text(a);break}case"html":{s+=n.html(a);break}case"link":{s+=n.link(a);break}case"image":{s+=n.image(a);break}case"checkbox":{s+=n.checkbox(a);break}case"strong":{s+=n.strong(a);break}case"em":{s+=n.em(a);break}case"codespan":{s+=n.codespan(a);break}case"br":{s+=n.br(a);break}case"del":{s+=n.del(a);break}case"text":{s+=n.text(a);break}default:{let l=\'Token with "\'+a.type+\'" type was not found.\';if(this.options.silent)return console.error(l),"";throw new Error(l)}}}return s}},q=class{options;block;constructor(t){this.options=t||_}static passThroughHooks=new Set(["preprocess","postprocess","processAllTokens","emStrongMask"]);static passThroughHooksRespectAsync=new Set(["preprocess","postprocess","processAllTokens"]);preprocess(t){return t}postprocess(t){return t}processAllTokens(t){return t}emStrongMask(t){return t}provideLexer(t=this.block){return t?R.lex:R.lexInline}provideParser(t=this.block){return t?$.parse:$.parseInline}},yt=class{defaults=V();options=this.setOptions;parse=this.parseMarkdown(!0);parseInline=this.parseMarkdown(!1);Parser=$;Renderer=N;TextRenderer=se;Lexer=R;Tokenizer=Z;Hooks=q;constructor(...t){this.use(...t)}walkTokens(t,e){let n=[];for(let s of t)switch(n=n.concat(e.call(this,s)),s.type){case"table":{let r=s;for(let i of r.header)n=n.concat(this.walkTokens(i.tokens,e));for(let i of r.rows)for(let a of i)n=n.concat(this.walkTokens(a.tokens,e));break}case"list":{let r=s;n=n.concat(this.walkTokens(r.items,e));break}default:{let r=s;this.defaults.extensions?.childTokens?.[r.type]?this.defaults.extensions.childTokens[r.type].forEach(i=>{let a=r[i].flat(1/0);n=n.concat(this.walkTokens(a,e))}):r.tokens&&(n=n.concat(this.walkTokens(r.tokens,e)))}}return n}use(...t){let e=this.defaults.extensions||{renderers:{},childTokens:{}};return t.forEach(n=>{let s={...n};if(s.async=this.defaults.async||s.async||!1,n.extensions&&(n.extensions.forEach(r=>{if(!r.name)throw new Error("extension name required");if("renderer"in r){let i=e.renderers[r.name];i?e.renderers[r.name]=function(...a){let l=r.renderer.apply(this,a);return l===!1&&(l=i.apply(this,a)),l}:e.renderers[r.name]=r.renderer}if("tokenizer"in r){if(!r.level||r.level!=="block"&&r.level!=="inline")throw new Error("extension level must be \'block\' or \'inline\'");let i=e[r.level];i?i.unshift(r.tokenizer):e[r.level]=[r.tokenizer],r.start&&(r.level==="block"?e.startBlock?e.startBlock.push(r.start):e.startBlock=[r.start]:r.level==="inline"&&(e.startInline?e.startInline.push(r.start):e.startInline=[r.start]))}"childTokens"in r&&r.childTokens&&(e.childTokens[r.name]=r.childTokens)}),s.extensions=e),n.renderer){let r=this.defaults.renderer||new N(this.defaults);for(let i in n.renderer){if(!(i in r))throw new Error(`renderer \'${i}\' does not exist`);if(["options","parser"].includes(i))continue;let a=i,l=n.renderer[a],o=r[a];r[a]=(...c)=>{let u=l.apply(r,c);return u===!1&&(u=o.apply(r,c)),u||""}}s.renderer=r}if(n.tokenizer){let r=this.defaults.tokenizer||new Z(this.defaults);for(let i in n.tokenizer){if(!(i in r))throw new Error(`tokenizer \'${i}\' does not exist`);if(["options","rules","lexer"].includes(i))continue;let a=i,l=n.tokenizer[a],o=r[a];r[a]=(...c)=>{let u=l.apply(r,c);return u===!1&&(u=o.apply(r,c)),u}}s.tokenizer=r}if(n.hooks){let r=this.defaults.hooks||new q;for(let i in n.hooks){if(!(i in r))throw new Error(`hook \'${i}\' does not exist`);if(["options","block"].includes(i))continue;let a=i,l=n.hooks[a],o=r[a];q.passThroughHooks.has(i)?r[a]=c=>{if(this.defaults.async&&q.passThroughHooksRespectAsync.has(i))return(async()=>{let h=await l.call(r,c);return o.call(r,h)})();let u=l.call(r,c);return o.call(r,u)}:r[a]=(...c)=>{if(this.defaults.async)return(async()=>{let h=await l.apply(r,c);return h===!1&&(h=await o.apply(r,c)),h})();let u=l.apply(r,c);return u===!1&&(u=o.apply(r,c)),u}}s.hooks=r}if(n.walkTokens){let r=this.defaults.walkTokens,i=n.walkTokens;s.walkTokens=function(a){let l=[];return l.push(i.call(this,a)),r&&(l=l.concat(r.call(this,a))),l}}this.defaults={...this.defaults,...s}}),this}setOptions(t){return this.defaults={...this.defaults,...t},this}lexer(t,e){return R.lex(t,e??this.defaults)}parser(t,e){return $.parse(t,e??this.defaults)}parseMarkdown(t){return(e,n)=>{let s={...n},r={...this.defaults,...s},i=this.onError(!!r.silent,!!r.async);if(this.defaults.async===!0&&s.async===!1)return i(new Error("marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise."));if(typeof e>"u"||e===null)return i(new Error("marked(): input parameter is undefined or null"));if(typeof e!="string")return i(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(e)+", string expected"));if(r.hooks&&(r.hooks.options=r,r.hooks.block=t),r.async)return(async()=>{let a=r.hooks?await r.hooks.preprocess(e):e,l=await(r.hooks?await r.hooks.provideLexer(t):t?R.lex:R.lexInline)(a,r),o=r.hooks?await r.hooks.processAllTokens(l):l;r.walkTokens&&await Promise.all(this.walkTokens(o,r.walkTokens));let c=await(r.hooks?await r.hooks.provideParser(t):t?$.parse:$.parseInline)(o,r);return r.hooks?await r.hooks.postprocess(c):c})().catch(i);try{r.hooks&&(e=r.hooks.preprocess(e));let a=(r.hooks?r.hooks.provideLexer(t):t?R.lex:R.lexInline)(e,r);r.hooks&&(a=r.hooks.processAllTokens(a)),r.walkTokens&&this.walkTokens(a,r.walkTokens);let l=(r.hooks?r.hooks.provideParser(t):t?$.parse:$.parseInline)(a,r);return r.hooks&&(l=r.hooks.postprocess(l)),l}catch(a){return i(a)}}}onError(t,e){return n=>{if(n.message+=`\nPlease report this to https://github.com/markedjs/marked.`,t){let s="<p>An error occurred:</p><pre>"+S(n.message+"",!0)+"</pre>";return e?Promise.resolve(s):s}if(e)return Promise.reject(n);throw n}}},I=new yt;function g(t,e){return I.parse(t,e)}g.options=g.setOptions=function(t){return I.setOptions(t),g.defaults=I.defaults,ke(g.defaults),g};g.getDefaults=V;g.defaults=_;g.use=function(...t){return I.use(...t),g.defaults=I.defaults,ke(g.defaults),g};g.walkTokens=function(t,e){return I.walkTokens(t,e)};g.parseInline=I.parseInline;g.Parser=$;g.parser=$.parse;g.Renderer=N;g.TextRenderer=se;g.Lexer=R;g.lexer=R.lex;g.Tokenizer=Z;g.Hooks=q;g.parse=g;var _t=g.options,Et=g.setOptions,Pt=g.use,Mt=g.walkTokens,Bt=g.parseInline;var qt=$.parse,vt=R.lex;function Se(t,e,n){let s=0;for(let r=e;r<n;r++)s+=t[r].raw.length;return s}function Rt(t,e){let n=t;return n.links=e,n}var $t=/^ {0,3}\\$\\$/m;function Le(t){return t.includes("$$")===!1?!1:$t.test(t)}function Tt(t,e){return t[e-2]?.type!=="list"?!0:e+1<t.length}function ze(t,e){for(let n=t.length-2;n>=e;n--)if(t[n].type==="space"&&Tt(t,n+1)!==!1)return n+1;return-1}function Ae(t){let e=t.links;if(!e)return!1;for(let n in e)return!0;return!1}function Ce(t,e,n,s,r){let i=r;for(let a=e;a<n;a++){let l=t[a].raw;if(s.startsWith(l,i)===!1)return!1;i+=l.length}return!0}function j(t,e,n){return{source:t,tail:t,tokens:e,stableCount:0,stableOffset:0,degraded:!0,degradedReason:n}}function Te(t,e){return{source:t,tail:t,tokens:e,stableCount:0,stableOffset:0,degraded:!1,degradedReason:null}}function St(t,e){if(Ae(e))return j(t,e,"link-definition");if(t.includes("\\r"))return j(t,e,"carriage-return");if(Le(t))return j(t,e,"block-math");let n=ze(e,1);if(n<0||Ce(e,0,n,t,0)===!1)return Te(t,e);let s=Se(e,0,n);return{source:t,tail:t.slice(s),tokens:e,stableCount:n,stableOffset:s,degraded:!1,degradedReason:null}}function ie(t){let e=g.lexer(t);return{tokens:e,cache:St(t,e),charsLexed:t.length,reusedTokens:0}}function H(t,e){let n=g.lexer(t);return{tokens:n,cache:j(t,n,e),charsLexed:t.length,reusedTokens:0}}function Ie(t,e){let n=t.source+e;if(t.degraded)return H(n,t.degradedReason??"link-definition");if(e.includes("\\r"))return H(n,"carriage-return");if(t.stableCount===0)return ie(n);let s=t.tail+e;if(Le(s))return H(n,"block-math");let r=g.lexer(s);if(Ae(r))return H(n,"link-definition");let i=t.tokens.slice(0,t.stableCount),a=Rt([...i,...r],r.links),l=t.stableCount,o=t.stableOffset,c=s,u=ze(a,t.stableCount+1);if(u>t.stableCount&&Ce(a,t.stableCount,u,s,0)){let h=Se(a,t.stableCount,u);l=u,o=t.stableOffset+h,c=s.slice(h)}return{tokens:a,cache:{source:n,tail:c,tokens:a,stableCount:l,stableOffset:o,degraded:!1,degradedReason:null},charsLexed:s.length,reusedTokens:t.stableCount}}var _e="([^\\\\]\\\\s]+)",Lt=new RegExp(`^\\\\[\\\\^${_e}\\\\]`),zt=new RegExp(`^ {0,3}\\\\[\\\\^${_e}\\\\]:[ \\\\t]*([^\\\\n]*)(?:\\\\n|$)`),Ee=[{name:"footnoteRef",level:"inline",tokenizer(t){let e=Lt.exec(t);if(e)return{type:"footnoteRef",raw:e[0],label:e[1]}},renderer(t){return t.raw}},{name:"footnoteDef",level:"block",tokenizer(t){let e=zt.exec(t);if(e)return{type:"footnoteDef",raw:e[0],label:e[1],body:e[2]}},renderer(t){return t.raw}}];var At=0;function Ct(t){if(typeof t!="string"||typeof performance.mark!="function"||typeof performance.measure!="function")return null;let e=At++,n={name:t,startMark:`${t}:start:${e}`,endMark:`${t}:end:${e}`};try{return performance.mark(n.startMark),n}catch{return null}}function It(t){if(t)try{performance.mark(t.endMark),performance.measure(t.name,t.startMark,t.endMark)}catch{}finally{try{performance.clearMarks?.(t.startMark),performance.clearMarks?.(t.endMark)}catch{}}}g.use({extensions:[...Ee,{name:"blockMath",level:"block",start(t){return t.match(/^ {0,3}\\$\\$/m)?.index},tokenizer(t){let e=/^ {0,3}\\$\\$([\\s\\S]+?)\\$\\$[ \\t]*(?:\\n|$)/.exec(t);if(e)return{type:"blockMath",raw:e[0],text:e[1].trim()}},renderer(t){return t.raw}},{name:"inlineMath",level:"inline",start(t){return t.match(/(?<![\\\\$])\\$(?![$\\s])/)?.index},tokenizer(t){let e=/^\\$(?![$\\s\\d])((?:\\\\\\$|[^$\\n])*?)(?<!\\s)\\$(?!\\d)/.exec(t);if(e)return{type:"inlineMath",raw:e[0],text:e[1].trim()}},renderer(t){return t.raw}}]});var M=new Map;self.onmessage=t=>{let e=t.data;if(typeof e!="object"||e===null)return;let{id:n,text:s,append:r,expectedLength:i,oldRaws:a,instance:l,baseVersion:o,dispose:c,userTimingName:u}=e;if(c===!0){typeof l=="string"&&M.delete(l);return}let h=typeof l=="string"?l:null,p=typeof o=="number"?o:null,d,f=null,m=null;if(typeof r=="string"){if(h===null||p===null){self.postMessage({id:n,needResync:!0});return}let w=M.get(h);if(!w||w.version!==p){self.postMessage({id:n,needResync:!0});return}if(typeof i=="number"&&w.lex.source.length+r.length!==i){M.delete(h),self.postMessage({id:n,needResync:!0});return}let y=w.lex;d=()=>Ie(y,r),m=y.tokens}else if(typeof s=="string"){let w=s;if(d=()=>ie(w),Array.isArray(a))f=a;else if(h!==null&&p!==null){let y=M.get(h);if(y&&y.version===p)m=y.lex.tokens;else{self.postMessage({id:n,needResync:!0});return}}}else return;try{let w=typeof u=="string"?Ct(u):null,y=performance.now(),L;try{L=d()}finally{w&&It(w)}let G=performance.now()-y,A=L.tokens,b=0;if(f!==null){let T=Math.min(f.length,A.length);for(;b<T&&f[b]===A[b].raw;b++);}else if(m!==null){let T=m,le=Math.min(T.length,A.length);for(b=Math.min(L.reusedTokens,le);b<le&&T[b].raw===A[b].raw;b++);}h!==null&&p!==null&&M.set(h,{version:p+1,lex:L.cache}),self.postMessage({id:n,matchLen:b,tail:A.slice(b),lexerMs:G,sourceCharsLexed:L.charsLexed})}catch(w){h!==null&&M.delete(h),self.postMessage({id:n,error:String(w)})}};})();\n';
2660
+ var WORKER_SOURCE_STRING = '"use strict";(()=>{function J(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var I=J();function de(t){I=t}var A={exec:()=>null};function C(t){let e=[];return n=>{let r=Math.max(0,Math.min(3,n-1)),s=e[r];return s||(s=t(r),e[r]=s),s}}function g(t,e=""){let n=typeof t=="string"?t:t.source,r={replace:(s,i)=>{let a=typeof i=="string"?i:i.source;return a=a.replace(x.caret,"$1"),n=n.replace(s,a),r},getRegex:()=>new RegExp(n,e)};return r}var Xe=((t="")=>{try{return!!new RegExp("(?<=1)(?<!1)"+t)}catch{return!1}})(),x={codeRemoveIndent:/^(?: {1,4}| {0,3}\\t)/gm,outputLinkReplace:/\\\\([\\[\\]])/g,indentCodeCompensation:/^(\\s+)(?:```)/,beginningSpace:/^\\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\\n/g,tabCharGlobal:/\\t/g,multipleSpaceGlobal:/\\s+/g,blankLine:/^[ \\t]*$/,doubleBlankLine:/\\n[ \\t]*\\n[ \\t]*$/,blockquoteStart:/^ {0,3}>/,blockquoteSetextReplace:/\\n {0,3}((?:=+|-+) *)(?=\\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \\t]?/gm,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\\[[ xX]\\] +\\S/,listReplaceTask:/^\\[[ xX]\\] +/,listTaskCheckbox:/\\[[ xX]\\]/,anyLine:/\\n.*\\n/,hrefBrackets:/^<(.*)>$/,tableDelimiter:/[:|]/,tableAlignChars:/^\\||\\| *$/g,tableRowBlankLine:/\\n[ \\t]*$/,tableAlignRight:/^ *-+: *$/,tableAlignCenter:/^ *:-+: *$/,tableAlignLeft:/^ *:-+ *$/,startATag:/^<a /i,endATag:/^<\\/a>/i,startPreScriptTag:/^<(pre|code|kbd|script)(\\s|>)/i,endPreScriptTag:/^<\\/(pre|code|kbd|script)(\\s|>)/i,startAngleBracket:/^</,endAngleBracket:/>$/,pedanticHrefTitle:/^([^\'"]*[^\\s])\\s+([\'"])(.*)\\2/,unicodeAlphaNumeric:/[\\p{L}\\p{N}]/u,escapeTest:/[&<>"\']/,escapeReplace:/[&<>"\']/g,escapeTestNoEncode:/[<>"\']|&(?!(#\\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\\w+);)/,escapeReplaceNoEncode:/[<>"\']|&(?!(#\\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\\w+);)/g,caret:/(^|[^\\[])\\^/g,percentDecode:/%25/g,findPipe:/\\|/g,splitPipe:/ \\|/,slashPipe:/\\\\\\|/g,carriageReturn:/\\r\\n|\\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\\S*/,endingNewline:/\\n$/,listItemRegex:t=>new RegExp(`^( {0,3}${t})((?:[ ][^\\\\n]*)?(?:\\\\n|$))`),nextBulletRegex:C(t=>new RegExp(`^ {0,${t}}(?:[*+-]|\\\\d{1,9}[.)])((?:[ ][^\\\\n]*)?(?:\\\\n|$))`)),hrRegex:C(t=>new RegExp(`^ {0,${t}}((?:- *){3,}|(?:_ *){3,}|(?:\\\\* *){3,})(?:\\\\n+|$)`)),fencesBeginRegex:C(t=>new RegExp(`^ {0,${t}}(?:\\`\\`\\`|~~~)`)),headingBeginRegex:C(t=>new RegExp(`^ {0,${t}}#`)),htmlBeginRegex:C(t=>new RegExp(`^ {0,${t}}<(?:[a-z].*>|!--)`,"i")),blockquoteBeginRegex:C(t=>new RegExp(`^ {0,${t}}>`))},Qe=/^(?:[ \\t]*(?:\\n|$))+/,He=/^((?: {4}| {0,3}\\t)[^\\n]+(?:\\n(?:[ \\t]*(?:\\n|$))*)?)+/,We=/^ {0,3}(`{3,}(?=[^`\\n]*(?:\\n|$))|~{3,})([^\\n]*)(?:\\n|$)(?:|([\\s\\S]*?)(?:\\n|$))(?: {0,3}\\1[~`]* *(?=\\n|$)|$)/,D=/^ {0,3}((?:-[\\t ]*){3,}|(?:_[ \\t]*){3,}|(?:\\*[ \\t]*){3,})(?:\\n+|$)/,Ge=/^ {0,3}(#{1,6})(?=\\s|$)(.*)(?:\\n+|$)/,K=/ {0,3}(?:[*+-]|\\d{1,9}[.)])/,xe=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\\n(?!\\s*?\\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\\n {0,3}(=+|-+) *(?:\\n+|$)/,be=g(xe).replace(/bull/g,K).replace(/blockCode/g,/(?: {4}| {0,3}\\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}(?:\\s|$)/).replace(/html/g,/ {0,3}<[^\\n>]+>\\n/).replace(/\\|table/g,"").getRegex(),Ue=g(xe).replace(/bull/g,K).replace(/blockCode/g,/(?: {4}| {0,3}\\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}(?:\\s|$)/).replace(/html/g,/ {0,3}<[^\\n>]+>\\n/).replace(/table/g,/ {0,3}\\|?(?:[:\\- ]*\\|)+[\\:\\- ]*\\n/).getRegex(),V=/^([^\\n]+(?:\\n(?!hr|heading|lheading|blockquote|fences|list|html|table|[ \\t]+\\n)[^\\n]+)*)/,Je=/^[^\\n]+/,Y=/(?!\\s*\\])(?:\\\\[\\s\\S]|[^\\[\\]\\\\])+/,Ke=g(/^ {0,3}\\[(label)\\]: *(?:\\n[ \\t]*)?([^<\\s][^\\s]*|<.*?>)(?:(?: +(?:\\n[ \\t]*)?| *\\n[ \\t]*)(title))? *(?:\\n+|$)/).replace("label",Y).replace("title",/(?:"(?:\\\\"?|[^"\\\\])*"|\'[^\'\\n]*(?:\\n[^\'\\n]+)*\\n?\'|\\([^()]*\\))/).getRegex(),Ve=g(/^(bull)([ \\t][^\\n]*?)?(?:\\n|$)/).replace(/bull/g,K).getRegex(),X="address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul",ee=/<!--(?:-?>|[\\s\\S]*?(?:-->|$))/,Ye=g("^ {0,3}(?:<(script|pre|style|textarea)[\\\\s>][\\\\s\\\\S]*?(?:</\\\\1>[^\\\\n]*\\\\n*|$)|comment[^\\\\n]*(\\\\n+|$)|<\\\\?[\\\\s\\\\S]*?(?:\\\\?>[^\\\\n]*\\\\n*|$)|<![A-Z][\\\\s\\\\S]*?(?:>[^\\\\n]*\\\\n*|$)|<!\\\\[CDATA\\\\[[\\\\s\\\\S]*?(?:\\\\]\\\\]>[^\\\\n]*\\\\n*|$)|</?(tag)(?: +|\\\\n|/?>)[\\\\s\\\\S]*?(?:(?:\\\\n[ ]*)+\\\\n|$)|<(?!script|pre|style|textarea)([a-z][\\\\w-]*)(?:attribute)*? */?>(?=[ \\\\t]*(?:\\\\n|$))[\\\\s\\\\S]*?(?:(?:\\\\n[ ]*)+\\\\n|$)|</(?!script|pre|style|textarea)[a-z][\\\\w-]*\\\\s*>(?=[ \\\\t]*(?:\\\\n|$))[\\\\s\\\\S]*?(?:(?:\\\\n[ ]*)+\\\\n|$))","i").replace("comment",ee).replace("tag",X).replace("attribute",/ +[a-zA-Z:_][\\w.:-]*(?: *= *"[^"\\n]*"| *= *\'[^\'\\n]*\'| *= *[^\\s"\'=<>`]+)?/).getRegex(),me=t=>g(V).replace("hr",D).replace("heading"," {0,3}#{1,6}(?:\\\\s|$)").replace("|lheading","").replace("|table","").replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\\\n]*\\\\n)|~~~)[^\\\\n]*\\\\n").replace("list",t).replace("html","</?(?:tag)(?: +|\\\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",X).getRegex(),et=me(/ {0,3}(?:[*+-]|1[.)])[ \\t]+[^ \\t\\n]/),tt=me(/ {0,3}(?:[*+-]|\\d{1,9}[.)])(?:[ \\t]|\\n|$)/),nt=g(/^( {0,3}> ?(paragraph|[^\\n]*)(?:\\n|$))+/).replace("paragraph",tt).getRegex(),te={blockquote:nt,code:He,def:Ke,fences:We,heading:Ge,hr:D,html:Ye,lheading:be,list:Ve,newline:Qe,paragraph:et,table:A,text:Je},ce=g("^ *([^\\\\n ].*)\\\\n {0,3}((?:\\\\| *)?:?-+:? *(?:\\\\| *:?-+:? *)*(?:\\\\| *)?)(?:\\\\n((?:(?! *\\\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\\\n|$))*)\\\\n*|$)").replace("hr",D).replace("heading"," {0,3}#{1,6}(?:\\\\s|$)").replace("blockquote"," {0,3}>").replace("code","(?: {4}| {0,3} )[^\\\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\\\n]*\\\\n)|~~~)[^\\\\n]*\\\\n").replace("list"," {0,3}(?:[*+-]|1[.)])[ \\\\t]").replace("html","</?(?:tag)(?: +|\\\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",X).getRegex(),rt={...te,lheading:Ue,table:ce,paragraph:g(V).replace("hr",D).replace("heading"," {0,3}#{1,6}(?:\\\\s|$)").replace("|lheading","").replace("table",ce).replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\\\n]*\\\\n)|~~~)[^\\\\n]*\\\\n").replace("list"," {0,3}(?:[*+-]|1[.)])[ \\\\t]+[^ \\\\t\\\\n]").replace("html","</?(?:tag)(?: +|\\\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",X).getRegex()},st={...te,html:g(`^ *(?:comment *(?:\\\\n|\\\\s*$)|<(tag)[\\\\s\\\\S]+?</\\\\1> *(?:\\\\n{2,}|\\\\s*$)|<tag(?:"[^"]*"|\'[^\']*\'|\\\\s[^\'"/>\\\\s]*)*?/?> *(?:\\\\n{2,}|\\\\s*$))`).replace("comment",ee).replace(/tag/g,"(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\\\b)\\\\w+(?!:|[^\\\\w\\\\s@]*@)\\\\b").getRegex(),def:/^ *\\[([^\\]]+)\\]: *<?([^\\s>]+)>?(?: +(["(][^\\n]+[")]))? *(?:\\n+|$)/,heading:/^(#{1,6})(.*)(?:\\n+|$)/,fences:A,lheading:/^(.+?)\\n {0,3}(=+|-+) *(?:\\n+|$)/,paragraph:g(V).replace("hr",D).replace("heading",` *#{1,6} *[^\n]`).replace("lheading",be).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},it=/^\\\\([!"#$%&\'()*+,\\-./:;<=>?@\\[\\]\\\\^_`{|}~])/,lt=/^(`+)([^`]|[^`][\\s\\S]*?[^`])\\1(?!`)/,we=/^( {2,}|\\\\)\\n(?!\\s*$)/,at=/^(`+|[^`])(?:(?= {2,}\\n)|[\\s\\S]*?(?:(?=[\\\\<!\\[`*_]|\\b_|$)|[^ ](?= {2,}\\n)))/,P=/[\\p{P}\\p{S}]/u,Q=/[\\s\\p{P}\\p{S}]/u,ne=/[^\\s\\p{P}\\p{S}]/u,ot=g(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,Q).getRegex(),ye=/(?!~)[\\p{P}\\p{S}]/u,ct=/(?!~)[\\s\\p{P}\\p{S}]/u,ut=/(?:[^\\s\\p{P}\\p{S}]|~)/u,ht=g(/link|precode-code|html/,"g").replace("link",/\\[(?:[^\\[\\]`]|(?<a>`+)[^`]+\\k<a>(?!`))*?\\]\\((?:\\\\[\\s\\S]|[^\\\\\\(\\)]|\\((?:\\\\[\\s\\S]|[^\\\\\\(\\)])*\\))*\\)/).replace("precode-",Xe?"(?<!`)()":"(^^|[^`])").replace("code",/(?<b>`+)[^`]+\\k<b>(?!`)/).replace("html",/<(?! )[^<>]*?>/).getRegex(),Re=/^(?:\\*+(?:((?!\\*)punct)|([^\\s*]))?)|^_+(?:((?!_)punct)|([^\\s_]))?/,pt=g(Re,"u").replace(/punct/g,P).getRegex(),ft=g(Re,"u").replace(/punct/g,ye).getRegex(),Te="^[^_*]*?__[^_*]*?\\\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\\\*)punct(\\\\*+)(?=[\\\\s]|$)|notPunctSpace(\\\\*+)(?!\\\\*)(?=punctSpace|$)|(?!\\\\*)punctSpace(\\\\*+)(?=notPunctSpace)|[\\\\s](\\\\*+)(?!\\\\*)(?=punct)|(?!\\\\*)punct(\\\\*+)(?!\\\\*)(?=punct)|notPunctSpace(\\\\*+)(?=notPunctSpace)",gt=g(Te,"gu").replace(/notPunctSpace/g,ne).replace(/punctSpace/g,Q).replace(/punct/g,P).getRegex(),kt=g(Te,"gu").replace(/notPunctSpace/g,ut).replace(/punctSpace/g,ct).replace(/punct/g,ye).getRegex(),dt=g("^[^_*]*?\\\\*\\\\*[^_*]*?_[^_*]*?(?=\\\\*\\\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,ne).replace(/punctSpace/g,Q).replace(/punct/g,P).getRegex(),xt=g(/^~~?(?:((?!~)punct)|[^\\s~])/,"u").replace(/punct/g,P).getRegex(),bt="^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)",mt=g(bt,"gu").replace(/notPunctSpace/g,ne).replace(/punctSpace/g,Q).replace(/punct/g,P).getRegex(),wt=g(/\\\\(punct)/,"gu").replace(/punct/g,P).getRegex(),yt=g(/^<(scheme:[^\\s\\x00-\\x1f<>]*|email)>/).replace("scheme",/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace("email",/[a-zA-Z0-9.!#$%&\'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex(),Rt=g(ee).replace("(?:-->|$)","-->").getRegex(),Tt=g("^comment|^</[a-zA-Z][\\\\w:-]*\\\\s*>|^<[a-zA-Z][\\\\w-]*(?:attribute)*?\\\\s*/?>|^<\\\\?[\\\\s\\\\S]*?\\\\?>|^<![a-zA-Z]+\\\\s[\\\\s\\\\S]*?>|^<!\\\\[CDATA\\\\[[\\\\s\\\\S]*?\\\\]\\\\]>").replace("comment",Rt).replace("attribute",/\\s+[a-zA-Z:_][\\w.:-]*(?:\\s*=\\s*"[^"]*"|\\s*=\\s*\'[^\']*\'|\\s*=\\s*[^\\s"\'=<>`]+)?/).getRegex(),Z=/(?:\\[(?:\\\\[\\s\\S]|[^\\[\\]\\\\])*\\]|\\\\[\\s\\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\\])|[^\\[\\]\\\\`])*?/,St=g(/^!?\\[(label)\\]\\(\\s*(href)(?:(?:[ \\t]+(?:\\n[ \\t]*)?|\\n[ \\t]*)(title))?\\s*\\)/).replace("label",Z).replace("href",/<(?:\\\\.|[^\\n<>\\\\])+>|[^ \\t\\n\\x00-\\x1f]+|(?=\\))/).replace("title",/"(?:\\\\"?|[^"\\\\])*"|\'(?:\\\\\'?|[^\'\\\\])*\'|\\((?:\\\\\\)?|[^)\\\\])*\\)/).getRegex(),Se=g(/^!?\\[(label)\\]\\[(ref)\\]/).replace("label",Z).replace("ref",Y).getRegex(),_e=g(/^!?\\[(ref)\\](?:\\[\\])?/).replace("ref",Y).getRegex(),_t=g("reflink|nolink(?!\\\\()","g").replace("reflink",Se).replace("nolink",_e).getRegex(),ue=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,re={_backpedal:A,anyPunctuation:wt,autolink:yt,blockSkip:ht,br:we,code:lt,del:A,delLDelim:A,delRDelim:A,emStrongLDelim:pt,emStrongRDelimAst:gt,emStrongRDelimUnd:dt,escape:it,link:St,nolink:_e,punctuation:ot,reflink:Se,reflinkSearch:_t,tag:Tt,text:at,url:A},$t={...re,link:g(/^!?\\[(label)\\]\\((.*?)\\)/).replace("label",Z).getRegex(),reflink:g(/^!?\\[(label)\\]\\s*\\[([^\\]]*)\\]/).replace("label",Z).getRegex()},W={...re,emStrongRDelimAst:kt,emStrongLDelim:ft,delLDelim:xt,delRDelim:mt,url:g(/^((?:protocol):\\/\\/|www\\.)(?:[a-zA-Z0-9\\-]+\\.?)+[^\\s<]*|^email/).replace("protocol",ue).replace("email",/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(),_backpedal:/(?:[^?!.,:;*_\'"~()&]+|\\([^)]*\\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_\'"~)]+(?!$))+/,del:/^(~~?)(?=[^\\s~])((?:\\\\[\\s\\S]|[^\\\\])*?(?:\\\\[\\s\\S]|[^\\s~\\\\]))\\1(?=[^~]|$)/,text:g(/^(`+|~+|[^`~])(?:(?=[`~])|(?= {2,}\\n)|(?=[a-zA-Z0-9.!#$%&\'*+\\/=?_`{\\|}~-]+@)|[\\s\\S]*?(?:(?=[\\\\<!\\[`*~_]|\\b_|protocol:\\/\\/|www\\.|$)|[^ ](?= {2,}\\n)|[^a-zA-Z0-9.!#$%&\'*+\\/=?_`{\\|}~-](?=[a-zA-Z0-9.!#$%&\'*+\\/=?_`{\\|}~-]+@)))/).replace("protocol",ue).getRegex()},Et={...W,br:g(we).replace("{2,}","*").getRegex(),text:g(W.text).replace("\\\\b_","\\\\b_| {2,}\\\\n").replace(/\\{2,\\}/g,"*").getRegex()},q={normal:te,gfm:rt,pedantic:st},v={normal:re,gfm:W,breaks:Et,pedantic:$t},zt={"&":"&amp;","<":"&lt;",">":"&gt;",\'"\':"&quot;","\'":"&#39;"},he=t=>zt[t];function _(t,e){if(e){if(x.escapeTest.test(t))return t.replace(x.escapeReplace,he)}else if(x.escapeTestNoEncode.test(t))return t.replace(x.escapeReplaceNoEncode,he);return t}function pe(t){try{t=encodeURI(t).replace(x.percentDecode,"%")}catch{return null}return t}function fe(t,e){let n=t.replace(x.findPipe,(i,a,l)=>{let o=!1,c=a;for(;--c>=0&&l[c]==="\\\\";)o=!o;return o?"|":" |"}),r=n.split(x.splitPipe),s=0;if(r[0].trim()||r.shift(),r.length>0&&!r.at(-1)?.trim()&&r.pop(),e)if(r.length>e)r.splice(e);else for(;r.length<e;)r.push("");for(;s<r.length;s++)r[s]=r[s].trim().replace(x.slashPipe,"|");return r}function E(t,e,n){let r=t.length;if(r===0)return"";let s=0;for(;s<r;){let i=t.charAt(r-s-1);if(i===e&&!n)s++;else if(i!==e&&n)s++;else break}return t.slice(0,r-s)}function ge(t){let e=t.split(`\n`),n=e.length-1;for(;n>=0&&x.blankLine.test(e[n]);)n--;return e.length-n<=2?t:e.slice(0,n+1).join(`\n`)}function At(t,e){if(t.indexOf(e[1])===-1)return-1;let n=0;for(let r=0;r<t.length;r++)if(t[r]==="\\\\")r++;else if(t[r]===e[0])n++;else if(t[r]===e[1]&&(n--,n<0))return r;return n>0?-2:-1}function Lt(t,e=0){let n=e,r="";for(let s of t)if(s===" "){let i=4-n%4;r+=" ".repeat(i),n+=i}else r+=s,n++;return r}function ke(t,e,n,r,s){let i=e.href,a=e.title||null,l=t[1].replace(s.other.outputLinkReplace,"$1");r.state.inLink=!0;let o={type:t[0].charAt(0)==="!"?"image":"link",raw:n,href:i,title:a,text:l,tokens:r.inlineTokens(l)};return r.state.inLink=!1,o}function It(t,e,n){let r=t.match(n.other.indentCodeCompensation);if(r===null)return e;let s=r[1];return e.split(`\n`).map(i=>{let a=i.match(n.other.beginningSpace);if(a===null)return i;let[l]=a;return l.length>=s.length?i.slice(s.length):i}).join(`\n`)}var j=class{options;rules;lexer;constructor(t){this.options=t||I}space(t){let e=this.rules.block.newline.exec(t);if(e&&e[0].length>0)return{type:"space",raw:e[0]}}code(t){let e=this.rules.block.code.exec(t);if(e){let n=this.options.pedantic?e[0]:ge(e[0]),r=n.replace(this.rules.other.codeRemoveIndent,"");return{type:"code",raw:n,codeBlockStyle:"indented",text:r}}}fences(t){let e=this.rules.block.fences.exec(t);if(e){let n=e[0],r=It(n,e[3]||"",this.rules);return{type:"code",raw:n,lang:e[2]?e[2].trim().replace(this.rules.inline.anyPunctuation,"$1"):e[2],text:r}}}heading(t){let e=this.rules.block.heading.exec(t);if(e){let n=e[2].trim();if(this.rules.other.endingHash.test(n)){let r=E(n,"#");(this.options.pedantic||!r||this.rules.other.endingSpaceChar.test(r))&&(n=r.trim())}return{type:"heading",raw:E(e[0],`\n`),depth:e[1].length,text:n,tokens:this.lexer.inline(n)}}}hr(t){let e=this.rules.block.hr.exec(t);if(e)return{type:"hr",raw:E(e[0],`\n`)}}blockquote(t){let e=this.rules.block.blockquote.exec(t);if(e){let n=E(e[0],`\n`).split(`\n`),r="",s="",i=[];for(;n.length>0;){let a=!1,l=[],o;for(o=0;o<n.length;o++)if(this.rules.other.blockquoteStart.test(n[o]))l.push(n[o]),a=!0;else if(!a)l.push(n[o]);else break;n=n.slice(o);let c=l.join(`\n`),h=c.replace(this.rules.other.blockquoteSetextReplace,`\n $1`).replace(this.rules.other.blockquoteSetextReplace2,"");r=r?`${r}\n${c}`:c,s=s?`${s}\n${h}`:h;let u=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTokens(h,i,!0),this.lexer.state.top=u,n.length===0)break;let p=i.at(-1);if(p?.type==="code")break;if(p?.type==="blockquote"){let d=p,k=d.raw+`\n`+n.join(`\n`),m=this.blockquote(k);i[i.length-1]=m,r=r.substring(0,r.length-d.raw.length)+m.raw,s=s.substring(0,s.length-d.text.length)+m.text;break}else if(p?.type==="list"){let d=p,k=d.raw+`\n`+n.join(`\n`),m=this.list(k);i[i.length-1]=m,r=r.substring(0,r.length-p.raw.length)+m.raw,s=s.substring(0,s.length-d.raw.length)+m.raw,n=k.substring(i.at(-1).raw.length).split(`\n`);continue}}return{type:"blockquote",raw:r,tokens:i,text:s}}}list(t){let e=this.rules.block.list.exec(t);if(e){let n=e[1].trim(),r=n.length>1,s={type:"list",raw:"",ordered:r,start:r?+n.slice(0,-1):"",loose:!1,items:[]};n=r?`\\\\d{1,9}\\\\${n.slice(-1)}`:`\\\\${n}`,this.options.pedantic&&(n=r?n:"[*+-]");let i=this.rules.other.listItemRegex(n),a=!1;for(;t;){let o=!1,c="",h="";if(!(e=i.exec(t))||this.rules.block.hr.test(t))break;c=e[0],t=t.substring(c.length);let u=Lt(e[2].split(`\n`,1)[0],e[1].length),p=t.split(`\n`,1)[0],d=!u.trim(),k=0;if(this.options.pedantic?(k=2,h=u.trimStart()):d?k=e[1].length+1:(k=u.search(this.rules.other.nonSpaceChar),k=k>4?1:k,h=u.slice(k),k+=e[1].length),d&&this.rules.other.blankLine.test(p)&&(c+=p+`\n`,t=t.substring(p.length+1),o=!0),!o){let m=this.rules.other.nextBulletRegex(k),w=this.rules.other.hrRegex(k),y=this.rules.other.fencesBeginRegex(k),$=this.rules.other.headingBeginRegex(k),H=this.rules.other.htmlBeginRegex(k),z=this.rules.other.blockquoteBeginRegex(k);for(;t;){let b=t.split(`\n`,1)[0],S;if(p=b,this.options.pedantic?(p=p.replace(this.rules.other.listReplaceNesting," "),S=p):S=p.replace(this.rules.other.tabCharGlobal," "),y.test(p)||$.test(p)||H.test(p)||z.test(p)||m.test(p)||w.test(p))break;if(S.search(this.rules.other.nonSpaceChar)>=k||!p.trim())h+=`\n`+S.slice(k);else{if(d||u.replace(this.rules.other.tabCharGlobal," ").search(this.rules.other.nonSpaceChar)>=4||y.test(u)||$.test(u)||w.test(u))break;h+=`\n`+p}d=!p.trim(),c+=b+`\n`,t=t.substring(b.length+1),u=S.slice(k)}}s.loose||(a?s.loose=!0:this.rules.other.doubleBlankLine.test(c)&&(a=!0)),s.items.push({type:"list_item",raw:c,task:!!this.options.gfm&&this.rules.other.listIsTask.test(h),loose:!1,text:h,tokens:[]}),s.raw+=c}let l=s.items.at(-1);if(l)l.raw=l.raw.trimEnd(),l.text=l.text.trimEnd();else return;s.raw=s.raw.trimEnd();for(let o of s.items){this.lexer.state.top=!1,o.tokens=this.lexer.blockTokens(o.text,[]);let c=o.tokens[0];if(o.task&&(c?.type==="text"||c?.type==="paragraph")){o.text=o.text.replace(this.rules.other.listReplaceTask,""),c.raw=c.raw.replace(this.rules.other.listReplaceTask,""),c.text=c.text.replace(this.rules.other.listReplaceTask,"");for(let u=this.lexer.inlineQueue.length-1;u>=0;u--)if(this.rules.other.listIsTask.test(this.lexer.inlineQueue[u].src)){this.lexer.inlineQueue[u].src=this.lexer.inlineQueue[u].src.replace(this.rules.other.listReplaceTask,"");break}let h=this.rules.other.listTaskCheckbox.exec(o.raw);if(h){let u={type:"checkbox",raw:h[0]+" ",checked:h[0]!=="[ ]"};o.checked=u.checked,s.loose?o.tokens[0]&&["paragraph","text"].includes(o.tokens[0].type)&&"tokens"in o.tokens[0]&&o.tokens[0].tokens?(o.tokens[0].raw=u.raw+o.tokens[0].raw,o.tokens[0].text=u.raw+o.tokens[0].text,o.tokens[0].tokens.unshift(u)):o.tokens.unshift({type:"paragraph",raw:u.raw,text:u.raw,tokens:[u]}):o.tokens.unshift(u)}}else o.task&&(o.task=!1);if(!s.loose){let h=o.tokens.filter(p=>p.type==="space"),u=h.length>0&&h.some(p=>this.rules.other.anyLine.test(p.raw));s.loose=u}}if(s.loose)for(let o of s.items){o.loose=!0;for(let c of o.tokens)c.type==="text"&&(c.type="paragraph")}return s}}html(t){let e=this.rules.block.html.exec(t);if(e){let n=ge(e[0]);return{type:"html",block:!0,raw:n,pre:e[1]==="pre"||e[1]==="script"||e[1]==="style",text:n}}}def(t){let e=this.rules.block.def.exec(t);if(e){let n=e[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal," "),r=e[2]?e[2].replace(this.rules.other.hrefBrackets,"$1").replace(this.rules.inline.anyPunctuation,"$1"):"",s=e[3]?e[3].substring(1,e[3].length-1).replace(this.rules.inline.anyPunctuation,"$1"):e[3];return{type:"def",tag:n,raw:E(e[0],`\n`),href:r,title:s}}}table(t){let e=this.rules.block.table.exec(t);if(!e||!this.rules.other.tableDelimiter.test(e[2]))return;let n=fe(e[1]),r=e[2].replace(this.rules.other.tableAlignChars,"").split("|"),s=e[3]?.trim()?e[3].replace(this.rules.other.tableRowBlankLine,"").split(`\n`):[],i={type:"table",raw:E(e[0],`\n`),header:[],align:[],rows:[]};if(n.length===r.length){for(let a of r)this.rules.other.tableAlignRight.test(a)?i.align.push("right"):this.rules.other.tableAlignCenter.test(a)?i.align.push("center"):this.rules.other.tableAlignLeft.test(a)?i.align.push("left"):i.align.push(null);for(let a=0;a<n.length;a++)i.header.push({text:n[a],tokens:this.lexer.inline(n[a]),header:!0,align:i.align[a]});for(let a of s)i.rows.push(fe(a,i.header.length).map((l,o)=>({text:l,tokens:this.lexer.inline(l),header:!1,align:i.align[o]})));return i}}lheading(t){let e=this.rules.block.lheading.exec(t);if(e){let n=e[1].trim();return{type:"heading",raw:E(e[0],`\n`),depth:e[2].charAt(0)==="="?1:2,text:n,tokens:this.lexer.inline(n)}}}paragraph(t){let e=this.rules.block.paragraph.exec(t);if(e){let n=e[1].charAt(e[1].length-1)===`\n`?e[1].slice(0,-1):e[1];return{type:"paragraph",raw:e[0],text:n,tokens:this.lexer.inline(n)}}}text(t){let e=this.rules.block.text.exec(t);if(e)return{type:"text",raw:e[0],text:e[0],tokens:this.lexer.inline(e[0])}}escape(t){let e=this.rules.inline.escape.exec(t);if(e)return{type:"escape",raw:e[0],text:e[1]}}tag(t){let e=this.rules.inline.tag.exec(t);if(e)return!this.lexer.state.inLink&&this.rules.other.startATag.test(e[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&this.rules.other.endATag.test(e[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&this.rules.other.startPreScriptTag.test(e[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&this.rules.other.endPreScriptTag.test(e[0])&&(this.lexer.state.inRawBlock=!1),{type:"html",raw:e[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:e[0]}}link(t){let e=this.rules.inline.link.exec(t);if(e){let n=e[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(n)){if(!this.rules.other.endAngleBracket.test(n))return;let i=E(n.slice(0,-1),"\\\\");if((n.length-i.length)%2===0)return}else{let i=At(e[2],"()");if(i===-2)return;if(i>-1){let a=(e[0].indexOf("!")===0?5:4)+e[1].length+i;e[2]=e[2].substring(0,i),e[0]=e[0].substring(0,a).trim(),e[3]=""}}let r=e[2],s="";if(this.options.pedantic){let i=this.rules.other.pedanticHrefTitle.exec(r);i&&(r=i[1],s=i[3])}else s=e[3]?e[3].slice(1,-1):"";return r=r.trim(),this.rules.other.startAngleBracket.test(r)&&(this.options.pedantic&&!this.rules.other.endAngleBracket.test(n)?r=r.slice(1):r=r.slice(1,-1)),ke(e,{href:r&&r.replace(this.rules.inline.anyPunctuation,"$1"),title:s&&s.replace(this.rules.inline.anyPunctuation,"$1")},e[0],this.lexer,this.rules)}}reflink(t,e){let n;if((n=this.rules.inline.reflink.exec(t))||(n=this.rules.inline.nolink.exec(t))){let r=(n[2]||n[1]).replace(this.rules.other.multipleSpaceGlobal," "),s=e[r.toLowerCase()];if(!s){let i=n[0].charAt(0);return{type:"text",raw:i,text:i}}return ke(n,s,n[0],this.lexer,this.rules)}}emStrong(t,e,n=""){let r=this.rules.inline.emStrongLDelim.exec(t);if(!(!r||!r[1]&&!r[2]&&!r[3]&&!r[4]||r[4]&&n.match(this.rules.other.unicodeAlphaNumeric))&&(!(r[1]||r[3])||!n||this.rules.inline.punctuation.exec(n))){let s=[...r[0]].length-1,i,a,l=s,o=0,c=r[0][0]==="*"?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(c.lastIndex=0,e=e.slice(-1*t.length+s);(r=c.exec(e))!==null;){if(i=r[1]||r[2]||r[3]||r[4]||r[5]||r[6],!i)continue;if(a=[...i].length,r[3]||r[4]){l+=a;continue}else if((r[5]||r[6])&&s%3&&!((s+a)%3)){o+=a;continue}if(l-=a,l>0)continue;a=Math.min(a,a+l+o);let h=[...r[0]][0].length,u=t.slice(0,s+r.index+h+a);if(Math.min(s,a)%2){let d=u.slice(1,-1);return{type:"em",raw:u,text:d,tokens:this.lexer.inlineTokens(d)}}let p=u.slice(2,-2);return{type:"strong",raw:u,text:p,tokens:this.lexer.inlineTokens(p)}}}}codespan(t){let e=this.rules.inline.code.exec(t);if(e){let n=e[2].replace(this.rules.other.newLineCharGlobal," "),r=this.rules.other.nonSpaceChar.test(n),s=this.rules.other.startingSpaceChar.test(n)&&this.rules.other.endingSpaceChar.test(n);return r&&s&&(n=n.substring(1,n.length-1)),{type:"codespan",raw:e[0],text:n}}}br(t){let e=this.rules.inline.br.exec(t);if(e)return{type:"br",raw:e[0]}}del(t,e,n=""){let r=this.rules.inline.delLDelim.exec(t);if(r&&(!r[1]||!n||this.rules.inline.punctuation.exec(n))){let s=[...r[0]].length-1,i,a,l=s,o=this.rules.inline.delRDelim;for(o.lastIndex=0,e=e.slice(-1*t.length+s);(r=o.exec(e))!==null;){if(i=r[1]||r[2]||r[3]||r[4]||r[5]||r[6],!i||(a=[...i].length,a!==s))continue;if(r[3]||r[4]){l+=a;continue}if(l-=a,l>0)continue;a=Math.min(a,a+l);let c=[...r[0]][0].length,h=t.slice(0,s+r.index+c+a),u=h.slice(s,-s);return{type:"del",raw:h,text:u,tokens:this.lexer.inlineTokens(u)}}}}autolink(t){let e=this.rules.inline.autolink.exec(t);if(e){let n,r;return e[2]==="@"?(n=e[1],r="mailto:"+n):(n=e[1],r=n),{type:"link",raw:e[0],text:n,href:r,tokens:[{type:"text",raw:n,text:n}]}}}url(t){let e;if(e=this.rules.inline.url.exec(t)){let n,r;if(e[2]==="@")n=e[0],r="mailto:"+n;else{let s;do s=e[0],e[0]=this.rules.inline._backpedal.exec(e[0])?.[0]??"";while(s!==e[0]);n=e[0],e[1]==="www."?r="http://"+e[0]:r=e[0]}return{type:"link",raw:e[0],text:n,href:r,tokens:[{type:"text",raw:n,text:n}]}}}inlineText(t){let e=this.rules.inline.text.exec(t);if(e){let n=this.lexer.state.inRawBlock;return{type:"text",raw:e[0],text:e[0],escaped:n}}}},R=class G{tokens;options;state;inlineQueue;tokenizer;constructor(e){this.tokens=[],this.tokens.links=Object.create(null),this.options=e||I,this.options.tokenizer=this.options.tokenizer||new j,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,top:!0};let n={other:x,block:q.normal,inline:v.normal};this.options.pedantic?(n.block=q.pedantic,n.inline=v.pedantic):this.options.gfm&&(n.block=q.gfm,this.options.breaks?n.inline=v.breaks:n.inline=v.gfm),this.tokenizer.rules=n}static get rules(){return{block:q,inline:v}}static lex(e,n){return new G(n).lex(e)}static lexInline(e,n){return new G(n).inlineTokens(e)}lex(e){e=e.replace(x.carriageReturn,`\n`),this.blockTokens(e,this.tokens);for(let n=0;n<this.inlineQueue.length;n++){let r=this.inlineQueue[n];this.inlineTokens(r.src,r.tokens)}return this.inlineQueue=[],this.tokens}blockTokens(e,n=[],r=!1){this.tokenizer.lexer=this,this.options.pedantic&&(e=e.replace(x.tabCharGlobal," ").replace(x.spaceLine,""));let s=1/0;for(;e;){if(e.length<s)s=e.length;else{this.infiniteLoopError(e.charCodeAt(0));break}let i;if(this.options.extensions?.block?.some(l=>(i=l.call({lexer:this},e,n))?(e=e.substring(i.raw.length),n.push(i),!0):!1))continue;if(i=this.tokenizer.space(e)){e=e.substring(i.raw.length);let l=n.at(-1);i.raw.length===1&&l!==void 0?l.raw+=`\n`:n.push(i);continue}if(i=this.tokenizer.code(e)){e=e.substring(i.raw.length);let l=n.at(-1);l?.type==="paragraph"||l?.type==="text"?(l.raw+=(l.raw.endsWith(`\n`)?"":`\n`)+i.raw,l.text+=`\n`+i.text,this.inlineQueue.at(-1).src=l.text):n.push(i);continue}if(i=this.tokenizer.fences(e)){e=e.substring(i.raw.length),n.push(i);continue}if(i=this.tokenizer.heading(e)){e=e.substring(i.raw.length),n.push(i);continue}if(i=this.tokenizer.hr(e)){e=e.substring(i.raw.length),n.push(i);continue}if(i=this.tokenizer.blockquote(e)){e=e.substring(i.raw.length),n.push(i);continue}if(i=this.tokenizer.list(e)){e=e.substring(i.raw.length),n.push(i);continue}if(i=this.tokenizer.html(e)){e=e.substring(i.raw.length),n.push(i);continue}if(i=this.tokenizer.def(e)){e=e.substring(i.raw.length);let l=n.at(-1);l?.type==="paragraph"||l?.type==="text"?(l.raw+=(l.raw.endsWith(`\n`)?"":`\n`)+i.raw,l.text+=`\n`+i.raw,this.inlineQueue.at(-1).src=l.text):this.tokens.links[i.tag]||(this.tokens.links[i.tag]={href:i.href,title:i.title},n.push(i));continue}if(i=this.tokenizer.table(e)){e=e.substring(i.raw.length),n.push(i);continue}if(i=this.tokenizer.lheading(e)){e=e.substring(i.raw.length),n.push(i);continue}let a=e;if(this.options.extensions?.startBlock){let l=1/0,o=e.slice(1),c;this.options.extensions.startBlock.forEach(h=>{c=h.call({lexer:this},o),typeof c=="number"&&c>=0&&(l=Math.min(l,c))}),l<1/0&&l>=0&&(a=e.substring(0,l+1))}if(this.state.top&&(i=this.tokenizer.paragraph(a))){let l=n.at(-1);r&&l?.type==="paragraph"?(l.raw+=(l.raw.endsWith(`\n`)?"":`\n`)+i.raw,l.text+=`\n`+i.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=l.text):n.push(i),r=a.length!==e.length,e=e.substring(i.raw.length);continue}if(i=this.tokenizer.text(e)){e=e.substring(i.raw.length);let l=n.at(-1);l?.type==="text"?(l.raw+=(l.raw.endsWith(`\n`)?"":`\n`)+i.raw,l.text+=`\n`+i.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=l.text):n.push(i);continue}if(e){this.infiniteLoopError(e.charCodeAt(0));break}}return this.state.top=!0,n}inline(e,n=[]){return this.inlineQueue.push({src:e,tokens:n}),n}inlineTokens(e,n=[]){this.tokenizer.lexer=this;let r=e;if(this.tokens.links){let l=Object.keys(this.tokens.links);l.length>0&&(r=r.replace(this.tokenizer.rules.inline.reflinkSearch,o=>l.includes(o.slice(o.lastIndexOf("[")+1,-1))?"["+"a".repeat(o.length-2)+"]":o))}r=r.replace(this.tokenizer.rules.inline.anyPunctuation,"++"),r=r.replace(this.tokenizer.rules.inline.blockSkip,(l,o,c)=>{let h=c?c.length:0;return l.slice(0,h)+"["+"a".repeat(l.length-h-2)+"]"}),r=this.options.hooks?.emStrongMask?.call({lexer:this},r)??r;let s=!1,i="",a=1/0;for(;e;){if(e.length<a)a=e.length;else{this.infiniteLoopError(e.charCodeAt(0));break}s||(i=""),s=!1;let l;if(this.options.extensions?.inline?.some(c=>(l=c.call({lexer:this},e,n))?(e=e.substring(l.raw.length),n.push(l),!0):!1))continue;if(l=this.tokenizer.escape(e)){e=e.substring(l.raw.length),n.push(l);continue}if(l=this.tokenizer.tag(e)){e=e.substring(l.raw.length),n.push(l);continue}if(l=this.tokenizer.link(e)){e=e.substring(l.raw.length),n.push(l);continue}if(l=this.tokenizer.reflink(e,this.tokens.links)){e=e.substring(l.raw.length);let c=n.at(-1);l.type==="text"&&c?.type==="text"?(c.raw+=l.raw,c.text+=l.text):n.push(l);continue}if(l=this.tokenizer.emStrong(e,r,i)){e=e.substring(l.raw.length),n.push(l);continue}if(l=this.tokenizer.codespan(e)){e=e.substring(l.raw.length),n.push(l);continue}if(l=this.tokenizer.br(e)){e=e.substring(l.raw.length),n.push(l);continue}if(l=this.tokenizer.del(e,r,i)){e=e.substring(l.raw.length),n.push(l);continue}if(l=this.tokenizer.autolink(e)){e=e.substring(l.raw.length),n.push(l);continue}if(!this.state.inLink&&(l=this.tokenizer.url(e))){e=e.substring(l.raw.length),n.push(l);continue}let o=e;if(this.options.extensions?.startInline){let c=1/0,h=e.slice(1),u;this.options.extensions.startInline.forEach(p=>{u=p.call({lexer:this},h),typeof u=="number"&&u>=0&&(c=Math.min(c,u))}),c<1/0&&c>=0&&(o=e.substring(0,c+1))}if(l=this.tokenizer.inlineText(o)){e=e.substring(l.raw.length),l.raw.slice(-1)!=="_"&&(i=l.raw.slice(-1)),s=!0;let c=n.at(-1);c?.type==="text"?(c.raw+=l.raw,c.text+=l.text):n.push(l);continue}if(e){this.infiniteLoopError(e.charCodeAt(0));break}}return n}infiniteLoopError(e){let n="Infinite loop on byte: "+e;if(this.options.silent)console.error(n);else throw new Error(n)}},F=class{options;parser;constructor(t){this.options=t||I}space(t){return""}code({text:t,lang:e,escaped:n}){let r=(e||"").match(x.notSpaceStart)?.[0],s=t.replace(x.endingNewline,"")+`\n`;return r?\'<pre><code class="language-\'+_(r)+\'">\'+(n?s:_(s,!0))+`</code></pre>\n`:"<pre><code>"+(n?s:_(s,!0))+`</code></pre>\n`}blockquote({tokens:t}){return`<blockquote>\n${this.parser.parse(t)}</blockquote>\n`}html({text:t}){return t}def(t){return""}heading({tokens:t,depth:e}){return`<h${e}>${this.parser.parseInline(t)}</h${e}>\n`}hr(t){return`<hr>\n`}list(t){let e=t.ordered,n=t.start,r="";for(let a=0;a<t.items.length;a++){let l=t.items[a];r+=this.listitem(l)}let s=e?"ol":"ul",i=e&&n!==1?\' start="\'+n+\'"\':"";return"<"+s+i+`>\n`+r+"</"+s+`>\n`}listitem(t){return`<li>${this.parser.parse(t.tokens)}</li>\n`}checkbox({checked:t}){return"<input "+(t?\'checked="" \':"")+\'disabled="" type="checkbox"> \'}paragraph({tokens:t}){return`<p>${this.parser.parseInline(t)}</p>\n`}table(t){let e="",n="";for(let s=0;s<t.header.length;s++)n+=this.tablecell(t.header[s]);e+=this.tablerow({text:n});let r="";for(let s=0;s<t.rows.length;s++){let i=t.rows[s];n="";for(let a=0;a<i.length;a++)n+=this.tablecell(i[a]);r+=this.tablerow({text:n})}return r&&(r=`<tbody>${r}</tbody>`),`<table>\n<thead>\n`+e+`</thead>\n`+r+`</table>\n`}tablerow({text:t}){return`<tr>\n${t}</tr>\n`}tablecell(t){let e=this.parser.parseInline(t.tokens),n=t.header?"th":"td";return(t.align?`<${n} align="${t.align}">`:`<${n}>`)+e+`</${n}>\n`}strong({tokens:t}){return`<strong>${this.parser.parseInline(t)}</strong>`}em({tokens:t}){return`<em>${this.parser.parseInline(t)}</em>`}codespan({text:t}){return`<code>${_(t,!0)}</code>`}br(t){return"<br>"}del({tokens:t}){return`<del>${this.parser.parseInline(t)}</del>`}link({href:t,title:e,tokens:n}){let r=this.parser.parseInline(n),s=pe(t);if(s===null)return r;t=s;let i=\'<a href="\'+t+\'"\';return e&&(i+=\' title="\'+_(e)+\'"\'),i+=">"+r+"</a>",i}image({href:t,title:e,text:n,tokens:r}){r&&(n=this.parser.parseInline(r,this.parser.textRenderer));let s=pe(t);if(s===null)return _(n);t=s;let i=`<img src="${t}" alt="${_(n)}"`;return e&&(i+=` title="${_(e)}"`),i+=">",i}text(t){return"tokens"in t&&t.tokens?this.parser.parseInline(t.tokens):"escaped"in t&&t.escaped?t.text:_(t.text)}},se=class{strong({text:t}){return t}em({text:t}){return t}codespan({text:t}){return t}del({text:t}){return t}html({text:t}){return t}text({text:t}){return t}link({text:t}){return""+t}image({text:t}){return""+t}br(){return""}checkbox({raw:t}){return t}},T=class U{options;renderer;textRenderer;constructor(e){this.options=e||I,this.options.renderer=this.options.renderer||new F,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new se}static parse(e,n){return new U(n).parse(e)}static parseInline(e,n){return new U(n).parseInline(e)}parse(e){this.renderer.parser=this;let n="";for(let r=0;r<e.length;r++){let s=e[r];if(this.options.extensions?.renderers?.[s.type]){let a=s,l=this.options.extensions.renderers[a.type].call({parser:this},a);if(l!==!1||!["space","hr","heading","code","table","blockquote","list","html","def","paragraph","text"].includes(a.type)){n+=l||"";continue}}let i=s;switch(i.type){case"space":{n+=this.renderer.space(i);break}case"hr":{n+=this.renderer.hr(i);break}case"heading":{n+=this.renderer.heading(i);break}case"code":{n+=this.renderer.code(i);break}case"table":{n+=this.renderer.table(i);break}case"blockquote":{n+=this.renderer.blockquote(i);break}case"list":{n+=this.renderer.list(i);break}case"checkbox":{n+=this.renderer.checkbox(i);break}case"html":{n+=this.renderer.html(i);break}case"def":{n+=this.renderer.def(i);break}case"paragraph":{n+=this.renderer.paragraph(i);break}case"text":{n+=this.renderer.text(i);break}default:{let a=\'Token with "\'+i.type+\'" type was not found.\';if(this.options.silent)return console.error(a),"";throw new Error(a)}}}return n}parseInline(e,n=this.renderer){this.renderer.parser=this;let r="";for(let s=0;s<e.length;s++){let i=e[s];if(this.options.extensions?.renderers?.[i.type]){let l=this.options.extensions.renderers[i.type].call({parser:this},i);if(l!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(i.type)){r+=l||"";continue}}let a=i;switch(a.type){case"escape":{r+=n.text(a);break}case"html":{r+=n.html(a);break}case"link":{r+=n.link(a);break}case"image":{r+=n.image(a);break}case"checkbox":{r+=n.checkbox(a);break}case"strong":{r+=n.strong(a);break}case"em":{r+=n.em(a);break}case"codespan":{r+=n.codespan(a);break}case"br":{r+=n.br(a);break}case"del":{r+=n.del(a);break}case"text":{r+=n.text(a);break}default:{let l=\'Token with "\'+a.type+\'" type was not found.\';if(this.options.silent)return console.error(l),"";throw new Error(l)}}}return r}},B=class{options;block;constructor(t){this.options=t||I}static passThroughHooks=new Set(["preprocess","postprocess","processAllTokens","emStrongMask"]);static passThroughHooksRespectAsync=new Set(["preprocess","postprocess","processAllTokens"]);preprocess(t){return t}postprocess(t){return t}processAllTokens(t){return t}emStrongMask(t){return t}provideLexer(t=this.block){return t?R.lex:R.lexInline}provideParser(t=this.block){return t?T.parse:T.parseInline}},Ct=class{defaults=J();options=this.setOptions;parse=this.parseMarkdown(!0);parseInline=this.parseMarkdown(!1);Parser=T;Renderer=F;TextRenderer=se;Lexer=R;Tokenizer=j;Hooks=B;constructor(...t){this.use(...t)}walkTokens(t,e){let n=[];for(let r of t)switch(n=n.concat(e.call(this,r)),r.type){case"table":{let s=r;for(let i of s.header)n=n.concat(this.walkTokens(i.tokens,e));for(let i of s.rows)for(let a of i)n=n.concat(this.walkTokens(a.tokens,e));break}case"list":{let s=r;n=n.concat(this.walkTokens(s.items,e));break}default:{let s=r;this.defaults.extensions?.childTokens?.[s.type]?this.defaults.extensions.childTokens[s.type].forEach(i=>{let a=s[i].flat(1/0);n=n.concat(this.walkTokens(a,e))}):s.tokens&&(n=n.concat(this.walkTokens(s.tokens,e)))}}return n}use(...t){let e=this.defaults.extensions||{renderers:{},childTokens:{}};return t.forEach(n=>{let r={...n};if(r.async=this.defaults.async||r.async||!1,n.extensions&&(n.extensions.forEach(s=>{if(!s.name)throw new Error("extension name required");if("renderer"in s){let i=e.renderers[s.name];i?e.renderers[s.name]=function(...a){let l=s.renderer.apply(this,a);return l===!1&&(l=i.apply(this,a)),l}:e.renderers[s.name]=s.renderer}if("tokenizer"in s){if(!s.level||s.level!=="block"&&s.level!=="inline")throw new Error("extension level must be \'block\' or \'inline\'");let i=e[s.level];i?i.unshift(s.tokenizer):e[s.level]=[s.tokenizer],s.start&&(s.level==="block"?e.startBlock?e.startBlock.push(s.start):e.startBlock=[s.start]:s.level==="inline"&&(e.startInline?e.startInline.push(s.start):e.startInline=[s.start]))}"childTokens"in s&&s.childTokens&&(e.childTokens[s.name]=s.childTokens)}),r.extensions=e),n.renderer){let s=this.defaults.renderer||new F(this.defaults);for(let i in n.renderer){if(!(i in s))throw new Error(`renderer \'${i}\' does not exist`);if(["options","parser"].includes(i))continue;let a=i,l=n.renderer[a],o=s[a];s[a]=(...c)=>{let h=l.apply(s,c);return h===!1&&(h=o.apply(s,c)),h||""}}r.renderer=s}if(n.tokenizer){let s=this.defaults.tokenizer||new j(this.defaults);for(let i in n.tokenizer){if(!(i in s))throw new Error(`tokenizer \'${i}\' does not exist`);if(["options","rules","lexer"].includes(i))continue;let a=i,l=n.tokenizer[a],o=s[a];s[a]=(...c)=>{let h=l.apply(s,c);return h===!1&&(h=o.apply(s,c)),h}}r.tokenizer=s}if(n.hooks){let s=this.defaults.hooks||new B;for(let i in n.hooks){if(!(i in s))throw new Error(`hook \'${i}\' does not exist`);if(["options","block"].includes(i))continue;let a=i,l=n.hooks[a],o=s[a];B.passThroughHooks.has(i)?s[a]=c=>{if(this.defaults.async&&B.passThroughHooksRespectAsync.has(i))return(async()=>{let u=await l.call(s,c);return o.call(s,u)})();let h=l.call(s,c);return o.call(s,h)}:s[a]=(...c)=>{if(this.defaults.async)return(async()=>{let u=await l.apply(s,c);return u===!1&&(u=await o.apply(s,c)),u})();let h=l.apply(s,c);return h===!1&&(h=o.apply(s,c)),h}}r.hooks=s}if(n.walkTokens){let s=this.defaults.walkTokens,i=n.walkTokens;r.walkTokens=function(a){let l=[];return l.push(i.call(this,a)),s&&(l=l.concat(s.call(this,a))),l}}this.defaults={...this.defaults,...r}}),this}setOptions(t){return this.defaults={...this.defaults,...t},this}lexer(t,e){return R.lex(t,e??this.defaults)}parser(t,e){return T.parse(t,e??this.defaults)}parseMarkdown(t){return(e,n)=>{let r={...n},s={...this.defaults,...r},i=this.onError(!!s.silent,!!s.async);if(this.defaults.async===!0&&r.async===!1)return i(new Error("marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise."));if(typeof e>"u"||e===null)return i(new Error("marked(): input parameter is undefined or null"));if(typeof e!="string")return i(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(e)+", string expected"));if(s.hooks&&(s.hooks.options=s,s.hooks.block=t),s.async)return(async()=>{let a=s.hooks?await s.hooks.preprocess(e):e,l=await(s.hooks?await s.hooks.provideLexer(t):t?R.lex:R.lexInline)(a,s),o=s.hooks?await s.hooks.processAllTokens(l):l;s.walkTokens&&await Promise.all(this.walkTokens(o,s.walkTokens));let c=await(s.hooks?await s.hooks.provideParser(t):t?T.parse:T.parseInline)(o,s);return s.hooks?await s.hooks.postprocess(c):c})().catch(i);try{s.hooks&&(e=s.hooks.preprocess(e));let a=(s.hooks?s.hooks.provideLexer(t):t?R.lex:R.lexInline)(e,s);s.hooks&&(a=s.hooks.processAllTokens(a)),s.walkTokens&&this.walkTokens(a,s.walkTokens);let l=(s.hooks?s.hooks.provideParser(t):t?T.parse:T.parseInline)(a,s);return s.hooks&&(l=s.hooks.postprocess(l)),l}catch(a){return i(a)}}}onError(t,e){return n=>{if(n.message+=`\nPlease report this to https://github.com/markedjs/marked.`,t){let r="<p>An error occurred:</p><pre>"+_(n.message+"",!0)+"</pre>";return e?Promise.resolve(r):r}if(e)return Promise.reject(n);throw n}}},L=new Ct;function f(t,e){return L.parse(t,e)}f.options=f.setOptions=function(t){return L.setOptions(t),f.defaults=L.defaults,de(f.defaults),f};f.getDefaults=J;f.defaults=I;f.use=function(...t){return L.use(...t),f.defaults=L.defaults,de(f.defaults),f};f.walkTokens=function(t,e){return L.walkTokens(t,e)};f.parseInline=L.parseInline;f.Parser=T;f.parser=T.parse;f.Renderer=F;f.TextRenderer=se;f.Lexer=R;f.lexer=R.lex;f.Tokenizer=j;f.Hooks=B;f.parse=f;var Jt=f.options,Kt=f.setOptions,Vt=f.use,Yt=f.walkTokens,en=f.parseInline;var tn=T.parse,nn=R.lex;var $e=/^ {0,3}:::([A-Za-z][\\w-]*)?[ \\t]*(?:\\n|$)/,Pt=/^ {0,3}:::([A-Za-z][\\w-]*)?[ \\t]*$/;function Ot(t){let e=1,n=0;for(;n<t.length;){let r=t.indexOf(`\n`,n),s=r===-1?t.slice(n):t.slice(n,r),i=Pt.exec(s);if(i){if(i[1]!==void 0)e++;else if(e--,e===0)return n}if(r===-1)break;n=r+1}return-1}var Ee=[{name:"container",level:"block",tokenizer(t){let e=$e.exec(t);if(!e)return;let n=t.slice(e[0].length),r=Ot(n);if(r<0)return;let s=n.slice(0,r),i=n.indexOf(`\n`,r),a=i===-1?n.length:i+1,l=e[0]+n.slice(0,a),o=this.lexer.blockTokens(s,[]);return{type:"container",raw:l,kind:e[1],tokens:o}},renderer(t){return t.raw}}];function ie(t){return t.includes(":::")===!1?!1:new RegExp($e.source,"m").test(t)}var Le="([^\\\\]\\\\s]+)",Mt=new RegExp(`^\\\\[\\\\^${Le}\\\\]`),Ie=new RegExp(`^ {0,3}\\\\[\\\\^${Le}\\\\]:[ \\\\t]*([^\\\\n]*)\\\\n?`);function ze(t){return/^[ \\t]*$/.test(t)}var Ae=/^(?: {4}| {0,3}\\t)/;function Nt(t){let e=0;for(;;){let r=e;for(;;){let l=t.indexOf(`\n`,r);if(l===-1)return n(e,!0);let o=t.slice(r,l);if(!ze(o))break;r=l+1}let s=t.indexOf(`\n`,r),i=s===-1?t.slice(r):t.slice(r,s+1),a=s===-1?t.slice(r):t.slice(r,s);if(!Ae.test(a))return n(e,!1);if(e=r+i.length,s===-1)return n(e,!0)}function n(r,s){let i=t.slice(0,r),a=i.split(`\n`).map(l=>ze(l)?"":l.replace(Ae,"")).join(`\n`);return{raw:i,body:a,open:s}}}function le(t){return t.includes("[^")===!1?!1:new RegExp(Ie.source,"m").test(t)}var Ce=[{name:"footnoteRef",level:"inline",tokenizer(t){let e=Mt.exec(t);if(e)return{type:"footnoteRef",raw:e[0],label:e[1]}},renderer(t){return t.raw}},{name:"footnoteDef",level:"block",tokenizer(t){let e=Ie.exec(t);if(!e)return;let n=t.slice(e[0].length),r=Nt(n),s=r.body.trim()?this.lexer.blockTokens(r.body,[]):[];return{type:"footnoteDef",raw:e[0]+r.raw,label:e[1],body:e[2],tokens:s}},renderer(t){return t.raw}}];function Oe(t,e,n){let r=0;for(let s=e;s<n;s++)r+=t[s].raw.length;return r}function vt(t,e){let n=t;return n.links=e,n}var Bt=/^ {0,3}\\$\\$/m;function Me(t){return t.includes("$$")===!1?!1:Bt.test(t)}function Dt(t,e){return t[e-2]?.type!=="list"?!0:e+1<t.length}function Ne(t,e){for(let n=t.length-2;n>=e;n--)if(t[n].type==="space"&&Dt(t,n+1)!==!1)return n+1;return-1}function ve(t){let e=t.links;if(!e)return!1;for(let n in e)return!0;return!1}function Be(t,e,n,r,s){let i=s;for(let a=e;a<n;a++){let l=t[a].raw;if(r.startsWith(l,i)===!1)return!1;i+=l.length}return!0}function M(t,e,n){return{source:t,tail:t,tokens:e,stableCount:0,stableOffset:0,degraded:!0,degradedReason:n}}function Pe(t,e){return{source:t,tail:t,tokens:e,stableCount:0,stableOffset:0,degraded:!1,degradedReason:null}}function qt(t,e){if(ve(e))return M(t,e,"link-definition");if(t.includes("\\r"))return M(t,e,"carriage-return");if(Me(t))return M(t,e,"block-math");if(ie(t))return M(t,e,"container");if(le(t))return M(t,e,"footnote-def");let n=Ne(e,1);if(n<0||Be(e,0,n,t,0)===!1)return Pe(t,e);let r=Oe(e,0,n);return{source:t,tail:t.slice(r),tokens:e,stableCount:n,stableOffset:r,degraded:!1,degradedReason:null}}function ae(t){let e=f.lexer(t);return{tokens:e,cache:qt(t,e),charsLexed:t.length,reusedTokens:0}}function O(t,e){let n=f.lexer(t);return{tokens:n,cache:M(t,n,e),charsLexed:t.length,reusedTokens:0}}function De(t,e){let n=t.source+e;if(t.degraded)return O(n,t.degradedReason??"link-definition");if(e.includes("\\r"))return O(n,"carriage-return");if(t.stableCount===0)return ae(n);let r=t.tail+e;if(Me(r))return O(n,"block-math");if(ie(r))return O(n,"container");if(le(r))return O(n,"footnote-def");let s=f.lexer(r);if(ve(s))return O(n,"link-definition");let i=t.tokens.slice(0,t.stableCount),a=vt([...i,...s],s.links),l=t.stableCount,o=t.stableOffset,c=r,h=Ne(a,t.stableCount+1);if(h>t.stableCount&&Be(a,t.stableCount,h,r,0)){let u=Oe(a,t.stableCount,h);l=h,o=t.stableOffset+u,c=r.slice(u)}return{tokens:a,cache:{source:n,tail:c,tokens:a,stableCount:l,stableOffset:o,degraded:!1,degradedReason:null},charsLexed:r.length,reusedTokens:t.stableCount}}var Zt=/^ {0,3}\\*\\[([^\\]\\n]+)\\]:[ \\t]*([^\\n]*)(?:\\n|$)/,qe=[{name:"abbrDef",level:"block",tokenizer(t){let e=Zt.exec(t);if(e)return{type:"abbrDef",raw:e[0],term:e[1],definition:e[2]}},renderer(t){return t.raw}}];var jt=Object.freeze({grinning:"\\u{1F600}",smiley:"\\u{1F603}",smile:"\\u{1F604}",grin:"\\u{1F601}",laughing:"\\u{1F606}",satisfied:"\\u{1F606}",sweat_smile:"\\u{1F605}",rofl:"\\u{1F923}",joy:"\\u{1F602}",slightly_smiling_face:"\\u{1F642}",upside_down_face:"\\u{1F643}",wink:"\\u{1F609}",blush:"\\u{1F60A}",innocent:"\\u{1F607}",heart_eyes:"\\u{1F60D}",star_struck:"\\u{1F929}",kissing_heart:"\\u{1F618}",yum:"\\u{1F60B}",stuck_out_tongue:"\\u{1F61B}",stuck_out_tongue_winking_eye:"\\u{1F61C}",stuck_out_tongue_closed_eyes:"\\u{1F61D}",hugs:"\\u{1F917}",thinking:"\\u{1F914}",neutral_face:"\\u{1F610}",expressionless:"\\u{1F611}",no_mouth:"\\u{1F636}",smirk:"\\u{1F60F}",unamused:"\\u{1F612}",roll_eyes:"\\u{1F644}",grimacing:"\\u{1F62C}",relieved:"\\u{1F60C}",pensive:"\\u{1F614}",sleepy:"\\u{1F62A}",sleeping:"\\u{1F634}",mask:"\\u{1F637}",dizzy_face:"\\u{1F635}",sunglasses:"\\u{1F60E}",nerd_face:"\\u{1F913}",confused:"\\u{1F615}",worried:"\\u{1F61F}",open_mouth:"\\u{1F62E}",hushed:"\\u{1F62F}",astonished:"\\u{1F632}",flushed:"\\u{1F633}",pleading_face:"\\u{1F97A}",fearful:"\\u{1F628}",cold_sweat:"\\u{1F630}",cry:"\\u{1F622}",sob:"\\u{1F62D}",scream:"\\u{1F631}",disappointed:"\\u{1F61E}",sweat:"\\u{1F613}",weary:"\\u{1F629}",tired_face:"\\u{1F62B}",triumph:"\\u{1F624}",rage:"\\u{1F621}",angry:"\\u{1F620}",smiling_imp:"\\u{1F608}",imp:"\\u{1F47F}",skull:"\\u{1F480}",clown_face:"\\u{1F921}",poop:"\\u{1F4A9}",ghost:"\\u{1F47B}",alien:"\\u{1F47D}",robot:"\\u{1F916}",thumbsup:"\\u{1F44D}","+1":"\\u{1F44D}",thumbsdown:"\\u{1F44E}","-1":"\\u{1F44E}",punch:"\\u{1F44A}",fist:"\\u270A",clap:"\\u{1F44F}",raised_hands:"\\u{1F64C}",open_hands:"\\u{1F450}",handshake:"\\u{1F91D}",pray:"\\u{1F64F}",muscle:"\\u{1F4AA}",eyes:"\\u{1F440}",wave:"\\u{1F44B}",point_up:"\\u261D\\uFE0F",point_down:"\\u{1F447}",point_left:"\\u{1F448}",point_right:"\\u{1F449}",ok_hand:"\\u{1F44C}",v:"\\u270C\\uFE0F",crossed_fingers:"\\u{1F91E}",heart:"\\u2764\\uFE0F",broken_heart:"\\u{1F494}",two_hearts:"\\u{1F495}",sparkling_heart:"\\u{1F496}",heartpulse:"\\u{1F497}",blue_heart:"\\u{1F499}",green_heart:"\\u{1F49A}",yellow_heart:"\\u{1F49B}",orange_heart:"\\u{1F9E1}",purple_heart:"\\u{1F49C}",black_heart:"\\u{1F5A4}",white_heart:"\\u{1F90D}",100:"\\u{1F4AF}",boom:"\\u{1F4A5}",collision:"\\u{1F4A5}",dizzy:"\\u{1F4AB}",sweat_drops:"\\u{1F4A6}",dash:"\\u{1F4A8}",zzz:"\\u{1F4A4}",fire:"\\u{1F525}",sparkles:"\\u2728",star:"\\u2B50",star2:"\\u{1F31F}",tada:"\\u{1F389}",confetti_ball:"\\u{1F38A}",balloon:"\\u{1F388}",gift:"\\u{1F381}",rocket:"\\u{1F680}",dart:"\\u{1F3AF}",trophy:"\\u{1F3C6}",warning:"\\u26A0\\uFE0F",no_entry_sign:"\\u{1F6AB}",white_check_mark:"\\u2705",x:"\\u274C",heavy_check_mark:"\\u2714\\uFE0F",question:"\\u2753",exclamation:"\\u2757",bulb:"\\u{1F4A1}",bell:"\\u{1F514}",computer:"\\u{1F4BB}",iphone:"\\u{1F4F1}",link:"\\u{1F517}",lock:"\\u{1F512}",unlock:"\\u{1F513}",key:"\\u{1F511}",mag:"\\u{1F50D}",bug:"\\u{1F41B}",package:"\\u{1F4E6}",memo:"\\u{1F4DD}",pencil2:"\\u270F\\uFE0F",book:"\\u{1F4D6}",books:"\\u{1F4DA}",pushpin:"\\u{1F4CC}",paperclip:"\\u{1F4CE}",calendar:"\\u{1F4C5}",file_folder:"\\u{1F4C1}",hammer:"\\u{1F528}",wrench:"\\u{1F527}",gear:"\\u2699\\uFE0F",chart_with_upwards_trend:"\\u{1F4C8}",chart_with_downwards_trend:"\\u{1F4C9}",bar_chart:"\\u{1F4CA}",construction:"\\u{1F6A7}",hourglass:"\\u23F3",stopwatch:"\\u23F1\\uFE0F",pizza:"\\u{1F355}",coffee:"\\u2615",beer:"\\u{1F37A}",cake:"\\u{1F382}",birthday:"\\u{1F382}",apple:"\\u{1F34E}",rainbow:"\\u{1F308}",sun_with_face:"\\u{1F31E}",crescent_moon:"\\u{1F319}",earth_americas:"\\u{1F30E}",dog:"\\u{1F436}",cat:"\\u{1F431}",fox_face:"\\u{1F98A}",bear:"\\u{1F43B}",panda_face:"\\u{1F43C}",monkey_face:"\\u{1F435}",see_no_evil:"\\u{1F648}",hear_no_evil:"\\u{1F649}",speak_no_evil:"\\u{1F64A}"}),Ft=/^:([A-Za-z0-9_+-]+):/,Ze=[{name:"emoji",level:"inline",start(t){return t.match(/:/)?.index},tokenizer(t){let e=Ft.exec(t);if(!e)return;let n=jt[e[1]];if(n!==void 0)return{type:"emoji",raw:e[0],text:n}},renderer(t){return t.raw}}];var Xt=/^\\+\\+(?!\\s)((?:\\\\[\\s\\S]|(?!\\+\\+)[\\s\\S])+?)(?<!\\s)\\+\\+/,Qt=/^==(?!\\s)((?:\\\\[\\s\\S]|(?!==)[\\s\\S])+?)(?<!\\s)==/,je=[{name:"ins",level:"inline",start(t){return t.match(/(?<!\\\\)\\+\\+(?!\\s)/)?.index},tokenizer(t){let e=Xt.exec(t);if(e)return{type:"ins",raw:e[0],text:e[1].replace(/\\\\(.)/g,"$1")}},renderer(t){return t.raw}},{name:"mark",level:"inline",start(t){return t.match(/(?<!\\\\)==(?!\\s)/)?.index},tokenizer(t){let e=Qt.exec(t);if(e)return{type:"mark",raw:e[0],text:e[1].replace(/\\\\(.)/g,"$1")}},renderer(t){return t.raw}}];var Ht=/^\\^((?:\\\\[\\s\\S]|[^\\s^\\\\])+)\\^/,Fe=[{name:"sup",level:"inline",start(t){return t.match(/(?<!\\\\)\\^(?!\\s)/)?.index},tokenizer(t){let e=Ht.exec(t);if(e)return{type:"sup",raw:e[0],text:e[1].replace(/\\\\(.)/g,"$1")}},renderer(t){return t.raw}}];var Wt=0;function Gt(t){if(typeof t!="string"||typeof performance.mark!="function"||typeof performance.measure!="function")return null;let e=Wt++,n={name:t,startMark:`${t}:start:${e}`,endMark:`${t}:end:${e}`};try{return performance.mark(n.startMark),n}catch{return null}}function Ut(t){if(t)try{performance.mark(t.endMark),performance.measure(t.name,t.startMark,t.endMark)}catch{}finally{try{performance.clearMarks?.(t.startMark),performance.clearMarks?.(t.endMark)}catch{}}}f.use({extensions:[...Ce,...Fe,...je,...Ze,...Ee,...qe,{name:"blockMath",level:"block",start(t){return t.match(/^ {0,3}\\$\\$/m)?.index},tokenizer(t){let e=/^ {0,3}\\$\\$([\\s\\S]+?)\\$\\$[ \\t]*(?:\\n|$)/.exec(t);if(e)return{type:"blockMath",raw:e[0],text:e[1].trim()}},renderer(t){return t.raw}},{name:"inlineMath",level:"inline",start(t){return t.match(/(?<![\\\\$])\\$(?![$\\s])/)?.index},tokenizer(t){let e=/^\\$(?![$\\s\\d])((?:\\\\\\$|[^$\\n])*?)(?<!\\s)\\$(?!\\d)/.exec(t);if(e)return{type:"inlineMath",raw:e[0],text:e[1].trim()}},renderer(t){return t.raw}}]});var N=new Map;self.onmessage=t=>{let e=t.data;if(typeof e!="object"||e===null)return;let{id:n,text:r,append:s,expectedLength:i,oldRaws:a,instance:l,baseVersion:o,dispose:c,userTimingName:h}=e;if(c===!0){typeof l=="string"&&N.delete(l);return}let u=typeof l=="string"?l:null,p=typeof o=="number"?o:null,d,k=null,m=null;if(typeof s=="string"){if(u===null||p===null){self.postMessage({id:n,needResync:!0});return}let w=N.get(u);if(!w||w.version!==p){self.postMessage({id:n,needResync:!0});return}if(typeof i=="number"&&w.lex.source.length+s.length!==i){N.delete(u),self.postMessage({id:n,needResync:!0});return}let y=w.lex;d=()=>De(y,s),m=y.tokens}else if(typeof r=="string"){let w=r;if(d=()=>ae(w),Array.isArray(a))k=a;else if(u!==null&&p!==null){let y=N.get(u);if(y&&y.version===p)m=y.lex.tokens;else{self.postMessage({id:n,needResync:!0});return}}}else return;try{let w=typeof h=="string"?Gt(h):null,y=performance.now(),$;try{$=d()}finally{w&&Ut(w)}let H=performance.now()-y,z=$.tokens,b=0;if(k!==null){let S=Math.min(k.length,z.length);for(;b<S&&k[b]===z[b].raw;b++);}else if(m!==null){let S=m,oe=Math.min(S.length,z.length);for(b=Math.min($.reusedTokens,oe);b<oe&&S[b].raw===z[b].raw;b++);}u!==null&&p!==null&&N.set(u,{version:p+1,lex:$.cache}),self.postMessage({id:n,matchLen:b,tail:z.slice(b),lexerMs:H,sourceCharsLexed:$.charsLexed})}catch(w){u!==null&&N.delete(u),self.postMessage({id:n,error:String(w)})}};})();\n';
1952
2661
 
1953
2662
  // src/Markdown.ts
1954
2663
  var now = () => typeof performance !== "undefined" && typeof performance.now === "function" ? performance.now() : Date.now();
2664
+ function mapsEqual(a, b) {
2665
+ if (a.size !== b.size) return false;
2666
+ for (const [key, value] of a) {
2667
+ if (b.get(key) !== value) return false;
2668
+ }
2669
+ return true;
2670
+ }
1955
2671
  function lexMarkdown(text, userTiming) {
1956
2672
  if (!userTiming) return import_marked.marked.lexer(text);
1957
2673
  const timing = (0, import_core4.beginVectoUserTiming)(import_core4.VECTO_USER_TIMING.markdown.parse);
@@ -1962,11 +2678,18 @@ function lexMarkdown(text, userTiming) {
1962
2678
  }
1963
2679
  }
1964
2680
  import_marked.marked.use({
1965
- // `FOOTNOTE_EXTENSIONS` is shared with `MarkdownWorker.ts` rather than spelled
1966
- // out twice: the two registration sites must agree exactly, or the worker
1967
- // returns tokens this renderer has no arm for.
2681
+ // `FOOTNOTE_EXTENSIONS`, `SUPERSCRIPT_EXTENSIONS`, `INS_MARK_EXTENSIONS`,
2682
+ // `EMOJI_EXTENSIONS`, `CONTAINER_EXTENSIONS`, and `ABBR_EXTENSIONS` are
2683
+ // shared with `MarkdownWorker.ts` rather than spelled out twice: the two
2684
+ // registration sites must agree exactly, or the worker returns tokens this
2685
+ // renderer has no arm for.
1968
2686
  extensions: [
1969
2687
  ...FOOTNOTE_EXTENSIONS,
2688
+ ...SUPERSCRIPT_EXTENSIONS,
2689
+ ...INS_MARK_EXTENSIONS,
2690
+ ...EMOJI_EXTENSIONS,
2691
+ ...CONTAINER_EXTENSIONS,
2692
+ ...ABBR_EXTENSIONS,
1970
2693
  {
1971
2694
  name: "blockMath",
1972
2695
  level: "block",
@@ -2176,6 +2899,19 @@ var Markdown = class _Markdown extends import_ui4.UIComponent {
2176
2899
  mathLoadPending = false;
2177
2900
  _userTiming;
2178
2901
  tokens = [];
2902
+ /**
2903
+ * The document's `*[TERM]: definition` dictionary, collected from
2904
+ * {@link tokens}'s top-level `abbrDef` entries.
2905
+ *
2906
+ * Recomputed whenever {@link setTokens} runs. Its own identity — not its
2907
+ * CONTENTS — is what {@link updateTokens} compares against the previous
2908
+ * render to decide whether prose rendered before this definition existed
2909
+ * needs a full rebuild rather than the usual prefix-reuse: see
2910
+ * `markdown-abbr.ts`'s module doc for why a late-arriving definition can
2911
+ * retroactively change already-rendered inline tokens, the same hazard
2912
+ * `hasLinkDefinitions` names for reference definitions.
2913
+ */
2914
+ abbreviations = /* @__PURE__ */ new Map();
2179
2915
  // At most one worker lex request in flight at a time. Required for the
2180
2916
  // delta-transfer protocol below to be safe: the request captures a
2181
2917
  // snapshot of `this.tokens` to reconstruct the full array from the
@@ -2310,7 +3046,7 @@ var Markdown = class _Markdown extends import_ui4.UIComponent {
2310
3046
  constructor(markdownText, opts = {}) {
2311
3047
  super();
2312
3048
  this.maxWidth = opts.maxWidth ?? 800;
2313
- this.theme = resolveTheme(opts.theme);
3049
+ this.theme = resolvePresetTheme(opts.theme);
2314
3050
  this.onLinkClick = opts.onLinkClick;
2315
3051
  this.selectable = opts.selectable ?? true;
2316
3052
  this._userTiming = opts.userTiming ?? false;
@@ -2428,6 +3164,7 @@ var Markdown = class _Markdown extends import_ui4.UIComponent {
2428
3164
  renderMarkdown(text) {
2429
3165
  const tokens = lexMarkdown(text, this._userTiming);
2430
3166
  this.setTokens(tokens);
3167
+ this.abbreviations = collectAbbreviations(tokens);
2431
3168
  for (const token of tokens) {
2432
3169
  const el = this.renderToken(token);
2433
3170
  if (el) {
@@ -2586,6 +3323,38 @@ var Markdown = class _Markdown extends import_ui4.UIComponent {
2586
3323
  entity.height = Math.max(border?.height ?? 0, innerStack?.height ?? 0);
2587
3324
  return;
2588
3325
  }
3326
+ case "container": {
3327
+ const ctToken = token;
3328
+ const innerStack = entity.children.find((c) => c instanceof import_ui4.Stack);
3329
+ const border = entity.children.find((c) => c instanceof QuoteBorder);
3330
+ const background = entity.children.find((c) => c instanceof ContainerBackground);
3331
+ const indentStart = Math.min(this.theme.containerIndent, availableWidth);
3332
+ const childWidth = Math.max(0, availableWidth - indentStart);
3333
+ if (innerStack instanceof import_ui4.Stack) {
3334
+ let index = 0;
3335
+ for (const inner of ctToken.tokens) {
3336
+ if (!this.producesEntity(inner)) continue;
3337
+ const wrapper = innerStack.children[index++];
3338
+ if (!wrapper) break;
3339
+ const block = wrapper.children[0];
3340
+ if (!block) continue;
3341
+ this.reflowToken(inner, block, childWidth);
3342
+ block.x = indentStart;
3343
+ wrapper.width = block.width + indentStart;
3344
+ wrapper.height = block.height;
3345
+ }
3346
+ innerStack.layout();
3347
+ }
3348
+ const contentHeight = innerStack?.height || 20;
3349
+ if (border instanceof QuoteBorder) border.height = contentHeight;
3350
+ if (background instanceof ContainerBackground) {
3351
+ background.width = availableWidth;
3352
+ background.height = contentHeight;
3353
+ }
3354
+ entity.width = availableWidth;
3355
+ entity.height = Math.max(background?.height ?? 0, border?.height ?? 0, contentHeight);
3356
+ return;
3357
+ }
2589
3358
  case "list": {
2590
3359
  if (!(entity instanceof import_ui4.Stack)) return;
2591
3360
  for (const item of entity.children) {
@@ -2603,7 +3372,31 @@ var Markdown = class _Markdown extends import_ui4.UIComponent {
2603
3372
  return;
2604
3373
  }
2605
3374
  case "footnoteDef": {
2606
- if (entity instanceof import_ui4.RichText) entity.setMaxWidth(availableWidth);
3375
+ if (entity instanceof import_ui4.RichText) {
3376
+ entity.setMaxWidth(availableWidth);
3377
+ return;
3378
+ }
3379
+ if (entity instanceof import_ui4.Stack) {
3380
+ const fnToken = token;
3381
+ entity.maxWidth = availableWidth;
3382
+ const header = entity.children[0];
3383
+ if (header instanceof import_ui4.RichText) header.setMaxWidth(availableWidth);
3384
+ const indent = Math.round(this.theme.fontSize);
3385
+ const childWidth = Math.max(1, availableWidth - indent);
3386
+ let index = 1;
3387
+ for (const inner of fnToken.tokens) {
3388
+ if (!this.producesEntity(inner)) continue;
3389
+ const wrapper = entity.children[index++];
3390
+ if (!wrapper) break;
3391
+ const block = wrapper.children[0];
3392
+ if (!block) continue;
3393
+ this.reflowToken(inner, block, childWidth);
3394
+ block.x = indent;
3395
+ wrapper.width = block.width + indent;
3396
+ wrapper.height = block.height;
3397
+ }
3398
+ entity.layout();
3399
+ }
2607
3400
  return;
2608
3401
  }
2609
3402
  default: {
@@ -3104,7 +3897,7 @@ var Markdown = class _Markdown extends import_ui4.UIComponent {
3104
3897
  literalParagraphSpans(token) {
3105
3898
  const spans = [];
3106
3899
  if (token.tokens && token.tokens.length > 0) {
3107
- collectSpans(token.tokens, {}, this.theme, spans);
3900
+ collectSpans(token.tokens, {}, this.theme, spans, void 0, this.abbreviations);
3108
3901
  }
3109
3902
  if (spans.length === 0) spans.push({ text: token.text });
3110
3903
  return spans;
@@ -3149,7 +3942,7 @@ var Markdown = class _Markdown extends import_ui4.UIComponent {
3149
3942
  */
3150
3943
  tableCellSpans(cell, t) {
3151
3944
  const spans = [];
3152
- collectSpans(cell.tokens, {}, t, spans);
3945
+ collectSpans(cell.tokens, {}, t, spans, void 0, this.abbreviations);
3153
3946
  if (spans.length === 0) spans.push({ text: decodeEntities(cell.text) });
3154
3947
  return spans;
3155
3948
  }
@@ -3167,7 +3960,7 @@ var Markdown = class _Markdown extends import_ui4.UIComponent {
3167
3960
  */
3168
3961
  inlineRunSpans(tokens, t) {
3169
3962
  const spans = [];
3170
- if (tokens.length > 0) collectSpans(tokens, {}, t, spans);
3963
+ if (tokens.length > 0) collectSpans(tokens, {}, t, spans, void 0, this.abbreviations);
3171
3964
  if (spans.length === 0) spans.push({ text: "" });
3172
3965
  return spans;
3173
3966
  }
@@ -3430,14 +4223,18 @@ var Markdown = class _Markdown extends import_ui4.UIComponent {
3430
4223
  inner.tokens,
3431
4224
  {},
3432
4225
  this.theme,
3433
- contentSpans
4226
+ contentSpans,
4227
+ void 0,
4228
+ this.abbreviations
3434
4229
  );
3435
4230
  } else if ("tokens" in inner && inner.tokens?.length) {
3436
4231
  collectSpans(
3437
4232
  inner.tokens,
3438
4233
  {},
3439
4234
  this.theme,
3440
- contentSpans
4235
+ contentSpans,
4236
+ void 0,
4237
+ this.abbreviations
3441
4238
  );
3442
4239
  } else if ("text" in inner) {
3443
4240
  contentSpans.push({ text: decodeEntities(inner.text) });
@@ -3711,7 +4508,7 @@ var Markdown = class _Markdown extends import_ui4.UIComponent {
3711
4508
  headingSpans(token) {
3712
4509
  const spans = [];
3713
4510
  if (token.tokens && token.tokens.length > 0) {
3714
- collectSpans(token.tokens, {}, this.theme, spans);
4511
+ collectSpans(token.tokens, {}, this.theme, spans, void 0, this.abbreviations);
3715
4512
  }
3716
4513
  if (spans.length === 0) spans.push({ text: decodeEntities(token.text) });
3717
4514
  return spans;
@@ -3752,7 +4549,14 @@ var Markdown = class _Markdown extends import_ui4.UIComponent {
3752
4549
  if (!found) return null;
3753
4550
  const spans = [];
3754
4551
  if (inline.length > runLength) {
3755
- collectSpans(inline.slice(0, -runLength), {}, this.theme, spans);
4552
+ collectSpans(
4553
+ inline.slice(0, -runLength),
4554
+ {},
4555
+ this.theme,
4556
+ spans,
4557
+ void 0,
4558
+ this.abbreviations
4559
+ );
3756
4560
  }
3757
4561
  const head = runText.slice(0, found.at);
3758
4562
  if (head) spans.push({ text: decodeEntities(head) });
@@ -3945,6 +4749,10 @@ var Markdown = class _Markdown extends import_ui4.UIComponent {
3945
4749
  }
3946
4750
  }
3947
4751
  }
4752
+ const newAbbreviations = collectAbbreviations(newTokens);
4753
+ const abbreviationsChanged = !mapsEqual(this.abbreviations, newAbbreviations);
4754
+ if (abbreviationsChanged) matchLen = 0;
4755
+ this.abbreviations = newAbbreviations;
3948
4756
  const oldTokenToChild = this.tokenChildPrefix;
3949
4757
  const rawMatchLen = matchLen;
3950
4758
  let pendingTail = null;
@@ -4112,6 +4920,10 @@ var Markdown = class _Markdown extends import_ui4.UIComponent {
4112
4920
  // It renders its own block, so it produces an entity — see `renderToken`'s
4113
4921
  // arm for why in place rather than collected into a document footer.
4114
4922
  case "footnoteDef":
4923
+ // A `ContainerToken` carries `tokens`, not `text`, so it would otherwise
4924
+ // fail the `default:` arm's `'text' in token` fallback check entirely —
4925
+ // the same trap `footnoteDef` above already documents.
4926
+ case "container":
4115
4927
  return true;
4116
4928
  default:
4117
4929
  return "text" in token;
@@ -4200,7 +5012,8 @@ var Markdown = class _Markdown extends import_ui4.UIComponent {
4200
5012
  availableWidth,
4201
5013
  t,
4202
5014
  this.selectable,
4203
- this.onLinkClick
5015
+ this.onLinkClick,
5016
+ this.abbreviations
4204
5017
  );
4205
5018
  }
4206
5019
  // ── Paragraphs ───────────────────────────────────────────────────
@@ -4215,7 +5028,8 @@ var Markdown = class _Markdown extends import_ui4.UIComponent {
4215
5028
  availableWidth,
4216
5029
  t,
4217
5030
  this.selectable,
4218
- this.onLinkClick
5031
+ this.onLinkClick,
5032
+ this.abbreviations
4219
5033
  );
4220
5034
  }
4221
5035
  const stack = new import_ui4.Stack({
@@ -4314,6 +5128,54 @@ var Markdown = class _Markdown extends import_ui4.UIComponent {
4314
5128
  container.height = Math.max(border.height, innerStack.height);
4315
5129
  return container;
4316
5130
  }
5131
+ // ── `:::` fenced containers ─────────────────────────────────────
5132
+ case "container": {
5133
+ const ctToken = token;
5134
+ const accent = containerColor(t, ctToken.kind);
5135
+ const innerStack = new import_ui4.Stack({
5136
+ direction: "vertical",
5137
+ gap: t.containerInnerGap
5138
+ });
5139
+ const indentStart = Math.min(t.containerIndent, availableWidth);
5140
+ const childMetrics = {
5141
+ marginBefore: 0,
5142
+ marginAfter: 0,
5143
+ indentStart,
5144
+ availableWidth: Math.max(0, availableWidth - indentStart)
5145
+ };
5146
+ for (const inner of ctToken.tokens) {
5147
+ const el = this.renderTokenWithMetrics(inner, childMetrics);
5148
+ if (el) {
5149
+ const wrapper2 = new MarkdownContainer();
5150
+ el.x = childMetrics.indentStart;
5151
+ wrapper2.add(el);
5152
+ wrapper2.width = el.width + childMetrics.indentStart;
5153
+ wrapper2.height = el.height;
5154
+ innerStack.add(wrapper2);
5155
+ }
5156
+ }
5157
+ const contentHeight = innerStack.height || 20;
5158
+ const background = new ContainerBackground(
5159
+ availableWidth,
5160
+ contentHeight,
5161
+ t.containerBgColor,
5162
+ t.containerRadius
5163
+ );
5164
+ const border = new QuoteBorder(contentHeight, accent, t.containerBorderWidth);
5165
+ const wrapper = new MarkdownContainer();
5166
+ background.x = 0;
5167
+ background.y = 0;
5168
+ wrapper.add(background);
5169
+ border.x = 0;
5170
+ border.y = 0;
5171
+ wrapper.add(border);
5172
+ innerStack.x = 0;
5173
+ innerStack.y = 0;
5174
+ wrapper.add(innerStack);
5175
+ wrapper.width = availableWidth;
5176
+ wrapper.height = Math.max(background.height, border.height, innerStack.height);
5177
+ return wrapper;
5178
+ }
4317
5179
  // ── Lists ────────────────────────────────────────────────
4318
5180
  case "list": {
4319
5181
  const listToken = token;
@@ -4357,20 +5219,43 @@ var Markdown = class _Markdown extends import_ui4.UIComponent {
4357
5219
  // ── Footnote definition (`[^1]: note`) ───────────────────────────
4358
5220
  case "footnoteDef": {
4359
5221
  const fnToken = token;
4360
- const spans = [
5222
+ const headerSpans = [
4361
5223
  {
4362
5224
  text: footnoteMarker(fnToken.label),
4363
5225
  style: { color: t.footnoteColor }
4364
5226
  },
4365
5227
  { text: " " }
4366
5228
  ];
4367
- if (fnToken.body) spans.push({ text: decodeEntities(fnToken.body) });
4368
- return new import_ui4.RichText(spans, {
5229
+ if (fnToken.body) headerSpans.push({ text: decodeEntities(fnToken.body) });
5230
+ const headerRichText = new import_ui4.RichText(headerSpans, {
4369
5231
  font: bodyFont,
4370
5232
  color: t.textColor,
4371
5233
  maxWidth: availableWidth,
4372
5234
  selectable: this.selectable
4373
5235
  });
5236
+ if (!fnToken.tokens || fnToken.tokens.length === 0) {
5237
+ return headerRichText;
5238
+ }
5239
+ const indent = Math.round(t.fontSize);
5240
+ const childMetrics = {
5241
+ marginBefore: 0,
5242
+ marginAfter: 0,
5243
+ indentStart: indent,
5244
+ availableWidth: Math.max(1, availableWidth - indent)
5245
+ };
5246
+ const stack = new import_ui4.Stack({ direction: "vertical", gap: t.listItemGap });
5247
+ stack.add(headerRichText);
5248
+ for (const inner of fnToken.tokens) {
5249
+ const el = this.renderTokenWithMetrics(inner, childMetrics);
5250
+ if (!el) continue;
5251
+ const wrapper = new MarkdownContainer();
5252
+ el.x = indent;
5253
+ wrapper.add(el);
5254
+ wrapper.width = el.width + indent;
5255
+ wrapper.height = el.height;
5256
+ stack.add(wrapper);
5257
+ }
5258
+ return stack;
4374
5259
  }
4375
5260
  // ── Horizontal rule ──────────────────────────────────────────────
4376
5261
  case "hr":
@@ -4411,6 +5296,7 @@ var Markdown = class _Markdown extends import_ui4.UIComponent {
4411
5296
  CodeBlock,
4412
5297
  Markdown,
4413
5298
  MathBlock,
5299
+ PRESET_THEMES,
4414
5300
  codeAtlas,
4415
5301
  codeAtlasStats,
4416
5302
  escapeCsvField,
@@ -4418,9 +5304,11 @@ var Markdown = class _Markdown extends import_ui4.UIComponent {
4418
5304
  extensionForLanguage,
4419
5305
  footnoteMarker,
4420
5306
  isMathJaxReady,
5307
+ isPresetName,
4421
5308
  mimeForLanguage,
4422
5309
  parseFrontMatterFields,
4423
5310
  preloadMathJax,
5311
+ resolvePresetTheme,
4424
5312
  scanFrontMatter,
4425
5313
  tableContentOf,
4426
5314
  tableToCsv,