@syntrologie/runtime-sdk 2.11.0 → 2.13.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 (57) hide show
  1. package/CAPABILITIES.md +261 -173
  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 +19 -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-GF364MMB.js} +1343 -393
  16. package/dist/chunk-GF364MMB.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 +1133 -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 +4763 -4955
  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/InterventionTracker.d.ts +23 -0
  42. package/dist/telemetry/adapters/posthog.d.ts +5 -10
  43. package/dist/telemetry/index.d.ts +1 -0
  44. package/dist/test/setup.d.ts +1 -0
  45. package/dist/token.d.ts +2 -0
  46. package/dist/version.d.ts +1 -1
  47. package/package.json +23 -29
  48. package/schema/canvas-config.schema.json +1 -1
  49. package/scripts/syntroReactPlugin.mjs +3 -0
  50. package/scripts/validate-config.mjs +42 -0
  51. package/dist/chunk-H3FAYTUV.js.map +0 -7
  52. package/dist/chunk-JMHRHAEL.js +0 -18
  53. package/dist/chunk-JMHRHAEL.js.map +0 -7
  54. package/dist/replayMirror-QZ3GQ527.js +0 -32
  55. package/dist/replayMirror-QZ3GQ527.js.map +0 -7
  56. package/dist/telemetry/replayMirror.d.ts +0 -7
  57. /package/dist/{chunk-37TTQRH5.js.map → chunk-XDYJ64IN.js.map} +0 -0
