@artooi/ag-ui-web-component 0.15.0 → 0.17.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. package/CHANGELOG.md +158 -1
  2. package/README.md +42 -4
  3. package/dist/ag-ui-web-component.bundle.js +91 -58
  4. package/dist/ag-ui-web-component.bundle.js.map +4 -4
  5. package/dist/constants.d.ts +21 -0
  6. package/dist/constants.d.ts.map +1 -1
  7. package/dist/core/ag_ui_chat.d.ts +41 -2
  8. package/dist/core/ag_ui_chat.d.ts.map +1 -1
  9. package/dist/core/agui_client.d.ts.map +1 -1
  10. package/dist/core/conversation_store.d.ts.map +1 -1
  11. package/dist/core/remote_conversation_store.d.ts.map +1 -1
  12. package/dist/core/run_index.d.ts.map +1 -1
  13. package/dist/index.d.ts +2 -2
  14. package/dist/index.d.ts.map +1 -1
  15. package/dist/index.js +534 -325
  16. package/dist/index.js.map +4 -4
  17. package/dist/tools/client_tool_registry.d.ts.map +1 -1
  18. package/dist/tools/page_action_tools.d.ts.map +1 -1
  19. package/dist/tools/route_map.d.ts.map +1 -1
  20. package/dist/ui/attachment_tray.d.ts +2 -0
  21. package/dist/ui/attachment_tray.d.ts.map +1 -1
  22. package/dist/ui/checkpoint_menu.d.ts.map +1 -1
  23. package/dist/ui/skills_menu.d.ts.map +1 -1
  24. package/dist/ui/styles.d.ts +1 -1
  25. package/dist/ui/styles.d.ts.map +1 -1
  26. package/dist/ui/thoughts_block.d.ts.map +1 -1
  27. package/dist/ui/thread_drawer.d.ts.map +1 -1
  28. package/dist/ui/tool_call_card.d.ts.map +1 -1
  29. package/dist/ui/ui_strings.d.ts +6 -0
  30. package/dist/ui/ui_strings.d.ts.map +1 -1
  31. package/dist/ui/voice_input.d.ts.map +1 -1
  32. package/package.json +9 -8
  33. package/src/constants.ts +23 -0
  34. package/src/core/ag_ui_chat.ts +243 -15
  35. package/src/core/remote_conversation_store.ts +2 -2
  36. package/src/index.ts +2 -0
  37. package/src/tools/route_map.ts +5 -8
  38. package/src/ui/attachment_tray.ts +5 -0
  39. package/src/ui/checkpoint_menu.ts +2 -0
  40. package/src/ui/styles.ts +38 -6
  41. package/src/ui/ui_strings.ts +11 -0
  42. package/src/version.ts +1 -1
package/dist/index.js CHANGED
@@ -3,6 +3,7 @@ var ELEMENT_TAG = "ag-ui-chat";
3
3
  var SUBMIT_EVENT = "ag-ui-submit";
4
4
  var TOGGLE_EVENT = "ag-ui-toggle";
5
5
  var STATE_EVENT = "ag-ui-state";
