@syntrologie/runtime-sdk 2.8.0-canary.9 → 2.8.0-canary.90

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 (64) hide show
  1. package/CAPABILITIES.md +291 -181
  2. package/README.md +3 -0
  3. package/dist/actions/schema.d.ts +783 -783
  4. package/dist/actions/schema.js +3 -3
  5. package/dist/actions/types.d.ts +3 -3
  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/anchor/AnchorResolver.d.ts +1 -0
  10. package/dist/bootstrap-init.d.ts +33 -0
  11. package/dist/bootstrap-runtime.d.ts +7 -0
  12. package/dist/bootstrap-types.d.ts +101 -0
  13. package/dist/bootstrap.d.ts +19 -83
  14. package/dist/{chunk-R5DNAIRI.js → chunk-77TNZ66J.js} +4 -4
  15. package/dist/{chunk-R5DNAIRI.js.map → chunk-77TNZ66J.js.map} +2 -2
  16. package/dist/{chunk-XDYJ64IN.js → chunk-IR6UOR63.js} +4 -4
  17. package/dist/chunk-IR6UOR63.js.map +7 -0
  18. package/dist/{chunk-UURRUKSW.js → chunk-TOBT6CVT.js} +1917 -725
  19. package/dist/chunk-TOBT6CVT.js.map +7 -0
  20. package/dist/chunk-YLLWLUQX.js +241 -0
  21. package/dist/chunk-YLLWLUQX.js.map +7 -0
  22. package/dist/components/ShadowCanvasOverlay.d.ts +1 -2
  23. package/dist/components/TileIcon.d.ts +2 -2
  24. package/dist/components/emojiToIcon.d.ts +24 -0
  25. package/dist/config/schema.d.ts +147 -136
  26. package/dist/config/schema.js +2 -2
  27. package/dist/decisions/schema.d.ts +47 -47
  28. package/dist/decisions/schema.js +1 -1
  29. package/dist/events/EventBus.d.ts +27 -1
  30. package/dist/events/history.d.ts +9 -0
  31. package/dist/events/index.d.ts +3 -0
  32. package/dist/events/normalizers/posthog.d.ts +4 -50
  33. package/dist/events/types.d.ts +30 -23
  34. package/dist/events/validation.d.ts +7 -0
  35. package/dist/fetchers/experimentsFetcher.d.ts +3 -3
  36. package/dist/fetchers/mergeConfigs.d.ts +7 -7
  37. package/dist/index.d.ts +0 -2
  38. package/dist/index.js +1198 -2035
  39. package/dist/index.js.map +4 -4
  40. package/dist/overlays/runtime/overlay/overlay-runner.d.ts +4 -0
  41. package/dist/overlays/runtime/overlay/overlay-state.d.ts +21 -0
  42. package/dist/overlays/types.d.ts +3 -1
  43. package/dist/react.js +6 -4
  44. package/dist/react.js.map +2 -2
  45. package/dist/smart-canvas.esm.js +104 -109
  46. package/dist/smart-canvas.esm.js.map +4 -4
  47. package/dist/smart-canvas.js +6277 -5463
  48. package/dist/smart-canvas.js.map +4 -4
  49. package/dist/smart-canvas.min.js +104 -109
  50. package/dist/smart-canvas.min.js.map +4 -4
  51. package/dist/telemetry/InterventionTracker.d.ts +23 -0
  52. package/dist/telemetry/adapters/posthog.d.ts +30 -4
  53. package/dist/telemetry/index.d.ts +1 -0
  54. package/dist/test/setup.d.ts +1 -0
  55. package/dist/token.d.ts +2 -0
  56. package/dist/version.d.ts +1 -1
  57. package/package.json +23 -28
  58. package/schema/canvas-config.schema.json +2369 -11366
  59. package/scripts/syntroReactPlugin.mjs +3 -0
  60. package/scripts/validate-config.mjs +42 -0
  61. package/dist/chunk-BU4Z6PD7.js +0 -218
  62. package/dist/chunk-BU4Z6PD7.js.map +0 -7
  63. package/dist/chunk-UURRUKSW.js.map +0 -7
  64. package/dist/chunk-XDYJ64IN.js.map +0 -7
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,
@@ -99,8 +101,10 @@ import {
99
101
  useViewportContext,
100
102
  validateAction,
101
103
  validateActions,
104
+ validateEventName,
105
+ validateProps,
102
106
  widgetRegistry
103
- } from "./chunk-UURRUKSW.js";
107
+ } from "./chunk-TOBT6CVT.js";
104
108
  import {
105
109
  AddClassZ,
106
110
  AnchorIdZ,
@@ -134,8 +138,8 @@ import {
134
138
  WaitZ,
135
139
  WidgetConfigZ,
136
140
  coreActionStepSchemas
137
- } from "./chunk-R5DNAIRI.js";
138
- import "./chunk-XDYJ64IN.js";
141
+ } from "./chunk-77TNZ66J.js";
142
+ import "./chunk-IR6UOR63.js";
139
143
  import {
140
144
  ActivationConfigZ,
141
145
  AnchorVisibleConditionZ,
@@ -165,7 +169,7 @@ import {
165
169
  validateActivationConfig,
166
170
  validateCondition,
167
171
  validateStrategy
168
- } from "./chunk-BU4Z6PD7.js";
172
+ } from "./chunk-YLLWLUQX.js";
169
173
 
170
174
  // src/index.ts
171
175
  import React4 from "react";
@@ -257,8 +261,8 @@ var nextId = 0;
257
261
  function generateId() {
258
262
  return `msg-${Date.now()}-${++nextId}`;
259
263
  }
