@vectojs/markdown 0.23.3 → 0.25.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/README.md +50 -0
- package/dist/Markdown.d.ts +16 -0
- package/dist/MarkdownWorkerSource.d.ts +1 -1
- package/dist/index.d.ts +4 -0
- package/dist/index.js +325 -53
- package/dist/index.mjs +321 -53
- package/dist/markdown-image.d.ts +24 -1
- package/dist/markdown-inline.d.ts +10 -2
- package/dist/projection-policy.d.ts +54 -0
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -36,8 +36,12 @@ __export(index_exports, {
|
|
|
36
36
|
Markdown: () => Markdown,
|
|
37
37
|
MathBlock: () => MathBlock,
|
|
38
38
|
PRESET_THEMES: () => PRESET_THEMES,
|
|
39
|
+
applyProjectionMode: () => applyProjectionMode,
|
|
40
|
+
classifyProjectionBlock: () => classifyProjectionBlock,
|
|
41
|
+
classifyProjectionBlocks: () => classifyProjectionBlocks,
|
|
39
42
|
codeAtlas: () => codeAtlas,
|
|
40
43
|
codeAtlasStats: () => codeAtlasStats,
|
|
44
|
+
defaultMarkdownImageResolver: () => defaultMarkdownImageResolver,
|
|
41
45
|
ensureFencedBlockRenderer: () => ensureFencedBlockRenderer,
|
|
42
46
|
escapeCsvField: () => escapeCsvField,
|
|
43
47
|
escapeMarkdownTableCell: () => escapeMarkdownTableCell,
|
|
@@ -2519,6 +2523,10 @@ var import_core3 = require("@vectojs/core");
|
|
|
2519
2523
|
var import_ui2 = require("@vectojs/ui");
|
|
2520
2524
|
|
|
2521
2525
|
// src/markdown-image.ts
|
|
2526
|
+
var defaultMarkdownImageResolver = (src) => ({
|
|
2527
|
+
kind: "url",
|
|
2528
|
+
url: src
|
|
2529
|
+
});
|
|
2522
2530
|
function paragraphHasImage(token) {
|
|
2523
2531
|
return containsImage(token.tokens);
|
|
2524
2532
|
}
|
|
@@ -2600,7 +2608,115 @@ function subscribeInlineImageRaster(notify) {
|
|
|
2600
2608
|
function unsubscribeInlineImageRaster(notify) {
|
|
2601
2609
|
inlineImageRasterWaiters.delete(notify);
|
|
2602
2610
|
}
|
|
2603
|
-
function
|
|
2611
|
+
function normalizeInlineSource(src) {
|
|
2612
|
+
if (typeof src === "string") return { kind: "url", url: src };
|
|
2613
|
+
return src;
|
|
2614
|
+
}
|
|
2615
|
+
function notifyInlineWaiters() {
|
|
2616
|
+
for (const notify of inlineImageRasterWaiters) notify();
|
|
2617
|
+
}
|
|
2618
|
+
function decodeInlineSource(resolved, entry, fallbackSrc) {
|
|
2619
|
+
const norm = normalizeInlineSource(resolved);
|
|
2620
|
+
switch (norm.kind) {
|
|
2621
|
+
case "bitmap": {
|
|
2622
|
+
const bmp = norm.bitmap;
|
|
2623
|
+
entry.source = bmp;
|
|
2624
|
+
entry.decoded = true;
|
|
2625
|
+
entry.naturalWidth = bmp.width;
|
|
2626
|
+
entry.naturalHeight = bmp.height;
|
|
2627
|
+
if (typeof queueMicrotask === "function") queueMicrotask(notifyInlineWaiters);
|
|
2628
|
+
else Promise.resolve().then(notifyInlineWaiters);
|
|
2629
|
+
break;
|
|
2630
|
+
}
|
|
2631
|
+
case "blob": {
|
|
2632
|
+
const blob = norm.blob;
|
|
2633
|
+
const gCreate = globalThis;
|
|
2634
|
+
if (typeof gCreate.createImageBitmap === "function") {
|
|
2635
|
+
gCreate.createImageBitmap(blob).then((bmp) => {
|
|
2636
|
+
entry.source = bmp;
|
|
2637
|
+
entry.decoded = true;
|
|
2638
|
+
entry.naturalWidth = bmp.width;
|
|
2639
|
+
entry.naturalHeight = bmp.height;
|
|
2640
|
+
entry.dispose = () => {
|
|
2641
|
+
try {
|
|
2642
|
+
bmp.close();
|
|
2643
|
+
} catch {
|
|
2644
|
+
}
|
|
2645
|
+
};
|
|
2646
|
+
notifyInlineWaiters();
|
|
2647
|
+
}).catch(() => {
|
|
2648
|
+
decodeBlobViaImageInline(blob, entry);
|
|
2649
|
+
});
|
|
2650
|
+
} else {
|
|
2651
|
+
decodeBlobViaImageInline(blob, entry);
|
|
2652
|
+
}
|
|
2653
|
+
break;
|
|
2654
|
+
}
|
|
2655
|
+
case "url":
|
|
2656
|
+
default: {
|
|
2657
|
+
const url = norm.kind === "url" ? norm.url : fallbackSrc;
|
|
2658
|
+
if (typeof globalThis.Image === "undefined") return;
|
|
2659
|
+
const bitmap = new globalThis.Image();
|
|
2660
|
+
bitmap.onload = () => {
|
|
2661
|
+
entry.decoded = true;
|
|
2662
|
+
entry.naturalWidth = bitmap.naturalWidth || void 0;
|
|
2663
|
+
entry.naturalHeight = bitmap.naturalHeight || void 0;
|
|
2664
|
+
entry.source = bitmap;
|
|
2665
|
+
notifyInlineWaiters();
|
|
2666
|
+
};
|
|
2667
|
+
bitmap.onerror = () => {
|
|
2668
|
+
entry.failed = true;
|
|
2669
|
+
notifyInlineWaiters();
|
|
2670
|
+
};
|
|
2671
|
+
bitmap.src = url;
|
|
2672
|
+
entry.bitmap = bitmap;
|
|
2673
|
+
entry.source = bitmap;
|
|
2674
|
+
break;
|
|
2675
|
+
}
|
|
2676
|
+
}
|
|
2677
|
+
}
|
|
2678
|
+
function decodeBlobViaImageInline(blob, entry) {
|
|
2679
|
+
if (typeof globalThis.Image === "undefined" || typeof URL === "undefined" || typeof URL.createObjectURL !== "function") {
|
|
2680
|
+
entry.failed = true;
|
|
2681
|
+
notifyInlineWaiters();
|
|
2682
|
+
return;
|
|
2683
|
+
}
|
|
2684
|
+
const url = URL.createObjectURL(blob);
|
|
2685
|
+
let objectURL = url;
|
|
2686
|
+
entry.dispose = () => {
|
|
2687
|
+
if (objectURL) {
|
|
2688
|
+
try {
|
|
2689
|
+
URL.revokeObjectURL(objectURL);
|
|
2690
|
+
} catch {
|
|
2691
|
+
}
|
|
2692
|
+
objectURL = null;
|
|
2693
|
+
}
|
|
2694
|
+
};
|
|
2695
|
+
const img = new globalThis.Image();
|
|
2696
|
+
entry.bitmap = img;
|
|
2697
|
+
entry.source = img;
|
|
2698
|
+
img.onload = () => {
|
|
2699
|
+
entry.decoded = true;
|
|
2700
|
+
entry.naturalWidth = img.naturalWidth || void 0;
|
|
2701
|
+
entry.naturalHeight = img.naturalHeight || void 0;
|
|
2702
|
+
entry.source = img;
|
|
2703
|
+
notifyInlineWaiters();
|
|
2704
|
+
};
|
|
2705
|
+
img.onerror = () => {
|
|
2706
|
+
if (objectURL) {
|
|
2707
|
+
try {
|
|
2708
|
+
URL.revokeObjectURL(objectURL);
|
|
2709
|
+
} catch {
|
|
2710
|
+
}
|
|
2711
|
+
objectURL = null;
|
|
2712
|
+
entry.dispose = void 0;
|
|
2713
|
+
}
|
|
2714
|
+
entry.failed = true;
|
|
2715
|
+
notifyInlineWaiters();
|
|
2716
|
+
};
|
|
2717
|
+
img.src = url;
|
|
2718
|
+
}
|
|
2719
|
+
function ensureInlineImageRaster(src, resolver = defaultMarkdownImageResolver) {
|
|
2604
2720
|
const existing = inlineImageRasters.get(src);
|
|
2605
2721
|
if (existing) {
|
|
2606
2722
|
inlineImageRasters.delete(src);
|
|
@@ -2612,29 +2728,37 @@ function ensureInlineImageRaster(src) {
|
|
|
2612
2728
|
while (inlineImageRasters.size > INLINE_IMAGE_RASTER_LIMIT) {
|
|
2613
2729
|
const oldest = inlineImageRasters.keys().next().value;
|
|
2614
2730
|
if (oldest === void 0 || oldest === src) break;
|
|
2731
|
+
const evicted = inlineImageRasters.get(oldest);
|
|
2732
|
+
try {
|
|
2733
|
+
evicted?.dispose?.();
|
|
2734
|
+
} catch {
|
|
2735
|
+
}
|
|
2615
2736
|
inlineImageRasters.delete(oldest);
|
|
2616
2737
|
}
|
|
2617
|
-
|
|
2618
|
-
|
|
2619
|
-
|
|
2620
|
-
|
|
2621
|
-
|
|
2622
|
-
|
|
2623
|
-
|
|
2624
|
-
|
|
2625
|
-
|
|
2738
|
+
let resolved;
|
|
2739
|
+
try {
|
|
2740
|
+
resolved = resolver(src);
|
|
2741
|
+
} catch (err) {
|
|
2742
|
+
console.warn("[Markdown] imageResolver threw for", src, err);
|
|
2743
|
+
resolved = { kind: "url", url: src };
|
|
2744
|
+
}
|
|
2745
|
+
if (resolved instanceof Promise) {
|
|
2746
|
+
resolved.then((r) => decodeInlineSource(r, entry, src)).catch((err) => {
|
|
2747
|
+
console.warn("[Markdown] imageResolver rejected for", src, err);
|
|
2626
2748
|
entry.failed = true;
|
|
2627
|
-
|
|
2628
|
-
};
|
|
2629
|
-
|
|
2630
|
-
entry
|
|
2749
|
+
notifyInlineWaiters();
|
|
2750
|
+
});
|
|
2751
|
+
} else {
|
|
2752
|
+
decodeInlineSource(resolved, entry, src);
|
|
2631
2753
|
}
|
|
2632
2754
|
return entry;
|
|
2633
2755
|
}
|
|
2634
2756
|
function paintInlineImage(src, surface, box) {
|
|
2635
2757
|
const raster = ensureInlineImageRaster(src);
|
|
2636
|
-
if (!raster.decoded
|
|
2637
|
-
|
|
2758
|
+
if (!raster.decoded) return;
|
|
2759
|
+
const backing = raster.source ?? raster.bitmap;
|
|
2760
|
+
if (!backing) return;
|
|
2761
|
+
surface.drawImage(backing, box.x, box.y, box.width, box.height);
|
|
2638
2762
|
}
|
|
2639
2763
|
function expectedImageParagraphChildren(tokens) {
|
|
2640
2764
|
let children = 0;
|
|
@@ -2691,13 +2815,21 @@ function emitProse(text, style, abbr, out) {
|
|
|
2691
2815
|
}
|
|
2692
2816
|
if (last < text.length) out.push({ text: text.slice(last), style });
|
|
2693
2817
|
}
|
|
2694
|
-
function collectSpans(tokens, inherited, theme, out, blockFontSize, abbr = NO_ABBREVIATIONS) {
|
|
2818
|
+
function collectSpans(tokens, inherited, theme, out, blockFontSize, abbr = NO_ABBREVIATIONS, imageResolver = defaultMarkdownImageResolver) {
|
|
2695
2819
|
for (const token of tokens) {
|
|
2696
2820
|
switch (token.type) {
|
|
2697
2821
|
case "strong": {
|
|
2698
2822
|
const t = token;
|
|
2699
2823
|
if (t.tokens) {
|
|
2700
|
-
collectSpans(
|
|
2824
|
+
collectSpans(
|
|
2825
|
+
t.tokens,
|
|
2826
|
+
{ ...inherited, bold: true },
|
|
2827
|
+
theme,
|
|
2828
|
+
out,
|
|
2829
|
+
blockFontSize,
|
|
2830
|
+
abbr,
|
|
2831
|
+
imageResolver
|
|
2832
|
+
);
|
|
2701
2833
|
} else {
|
|
2702
2834
|
emitProse(decodeProse(t.text, theme), { ...inherited, bold: true }, abbr, out);
|
|
2703
2835
|
}
|
|
@@ -2706,7 +2838,15 @@ function collectSpans(tokens, inherited, theme, out, blockFontSize, abbr = NO_AB
|
|
|
2706
2838
|
case "em": {
|
|
2707
2839
|
const t = token;
|
|
2708
2840
|
if (t.tokens) {
|
|
2709
|
-
collectSpans(
|
|
2841
|
+
collectSpans(
|
|
2842
|
+
t.tokens,
|
|
2843
|
+
{ ...inherited, italic: true },
|
|
2844
|
+
theme,
|
|
2845
|
+
out,
|
|
2846
|
+
blockFontSize,
|
|
2847
|
+
abbr,
|
|
2848
|
+
imageResolver
|
|
2849
|
+
);
|
|
2710
2850
|
} else {
|
|
2711
2851
|
emitProse(decodeProse(t.text, theme), { ...inherited, italic: true }, abbr, out);
|
|
2712
2852
|
}
|
|
@@ -2723,7 +2863,7 @@ function collectSpans(tokens, inherited, theme, out, blockFontSize, abbr = NO_AB
|
|
|
2723
2863
|
baselineShift: runSize * theme.subscriptShift
|
|
2724
2864
|
};
|
|
2725
2865
|
if (t.tokens) {
|
|
2726
|
-
collectSpans(t.tokens, subStyle, theme, out, blockFontSize, abbr);
|
|
2866
|
+
collectSpans(t.tokens, subStyle, theme, out, blockFontSize, abbr, imageResolver);
|
|
2727
2867
|
} else {
|
|
2728
2868
|
emitProse(decodeProse(t.text, theme), subStyle, abbr, out);
|
|
2729
2869
|
}
|
|
@@ -2736,7 +2876,8 @@ function collectSpans(tokens, inherited, theme, out, blockFontSize, abbr = NO_AB
|
|
|
2736
2876
|
theme,
|
|
2737
2877
|
out,
|
|
2738
2878
|
blockFontSize,
|
|
2739
|
-
abbr
|
|
2879
|
+
abbr,
|
|
2880
|
+
imageResolver
|
|
2740
2881
|
);
|
|
2741
2882
|
} else {
|
|
2742
2883
|
emitProse(decodeProse(t.text, theme), { ...inherited, lineThrough: true }, abbr, out);
|
|
@@ -2801,7 +2942,7 @@ function collectSpans(tokens, inherited, theme, out, blockFontSize, abbr = NO_AB
|
|
|
2801
2942
|
case "image": {
|
|
2802
2943
|
const t = token;
|
|
2803
2944
|
const runSize = inherited.fontSize ?? blockFontSize ?? theme.fontSize;
|
|
2804
|
-
const raster = ensureInlineImageRaster(t.href);
|
|
2945
|
+
const raster = ensureInlineImageRaster(t.href, imageResolver);
|
|
2805
2946
|
if (raster.failed) {
|
|
2806
2947
|
out.push({ text: decodeEntities(t.text), style: inherited });
|
|
2807
2948
|
break;
|
|
@@ -2892,7 +3033,7 @@ function collectSpans(tokens, inherited, theme, out, blockFontSize, abbr = NO_AB
|
|
|
2892
3033
|
if (isAutolink) {
|
|
2893
3034
|
out.push({ text: t.text, style: linkStyle });
|
|
2894
3035
|
} else if (t.tokens && t.tokens.length > 0) {
|
|
2895
|
-
collectSpans(t.tokens, linkStyle, theme, out, blockFontSize, abbr);
|
|
3036
|
+
collectSpans(t.tokens, linkStyle, theme, out, blockFontSize, abbr, imageResolver);
|
|
2896
3037
|
} else {
|
|
2897
3038
|
emitProse(decodeProse(t.text, theme), linkStyle, abbr, out);
|
|
2898
3039
|
}
|
|
@@ -2901,7 +3042,15 @@ function collectSpans(tokens, inherited, theme, out, blockFontSize, abbr = NO_AB
|
|
|
2901
3042
|
case "text": {
|
|
2902
3043
|
const t = token;
|
|
2903
3044
|
if ("tokens" in t && t.tokens?.length) {
|
|
2904
|
-
collectSpans(
|
|
3045
|
+
collectSpans(
|
|
3046
|
+
t.tokens,
|
|
3047
|
+
inherited,
|
|
3048
|
+
theme,
|
|
3049
|
+
out,
|
|
3050
|
+
blockFontSize,
|
|
3051
|
+
abbr,
|
|
3052
|
+
imageResolver
|
|
3053
|
+
);
|
|
2905
3054
|
} else {
|
|
2906
3055
|
const decoded = decodeProse(t.text, theme);
|
|
2907
3056
|
const style = Object.keys(inherited).length > 0 ? inherited : void 0;
|
|
@@ -2947,10 +3096,10 @@ function findUnclosedInline(text) {
|
|
|
2947
3096
|
}
|
|
2948
3097
|
return best;
|
|
2949
3098
|
}
|
|
2950
|
-
function renderInlineToRichText(tokens, fallbackText, font, color, maxWidth, theme, selectable, onLinkClick, abbr = NO_ABBREVIATIONS) {
|
|
3099
|
+
function renderInlineToRichText(tokens, fallbackText, font, color, maxWidth, theme, selectable, onLinkClick, abbr = NO_ABBREVIATIONS, imageResolver = defaultMarkdownImageResolver) {
|
|
2951
3100
|
const spans = [];
|
|
2952
3101
|
if (tokens && tokens.length > 0) {
|
|
2953
|
-
collectSpans(tokens, {}, theme, spans, fontSizeFromFont(font), abbr);
|
|
3102
|
+
collectSpans(tokens, {}, theme, spans, fontSizeFromFont(font), abbr, imageResolver);
|
|
2954
3103
|
}
|
|
2955
3104
|
if (spans.length === 0) {
|
|
2956
3105
|
spans.push({ text: decodeEntities(fallbackText) });
|
|
@@ -3345,7 +3494,7 @@ function unquote(value) {
|
|
|
3345
3494
|
}
|
|
3346
3495
|
|
|
3347
3496
|
// src/MarkdownWorkerSource.ts
|
|
3348
|
-
var WORKER_SOURCE_STRING = '"use strict";(()=>{function ee(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var P=ee();function me(t){P=t}var I={exec:()=>null};function M(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 f(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(b.caret,"$1"),n=n.replace(s,a),r},getRegex:()=>new RegExp(n,e)};return r}var Ge=((t="")=>{try{return!!new RegExp("(?<=1)(?<!1)"+t)}catch{return!1}})(),b={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:M(t=>new RegExp(`^ {0,${t}}(?:[*+-]|\\\\d{1,9}[.)])((?:[ ][^\\\\n]*)?(?:\\\\n|$))`)),hrRegex:M(t=>new RegExp(`^ {0,${t}}((?:- *){3,}|(?:_ *){3,}|(?:\\\\* *){3,})(?:\\\\n+|$)`)),fencesBeginRegex:M(t=>new RegExp(`^ {0,${t}}(?:\\`\\`\\`|~~~)`)),headingBeginRegex:M(t=>new RegExp(`^ {0,${t}}#`)),htmlBeginRegex:M(t=>new RegExp(`^ {0,${t}}<(?:[a-z].*>|!--)`,"i")),blockquoteBeginRegex:M(t=>new RegExp(`^ {0,${t}}>`))},Ue=/^(?:[ \\t]*(?:\\n|$))+/,We=/^((?: {4}| {0,3}\\t)[^\\n]+(?:\\n(?:[ \\t]*(?:\\n|$))*)?)+/,Je=/^ {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+|$)/,Ke=/^ {0,3}(#{1,6})(?=\\s|$)(.*)(?:\\n+|$)/,te=/ {0,3}(?:[*+-]|\\d{1,9}[.)])/,we=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\\n(?!\\s*?\\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\\n {0,3}(=+|-+) *(?:\\n+|$)/,ye=f(we).replace(/bull/g,te).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(),Ve=f(we).replace(/bull/g,te).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(),ne=/^([^\\n]+(?:\\n(?!hr|heading|lheading|blockquote|fences|list|html|table|[ \\t]+\\n)[^\\n]+)*)/,Ye=/^[^\\n]+/,re=/(?!\\s*\\])(?:\\\\[\\s\\S]|[^\\[\\]\\\\])+/,et=f(/^ {0,3}\\[(label)\\]: *(?:\\n[ \\t]*)?([^<\\s][^\\s]*|<.*?>)(?:(?: +(?:\\n[ \\t]*)?| *\\n[ \\t]*)(title))? *(?:\\n+|$)/).replace("label",re).replace("title",/(?:"(?:\\\\"?|[^"\\\\])*"|\'[^\'\\n]*(?:\\n[^\'\\n]+)*\\n?\'|\\([^()]*\\))/).getRegex(),tt=f(/^(bull)([ \\t][^\\n]*?)?(?:\\n|$)/).replace(/bull/g,te).getRegex(),W="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",se=/<!--(?:-?>|[\\s\\S]*?(?:-->|$))/,nt=f("^ {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",se).replace("tag",W).replace("attribute",/ +[a-zA-Z:_][\\w.:-]*(?: *= *"[^"\\n]*"| *= *\'[^\'\\n]*\'| *= *[^\\s"\'=<>`]+)?/).getRegex(),Te=t=>f(ne).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",W).getRegex(),rt=Te(/ {0,3}(?:[*+-]|1[.)])[ \\t]+[^ \\t\\n]/),st=Te(/ {0,3}(?:[*+-]|\\d{1,9}[.)])(?:[ \\t]|\\n|$)/),it=f(/^( {0,3}> ?(paragraph|[^\\n]*)(?:\\n|$))+/).replace("paragraph",st).getRegex(),ie={blockquote:it,code:We,def:et,fences:Je,heading:Ke,hr:D,html:nt,lheading:ye,list:tt,newline:Ue,paragraph:rt,table:I,text:Ye},he=f("^ *([^\\\\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",W).getRegex(),lt={...ie,lheading:Ve,table:he,paragraph:f(ne).replace("hr",D).replace("heading"," {0,3}#{1,6}(?:\\\\s|$)").replace("|lheading","").replace("table",he).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",W).getRegex()},at={...ie,html:f(`^ *(?:comment *(?:\\\\n|\\\\s*$)|<(tag)[\\\\s\\\\S]+?</\\\\1> *(?:\\\\n{2,}|\\\\s*$)|<tag(?:"[^"]*"|\'[^\']*\'|\\\\s[^\'"/>\\\\s]*)*?/?> *(?:\\\\n{2,}|\\\\s*$))`).replace("comment",se).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:I,lheading:/^(.+?)\\n {0,3}(=+|-+) *(?:\\n+|$)/,paragraph:f(ne).replace("hr",D).replace("heading",` *#{1,6} *[^\n]`).replace("lheading",ye).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},ot=/^\\\\([!"#$%&\'()*+,\\-./:;<=>?@\\[\\]\\\\^_`{|}~])/,ct=/^(`+)([^`]|[^`][\\s\\S]*?[^`])\\1(?!`)/,Re=/^( {2,}|\\\\)\\n(?!\\s*$)/,pt=/^(`+|[^`])(?:(?= {2,}\\n)|[\\s\\S]*?(?:(?=[\\\\<!\\[`*_]|\\b_|$)|[^ ](?= {2,}\\n)))/,A=/[\\p{P}\\p{S}]/u,O=/[\\s\\p{P}\\p{S}]/u,B=/[^\\s\\p{P}\\p{S}]/u,ut=f(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,O).getRegex(),ht=/[\\p{Pi}\\p{Ps}"\']/u,_e=/(?!~)[\\p{P}\\p{S}]/u,ft=/(?!~)[\\s\\p{P}\\p{S}]/u,gt=/(?:[^\\s\\p{P}\\p{S}]|~)/u,kt=f(/link|precode-code|html/,"g").replace("link",/\\[(?:[^\\[\\]`]|(?<a>`+)[^`]+\\k<a>(?!`))*?\\]\\((?:\\\\[\\s\\S]|[^\\\\\\(\\)]|\\((?:\\\\[\\s\\S]|[^\\\\\\(\\)])*\\))*\\)/).replace("precode-",Ge?"(?<!`)()":"(^^|[^`])").replace("code",/(?<b>`+)[^`]+\\k<b>(?!`)/).replace("html",/<(?! )[^<>]*?>/).getRegex(),Se=/^(?:\\*+(?:((?!\\*)punct)|([^\\s*]))?)|^_+(?:((?!_)punct)|([^\\s_]))?/,dt=f(Se,"u").replace(/punct/g,A).getRegex(),xt=f(Se,"u").replace(/punct/g,_e).getRegex(),bt=/^(?:\\*+(?:((?!\\*)(?!openQuote)punct)|([^\\s*]))?)|^_+(?:((?!_)(?!openQuote)punct)|([^\\s_]))?/,mt=f(bt,"u").replace(/openQuote/g,ht).replace(/punct/g,A).getRegex(),$e="^[^_*]*?__[^_*]*?\\\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\\\*)punct(\\\\*+)(?=[\\\\s]|$)|notPunctSpace(\\\\*+)(?!\\\\*)(?=punctSpace|$)|(?!\\\\*)punctSpace(\\\\*+)(?=notPunctSpace)|[\\\\s](\\\\*+)(?!\\\\*)(?=punct)|(?!\\\\*)punct(\\\\*+)(?!\\\\*)(?=punct)|notPunctSpace(\\\\*+)(?=notPunctSpace)",wt=f($e,"gu").replace(/notPunctSpace/g,B).replace(/punctSpace/g,O).replace(/punct/g,A).getRegex(),yt=f($e,"gu").replace(/notPunctSpace/g,gt).replace(/punctSpace/g,ft).replace(/punct/g,_e).getRegex(),Tt="^[^_*]*?__[^_*]*?\\\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\\\*)punct(\\\\*+)(?=[\\\\s]|$)|notPunctSpace(\\\\*+)(?!\\\\*)(?=punctSpace|$)|(?!\\\\*)[\\\\s](\\\\*+)(?=notPunctSpace)|[\\\\s](\\\\*+)(?!\\\\*)(?=punct)|(?!\\\\*)punct(\\\\*+)(?!\\\\*)(?=punct)|(?:(?!\\\\*)punct|notPunctSpace)(\\\\*+)(?!\\\\*)(?=notPunctSpace)",Rt=f(Tt,"gu").replace(/notPunctSpace/g,B).replace(/punctSpace/g,O).replace(/punct/g,A).getRegex(),_t=f("^[^_*]*?\\\\*\\\\*[^_*]*?_[^_*]*?(?=\\\\*\\\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,B).replace(/punctSpace/g,O).replace(/punct/g,A).getRegex(),St="^[^_*]*?\\\\*\\\\*[^_*]*?_[^_*]*?(?=\\\\*\\\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)[\\\\s](_+)(?=notPunctSpace)|[\\\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)|(?:(?!_)punct|notPunctSpace)(_+)(?!_)(?=notPunctSpace)",$t=f(St,"gu").replace(/notPunctSpace/g,B).replace(/punctSpace/g,O).replace(/punct/g,A).getRegex(),Et=f(/^~~?(?:((?!~)punct)|[^\\s~])/,"u").replace(/punct/g,A).getRegex(),At="^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)",zt=f(At,"gu").replace(/notPunctSpace/g,B).replace(/punctSpace/g,O).replace(/punct/g,A).getRegex(),Lt=f(/\\\\(punct)/,"gu").replace(/punct/g,A).getRegex(),It=f(/^<(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(),Ct=f(se).replace("(?:-->|$)","-->").getRegex(),Pt=f("^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",Ct).replace("attribute",/\\s+[a-zA-Z:_][\\w.:-]*(?:\\s*=\\s*"[^"]*"|\\s*=\\s*\'[^\']*\'|\\s*=\\s*[^\\s"\'=<>`]+)?/).getRegex(),Q=/(?:\\[(?:\\\\[\\s\\S]|[^\\[\\]\\\\])*\\]|\\\\[\\s\\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\\])|[^\\[\\]\\\\`])*?/,Mt=f(/^!?\\[(label)\\]\\(\\s*(href)(?:(?:[ \\t]+(?:\\n[ \\t]*)?|\\n[ \\t]*)(title))?\\s*\\)/).replace("label",Q).replace("href",/<(?:\\\\.|[^\\n<>\\\\])+>|[^ \\t\\n\\x00-\\x1f]+|(?=\\))/).replace("title",/"(?:\\\\"?|[^"\\\\])*"|\'(?:\\\\\'?|[^\'\\\\])*\'|\\((?:\\\\\\)?|[^)\\\\])*\\)/).getRegex(),Ee=f(/^!?\\[(label)\\]\\[(ref)\\]/).replace("label",Q).replace("ref",re).getRegex(),Ae=f(/^!?\\[(ref)\\](?:\\[\\])?/).replace("ref",re).getRegex(),Ot=f("reflink|nolink(?!\\\\()","g").replace("reflink",Ee).replace("nolink",Ae).getRegex(),fe=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,le={_backpedal:I,anyPunctuation:Lt,autolink:It,blockSkip:kt,br:Re,code:ct,del:I,delLDelim:I,delRDelim:I,emStrongLDelim:dt,emStrongRDelimAst:wt,emStrongRDelimUnd:_t,escape:ot,link:Mt,nolink:Ae,punctuation:ut,reflink:Ee,reflinkSearch:Ot,tag:Pt,text:pt,url:I},Nt={...le,emStrongLDelim:mt,emStrongRDelimAst:Rt,emStrongRDelimUnd:$t,link:f(/^!?\\[(label)\\]\\((.*?)\\)/).replace("label",Q).getRegex(),reflink:f(/^!?\\[(label)\\]\\s*\\[([^\\]]*)\\]/).replace("label",Q).getRegex()},K={...le,emStrongRDelimAst:yt,emStrongLDelim:xt,delLDelim:Et,delRDelim:zt,url:f(/^((?:protocol):\\/\\/|www\\.)(?:[a-zA-Z0-9\\-]+\\.?)+[^\\s<]*|^email/).replace("protocol",fe).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:f(/^(`+|~+|[^`~])(?:(?=[`~])|(?= {2,}\\n)|(?=[a-zA-Z0-9.!#$%&\'*+\\/=?_`{\\|}~-]+@)|[\\s\\S]*?(?:(?=[\\\\<!\\[`*~_]|\\b_|protocol:\\/\\/|www\\.|$)|[^ ](?= {2,}\\n)|[^a-zA-Z0-9.!#$%&\'*+\\/=?_`{\\|}~-](?=[a-zA-Z0-9.!#$%&\'*+\\/=?_`{\\|}~-]+@)))/).replace("protocol",fe).getRegex()},vt={...K,br:f(Re).replace("{2,}","*").getRegex(),text:f(K.text).replace("\\\\b_","\\\\b_| {2,}\\\\n").replace(/\\{2,\\}/g,"*").getRegex()},X={normal:ie,gfm:lt,pedantic:at},N={normal:le,gfm:K,breaks:vt,pedantic:Nt},Dt={"&":"&","<":"<",">":">",\'"\':""","\'":"'"},ge=t=>Dt[t];function S(t,e){if(e){if(b.escapeTest.test(t))return t.replace(b.escapeReplace,ge)}else if(b.escapeTestNoEncode.test(t))return t.replace(b.escapeReplaceNoEncode,ge);return t}function ke(t){try{t=encodeURI(t).replace(b.percentDecode,"%")}catch{return null}return t}function de(t,e){let n=t.replace(b.findPipe,(i,a,l)=>{let o=!1,c=a;for(;--c>=0&&l[c]==="\\\\";)o=!o;return o?"|":" |"}),r=n.split(b.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(b.slashPipe,"|");return r}function z(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 xe(t){let e=t.split(`\n`),n=e.length-1;for(;n>=0&&b.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 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 qt(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 be(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 Zt(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 G=class{options;rules;lexer;constructor(t){this.options=t||P}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]:xe(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=Zt(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=z(n,"#");(this.options.pedantic||!r||this.rules.other.endingSpaceChar.test(r))&&(n=r.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`),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`),u=c.replace(this.rules.other.blockquoteSetextReplace,`\n $1`).replace(this.rules.other.blockquoteSetextReplace2,"");r=r?`${r}\n${c}`:c,s=s?`${s}\n${u}`:u;let p=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTokens(u,i,!0),this.lexer.state.top=p,n.length===0)break;let h=i.at(-1);if(h?.type==="code")break;if(h?.type==="blockquote"){let d=h,k=n.join(`\n`),m=d.raw+`\n`+k.replace(this.rules.other.blockquoteSetextReplace2,""),x=this.blockquote(m);i[i.length-1]=x,r=`${r}\n${k}`,s=s.substring(0,s.length-d.text.length)+x.text;break}else if(h?.type==="list"){let d=h,k=d.raw+`\n`+n.join(`\n`),m=this.list(k);i[i.length-1]=m,r=r.substring(0,r.length-h.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="",u="";if(!(e=i.exec(t))||this.rules.block.hr.test(t))break;c=e[0],t=t.substring(c.length);let p=qt(e[2].split(`\n`,1)[0],e[1].length),h=t.split(`\n`,1)[0],d=!p.trim(),k=0;if(this.options.pedantic?(k=2,u=p.trimStart()):d?k=e[1].length+1:(k=p.search(this.rules.other.nonSpaceChar),k=k>4?1:k,u=p.slice(k),k+=e[1].length),d&&this.rules.other.blankLine.test(h)&&(c+=h+`\n`,t=t.substring(h.length+1),o=!0),!o){let m=this.rules.other.nextBulletRegex(k),x=this.rules.other.hrRegex(k),y=this.rules.other.fencesBeginRegex(k),E=this.rules.other.headingBeginRegex(k),J=this.rules.other.htmlBeginRegex(k),L=this.rules.other.blockquoteBeginRegex(k);for(;t;){let w=t.split(`\n`,1)[0],_;if(h=w,this.options.pedantic?(h=h.replace(this.rules.other.listReplaceNesting," "),_=h):_=h.replace(this.rules.other.tabCharGlobal," "),y.test(h)||E.test(h)||J.test(h)||L.test(h)||m.test(h)||x.test(h))break;if(_.search(this.rules.other.nonSpaceChar)>=k||!h.trim())u+=`\n`+_.slice(k);else{if(d||p.replace(this.rules.other.tabCharGlobal," ").search(this.rules.other.nonSpaceChar)>=4||y.test(p)||E.test(p)||x.test(p))break;u+=`\n`+h}d=!h.trim(),c+=w+`\n`,t=t.substring(w.length+1),p=_.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(u),loose:!1,text:u,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 p=this.lexer.inlineQueue.length-1;p>=0;p--)if(this.rules.other.listIsTask.test(this.lexer.inlineQueue[p].src)){this.lexer.inlineQueue[p].src=this.lexer.inlineQueue[p].src.replace(this.rules.other.listReplaceTask,"");break}let u=this.rules.other.listTaskCheckbox.exec(o.raw);if(u){let p={type:"checkbox",raw:u[0]+" ",checked:u[0]!=="[ ]"};o.checked=p.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=p.raw+o.tokens[0].raw,o.tokens[0].text=p.raw+o.tokens[0].text,o.tokens[0].tokens.unshift(p)):o.tokens.unshift({type:"paragraph",raw:p.raw,text:p.raw,tokens:[p]}):o.tokens.unshift(p)}}else o.task&&(o.task=!1);if(!s.loose){let u=o.tokens.filter(h=>h.type==="space"),p=u.length>0&&u.some(h=>this.rules.other.anyLine.test(h.raw));s.loose=p}}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=xe(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:z(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=de(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:z(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(de(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 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)),be(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 be(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],u=n===c,p=c==="*"?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(p.lastIndex=0,e=e.slice(-1*t.length+s);(r=p.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]){if(s%3&&!((s+a)%3)){o+=a;continue}if(u)break}if(l-=a,l>0)continue;a=Math.min(a,a+l+o);let h=[...r[0]][0].length,d=t.slice(0,s+r.index+h+a);if(Math.min(s,a)%2){let m=d.slice(1,-1);return{type:"em",raw:d,text:m,tokens:this.lexer.inlineTokens(m)}}let k=d.slice(2,-2);return{type:"strong",raw:d,text:k,tokens:this.lexer.inlineTokens(k)}}}}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,u=t.slice(0,s+r.index+c+a),p=u.slice(s,-s);return{type:"del",raw:u,text:p,tokens:this.lexer.inlineTokens(p)}}}}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}}}},T=class V{tokens;options;state;inlineQueue;tokenizer;constructor(e){this.tokens=[],this.tokens.links=Object.create(null),this.options=e||P,this.options.tokenizer=this.options.tokenizer||new G,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:b,block:X.normal,inline:N.normal};this.options.pedantic?(n.block=X.pedantic,n.inline=N.pedantic):this.options.gfm&&(n.block=X.gfm,this.options.breaks?n.inline=N.breaks:n.inline=N.gfm),this.tokenizer.rules=n}static get rules(){return{block:X,inline:N}}static lex(e,n){return new V(n).lex(e)}static lexInline(e,n){return new V(n).inlineTokens(e)}lex(e){e=e.replace(b.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(b.tabCharGlobal," ").replace(b.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(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);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 u=c?c.length:0;return l.slice(0,u)+"["+"a".repeat(l.length-u-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,u=e.slice(1),p;this.options.extensions.startInline.forEach(h=>{p=h.call({lexer:this},u),typeof p=="number"&&p>=0&&(c=Math.min(c,p))}),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)}},U=class{options;parser;constructor(t){this.options=t||P}space(t){return""}code({text:t,lang:e,escaped:n}){let r=(e||"").match(b.notSpaceStart)?.[0],s=t.replace(b.endingNewline,"")+`\n`;return r?\'<pre><code class="language-\'+S(r)+\'">\'+(n?s:S(s,!0))+`</code></pre>\n`:"<pre><code>"+(n?s: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>${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 r=this.parser.parseInline(n),s=ke(t);if(s===null)return r;t=s;let i=\'<a href="\'+t+\'"\';return e&&(i+=\' title="\'+S(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=ke(t);if(s===null)return S(n);t=s;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)}},ae=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}},R=class Y{options;renderer;textRenderer;constructor(e){this.options=e||P,this.options.renderer=this.options.renderer||new U,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new ae}static parse(e,n){return new Y(n).parse(e)}static parseInline(e,n){return new Y(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","checkbox","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","checkbox","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}},v=class{options;block;constructor(t){this.options=t||P}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?T.lex:T.lexInline}provideParser(t=this.block){return t?R.parse:R.parseInline}},Ft=class{defaults=ee();options=this.setOptions;parse=this.parseMarkdown(!0);parseInline=this.parseMarkdown(!1);Parser=R;Renderer=U;TextRenderer=ae;Lexer=T;Tokenizer=G;Hooks=v;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 U(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 u=l.apply(s,c);return u===!1&&(u=o.apply(s,c)),u||""}}r.renderer=s}if(n.tokenizer){let s=this.defaults.tokenizer||new G(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 u=l.apply(s,c);return u===!1&&(u=o.apply(s,c)),u}}r.tokenizer=s}if(n.hooks){let s=this.defaults.hooks||new v;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];v.passThroughHooks.has(i)?s[a]=c=>{if(this.defaults.async&&v.passThroughHooksRespectAsync.has(i))return(async()=>{let p=await l.call(s,c);return o.call(s,p)})();let u=l.call(s,c);return o.call(s,u)}:s[a]=(...c)=>{if(this.defaults.async)return(async()=>{let p=await l.apply(s,c);return p===!1&&(p=await o.apply(s,c)),p})();let u=l.apply(s,c);return u===!1&&(u=o.apply(s,c)),u}}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 T.lex(t,e??this.defaults)}parser(t,e){return R.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?T.lex:T.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?R.parse:R.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?T.lex:T.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?R.parse:R.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>"+S(n.message+"",!0)+"</pre>";return e?Promise.resolve(r):r}if(e)return Promise.reject(n);throw n}}},C=new Ft;function g(t,e){return C.parse(t,e)}g.options=g.setOptions=function(t){return C.setOptions(t),g.defaults=C.defaults,me(g.defaults),g};g.getDefaults=ee;g.defaults=P;function Ht(...t){return C.use(...t),g.defaults=C.defaults,me(g.defaults),g}g.use=Ht;g.walkTokens=function(t,e){return C.walkTokens(t,e)};g.parseInline=C.parseInline;g.Parser=R;g.parser=R.parse;g.Renderer=U;g.TextRenderer=ae;g.Lexer=T;g.lexer=T.lex;g.Tokenizer=G;g.Hooks=v;g.parse=g;var pn=g.options,un=g.setOptions,hn=g.walkTokens,fn=g.parseInline;var gn=R.parse,kn=T.lex;var ze=/^ {0,3}:::([A-Za-z][\\w-]*)?[ \\t]*(?:\\n|$)/,jt=/^ {0,3}:::([A-Za-z][\\w-]*)?[ \\t]*$/;function Xt(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=jt.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 Le=[{name:"container",level:"block",tokenizer(t){let e=ze.exec(t);if(!e)return;let n=t.slice(e[0].length),r=Xt(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 oe(t){return t.includes(":::")===!1?!1:new RegExp(ze.source,"m").test(t)}var Pe="([^\\\\]\\\\s]+)",Qt=new RegExp(`^\\\\[\\\\^${Pe}\\\\]`),Me=new RegExp(`^ {0,3}\\\\[\\\\^${Pe}\\\\]:[ \\\\t]*([^\\\\n]*)\\\\n?`);function Ie(t){return/^[ \\t]*$/.test(t)}var Ce=/^(?: {4}| {0,3}\\t)/;function Gt(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(!Ie(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(!Ce.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=>Ie(l)?"":l.replace(Ce,"")).join(`\n`);return{raw:i,body:a,open:s}}}function ce(t){return t.includes("[^")===!1?!1:new RegExp(Me.source,"m").test(t)}var Oe=[{name:"footnoteRef",level:"inline",tokenizer(t){let e=Qt.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=Me.exec(t);if(!e)return;let n=t.slice(e[0].length),r=Gt(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}}];var q=/\\s*\\{(?:#|\\.)[^}]*\\}\\s*$/;function Ut(t){if(q.test(t.text)&&(t.text=t.text.replace(q,""),t.tokens&&t.tokens.length>0))for(let e=t.tokens.length-1;e>=0;e--){let n=t.tokens[e];if(n.type==="text"&&typeof n.text=="string"){if(q.test(n.text)){let r=n.text.replace(q,"");r===""?t.tokens.splice(e,1):(n.text=r,typeof n.raw=="string"&&(n.raw=n.raw.replace(q,"")));break}if(n.text.trim()==="")continue;break}break}}function H(t){for(let e of t){e.type==="heading"&&Ut(e);let n=e;if(Array.isArray(n.tokens)&&H(n.tokens),Array.isArray(n.items))for(let r of n.items)Array.isArray(r.tokens)&&H(r.tokens)}}function ve(t,e,n){let r=0;for(let s=e;s<n;s++)r+=t[s].raw.length;return r}function Wt(t,e){let n=t;return n.links=e,n}function De(t,e){for(let n=e;n+1<t.length;n++)if(t[n].type==="paragraph"&&t[n+1].type==="paragraph")return n;return t.length}function Jt(t,e){return t[e-2]?.type!=="list"?!0:e+1<t.length}function Be(t,e,n){let r=Math.min(t.length-2,n-1);for(let s=r;s>=e;s--)if(t[s].type==="space"&&Jt(t,s+1)!==!1)return s+1;return-1}function qe(t){let e=t.links;if(!e)return!1;for(let n in e)return!0;return!1}function Ze(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 F(t,e,n){return{source:t,tail:t,tokens:e,stableCount:0,stableOffset:0,degraded:!0,degradedReason:n}}function Ne(t,e){return{source:t,tail:t,tokens:e,stableCount:0,stableOffset:0,degraded:!1,degradedReason:null}}function Kt(t,e){if(qe(e))return F(t,e,"link-definition");if(t.includes("\\r"))return F(t,e,"carriage-return");if(oe(t))return F(t,e,"container");if(ce(t))return F(t,e,"footnote-def");let n=De(e,0),r=Be(e,1,n);if(r<0||Ze(e,0,r,t,0)===!1)return Ne(t,e);let s=ve(e,0,r);return{source:t,tail:t.slice(s),tokens:e,stableCount:r,stableOffset:s,degraded:!1,degradedReason:null}}function pe(t){let e=g.lexer(t);return H(e),{tokens:e,cache:Kt(t,e),charsLexed:t.length,reusedTokens:0}}function Z(t,e){let n=g.lexer(t);return H(n),{tokens:n,cache:F(t,n,e),charsLexed:t.length,reusedTokens:0}}function Fe(t,e){let n=t.source+e;if(t.degraded)return Z(n,t.degradedReason??"link-definition");if(e.includes("\\r"))return Z(n,"carriage-return");if(t.stableCount===0)return pe(n);let r=t.tail+e;if(oe(r))return Z(n,"container");if(ce(r))return Z(n,"footnote-def");let s=g.lexer(r);if(H(s),qe(s))return Z(n,"link-definition");let i=t.tokens.slice(0,t.stableCount),a=Wt([...i,...s],s.links),l=t.stableCount,o=t.stableOffset,c=r,u=Be(a,t.stableCount+1,De(a,t.stableCount));if(u>t.stableCount&&Ze(a,t.stableCount,u,r,0)){let p=ve(a,t.stableCount,u);l=u,o=t.stableOffset+p,c=r.slice(p)}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 Vt=/^ {0,3}\\*\\[([^\\]\\n]+)\\]:[ \\t]*([^\\n]*)(?:\\n|$)/,He=[{name:"abbrDef",level:"block",tokenizer(t){let e=Vt.exec(t);if(e)return{type:"abbrDef",raw:e[0],term:e[1],definition:e[2]}},renderer(t){return t.raw}}];var Yt=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}"}),en=/^:([A-Za-z0-9_+-]+):/,je=[{name:"emoji",level:"inline",start(t){return t.match(/:/)?.index},tokenizer(t){let e=en.exec(t);if(!e)return;let n=Yt[e[1]];if(n!==void 0)return{type:"emoji",raw:e[0],text:n}},renderer(t){return t.raw}}];var tn=/^\\+\\+(?!\\s)((?:\\\\[\\s\\S]|(?!\\+\\+)[\\s\\S])+?)(?<!\\s)\\+\\+/,nn=/^==(?!\\s)((?:\\\\[\\s\\S]|(?!==)[\\s\\S])+?)(?<!\\s)==/,Xe=[{name:"ins",level:"inline",start(t){return t.match(/(?<!\\\\)\\+\\+(?!\\s)/)?.index},tokenizer(t){let e=tn.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=nn.exec(t);if(e)return{type:"mark",raw:e[0],text:e[1].replace(/\\\\(.)/g,"$1")}},renderer(t){return t.raw}}];var rn=/^\\^((?:\\\\[\\s\\S]|[^\\s^\\\\])+)\\^/,Qe=[{name:"sup",level:"inline",start(t){return t.match(/(?<!\\\\)\\^(?!\\s)/)?.index},tokenizer(t){let e=rn.exec(t);if(e)return{type:"sup",raw:e[0],text:e[1].replace(/\\\\(.)/g,"$1")}},renderer(t){return t.raw}}];var j=/\\s*\\{(?:#|\\.)[^}]*\\}\\s*$/;function sn(t){if(j.test(t.text)&&(t.text=t.text.replace(j,""),t.tokens&&t.tokens.length>0))for(let e=t.tokens.length-1;e>=0;e--){let n=t.tokens[e];if(n.type==="text"&&typeof n.text=="string"){if(j.test(n.text)){let r=n.text.replace(j,"");r===""?t.tokens.splice(e,1):(n.text=r,typeof n.raw=="string"&&(n.raw=n.raw.replace(j,"")));break}if(n.text.trim()==="")continue;break}break}}var ln=0;function an(t){if(typeof t!="string"||typeof performance.mark!="function"||typeof performance.measure!="function")return null;let e=ln++,n={name:t,startMark:`${t}:start:${e}`,endMark:`${t}:end:${e}`};try{return performance.mark(n.startMark),n}catch{return null}}function on(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({walkTokens(t){t.type==="heading"&&sn(t)},extensions:[...Oe,...Qe,...Xe,...je,...Le,...He,{name:"blockMath",level:"block",start(t){return t.match(/^ {0,3}\\$\\$/m)?.index},tokenizer(t){let e=/^ {0,3}\\$\\$((?:(?!\\n[ \\t]*\\n)[\\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)|\\$(?![$\\s]))/)?.index},tokenizer(t){let e=/^\\$\\$(?!\\s)((?:\\\\\\$|[^$\\n])*?)(?<!\\s)\\$\\$(?!\\d)/.exec(t);if(e){let r=e[1].trim();if(r!=="")return{type:"inlineMath",raw:e[0],text:r}}let n=/^\\$(?![$\\s])((?:\\\\\\$|[^$\\n])*?)(?<!\\s)\\$(?!\\d)/.exec(t);if(n)return{type:"inlineMath",raw:n[0],text:n[1].trim()}},renderer(t){return t.raw}}]});var $=new Map,cn=256;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:u}=e;if(c===!0){typeof l=="string"&&$.delete(l);return}let p=typeof l=="string"?l:null,h=typeof o=="number"?o:null,d,k=null,m=null;if(typeof s=="string"){if(p===null||h===null){self.postMessage({id:n,needResync:!0});return}let x=$.get(p);if(!x||x.version!==h){self.postMessage({id:n,needResync:!0});return}if(typeof i=="number"&&x.lex.source.length+s.length!==i){$.delete(p),self.postMessage({id:n,needResync:!0});return}let y=x.lex;d=()=>Fe(y,s),m=y.tokens}else if(typeof r=="string"){let x=r;if(d=()=>pe(x),Array.isArray(a))k=a;else if(p!==null&&h!==null){let y=$.get(p);if(y&&y.version===h)m=y.lex.tokens;else{self.postMessage({id:n,needResync:!0});return}}}else return;try{let x=typeof u=="string"?an(u):null,y=performance.now(),E;try{E=d()}finally{x&&on(x)}let J=performance.now()-y,L=E.tokens,w=0;if(k!==null){let _=Math.min(k.length,L.length);for(;w<_&&k[w]===L[w].raw;w++);}else if(m!==null){let _=m,ue=Math.min(_.length,L.length);for(w=Math.min(E.reusedTokens,ue);w<ue&&_[w].raw===L[w].raw;w++);}p!==null&&h!==null&&($.delete(p),$.set(p,{version:h+1,lex:E.cache}),$.size>cn&&$.delete($.keys().next().value)),self.postMessage({id:n,matchLen:w,tail:L.slice(w),lexerMs:J,sourceCharsLexed:E.charsLexed,stablePrefixChars:E.cache.stableOffset})}catch(x){p!==null&&$.delete(p),self.postMessage({id:n,error:String(x)})}};})();\n';
|
|
3497
|
+
var WORKER_SOURCE_STRING = '"use strict";(()=>{function ee(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var P=ee();function me(t){P=t}var I={exec:()=>null};function O(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 f(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(b.caret,"$1"),n=n.replace(s,a),r},getRegex:()=>new RegExp(n,e)};return r}var Ge=((t="")=>{try{return!!new RegExp("(?<=1)(?<!1)"+t)}catch{return!1}})(),b={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:O(t=>new RegExp(`^ {0,${t}}(?:[*+-]|\\\\d{1,9}[.)])((?:[ ][^\\\\n]*)?(?:\\\\n|$))`)),hrRegex:O(t=>new RegExp(`^ {0,${t}}((?:- *){3,}|(?:_ *){3,}|(?:\\\\* *){3,})(?:\\\\n+|$)`)),fencesBeginRegex:O(t=>new RegExp(`^ {0,${t}}(?:\\`\\`\\`|~~~)`)),headingBeginRegex:O(t=>new RegExp(`^ {0,${t}}#`)),htmlBeginRegex:O(t=>new RegExp(`^ {0,${t}}<(?:[a-z].*>|!--)`,"i")),blockquoteBeginRegex:O(t=>new RegExp(`^ {0,${t}}>`))},Ue=/^(?:[ \\t]*(?:\\n|$))+/,We=/^((?: {4}| {0,3}\\t)[^\\n]+(?:\\n(?:[ \\t]*(?:\\n|$))*)?)+/,Je=/^ {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+|$)/,Ke=/^ {0,3}(#{1,6})(?=\\s|$)(.*)(?:\\n+|$)/,te=/ {0,3}(?:[*+-]|\\d{1,9}[.)])/,we=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\\n(?!\\s*?\\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\\n {0,3}(=+|-+) *(?:\\n+|$)/,ye=f(we).replace(/bull/g,te).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(),Ve=f(we).replace(/bull/g,te).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(),ne=/^([^\\n]+(?:\\n(?!hr|heading|lheading|blockquote|fences|list|html|table|[ \\t]+\\n)[^\\n]+)*)/,Ye=/^[^\\n]+/,re=/(?!\\s*\\])(?:\\\\[\\s\\S]|[^\\[\\]\\\\])+/,et=f(/^ {0,3}\\[(label)\\]: *(?:\\n[ \\t]*)?([^<\\s][^\\s]*|<.*?>)(?:(?: +(?:\\n[ \\t]*)?| *\\n[ \\t]*)(title))? *(?:\\n+|$)/).replace("label",re).replace("title",/(?:"(?:\\\\"?|[^"\\\\])*"|\'[^\'\\n]*(?:\\n[^\'\\n]+)*\\n?\'|\\([^()]*\\))/).getRegex(),tt=f(/^(bull)([ \\t][^\\n]*?)?(?:\\n|$)/).replace(/bull/g,te).getRegex(),W="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",se=/<!--(?:-?>|[\\s\\S]*?(?:-->|$))/,nt=f("^ {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",se).replace("tag",W).replace("attribute",/ +[a-zA-Z:_][\\w.:-]*(?: *= *"[^"\\n]*"| *= *\'[^\'\\n]*\'| *= *[^\\s"\'=<>`]+)?/).getRegex(),Te=t=>f(ne).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",W).getRegex(),rt=Te(/ {0,3}(?:[*+-]|1[.)])[ \\t]+[^ \\t\\n]/),st=Te(/ {0,3}(?:[*+-]|\\d{1,9}[.)])(?:[ \\t]|\\n|$)/),it=f(/^( {0,3}> ?(paragraph|[^\\n]*)(?:\\n|$))+/).replace("paragraph",st).getRegex(),ie={blockquote:it,code:We,def:et,fences:Je,heading:Ke,hr:D,html:nt,lheading:ye,list:tt,newline:Ue,paragraph:rt,table:I,text:Ye},he=f("^ *([^\\\\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",W).getRegex(),lt={...ie,lheading:Ve,table:he,paragraph:f(ne).replace("hr",D).replace("heading"," {0,3}#{1,6}(?:\\\\s|$)").replace("|lheading","").replace("table",he).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",W).getRegex()},at={...ie,html:f(`^ *(?:comment *(?:\\\\n|\\\\s*$)|<(tag)[\\\\s\\\\S]+?</\\\\1> *(?:\\\\n{2,}|\\\\s*$)|<tag(?:"[^"]*"|\'[^\']*\'|\\\\s[^\'"/>\\\\s]*)*?/?> *(?:\\\\n{2,}|\\\\s*$))`).replace("comment",se).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:I,lheading:/^(.+?)\\n {0,3}(=+|-+) *(?:\\n+|$)/,paragraph:f(ne).replace("hr",D).replace("heading",` *#{1,6} *[^\n]`).replace("lheading",ye).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},ot=/^\\\\([!"#$%&\'()*+,\\-./:;<=>?@\\[\\]\\\\^_`{|}~])/,ct=/^(`+)([^`]|[^`][\\s\\S]*?[^`])\\1(?!`)/,Re=/^( {2,}|\\\\)\\n(?!\\s*$)/,ut=/^(`+|[^`])(?:(?= {2,}\\n)|[\\s\\S]*?(?:(?=[\\\\<!\\[`*_]|\\b_|$)|[^ ](?= {2,}\\n)))/,A=/[\\p{P}\\p{S}]/u,M=/[\\s\\p{P}\\p{S}]/u,B=/[^\\s\\p{P}\\p{S}]/u,pt=f(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,M).getRegex(),ht=/[\\p{Pi}\\p{Ps}"\']/u,_e=/(?!~)[\\p{P}\\p{S}]/u,ft=/(?!~)[\\s\\p{P}\\p{S}]/u,gt=/(?:[^\\s\\p{P}\\p{S}]|~)/u,kt=f(/link|precode-code|html/,"g").replace("link",/\\[(?:[^\\[\\]`]|(?<a>`+)[^`]+\\k<a>(?!`))*?\\]\\((?:\\\\[\\s\\S]|[^\\\\\\(\\)]|\\((?:\\\\[\\s\\S]|[^\\\\\\(\\)])*\\))*\\)/).replace("precode-",Ge?"(?<!`)()":"(^^|[^`])").replace("code",/(?<b>`+)[^`]+\\k<b>(?!`)/).replace("html",/<(?! )[^<>]*?>/).getRegex(),Se=/^(?:\\*+(?:((?!\\*)punct)|([^\\s*]))?)|^_+(?:((?!_)punct)|([^\\s_]))?/,dt=f(Se,"u").replace(/punct/g,A).getRegex(),xt=f(Se,"u").replace(/punct/g,_e).getRegex(),bt=/^(?:\\*+(?:((?!\\*)(?!openQuote)punct)|([^\\s*]))?)|^_+(?:((?!_)(?!openQuote)punct)|([^\\s_]))?/,mt=f(bt,"u").replace(/openQuote/g,ht).replace(/punct/g,A).getRegex(),$e="^[^_*]*?__[^_*]*?\\\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\\\*)punct(\\\\*+)(?=[\\\\s]|$)|notPunctSpace(\\\\*+)(?!\\\\*)(?=punctSpace|$)|(?!\\\\*)punctSpace(\\\\*+)(?=notPunctSpace)|[\\\\s](\\\\*+)(?!\\\\*)(?=punct)|(?!\\\\*)punct(\\\\*+)(?!\\\\*)(?=punct)|notPunctSpace(\\\\*+)(?=notPunctSpace)",wt=f($e,"gu").replace(/notPunctSpace/g,B).replace(/punctSpace/g,M).replace(/punct/g,A).getRegex(),yt=f($e,"gu").replace(/notPunctSpace/g,gt).replace(/punctSpace/g,ft).replace(/punct/g,_e).getRegex(),Tt="^[^_*]*?__[^_*]*?\\\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\\\*)punct(\\\\*+)(?=[\\\\s]|$)|notPunctSpace(\\\\*+)(?!\\\\*)(?=punctSpace|$)|(?!\\\\*)[\\\\s](\\\\*+)(?=notPunctSpace)|[\\\\s](\\\\*+)(?!\\\\*)(?=punct)|(?!\\\\*)punct(\\\\*+)(?!\\\\*)(?=punct)|(?:(?!\\\\*)punct|notPunctSpace)(\\\\*+)(?!\\\\*)(?=notPunctSpace)",Rt=f(Tt,"gu").replace(/notPunctSpace/g,B).replace(/punctSpace/g,M).replace(/punct/g,A).getRegex(),_t=f("^[^_*]*?\\\\*\\\\*[^_*]*?_[^_*]*?(?=\\\\*\\\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,B).replace(/punctSpace/g,M).replace(/punct/g,A).getRegex(),St="^[^_*]*?\\\\*\\\\*[^_*]*?_[^_*]*?(?=\\\\*\\\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)[\\\\s](_+)(?=notPunctSpace)|[\\\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)|(?:(?!_)punct|notPunctSpace)(_+)(?!_)(?=notPunctSpace)",$t=f(St,"gu").replace(/notPunctSpace/g,B).replace(/punctSpace/g,M).replace(/punct/g,A).getRegex(),Et=f(/^~~?(?:((?!~)punct)|[^\\s~])/,"u").replace(/punct/g,A).getRegex(),At="^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)",zt=f(At,"gu").replace(/notPunctSpace/g,B).replace(/punctSpace/g,M).replace(/punct/g,A).getRegex(),Lt=f(/\\\\(punct)/,"gu").replace(/punct/g,A).getRegex(),It=f(/^<(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(),Ct=f(se).replace("(?:-->|$)","-->").getRegex(),Pt=f("^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",Ct).replace("attribute",/\\s+[a-zA-Z:_][\\w.:-]*(?:\\s*=\\s*"[^"]*"|\\s*=\\s*\'[^\']*\'|\\s*=\\s*[^\\s"\'=<>`]+)?/).getRegex(),Q=/(?:\\[(?:\\\\[\\s\\S]|[^\\[\\]\\\\])*\\]|\\\\[\\s\\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\\])|[^\\[\\]\\\\`])*?/,Ot=f(/^!?\\[(label)\\]\\(\\s*(href)(?:(?:[ \\t]+(?:\\n[ \\t]*)?|\\n[ \\t]*)(title))?\\s*\\)/).replace("label",Q).replace("href",/<(?:\\\\.|[^\\n<>\\\\])+>|[^ \\t\\n\\x00-\\x1f]+|(?=\\))/).replace("title",/"(?:\\\\"?|[^"\\\\])*"|\'(?:\\\\\'?|[^\'\\\\])*\'|\\((?:\\\\\\)?|[^)\\\\])*\\)/).getRegex(),Ee=f(/^!?\\[(label)\\]\\[(ref)\\]/).replace("label",Q).replace("ref",re).getRegex(),Ae=f(/^!?\\[(ref)\\](?:\\[\\])?/).replace("ref",re).getRegex(),Mt=f("reflink|nolink(?!\\\\()","g").replace("reflink",Ee).replace("nolink",Ae).getRegex(),fe=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,le={_backpedal:I,anyPunctuation:Lt,autolink:It,blockSkip:kt,br:Re,code:ct,del:I,delLDelim:I,delRDelim:I,emStrongLDelim:dt,emStrongRDelimAst:wt,emStrongRDelimUnd:_t,escape:ot,link:Ot,nolink:Ae,punctuation:pt,reflink:Ee,reflinkSearch:Mt,tag:Pt,text:ut,url:I},Nt={...le,emStrongLDelim:mt,emStrongRDelimAst:Rt,emStrongRDelimUnd:$t,link:f(/^!?\\[(label)\\]\\((.*?)\\)/).replace("label",Q).getRegex(),reflink:f(/^!?\\[(label)\\]\\s*\\[([^\\]]*)\\]/).replace("label",Q).getRegex()},K={...le,emStrongRDelimAst:yt,emStrongLDelim:xt,delLDelim:Et,delRDelim:zt,url:f(/^((?:protocol):\\/\\/|www\\.)(?:[a-zA-Z0-9\\-]+\\.?)+[^\\s<]*|^email/).replace("protocol",fe).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:f(/^(`+|~+|[^`~])(?:(?=[`~])|(?= {2,}\\n)|(?=[a-zA-Z0-9.!#$%&\'*+\\/=?_`{\\|}~-]+@)|[\\s\\S]*?(?:(?=[\\\\<!\\[`*~_]|\\b_|protocol:\\/\\/|www\\.|$)|[^ ](?= {2,}\\n)|[^a-zA-Z0-9.!#$%&\'*+\\/=?_`{\\|}~-](?=[a-zA-Z0-9.!#$%&\'*+\\/=?_`{\\|}~-]+@)))/).replace("protocol",fe).getRegex()},vt={...K,br:f(Re).replace("{2,}","*").getRegex(),text:f(K.text).replace("\\\\b_","\\\\b_| {2,}\\\\n").replace(/\\{2,\\}/g,"*").getRegex()},X={normal:ie,gfm:lt,pedantic:at},N={normal:le,gfm:K,breaks:vt,pedantic:Nt},Dt={"&":"&","<":"<",">":">",\'"\':""","\'":"'"},ge=t=>Dt[t];function S(t,e){if(e){if(b.escapeTest.test(t))return t.replace(b.escapeReplace,ge)}else if(b.escapeTestNoEncode.test(t))return t.replace(b.escapeReplaceNoEncode,ge);return t}function ke(t){try{t=encodeURI(t).replace(b.percentDecode,"%")}catch{return null}return t}function de(t,e){let n=t.replace(b.findPipe,(i,a,l)=>{let c=!1,o=a;for(;--o>=0&&l[o]==="\\\\";)c=!c;return c?"|":" |"}),r=n.split(b.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(b.slashPipe,"|");return r}function z(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 xe(t){let e=t.split(`\n`),n=e.length-1;for(;n>=0&&b.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 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 qt(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 be(t,e,n,r,s){let i=e.href,a=e.title||null,l=t[1].replace(s.other.outputLinkReplace,"$1"),c=t[0].charAt(0)==="!";r.state.inLink=!0;let o=r.state.linkEmitted,p=r.state.inRawBlock;r.state.linkEmitted=!1;let u=r.inlineTokens(l),h=r.state.linkEmitted;if(r.state.linkEmitted=o,r.state.inLink=!1,!c){if(h){r.state.inRawBlock=p;return}r.state.linkEmitted=!0}return{type:c?"image":"link",raw:n,href:i,title:a,text:l,tokens:u}}function Zt(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 G=class{options;rules;lexer;constructor(t){this.options=t||P}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]:xe(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=Zt(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=z(n,"#");(this.options.pedantic||!r||this.rules.other.endingSpaceChar.test(r))&&(n=r.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`),r="",s="",i=[];for(;n.length>0;){let a=!1,l=[],c;for(c=0;c<n.length;c++)if(this.rules.other.blockquoteStart.test(n[c]))l.push(n[c]),a=!0;else if(!a)l.push(n[c]);else break;n=n.slice(c);let o=l.join(`\n`),p=o.replace(this.rules.other.blockquoteSetextReplace,`\n $1`).replace(this.rules.other.blockquoteSetextReplace2,"");r=r?`${r}\n${o}`:o,s=s?`${s}\n${p}`:p;let u=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTokens(p,i,!0),this.lexer.state.top=u,n.length===0)break;let h=i.at(-1);if(h?.type==="code")break;if(h?.type==="blockquote"){let d=h,k=n.join(`\n`),m=d.raw+`\n`+k.replace(this.rules.other.blockquoteSetextReplace2,""),x=this.blockquote(m);i[i.length-1]=x,r=`${r}\n${k}`,s=s.substring(0,s.length-d.text.length)+x.text;break}else if(h?.type==="list"){let d=h,k=d.raw+`\n`+n.join(`\n`),m=this.list(k);i[i.length-1]=m,r=r.substring(0,r.length-h.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 c=!1,o="",p="";if(!(e=i.exec(t))||this.rules.block.hr.test(t))break;o=e[0],t=t.substring(o.length);let u=qt(e[2].split(`\n`,1)[0],e[1].length),h=t.split(`\n`,1)[0],d=!u.trim(),k=0;if(this.options.pedantic?(k=2,p=u.trimStart()):d?k=e[1].length+1:(k=u.search(this.rules.other.nonSpaceChar),k=k>4?1:k,p=u.slice(k),k+=e[1].length),d&&this.rules.other.blankLine.test(h)&&(o+=h+`\n`,t=t.substring(h.length+1),c=!0),!c){let m=this.rules.other.nextBulletRegex(k),x=this.rules.other.hrRegex(k),y=this.rules.other.fencesBeginRegex(k),E=this.rules.other.headingBeginRegex(k),J=this.rules.other.htmlBeginRegex(k),L=this.rules.other.blockquoteBeginRegex(k);for(;t;){let w=t.split(`\n`,1)[0],_;if(h=w,this.options.pedantic?(h=h.replace(this.rules.other.listReplaceNesting," "),_=h):_=h.replace(this.rules.other.tabCharGlobal," "),y.test(h)||E.test(h)||J.test(h)||L.test(h)||m.test(h)||x.test(h))break;if(_.search(this.rules.other.nonSpaceChar)>=k||!h.trim())p+=`\n`+_.slice(k);else{if(d||u.replace(this.rules.other.tabCharGlobal," ").search(this.rules.other.nonSpaceChar)>=4||y.test(u)||E.test(u)||x.test(u))break;p+=`\n`+h}d=!h.trim(),o+=w+`\n`,t=t.substring(w.length+1),u=_.slice(k)}}s.loose||(a?s.loose=!0:this.rules.other.doubleBlankLine.test(o)&&(a=!0)),s.items.push({type:"list_item",raw:o,task:!!this.options.gfm&&this.rules.other.listIsTask.test(p),loose:!1,text:p,tokens:[]}),s.raw+=o}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 c of s.items)if(this.lexer.state.top=!1,c.tokens=this.lexer.blockTokens(c.text,[]),!s.loose){let o=c.tokens.filter(u=>u.type==="space"),p=o.length>0&&o.some(u=>this.rules.other.anyLine.test(u.raw));s.loose=p}for(let c of s.items){let o=c.tokens[0];if(c.task&&(o?.type==="text"||o?.type==="paragraph")){c.text=c.text.replace(this.rules.other.listReplaceTask,""),o.raw=o.raw.replace(this.rules.other.listReplaceTask,""),o.text=o.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 p=this.rules.other.listTaskCheckbox.exec(c.raw);if(p){let u={type:"checkbox",raw:p[0]+" ",checked:p[0]!=="[ ]"};c.checked=u.checked,s.loose?c.tokens[0]&&["paragraph","text"].includes(c.tokens[0].type)&&"tokens"in c.tokens[0]&&c.tokens[0].tokens?(c.tokens[0].raw=u.raw+c.tokens[0].raw,c.tokens[0].text=u.raw+c.tokens[0].text,c.tokens[0].tokens.unshift(u)):c.tokens.unshift({type:"paragraph",raw:u.raw,text:u.raw,tokens:[u]}):c.tokens.unshift(u)}}else c.task&&(c.task=!1)}if(s.loose)for(let c of s.items){c.loose=!0;for(let o of c.tokens)o.type==="text"&&(o.type="paragraph")}return s}}html(t){let e=this.rules.block.html.exec(t);if(e){let n=xe(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:z(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=de(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:z(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(de(a,i.header.length).map((l,c)=>({text:l,tokens:this.lexer.inline(l),header:!1,align:i.align[c]})));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 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)),be(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 be(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,c=0,o=r[0][0],p=n===o,u=o==="*"?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(u.lastIndex=0,e=e.slice(-1*t.length+s);(r=u.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]){if(s%3&&!((s+a)%3)){c+=a;continue}if(p)break}if(l-=a,l>0)continue;a=Math.min(a,a+l+c);let h=[...r[0]][0].length,d=t.slice(0,s+r.index+h+a);if(Math.min(s,a)%2){let m=d.slice(1,-1);return{type:"em",raw:d,text:m,tokens:this.lexer.inlineTokens(m)}}let k=d.slice(2,-2);return{type:"strong",raw:d,text:k,tokens:this.lexer.inlineTokens(k)}}}}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,c=this.rules.inline.delRDelim;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||(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 o=[...r[0]][0].length,p=t.slice(0,s+r.index+o+a),u=p.slice(s,-s);return{type:"del",raw:p,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}}}},T=class V{tokens;options;state;inlineQueue;tokenizer;constructor(e){this.tokens=[],this.tokens.links=Object.create(null),this.options=e||P,this.options.tokenizer=this.options.tokenizer||new G,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,linkEmitted:!1,top:!0};let n={other:b,block:X.normal,inline:N.normal};this.options.pedantic?(n.block=X.pedantic,n.inline=N.pedantic):this.options.gfm&&(n.block=X.gfm,this.options.breaks?n.inline=N.breaks:n.inline=N.gfm),this.tokenizer.rules=n}static get rules(){return{block:X,inline:N}}static lex(e,n){return new V(n).lex(e)}static lexInline(e,n){return new V(n).inlineTokens(e)}lex(e){e=e.replace(b.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(b.tabCharGlobal," ").replace(b.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,c=e.slice(1),o;this.options.extensions.startBlock.forEach(p=>{o=p.call({lexer:this},c),typeof o=="number"&&o>=0&&(l=Math.min(l,o))}),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}linkInText(e){if(!e.includes("["))return!1;let n=this.tokenizer.rules.inline.link;for(let r of e.matchAll(this.tokenizer.rules.inline.blockSkip))if(n.test(r[0])&&e.charAt(r.index-1)!=="!")return!0;for(let r of e.matchAll(this.tokenizer.rules.inline.reflinkSearch)){let s=r[0],i=s.lastIndexOf("[");if(!(s.charAt(0)==="!"||!Object.hasOwn(this.tokens.links,s.slice(i+1,-1)))&&!(i>1&&this.linkInText(s.slice(1,i-1))))return!0}return!1}inlineTokens(e,n=[]){this.tokenizer.lexer=this;let r=e;if(this.tokens.links&&e.includes("[")){let l=this.tokenizer.rules.inline.reflinkSearch,c=o=>{let p=o.lastIndexOf("[");if(!Object.hasOwn(this.tokens.links,o.slice(p+1,-1)))return o;if(p>1&&o.charAt(0)!=="!"){let u=o.slice(1,p-1);if(this.linkInText(u))return"["+u.replace(l,c)+"]["+"a".repeat(o.length-p-2)+"]"}return"["+"a".repeat(o.length-2)+"]"};r=r.replace(l,c)}r=r.replace(this.tokenizer.rules.inline.anyPunctuation,l=>"+".repeat(l.length)),r=r.replace(this.tokenizer.rules.inline.blockSkip,(l,c,o)=>{let p=o?o.length:0;return l.slice(0,p)+"["+"a".repeat(l.length-p-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(o=>(l=o.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 o=n.at(-1);l.type==="text"&&o?.type==="text"?(o.raw+=l.raw,o.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 c=e;if(this.options.extensions?.startInline){let o=1/0,p=e.slice(1),u;this.options.extensions.startInline.forEach(h=>{u=h.call({lexer:this},p),typeof u=="number"&&u>=0&&(o=Math.min(o,u))}),o<1/0&&o>=0&&(c=e.substring(0,o+1))}if(l=this.tokenizer.inlineText(c)){e=e.substring(l.raw.length),l.raw.slice(-1)!=="_"&&(i=l.raw.slice(-1)),s=!0;let o=n.at(-1);o?.type==="text"?(o.raw+=l.raw,o.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)}},U=class{options;parser;constructor(t){this.options=t||P}space(t){return""}code({text:t,lang:e,escaped:n}){let r=(e||"").match(b.notSpaceStart)?.[0],s=t.replace(b.endingNewline,"")+`\n`;return r?\'<pre><code class="language-\'+S(r)+\'">\'+(n?s:S(s,!0))+`</code></pre>\n`:"<pre><code>"+(n?s: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>${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 r=this.parser.parseInline(n),s=ke(t);if(s===null)return r;t=s;let i=\'<a href="\'+t+\'"\';return e&&(i+=\' title="\'+S(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=ke(t);if(s===null)return S(n);t=s;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)}},ae=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}},R=class Y{options;renderer;textRenderer;constructor(e){this.options=e||P,this.options.renderer=this.options.renderer||new U,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new ae}static parse(e,n){return new Y(n).parse(e)}static parseInline(e,n){return new Y(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","checkbox","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","checkbox","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}},v=class{options;block;constructor(t){this.options=t||P}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?T.lex:T.lexInline}provideParser(t=this.block){return t?R.parse:R.parseInline}},Ft=class{defaults=ee();options=this.setOptions;parse=this.parseMarkdown(!0);parseInline=this.parseMarkdown(!1);Parser=R;Renderer=U;TextRenderer=ae;Lexer=T;Tokenizer=G;Hooks=v;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 U(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],c=s[a];s[a]=(...o)=>{let p=l.apply(s,o);return p===!1&&(p=c.apply(s,o)),p||""}}r.renderer=s}if(n.tokenizer){let s=this.defaults.tokenizer||new G(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],c=s[a];s[a]=(...o)=>{let p=l.apply(s,o);return p===!1&&(p=c.apply(s,o)),p}}r.tokenizer=s}if(n.hooks){let s=this.defaults.hooks||new v;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],c=s[a];v.passThroughHooks.has(i)?s[a]=o=>{if(this.defaults.async&&v.passThroughHooksRespectAsync.has(i))return(async()=>{let u=await l.call(s,o);return c.call(s,u)})();let p=l.call(s,o);return c.call(s,p)}:s[a]=(...o)=>{if(this.defaults.async)return(async()=>{let u=await l.apply(s,o);return u===!1&&(u=await c.apply(s,o)),u})();let p=l.apply(s,o);return p===!1&&(p=c.apply(s,o)),p}}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 T.lex(t,e??this.defaults)}parser(t,e){return R.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?T.lex:T.lexInline)(a,s),c=s.hooks?await s.hooks.processAllTokens(l):l;s.walkTokens&&await Promise.all(this.walkTokens(c,s.walkTokens));let o=await(s.hooks?await s.hooks.provideParser(t):t?R.parse:R.parseInline)(c,s);return s.hooks?await s.hooks.postprocess(o):o})().catch(i);try{s.hooks&&(e=s.hooks.preprocess(e));let a=(s.hooks?s.hooks.provideLexer(t):t?T.lex:T.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?R.parse:R.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>"+S(n.message+"",!0)+"</pre>";return e?Promise.resolve(r):r}if(e)return Promise.reject(n);throw n}}},C=new Ft;function g(t,e){return C.parse(t,e)}g.options=g.setOptions=function(t){return C.setOptions(t),g.defaults=C.defaults,me(g.defaults),g};g.getDefaults=ee;g.defaults=P;function Ht(...t){return C.use(...t),g.defaults=C.defaults,me(g.defaults),g}g.use=Ht;g.walkTokens=function(t,e){return C.walkTokens(t,e)};g.parseInline=C.parseInline;g.Parser=R;g.parser=R.parse;g.Renderer=U;g.TextRenderer=ae;g.Lexer=T;g.lexer=T.lex;g.Tokenizer=G;g.Hooks=v;g.parse=g;var un=g.options,pn=g.setOptions,hn=g.walkTokens,fn=g.parseInline;var gn=R.parse,kn=T.lex;var ze=/^ {0,3}:::([A-Za-z][\\w-]*)?[ \\t]*(?:\\n|$)/,jt=/^ {0,3}:::([A-Za-z][\\w-]*)?[ \\t]*$/;function Xt(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=jt.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 Le=[{name:"container",level:"block",tokenizer(t){let e=ze.exec(t);if(!e)return;let n=t.slice(e[0].length),r=Xt(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),c=this.lexer.blockTokens(s,[]);return{type:"container",raw:l,kind:e[1],tokens:c}},renderer(t){return t.raw}}];function oe(t){return t.includes(":::")===!1?!1:new RegExp(ze.source,"m").test(t)}var Pe="([^\\\\]\\\\s]+)",Qt=new RegExp(`^\\\\[\\\\^${Pe}\\\\]`),Oe=new RegExp(`^ {0,3}\\\\[\\\\^${Pe}\\\\]:[ \\\\t]*([^\\\\n]*)\\\\n?`);function Ie(t){return/^[ \\t]*$/.test(t)}var Ce=/^(?: {4}| {0,3}\\t)/;function Gt(t){let e=0;for(;;){let r=e;for(;;){let l=t.indexOf(`\n`,r);if(l===-1)return n(e,!0);let c=t.slice(r,l);if(!Ie(c))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(!Ce.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=>Ie(l)?"":l.replace(Ce,"")).join(`\n`);return{raw:i,body:a,open:s}}}function ce(t){return t.includes("[^")===!1?!1:new RegExp(Oe.source,"m").test(t)}var Me=[{name:"footnoteRef",level:"inline",tokenizer(t){let e=Qt.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=Oe.exec(t);if(!e)return;let n=t.slice(e[0].length),r=Gt(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}}];var q=/\\s*\\{(?:#|\\.)[^}]*\\}\\s*$/;function Ut(t){if(q.test(t.text)&&(t.text=t.text.replace(q,""),t.tokens&&t.tokens.length>0))for(let e=t.tokens.length-1;e>=0;e--){let n=t.tokens[e];if(n.type==="text"&&typeof n.text=="string"){if(q.test(n.text)){let r=n.text.replace(q,"");r===""?t.tokens.splice(e,1):(n.text=r,typeof n.raw=="string"&&(n.raw=n.raw.replace(q,"")));break}if(n.text.trim()==="")continue;break}break}}function H(t){for(let e of t){e.type==="heading"&&Ut(e);let n=e;if(Array.isArray(n.tokens)&&H(n.tokens),Array.isArray(n.items))for(let r of n.items)Array.isArray(r.tokens)&&H(r.tokens)}}function ve(t,e,n){let r=0;for(let s=e;s<n;s++)r+=t[s].raw.length;return r}function Wt(t,e){let n=t;return n.links=e,n}function De(t,e){for(let n=e;n+1<t.length;n++)if(t[n].type==="paragraph"&&t[n+1].type==="paragraph")return n;return t.length}function Jt(t,e){return t[e-2]?.type!=="list"?!0:e+1<t.length}function Be(t,e,n){let r=Math.min(t.length-2,n-1);for(let s=r;s>=e;s--)if(t[s].type==="space"&&Jt(t,s+1)!==!1)return s+1;return-1}function qe(t){let e=t.links;if(!e)return!1;for(let n in e)return!0;return!1}function Ze(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 F(t,e,n){return{source:t,tail:t,tokens:e,stableCount:0,stableOffset:0,degraded:!0,degradedReason:n}}function Ne(t,e){return{source:t,tail:t,tokens:e,stableCount:0,stableOffset:0,degraded:!1,degradedReason:null}}function Kt(t,e){if(qe(e))return F(t,e,"link-definition");if(t.includes("\\r"))return F(t,e,"carriage-return");if(oe(t))return F(t,e,"container");if(ce(t))return F(t,e,"footnote-def");let n=De(e,0),r=Be(e,1,n);if(r<0||Ze(e,0,r,t,0)===!1)return Ne(t,e);let s=ve(e,0,r);return{source:t,tail:t.slice(s),tokens:e,stableCount:r,stableOffset:s,degraded:!1,degradedReason:null}}function ue(t){let e=g.lexer(t);return H(e),{tokens:e,cache:Kt(t,e),charsLexed:t.length,reusedTokens:0}}function Z(t,e){let n=g.lexer(t);return H(n),{tokens:n,cache:F(t,n,e),charsLexed:t.length,reusedTokens:0}}function Fe(t,e){let n=t.source+e;if(t.degraded)return Z(n,t.degradedReason??"link-definition");if(e.includes("\\r"))return Z(n,"carriage-return");if(t.stableCount===0)return ue(n);let r=t.tail+e;if(oe(r))return Z(n,"container");if(ce(r))return Z(n,"footnote-def");let s=g.lexer(r);if(H(s),qe(s))return Z(n,"link-definition");let i=t.tokens.slice(0,t.stableCount),a=Wt([...i,...s],s.links),l=t.stableCount,c=t.stableOffset,o=r,p=Be(a,t.stableCount+1,De(a,t.stableCount));if(p>t.stableCount&&Ze(a,t.stableCount,p,r,0)){let u=ve(a,t.stableCount,p);l=p,c=t.stableOffset+u,o=r.slice(u)}return{tokens:a,cache:{source:n,tail:o,tokens:a,stableCount:l,stableOffset:c,degraded:!1,degradedReason:null},charsLexed:r.length,reusedTokens:t.stableCount}}var Vt=/^ {0,3}\\*\\[([^\\]\\n]+)\\]:[ \\t]*([^\\n]*)(?:\\n|$)/,He=[{name:"abbrDef",level:"block",tokenizer(t){let e=Vt.exec(t);if(e)return{type:"abbrDef",raw:e[0],term:e[1],definition:e[2]}},renderer(t){return t.raw}}];var Yt=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}"}),en=/^:([A-Za-z0-9_+-]+):/,je=[{name:"emoji",level:"inline",start(t){return t.match(/:/)?.index},tokenizer(t){let e=en.exec(t);if(!e)return;let n=Yt[e[1]];if(n!==void 0)return{type:"emoji",raw:e[0],text:n}},renderer(t){return t.raw}}];var tn=/^\\+\\+(?!\\s)((?:\\\\[\\s\\S]|(?!\\+\\+)[\\s\\S])+?)(?<!\\s)\\+\\+/,nn=/^==(?!\\s)((?:\\\\[\\s\\S]|(?!==)[\\s\\S])+?)(?<!\\s)==/,Xe=[{name:"ins",level:"inline",start(t){return t.match(/(?<!\\\\)\\+\\+(?!\\s)/)?.index},tokenizer(t){let e=tn.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=nn.exec(t);if(e)return{type:"mark",raw:e[0],text:e[1].replace(/\\\\(.)/g,"$1")}},renderer(t){return t.raw}}];var rn=/^\\^((?:\\\\[\\s\\S]|[^\\s^\\\\])+)\\^/,Qe=[{name:"sup",level:"inline",start(t){return t.match(/(?<!\\\\)\\^(?!\\s)/)?.index},tokenizer(t){let e=rn.exec(t);if(e)return{type:"sup",raw:e[0],text:e[1].replace(/\\\\(.)/g,"$1")}},renderer(t){return t.raw}}];var j=/\\s*\\{(?:#|\\.)[^}]*\\}\\s*$/;function sn(t){if(j.test(t.text)&&(t.text=t.text.replace(j,""),t.tokens&&t.tokens.length>0))for(let e=t.tokens.length-1;e>=0;e--){let n=t.tokens[e];if(n.type==="text"&&typeof n.text=="string"){if(j.test(n.text)){let r=n.text.replace(j,"");r===""?t.tokens.splice(e,1):(n.text=r,typeof n.raw=="string"&&(n.raw=n.raw.replace(j,"")));break}if(n.text.trim()==="")continue;break}break}}var ln=0;function an(t){if(typeof t!="string"||typeof performance.mark!="function"||typeof performance.measure!="function")return null;let e=ln++,n={name:t,startMark:`${t}:start:${e}`,endMark:`${t}:end:${e}`};try{return performance.mark(n.startMark),n}catch{return null}}function on(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({walkTokens(t){t.type==="heading"&&sn(t)},extensions:[...Me,...Qe,...Xe,...je,...Le,...He,{name:"blockMath",level:"block",start(t){return t.match(/^ {0,3}\\$\\$/m)?.index},tokenizer(t){let e=/^ {0,3}\\$\\$((?:(?!\\n[ \\t]*\\n)[\\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)|\\$(?![$\\s]))/)?.index},tokenizer(t){let e=/^\\$\\$(?!\\s)((?:\\\\\\$|[^$\\n])*?)(?<!\\s)\\$\\$(?!\\d)/.exec(t);if(e){let r=e[1].trim();if(r!=="")return{type:"inlineMath",raw:e[0],text:r}}let n=/^\\$(?![$\\s])((?:\\\\\\$|[^$\\n])*?)(?<!\\s)\\$(?!\\d)/.exec(t);if(n)return{type:"inlineMath",raw:n[0],text:n[1].trim()}},renderer(t){return t.raw}}]});var $=new Map,cn=256;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:c,dispose:o,userTimingName:p}=e;if(o===!0){typeof l=="string"&&$.delete(l);return}let u=typeof l=="string"?l:null,h=typeof c=="number"?c:null,d,k=null,m=null;if(typeof s=="string"){if(u===null||h===null){self.postMessage({id:n,needResync:!0});return}let x=$.get(u);if(!x||x.version!==h){self.postMessage({id:n,needResync:!0});return}if(typeof i=="number"&&x.lex.source.length+s.length!==i){$.delete(u),self.postMessage({id:n,needResync:!0});return}let y=x.lex;d=()=>Fe(y,s),m=y.tokens}else if(typeof r=="string"){let x=r;if(d=()=>ue(x),Array.isArray(a))k=a;else if(u!==null&&h!==null){let y=$.get(u);if(y&&y.version===h)m=y.lex.tokens;else{self.postMessage({id:n,needResync:!0});return}}}else return;try{let x=typeof p=="string"?an(p):null,y=performance.now(),E;try{E=d()}finally{x&&on(x)}let J=performance.now()-y,L=E.tokens,w=0;if(k!==null){let _=Math.min(k.length,L.length);for(;w<_&&k[w]===L[w].raw;w++);}else if(m!==null){let _=m,pe=Math.min(_.length,L.length);for(w=Math.min(E.reusedTokens,pe);w<pe&&_[w].raw===L[w].raw;w++);}u!==null&&h!==null&&($.delete(u),$.set(u,{version:h+1,lex:E.cache}),$.size>cn&&$.delete($.keys().next().value)),self.postMessage({id:n,matchLen:w,tail:L.slice(w),lexerMs:J,sourceCharsLexed:E.charsLexed,stablePrefixChars:E.cache.stableOffset})}catch(x){u!==null&&$.delete(u),self.postMessage({id:n,error:String(x)})}};})();\n';
|
|
3349
3498
|
|
|
3350
3499
|
// src/Markdown.ts
|
|
3351
3500
|
var now = () => typeof performance !== "undefined" && typeof performance.now === "function" ? performance.now() : Date.now();
|
|
@@ -3626,6 +3775,8 @@ var Markdown = class _Markdown extends import_ui4.UIComponent {
|
|
|
3626
3775
|
writeClipboard;
|
|
3627
3776
|
/** File saver used by the download controls. */
|
|
3628
3777
|
saveFile;
|
|
3778
|
+
/** How `src` strings become {@link ImageSource} for {@link Image} construction. */
|
|
3779
|
+
imageResolver;
|
|
3629
3780
|
activeBlockMetrics = null;
|
|
3630
3781
|
/** Whether `opts.virtualize` enabled viewport-culled block materialization. */
|
|
3631
3782
|
virtualizeBlocks;
|
|
@@ -3936,6 +4087,7 @@ var Markdown = class _Markdown extends import_ui4.UIComponent {
|
|
|
3936
4087
|
this.showCodeLanguage = opts.showCodeLanguage ?? false;
|
|
3937
4088
|
this.writeClipboard = opts.writeClipboard ?? defaultWriteClipboard;
|
|
3938
4089
|
this.saveFile = opts.saveFile ?? defaultSaveFile;
|
|
4090
|
+
this.imageResolver = opts.imageResolver ?? defaultMarkdownImageResolver;
|
|
3939
4091
|
const virt = opts.virtualize;
|
|
3940
4092
|
this.virtualizeBlocks = virt === true || typeof virt === "object" && virt !== null;
|
|
3941
4093
|
this.virtualOverscan = typeof virt === "object" && virt !== null && typeof virt.overscan === "number" ? virt.overscan : 800;
|
|
@@ -4453,8 +4605,15 @@ var Markdown = class _Markdown extends import_ui4.UIComponent {
|
|
|
4453
4605
|
* closure applies.
|
|
4454
4606
|
*/
|
|
4455
4607
|
refitParagraphImage(image, availableWidth) {
|
|
4608
|
+
const decoded = image.decodedImage;
|
|
4609
|
+
if (decoded && decoded.width && decoded.height) {
|
|
4610
|
+
const aspect = decoded.height / decoded.width;
|
|
4611
|
+
image.width = Math.min(decoded.width, availableWidth);
|
|
4612
|
+
image.height = Math.round(image.width * aspect);
|
|
4613
|
+
return;
|
|
4614
|
+
}
|
|
4456
4615
|
const bitmap = image.bitmap;
|
|
4457
|
-
if (bitmap?.naturalWidth && bitmap
|
|
4616
|
+
if (bitmap?.naturalWidth && bitmap?.naturalHeight) {
|
|
4458
4617
|
const aspect = bitmap.naturalHeight / bitmap.naturalWidth;
|
|
4459
4618
|
image.width = Math.min(bitmap.naturalWidth, availableWidth);
|
|
4460
4619
|
image.height = Math.round(image.width * aspect);
|
|
@@ -4554,7 +4713,7 @@ var Markdown = class _Markdown extends import_ui4.UIComponent {
|
|
|
4554
4713
|
if (token.type === "image") {
|
|
4555
4714
|
const href = token.href;
|
|
4556
4715
|
if (this.inlineImagesMeasured.has(href)) continue;
|
|
4557
|
-
const raster = ensureInlineImageRaster(href);
|
|
4716
|
+
const raster = ensureInlineImageRaster(href, this.imageResolver);
|
|
4558
4717
|
if (raster.failed) {
|
|
4559
4718
|
this.inlineImagesMeasured.add(href);
|
|
4560
4719
|
changed = true;
|
|
@@ -4958,7 +5117,15 @@ var Markdown = class _Markdown extends import_ui4.UIComponent {
|
|
|
4958
5117
|
literalParagraphSpans(token) {
|
|
4959
5118
|
const spans = [];
|
|
4960
5119
|
if (token.tokens && token.tokens.length > 0) {
|
|
4961
|
-
collectSpans(
|
|
5120
|
+
collectSpans(
|
|
5121
|
+
token.tokens,
|
|
5122
|
+
{},
|
|
5123
|
+
this.theme,
|
|
5124
|
+
spans,
|
|
5125
|
+
void 0,
|
|
5126
|
+
this.abbreviations,
|
|
5127
|
+
this.imageResolver
|
|
5128
|
+
);
|
|
4962
5129
|
}
|
|
4963
5130
|
if (spans.length === 0) spans.push({ text: token.text });
|
|
4964
5131
|
return spans;
|
|
@@ -4979,7 +5146,7 @@ var Markdown = class _Markdown extends import_ui4.UIComponent {
|
|
|
4979
5146
|
*/
|
|
4980
5147
|
tableCellSpans(cell, t) {
|
|
4981
5148
|
const spans = [];
|
|
4982
|
-
collectSpans(cell.tokens, {}, t, spans, void 0, this.abbreviations);
|
|
5149
|
+
collectSpans(cell.tokens, {}, t, spans, void 0, this.abbreviations, this.imageResolver);
|
|
4983
5150
|
if (spans.length === 0) spans.push({ text: decodeEntities(cell.text) });
|
|
4984
5151
|
return spans;
|
|
4985
5152
|
}
|
|
@@ -4997,7 +5164,8 @@ var Markdown = class _Markdown extends import_ui4.UIComponent {
|
|
|
4997
5164
|
*/
|
|
4998
5165
|
inlineRunSpans(tokens, t) {
|
|
4999
5166
|
const spans = [];
|
|
5000
|
-
if (tokens.length > 0)
|
|
5167
|
+
if (tokens.length > 0)
|
|
5168
|
+
collectSpans(tokens, {}, t, spans, void 0, this.abbreviations, this.imageResolver);
|
|
5001
5169
|
if (spans.length === 0) spans.push({ text: "" });
|
|
5002
5170
|
return spans;
|
|
5003
5171
|
}
|
|
@@ -5127,26 +5295,74 @@ var Markdown = class _Markdown extends import_ui4.UIComponent {
|
|
|
5127
5295
|
paragraphImage(imgToken, availableWidth) {
|
|
5128
5296
|
const initialWidth = Math.min(800, availableWidth);
|
|
5129
5297
|
const initialHeight = Math.round(initialWidth * 0.6);
|
|
5130
|
-
const
|
|
5131
|
-
|
|
5132
|
-
|
|
5133
|
-
|
|
5134
|
-
|
|
5135
|
-
|
|
5298
|
+
const rawSrc = imgToken.href;
|
|
5299
|
+
let initialSource = { kind: "url", url: rawSrc };
|
|
5300
|
+
let pending = null;
|
|
5301
|
+
try {
|
|
5302
|
+
const out = this.imageResolver(rawSrc);
|
|
5303
|
+
if (out instanceof Promise) {
|
|
5304
|
+
pending = out;
|
|
5305
|
+
} else {
|
|
5306
|
+
initialSource = out;
|
|
5307
|
+
}
|
|
5308
|
+
} catch (err) {
|
|
5309
|
+
console.warn("[Markdown] imageResolver threw for", rawSrc, err);
|
|
5310
|
+
}
|
|
5311
|
+
let img = null;
|
|
5312
|
+
const handleLoad = () => {
|
|
5313
|
+
if (!img) return;
|
|
5314
|
+
const decoded = img.decodedImage;
|
|
5315
|
+
const previousWidth = img.width;
|
|
5316
|
+
const previousHeight = img.height;
|
|
5317
|
+
if (decoded && decoded.width && decoded.height) {
|
|
5318
|
+
const aspect = decoded.height / decoded.width;
|
|
5319
|
+
img.width = Math.min(decoded.width, availableWidth);
|
|
5320
|
+
img.height = Math.round(img.width * aspect);
|
|
5321
|
+
} else {
|
|
5136
5322
|
const bmp = img.bitmap;
|
|
5137
|
-
const previousWidth = img.width;
|
|
5138
|
-
const previousHeight = img.height;
|
|
5139
5323
|
if (bmp && bmp.naturalWidth && bmp.naturalHeight) {
|
|
5140
5324
|
const aspect = bmp.naturalHeight / bmp.naturalWidth;
|
|
5141
5325
|
img.width = Math.min(bmp.naturalWidth, availableWidth);
|
|
5142
5326
|
img.height = Math.round(img.width * aspect);
|
|
5143
5327
|
}
|
|
5144
|
-
if (img.width !== previousWidth || img.height !== previousHeight) {
|
|
5145
|
-
this.reflowAfterImageResize(img);
|
|
5146
|
-
}
|
|
5147
|
-
this.scene?.markDirty();
|
|
5148
5328
|
}
|
|
5329
|
+
if (img.width !== previousWidth || img.height !== previousHeight) {
|
|
5330
|
+
this.reflowAfterImageResize(img);
|
|
5331
|
+
}
|
|
5332
|
+
this.scene?.markDirty();
|
|
5333
|
+
};
|
|
5334
|
+
img = new import_ui4.Image(initialSource, {
|
|
5335
|
+
width: initialWidth,
|
|
5336
|
+
height: initialHeight,
|
|
5337
|
+
alt: imgToken.text,
|
|
5338
|
+
radius: this.theme.imageRadius,
|
|
5339
|
+
onLoad: handleLoad
|
|
5149
5340
|
});
|
|
5341
|
+
if (img.decodedImage?.width && img.decodedImage?.height) {
|
|
5342
|
+
const decoded = img.decodedImage;
|
|
5343
|
+
const prevW = img.width;
|
|
5344
|
+
const prevH = img.height;
|
|
5345
|
+
const aspect = decoded.height / decoded.width;
|
|
5346
|
+
const nextW = Math.min(decoded.width, availableWidth);
|
|
5347
|
+
const nextH = Math.round(nextW * aspect);
|
|
5348
|
+
if (nextW !== prevW || nextH !== prevH) {
|
|
5349
|
+
img.width = nextW;
|
|
5350
|
+
img.height = nextH;
|
|
5351
|
+
this.reflowAfterImageResize(img);
|
|
5352
|
+
this.scene?.markDirty();
|
|
5353
|
+
}
|
|
5354
|
+
}
|
|
5355
|
+
if (pending) {
|
|
5356
|
+
pending.then((resolved) => {
|
|
5357
|
+
try {
|
|
5358
|
+
img.setSource(resolved);
|
|
5359
|
+
} catch {
|
|
5360
|
+
}
|
|
5361
|
+
this.scene?.markDirty();
|
|
5362
|
+
}).catch((err) => {
|
|
5363
|
+
console.warn("[Markdown] imageResolver rejected for", rawSrc, err);
|
|
5364
|
+
});
|
|
5365
|
+
}
|
|
5150
5366
|
return img;
|
|
5151
5367
|
}
|
|
5152
5368
|
/**
|
|
@@ -5392,7 +5608,8 @@ var Markdown = class _Markdown extends import_ui4.UIComponent {
|
|
|
5392
5608
|
this.theme,
|
|
5393
5609
|
contentSpans,
|
|
5394
5610
|
void 0,
|
|
5395
|
-
this.abbreviations
|
|
5611
|
+
this.abbreviations,
|
|
5612
|
+
this.imageResolver
|
|
5396
5613
|
);
|
|
5397
5614
|
} else if ("tokens" in inner && inner.tokens?.length) {
|
|
5398
5615
|
collectSpans(
|
|
@@ -5401,7 +5618,8 @@ var Markdown = class _Markdown extends import_ui4.UIComponent {
|
|
|
5401
5618
|
this.theme,
|
|
5402
5619
|
contentSpans,
|
|
5403
5620
|
void 0,
|
|
5404
|
-
this.abbreviations
|
|
5621
|
+
this.abbreviations,
|
|
5622
|
+
this.imageResolver
|
|
5405
5623
|
);
|
|
5406
5624
|
} else if ("text" in inner) {
|
|
5407
5625
|
contentSpans.push({ text: decodeEntities(inner.text) });
|
|
@@ -5700,7 +5918,15 @@ var Markdown = class _Markdown extends import_ui4.UIComponent {
|
|
|
5700
5918
|
}
|
|
5701
5919
|
const spans = [];
|
|
5702
5920
|
if (token.tokens && token.tokens.length > 0) {
|
|
5703
|
-
collectSpans(
|
|
5921
|
+
collectSpans(
|
|
5922
|
+
token.tokens,
|
|
5923
|
+
{},
|
|
5924
|
+
this.theme,
|
|
5925
|
+
spans,
|
|
5926
|
+
void 0,
|
|
5927
|
+
this.abbreviations,
|
|
5928
|
+
this.imageResolver
|
|
5929
|
+
);
|
|
5704
5930
|
}
|
|
5705
5931
|
if (spans.length === 0) spans.push({ text: decodeEntities(token.text) });
|
|
5706
5932
|
return spans;
|
|
@@ -5747,7 +5973,8 @@ var Markdown = class _Markdown extends import_ui4.UIComponent {
|
|
|
5747
5973
|
this.theme,
|
|
5748
5974
|
spans,
|
|
5749
5975
|
void 0,
|
|
5750
|
-
this.abbreviations
|
|
5976
|
+
this.abbreviations,
|
|
5977
|
+
this.imageResolver
|
|
5751
5978
|
);
|
|
5752
5979
|
}
|
|
5753
5980
|
const head = runText.slice(0, found.at);
|
|
@@ -5834,6 +6061,7 @@ var Markdown = class _Markdown extends import_ui4.UIComponent {
|
|
|
5834
6061
|
}
|
|
5835
6062
|
this.width = this.content.width;
|
|
5836
6063
|
this.height = this.content.height;
|
|
6064
|
+
this.notifyLayoutUpdated();
|
|
5837
6065
|
this.scene?.markDirty();
|
|
5838
6066
|
}
|
|
5839
6067
|
/**
|
|
@@ -5894,7 +6122,8 @@ var Markdown = class _Markdown extends import_ui4.UIComponent {
|
|
|
5894
6122
|
* or exporting there would capture placeholders.
|
|
5895
6123
|
*/
|
|
5896
6124
|
waitForAppendSettled() {
|
|
5897
|
-
if (!this.appendInFlight && !this.mathLoadPending
|
|
6125
|
+
if (!this.appendInFlight && !this.mathLoadPending && !this.fencedRebuildPending)
|
|
6126
|
+
return Promise.resolve();
|
|
5898
6127
|
return new Promise((resolve) => {
|
|
5899
6128
|
this.appendSettledWaiters.push(resolve);
|
|
5900
6129
|
});
|
|
@@ -5911,7 +6140,7 @@ var Markdown = class _Markdown extends import_ui4.UIComponent {
|
|
|
5911
6140
|
* one chunk early.
|
|
5912
6141
|
*/
|
|
5913
6142
|
flushAppendSettledWaiters() {
|
|
5914
|
-
if (this.appendInFlight || this.mathLoadPending || this.appendSettledWaiters.length === 0) {
|
|
6143
|
+
if (this.appendInFlight || this.mathLoadPending || this.fencedRebuildPending || this.appendSettledWaiters.length === 0) {
|
|
5915
6144
|
return;
|
|
5916
6145
|
}
|
|
5917
6146
|
const waiters = this.appendSettledWaiters;
|
|
@@ -6213,7 +6442,8 @@ var Markdown = class _Markdown extends import_ui4.UIComponent {
|
|
|
6213
6442
|
t,
|
|
6214
6443
|
this.selectable,
|
|
6215
6444
|
this.onLinkClick,
|
|
6216
|
-
this.abbreviations
|
|
6445
|
+
this.abbreviations,
|
|
6446
|
+
this.imageResolver
|
|
6217
6447
|
);
|
|
6218
6448
|
}
|
|
6219
6449
|
// ── Paragraphs ───────────────────────────────────────────────────
|
|
@@ -6229,7 +6459,8 @@ var Markdown = class _Markdown extends import_ui4.UIComponent {
|
|
|
6229
6459
|
t,
|
|
6230
6460
|
this.selectable,
|
|
6231
6461
|
this.onLinkClick,
|
|
6232
|
-
this.abbreviations
|
|
6462
|
+
this.abbreviations,
|
|
6463
|
+
this.imageResolver
|
|
6233
6464
|
);
|
|
6234
6465
|
}
|
|
6235
6466
|
const stack = new import_ui4.Stack({
|
|
@@ -6291,8 +6522,12 @@ var Markdown = class _Markdown extends import_ui4.UIComponent {
|
|
|
6291
6522
|
this.fencedRebuildPending = true;
|
|
6292
6523
|
loadPromise.then(() => {
|
|
6293
6524
|
this.fencedRebuildPending = false;
|
|
6294
|
-
if (this.isDestroyed)
|
|
6525
|
+
if (this.isDestroyed) {
|
|
6526
|
+
this.flushAppendSettledWaiters();
|
|
6527
|
+
return;
|
|
6528
|
+
}
|
|
6295
6529
|
if (isFencedBlockRendererReady(lang)) this.retypesetFromTokens();
|
|
6530
|
+
this.flushAppendSettledWaiters();
|
|
6296
6531
|
});
|
|
6297
6532
|
}
|
|
6298
6533
|
}
|
|
@@ -6524,6 +6759,39 @@ var Markdown = class _Markdown extends import_ui4.UIComponent {
|
|
|
6524
6759
|
render(_r) {
|
|
6525
6760
|
}
|
|
6526
6761
|
};
|
|
6762
|
+
|
|
6763
|
+
// src/projection-policy.ts
|
|
6764
|
+
var import_ui5 = require("@vectojs/ui");
|
|
6765
|
+
function classifyProjectionBlock(node, index) {
|
|
6766
|
+
if (node instanceof import_ui5.Text || node instanceof import_ui5.RichText) {
|
|
6767
|
+
return { node, label: `${index}: ${node.constructor.name} (prose)`, domKind: "prose" };
|
|
6768
|
+
}
|
|
6769
|
+
if (node instanceof CodeBlock) return { node, label: `${index}: CodeBlock`, domKind: "code" };
|
|
6770
|
+
if (node instanceof import_ui5.Table) return { node, label: `${index}: Table`, domKind: "" };
|
|
6771
|
+
if (node.children.length > 0) {
|
|
6772
|
+
return { node, label: `${index}: ${node.constructor.name} (container)`, domKind: "container" };
|
|
6773
|
+
}
|
|
6774
|
+
return { node, label: `${index}: ${node.constructor.name} (canvas leaf)`, domKind: "" };
|
|
6775
|
+
}
|
|
6776
|
+
function classifyProjectionBlocks(content) {
|
|
6777
|
+
const blocks = content.children.map((child, i) => classifyProjectionBlock(child, i));
|
|
6778
|
+
for (const { node, domKind } of blocks) {
|
|
6779
|
+
if (domKind) node.domKind = domKind;
|
|
6780
|
+
}
|
|
6781
|
+
return blocks;
|
|
6782
|
+
}
|
|
6783
|
+
function applyProjectionMode(root, mode) {
|
|
6784
|
+
const visit = (node) => {
|
|
6785
|
+
if (mode === "canvas") node.domPolicy = "canvas";
|
|
6786
|
+
else if (mode === "dom") {
|
|
6787
|
+
node.domPolicy = node.domKind === "prose" || node.domKind === "code" ? "dom" : "canvas";
|
|
6788
|
+
} else {
|
|
6789
|
+
node.domPolicy = "auto";
|
|
6790
|
+
}
|
|
6791
|
+
for (const child of node.children) visit(child);
|
|
6792
|
+
};
|
|
6793
|
+
visit(root);
|
|
6794
|
+
}
|
|
6527
6795
|
// Annotate the CommonJS export names for ESM import in node:
|
|
6528
6796
|
0 && (module.exports = {
|
|
6529
6797
|
BlockAffordanceButton,
|
|
@@ -6532,8 +6800,12 @@ var Markdown = class _Markdown extends import_ui4.UIComponent {
|
|
|
6532
6800
|
Markdown,
|
|
6533
6801
|
MathBlock,
|
|
6534
6802
|
PRESET_THEMES,
|
|
6803
|
+
applyProjectionMode,
|
|
6804
|
+
classifyProjectionBlock,
|
|
6805
|
+
classifyProjectionBlocks,
|
|
6535
6806
|
codeAtlas,
|
|
6536
6807
|
codeAtlasStats,
|
|
6808
|
+
defaultMarkdownImageResolver,
|
|
6537
6809
|
ensureFencedBlockRenderer,
|
|
6538
6810
|
escapeCsvField,
|
|
6539
6811
|
escapeMarkdownTableCell,
|