6
+ var ATTACHMENT_EVENT = "ag-ui-attachments";
6
7
  var MESSAGE_ROLE = {
7
8
  USER: "user",
8
9
  ASSISTANT: "assistant"
@@ -11,6 +12,7 @@ var X_DESTRUCTIVE_KEY = "x-destructive";
11
12
  var X_CONFIRM_KEY = "x-confirm";
12
13
  var X_SUMMARY_KEY = "x-summary";
13
14
  var X_NAVIGATES_KEY = "x-navigates";
15
+ var READ_PAGE_TOOL = "read_page";
14
16
  var MAX_TOOL_ROUNDS = 10;
15
17
  var TOOL_CALL_STATUS = {
16
18
  PENDING: "pending",
@@ -376,14 +378,7 @@ function parseToolCatalog(data) {
376
378
  // src/tools/route_map.ts
377
379
  var PATH_PARAM_RE = /:([A-Za-z_][A-Za-z0-9_]*)/g;
378
380
  function pathParamNames(path) {
379
- const names = [];
380
- for (const match of path.matchAll(PATH_PARAM_RE)) {
381
- const name = match[1];
382
- if (name !== void 0) {
383
- names.push(name);
384
- }
385
- }
386
- return names;
381
+ return [...path.matchAll(PATH_PARAM_RE)].map((match) => match[0].slice(1));
387
382
  }
388
383
  function fillPath(routeId, path, params) {
389
384
  const leftover = { ...params };
@@ -470,6 +465,9 @@ var DEFAULT_UI_STRINGS = {
470
465
  navigating: "Navigating\u2026",
471
466
  historyCompacted: "Earlier turns condensed to fit the context window ({count} removed)",
472
467
  usingSkill: "Using skill {name}",
468
+ runInterrupted: "The previous response didn\u2019t finish \u2014 the page changed before it arrived.",
469
+ pageMoved: "The page changed since you last looked at it. Call read_page to see the current page, then retry.",
470
+ attachmentsStillUploading: "{n} file still uploading \u2014 it was not sent with this message and is still attached.",
473
471
  skillNeeds: "\u201C{title}\u201D needs: {fields}",
474
472
  message: "Message",
475
473
  inputPlaceholder: "Ask anything\u2026",
@@ -697,6 +695,10 @@ var AttachmentTray = class {
697
695
  hasPending() {
698
696
  return this.#items.some((item) => item.status === ATTACHMENT_STATUS.UPLOADING);
699
697
  }
698
+ /** How many chips are still uploading — the count a send-time notice names. */
699
+ pendingCount() {
700
+ return this.#items.filter((item) => item.status === ATTACHMENT_STATUS.UPLOADING).length;
701
+ }
700
702
  /** Whether the tray holds no chips. */
701
703
  isEmpty() {
702
704
  return this.#items.length === 0;
@@ -899,6 +901,7 @@ var CheckpointMenu = class {
899
901
  header.setAttribute("part", "checkpoints-header");
900
902
  this.#heading = document.createElement("span");
901
903
  this.#heading.className = "checkpoints-title";
904
+ this.#heading.setAttribute("part", "checkpoints-title");
902
905
  this.#heading.textContent = strings.checkpoints;
903
906
  header.append(this.#heading);
904
907
  this.#list = document.createElement("div");
@@ -953,6 +956,7 @@ var CheckpointMenu = class {
953
956
  row.setAttribute("part", "checkpoint-row");
954
957
  const label = document.createElement("span");
955
958
  label.className = "checkpoint-label";
959
+ label.setAttribute("part", "checkpoint-label");
956
960
  label.textContent = run.started_at === null ? run.run_id : relativeTime(Date.parse(run.started_at), Date.now(), this.#strings);
957
961
  label.title = run.run_id;
958
962
  row.append(label);
@@ -1204,15 +1208,15 @@ function _arrayWithHoles(r) {
1204
1208
  function _iterableToArrayLimit(r, l3) {
1205
1209
  var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
1206
1210
  if (null != t) {
1207
- var e, n, i, u, a = [], f = true, o = false;
1211
+ var e, n, i, u, a = [], f2 = true, o = false;
1208
1212
  try {
1209
1213
  if (i = (t = t.call(r)).next, 0 === l3) ;
1210
- else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l3); f = true) ;
1214
+ else for (; !(f2 = (e = i.call(t)).done) && (a.push(e.value), a.length !== l3); f2 = true) ;
1211
1215
  } catch (r2) {
1212
1216
  o = true, n = r2;
1213
1217
  } finally {
1214
1218
  try {
1215
- if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return;
1219
+ if (!f2 && null != t.return && (u = t.return(), Object(u) !== u)) return;
1216
1220
  } finally {
1217
1221
  if (o) throw n;
1218
1222
  }
@@ -2563,9 +2567,9 @@ function createDOMPurify() {
2563
2567
  const inPlace = IN_PLACE && typeof dirty !== "string" && _isNode(dirty);
2564
2568
  if (inPlace) {
2565
2569
  _neutralizePatchLinkage(dirty);
2566
- const nn = getNodeName ? getNodeName(dirty) : dirty.nodeName;
2567
- if (typeof nn === "string") {
2568
- const tagName = transformCaseFunc(nn);
2570
+ const nn2 = getNodeName ? getNodeName(dirty) : dirty.nodeName;
2571
+ if (typeof nn2 === "string") {
2572
+ const tagName = transformCaseFunc(nn2);
2569
2573
  if (!ALLOWED_TAGS2[tagName] || FORBID_TAGS[tagName]) {
2570
2574
  _neutralizeRoot(dirty);
2571
2575
  throw typeErrorCreate("root node is forbidden and cannot be sanitized in-place");
@@ -2718,23 +2722,23 @@ function createDOMPurify() {
2718
2722
  }
2719
2723
  var purify = createDOMPurify();
2720
2724
 
2721
- // node_modules/.pnpm/marked@18.0.5/node_modules/marked/lib/marked.esm.js
2722
- function M() {
2725
+ // node_modules/.pnpm/marked@18.0.9/node_modules/marked/lib/marked.esm.js
2726
+ function C() {
2723
2727
  return { async: false, breaks: false, extensions: null, gfm: true, hooks: null, pedantic: false, renderer: null, silent: false, tokenizer: null, walkTokens: null };
2724
2728
  }
2725
- var T = M();
2726
- function N(l3) {
2727
- T = l3;
2729
+ var R = C();
2730
+ function j(l3) {
2731
+ R = l3;
2728
2732
  }
2729
- var _ = { exec: () => null };
2730
- function E(l3) {
2733
+ var z = { exec: () => null };
2734
+ function A(l3) {
2731
2735
  let e = [];
2732
2736
  return (t) => {
2733
2737
  let n = Math.max(0, Math.min(3, t - 1)), s = e[n];
2734
2738
  return s || (s = l3(n), e[n] = s), s;
2735
2739
  };
2736
2740
  }
2737
- function d(l3, e = "") {
2741
+ function k(l3, e = "") {
2738
2742
  let t = typeof l3 == "string" ? l3 : l3.source, n = { replace: (s, r) => {
2739
2743
  let i = typeof r == "string" ? r : r.source;
2740
2744
  return i = i.replace(m.caret, "$1"), t = t.replace(s, i), n;
@@ -2748,78 +2752,87 @@ var Te = ((l3 = "") => {
2748
2752
  return false;
2749
2753
  }
2750
2754
  })();
2751
- 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: (l3) => new RegExp(`^( {0,3}${l3})((?:[ ][^\\n]*)?(?:\\n|$))`), nextBulletRegex: E((l3) => new RegExp(`^ {0,${l3}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`)), hrRegex: E((l3) => new RegExp(`^ {0,${l3}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`)), fencesBeginRegex: E((l3) => new RegExp(`^ {0,${l3}}(?:\`\`\`|~~~)`)), headingBeginRegex: E((l3) => new RegExp(`^ {0,${l3}}#`)), htmlBeginRegex: E((l3) => new RegExp(`^ {0,${l3}}<(?:[a-z].*>|!--)`, "i")), blockquoteBeginRegex: E((l3) => new RegExp(`^ {0,${l3}}>`)) };
2755
+ 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: (l3) => new RegExp(`^( {0,3}${l3})((?:[ ][^\\n]*)?(?:\\n|$))`), nextBulletRegex: A((l3) => new RegExp(`^ {0,${l3}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`)), hrRegex: A((l3) => new RegExp(`^ {0,${l3}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`)), fencesBeginRegex: A((l3) => new RegExp(`^ {0,${l3}}(?:\`\`\`|~~~)`)), headingBeginRegex: A((l3) => new RegExp(`^ {0,${l3}}#`)), htmlBeginRegex: A((l3) => new RegExp(`^ {0,${l3}}<(?:[a-z].*>|!--)`, "i")), blockquoteBeginRegex: A((l3) => new RegExp(`^ {0,${l3}}>`)) };
2752
2756
  var Oe = /^(?:[ \t]*(?:\n|$))+/;
2753
2757
  var we = /^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/;
2754
2758
  var ye = /^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/;
2755
- var B = /^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/;
2759
+ var q = /^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/;
2756
2760
  var Pe = /^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/;
2757
- var j = / {0,3}(?:[*+-]|\d{1,9}[.)])/;
2761
+ var U = / {0,3}(?:[*+-]|\d{1,9}[.)])/;
2758
2762
  var oe = /^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/;
2759
- var ae = d(oe).replace(/bull/g, j).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();
2760
- var Se = d(oe).replace(/bull/g, j).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();
2761
- var F = /^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/;
2762
- var $e = /^[^\n]+/;
2763
- var U = /(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/;
2764
- var Le = d(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label", U).replace("title", /(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex();
2765
- var _e = d(/^(bull)([ \t][^\n]*?)?(?:\n|$)/).replace(/bull/g, j).getRegex();
2766
- var H = "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";
2767
- var K = /<!--(?:-?>|[\s\S]*?(?:-->|$))/;
2768
- var ze = d("^ {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", K).replace("tag", H).replace("attribute", / +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex();
2769
- var le = d(F).replace("hr", B).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]+[^ \\t\\n]").replace("html", "</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag", H).getRegex();
2770
- var Me = d(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph", le).getRegex();
2771
- var W = { blockquote: Me, code: we, def: Le, fences: ye, heading: Pe, hr: B, html: ze, lheading: ae, list: _e, newline: Oe, paragraph: le, table: _, text: $e };
2772
- var se = d("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr", B).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", H).getRegex();
2773
- var Ee = { ...W, lheading: Se, table: se, paragraph: d(F).replace("hr", B).replace("heading", " {0,3}#{1,6}(?:\\s|$)").replace("|lheading", "").replace("table", se).replace("blockquote", " {0,3}>").replace("fences", " {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list", " {0,3}(?:[*+-]|1[.)])[ \\t]+[^ \\t\\n]").replace("html", "</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag", H).getRegex() };
2774
- var Ie = { ...W, html: d(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment", K).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: d(F).replace("hr", B).replace("heading", ` *#{1,6} *[^
2763
+ var ae = k(oe).replace(/bull/g, U).replace(/blockCode/g, /(?: {4}| {0,3}\t)/).replace(/fences/g, / {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g, / {0,3}>/).replace(/heading/g, / {0,3}#{1,6}(?:\s|$)/).replace(/html/g, / {0,3}<[^\n>]+>\n/).replace(/\|table/g, "").getRegex();
2764
+ var Se = k(oe).replace(/bull/g, U).replace(/blockCode/g, /(?: {4}| {0,3}\t)/).replace(/fences/g, / {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g, / {0,3}>/).replace(/heading/g, / {0,3}#{1,6}(?:\s|$)/).replace(/html/g, / {0,3}<[^\n>]+>\n/).replace(/table/g, / {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex();
2765
+ var K = /^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table|[ \t]+\n)[^\n]+)*)/;
2766
+ var _e = /^[^\n]+/;
2767
+ var W = /(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/;
2768
+ var $e = k(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label", W).replace("title", /(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex();
2769
+ var Le = k(/^(bull)([ \t][^\n]*?)?(?:\n|$)/).replace(/bull/g, U).getRegex();
2770
+ 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";
2771
+ var X = /<!--(?:-?>|[\s\S]*?(?:-->|$))/;
2772
+ var Me = k("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n*|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>[^\\n]*\\n*|$)|<![A-Z][\\s\\S]*?(?:>[^\\n]*\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>[^\\n]*\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))", "i").replace("comment", X).replace("tag", Q).replace("attribute", / +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex();
2773
+ var le = (l3) => k(K).replace("hr", q).replace("heading", " {0,3}#{1,6}(?:\\s|$)").replace("|lheading", "").replace("|table", "").replace("blockquote", " {0,3}>").replace("fences", " {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~~~)[^\\n]*\\n").replace("list", l3).replace("html", "</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag", Q).getRegex();
2774
+ var ze = le(/ {0,3}(?:[*+-]|1[.)])[ \t]+[^ \t\n]/);
2775
+ var Ee = le(/ {0,3}(?:[*+-]|\d{1,9}[.)])(?:[ \t]|\n|$)/);
2776
+ var Ce = k(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph", Ee).getRegex();
2777
+ var J = { blockquote: Ce, code: we, def: $e, fences: ye, heading: Pe, hr: q, html: Me, lheading: ae, list: Le, newline: Oe, paragraph: ze, table: z, text: _e };
2778
+ var se = k("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr", q).replace("heading", " {0,3}#{1,6}(?:\\s|$)").replace("blockquote", " {0,3}>").replace("code", "(?: {4}| {0,3} )[^\\n]").replace("fences", " {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~~~)[^\\n]*\\n").replace("list", " {0,3}(?:[*+-]|1[.)])[ \\t]").replace("html", "</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag", Q).getRegex();
2779
+ var Ae = { ...J, lheading: Se, table: se, paragraph: k(K).replace("hr", q).replace("heading", " {0,3}#{1,6}(?:\\s|$)").replace("|lheading", "").replace("table", se).replace("blockquote", " {0,3}>").replace("fences", " {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~~~)[^\\n]*\\n").replace("list", " {0,3}(?:[*+-]|1[.)])[ \\t]+[^ \\t\\n]").replace("html", "</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag", Q).getRegex() };
2780
+ var Ie = { ...J, html: k(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment", X).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: z, lheading: /^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/, paragraph: k(K).replace("hr", q).replace("heading", ` *#{1,6} *[^
2775
2781
  ]`).replace("lheading", ae).replace("|table", "").replace("blockquote", " {0,3}>").replace("|fences", "").replace("|list", "").replace("|html", "").replace("|tag", "").getRegex() };
2776
- var Ae = /^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/;
2777
- var Ce = /^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/;
2778
- var ue = /^( {2,}|\\)\n(?!\s*$)/;
2779
- var Be = /^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/;
2780
- var I = /[\p{P}\p{S}]/u;
2781
- var Z = /[\s\p{P}\p{S}]/u;
2782
- var X = /[^\s\p{P}\p{S}]/u;
2783
- var De = d(/^((?![*_])punctSpace)/, "u").replace(/punctSpace/g, Z).getRegex();
2784
- var pe = /(?!~)[\p{P}\p{S}]/u;
2785
- var qe = /(?!~)[\s\p{P}\p{S}]/u;
2786
- var ve = /(?:[^\s\p{P}\p{S}]|~)/u;
2787
- var He = d(/link|precode-code|html/, "g").replace("link", /\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("precode-", Te ? "(?<!`)()" : "(^^|[^`])").replace("code", /(?<b>`+)[^`]+\k<b>(?!`)/).replace("html", /<(?! )[^<>]*?>/).getRegex();
2782
+ var Be = /^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/;
2783
+ var De = /^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/;
2784
+ var pe = /^( {2,}|\\)\n(?!\s*$)/;
2785
+ var qe = /^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/;
2786
+ var _ = /[\p{P}\p{S}]/u;
2787
+ var I = /[\s\p{P}\p{S}]/u;
2788
+ var v = /[^\s\p{P}\p{S}]/u;
2789
+ var ve = k(/^((?![*_])punctSpace)/, "u").replace(/punctSpace/g, I).getRegex();
2790
+ var He = /[\p{Pi}\p{Ps}"']/u;
2791
+ var ue = /(?!~)[\p{P}\p{S}]/u;
2792
+ var Ze = /(?!~)[\s\p{P}\p{S}]/u;
2793
+ var Ge = /(?:[^\s\p{P}\p{S}]|~)/u;
2794
+ var Qe = k(/link|precode-code|html/, "g").replace("link", /\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("precode-", Te ? "(?<!`)()" : "(^^|[^`])").replace("code", /(?<b>`+)[^`]+\k<b>(?!`)/).replace("html", /<(?! )[^<>]*?>/).getRegex();
2788
2795
  var ce = /^(?:\*+(?:((?!\*)punct)|([^\s*]))?)|^_+(?:((?!_)punct)|([^\s_]))?/;
2789
- var Ze = d(ce, "u").replace(/punct/g, I).getRegex();
2790
- var Ge = d(ce, "u").replace(/punct/g, pe).getRegex();
2796
+ var Ne = k(ce, "u").replace(/punct/g, _).getRegex();
2797
+ var je = k(ce, "u").replace(/punct/g, ue).getRegex();
2798
+ var Fe = /^(?:\*+(?:((?!\*)(?!openQuote)punct)|([^\s*]))?)|^_+(?:((?!_)(?!openQuote)punct)|([^\s_]))?/;
2799
+ var Ue = k(Fe, "u").replace(/openQuote/g, He).replace(/punct/g, _).getRegex();
2791
2800
  var he = "^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)";
2792
- var Ne = d(he, "gu").replace(/notPunctSpace/g, X).replace(/punctSpace/g, Z).replace(/punct/g, I).getRegex();
2793
- var Qe = d(he, "gu").replace(/notPunctSpace/g, ve).replace(/punctSpace/g, qe).replace(/punct/g, pe).getRegex();
2794
- var je = d("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)", "gu").replace(/notPunctSpace/g, X).replace(/punctSpace/g, Z).replace(/punct/g, I).getRegex();
2795
- var Fe = d(/^~~?(?:((?!~)punct)|[^\s~])/, "u").replace(/punct/g, I).getRegex();
2796
- var Ue = "^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)";
2797
- var Ke = d(Ue, "gu").replace(/notPunctSpace/g, X).replace(/punctSpace/g, Z).replace(/punct/g, I).getRegex();
2798
- var We = d(/\\(punct)/, "gu").replace(/punct/g, I).getRegex();
2799
- var Xe = d(/^<(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();
2800
- var Je = d(K).replace("(?:-->|$)", "-->").getRegex();
2801
- var Ve = d("^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", Je).replace("attribute", /\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex();
2802
- var v = /(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\])|[^\[\]\\`])*?/;
2803
- var Ye = d(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?\s*\)/).replace("label", v).replace("href", /<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title", /"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex();
2804
- var ke = d(/^!?\[(label)\]\[(ref)\]/).replace("label", v).replace("ref", U).getRegex();
2805
- var de = d(/^!?\[(ref)\](?:\[\])?/).replace("ref", U).getRegex();
2806
- var et = d("reflink|nolink(?!\\()", "g").replace("reflink", ke).replace("nolink", de).getRegex();
2801
+ var Ke = k(he, "gu").replace(/notPunctSpace/g, v).replace(/punctSpace/g, I).replace(/punct/g, _).getRegex();
2802
+ var We = k(he, "gu").replace(/notPunctSpace/g, Ge).replace(/punctSpace/g, Ze).replace(/punct/g, ue).getRegex();
2803
+ var Xe = "^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)[\\s](\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|(?:(?!\\*)punct|notPunctSpace)(\\*+)(?!\\*)(?=notPunctSpace)";
2804
+ var Je = k(Xe, "gu").replace(/notPunctSpace/g, v).replace(/punctSpace/g, I).replace(/punct/g, _).getRegex();
2805
+ var Ve = k("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)", "gu").replace(/notPunctSpace/g, v).replace(/punctSpace/g, I).replace(/punct/g, _).getRegex();
2806
+ var Ye = "^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)[\\s](_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)|(?:(?!_)punct|notPunctSpace)(_+)(?!_)(?=notPunctSpace)";
2807
+ var et = k(Ye, "gu").replace(/notPunctSpace/g, v).replace(/punctSpace/g, I).replace(/punct/g, _).getRegex();
2808
+ var tt = k(/^~~?(?:((?!~)punct)|[^\s~])/, "u").replace(/punct/g, _).getRegex();
2809
+ var nt = "^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)";
2810
+ var rt = k(nt, "gu").replace(/notPunctSpace/g, v).replace(/punctSpace/g, I).replace(/punct/g, _).getRegex();
2811
+ var st = k(/\\(punct)/, "gu").replace(/punct/g, _).getRegex();
2812
+ var it = 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();
2813
+ var ot = k(X).replace("(?:-->|$)", "-->").getRegex();
2814
+ var at = 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", ot).replace("attribute", /\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex();
2815
+ var G = /(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\])|[^\[\]\\`])*?/;
2816
+ var lt = k(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?\s*\)/).replace("label", G).replace("href", /<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]+|(?=\))/).replace("title", /"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex();
2817
+ var de = k(/^!?\[(label)\]\[(ref)\]/).replace("label", G).replace("ref", W).getRegex();
2818
+ var ke = k(/^!?\[(ref)\](?:\[\])?/).replace("ref", W).getRegex();
2819
+ var pt = k("reflink|nolink(?!\\()", "g").replace("reflink", de).replace("nolink", ke).getRegex();
2807
2820
  var ie = /[hH][tT][tT][pP][sS]?|[fF][tT][pP]/;
2808
- var J = { _backpedal: _, anyPunctuation: We, autolink: Xe, blockSkip: He, br: ue, code: Ce, del: _, delLDelim: _, delRDelim: _, emStrongLDelim: Ze, emStrongRDelimAst: Ne, emStrongRDelimUnd: je, escape: Ae, link: Ye, nolink: de, punctuation: De, reflink: ke, reflinkSearch: et, tag: Ve, text: Be, url: _ };
2809
- var tt = { ...J, link: d(/^!?\[(label)\]\((.*?)\)/).replace("label", v).getRegex(), reflink: d(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label", v).getRegex() };
2810
- var Q = { ...J, emStrongRDelimAst: Qe, emStrongLDelim: Ge, delLDelim: Fe, delRDelim: Ke, url: d(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("protocol", ie).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: d(/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace("protocol", ie).getRegex() };
2811
- var nt = { ...Q, br: d(ue).replace("{2,}", "*").getRegex(), text: d(Q.text).replace("\\b_", "\\b_| {2,}\\n").replace(/\{2,\}/g, "*").getRegex() };
2812
- var D = { normal: W, gfm: Ee, pedantic: Ie };
2813
- var A = { normal: J, gfm: Q, breaks: nt, pedantic: tt };
2814
- var rt = { "&": "&amp;", "<": "&lt;", ">": "&gt;", '"': "&quot;", "'": "&#39;" };
2815
- var ge = (l3) => rt[l3];
2821
+ var V = { _backpedal: z, anyPunctuation: st, autolink: it, blockSkip: Qe, br: pe, code: De, del: z, delLDelim: z, delRDelim: z, emStrongLDelim: Ne, emStrongRDelimAst: Ke, emStrongRDelimUnd: Ve, escape: Be, link: lt, nolink: ke, punctuation: ve, reflink: de, reflinkSearch: pt, tag: at, text: qe, url: z };
2822
+ var ut = { ...V, emStrongLDelim: Ue, emStrongRDelimAst: Je, emStrongRDelimUnd: et, link: k(/^!?\[(label)\]\((.*?)\)/).replace("label", G).getRegex(), reflink: k(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label", G).getRegex() };
2823
+ var F = { ...V, emStrongRDelimAst: We, emStrongLDelim: je, delLDelim: tt, delRDelim: rt, url: k(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("protocol", ie).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", ie).getRegex() };
2824
+ var ct = { ...F, br: k(pe).replace("{2,}", "*").getRegex(), text: k(F.text).replace("\\b_", "\\b_| {2,}\\n").replace(/\{2,\}/g, "*").getRegex() };
2825
+ var H = { normal: J, gfm: Ae, pedantic: Ie };
2826
+ var B = { normal: V, gfm: F, breaks: ct, pedantic: ut };
2827
+ var ht = { "&": "&amp;", "<": "&lt;", ">": "&gt;", '"': "&quot;", "'": "&#39;" };
2828
+ var ge = (l3) => ht[l3];
2816
2829
  function O(l3, e) {
2817
2830
  if (e) {
2818
2831
  if (m.escapeTest.test(l3)) return l3.replace(m.escapeReplace, ge);
2819
2832
  } else if (m.escapeTestNoEncode.test(l3)) return l3.replace(m.escapeReplaceNoEncode, ge);
2820
2833
  return l3;
2821
2834
  }
2822
- function V(l3) {
2835
+ function Y(l3) {
2823
2836
  try {
2824
2837
  l3 = encodeURI(l3).replace(m.percentDecode, "%");
2825
2838
  } catch {
@@ -2827,11 +2840,11 @@ function V(l3) {
2827
2840
  }
2828
2841
  return l3;
2829
2842
  }
2830
- function Y(l3, e) {
2843
+ function ee(l3, e) {
2831
2844
  let t = l3.replace(m.findPipe, (r, i, o) => {
2832
- let u = false, a = i;
2833
- for (; --a >= 0 && o[a] === "\\"; ) u = !u;
2834
- return u ? "|" : " |";
2845
+ let p = false, a = i;
2846
+ for (; --a >= 0 && o[a] === "\\"; ) p = !p;
2847
+ return p ? "|" : " |";
2835
2848
  }), n = t.split(m.splitPipe), s = 0;
2836
2849
  if (n[0].trim() || n.shift(), n.length > 0 && !n.at(-1)?.trim() && n.pop(), e) if (n.length > e) n.splice(e);
2837
2850
  else for (; n.length < e; ) n.push("");
@@ -2850,7 +2863,7 @@ function $(l3, e, t) {
2850
2863
  }
2851
2864
  return l3.slice(0, n - s);
2852
2865
  }
2853
- function ee(l3) {
2866
+ function te(l3) {
2854
2867
  let e = l3.split(`
2855
2868
  `), t = e.length - 1;
2856
2869
  for (; t >= 0 && m.blankLine.test(e[t]); ) t--;
@@ -2876,10 +2889,10 @@ function me(l3, e = 0) {
2876
2889
  function xe(l3, e, t, n, s) {
2877
2890
  let r = e.href, i = e.title || null, o = l3[1].replace(s.other.outputLinkReplace, "$1");
2878
2891
  n.state.inLink = true;
2879
- let u = { type: l3[0].charAt(0) === "!" ? "image" : "link", raw: t, href: r, title: i, text: o, tokens: n.inlineTokens(o) };
2880
- return n.state.inLink = false, u;
2892
+ let p = { type: l3[0].charAt(0) === "!" ? "image" : "link", raw: t, href: r, title: i, text: o, tokens: n.inlineTokens(o) };
2893
+ return n.state.inLink = false, p;
2881
2894
  }
2882
- function st(l3, e, t) {
2895
+ function dt(l3, e, t) {
2883
2896
  let n = l3.match(t.other.indentCodeCompensation);
2884
2897
  if (n === null) return e;
2885
2898
  let s = n[1];
@@ -2892,12 +2905,12 @@ function st(l3, e, t) {
2892
2905
  }).join(`
2893
2906
  `);
2894
2907
  }
2895
- var w = class {
2908
+ var y = class {
2896
2909
  options;
2897
2910
  rules;
2898
2911
  lexer;
2899
2912
  constructor(e) {
2900
- this.options = e || T;
2913
+ this.options = e || R;
2901
2914
  }
2902
2915
  space(e) {
2903
2916
  let t = this.rules.block.newline.exec(e);
@@ -2906,14 +2919,14 @@ var w = class {
2906
2919
  code(e) {
2907
2920
  let t = this.rules.block.code.exec(e);
2908
2921
  if (t) {
2909
- let n = this.options.pedantic ? t[0] : ee(t[0]), s = n.replace(this.rules.other.codeRemoveIndent, "");
2922
+ let n = this.options.pedantic ? t[0] : te(t[0]), s = n.replace(this.rules.other.codeRemoveIndent, "");
2910
2923
  return { type: "code", raw: n, codeBlockStyle: "indented", text: s };
2911
2924
  }
2912
2925
  }
2913
2926
  fences(e) {
2914
2927
  let t = this.rules.block.fences.exec(e);
2915
2928
  if (t) {
2916
- let n = t[0], s = st(n, t[3] || "", this.rules);
2929
+ let n = t[0], s = dt(n, t[3] || "", this.rules);
2917
2930
  return { type: "code", raw: n, lang: t[2] ? t[2].trim().replace(this.rules.inline.anyPunctuation, "$1") : t[2], text: s };
2918
2931
  }
2919
2932
  }
@@ -2941,32 +2954,33 @@ var w = class {
2941
2954
  `).split(`
2942
2955
  `), s = "", r = "", i = [];
2943
2956
  for (; n.length > 0; ) {
2944
- let o = false, u = [], a;
2945
- for (a = 0; a < n.length; a++) if (this.rules.other.blockquoteStart.test(n[a])) u.push(n[a]), o = true;
2946
- else if (!o) u.push(n[a]);
2957
+ let o = false, p = [], a;
2958
+ for (a = 0; a < n.length; a++) if (this.rules.other.blockquoteStart.test(n[a])) p.push(n[a]), o = true;
2959
+ else if (!o) p.push(n[a]);
2947
2960
  else break;
2948
2961
  n = n.slice(a);
2949
- let c = u.join(`
2950
- `), p = c.replace(this.rules.other.blockquoteSetextReplace, `
2962
+ let u = p.join(`
2963
+ `), c = u.replace(this.rules.other.blockquoteSetextReplace, `
2951
2964
  $1`).replace(this.rules.other.blockquoteSetextReplace2, "");
2952
2965
  s = s ? `${s}
2953
- ${c}` : c, r = r ? `${r}
2954
- ${p}` : p;
2955
- let k = this.lexer.state.top;
2956
- if (this.lexer.state.top = true, this.lexer.blockTokens(p, i, true), this.lexer.state.top = k, n.length === 0) break;
2957
- let h = i.at(-1);
2958
- if (h?.type === "code") break;
2959
- if (h?.type === "blockquote") {
2960
- let R = h, f = R.raw + `
2961
- ` + n.join(`
2962
- `), S = this.blockquote(f);
2963
- i[i.length - 1] = S, s = s.substring(0, s.length - R.raw.length) + S.raw, r = r.substring(0, r.length - R.text.length) + S.text;
2966
+ ${u}` : u, r = r ? `${r}
2967
+ ${c}` : c;
2968
+ let h = this.lexer.state.top;
2969
+ if (this.lexer.state.top = true, this.lexer.blockTokens(c, i, true), this.lexer.state.top = h, n.length === 0) break;
2970
+ let d = i.at(-1);
2971
+ if (d?.type === "code") break;
2972
+ if (d?.type === "blockquote") {
2973
+ let T = d, g = n.join(`
2974
+ `), w = T.raw + `
2975
+ ` + g.replace(this.rules.other.blockquoteSetextReplace2, ""), M = this.blockquote(w);
2976
+ i[i.length - 1] = M, s = `${s}
2977
+ ${g}`, r = r.substring(0, r.length - T.text.length) + M.text;
2964
2978
  break;
2965
- } else if (h?.type === "list") {
2966
- let R = h, f = R.raw + `
2979
+ } else if (d?.type === "list") {
2980
+ let T = d, g = T.raw + `
2967
2981
  ` + n.join(`
2968
- `), S = this.list(f);
2969
- i[i.length - 1] = S, s = s.substring(0, s.length - h.raw.length) + S.raw, r = r.substring(0, r.length - R.raw.length) + S.raw, n = f.substring(i.at(-1).raw.length).split(`
2982
+ `), w = this.list(g);
2983
+ i[i.length - 1] = w, s = s.substring(0, s.length - d.raw.length) + w.raw, r = r.substring(0, r.length - T.raw.length) + w.raw, n = g.substring(i.at(-1).raw.length).split(`
2970
2984
  `);
2971
2985
  continue;
2972
2986
  }
@@ -2981,59 +2995,59 @@ ${p}` : p;
2981
2995
  n = s ? `\\d{1,9}\\${n.slice(-1)}` : `\\${n}`, this.options.pedantic && (n = s ? n : "[*+-]");
2982
2996
  let i = this.rules.other.listItemRegex(n), o = false;
2983
2997
  for (; e; ) {
2984
- let a = false, c = "", p = "";
2998
+ let a = false, u = "", c = "";
2985
2999
  if (!(t = i.exec(e)) || this.rules.block.hr.test(e)) break;
2986
- c = t[0], e = e.substring(c.length);
2987
- let k = me(t[2].split(`
2988
- `, 1)[0], t[1].length), h = e.split(`
2989
- `, 1)[0], R = !k.trim(), f = 0;
2990
- if (this.options.pedantic ? (f = 2, p = k.trimStart()) : R ? f = t[1].length + 1 : (f = k.search(this.rules.other.nonSpaceChar), f = f > 4 ? 1 : f, p = k.slice(f), f += t[1].length), R && this.rules.other.blankLine.test(h) && (c += h + `
2991
- `, e = e.substring(h.length + 1), a = true), !a) {
2992
- let S = this.rules.other.nextBulletRegex(f), te = this.rules.other.hrRegex(f), ne = this.rules.other.fencesBeginRegex(f), re = this.rules.other.headingBeginRegex(f), be = this.rules.other.htmlBeginRegex(f), Re = this.rules.other.blockquoteBeginRegex(f);
3000
+ u = t[0], e = e.substring(u.length);
3001
+ let h = me(t[2].split(`
3002
+ `, 1)[0], t[1].length), d = e.split(`
3003
+ `, 1)[0], T = !h.trim(), g = 0;
3004
+ if (this.options.pedantic ? (g = 2, c = h.trimStart()) : T ? g = t[1].length + 1 : (g = h.search(this.rules.other.nonSpaceChar), g = g > 4 ? 1 : g, c = h.slice(g), g += t[1].length), T && this.rules.other.blankLine.test(d) && (u += d + `
3005
+ `, e = e.substring(d.length + 1), a = true), !a) {
3006
+ let w = this.rules.other.nextBulletRegex(g), M = this.rules.other.hrRegex(g), ne = this.rules.other.fencesBeginRegex(g), re = this.rules.other.headingBeginRegex(g), be = this.rules.other.htmlBeginRegex(g), Re = this.rules.other.blockquoteBeginRegex(g);
2993
3007
  for (; e; ) {
2994
- let G = e.split(`
2995
- `, 1)[0], C;
2996
- if (h = G, this.options.pedantic ? (h = h.replace(this.rules.other.listReplaceNesting, " "), C = h) : C = h.replace(this.rules.other.tabCharGlobal, " "), ne.test(h) || re.test(h) || be.test(h) || Re.test(h) || S.test(h) || te.test(h)) break;
2997
- if (C.search(this.rules.other.nonSpaceChar) >= f || !h.trim()) p += `
2998
- ` + C.slice(f);
3008
+ let N = e.split(`
3009
+ `, 1)[0], D;
3010
+ if (d = N, this.options.pedantic ? (d = d.replace(this.rules.other.listReplaceNesting, " "), D = d) : D = d.replace(this.rules.other.tabCharGlobal, " "), ne.test(d) || re.test(d) || be.test(d) || Re.test(d) || w.test(d) || M.test(d)) break;
3011
+ if (D.search(this.rules.other.nonSpaceChar) >= g || !d.trim()) c += `
3012
+ ` + D.slice(g);
2999
3013
  else {
3000
- if (R || k.replace(this.rules.other.tabCharGlobal, " ").search(this.rules.other.nonSpaceChar) >= 4 || ne.test(k) || re.test(k) || te.test(k)) break;
3001
- p += `
3002
- ` + h;
3014
+ if (T || h.replace(this.rules.other.tabCharGlobal, " ").search(this.rules.other.nonSpaceChar) >= 4 || ne.test(h) || re.test(h) || M.test(h)) break;
3015
+ c += `
3016
+ ` + d;
3003
3017
  }
3004
- R = !h.trim(), c += G + `
3005
- `, e = e.substring(G.length + 1), k = C.slice(f);
3018
+ T = !d.trim(), u += N + `
3019
+ `, e = e.substring(N.length + 1), h = D.slice(g);
3006
3020
  }
3007
3021
  }
3008
- r.loose || (o ? r.loose = true : this.rules.other.doubleBlankLine.test(c) && (o = true)), r.items.push({ type: "list_item", raw: c, task: !!this.options.gfm && this.rules.other.listIsTask.test(p), loose: false, text: p, tokens: [] }), r.raw += c;
3022
+ r.loose || (o ? r.loose = true : this.rules.other.doubleBlankLine.test(u) && (o = true)), r.items.push({ type: "list_item", raw: u, task: !!this.options.gfm && this.rules.other.listIsTask.test(c), loose: false, text: c, tokens: [] }), r.raw += u;
3009
3023
  }
3010
- let u = r.items.at(-1);
3011
- if (u) u.raw = u.raw.trimEnd(), u.text = u.text.trimEnd();
3024
+ let p = r.items.at(-1);
3025
+ if (p) p.raw = p.raw.trimEnd(), p.text = p.text.trimEnd();
3012
3026
  else return;
3013
3027
  r.raw = r.raw.trimEnd();
3014
3028
  for (let a of r.items) {
3015
3029
  this.lexer.state.top = false, a.tokens = this.lexer.blockTokens(a.text, []);
3016
- let c = a.tokens[0];
3017
- if (a.task && (c?.type === "text" || c?.type === "paragraph")) {
3018
- a.text = a.text.replace(this.rules.other.listReplaceTask, ""), c.raw = c.raw.replace(this.rules.other.listReplaceTask, ""), c.text = c.text.replace(this.rules.other.listReplaceTask, "");
3019
- for (let k = this.lexer.inlineQueue.length - 1; k >= 0; k--) if (this.rules.other.listIsTask.test(this.lexer.inlineQueue[k].src)) {
3020
- this.lexer.inlineQueue[k].src = this.lexer.inlineQueue[k].src.replace(this.rules.other.listReplaceTask, "");
3030
+ let u = a.tokens[0];
3031
+ if (a.task && (u?.type === "text" || u?.type === "paragraph")) {
3032
+ a.text = a.text.replace(this.rules.other.listReplaceTask, ""), u.raw = u.raw.replace(this.rules.other.listReplaceTask, ""), u.text = u.text.replace(this.rules.other.listReplaceTask, "");
3033
+ for (let h = this.lexer.inlineQueue.length - 1; h >= 0; h--) if (this.rules.other.listIsTask.test(this.lexer.inlineQueue[h].src)) {
3034
+ this.lexer.inlineQueue[h].src = this.lexer.inlineQueue[h].src.replace(this.rules.other.listReplaceTask, "");
3021
3035
  break;
3022
3036
  }
3023
- let p = this.rules.other.listTaskCheckbox.exec(a.raw);
3024
- if (p) {
3025
- let k = { type: "checkbox", raw: p[0] + " ", checked: p[0] !== "[ ]" };
3026
- a.checked = k.checked, r.loose ? a.tokens[0] && ["paragraph", "text"].includes(a.tokens[0].type) && "tokens" in a.tokens[0] && a.tokens[0].tokens ? (a.tokens[0].raw = k.raw + a.tokens[0].raw, a.tokens[0].text = k.raw + a.tokens[0].text, a.tokens[0].tokens.unshift(k)) : a.tokens.unshift({ type: "paragraph", raw: k.raw, text: k.raw, tokens: [k] }) : a.tokens.unshift(k);
3037
+ let c = this.rules.other.listTaskCheckbox.exec(a.raw);
3038
+ if (c) {
3039
+ let h = { type: "checkbox", raw: c[0] + " ", checked: c[0] !== "[ ]" };
3040
+ a.checked = h.checked, r.loose ? a.tokens[0] && ["paragraph", "text"].includes(a.tokens[0].type) && "tokens" in a.tokens[0] && a.tokens[0].tokens ? (a.tokens[0].raw = h.raw + a.tokens[0].raw, a.tokens[0].text = h.raw + a.tokens[0].text, a.tokens[0].tokens.unshift(h)) : a.tokens.unshift({ type: "paragraph", raw: h.raw, text: h.raw, tokens: [h] }) : a.tokens.unshift(h);
3027
3041
  }
3028
3042
  } else a.task && (a.task = false);
3029
3043
  if (!r.loose) {
3030
- let p = a.tokens.filter((h) => h.type === "space"), k = p.length > 0 && p.some((h) => this.rules.other.anyLine.test(h.raw));
3031
- r.loose = k;
3044
+ let c = a.tokens.filter((d) => d.type === "space"), h = c.length > 0 && c.some((d) => this.rules.other.anyLine.test(d.raw));
3045
+ r.loose = h;
3032
3046
  }
3033
3047
  }
3034
3048
  if (r.loose) for (let a of r.items) {
3035
3049
  a.loose = true;
3036
- for (let c of a.tokens) c.type === "text" && (c.type = "paragraph");
3050
+ for (let u of a.tokens) u.type === "text" && (u.type = "paragraph");
3037
3051
  }
3038
3052
  return r;
3039
3053
  }
@@ -3041,7 +3055,7 @@ ${p}` : p;
3041
3055
  html(e) {
3042
3056
  let t = this.rules.block.html.exec(e);
3043
3057
  if (t) {
3044
- let n = ee(t[0]);
3058
+ let n = te(t[0]);
3045
3059
  return { type: "html", block: true, raw: n, pre: t[1] === "pre" || t[1] === "script" || t[1] === "style", text: n };
3046
3060
  }
3047
3061
  }
@@ -3056,13 +3070,13 @@ ${p}` : p;
3056
3070
  table(e) {
3057
3071
  let t = this.rules.block.table.exec(e);
3058
3072
  if (!t || !this.rules.other.tableDelimiter.test(t[2])) return;
3059
- let n = Y(t[1]), s = t[2].replace(this.rules.other.tableAlignChars, "").split("|"), r = t[3]?.trim() ? t[3].replace(this.rules.other.tableRowBlankLine, "").split(`
3073
+ let n = ee(t[1]), s = t[2].replace(this.rules.other.tableAlignChars, "").split("|"), r = t[3]?.trim() ? t[3].replace(this.rules.other.tableRowBlankLine, "").split(`
3060
3074
  `) : [], i = { type: "table", raw: $(t[0], `
3061
3075
  `), header: [], align: [], rows: [] };
3062
3076
  if (n.length === s.length) {
3063
3077
  for (let o of s) this.rules.other.tableAlignRight.test(o) ? i.align.push("right") : this.rules.other.tableAlignCenter.test(o) ? i.align.push("center") : this.rules.other.tableAlignLeft.test(o) ? i.align.push("left") : i.align.push(null);
3064
3078
  for (let o = 0; o < n.length; o++) i.header.push({ text: n[o], tokens: this.lexer.inline(n[o]), header: true, align: i.align[o] });
3065
- for (let o of r) i.rows.push(Y(o, i.header.length).map((u, a) => ({ text: u, tokens: this.lexer.inline(u), header: false, align: i.align[a] })));
3079
+ for (let o of r) i.rows.push(ee(o, i.header.length).map((p, a) => ({ text: p, tokens: this.lexer.inline(p), header: false, align: i.align[a] })));
3066
3080
  return i;
3067
3081
  }
3068
3082
  }
@@ -3106,8 +3120,8 @@ ${p}` : p;
3106
3120
  let i = fe(t[2], "()");
3107
3121
  if (i === -2) return;
3108
3122
  if (i > -1) {
3109
- let u = (t[0].indexOf("!") === 0 ? 5 : 4) + t[1].length + i;
3110
- t[2] = t[2].substring(0, i), t[0] = t[0].substring(0, u).trim(), t[3] = "";
3123
+ let p = (t[0].indexOf("!") === 0 ? 5 : 4) + t[1].length + i;
3124
+ t[2] = t[2].substring(0, i), t[0] = t[0].substring(0, p).trim(), t[3] = "";
3111
3125
  }
3112
3126
  }
3113
3127
  let s = t[2], r = "";
@@ -3133,25 +3147,28 @@ ${p}` : p;
3133
3147
  let s = this.rules.inline.emStrongLDelim.exec(e);
3134
3148
  if (!s || !s[1] && !s[2] && !s[3] && !s[4] || s[4] && n.match(this.rules.other.unicodeAlphaNumeric)) return;
3135
3149
  if (!(s[1] || s[3] || "") || !n || this.rules.inline.punctuation.exec(n)) {
3136
- let i = [...s[0]].length - 1, o, u, a = i, c = 0, p = s[0][0] === "*" ? this.rules.inline.emStrongRDelimAst : this.rules.inline.emStrongRDelimUnd;
3137
- for (p.lastIndex = 0, t = t.slice(-1 * e.length + i); (s = p.exec(t)) !== null; ) {
3150
+ let i = [...s[0]].length - 1, o, p, a = i, u = 0, c = s[0][0], h = n === c, d = c === "*" ? this.rules.inline.emStrongRDelimAst : this.rules.inline.emStrongRDelimUnd;
3151
+ for (d.lastIndex = 0, t = t.slice(-1 * e.length + i); (s = d.exec(t)) !== null; ) {
3138
3152
  if (o = s[1] || s[2] || s[3] || s[4] || s[5] || s[6], !o) continue;
3139
- if (u = [...o].length, s[3] || s[4]) {
3140
- a += u;
3141
- continue;
3142
- } else if ((s[5] || s[6]) && i % 3 && !((i + u) % 3)) {
3143
- c += u;
3153
+ if (p = [...o].length, s[3] || s[4]) {
3154
+ a += p;
3144
3155
  continue;
3156
+ } else if (s[5] || s[6]) {
3157
+ if (i % 3 && !((i + p) % 3)) {
3158
+ u += p;
3159
+ continue;
3160
+ }
3161
+ if (h) break;
3145
3162
  }
3146
- if (a -= u, a > 0) continue;
3147
- u = Math.min(u, u + a + c);
3148
- let k = [...s[0]][0].length, h = e.slice(0, i + s.index + k + u);
3149
- if (Math.min(i, u) % 2) {
3150
- let f = h.slice(1, -1);
3151
- return { type: "em", raw: h, text: f, tokens: this.lexer.inlineTokens(f) };
3163
+ if (a -= p, a > 0) continue;
3164
+ p = Math.min(p, p + a + u);
3165
+ let T = [...s[0]][0].length, g = e.slice(0, i + s.index + T + p);
3166
+ if (Math.min(i, p) % 2) {
3167
+ let M = g.slice(1, -1);
3168
+ return { type: "em", raw: g, text: M, tokens: this.lexer.inlineTokens(M) };
3152
3169
  }
3153
- let R = h.slice(2, -2);
3154
- return { type: "strong", raw: h, text: R, tokens: this.lexer.inlineTokens(R) };
3170
+ let w = g.slice(2, -2);
3171
+ return { type: "strong", raw: g, text: w, tokens: this.lexer.inlineTokens(w) };
3155
3172
  }
3156
3173
  }
3157
3174
  }
@@ -3170,17 +3187,17 @@ ${p}` : p;
3170
3187
  let s = this.rules.inline.delLDelim.exec(e);
3171
3188
  if (!s) return;
3172
3189
  if (!(s[1] || "") || !n || this.rules.inline.punctuation.exec(n)) {
3173
- let i = [...s[0]].length - 1, o, u, a = i, c = this.rules.inline.delRDelim;
3174
- for (c.lastIndex = 0, t = t.slice(-1 * e.length + i); (s = c.exec(t)) !== null; ) {
3175
- if (o = s[1] || s[2] || s[3] || s[4] || s[5] || s[6], !o || (u = [...o].length, u !== i)) continue;
3190
+ let i = [...s[0]].length - 1, o, p, a = i, u = this.rules.inline.delRDelim;
3191
+ for (u.lastIndex = 0, t = t.slice(-1 * e.length + i); (s = u.exec(t)) !== null; ) {
3192
+ if (o = s[1] || s[2] || s[3] || s[4] || s[5] || s[6], !o || (p = [...o].length, p !== i)) continue;
3176
3193
  if (s[3] || s[4]) {
3177
- a += u;
3194
+ a += p;
3178
3195
  continue;
3179
3196
  }
3180
- if (a -= u, a > 0) continue;
3181
- u = Math.min(u, u + a);
3182
- let p = [...s[0]][0].length, k = e.slice(0, i + s.index + p + u), h = k.slice(i, -i);
3183
- return { type: "del", raw: k, text: h, tokens: this.lexer.inlineTokens(h) };
3197
+ if (a -= p, a > 0) continue;
3198
+ p = Math.min(p, p + a);
3199
+ let c = [...s[0]][0].length, h = e.slice(0, i + s.index + c + p), d = h.slice(i, -i);
3200
+ return { type: "del", raw: h, text: d, tokens: this.lexer.inlineTokens(d) };
3184
3201
  }
3185
3202
  }
3186
3203
  }
@@ -3221,12 +3238,12 @@ var x = class l {
3221
3238
  inlineQueue;
3222
3239
  tokenizer;
3223
3240
  constructor(e) {
3224
- 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 };
3225
- let t = { other: m, block: D.normal, inline: A.normal };
3226
- this.options.pedantic ? (t.block = D.pedantic, t.inline = A.pedantic) : this.options.gfm && (t.block = D.gfm, this.options.breaks ? t.inline = A.breaks : t.inline = A.gfm), this.tokenizer.rules = t;
3241
+ this.tokens = [], this.tokens.links = /* @__PURE__ */ Object.create(null), this.options = e || R, this.options.tokenizer = this.options.tokenizer || new y(), this.tokenizer = this.options.tokenizer, this.tokenizer.options = this.options, this.tokenizer.lexer = this, this.inlineQueue = [], this.state = { inLink: false, inRawBlock: false, top: true };
3242
+ let t = { other: m, block: H.normal, inline: B.normal };
3243
+ this.options.pedantic ? (t.block = H.pedantic, t.inline = B.pedantic) : this.options.gfm && (t.block = H.gfm, this.options.breaks ? t.inline = B.breaks : t.inline = B.gfm), this.tokenizer.rules = t;
3227
3244
  }
3228
3245
  static get rules() {
3229
- return { block: D, inline: A };
3246
+ return { block: H, inline: B };
3230
3247
  }
3231
3248
  static lex(e, t) {
3232
3249
  return new l(t).lex(e);
@@ -3313,9 +3330,9 @@ var x = class l {
3313
3330
  }
3314
3331
  let i = e;
3315
3332
  if (this.options.extensions?.startBlock) {
3316
- let o = 1 / 0, u = e.slice(1), a;
3317
- this.options.extensions.startBlock.forEach((c) => {
3318
- a = c.call({ lexer: this }, u), typeof a == "number" && a >= 0 && (o = Math.min(o, a));
3333
+ let o = 1 / 0, p = e.slice(1), a;
3334
+ this.options.extensions.startBlock.forEach((u) => {
3335
+ a = u.call({ lexer: this }, p), typeof a == "number" && a >= 0 && (o = Math.min(o, a));
3319
3336
  }), o < 1 / 0 && o >= 0 && (i = e.substring(0, o + 1));
3320
3337
  }
3321
3338
  if (this.state.top && (r = this.tokenizer.paragraph(i))) {
@@ -3347,78 +3364,78 @@ var x = class l {
3347
3364
  }
3348
3365
  inlineTokens(e, t = []) {
3349
3366
  this.tokenizer.lexer = this;
3350
- let n = e, s = null;
3367
+ let n = e;
3351
3368
  if (this.tokens.links) {
3352
- let a = Object.keys(this.tokens.links);
3353
- if (a.length > 0) for (; (s = this.tokenizer.rules.inline.reflinkSearch.exec(n)) !== null; ) a.includes(s[0].slice(s[0].lastIndexOf("[") + 1, -1)) && (n = n.slice(0, s.index) + "[" + "a".repeat(s[0].length - 2) + "]" + n.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex));
3354
- }
3355
- for (; (s = this.tokenizer.rules.inline.anyPunctuation.exec(n)) !== null; ) n = n.slice(0, s.index) + "++" + n.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);
3356
- let r;
3357
- for (; (s = this.tokenizer.rules.inline.blockSkip.exec(n)) !== null; ) r = s[2] ? s[2].length : 0, n = n.slice(0, s.index + r) + "[" + "a".repeat(s[0].length - r - 2) + "]" + n.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);
3358
- n = this.options.hooks?.emStrongMask?.call({ lexer: this }, n) ?? n;
3359
- let i = false, o = "", u = 1 / 0;
3369
+ let o = Object.keys(this.tokens.links);
3370
+ o.length > 0 && (n = n.replace(this.tokenizer.rules.inline.reflinkSearch, (p) => o.includes(p.slice(p.lastIndexOf("[") + 1, -1)) ? "[" + "a".repeat(p.length - 2) + "]" : p));
3371
+ }
3372
+ n = n.replace(this.tokenizer.rules.inline.anyPunctuation, "++"), n = n.replace(this.tokenizer.rules.inline.blockSkip, (o, p, a) => {
3373
+ let u = a ? a.length : 0;
3374
+ return o.slice(0, u) + "[" + "a".repeat(o.length - u - 2) + "]";
3375
+ }), n = this.options.hooks?.emStrongMask?.call({ lexer: this }, n) ?? n;
3376
+ let s = false, r = "", i = 1 / 0;
3360
3377
  for (; e; ) {
3361
- if (e.length < u) u = e.length;
3378
+ if (e.length < i) i = e.length;
3362
3379
  else {
3363
3380
  this.infiniteLoopError(e.charCodeAt(0));
3364
3381
  break;
3365
3382
  }
3366
- i || (o = ""), i = false;
3367
- let a;
3368
- if (this.options.extensions?.inline?.some((p) => (a = p.call({ lexer: this }, e, t)) ? (e = e.substring(a.raw.length), t.push(a), true) : false)) continue;
3369
- if (a = this.tokenizer.escape(e)) {
3370
- e = e.substring(a.raw.length), t.push(a);
3383
+ s || (r = ""), s = false;
3384
+ let o;
3385
+ if (this.options.extensions?.inline?.some((a) => (o = a.call({ lexer: this }, e, t)) ? (e = e.substring(o.raw.length), t.push(o), true) : false)) continue;
3386
+ if (o = this.tokenizer.escape(e)) {
3387
+ e = e.substring(o.raw.length), t.push(o);
3371
3388
  continue;
3372
3389
  }
3373
- if (a = this.tokenizer.tag(e)) {
3374
- e = e.substring(a.raw.length), t.push(a);
3390
+ if (o = this.tokenizer.tag(e)) {
3391
+ e = e.substring(o.raw.length), t.push(o);
3375
3392
  continue;
3376
3393
  }
3377
- if (a = this.tokenizer.link(e)) {
3378
- e = e.substring(a.raw.length), t.push(a);
3394
+ if (o = this.tokenizer.link(e)) {
3395
+ e = e.substring(o.raw.length), t.push(o);
3379
3396
  continue;
3380
3397
  }
3381
- if (a = this.tokenizer.reflink(e, this.tokens.links)) {
3382
- e = e.substring(a.raw.length);
3383
- let p = t.at(-1);
3384
- a.type === "text" && p?.type === "text" ? (p.raw += a.raw, p.text += a.text) : t.push(a);
3398
+ if (o = this.tokenizer.reflink(e, this.tokens.links)) {
3399
+ e = e.substring(o.raw.length);
3400
+ let a = t.at(-1);
3401
+ o.type === "text" && a?.type === "text" ? (a.raw += o.raw, a.text += o.text) : t.push(o);
3385
3402
  continue;
3386
3403
  }
3387
- if (a = this.tokenizer.emStrong(e, n, o)) {
3388
- e = e.substring(a.raw.length), t.push(a);
3404
+ if (o = this.tokenizer.emStrong(e, n, r)) {
3405
+ e = e.substring(o.raw.length), t.push(o);
3389
3406
  continue;
3390
3407
  }
3391
- if (a = this.tokenizer.codespan(e)) {
3392
- e = e.substring(a.raw.length), t.push(a);
3408
+ if (o = this.tokenizer.codespan(e)) {
3409
+ e = e.substring(o.raw.length), t.push(o);
3393
3410
  continue;
3394
3411
  }
3395
- if (a = this.tokenizer.br(e)) {
3396
- e = e.substring(a.raw.length), t.push(a);
3412
+ if (o = this.tokenizer.br(e)) {
3413
+ e = e.substring(o.raw.length), t.push(o);
3397
3414
  continue;
3398
3415
  }
3399
- if (a = this.tokenizer.del(e, n, o)) {
3400
- e = e.substring(a.raw.length), t.push(a);
3416
+ if (o = this.tokenizer.del(e, n, r)) {
3417
+ e = e.substring(o.raw.length), t.push(o);
3401
3418
  continue;
3402
3419
  }
3403
- if (a = this.tokenizer.autolink(e)) {
3404
- e = e.substring(a.raw.length), t.push(a);
3420
+ if (o = this.tokenizer.autolink(e)) {
3421
+ e = e.substring(o.raw.length), t.push(o);
3405
3422
  continue;
3406
3423
  }
3407
- if (!this.state.inLink && (a = this.tokenizer.url(e))) {
3408
- e = e.substring(a.raw.length), t.push(a);
3424
+ if (!this.state.inLink && (o = this.tokenizer.url(e))) {
3425
+ e = e.substring(o.raw.length), t.push(o);
3409
3426
  continue;
3410
3427
  }
3411
- let c = e;
3428
+ let p = e;
3412
3429
  if (this.options.extensions?.startInline) {
3413
- let p = 1 / 0, k = e.slice(1), h;
3414
- this.options.extensions.startInline.forEach((R) => {
3415
- h = R.call({ lexer: this }, k), typeof h == "number" && h >= 0 && (p = Math.min(p, h));
3416
- }), p < 1 / 0 && p >= 0 && (c = e.substring(0, p + 1));
3417
- }
3418
- if (a = this.tokenizer.inlineText(c)) {
3419
- e = e.substring(a.raw.length), a.raw.slice(-1) !== "_" && (o = a.raw.slice(-1)), i = true;
3420
- let p = t.at(-1);
3421
- p?.type === "text" ? (p.raw += a.raw, p.text += a.text) : t.push(a);
3430
+ let a = 1 / 0, u = e.slice(1), c;
3431
+ this.options.extensions.startInline.forEach((h) => {
3432
+ c = h.call({ lexer: this }, u), typeof c == "number" && c >= 0 && (a = Math.min(a, c));
3433
+ }), a < 1 / 0 && a >= 0 && (p = e.substring(0, a + 1));
3434
+ }
3435
+ if (o = this.tokenizer.inlineText(p)) {
3436
+ e = e.substring(o.raw.length), o.raw.slice(-1) !== "_" && (r = o.raw.slice(-1)), s = true;
3437
+ let a = t.at(-1);
3438
+ a?.type === "text" ? (a.raw += o.raw, a.text += o.text) : t.push(o);
3422
3439
  continue;
3423
3440
  }
3424
3441
  if (e) {
@@ -3434,11 +3451,11 @@ var x = class l {
3434
3451
  else throw new Error(t);
3435
3452
  }
3436
3453
  };
3437
- var y = class {
3454
+ var P = class {
3438
3455
  options;
3439
3456
  parser;
3440
3457
  constructor(e) {
3441
- this.options = e || T;
3458
+ this.options = e || R;
3442
3459
  }
3443
3460
  space(e) {
3444
3461
  return "";
@@ -3472,8 +3489,8 @@ ${this.parser.parse(e)}</blockquote>
3472
3489
  list(e) {
3473
3490
  let t = e.ordered, n = e.start, s = "";
3474
3491
  for (let o = 0; o < e.items.length; o++) {
3475
- let u = e.items[o];
3476
- s += this.listitem(u);
3492
+ let p = e.items[o];
3493
+ s += this.listitem(p);
3477
3494
  }
3478
3495
  let r = t ? "ol" : "ul", i = t && n !== 1 ? ' start="' + n + '"' : "";
3479
3496
  return "<" + r + i + `>
@@ -3534,7 +3551,7 @@ ${e}</tr>
3534
3551
  return `<del>${this.parser.parseInline(e)}</del>`;
3535
3552
  }
3536
3553
  link({ href: e, title: t, tokens: n }) {
3537
- let s = this.parser.parseInline(n), r = V(e);
3554
+ let s = this.parser.parseInline(n), r = Y(e);
3538
3555
  if (r === null) return s;
3539
3556
  e = r;
3540
3557
  let i = '<a href="' + e + '"';
@@ -3542,7 +3559,7 @@ ${e}</tr>
3542
3559
  }
3543
3560
  image({ href: e, title: t, text: n, tokens: s }) {
3544
3561
  s && (n = this.parser.parseInline(s, this.parser.textRenderer));
3545
- let r = V(e);
3562
+ let r = Y(e);
3546
3563
  if (r === null) return O(n);
3547
3564
  e = r;
3548
3565
  let i = `<img src="${e}" alt="${O(n)}"`;
@@ -3589,7 +3606,7 @@ var b = class l2 {
3589
3606
  renderer;
3590
3607
  textRenderer;
3591
3608
  constructor(e) {
3592
- 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 L();
3609
+ this.options = e || R, this.options.renderer = this.options.renderer || new P(), this.renderer = this.options.renderer, this.renderer.options = this.options, this.renderer.parser = this, this.textRenderer = new L();
3593
3610
  }
3594
3611
  static parse(e, t) {
3595
3612
  return new l2(t).parse(e);
@@ -3604,7 +3621,7 @@ var b = class l2 {
3604
3621
  let s = e[n];
3605
3622
  if (this.options.extensions?.renderers?.[s.type]) {
3606
3623
  let i = s, o = this.options.extensions.renderers[i.type].call({ parser: this }, i);
3607
- if (o !== false || !["space", "hr", "heading", "code", "table", "blockquote", "list", "html", "def", "paragraph", "text"].includes(i.type)) {
3624
+ if (o !== false || !["space", "hr", "heading", "code", "table", "blockquote", "list", "checkbox", "html", "def", "paragraph", "text"].includes(i.type)) {
3608
3625
  t += o || "";
3609
3626
  continue;
3610
3627
  }
@@ -3675,7 +3692,7 @@ var b = class l2 {
3675
3692
  let r = e[s];
3676
3693
  if (this.options.extensions?.renderers?.[r.type]) {
3677
3694
  let o = this.options.extensions.renderers[r.type].call({ parser: this }, r);
3678
- if (o !== false || !["escape", "html", "link", "image", "strong", "em", "codespan", "br", "del", "text"].includes(r.type)) {
3695
+ if (o !== false || !["escape", "html", "link", "image", "checkbox", "strong", "em", "codespan", "br", "del", "text"].includes(r.type)) {
3679
3696
  n += o || "";
3680
3697
  continue;
3681
3698
  }
@@ -3736,11 +3753,11 @@ var b = class l2 {
3736
3753
  return n;
3737
3754
  }
3738
3755
  };
3739
- var P = class {
3756
+ var S = class {
3740
3757
  options;
3741
3758
  block;
3742
3759
  constructor(e) {
3743
- this.options = e || T;
3760
+ this.options = e || R;
3744
3761
  }
3745
3762
  static passThroughHooks = /* @__PURE__ */ new Set(["preprocess", "postprocess", "processAllTokens", "emStrongMask"]);
3746
3763
  static passThroughHooksRespectAsync = /* @__PURE__ */ new Set(["preprocess", "postprocess", "processAllTokens"]);
@@ -3763,17 +3780,17 @@ var P = class {
3763
3780
  return e ? b.parse : b.parseInline;
3764
3781
  }
3765
3782
  };
3766
- var q = class {
3767
- defaults = M();
3783
+ var Z = class {
3784
+ defaults = C();
3768
3785
  options = this.setOptions;
3769
3786
  parse = this.parseMarkdown(true);
3770
3787
  parseInline = this.parseMarkdown(false);
3771
3788
  Parser = b;
3772
- Renderer = y;
3789
+ Renderer = P;
3773
3790
  TextRenderer = L;
3774
3791
  Lexer = x;
3775
- Tokenizer = w;
3776
- Hooks = P;
3792
+ Tokenizer = y;
3793
+ Hooks = S;
3777
3794
  constructor(...e) {
3778
3795
  this.use(...e);
3779
3796
  }
@@ -3810,8 +3827,8 @@ var q = class {
3810
3827
  if ("renderer" in r) {
3811
3828
  let i = t.renderers[r.name];
3812
3829
  i ? t.renderers[r.name] = function(...o) {
3813
- let u = r.renderer.apply(this, o);
3814
- return u === false && (u = i.apply(this, o)), u;
3830
+ let p = r.renderer.apply(this, o);
3831
+ return p === false && (p = i.apply(this, o)), p;
3815
3832
  } : t.renderers[r.name] = r.renderer;
3816
3833
  }
3817
3834
  if ("tokenizer" in r) {
@@ -3821,51 +3838,51 @@ var q = class {
3821
3838
  }
3822
3839
  "childTokens" in r && r.childTokens && (t.childTokens[r.name] = r.childTokens);
3823
3840
  }), s.extensions = t), n.renderer) {
3824
- let r = this.defaults.renderer || new y(this.defaults);
3841
+ let r = this.defaults.renderer || new P(this.defaults);
3825
3842
  for (let i in n.renderer) {
3826
3843
  if (!(i in r)) throw new Error(`renderer '${i}' does not exist`);
3827
3844
  if (["options", "parser"].includes(i)) continue;
3828
- let o = i, u = n.renderer[o], a = r[o];
3829
- r[o] = (...c) => {
3830
- let p = u.apply(r, c);
3831
- return p === false && (p = a.apply(r, c)), p || "";
3845
+ let o = i, p = n.renderer[o], a = r[o];
3846
+ r[o] = (...u) => {
3847
+ let c = p.apply(r, u);
3848
+ return c === false && (c = a.apply(r, u)), c || "";
3832
3849
  };
3833
3850
  }
3834
3851
  s.renderer = r;
3835
3852
  }
3836
3853
  if (n.tokenizer) {
3837
- let r = this.defaults.tokenizer || new w(this.defaults);
3854
+ let r = this.defaults.tokenizer || new y(this.defaults);
3838
3855
  for (let i in n.tokenizer) {
3839
3856
  if (!(i in r)) throw new Error(`tokenizer '${i}' does not exist`);
3840
3857
  if (["options", "rules", "lexer"].includes(i)) continue;
3841
- let o = i, u = n.tokenizer[o], a = r[o];
3842
- r[o] = (...c) => {
3843
- let p = u.apply(r, c);
3844
- return p === false && (p = a.apply(r, c)), p;
3858
+ let o = i, p = n.tokenizer[o], a = r[o];
3859
+ r[o] = (...u) => {
3860
+ let c = p.apply(r, u);
3861
+ return c === false && (c = a.apply(r, u)), c;
3845
3862
  };
3846
3863
  }
3847
3864
  s.tokenizer = r;
3848
3865
  }
3849
3866
  if (n.hooks) {
3850
- let r = this.defaults.hooks || new P();
3867
+ let r = this.defaults.hooks || new S();
3851
3868
  for (let i in n.hooks) {
3852
3869
  if (!(i in r)) throw new Error(`hook '${i}' does not exist`);
3853
3870
  if (["options", "block"].includes(i)) continue;
3854
- let o = i, u = n.hooks[o], a = r[o];
3855
- P.passThroughHooks.has(i) ? r[o] = (c) => {
3856
- if (this.defaults.async && P.passThroughHooksRespectAsync.has(i)) return (async () => {
3857
- let k = await u.call(r, c);
3858
- return a.call(r, k);
3871
+ let o = i, p = n.hooks[o], a = r[o];
3872
+ S.passThroughHooks.has(i) ? r[o] = (u) => {
3873
+ if (this.defaults.async && S.passThroughHooksRespectAsync.has(i)) return (async () => {
3874
+ let h = await p.call(r, u);
3875
+ return a.call(r, h);
3859
3876
  })();
3860
- let p = u.call(r, c);
3861
- return a.call(r, p);
3862
- } : r[o] = (...c) => {
3877
+ let c = p.call(r, u);
3878
+ return a.call(r, c);
3879
+ } : r[o] = (...u) => {
3863
3880
  if (this.defaults.async) return (async () => {
3864
- let k = await u.apply(r, c);
3865
- return k === false && (k = await a.apply(r, c)), k;
3881
+ let h = await p.apply(r, u);
3882
+ return h === false && (h = await a.apply(r, u)), h;
3866
3883
  })();
3867
- let p = u.apply(r, c);
3868
- return p === false && (p = a.apply(r, c)), p;
3884
+ let c = p.apply(r, u);
3885
+ return c === false && (c = a.apply(r, u)), c;
3869
3886
  };
3870
3887
  }
3871
3888
  s.hooks = r;
@@ -3873,8 +3890,8 @@ var q = class {
3873
3890
  if (n.walkTokens) {
3874
3891
  let r = this.defaults.walkTokens, i = n.walkTokens;
3875
3892
  s.walkTokens = function(o) {
3876
- let u = [];
3877
- return u.push(i.call(this, o)), r && (u = u.concat(r.call(this, o))), u;
3893
+ let p = [];
3894
+ return p.push(i.call(this, o)), r && (p = p.concat(r.call(this, o))), p;
3878
3895
  };
3879
3896
  }
3880
3897
  this.defaults = { ...this.defaults, ...s };
@@ -3896,19 +3913,19 @@ var q = class {
3896
3913
  if (typeof n > "u" || n === null) return o(new Error("marked(): input parameter is undefined or null"));
3897
3914
  if (typeof n != "string") return o(new Error("marked(): input parameter is of type " + Object.prototype.toString.call(n) + ", string expected"));
3898
3915
  if (i.hooks && (i.hooks.options = i, i.hooks.block = e), i.async) return (async () => {
3899
- let u = i.hooks ? await i.hooks.preprocess(n) : n, c = await (i.hooks ? await i.hooks.provideLexer(e) : e ? x.lex : x.lexInline)(u, i), p = i.hooks ? await i.hooks.processAllTokens(c) : c;
3900
- i.walkTokens && await Promise.all(this.walkTokens(p, i.walkTokens));
3901
- let h = await (i.hooks ? await i.hooks.provideParser(e) : e ? b.parse : b.parseInline)(p, i);
3902
- return i.hooks ? await i.hooks.postprocess(h) : h;
3916
+ let p = i.hooks ? await i.hooks.preprocess(n) : n, u = await (i.hooks ? await i.hooks.provideLexer(e) : e ? x.lex : x.lexInline)(p, i), c = i.hooks ? await i.hooks.processAllTokens(u) : u;
3917
+ i.walkTokens && await Promise.all(this.walkTokens(c, i.walkTokens));
3918
+ let d = await (i.hooks ? await i.hooks.provideParser(e) : e ? b.parse : b.parseInline)(c, i);
3919
+ return i.hooks ? await i.hooks.postprocess(d) : d;
3903
3920
  })().catch(o);
3904
3921
  try {
3905
3922
  i.hooks && (n = i.hooks.preprocess(n));
3906
3923
  let a = (i.hooks ? i.hooks.provideLexer(e) : e ? x.lex : x.lexInline)(n, i);
3907
3924
  i.hooks && (a = i.hooks.processAllTokens(a)), i.walkTokens && this.walkTokens(a, i.walkTokens);
3908
- let p = (i.hooks ? i.hooks.provideParser(e) : e ? b.parse : b.parseInline)(a, i);
3909
- return i.hooks && (p = i.hooks.postprocess(p)), p;
3910
- } catch (u) {
3911
- return o(u);
3925
+ let c = (i.hooks ? i.hooks.provideParser(e) : e ? b.parse : b.parseInline)(a, i);
3926
+ return i.hooks && (c = i.hooks.postprocess(c)), c;
3927
+ } catch (p) {
3928
+ return o(p);
3912
3929
  }
3913
3930
  };
3914
3931
  }
@@ -3924,41 +3941,41 @@ Please report this to https://github.com/markedjs/marked.`, e) {
3924
3941
  };
3925
3942
  }
3926
3943
  };
3927
- var z = new q();
3928
- function g(l3, e) {
3929
- return z.parse(l3, e);
3944
+ var E = new Z();
3945
+ function f(l3, e) {
3946
+ return E.parse(l3, e);
3930
3947
  }
3931
- g.options = g.setOptions = function(l3) {
3932
- return z.setOptions(l3), g.defaults = z.defaults, N(g.defaults), g;
3948
+ f.options = f.setOptions = function(l3) {
3949
+ return E.setOptions(l3), f.defaults = E.defaults, j(f.defaults), f;
3933
3950
  };
3934
- g.getDefaults = M;
3935
- g.defaults = T;
3936
- g.use = function(...l3) {
3937
- return z.use(...l3), g.defaults = z.defaults, N(g.defaults), g;
3951
+ f.getDefaults = C;
3952
+ f.defaults = R;
3953
+ function kt(...l3) {
3954
+ return E.use(...l3), f.defaults = E.defaults, j(f.defaults), f;
3955
+ }
3956
+ f.use = kt;
3957
+ f.walkTokens = function(l3, e) {
3958
+ return E.walkTokens(l3, e);
3938
3959
  };
3939
- g.walkTokens = function(l3, e) {
3940
- return z.walkTokens(l3, e);
3941
- };
3942
- g.parseInline = z.parseInline;
3943
- g.Parser = b;
3944
- g.parser = b.parse;
3945
- g.Renderer = y;
3946
- g.TextRenderer = L;
3947
- g.Lexer = x;
3948
- g.lexer = x.lex;
3949
- g.Tokenizer = w;
3950
- g.Hooks = P;
3951
- g.parse = g;
3952
- var Ft = g.options;
3953
- var Ut = g.setOptions;
3954
- var Kt = g.use;
3955
- var Wt = g.walkTokens;
3956
- var Xt = g.parseInline;
3957
- var Vt = b.parse;
3958
- var Yt = x.lex;
3960
+ f.parseInline = E.parseInline;
3961
+ f.Parser = b;
3962
+ f.parser = b.parse;
3963
+ f.Renderer = P;
3964
+ f.TextRenderer = L;
3965
+ f.Lexer = x;
3966
+ f.lexer = x.lex;
3967
+ f.Tokenizer = y;
3968
+ f.Hooks = S;
3969
+ f.parse = f;
3970
+ var nn = f.options;
3971
+ var rn = f.setOptions;
3972
+ var sn = f.walkTokens;
3973
+ var on = f.parseInline;
3974
+ var ln = b.parse;
3975
+ var pn = x.lex;
3959
3976
 
3960
3977
  // src/ui/render_markdown.ts
3961
- var parser = new q({ gfm: true, breaks: true });
3978
+ var parser = new Z({ gfm: true, breaks: true });
3962
3979
  var ALLOWED_TAGS = [
3963
3980
  "a",
3964
3981
  "p",
@@ -4222,6 +4239,7 @@ var STYLES = `
4222
4239
  --ag-ui-user-bg: #4f46e5;
4223
4240
  --ag-ui-user-fg: #ffffff;
4224
4241
  --ag-ui-assistant-bg: #f1f1f6;
4242
+ --ag-ui-hover: #e7e7ee;
4225
4243
  --ag-ui-input-bg: var(--ag-ui-bg);
4226
4244
  --ag-ui-tool-bg: var(--ag-ui-assistant-bg);
4227
4245
  --ag-ui-tool-fg: var(--ag-ui-accent);
@@ -4291,6 +4309,7 @@ var STYLES = `
4291
4309
  --ag-ui-bg: #15151f;
4292
4310
  --ag-ui-fg: #e8e8f2;
4293
4311
  --ag-ui-assistant-bg: #25253a;
4312
+ --ag-ui-hover: #303049;
4294
4313
  --ag-ui-header-bg: #1f1f30;
4295
4314
  --ag-ui-header-fg: #e8e8f2;
4296
4315
  --ag-ui-border: #33334a;
@@ -4303,6 +4322,7 @@ var STYLES = `
4303
4322
  --ag-ui-bg: #15151f;
4304
4323
  --ag-ui-fg: #e8e8f2;
4305
4324
  --ag-ui-assistant-bg: #25253a;
4325
+ --ag-ui-hover: #303049;
4306
4326
  --ag-ui-header-bg: #1f1f30;
4307
4327
  --ag-ui-header-fg: #e8e8f2;
4308
4328
  --ag-ui-border: #33334a;
@@ -4318,6 +4338,7 @@ var STYLES = `
4318
4338
  --ag-ui-accent: #3fb950;
4319
4339
  --ag-ui-user-bg: #238636;
4320
4340
  --ag-ui-assistant-bg: #161b22;
4341
+ --ag-ui-hover: #21262d;
4321
4342
  --ag-ui-header-bg: #010409;
4322
4343
  --ag-ui-header-fg: #c9d1d9;
4323
4344
  --ag-ui-border: #30363d;
@@ -4725,6 +4746,34 @@ var STYLES = `
4725
4746
  color: var(--ag-ui-muted);
4726
4747
  }
4727
4748
 
4749
+ /* Markdown tables. table/thead/tbody/tr/th/td are all in
4750
+ the sanitizer's ALLOWED_TAGS, so an agent emitting one renders it \u2014 and until
4751
+ now rendered it entirely unstyled, overflowing the bubble. A wide table
4752
+ scrolls inside its own box rather than stretching the message: the bubble is
4753
+ width-constrained, so without this the columns either crush or push the
4754
+ layout sideways. */
4755
+ .message--assistant table {
4756
+ display: block;
4757
+ width: fit-content;
4758
+ max-width: 100%;
4759
+ overflow-x: auto;
4760
+ border-collapse: collapse;
4761
+ font-size: 0.95em;
4762
+ }
4763
+
4764
+ .message--assistant th,
4765
+ .message--assistant td {
4766
+ padding: 6px 10px;
4767
+ border: 1px solid var(--ag-ui-border);
4768
+ text-align: left;
4769
+ vertical-align: top;
4770
+ }
4771
+
4772
+ .message--assistant th {
4773
+ background: var(--ag-ui-hover);
4774
+ font-weight: 600;
4775
+ }
4776
+
4728
4777
  .pending {
4729
4778
  align-self: flex-start;
4730
4779
  display: inline-flex;
@@ -5475,9 +5524,9 @@ var STYLES = `
5475
5524
  flex-direction: column;
5476
5525
  gap: 0.25rem;
5477
5526
  padding: 0.5rem;
5478
- border: 1px solid var(--agui-border, #d7d7dc);
5527
+ border: 1px solid var(--ag-ui-border);
5479
5528
  border-radius: 0.5rem;
5480
- background: var(--agui-surface, #fff);
5529
+ background: var(--ag-ui-assistant-bg);
5481
5530
  box-shadow: 0 6px 24px rgb(0 0 0 / 12%);
5482
5531
  max-height: 60%;
5483
5532
  overflow-y: auto;
@@ -5508,7 +5557,7 @@ var STYLES = `
5508
5557
  }
5509
5558
 
5510
5559
  .checkpoint-row:hover {
5511
- background: var(--agui-hover, #f3f3f5);
5560
+ background: var(--ag-ui-hover);
5512
5561
  }
5513
5562
 
5514
5563
  .checkpoint-label {
@@ -5523,7 +5572,7 @@ var STYLES = `
5523
5572
  font-size: 0.6875rem;
5524
5573
  padding: 0 0.375rem;
5525
5574
  border-radius: 999px;
5526
- background: var(--agui-hover, #f3f3f5);
5575
+ background: var(--ag-ui-hover);
5527
5576
  opacity: 0.8;
5528
5577
  }
5529
5578
 
@@ -5532,14 +5581,14 @@ var STYLES = `
5532
5581
  font-size: 0.75rem;
5533
5582
  cursor: pointer;
5534
5583
  padding: 0.125rem 0.5rem;
5535
- border: 1px solid var(--agui-border, #d7d7dc);
5584
+ border: 1px solid var(--ag-ui-border);
5536
5585
  border-radius: 0.375rem;
5537
5586
  background: transparent;
5538
5587
  color: inherit;
5539
5588
  }
5540
5589
 
5541
5590
  .checkpoint-action:hover {
5542
- background: var(--agui-hover, #f3f3f5);
5591
+ background: var(--ag-ui-hover);
5543
5592
  }
5544
5593
 
5545
5594
  .drawer-backdrop {
@@ -6780,7 +6829,7 @@ var RemoteConversationStore = class {
6780
6829
  return rows.filter((row) => !this.#dropped.has(row.thread_id)).map((row) => this.#toMeta(row));
6781
6830
  }
6782
6831
  async loadMessages(threadId) {
6783
- const response = await this.#get(this.#url + encodeURIComponent(threadId) + "/");
6832
+ const response = await this.#get(`${this.#url}${encodeURIComponent(threadId)}/`);
6784
6833
  if (response === null || !response.ok) {
6785
6834
  return this.#local.loadMessages(threadId);
6786
6835
  }
@@ -6832,7 +6881,7 @@ var RemoteConversationStore = class {
6832
6881
  async #mutate(threadId, method, body) {
6833
6882
  const headers = this.#headers();
6834
6883
  try {
6835
- await fetch(this.#url + encodeURIComponent(threadId) + "/", {
6884
+ await fetch(`${this.#url}${encodeURIComponent(threadId)}/`, {
6836
6885
  method,
6837
6886
  headers: body === void 0 ? headers : { ...headers, "content-type": "application/json" },
6838
6887
  body: body === void 0 ? null : JSON.stringify(body)
@@ -6990,6 +7039,21 @@ function errorMessage2(xhr) {
6990
7039
  }
6991
7040
 
6992
7041
  // src/core/ag_ui_chat.ts
7042
+ var CONNECT_TIME_ATTRIBUTES = [
7043
+ "data-attachments-url",
7044
+ "data-attachment-accept",
7045
+ "data-attachment-max-bytes",
7046
+ "data-transcribe-url",
7047
+ "data-threads-url",
7048
+ "data-tools-url",
7049
+ "data-skills-url",
7050
+ "data-skills",
7051
+ "data-prompt-chips",
7052
+ "data-slash-commands",
7053
+ "data-theme-toggle",
7054
+ "data-strings",
7055
+ "data-icon-url"
7056
+ ];
6993
7057
  var COLLAPSED_KEY = "ag-ui-chat:collapsed";
6994
7058
  var THEME_KEY = "ag-ui-chat:theme";
6995
7059
  var AgUiChat = class extends HTMLElement {
@@ -7189,6 +7253,8 @@ var AgUiChat = class extends HTMLElement {
7189
7253
  #voiceSlot;
7190
7254
  /** Voice-input control; created on connect when transcription is available. */
7191
7255
  #voice = null;
7256
+ /** Whether the element is currently in the DOM; gates the connect-time warning. */
7257
+ #connected = false;
7192
7258
  /** Refs attached to the message currently being sent (the context manifest). */
7193
7259
  #runAttachments = [];
7194
7260
  #client = null;
@@ -7200,6 +7266,10 @@ var AgUiChat = class extends HTMLElement {
7200
7266
  // the Send⇄Stop button: `agent.isRunning` is false between frontend-tool
7201
7267
  // rounds, but the user must still be able to stop there.
7202
7268
  #running = false;
7269
+ // The page the current round's context describes, captured when that context
7270
+ // was built. `null` until the first round. Compared in `#executeTool` to
7271
+ // catch a page that moved under a round still in flight.
7272
+ #contextHref = null;
7203
7273
  // Aborting this dismisses (declines) an open confirmation card when the run
7204
7274
  // is cancelled while the card awaits a decision. One controller per card.
7205
7275
  #confirmAbort = null;
@@ -7319,7 +7389,7 @@ var AgUiChat = class extends HTMLElement {
7319
7389
  agent,
7320
7390
  handlers: this.#handlers(),
7321
7391
  getTools: () => this.getTools(),
7322
- getContext: () => this.getContext(),
7392
+ getContext: () => this.#buildContext(),
7323
7393
  executeTool: (call) => this.#executeTool(call),
7324
7394
  resolveInterrupts: (interrupts) => this.#resolveInterrupts(interrupts),
7325
7395
  connectionLostMessage: this.#strings.connectionLost
@@ -7331,12 +7401,21 @@ var AgUiChat = class extends HTMLElement {
7331
7401
  const index = this.#runs();
7332
7402
  this.#checkpoints.setRuns(index === null ? [] : await index.continuable());
7333
7403
  }
7334
- /** Attributes whose late changes must reflect in already-rendered chrome. */
7404
+ /** Attributes the element reacts to after it has been connected. */
7335
7405
  static get observedAttributes() {
7336
- return ["title-text"];
7406
+ return ["title-text", ...CONNECT_TIME_ATTRIBUTES];
7337
7407
  }
7338
- attributeChangedCallback(_name, _previous, value) {
7339
- this.#title.textContent = value ?? this.#strings.title;
7408
+ attributeChangedCallback(name, previous, value) {
7409
+ if (name === "title-text") {
7410
+ this.#title.textContent = value ?? this.#strings.title;
7411
+ return;
7412
+ }
7413
+ if (previous === value || !this.#connected) {
7414
+ return;
7415
+ }
7416
+ console.warn(
7417
+ `<ag-ui-chat>: "${name}" was changed after the element connected, and is read only while connecting \u2014 this assignment has no effect. Set it before the element enters the DOM (in the markup, or on the element before appending it); frameworks that patch attributes after mount should bind it at creation. To apply a new value now, remove and re-insert the element.`
7418
+ );
7340
7419
  }
7341
7420
  /** Declare a frontend tool the agent may call. */
7342
7421
  registerTool(tool) {
@@ -7398,7 +7477,7 @@ var AgUiChat = class extends HTMLElement {
7398
7477
  }
7399
7478
  return [
7400
7479
  {
7401
- name: "read_page",
7480
+ name: READ_PAGE_TOOL,
7402
7481
  description: "Read the current page's structure (fields, buttons, route). Call after acting to observe the result within the same turn.",
7403
7482
  parameters: {
7404
7483
  type: "object",
@@ -7552,6 +7631,7 @@ var AgUiChat = class extends HTMLElement {
7552
7631
  this.#wireVoice();
7553
7632
  this.#threadId = this.conversationStore.threadId();
7554
7633
  void this.#rehydrate();
7634
+ this.#connected = true;
7555
7635
  }
7556
7636
  /**
7557
7637
  * Tear down live resources when the element leaves the DOM (a removed node, a
@@ -7562,6 +7642,7 @@ var AgUiChat = class extends HTMLElement {
7562
7642
  * `MediaRecorder`.
7563
7643
  */
7564
7644
  disconnectedCallback() {
7645
+ this.#connected = false;
7565
7646
  this.#cancelRun();
7566
7647
  this.#attachTray?.dispose();
7567
7648
  this.#voice?.dispose();
@@ -7595,12 +7676,18 @@ var AgUiChat = class extends HTMLElement {
7595
7676
  return;
7596
7677
  }
7597
7678
  const accept = this.getAttribute("data-attachment-accept") ?? "";
7598
- this.#attachTray = new AttachmentTray({
7679
+ const tray = new AttachmentTray({
7599
7680
  upload,
7600
7681
  maxBytes: this.#attachmentMaxBytes(),
7601
7682
  accept,
7602
- strings: this.#strings
7683
+ strings: this.#strings,
7684
+ // The tray's change hook, surfaced to the host as an event. A host
7685
+ // driving its own composer could otherwise not tell a settled upload from
7686
+ // one still in flight, which is the state sendMessage() has to be called
7687
+ // with knowledge of.
7688
+ onChange: () => this.#dispatchAttachments(tray)
7603
7689
  });
7690
+ this.#attachTray = tray;
7604
7691
  this.#attachSlot.appendChild(this.#attachTray.element);
7605
7692
  this.#fileInput.accept = accept;
7606
7693
  this.#attachButton.hidden = false;
@@ -7939,7 +8026,59 @@ Use the read_attachment tool with an id to read a file's contents.`
7939
8026
  const checkpoint = this.conversationStore.loadCheckpoint(this.#threadId);
7940
8027
  if (checkpoint !== null) {
7941
8028
  await this.#resumeFrom(checkpoint);
8029
+ return;
7942
8030
  }
8031
+ this.#noticeIfRunUnfinished(messages);
8032
+ }
8033
+ /**
8034
+ * Notice a previous run that never produced a response.
8035
+ *
8036
+ * {@link AgUiClient.send} persists the user's message *before* starting the
8037
+ * run, so a transcript whose last entry is that user message means nothing
8038
+ * ever came back: the page navigated or reloaded mid-run, the tab closed, or
8039
+ * the process died. No extra persistence is needed to detect it — the shape
8040
+ * of the transcript already says so, which is why this needs no
8041
+ * {@link ClientConversationStore} method and no `pagehide` listener (neither
8042
+ * of which fires on a crash or a force-quit anyway).
8043
+ *
8044
+ * The *agent*-initiated reload is not this case: a navigating tool leaves a
8045
+ * checkpoint and resumes, which is why the caller returns early on one before
8046
+ * reaching here.
8047
+ *
8048
+ * Deliberately a notice and never a resume. AG-UI has no
8049
+ * resume-an-aborted-run primitive; re-sending the accumulated messages is
8050
+ * semantically a **new** run, so any server-side tool the agent had already
8051
+ * executed before the interruption would run a second time. Saying plainly
8052
+ * that the answer was lost is the honest option, and the user can re-ask.
8053
+ */
8054
+ /**
8055
+ * Build a round's context, recording which page it describes.
8056
+ *
8057
+ * The AG-UI client re-invokes this at the top of **every** tool round, not
8058
+ * once per `send()`, so the page map the agent sees is already refreshed
8059
+ * between rounds and the href captured here is the page it was shown for
8060
+ * *this* round. {@link #executeTool} compares against it to catch a page that
8061
+ * moved under a round still in flight.
8062
+ */
8063
+ #buildContext() {
8064
+ this.#contextHref = window.location.href;
8065
+ return this.getContext();
8066
+ }
8067
+ /**
8068
+ * Whether the page moved since the current round's context was built.
8069
+ *
8070
+ * `null` means no round has built context yet (nothing to compare), which is
8071
+ * not a move.
8072
+ */
8073
+ #pageMoved() {
8074
+ return this.#contextHref !== null && this.#contextHref !== window.location.href;
8075
+ }
8076
+ #noticeIfRunUnfinished(messages) {
8077
+ const last = messages?.at(-1);
8078
+ if (last === void 0 || last.role !== MESSAGE_ROLE.USER) {
8079
+ return;
8080
+ }
8081
+ this.#appendNotice("\u26A0", this.#strings.runInterrupted, "interrupted");
7943
8082
  }
7944
8083
  /**
7945
8084
  * Replay a restored message: text bubbles *and* tool activity. An assistant
@@ -8273,12 +8412,46 @@ Use the read_attachment tool with an id to read a file's contents.`
8273
8412
  if (content === "" && attachments.length === 0) {
8274
8413
  return;
8275
8414
  }
8415
+ this.#input.value = "";
8416
+ if (this.#attachTray?.hasPending() === true) {
8417
+ this.#appendNotice(
8418
+ "\u{1F4CE}",
8419
+ this.#strings.attachmentsStillUploading.replace(
8420
+ "{n}",
8421
+ String(this.#attachTray.pendingCount())
8422
+ ),
8423
+ "attachment-pending"
8424
+ );
8425
+ }
8426
+ this.#attachTray?.clearReady();
8427
+ await this.sendMessage(content, attachments);
8428
+ }
8429
+ /**
8430
+ * Send a message as if the user had typed it — renders the user bubble,
8431
+ * dispatches {@link SUBMIT_EVENT}, and starts the run.
8432
+ *
8433
+ * The programmatic half of the composer, for a host driving its own input
8434
+ * (a "Ask about this order" button, a command palette, a custom composer
8435
+ * replacing the built-in one). Everything the built-in Send does happens
8436
+ * here; Send itself now reads the composer, clears it, and calls this.
8437
+ *
8438
+ * `attachments` are durable {@link AttachmentRef}s — the shape
8439
+ * {@link attachFile}'s upload resolves to, and the shape
8440
+ * {@link ATTACHMENT_EVENT} reports. Pass them to attach files to the message.
8441
+ *
8442
+ * No-ops while a run is in flight (a second concurrent run would orphan the
8443
+ * first) and for an entirely empty message. Unlike the built-in Send, this
8444
+ * does **not** consult the tray: what you pass is what is sent, so a host
8445
+ * composer stays in charge of its own state.
8446
+ */
8447
+ async sendMessage(content, attachments = []) {
8448
+ if (this.#running || content === "" && attachments.length === 0) {
8449
+ return;
8450
+ }
8276
8451
  const bubble = this.appendMessage(MESSAGE_ROLE.USER, content);
8277
8452
  if (attachments.length > 0) {
8278
8453
  bubble.appendChild(renderAttachmentChips(attachments));
8279
8454
  }
8280
- this.#input.value = "";
8281
- this.#attachTray?.clearReady();
8282
8455
  this.#runAttachments = attachments;
8283
8456
  this.dispatchEvent(
8284
8457
  new CustomEvent(SUBMIT_EVENT, {
@@ -8289,6 +8462,35 @@ Use the read_attachment tool with an id to read a file's contents.`
8289
8462
  );
8290
8463
  await this.#client_send(content, attachments);
8291
8464
  }
8465
+ /**
8466
+ * Queue a file for upload into the attachment tray, exactly as the file
8467
+ * picker and drag-and-drop do — validation, progress chip, and all.
8468
+ *
8469
+ * Returns `false` when uploads are not configured (no `data-attachments-url`
8470
+ * and no {@link uploadHandler}), which is the only way for a host to tell;
8471
+ * the tray does not exist to report anything in that case.
8472
+ *
8473
+ * Uploading is asynchronous: watch {@link ATTACHMENT_EVENT} for the resulting
8474
+ * {@link AttachmentRef}, and pass it to {@link sendMessage} once `pending`
8475
+ * reaches zero.
8476
+ */
8477
+ attachFile(file) {
8478
+ if (this.#attachTray === null) {
8479
+ return false;
8480
+ }
8481
+ this.#attachTray.add(file);
8482
+ return true;
8483
+ }
8484
+ /** Tell the host what the tray now holds — see {@link ATTACHMENT_EVENT}. */
8485
+ #dispatchAttachments(tray) {
8486
+ this.dispatchEvent(
8487
+ new CustomEvent(ATTACHMENT_EVENT, {
8488
+ detail: { attachments: tray.readyRefs(), pending: tray.pendingCount() },
8489
+ bubbles: true,
8490
+ composed: true
8491
+ })
8492
+ );
8493
+ }
8292
8494
  async #client_send(content, attachments) {
8293
8495
  if (this.endpoint === "") {
8294
8496
  return;
@@ -8312,7 +8514,7 @@ Use the read_attachment tool with an id to read a file's contents.`
8312
8514
  agent,
8313
8515
  handlers: this.#handlers(),
8314
8516
  getTools: () => this.getTools(),
8315
- getContext: () => this.getContext(),
8517
+ getContext: () => this.#buildContext(),
8316
8518
  executeTool: (call) => this.#executeTool(call),
8317
8519
  resolveInterrupts: (interrupts) => this.#resolveInterrupts(interrupts),
8318
8520
  onPersist: (messages) => this.conversationStore.saveMessages(this.#threadId, messages),
@@ -8356,6 +8558,12 @@ Use the read_attachment tool with an id to read a file's contents.`
8356
8558
  }
8357
8559
  return null;
8358
8560
  }
8561
+ if (this.getPageMap !== null && call.name !== READ_PAGE_TOOL && !isNavigates(tool.parameters) && this.#pageMoved()) {
8562
+ const message = this.#strings.pageMoved;
8563
+ card.settle(TOOL_CALL_STATUS.ERROR, message);
8564
+ this.#showPending();
8565
+ return { content: `Error: ${message}`, error: message };
8566
+ }
8359
8567
  if (await this.#needsConfirmation(call, tool)) {
8360
8568
  const request = { toolName: call.name, args: call.args };
8361
8569
  const confirmText = tool.parameters[X_CONFIRM_KEY];
@@ -8695,8 +8903,9 @@ function setControlValue(el, value) {
8695
8903
  }
8696
8904
 
8697
8905
  // src/version.ts
8698
- var VERSION = "0.15.0";
8906
+ var VERSION = "0.17.0";
8699
8907
  export {
8908
+ ATTACHMENT_EVENT,
8700
8909
  AgUiChat,
8701
8910
  AgUiClient,
8702
8911
  COMPACTION_ACTIVITY_TYPE,