package/dist/index.js CHANGED
@@ -7,7 +7,9 @@ import {
7
7
  DEFAULT_TTL,
8
8
  EVENT_SCHEMA_VERSION,
9
9
  EventBus,
10
+ EventHistory,
10
11
  ExecutorRegistry,
12
+ InterventionTracker,
11
13
  MAX_VISIBLE_TOASTS,
12
14
  NavigationMonitor,
13
15
  NotificationToastStack,
@@ -43,6 +45,7 @@ import {
43
45
  createGrowthBookClient,
44
46
  createNoopClient,
45
47
  createPostHogClient,
48
+ createPostHogNormalizer,
46
49
  createSessionMetricTracker,
47
50
  createSmartCanvas,
48
51
  createSmartCanvasController,
@@ -70,6 +73,7 @@ import {
70
73
  interpolateTemplate,
71
74
  isCoreActionKind,
72
75
  matchEvent,
76
+ normalizePostHogEvent,
73
77
  playEnterAnimation,
74
78
  playExitAnimation,
75
79
  purple,
@@ -81,6 +85,7 @@ import {
81
85
  runtime2,
82
86
  setupAdjacentPositioning,
83
87
  setupInlinePositioning,
88
+ shouldNormalizeEvent,
84
89
  slateGrey,
85
90
  useDecision,
86
91
  useNotifications,
@@ -96,8 +101,10 @@ import {
96
101
  useViewportContext,
97
102
  validateAction,
98
103
  validateActions,
104
+ validateEventName,
105
+ validateProps,
99
106
  widgetRegistry
100
- } from "./chunk-H3FAYTUV.js";
107
+ } from "./chunk-GF364MMB.js";
101
108
  import {
102
109
  AddClassZ,
103
110
  AnchorIdZ,
@@ -131,8 +138,8 @@ import {
131
138
  WaitZ,
132
139
  WidgetConfigZ,
133
140
  coreActionStepSchemas
134
- } from "./chunk-NBFQGKSV.js";
135
- import "./chunk-37TTQRH5.js";
141
+ } from "./chunk-L6RJMBR2.js";
142
+ import "./chunk-XDYJ64IN.js";
136
143
  import {
137
144
  ActivationConfigZ,
138
145
  AnchorVisibleConditionZ,
@@ -157,14 +164,12 @@ import {
157
164
  StateEqualsConditionZ,
158
165
  TriggerWhenZ,
159
166
  ViewportConditionZ,
167
+ __publicField,
160
168
  decisionSchemas,
161
169
  validateActivationConfig,
162
170
  validateCondition,
163
171
  validateStrategy
164
- } from "./chunk-Q77NT67W.js";
165
- import {
166
- __publicField
167
- } from "./chunk-JMHRHAEL.js";
172
+ } from "./chunk-BU4Z6PD7.js";
168
173
 
169
174
  // src/index.ts
170
175
  import React4 from "react";
@@ -256,8 +261,8 @@ var nextId = 0;
256
261
  function generateId() {
257
262
  return `msg-${Date.now()}-${++nextId}`;
258
263
  }
259
- function useChat(options2) {
260
- const { backendUrl, tileId, runtime: runtime7, greeting, maxHistory = 20, mlflowRunId, config } = options2;
264
+ function useChat(options) {
265
+ const { backendUrl, tileId, runtime: runtime7, greeting, maxHistory = 20, mlflowRunId, config } = options;
261
266
  const [messages, setMessages] = useState(() => {
262
267
  if (greeting) {
263
268
  return [
@@ -290,9 +295,9 @@ function useChat(options2) {
290
295
  setIsLoading(true);
291
296
  try {
292
297
  const currentMessages = [...messages, userMessage];
293
- const historySlice = currentMessages.slice(-maxHistory).map((m) => ({
294
- role: m.role,
295
- content: m.text
298
+ const historySlice = currentMessages.slice(-maxHistory).map((m2) => ({
299
+ role: m2.role,
300
+ content: m2.text
296
301
  }));
297
302
  const response = await sendMessage(backendUrl, {
298
303
  message: trimmed,
@@ -631,2186 +636,1224 @@ var executorDefinitions = [
631
636
  import { jsx as _jsx2, jsxs as _jsxs2 } from "react/jsx-runtime";
632
637
 
633
638
  // ../../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
- };
639
+ function M() {
640
+ return { async: false, breaks: false, extensions: null, gfm: true, hooks: null, pedantic: false, renderer: null, silent: false, tokenizer: null, walkTokens: null };
647
641
  }
648
- var _defaults = _getDefaults();
649
- function changeDefaults(newDefaults) {
650
- _defaults = newDefaults;
642
+ var T = M();
643
+ function G(u3) {
644
+ T = u3;
651
645
  }
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;
646
+ var _ = { exec: () => null };
647
+ function k(u3, e = "") {
648
+ let t = typeof u3 == "string" ? u3 : u3.source, n = { replace: (r, i) => {
649
+ let s = typeof i == "string" ? i : i.source;
650
+ return s = s.replace(m.caret, "$1"), t = t.replace(r, s), n;
651
+ }, getRegex: () => new RegExp(t, e) };
652
+ return n;
667
653
  }
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
- }
654
+ var Re = (() => {
655
+ try {
656
+ return !!new RegExp("(?<=1)(?<!1)");
657
+ } catch {
658
+ return false;
886
659
  }
887
- return html2;
660
+ })();
661
+ 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)}}>`) };
662
+ var Te = /^(?:[ \t]*(?:\n|$))+/;
663
+ var Oe = /^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/;
664
+ var we = /^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/;
665
+ var A = /^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/;
666
+ var ye = /^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/;
667
+ var N = / {0,3}(?:[*+-]|\d{1,9}[.)])/;
668
+ var re = /^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/;
669
+ 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();
670
+ 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();
671
+ var Q = /^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/;
672
+ var Se = /^[^\n]+/;
673
+ var j = /(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/;
674
+ 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();
675
+ var _e = k(/^(bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g, N).getRegex();
676
+ 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";
677
+ var F = /<!--(?:-?>|[\s\S]*?(?:-->|$))/;
678
+ 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();
679
+ 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();
680
+ var Me = k(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph", ie).getRegex();
681
+ 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 };
682
+ 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();
683
+ 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() };
684
+ 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} *[^
685
+ ]`).replace("lheading", se).replace("|table", "").replace("blockquote", " {0,3}>").replace("|fences", "").replace("|list", "").replace("|html", "").replace("|tag", "").getRegex() };
686
+ var Ie = /^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/;
687
+ var Ae = /^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/;
688
+ var oe = /^( {2,}|\\)\n(?!\s*$)/;
689
+ var Ce = /^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/;
690
+ var v = /[\p{P}\p{S}]/u;
691
+ var K = /[\s\p{P}\p{S}]/u;
692
+ var ae = /[^\s\p{P}\p{S}]/u;
693
+ var Be = k(/^((?![*_])punctSpace)/, "u").replace(/punctSpace/g, K).getRegex();
694
+ var le = /(?!~)[\p{P}\p{S}]/u;
695
+ var De = /(?!~)[\s\p{P}\p{S}]/u;
696
+ var qe = /(?:[^\s\p{P}\p{S}]|~)/u;
697
+ var ue = /(?![*_])[\p{P}\p{S}]/u;
698
+ var ve = /(?![*_])[\s\p{P}\p{S}]/u;
699
+ var He = /(?:[^\s\p{P}\p{S}]|[*_])/u;
700
+ 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();
701
+ var pe = /^(?:\*+(?:((?!\*)punct)|[^\s*]))|^_+(?:((?!_)punct)|([^\s_]))/;
702
+ var Ze = k(pe, "u").replace(/punct/g, v).getRegex();
703
+ var Ne = k(pe, "u").replace(/punct/g, le).getRegex();
704
+ var ce = "^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)";
705
+ var Qe = k(ce, "gu").replace(/notPunctSpace/g, ae).replace(/punctSpace/g, K).replace(/punct/g, v).getRegex();
706
+ var je = k(ce, "gu").replace(/notPunctSpace/g, qe).replace(/punctSpace/g, De).replace(/punct/g, le).getRegex();
707
+ 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();
708
+ var Ue = k(/^~~?(?:((?!~)punct)|[^\s~])/, "u").replace(/punct/g, ue).getRegex();
709
+ var Ke = "^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)";
710
+ var We = k(Ke, "gu").replace(/notPunctSpace/g, He).replace(/punctSpace/g, ve).replace(/punct/g, ue).getRegex();
711
+ var Xe = k(/\\(punct)/, "gu").replace(/punct/g, v).getRegex();
712
+ 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();
713
+ var Ve = k(F).replace("(?:-->|$)", "-->").getRegex();
714
+ 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();
715
+ var D = /(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+[^`]*?`+(?!`)|[^\[\]\\`])*?/;
716
+ 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();
717
+ var he = k(/^!?\[(label)\]\[(ref)\]/).replace("label", D).replace("ref", j).getRegex();
718
+ var ke = k(/^!?\[(ref)\](?:\[\])?/).replace("ref", j).getRegex();
719
+ var tt = k("reflink|nolink(?!\\()", "g").replace("reflink", he).replace("nolink", ke).getRegex();
720
+ var ne = /[hH][tT][tT][pP][sS]?|[fF][tT][pP]/;
721
+ 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: _ };
722
+ var nt = { ...W, link: k(/^!?\[(label)\]\((.*?)\)/).replace("label", D).getRegex(), reflink: k(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label", D).getRegex() };
723
+ 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() };
724
+ var rt = { ...Z, br: k(oe).replace("{2,}", "*").getRegex(), text: k(Z.text).replace("\\b_", "\\b_| {2,}\\n").replace(/\{2,\}/g, "*").getRegex() };
725
+ var C = { normal: U, gfm: ze, pedantic: Ee };
726
+ var z = { normal: W, gfm: Z, breaks: rt, pedantic: nt };
727
+ var st = { "&": "&amp;", "<": "&lt;", ">": "&gt;", '"': "&quot;", "'": "&#39;" };
728
+ var de = (u3) => st[u3];
729
+ function O(u3, e) {
730
+ if (e) {
731
+ if (m.escapeTest.test(u3)) return u3.replace(m.escapeReplace, de);
732
+ } else if (m.escapeTestNoEncode.test(u3)) return u3.replace(m.escapeReplaceNoEncode, de);
733
+ return u3;
888
734
  }
889
- function cleanUrl(href) {
735
+ function X(u3) {
890
736
  try {
891
- href = encodeURI(href).replace(other.percentDecode, "%");
737
+ u3 = encodeURI(u3).replace(m.percentDecode, "%");
892
738
  } catch {
893
739
  return null;
894
740
  }
895
- return href;
741
+ return u3;
896
742
  }
897
- function splitCells(tableRow, count) {
743
+ function J(u3, e) {
898
744
  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;
745
+ let t = u3.replace(m.findPipe, (i, s, a) => {
746
+ let o = false, l = s;
747
+ for (; --l >= 0 && a[l] === "\\"; ) o = !o;
748
+ return o ? "|" : " |";
749
+ }), n = t.split(m.splitPipe), r = 0;
750
+ 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);
751
+ else for (; n.length < e; ) n.push("");
752
+ for (; r < n.length; r++) n[r] = n[r].trim().replace(m.slashPipe, "|");
753
+ return n;
927
754
  }
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);
755
+ function E(u3, e, t) {
756
+ let n = u3.length;
757
+ if (n === 0) return "";
758
+ let r = 0;
759
+ for (; r < n; ) {
760
+ let i = u3.charAt(n - r - 1);
761
+ if (i === e && !t) r++;
762
+ else if (i !== e && t) r++;
763
+ else break;
764
+ }
765
+ return u3.slice(0, n - r);
945
766
  }
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;
767
+ function ge(u3, e) {
768
+ if (u3.indexOf(e[1]) === -1) return -1;
769
+ let t = 0;
770
+ for (let n = 0; n < u3.length; n++) if (u3[n] === "\\") n++;
771
+ else if (u3[n] === e[0]) t++;
772
+ else if (u3[n] === e[1] && (t--, t < 0)) return n;
773
+ return t > 0 ? -2 : -1;
967
774
  }
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;
775
+ function fe(u3, e = 0) {
776
+ let t = e, n = "";
777
+ for (let r of u3) if (r === " ") {
778
+ let i = 4 - t % 4;
779
+ n += " ".repeat(i), t += i;
780
+ } else n += r, t++;
781
+ return n;
983
782
  }
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");
783
+ function me(u3, e, t, n, r) {
784
+ let i = e.href, s = e.title || null, a = u3[1].replace(r.other.outputLinkReplace, "$1");
785
+ n.state.inLink = true;
786
+ let o = { type: u3[0].charAt(0) === "!" ? "image" : "link", raw: t, href: i, title: s, text: a, tokens: n.inlineTokens(a) };
787
+ return n.state.inLink = false, o;
788
+ }
789
+ function it(u3, e, t) {
790
+ let n = u3.match(t.other.indentCodeCompensation);
791
+ if (n === null) return e;
792
+ let r = n[1];
793
+ return e.split(`
794
+ `).map((i) => {
795
+ let s = i.match(t.other.beginningSpace);
796
+ if (s === null) return i;
797
+ let [a] = s;
798
+ return a.length >= r.length ? i.slice(r.length) : i;
799
+ }).join(`
800
+ `);
1001
801
  }
1002
- var _Tokenizer = class {
1003
- // set by the lexer
1004
- constructor(options2) {
802
+ var w = class {
803
+ constructor(e) {
1005
804
  __publicField(this, "options");
1006
805
  __publicField(this, "rules");
1007
- // set by the lexer
1008
806
  __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) {
807
+ this.options = e || T;
808
+ }
809
+ space(e) {
810
+ let t = this.rules.block.newline.exec(e);
811
+ if (t && t[0].length > 0) return { type: "space", raw: t[0] };
812
+ }
813
+ code(e) {
814
+ let t = this.rules.block.code.exec(e);
815
+ if (t) {
816
+ let n = t[0].replace(this.rules.other.codeRemoveIndent, "");
817
+ return { type: "code", raw: t[0], codeBlockStyle: "indented", text: this.options.pedantic ? n : E(n, `
818
+ `) };
819
+ }
820
+ }
821
+ fences(e) {
822
+ let t = this.rules.block.fences.exec(e);
823
+ if (t) {
824
+ let n = t[0], r = it(n, t[3] || "", this.rules);
825
+ return { type: "code", raw: n, lang: t[2] ? t[2].trim().replace(this.rules.inline.anyPunctuation, "$1") : t[2], text: r };
826
+ }
827
+ }
828
+ heading(e) {
829
+ let t = this.rules.block.heading.exec(e);
830
+ if (t) {
831
+ let n = t[2].trim();
832
+ if (this.rules.other.endingHash.test(n)) {
833
+ let r = E(n, "#");
834
+ (this.options.pedantic || !r || this.rules.other.endingSpaceChar.test(r)) && (n = r.trim());
835
+ }
836
+ return { type: "heading", raw: t[0], depth: t[1].length, text: n, tokens: this.lexer.inline(n) };
837
+ }
838
+ }
839
+ hr(e) {
840
+ let t = this.rules.block.hr.exec(e);
841
+ if (t) return { type: "hr", raw: E(t[0], `
842
+ `) };
843
+ }
844
+ blockquote(e) {
845
+ let t = this.rules.block.blockquote.exec(e);
846
+ if (t) {
847
+ let n = E(t[0], `
848
+ `).split(`
849
+ `), r = "", i = "", s = [];
850
+ for (; n.length > 0; ) {
851
+ let a = false, o = [], l;
852
+ for (l = 0; l < n.length; l++) if (this.rules.other.blockquoteStart.test(n[l])) o.push(n[l]), a = true;
853
+ else if (!a) o.push(n[l]);
854
+ else break;
855
+ n = n.slice(l);
856
+ let p = o.join(`
857
+ `), c = p.replace(this.rules.other.blockquoteSetextReplace, `
858
+ $1`).replace(this.rules.other.blockquoteSetextReplace2, "");
859
+ r = r ? `${r}
860
+ ${p}` : p, i = i ? `${i}
861
+ ${c}` : c;
862
+ let d = this.lexer.state.top;
863
+ if (this.lexer.state.top = true, this.lexer.blockTokens(c, s, true), this.lexer.state.top = d, n.length === 0) break;
864
+ let h = s.at(-1);
865
+ if ((h == null ? void 0 : h.type) === "code") break;
866
+ if ((h == null ? void 0 : h.type) === "blockquote") {
867
+ let R = h, f = R.raw + `
868
+ ` + n.join(`
869
+ `), S = this.blockquote(f);
870
+ 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
871
  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");
872
+ } else if ((h == null ? void 0 : h.type) === "list") {
873
+ let R = h, f = R.raw + `
874
+ ` + n.join(`
875
+ `), S = this.list(f);
876
+ 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(`
877
+ `);
1129
878
  continue;
1130
879
  }
1131
880
  }
1132
- return {
1133
- type: "blockquote",
1134
- raw,
1135
- tokens,
1136
- text
1137
- };
881
+ return { type: "blockquote", raw: r, tokens: s, text: i };
1138
882
  }
1139
883
  }
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;
884
+ list(e) {
885
+ var _a2, _b;
886
+ let t = this.rules.block.list.exec(e);
887
+ if (t) {
888
+ let n = t[1].trim(), r = n.length > 1, i = { type: "list", raw: "", ordered: r, start: r ? +n.slice(0, -1) : "", loose: false, items: [] };
889
+ n = r ? `\\d{1,9}\\${n.slice(-1)}` : `\\${n}`, this.options.pedantic && (n = r ? n : "[*+-]");
890
+ let s = this.rules.other.listItemRegex(n), a = false;
891
+ for (; e; ) {
892
+ let l = false, p = "", c = "";
893
+ if (!(t = s.exec(e)) || this.rules.block.hr.test(e)) break;
894
+ p = t[0], e = e.substring(p.length);
895
+ let d = fe(t[2].split(`
896
+ `, 1)[0], t[1].length), h = e.split(`
897
+ `, 1)[0], R = !d.trim(), f = 0;
898
+ 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 + `
899
+ `, e = e.substring(h.length + 1), l = true), !l) {
900
+ 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);
901
+ for (; e; ) {
902
+ let H = e.split(`
903
+ `, 1)[0], I;
904
+ 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;
905
+ if (I.search(this.rules.other.nonSpaceChar) >= f || !h.trim()) c += `
906
+ ` + I.slice(f);
907
+ else {
908
+ if (R || d.replace(this.rules.other.tabCharGlobal, " ").search(this.rules.other.nonSpaceChar) >= 4 || Y.test(d) || ee.test(d) || V.test(d)) break;
909
+ c += `
910
+ ` + h;
1244
911
  }
1245
- raw += rawLine + "\n";
1246
- src = src.substring(rawLine.length + 1);
1247
- line = nextLineWithoutTabs.slice(indent);
912
+ R = !h.trim(), p += H + `
913
+ `, e = e.substring(H.length + 1), d = I.slice(f);
1248
914
  }
1249
915
  }
1250
- if (!list2.loose) {
1251
- if (endsWithBlankLine) {
1252
- list2.loose = true;
1253
- } else if (this.rules.other.doubleBlankLine.test(raw)) {
1254
- endsWithBlankLine = true;
916
+ 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;
917
+ }
918
+ let o = i.items.at(-1);
919
+ if (o) o.raw = o.raw.trimEnd(), o.text = o.text.trimEnd();
920
+ else return;
921
+ i.raw = i.raw.trimEnd();
922
+ for (let l of i.items) {
923
+ if (this.lexer.state.top = false, l.tokens = this.lexer.blockTokens(l.text, []), l.task) {
924
+ 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") {
925
+ 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, "");
926
+ for (let c = this.lexer.inlineQueue.length - 1; c >= 0; c--) if (this.rules.other.listIsTask.test(this.lexer.inlineQueue[c].src)) {
927
+ this.lexer.inlineQueue[c].src = this.lexer.inlineQueue[c].src.replace(this.rules.other.listReplaceTask, "");
928
+ break;
929
+ }
1255
930
  }
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, "");
931
+ let p = this.rules.other.listTaskCheckbox.exec(l.raw);
932
+ if (p) {
933
+ let c = { type: "checkbox", raw: p[0] + " ", checked: p[0] !== "[ ]" };
934
+ 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
935
  }
1265
936
  }
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;
937
+ if (!i.loose) {
938
+ let p = l.tokens.filter((d) => d.type === "space"), c = p.length > 0 && p.some((d) => this.rules.other.anyLine.test(d.raw));
939
+ i.loose = c;
1292
940
  }
1293
941
  }
1294
- if (list2.loose) {
1295
- for (let i = 0; i < list2.items.length; i++) {
1296
- list2.items[i].loose = true;
1297
- }
942
+ if (i.loose) for (let l of i.items) {
943
+ l.loose = true;
944
+ for (let p of l.tokens) p.type === "text" && (p.type = "paragraph");
1298
945
  }
1299
- return list2;
946
+ return i;
1300
947
  }
1301
948
  }
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
- }
949
+ html(e) {
950
+ let t = this.rules.block.html.exec(e);
951
+ if (t) return { type: "html", block: true, raw: t[0], pre: t[1] === "pre" || t[1] === "script" || t[1] === "style", text: t[0] };
1314
952
  }
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
- };
953
+ def(e) {
954
+ let t = this.rules.block.def.exec(e);
955
+ if (t) {
956
+ 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];
957
+ return { type: "def", tag: n, raw: t[0], href: r, title: i };
1328
958
  }
1329
959
  }
1330
- table(src) {
960
+ table(e) {
1331
961
  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
- }
962
+ let t = this.rules.block.table.exec(e);
963
+ if (!t || !this.rules.other.tableDelimiter.test(t[2])) return;
964
+ 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(`
965
+ `) : [], s = { type: "table", raw: t[0], header: [], align: [], rows: [] };
966
+ if (n.length === r.length) {
967
+ 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);
968
+ 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] });
969
+ 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] })));
970
+ return s;
971
+ }
972
+ }
973
+ lheading(e) {
974
+ let t = this.rules.block.lheading.exec(e);
975
+ if (t) return { type: "heading", raw: t[0], depth: t[2].charAt(0) === "=" ? 1 : 2, text: t[1], tokens: this.lexer.inline(t[1]) };
976
+ }
977
+ paragraph(e) {
978
+ let t = this.rules.block.paragraph.exec(e);
979
+ if (t) {
980
+ let n = t[1].charAt(t[1].length - 1) === `
981
+ ` ? t[1].slice(0, -1) : t[1];
982
+ return { type: "paragraph", raw: t[0], text: n, tokens: this.lexer.inline(n) };
983
+ }
984
+ }
985
+ text(e) {
986
+ let t = this.rules.block.text.exec(e);
987
+ if (t) return { type: "text", raw: t[0], text: t[0], tokens: this.lexer.inline(t[0]) };
988
+ }
989
+ escape(e) {
990
+ let t = this.rules.inline.escape.exec(e);
991
+ if (t) return { type: "escape", raw: t[0], text: t[1] };
992
+ }
993
+ tag(e) {
994
+ let t = this.rules.inline.tag.exec(e);
995
+ 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] };
996
+ }
997
+ link(e) {
998
+ let t = this.rules.inline.link.exec(e);
999
+ if (t) {
1000
+ let n = t[2].trim();
1001
+ if (!this.options.pedantic && this.rules.other.startAngleBracket.test(n)) {
1002
+ if (!this.rules.other.endAngleBracket.test(n)) return;
1003
+ let s = E(n.slice(0, -1), "\\");
1004
+ if ((n.length - s.length) % 2 === 0) return;
1463
1005
  } 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] = "";
1006
+ let s = ge(t[2], "()");
1007
+ if (s === -2) return;
1008
+ if (s > -1) {
1009
+ let o = (t[0].indexOf("!") === 0 ? 5 : 4) + t[1].length + s;
1010
+ t[2] = t[2].substring(0, s), t[0] = t[0].substring(0, o).trim(), t[3] = "";
1474
1011
  }
1475
1012
  }