260
- function useChat(options2) {
261
- 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;
262
266
  const [messages, setMessages] = useState(() => {
263
267
  if (greeting) {
264
268
  return [
@@ -291,9 +295,9 @@ function useChat(options2) {
291
295
  setIsLoading(true);
292
296
  try {
293
297
  const currentMessages = [...messages, userMessage];
294
- const historySlice = currentMessages.slice(-maxHistory).map((m) => ({
295
- role: m.role,
296
- content: m.text
298
+ const historySlice = currentMessages.slice(-maxHistory).map((m2) => ({
299
+ role: m2.role,
300
+ content: m2.text
297
301
  }));
298
302
  const response = await sendMessage(backendUrl, {
299
303
  message: trimmed,
@@ -632,2186 +636,1224 @@ var executorDefinitions = [
632
636
  import { jsx as _jsx2, jsxs as _jsxs2 } from "react/jsx-runtime";
633
637
 
634
638
  // ../../node_modules/marked/lib/marked.esm.js
635
- function _getDefaults() {
636
- return {
637
- async: false,
638
- breaks: false,
639
- extensions: null,
640
- gfm: true,
641
- hooks: null,
642
- pedantic: false,
643
- renderer: null,
644
- silent: false,
645
- tokenizer: null,
646
- walkTokens: null
647
- };
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 };
648
641
  }
649
- var _defaults = _getDefaults();
650
- function changeDefaults(newDefaults) {
651
- _defaults = newDefaults;
642
+ var T = M();
643
+ function G(u3) {
644
+ T = u3;
652
645
  }
653
- var noopTest = { exec: () => null };
654
- function edit(regex, opt = "") {
655
- let source = typeof regex === "string" ? regex : regex.source;
656
- const obj = {
657
- replace: (name, val) => {
658
- let valSource = typeof val === "string" ? val : val.source;
659
- valSource = valSource.replace(other.caret, "$1");
660
- source = source.replace(name, valSource);
661
- return obj;
662
- },
663
- getRegex: () => {
664
- return new RegExp(source, opt);
665
- }
666
- };
667
- 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;
668
653
  }
669
- var other = {
670
- codeRemoveIndent: /^(?: {1,4}| {0,3}\t)/gm,
671
- outputLinkReplace: /\\([\[\]])/g,
672
- indentCodeCompensation: /^(\s+)(?:```)/,
673
- beginningSpace: /^\s+/,
674
- endingHash: /#$/,
675
- startingSpaceChar: /^ /,
676
- endingSpaceChar: / $/,
677
- nonSpaceChar: /[^ ]/,
678
- newLineCharGlobal: /\n/g,
679
- tabCharGlobal: /\t/g,
680
- multipleSpaceGlobal: /\s+/g,
681
- blankLine: /^[ \t]*$/,
682
- doubleBlankLine: /\n[ \t]*\n[ \t]*$/,
683
- blockquoteStart: /^ {0,3}>/,
684
- blockquoteSetextReplace: /\n {0,3}((?:=+|-+) *)(?=\n|$)/g,
685
- blockquoteSetextReplace2: /^ {0,3}>[ \t]?/gm,
686
- listReplaceTabs: /^\t+/,
687
- listReplaceNesting: /^ {1,4}(?=( {4})*[^ ])/g,
688
- listIsTask: /^\[[ xX]\] /,
689
- listReplaceTask: /^\[[ xX]\] +/,
690
- anyLine: /\n.*\n/,
691
- hrefBrackets: /^<(.*)>$/,
692
- tableDelimiter: /[:|]/,
693
- tableAlignChars: /^\||\| *$/g,
694
- tableRowBlankLine: /\n[ \t]*$/,
695
- tableAlignRight: /^ *-+: *$/,
696
- tableAlignCenter: /^ *:-+: *$/,
697
- tableAlignLeft: /^ *:-+ *$/,
698
- startATag: /^<a /i,
699
- endATag: /^<\/a>/i,
700
- startPreScriptTag: /^<(pre|code|kbd|script)(\s|>)/i,
701
- endPreScriptTag: /^<\/(pre|code|kbd|script)(\s|>)/i,
702
- startAngleBracket: /^</,
703
- endAngleBracket: />$/,
704
- pedanticHrefTitle: /^([^'"]*[^\s])\s+(['"])(.*)\2/,
705
- unicodeAlphaNumeric: /[\p{L}\p{N}]/u,
706
- escapeTest: /[&<>"']/,
707
- escapeReplace: /[&<>"']/g,
708
- escapeTestNoEncode: /[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,
709
- escapeReplaceNoEncode: /[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,
710
- unescapeTest: /&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig,
711
- caret: /(^|[^\[])\^/g,
712
- percentDecode: /%25/g,
713
- findPipe: /\|/g,
714
- splitPipe: / \|/,
715
- slashPipe: /\\\|/g,
716
- carriageReturn: /\r\n|\r/g,
717
- spaceLine: /^ +$/gm,
718
- notSpaceStart: /^\S*/,
719
- endingNewline: /\n$/,
720
- listItemRegex: (bull) => new RegExp(`^( {0,3}${bull})((?:[ ][^\\n]*)?(?:\\n|$))`),
721
- nextBulletRegex: (indent) => new RegExp(`^ {0,${Math.min(3, indent - 1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),
722
- hrRegex: (indent) => new RegExp(`^ {0,${Math.min(3, indent - 1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),
723
- fencesBeginRegex: (indent) => new RegExp(`^ {0,${Math.min(3, indent - 1)}}(?:\`\`\`|~~~)`),
724
- headingBeginRegex: (indent) => new RegExp(`^ {0,${Math.min(3, indent - 1)}}#`),
725
- htmlBeginRegex: (indent) => new RegExp(`^ {0,${Math.min(3, indent - 1)}}<(?:[a-z].*>|!--)`, "i")
726
- };
727
- var newline = /^(?:[ \t]*(?:\n|$))+/;
728
- var blockCode = /^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/;
729
- var fences = /^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/;
730
- var hr = /^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/;
731
- var heading = /^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/;
732
- var bullet = /(?:[*+-]|\d{1,9}[.)])/;
733
- var lheadingCore = /^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/;
734
- 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();
735
- 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();
736
- var _paragraph = /^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/;
737
- var blockText = /^[^\n]+/;
738
- var _blockLabel = /(?!\s*\])(?:\\.|[^\[\]\\])+/;
739
- 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();
740
- var list = edit(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g, bullet).getRegex();
741
- 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";
742
- var _comment = /<!--(?:-?>|[\s\S]*?(?:-->|$))/;
743
- var html = edit(
744
- "^ {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|$))",
745
- "i"
746
- ).replace("comment", _comment).replace("tag", _tag).replace("attribute", / +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex();
747
- 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();
748
- var blockquote = edit(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph", paragraph).getRegex();
749
- var blockNormal = {
750
- blockquote,
751
- code: blockCode,
752
- def,
753
- fences,
754
- heading,
755
- hr,
756
- html,
757
- lheading,
758
- list,
759
- newline,
760
- paragraph,
761
- table: noopTest,
762
- text: blockText
763
- };
764
- var gfmTable = edit(
765
- "^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)"
766
- ).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();
767
- var blockGfm = {
768
- ...blockNormal,
769
- lheading: lheadingGfm,
770
- table: gfmTable,
771
- 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()
772
- };
773
- var blockPedantic = {
774
- ...blockNormal,
775
- html: edit(
776
- `^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`
777
- ).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(),
778
- def: /^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,
779
- heading: /^(#{1,6})(.*)(?:\n+|$)/,
780
- fences: noopTest,
781
- // fences not supported
782
- lheading: /^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,
783
- 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()
784
- };
785
- var escape = /^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/;
786
- var inlineCode = /^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/;
787
- var br = /^( {2,}|\\)\n(?!\s*$)/;
788
- var inlineText = /^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/;
789
- var _punctuation = /[\p{P}\p{S}]/u;
790
- var _punctuationOrSpace = /[\s\p{P}\p{S}]/u;
791
- var _notPunctuationOrSpace = /[^\s\p{P}\p{S}]/u;
792
- var punctuation = edit(/^((?![*_])punctSpace)/, "u").replace(/punctSpace/g, _punctuationOrSpace).getRegex();
793
- var _punctuationGfmStrongEm = /(?!~)[\p{P}\p{S}]/u;
794
- var _punctuationOrSpaceGfmStrongEm = /(?!~)[\s\p{P}\p{S}]/u;
795
- var _notPunctuationOrSpaceGfmStrongEm = /(?:[^\s\p{P}\p{S}]|~)/u;
796
- var blockSkip = /\[[^[\]]*?\]\((?:\\.|[^\\\(\)]|\((?:\\.|[^\\\(\)])*\))*\)|`[^`]*?`|<[^<>]*?>/g;
797
- var emStrongLDelimCore = /^(?:\*+(?:((?!\*)punct)|[^\s*]))|^_+(?:((?!_)punct)|([^\s_]))/;
798
- var emStrongLDelim = edit(emStrongLDelimCore, "u").replace(/punct/g, _punctuation).getRegex();
799
- var emStrongLDelimGfm = edit(emStrongLDelimCore, "u").replace(/punct/g, _punctuationGfmStrongEm).getRegex();
800
- var emStrongRDelimAstCore = "^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)";
801
- var emStrongRDelimAst = edit(emStrongRDelimAstCore, "gu").replace(/notPunctSpace/g, _notPunctuationOrSpace).replace(/punctSpace/g, _punctuationOrSpace).replace(/punct/g, _punctuation).getRegex();
802
- var emStrongRDelimAstGfm = edit(emStrongRDelimAstCore, "gu").replace(/notPunctSpace/g, _notPunctuationOrSpaceGfmStrongEm).replace(/punctSpace/g, _punctuationOrSpaceGfmStrongEm).replace(/punct/g, _punctuationGfmStrongEm).getRegex();
803
- var emStrongRDelimUnd = edit(
804
- "^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)",
805
- "gu"
806
- ).replace(/notPunctSpace/g, _notPunctuationOrSpace).replace(/punctSpace/g, _punctuationOrSpace).replace(/punct/g, _punctuation).getRegex();
807
- var anyPunctuation = edit(/\\(punct)/, "gu").replace(/punct/g, _punctuation).getRegex();
808
- 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();
809
- var _inlineComment = edit(_comment).replace("(?:-->|$)", "-->").getRegex();
810
- var tag = edit(
811
- "^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>"
812
- ).replace("comment", _inlineComment).replace("attribute", /\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex();
813
- var _inlineLabel = /(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/;
814
- var link = edit(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]*(?:\n[ \t]*)?)(title))?\s*\)/).replace("label", _inlineLabel).replace("href", /<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title", /"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex();
815
- var reflink = edit(/^!?\[(label)\]\[(ref)\]/).replace("label", _inlineLabel).replace("ref", _blockLabel).getRegex();
816
- var nolink = edit(/^!?\[(ref)\](?:\[\])?/).replace("ref", _blockLabel).getRegex();
817
- var reflinkSearch = edit("reflink|nolink(?!\\()", "g").replace("reflink", reflink).replace("nolink", nolink).getRegex();
818
- var inlineNormal = {
819
- _backpedal: noopTest,
820
- // only used for GFM url
821
- anyPunctuation,
822
- autolink,
823
- blockSkip,
824
- br,
825
- code: inlineCode,
826
- del: noopTest,
827
- emStrongLDelim,
828
- emStrongRDelimAst,
829
- emStrongRDelimUnd,
830
- escape,
831
- link,
832
- nolink,
833
- punctuation,
834
- reflink,
835
- reflinkSearch,
836
- tag,
837
- text: inlineText,
838
- url: noopTest
839
- };
840
- var inlinePedantic = {
841
- ...inlineNormal,
842
- link: edit(/^!?\[(label)\]\((.*?)\)/).replace("label", _inlineLabel).getRegex(),
843
- reflink: edit(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label", _inlineLabel).getRegex()
844
- };
845
- var inlineGfm = {
846
- ...inlineNormal,
847
- emStrongRDelimAst: emStrongRDelimAstGfm,
848
- emStrongLDelim: emStrongLDelimGfm,
849
- 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(),
850
- _backpedal: /(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,
851
- del: /^(~~?)(?=[^\s~])((?:\\.|[^\\])*?(?:\\.|[^\s~\\]))\1(?=[^~]|$)/,
852
- text: /^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|https?:\/\/|ftp:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/
853
- };
854
- var inlineBreaks = {
855
- ...inlineGfm,
856
- br: edit(br).replace("{2,}", "*").getRegex(),
857
- text: edit(inlineGfm.text).replace("\\b_", "\\b_| {2,}\\n").replace(/\{2,\}/g, "*").getRegex()
858
- };
859
- var block = {
860
- normal: blockNormal,
861
- gfm: blockGfm,
862
- pedantic: blockPedantic
863
- };
864
- var inline = {
865
- normal: inlineNormal,
866
- gfm: inlineGfm,
867
- breaks: inlineBreaks,
868
- pedantic: inlinePedantic
869
- };
870
- var escapeReplacements = {
871
- "&": "&amp;",
872
- "<": "&lt;",
873
- ">": "&gt;",
874
- '"': "&quot;",
875
- "'": "&#39;"
876
- };
877
- var getEscapeReplacement = (ch) => escapeReplacements[ch];
878
- function escape2(html2, encode) {
879
- if (encode) {
880
- if (other.escapeTest.test(html2)) {
881
- return html2.replace(other.escapeReplace, getEscapeReplacement);
882
- }
883
- } else {
884
- if (other.escapeTestNoEncode.test(html2)) {
885
- return html2.replace(other.escapeReplaceNoEncode, getEscapeReplacement);
886
- }
654
+ var Re = (() => {
655
+ try {
656
+ return !!new RegExp("(?<=1)(?<!1)");
657
+ } catch {
658
+ return false;
887
659
  }
888
- 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;
889
734
  }
890
- function cleanUrl(href) {
735
+ function X(u3) {
891
736
  try {
892
- href = encodeURI(href).replace(other.percentDecode, "%");
737
+ u3 = encodeURI(u3).replace(m.percentDecode, "%");
893
738
  } catch {
894
739
  return null;
895
740
  }
896
- return href;
741
+ return u3;
897
742
  }
898
- function splitCells(tableRow, count) {
743
+ function J(u3, e) {
899
744
  var _a2;
900
- const row = tableRow.replace(other.findPipe, (match, offset, str) => {
901
- let escaped = false;
902
- let curr = offset;
903
- while (--curr >= 0 && str[curr] === "\\") escaped = !escaped;
904
- if (escaped) {
905
- return "|";
906
- } else {
907
- return " |";
908
- }
909
- }), cells = row.split(other.splitPipe);
910
- let i = 0;
911
- if (!cells[0].trim()) {
912
- cells.shift();
913
- }
914
- if (cells.length > 0 && !((_a2 = cells.at(-1)) == null ? void 0 : _a2.trim())) {
915
- cells.pop();
916
- }
917
- if (count) {
918
- if (cells.length > count) {
919
- cells.splice(count);
920
- } else {
921
- while (cells.length < count) cells.push("");
922
- }
923
- }
924
- for (; i < cells.length; i++) {
925
- cells[i] = cells[i].trim().replace(other.slashPipe, "|");
926
- }
927
- 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;
928
754
  }
929
- function rtrim(str, c, invert) {
930
- const l = str.length;
931
- if (l === 0) {
932
- return "";
933
- }
934
- let suffLen = 0;
935
- while (suffLen < l) {
936
- const currChar = str.charAt(l - suffLen - 1);
937
- if (currChar === c && !invert) {
938
- suffLen++;
939
- } else if (currChar !== c && invert) {
940
- suffLen++;
941
- } else {
942
- break;
943
- }
944
- }
945
- 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);
946
766
  }
947
- function findClosingBracket(str, b) {
948
- if (str.indexOf(b[1]) === -1) {
949
- return -1;
950
- }
951
- let level = 0;
952
- for (let i = 0; i < str.length; i++) {
953
- if (str[i] === "\\") {
954
- i++;
955
- } else if (str[i] === b[0]) {
956
- level++;
957
- } else if (str[i] === b[1]) {
958
- level--;
959
- if (level < 0) {
960
- return i;
961
- }
962
- }
963
- }
964
- if (level > 0) {
965
- return -2;
966
- }
967
- 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;
968
774
  }
969
- function outputLink(cap, link2, raw, lexer2, rules) {
970
- const href = link2.href;
971
- const title = link2.title || null;
972
- const text = cap[1].replace(rules.other.outputLinkReplace, "$1");
973
- lexer2.state.inLink = true;
974
- const token = {
975
- type: cap[0].charAt(0) === "!" ? "image" : "link",
976
- raw,
977
- href,
978
- title,
979
- text,
980
- tokens: lexer2.inlineTokens(text)
981
- };
982
- lexer2.state.inLink = false;
983
- 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;
984
782
  }
985
- function indentCodeCompensation(raw, text, rules) {
986
- const matchIndentToCode = raw.match(rules.other.indentCodeCompensation);
987
- if (matchIndentToCode === null) {
988
- return text;
989
- }
990
- const indentToCode = matchIndentToCode[1];
991
- return text.split("\n").map((node) => {
992
- const matchIndentInNode = node.match(rules.other.beginningSpace);
993
- if (matchIndentInNode === null) {
994
- return node;
995
- }
996
- const [indentInNode] = matchIndentInNode;
997
- if (indentInNode.length >= indentToCode.length) {
998
- return node.slice(indentToCode.length);
999
- }
1000
- return node;
1001
- }).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;
1002
788
  }
1003
- var _Tokenizer = class {
1004
- // set by the lexer
1005
- constructor(options2) {
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
+ `);
801
+ }
802
+ var w = class {
803
+ constructor(e) {
1006
804
  __publicField(this, "options");
1007
805
  __publicField(this, "rules");
1008
- // set by the lexer
1009
806
  __publicField(this, "lexer");
1010
- this.options = options2 || _defaults;
1011
- }
1012
- space(src) {
1013
- const cap = this.rules.block.newline.exec(src);
1014
- if (cap && cap[0].length > 0) {
1015
- return {
1016
- type: "space",
1017
- raw: cap[0]
1018
- };
1019
- }
1020
- }
1021
- code(src) {
1022
- const cap = this.rules.block.code.exec(src);
1023
- if (cap) {
1024
- const text = cap[0].replace(this.rules.other.codeRemoveIndent, "");
1025
- return {
1026
- type: "code",
1027
- raw: cap[0],
1028
- codeBlockStyle: "indented",
1029
- text: !this.options.pedantic ? rtrim(text, "\n") : text
1030
- };
1031
- }
1032
- }
1033
- fences(src) {
1034
- const cap = this.rules.block.fences.exec(src);
1035
- if (cap) {
1036
- const raw = cap[0];
1037
- const text = indentCodeCompensation(raw, cap[3] || "", this.rules);
1038
- return {
1039
- type: "code",
1040
- raw,
1041
- lang: cap[2] ? cap[2].trim().replace(this.rules.inline.anyPunctuation, "$1") : cap[2],
1042
- text
1043
- };
1044
- }
1045
- }
1046
- heading(src) {
1047
- const cap = this.rules.block.heading.exec(src);
1048
- if (cap) {
1049
- let text = cap[2].trim();
1050
- if (this.rules.other.endingHash.test(text)) {
1051
- const trimmed = rtrim(text, "#");
1052
- if (this.options.pedantic) {
1053
- text = trimmed.trim();
1054
- } else if (!trimmed || this.rules.other.endingSpaceChar.test(trimmed)) {
1055
- text = trimmed.trim();
1056
- }
1057
- }
1058
- return {
1059
- type: "heading",
1060
- raw: cap[0],
1061
- depth: cap[1].length,
1062
- text,
1063
- tokens: this.lexer.inline(text)
1064
- };
1065
- }
1066
- }
1067
- hr(src) {
1068
- const cap = this.rules.block.hr.exec(src);
1069
- if (cap) {
1070
- return {
1071
- type: "hr",
1072
- raw: rtrim(cap[0], "\n")
1073
- };
1074
- }
1075
- }
1076
- blockquote(src) {
1077
- const cap = this.rules.block.blockquote.exec(src);
1078
- if (cap) {
1079
- let lines = rtrim(cap[0], "\n").split("\n");
1080
- let raw = "";
1081
- let text = "";
1082
- const tokens = [];
1083
- while (lines.length > 0) {
1084
- let inBlockquote = false;
1085
- const currentLines = [];
1086
- let i;
1087
- for (i = 0; i < lines.length; i++) {
1088
- if (this.rules.other.blockquoteStart.test(lines[i])) {
1089
- currentLines.push(lines[i]);
1090
- inBlockquote = true;
1091
- } else if (!inBlockquote) {
1092
- currentLines.push(lines[i]);
1093
- } else {
1094
- break;
1095
- }
1096
- }
1097
- lines = lines.slice(i);
1098
- const currentRaw = currentLines.join("\n");
1099
- const currentText = currentRaw.replace(this.rules.other.blockquoteSetextReplace, "\n $1").replace(this.rules.other.blockquoteSetextReplace2, "");
1100
- raw = raw ? `${raw}
1101
- ${currentRaw}` : currentRaw;
1102
- text = text ? `${text}
1103
- ${currentText}` : currentText;
1104
- const top = this.lexer.state.top;
1105
- this.lexer.state.top = true;
1106
- this.lexer.blockTokens(currentText, tokens, true);
1107
- this.lexer.state.top = top;
1108
- if (lines.length === 0) {
1109
- break;
1110
- }
1111
- const lastToken = tokens.at(-1);
1112
- if ((lastToken == null ? void 0 : lastToken.type) === "code") {
1113
- break;
1114
- } else if ((lastToken == null ? void 0 : lastToken.type) === "blockquote") {
1115
- const oldToken = lastToken;
1116
- const newText = oldToken.raw + "\n" + lines.join("\n");
1117
- const newToken = this.blockquote(newText);
1118
- tokens[tokens.length - 1] = newToken;
1119
- raw = raw.substring(0, raw.length - oldToken.raw.length) + newToken.raw;
1120
- text = text.substring(0, text.length - oldToken.text.length) + newToken.text;
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;
1121
871
  break;
1122
- } else if ((lastToken == null ? void 0 : lastToken.type) === "list") {
1123
- const oldToken = lastToken;
1124
- const newText = oldToken.raw + "\n" + lines.join("\n");
1125
- const newToken = this.list(newText);
1126
- tokens[tokens.length - 1] = newToken;
1127
- raw = raw.substring(0, raw.length - lastToken.raw.length) + newToken.raw;
1128
- text = text.substring(0, text.length - oldToken.raw.length) + newToken.raw;
1129
- 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
+ `);
1130
878
  continue;
1131
879
  }
1132
880
  }
1133
- return {
1134
- type: "blockquote",
1135
- raw,
1136
- tokens,
1137
- text
1138
- };
881
+ return { type: "blockquote", raw: r, tokens: s, text: i };
1139
882
  }
1140
883
  }
1141
- list(src) {
1142
- let cap = this.rules.block.list.exec(src);
1143
- if (cap) {
1144
- let bull = cap[1].trim();
1145
- const isordered = bull.length > 1;
1146
- const list2 = {
1147
- type: "list",
1148
- raw: "",
1149
- ordered: isordered,
1150
- start: isordered ? +bull.slice(0, -1) : "",
1151
- loose: false,
1152
- items: []
1153
- };
1154
- bull = isordered ? `\\d{1,9}\\${bull.slice(-1)}` : `\\${bull}`;
1155
- if (this.options.pedantic) {
1156
- bull = isordered ? bull : "[*+-]";
1157
- }
1158
- const itemRegex = this.rules.other.listItemRegex(bull);
1159
- let endsWithBlankLine = false;
1160
- while (src) {
1161
- let endEarly = false;
1162
- let raw = "";
1163
- let itemContents = "";
1164
- if (!(cap = itemRegex.exec(src))) {
1165
- break;
1166
- }
1167
- if (this.rules.block.hr.test(src)) {
1168
- break;
1169
- }
1170
- raw = cap[0];
1171
- src = src.substring(raw.length);
1172
- let line = cap[2].split("\n", 1)[0].replace(this.rules.other.listReplaceTabs, (t) => " ".repeat(3 * t.length));
1173
- let nextLine = src.split("\n", 1)[0];
1174
- let blankLine = !line.trim();
1175
- let indent = 0;
1176
- if (this.options.pedantic) {
1177
- indent = 2;
1178
- itemContents = line.trimStart();
1179
- } else if (blankLine) {
1180
- indent = cap[1].length + 1;
1181
- } else {
1182
- indent = cap[2].search(this.rules.other.nonSpaceChar);
1183
- indent = indent > 4 ? 1 : indent;
1184
- itemContents = line.slice(indent);
1185
- indent += cap[1].length;
1186
- }
1187
- if (blankLine && this.rules.other.blankLine.test(nextLine)) {
1188
- raw += nextLine + "\n";
1189
- src = src.substring(nextLine.length + 1);
1190
- endEarly = true;
1191
- }
1192
- if (!endEarly) {
1193
- const nextBulletRegex = this.rules.other.nextBulletRegex(indent);
1194
- const hrRegex = this.rules.other.hrRegex(indent);
1195
- const fencesBeginRegex = this.rules.other.fencesBeginRegex(indent);
1196
- const headingBeginRegex = this.rules.other.headingBeginRegex(indent);
1197
- const htmlBeginRegex = this.rules.other.htmlBeginRegex(indent);
1198
- while (src) {
1199
- const rawLine = src.split("\n", 1)[0];
1200
- let nextLineWithoutTabs;
1201
- nextLine = rawLine;
1202
- if (this.options.pedantic) {
1203
- nextLine = nextLine.replace(this.rules.other.listReplaceNesting, " ");
1204
- nextLineWithoutTabs = nextLine;
1205
- } else {
1206
- nextLineWithoutTabs = nextLine.replace(this.rules.other.tabCharGlobal, " ");
1207
- }
1208
- if (fencesBeginRegex.test(nextLine)) {
1209
- break;
1210
- }
1211
- if (headingBeginRegex.test(nextLine)) {
1212
- break;
1213
- }
1214
- if (htmlBeginRegex.test(nextLine)) {
1215
- break;
1216
- }
1217
- if (nextBulletRegex.test(nextLine)) {
1218
- break;
1219
- }
1220
- if (hrRegex.test(nextLine)) {
1221
- break;
1222
- }
1223
- if (nextLineWithoutTabs.search(this.rules.other.nonSpaceChar) >= indent || !nextLine.trim()) {
1224
- itemContents += "\n" + nextLineWithoutTabs.slice(indent);
1225
- } else {
1226
- if (blankLine) {
1227
- break;
1228
- }
1229
- if (line.replace(this.rules.other.tabCharGlobal, " ").search(this.rules.other.nonSpaceChar) >= 4) {
1230
- break;
1231
- }
1232
- if (fencesBeginRegex.test(line)) {
1233
- break;
1234
- }
1235
- if (headingBeginRegex.test(line)) {
1236
- break;
1237
- }
1238
- if (hrRegex.test(line)) {
1239
- break;
1240
- }
1241
- itemContents += "\n" + nextLine;
1242
- }
1243
- if (!blankLine && !nextLine.trim()) {
1244
- 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;
1245
911
  }
1246
- raw += rawLine + "\n";
1247
- src = src.substring(rawLine.length + 1);
1248
- line = nextLineWithoutTabs.slice(indent);
912
+ R = !h.trim(), p += H + `
913
+ `, e = e.substring(H.length + 1), d = I.slice(f);
1249
914
  }
1250
915
  }
1251
- if (!list2.loose) {
1252
- if (endsWithBlankLine) {
1253
- list2.loose = true;
1254
- } else if (this.rules.other.doubleBlankLine.test(raw)) {
1255
- 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
+ }
1256
930
  }
1257
- }
1258
- let istask = null;
1259
- let ischecked;
1260
- if (this.options.gfm) {
1261
- istask = this.rules.other.listIsTask.exec(itemContents);
1262
- if (istask) {
1263
- ischecked = istask[0] !== "[ ] ";
1264
- 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);
1265
935
  }
1266
936
  }
1267
- list2.items.push({
1268
- type: "list_item",
1269
- raw,
1270
- task: !!istask,
1271
- checked: ischecked,
1272
- loose: false,
1273
- text: itemContents,
1274
- tokens: []
1275
- });
1276
- list2.raw += raw;
1277
- }
1278
- const lastItem = list2.items.at(-1);
1279
- if (lastItem) {
1280
- lastItem.raw = lastItem.raw.trimEnd();
1281
- lastItem.text = lastItem.text.trimEnd();
1282
- } else {
1283
- return;
1284
- }
1285
- list2.raw = list2.raw.trimEnd();
1286
- for (let i = 0; i < list2.items.length; i++) {
1287
- this.lexer.state.top = false;
1288
- list2.items[i].tokens = this.lexer.blockTokens(list2.items[i].text, []);
1289
- if (!list2.loose) {
1290
- const spacers = list2.items[i].tokens.filter((t) => t.type === "space");
1291
- const hasMultipleLineBreaks = spacers.length > 0 && spacers.some((t) => this.rules.other.anyLine.test(t.raw));
1292
- 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;
1293
940
  }
1294
941
  }
1295
- if (list2.loose) {
1296
- for (let i = 0; i < list2.items.length; i++) {
1297
- list2.items[i].loose = true;
1298
- }
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");
1299
945
  }
1300
- return list2;
946
+ return i;
1301
947
  }
1302
948
  }
1303
- html(src) {
1304
- const cap = this.rules.block.html.exec(src);
1305
- if (cap) {
1306
- const token = {
1307
- type: "html",
1308
- block: true,
1309
- raw: cap[0],
1310
- pre: cap[1] === "pre" || cap[1] === "script" || cap[1] === "style",
1311
- text: cap[0]
1312
- };
1313
- return token;
1314
- }
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] };
1315
952
  }
1316
- def(src) {
1317
- const cap = this.rules.block.def.exec(src);
1318
- if (cap) {
1319
- const tag2 = cap[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal, " ");
1320
- const href = cap[2] ? cap[2].replace(this.rules.other.hrefBrackets, "$1").replace(this.rules.inline.anyPunctuation, "$1") : "";
1321
- const title = cap[3] ? cap[3].substring(1, cap[3].length - 1).replace(this.rules.inline.anyPunctuation, "$1") : cap[3];
1322
- return {
1323
- type: "def",
1324
- tag: tag2,
1325
- raw: cap[0],
1326
- href,
1327
- title
1328
- };
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 };
1329
958
  }
1330
959
  }
1331
- table(src) {
960
+ table(e) {
1332
961
  var _a2;
1333
- const cap = this.rules.block.table.exec(src);
1334
- if (!cap) {
1335
- return;
1336
- }
1337
- if (!this.rules.other.tableDelimiter.test(cap[2])) {
1338
- return;
1339
- }
1340
- const headers = splitCells(cap[1]);
1341
- const aligns = cap[2].replace(this.rules.other.tableAlignChars, "").split("|");
1342
- const rows = ((_a2 = cap[3]) == null ? void 0 : _a2.trim()) ? cap[3].replace(this.rules.other.tableRowBlankLine, "").split("\n") : [];
1343
- const item = {
1344
- type: "table",
1345
- raw: cap[0],
1346
- header: [],
1347
- align: [],
1348
- rows: []
1349
- };
1350
- if (headers.length !== aligns.length) {
1351
- return;
1352
- }
1353
- for (const align of aligns) {
1354
- if (this.rules.other.tableAlignRight.test(align)) {
1355
- item.align.push("right");
1356
- } else if (this.rules.other.tableAlignCenter.test(align)) {
1357
- item.align.push("center");
1358
- } else if (this.rules.other.tableAlignLeft.test(align)) {
1359
- item.align.push("left");
1360
- } else {
1361
- item.align.push(null);
1362
- }
1363
- }
1364
- for (let i = 0; i < headers.length; i++) {
1365
- item.header.push({
1366
- text: headers[i],
1367
- tokens: this.lexer.inline(headers[i]),
1368
- header: true,
1369
- align: item.align[i]
1370
- });
1371
- }
1372
- for (const row of rows) {
1373
- item.rows.push(splitCells(row, item.header.length).map((cell, i) => {
1374
- return {
1375
- text: cell,
1376
- tokens: this.lexer.inline(cell),
1377
- header: false,
1378
- align: item.align[i]
1379
- };
1380
- }));
1381
- }
1382
- return item;
1383
- }
1384
- lheading(src) {
1385
- const cap = this.rules.block.lheading.exec(src);
1386
- if (cap) {
1387
- return {
1388
- type: "heading",
1389
- raw: cap[0],
1390
- depth: cap[2].charAt(0) === "=" ? 1 : 2,
1391
- text: cap[1],
1392
- tokens: this.lexer.inline(cap[1])
1393
- };
1394
- }
1395
- }
1396
- paragraph(src) {
1397
- const cap = this.rules.block.paragraph.exec(src);
1398
- if (cap) {
1399
- const text = cap[1].charAt(cap[1].length - 1) === "\n" ? cap[1].slice(0, -1) : cap[1];
1400
- return {
1401
- type: "paragraph",
1402
- raw: cap[0],
1403
- text,
1404
- tokens: this.lexer.inline(text)
1405
- };
1406
- }
1407
- }
1408
- text(src) {
1409
- const cap = this.rules.block.text.exec(src);
1410
- if (cap) {
1411
- return {
1412
- type: "text",
1413
- raw: cap[0],
1414
- text: cap[0],
1415
- tokens: this.lexer.inline(cap[0])
1416
- };
1417
- }
1418
- }
1419
- escape(src) {
1420
- const cap = this.rules.inline.escape.exec(src);
1421
- if (cap) {
1422
- return {
1423
- type: "escape",
1424
- raw: cap[0],
1425
- text: cap[1]
1426
- };
1427
- }
1428
- }
1429
- tag(src) {
1430
- const cap = this.rules.inline.tag.exec(src);
1431
- if (cap) {
1432
- if (!this.lexer.state.inLink && this.rules.other.startATag.test(cap[0])) {
1433
- this.lexer.state.inLink = true;
1434
- } else if (this.lexer.state.inLink && this.rules.other.endATag.test(cap[0])) {
1435
- this.lexer.state.inLink = false;
1436
- }
1437
- if (!this.lexer.state.inRawBlock && this.rules.other.startPreScriptTag.test(cap[0])) {
1438
- this.lexer.state.inRawBlock = true;
1439
- } else if (this.lexer.state.inRawBlock && this.rules.other.endPreScriptTag.test(cap[0])) {
1440
- this.lexer.state.inRawBlock = false;
1441
- }
1442
- return {
1443
- type: "html",
1444
- raw: cap[0],
1445
- inLink: this.lexer.state.inLink,
1446
- inRawBlock: this.lexer.state.inRawBlock,
1447
- block: false,
1448
- text: cap[0]
1449
- };
1450
- }
1451
- }
1452
- link(src) {
1453
- const cap = this.rules.inline.link.exec(src);
1454
- if (cap) {
1455
- const trimmedUrl = cap[2].trim();
1456
- if (!this.options.pedantic && this.rules.other.startAngleBracket.test(trimmedUrl)) {
1457
- if (!this.rules.other.endAngleBracket.test(trimmedUrl)) {
1458
- return;
1459
- }
1460
- const rtrimSlash = rtrim(trimmedUrl.slice(0, -1), "\\");
1461
- if ((trimmedUrl.length - rtrimSlash.length) % 2 === 0) {
1462
- return;
1463
- }
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;
1464
1005
  } else {
1465
- const lastParenIndex = findClosingBracket(cap[2], "()");
1466
- if (lastParenIndex === -2) {
1467
- return;
1468
- }
1469
- if (lastParenIndex > -1) {
1470
- const start = cap[0].indexOf("!") === 0 ? 5 : 4;
1471
- const linkLen = start + cap[1].length + lastParenIndex;
1472
- cap[2] = cap[2].substring(0, lastParenIndex);
1473
- cap[0] = cap[0].substring(0, linkLen).trim();
1474
- 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] = "";
1475
1011
  }
1476
1012
  }
1477
- let href = cap[2];
1478
- let title = "";
1013
+ let r = t[2], i = "";
1479
1014
  if (this.options.pedantic) {
1480
- const link2 = this.rules.other.pedanticHrefTitle.exec(href);
1481
- if (link2) {
1482
- href = link2[1];
1483
- 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;
1484
1045
  }
1485
- } else {
1486
- title = cap[3] ? cap[3].slice(1, -1) : "";
1487
- }
1488
- href = href.trim();
1489
- if (this.rules.other.startAngleBracket.test(href)) {
1490
- if (this.options.pedantic && !this.rules.other.endAngleBracket.test(trimmedUrl)) {
1491
- href = href.slice(1);
1492
- } else {
1493
- 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) };
1494
1052
  }
1053
+ let R = h.slice(2, -2);
1054
+ return { type: "strong", raw: h, text: R, tokens: this.lexer.inlineTokens(R) };
1495
1055
  }
1496
- return outputLink(cap, {
1497
- href: href ? href.replace(this.rules.inline.anyPunctuation, "$1") : href,
1498
- title: title ? title.replace(this.rules.inline.anyPunctuation, "$1") : title
1499
- }, cap[0], this.lexer, this.rules);
1500
1056
  }
1501
1057
  }
1502
- reflink(src, links) {
1503
- let cap;
1504
- if ((cap = this.rules.inline.reflink.exec(src)) || (cap = this.rules.inline.nolink.exec(src))) {
1505
- const linkString = (cap[2] || cap[1]).replace(this.rules.other.multipleSpaceGlobal, " ");
1506
- const link2 = links[linkString.toLowerCase()];
1507
- if (!link2) {
1508
- const text = cap[0].charAt(0);
1509
- return {
1510
- type: "text",
1511
- raw: text,
1512
- text
1513
- };
1514
- }
1515
- 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 };
1516
1063
  }
1517
1064
  }
1518
- emStrong(src, maskedSrc, prevChar = "") {
1519
- let match = this.rules.inline.emStrongLDelim.exec(src);
1520
- if (!match) return;
1521
- if (match[3] && prevChar.match(this.rules.other.unicodeAlphaNumeric)) return;
1522
- const nextChar = match[1] || match[2] || "";
1523
- if (!nextChar || !prevChar || this.rules.inline.punctuation.exec(prevChar)) {
1524
- const lLength = [...match[0]].length - 1;
1525
- let rDelim, rLength, delimTotal = lLength, midDelimTotal = 0;
1526
- const endReg = match[0][0] === "*" ? this.rules.inline.emStrongRDelimAst : this.rules.inline.emStrongRDelimUnd;
1527
- endReg.lastIndex = 0;
1528
- maskedSrc = maskedSrc.slice(-1 * src.length + lLength);
1529
- while ((match = endReg.exec(maskedSrc)) != null) {
1530
- rDelim = match[1] || match[2] || match[3] || match[4] || match[5] || match[6];
1531
- if (!rDelim) continue;
1532
- rLength = [...rDelim].length;
1533
- if (match[3] || match[4]) {
1534
- 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;
1535
1078
  continue;
1536
- } else if (match[5] || match[6]) {
1537
- if (lLength % 3 && !((lLength + rLength) % 3)) {
1538
- midDelimTotal += rLength;
1539
- continue;
1540
- }
1541
- }
1542
- delimTotal -= rLength;
1543
- if (delimTotal > 0) continue;
1544
- rLength = Math.min(rLength, rLength + delimTotal + midDelimTotal);
1545
- const lastCharLength = [...match[0]][0].length;
1546
- const raw = src.slice(0, lLength + match.index + lastCharLength + rLength);
1547
- if (Math.min(lLength, rLength) % 2) {
1548
- const text2 = raw.slice(1, -1);
1549
- return {
1550
- type: "em",
1551
- raw,
1552
- text: text2,
1553
- tokens: this.lexer.inlineTokens(text2)
1554
- };
1555
1079
  }
1556
- const text = raw.slice(2, -2);
1557
- return {
1558
- type: "strong",
1559
- raw,
1560
- text,
1561
- tokens: this.lexer.inlineTokens(text)
1562
- };
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) };
1563
1084
  }
1564
1085
  }
1565
1086
  }
1566
- codespan(src) {
1567
- const cap = this.rules.inline.code.exec(src);
1568
- if (cap) {
1569
- let text = cap[2].replace(this.rules.other.newLineCharGlobal, " ");
1570
- const hasNonSpaceChars = this.rules.other.nonSpaceChar.test(text);
1571
- const hasSpaceCharsOnBothEnds = this.rules.other.startingSpaceChar.test(text) && this.rules.other.endingSpaceChar.test(text);
1572
- if (hasNonSpaceChars && hasSpaceCharsOnBothEnds) {
1573
- text = text.substring(1, text.length - 1);
1574
- }
1575
- return {
1576
- type: "codespan",
1577
- raw: cap[0],
1578
- text
1579
- };
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 }] };
1580
1092
  }
1581
1093
  }
1582
- br(src) {
1583
- const cap = this.rules.inline.br.exec(src);
1584
- if (cap) {
1585
- return {
1586
- type: "br",
1587
- raw: cap[0]
1588
- };
1589
- }
1590
- }
1591
- del(src) {
1592
- const cap = this.rules.inline.del.exec(src);
1593
- if (cap) {
1594
- return {
1595
- type: "del",
1596
- raw: cap[0],
1597
- text: cap[2],
1598
- tokens: this.lexer.inlineTokens(cap[2])
1599
- };
1600
- }
1601
- }
1602
- autolink(src) {
1603
- const cap = this.rules.inline.autolink.exec(src);
1604
- if (cap) {
1605
- let text, href;
1606
- if (cap[2] === "@") {
1607
- text = cap[1];
1608
- href = "mailto:" + text;
1609
- } else {
1610
- text = cap[1];
1611
- href = text;
1612
- }
1613
- return {
1614
- type: "link",
1615
- raw: cap[0],
1616
- text,
1617
- href,
1618
- tokens: [
1619
- {
1620
- type: "text",
1621
- raw: text,
1622
- text
1623
- }
1624
- ]
1625
- };
1626
- }
1627
- }
1628
- url(src) {
1094
+ url(e) {
1629
1095
  var _a2, _b;
1630
- let cap;
1631
- if (cap = this.rules.inline.url.exec(src)) {
1632
- let text, href;
1633
- if (cap[2] === "@") {
1634
- text = cap[0];
1635
- href = "mailto:" + text;
1636
- } else {
1637
- let prevCapZero;
1638
- do {
1639
- prevCapZero = cap[0];
1640
- cap[0] = (_b = (_a2 = this.rules.inline._backpedal.exec(cap[0])) == null ? void 0 : _a2[0]) != null ? _b : "";
1641
- } while (prevCapZero !== cap[0]);
1642
- text = cap[0];
1643
- if (cap[1] === "www.") {
1644
- href = "http://" + cap[0];
1645
- } else {
1646
- href = cap[0];
1647
- }
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];
1648
1106
  }
1649
- return {
1650
- type: "link",
1651
- raw: cap[0],
1652
- text,
1653
- href,
1654
- tokens: [
1655
- {
1656
- type: "text",
1657
- raw: text,
1658
- text
1659
- }
1660
- ]
1661
- };
1107
+ return { type: "link", raw: t[0], text: n, href: r, tokens: [{ type: "text", raw: n, text: n }] };
1662
1108
  }
1663
1109
  }
1664
- inlineText(src) {
1665
- const cap = this.rules.inline.text.exec(src);
1666
- if (cap) {
1667
- const escaped = this.lexer.state.inRawBlock;
1668
- return {
1669
- type: "text",
1670
- raw: cap[0],
1671
- text: cap[0],
1672
- escaped
1673
- };
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 };
1674
1115
  }
1675
1116
  }
1676
1117
  };
1677
- var _Lexer = class __Lexer {
1678
- constructor(options2) {
1118
+ var x = class u {
1119
+ constructor(e) {
1679
1120
  __publicField(this, "tokens");
1680
1121
  __publicField(this, "options");
1681
1122
  __publicField(this, "state");
1682
- __publicField(this, "tokenizer");
1683
1123
  __publicField(this, "inlineQueue");
1684
- this.tokens = [];
1685
- this.tokens.links = /* @__PURE__ */ Object.create(null);
1686
- this.options = options2 || _defaults;
1687
- this.options.tokenizer = this.options.tokenizer || new _Tokenizer();
1688
- this.tokenizer = this.options.tokenizer;
1689
- this.tokenizer.options = this.options;
1690
- this.tokenizer.lexer = this;
1691
- this.inlineQueue = [];
1692
- this.state = {
1693
- inLink: false,
1694
- inRawBlock: false,
1695
- top: true
1696
- };
1697
- const rules = {
1698
- other,
1699
- block: block.normal,
1700
- inline: inline.normal
1701
- };
1702
- if (this.options.pedantic) {
1703
- rules.block = block.pedantic;
1704
- rules.inline = inline.pedantic;
1705
- } else if (this.options.gfm) {
1706
- rules.block = block.gfm;
1707
- if (this.options.breaks) {
1708
- rules.inline = inline.breaks;
1709
- } else {
1710
- rules.inline = inline.gfm;
1711
- }
1712
- }
1713
- 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;
1714
1128
  }
1715
- /**
1716
- * Expose Rules
1717
- */
1718
1129
  static get rules() {
1719
- return {
1720
- block,
1721
- inline
1722
- };
1130
+ return { block: C, inline: z };
1723
1131
  }
1724
- /**
1725
- * Static Lex Method
1726
- */
1727
- static lex(src, options2) {
1728
- const lexer2 = new __Lexer(options2);
1729
- return lexer2.lex(src);
1132
+ static lex(e, t) {
1133
+ return new u(t).lex(e);
1730
1134
  }
1731
- /**
1732
- * Static Lex Inline Method
1733
- */
1734
- static lexInline(src, options2) {
1735
- const lexer2 = new __Lexer(options2);
1736
- return lexer2.inlineTokens(src);
1135
+ static lexInline(e, t) {
1136
+ return new u(t).inlineTokens(e);
1737
1137
  }
1738
- /**
1739
- * Preprocessing
1740
- */
1741
- lex(src) {
1742
- src = src.replace(other.carriageReturn, "\n");
1743
- this.blockTokens(src, this.tokens);
1744
- for (let i = 0; i < this.inlineQueue.length; i++) {
1745
- const next = this.inlineQueue[i];
1746
- 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);
1747
1144
  }
1748
- this.inlineQueue = [];
1749
- return this.tokens;
1145
+ return this.inlineQueue = [], this.tokens;
1750
1146
  }
1751
- blockTokens(src, tokens = [], lastParagraphClipped = false) {
1147
+ blockTokens(e, t = [], n = false) {
1752
1148
  var _a2, _b, _c;
1753
- if (this.options.pedantic) {
1754
- src = src.replace(other.tabCharGlobal, " ").replace(other.spaceLine, "");
1755
- }
1756
- while (src) {
1757
- let token;
1758
- if ((_b = (_a2 = this.options.extensions) == null ? void 0 : _a2.block) == null ? void 0 : _b.some((extTokenizer) => {
1759
- if (token = extTokenizer.call({ lexer: this }, src, tokens)) {
1760
- src = src.substring(token.raw.length);
1761
- tokens.push(token);
1762
- return true;
1763
- }
1764
- return false;
1765
- })) {
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);
1766
1157
  continue;
1767
1158
  }
1768
- if (token = this.tokenizer.space(src)) {
1769
- src = src.substring(token.raw.length);
1770
- const lastToken = tokens.at(-1);
1771
- if (token.raw.length === 1 && lastToken !== void 0) {
1772
- lastToken.raw += "\n";
1773
- } else {
1774
- tokens.push(token);
1775
- }
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);
1776
1166
  continue;
1777
1167
  }
1778
- if (token = this.tokenizer.code(src)) {
1779
- src = src.substring(token.raw.length);
1780
- const lastToken = tokens.at(-1);
1781
- if ((lastToken == null ? void 0 : lastToken.type) === "paragraph" || (lastToken == null ? void 0 : lastToken.type) === "text") {
1782
- lastToken.raw += "\n" + token.raw;
1783
- lastToken.text += "\n" + token.text;
1784
- this.inlineQueue.at(-1).src = lastToken.text;
1785
- } else {
1786
- tokens.push(token);
1787
- }
1168
+ if (r = this.tokenizer.fences(e)) {
1169
+ e = e.substring(r.raw.length), t.push(r);
1788
1170
  continue;
1789
1171
  }
1790
- if (token = this.tokenizer.fences(src)) {
1791
- src = src.substring(token.raw.length);
1792
- tokens.push(token);
1172
+ if (r = this.tokenizer.heading(e)) {
1173
+ e = e.substring(r.raw.length), t.push(r);
1793
1174
  continue;
1794
1175
  }
1795
- if (token = this.tokenizer.heading(src)) {
1796
- src = src.substring(token.raw.length);
1797
- tokens.push(token);
1176
+ if (r = this.tokenizer.hr(e)) {
1177
+ e = e.substring(r.raw.length), t.push(r);
1798
1178
  continue;
1799
1179
  }
1800
- if (token = this.tokenizer.hr(src)) {
1801
- src = src.substring(token.raw.length);
1802
- tokens.push(token);
1180
+ if (r = this.tokenizer.blockquote(e)) {
1181
+ e = e.substring(r.raw.length), t.push(r);
1803
1182
  continue;
1804
1183
  }
1805
- if (token = this.tokenizer.blockquote(src)) {
1806
- src = src.substring(token.raw.length);
1807
- tokens.push(token);
1184
+ if (r = this.tokenizer.list(e)) {
1185
+ e = e.substring(r.raw.length), t.push(r);
1808
1186
  continue;
1809
1187
  }
1810
- if (token = this.tokenizer.list(src)) {
1811
- src = src.substring(token.raw.length);
1812
- tokens.push(token);
1188
+ if (r = this.tokenizer.html(e)) {
1189
+ e = e.substring(r.raw.length), t.push(r);
1813
1190
  continue;
1814
1191
  }
1815
- if (token = this.tokenizer.html(src)) {
1816
- src = src.substring(token.raw.length);
1817
- tokens.push(token);
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));
1818
1199
  continue;
1819
1200
  }
1820
- if (token = this.tokenizer.def(src)) {
1821
- src = src.substring(token.raw.length);
1822
- const lastToken = tokens.at(-1);
1823
- if ((lastToken == null ? void 0 : lastToken.type) === "paragraph" || (lastToken == null ? void 0 : lastToken.type) === "text") {
1824
- lastToken.raw += "\n" + token.raw;
1825
- lastToken.text += "\n" + token.raw;
1826
- this.inlineQueue.at(-1).src = lastToken.text;
1827
- } else if (!this.tokens.links[token.tag]) {
1828
- this.tokens.links[token.tag] = {
1829
- href: token.href,
1830
- title: token.title
1831
- };
1832
- }
1201
+ if (r = this.tokenizer.table(e)) {
1202
+ e = e.substring(r.raw.length), t.push(r);
1833
1203
  continue;
1834
1204
  }
1835
- if (token = this.tokenizer.table(src)) {
1836
- src = src.substring(token.raw.length);
1837
- tokens.push(token);
1205
+ if (r = this.tokenizer.lheading(e)) {
1206
+ e = e.substring(r.raw.length), t.push(r);
1838
1207
  continue;
1839
1208
  }
1840
- if (token = this.tokenizer.lheading(src)) {
1841
- src = src.substring(token.raw.length);
1842
- tokens.push(token);
1843
- continue;
1844
- }
1845
- let cutSrc = src;
1209
+ let i = e;
1846
1210
  if ((_c = this.options.extensions) == null ? void 0 : _c.startBlock) {
1847
- let startIndex = Infinity;
1848
- const tempSrc = src.slice(1);
1849
- let tempStart;
1850
- this.options.extensions.startBlock.forEach((getStartIndex) => {
1851
- tempStart = getStartIndex.call({ lexer: this }, tempSrc);
1852
- if (typeof tempStart === "number" && tempStart >= 0) {
1853
- startIndex = Math.min(startIndex, tempStart);
1854
- }
1855
- });
1856
- if (startIndex < Infinity && startIndex >= 0) {
1857
- cutSrc = src.substring(0, startIndex + 1);
1858
- }
1859
- }
1860
- if (this.state.top && (token = this.tokenizer.paragraph(cutSrc))) {
1861
- const lastToken = tokens.at(-1);
1862
- if (lastParagraphClipped && (lastToken == null ? void 0 : lastToken.type) === "paragraph") {
1863
- lastToken.raw += "\n" + token.raw;
1864
- lastToken.text += "\n" + token.text;
1865
- this.inlineQueue.pop();
1866
- this.inlineQueue.at(-1).src = lastToken.text;
1867
- } else {
1868
- tokens.push(token);
1869
- }
1870
- lastParagraphClipped = cutSrc.length !== src.length;
1871
- 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);
1872
1222
  continue;
1873
1223
  }
1874
- if (token = this.tokenizer.text(src)) {
1875
- src = src.substring(token.raw.length);
1876
- const lastToken = tokens.at(-1);
1877
- if ((lastToken == null ? void 0 : lastToken.type) === "text") {
1878
- lastToken.raw += "\n" + token.raw;
1879
- lastToken.text += "\n" + token.text;
1880
- this.inlineQueue.pop();
1881
- this.inlineQueue.at(-1).src = lastToken.text;
1882
- } else {
1883
- tokens.push(token);
1884
- }
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);
1885
1231
  continue;
1886
1232
  }
1887
- if (src) {
1888
- const errMsg = "Infinite loop on byte: " + src.charCodeAt(0);
1233
+ if (e) {
1234
+ let s = "Infinite loop on byte: " + e.charCodeAt(0);
1889
1235
  if (this.options.silent) {
1890
- console.error(errMsg);
1236
+ console.error(s);
1891
1237
  break;
1892
- } else {
1893
- throw new Error(errMsg);
1894
- }
1238
+ } else throw new Error(s);
1895
1239
  }
1896
1240
  }
1897
- this.state.top = true;
1898
- return tokens;
1241
+ return this.state.top = true, t;
1899
1242
  }
1900
- inline(src, tokens = []) {
1901
- this.inlineQueue.push({ src, tokens });
1902
- return tokens;
1243
+ inline(e, t = []) {
1244
+ return this.inlineQueue.push({ src: e, tokens: t }), t;
1903
1245
  }
1904
- /**
1905
- * Lexing/Compiling
1906
- */
1907
- inlineTokens(src, tokens = []) {
1908
- var _a2, _b, _c;
1909
- let maskedSrc = src;
1910
- let match = null;
1246
+ inlineTokens(e, t = []) {
1247
+ var _a2, _b, _c, _d, _e2, _f;
1248
+ let n = e, r = null;
1911
1249
  if (this.tokens.links) {
1912
- const links = Object.keys(this.tokens.links);
1913
- if (links.length > 0) {
1914
- while ((match = this.tokenizer.rules.inline.reflinkSearch.exec(maskedSrc)) != null) {
1915
- if (links.includes(match[0].slice(match[0].lastIndexOf("[") + 1, -1))) {
1916
- maskedSrc = maskedSrc.slice(0, match.index) + "[" + "a".repeat(match[0].length - 2) + "]" + maskedSrc.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex);
1917
- }
1918
- }
1919
- }
1920
- }
1921
- while ((match = this.tokenizer.rules.inline.anyPunctuation.exec(maskedSrc)) != null) {
1922
- maskedSrc = maskedSrc.slice(0, match.index) + "++" + maskedSrc.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);
1923
- }
1924
- while ((match = this.tokenizer.rules.inline.blockSkip.exec(maskedSrc)) != null) {
1925
- maskedSrc = maskedSrc.slice(0, match.index) + "[" + "a".repeat(match[0].length - 2) + "]" + maskedSrc.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);
1926
- }
1927
- let keepPrevChar = false;
1928
- let prevChar = "";
1929
- while (src) {
1930
- if (!keepPrevChar) {
1931
- prevChar = "";
1932
- }
1933
- keepPrevChar = false;
1934
- let token;
1935
- if ((_b = (_a2 = this.options.extensions) == null ? void 0 : _a2.inline) == null ? void 0 : _b.some((extTokenizer) => {
1936
- if (token = extTokenizer.call({ lexer: this }, src, tokens)) {
1937
- src = src.substring(token.raw.length);
1938
- tokens.push(token);
1939
- return true;
1940
- }
1941
- return false;
1942
- })) {
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);
1943
1264
  continue;
1944
1265
  }
1945
- if (token = this.tokenizer.escape(src)) {
1946
- src = src.substring(token.raw.length);
1947
- tokens.push(token);
1266
+ if (o = this.tokenizer.tag(e)) {
1267
+ e = e.substring(o.raw.length), t.push(o);
1948
1268
  continue;
1949
1269
  }
1950
- if (token = this.tokenizer.tag(src)) {
1951
- src = src.substring(token.raw.length);
1952
- tokens.push(token);
1270
+ if (o = this.tokenizer.link(e)) {
1271
+ e = e.substring(o.raw.length), t.push(o);
1953
1272
  continue;
1954
1273
  }
1955
- if (token = this.tokenizer.link(src)) {
1956
- src = src.substring(token.raw.length);
1957
- tokens.push(token);
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);
1958
1278
  continue;
1959
1279
  }
1960
- if (token = this.tokenizer.reflink(src, this.tokens.links)) {
1961
- src = src.substring(token.raw.length);
1962
- const lastToken = tokens.at(-1);
1963
- if (token.type === "text" && (lastToken == null ? void 0 : lastToken.type) === "text") {
1964
- lastToken.raw += token.raw;
1965
- lastToken.text += token.text;
1966
- } else {
1967
- tokens.push(token);
1968
- }
1969
- continue;
1970
- }
1971
- if (token = this.tokenizer.emStrong(src, maskedSrc, prevChar)) {
1972
- src = src.substring(token.raw.length);
1973
- tokens.push(token);
1280
+ if (o = this.tokenizer.emStrong(e, n, a)) {
1281
+ e = e.substring(o.raw.length), t.push(o);
1974
1282
  continue;
1975
1283
  }
1976
- if (token = this.tokenizer.codespan(src)) {
1977
- src = src.substring(token.raw.length);
1978
- tokens.push(token);
1284
+ if (o = this.tokenizer.codespan(e)) {
1285
+ e = e.substring(o.raw.length), t.push(o);
1979
1286
  continue;
1980
1287
  }
1981
- if (token = this.tokenizer.br(src)) {
1982
- src = src.substring(token.raw.length);
1983
- tokens.push(token);
1288
+ if (o = this.tokenizer.br(e)) {
1289
+ e = e.substring(o.raw.length), t.push(o);
1984
1290
  continue;
1985
1291
  }
1986
- if (token = this.tokenizer.del(src)) {
1987
- src = src.substring(token.raw.length);
1988
- tokens.push(token);
1292
+ if (o = this.tokenizer.del(e, n, a)) {
1293
+ e = e.substring(o.raw.length), t.push(o);
1989
1294
  continue;
1990
1295
  }
1991
- if (token = this.tokenizer.autolink(src)) {
1992
- src = src.substring(token.raw.length);
1993
- tokens.push(token);
1296
+ if (o = this.tokenizer.autolink(e)) {
1297
+ e = e.substring(o.raw.length), t.push(o);
1994
1298
  continue;
1995
1299
  }
1996
- if (!this.state.inLink && (token = this.tokenizer.url(src))) {
1997
- src = src.substring(token.raw.length);
1998
- tokens.push(token);
1300
+ if (!this.state.inLink && (o = this.tokenizer.url(e))) {
1301
+ e = e.substring(o.raw.length), t.push(o);
1999
1302
  continue;
2000
1303
  }
2001
- let cutSrc = src;
2002
- if ((_c = this.options.extensions) == null ? void 0 : _c.startInline) {
2003
- let startIndex = Infinity;
2004
- const tempSrc = src.slice(1);
2005
- let tempStart;
2006
- this.options.extensions.startInline.forEach((getStartIndex) => {
2007
- tempStart = getStartIndex.call({ lexer: this }, tempSrc);
2008
- if (typeof tempStart === "number" && tempStart >= 0) {
2009
- startIndex = Math.min(startIndex, tempStart);
2010
- }
2011
- });
2012
- if (startIndex < Infinity && startIndex >= 0) {
2013
- cutSrc = src.substring(0, startIndex + 1);
2014
- }
2015
- }
2016
- if (token = this.tokenizer.inlineText(cutSrc)) {
2017
- src = src.substring(token.raw.length);
2018
- if (token.raw.slice(-1) !== "_") {
2019
- prevChar = token.raw.slice(-1);
2020
- }
2021
- keepPrevChar = true;
2022
- const lastToken = tokens.at(-1);
2023
- if ((lastToken == null ? void 0 : lastToken.type) === "text") {
2024
- lastToken.raw += token.raw;
2025
- lastToken.text += token.text;
2026
- } else {
2027
- tokens.push(token);
2028
- }
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);
2029
1315
  continue;
2030
1316
  }
2031
- if (src) {
2032
- const errMsg = "Infinite loop on byte: " + src.charCodeAt(0);
1317
+ if (e) {
1318
+ let p = "Infinite loop on byte: " + e.charCodeAt(0);
2033
1319
  if (this.options.silent) {
2034
- console.error(errMsg);
1320
+ console.error(p);
2035
1321
  break;
2036
- } else {
2037
- throw new Error(errMsg);
2038
- }
1322
+ } else throw new Error(p);
2039
1323
  }
2040
1324
  }
2041
- return tokens;
1325
+ return t;
2042
1326
  }
2043
1327
  };
2044
- var _Renderer = class {
2045
- // set by the parser
2046
- constructor(options2) {
1328
+ var y = class {
1329
+ constructor(e) {
2047
1330
  __publicField(this, "options");
2048
1331
  __publicField(this, "parser");
2049
- this.options = options2 || _defaults;
1332
+ this.options = e || T;
2050
1333
  }
2051
- space(token) {
1334
+ space(e) {
2052
1335
  return "";
2053
1336
  }
2054
- code({ text, lang, escaped }) {
1337
+ code({ text: e, lang: t, escaped: n }) {
2055
1338
  var _a2;
2056
- const langString = (_a2 = (lang || "").match(other.notSpaceStart)) == null ? void 0 : _a2[0];
2057
- const code = text.replace(other.endingNewline, "") + "\n";
2058
- if (!langString) {
2059
- return "<pre><code>" + (escaped ? code : escape2(code, true)) + "</code></pre>\n";
2060
- }
2061
- 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
+ `;
2062
1344
  }
2063
- blockquote({ tokens }) {
2064
- const body = this.parser.parse(tokens);
1345
+ blockquote({ tokens: e }) {
2065
1346
  return `<blockquote>
2066
- ${body}</blockquote>
1347
+ ${this.parser.parse(e)}</blockquote>
2067
1348
  `;
2068
1349
  }
2069
- html({ text }) {
2070
- return text;
1350
+ html({ text: e }) {
1351
+ return e;
2071
1352
  }
2072
- heading({ tokens, depth }) {
2073
- return `<h${depth}>${this.parser.parseInline(tokens)}</h${depth}>
1353
+ def(e) {
1354
+ return "";
1355
+ }
1356
+ heading({ tokens: e, depth: t }) {
1357
+ return `<h${t}>${this.parser.parseInline(e)}</h${t}>
2074
1358
  `;
2075
1359
  }
2076
- hr(token) {
2077
- return "<hr>\n";
1360
+ hr(e) {
1361
+ return `<hr>
1362
+ `;
2078
1363
  }
2079
- list(token) {
2080
- const ordered = token.ordered;
2081
- const start = token.start;
2082
- let body = "";
2083
- for (let j = 0; j < token.items.length; j++) {
2084
- const item = token.items[j];
2085
- 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);
2086
1369
  }
2087
- const type = ordered ? "ol" : "ul";
2088
- const startAttr = ordered && start !== 1 ? ' start="' + start + '"' : "";
2089
- 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
+ `;
2090
1374
  }
2091
- listitem(item) {
2092
- var _a2;
2093
- let itemBody = "";
2094
- if (item.task) {
2095
- const checkbox = this.checkbox({ checked: !!item.checked });
2096
- if (item.loose) {
2097
- if (((_a2 = item.tokens[0]) == null ? void 0 : _a2.type) === "paragraph") {
2098
- item.tokens[0].text = checkbox + " " + item.tokens[0].text;
2099
- if (item.tokens[0].tokens && item.tokens[0].tokens.length > 0 && item.tokens[0].tokens[0].type === "text") {
2100
- item.tokens[0].tokens[0].text = checkbox + " " + escape2(item.tokens[0].tokens[0].text);
2101
- item.tokens[0].tokens[0].escaped = true;
2102
- }
2103
- } else {
2104
- item.tokens.unshift({
2105
- type: "text",
2106
- raw: checkbox + " ",
2107
- text: checkbox + " ",
2108
- escaped: true
2109
- });
2110
- }
2111
- } else {
2112
- itemBody += checkbox + " ";
2113
- }
2114
- }
2115
- itemBody += this.parser.parse(item.tokens, !!item.loose);
2116
- return `<li>${itemBody}</li>
1375
+ listitem(e) {
1376
+ return `<li>${this.parser.parse(e.tokens)}</li>
2117
1377
  `;
2118
1378
  }
2119
- checkbox({ checked }) {
2120
- return "<input " + (checked ? 'checked="" ' : "") + 'disabled="" type="checkbox">';
1379
+ checkbox({ checked: e }) {
1380
+ return "<input " + (e ? 'checked="" ' : "") + 'disabled="" type="checkbox"> ';
2121
1381
  }
2122
- paragraph({ tokens }) {
2123
- return `<p>${this.parser.parseInline(tokens)}</p>
1382
+ paragraph({ tokens: e }) {
1383
+ return `<p>${this.parser.parseInline(e)}</p>
2124
1384
  `;
2125
1385
  }
2126
- table(token) {
2127
- let header = "";
2128
- let cell = "";
2129
- for (let j = 0; j < token.header.length; j++) {
2130
- cell += this.tablecell(token.header[j]);
2131
- }
2132
- header += this.tablerow({ text: cell });
2133
- let body = "";
2134
- for (let j = 0; j < token.rows.length; j++) {
2135
- const row = token.rows[j];
2136
- cell = "";
2137
- for (let k = 0; k < row.length; k++) {
2138
- cell += this.tablecell(row[k]);
2139
- }
2140
- body += this.tablerow({ text: cell });
2141
- }
2142
- if (body) body = `<tbody>${body}</tbody>`;
2143
- 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
+ `;
2144
1402
  }
2145
- tablerow({ text }) {
1403
+ tablerow({ text: e }) {
2146
1404
  return `<tr>
2147
- ${text}</tr>
1405
+ ${e}</tr>
2148
1406
  `;
2149
1407
  }
2150
- tablecell(token) {
2151
- const content = this.parser.parseInline(token.tokens);
2152
- const type = token.header ? "th" : "td";
2153
- const tag2 = token.align ? `<${type} align="${token.align}">` : `<${type}>`;
2154
- 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}>
2155
1411
  `;
2156
1412
  }
2157
- /**
2158
- * span level renderer
2159
- */
2160
- strong({ tokens }) {
2161
- return `<strong>${this.parser.parseInline(tokens)}</strong>`;
1413
+ strong({ tokens: e }) {
1414
+ return `<strong>${this.parser.parseInline(e)}</strong>`;
2162
1415
  }
2163
- em({ tokens }) {
2164
- return `<em>${this.parser.parseInline(tokens)}</em>`;
1416
+ em({ tokens: e }) {
1417
+ return `<em>${this.parser.parseInline(e)}</em>`;
2165
1418
  }
2166
- codespan({ text }) {
2167
- return `<code>${escape2(text, true)}</code>`;
1419
+ codespan({ text: e }) {
1420
+ return `<code>${O(e, true)}</code>`;
2168
1421
  }
2169
- br(token) {
1422
+ br(e) {
2170
1423
  return "<br>";
2171
1424
  }
2172
- del({ tokens }) {
2173
- return `<del>${this.parser.parseInline(tokens)}</del>`;
1425
+ del({ tokens: e }) {
1426
+ return `<del>${this.parser.parseInline(e)}</del>`;
2174
1427
  }
2175
- link({ href, title, tokens }) {
2176
- const text = this.parser.parseInline(tokens);
2177
- const cleanHref = cleanUrl(href);
2178
- if (cleanHref === null) {
2179
- return text;
2180
- }
2181
- href = cleanHref;
2182
- let out = '<a href="' + href + '"';
2183
- if (title) {
2184
- out += ' title="' + escape2(title) + '"';
2185
- }
2186
- out += ">" + text + "</a>";
2187
- 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;
2188
1434
  }
2189
- image({ href, title, text, tokens }) {
2190
- if (tokens) {
2191
- text = this.parser.parseInline(tokens, this.parser.textRenderer);
2192
- }
2193
- const cleanHref = cleanUrl(href);
2194
- if (cleanHref === null) {
2195
- return escape2(text);
2196
- }
2197
- href = cleanHref;
2198
- let out = `<img src="${href}" alt="${text}"`;
2199
- if (title) {
2200
- out += ` title="${escape2(title)}"`;
2201
- }
2202
- out += ">";
2203
- 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;
2204
1442
  }
2205
- text(token) {
2206
- 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);
2207
1445
  }
2208
1446
  };
2209
- var _TextRenderer = class {
2210
- // no need for block level renderers
2211
- strong({ text }) {
2212
- return text;
1447
+ var $ = class {
1448
+ strong({ text: e }) {
1449
+ return e;
2213
1450
  }
2214
- em({ text }) {
2215
- return text;
1451
+ em({ text: e }) {
1452
+ return e;
2216
1453
  }
2217
- codespan({ text }) {
2218
- return text;
1454
+ codespan({ text: e }) {
1455
+ return e;
2219
1456
  }
2220
- del({ text }) {
2221
- return text;
1457
+ del({ text: e }) {
1458
+ return e;
2222
1459
  }
2223
- html({ text }) {
2224
- return text;
1460
+ html({ text: e }) {
1461
+ return e;
2225
1462
  }
2226
- text({ text }) {
2227
- return text;
1463
+ text({ text: e }) {
1464
+ return e;
2228
1465
  }
2229
- link({ text }) {
2230
- return "" + text;
1466
+ link({ text: e }) {
1467
+ return "" + e;
2231
1468
  }
2232
- image({ text }) {
2233
- return "" + text;
1469
+ image({ text: e }) {
1470
+ return "" + e;
2234
1471
  }
2235
1472
  br() {
2236
1473
  return "";
2237
1474
  }
1475
+ checkbox({ raw: e }) {
1476
+ return e;
1477
+ }
2238
1478
  };
2239
- var _Parser = class __Parser {
2240
- constructor(options2) {
1479
+ var b = class u2 {
1480
+ constructor(e) {
2241
1481
  __publicField(this, "options");
2242
1482
  __publicField(this, "renderer");
2243
1483
  __publicField(this, "textRenderer");
2244
- this.options = options2 || _defaults;
2245
- this.options.renderer = this.options.renderer || new _Renderer();
2246
- this.renderer = this.options.renderer;
2247
- this.renderer.options = this.options;
2248
- this.renderer.parser = this;
2249
- 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 $();
2250
1485
  }
2251
- /**
2252
- * Static Parse Method
2253
- */
2254
- static parse(tokens, options2) {
2255
- const parser2 = new __Parser(options2);
2256
- return parser2.parse(tokens);
1486
+ static parse(e, t) {
1487
+ return new u2(t).parse(e);
2257
1488
  }
2258
- /**
2259
- * Static Parse Inline Method
2260
- */
2261
- static parseInline(tokens, options2) {
2262
- const parser2 = new __Parser(options2);
2263
- return parser2.parseInline(tokens);
1489
+ static parseInline(e, t) {
1490
+ return new u2(t).parseInline(e);
2264
1491
  }
2265
- /**
2266
- * Parse Loop
2267
- */
2268
- parse(tokens, top = true) {
1492
+ parse(e) {
2269
1493
  var _a2, _b;
2270
- let out = "";
2271
- for (let i = 0; i < tokens.length; i++) {
2272
- const anyToken = tokens[i];
2273
- if ((_b = (_a2 = this.options.extensions) == null ? void 0 : _a2.renderers) == null ? void 0 : _b[anyToken.type]) {
2274
- const genericToken = anyToken;
2275
- const ret = this.options.extensions.renderers[genericToken.type].call({ parser: this }, genericToken);
2276
- if (ret !== false || !["space", "hr", "heading", "code", "table", "blockquote", "list", "html", "paragraph", "text"].includes(genericToken.type)) {
2277
- 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 || "";
2278
1501
  continue;
2279
1502
  }
2280
1503
  }
2281
- const token = anyToken;
2282
- switch (token.type) {
1504
+ let i = r;
1505
+ switch (i.type) {
2283
1506
  case "space": {
2284
- out += this.renderer.space(token);
2285
- continue;
1507
+ t += this.renderer.space(i);
1508
+ break;
2286
1509
  }
2287
1510
  case "hr": {
2288
- out += this.renderer.hr(token);
2289
- continue;
1511
+ t += this.renderer.hr(i);
1512
+ break;
2290
1513
  }
2291
1514
  case "heading": {
2292
- out += this.renderer.heading(token);
2293
- continue;
1515
+ t += this.renderer.heading(i);
1516
+ break;
2294
1517
  }
2295
1518
  case "code": {
2296
- out += this.renderer.code(token);
2297
- continue;
1519
+ t += this.renderer.code(i);
1520
+ break;
2298
1521
  }
2299
1522
  case "table": {
2300
- out += this.renderer.table(token);
2301
- continue;
1523
+ t += this.renderer.table(i);
1524
+ break;
2302
1525
  }
2303
1526
  case "blockquote": {
2304
- out += this.renderer.blockquote(token);
2305
- continue;
1527
+ t += this.renderer.blockquote(i);
1528
+ break;
2306
1529
  }
2307
1530
  case "list": {
2308
- out += this.renderer.list(token);
2309
- continue;
1531
+ t += this.renderer.list(i);
1532
+ break;
1533
+ }
1534
+ case "checkbox": {
1535
+ t += this.renderer.checkbox(i);
1536
+ break;
2310
1537
  }
2311
1538
  case "html": {
2312
- out += this.renderer.html(token);
2313
- continue;
1539
+ t += this.renderer.html(i);
1540
+ break;
1541
+ }
1542
+ case "def": {
1543
+ t += this.renderer.def(i);
1544
+ break;
2314
1545
  }
2315
1546
  case "paragraph": {
2316
- out += this.renderer.paragraph(token);
2317
- continue;
1547
+ t += this.renderer.paragraph(i);
1548
+ break;
2318
1549
  }
2319
1550
  case "text": {
2320
- let textToken = token;
2321
- let body = this.renderer.text(textToken);
2322
- while (i + 1 < tokens.length && tokens[i + 1].type === "text") {
2323
- textToken = tokens[++i];
2324
- body += "\n" + this.renderer.text(textToken);
2325
- }
2326
- if (top) {
2327
- out += this.renderer.paragraph({
2328
- type: "paragraph",
2329
- raw: body,
2330
- text: body,
2331
- tokens: [{ type: "text", raw: body, text: body, escaped: true }]
2332
- });
2333
- } else {
2334
- out += body;
2335
- }
2336
- continue;
1551
+ t += this.renderer.text(i);
1552
+ break;
2337
1553
  }
2338
1554
  default: {
2339
- const errMsg = 'Token with "' + token.type + '" type was not found.';
2340
- if (this.options.silent) {
2341
- console.error(errMsg);
2342
- return "";
2343
- } else {
2344
- throw new Error(errMsg);
2345
- }
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);
2346
1558
  }
2347
1559
  }
2348
1560
  }
2349
- return out;
1561
+ return t;
2350
1562
  }
2351
- /**
2352
- * Parse Inline Tokens
2353
- */
2354
- parseInline(tokens, renderer = this.renderer) {
1563
+ parseInline(e, t = this.renderer) {
2355
1564
  var _a2, _b;
2356
- let out = "";
2357
- for (let i = 0; i < tokens.length; i++) {
2358
- const anyToken = tokens[i];
2359
- if ((_b = (_a2 = this.options.extensions) == null ? void 0 : _a2.renderers) == null ? void 0 : _b[anyToken.type]) {
2360
- const ret = this.options.extensions.renderers[anyToken.type].call({ parser: this }, anyToken);
2361
- if (ret !== false || !["escape", "html", "link", "image", "strong", "em", "codespan", "br", "del", "text"].includes(anyToken.type)) {
2362
- 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 || "";
2363
1572
  continue;
2364
1573
  }
2365
1574
  }
2366
- const token = anyToken;
2367
- switch (token.type) {
1575
+ let s = i;
1576
+ switch (s.type) {
2368
1577
  case "escape": {
2369
- out += renderer.text(token);
1578
+ n += t.text(s);
2370
1579
  break;
2371
1580
  }
2372
1581
  case "html": {
2373
- out += renderer.html(token);
1582
+ n += t.html(s);
2374
1583
  break;
2375
1584
  }
2376
1585
  case "link": {
2377
- out += renderer.link(token);
1586
+ n += t.link(s);
2378
1587
  break;
2379
1588
  }
2380
1589
  case "image": {
2381
- out += renderer.image(token);
1590
+ n += t.image(s);
1591
+ break;
1592
+ }
1593
+ case "checkbox": {
1594
+ n += t.checkbox(s);
2382
1595
  break;
2383
1596
  }
2384
1597
  case "strong": {
2385
- out += renderer.strong(token);
1598
+ n += t.strong(s);
2386
1599
  break;
2387
1600
  }
2388
1601
  case "em": {
2389
- out += renderer.em(token);
1602
+ n += t.em(s);
2390
1603
  break;
2391
1604
  }
2392
1605
  case "codespan": {
2393
- out += renderer.codespan(token);
1606
+ n += t.codespan(s);
2394
1607
  break;
2395
1608
  }
2396
1609
  case "br": {
2397
- out += renderer.br(token);
1610
+ n += t.br(s);
2398
1611
  break;
2399
1612
  }
2400
1613
  case "del": {
2401
- out += renderer.del(token);
1614
+ n += t.del(s);
2402
1615
  break;
2403
1616
  }
2404
1617
  case "text": {
2405
- out += renderer.text(token);
1618
+ n += t.text(s);
2406
1619
  break;
2407
1620
  }
2408
1621
  default: {
2409
- const errMsg = 'Token with "' + token.type + '" type was not found.';
2410
- if (this.options.silent) {
2411
- console.error(errMsg);
2412
- return "";
2413
- } else {
2414
- throw new Error(errMsg);
2415
- }
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);
2416
1625
  }
2417
1626
  }
2418
1627
  }
2419
- return out;
1628
+ return n;
2420
1629
  }
2421
1630
  };
2422
1631
  var _a;
2423
- var _Hooks = (_a = class {
2424
- constructor(options2) {
1632
+ var P = (_a = class {
1633
+ constructor(e) {
2425
1634
  __publicField(this, "options");
2426
1635
  __publicField(this, "block");
2427
- this.options = options2 || _defaults;
1636
+ this.options = e || T;
2428
1637
  }
2429
- /**
2430
- * Process markdown before marked
2431
- */
2432
- preprocess(markdown) {
2433
- return markdown;
1638
+ preprocess(e) {
1639
+ return e;
2434
1640
  }
2435
- /**
2436
- * Process HTML after marked is finished
2437
- */
2438
- postprocess(html2) {
2439
- return html2;
1641
+ postprocess(e) {
1642
+ return e;
2440
1643
  }
2441
- /**
2442
- * Process all tokens before walk tokens
2443
- */
2444
- processAllTokens(tokens) {
2445
- return tokens;
1644
+ processAllTokens(e) {
1645
+ return e;
1646
+ }
1647
+ emStrongMask(e) {
1648
+ return e;
2446
1649
  }
2447
- /**
2448
- * Provide function to tokenize markdown
2449
- */
2450
1650
  provideLexer() {
2451
- return this.block ? _Lexer.lex : _Lexer.lexInline;
1651
+ return this.block ? x.lex : x.lexInline;
2452
1652
  }
2453
- /**
2454
- * Provide function to parse tokens
2455
- */
2456
1653
  provideParser() {
2457
- return this.block ? _Parser.parse : _Parser.parseInline;
2458
- }
2459
- }, __publicField(_a, "passThroughHooks", /* @__PURE__ */ new Set([
2460
- "preprocess",
2461
- "postprocess",
2462
- "processAllTokens"
2463
- ])), _a);
2464
- var Marked = class {
2465
- constructor(...args) {
2466
- __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());
2467
1660
  __publicField(this, "options", this.setOptions);
2468
1661
  __publicField(this, "parse", this.parseMarkdown(true));
2469
1662
  __publicField(this, "parseInline", this.parseMarkdown(false));
2470
- __publicField(this, "Parser", _Parser);
2471
- __publicField(this, "Renderer", _Renderer);
2472
- __publicField(this, "TextRenderer", _TextRenderer);
2473
- __publicField(this, "Lexer", _Lexer);
2474
- __publicField(this, "Tokenizer", _Tokenizer);
2475
- __publicField(this, "Hooks", _Hooks);
2476
- this.use(...args);
2477
- }
2478
- /**
2479
- * Run callback for every token
2480
- */
2481
- 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) {
2482
1672
  var _a2, _b;
2483
- let values = [];
2484
- for (const token of tokens) {
2485
- values = values.concat(callback.call(this, token));
2486
- switch (token.type) {
2487
- case "table": {
2488
- const tableToken = token;
2489
- for (const cell of tableToken.header) {
2490
- values = values.concat(this.walkTokens(cell.tokens, callback));
2491
- }
2492
- for (const row of tableToken.rows) {
2493
- for (const cell of row) {
2494
- values = values.concat(this.walkTokens(cell.tokens, callback));
2495
- }
2496
- }
2497
- break;
2498
- }
2499
- case "list": {
2500
- const listToken = token;
2501
- values = values.concat(this.walkTokens(listToken.items, callback));
2502
- break;
2503
- }
2504
- default: {
2505
- const genericToken = token;
2506
- if ((_b = (_a2 = this.defaults.extensions) == null ? void 0 : _a2.childTokens) == null ? void 0 : _b[genericToken.type]) {
2507
- this.defaults.extensions.childTokens[genericToken.type].forEach((childTokens) => {
2508
- const tokens2 = genericToken[childTokens].flat(Infinity);
2509
- values = values.concat(this.walkTokens(tokens2, callback));
2510
- });
2511
- } else if (genericToken.tokens) {
2512
- values = values.concat(this.walkTokens(genericToken.tokens, callback));
2513
- }
2514
- }
2515
- }
2516
- }
2517
- return values;
2518
- }
2519
- use(...args) {
2520
- const extensions = this.defaults.extensions || { renderers: {}, childTokens: {} };
2521
- args.forEach((pack) => {
2522
- const opts = { ...pack };
2523
- opts.async = this.defaults.async || opts.async || false;
2524
- if (pack.extensions) {
2525
- pack.extensions.forEach((ext) => {
2526
- if (!ext.name) {
2527
- throw new Error("extension name required");
2528
- }
2529
- if ("renderer" in ext) {
2530
- const prevRenderer = extensions.renderers[ext.name];
2531
- if (prevRenderer) {
2532
- extensions.renderers[ext.name] = function(...args2) {
2533
- let ret = ext.renderer.apply(this, args2);
2534
- if (ret === false) {
2535
- ret = prevRenderer.apply(this, args2);
2536
- }
2537
- return ret;
2538
- };
2539
- } else {
2540
- extensions.renderers[ext.name] = ext.renderer;
2541
- }
2542
- }
2543
- if ("tokenizer" in ext) {
2544
- if (!ext.level || ext.level !== "block" && ext.level !== "inline") {
2545
- throw new Error("extension level must be 'block' or 'inline'");
2546
- }
2547
- const extLevel = extensions[ext.level];
2548
- if (extLevel) {
2549
- extLevel.unshift(ext.tokenizer);
2550
- } else {
2551
- extensions[ext.level] = [ext.tokenizer];
2552
- }
2553
- if (ext.start) {
2554
- if (ext.level === "block") {
2555
- if (extensions.startBlock) {
2556
- extensions.startBlock.push(ext.start);
2557
- } else {
2558
- extensions.startBlock = [ext.start];
2559
- }
2560
- } else if (ext.level === "inline") {
2561
- if (extensions.startInline) {
2562
- extensions.startInline.push(ext.start);
2563
- } else {
2564
- extensions.startInline = [ext.start];
2565
- }
2566
- }
2567
- }
2568
- }
2569
- if ("childTokens" in ext && ext.childTokens) {
2570
- extensions.childTokens[ext.name] = ext.childTokens;
2571
- }
2572
- });
2573
- opts.extensions = extensions;
2574
- }
2575
- if (pack.renderer) {
2576
- const renderer = this.defaults.renderer || new _Renderer(this.defaults);
2577
- for (const prop in pack.renderer) {
2578
- if (!(prop in renderer)) {
2579
- throw new Error(`renderer '${prop}' does not exist`);
2580
- }
2581
- if (["options", "parser"].includes(prop)) {
2582
- continue;
2583
- }
2584
- const rendererProp = prop;
2585
- const rendererFunc = pack.renderer[rendererProp];
2586
- const prevRenderer = renderer[rendererProp];
2587
- renderer[rendererProp] = (...args2) => {
2588
- let ret = rendererFunc.apply(renderer, args2);
2589
- if (ret === false) {
2590
- ret = prevRenderer.apply(renderer, args2);
2591
- }
2592
- 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 || "";
2593
1724
  };
2594
1725
  }
2595
- opts.renderer = renderer;
2596
- }
2597
- if (pack.tokenizer) {
2598
- const tokenizer = this.defaults.tokenizer || new _Tokenizer(this.defaults);
2599
- for (const prop in pack.tokenizer) {
2600
- if (!(prop in tokenizer)) {
2601
- throw new Error(`tokenizer '${prop}' does not exist`);
2602
- }
2603
- if (["options", "rules", "lexer"].includes(prop)) {
2604
- continue;
2605
- }
2606
- const tokenizerProp = prop;
2607
- const tokenizerFunc = pack.tokenizer[tokenizerProp];
2608
- const prevTokenizer = tokenizer[tokenizerProp];
2609
- tokenizer[tokenizerProp] = (...args2) => {
2610
- let ret = tokenizerFunc.apply(tokenizer, args2);
2611
- if (ret === false) {
2612
- ret = prevTokenizer.apply(tokenizer, args2);
2613
- }
2614
- 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;
2615
1737
  };
2616
1738
  }
2617
- opts.tokenizer = tokenizer;
2618
- }
2619
- if (pack.hooks) {
2620
- const hooks = this.defaults.hooks || new _Hooks();
2621
- for (const prop in pack.hooks) {
2622
- if (!(prop in hooks)) {
2623
- throw new Error(`hook '${prop}' does not exist`);
2624
- }
2625
- if (["options", "block"].includes(prop)) {
2626
- continue;
2627
- }
2628
- const hooksProp = prop;
2629
- const hooksFunc = pack.hooks[hooksProp];
2630
- const prevHook = hooks[hooksProp];
2631
- if (_Hooks.passThroughHooks.has(prop)) {
2632
- hooks[hooksProp] = (arg) => {
2633
- if (this.defaults.async) {
2634
- return Promise.resolve(hooksFunc.call(hooks, arg)).then((ret2) => {
2635
- return prevHook.call(hooks, ret2);
2636
- });
2637
- }
2638
- const ret = hooksFunc.call(hooks, arg);
2639
- return prevHook.call(hooks, ret);
2640
- };
2641
- } else {
2642
- hooks[hooksProp] = (...args2) => {
2643
- let ret = hooksFunc.apply(hooks, args2);
2644
- if (ret === false) {
2645
- ret = prevHook.apply(hooks, args2);
2646
- }
2647
- return ret;
2648
- };
2649
- }
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
+ };
2650
1762
  }
2651
- opts.hooks = hooks;
1763
+ r.hooks = i;
2652
1764
  }
2653
- if (pack.walkTokens) {
2654
- const walkTokens2 = this.defaults.walkTokens;
2655
- const packWalktokens = pack.walkTokens;
2656
- opts.walkTokens = function(token) {
2657
- let values = [];
2658
- values.push(packWalktokens.call(this, token));
2659
- if (walkTokens2) {
2660
- values = values.concat(walkTokens2.call(this, token));
2661
- }
2662
- 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;
2663
1770
  };
2664
1771
  }
2665
- this.defaults = { ...this.defaults, ...opts };
2666
- });
2667
- return this;
2668
- }
2669
- setOptions(opt) {
2670
- this.defaults = { ...this.defaults, ...opt };
2671
- return this;
2672
- }
2673
- lexer(src, options2) {
2674
- return _Lexer.lex(src, options2 != null ? options2 : this.defaults);
2675
- }
2676
- parser(tokens, options2) {
2677
- return _Parser.parse(tokens, options2 != null ? options2 : this.defaults);
2678
- }
2679
- parseMarkdown(blockType) {
2680
- const parse2 = (src, options2) => {
2681
- const origOpt = { ...options2 };
2682
- const opt = { ...this.defaults, ...origOpt };
2683
- const throwError = this.onError(!!opt.silent, !!opt.async);
2684
- if (this.defaults.async === true && origOpt.async === false) {
2685
- 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."));
2686
- }
2687
- if (typeof src === "undefined" || src === null) {
2688
- return throwError(new Error("marked(): input parameter is undefined or null"));
2689
- }
2690
- if (typeof src !== "string") {
2691
- return throwError(new Error("marked(): input parameter is of type " + Object.prototype.toString.call(src) + ", string expected"));
2692
- }
2693
- if (opt.hooks) {
2694
- opt.hooks.options = opt;
2695
- opt.hooks.block = blockType;
2696
- }
2697
- const lexer2 = opt.hooks ? opt.hooks.provideLexer() : blockType ? _Lexer.lex : _Lexer.lexInline;
2698
- const parser2 = opt.hooks ? opt.hooks.provideParser() : blockType ? _Parser.parse : _Parser.parseInline;
2699
- if (opt.async) {
2700
- 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);
2701
- }
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);
2702
1796
  try {
2703
- if (opt.hooks) {
2704
- src = opt.hooks.preprocess(src);
2705
- }
2706
- let tokens = lexer2(src, opt);
2707
- if (opt.hooks) {
2708
- tokens = opt.hooks.processAllTokens(tokens);
2709
- }
2710
- if (opt.walkTokens) {
2711
- this.walkTokens(tokens, opt.walkTokens);
2712
- }
2713
- let html2 = parser2(tokens, opt);
2714
- if (opt.hooks) {
2715
- html2 = opt.hooks.postprocess(html2);
2716
- }
2717
- return html2;
2718
- } catch (e) {
2719
- 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);
2720
1804
  }
2721
1805
  };
2722
- return parse2;
2723
- }
2724
- onError(silent, async) {
2725
- return (e) => {
2726
- e.message += "\nPlease report this to https://github.com/markedjs/marked.";
2727
- if (silent) {
2728
- const msg = "<p>An error occurred:</p><pre>" + escape2(e.message + "", true) + "</pre>";
2729
- if (async) {
2730
- return Promise.resolve(msg);
2731
- }
2732
- return msg;
2733
- }
2734
- if (async) {
2735
- 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;
2736
1813
  }
2737
- throw e;
1814
+ if (t) return Promise.reject(n);
1815
+ throw n;
2738
1816
  };
2739
1817
  }
2740
1818
  };
2741
- var markedInstance = new Marked();
2742
- function marked(src, opt) {
2743
- return markedInstance.parse(src, opt);
1819
+ var L = new B();
1820
+ function g(u3, e) {
1821
+ return L.parse(u3, e);
2744
1822
  }
2745
- marked.options = marked.setOptions = function(options2) {
2746
- markedInstance.setOptions(options2);
2747
- marked.defaults = markedInstance.defaults;
2748
- changeDefaults(marked.defaults);
2749
- return marked;
1823
+ g.options = g.setOptions = function(u3) {
1824
+ return L.setOptions(u3), g.defaults = L.defaults, G(g.defaults), g;
2750
1825
  };
2751
- marked.getDefaults = _getDefaults;
2752
- marked.defaults = _defaults;
2753
- marked.use = function(...args) {
2754
- markedInstance.use(...args);
2755
- marked.defaults = markedInstance.defaults;
2756
- changeDefaults(marked.defaults);
2757
- 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;
2758
1830
  };
2759
- marked.walkTokens = function(tokens, callback) {
2760
- return markedInstance.walkTokens(tokens, callback);
1831
+ g.walkTokens = function(u3, e) {
1832
+ return L.walkTokens(u3, e);
2761
1833
  };
2762
- marked.parseInline = markedInstance.parseInline;
2763
- marked.Parser = _Parser;
2764
- marked.parser = _Parser.parse;
2765
- marked.Renderer = _Renderer;
2766
- marked.TextRenderer = _TextRenderer;
2767
- marked.Lexer = _Lexer;
2768
- marked.lexer = _Lexer.lex;
2769
- marked.Tokenizer = _Tokenizer;
2770
- marked.Hooks = _Hooks;
2771
- marked.parse = marked;
2772
- var options = marked.options;
2773
- var setOptions = marked.setOptions;
2774
- var use = marked.use;
2775
- var walkTokens = marked.walkTokens;
2776
- var parseInline = marked.parseInline;
2777
- var parser = _Parser.parse;
2778
- 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;
2779
1851
 
2780
1852
  // ../adaptives/adaptive-faq/dist/FAQWidget.js
2781
1853
  import React2, { useCallback as useCallback2, useEffect as useEffect2, useMemo, useReducer, useState as useState2 } from "react";
2782
1854
  import { createRoot as createRoot2 } from "react-dom/client";
2783
- var marked2 = new Marked({ async: false, gfm: true, breaks: true });
2784
- function getAnswerText(answer) {
2785
- if (typeof answer === "string")
2786
- return answer;
2787
- if (answer.type === "rich")
2788
- return answer.html;
2789
- return answer.content;
2790
- }
2791
- function renderAnswer(answer) {
2792
- if (typeof answer === "string") {
2793
- return _jsx2("p", { style: { margin: 0 }, children: answer });
2794
- }
2795
- if (answer.type === "rich") {
2796
- return _jsx2("div", { style: { margin: 0 }, dangerouslySetInnerHTML: { __html: answer.html } });
2797
- }
2798
- const html2 = marked2.parse(answer.content);
2799
- return (
2800
- // biome-ignore lint/security/noDangerouslySetInnerHtml: markdown content is CMS/config content, not user-controlled input
2801
- _jsx2("div", { style: { margin: 0 }, "data-faq-markdown": "", dangerouslySetInnerHTML: { __html: html2 } })
2802
- );
2803
- }
2804
- function resolveFeedbackConfig(feedback) {
2805
- if (!feedback)
2806
- return null;
2807
- if (feedback === true) {
2808
- return { style: "thumbs" };
2809
- }
2810
- return feedback;
2811
- }
2812
- function getFeedbackPrompt(feedbackConfig) {
2813
- return feedbackConfig.prompt || "Was this helpful?";
2814
- }
1855
+
1856
+ // ../adaptives/adaptive-faq/dist/faq-styles.js
2815
1857
  var baseStyles = {
2816
1858
  container: {
2817
1859
  fontFamily: "var(--sc-font-family, system-ui, -apple-system, sans-serif)",
@@ -2928,7 +1970,10 @@ var themeStyles = {
2928
1970
  },
2929
1971
  item: {
2930
1972
  backgroundColor: "var(--sc-content-background)",
2931
- border: "var(--sc-content-border)"
1973
+ borderTop: "var(--sc-content-border)",
1974
+ borderRight: "var(--sc-content-border)",
1975
+ borderBottom: "var(--sc-content-border)",
1976
+ borderLeft: "var(--sc-content-border)"
2932
1977
  },
2933
1978
  itemExpanded: {
2934
1979
  boxShadow: "0 4px 12px rgba(0, 0, 0, 0.08)"
@@ -2967,7 +2012,10 @@ var themeStyles = {
2967
2012
  },
2968
2013
  item: {
2969
2014
  backgroundColor: "var(--sc-content-background)",
2970
- border: "var(--sc-content-border)"
2015
+ borderTop: "var(--sc-content-border)",
2016
+ borderRight: "var(--sc-content-border)",
2017
+ borderBottom: "var(--sc-content-border)",
2018
+ borderLeft: "var(--sc-content-border)"
2971
2019
  },
2972
2020
  itemExpanded: {
2973
2021
  boxShadow: "0 4px 12px rgba(0, 0, 0, 0.15)"
@@ -2997,6 +2045,44 @@ var themeStyles = {
2997
2045
  }
2998
2046
  }
2999
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
+ }
3000
2086
  function FAQItem({ item, isExpanded, isHighlighted, isLast, onToggle, theme, feedbackConfig, feedbackValue, onFeedback }) {
3001
2087
  const [isHovered, setIsHovered] = useState2(false);
3002
2088
  const colors = themeStyles[theme];
@@ -3006,7 +2092,8 @@ function FAQItem({ item, isExpanded, isHighlighted, isLast, onToggle, theme, fee
3006
2092
  ...colors.item,
3007
2093
  ...isExpanded ? colors.itemExpanded : {},
3008
2094
  ...isHighlighted ? {
3009
- 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)`,
3010
2097
  transition: "box-shadow 0.3s ease"
3011
2098
  } : {},
3012
2099
  ...!isLast ? { borderBottom: "var(--sc-content-item-divider, none)" } : {}
@@ -3039,7 +2126,7 @@ function FAQItem({ item, isExpanded, isHighlighted, isLast, onToggle, theme, fee
3039
2126
  }, "aria-label": "Thumbs down", onClick: () => onFeedback(item.config.id, question, "down"), children: "\u{1F44E}" })] })] })] });
3040
2127
  }
3041
2128
  function FAQWidget({ config, runtime: runtime7, instanceId }) {
3042
- const [renderTick, forceUpdate] = useReducer((x) => x + 1, 0);
2129
+ const [renderTick, forceUpdate] = useReducer((x2) => x2 + 1, 0);
3043
2130
  const [expandedIds, setExpandedIds] = useState2(/* @__PURE__ */ new Set());
3044
2131
  const [highlightId, setHighlightId] = useState2(null);
3045
2132
  const [searchQuery, setSearchQuery] = useState2("");
@@ -3128,17 +2215,20 @@ function FAQWidget({ config, runtime: runtime7, instanceId }) {
3128
2215
  const unsubscribe = runtime7.events.subscribe({ names: ["notification.deep_link"] }, handleDeepLink);
3129
2216
  return unsubscribe;
3130
2217
  }, [runtime7, instanceId]);
3131
- const visibleQuestions = useMemo(() => config.actions.filter((q) => {
3132
- if (!q.triggerWhen)
3133
- return true;
3134
- const result = runtime7.evaluateSync(q.triggerWhen);
3135
- return result.value;
3136
- }), [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]);
3137
2227
  const orderedQuestions = useMemo(() => {
3138
2228
  if (config.ordering === "priority") {
3139
- return [...visibleQuestions].sort((a, b) => {
2229
+ return [...visibleQuestions].sort((a, b2) => {
3140
2230
  var _a2, _b;
3141
- 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);
3142
2232
  });
3143
2233
  }
3144
2234
  return visibleQuestions;
@@ -3148,23 +2238,23 @@ function FAQWidget({ config, runtime: runtime7, instanceId }) {
3148
2238
  return orderedQuestions;
3149
2239
  }
3150
2240
  const query = searchQuery.toLowerCase();
3151
- return orderedQuestions.filter((q) => {
2241
+ return orderedQuestions.filter((q2) => {
3152
2242
  var _a2;
3153
- 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));
3154
2244
  });
3155
2245
  }, [orderedQuestions, searchQuery, config.searchable]);
3156
2246
  const categoryGroups = useMemo(() => {
3157
2247
  const groups = /* @__PURE__ */ new Map();
3158
- for (const q of filteredQuestions) {
3159
- const cat = q.config.category;
2248
+ for (const q2 of filteredQuestions) {
2249
+ const cat = q2.config.category;
3160
2250
  if (!groups.has(cat)) {
3161
2251
  groups.set(cat, []);
3162
2252
  }
3163
- groups.get(cat).push(q);
2253
+ groups.get(cat).push(q2);
3164
2254
  }
3165
2255
  return groups;
3166
2256
  }, [filteredQuestions]);
3167
- const hasCategories = useMemo(() => filteredQuestions.some((q) => q.config.category), [filteredQuestions]);
2257
+ const hasCategories = useMemo(() => filteredQuestions.some((q2) => q2.config.category), [filteredQuestions]);
3168
2258
  const resolvedTheme = useMemo(() => {
3169
2259
  var _a2;
3170
2260
  if (config.theme && config.theme !== "auto")
@@ -3225,7 +2315,7 @@ function FAQWidget({ config, runtime: runtime7, instanceId }) {
3225
2315
  ...baseStyles.categoryHeader,
3226
2316
  ...themeStyles[resolvedTheme].categoryHeader
3227
2317
  };
3228
- 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));
3229
2319
  if (visibleQuestions.length === 0) {
3230
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." }) });
3231
2321
  }
@@ -3250,20 +2340,6 @@ var FAQMountableWidget = {
3250
2340
  root.unmount();
3251
2341
  };
3252
2342
  }
3253
- const questions = faqConfig.actions || [];
3254
- container.innerHTML = `
3255
- <div style="font-family: system-ui; max-width: 800px;">
3256
- ${questions.map((q) => `
3257
- <div style="margin-bottom: 8px; padding: 16px; background: ${slateGrey[12]}; border-radius: 8px;">
3258
- <strong>${q.config.question}</strong>
3259
- <p style="margin-top: 8px; color: ${slateGrey[6]};">${getAnswerText(q.config.answer)}</p>
3260
- </div>
3261
- `).join("")}
3262
- </div>
3263
- `;
3264
- return () => {
3265
- container.innerHTML = "";
3266
- };
3267
2343
  }
3268
2344
  };
3269
2345
 
@@ -3363,6 +2439,21 @@ var runtime5 = {
3363
2439
  import { jsx as _jsx3, jsxs as _jsxs3 } from "react/jsx-runtime";
3364
2440
  import React3, { useCallback as useCallback3, useEffect as useEffect3, useMemo as useMemo2, useReducer as useReducer2, useState as useState3 } from "react";
3365
2441
  import { createRoot as createRoot3 } from "react-dom/client";
2442
+ var EMOJI_SVG_MAP = {
2443
+ "\u{1F4B5}": '<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect width="20" height="12" x="2" y="6" rx="2"/><circle cx="12" cy="12" r="2"/><path d="M6 12h.01M18 12h.01"/></svg>',
2444
+ "\u{1F3DB}\uFE0F": '<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="3" x2="21" y1="22" y2="22"/><line x1="6" x2="6" y1="18" y2="11"/><line x1="10" x2="10" y1="18" y2="11"/><line x1="14" x2="14" y1="18" y2="11"/><line x1="18" x2="18" y1="18" y2="11"/><polygon points="12 2 20 7 4 7"/></svg>',
2445
+ "\u23ED\uFE0F": '<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polygon points="5 4 15 12 5 20 5 4"/><line x1="19" x2="19" y1="5" y2="19"/></svg>',
2446
+ "\u27A1\uFE0F": '<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M5 12h14"/><path d="m12 5 7 7-7 7"/></svg>',
2447
+ "\u{1F4A1}": '<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M15 14c.2-1 .7-1.7 1.5-2.5 1-.9 1.5-2.2 1.5-3.5A6 6 0 0 0 6 8c0 1 .2 2.2 1.5 3.5.7.7 1.3 1.5 1.5 2.5"/><path d="M9 18h6"/><path d="M10 22h4"/></svg>',
2448
+ "\u{1F4B0}": '<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect width="20" height="12" x="2" y="6" rx="2"/><circle cx="12" cy="12" r="2"/><path d="M6 12h.01M18 12h.01"/></svg>',
2449
+ "\u{1F4CB}": '<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect width="8" height="4" x="8" y="2" rx="1" ry="1"/><path d="M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2"/><path d="M12 11h4"/><path d="M12 16h4"/><path d="M8 11h.01"/><path d="M8 16h.01"/></svg>',
2450
+ "\u2705": '<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M22 11.08V12a10 10 0 1 1-5.93-9.14"/><path d="m9 11 3 3L22 4"/></svg>',
2451
+ "\u26A0\uFE0F": '<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3"/><path d="M12 9v4"/><path d="M12 17h.01"/></svg>'
2452
+ };
2453
+ function renderIcon(emoji) {
2454
+ var _a2;
2455
+ return (_a2 = EMOJI_SVG_MAP[emoji]) != null ? _a2 : escapeHtml(emoji);
2456
+ }
3366
2457
  function escapeHtml(str) {
3367
2458
  return str.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#39;");
3368
2459
  }
@@ -3468,7 +2559,8 @@ var themeStyles2 = {
3468
2559
  color: "var(--sc-content-text-secondary-color)"
3469
2560
  },
3470
2561
  linkButton: {
3471
- 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]})`,
3472
2564
  color: "#ffffff"
3473
2565
  },
3474
2566
  categoryHeader: {
@@ -3501,7 +2593,8 @@ var themeStyles2 = {
3501
2593
  color: "var(--sc-content-text-secondary-color)"
3502
2594
  },
3503
2595
  linkButton: {
3504
- 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]})`,
3505
2598
  color: "#ffffff"
3506
2599
  },
3507
2600
  categoryHeader: {
@@ -3512,10 +2605,29 @@ var themeStyles2 = {
3512
2605
  }
3513
2606
  }
3514
2607
  };
3515
- function NavTipItem({ item, isExpanded, isLast, onToggle, onNavigate, theme }) {
2608
+ function routeMatchesCurrent(routes) {
2609
+ if (typeof window === "undefined")
2610
+ return false;
2611
+ const current = window.location.pathname;
2612
+ return routes.some((route) => {
2613
+ const routePath = route.split("?")[0].split("#")[0];
2614
+ if (routePath.endsWith("/**")) {
2615
+ return current.startsWith(routePath.slice(0, -3));
2616
+ }
2617
+ return current === routePath;
2618
+ });
2619
+ }
2620
+ function pulseElement(el) {
2621
+ const keyframes = [
2622
+ { boxShadow: "0 0 0 0 rgba(13, 148, 136, 0.5)" },
2623
+ { boxShadow: "0 0 0 8px rgba(13, 148, 136, 0)" }
2624
+ ];
2625
+ el.animate(keyframes, { duration: 600, iterations: 3, easing: "ease-out" });
2626
+ }
2627
+ function NavTipItem({ item, isExpanded, isLast, onToggle, onNavigate, onFocusAnchor, theme }) {
3516
2628
  const [isHovered, setIsHovered] = useState3(false);
3517
2629
  const colors = themeStyles2[theme];
3518
- const { title, description, href, icon, external } = item.config;
2630
+ const { title, description, href, icon, external, anchor } = item.config;
3519
2631
  const itemStyle = {
3520
2632
  ...baseStyles2.item,
3521
2633
  ...colors.item,
@@ -3537,17 +2649,26 @@ function NavTipItem({ item, isExpanded, isLast, onToggle, onNavigate, theme }) {
3537
2649
  maxHeight: isExpanded ? "500px" : "0",
3538
2650
  paddingBottom: isExpanded ? "16px" : "0"
3539
2651
  };
2652
+ const effectiveHref = anchor ? Array.isArray(anchor.route) ? anchor.route[0] : anchor.route : href;
2653
+ const isSamePage = anchor ? routeMatchesCurrent(Array.isArray(anchor.route) ? anchor.route : [anchor.route]) : effectiveHref ? routeMatchesCurrent([effectiveHref]) : false;
2654
+ const hasSelector = (anchor == null ? void 0 : anchor.selector) && anchor.selector !== "*";
2655
+ const isFocusAction = isSamePage && hasSelector;
2656
+ const hasAction = !!effectiveHref || isFocusAction;
3540
2657
  const handleLinkClick = (e) => {
3541
2658
  e.preventDefault();
3542
2659
  e.stopPropagation();
3543
- if (href) {
3544
- onNavigate(href, external != null ? external : false);
2660
+ if (isFocusAction && anchor) {
2661
+ onFocusAnchor(anchor);
2662
+ } else if (effectiveHref) {
2663
+ onNavigate(effectiveHref, external != null ? external : false);
3545
2664
  }
3546
2665
  };
3547
- 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, children: 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 }), href && _jsxs3("a", { href, onClick: handleLinkClick, style: { ...baseStyles2.linkButton, ...colors.linkButton }, target: external ? "_blank" : void 0, rel: external ? "noopener noreferrer" : void 0, children: ["Go ", external ? "\u2197" : "\u2192"] })] })] });
2666
+ const ctaLabel = isFocusAction ? `Focus \u2192` : external ? `Go \u2197` : `Go \u2192`;
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 })] })] });
3548
2669
  }
3549
2670
  function NavWidget({ config, runtime: runtime7, instanceId }) {
3550
- const [renderTick, forceUpdate] = useReducer2((x) => x + 1, 0);
2671
+ const [renderTick, forceUpdate] = useReducer2((x2) => x2 + 1, 0);
3551
2672
  const [expandedIds, setExpandedIds] = useState3(/* @__PURE__ */ new Set());
3552
2673
  useEffect3(() => {
3553
2674
  const unsubscribe = runtime7.context.subscribe(() => {
@@ -3643,9 +2764,26 @@ function NavWidget({ config, runtime: runtime7, instanceId }) {
3643
2764
  } else {
3644
2765
  const url = new URL(href, window.location.origin);
3645
2766
  url.search = window.location.search;
3646
- window.location.href = url.toString();
2767
+ if (!navigateWithFrameworkRouter(url.toString())) {
2768
+ window.history.pushState(null, "", url.toString());
2769
+ window.dispatchEvent(new PopStateEvent("popstate"));
2770
+ }
3647
2771
  }
3648
2772
  }, [runtime7.events, instanceId]);
2773
+ const handleFocusAnchor = useCallback3((anchor) => {
2774
+ const el = document.querySelector(anchor.selector);
2775
+ if (!(el instanceof HTMLElement))
2776
+ return;
2777
+ runtime7.events.publish("nav:tip_focused", {
2778
+ instanceId,
2779
+ selector: anchor.selector,
2780
+ route: anchor.route,
2781
+ timestamp: Date.now()
2782
+ });
2783
+ el.scrollIntoView({ behavior: "smooth", block: "center" });
2784
+ pulseElement(el);
2785
+ setTimeout(() => el.focus(), 400);
2786
+ }, [runtime7.events, instanceId]);
3649
2787
  const containerStyle = {
3650
2788
  ...baseStyles2.container,
3651
2789
  ...themeStyles2[resolvedTheme].container
@@ -3658,7 +2796,7 @@ function NavWidget({ config, runtime: runtime7, instanceId }) {
3658
2796
  ...baseStyles2.emptyState,
3659
2797
  ...themeStyles2[resolvedTheme].emptyState
3660
2798
  };
3661
- const renderItems = (items) => items.map((tip, index) => _jsx3(NavTipItem, { item: tip, isExpanded: expandedIds.has(tip.config.id), isLast: index === items.length - 1, onToggle: () => handleToggle(tip.config.id), onNavigate: handleNavigate, theme: resolvedTheme }, tip.config.id));
2799
+ const renderItems = (items) => items.map((tip, index) => _jsx3(NavTipItem, { item: tip, isExpanded: expandedIds.has(tip.config.id), isLast: index === items.length - 1, onToggle: () => handleToggle(tip.config.id), onNavigate: handleNavigate, onFocusAnchor: handleFocusAnchor, theme: resolvedTheme }, tip.config.id));
3662
2800
  if (visibleTips.length === 0) {
3663
2801
  return _jsx3("div", { style: containerStyle, "data-adaptive-id": instanceId, "data-adaptive-type": "adaptive-nav", children: _jsx3("div", { style: emptyStateStyle, children: "You're all set for now! We'll share helpful tips here when they're relevant to what you're doing." }) });
3664
2802
  }
@@ -3682,21 +2820,6 @@ var NavMountableWidget = {
3682
2820
  root.unmount();
3683
2821
  };
3684
2822
  }
3685
- const tips = navConfig.actions || [];
3686
- container.innerHTML = `
3687
- <div style="font-family: system-ui; max-width: 100%;">
3688
- ${tips.map((tip) => `
3689
- <div style="margin-bottom: 4px; padding: 12px 16px; background: ${slateGrey[12]}; border-radius: 8px;">
3690
- ${tip.config.icon ? `<span>${escapeHtml(tip.config.icon)}</span> ` : ""}<strong>${escapeHtml(tip.config.title)}</strong>
3691
- <p style="margin-top: 8px; color: ${slateGrey[6]}; font-size: 13px;">${escapeHtml(tip.config.description)}</p>
3692
- ${tip.config.href ? `<a href="${escapeHtml(tip.config.href)}" style="color: ${purple[2]}; font-size: 13px;">Go &rarr;</a>` : ""}
3693
- </div>
3694
- `).join("")}
3695
- </div>
3696
- `;
3697
- return () => {
3698
- container.innerHTML = "";
3699
- };
3700
2823
  }
3701
2824
  };
3702
2825
 
@@ -3725,6 +2848,40 @@ var executeScrollTo = async (action, context) => {
3725
2848
  }
3726
2849
  };
3727
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
+ }
3728
2885
  function isSameOrigin(url) {
3729
2886
  try {
3730
2887
  const parsed = new URL(url, window.location.origin);
@@ -3749,8 +2906,10 @@ var executeNavigate = async (action, context) => {
3749
2906
  if (target === "_blank") {
3750
2907
  window.open(url, "_blank", "noopener,noreferrer");
3751
2908
  } else if (!action.forceFullNavigation && isSameOrigin(url)) {
3752
- window.history.pushState(null, "", url);
3753
- window.dispatchEvent(new PopStateEvent("popstate"));
2909
+ if (!navigateWithFrameworkRouter(url)) {
2910
+ window.history.pushState(null, "", url);
2911
+ window.dispatchEvent(new PopStateEvent("popstate"));
2912
+ }
3754
2913
  } else {
3755
2914
  window.location.href = url;
3756
2915
  }
@@ -3841,9 +3000,9 @@ import { jsx, jsxs } from "react/jsx-runtime";
3841
3000
  function TileWheel({ tiles, intervalMs = 7e3, telemetry }) {
3842
3001
  const [index, setIndex] = useState4(0);
3843
3002
  const ordered = useMemo3(
3844
- () => [...tiles].sort((a, b) => {
3003
+ () => [...tiles].sort((a, b2) => {
3845
3004
  var _a2, _b;
3846
- 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);
3847
3006
  }),
3848
3007
  [tiles]
3849
3008
  );
@@ -4011,50 +3170,50 @@ function needsMigration(config) {
4011
3170
  }
4012
3171
 
4013
3172
  // src/overlays/schema.ts
4014
- import { z } from "zod";
4015
- var SelectorZ = z.union([
4016
- z.object({ type: z.literal("data"), key: z.string(), value: z.string().optional() }),
4017
- z.object({ type: z.literal("css"), value: z.string() }),
4018
- z.object({ type: z.literal("aria"), role: z.string().optional(), label: z.string().optional() }),
4019
- z.object({ type: z.literal("shadow-css"), value: z.string() }),
4020
- 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() })
4021
3180
  // runtime-only
4022
3181
  ]);
4023
- var TooltipStepZ = z.object({
4024
- kind: z.literal("tooltip"),
4025
- id: z.string(),
3182
+ var TooltipStepZ = z2.object({
3183
+ kind: z2.literal("tooltip"),
3184
+ id: z2.string(),
4026
3185
  anchor: SelectorZ,
4027
- content: z.object({ title: z.string().optional(), body: z.string() }),
4028
- placement: z.enum(["top", "bottom", "left", "right", "auto"]).optional(),
4029
- offsetPx: z.number().optional(),
4030
- blocking: z.boolean().optional(),
4031
- trigger: z.enum(["immediate", "hover", "click"]).optional(),
4032
- dismiss: z.object({
4033
- onEsc: z.boolean().optional(),
4034
- closeButton: z.boolean().optional(),
4035
- 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()
4036
3195
  }).optional()
4037
3196
  });
4038
- var HighlightStepZ = z.object({
4039
- kind: z.literal("highlight"),
4040
- id: z.string(),
3197
+ var HighlightStepZ = z2.object({
3198
+ kind: z2.literal("highlight"),
3199
+ id: z2.string(),
4041
3200
  anchor: SelectorZ,
4042
- copy: z.string().optional(),
4043
- ring: z.object({ paddingPx: z.number().optional(), radiusPx: z.number().optional() }).optional(),
4044
- scrim: z.object({ opacity: z.number().optional() }).optional(),
4045
- ringColor: z.string().optional(),
4046
- blocking: z.boolean().optional(),
4047
- dismiss: z.object({
4048
- onClickOutside: z.boolean().optional(),
4049
- onEsc: z.boolean().optional(),
4050
- 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()
4051
3210
  }).optional()
4052
3211
  });
4053
- var CanvasRecipeZ = z.object({
4054
- id: z.string(),
4055
- version: z.number(),
4056
- routes: z.array(z.string()).optional(),
4057
- 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]))
4058
3217
  });
4059
3218
  function validateRecipe(json) {
4060
3219
  return CanvasRecipeZ.parse(json);
@@ -4097,47 +3256,47 @@ function SmartCanvasPortal({ element, children }) {
4097
3256
  }
4098
3257
 
4099
3258
  // src/context/schema.ts
4100
- import { z as z2 } from "zod";
4101
- var PageContextZ = z2.object({
4102
- url: z2.string(),
4103
- routeId: z2.string().optional(),
4104
- title: z2.string().optional(),
4105
- 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()
4106
3265
  });
4107
- var PageHistoryEntryZ = z2.object({
4108
- url: z2.string(),
4109
- ts: z2.number()
3266
+ var PageHistoryEntryZ = z3.object({
3267
+ url: z3.string(),
3268
+ ts: z3.number()
4110
3269
  });
4111
- var SessionContextZ = z2.object({
4112
- sessionId: z2.string(),
4113
- startTs: z2.number(),
4114
- pageHistory: z2.array(PageHistoryEntryZ).optional()
3270
+ var SessionContextZ = z3.object({
3271
+ sessionId: z3.string(),
3272
+ startTs: z3.number(),
3273
+ pageHistory: z3.array(PageHistoryEntryZ).optional()
4115
3274
  });
4116
- var ViewportContextZ = z2.object({
4117
- width: z2.number(),
4118
- height: z2.number()
3275
+ var ViewportContextZ = z3.object({
3276
+ width: z3.number(),
3277
+ height: z3.number()
4119
3278
  });
4120
- var BoundingBoxZ = z2.object({
4121
- x: z2.number(),
4122
- y: z2.number(),
4123
- w: z2.number(),
4124
- h: z2.number()
3279
+ var BoundingBoxZ = z3.object({
3280
+ x: z3.number(),
3281
+ y: z3.number(),
3282
+ w: z3.number(),
3283
+ h: z3.number()
4125
3284
  });
4126
- var AnchorStateZ = z2.object({
4127
- anchorId: z2.string(),
4128
- present: z2.boolean(),
4129
- visible: z2.boolean().optional(),
3285
+ var AnchorStateZ = z3.object({
3286
+ anchorId: z3.string(),
3287
+ present: z3.boolean(),
3288
+ visible: z3.boolean().optional(),
4130
3289
  boundingBox: BoundingBoxZ.optional()
4131
3290
  });
4132
- var AugmentationZ = z2.record(
4133
- z2.string(),
4134
- 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()])
4135
3294
  );
4136
- var RuntimeContextZ = z2.object({
3295
+ var RuntimeContextZ = z3.object({
4137
3296
  page: PageContextZ,
4138
3297
  session: SessionContextZ,
4139
3298
  viewport: ViewportContextZ,
4140
- anchors: z2.array(AnchorStateZ).optional(),
3299
+ anchors: z3.array(AnchorStateZ).optional(),
4141
3300
  augmented: AugmentationZ.optional()
4142
3301
  });
4143
3302
  function validateRuntimeContext(data) {
@@ -4145,19 +3304,19 @@ function validateRuntimeContext(data) {
4145
3304
  }
4146
3305
 
4147
3306
  // src/events/schema.ts
4148
- import { z as z3 } from "zod";
4149
- var EventSourceZ = z3.enum(["posthog", "canvas", "derived"]);
4150
- var NormalizedEventZ = z3.object({
4151
- ts: z3.number(),
4152
- 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(),
4153
3312
  source: EventSourceZ,
4154
- props: z3.record(z3.string(), z3.unknown()).optional(),
4155
- schemaVersion: z3.string()
3313
+ props: z4.record(z4.string(), z4.unknown()).optional(),
3314
+ schemaVersion: z4.string()
4156
3315
  });
4157
- var EventFilterZ = z3.object({
4158
- names: z3.array(z3.string()).optional(),
4159
- patterns: z3.array(z3.string()).optional(),
4160
- 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()
4161
3320
  });
4162
3321
  function validateNormalizedEvent(data) {
4163
3322
  return NormalizedEventZ.safeParse(data);
@@ -4167,14 +3326,14 @@ function validateEventFilter(data) {
4167
3326
  }
4168
3327
 
4169
3328
  // src/state/schema.ts
4170
- import { z as z4 } from "zod";
4171
- var StoredValueZ = z4.object({
4172
- value: z4.unknown(),
4173
- 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()
4174
3333
  });
4175
- var FrequencyEntryZ = z4.object({
4176
- count: z4.number(),
4177
- resetAt: z4.number().optional()
3334
+ var FrequencyEntryZ = z5.object({
3335
+ count: z5.number(),
3336
+ resetAt: z5.number().optional()
4178
3337
  });
4179
3338
  function validateStoredValue(data) {
4180
3339
  return StoredValueZ.safeParse(data);
@@ -4225,6 +3384,7 @@ export {
4225
3384
  EventBus,
4226
3385
  EventCountConditionZ,
4227
3386
  EventFilterZ,
3387
+ EventHistory,
4228
3388
  EventOccurredConditionZ,
4229
3389
  EventSourceZ,
4230
3390
  ExecutorRegistry,
@@ -4236,6 +3396,7 @@ export {
4236
3396
  HighlightZ,
4237
3397
  InsertHtmlZ,
4238
3398
  InsertPositionZ,
3399
+ InterventionTracker,
4239
3400
  MAX_VISIBLE_TOASTS,
4240
3401
  MatchOpZ,
4241
3402
  ModalContentZ,
@@ -4378,8 +3539,10 @@ export {
4378
3539
  validateCondition,
4379
3540
  validateConfig,
4380
3541
  validateEventFilter,
3542
+ validateEventName,
4381
3543
  validateFrequencyEntry,
4382
3544
  validateNormalizedEvent,
3545
+ validateProps,
4383
3546
  validateRecipe,
4384
3547
  validateRuntimeContext,
4385
3548
  validateStoredValue,