@syntrologie/runtime-sdk 2.11.0 → 2.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. package/CAPABILITIES.md +176 -117
  2. package/README.md +2 -0
  3. package/dist/actions/schema.d.ts +7 -7
  4. package/dist/actions/schema.js +3 -4
  5. package/dist/actions/types.d.ts +1 -1
  6. package/dist/actions/validation-core.d.ts +24 -0
  7. package/dist/actions/validation-rules.d.ts +74 -0
  8. package/dist/actions/validation.d.ts +5 -11
  9. package/dist/bootstrap-init.d.ts +33 -0
  10. package/dist/bootstrap-runtime.d.ts +7 -0
  11. package/dist/bootstrap-types.d.ts +90 -0
  12. package/dist/bootstrap.d.ts +17 -83
  13. package/dist/{chunk-Q77NT67W.js → chunk-BU4Z6PD7.js} +16 -1
  14. package/dist/{chunk-Q77NT67W.js.map → chunk-BU4Z6PD7.js.map} +1 -1
  15. package/dist/{chunk-H3FAYTUV.js → chunk-J2LGX2PV.js} +1216 -394
  16. package/dist/chunk-J2LGX2PV.js.map +7 -0
  17. package/dist/{chunk-NBFQGKSV.js → chunk-L6RJMBR2.js} +4 -4
  18. package/dist/{chunk-NBFQGKSV.js.map → chunk-L6RJMBR2.js.map} +2 -2
  19. package/dist/{chunk-37TTQRH5.js → chunk-XDYJ64IN.js} +2 -2
  20. package/dist/config/schema.js +2 -3
  21. package/dist/decisions/schema.js +1 -2
  22. package/dist/events/EventBus.d.ts +27 -1
  23. package/dist/events/history.d.ts +9 -0
  24. package/dist/events/index.d.ts +3 -0
  25. package/dist/events/types.d.ts +24 -0
  26. package/dist/events/validation.d.ts +7 -0
  27. package/dist/index.d.ts +0 -2
  28. package/dist/index.js +1131 -2039
  29. package/dist/index.js.map +4 -4
  30. package/dist/overlays/runtime/overlay/overlay-runner.d.ts +4 -0
  31. package/dist/overlays/runtime/overlay/overlay-state.d.ts +21 -0
  32. package/dist/overlays/types.d.ts +3 -1
  33. package/dist/react.js +6 -5
  34. package/dist/react.js.map +2 -2
  35. package/dist/smart-canvas.esm.js +92 -108
  36. package/dist/smart-canvas.esm.js.map +4 -4
  37. package/dist/smart-canvas.js +4649 -4957
  38. package/dist/smart-canvas.js.map +4 -4
  39. package/dist/smart-canvas.min.js +92 -108
  40. package/dist/smart-canvas.min.js.map +4 -4
  41. package/dist/telemetry/adapters/posthog.d.ts +5 -10
  42. package/dist/test/setup.d.ts +1 -0
  43. package/dist/token.d.ts +2 -0
  44. package/dist/version.d.ts +1 -1
  45. package/package.json +23 -29
  46. package/schema/canvas-config.schema.json +1 -1
  47. package/scripts/syntroReactPlugin.mjs +3 -0
  48. package/scripts/validate-config.mjs +42 -0
  49. package/dist/chunk-H3FAYTUV.js.map +0 -7
  50. package/dist/chunk-JMHRHAEL.js +0 -18
  51. package/dist/chunk-JMHRHAEL.js.map +0 -7
  52. package/dist/replayMirror-QZ3GQ527.js +0 -32
  53. package/dist/replayMirror-QZ3GQ527.js.map +0 -7
  54. package/dist/telemetry/replayMirror.d.ts +0 -7
  55. /package/dist/{chunk-37TTQRH5.js.map → chunk-XDYJ64IN.js.map} +0 -0