1476
- let href = cap[2];
1477
- let title = "";
1013
+ let r = t[2], i = "";
1478
1014
  if (this.options.pedantic) {
1479
- const link2 = this.rules.other.pedanticHrefTitle.exec(href);
1480
- if (link2) {
1481
- href = link2[1];
1482
- title = link2[3];
1015
+ let s = this.rules.other.pedanticHrefTitle.exec(r);
1016
+ s && (r = s[1], i = s[3]);
1017
+ } else i = t[3] ? t[3].slice(1, -1) : "";
1018
+ 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);
1019
+ }
1020
+ }
1021
+ reflink(e, t) {
1022
+ let n;
1023
+ if ((n = this.rules.inline.reflink.exec(e)) || (n = this.rules.inline.nolink.exec(e))) {
1024
+ let r = (n[2] || n[1]).replace(this.rules.other.multipleSpaceGlobal, " "), i = t[r.toLowerCase()];
1025
+ if (!i) {
1026
+ let s = n[0].charAt(0);
1027
+ return { type: "text", raw: s, text: s };
1028
+ }
1029
+ return me(n, i, n[0], this.lexer, this.rules);
1030
+ }
1031
+ }
1032
+ emStrong(e, t, n = "") {
1033
+ let r = this.rules.inline.emStrongLDelim.exec(e);
1034
+ if (!r || r[3] && n.match(this.rules.other.unicodeAlphaNumeric)) return;
1035
+ if (!(r[1] || r[2] || "") || !n || this.rules.inline.punctuation.exec(n)) {
1036
+ let s = [...r[0]].length - 1, a, o, l = s, p = 0, c = r[0][0] === "*" ? this.rules.inline.emStrongRDelimAst : this.rules.inline.emStrongRDelimUnd;
1037
+ for (c.lastIndex = 0, t = t.slice(-1 * e.length + s); (r = c.exec(t)) != null; ) {
1038
+ if (a = r[1] || r[2] || r[3] || r[4] || r[5] || r[6], !a) continue;
1039
+ if (o = [...a].length, r[3] || r[4]) {
1040
+ l += o;
1041
+ continue;
1042
+ } else if ((r[5] || r[6]) && s % 3 && !((s + o) % 3)) {
1043
+ p += o;
1044
+ continue;
1483
1045
  }
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);
1046
+ if (l -= o, l > 0) continue;
1047
+ o = Math.min(o, o + l + p);
1048
+ let d = [...r[0]][0].length, h = e.slice(0, s + r.index + d + o);
1049
+ if (Math.min(s, o) % 2) {
1050
+ let f = h.slice(1, -1);
1051
+ return { type: "em", raw: h, text: f, tokens: this.lexer.inlineTokens(f) };
1493
1052
  }
1053
+ let R = h.slice(2, -2);
1054
+ return { type: "strong", raw: h, text: R, tokens: this.lexer.inlineTokens(R) };
1494
1055
  }
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
1056
  }
1500
1057
  }
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);
1058
+ codespan(e) {
1059
+ let t = this.rules.inline.code.exec(e);
1060
+ if (t) {
1061
+ 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);
1062
+ return r && i && (n = n.substring(1, n.length - 1)), { type: "codespan", raw: t[0], text: n };
1515
1063
  }
1516
1064
  }
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;
1065
+ br(e) {
1066
+ let t = this.rules.inline.br.exec(e);
1067
+ if (t) return { type: "br", raw: t[0] };
1068
+ }
1069
+ del(e, t, n = "") {
1070
+ let r = this.rules.inline.delLDelim.exec(e);
1071
+ if (!r) return;
1072
+ if (!(r[1] || "") || !n || this.rules.inline.punctuation.exec(n)) {
1073
+ let s = [...r[0]].length - 1, a, o, l = s, p = this.rules.inline.delRDelim;
1074
+ for (p.lastIndex = 0, t = t.slice(-1 * e.length + s); (r = p.exec(t)) != null; ) {
1075
+ if (a = r[1] || r[2] || r[3] || r[4] || r[5] || r[6], !a || (o = [...a].length, o !== s)) continue;
1076
+ if (r[3] || r[4]) {
1077
+ l += o;
1534
1078
  continue;
1535
- } else if (match[5] || match[6]) {
1536
- if (lLength % 3 && !((lLength + rLength) % 3)) {
1537
- midDelimTotal += rLength;
1538
- continue;
1539
- }
1540
1079
  }
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);
1080
+ if (l -= o, l > 0) continue;
1081
+ o = Math.min(o, o + l);
1082
+ let c = [...r[0]][0].length, d = e.slice(0, s + r.index + c + o), h = d.slice(s, -s);
1083
+ return { type: "del", raw: d, text: h, tokens: this.lexer.inlineTokens(h) };
1573
1084
  }
1574
- return {
1575
- type: "codespan",
1576
- raw: cap[0],
1577
- text
1578
- };
1579
1085
  }
1580
1086
  }
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
- };
1087
+ autolink(e) {
1088
+ let t = this.rules.inline.autolink.exec(e);
1089
+ if (t) {
1090
+ let n, r;
1091
+ 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
1092
  }
1626
1093
  }
1627
- url(src) {
1094
+ url(e) {
1628
1095
  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
- }
1096
+ let t;
1097
+ if (t = this.rules.inline.url.exec(e)) {
1098
+ let n, r;
1099
+ if (t[2] === "@") n = t[0], r = "mailto:" + n;
1100
+ else {
1101
+ let i;
1102
+ do
1103
+ i = t[0], t[0] = (_b = (_a2 = this.rules.inline._backpedal.exec(t[0])) == null ? void 0 : _a2[0]) != null ? _b : "";
1104
+ while (i !== t[0]);
1105
+ n = t[0], t[1] === "www." ? r = "http://" + t[0] : r = t[0];
1647
1106
  }
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
- };
1107
+ return { type: "link", raw: t[0], text: n, href: r, tokens: [{ type: "text", raw: n, text: n }] };
1661
1108
  }
1662
1109
  }
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
- };
1110
+ inlineText(e) {
1111
+ let t = this.rules.inline.text.exec(e);
1112
+ if (t) {
1113
+ let n = this.lexer.state.inRawBlock;
1114
+ return { type: "text", raw: t[0], text: t[0], escaped: n };
1673
1115
  }
1674
1116
  }
1675
1117
  };
1676
- var _Lexer = class __Lexer {
1677
- constructor(options2) {
1118
+ var x = class u {
1119
+ constructor(e) {
1678
1120
  __publicField(this, "tokens");
1679
1121
  __publicField(this, "options");
1680
1122
  __publicField(this, "state");
1681
- __publicField(this, "tokenizer");
1682
1123
  __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;
1124
+ __publicField(this, "tokenizer");
1125
+ 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 };
1126
+ let t = { other: m, block: C.normal, inline: z.normal };
1127
+ 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
1128
  }
1714
- /**
1715
- * Expose Rules
1716
- */
1717
1129
  static get rules() {
1718
- return {
1719
- block,
1720
- inline
1721
- };
1130
+ return { block: C, inline: z };
1722
1131
  }
1723
- /**
1724
- * Static Lex Method
1725
- */
1726
- static lex(src, options2) {
1727
- const lexer2 = new __Lexer(options2);
1728
- return lexer2.lex(src);
1132
+ static lex(e, t) {
1133
+ return new u(t).lex(e);
1729
1134
  }
1730
- /**
1731
- * Static Lex Inline Method
1732
- */
1733
- static lexInline(src, options2) {
1734
- const lexer2 = new __Lexer(options2);
1735
- return lexer2.inlineTokens(src);
1135
+ static lexInline(e, t) {
1136
+ return new u(t).inlineTokens(e);
1736
1137
  }
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);
1138
+ lex(e) {
1139
+ e = e.replace(m.carriageReturn, `
1140
+ `), this.blockTokens(e, this.tokens);
1141
+ for (let t = 0; t < this.inlineQueue.length; t++) {
1142
+ let n = this.inlineQueue[t];
1143
+ this.inlineTokens(n.src, n.tokens);
1746
1144
  }
1747
- this.inlineQueue = [];
1748
- return this.tokens;
1145
+ return this.inlineQueue = [], this.tokens;
1749
1146
  }
1750
- blockTokens(src, tokens = [], lastParagraphClipped = false) {
1147
+ blockTokens(e, t = [], n = false) {
1751
1148
  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
- }
1149
+ for (this.options.pedantic && (e = e.replace(m.tabCharGlobal, " ").replace(m.spaceLine, "")); e; ) {
1150
+ let r;
1151
+ 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;
1152
+ if (r = this.tokenizer.space(e)) {
1153
+ e = e.substring(r.raw.length);
1154
+ let s = t.at(-1);
1155
+ r.raw.length === 1 && s !== void 0 ? s.raw += `
1156
+ ` : t.push(r);
1775
1157
  continue;
1776
1158
  }
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
- }
1159
+ if (r = this.tokenizer.code(e)) {
1160
+ e = e.substring(r.raw.length);
1161
+ let s = t.at(-1);
1162
+ (s == null ? void 0 : s.type) === "paragraph" || (s == null ? void 0 : s.type) === "text" ? (s.raw += (s.raw.endsWith(`
1163
+ `) ? "" : `
1164
+ `) + r.raw, s.text += `
1165
+ ` + r.text, this.inlineQueue.at(-1).src = s.text) : t.push(r);
1787
1166
  continue;
1788
1167
  }
1789
- if (token = this.tokenizer.fences(src)) {
1790
- src = src.substring(token.raw.length);
1791
- tokens.push(token);
1168
+ if (r = this.tokenizer.fences(e)) {
1169
+ e = e.substring(r.raw.length), t.push(r);
1792
1170
  continue;
1793
1171
  }
1794
- if (token = this.tokenizer.heading(src)) {
1795
- src = src.substring(token.raw.length);
1796
- tokens.push(token);
1172
+ if (r = this.tokenizer.heading(e)) {
1173
+ e = e.substring(r.raw.length), t.push(r);
1797
1174
  continue;
1798
1175
  }
1799
- if (token = this.tokenizer.hr(src)) {
1800
- src = src.substring(token.raw.length);
1801
- tokens.push(token);
1176
+ if (r = this.tokenizer.hr(e)) {
1177
+ e = e.substring(r.raw.length), t.push(r);
1802
1178
  continue;
1803
1179
  }
1804
- if (token = this.tokenizer.blockquote(src)) {
1805
- src = src.substring(token.raw.length);
1806
- tokens.push(token);
1180
+ if (r = this.tokenizer.blockquote(e)) {
1181
+ e = e.substring(r.raw.length), t.push(r);
1807
1182
  continue;
1808
1183
  }
1809
- if (token = this.tokenizer.list(src)) {
1810
- src = src.substring(token.raw.length);
1811
- tokens.push(token);
1184
+ if (r = this.tokenizer.list(e)) {
1185
+ e = e.substring(r.raw.length), t.push(r);
1812
1186
  continue;
1813
1187
  }
1814
- if (token = this.tokenizer.html(src)) {
1815
- src = src.substring(token.raw.length);
1816
- tokens.push(token);
1188
+ if (r = this.tokenizer.html(e)) {
1189
+ e = e.substring(r.raw.length), t.push(r);
1817
1190
  continue;
1818
1191
  }
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
- }
1192
+ if (r = this.tokenizer.def(e)) {
1193
+ e = e.substring(r.raw.length);
1194
+ let s = t.at(-1);
1195
+ (s == null ? void 0 : s.type) === "paragraph" || (s == null ? void 0 : s.type) === "text" ? (s.raw += (s.raw.endsWith(`
1196
+ `) ? "" : `
1197
+ `) + r.raw, s.text += `
1198
+ ` + 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
1199
  continue;
1833
1200
  }
1834
- if (token = this.tokenizer.table(src)) {
1835
- src = src.substring(token.raw.length);
1836
- tokens.push(token);
1201
+ if (r = this.tokenizer.table(e)) {
1202
+ e = e.substring(r.raw.length), t.push(r);
1837
1203
  continue;
1838
1204
  }
1839
- if (token = this.tokenizer.lheading(src)) {
1840
- src = src.substring(token.raw.length);
1841
- tokens.push(token);
1205
+ if (r = this.tokenizer.lheading(e)) {
1206
+ e = e.substring(r.raw.length), t.push(r);
1842
1207
  continue;
1843
1208
  }
1844
- let cutSrc = src;
1209
+ let i = e;
1845
1210
  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);
1211
+ let s = 1 / 0, a = e.slice(1), o;
1212
+ this.options.extensions.startBlock.forEach((l) => {
1213
+ o = l.call({ lexer: this }, a), typeof o == "number" && o >= 0 && (s = Math.min(s, o));
1214
+ }), s < 1 / 0 && s >= 0 && (i = e.substring(0, s + 1));
1215
+ }
1216
+ if (this.state.top && (r = this.tokenizer.paragraph(i))) {
1217
+ let s = t.at(-1);
1218
+ n && (s == null ? void 0 : s.type) === "paragraph" ? (s.raw += (s.raw.endsWith(`
1219
+ `) ? "" : `
1220
+ `) + r.raw, s.text += `
1221
+ ` + 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
1222
  continue;
1872
1223
  }
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
- }
1224
+ if (r = this.tokenizer.text(e)) {
1225
+ e = e.substring(r.raw.length);
1226
+ let s = t.at(-1);
1227
+ (s == null ? void 0 : s.type) === "text" ? (s.raw += (s.raw.endsWith(`
1228
+ `) ? "" : `
1229
+ `) + r.raw, s.text += `
1230
+ ` + r.text, this.inlineQueue.pop(), this.inlineQueue.at(-1).src = s.text) : t.push(r);
1884
1231
  continue;
1885
1232
  }
1886
- if (src) {
1887
- const errMsg = "Infinite loop on byte: " + src.charCodeAt(0);
1233
+ if (e) {
1234
+ let s = "Infinite loop on byte: " + e.charCodeAt(0);
1888
1235
  if (this.options.silent) {
1889
- console.error(errMsg);
1236
+ console.error(s);
1890
1237
  break;
1891
- } else {
1892
- throw new Error(errMsg);
1893
- }
1238
+ } else throw new Error(s);
1894
1239
  }
1895
1240
  }
1896
- this.state.top = true;
1897
- return tokens;
1241
+ return this.state.top = true, t;
1898
1242
  }
1899
- inline(src, tokens = []) {
1900
- this.inlineQueue.push({ src, tokens });
1901
- return tokens;
1243
+ inline(e, t = []) {
1244
+ return this.inlineQueue.push({ src: e, tokens: t }), t;
1902
1245
  }
1903
- /**
1904
- * Lexing/Compiling
1905
- */
1906
- inlineTokens(src, tokens = []) {
1907
- var _a2, _b, _c;
1908
- let maskedSrc = src;
1909
- let match = null;
1246
+ inlineTokens(e, t = []) {
1247
+ var _a2, _b, _c, _d, _e2, _f;
1248
+ let n = e, r = null;
1910
1249
  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);
1250
+ let o = Object.keys(this.tokens.links);
1251
+ 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));
1252
+ }
1253
+ for (; (r = this.tokenizer.rules.inline.anyPunctuation.exec(n)) != null; ) n = n.slice(0, r.index) + "++" + n.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);
1254
+ let i;
1255
+ 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);
1256
+ n = (_c = (_b = (_a2 = this.options.hooks) == null ? void 0 : _a2.emStrongMask) == null ? void 0 : _b.call({ lexer: this }, n)) != null ? _c : n;
1257
+ let s = false, a = "";
1258
+ for (; e; ) {
1259
+ s || (a = ""), s = false;
1260
+ let o;
1261
+ 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;
1262
+ if (o = this.tokenizer.escape(e)) {
1263
+ e = e.substring(o.raw.length), t.push(o);
1947
1264
  continue;
1948
1265
  }
1949
- if (token = this.tokenizer.tag(src)) {
1950
- src = src.substring(token.raw.length);
1951
- tokens.push(token);
1266
+ if (o = this.tokenizer.tag(e)) {
1267
+ e = e.substring(o.raw.length), t.push(o);
1952
1268
  continue;
1953
1269
  }
1954
- if (token = this.tokenizer.link(src)) {
1955
- src = src.substring(token.raw.length);
1956
- tokens.push(token);
1270
+ if (o = this.tokenizer.link(e)) {
1271
+ e = e.substring(o.raw.length), t.push(o);
1957
1272
  continue;
1958
1273
  }
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
- }
1274
+ if (o = this.tokenizer.reflink(e, this.tokens.links)) {
1275
+ e = e.substring(o.raw.length);
1276
+ let p = t.at(-1);
1277
+ o.type === "text" && (p == null ? void 0 : p.type) === "text" ? (p.raw += o.raw, p.text += o.text) : t.push(o);
1968
1278
  continue;
1969
1279
  }
1970
- if (token = this.tokenizer.emStrong(src, maskedSrc, prevChar)) {
1971
- src = src.substring(token.raw.length);
1972
- tokens.push(token);
1280
+ if (o = this.tokenizer.emStrong(e, n, a)) {
1281
+ e = e.substring(o.raw.length), t.push(o);
1973
1282
  continue;
1974
1283
  }
1975
- if (token = this.tokenizer.codespan(src)) {
1976
- src = src.substring(token.raw.length);
1977
- tokens.push(token);
1284
+ if (o = this.tokenizer.codespan(e)) {
1285
+ e = e.substring(o.raw.length), t.push(o);
1978
1286
  continue;
1979
1287
  }
1980
- if (token = this.tokenizer.br(src)) {
1981
- src = src.substring(token.raw.length);
1982
- tokens.push(token);
1288
+ if (o = this.tokenizer.br(e)) {
1289
+ e = e.substring(o.raw.length), t.push(o);
1983
1290
  continue;
1984
1291
  }
1985
- if (token = this.tokenizer.del(src)) {
1986
- src = src.substring(token.raw.length);
1987
- tokens.push(token);
1292
+ if (o = this.tokenizer.del(e, n, a)) {
1293
+ e = e.substring(o.raw.length), t.push(o);
1988
1294
  continue;
1989
1295
  }
1990
- if (token = this.tokenizer.autolink(src)) {
1991
- src = src.substring(token.raw.length);
1992
- tokens.push(token);
1296
+ if (o = this.tokenizer.autolink(e)) {
1297
+ e = e.substring(o.raw.length), t.push(o);
1993
1298
  continue;
1994
1299
  }
1995
- if (!this.state.inLink && (token = this.tokenizer.url(src))) {
1996
- src = src.substring(token.raw.length);
1997
- tokens.push(token);
1300
+ if (!this.state.inLink && (o = this.tokenizer.url(e))) {
1301
+ e = e.substring(o.raw.length), t.push(o);
1998
1302
  continue;
1999
1303
  }
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
- }
1304
+ let l = e;
1305
+ if ((_f = this.options.extensions) == null ? void 0 : _f.startInline) {
1306
+ let p = 1 / 0, c = e.slice(1), d;
1307
+ this.options.extensions.startInline.forEach((h) => {
1308
+ d = h.call({ lexer: this }, c), typeof d == "number" && d >= 0 && (p = Math.min(p, d));
1309
+ }), p < 1 / 0 && p >= 0 && (l = e.substring(0, p + 1));
1310
+ }
1311
+ if (o = this.tokenizer.inlineText(l)) {
1312
+ e = e.substring(o.raw.length), o.raw.slice(-1) !== "_" && (a = o.raw.slice(-1)), s = true;
1313
+ let p = t.at(-1);
1314
+ (p == null ? void 0 : p.type) === "text" ? (p.raw += o.raw, p.text += o.text) : t.push(o);
2028
1315
  continue;
2029
1316
  }
2030
- if (src) {
2031
- const errMsg = "Infinite loop on byte: " + src.charCodeAt(0);
1317
+ if (e) {
1318
+ let p = "Infinite loop on byte: " + e.charCodeAt(0);
2032
1319
  if (this.options.silent) {
2033
- console.error(errMsg);
1320
+ console.error(p);
2034
1321
  break;
2035
- } else {
2036
- throw new Error(errMsg);
2037
- }
1322
+ } else throw new Error(p);
2038
1323
  }
2039
1324
  }
2040
- return tokens;
1325
+ return t;
2041
1326
  }
2042
1327
  };
2043
- var _Renderer = class {
2044
- // set by the parser
2045
- constructor(options2) {
1328
+ var y = class {
1329
+ constructor(e) {
2046
1330
  __publicField(this, "options");
2047
1331
  __publicField(this, "parser");
2048
- this.options = options2 || _defaults;
1332
+ this.options = e || T;
2049
1333
  }
2050
- space(token) {
1334
+ space(e) {
2051
1335
  return "";
2052
1336
  }
2053
- code({ text, lang, escaped }) {
1337
+ code({ text: e, lang: t, escaped: n }) {
2054
1338
  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";
1339
+ let r = (_a2 = (t || "").match(m.notSpaceStart)) == null ? void 0 : _a2[0], i = e.replace(m.endingNewline, "") + `
1340
+ `;
1341
+ return r ? '<pre><code class="language-' + O(r) + '">' + (n ? i : O(i, true)) + `</code></pre>
1342
+ ` : "<pre><code>" + (n ? i : O(i, true)) + `</code></pre>
1343
+ `;
2061
1344
  }
2062
- blockquote({ tokens }) {
2063
- const body = this.parser.parse(tokens);
1345
+ blockquote({ tokens: e }) {
2064
1346
  return `<blockquote>
2065
- ${body}</blockquote>
1347
+ ${this.parser.parse(e)}</blockquote>
2066
1348
  `;
2067
1349
  }
2068
- html({ text }) {
2069
- return text;
1350
+ html({ text: e }) {
1351
+ return e;
1352
+ }
1353
+ def(e) {
1354
+ return "";
2070
1355
  }
2071
- heading({ tokens, depth }) {
2072
- return `<h${depth}>${this.parser.parseInline(tokens)}</h${depth}>
1356
+ heading({ tokens: e, depth: t }) {
1357
+ return `<h${t}>${this.parser.parseInline(e)}</h${t}>
2073
1358
  `;
2074
1359
  }
2075
- hr(token) {
2076
- return "<hr>\n";
1360
+ hr(e) {
1361
+ return `<hr>
1362
+ `;
2077
1363
  }
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);
1364
+ list(e) {
1365
+ let t = e.ordered, n = e.start, r = "";
1366
+ for (let a = 0; a < e.items.length; a++) {
1367
+ let o = e.items[a];
1368
+ r += this.listitem(o);
2085
1369
  }
2086
- const type = ordered ? "ol" : "ul";
2087
- const startAttr = ordered && start !== 1 ? ' start="' + start + '"' : "";
2088
- return "<" + type + startAttr + ">\n" + body + "</" + type + ">\n";
1370
+ let i = t ? "ol" : "ul", s = t && n !== 1 ? ' start="' + n + '"' : "";
1371
+ return "<" + i + s + `>
1372
+ ` + r + "</" + i + `>
1373
+ `;
2089
1374
  }
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>
1375
+ listitem(e) {
1376
+ return `<li>${this.parser.parse(e.tokens)}</li>
2116
1377
  `;
2117
1378
  }
2118
- checkbox({ checked }) {
2119
- return "<input " + (checked ? 'checked="" ' : "") + 'disabled="" type="checkbox">';
1379
+ checkbox({ checked: e }) {
1380
+ return "<input " + (e ? 'checked="" ' : "") + 'disabled="" type="checkbox"> ';
2120
1381
  }
2121
- paragraph({ tokens }) {
2122
- return `<p>${this.parser.parseInline(tokens)}</p>
1382
+ paragraph({ tokens: e }) {
1383
+ return `<p>${this.parser.parseInline(e)}</p>
2123
1384
  `;
2124
1385
  }
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";
1386
+ table(e) {
1387
+ let t = "", n = "";
1388
+ for (let i = 0; i < e.header.length; i++) n += this.tablecell(e.header[i]);
1389
+ t += this.tablerow({ text: n });
1390
+ let r = "";
1391
+ for (let i = 0; i < e.rows.length; i++) {
1392
+ let s = e.rows[i];
1393
+ n = "";
1394
+ for (let a = 0; a < s.length; a++) n += this.tablecell(s[a]);
1395
+ r += this.tablerow({ text: n });
1396
+ }
1397
+ return r && (r = `<tbody>${r}</tbody>`), `<table>
1398
+ <thead>
1399
+ ` + t + `</thead>
1400
+ ` + r + `</table>
1401
+ `;
2143
1402
  }
2144
- tablerow({ text }) {
1403
+ tablerow({ text: e }) {
2145
1404
  return `<tr>
2146
- ${text}</tr>
1405
+ ${e}</tr>
2147
1406
  `;
2148
1407
  }
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}>
1408
+ tablecell(e) {
1409
+ let t = this.parser.parseInline(e.tokens), n = e.header ? "th" : "td";
1410
+ return (e.align ? `<${n} align="${e.align}">` : `<${n}>`) + t + `</${n}>
2154
1411
  `;
2155
1412
  }
2156
- /**
2157
- * span level renderer
2158
- */
2159
- strong({ tokens }) {
2160
- return `<strong>${this.parser.parseInline(tokens)}</strong>`;
1413
+ strong({ tokens: e }) {
1414
+ return `<strong>${this.parser.parseInline(e)}</strong>`;
2161
1415
  }
2162
- em({ tokens }) {
2163
- return `<em>${this.parser.parseInline(tokens)}</em>`;
1416
+ em({ tokens: e }) {
1417
+ return `<em>${this.parser.parseInline(e)}</em>`;
2164
1418
  }
2165
- codespan({ text }) {
2166
- return `<code>${escape2(text, true)}</code>`;
1419
+ codespan({ text: e }) {
1420
+ return `<code>${O(e, true)}</code>`;
2167
1421
  }
2168
- br(token) {
1422
+ br(e) {
2169
1423
  return "<br>";
2170
1424
  }
2171
- del({ tokens }) {
2172
- return `<del>${this.parser.parseInline(tokens)}</del>`;
1425
+ del({ tokens: e }) {
1426
+ return `<del>${this.parser.parseInline(e)}</del>`;
2173
1427
  }
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;
1428
+ link({ href: e, title: t, tokens: n }) {
1429
+ let r = this.parser.parseInline(n), i = X(e);
1430
+ if (i === null) return r;
1431
+ e = i;
1432
+ let s = '<a href="' + e + '"';
1433
+ return t && (s += ' title="' + O(t) + '"'), s += ">" + r + "</a>", s;
2187
1434
  }
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;
1435
+ image({ href: e, title: t, text: n, tokens: r }) {
1436
+ r && (n = this.parser.parseInline(r, this.parser.textRenderer));
1437
+ let i = X(e);
1438
+ if (i === null) return O(n);
1439
+ e = i;
1440
+ let s = `<img src="${e}" alt="${O(n)}"`;
1441
+ return t && (s += ` title="${O(t)}"`), s += ">", s;
2203
1442
  }
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);
1443
+ text(e) {
1444
+ return "tokens" in e && e.tokens ? this.parser.parseInline(e.tokens) : "escaped" in e && e.escaped ? e.text : O(e.text);
2206
1445
  }
2207
1446
  };
2208
- var _TextRenderer = class {
2209
- // no need for block level renderers
2210
- strong({ text }) {
2211
- return text;
1447
+ var $ = class {
1448
+ strong({ text: e }) {
1449
+ return e;
2212
1450
  }
2213
- em({ text }) {
2214
- return text;
1451
+ em({ text: e }) {
1452
+ return e;
2215
1453
  }
2216
- codespan({ text }) {
2217
- return text;
1454
+ codespan({ text: e }) {
1455
+ return e;
2218
1456
  }
2219
- del({ text }) {
2220
- return text;
1457
+ del({ text: e }) {
1458
+ return e;
2221
1459
  }
2222
- html({ text }) {
2223
- return text;
1460
+ html({ text: e }) {
1461
+ return e;
2224
1462
  }
2225
- text({ text }) {
2226
- return text;
1463
+ text({ text: e }) {
1464
+ return e;
2227
1465
  }
2228
- link({ text }) {
2229
- return "" + text;
1466
+ link({ text: e }) {
1467
+ return "" + e;
2230
1468
  }
2231
- image({ text }) {
2232
- return "" + text;
1469
+ image({ text: e }) {
1470
+ return "" + e;
2233
1471
  }
2234
1472
  br() {
2235
1473
  return "";
2236
1474
  }
1475
+ checkbox({ raw: e }) {
1476
+ return e;
1477
+ }
2237
1478
  };
2238
- var _Parser = class __Parser {
2239
- constructor(options2) {
1479
+ var b = class u2 {
1480
+ constructor(e) {
2240
1481
  __publicField(this, "options");
2241
1482
  __publicField(this, "renderer");
2242
1483
  __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();
1484
+ 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
1485
  }
2250
- /**
2251
- * Static Parse Method
2252
- */
2253
- static parse(tokens, options2) {
2254
- const parser2 = new __Parser(options2);
2255
- return parser2.parse(tokens);
1486
+ static parse(e, t) {
1487
+ return new u2(t).parse(e);
2256
1488
  }
2257
- /**
2258
- * Static Parse Inline Method
2259
- */
2260
- static parseInline(tokens, options2) {
2261
- const parser2 = new __Parser(options2);
2262
- return parser2.parseInline(tokens);
1489
+ static parseInline(e, t) {
1490
+ return new u2(t).parseInline(e);
2263
1491
  }
2264
- /**
2265
- * Parse Loop
2266
- */
2267
- parse(tokens, top = true) {
1492
+ parse(e) {
2268
1493
  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 || "";
1494
+ let t = "";
1495
+ for (let n = 0; n < e.length; n++) {
1496
+ let r = e[n];
1497
+ if ((_b = (_a2 = this.options.extensions) == null ? void 0 : _a2.renderers) == null ? void 0 : _b[r.type]) {
1498
+ let s = r, a = this.options.extensions.renderers[s.type].call({ parser: this }, s);
1499
+ if (a !== false || !["space", "hr", "heading", "code", "table", "blockquote", "list", "html", "def", "paragraph", "text"].includes(s.type)) {
1500
+ t += a || "";
2277
1501
  continue;
2278
1502
  }
2279
1503
  }
2280
- const token = anyToken;
2281
- switch (token.type) {
1504
+ let i = r;
1505
+ switch (i.type) {
2282
1506
  case "space": {
2283
- out += this.renderer.space(token);
2284
- continue;
1507
+ t += this.renderer.space(i);
1508
+ break;
2285
1509
  }
2286
1510
  case "hr": {
2287
- out += this.renderer.hr(token);
2288
- continue;
1511
+ t += this.renderer.hr(i);
1512
+ break;
2289
1513
  }
2290
1514
  case "heading": {
2291
- out += this.renderer.heading(token);
2292
- continue;
1515
+ t += this.renderer.heading(i);
1516
+ break;
2293
1517
  }
2294
1518
  case "code": {
2295
- out += this.renderer.code(token);
2296
- continue;
1519
+ t += this.renderer.code(i);
1520
+ break;
2297
1521
  }
2298
1522
  case "table": {
2299
- out += this.renderer.table(token);
2300
- continue;
1523
+ t += this.renderer.table(i);
1524
+ break;
2301
1525
  }
2302
1526
  case "blockquote": {
2303
- out += this.renderer.blockquote(token);
2304
- continue;
1527
+ t += this.renderer.blockquote(i);
1528
+ break;
2305
1529
  }
2306
1530
  case "list": {
2307
- out += this.renderer.list(token);
2308
- continue;
1531
+ t += this.renderer.list(i);
1532
+ break;
1533
+ }
1534
+ case "checkbox": {
1535
+ t += this.renderer.checkbox(i);
1536
+ break;
2309
1537
  }
2310
1538
  case "html": {
2311
- out += this.renderer.html(token);
2312
- continue;
1539
+ t += this.renderer.html(i);
1540
+ break;
1541
+ }
1542
+ case "def": {
1543
+ t += this.renderer.def(i);
1544
+ break;
2313
1545
  }
2314
1546
  case "paragraph": {
2315
- out += this.renderer.paragraph(token);
2316
- continue;
1547
+ t += this.renderer.paragraph(i);
1548
+ break;
2317
1549
  }
2318
1550
  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;
1551
+ t += this.renderer.text(i);
1552
+ break;
2336
1553
  }
2337
1554
  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
- }
1555
+ let s = 'Token with "' + i.type + '" type was not found.';
1556
+ if (this.options.silent) return console.error(s), "";
1557
+ throw new Error(s);
2345
1558
  }
2346
1559
  }
2347
1560
  }
2348
- return out;
1561
+ return t;
2349
1562
  }
2350
- /**
2351
- * Parse Inline Tokens
2352
- */
2353
- parseInline(tokens, renderer = this.renderer) {
1563
+ parseInline(e, t = this.renderer) {
2354
1564
  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 || "";
1565
+ let n = "";
1566
+ for (let r = 0; r < e.length; r++) {
1567
+ let i = e[r];
1568
+ if ((_b = (_a2 = this.options.extensions) == null ? void 0 : _a2.renderers) == null ? void 0 : _b[i.type]) {
1569
+ let a = this.options.extensions.renderers[i.type].call({ parser: this }, i);
1570
+ if (a !== false || !["escape", "html", "link", "image", "strong", "em", "codespan", "br", "del", "text"].includes(i.type)) {
1571
+ n += a || "";
2362
1572
  continue;
2363
1573
  }
2364
1574
  }
2365
- const token = anyToken;
2366
- switch (token.type) {
1575
+ let s = i;
1576
+ switch (s.type) {
2367
1577
  case "escape": {
2368
- out += renderer.text(token);
1578
+ n += t.text(s);
2369
1579
  break;
2370
1580
  }
2371
1581
  case "html": {
2372
- out += renderer.html(token);
1582
+ n += t.html(s);
2373
1583
  break;
2374
1584
  }
2375
1585
  case "link": {
2376
- out += renderer.link(token);
1586
+ n += t.link(s);
2377
1587
  break;
2378
1588
  }
2379
1589
  case "image": {
2380
- out += renderer.image(token);
1590
+ n += t.image(s);
1591
+ break;
1592
+ }
1593
+ case "checkbox": {
1594
+ n += t.checkbox(s);
2381
1595
  break;
2382
1596
  }
2383
1597
  case "strong": {
2384
- out += renderer.strong(token);
1598
+ n += t.strong(s);
2385
1599
  break;
2386
1600
  }
2387
1601
  case "em": {
2388
- out += renderer.em(token);
1602
+ n += t.em(s);
2389
1603
  break;
2390
1604
  }
2391
1605
  case "codespan": {
2392
- out += renderer.codespan(token);
1606
+ n += t.codespan(s);
2393
1607
  break;
2394
1608
  }
2395
1609
  case "br": {
2396
- out += renderer.br(token);
1610
+ n += t.br(s);
2397
1611
  break;
2398
1612
  }
2399
1613
  case "del": {
2400
- out += renderer.del(token);
1614
+ n += t.del(s);
2401
1615
  break;
2402
1616
  }
2403
1617
  case "text": {
2404
- out += renderer.text(token);
1618
+ n += t.text(s);
2405
1619
  break;
2406
1620
  }
2407
1621
  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
- }
1622
+ let a = 'Token with "' + s.type + '" type was not found.';
1623
+ if (this.options.silent) return console.error(a), "";
1624
+ throw new Error(a);
2415
1625
  }
2416
1626
  }
2417
1627
  }
2418
- return out;
1628
+ return n;
2419
1629
  }
2420
1630
  };
2421
1631
  var _a;
2422
- var _Hooks = (_a = class {
2423
- constructor(options2) {
1632
+ var P = (_a = class {
1633
+ constructor(e) {
2424
1634
  __publicField(this, "options");
2425
1635
  __publicField(this, "block");
2426
- this.options = options2 || _defaults;
1636
+ this.options = e || T;
2427
1637
  }
2428
- /**
2429
- * Process markdown before marked
2430
- */
2431
- preprocess(markdown) {
2432
- return markdown;
1638
+ preprocess(e) {
1639
+ return e;
2433
1640
  }
2434
- /**
2435
- * Process HTML after marked is finished
2436
- */
2437
- postprocess(html2) {
2438
- return html2;
1641
+ postprocess(e) {
1642
+ return e;
2439
1643
  }
2440
- /**
2441
- * Process all tokens before walk tokens
2442
- */
2443
- processAllTokens(tokens) {
2444
- return tokens;
1644
+ processAllTokens(e) {
1645
+ return e;
1646
+ }
1647
+ emStrongMask(e) {
1648
+ return e;
2445
1649
  }
2446
- /**
2447
- * Provide function to tokenize markdown
2448
- */
2449
1650
  provideLexer() {
2450
- return this.block ? _Lexer.lex : _Lexer.lexInline;
1651
+ return this.block ? x.lex : x.lexInline;
2451
1652
  }
2452
- /**
2453
- * Provide function to parse tokens
2454
- */
2455
1653
  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());
1654
+ return this.block ? b.parse : b.parseInline;
1655
+ }
1656
+ }, __publicField(_a, "passThroughHooks", /* @__PURE__ */ new Set(["preprocess", "postprocess", "processAllTokens", "emStrongMask"])), __publicField(_a, "passThroughHooksRespectAsync", /* @__PURE__ */ new Set(["preprocess", "postprocess", "processAllTokens"])), _a);
1657
+ var B = class {
1658
+ constructor(...e) {
1659
+ __publicField(this, "defaults", M());
2466
1660
  __publicField(this, "options", this.setOptions);
2467
1661
  __publicField(this, "parse", this.parseMarkdown(true));
2468
1662
  __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) {
1663
+ __publicField(this, "Parser", b);
1664
+ __publicField(this, "Renderer", y);
1665
+ __publicField(this, "TextRenderer", $);
1666
+ __publicField(this, "Lexer", x);
1667
+ __publicField(this, "Tokenizer", w);
1668
+ __publicField(this, "Hooks", P);
1669
+ this.use(...e);
1670
+ }
1671
+ walkTokens(e, t) {
2481
1672
  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 || "";
1673
+ let n = [];
1674
+ for (let r of e) switch (n = n.concat(t.call(this, r)), r.type) {
1675
+ case "table": {
1676
+ let i = r;
1677
+ for (let s of i.header) n = n.concat(this.walkTokens(s.tokens, t));
1678
+ for (let s of i.rows) for (let a of s) n = n.concat(this.walkTokens(a.tokens, t));
1679
+ break;
1680
+ }
1681
+ case "list": {
1682
+ let i = r;
1683
+ n = n.concat(this.walkTokens(i.items, t));
1684
+ break;
1685
+ }
1686
+ default: {
1687
+ let i = r;
1688
+ ((_b = (_a2 = this.defaults.extensions) == null ? void 0 : _a2.childTokens) == null ? void 0 : _b[i.type]) ? this.defaults.extensions.childTokens[i.type].forEach((s) => {
1689
+ let a = i[s].flat(1 / 0);
1690
+ n = n.concat(this.walkTokens(a, t));
1691
+ }) : i.tokens && (n = n.concat(this.walkTokens(i.tokens, t)));
1692
+ }
1693
+ }
1694
+ return n;
1695
+ }
1696
+ use(...e) {
1697
+ let t = this.defaults.extensions || { renderers: {}, childTokens: {} };
1698
+ return e.forEach((n) => {
1699
+ let r = { ...n };
1700
+ if (r.async = this.defaults.async || r.async || false, n.extensions && (n.extensions.forEach((i) => {
1701
+ if (!i.name) throw new Error("extension name required");
1702
+ if ("renderer" in i) {
1703
+ let s = t.renderers[i.name];
1704
+ s ? t.renderers[i.name] = function(...a) {
1705
+ let o = i.renderer.apply(this, a);
1706
+ return o === false && (o = s.apply(this, a)), o;
1707
+ } : t.renderers[i.name] = i.renderer;
1708
+ }
1709
+ if ("tokenizer" in i) {
1710
+ if (!i.level || i.level !== "block" && i.level !== "inline") throw new Error("extension level must be 'block' or 'inline'");
1711
+ let s = t[i.level];
1712
+ 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]));
1713
+ }
1714
+ "childTokens" in i && i.childTokens && (t.childTokens[i.name] = i.childTokens);
1715
+ }), r.extensions = t), n.renderer) {
1716
+ let i = this.defaults.renderer || new y(this.defaults);
1717
+ for (let s in n.renderer) {
1718
+ if (!(s in i)) throw new Error(`renderer '${s}' does not exist`);
1719
+ if (["options", "parser"].includes(s)) continue;
1720
+ let a = s, o = n.renderer[a], l = i[a];
1721
+ i[a] = (...p) => {
1722
+ let c = o.apply(i, p);
1723
+ return c === false && (c = l.apply(i, p)), c || "";
2592
1724
  };
2593
1725
  }
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;
1726
+ r.renderer = i;
1727
+ }
1728
+ if (n.tokenizer) {
1729
+ let i = this.defaults.tokenizer || new w(this.defaults);
1730
+ for (let s in n.tokenizer) {
1731
+ if (!(s in i)) throw new Error(`tokenizer '${s}' does not exist`);
1732
+ if (["options", "rules", "lexer"].includes(s)) continue;
1733
+ let a = s, o = n.tokenizer[a], l = i[a];
1734
+ i[a] = (...p) => {
1735
+ let c = o.apply(i, p);
1736
+ return c === false && (c = l.apply(i, p)), c;
2614
1737
  };
2615
1738
  }
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
- }
1739
+ r.tokenizer = i;
1740
+ }
1741
+ if (n.hooks) {
1742
+ let i = this.defaults.hooks || new P();
1743
+ for (let s in n.hooks) {
1744
+ if (!(s in i)) throw new Error(`hook '${s}' does not exist`);
1745
+ if (["options", "block"].includes(s)) continue;
1746
+ let a = s, o = n.hooks[a], l = i[a];
1747
+ P.passThroughHooks.has(s) ? i[a] = (p) => {
1748
+ if (this.defaults.async && P.passThroughHooksRespectAsync.has(s)) return (async () => {
1749
+ let d = await o.call(i, p);
1750
+ return l.call(i, d);
1751
+ })();
1752
+ let c = o.call(i, p);
1753
+ return l.call(i, c);
1754
+ } : i[a] = (...p) => {
1755
+ if (this.defaults.async) return (async () => {
1756
+ let d = await o.apply(i, p);
1757
+ return d === false && (d = await l.apply(i, p)), d;
1758
+ })();
1759
+ let c = o.apply(i, p);
1760
+ return c === false && (c = l.apply(i, p)), c;
1761
+ };
2649
1762
  }
2650
- opts.hooks = hooks;
1763
+ r.hooks = i;
2651
1764
  }
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;
1765
+ if (n.walkTokens) {
1766
+ let i = this.defaults.walkTokens, s = n.walkTokens;
1767
+ r.walkTokens = function(a) {
1768
+ let o = [];
1769
+ return o.push(s.call(this, a)), i && (o = o.concat(i.call(this, a))), o;
2662
1770
  };
2663
1771
  }
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
- }
1772
+ this.defaults = { ...this.defaults, ...r };
1773
+ }), this;
1774
+ }
1775
+ setOptions(e) {
1776
+ return this.defaults = { ...this.defaults, ...e }, this;
1777
+ }
1778
+ lexer(e, t) {
1779
+ return x.lex(e, t != null ? t : this.defaults);
1780
+ }
1781
+ parser(e, t) {
1782
+ return b.parse(e, t != null ? t : this.defaults);
1783
+ }
1784
+ parseMarkdown(e) {
1785
+ return (n, r) => {
1786
+ let i = { ...r }, s = { ...this.defaults, ...i }, a = this.onError(!!s.silent, !!s.async);
1787
+ 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."));
1788
+ if (typeof n > "u" || n === null) return a(new Error("marked(): input parameter is undefined or null"));
1789
+ if (typeof n != "string") return a(new Error("marked(): input parameter is of type " + Object.prototype.toString.call(n) + ", string expected"));
1790
+ if (s.hooks && (s.hooks.options = s, s.hooks.block = e), s.async) return (async () => {
1791
+ 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;
1792
+ s.walkTokens && await Promise.all(this.walkTokens(c, s.walkTokens));
1793
+ let h = await (s.hooks ? await s.hooks.provideParser() : e ? b.parse : b.parseInline)(c, s);
1794
+ return s.hooks ? await s.hooks.postprocess(h) : h;
1795
+ })().catch(a);
2701
1796
  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);
1797
+ s.hooks && (n = s.hooks.preprocess(n));
1798
+ let l = (s.hooks ? s.hooks.provideLexer() : e ? x.lex : x.lexInline)(n, s);
1799
+ s.hooks && (l = s.hooks.processAllTokens(l)), s.walkTokens && this.walkTokens(l, s.walkTokens);
1800
+ let c = (s.hooks ? s.hooks.provideParser() : e ? b.parse : b.parseInline)(l, s);
1801
+ return s.hooks && (c = s.hooks.postprocess(c)), c;
1802
+ } catch (o) {
1803
+ return a(o);
2719
1804
  }
2720
1805
  };
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);
1806
+ }
1807
+ onError(e, t) {
1808
+ return (n) => {
1809
+ if (n.message += `
1810
+ Please report this to https://github.com/markedjs/marked.`, e) {
1811
+ let r = "<p>An error occurred:</p><pre>" + O(n.message + "", true) + "</pre>";
1812
+ return t ? Promise.resolve(r) : r;
2735
1813
  }
2736
- throw e;
1814
+ if (t) return Promise.reject(n);
1815
+ throw n;
2737
1816
  };
2738
1817
  }
2739
1818
  };
2740
- var markedInstance = new Marked();
2741
- function marked(src, opt) {
2742
- return markedInstance.parse(src, opt);
1819
+ var L = new B();
1820
+ function g(u3, e) {
1821
+ return L.parse(u3, e);
2743
1822
  }
2744
- marked.options = marked.setOptions = function(options2) {
2745
- markedInstance.setOptions(options2);
2746
- marked.defaults = markedInstance.defaults;
2747
- changeDefaults(marked.defaults);
2748
- return marked;
1823
+ g.options = g.setOptions = function(u3) {
1824
+ return L.setOptions(u3), g.defaults = L.defaults, G(g.defaults), g;
2749
1825
  };
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;
1826
+ g.getDefaults = M;
1827
+ g.defaults = T;
1828
+ g.use = function(...u3) {
1829
+ return L.use(...u3), g.defaults = L.defaults, G(g.defaults), g;
2757
1830
  };
2758
- marked.walkTokens = function(tokens, callback) {
2759
- return markedInstance.walkTokens(tokens, callback);
1831
+ g.walkTokens = function(u3, e) {
1832
+ return L.walkTokens(u3, e);
2760
1833
  };
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;
1834
+ g.parseInline = L.parseInline;
1835
+ g.Parser = b;
1836
+ g.parser = b.parse;
1837
+ g.Renderer = y;
1838
+ g.TextRenderer = $;
1839
+ g.Lexer = x;
1840
+ g.lexer = x.lex;
1841
+ g.Tokenizer = w;
1842
+ g.Hooks = P;
1843
+ g.parse = g;
1844
+ var Ut = g.options;
1845
+ var Kt = g.setOptions;
1846
+ var Wt = g.use;
1847
+ var Xt = g.walkTokens;
1848
+ var Jt = g.parseInline;
1849
+ var Yt = b.parse;
1850
+ var en = x.lex;
2778
1851
 
2779
1852
  // ../adaptives/adaptive-faq/dist/FAQWidget.js
2780
1853
  import React2, { useCallback as useCallback2, useEffect as useEffect2, useMemo, useReducer, useState as useState2 } from "react";
2781
1854
  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
- }
1855
+
1856
+ // ../adaptives/adaptive-faq/dist/faq-styles.js
2814
1857
  var baseStyles = {
2815
1858
  container: {
2816
1859
  fontFamily: "var(--sc-font-family, system-ui, -apple-system, sans-serif)",
@@ -3002,6 +2045,44 @@ var themeStyles = {
3002
2045
  }
3003
2046
  }
3004
2047
  };
2048
+
2049
+ // ../adaptives/adaptive-faq/dist/FAQWidget.js
2050
+ var marked = new B({ async: false, gfm: true, breaks: true });
2051
+ function getAnswerText(answer) {
2052
+ if (typeof answer === "string")
2053
+ return answer;
2054
+ if (answer.type === "rich")
2055
+ return answer.html;
2056
+ return answer.content;
2057
+ }
2058
+ function renderAnswer(answer) {
2059
+ if (typeof answer === "string") {
2060
+ const html2 = marked.parse(answer);
2061
+ return (
2062
+ // biome-ignore lint/security/noDangerouslySetInnerHtml: content is CMS/config content, not user-controlled input
2063
+ _jsx2("div", { style: { margin: 0 }, "data-faq-markdown": "", dangerouslySetInnerHTML: { __html: html2 } })
2064
+ );
2065
+ }
2066
+ if (answer.type === "rich") {
2067
+ return _jsx2("div", { style: { margin: 0 }, dangerouslySetInnerHTML: { __html: answer.html } });
2068
+ }
2069
+ const html = marked.parse(answer.content);
2070
+ return (
2071
+ // biome-ignore lint/security/noDangerouslySetInnerHtml: markdown content is CMS/config content, not user-controlled input
2072
+ _jsx2("div", { style: { margin: 0 }, "data-faq-markdown": "", dangerouslySetInnerHTML: { __html: html } })
2073
+ );
2074
+ }
2075
+ function resolveFeedbackConfig(feedback) {
2076
+ if (!feedback)
2077
+ return null;
2078
+ if (feedback === true) {
2079
+ return { style: "thumbs" };
2080
+ }
2081
+ return feedback;
2082
+ }
2083
+ function getFeedbackPrompt(feedbackConfig) {
2084
+ return feedbackConfig.prompt || "Was this helpful?";
2085
+ }
3005
2086
  function FAQItem({ item, isExpanded, isHighlighted, isLast, onToggle, theme, feedbackConfig, feedbackValue, onFeedback }) {
3006
2087
  const [isHovered, setIsHovered] = useState2(false);
3007
2088
  const colors = themeStyles[theme];
@@ -3011,7 +2092,8 @@ function FAQItem({ item, isExpanded, isHighlighted, isLast, onToggle, theme, fee
3011
2092
  ...colors.item,
3012
2093
  ...isExpanded ? colors.itemExpanded : {},
3013
2094
  ...isHighlighted ? {
3014
- boxShadow: "0 0 0 2px #6366f1, 0 0 12px rgba(99, 102, 241, 0.4)",
2095
+ // purple[4] = #6a59ce design system primary purple
2096
+ boxShadow: `0 0 0 2px ${purple[4]}, 0 0 12px rgba(106, 89, 206, 0.4)`,
3015
2097
  transition: "box-shadow 0.3s ease"
3016
2098
  } : {},
3017
2099
  ...!isLast ? { borderBottom: "var(--sc-content-item-divider, none)" } : {}
@@ -3044,7 +2126,7 @@ function FAQItem({ item, isExpanded, isHighlighted, isLast, onToggle, theme, fee
3044
2126
  }, "aria-label": "Thumbs down", onClick: () => onFeedback(item.config.id, question, "down"), children: "\u{1F44E}" })] })] })] });
3045
2127
  }
3046
2128
  function FAQWidget({ config, runtime: runtime7, instanceId }) {
3047
- const [renderTick, forceUpdate] = useReducer((x) => x + 1, 0);
2129
+ const [renderTick, forceUpdate] = useReducer((x2) => x2 + 1, 0);
3048
2130
  const [expandedIds, setExpandedIds] = useState2(/* @__PURE__ */ new Set());
3049
2131
  const [highlightId, setHighlightId] = useState2(null);
3050
2132
  const [searchQuery, setSearchQuery] = useState2("");
@@ -3133,17 +2215,20 @@ function FAQWidget({ config, runtime: runtime7, instanceId }) {
3133
2215
  const unsubscribe = runtime7.events.subscribe({ names: ["notification.deep_link"] }, handleDeepLink);
3134
2216
  return unsubscribe;
3135
2217
  }, [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]);
2218
+ const visibleQuestions = useMemo(() => {
2219
+ var _a2;
2220
+ return ((_a2 = config.actions) != null ? _a2 : []).filter((q2) => {
2221
+ if (!q2.triggerWhen)
2222
+ return true;
2223
+ const result = runtime7.evaluateSync(q2.triggerWhen);
2224
+ return result.value;
2225
+ });
2226
+ }, [config.actions, runtime7, renderTick]);
3142
2227
  const orderedQuestions = useMemo(() => {
3143
2228
  if (config.ordering === "priority") {
3144
- return [...visibleQuestions].sort((a, b) => {
2229
+ return [...visibleQuestions].sort((a, b2) => {
3145
2230
  var _a2, _b;
3146
- return ((_a2 = b.config.priority) != null ? _a2 : 0) - ((_b = a.config.priority) != null ? _b : 0);
2231
+ return ((_a2 = b2.config.priority) != null ? _a2 : 0) - ((_b = a.config.priority) != null ? _b : 0);
3147
2232
  });
3148
2233
  }
3149
2234
  return visibleQuestions;
@@ -3153,23 +2238,23 @@ function FAQWidget({ config, runtime: runtime7, instanceId }) {
3153
2238
  return orderedQuestions;
3154
2239
  }
3155
2240
  const query = searchQuery.toLowerCase();
3156
- return orderedQuestions.filter((q) => {
2241
+ return orderedQuestions.filter((q2) => {
3157
2242
  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));
2243
+ 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
2244
  });
3160
2245
  }, [orderedQuestions, searchQuery, config.searchable]);
3161
2246
  const categoryGroups = useMemo(() => {
3162
2247
  const groups = /* @__PURE__ */ new Map();
3163
- for (const q of filteredQuestions) {
3164
- const cat = q.config.category;
2248
+ for (const q2 of filteredQuestions) {
2249
+ const cat = q2.config.category;
3165
2250
  if (!groups.has(cat)) {
3166
2251
  groups.set(cat, []);
3167
2252
  }
3168
- groups.get(cat).push(q);
2253
+ groups.get(cat).push(q2);
3169
2254
  }
3170
2255
  return groups;
3171
2256
  }, [filteredQuestions]);
3172
- const hasCategories = useMemo(() => filteredQuestions.some((q) => q.config.category), [filteredQuestions]);
2257
+ const hasCategories = useMemo(() => filteredQuestions.some((q2) => q2.config.category), [filteredQuestions]);
3173
2258
  const resolvedTheme = useMemo(() => {
3174
2259
  var _a2;
3175
2260
  if (config.theme && config.theme !== "auto")
@@ -3230,7 +2315,7 @@ function FAQWidget({ config, runtime: runtime7, instanceId }) {
3230
2315
  ...baseStyles.categoryHeader,
3231
2316
  ...themeStyles[resolvedTheme].categoryHeader
3232
2317
  };
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));
2318
+ 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
2319
  if (visibleQuestions.length === 0) {
3235
2320
  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
2321
  }
@@ -3255,20 +2340,6 @@ var FAQMountableWidget = {
3255
2340
  root.unmount();
3256
2341
  };
3257
2342
  }
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
2343
  }
3273
2344
  };
3274
2345
 
@@ -3488,7 +2559,8 @@ var themeStyles2 = {
3488
2559
  color: "var(--sc-content-text-secondary-color)"
3489
2560
  },
3490
2561
  linkButton: {
3491
- backgroundColor: "var(--sc-color-primary, #6366f1)",
2562
+ // purple[4] = #6a59ce — design system primary purple, used as fallback when --sc-color-primary is not set
2563
+ backgroundColor: `var(--sc-color-primary, ${purple[4]})`,
3492
2564
  color: "#ffffff"
3493
2565
  },
3494
2566
  categoryHeader: {
@@ -3521,7 +2593,8 @@ var themeStyles2 = {
3521
2593
  color: "var(--sc-content-text-secondary-color)"
3522
2594
  },
3523
2595
  linkButton: {
3524
- backgroundColor: "var(--sc-color-primary, #6366f1)",
2596
+ // purple[4] = #6a59ce — design system primary purple, used as fallback when --sc-color-primary is not set
2597
+ backgroundColor: `var(--sc-color-primary, ${purple[4]})`,
3525
2598
  color: "#ffffff"
3526
2599
  },
3527
2600
  categoryHeader: {
@@ -3591,10 +2664,11 @@ function NavTipItem({ item, isExpanded, isLast, onToggle, onNavigate, onFocusAnc
3591
2664
  }
3592
2665
  };
3593
2666
  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 })] })] });
2667
+ 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
2668
+ _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
2669
  }
3596
2670
  function NavWidget({ config, runtime: runtime7, instanceId }) {
3597
- const [renderTick, forceUpdate] = useReducer2((x) => x + 1, 0);
2671
+ const [renderTick, forceUpdate] = useReducer2((x2) => x2 + 1, 0);
3598
2672
  const [expandedIds, setExpandedIds] = useState3(/* @__PURE__ */ new Set());
3599
2673
  useEffect3(() => {
3600
2674
  const unsubscribe = runtime7.context.subscribe(() => {
@@ -3690,8 +2764,10 @@ function NavWidget({ config, runtime: runtime7, instanceId }) {
3690
2764
  } else {
3691
2765
  const url = new URL(href, window.location.origin);
3692
2766
  url.search = window.location.search;
3693
- window.history.pushState(null, "", url.toString());
3694
- window.dispatchEvent(new PopStateEvent("popstate"));
2767
+ if (!navigateWithFrameworkRouter(url.toString())) {
2768
+ window.history.pushState(null, "", url.toString());
2769
+ window.dispatchEvent(new PopStateEvent("popstate"));
2770
+ }
3695
2771
  }
3696
2772
  }, [runtime7.events, instanceId]);
3697
2773
  const handleFocusAnchor = useCallback3((anchor) => {
@@ -3744,21 +2820,6 @@ var NavMountableWidget = {
3744
2820
  root.unmount();
3745
2821
  };
3746
2822
  }
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
2823
  }
3763
2824
  };
3764
2825
 
@@ -3787,6 +2848,40 @@ var executeScrollTo = async (action, context) => {
3787
2848
  }
3788
2849
  };
3789
2850
  };
2851
+ function navigateWithFrameworkRouter(url) {
2852
+ var _a2, _b, _c, _d;
2853
+ if (typeof window === "undefined")
2854
+ return false;
2855
+ const w2 = window;
2856
+ try {
2857
+ const nextRouter = (_a2 = w2.next) == null ? void 0 : _a2.router;
2858
+ if (nextRouter == null ? void 0 : nextRouter.push) {
2859
+ nextRouter.push(url);
2860
+ return true;
2861
+ }
2862
+ } catch {
2863
+ }
2864
+ try {
2865
+ if ((_c = (_b = w2.$nuxt) == null ? void 0 : _b.$router) == null ? void 0 : _c.push) {
2866
+ w2.$nuxt.$router.push(url);
2867
+ return true;
2868
+ }
2869
+ } catch {
2870
+ }
2871
+ if (w2.ng || w2.getAllAngularRootElements || document.querySelector("[ng-version]")) {
2872
+ window.location.href = url;
2873
+ return true;
2874
+ }
2875
+ if (w2.__SVELTEKIT_DATA__ || ((_d = document.body) == null ? void 0 : _d.hasAttribute("data-sveltekit"))) {
2876
+ window.location.href = url;
2877
+ return true;
2878
+ }
2879
+ if (document.querySelector("[data-astro-transition-fallback]")) {
2880
+ window.location.href = url;
2881
+ return true;
2882
+ }
2883
+ return false;
2884
+ }
3790
2885
  function isSameOrigin(url) {
3791
2886
  try {
3792
2887
  const parsed = new URL(url, window.location.origin);
@@ -3811,8 +2906,10 @@ var executeNavigate = async (action, context) => {
3811
2906
  if (target === "_blank") {
3812
2907
  window.open(url, "_blank", "noopener,noreferrer");
3813
2908
  } else if (!action.forceFullNavigation && isSameOrigin(url)) {
3814
- window.history.pushState(null, "", url);
3815
- window.dispatchEvent(new PopStateEvent("popstate"));
2909
+ if (!navigateWithFrameworkRouter(url)) {
2910
+ window.history.pushState(null, "", url);
2911
+ window.dispatchEvent(new PopStateEvent("popstate"));
2912
+ }
3816
2913
  } else {
3817
2914
  window.location.href = url;
3818
2915
  }
@@ -3903,9 +3000,9 @@ import { jsx, jsxs } from "react/jsx-runtime";
3903
3000
  function TileWheel({ tiles, intervalMs = 7e3, telemetry }) {
3904
3001
  const [index, setIndex] = useState4(0);
3905
3002
  const ordered = useMemo3(
3906
- () => [...tiles].sort((a, b) => {
3003
+ () => [...tiles].sort((a, b2) => {
3907
3004
  var _a2, _b;
3908
- return ((_a2 = a.priority) != null ? _a2 : 0) - ((_b = b.priority) != null ? _b : 0);
3005
+ return ((_a2 = a.priority) != null ? _a2 : 0) - ((_b = b2.priority) != null ? _b : 0);
3909
3006
  }),
3910
3007
  [tiles]
3911
3008
  );
@@ -4073,50 +3170,50 @@ function needsMigration(config) {
4073
3170
  }
4074
3171
 
4075
3172
  // 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() })
3173
+ import { z as z2 } from "zod";
3174
+ var SelectorZ = z2.union([
3175
+ z2.object({ type: z2.literal("data"), key: z2.string(), value: z2.string().optional() }),
3176
+ z2.object({ type: z2.literal("css"), value: z2.string() }),
3177
+ z2.object({ type: z2.literal("aria"), role: z2.string().optional(), label: z2.string().optional() }),
3178
+ z2.object({ type: z2.literal("shadow-css"), value: z2.string() }),
3179
+ z2.object({ type: z2.literal("ref"), el: z2.any() })
4083
3180
  // runtime-only
4084
3181
  ]);
4085
- var TooltipStepZ = z.object({
4086
- kind: z.literal("tooltip"),
4087
- id: z.string(),
3182
+ var TooltipStepZ = z2.object({
3183
+ kind: z2.literal("tooltip"),
3184
+ id: z2.string(),
4088
3185
  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()
3186
+ content: z2.object({ title: z2.string().optional(), body: z2.string() }),
3187
+ placement: z2.enum(["top", "bottom", "left", "right", "auto"]).optional(),
3188
+ offsetPx: z2.number().optional(),
3189
+ blocking: z2.boolean().optional(),
3190
+ trigger: z2.enum(["immediate", "hover", "click"]).optional(),
3191
+ dismiss: z2.object({
3192
+ onEsc: z2.boolean().optional(),
3193
+ closeButton: z2.boolean().optional(),
3194
+ timeoutMs: z2.number().optional()
4098
3195
  }).optional()
4099
3196
  });
4100
- var HighlightStepZ = z.object({
4101
- kind: z.literal("highlight"),
4102
- id: z.string(),
3197
+ var HighlightStepZ = z2.object({
3198
+ kind: z2.literal("highlight"),
3199
+ id: z2.string(),
4103
3200
  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()
3201
+ copy: z2.string().optional(),
3202
+ ring: z2.object({ paddingPx: z2.number().optional(), radiusPx: z2.number().optional() }).optional(),
3203
+ scrim: z2.object({ opacity: z2.number().optional() }).optional(),
3204
+ ringColor: z2.string().optional(),
3205
+ blocking: z2.boolean().optional(),
3206
+ dismiss: z2.object({
3207
+ onClickOutside: z2.boolean().optional(),
3208
+ onEsc: z2.boolean().optional(),
3209
+ timeoutMs: z2.number().optional()
4113
3210
  }).optional()
4114
3211
  });
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]))
3212
+ var CanvasRecipeZ = z2.object({
3213
+ id: z2.string(),
3214
+ version: z2.number(),
3215
+ routes: z2.array(z2.string()).optional(),
3216
+ steps: z2.array(z2.union([TooltipStepZ, HighlightStepZ]))
4120
3217
  });
4121
3218
  function validateRecipe(json) {
4122
3219
  return CanvasRecipeZ.parse(json);
@@ -4159,74 +3256,67 @@ function SmartCanvasPortal({ element, children }) {
4159
3256
  }
4160
3257
 
4161
3258
  // 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()
3259
+ import { z as z3 } from "zod";
3260
+ var PageContextZ = z3.object({
3261
+ url: z3.string(),
3262
+ routeId: z3.string().optional(),
3263
+ title: z3.string().optional(),
3264
+ locale: z3.string().optional()
4168
3265
  });
4169
- var PageHistoryEntryZ = z2.object({
4170
- url: z2.string(),
4171
- ts: z2.number()
3266
+ var PageHistoryEntryZ = z3.object({
3267
+ url: z3.string(),
3268
+ ts: z3.number()
4172
3269
  });
4173
- var SessionContextZ = z2.object({
4174
- sessionId: z2.string(),
4175
- startTs: z2.number(),
4176
- pageHistory: z2.array(PageHistoryEntryZ).optional()
3270
+ var SessionContextZ = z3.object({
3271
+ sessionId: z3.string(),
3272
+ startTs: z3.number(),
3273
+ pageHistory: z3.array(PageHistoryEntryZ).optional()
4177
3274
  });
4178
- var ViewportContextZ = z2.object({
4179
- width: z2.number(),
4180
- height: z2.number()
3275
+ var ViewportContextZ = z3.object({
3276
+ width: z3.number(),
3277
+ height: z3.number()
4181
3278
  });
4182
- var BoundingBoxZ = z2.object({
4183
- x: z2.number(),
4184
- y: z2.number(),
4185
- w: z2.number(),
4186
- h: z2.number()
3279
+ var BoundingBoxZ = z3.object({
3280
+ x: z3.number(),
3281
+ y: z3.number(),
3282
+ w: z3.number(),
3283
+ h: z3.number()
4187
3284
  });
4188
- var AnchorStateZ = z2.object({
4189
- anchorId: z2.string(),
4190
- present: z2.boolean(),
4191
- visible: z2.boolean().optional(),
3285
+ var AnchorStateZ = z3.object({
3286
+ anchorId: z3.string(),
3287
+ present: z3.boolean(),
3288
+ visible: z3.boolean().optional(),
4192
3289
  boundingBox: BoundingBoxZ.optional()
4193
3290
  });
4194
- var AugmentationZ = z2.record(
4195
- z2.string(),
4196
- z2.union([z2.number(), z2.string(), z2.boolean(), z2.undefined()])
3291
+ var AugmentationZ = z3.record(
3292
+ z3.string(),
3293
+ z3.union([z3.number(), z3.string(), z3.boolean(), z3.undefined()])
4197
3294
  );
4198
- var RuntimeContextZ = z2.object({
3295
+ var RuntimeContextZ = z3.object({
4199
3296
  page: PageContextZ,
4200
3297
  session: SessionContextZ,
4201
3298
  viewport: ViewportContextZ,
4202
- anchors: z2.array(AnchorStateZ).optional(),
3299
+ anchors: z3.array(AnchorStateZ).optional(),
4203
3300
  augmented: AugmentationZ.optional()
4204
3301
  });
4205
3302
  function validateRuntimeContext(data) {
4206
3303
  return RuntimeContextZ.safeParse(data);
4207
3304
  }
4208
3305
 
4209
- // src/events/normalizers/posthog.ts
4210
- import {
4211
- createPostHogNormalizer,
4212
- normalizePostHogEvent,
4213
- shouldNormalizeEvent
4214
- } from "@syntrologie/event-processor/normalizers/posthog";
4215
-
4216
3306
  // 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(),
3307
+ import { z as z4 } from "zod";
3308
+ var EventSourceZ = z4.enum(["posthog", "canvas", "derived"]);
3309
+ var NormalizedEventZ = z4.object({
3310
+ ts: z4.number(),
3311
+ name: z4.string(),
4222
3312
  source: EventSourceZ,
4223
- props: z3.record(z3.string(), z3.unknown()).optional(),
4224
- schemaVersion: z3.string()
3313
+ props: z4.record(z4.string(), z4.unknown()).optional(),
3314
+ schemaVersion: z4.string()
4225
3315
  });
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()
3316
+ var EventFilterZ = z4.object({
3317
+ names: z4.array(z4.string()).optional(),
3318
+ patterns: z4.array(z4.string()).optional(),
3319
+ sources: z4.array(EventSourceZ).optional()
4230
3320
  });
4231
3321
  function validateNormalizedEvent(data) {
4232
3322
  return NormalizedEventZ.safeParse(data);
@@ -4236,14 +3326,14 @@ function validateEventFilter(data) {
4236
3326
  }
4237
3327
 
4238
3328
  // 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()
3329
+ import { z as z5 } from "zod";
3330
+ var StoredValueZ = z5.object({
3331
+ value: z5.unknown(),
3332
+ expiresAt: z5.number().optional()
4243
3333
  });
4244
- var FrequencyEntryZ = z4.object({
4245
- count: z4.number(),
4246
- resetAt: z4.number().optional()
3334
+ var FrequencyEntryZ = z5.object({
3335
+ count: z5.number(),
3336
+ resetAt: z5.number().optional()
4247
3337
  });
4248
3338
  function validateStoredValue(data) {
4249
3339
  return StoredValueZ.safeParse(data);
@@ -4294,6 +3384,7 @@ export {
4294
3384
  EventBus,
4295
3385
  EventCountConditionZ,
4296
3386
  EventFilterZ,
3387
+ EventHistory,
4297
3388
  EventOccurredConditionZ,
4298
3389
  EventSourceZ,
4299
3390
  ExecutorRegistry,
@@ -4305,6 +3396,7 @@ export {
4305
3396
  HighlightZ,
4306
3397
  InsertHtmlZ,
4307
3398
  InsertPositionZ,
3399
+ InterventionTracker,
4308
3400
  MAX_VISIBLE_TOASTS,
4309
3401
  MatchOpZ,
4310
3402
  ModalContentZ,
@@ -4447,8 +3539,10 @@ export {
4447
3539
  validateCondition,
4448
3540
  validateConfig,
4449
3541
  validateEventFilter,
3542
+ validateEventName,
4450
3543
  validateFrequencyEntry,
4451
3544
  validateNormalizedEvent,
3545
+ validateProps,
4452
3546
  validateRecipe,
4453
3547
  validateRuntimeContext,
4454
3548
  validateStoredValue,