package/dist/index.js CHANGED
@@ -7,6 +7,7 @@ import {
7
7
  DEFAULT_TTL,
8
8
  EVENT_SCHEMA_VERSION,
9
9
  EventBus,
10
+ EventHistory,
10
11
  ExecutorRegistry,
11
12
  MAX_VISIBLE_TOASTS,
12
13
  NavigationMonitor,
@@ -43,6 +44,7 @@ import {
43
44
  createGrowthBookClient,
44
45
  createNoopClient,
45
46
  createPostHogClient,
47
+ createPostHogNormalizer,
46
48
  createSessionMetricTracker,
47
49
  createSmartCanvas,
48
50
  createSmartCanvasController,
@@ -70,6 +72,7 @@ import {
70
72
  interpolateTemplate,
71
73
  isCoreActionKind,
72
74
  matchEvent,
75
+ normalizePostHogEvent,
73
76
  playEnterAnimation,
74
77
  playExitAnimation,
75
78
  purple,
@@ -81,6 +84,7 @@ import {
81
84
  runtime2,
82
85
  setupAdjacentPositioning,
83
86
  setupInlinePositioning,
87
+ shouldNormalizeEvent,
84
88
  slateGrey,
85
89
  useDecision,
86
90
  useNotifications,
@@ -96,8 +100,10 @@ import {
96
100
  useViewportContext,
97
101
  validateAction,
98
102
  validateActions,
103
+ validateEventName,
104
+ validateProps,
99
105
  widgetRegistry
100
- } from "./chunk-H3FAYTUV.js";
106
+ } from "./chunk-J2LGX2PV.js";
101
107
  import {
102
108
  AddClassZ,
103
109
  AnchorIdZ,
@@ -131,8 +137,8 @@ import {
131
137
  WaitZ,
132
138
  WidgetConfigZ,
133
139
  coreActionStepSchemas
134
- } from "./chunk-NBFQGKSV.js";
135
- import "./chunk-37TTQRH5.js";
140
+ } from "./chunk-L6RJMBR2.js";
141
+ import "./chunk-XDYJ64IN.js";
136
142
  import {
137
143
  ActivationConfigZ,
138
144
  AnchorVisibleConditionZ,
@@ -157,14 +163,12 @@ import {
157
163
  StateEqualsConditionZ,
158
164
  TriggerWhenZ,
159
165
  ViewportConditionZ,
166
+ __publicField,
160
167
  decisionSchemas,
161
168
  validateActivationConfig,
162
169
  validateCondition,
163
170
  validateStrategy
164
- } from "./chunk-Q77NT67W.js";
165
- import {
166
- __publicField
167
- } from "./chunk-JMHRHAEL.js";
171
+ } from "./chunk-BU4Z6PD7.js";
168
172
 
169
173
  // src/index.ts
170
174
  import React4 from "react";
@@ -256,8 +260,8 @@ var nextId = 0;
256
260
  function generateId() {
257
261
  return `msg-${Date.now()}-${++nextId}`;
258
262
  }
259
- function useChat(options2) {
260
- const { backendUrl, tileId, runtime: runtime7, greeting, maxHistory = 20, mlflowRunId, config } = options2;
263
+ function useChat(options) {
264
+ const { backendUrl, tileId, runtime: runtime7, greeting, maxHistory = 20, mlflowRunId, config } = options;
261
265
  const [messages, setMessages] = useState(() => {
262
266
  if (greeting) {
263
267
  return [
@@ -290,9 +294,9 @@ function useChat(options2) {
290
294
  setIsLoading(true);
291
295
  try {
292
296
  const currentMessages = [...messages, userMessage];
293
- const historySlice = currentMessages.slice(-maxHistory).map((m) => ({
294
- role: m.role,
295
- content: m.text
297
+ const historySlice = currentMessages.slice(-maxHistory).map((m2) => ({
298
+ role: m2.role,
299
+ content: m2.text
296
300
  }));
297
301
  const response = await sendMessage(backendUrl, {
298
302
  message: trimmed,
@@ -631,2186 +635,1224 @@ var executorDefinitions = [
631
635
  import { jsx as _jsx2, jsxs as _jsxs2 } from "react/jsx-runtime";
632
636
 
633
637
  // ../../node_modules/marked/lib/marked.esm.js
634
- function _getDefaults() {
635
- return {
636
- async: false,
637
- breaks: false,
638
- extensions: null,
639
- gfm: true,
640
- hooks: null,
641
- pedantic: false,
642
- renderer: null,
643
- silent: false,
644
- tokenizer: null,
645
- walkTokens: null
646
- };
638
+ function M() {
639
+ return { async: false, breaks: false, extensions: null, gfm: true, hooks: null, pedantic: false, renderer: null, silent: false, tokenizer: null, walkTokens: null };
647
640
  }
648
- var _defaults = _getDefaults();
649
- function changeDefaults(newDefaults) {
650
- _defaults = newDefaults;
641
+ var T = M();
642
+ function G(u3) {
643
+ T = u3;
651
644
  }
652
- var noopTest = { exec: () => null };
653
- function edit(regex, opt = "") {
654
- let source = typeof regex === "string" ? regex : regex.source;
655
- const obj = {
656
- replace: (name, val) => {
657
- let valSource = typeof val === "string" ? val : val.source;
658
- valSource = valSource.replace(other.caret, "$1");
659
- source = source.replace(name, valSource);
660
- return obj;
661
- },
662
- getRegex: () => {
663
- return new RegExp(source, opt);
664
- }
665
- };
666
- return obj;
645
+ var _ = { exec: () => null };
646
+ function k(u3, e = "") {
647
+ let t = typeof u3 == "string" ? u3 : u3.source, n = { replace: (r, i) => {
648
+ let s = typeof i == "string" ? i : i.source;
649
+ return s = s.replace(m.caret, "$1"), t = t.replace(r, s), n;
650
+ }, getRegex: () => new RegExp(t, e) };
651
+ return n;
667
652
  }
668
- var other = {
669
- codeRemoveIndent: /^(?: {1,4}| {0,3}\t)/gm,
670
- outputLinkReplace: /\\([\[\]])/g,
671
- indentCodeCompensation: /^(\s+)(?:```)/,
672
- beginningSpace: /^\s+/,
673
- endingHash: /#$/,
674
- startingSpaceChar: /^ /,
675
- endingSpaceChar: / $/,
676
- nonSpaceChar: /[^ ]/,
677
- newLineCharGlobal: /\n/g,
678
- tabCharGlobal: /\t/g,
679
- multipleSpaceGlobal: /\s+/g,
680
- blankLine: /^[ \t]*$/,
681
- doubleBlankLine: /\n[ \t]*\n[ \t]*$/,
682
- blockquoteStart: /^ {0,3}>/,
683
- blockquoteSetextReplace: /\n {0,3}((?:=+|-+) *)(?=\n|$)/g,
684
- blockquoteSetextReplace2: /^ {0,3}>[ \t]?/gm,
685
- listReplaceTabs: /^\t+/,
686
- listReplaceNesting: /^ {1,4}(?=( {4})*[^ ])/g,
687
- listIsTask: /^\[[ xX]\] /,
688
- listReplaceTask: /^\[[ xX]\] +/,
689
- anyLine: /\n.*\n/,
690
- hrefBrackets: /^<(.*)>$/,
691
- tableDelimiter: /[:|]/,
692
- tableAlignChars: /^\||\| *$/g,
693
- tableRowBlankLine: /\n[ \t]*$/,
694
- tableAlignRight: /^ *-+: *$/,
695
- tableAlignCenter: /^ *:-+: *$/,
696
- tableAlignLeft: /^ *:-+ *$/,
697
- startATag: /^<a /i,
698
- endATag: /^<\/a>/i,
699
- startPreScriptTag: /^<(pre|code|kbd|script)(\s|>)/i,
700
- endPreScriptTag: /^<\/(pre|code|kbd|script)(\s|>)/i,
701
- startAngleBracket: /^</,
702
- endAngleBracket: />$/,
703
- pedanticHrefTitle: /^([^'"]*[^\s])\s+(['"])(.*)\2/,
704
- unicodeAlphaNumeric: /[\p{L}\p{N}]/u,
705
- escapeTest: /[&<>"']/,
706
- escapeReplace: /[&<>"']/g,
707
- escapeTestNoEncode: /[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,
708
- escapeReplaceNoEncode: /[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,
709
- unescapeTest: /&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig,
710
- caret: /(^|[^\[])\^/g,
711
- percentDecode: /%25/g,
712
- findPipe: /\|/g,
713
- splitPipe: / \|/,
714
- slashPipe: /\\\|/g,
715
- carriageReturn: /\r\n|\r/g,
716
- spaceLine: /^ +$/gm,
717
- notSpaceStart: /^\S*/,
718
- endingNewline: /\n$/,
719
- listItemRegex: (bull) => new RegExp(`^( {0,3}${bull})((?:[ ][^\\n]*)?(?:\\n|$))`),
720
- nextBulletRegex: (indent) => new RegExp(`^ {0,${Math.min(3, indent - 1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),
721
- hrRegex: (indent) => new RegExp(`^ {0,${Math.min(3, indent - 1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),
722
- fencesBeginRegex: (indent) => new RegExp(`^ {0,${Math.min(3, indent - 1)}}(?:\`\`\`|~~~)`),
723
- headingBeginRegex: (indent) => new RegExp(`^ {0,${Math.min(3, indent - 1)}}#`),
724
- htmlBeginRegex: (indent) => new RegExp(`^ {0,${Math.min(3, indent - 1)}}<(?:[a-z].*>|!--)`, "i")
725
- };
726
- var newline = /^(?:[ \t]*(?:\n|$))+/;
727
- var blockCode = /^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/;
728
- var fences = /^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/;
729
- var hr = /^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/;
730
- var heading = /^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/;
731
- var bullet = /(?:[*+-]|\d{1,9}[.)])/;
732
- var lheadingCore = /^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/;
733
- var lheading = edit(lheadingCore).replace(/bull/g, bullet).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}/).replace(/html/g, / {0,3}<[^\n>]+>\n/).replace(/\|table/g, "").getRegex();
734
- var lheadingGfm = edit(lheadingCore).replace(/bull/g, bullet).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}/).replace(/html/g, / {0,3}<[^\n>]+>\n/).replace(/table/g, / {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex();
735
- var _paragraph = /^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/;
736
- var blockText = /^[^\n]+/;
737
- var _blockLabel = /(?!\s*\])(?:\\.|[^\[\]\\])+/;
738
- var def = edit(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label", _blockLabel).replace("title", /(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex();
739
- var list = edit(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g, bullet).getRegex();
740
- var _tag = "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";
741
- var _comment = /<!--(?:-?>|[\s\S]*?(?:-->|$))/;
742
- var html = edit(
743
- "^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\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|$))",
744
- "i"
745
- ).replace("comment", _comment).replace("tag", _tag).replace("attribute", / +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex();
746
- var paragraph = edit(_paragraph).replace("hr", hr).replace("heading", " {0,3}#{1,6}(?:\\s|$)").replace("|lheading", "").replace("|table", "").replace("blockquote", " {0,3}>").replace("fences", " {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list", " {0,3}(?:[*+-]|1[.)]) ").replace("html", "</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag", _tag).getRegex();
747
- var blockquote = edit(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph", paragraph).getRegex();
748
- var blockNormal = {
749
- blockquote,
750
- code: blockCode,
751
- def,
752
- fences,
753
- heading,
754
- hr,
755
- html,
756
- lheading,
757
- list,
758
- newline,
759
- paragraph,
760
- table: noopTest,
761
- text: blockText
762
- };
763
- var gfmTable = edit(
764
- "^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)"
765
- ).replace("hr", hr).replace("heading", " {0,3}#{1,6}(?:\\s|$)").replace("blockquote", " {0,3}>").replace("code", "(?: {4}| {0,3} )[^\\n]").replace("fences", " {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list", " {0,3}(?:[*+-]|1[.)]) ").replace("html", "</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag", _tag).getRegex();
766
- var blockGfm = {
767
- ...blockNormal,
768
- lheading: lheadingGfm,
769
- table: gfmTable,
770
- paragraph: edit(_paragraph).replace("hr", hr).replace("heading", " {0,3}#{1,6}(?:\\s|$)").replace("|lheading", "").replace("table", gfmTable).replace("blockquote", " {0,3}>").replace("fences", " {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list", " {0,3}(?:[*+-]|1[.)]) ").replace("html", "</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag", _tag).getRegex()
771
- };
772
- var blockPedantic = {
773
- ...blockNormal,
774
- html: edit(
775
- `^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`
776
- ).replace("comment", _comment).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(),
777
- def: /^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,
778
- heading: /^(#{1,6})(.*)(?:\n+|$)/,
779
- fences: noopTest,
780
- // fences not supported
781
- lheading: /^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,
782
- paragraph: edit(_paragraph).replace("hr", hr).replace("heading", " *#{1,6} *[^\n]").replace("lheading", lheading).replace("|table", "").replace("blockquote", " {0,3}>").replace("|fences", "").replace("|list", "").replace("|html", "").replace("|tag", "").getRegex()
783
- };
784
- var escape = /^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/;
785
- var inlineCode = /^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/;
786
- var br = /^( {2,}|\\)\n(?!\s*$)/;
787
- var inlineText = /^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/;
788
- var _punctuation = /[\p{P}\p{S}]/u;
789
- var _punctuationOrSpace = /[\s\p{P}\p{S}]/u;
790
- var _notPunctuationOrSpace = /[^\s\p{P}\p{S}]/u;
791
- var punctuation = edit(/^((?![*_])punctSpace)/, "u").replace(/punctSpace/g, _punctuationOrSpace).getRegex();
792
- var _punctuationGfmStrongEm = /(?!~)[\p{P}\p{S}]/u;
793
- var _punctuationOrSpaceGfmStrongEm = /(?!~)[\s\p{P}\p{S}]/u;
794
- var _notPunctuationOrSpaceGfmStrongEm = /(?:[^\s\p{P}\p{S}]|~)/u;
795
- var blockSkip = /\[[^[\]]*?\]\((?:\\.|[^\\\(\)]|\((?:\\.|[^\\\(\)])*\))*\)|`[^`]*?`|<[^<>]*?>/g;
796
- var emStrongLDelimCore = /^(?:\*+(?:((?!\*)punct)|[^\s*]))|^_+(?:((?!_)punct)|([^\s_]))/;
797
- var emStrongLDelim = edit(emStrongLDelimCore, "u").replace(/punct/g, _punctuation).getRegex();
798
- var emStrongLDelimGfm = edit(emStrongLDelimCore, "u").replace(/punct/g, _punctuationGfmStrongEm).getRegex();
799
- var emStrongRDelimAstCore = "^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)";
800
- var emStrongRDelimAst = edit(emStrongRDelimAstCore, "gu").replace(/notPunctSpace/g, _notPunctuationOrSpace).replace(/punctSpace/g, _punctuationOrSpace).replace(/punct/g, _punctuation).getRegex();
801
- var emStrongRDelimAstGfm = edit(emStrongRDelimAstCore, "gu").replace(/notPunctSpace/g, _notPunctuationOrSpaceGfmStrongEm).replace(/punctSpace/g, _punctuationOrSpaceGfmStrongEm).replace(/punct/g, _punctuationGfmStrongEm).getRegex();
802
- var emStrongRDelimUnd = edit(
803
- "^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)",
804
- "gu"
805
- ).replace(/notPunctSpace/g, _notPunctuationOrSpace).replace(/punctSpace/g, _punctuationOrSpace).replace(/punct/g, _punctuation).getRegex();
806
- var anyPunctuation = edit(/\\(punct)/, "gu").replace(/punct/g, _punctuation).getRegex();
807
- var autolink = edit(/^<(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();
808
- var _inlineComment = edit(_comment).replace("(?:-->|$)", "-->").getRegex();
809
- var tag = edit(
810
- "^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>"
811
- ).replace("comment", _inlineComment).replace("attribute", /\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex();
812
- var _inlineLabel = /(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/;
813
- var link = edit(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]*(?:\n[ \t]*)?)(title))?\s*\)/).replace("label", _inlineLabel).replace("href", /<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title", /"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex();
814
- var reflink = edit(/^!?\[(label)\]\[(ref)\]/).replace("label", _inlineLabel).replace("ref", _blockLabel).getRegex();
815
- var nolink = edit(/^!?\[(ref)\](?:\[\])?/).replace("ref", _blockLabel).getRegex();
816
- var reflinkSearch = edit("reflink|nolink(?!\\()", "g").replace("reflink", reflink).replace("nolink", nolink).getRegex();
817
- var inlineNormal = {
818
- _backpedal: noopTest,
819
- // only used for GFM url
820
- anyPunctuation,
821
- autolink,
822
- blockSkip,
823
- br,
824
- code: inlineCode,
825
- del: noopTest,
826
- emStrongLDelim,
827
- emStrongRDelimAst,
828
- emStrongRDelimUnd,
829
- escape,
830
- link,
831
- nolink,
832
- punctuation,
833
- reflink,
834
- reflinkSearch,
835
- tag,
836
- text: inlineText,
837
- url: noopTest
838
- };
839
- var inlinePedantic = {
840
- ...inlineNormal,
841
- link: edit(/^!?\[(label)\]\((.*?)\)/).replace("label", _inlineLabel).getRegex(),
842
- reflink: edit(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label", _inlineLabel).getRegex()
843
- };
844
- var inlineGfm = {
845
- ...inlineNormal,
846
- emStrongRDelimAst: emStrongRDelimAstGfm,
847
- emStrongLDelim: emStrongLDelimGfm,
848
- url: edit(/^((?:ftp|https?):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/, "i").replace("email", /[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(),
849
- _backpedal: /(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,
850
- del: /^(~~?)(?=[^\s~])((?:\\.|[^\\])*?(?:\\.|[^\s~\\]))\1(?=[^~]|$)/,
851
- text: /^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|https?:\/\/|ftp:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/
852
- };
853
- var inlineBreaks = {
854
- ...inlineGfm,
855
- br: edit(br).replace("{2,}", "*").getRegex(),
856
- text: edit(inlineGfm.text).replace("\\b_", "\\b_| {2,}\\n").replace(/\{2,\}/g, "*").getRegex()
857
- };
858
- var block = {
859
- normal: blockNormal,
860
- gfm: blockGfm,
861
- pedantic: blockPedantic
862
- };
863
- var inline = {
864
- normal: inlineNormal,
865
- gfm: inlineGfm,
866
- breaks: inlineBreaks,
867
- pedantic: inlinePedantic
868
- };
869
- var escapeReplacements = {
870
- "&": "&amp;",
871
- "<": "&lt;",
872
- ">": "&gt;",
873
- '"': "&quot;",
874
- "'": "&#39;"
875
- };
876
- var getEscapeReplacement = (ch) => escapeReplacements[ch];
877
- function escape2(html2, encode) {
878
- if (encode) {
879
- if (other.escapeTest.test(html2)) {
880
- return html2.replace(other.escapeReplace, getEscapeReplacement);
881
- }
882
- } else {
883
- if (other.escapeTestNoEncode.test(html2)) {
884
- return html2.replace(other.escapeReplaceNoEncode, getEscapeReplacement);
885
- }
653
+ var Re = (() => {
654
+ try {
655
+ return !!new RegExp("(?<=1)(?<!1)");
656
+ } catch {
657
+ return false;
886
658
  }
887
- return html2;
659
+ })();
660
+ var m = { 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: (u3) => new RegExp(`^( {0,3}${u3})((?:[ ][^\\n]*)?(?:\\n|$))`), nextBulletRegex: (u3) => new RegExp(`^ {0,${Math.min(3, u3 - 1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`), hrRegex: (u3) => new RegExp(`^ {0,${Math.min(3, u3 - 1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`), fencesBeginRegex: (u3) => new RegExp(`^ {0,${Math.min(3, u3 - 1)}}(?:\`\`\`|~~~)`), headingBeginRegex: (u3) => new RegExp(`^ {0,${Math.min(3, u3 - 1)}}#`), htmlBeginRegex: (u3) => new RegExp(`^ {0,${Math.min(3, u3 - 1)}}<(?:[a-z].*>|!--)`, "i"), blockquoteBeginRegex: (u3) => new RegExp(`^ {0,${Math.min(3, u3 - 1)}}>`) };
661
+ var Te = /^(?:[ \t]*(?:\n|$))+/;
662
+ var Oe = /^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/;
663
+ var we = /^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/;
664
+ var A = /^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/;
665
+ var ye = /^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/;
666
+ var N = / {0,3}(?:[*+-]|\d{1,9}[.)])/;
667
+ var re = /^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/;
668
+ var se = k(re).replace(/bull/g, N).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}/).replace(/html/g, / {0,3}<[^\n>]+>\n/).replace(/\|table/g, "").getRegex();
669
+ var Pe = k(re).replace(/bull/g, N).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}/).replace(/html/g, / {0,3}<[^\n>]+>\n/).replace(/table/g, / {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex();
670
+ var Q = /^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/;
671
+ var Se = /^[^\n]+/;
672
+ var j = /(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/;
673
+ var $e = k(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label", j).replace("title", /(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex();
674
+ var _e = k(/^(bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g, N).getRegex();
675
+ var q = "address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul";
676
+ var F = /<!--(?:-?>|[\s\S]*?(?:-->|$))/;
677
+ var Le = k("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\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", F).replace("tag", q).replace("attribute", / +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex();
678
+ var ie = k(Q).replace("hr", A).replace("heading", " {0,3}#{1,6}(?:\\s|$)").replace("|lheading", "").replace("|table", "").replace("blockquote", " {0,3}>").replace("fences", " {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list", " {0,3}(?:[*+-]|1[.)])[ \\t]").replace("html", "</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag", q).getRegex();
679
+ var Me = k(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph", ie).getRegex();
680
+ var U = { blockquote: Me, code: Oe, def: $e, fences: we, heading: ye, hr: A, html: Le, lheading: se, list: _e, newline: Te, paragraph: ie, table: _, text: Se };
681
+ var te = k("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr", A).replace("heading", " {0,3}#{1,6}(?:\\s|$)").replace("blockquote", " {0,3}>").replace("code", "(?: {4}| {0,3} )[^\\n]").replace("fences", " {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list", " {0,3}(?:[*+-]|1[.)])[ \\t]").replace("html", "</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag", q).getRegex();
682
+ var ze = { ...U, lheading: Pe, table: te, paragraph: k(Q).replace("hr", A).replace("heading", " {0,3}#{1,6}(?:\\s|$)").replace("|lheading", "").replace("table", te).replace("blockquote", " {0,3}>").replace("fences", " {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list", " {0,3}(?:[*+-]|1[.)])[ \\t]").replace("html", "</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag", q).getRegex() };
683
+ var Ee = { ...U, html: k(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment", F).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: _, lheading: /^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/, paragraph: k(Q).replace("hr", A).replace("heading", ` *#{1,6} *[^
684
+ ]`).replace("lheading", se).replace("|table", "").replace("blockquote", " {0,3}>").replace("|fences", "").replace("|list", "").replace("|html", "").replace("|tag", "").getRegex() };
685
+ var Ie = /^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/;
686
+ var Ae = /^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/;
687
+ var oe = /^( {2,}|\\)\n(?!\s*$)/;
688
+ var Ce = /^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/;
689
+ var v = /[\p{P}\p{S}]/u;
690
+ var K = /[\s\p{P}\p{S}]/u;
691
+ var ae = /[^\s\p{P}\p{S}]/u;
692
+ var Be = k(/^((?![*_])punctSpace)/, "u").replace(/punctSpace/g, K).getRegex();
693
+ var le = /(?!~)[\p{P}\p{S}]/u;
694
+ var De = /(?!~)[\s\p{P}\p{S}]/u;
695
+ var qe = /(?:[^\s\p{P}\p{S}]|~)/u;
696
+ var ue = /(?![*_])[\p{P}\p{S}]/u;
697
+ var ve = /(?![*_])[\s\p{P}\p{S}]/u;
698
+ var He = /(?:[^\s\p{P}\p{S}]|[*_])/u;
699
+ var Ge = k(/link|precode-code|html/, "g").replace("link", /\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("precode-", Re ? "(?<!`)()" : "(^^|[^`])").replace("code", /(?<b>`+)[^`]+\k<b>(?!`)/).replace("html", /<(?! )[^<>]*?>/).getRegex();
700
+ var pe = /^(?:\*+(?:((?!\*)punct)|[^\s*]))|^_+(?:((?!_)punct)|([^\s_]))/;
701
+ var Ze = k(pe, "u").replace(/punct/g, v).getRegex();
702
+ var Ne = k(pe, "u").replace(/punct/g, le).getRegex();
703
+ var ce = "^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)";
704
+ var Qe = k(ce, "gu").replace(/notPunctSpace/g, ae).replace(/punctSpace/g, K).replace(/punct/g, v).getRegex();
705
+ var je = k(ce, "gu").replace(/notPunctSpace/g, qe).replace(/punctSpace/g, De).replace(/punct/g, le).getRegex();
706
+ var Fe = k("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)", "gu").replace(/notPunctSpace/g, ae).replace(/punctSpace/g, K).replace(/punct/g, v).getRegex();
707
+ var Ue = k(/^~~?(?:((?!~)punct)|[^\s~])/, "u").replace(/punct/g, ue).getRegex();
708
+ var Ke = "^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)";
709
+ var We = k(Ke, "gu").replace(/notPunctSpace/g, He).replace(/punctSpace/g, ve).replace(/punct/g, ue).getRegex();
710
+ var Xe = k(/\\(punct)/, "gu").replace(/punct/g, v).getRegex();
711
+ var Je = k(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace("scheme", /[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace("email", /[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex();
712
+ var Ve = k(F).replace("(?:-->|$)", "-->").getRegex();
713
+ var Ye = k("^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>").replace("comment", Ve).replace("attribute", /\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex();
714
+ var D = /(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+[^`]*?`+(?!`)|[^\[\]\\`])*?/;
715
+ var et = k(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?\s*\)/).replace("label", D).replace("href", /<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title", /"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex();
716
+ var he = k(/^!?\[(label)\]\[(ref)\]/).replace("label", D).replace("ref", j).getRegex();
717
+ var ke = k(/^!?\[(ref)\](?:\[\])?/).replace("ref", j).getRegex();
718
+ var tt = k("reflink|nolink(?!\\()", "g").replace("reflink", he).replace("nolink", ke).getRegex();
719
+ var ne = /[hH][tT][tT][pP][sS]?|[fF][tT][pP]/;
720
+ var W = { _backpedal: _, anyPunctuation: Xe, autolink: Je, blockSkip: Ge, br: oe, code: Ae, del: _, delLDelim: _, delRDelim: _, emStrongLDelim: Ze, emStrongRDelimAst: Qe, emStrongRDelimUnd: Fe, escape: Ie, link: et, nolink: ke, punctuation: Be, reflink: he, reflinkSearch: tt, tag: Ye, text: Ce, url: _ };
721
+ var nt = { ...W, link: k(/^!?\[(label)\]\((.*?)\)/).replace("label", D).getRegex(), reflink: k(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label", D).getRegex() };
722
+ var Z = { ...W, emStrongRDelimAst: je, emStrongLDelim: Ne, delLDelim: Ue, delRDelim: We, url: k(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("protocol", ne).replace("email", /[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(), _backpedal: /(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/, del: /^(~~?)(?=[^\s~])((?:\\[\s\S]|[^\\])*?(?:\\[\s\S]|[^\s~\\]))\1(?=[^~]|$)/, text: k(/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace("protocol", ne).getRegex() };
723
+ var rt = { ...Z, br: k(oe).replace("{2,}", "*").getRegex(), text: k(Z.text).replace("\\b_", "\\b_| {2,}\\n").replace(/\{2,\}/g, "*").getRegex() };
724
+ var C = { normal: U, gfm: ze, pedantic: Ee };
725
+ var z = { normal: W, gfm: Z, breaks: rt, pedantic: nt };
726
+ var st = { "&": "&amp;", "<": "&lt;", ">": "&gt;", '"': "&quot;", "'": "&#39;" };
727
+ var de = (u3) => st[u3];
728
+ function O(u3, e) {
729
+ if (e) {
730
+ if (m.escapeTest.test(u3)) return u3.replace(m.escapeReplace, de);
731
+ } else if (m.escapeTestNoEncode.test(u3)) return u3.replace(m.escapeReplaceNoEncode, de);
732
+ return u3;
888
733
  }
889
- function cleanUrl(href) {
734
+ function X(u3) {
890
735
  try {
891
- href = encodeURI(href).replace(other.percentDecode, "%");
736
+ u3 = encodeURI(u3).replace(m.percentDecode, "%");
892
737
  } catch {
893
738
  return null;
894
739
  }
895
- return href;
740
+ return u3;
896
741
  }
897
- function splitCells(tableRow, count) {
742
+ function J(u3, e) {
898
743
  var _a2;
899
- const row = tableRow.replace(other.findPipe, (match, offset, str) => {
900
- let escaped = false;
901
- let curr = offset;
902
- while (--curr >= 0 && str[curr] === "\\") escaped = !escaped;
903
- if (escaped) {
904
- return "|";
905
- } else {
906
- return " |";
907
- }
908
- }), cells = row.split(other.splitPipe);
909
- let i = 0;
910
- if (!cells[0].trim()) {
911
- cells.shift();
912
- }
913
- if (cells.length > 0 && !((_a2 = cells.at(-1)) == null ? void 0 : _a2.trim())) {
914
- cells.pop();
915
- }
916
- if (count) {
917
- if (cells.length > count) {
918
- cells.splice(count);
919
- } else {
920
- while (cells.length < count) cells.push("");
921
- }
922
- }
923
- for (; i < cells.length; i++) {
924
- cells[i] = cells[i].trim().replace(other.slashPipe, "|");
925
- }
926
- return cells;
744
+ let t = u3.replace(m.findPipe, (i, s, a) => {
745
+ let o = false, l = s;
746
+ for (; --l >= 0 && a[l] === "\\"; ) o = !o;
747
+ return o ? "|" : " |";
748
+ }), n = t.split(m.splitPipe), r = 0;
749
+ if (n[0].trim() || n.shift(), n.length > 0 && !((_a2 = n.at(-1)) == null ? void 0 : _a2.trim()) && n.pop(), e) if (n.length > e) n.splice(e);
750
+ else for (; n.length < e; ) n.push("");
751
+ for (; r < n.length; r++) n[r] = n[r].trim().replace(m.slashPipe, "|");
752
+ return n;
927
753
  }
928
- function rtrim(str, c, invert) {
929
- const l = str.length;
930
- if (l === 0) {
931
- return "";
932
- }
933
- let suffLen = 0;
934
- while (suffLen < l) {
935
- const currChar = str.charAt(l - suffLen - 1);
936
- if (currChar === c && !invert) {
937
- suffLen++;
938
- } else if (currChar !== c && invert) {
939
- suffLen++;
940
- } else {
941
- break;
942
- }
943
- }
944
- return str.slice(0, l - suffLen);
754
+ function E(u3, e, t) {
755
+ let n = u3.length;
756
+ if (n === 0) return "";
757
+ let r = 0;
758
+ for (; r < n; ) {
759
+ let i = u3.charAt(n - r - 1);
760
+ if (i === e && !t) r++;
761
+ else if (i !== e && t) r++;
762
+ else break;
763
+ }
764
+ return u3.slice(0, n - r);
945
765
  }
946
- function findClosingBracket(str, b) {
947
- if (str.indexOf(b[1]) === -1) {
948
- return -1;
949
- }
950
- let level = 0;
951
- for (let i = 0; i < str.length; i++) {
952
- if (str[i] === "\\") {
953
- i++;
954
- } else if (str[i] === b[0]) {
955
- level++;
956
- } else if (str[i] === b[1]) {
957
- level--;
958
- if (level < 0) {
959
- return i;
960
- }
961
- }
962
- }
963
- if (level > 0) {
964
- return -2;
965
- }
966
- return -1;
766
+ function ge(u3, e) {
767
+ if (u3.indexOf(e[1]) === -1) return -1;
768
+ let t = 0;
769
+ for (let n = 0; n < u3.length; n++) if (u3[n] === "\\") n++;
770
+ else if (u3[n] === e[0]) t++;
771
+ else if (u3[n] === e[1] && (t--, t < 0)) return n;
772
+ return t > 0 ? -2 : -1;
967
773
  }
968
- function outputLink(cap, link2, raw, lexer2, rules) {
969
- const href = link2.href;
970
- const title = link2.title || null;
971
- const text = cap[1].replace(rules.other.outputLinkReplace, "$1");
972
- lexer2.state.inLink = true;
973
- const token = {
974
- type: cap[0].charAt(0) === "!" ? "image" : "link",
975
- raw,
976
- href,
977
- title,
978
- text,
979
- tokens: lexer2.inlineTokens(text)
980
- };
981
- lexer2.state.inLink = false;
982
- return token;
774
+ function fe(u3, e = 0) {
775
+ let t = e, n = "";
776
+ for (let r of u3) if (r === " ") {
777
+ let i = 4 - t % 4;
778
+ n += " ".repeat(i), t += i;
779
+ } else n += r, t++;
780
+ return n;
983
781
  }
984
- function indentCodeCompensation(raw, text, rules) {
985
- const matchIndentToCode = raw.match(rules.other.indentCodeCompensation);
986
- if (matchIndentToCode === null) {
987
- return text;
988
- }
989
- const indentToCode = matchIndentToCode[1];
990
- return text.split("\n").map((node) => {
991
- const matchIndentInNode = node.match(rules.other.beginningSpace);
992
- if (matchIndentInNode === null) {
993
- return node;
994
- }
995
- const [indentInNode] = matchIndentInNode;
996
- if (indentInNode.length >= indentToCode.length) {
997
- return node.slice(indentToCode.length);
998
- }
999
- return node;
1000
- }).join("\n");
782
+ function me(u3, e, t, n, r) {
783
+ let i = e.href, s = e.title || null, a = u3[1].replace(r.other.outputLinkReplace, "$1");
784
+ n.state.inLink = true;
785
+ let o = { type: u3[0].charAt(0) === "!" ? "image" : "link", raw: t, href: i, title: s, text: a, tokens: n.inlineTokens(a) };
786
+ return n.state.inLink = false, o;
787
+ }
788
+ function it(u3, e, t) {
789
+ let n = u3.match(t.other.indentCodeCompensation);
790
+ if (n === null) return e;
791
+ let r = n[1];
792
+ return e.split(`
793
+ `).map((i) => {
794
+ let s = i.match(t.other.beginningSpace);
795
+ if (s === null) return i;
796
+ let [a] = s;
797
+ return a.length >= r.length ? i.slice(r.length) : i;
798
+ }).join(`
799
+ `);
1001
800
  }
1002
- var _Tokenizer = class {
1003
- // set by the lexer
1004
- constructor(options2) {
801
+ var w = class {
802
+ constructor(e) {
1005
803
  __publicField(this, "options");
1006
804
  __publicField(this, "rules");
1007
- // set by the lexer
1008
805
  __publicField(this, "lexer");
1009
- this.options = options2 || _defaults;
1010
- }
1011
- space(src) {
1012
- const cap = this.rules.block.newline.exec(src);
1013
- if (cap && cap[0].length > 0) {
1014
- return {
1015
- type: "space",
1016
- raw: cap[0]
1017
- };
1018
- }
1019
- }
1020
- code(src) {
1021
- const cap = this.rules.block.code.exec(src);
1022
- if (cap) {
1023
- const text = cap[0].replace(this.rules.other.codeRemoveIndent, "");
1024
- return {
1025
- type: "code",
1026
- raw: cap[0],
1027
- codeBlockStyle: "indented",
1028
- text: !this.options.pedantic ? rtrim(text, "\n") : text
1029
- };
1030
- }
1031
- }
1032
- fences(src) {
1033
- const cap = this.rules.block.fences.exec(src);
1034
- if (cap) {
1035
- const raw = cap[0];
1036
- const text = indentCodeCompensation(raw, cap[3] || "", this.rules);
1037
- return {
1038
- type: "code",
1039
- raw,
1040
- lang: cap[2] ? cap[2].trim().replace(this.rules.inline.anyPunctuation, "$1") : cap[2],
1041
- text
1042
- };
1043
- }
1044
- }
1045
- heading(src) {
1046
- const cap = this.rules.block.heading.exec(src);
1047
- if (cap) {
1048
- let text = cap[2].trim();
1049
- if (this.rules.other.endingHash.test(text)) {
1050
- const trimmed = rtrim(text, "#");
1051
- if (this.options.pedantic) {
1052
- text = trimmed.trim();
1053
- } else if (!trimmed || this.rules.other.endingSpaceChar.test(trimmed)) {
1054
- text = trimmed.trim();
1055
- }
1056
- }
1057
- return {
1058
- type: "heading",
1059
- raw: cap[0],
1060
- depth: cap[1].length,
1061
- text,
1062
- tokens: this.lexer.inline(text)
1063
- };
1064
- }
1065
- }
1066
- hr(src) {
1067
- const cap = this.rules.block.hr.exec(src);
1068
- if (cap) {
1069
- return {
1070
- type: "hr",
1071
- raw: rtrim(cap[0], "\n")
1072
- };
1073
- }
1074
- }
1075
- blockquote(src) {
1076
- const cap = this.rules.block.blockquote.exec(src);
1077
- if (cap) {
1078
- let lines = rtrim(cap[0], "\n").split("\n");
1079
- let raw = "";
1080
- let text = "";
1081
- const tokens = [];
1082
- while (lines.length > 0) {
1083
- let inBlockquote = false;
1084
- const currentLines = [];
1085
- let i;
1086
- for (i = 0; i < lines.length; i++) {
1087
- if (this.rules.other.blockquoteStart.test(lines[i])) {
1088
- currentLines.push(lines[i]);
1089
- inBlockquote = true;
1090
- } else if (!inBlockquote) {
1091
- currentLines.push(lines[i]);
1092
- } else {
1093
- break;
1094
- }
1095
- }
1096
- lines = lines.slice(i);
1097
- const currentRaw = currentLines.join("\n");
1098
- const currentText = currentRaw.replace(this.rules.other.blockquoteSetextReplace, "\n $1").replace(this.rules.other.blockquoteSetextReplace2, "");
1099
- raw = raw ? `${raw}
1100
- ${currentRaw}` : currentRaw;
1101
- text = text ? `${text}
1102
- ${currentText}` : currentText;
1103
- const top = this.lexer.state.top;
1104
- this.lexer.state.top = true;
1105
- this.lexer.blockTokens(currentText, tokens, true);
1106
- this.lexer.state.top = top;
1107
- if (lines.length === 0) {
806
+ this.options = e || T;
807
+ }
808
+ space(e) {
809
+ let t = this.rules.block.newline.exec(e);
810
+ if (t && t[0].length > 0) return { type: "space", raw: t[0] };
811
+ }
812
+ code(e) {
813
+ let t = this.rules.block.code.exec(e);
814
+ if (t) {
815
+ let n = t[0].replace(this.rules.other.codeRemoveIndent, "");
816
+ return { type: "code", raw: t[0], codeBlockStyle: "indented", text: this.options.pedantic ? n : E(n, `
817
+ `) };
818
+ }
819
+ }
820
+ fences(e) {
821
+ let t = this.rules.block.fences.exec(e);
822
+ if (t) {
823
+ let n = t[0], r = it(n, t[3] || "", this.rules);
824
+ return { type: "code", raw: n, lang: t[2] ? t[2].trim().replace(this.rules.inline.anyPunctuation, "$1") : t[2], text: r };
825
+ }
826
+ }
827
+ heading(e) {
828
+ let t = this.rules.block.heading.exec(e);
829
+ if (t) {
830
+ let n = t[2].trim();
831
+ if (this.rules.other.endingHash.test(n)) {
832
+ let r = E(n, "#");
833
+ (this.options.pedantic || !r || this.rules.other.endingSpaceChar.test(r)) && (n = r.trim());
834
+ }
835
+ return { type: "heading", raw: t[0], depth: t[1].length, text: n, tokens: this.lexer.inline(n) };
836
+ }
837
+ }
838
+ hr(e) {
839
+ let t = this.rules.block.hr.exec(e);
840
+ if (t) return { type: "hr", raw: E(t[0], `
841
+ `) };
842
+ }
843
+ blockquote(e) {
844
+ let t = this.rules.block.blockquote.exec(e);
845
+ if (t) {
846
+ let n = E(t[0], `
847
+ `).split(`
848
+ `), r = "", i = "", s = [];
849
+ for (; n.length > 0; ) {
850
+ let a = false, o = [], l;
851
+ for (l = 0; l < n.length; l++) if (this.rules.other.blockquoteStart.test(n[l])) o.push(n[l]), a = true;
852
+ else if (!a) o.push(n[l]);
853
+ else break;
854
+ n = n.slice(l);
855
+ let p = o.join(`
856
+ `), c = p.replace(this.rules.other.blockquoteSetextReplace, `
857
+ $1`).replace(this.rules.other.blockquoteSetextReplace2, "");
858
+ r = r ? `${r}
859
+ ${p}` : p, i = i ? `${i}
860
+ ${c}` : c;
861
+ let d = this.lexer.state.top;
862
+ if (this.lexer.state.top = true, this.lexer.blockTokens(c, s, true), this.lexer.state.top = d, n.length === 0) break;
863
+ let h = s.at(-1);
864
+ if ((h == null ? void 0 : h.type) === "code") break;
865
+ if ((h == null ? void 0 : h.type) === "blockquote") {
866
+ let R = h, f = R.raw + `
867
+ ` + n.join(`
868
+ `), S = this.blockquote(f);
869
+ s[s.length - 1] = S, r = r.substring(0, r.length - R.raw.length) + S.raw, i = i.substring(0, i.length - R.text.length) + S.text;
1108
870
  break;
1109
- }
1110
- const lastToken = tokens.at(-1);
1111
- if ((lastToken == null ? void 0 : lastToken.type) === "code") {
1112
- break;
1113
- } else if ((lastToken == null ? void 0 : lastToken.type) === "blockquote") {
1114
- const oldToken = lastToken;
1115
- const newText = oldToken.raw + "\n" + lines.join("\n");
1116
- const newToken = this.blockquote(newText);
1117
- tokens[tokens.length - 1] = newToken;
1118
- raw = raw.substring(0, raw.length - oldToken.raw.length) + newToken.raw;
1119
- text = text.substring(0, text.length - oldToken.text.length) + newToken.text;
1120
- break;
1121
- } else if ((lastToken == null ? void 0 : lastToken.type) === "list") {
1122
- const oldToken = lastToken;
1123
- const newText = oldToken.raw + "\n" + lines.join("\n");
1124
- const newToken = this.list(newText);
1125
- tokens[tokens.length - 1] = newToken;
1126
- raw = raw.substring(0, raw.length - lastToken.raw.length) + newToken.raw;
1127
- text = text.substring(0, text.length - oldToken.raw.length) + newToken.raw;
1128
- lines = newText.substring(tokens.at(-1).raw.length).split("\n");
871
+ } else if ((h == null ? void 0 : h.type) === "list") {
872
+ let R = h, f = R.raw + `
873
+ ` + n.join(`
874
+ `), S = this.list(f);
875
+ s[s.length - 1] = S, r = r.substring(0, r.length - h.raw.length) + S.raw, i = i.substring(0, i.length - R.raw.length) + S.raw, n = f.substring(s.at(-1).raw.length).split(`
876
+ `);
1129
877
  continue;
1130
878
  }
1131
879
  }
1132
- return {
1133
- type: "blockquote",
1134
- raw,
1135
- tokens,
1136
- text
1137
- };
880
+ return { type: "blockquote", raw: r, tokens: s, text: i };
1138
881
  }
1139
882
  }
1140
- list(src) {
1141
- let cap = this.rules.block.list.exec(src);
1142
- if (cap) {
1143
- let bull = cap[1].trim();
1144
- const isordered = bull.length > 1;
1145
- const list2 = {
1146
- type: "list",
1147
- raw: "",
1148
- ordered: isordered,
1149
- start: isordered ? +bull.slice(0, -1) : "",
1150
- loose: false,
1151
- items: []
1152
- };
1153
- bull = isordered ? `\\d{1,9}\\${bull.slice(-1)}` : `\\${bull}`;
1154
- if (this.options.pedantic) {
1155
- bull = isordered ? bull : "[*+-]";
1156
- }
1157
- const itemRegex = this.rules.other.listItemRegex(bull);
1158
- let endsWithBlankLine = false;
1159
- while (src) {
1160
- let endEarly = false;
1161
- let raw = "";
1162
- let itemContents = "";
1163
- if (!(cap = itemRegex.exec(src))) {
1164
- break;
1165
- }
1166
- if (this.rules.block.hr.test(src)) {
1167
- break;
1168
- }
1169
- raw = cap[0];
1170
- src = src.substring(raw.length);
1171
- let line = cap[2].split("\n", 1)[0].replace(this.rules.other.listReplaceTabs, (t) => " ".repeat(3 * t.length));
1172
- let nextLine = src.split("\n", 1)[0];
1173
- let blankLine = !line.trim();
1174
- let indent = 0;
1175
- if (this.options.pedantic) {
1176
- indent = 2;
1177
- itemContents = line.trimStart();
1178
- } else if (blankLine) {
1179
- indent = cap[1].length + 1;
1180
- } else {
1181
- indent = cap[2].search(this.rules.other.nonSpaceChar);
1182
- indent = indent > 4 ? 1 : indent;
1183
- itemContents = line.slice(indent);
1184
- indent += cap[1].length;
1185
- }
1186
- if (blankLine && this.rules.other.blankLine.test(nextLine)) {
1187
- raw += nextLine + "\n";
1188
- src = src.substring(nextLine.length + 1);
1189
- endEarly = true;
1190
- }
1191
- if (!endEarly) {
1192
- const nextBulletRegex = this.rules.other.nextBulletRegex(indent);
1193
- const hrRegex = this.rules.other.hrRegex(indent);
1194
- const fencesBeginRegex = this.rules.other.fencesBeginRegex(indent);
1195
- const headingBeginRegex = this.rules.other.headingBeginRegex(indent);
1196
- const htmlBeginRegex = this.rules.other.htmlBeginRegex(indent);
1197
- while (src) {
1198
- const rawLine = src.split("\n", 1)[0];
1199
- let nextLineWithoutTabs;
1200
- nextLine = rawLine;
1201
- if (this.options.pedantic) {
1202
- nextLine = nextLine.replace(this.rules.other.listReplaceNesting, " ");
1203
- nextLineWithoutTabs = nextLine;
1204
- } else {
1205
- nextLineWithoutTabs = nextLine.replace(this.rules.other.tabCharGlobal, " ");
1206
- }
1207
- if (fencesBeginRegex.test(nextLine)) {
1208
- break;
1209
- }
1210
- if (headingBeginRegex.test(nextLine)) {
1211
- break;
1212
- }
1213
- if (htmlBeginRegex.test(nextLine)) {
1214
- break;
1215
- }
1216
- if (nextBulletRegex.test(nextLine)) {
1217
- break;
1218
- }
1219
- if (hrRegex.test(nextLine)) {
1220
- break;
1221
- }
1222
- if (nextLineWithoutTabs.search(this.rules.other.nonSpaceChar) >= indent || !nextLine.trim()) {
1223
- itemContents += "\n" + nextLineWithoutTabs.slice(indent);
1224
- } else {
1225
- if (blankLine) {
1226
- break;
1227
- }
1228
- if (line.replace(this.rules.other.tabCharGlobal, " ").search(this.rules.other.nonSpaceChar) >= 4) {
1229
- break;
1230
- }
1231
- if (fencesBeginRegex.test(line)) {
1232
- break;
1233
- }
1234
- if (headingBeginRegex.test(line)) {
1235
- break;
1236
- }
1237
- if (hrRegex.test(line)) {
1238
- break;
1239
- }
1240
- itemContents += "\n" + nextLine;
1241
- }
1242
- if (!blankLine && !nextLine.trim()) {
1243
- blankLine = true;
883
+ list(e) {
884
+ var _a2, _b;
885
+ let t = this.rules.block.list.exec(e);
886
+ if (t) {
887
+ let n = t[1].trim(), r = n.length > 1, i = { type: "list", raw: "", ordered: r, start: r ? +n.slice(0, -1) : "", loose: false, items: [] };
888
+ n = r ? `\\d{1,9}\\${n.slice(-1)}` : `\\${n}`, this.options.pedantic && (n = r ? n : "[*+-]");
889
+ let s = this.rules.other.listItemRegex(n), a = false;
890
+ for (; e; ) {
891
+ let l = false, p = "", c = "";
892
+ if (!(t = s.exec(e)) || this.rules.block.hr.test(e)) break;
893
+ p = t[0], e = e.substring(p.length);
894
+ let d = fe(t[2].split(`
895
+ `, 1)[0], t[1].length), h = e.split(`
896
+ `, 1)[0], R = !d.trim(), f = 0;
897
+ if (this.options.pedantic ? (f = 2, c = d.trimStart()) : R ? f = t[1].length + 1 : (f = d.search(this.rules.other.nonSpaceChar), f = f > 4 ? 1 : f, c = d.slice(f), f += t[1].length), R && this.rules.other.blankLine.test(h) && (p += h + `
898
+ `, e = e.substring(h.length + 1), l = true), !l) {
899
+ let S = this.rules.other.nextBulletRegex(f), V = this.rules.other.hrRegex(f), Y = this.rules.other.fencesBeginRegex(f), ee = this.rules.other.headingBeginRegex(f), xe = this.rules.other.htmlBeginRegex(f), be = this.rules.other.blockquoteBeginRegex(f);
900
+ for (; e; ) {
901
+ let H = e.split(`
902
+ `, 1)[0], I;
903
+ if (h = H, this.options.pedantic ? (h = h.replace(this.rules.other.listReplaceNesting, " "), I = h) : I = h.replace(this.rules.other.tabCharGlobal, " "), Y.test(h) || ee.test(h) || xe.test(h) || be.test(h) || S.test(h) || V.test(h)) break;
904
+ if (I.search(this.rules.other.nonSpaceChar) >= f || !h.trim()) c += `
905
+ ` + I.slice(f);
906
+ else {
907
+ if (R || d.replace(this.rules.other.tabCharGlobal, " ").search(this.rules.other.nonSpaceChar) >= 4 || Y.test(d) || ee.test(d) || V.test(d)) break;
908
+ c += `
909
+ ` + h;
1244
910
  }
1245
- raw += rawLine + "\n";
1246
- src = src.substring(rawLine.length + 1);
1247
- line = nextLineWithoutTabs.slice(indent);
911
+ R = !h.trim(), p += H + `
912
+ `, e = e.substring(H.length + 1), d = I.slice(f);
1248
913
  }
1249
914
  }
1250
- if (!list2.loose) {
1251
- if (endsWithBlankLine) {
1252
- list2.loose = true;
1253
- } else if (this.rules.other.doubleBlankLine.test(raw)) {
1254
- endsWithBlankLine = true;
915
+ i.loose || (a ? i.loose = true : this.rules.other.doubleBlankLine.test(p) && (a = true)), i.items.push({ type: "list_item", raw: p, task: !!this.options.gfm && this.rules.other.listIsTask.test(c), loose: false, text: c, tokens: [] }), i.raw += p;
916
+ }
917
+ let o = i.items.at(-1);
918
+ if (o) o.raw = o.raw.trimEnd(), o.text = o.text.trimEnd();
919
+ else return;
920
+ i.raw = i.raw.trimEnd();
921
+ for (let l of i.items) {
922
+ if (this.lexer.state.top = false, l.tokens = this.lexer.blockTokens(l.text, []), l.task) {
923
+ if (l.text = l.text.replace(this.rules.other.listReplaceTask, ""), ((_a2 = l.tokens[0]) == null ? void 0 : _a2.type) === "text" || ((_b = l.tokens[0]) == null ? void 0 : _b.type) === "paragraph") {
924
+ l.tokens[0].raw = l.tokens[0].raw.replace(this.rules.other.listReplaceTask, ""), l.tokens[0].text = l.tokens[0].text.replace(this.rules.other.listReplaceTask, "");
925
+ for (let c = this.lexer.inlineQueue.length - 1; c >= 0; c--) if (this.rules.other.listIsTask.test(this.lexer.inlineQueue[c].src)) {
926
+ this.lexer.inlineQueue[c].src = this.lexer.inlineQueue[c].src.replace(this.rules.other.listReplaceTask, "");
927
+ break;
928
+ }
1255
929
  }
1256
- }
1257
- let istask = null;
1258
- let ischecked;
1259
- if (this.options.gfm) {
1260
- istask = this.rules.other.listIsTask.exec(itemContents);
1261
- if (istask) {
1262
- ischecked = istask[0] !== "[ ] ";
1263
- itemContents = itemContents.replace(this.rules.other.listReplaceTask, "");
930
+ let p = this.rules.other.listTaskCheckbox.exec(l.raw);
931
+ if (p) {
932
+ let c = { type: "checkbox", raw: p[0] + " ", checked: p[0] !== "[ ]" };
933
+ l.checked = c.checked, i.loose ? l.tokens[0] && ["paragraph", "text"].includes(l.tokens[0].type) && "tokens" in l.tokens[0] && l.tokens[0].tokens ? (l.tokens[0].raw = c.raw + l.tokens[0].raw, l.tokens[0].text = c.raw + l.tokens[0].text, l.tokens[0].tokens.unshift(c)) : l.tokens.unshift({ type: "paragraph", raw: c.raw, text: c.raw, tokens: [c] }) : l.tokens.unshift(c);
1264
934
  }
1265
935
  }
1266
- list2.items.push({
1267
- type: "list_item",
1268
- raw,
1269
- task: !!istask,
1270
- checked: ischecked,
1271
- loose: false,
1272
- text: itemContents,
1273
- tokens: []
1274
- });
1275
- list2.raw += raw;
1276
- }
1277
- const lastItem = list2.items.at(-1);
1278
- if (lastItem) {
1279
- lastItem.raw = lastItem.raw.trimEnd();
1280
- lastItem.text = lastItem.text.trimEnd();
1281
- } else {
1282
- return;
1283
- }
1284
- list2.raw = list2.raw.trimEnd();
1285
- for (let i = 0; i < list2.items.length; i++) {
1286
- this.lexer.state.top = false;
1287
- list2.items[i].tokens = this.lexer.blockTokens(list2.items[i].text, []);
1288
- if (!list2.loose) {
1289
- const spacers = list2.items[i].tokens.filter((t) => t.type === "space");
1290
- const hasMultipleLineBreaks = spacers.length > 0 && spacers.some((t) => this.rules.other.anyLine.test(t.raw));
1291
- list2.loose = hasMultipleLineBreaks;
936
+ if (!i.loose) {
937
+ let p = l.tokens.filter((d) => d.type === "space"), c = p.length > 0 && p.some((d) => this.rules.other.anyLine.test(d.raw));
938
+ i.loose = c;
1292
939
  }
1293
940
  }
1294
- if (list2.loose) {
1295
- for (let i = 0; i < list2.items.length; i++) {
1296
- list2.items[i].loose = true;
1297
- }
941
+ if (i.loose) for (let l of i.items) {
942
+ l.loose = true;
943
+ for (let p of l.tokens) p.type === "text" && (p.type = "paragraph");
1298
944
  }
1299
- return list2;
945
+ return i;
1300
946
  }
1301
947
  }
1302
- html(src) {
1303
- const cap = this.rules.block.html.exec(src);
1304
- if (cap) {
1305
- const token = {
1306
- type: "html",
1307
- block: true,
1308
- raw: cap[0],
1309
- pre: cap[1] === "pre" || cap[1] === "script" || cap[1] === "style",
1310
- text: cap[0]
1311
- };
1312
- return token;
1313
- }
948
+ html(e) {
949
+ let t = this.rules.block.html.exec(e);
950
+ if (t) return { type: "html", block: true, raw: t[0], pre: t[1] === "pre" || t[1] === "script" || t[1] === "style", text: t[0] };
1314
951
  }
1315
- def(src) {
1316
- const cap = this.rules.block.def.exec(src);
1317
- if (cap) {
1318
- const tag2 = cap[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal, " ");
1319
- const href = cap[2] ? cap[2].replace(this.rules.other.hrefBrackets, "$1").replace(this.rules.inline.anyPunctuation, "$1") : "";
1320
- const title = cap[3] ? cap[3].substring(1, cap[3].length - 1).replace(this.rules.inline.anyPunctuation, "$1") : cap[3];
1321
- return {
1322
- type: "def",
1323
- tag: tag2,
1324
- raw: cap[0],
1325
- href,
1326
- title
1327
- };
952
+ def(e) {
953
+ let t = this.rules.block.def.exec(e);
954
+ if (t) {
955
+ let n = t[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal, " "), r = t[2] ? t[2].replace(this.rules.other.hrefBrackets, "$1").replace(this.rules.inline.anyPunctuation, "$1") : "", i = t[3] ? t[3].substring(1, t[3].length - 1).replace(this.rules.inline.anyPunctuation, "$1") : t[3];
956
+ return { type: "def", tag: n, raw: t[0], href: r, title: i };
1328
957
  }
1329
958
  }
1330
- table(src) {
959
+ table(e) {
1331
960
  var _a2;
1332
- const cap = this.rules.block.table.exec(src);
1333
- if (!cap) {
1334
- return;
1335
- }
1336
- if (!this.rules.other.tableDelimiter.test(cap[2])) {
1337
- return;
1338
- }
1339
- const headers = splitCells(cap[1]);
1340
- const aligns = cap[2].replace(this.rules.other.tableAlignChars, "").split("|");
1341
- const rows = ((_a2 = cap[3]) == null ? void 0 : _a2.trim()) ? cap[3].replace(this.rules.other.tableRowBlankLine, "").split("\n") : [];
1342
- const item = {
1343
- type: "table",
1344
- raw: cap[0],
1345
- header: [],
1346
- align: [],
1347
- rows: []
1348
- };
1349
- if (headers.length !== aligns.length) {
1350
- return;
1351
- }
1352
- for (const align of aligns) {
1353
- if (this.rules.other.tableAlignRight.test(align)) {
1354
- item.align.push("right");
1355
- } else if (this.rules.other.tableAlignCenter.test(align)) {
1356
- item.align.push("center");
1357
- } else if (this.rules.other.tableAlignLeft.test(align)) {
1358
- item.align.push("left");
1359
- } else {
1360
- item.align.push(null);
1361
- }
1362
- }
1363
- for (let i = 0; i < headers.length; i++) {
1364
- item.header.push({
1365
- text: headers[i],
1366
- tokens: this.lexer.inline(headers[i]),
1367
- header: true,
1368
- align: item.align[i]
1369
- });
1370
- }
1371
- for (const row of rows) {
1372
- item.rows.push(splitCells(row, item.header.length).map((cell, i) => {
1373
- return {
1374
- text: cell,
1375
- tokens: this.lexer.inline(cell),
1376
- header: false,
1377
- align: item.align[i]
1378
- };
1379
- }));
1380
- }
1381
- return item;
1382
- }
1383
- lheading(src) {
1384
- const cap = this.rules.block.lheading.exec(src);
1385
- if (cap) {
1386
- return {
1387
- type: "heading",
1388
- raw: cap[0],
1389
- depth: cap[2].charAt(0) === "=" ? 1 : 2,
1390
- text: cap[1],
1391
- tokens: this.lexer.inline(cap[1])
1392
- };
1393
- }
1394
- }
1395
- paragraph(src) {
1396
- const cap = this.rules.block.paragraph.exec(src);
1397
- if (cap) {
1398
- const text = cap[1].charAt(cap[1].length - 1) === "\n" ? cap[1].slice(0, -1) : cap[1];
1399
- return {
1400
- type: "paragraph",
1401
- raw: cap[0],
1402
- text,
1403
- tokens: this.lexer.inline(text)
1404
- };
1405
- }
1406
- }
1407
- text(src) {
1408
- const cap = this.rules.block.text.exec(src);
1409
- if (cap) {
1410
- return {
1411
- type: "text",
1412
- raw: cap[0],
1413
- text: cap[0],
1414
- tokens: this.lexer.inline(cap[0])
1415
- };
1416
- }
1417
- }
1418
- escape(src) {
1419
- const cap = this.rules.inline.escape.exec(src);
1420
- if (cap) {
1421
- return {
1422
- type: "escape",
1423
- raw: cap[0],
1424
- text: cap[1]
1425
- };
1426
- }
1427
- }
1428
- tag(src) {
1429
- const cap = this.rules.inline.tag.exec(src);
1430
- if (cap) {
1431
- if (!this.lexer.state.inLink && this.rules.other.startATag.test(cap[0])) {
1432
- this.lexer.state.inLink = true;
1433
- } else if (this.lexer.state.inLink && this.rules.other.endATag.test(cap[0])) {
1434
- this.lexer.state.inLink = false;
1435
- }
1436
- if (!this.lexer.state.inRawBlock && this.rules.other.startPreScriptTag.test(cap[0])) {
1437
- this.lexer.state.inRawBlock = true;
1438
- } else if (this.lexer.state.inRawBlock && this.rules.other.endPreScriptTag.test(cap[0])) {
1439
- this.lexer.state.inRawBlock = false;
1440
- }
1441
- return {
1442
- type: "html",
1443
- raw: cap[0],
1444
- inLink: this.lexer.state.inLink,
1445
- inRawBlock: this.lexer.state.inRawBlock,
1446
- block: false,
1447
- text: cap[0]
1448
- };
1449
- }
1450
- }
1451
- link(src) {
1452
- const cap = this.rules.inline.link.exec(src);
1453
- if (cap) {
1454
- const trimmedUrl = cap[2].trim();
1455
- if (!this.options.pedantic && this.rules.other.startAngleBracket.test(trimmedUrl)) {
1456
- if (!this.rules.other.endAngleBracket.test(trimmedUrl)) {
1457
- return;
1458
- }
1459
- const rtrimSlash = rtrim(trimmedUrl.slice(0, -1), "\\");
1460
- if ((trimmedUrl.length - rtrimSlash.length) % 2 === 0) {
1461
- return;
1462
- }
961
+ let t = this.rules.block.table.exec(e);
962
+ if (!t || !this.rules.other.tableDelimiter.test(t[2])) return;
963
+ let n = J(t[1]), r = t[2].replace(this.rules.other.tableAlignChars, "").split("|"), i = ((_a2 = t[3]) == null ? void 0 : _a2.trim()) ? t[3].replace(this.rules.other.tableRowBlankLine, "").split(`
964
+ `) : [], s = { type: "table", raw: t[0], header: [], align: [], rows: [] };
965
+ if (n.length === r.length) {
966
+ for (let a of r) this.rules.other.tableAlignRight.test(a) ? s.align.push("right") : this.rules.other.tableAlignCenter.test(a) ? s.align.push("center") : this.rules.other.tableAlignLeft.test(a) ? s.align.push("left") : s.align.push(null);
967
+ for (let a = 0; a < n.length; a++) s.header.push({ text: n[a], tokens: this.lexer.inline(n[a]), header: true, align: s.align[a] });
968
+ for (let a of i) s.rows.push(J(a, s.header.length).map((o, l) => ({ text: o, tokens: this.lexer.inline(o), header: false, align: s.align[l] })));
969
+ return s;
970
+ }
971
+ }
972
+ lheading(e) {
973
+ let t = this.rules.block.lheading.exec(e);
974
+ if (t) return { type: "heading", raw: t[0], depth: t[2].charAt(0) === "=" ? 1 : 2, text: t[1], tokens: this.lexer.inline(t[1]) };
975
+ }
976
+ paragraph(e) {
977
+ let t = this.rules.block.paragraph.exec(e);
978
+ if (t) {
979
+ let n = t[1].charAt(t[1].length - 1) === `
980
+ ` ? t[1].slice(0, -1) : t[1];
981
+ return { type: "paragraph", raw: t[0], text: n, tokens: this.lexer.inline(n) };
982
+ }
983
+ }
984
+ text(e) {
985
+ let t = this.rules.block.text.exec(e);
986
+ if (t) return { type: "text", raw: t[0], text: t[0], tokens: this.lexer.inline(t[0]) };
987
+ }
988
+ escape(e) {
989
+ let t = this.rules.inline.escape.exec(e);
990
+ if (t) return { type: "escape", raw: t[0], text: t[1] };
991
+ }
992
+ tag(e) {
993
+ let t = this.rules.inline.tag.exec(e);
994
+ if (t) return !this.lexer.state.inLink && this.rules.other.startATag.test(t[0]) ? this.lexer.state.inLink = true : this.lexer.state.inLink && this.rules.other.endATag.test(t[0]) && (this.lexer.state.inLink = false), !this.lexer.state.inRawBlock && this.rules.other.startPreScriptTag.test(t[0]) ? this.lexer.state.inRawBlock = true : this.lexer.state.inRawBlock && this.rules.other.endPreScriptTag.test(t[0]) && (this.lexer.state.inRawBlock = false), { type: "html", raw: t[0], inLink: this.lexer.state.inLink, inRawBlock: this.lexer.state.inRawBlock, block: false, text: t[0] };
995
+ }
996
+ link(e) {
997
+ let t = this.rules.inline.link.exec(e);
998
+ if (t) {
999
+ let n = t[2].trim();
1000
+ if (!this.options.pedantic && this.rules.other.startAngleBracket.test(n)) {
1001
+ if (!this.rules.other.endAngleBracket.test(n)) return;
1002
+ let s = E(n.slice(0, -1), "\\");
1003
+ if ((n.length - s.length) % 2 === 0) return;
1463
1004
  } else {
1464
- const lastParenIndex = findClosingBracket(cap[2], "()");
1465
- if (lastParenIndex === -2) {
1466
- return;
1467
- }
1468
- if (lastParenIndex > -1) {
1469
- const start = cap[0].indexOf("!") === 0 ? 5 : 4;
1470
- const linkLen = start + cap[1].length + lastParenIndex;
1471
- cap[2] = cap[2].substring(0, lastParenIndex);
1472
- cap[0] = cap[0].substring(0, linkLen).trim();
1473
- cap[3] = "";
1005
+ let s = ge(t[2], "()");
1006
+ if (s === -2) return;
1007
+ if (s > -1) {
1008
+ let o = (t[0].indexOf("!") === 0 ? 5 : 4) + t[1].length + s;
1009
+ t[2] = t[2].substring(0, s), t[0] = t[0].substring(0, o).trim(), t[3] = "";
1474
1010
  }
1475
1011
  }
1476
- let href = cap[2];
1477
- let title = "";
1012
+ let r = t[2], i = "";
1478
1013
  if (this.options.pedantic) {
1479
- const link2 = this.rules.other.pedanticHrefTitle.exec(href);
1480
- if (link2) {
1481
- href = link2[1];
1482
- title = link2[3];
1014
+ let s = this.rules.other.pedanticHrefTitle.exec(r);
1015
+ s && (r = s[1], i = s[3]);
1016
+ } else i = t[3] ? t[3].slice(1, -1) : "";
1017
+ 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)), me(t, { href: r && r.replace(this.rules.inline.anyPunctuation, "$1"), title: i && i.replace(this.rules.inline.anyPunctuation, "$1") }, t[0], this.lexer, this.rules);
1018
+ }
1019
+ }
1020
+ reflink(e, t) {
1021
+ let n;
1022
+ if ((n = this.rules.inline.reflink.exec(e)) || (n = this.rules.inline.nolink.exec(e))) {
1023
+ let r = (n[2] || n[1]).replace(this.rules.other.multipleSpaceGlobal, " "), i = t[r.toLowerCase()];
1024
+ if (!i) {
1025
+ let s = n[0].charAt(0);
1026
+ return { type: "text", raw: s, text: s };
1027
+ }
1028
+ return me(n, i, n[0], this.lexer, this.rules);
1029
+ }
1030
+ }
1031
+ emStrong(e, t, n = "") {
1032
+ let r = this.rules.inline.emStrongLDelim.exec(e);
1033
+ if (!r || r[3] && n.match(this.rules.other.unicodeAlphaNumeric)) return;
1034
+ if (!(r[1] || r[2] || "") || !n || this.rules.inline.punctuation.exec(n)) {
1035
+ let s = [...r[0]].length - 1, a, o, l = s, p = 0, c = r[0][0] === "*" ? this.rules.inline.emStrongRDelimAst : this.rules.inline.emStrongRDelimUnd;
1036
+ for (c.lastIndex = 0, t = t.slice(-1 * e.length + s); (r = c.exec(t)) != null; ) {
1037
+ if (a = r[1] || r[2] || r[3] || r[4] || r[5] || r[6], !a) continue;
1038
+ if (o = [...a].length, r[3] || r[4]) {
1039
+ l += o;
1040
+ continue;
1041
+ } else if ((r[5] || r[6]) && s % 3 && !((s + o) % 3)) {
1042
+ p += o;
1043
+ continue;
1483
1044
  }
1484
- } else {
1485
- title = cap[3] ? cap[3].slice(1, -1) : "";
1486
- }
1487
- href = href.trim();
1488
- if (this.rules.other.startAngleBracket.test(href)) {
1489
- if (this.options.pedantic && !this.rules.other.endAngleBracket.test(trimmedUrl)) {
1490
- href = href.slice(1);
1491
- } else {
1492
- href = href.slice(1, -1);
1045
+ if (l -= o, l > 0) continue;
1046
+ o = Math.min(o, o + l + p);
1047
+ let d = [...r[0]][0].length, h = e.slice(0, s + r.index + d + o);
1048
+ if (Math.min(s, o) % 2) {
1049
+ let f = h.slice(1, -1);
1050
+ return { type: "em", raw: h, text: f, tokens: this.lexer.inlineTokens(f) };
1493
1051
  }
1052
+ let R = h.slice(2, -2);
1053
+ return { type: "strong", raw: h, text: R, tokens: this.lexer.inlineTokens(R) };
1494
1054
  }
1495
- return outputLink(cap, {
1496
- href: href ? href.replace(this.rules.inline.anyPunctuation, "$1") : href,
1497
- title: title ? title.replace(this.rules.inline.anyPunctuation, "$1") : title
1498
- }, cap[0], this.lexer, this.rules);
1499
1055
  }
1500
1056
  }
1501
- reflink(src, links) {
1502
- let cap;
1503
- if ((cap = this.rules.inline.reflink.exec(src)) || (cap = this.rules.inline.nolink.exec(src))) {
1504
- const linkString = (cap[2] || cap[1]).replace(this.rules.other.multipleSpaceGlobal, " ");
1505
- const link2 = links[linkString.toLowerCase()];
1506
- if (!link2) {
1507
- const text = cap[0].charAt(0);
1508
- return {
1509
- type: "text",
1510
- raw: text,
1511
- text
1512
- };
1513
- }
1514
- return outputLink(cap, link2, cap[0], this.lexer, this.rules);
1057
+ codespan(e) {
1058
+ let t = this.rules.inline.code.exec(e);
1059
+ if (t) {
1060
+ let n = t[2].replace(this.rules.other.newLineCharGlobal, " "), r = this.rules.other.nonSpaceChar.test(n), i = this.rules.other.startingSpaceChar.test(n) && this.rules.other.endingSpaceChar.test(n);
1061
+ return r && i && (n = n.substring(1, n.length - 1)), { type: "codespan", raw: t[0], text: n };
1515
1062
  }
1516
1063
  }
1517
- emStrong(src, maskedSrc, prevChar = "") {
1518
- let match = this.rules.inline.emStrongLDelim.exec(src);
1519
- if (!match) return;
1520
- if (match[3] && prevChar.match(this.rules.other.unicodeAlphaNumeric)) return;
1521
- const nextChar = match[1] || match[2] || "";
1522
- if (!nextChar || !prevChar || this.rules.inline.punctuation.exec(prevChar)) {
1523
- const lLength = [...match[0]].length - 1;
1524
- let rDelim, rLength, delimTotal = lLength, midDelimTotal = 0;
1525
- const endReg = match[0][0] === "*" ? this.rules.inline.emStrongRDelimAst : this.rules.inline.emStrongRDelimUnd;
1526
- endReg.lastIndex = 0;
1527
- maskedSrc = maskedSrc.slice(-1 * src.length + lLength);
1528
- while ((match = endReg.exec(maskedSrc)) != null) {
1529
- rDelim = match[1] || match[2] || match[3] || match[4] || match[5] || match[6];
1530
- if (!rDelim) continue;
1531
- rLength = [...rDelim].length;
1532
- if (match[3] || match[4]) {
1533
- delimTotal += rLength;
1064
+ br(e) {
1065
+ let t = this.rules.inline.br.exec(e);
1066
+ if (t) return { type: "br", raw: t[0] };
1067
+ }
1068
+ del(e, t, n = "") {
1069
+ let r = this.rules.inline.delLDelim.exec(e);
1070
+ if (!r) return;
1071
+ if (!(r[1] || "") || !n || this.rules.inline.punctuation.exec(n)) {
1072
+ let s = [...r[0]].length - 1, a, o, l = s, p = this.rules.inline.delRDelim;
1073
+ for (p.lastIndex = 0, t = t.slice(-1 * e.length + s); (r = p.exec(t)) != null; ) {
1074
+ if (a = r[1] || r[2] || r[3] || r[4] || r[5] || r[6], !a || (o = [...a].length, o !== s)) continue;
1075
+ if (r[3] || r[4]) {
1076
+ l += o;
1534
1077
  continue;
1535
- } else if (match[5] || match[6]) {
1536
- if (lLength % 3 && !((lLength + rLength) % 3)) {
1537
- midDelimTotal += rLength;
1538
- continue;
1539
- }
1540
1078
  }
1541
- delimTotal -= rLength;
1542
- if (delimTotal > 0) continue;
1543
- rLength = Math.min(rLength, rLength + delimTotal + midDelimTotal);
1544
- const lastCharLength = [...match[0]][0].length;
1545
- const raw = src.slice(0, lLength + match.index + lastCharLength + rLength);
1546
- if (Math.min(lLength, rLength) % 2) {
1547
- const text2 = raw.slice(1, -1);
1548
- return {
1549
- type: "em",
1550
- raw,
1551
- text: text2,
1552
- tokens: this.lexer.inlineTokens(text2)
1553
- };
1554
- }
1555
- const text = raw.slice(2, -2);
1556
- return {
1557
- type: "strong",
1558
- raw,
1559
- text,
1560
- tokens: this.lexer.inlineTokens(text)
1561
- };
1562
- }
1563
- }
1564
- }
1565
- codespan(src) {
1566
- const cap = this.rules.inline.code.exec(src);
1567
- if (cap) {
1568
- let text = cap[2].replace(this.rules.other.newLineCharGlobal, " ");
1569
- const hasNonSpaceChars = this.rules.other.nonSpaceChar.test(text);
1570
- const hasSpaceCharsOnBothEnds = this.rules.other.startingSpaceChar.test(text) && this.rules.other.endingSpaceChar.test(text);
1571
- if (hasNonSpaceChars && hasSpaceCharsOnBothEnds) {
1572
- text = text.substring(1, text.length - 1);
1079
+ if (l -= o, l > 0) continue;
1080
+ o = Math.min(o, o + l);
1081
+ let c = [...r[0]][0].length, d = e.slice(0, s + r.index + c + o), h = d.slice(s, -s);
1082
+ return { type: "del", raw: d, text: h, tokens: this.lexer.inlineTokens(h) };
1573
1083
  }
1574
- return {
1575
- type: "codespan",
1576
- raw: cap[0],
1577
- text
1578
- };
1579
1084
  }
1580
1085
  }
1581
- br(src) {
1582
- const cap = this.rules.inline.br.exec(src);
1583
- if (cap) {
1584
- return {
1585
- type: "br",
1586
- raw: cap[0]
1587
- };
1588
- }
1589
- }
1590
- del(src) {
1591
- const cap = this.rules.inline.del.exec(src);
1592
- if (cap) {
1593
- return {
1594
- type: "del",
1595
- raw: cap[0],
1596
- text: cap[2],
1597
- tokens: this.lexer.inlineTokens(cap[2])
1598
- };
1599
- }
1600
- }
1601
- autolink(src) {
1602
- const cap = this.rules.inline.autolink.exec(src);
1603
- if (cap) {
1604
- let text, href;
1605
- if (cap[2] === "@") {
1606
- text = cap[1];
1607
- href = "mailto:" + text;
1608
- } else {
1609
- text = cap[1];
1610
- href = text;
1611
- }
1612
- return {
1613
- type: "link",
1614
- raw: cap[0],
1615
- text,
1616
- href,
1617
- tokens: [
1618
- {
1619
- type: "text",
1620
- raw: text,
1621
- text
1622
- }
1623
- ]
1624
- };
1086
+ autolink(e) {
1087
+ let t = this.rules.inline.autolink.exec(e);
1088
+ if (t) {
1089
+ let n, r;
1090
+ return t[2] === "@" ? (n = t[1], r = "mailto:" + n) : (n = t[1], r = n), { type: "link", raw: t[0], text: n, href: r, tokens: [{ type: "text", raw: n, text: n }] };
1625
1091
  }
1626
1092
  }
1627
- url(src) {
1093
+ url(e) {
1628
1094
  var _a2, _b;
1629
- let cap;
1630
- if (cap = this.rules.inline.url.exec(src)) {
1631
- let text, href;
1632
- if (cap[2] === "@") {
1633
- text = cap[0];
1634
- href = "mailto:" + text;
1635
- } else {
1636
- let prevCapZero;
1637
- do {
1638
- prevCapZero = cap[0];
1639
- cap[0] = (_b = (_a2 = this.rules.inline._backpedal.exec(cap[0])) == null ? void 0 : _a2[0]) != null ? _b : "";
1640
- } while (prevCapZero !== cap[0]);
1641
- text = cap[0];
1642
- if (cap[1] === "www.") {
1643
- href = "http://" + cap[0];
1644
- } else {
1645
- href = cap[0];
1646
- }
1095
+ let t;
1096
+ if (t = this.rules.inline.url.exec(e)) {
1097
+ let n, r;
1098
+ if (t[2] === "@") n = t[0], r = "mailto:" + n;
1099
+ else {
1100
+ let i;
1101
+ do
1102
+ i = t[0], t[0] = (_b = (_a2 = this.rules.inline._backpedal.exec(t[0])) == null ? void 0 : _a2[0]) != null ? _b : "";
1103
+ while (i !== t[0]);
1104
+ n = t[0], t[1] === "www." ? r = "http://" + t[0] : r = t[0];
1647
1105
  }
1648
- return {
1649
- type: "link",
1650
- raw: cap[0],
1651
- text,
1652
- href,
1653
- tokens: [
1654
- {
1655
- type: "text",
1656
- raw: text,
1657
- text
1658
- }
1659
- ]
1660
- };
1106
+ return { type: "link", raw: t[0], text: n, href: r, tokens: [{ type: "text", raw: n, text: n }] };
1661
1107
  }
1662
1108
  }
1663
- inlineText(src) {
1664
- const cap = this.rules.inline.text.exec(src);
1665
- if (cap) {
1666
- const escaped = this.lexer.state.inRawBlock;
1667
- return {
1668
- type: "text",
1669
- raw: cap[0],
1670
- text: cap[0],
1671
- escaped
1672
- };
1109
+ inlineText(e) {
1110
+ let t = this.rules.inline.text.exec(e);
1111
+ if (t) {
1112
+ let n = this.lexer.state.inRawBlock;
1113
+ return { type: "text", raw: t[0], text: t[0], escaped: n };
1673
1114
  }
1674
1115
  }
1675
1116
  };
1676
- var _Lexer = class __Lexer {
1677
- constructor(options2) {
1117
+ var x = class u {
1118
+ constructor(e) {
1678
1119
  __publicField(this, "tokens");
1679
1120
  __publicField(this, "options");
1680
1121
  __publicField(this, "state");
1681
- __publicField(this, "tokenizer");
1682
1122
  __publicField(this, "inlineQueue");
1683
- this.tokens = [];
1684
- this.tokens.links = /* @__PURE__ */ Object.create(null);
1685
- this.options = options2 || _defaults;
1686
- this.options.tokenizer = this.options.tokenizer || new _Tokenizer();
1687
- this.tokenizer = this.options.tokenizer;
1688
- this.tokenizer.options = this.options;
1689
- this.tokenizer.lexer = this;
1690
- this.inlineQueue = [];
1691
- this.state = {
1692
- inLink: false,
1693
- inRawBlock: false,
1694
- top: true
1695
- };
1696
- const rules = {
1697
- other,
1698
- block: block.normal,
1699
- inline: inline.normal
1700
- };
1701
- if (this.options.pedantic) {
1702
- rules.block = block.pedantic;
1703
- rules.inline = inline.pedantic;
1704
- } else if (this.options.gfm) {
1705
- rules.block = block.gfm;
1706
- if (this.options.breaks) {
1707
- rules.inline = inline.breaks;
1708
- } else {
1709
- rules.inline = inline.gfm;
1710
- }
1711
- }
1712
- this.tokenizer.rules = rules;
1123
+ __publicField(this, "tokenizer");
1124
+ this.tokens = [], this.tokens.links = /* @__PURE__ */ Object.create(null), this.options = e || T, this.options.tokenizer = this.options.tokenizer || new w(), this.tokenizer = this.options.tokenizer, this.tokenizer.options = this.options, this.tokenizer.lexer = this, this.inlineQueue = [], this.state = { inLink: false, inRawBlock: false, top: true };
1125
+ let t = { other: m, block: C.normal, inline: z.normal };
1126
+ this.options.pedantic ? (t.block = C.pedantic, t.inline = z.pedantic) : this.options.gfm && (t.block = C.gfm, this.options.breaks ? t.inline = z.breaks : t.inline = z.gfm), this.tokenizer.rules = t;
1713
1127
  }
1714
- /**
1715
- * Expose Rules
1716
- */
1717
1128
  static get rules() {
1718
- return {
1719
- block,
1720
- inline
1721
- };
1129
+ return { block: C, inline: z };
1722
1130
  }
1723
- /**
1724
- * Static Lex Method
1725
- */
1726
- static lex(src, options2) {
1727
- const lexer2 = new __Lexer(options2);
1728
- return lexer2.lex(src);
1131
+ static lex(e, t) {
1132
+ return new u(t).lex(e);
1729
1133
  }
1730
- /**
1731
- * Static Lex Inline Method
1732
- */
1733
- static lexInline(src, options2) {
1734
- const lexer2 = new __Lexer(options2);
1735
- return lexer2.inlineTokens(src);
1134
+ static lexInline(e, t) {
1135
+ return new u(t).inlineTokens(e);
1736
1136
  }
1737
- /**
1738
- * Preprocessing
1739
- */
1740
- lex(src) {
1741
- src = src.replace(other.carriageReturn, "\n");
1742
- this.blockTokens(src, this.tokens);
1743
- for (let i = 0; i < this.inlineQueue.length; i++) {
1744
- const next = this.inlineQueue[i];
1745
- this.inlineTokens(next.src, next.tokens);
1137
+ lex(e) {
1138
+ e = e.replace(m.carriageReturn, `
1139
+ `), this.blockTokens(e, this.tokens);
1140
+ for (let t = 0; t < this.inlineQueue.length; t++) {
1141
+ let n = this.inlineQueue[t];
1142
+ this.inlineTokens(n.src, n.tokens);
1746
1143
  }
1747
- this.inlineQueue = [];
1748
- return this.tokens;
1144
+ return this.inlineQueue = [], this.tokens;
1749
1145
  }
1750
- blockTokens(src, tokens = [], lastParagraphClipped = false) {
1146
+ blockTokens(e, t = [], n = false) {
1751
1147
  var _a2, _b, _c;
1752
- if (this.options.pedantic) {
1753
- src = src.replace(other.tabCharGlobal, " ").replace(other.spaceLine, "");
1754
- }
1755
- while (src) {
1756
- let token;
1757
- if ((_b = (_a2 = this.options.extensions) == null ? void 0 : _a2.block) == null ? void 0 : _b.some((extTokenizer) => {
1758
- if (token = extTokenizer.call({ lexer: this }, src, tokens)) {
1759
- src = src.substring(token.raw.length);
1760
- tokens.push(token);
1761
- return true;
1762
- }
1763
- return false;
1764
- })) {
1765
- continue;
1766
- }
1767
- if (token = this.tokenizer.space(src)) {
1768
- src = src.substring(token.raw.length);
1769
- const lastToken = tokens.at(-1);
1770
- if (token.raw.length === 1 && lastToken !== void 0) {
1771
- lastToken.raw += "\n";
1772
- } else {
1773
- tokens.push(token);
1774
- }
1148
+ for (this.options.pedantic && (e = e.replace(m.tabCharGlobal, " ").replace(m.spaceLine, "")); e; ) {
1149
+ let r;
1150
+ if ((_b = (_a2 = this.options.extensions) == null ? void 0 : _a2.block) == null ? void 0 : _b.some((s) => (r = s.call({ lexer: this }, e, t)) ? (e = e.substring(r.raw.length), t.push(r), true) : false)) continue;
1151
+ if (r = this.tokenizer.space(e)) {
1152
+ e = e.substring(r.raw.length);
1153
+ let s = t.at(-1);
1154
+ r.raw.length === 1 && s !== void 0 ? s.raw += `
1155
+ ` : t.push(r);
1775
1156
  continue;
1776
1157
  }
1777
- if (token = this.tokenizer.code(src)) {
1778
- src = src.substring(token.raw.length);
1779
- const lastToken = tokens.at(-1);
1780
- if ((lastToken == null ? void 0 : lastToken.type) === "paragraph" || (lastToken == null ? void 0 : lastToken.type) === "text") {
1781
- lastToken.raw += "\n" + token.raw;
1782
- lastToken.text += "\n" + token.text;
1783
- this.inlineQueue.at(-1).src = lastToken.text;
1784
- } else {
1785
- tokens.push(token);
1786
- }
1158
+ if (r = this.tokenizer.code(e)) {
1159
+ e = e.substring(r.raw.length);
1160
+ let s = t.at(-1);
1161
+ (s == null ? void 0 : s.type) === "paragraph" || (s == null ? void 0 : s.type) === "text" ? (s.raw += (s.raw.endsWith(`
1162
+ `) ? "" : `
1163
+ `) + r.raw, s.text += `
1164
+ ` + r.text, this.inlineQueue.at(-1).src = s.text) : t.push(r);
1787
1165
  continue;
1788
1166
  }
1789
- if (token = this.tokenizer.fences(src)) {
1790
- src = src.substring(token.raw.length);
1791
- tokens.push(token);
1167
+ if (r = this.tokenizer.fences(e)) {
1168
+ e = e.substring(r.raw.length), t.push(r);
1792
1169
  continue;
1793
1170
  }
1794
- if (token = this.tokenizer.heading(src)) {
1795
- src = src.substring(token.raw.length);
1796
- tokens.push(token);
1171
+ if (r = this.tokenizer.heading(e)) {
1172
+ e = e.substring(r.raw.length), t.push(r);
1797
1173
  continue;
1798
1174
  }
1799
- if (token = this.tokenizer.hr(src)) {
1800
- src = src.substring(token.raw.length);
1801
- tokens.push(token);
1175
+ if (r = this.tokenizer.hr(e)) {
1176
+ e = e.substring(r.raw.length), t.push(r);
1802
1177
  continue;
1803
1178
  }
1804
- if (token = this.tokenizer.blockquote(src)) {
1805
- src = src.substring(token.raw.length);
1806
- tokens.push(token);
1179
+ if (r = this.tokenizer.blockquote(e)) {
1180
+ e = e.substring(r.raw.length), t.push(r);
1807
1181
  continue;
1808
1182
  }
1809
- if (token = this.tokenizer.list(src)) {
1810
- src = src.substring(token.raw.length);
1811
- tokens.push(token);
1183
+ if (r = this.tokenizer.list(e)) {
1184
+ e = e.substring(r.raw.length), t.push(r);
1812
1185
  continue;
1813
1186
  }
1814
- if (token = this.tokenizer.html(src)) {
1815
- src = src.substring(token.raw.length);
1816
- tokens.push(token);
1187
+ if (r = this.tokenizer.html(e)) {
1188
+ e = e.substring(r.raw.length), t.push(r);
1817
1189
  continue;
1818
1190
  }
1819
- if (token = this.tokenizer.def(src)) {
1820
- src = src.substring(token.raw.length);
1821
- const lastToken = tokens.at(-1);
1822
- if ((lastToken == null ? void 0 : lastToken.type) === "paragraph" || (lastToken == null ? void 0 : lastToken.type) === "text") {
1823
- lastToken.raw += "\n" + token.raw;
1824
- lastToken.text += "\n" + token.raw;
1825
- this.inlineQueue.at(-1).src = lastToken.text;
1826
- } else if (!this.tokens.links[token.tag]) {
1827
- this.tokens.links[token.tag] = {
1828
- href: token.href,
1829
- title: token.title
1830
- };
1831
- }
1191
+ if (r = this.tokenizer.def(e)) {
1192
+ e = e.substring(r.raw.length);
1193
+ let s = t.at(-1);
1194
+ (s == null ? void 0 : s.type) === "paragraph" || (s == null ? void 0 : s.type) === "text" ? (s.raw += (s.raw.endsWith(`
1195
+ `) ? "" : `
1196
+ `) + r.raw, s.text += `
1197
+ ` + r.raw, this.inlineQueue.at(-1).src = s.text) : this.tokens.links[r.tag] || (this.tokens.links[r.tag] = { href: r.href, title: r.title }, t.push(r));
1832
1198
  continue;
1833
1199
  }
1834
- if (token = this.tokenizer.table(src)) {
1835
- src = src.substring(token.raw.length);
1836
- tokens.push(token);
1200
+ if (r = this.tokenizer.table(e)) {
1201
+ e = e.substring(r.raw.length), t.push(r);
1837
1202
  continue;
1838
1203
  }
1839
- if (token = this.tokenizer.lheading(src)) {
1840
- src = src.substring(token.raw.length);
1841
- tokens.push(token);
1204
+ if (r = this.tokenizer.lheading(e)) {
1205
+ e = e.substring(r.raw.length), t.push(r);
1842
1206
  continue;
1843
1207
  }
1844
- let cutSrc = src;
1208
+ let i = e;
1845
1209
  if ((_c = this.options.extensions) == null ? void 0 : _c.startBlock) {
1846
- let startIndex = Infinity;
1847
- const tempSrc = src.slice(1);
1848
- let tempStart;
1849
- this.options.extensions.startBlock.forEach((getStartIndex) => {
1850
- tempStart = getStartIndex.call({ lexer: this }, tempSrc);
1851
- if (typeof tempStart === "number" && tempStart >= 0) {
1852
- startIndex = Math.min(startIndex, tempStart);
1853
- }
1854
- });
1855
- if (startIndex < Infinity && startIndex >= 0) {
1856
- cutSrc = src.substring(0, startIndex + 1);
1857
- }
1858
- }
1859
- if (this.state.top && (token = this.tokenizer.paragraph(cutSrc))) {
1860
- const lastToken = tokens.at(-1);
1861
- if (lastParagraphClipped && (lastToken == null ? void 0 : lastToken.type) === "paragraph") {
1862
- lastToken.raw += "\n" + token.raw;
1863
- lastToken.text += "\n" + token.text;
1864
- this.inlineQueue.pop();
1865
- this.inlineQueue.at(-1).src = lastToken.text;
1866
- } else {
1867
- tokens.push(token);
1868
- }
1869
- lastParagraphClipped = cutSrc.length !== src.length;
1870
- src = src.substring(token.raw.length);
1210
+ let s = 1 / 0, a = e.slice(1), o;
1211
+ this.options.extensions.startBlock.forEach((l) => {
1212
+ o = l.call({ lexer: this }, a), typeof o == "number" && o >= 0 && (s = Math.min(s, o));
1213
+ }), s < 1 / 0 && s >= 0 && (i = e.substring(0, s + 1));
1214
+ }
1215
+ if (this.state.top && (r = this.tokenizer.paragraph(i))) {
1216
+ let s = t.at(-1);
1217
+ n && (s == null ? void 0 : s.type) === "paragraph" ? (s.raw += (s.raw.endsWith(`
1218
+ `) ? "" : `
1219
+ `) + r.raw, s.text += `
1220
+ ` + r.text, this.inlineQueue.pop(), this.inlineQueue.at(-1).src = s.text) : t.push(r), n = i.length !== e.length, e = e.substring(r.raw.length);
1871
1221
  continue;
1872
1222
  }
1873
- if (token = this.tokenizer.text(src)) {
1874
- src = src.substring(token.raw.length);
1875
- const lastToken = tokens.at(-1);
1876
- if ((lastToken == null ? void 0 : lastToken.type) === "text") {
1877
- lastToken.raw += "\n" + token.raw;
1878
- lastToken.text += "\n" + token.text;
1879
- this.inlineQueue.pop();
1880
- this.inlineQueue.at(-1).src = lastToken.text;
1881
- } else {
1882
- tokens.push(token);
1883
- }
1223
+ if (r = this.tokenizer.text(e)) {
1224
+ e = e.substring(r.raw.length);
1225
+ let s = t.at(-1);
1226
+ (s == null ? void 0 : s.type) === "text" ? (s.raw += (s.raw.endsWith(`
1227
+ `) ? "" : `
1228
+ `) + r.raw, s.text += `
1229
+ ` + r.text, this.inlineQueue.pop(), this.inlineQueue.at(-1).src = s.text) : t.push(r);
1884
1230
  continue;
1885
1231
  }
1886
- if (src) {
1887
- const errMsg = "Infinite loop on byte: " + src.charCodeAt(0);
1232
+ if (e) {
1233
+ let s = "Infinite loop on byte: " + e.charCodeAt(0);
1888
1234
  if (this.options.silent) {
1889
- console.error(errMsg);
1235
+ console.error(s);
1890
1236
  break;
1891
- } else {
1892
- throw new Error(errMsg);
1893
- }
1237
+ } else throw new Error(s);
1894
1238
  }
1895
1239
  }
1896
- this.state.top = true;
1897
- return tokens;
1240
+ return this.state.top = true, t;
1898
1241
  }
1899
- inline(src, tokens = []) {
1900
- this.inlineQueue.push({ src, tokens });
1901
- return tokens;
1242
+ inline(e, t = []) {
1243
+ return this.inlineQueue.push({ src: e, tokens: t }), t;
1902
1244
  }
1903
- /**
1904
- * Lexing/Compiling
1905
- */
1906
- inlineTokens(src, tokens = []) {
1907
- var _a2, _b, _c;
1908
- let maskedSrc = src;
1909
- let match = null;
1245
+ inlineTokens(e, t = []) {
1246
+ var _a2, _b, _c, _d, _e2, _f;
1247
+ let n = e, r = null;
1910
1248
  if (this.tokens.links) {
1911
- const links = Object.keys(this.tokens.links);
1912
- if (links.length > 0) {
1913
- while ((match = this.tokenizer.rules.inline.reflinkSearch.exec(maskedSrc)) != null) {
1914
- if (links.includes(match[0].slice(match[0].lastIndexOf("[") + 1, -1))) {
1915
- maskedSrc = maskedSrc.slice(0, match.index) + "[" + "a".repeat(match[0].length - 2) + "]" + maskedSrc.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex);
1916
- }
1917
- }
1918
- }
1919
- }
1920
- while ((match = this.tokenizer.rules.inline.anyPunctuation.exec(maskedSrc)) != null) {
1921
- maskedSrc = maskedSrc.slice(0, match.index) + "++" + maskedSrc.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);
1922
- }
1923
- while ((match = this.tokenizer.rules.inline.blockSkip.exec(maskedSrc)) != null) {
1924
- maskedSrc = maskedSrc.slice(0, match.index) + "[" + "a".repeat(match[0].length - 2) + "]" + maskedSrc.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);
1925
- }
1926
- let keepPrevChar = false;
1927
- let prevChar = "";
1928
- while (src) {
1929
- if (!keepPrevChar) {
1930
- prevChar = "";
1931
- }
1932
- keepPrevChar = false;
1933
- let token;
1934
- if ((_b = (_a2 = this.options.extensions) == null ? void 0 : _a2.inline) == null ? void 0 : _b.some((extTokenizer) => {
1935
- if (token = extTokenizer.call({ lexer: this }, src, tokens)) {
1936
- src = src.substring(token.raw.length);
1937
- tokens.push(token);
1938
- return true;
1939
- }
1940
- return false;
1941
- })) {
1942
- continue;
1943
- }
1944
- if (token = this.tokenizer.escape(src)) {
1945
- src = src.substring(token.raw.length);
1946
- tokens.push(token);
1249
+ let o = Object.keys(this.tokens.links);
1250
+ if (o.length > 0) for (; (r = this.tokenizer.rules.inline.reflinkSearch.exec(n)) != null; ) o.includes(r[0].slice(r[0].lastIndexOf("[") + 1, -1)) && (n = n.slice(0, r.index) + "[" + "a".repeat(r[0].length - 2) + "]" + n.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex));
1251
+ }
1252
+ for (; (r = this.tokenizer.rules.inline.anyPunctuation.exec(n)) != null; ) n = n.slice(0, r.index) + "++" + n.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);
1253
+ let i;
1254
+ for (; (r = this.tokenizer.rules.inline.blockSkip.exec(n)) != null; ) i = r[2] ? r[2].length : 0, n = n.slice(0, r.index + i) + "[" + "a".repeat(r[0].length - i - 2) + "]" + n.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);
1255
+ n = (_c = (_b = (_a2 = this.options.hooks) == null ? void 0 : _a2.emStrongMask) == null ? void 0 : _b.call({ lexer: this }, n)) != null ? _c : n;
1256
+ let s = false, a = "";
1257
+ for (; e; ) {
1258
+ s || (a = ""), s = false;
1259
+ let o;
1260
+ if ((_e2 = (_d = this.options.extensions) == null ? void 0 : _d.inline) == null ? void 0 : _e2.some((p) => (o = p.call({ lexer: this }, e, t)) ? (e = e.substring(o.raw.length), t.push(o), true) : false)) continue;
1261
+ if (o = this.tokenizer.escape(e)) {
1262
+ e = e.substring(o.raw.length), t.push(o);
1947
1263
  continue;
1948
1264
  }
1949
- if (token = this.tokenizer.tag(src)) {
1950
- src = src.substring(token.raw.length);
1951
- tokens.push(token);
1265
+ if (o = this.tokenizer.tag(e)) {
1266
+ e = e.substring(o.raw.length), t.push(o);
1952
1267
  continue;
1953
1268
  }
1954
- if (token = this.tokenizer.link(src)) {
1955
- src = src.substring(token.raw.length);
1956
- tokens.push(token);
1269
+ if (o = this.tokenizer.link(e)) {
1270
+ e = e.substring(o.raw.length), t.push(o);
1957
1271
  continue;
1958
1272
  }
1959
- if (token = this.tokenizer.reflink(src, this.tokens.links)) {
1960
- src = src.substring(token.raw.length);
1961
- const lastToken = tokens.at(-1);
1962
- if (token.type === "text" && (lastToken == null ? void 0 : lastToken.type) === "text") {
1963
- lastToken.raw += token.raw;
1964
- lastToken.text += token.text;
1965
- } else {
1966
- tokens.push(token);
1967
- }
1273
+ if (o = this.tokenizer.reflink(e, this.tokens.links)) {
1274
+ e = e.substring(o.raw.length);
1275
+ let p = t.at(-1);
1276
+ o.type === "text" && (p == null ? void 0 : p.type) === "text" ? (p.raw += o.raw, p.text += o.text) : t.push(o);
1968
1277
  continue;
1969
1278
  }
1970
- if (token = this.tokenizer.emStrong(src, maskedSrc, prevChar)) {
1971
- src = src.substring(token.raw.length);
1972
- tokens.push(token);
1279
+ if (o = this.tokenizer.emStrong(e, n, a)) {
1280
+ e = e.substring(o.raw.length), t.push(o);
1973
1281
  continue;
1974
1282
  }
1975
- if (token = this.tokenizer.codespan(src)) {
1976
- src = src.substring(token.raw.length);
1977
- tokens.push(token);
1283
+ if (o = this.tokenizer.codespan(e)) {
1284
+ e = e.substring(o.raw.length), t.push(o);
1978
1285
  continue;
1979
1286
  }
1980
- if (token = this.tokenizer.br(src)) {
1981
- src = src.substring(token.raw.length);
1982
- tokens.push(token);
1287
+ if (o = this.tokenizer.br(e)) {
1288
+ e = e.substring(o.raw.length), t.push(o);
1983
1289
  continue;
1984
1290
  }
1985
- if (token = this.tokenizer.del(src)) {
1986
- src = src.substring(token.raw.length);
1987
- tokens.push(token);
1291
+ if (o = this.tokenizer.del(e, n, a)) {
1292
+ e = e.substring(o.raw.length), t.push(o);
1988
1293
  continue;
1989
1294
  }
1990
- if (token = this.tokenizer.autolink(src)) {
1991
- src = src.substring(token.raw.length);
1992
- tokens.push(token);
1295
+ if (o = this.tokenizer.autolink(e)) {
1296
+ e = e.substring(o.raw.length), t.push(o);
1993
1297
  continue;
1994
1298
  }
1995
- if (!this.state.inLink && (token = this.tokenizer.url(src))) {
1996
- src = src.substring(token.raw.length);
1997
- tokens.push(token);
1299
+ if (!this.state.inLink && (o = this.tokenizer.url(e))) {
1300
+ e = e.substring(o.raw.length), t.push(o);
1998
1301
  continue;
1999
1302
  }
2000
- let cutSrc = src;
2001
- if ((_c = this.options.extensions) == null ? void 0 : _c.startInline) {
2002
- let startIndex = Infinity;
2003
- const tempSrc = src.slice(1);
2004
- let tempStart;
2005
- this.options.extensions.startInline.forEach((getStartIndex) => {
2006
- tempStart = getStartIndex.call({ lexer: this }, tempSrc);
2007
- if (typeof tempStart === "number" && tempStart >= 0) {
2008
- startIndex = Math.min(startIndex, tempStart);
2009
- }
2010
- });
2011
- if (startIndex < Infinity && startIndex >= 0) {
2012
- cutSrc = src.substring(0, startIndex + 1);
2013
- }
2014
- }
2015
- if (token = this.tokenizer.inlineText(cutSrc)) {
2016
- src = src.substring(token.raw.length);
2017
- if (token.raw.slice(-1) !== "_") {
2018
- prevChar = token.raw.slice(-1);
2019
- }
2020
- keepPrevChar = true;
2021
- const lastToken = tokens.at(-1);
2022
- if ((lastToken == null ? void 0 : lastToken.type) === "text") {
2023
- lastToken.raw += token.raw;
2024
- lastToken.text += token.text;
2025
- } else {
2026
- tokens.push(token);
2027
- }
1303
+ let l = e;
1304
+ if ((_f = this.options.extensions) == null ? void 0 : _f.startInline) {
1305
+ let p = 1 / 0, c = e.slice(1), d;
1306
+ this.options.extensions.startInline.forEach((h) => {
1307
+ d = h.call({ lexer: this }, c), typeof d == "number" && d >= 0 && (p = Math.min(p, d));
1308
+ }), p < 1 / 0 && p >= 0 && (l = e.substring(0, p + 1));
1309
+ }
1310
+ if (o = this.tokenizer.inlineText(l)) {
1311
+ e = e.substring(o.raw.length), o.raw.slice(-1) !== "_" && (a = o.raw.slice(-1)), s = true;
1312
+ let p = t.at(-1);
1313
+ (p == null ? void 0 : p.type) === "text" ? (p.raw += o.raw, p.text += o.text) : t.push(o);
2028
1314
  continue;
2029
1315
  }
2030
- if (src) {
2031
- const errMsg = "Infinite loop on byte: " + src.charCodeAt(0);
1316
+ if (e) {
1317
+ let p = "Infinite loop on byte: " + e.charCodeAt(0);
2032
1318
  if (this.options.silent) {
2033
- console.error(errMsg);
1319
+ console.error(p);
2034
1320
  break;
2035
- } else {
2036
- throw new Error(errMsg);
2037
- }
1321
+ } else throw new Error(p);
2038
1322
  }
2039
1323
  }
2040
- return tokens;
1324
+ return t;
2041
1325
  }
2042
1326
  };
2043
- var _Renderer = class {
2044
- // set by the parser
2045
- constructor(options2) {
1327
+ var y = class {
1328
+ constructor(e) {
2046
1329
  __publicField(this, "options");
2047
1330
  __publicField(this, "parser");
2048
- this.options = options2 || _defaults;
1331
+ this.options = e || T;
2049
1332
  }
2050
- space(token) {
1333
+ space(e) {
2051
1334
  return "";
2052
1335
  }
2053
- code({ text, lang, escaped }) {
1336
+ code({ text: e, lang: t, escaped: n }) {
2054
1337
  var _a2;
2055
- const langString = (_a2 = (lang || "").match(other.notSpaceStart)) == null ? void 0 : _a2[0];
2056
- const code = text.replace(other.endingNewline, "") + "\n";
2057
- if (!langString) {
2058
- return "<pre><code>" + (escaped ? code : escape2(code, true)) + "</code></pre>\n";
2059
- }
2060
- return '<pre><code class="language-' + escape2(langString) + '">' + (escaped ? code : escape2(code, true)) + "</code></pre>\n";
1338
+ let r = (_a2 = (t || "").match(m.notSpaceStart)) == null ? void 0 : _a2[0], i = e.replace(m.endingNewline, "") + `
1339
+ `;
1340
+ return r ? '<pre><code class="language-' + O(r) + '">' + (n ? i : O(i, true)) + `</code></pre>
1341
+ ` : "<pre><code>" + (n ? i : O(i, true)) + `</code></pre>
1342
+ `;
2061
1343
  }
2062
- blockquote({ tokens }) {
2063
- const body = this.parser.parse(tokens);
1344
+ blockquote({ tokens: e }) {
2064
1345
  return `<blockquote>
2065
- ${body}</blockquote>
1346
+ ${this.parser.parse(e)}</blockquote>
2066
1347
  `;
2067
1348
  }
2068
- html({ text }) {
2069
- return text;
1349
+ html({ text: e }) {
1350
+ return e;
1351
+ }
1352
+ def(e) {
1353
+ return "";
2070
1354
  }
2071
- heading({ tokens, depth }) {
2072
- return `<h${depth}>${this.parser.parseInline(tokens)}</h${depth}>
1355
+ heading({ tokens: e, depth: t }) {
1356
+ return `<h${t}>${this.parser.parseInline(e)}</h${t}>
2073
1357
  `;
2074
1358
  }
2075
- hr(token) {
2076
- return "<hr>\n";
1359
+ hr(e) {
1360
+ return `<hr>
1361
+ `;
2077
1362
  }
2078
- list(token) {
2079
- const ordered = token.ordered;
2080
- const start = token.start;
2081
- let body = "";
2082
- for (let j = 0; j < token.items.length; j++) {
2083
- const item = token.items[j];
2084
- body += this.listitem(item);
1363
+ list(e) {
1364
+ let t = e.ordered, n = e.start, r = "";
1365
+ for (let a = 0; a < e.items.length; a++) {
1366
+ let o = e.items[a];
1367
+ r += this.listitem(o);
2085
1368
  }
2086
- const type = ordered ? "ol" : "ul";
2087
- const startAttr = ordered && start !== 1 ? ' start="' + start + '"' : "";
2088
- return "<" + type + startAttr + ">\n" + body + "</" + type + ">\n";
1369
+ let i = t ? "ol" : "ul", s = t && n !== 1 ? ' start="' + n + '"' : "";
1370
+ return "<" + i + s + `>
1371
+ ` + r + "</" + i + `>
1372
+ `;
2089
1373
  }
2090
- listitem(item) {
2091
- var _a2;
2092
- let itemBody = "";
2093
- if (item.task) {
2094
- const checkbox = this.checkbox({ checked: !!item.checked });
2095
- if (item.loose) {
2096
- if (((_a2 = item.tokens[0]) == null ? void 0 : _a2.type) === "paragraph") {
2097
- item.tokens[0].text = checkbox + " " + item.tokens[0].text;
2098
- if (item.tokens[0].tokens && item.tokens[0].tokens.length > 0 && item.tokens[0].tokens[0].type === "text") {
2099
- item.tokens[0].tokens[0].text = checkbox + " " + escape2(item.tokens[0].tokens[0].text);
2100
- item.tokens[0].tokens[0].escaped = true;
2101
- }
2102
- } else {
2103
- item.tokens.unshift({
2104
- type: "text",
2105
- raw: checkbox + " ",
2106
- text: checkbox + " ",
2107
- escaped: true
2108
- });
2109
- }
2110
- } else {
2111
- itemBody += checkbox + " ";
2112
- }
2113
- }
2114
- itemBody += this.parser.parse(item.tokens, !!item.loose);
2115
- return `<li>${itemBody}</li>
1374
+ listitem(e) {
1375
+ return `<li>${this.parser.parse(e.tokens)}</li>
2116
1376
  `;
2117
1377
  }
2118
- checkbox({ checked }) {
2119
- return "<input " + (checked ? 'checked="" ' : "") + 'disabled="" type="checkbox">';
1378
+ checkbox({ checked: e }) {
1379
+ return "<input " + (e ? 'checked="" ' : "") + 'disabled="" type="checkbox"> ';
2120
1380
  }
2121
- paragraph({ tokens }) {
2122
- return `<p>${this.parser.parseInline(tokens)}</p>
1381
+ paragraph({ tokens: e }) {
1382
+ return `<p>${this.parser.parseInline(e)}</p>
2123
1383
  `;
2124
1384
  }
2125
- table(token) {
2126
- let header = "";
2127
- let cell = "";
2128
- for (let j = 0; j < token.header.length; j++) {
2129
- cell += this.tablecell(token.header[j]);
2130
- }
2131
- header += this.tablerow({ text: cell });
2132
- let body = "";
2133
- for (let j = 0; j < token.rows.length; j++) {
2134
- const row = token.rows[j];
2135
- cell = "";
2136
- for (let k = 0; k < row.length; k++) {
2137
- cell += this.tablecell(row[k]);
2138
- }
2139
- body += this.tablerow({ text: cell });
2140
- }
2141
- if (body) body = `<tbody>${body}</tbody>`;
2142
- return "<table>\n<thead>\n" + header + "</thead>\n" + body + "</table>\n";
1385
+ table(e) {
1386
+ let t = "", n = "";
1387
+ for (let i = 0; i < e.header.length; i++) n += this.tablecell(e.header[i]);
1388
+ t += this.tablerow({ text: n });
1389
+ let r = "";
1390
+ for (let i = 0; i < e.rows.length; i++) {
1391
+ let s = e.rows[i];
1392
+ n = "";
1393
+ for (let a = 0; a < s.length; a++) n += this.tablecell(s[a]);
1394
+ r += this.tablerow({ text: n });
1395
+ }
1396
+ return r && (r = `<tbody>${r}</tbody>`), `<table>
1397
+ <thead>
1398
+ ` + t + `</thead>
1399
+ ` + r + `</table>
1400
+ `;
2143
1401
  }
2144
- tablerow({ text }) {
1402
+ tablerow({ text: e }) {
2145
1403
  return `<tr>
2146
- ${text}</tr>
1404
+ ${e}</tr>
2147
1405
  `;
2148
1406
  }
2149
- tablecell(token) {
2150
- const content = this.parser.parseInline(token.tokens);
2151
- const type = token.header ? "th" : "td";
2152
- const tag2 = token.align ? `<${type} align="${token.align}">` : `<${type}>`;
2153
- return tag2 + content + `</${type}>
1407
+ tablecell(e) {
1408
+ let t = this.parser.parseInline(e.tokens), n = e.header ? "th" : "td";
1409
+ return (e.align ? `<${n} align="${e.align}">` : `<${n}>`) + t + `</${n}>
2154
1410
  `;
2155
1411
  }
2156
- /**
2157
- * span level renderer
2158
- */
2159
- strong({ tokens }) {
2160
- return `<strong>${this.parser.parseInline(tokens)}</strong>`;
1412
+ strong({ tokens: e }) {
1413
+ return `<strong>${this.parser.parseInline(e)}</strong>`;
2161
1414
  }
2162
- em({ tokens }) {
2163
- return `<em>${this.parser.parseInline(tokens)}</em>`;
1415
+ em({ tokens: e }) {
1416
+ return `<em>${this.parser.parseInline(e)}</em>`;
2164
1417
  }
2165
- codespan({ text }) {
2166
- return `<code>${escape2(text, true)}</code>`;
1418
+ codespan({ text: e }) {
1419
+ return `<code>${O(e, true)}</code>`;
2167
1420
  }
2168
- br(token) {
1421
+ br(e) {
2169
1422
  return "<br>";
2170
1423
  }
2171
- del({ tokens }) {
2172
- return `<del>${this.parser.parseInline(tokens)}</del>`;
1424
+ del({ tokens: e }) {
1425
+ return `<del>${this.parser.parseInline(e)}</del>`;
2173
1426
  }
2174
- link({ href, title, tokens }) {
2175
- const text = this.parser.parseInline(tokens);
2176
- const cleanHref = cleanUrl(href);
2177
- if (cleanHref === null) {
2178
- return text;
2179
- }
2180
- href = cleanHref;
2181
- let out = '<a href="' + href + '"';
2182
- if (title) {
2183
- out += ' title="' + escape2(title) + '"';
2184
- }
2185
- out += ">" + text + "</a>";
2186
- return out;
1427
+ link({ href: e, title: t, tokens: n }) {
1428
+ let r = this.parser.parseInline(n), i = X(e);
1429
+ if (i === null) return r;
1430
+ e = i;
1431
+ let s = '<a href="' + e + '"';
1432
+ return t && (s += ' title="' + O(t) + '"'), s += ">" + r + "</a>", s;
2187
1433
  }
2188
- image({ href, title, text, tokens }) {
2189
- if (tokens) {
2190
- text = this.parser.parseInline(tokens, this.parser.textRenderer);
2191
- }
2192
- const cleanHref = cleanUrl(href);
2193
- if (cleanHref === null) {
2194
- return escape2(text);
2195
- }
2196
- href = cleanHref;
2197
- let out = `<img src="${href}" alt="${text}"`;
2198
- if (title) {
2199
- out += ` title="${escape2(title)}"`;
2200
- }
2201
- out += ">";
2202
- return out;
1434
+ image({ href: e, title: t, text: n, tokens: r }) {
1435
+ r && (n = this.parser.parseInline(r, this.parser.textRenderer));
1436
+ let i = X(e);
1437
+ if (i === null) return O(n);
1438
+ e = i;
1439
+ let s = `<img src="${e}" alt="${O(n)}"`;
1440
+ return t && (s += ` title="${O(t)}"`), s += ">", s;
2203
1441
  }
2204
- text(token) {
2205
- return "tokens" in token && token.tokens ? this.parser.parseInline(token.tokens) : "escaped" in token && token.escaped ? token.text : escape2(token.text);
1442
+ text(e) {
1443
+ return "tokens" in e && e.tokens ? this.parser.parseInline(e.tokens) : "escaped" in e && e.escaped ? e.text : O(e.text);
2206
1444
  }
2207
1445
  };
2208
- var _TextRenderer = class {
2209
- // no need for block level renderers
2210
- strong({ text }) {
2211
- return text;
1446
+ var $ = class {
1447
+ strong({ text: e }) {
1448
+ return e;
2212
1449
  }
2213
- em({ text }) {
2214
- return text;
1450
+ em({ text: e }) {
1451
+ return e;
2215
1452
  }
2216
- codespan({ text }) {
2217
- return text;
1453
+ codespan({ text: e }) {
1454
+ return e;
2218
1455
  }
2219
- del({ text }) {
2220
- return text;
1456
+ del({ text: e }) {
1457
+ return e;
2221
1458
  }
2222
- html({ text }) {
2223
- return text;
1459
+ html({ text: e }) {
1460
+ return e;
2224
1461
  }
2225
- text({ text }) {
2226
- return text;
1462
+ text({ text: e }) {
1463
+ return e;
2227
1464
  }
2228
- link({ text }) {
2229
- return "" + text;
1465
+ link({ text: e }) {
1466
+ return "" + e;
2230
1467
  }
2231
- image({ text }) {
2232
- return "" + text;
1468
+ image({ text: e }) {
1469
+ return "" + e;
2233
1470
  }
2234
1471
  br() {
2235
1472
  return "";
2236
1473
  }
1474
+ checkbox({ raw: e }) {
1475
+ return e;
1476
+ }
2237
1477
  };
2238
- var _Parser = class __Parser {
2239
- constructor(options2) {
1478
+ var b = class u2 {
1479
+ constructor(e) {
2240
1480
  __publicField(this, "options");
2241
1481
  __publicField(this, "renderer");
2242
1482
  __publicField(this, "textRenderer");
2243
- this.options = options2 || _defaults;
2244
- this.options.renderer = this.options.renderer || new _Renderer();
2245
- this.renderer = this.options.renderer;
2246
- this.renderer.options = this.options;
2247
- this.renderer.parser = this;
2248
- this.textRenderer = new _TextRenderer();
1483
+ this.options = e || T, this.options.renderer = this.options.renderer || new y(), this.renderer = this.options.renderer, this.renderer.options = this.options, this.renderer.parser = this, this.textRenderer = new $();
2249
1484
  }
2250
- /**
2251
- * Static Parse Method
2252
- */
2253
- static parse(tokens, options2) {
2254
- const parser2 = new __Parser(options2);
2255
- return parser2.parse(tokens);
1485
+ static parse(e, t) {
1486
+ return new u2(t).parse(e);
2256
1487
  }
2257
- /**
2258
- * Static Parse Inline Method
2259
- */
2260
- static parseInline(tokens, options2) {
2261
- const parser2 = new __Parser(options2);
2262
- return parser2.parseInline(tokens);
1488
+ static parseInline(e, t) {
1489
+ return new u2(t).parseInline(e);
2263
1490
  }
2264
- /**
2265
- * Parse Loop
2266
- */
2267
- parse(tokens, top = true) {
1491
+ parse(e) {
2268
1492
  var _a2, _b;
2269
- let out = "";
2270
- for (let i = 0; i < tokens.length; i++) {
2271
- const anyToken = tokens[i];
2272
- if ((_b = (_a2 = this.options.extensions) == null ? void 0 : _a2.renderers) == null ? void 0 : _b[anyToken.type]) {
2273
- const genericToken = anyToken;
2274
- const ret = this.options.extensions.renderers[genericToken.type].call({ parser: this }, genericToken);
2275
- if (ret !== false || !["space", "hr", "heading", "code", "table", "blockquote", "list", "html", "paragraph", "text"].includes(genericToken.type)) {
2276
- out += ret || "";
1493
+ let t = "";
1494
+ for (let n = 0; n < e.length; n++) {
1495
+ let r = e[n];
1496
+ if ((_b = (_a2 = this.options.extensions) == null ? void 0 : _a2.renderers) == null ? void 0 : _b[r.type]) {
1497
+ let s = r, a = this.options.extensions.renderers[s.type].call({ parser: this }, s);
1498
+ if (a !== false || !["space", "hr", "heading", "code", "table", "blockquote", "list", "html", "def", "paragraph", "text"].includes(s.type)) {
1499
+ t += a || "";
2277
1500
  continue;
2278
1501
  }
2279
1502
  }
2280
- const token = anyToken;
2281
- switch (token.type) {
1503
+ let i = r;
1504
+ switch (i.type) {
2282
1505
  case "space": {
2283
- out += this.renderer.space(token);
2284
- continue;
1506
+ t += this.renderer.space(i);
1507
+ break;
2285
1508
  }
2286
1509
  case "hr": {
2287
- out += this.renderer.hr(token);
2288
- continue;
1510
+ t += this.renderer.hr(i);
1511
+ break;
2289
1512
  }
2290
1513
  case "heading": {
2291
- out += this.renderer.heading(token);
2292
- continue;
1514
+ t += this.renderer.heading(i);
1515
+ break;
2293
1516
  }
2294
1517
  case "code": {
2295
- out += this.renderer.code(token);
2296
- continue;
1518
+ t += this.renderer.code(i);
1519
+ break;
2297
1520
  }
2298
1521
  case "table": {
2299
- out += this.renderer.table(token);
2300
- continue;
1522
+ t += this.renderer.table(i);
1523
+ break;
2301
1524
  }
2302
1525
  case "blockquote": {
2303
- out += this.renderer.blockquote(token);
2304
- continue;
1526
+ t += this.renderer.blockquote(i);
1527
+ break;
2305
1528
  }
2306
1529
  case "list": {
2307
- out += this.renderer.list(token);
2308
- continue;
1530
+ t += this.renderer.list(i);
1531
+ break;
1532
+ }
1533
+ case "checkbox": {
1534
+ t += this.renderer.checkbox(i);
1535
+ break;
2309
1536
  }
2310
1537
  case "html": {
2311
- out += this.renderer.html(token);
2312
- continue;
1538
+ t += this.renderer.html(i);
1539
+ break;
1540
+ }
1541
+ case "def": {
1542
+ t += this.renderer.def(i);
1543
+ break;
2313
1544
  }
2314
1545
  case "paragraph": {
2315
- out += this.renderer.paragraph(token);
2316
- continue;
1546
+ t += this.renderer.paragraph(i);
1547
+ break;
2317
1548
  }
2318
1549
  case "text": {
2319
- let textToken = token;
2320
- let body = this.renderer.text(textToken);
2321
- while (i + 1 < tokens.length && tokens[i + 1].type === "text") {
2322
- textToken = tokens[++i];
2323
- body += "\n" + this.renderer.text(textToken);
2324
- }
2325
- if (top) {
2326
- out += this.renderer.paragraph({
2327
- type: "paragraph",
2328
- raw: body,
2329
- text: body,
2330
- tokens: [{ type: "text", raw: body, text: body, escaped: true }]
2331
- });
2332
- } else {
2333
- out += body;
2334
- }
2335
- continue;
1550
+ t += this.renderer.text(i);
1551
+ break;
2336
1552
  }
2337
1553
  default: {
2338
- const errMsg = 'Token with "' + token.type + '" type was not found.';
2339
- if (this.options.silent) {
2340
- console.error(errMsg);
2341
- return "";
2342
- } else {
2343
- throw new Error(errMsg);
2344
- }
1554
+ let s = 'Token with "' + i.type + '" type was not found.';
1555
+ if (this.options.silent) return console.error(s), "";
1556
+ throw new Error(s);
2345
1557
  }
2346
1558
  }
2347
1559
  }
2348
- return out;
1560
+ return t;
2349
1561
  }
2350
- /**
2351
- * Parse Inline Tokens
2352
- */
2353
- parseInline(tokens, renderer = this.renderer) {
1562
+ parseInline(e, t = this.renderer) {
2354
1563
  var _a2, _b;
2355
- let out = "";
2356
- for (let i = 0; i < tokens.length; i++) {
2357
- const anyToken = tokens[i];
2358
- if ((_b = (_a2 = this.options.extensions) == null ? void 0 : _a2.renderers) == null ? void 0 : _b[anyToken.type]) {
2359
- const ret = this.options.extensions.renderers[anyToken.type].call({ parser: this }, anyToken);
2360
- if (ret !== false || !["escape", "html", "link", "image", "strong", "em", "codespan", "br", "del", "text"].includes(anyToken.type)) {
2361
- out += ret || "";
1564
+ let n = "";
1565
+ for (let r = 0; r < e.length; r++) {
1566
+ let i = e[r];
1567
+ if ((_b = (_a2 = this.options.extensions) == null ? void 0 : _a2.renderers) == null ? void 0 : _b[i.type]) {
1568
+ let a = this.options.extensions.renderers[i.type].call({ parser: this }, i);
1569
+ if (a !== false || !["escape", "html", "link", "image", "strong", "em", "codespan", "br", "del", "text"].includes(i.type)) {
1570
+ n += a || "";
2362
1571
  continue;
2363
1572
  }
2364
1573
  }
2365
- const token = anyToken;
2366
- switch (token.type) {
1574
+ let s = i;
1575
+ switch (s.type) {
2367
1576
  case "escape": {
2368
- out += renderer.text(token);
1577
+ n += t.text(s);
2369
1578
  break;
2370
1579
  }
2371
1580
  case "html": {
2372
- out += renderer.html(token);
1581
+ n += t.html(s);
2373
1582
  break;
2374
1583
  }
2375
1584
  case "link": {
2376
- out += renderer.link(token);
1585
+ n += t.link(s);
2377
1586
  break;
2378
1587
  }
2379
1588
  case "image": {
2380
- out += renderer.image(token);
1589
+ n += t.image(s);
1590
+ break;
1591
+ }
1592
+ case "checkbox": {
1593
+ n += t.checkbox(s);
2381
1594
  break;
2382
1595
  }
2383
1596
  case "strong": {
2384
- out += renderer.strong(token);
1597
+ n += t.strong(s);
2385
1598
  break;
2386
1599
  }
2387
1600
  case "em": {
2388
- out += renderer.em(token);
1601
+ n += t.em(s);
2389
1602
  break;
2390
1603
  }
2391
1604
  case "codespan": {
2392
- out += renderer.codespan(token);
1605
+ n += t.codespan(s);
2393
1606
  break;
2394
1607
  }
2395
1608
  case "br": {
2396
- out += renderer.br(token);
1609
+ n += t.br(s);
2397
1610
  break;
2398
1611
  }
2399
1612
  case "del": {
2400
- out += renderer.del(token);
1613
+ n += t.del(s);
2401
1614
  break;
2402
1615
  }
2403
1616
  case "text": {
2404
- out += renderer.text(token);
1617
+ n += t.text(s);
2405
1618
  break;
2406
1619
  }
2407
1620
  default: {
2408
- const errMsg = 'Token with "' + token.type + '" type was not found.';
2409
- if (this.options.silent) {
2410
- console.error(errMsg);
2411
- return "";
2412
- } else {
2413
- throw new Error(errMsg);
2414
- }
1621
+ let a = 'Token with "' + s.type + '" type was not found.';
1622
+ if (this.options.silent) return console.error(a), "";
1623
+ throw new Error(a);
2415
1624
  }
2416
1625
  }
2417
1626
  }
2418
- return out;
1627
+ return n;
2419
1628
  }
2420
1629
  };
2421
1630
  var _a;
2422
- var _Hooks = (_a = class {
2423
- constructor(options2) {
1631
+ var P = (_a = class {
1632
+ constructor(e) {
2424
1633
  __publicField(this, "options");
2425
1634
  __publicField(this, "block");
2426
- this.options = options2 || _defaults;
1635
+ this.options = e || T;
2427
1636
  }
2428
- /**
2429
- * Process markdown before marked
2430
- */
2431
- preprocess(markdown) {
2432
- return markdown;
1637
+ preprocess(e) {
1638
+ return e;
2433
1639
  }
2434
- /**
2435
- * Process HTML after marked is finished
2436
- */
2437
- postprocess(html2) {
2438
- return html2;
1640
+ postprocess(e) {
1641
+ return e;
2439
1642
  }
2440
- /**
2441
- * Process all tokens before walk tokens
2442
- */
2443
- processAllTokens(tokens) {
2444
- return tokens;
1643
+ processAllTokens(e) {
1644
+ return e;
1645
+ }
1646
+ emStrongMask(e) {
1647
+ return e;
2445
1648
  }
2446
- /**
2447
- * Provide function to tokenize markdown
2448
- */
2449
1649
  provideLexer() {
2450
- return this.block ? _Lexer.lex : _Lexer.lexInline;
1650
+ return this.block ? x.lex : x.lexInline;
2451
1651
  }
2452
- /**
2453
- * Provide function to parse tokens
2454
- */
2455
1652
  provideParser() {
2456
- return this.block ? _Parser.parse : _Parser.parseInline;
2457
- }
2458
- }, __publicField(_a, "passThroughHooks", /* @__PURE__ */ new Set([
2459
- "preprocess",
2460
- "postprocess",
2461
- "processAllTokens"
2462
- ])), _a);
2463
- var Marked = class {
2464
- constructor(...args) {
2465
- __publicField(this, "defaults", _getDefaults());
1653
+ return this.block ? b.parse : b.parseInline;
1654
+ }
1655
+ }, __publicField(_a, "passThroughHooks", /* @__PURE__ */ new Set(["preprocess", "postprocess", "processAllTokens", "emStrongMask"])), __publicField(_a, "passThroughHooksRespectAsync", /* @__PURE__ */ new Set(["preprocess", "postprocess", "processAllTokens"])), _a);
1656
+ var B = class {
1657
+ constructor(...e) {
1658
+ __publicField(this, "defaults", M());
2466
1659
  __publicField(this, "options", this.setOptions);
2467
1660
  __publicField(this, "parse", this.parseMarkdown(true));
2468
1661
  __publicField(this, "parseInline", this.parseMarkdown(false));
2469
- __publicField(this, "Parser", _Parser);
2470
- __publicField(this, "Renderer", _Renderer);
2471
- __publicField(this, "TextRenderer", _TextRenderer);
2472
- __publicField(this, "Lexer", _Lexer);
2473
- __publicField(this, "Tokenizer", _Tokenizer);
2474
- __publicField(this, "Hooks", _Hooks);
2475
- this.use(...args);
2476
- }
2477
- /**
2478
- * Run callback for every token
2479
- */
2480
- walkTokens(tokens, callback) {
1662
+ __publicField(this, "Parser", b);
1663
+ __publicField(this, "Renderer", y);
1664
+ __publicField(this, "TextRenderer", $);
1665
+ __publicField(this, "Lexer", x);
1666
+ __publicField(this, "Tokenizer", w);
1667
+ __publicField(this, "Hooks", P);
1668
+ this.use(...e);
1669
+ }
1670
+ walkTokens(e, t) {
2481
1671
  var _a2, _b;
2482
- let values = [];
2483
- for (const token of tokens) {
2484
- values = values.concat(callback.call(this, token));
2485
- switch (token.type) {
2486
- case "table": {
2487
- const tableToken = token;
2488
- for (const cell of tableToken.header) {
2489
- values = values.concat(this.walkTokens(cell.tokens, callback));
2490
- }
2491
- for (const row of tableToken.rows) {
2492
- for (const cell of row) {
2493
- values = values.concat(this.walkTokens(cell.tokens, callback));
2494
- }
2495
- }
2496
- break;
2497
- }
2498
- case "list": {
2499
- const listToken = token;
2500
- values = values.concat(this.walkTokens(listToken.items, callback));
2501
- break;
2502
- }
2503
- default: {
2504
- const genericToken = token;
2505
- if ((_b = (_a2 = this.defaults.extensions) == null ? void 0 : _a2.childTokens) == null ? void 0 : _b[genericToken.type]) {
2506
- this.defaults.extensions.childTokens[genericToken.type].forEach((childTokens) => {
2507
- const tokens2 = genericToken[childTokens].flat(Infinity);
2508
- values = values.concat(this.walkTokens(tokens2, callback));
2509
- });
2510
- } else if (genericToken.tokens) {
2511
- values = values.concat(this.walkTokens(genericToken.tokens, callback));
2512
- }
2513
- }
2514
- }
2515
- }
2516
- return values;
2517
- }
2518
- use(...args) {
2519
- const extensions = this.defaults.extensions || { renderers: {}, childTokens: {} };
2520
- args.forEach((pack) => {
2521
- const opts = { ...pack };
2522
- opts.async = this.defaults.async || opts.async || false;
2523
- if (pack.extensions) {
2524
- pack.extensions.forEach((ext) => {
2525
- if (!ext.name) {
2526
- throw new Error("extension name required");
2527
- }
2528
- if ("renderer" in ext) {
2529
- const prevRenderer = extensions.renderers[ext.name];
2530
- if (prevRenderer) {
2531
- extensions.renderers[ext.name] = function(...args2) {
2532
- let ret = ext.renderer.apply(this, args2);
2533
- if (ret === false) {
2534
- ret = prevRenderer.apply(this, args2);
2535
- }
2536
- return ret;
2537
- };
2538
- } else {
2539
- extensions.renderers[ext.name] = ext.renderer;
2540
- }
2541
- }
2542
- if ("tokenizer" in ext) {
2543
- if (!ext.level || ext.level !== "block" && ext.level !== "inline") {
2544
- throw new Error("extension level must be 'block' or 'inline'");
2545
- }
2546
- const extLevel = extensions[ext.level];
2547
- if (extLevel) {
2548
- extLevel.unshift(ext.tokenizer);
2549
- } else {
2550
- extensions[ext.level] = [ext.tokenizer];
2551
- }
2552
- if (ext.start) {
2553
- if (ext.level === "block") {
2554
- if (extensions.startBlock) {
2555
- extensions.startBlock.push(ext.start);
2556
- } else {
2557
- extensions.startBlock = [ext.start];
2558
- }
2559
- } else if (ext.level === "inline") {
2560
- if (extensions.startInline) {
2561
- extensions.startInline.push(ext.start);
2562
- } else {
2563
- extensions.startInline = [ext.start];
2564
- }
2565
- }
2566
- }
2567
- }
2568
- if ("childTokens" in ext && ext.childTokens) {
2569
- extensions.childTokens[ext.name] = ext.childTokens;
2570
- }
2571
- });
2572
- opts.extensions = extensions;
2573
- }
2574
- if (pack.renderer) {
2575
- const renderer = this.defaults.renderer || new _Renderer(this.defaults);
2576
- for (const prop in pack.renderer) {
2577
- if (!(prop in renderer)) {
2578
- throw new Error(`renderer '${prop}' does not exist`);
2579
- }
2580
- if (["options", "parser"].includes(prop)) {
2581
- continue;
2582
- }
2583
- const rendererProp = prop;
2584
- const rendererFunc = pack.renderer[rendererProp];
2585
- const prevRenderer = renderer[rendererProp];
2586
- renderer[rendererProp] = (...args2) => {
2587
- let ret = rendererFunc.apply(renderer, args2);
2588
- if (ret === false) {
2589
- ret = prevRenderer.apply(renderer, args2);
2590
- }
2591
- return ret || "";
1672
+ let n = [];
1673
+ for (let r of e) switch (n = n.concat(t.call(this, r)), r.type) {
1674
+ case "table": {
1675
+ let i = r;
1676
+ for (let s of i.header) n = n.concat(this.walkTokens(s.tokens, t));
1677
+ for (let s of i.rows) for (let a of s) n = n.concat(this.walkTokens(a.tokens, t));
1678
+ break;
1679
+ }
1680
+ case "list": {
1681
+ let i = r;
1682
+ n = n.concat(this.walkTokens(i.items, t));
1683
+ break;
1684
+ }
1685
+ default: {
1686
+ let i = r;
1687
+ ((_b = (_a2 = this.defaults.extensions) == null ? void 0 : _a2.childTokens) == null ? void 0 : _b[i.type]) ? this.defaults.extensions.childTokens[i.type].forEach((s) => {
1688
+ let a = i[s].flat(1 / 0);
1689
+ n = n.concat(this.walkTokens(a, t));
1690
+ }) : i.tokens && (n = n.concat(this.walkTokens(i.tokens, t)));
1691
+ }
1692
+ }
1693
+ return n;
1694
+ }
1695
+ use(...e) {
1696
+ let t = this.defaults.extensions || { renderers: {}, childTokens: {} };
1697
+ return e.forEach((n) => {
1698
+ let r = { ...n };
1699
+ if (r.async = this.defaults.async || r.async || false, n.extensions && (n.extensions.forEach((i) => {
1700
+ if (!i.name) throw new Error("extension name required");
1701
+ if ("renderer" in i) {
1702
+ let s = t.renderers[i.name];
1703
+ s ? t.renderers[i.name] = function(...a) {
1704
+ let o = i.renderer.apply(this, a);
1705
+ return o === false && (o = s.apply(this, a)), o;
1706
+ } : t.renderers[i.name] = i.renderer;
1707
+ }
1708
+ if ("tokenizer" in i) {
1709
+ if (!i.level || i.level !== "block" && i.level !== "inline") throw new Error("extension level must be 'block' or 'inline'");
1710
+ let s = t[i.level];
1711
+ s ? s.unshift(i.tokenizer) : t[i.level] = [i.tokenizer], i.start && (i.level === "block" ? t.startBlock ? t.startBlock.push(i.start) : t.startBlock = [i.start] : i.level === "inline" && (t.startInline ? t.startInline.push(i.start) : t.startInline = [i.start]));
1712
+ }
1713
+ "childTokens" in i && i.childTokens && (t.childTokens[i.name] = i.childTokens);
1714
+ }), r.extensions = t), n.renderer) {
1715
+ let i = this.defaults.renderer || new y(this.defaults);
1716
+ for (let s in n.renderer) {
1717
+ if (!(s in i)) throw new Error(`renderer '${s}' does not exist`);
1718
+ if (["options", "parser"].includes(s)) continue;
1719
+ let a = s, o = n.renderer[a], l = i[a];
1720
+ i[a] = (...p) => {
1721
+ let c = o.apply(i, p);
1722
+ return c === false && (c = l.apply(i, p)), c || "";
2592
1723
  };
2593
1724
  }
2594
- opts.renderer = renderer;
2595
- }
2596
- if (pack.tokenizer) {
2597
- const tokenizer = this.defaults.tokenizer || new _Tokenizer(this.defaults);
2598
- for (const prop in pack.tokenizer) {
2599
- if (!(prop in tokenizer)) {
2600
- throw new Error(`tokenizer '${prop}' does not exist`);
2601
- }
2602
- if (["options", "rules", "lexer"].includes(prop)) {
2603
- continue;
2604
- }
2605
- const tokenizerProp = prop;
2606
- const tokenizerFunc = pack.tokenizer[tokenizerProp];
2607
- const prevTokenizer = tokenizer[tokenizerProp];
2608
- tokenizer[tokenizerProp] = (...args2) => {
2609
- let ret = tokenizerFunc.apply(tokenizer, args2);
2610
- if (ret === false) {
2611
- ret = prevTokenizer.apply(tokenizer, args2);
2612
- }
2613
- return ret;
1725
+ r.renderer = i;
1726
+ }
1727
+ if (n.tokenizer) {
1728
+ let i = this.defaults.tokenizer || new w(this.defaults);
1729
+ for (let s in n.tokenizer) {
1730
+ if (!(s in i)) throw new Error(`tokenizer '${s}' does not exist`);
1731
+ if (["options", "rules", "lexer"].includes(s)) continue;
1732
+ let a = s, o = n.tokenizer[a], l = i[a];
1733
+ i[a] = (...p) => {
1734
+ let c = o.apply(i, p);
1735
+ return c === false && (c = l.apply(i, p)), c;
2614
1736
  };
2615
1737
  }
2616
- opts.tokenizer = tokenizer;
2617
- }
2618
- if (pack.hooks) {
2619
- const hooks = this.defaults.hooks || new _Hooks();
2620
- for (const prop in pack.hooks) {
2621
- if (!(prop in hooks)) {
2622
- throw new Error(`hook '${prop}' does not exist`);
2623
- }
2624
- if (["options", "block"].includes(prop)) {
2625
- continue;
2626
- }
2627
- const hooksProp = prop;
2628
- const hooksFunc = pack.hooks[hooksProp];
2629
- const prevHook = hooks[hooksProp];
2630
- if (_Hooks.passThroughHooks.has(prop)) {
2631
- hooks[hooksProp] = (arg) => {
2632
- if (this.defaults.async) {
2633
- return Promise.resolve(hooksFunc.call(hooks, arg)).then((ret2) => {
2634
- return prevHook.call(hooks, ret2);
2635
- });
2636
- }
2637
- const ret = hooksFunc.call(hooks, arg);
2638
- return prevHook.call(hooks, ret);
2639
- };
2640
- } else {
2641
- hooks[hooksProp] = (...args2) => {
2642
- let ret = hooksFunc.apply(hooks, args2);
2643
- if (ret === false) {
2644
- ret = prevHook.apply(hooks, args2);
2645
- }
2646
- return ret;
2647
- };
2648
- }
1738
+ r.tokenizer = i;
1739
+ }
1740
+ if (n.hooks) {
1741
+ let i = this.defaults.hooks || new P();
1742
+ for (let s in n.hooks) {
1743
+ if (!(s in i)) throw new Error(`hook '${s}' does not exist`);
1744
+ if (["options", "block"].includes(s)) continue;
1745
+ let a = s, o = n.hooks[a], l = i[a];
1746
+ P.passThroughHooks.has(s) ? i[a] = (p) => {
1747
+ if (this.defaults.async && P.passThroughHooksRespectAsync.has(s)) return (async () => {
1748
+ let d = await o.call(i, p);
1749
+ return l.call(i, d);
1750
+ })();
1751
+ let c = o.call(i, p);
1752
+ return l.call(i, c);
1753
+ } : i[a] = (...p) => {
1754
+ if (this.defaults.async) return (async () => {
1755
+ let d = await o.apply(i, p);
1756
+ return d === false && (d = await l.apply(i, p)), d;
1757
+ })();
1758
+ let c = o.apply(i, p);
1759
+ return c === false && (c = l.apply(i, p)), c;
1760
+ };
2649
1761
  }
2650
- opts.hooks = hooks;
1762
+ r.hooks = i;
2651
1763
  }
2652
- if (pack.walkTokens) {
2653
- const walkTokens2 = this.defaults.walkTokens;
2654
- const packWalktokens = pack.walkTokens;
2655
- opts.walkTokens = function(token) {
2656
- let values = [];
2657
- values.push(packWalktokens.call(this, token));
2658
- if (walkTokens2) {
2659
- values = values.concat(walkTokens2.call(this, token));
2660
- }
2661
- return values;
1764
+ if (n.walkTokens) {
1765
+ let i = this.defaults.walkTokens, s = n.walkTokens;
1766
+ r.walkTokens = function(a) {
1767
+ let o = [];
1768
+ return o.push(s.call(this, a)), i && (o = o.concat(i.call(this, a))), o;
2662
1769
  };
2663
1770
  }
2664
- this.defaults = { ...this.defaults, ...opts };
2665
- });
2666
- return this;
2667
- }
2668
- setOptions(opt) {
2669
- this.defaults = { ...this.defaults, ...opt };
2670
- return this;
2671
- }
2672
- lexer(src, options2) {
2673
- return _Lexer.lex(src, options2 != null ? options2 : this.defaults);
2674
- }
2675
- parser(tokens, options2) {
2676
- return _Parser.parse(tokens, options2 != null ? options2 : this.defaults);
2677
- }
2678
- parseMarkdown(blockType) {
2679
- const parse2 = (src, options2) => {
2680
- const origOpt = { ...options2 };
2681
- const opt = { ...this.defaults, ...origOpt };
2682
- const throwError = this.onError(!!opt.silent, !!opt.async);
2683
- if (this.defaults.async === true && origOpt.async === false) {
2684
- return throwError(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."));
2685
- }
2686
- if (typeof src === "undefined" || src === null) {
2687
- return throwError(new Error("marked(): input parameter is undefined or null"));
2688
- }
2689
- if (typeof src !== "string") {
2690
- return throwError(new Error("marked(): input parameter is of type " + Object.prototype.toString.call(src) + ", string expected"));
2691
- }
2692
- if (opt.hooks) {
2693
- opt.hooks.options = opt;
2694
- opt.hooks.block = blockType;
2695
- }
2696
- const lexer2 = opt.hooks ? opt.hooks.provideLexer() : blockType ? _Lexer.lex : _Lexer.lexInline;
2697
- const parser2 = opt.hooks ? opt.hooks.provideParser() : blockType ? _Parser.parse : _Parser.parseInline;
2698
- if (opt.async) {
2699
- return Promise.resolve(opt.hooks ? opt.hooks.preprocess(src) : src).then((src2) => lexer2(src2, opt)).then((tokens) => opt.hooks ? opt.hooks.processAllTokens(tokens) : tokens).then((tokens) => opt.walkTokens ? Promise.all(this.walkTokens(tokens, opt.walkTokens)).then(() => tokens) : tokens).then((tokens) => parser2(tokens, opt)).then((html2) => opt.hooks ? opt.hooks.postprocess(html2) : html2).catch(throwError);
2700
- }
1771
+ this.defaults = { ...this.defaults, ...r };
1772
+ }), this;
1773
+ }
1774
+ setOptions(e) {
1775
+ return this.defaults = { ...this.defaults, ...e }, this;
1776
+ }
1777
+ lexer(e, t) {
1778
+ return x.lex(e, t != null ? t : this.defaults);
1779
+ }
1780
+ parser(e, t) {
1781
+ return b.parse(e, t != null ? t : this.defaults);
1782
+ }
1783
+ parseMarkdown(e) {
1784
+ return (n, r) => {
1785
+ let i = { ...r }, s = { ...this.defaults, ...i }, a = this.onError(!!s.silent, !!s.async);
1786
+ if (this.defaults.async === true && i.async === false) return a(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."));
1787
+ if (typeof n > "u" || n === null) return a(new Error("marked(): input parameter is undefined or null"));
1788
+ if (typeof n != "string") return a(new Error("marked(): input parameter is of type " + Object.prototype.toString.call(n) + ", string expected"));
1789
+ if (s.hooks && (s.hooks.options = s, s.hooks.block = e), s.async) return (async () => {
1790
+ let o = s.hooks ? await s.hooks.preprocess(n) : n, p = await (s.hooks ? await s.hooks.provideLexer() : e ? x.lex : x.lexInline)(o, s), c = s.hooks ? await s.hooks.processAllTokens(p) : p;
1791
+ s.walkTokens && await Promise.all(this.walkTokens(c, s.walkTokens));
1792
+ let h = await (s.hooks ? await s.hooks.provideParser() : e ? b.parse : b.parseInline)(c, s);
1793
+ return s.hooks ? await s.hooks.postprocess(h) : h;
1794
+ })().catch(a);
2701
1795
  try {
2702
- if (opt.hooks) {
2703
- src = opt.hooks.preprocess(src);
2704
- }
2705
- let tokens = lexer2(src, opt);
2706
- if (opt.hooks) {
2707
- tokens = opt.hooks.processAllTokens(tokens);
2708
- }
2709
- if (opt.walkTokens) {
2710
- this.walkTokens(tokens, opt.walkTokens);
2711
- }
2712
- let html2 = parser2(tokens, opt);
2713
- if (opt.hooks) {
2714
- html2 = opt.hooks.postprocess(html2);
2715
- }
2716
- return html2;
2717
- } catch (e) {
2718
- return throwError(e);
1796
+ s.hooks && (n = s.hooks.preprocess(n));
1797
+ let l = (s.hooks ? s.hooks.provideLexer() : e ? x.lex : x.lexInline)(n, s);
1798
+ s.hooks && (l = s.hooks.processAllTokens(l)), s.walkTokens && this.walkTokens(l, s.walkTokens);
1799
+ let c = (s.hooks ? s.hooks.provideParser() : e ? b.parse : b.parseInline)(l, s);
1800
+ return s.hooks && (c = s.hooks.postprocess(c)), c;
1801
+ } catch (o) {
1802
+ return a(o);
2719
1803
  }
2720
1804
  };
2721
- return parse2;
2722
- }
2723
- onError(silent, async) {
2724
- return (e) => {
2725
- e.message += "\nPlease report this to https://github.com/markedjs/marked.";
2726
- if (silent) {
2727
- const msg = "<p>An error occurred:</p><pre>" + escape2(e.message + "", true) + "</pre>";
2728
- if (async) {
2729
- return Promise.resolve(msg);
2730
- }
2731
- return msg;
2732
- }
2733
- if (async) {
2734
- return Promise.reject(e);
1805
+ }
1806
+ onError(e, t) {
1807
+ return (n) => {
1808
+ if (n.message += `
1809
+ Please report this to https://github.com/markedjs/marked.`, e) {
1810
+ let r = "<p>An error occurred:</p><pre>" + O(n.message + "", true) + "</pre>";
1811
+ return t ? Promise.resolve(r) : r;
2735
1812
  }
2736
- throw e;
1813
+ if (t) return Promise.reject(n);
1814
+ throw n;
2737
1815
  };
2738
1816
  }
2739
1817
  };
2740
- var markedInstance = new Marked();
2741
- function marked(src, opt) {
2742
- return markedInstance.parse(src, opt);
1818
+ var L = new B();
1819
+ function g(u3, e) {
1820
+ return L.parse(u3, e);
2743
1821
  }
2744
- marked.options = marked.setOptions = function(options2) {
2745
- markedInstance.setOptions(options2);
2746
- marked.defaults = markedInstance.defaults;
2747
- changeDefaults(marked.defaults);
2748
- return marked;
1822
+ g.options = g.setOptions = function(u3) {
1823
+ return L.setOptions(u3), g.defaults = L.defaults, G(g.defaults), g;
2749
1824
  };
2750
- marked.getDefaults = _getDefaults;
2751
- marked.defaults = _defaults;
2752
- marked.use = function(...args) {
2753
- markedInstance.use(...args);
2754
- marked.defaults = markedInstance.defaults;
2755
- changeDefaults(marked.defaults);
2756
- return marked;
1825
+ g.getDefaults = M;
1826
+ g.defaults = T;
1827
+ g.use = function(...u3) {
1828
+ return L.use(...u3), g.defaults = L.defaults, G(g.defaults), g;
2757
1829
  };
2758
- marked.walkTokens = function(tokens, callback) {
2759
- return markedInstance.walkTokens(tokens, callback);
1830
+ g.walkTokens = function(u3, e) {
1831
+ return L.walkTokens(u3, e);
2760
1832
  };
2761
- marked.parseInline = markedInstance.parseInline;
2762
- marked.Parser = _Parser;
2763
- marked.parser = _Parser.parse;
2764
- marked.Renderer = _Renderer;
2765
- marked.TextRenderer = _TextRenderer;
2766
- marked.Lexer = _Lexer;
2767
- marked.lexer = _Lexer.lex;
2768
- marked.Tokenizer = _Tokenizer;
2769
- marked.Hooks = _Hooks;
2770
- marked.parse = marked;
2771
- var options = marked.options;
2772
- var setOptions = marked.setOptions;
2773
- var use = marked.use;
2774
- var walkTokens = marked.walkTokens;
2775
- var parseInline = marked.parseInline;
2776
- var parser = _Parser.parse;
2777
- var lexer = _Lexer.lex;
1833
+ g.parseInline = L.parseInline;
1834
+ g.Parser = b;
1835
+ g.parser = b.parse;
1836
+ g.Renderer = y;
1837
+ g.TextRenderer = $;
1838
+ g.Lexer = x;
1839
+ g.lexer = x.lex;
1840
+ g.Tokenizer = w;
1841
+ g.Hooks = P;
1842
+ g.parse = g;
1843
+ var Ut = g.options;
1844
+ var Kt = g.setOptions;
1845
+ var Wt = g.use;
1846
+ var Xt = g.walkTokens;
1847
+ var Jt = g.parseInline;
1848
+ var Yt = b.parse;
1849
+ var en = x.lex;
2778
1850
 
2779
1851
  // ../adaptives/adaptive-faq/dist/FAQWidget.js
2780
1852
  import React2, { useCallback as useCallback2, useEffect as useEffect2, useMemo, useReducer, useState as useState2 } from "react";
2781
1853
  import { createRoot as createRoot2 } from "react-dom/client";
2782
- var marked2 = new Marked({ async: false, gfm: true, breaks: true });
2783
- function getAnswerText(answer) {
2784
- if (typeof answer === "string")
2785
- return answer;
2786
- if (answer.type === "rich")
2787
- return answer.html;
2788
- return answer.content;
2789
- }
2790
- function renderAnswer(answer) {
2791
- if (typeof answer === "string") {
2792
- return _jsx2("p", { style: { margin: 0 }, children: answer });
2793
- }
2794
- if (answer.type === "rich") {
2795
- return _jsx2("div", { style: { margin: 0 }, dangerouslySetInnerHTML: { __html: answer.html } });
2796
- }
2797
- const html2 = marked2.parse(answer.content);
2798
- return (
2799
- // biome-ignore lint/security/noDangerouslySetInnerHtml: markdown content is CMS/config content, not user-controlled input
2800
- _jsx2("div", { style: { margin: 0 }, "data-faq-markdown": "", dangerouslySetInnerHTML: { __html: html2 } })
2801
- );
2802
- }
2803
- function resolveFeedbackConfig(feedback) {
2804
- if (!feedback)
2805
- return null;
2806
- if (feedback === true) {
2807
- return { style: "thumbs" };
2808
- }
2809
- return feedback;
2810
- }
2811
- function getFeedbackPrompt(feedbackConfig) {
2812
- return feedbackConfig.prompt || "Was this helpful?";
2813
- }
1854
+
1855
+ // ../adaptives/adaptive-faq/dist/faq-styles.js
2814
1856
  var baseStyles = {
2815
1857
  container: {
2816
1858
  fontFamily: "var(--sc-font-family, system-ui, -apple-system, sans-serif)",
@@ -3002,6 +2044,44 @@ var themeStyles = {
3002
2044
  }
3003
2045
  }
3004
2046
  };
2047
+
2048
+ // ../adaptives/adaptive-faq/dist/FAQWidget.js
2049
+ var marked = new B({ async: false, gfm: true, breaks: true });
2050
+ function getAnswerText(answer) {
2051
+ if (typeof answer === "string")
2052
+ return answer;
2053
+ if (answer.type === "rich")
2054
+ return answer.html;
2055
+ return answer.content;
2056
+ }
2057
+ function renderAnswer(answer) {
2058
+ if (typeof answer === "string") {
2059
+ const html2 = marked.parse(answer);
2060
+ return (
2061
+ // biome-ignore lint/security/noDangerouslySetInnerHtml: content is CMS/config content, not user-controlled input
2062
+ _jsx2("div", { style: { margin: 0 }, "data-faq-markdown": "", dangerouslySetInnerHTML: { __html: html2 } })
2063
+ );
2064
+ }
2065
+ if (answer.type === "rich") {
2066
+ return _jsx2("div", { style: { margin: 0 }, dangerouslySetInnerHTML: { __html: answer.html } });
2067
+ }
2068
+ const html = marked.parse(answer.content);
2069
+ return (
2070
+ // biome-ignore lint/security/noDangerouslySetInnerHtml: markdown content is CMS/config content, not user-controlled input
2071
+ _jsx2("div", { style: { margin: 0 }, "data-faq-markdown": "", dangerouslySetInnerHTML: { __html: html } })
2072
+ );
2073
+ }
2074
+ function resolveFeedbackConfig(feedback) {
2075
+ if (!feedback)
2076
+ return null;
2077
+ if (feedback === true) {
2078
+ return { style: "thumbs" };
2079
+ }
2080
+ return feedback;
2081
+ }
2082
+ function getFeedbackPrompt(feedbackConfig) {
2083
+ return feedbackConfig.prompt || "Was this helpful?";
2084
+ }
3005
2085
  function FAQItem({ item, isExpanded, isHighlighted, isLast, onToggle, theme, feedbackConfig, feedbackValue, onFeedback }) {
3006
2086
  const [isHovered, setIsHovered] = useState2(false);
3007
2087
  const colors = themeStyles[theme];
@@ -3011,7 +2091,8 @@ function FAQItem({ item, isExpanded, isHighlighted, isLast, onToggle, theme, fee
3011
2091
  ...colors.item,
3012
2092
  ...isExpanded ? colors.itemExpanded : {},
3013
2093
  ...isHighlighted ? {
3014
- boxShadow: "0 0 0 2px #6366f1, 0 0 12px rgba(99, 102, 241, 0.4)",
2094
+ // purple[4] = #6a59ce design system primary purple
2095
+ boxShadow: `0 0 0 2px ${purple[4]}, 0 0 12px rgba(106, 89, 206, 0.4)`,
3015
2096
  transition: "box-shadow 0.3s ease"
3016
2097
  } : {},
3017
2098
  ...!isLast ? { borderBottom: "var(--sc-content-item-divider, none)" } : {}
@@ -3044,7 +2125,7 @@ function FAQItem({ item, isExpanded, isHighlighted, isLast, onToggle, theme, fee
3044
2125
  }, "aria-label": "Thumbs down", onClick: () => onFeedback(item.config.id, question, "down"), children: "\u{1F44E}" })] })] })] });
3045
2126
  }
3046
2127
  function FAQWidget({ config, runtime: runtime7, instanceId }) {
3047
- const [renderTick, forceUpdate] = useReducer((x) => x + 1, 0);
2128
+ const [renderTick, forceUpdate] = useReducer((x2) => x2 + 1, 0);
3048
2129
  const [expandedIds, setExpandedIds] = useState2(/* @__PURE__ */ new Set());
3049
2130
  const [highlightId, setHighlightId] = useState2(null);
3050
2131
  const [searchQuery, setSearchQuery] = useState2("");
@@ -3133,17 +2214,20 @@ function FAQWidget({ config, runtime: runtime7, instanceId }) {
3133
2214
  const unsubscribe = runtime7.events.subscribe({ names: ["notification.deep_link"] }, handleDeepLink);
3134
2215
  return unsubscribe;
3135
2216
  }, [runtime7, instanceId]);
3136
- const visibleQuestions = useMemo(() => config.actions.filter((q) => {
3137
- if (!q.triggerWhen)
3138
- return true;
3139
- const result = runtime7.evaluateSync(q.triggerWhen);
3140
- return result.value;
3141
- }), [config.actions, runtime7, renderTick]);
2217
+ const visibleQuestions = useMemo(() => {
2218
+ var _a2;
2219
+ return ((_a2 = config.actions) != null ? _a2 : []).filter((q2) => {
2220
+ if (!q2.triggerWhen)
2221
+ return true;
2222
+ const result = runtime7.evaluateSync(q2.triggerWhen);
2223
+ return result.value;
2224
+ });
2225
+ }, [config.actions, runtime7, renderTick]);
3142
2226
  const orderedQuestions = useMemo(() => {
3143
2227
  if (config.ordering === "priority") {
3144
- return [...visibleQuestions].sort((a, b) => {
2228
+ return [...visibleQuestions].sort((a, b2) => {
3145
2229
  var _a2, _b;
3146
- return ((_a2 = b.config.priority) != null ? _a2 : 0) - ((_b = a.config.priority) != null ? _b : 0);
2230
+ return ((_a2 = b2.config.priority) != null ? _a2 : 0) - ((_b = a.config.priority) != null ? _b : 0);
3147
2231
  });
3148
2232
  }
3149
2233
  return visibleQuestions;
@@ -3153,23 +2237,23 @@ function FAQWidget({ config, runtime: runtime7, instanceId }) {
3153
2237
  return orderedQuestions;
3154
2238
  }
3155
2239
  const query = searchQuery.toLowerCase();
3156
- return orderedQuestions.filter((q) => {
2240
+ return orderedQuestions.filter((q2) => {
3157
2241
  var _a2;
3158
- return q.config.question.toLowerCase().includes(query) || getAnswerText(q.config.answer).toLowerCase().includes(query) || ((_a2 = q.config.category) == null ? void 0 : _a2.toLowerCase().includes(query));
2242
+ return q2.config.question.toLowerCase().includes(query) || getAnswerText(q2.config.answer).toLowerCase().includes(query) || ((_a2 = q2.config.category) == null ? void 0 : _a2.toLowerCase().includes(query));
3159
2243
  });
3160
2244
  }, [orderedQuestions, searchQuery, config.searchable]);
3161
2245
  const categoryGroups = useMemo(() => {
3162
2246
  const groups = /* @__PURE__ */ new Map();
3163
- for (const q of filteredQuestions) {
3164
- const cat = q.config.category;
2247
+ for (const q2 of filteredQuestions) {
2248
+ const cat = q2.config.category;
3165
2249
  if (!groups.has(cat)) {
3166
2250
  groups.set(cat, []);
3167
2251
  }
3168
- groups.get(cat).push(q);
2252
+ groups.get(cat).push(q2);
3169
2253
  }
3170
2254
  return groups;
3171
2255
  }, [filteredQuestions]);
3172
- const hasCategories = useMemo(() => filteredQuestions.some((q) => q.config.category), [filteredQuestions]);
2256
+ const hasCategories = useMemo(() => filteredQuestions.some((q2) => q2.config.category), [filteredQuestions]);
3173
2257
  const resolvedTheme = useMemo(() => {
3174
2258
  var _a2;
3175
2259
  if (config.theme && config.theme !== "auto")
@@ -3230,7 +2314,7 @@ function FAQWidget({ config, runtime: runtime7, instanceId }) {
3230
2314
  ...baseStyles.categoryHeader,
3231
2315
  ...themeStyles[resolvedTheme].categoryHeader
3232
2316
  };
3233
- const renderItems = (items) => items.map((q, index) => _jsx2(FAQItem, { item: q, isExpanded: expandedIds.has(q.config.id), isHighlighted: highlightId === q.config.id, isLast: index === items.length - 1, onToggle: () => handleToggle(q.config.id), theme: resolvedTheme, feedbackConfig, feedbackValue: feedbackState.get(q.config.id), onFeedback: handleFeedback }, q.config.id));
2317
+ const renderItems = (items) => items.map((q2, index) => _jsx2(FAQItem, { item: q2, isExpanded: expandedIds.has(q2.config.id), isHighlighted: highlightId === q2.config.id, isLast: index === items.length - 1, onToggle: () => handleToggle(q2.config.id), theme: resolvedTheme, feedbackConfig, feedbackValue: feedbackState.get(q2.config.id), onFeedback: handleFeedback }, q2.config.id));
3234
2318
  if (visibleQuestions.length === 0) {
3235
2319
  return _jsx2("div", { style: containerStyle, "data-adaptive-id": instanceId, "data-adaptive-type": "adaptive-faq", children: _jsx2("div", { style: emptyStateStyle, children: "You're all set for now! We'll surface answers here when they're relevant to what you're doing." }) });
3236
2320
  }
@@ -3255,20 +2339,6 @@ var FAQMountableWidget = {
3255
2339
  root.unmount();
3256
2340
  };
3257
2341
  }
3258
- const questions = faqConfig.actions || [];
3259
- container.innerHTML = `
3260
- <div style="font-family: system-ui; max-width: 800px;">
3261
- ${questions.map((q) => `
3262
- <div style="margin-bottom: 8px; padding: 16px; background: ${slateGrey[12]}; border-radius: 8px;">
3263
- <strong>${q.config.question}</strong>
3264
- <p style="margin-top: 8px; color: ${slateGrey[6]};">${getAnswerText(q.config.answer)}</p>
3265
- </div>
3266
- `).join("")}
3267
- </div>
3268
- `;
3269
- return () => {
3270
- container.innerHTML = "";
3271
- };
3272
2342
  }
3273
2343
  };
3274
2344
 
@@ -3488,7 +2558,8 @@ var themeStyles2 = {
3488
2558
  color: "var(--sc-content-text-secondary-color)"
3489
2559
  },
3490
2560
  linkButton: {
3491
- backgroundColor: "var(--sc-color-primary, #6366f1)",
2561
+ // purple[4] = #6a59ce — design system primary purple, used as fallback when --sc-color-primary is not set
2562
+ backgroundColor: `var(--sc-color-primary, ${purple[4]})`,
3492
2563
  color: "#ffffff"
3493
2564
  },
3494
2565
  categoryHeader: {
@@ -3521,7 +2592,8 @@ var themeStyles2 = {
3521
2592
  color: "var(--sc-content-text-secondary-color)"
3522
2593
  },
3523
2594
  linkButton: {
3524
- backgroundColor: "var(--sc-color-primary, #6366f1)",
2595
+ // purple[4] = #6a59ce — design system primary purple, used as fallback when --sc-color-primary is not set
2596
+ backgroundColor: `var(--sc-color-primary, ${purple[4]})`,
3525
2597
  color: "#ffffff"
3526
2598
  },
3527
2599
  categoryHeader: {
@@ -3591,10 +2663,11 @@ function NavTipItem({ item, isExpanded, isLast, onToggle, onNavigate, onFocusAnc
3591
2663
  }
3592
2664
  };
3593
2665
  const ctaLabel = isFocusAction ? `Focus \u2192` : external ? `Go \u2197` : `Go \u2192`;
3594
- return _jsxs3("div", { style: itemStyle, "data-nav-tip-id": item.config.id, children: [_jsxs3("button", { type: "button", style: headerStyle, onClick: onToggle, onMouseEnter: () => setIsHovered(true), onMouseLeave: () => setIsHovered(false), "aria-expanded": isExpanded, children: [icon && _jsx3("span", { style: baseStyles2.icon, dangerouslySetInnerHTML: { __html: renderIcon(icon) } }), _jsx3("span", { children: title }), _jsx3("span", { style: chevronStyle, children: "\u203A" })] }), _jsxs3("div", { style: bodyStyle, "aria-hidden": !isExpanded, children: [_jsx3("p", { style: baseStyles2.description, children: description }), hasAction && _jsx3("a", { href: effectiveHref || "#", onClick: handleLinkClick, style: { ...baseStyles2.linkButton, ...colors.linkButton }, target: external ? "_blank" : void 0, rel: external ? "noopener noreferrer" : void 0, children: ctaLabel })] })] });
2666
+ return _jsxs3("div", { style: itemStyle, "data-nav-tip-id": item.config.id, children: [_jsxs3("button", { type: "button", style: headerStyle, onClick: onToggle, onMouseEnter: () => setIsHovered(true), onMouseLeave: () => setIsHovered(false), "aria-expanded": isExpanded, children: [icon && // biome-ignore lint/security/noDangerouslySetInnerHtml: renderIcon returns sanitized SVG from EMOJI_SVG_MAP or escapeHtml
2667
+ _jsx3("span", { style: baseStyles2.icon, dangerouslySetInnerHTML: { __html: renderIcon(icon) } }), _jsx3("span", { children: title }), _jsx3("span", { style: chevronStyle, children: "\u203A" })] }), _jsxs3("div", { style: bodyStyle, "aria-hidden": !isExpanded, children: [_jsx3("p", { style: baseStyles2.description, children: description }), hasAction && _jsx3("a", { href: effectiveHref || "#", onClick: handleLinkClick, style: { ...baseStyles2.linkButton, ...colors.linkButton }, target: external ? "_blank" : void 0, rel: external ? "noopener noreferrer" : void 0, children: ctaLabel })] })] });
3595
2668
  }
3596
2669
  function NavWidget({ config, runtime: runtime7, instanceId }) {
3597
- const [renderTick, forceUpdate] = useReducer2((x) => x + 1, 0);
2670
+ const [renderTick, forceUpdate] = useReducer2((x2) => x2 + 1, 0);
3598
2671
  const [expandedIds, setExpandedIds] = useState3(/* @__PURE__ */ new Set());
3599
2672
  useEffect3(() => {
3600
2673
  const unsubscribe = runtime7.context.subscribe(() => {
@@ -3690,8 +2763,10 @@ function NavWidget({ config, runtime: runtime7, instanceId }) {
3690
2763
  } else {
3691
2764
  const url = new URL(href, window.location.origin);
3692
2765
  url.search = window.location.search;
3693
- window.history.pushState(null, "", url.toString());
3694
- window.dispatchEvent(new PopStateEvent("popstate"));
2766
+ if (!navigateWithFrameworkRouter(url.toString())) {
2767
+ window.history.pushState(null, "", url.toString());
2768
+ window.dispatchEvent(new PopStateEvent("popstate"));
2769
+ }
3695
2770
  }
3696
2771
  }, [runtime7.events, instanceId]);
3697
2772
  const handleFocusAnchor = useCallback3((anchor) => {
@@ -3744,21 +2819,6 @@ var NavMountableWidget = {
3744
2819
  root.unmount();
3745
2820
  };
3746
2821
  }
3747
- const tips = navConfig.actions || [];
3748
- container.innerHTML = `
3749
- <div style="font-family: system-ui; max-width: 100%;">
3750
- ${tips.map((tip) => `
3751
- <div style="margin-bottom: 4px; padding: 12px 16px; background: ${slateGrey[12]}; border-radius: 8px;">
3752
- ${tip.config.icon ? `<span>${renderIcon(tip.config.icon)}</span> ` : ""}<strong>${escapeHtml(tip.config.title)}</strong>
3753
- <p style="margin-top: 8px; color: ${slateGrey[6]}; font-size: 13px;">${escapeHtml(tip.config.description)}</p>
3754
- ${tip.config.href ? `<a href="${escapeHtml(tip.config.href)}" style="color: ${purple[2]}; font-size: 13px;">Go &rarr;</a>` : ""}
3755
- </div>
3756
- `).join("")}
3757
- </div>
3758
- `;
3759
- return () => {
3760
- container.innerHTML = "";
3761
- };
3762
2822
  }
3763
2823
  };
3764
2824
 
@@ -3787,6 +2847,40 @@ var executeScrollTo = async (action, context) => {
3787
2847
  }
3788
2848
  };
3789
2849
  };
2850
+ function navigateWithFrameworkRouter(url) {
2851
+ var _a2, _b, _c, _d;
2852
+ if (typeof window === "undefined")
2853
+ return false;
2854
+ const w2 = window;
2855
+ try {
2856
+ const nextRouter = (_a2 = w2.next) == null ? void 0 : _a2.router;
2857
+ if (nextRouter == null ? void 0 : nextRouter.push) {
2858
+ nextRouter.push(url);
2859
+ return true;
2860
+ }
2861
+ } catch {
2862
+ }
2863
+ try {
2864
+ if ((_c = (_b = w2.$nuxt) == null ? void 0 : _b.$router) == null ? void 0 : _c.push) {
2865
+ w2.$nuxt.$router.push(url);
2866
+ return true;
2867
+ }
2868
+ } catch {
2869
+ }
2870
+ if (w2.ng || w2.getAllAngularRootElements || document.querySelector("[ng-version]")) {
2871
+ window.location.href = url;
2872
+ return true;
2873
+ }
2874
+ if (w2.__SVELTEKIT_DATA__ || ((_d = document.body) == null ? void 0 : _d.hasAttribute("data-sveltekit"))) {
2875
+ window.location.href = url;
2876
+ return true;
2877
+ }
2878
+ if (document.querySelector("[data-astro-transition-fallback]")) {
2879
+ window.location.href = url;
2880
+ return true;
2881
+ }
2882
+ return false;
2883
+ }
3790
2884
  function isSameOrigin(url) {
3791
2885
  try {
3792
2886
  const parsed = new URL(url, window.location.origin);
@@ -3811,8 +2905,10 @@ var executeNavigate = async (action, context) => {
3811
2905
  if (target === "_blank") {
3812
2906
  window.open(url, "_blank", "noopener,noreferrer");
3813
2907
  } else if (!action.forceFullNavigation && isSameOrigin(url)) {
3814
- window.history.pushState(null, "", url);
3815
- window.dispatchEvent(new PopStateEvent("popstate"));
2908
+ if (!navigateWithFrameworkRouter(url)) {
2909
+ window.history.pushState(null, "", url);
2910
+ window.dispatchEvent(new PopStateEvent("popstate"));
2911
+ }
3816
2912
  } else {
3817
2913
  window.location.href = url;
3818
2914
  }
@@ -3903,9 +2999,9 @@ import { jsx, jsxs } from "react/jsx-runtime";
3903
2999
  function TileWheel({ tiles, intervalMs = 7e3, telemetry }) {
3904
3000
  const [index, setIndex] = useState4(0);
3905
3001
  const ordered = useMemo3(
3906
- () => [...tiles].sort((a, b) => {
3002
+ () => [...tiles].sort((a, b2) => {
3907
3003
  var _a2, _b;
3908
- return ((_a2 = a.priority) != null ? _a2 : 0) - ((_b = b.priority) != null ? _b : 0);
3004
+ return ((_a2 = a.priority) != null ? _a2 : 0) - ((_b = b2.priority) != null ? _b : 0);
3909
3005
  }),
3910
3006
  [tiles]
3911
3007
  );
@@ -4073,50 +3169,50 @@ function needsMigration(config) {
4073
3169
  }
4074
3170
 
4075
3171
  // src/overlays/schema.ts
4076
- import { z } from "zod";
4077
- var SelectorZ = z.union([
4078
- z.object({ type: z.literal("data"), key: z.string(), value: z.string().optional() }),
4079
- z.object({ type: z.literal("css"), value: z.string() }),
4080
- z.object({ type: z.literal("aria"), role: z.string().optional(), label: z.string().optional() }),
4081
- z.object({ type: z.literal("shadow-css"), value: z.string() }),
4082
- z.object({ type: z.literal("ref"), el: z.any() })
3172
+ import { z as z2 } from "zod";
3173
+ var SelectorZ = z2.union([
3174
+ z2.object({ type: z2.literal("data"), key: z2.string(), value: z2.string().optional() }),
3175
+ z2.object({ type: z2.literal("css"), value: z2.string() }),
3176
+ z2.object({ type: z2.literal("aria"), role: z2.string().optional(), label: z2.string().optional() }),
3177
+ z2.object({ type: z2.literal("shadow-css"), value: z2.string() }),
3178
+ z2.object({ type: z2.literal("ref"), el: z2.any() })
4083
3179
  // runtime-only
4084
3180
  ]);
4085
- var TooltipStepZ = z.object({
4086
- kind: z.literal("tooltip"),
4087
- id: z.string(),
3181
+ var TooltipStepZ = z2.object({
3182
+ kind: z2.literal("tooltip"),
3183
+ id: z2.string(),
4088
3184
  anchor: SelectorZ,
4089
- content: z.object({ title: z.string().optional(), body: z.string() }),
4090
- placement: z.enum(["top", "bottom", "left", "right", "auto"]).optional(),
4091
- offsetPx: z.number().optional(),
4092
- blocking: z.boolean().optional(),
4093
- trigger: z.enum(["immediate", "hover", "click"]).optional(),
4094
- dismiss: z.object({
4095
- onEsc: z.boolean().optional(),
4096
- closeButton: z.boolean().optional(),
4097
- timeoutMs: z.number().optional()
3185
+ content: z2.object({ title: z2.string().optional(), body: z2.string() }),
3186
+ placement: z2.enum(["top", "bottom", "left", "right", "auto"]).optional(),
3187
+ offsetPx: z2.number().optional(),
3188
+ blocking: z2.boolean().optional(),
3189
+ trigger: z2.enum(["immediate", "hover", "click"]).optional(),
3190
+ dismiss: z2.object({
3191
+ onEsc: z2.boolean().optional(),
3192
+ closeButton: z2.boolean().optional(),
3193
+ timeoutMs: z2.number().optional()
4098
3194
  }).optional()
4099
3195
  });
4100
- var HighlightStepZ = z.object({
4101
- kind: z.literal("highlight"),
4102
- id: z.string(),
3196
+ var HighlightStepZ = z2.object({
3197
+ kind: z2.literal("highlight"),
3198
+ id: z2.string(),
4103
3199
  anchor: SelectorZ,
4104
- copy: z.string().optional(),
4105
- ring: z.object({ paddingPx: z.number().optional(), radiusPx: z.number().optional() }).optional(),
4106
- scrim: z.object({ opacity: z.number().optional() }).optional(),
4107
- ringColor: z.string().optional(),
4108
- blocking: z.boolean().optional(),
4109
- dismiss: z.object({
4110
- onClickOutside: z.boolean().optional(),
4111
- onEsc: z.boolean().optional(),
4112
- timeoutMs: z.number().optional()
3200
+ copy: z2.string().optional(),
3201
+ ring: z2.object({ paddingPx: z2.number().optional(), radiusPx: z2.number().optional() }).optional(),
3202
+ scrim: z2.object({ opacity: z2.number().optional() }).optional(),
3203
+ ringColor: z2.string().optional(),
3204
+ blocking: z2.boolean().optional(),
3205
+ dismiss: z2.object({
3206
+ onClickOutside: z2.boolean().optional(),
3207
+ onEsc: z2.boolean().optional(),
3208
+ timeoutMs: z2.number().optional()
4113
3209
  }).optional()
4114
3210
  });
4115
- var CanvasRecipeZ = z.object({
4116
- id: z.string(),
4117
- version: z.number(),
4118
- routes: z.array(z.string()).optional(),
4119
- steps: z.array(z.union([TooltipStepZ, HighlightStepZ]))
3211
+ var CanvasRecipeZ = z2.object({
3212
+ id: z2.string(),
3213
+ version: z2.number(),
3214
+ routes: z2.array(z2.string()).optional(),
3215
+ steps: z2.array(z2.union([TooltipStepZ, HighlightStepZ]))
4120
3216
  });
4121
3217
  function validateRecipe(json) {
4122
3218
  return CanvasRecipeZ.parse(json);
@@ -4159,74 +3255,67 @@ function SmartCanvasPortal({ element, children }) {
4159
3255
  }
4160
3256
 
4161
3257
  // src/context/schema.ts
4162
- import { z as z2 } from "zod";
4163
- var PageContextZ = z2.object({
4164
- url: z2.string(),
4165
- routeId: z2.string().optional(),
4166
- title: z2.string().optional(),
4167
- locale: z2.string().optional()
3258
+ import { z as z3 } from "zod";
3259
+ var PageContextZ = z3.object({
3260
+ url: z3.string(),
3261
+ routeId: z3.string().optional(),
3262
+ title: z3.string().optional(),
3263
+ locale: z3.string().optional()
4168
3264
  });
4169
- var PageHistoryEntryZ = z2.object({
4170
- url: z2.string(),
4171
- ts: z2.number()
3265
+ var PageHistoryEntryZ = z3.object({
3266
+ url: z3.string(),
3267
+ ts: z3.number()
4172
3268
  });
4173
- var SessionContextZ = z2.object({
4174
- sessionId: z2.string(),
4175
- startTs: z2.number(),
4176
- pageHistory: z2.array(PageHistoryEntryZ).optional()
3269
+ var SessionContextZ = z3.object({
3270
+ sessionId: z3.string(),
3271
+ startTs: z3.number(),
3272
+ pageHistory: z3.array(PageHistoryEntryZ).optional()
4177
3273
  });
4178
- var ViewportContextZ = z2.object({
4179
- width: z2.number(),
4180
- height: z2.number()
3274
+ var ViewportContextZ = z3.object({
3275
+ width: z3.number(),
3276
+ height: z3.number()
4181
3277
  });
4182
- var BoundingBoxZ = z2.object({
4183
- x: z2.number(),
4184
- y: z2.number(),
4185
- w: z2.number(),
4186
- h: z2.number()
3278
+ var BoundingBoxZ = z3.object({
3279
+ x: z3.number(),
3280
+ y: z3.number(),
3281
+ w: z3.number(),
3282
+ h: z3.number()
4187
3283
  });
4188
- var AnchorStateZ = z2.object({
4189
- anchorId: z2.string(),
4190
- present: z2.boolean(),
4191
- visible: z2.boolean().optional(),
3284
+ var AnchorStateZ = z3.object({
3285
+ anchorId: z3.string(),
3286
+ present: z3.boolean(),
3287
+ visible: z3.boolean().optional(),
4192
3288
  boundingBox: BoundingBoxZ.optional()
4193
3289
  });
4194
- var AugmentationZ = z2.record(
4195
- z2.string(),
4196
- z2.union([z2.number(), z2.string(), z2.boolean(), z2.undefined()])
3290
+ var AugmentationZ = z3.record(
3291
+ z3.string(),
3292
+ z3.union([z3.number(), z3.string(), z3.boolean(), z3.undefined()])
4197
3293
  );
4198
- var RuntimeContextZ = z2.object({
3294
+ var RuntimeContextZ = z3.object({
4199
3295
  page: PageContextZ,
4200
3296
  session: SessionContextZ,
4201
3297
  viewport: ViewportContextZ,
4202
- anchors: z2.array(AnchorStateZ).optional(),
3298
+ anchors: z3.array(AnchorStateZ).optional(),
4203
3299
  augmented: AugmentationZ.optional()
4204
3300
  });
4205
3301
  function validateRuntimeContext(data) {
4206
3302
  return RuntimeContextZ.safeParse(data);
4207
3303
  }
4208
3304
 
4209
- // src/events/normalizers/posthog.ts
4210
- import {
4211
- createPostHogNormalizer,
4212
- normalizePostHogEvent,
4213
- shouldNormalizeEvent
4214
- } from "@syntrologie/event-processor/normalizers/posthog";
4215
-
4216
3305
  // src/events/schema.ts
4217
- import { z as z3 } from "zod";
4218
- var EventSourceZ = z3.enum(["posthog", "canvas", "derived"]);
4219
- var NormalizedEventZ = z3.object({
4220
- ts: z3.number(),
4221
- name: z3.string(),
3306
+ import { z as z4 } from "zod";
3307
+ var EventSourceZ = z4.enum(["posthog", "canvas", "derived"]);
3308
+ var NormalizedEventZ = z4.object({
3309
+ ts: z4.number(),
3310
+ name: z4.string(),
4222
3311
  source: EventSourceZ,
4223
- props: z3.record(z3.string(), z3.unknown()).optional(),
4224
- schemaVersion: z3.string()
3312
+ props: z4.record(z4.string(), z4.unknown()).optional(),
3313
+ schemaVersion: z4.string()
4225
3314
  });
4226
- var EventFilterZ = z3.object({
4227
- names: z3.array(z3.string()).optional(),
4228
- patterns: z3.array(z3.string()).optional(),
4229
- sources: z3.array(EventSourceZ).optional()
3315
+ var EventFilterZ = z4.object({
3316
+ names: z4.array(z4.string()).optional(),
3317
+ patterns: z4.array(z4.string()).optional(),
3318
+ sources: z4.array(EventSourceZ).optional()
4230
3319
  });
4231
3320
  function validateNormalizedEvent(data) {
4232
3321
  return NormalizedEventZ.safeParse(data);
@@ -4236,14 +3325,14 @@ function validateEventFilter(data) {
4236
3325
  }
4237
3326
 
4238
3327
  // src/state/schema.ts
4239
- import { z as z4 } from "zod";
4240
- var StoredValueZ = z4.object({
4241
- value: z4.unknown(),
4242
- expiresAt: z4.number().optional()
3328
+ import { z as z5 } from "zod";
3329
+ var StoredValueZ = z5.object({
3330
+ value: z5.unknown(),
3331
+ expiresAt: z5.number().optional()
4243
3332
  });
4244
- var FrequencyEntryZ = z4.object({
4245
- count: z4.number(),
4246
- resetAt: z4.number().optional()
3333
+ var FrequencyEntryZ = z5.object({
3334
+ count: z5.number(),
3335
+ resetAt: z5.number().optional()
4247
3336
  });
4248
3337
  function validateStoredValue(data) {
4249
3338
  return StoredValueZ.safeParse(data);
@@ -4294,6 +3383,7 @@ export {
4294
3383
  EventBus,
4295
3384
  EventCountConditionZ,
4296
3385
  EventFilterZ,
3386
+ EventHistory,
4297
3387
  EventOccurredConditionZ,
4298
3388
  EventSourceZ,
4299
3389
  ExecutorRegistry,
@@ -4447,8 +3537,10 @@ export {
4447
3537
  validateCondition,
4448
3538
  validateConfig,
4449
3539
  validateEventFilter,
3540
+ validateEventName,
4450
3541
  validateFrequencyEntry,
4451
3542
  validateNormalizedEvent,
3543
+ validateProps,
4452
3544
  validateRecipe,
4453
3545
  validateRuntimeContext,
4454
3546
  validateStoredValue,