import { i as ee } from "./monaco-importer.js";
import { StandaloneServices as W } from "monaco-editor/esm/vs/editor/standalone/browser/standaloneServices.js";
import { IStandaloneThemeService as G } from "monaco-editor/esm/vs/editor/standalone/common/standaloneTheme.js";
import { generateTokensCSSForColorMap as te } from "monaco-editor/esm/vs/editor/common/languages/supports/tokenization.js";
/*! All material copyright Esri, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/4.34/esri/copyright.txt for details.
v4.34.0-next.25 */
async function ne(l, t) {
  return await (await ee()).colorize(l, t, { tabSize: 2 });
}
async function ze(l, t) {
  if (!l)
    return;
  const n = Array.from(
    l.querySelectorAll("code.language-arcade, code.language-sql"),
    async (e) => await ie(e, e.textContent, t)
  );
  await Promise.all(n);
}
async function ie(l, t, n) {
  !l || l.tagName !== "CODE" || (l.innerHTML = await ne(t ?? "", n));
}
function Se() {
  const t = W.get(G).getColorTheme();
  return te(t.tokenTheme.getColorMap());
}
function Te(l) {
  return W.get(G).onDidColorThemeChange(() => l());
}
function M() {
  return {
    async: !1,
    baseUrl: null,
    breaks: !1,
    extensions: null,
    gfm: !0,
    headerIds: !0,
    headerPrefix: "",
    highlight: null,
    hooks: null,
    langPrefix: "language-",
    mangle: !0,
    pedantic: !1,
    renderer: null,
    sanitize: !1,
    sanitizer: null,
    silent: !1,
    smartypants: !1,
    tokenizer: null,
    walkTokens: null,
    xhtml: !1
  };
}
let A = M();
function V(l) {
  A = l;
}
const J = /[&<>"']/, se = new RegExp(J.source, "g"), K = /[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/, re = new RegExp(K.source, "g"), le = {
  "&": "&amp;",
  "<": "&lt;",
  ">": "&gt;",
  '"': "&quot;",
  "'": "&#39;"
}, Q = (l) => le[l];
function b(l, t) {
  if (t) {
    if (J.test(l))
      return l.replace(se, Q);
  } else if (K.test(l))
    return l.replace(re, Q);
  return l;
}
const ae = /&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig;
function Y(l) {
  return l.replace(ae, (t, n) => (n = n.toLowerCase(), n === "colon" ? ":" : n.charAt(0) === "#" ? n.charAt(1) === "x" ? String.fromCharCode(parseInt(n.substring(2), 16)) : String.fromCharCode(+n.substring(1)) : ""));
}
const oe = /(^|[^\[])\^/g;
function m(l, t) {
  l = typeof l == "string" ? l : l.source, t = t || "";
  const n = {
    replace: (e, i) => (i = i.source || i, i = i.replace(oe, "$1"), l = l.replace(e, i), n),
    getRegex: () => new RegExp(l, t)
  };
  return n;
}
const he = /[^\w:]/g, ce = /^$|^[a-z][a-z0-9+.-]*:|^[?#]/i;
function N(l, t, n) {
  if (l) {
    let e;
    try {
      e = decodeURIComponent(Y(n)).replace(he, "").toLowerCase();
    } catch {
      return null;
    }
    if (e.indexOf("javascript:") === 0 || e.indexOf("vbscript:") === 0 || e.indexOf("data:") === 0)
      return null;
  }
  t && !ce.test(n) && (n = ge(t, n));
  try {
    n = encodeURI(n).replace(/%25/g, "%");
  } catch {
    return null;
  }
  return n;
}
const L = {}, ue = /^[^:]+:\/*[^/]*$/, pe = /^([^:]+:)[\s\S]*$/, fe = /^([^:]+:\/*[^/]*)[\s\S]*$/;
function ge(l, t) {
  L[" " + l] || (ue.test(l) ? L[" " + l] = l + "/" : L[" " + l] = P(l, "/", !0)), l = L[" " + l];
  const n = l.indexOf(":") === -1;
  return t.substring(0, 2) === "//" ? n ? t : l.replace(pe, "$1") + t : t.charAt(0) === "/" ? n ? t : l.replace(fe, "$1") + t : l + t;
}
const D = { exec: function() {
} };
function H(l, t) {
  const n = l.replace(/\|/g, (s, r, a) => {
    let o = !1, p = r;
    for (; --p >= 0 && a[p] === "\\"; ) o = !o;
    return o ? "|" : " |";
  }), e = n.split(/ \|/);
  let i = 0;
  if (e[0].trim() || e.shift(), e.length > 0 && !e[e.length - 1].trim() && e.pop(), e.length > t)
    e.splice(t);
  else
    for (; e.length < t; ) e.push("");
  for (; i < e.length; i++)
    e[i] = e[i].trim().replace(/\\\|/g, "|");
  return e;
}
function P(l, t, n) {
  const e = l.length;
  if (e === 0)
    return "";
  let i = 0;
  for (; i < e; ) {
    const s = l.charAt(e - i - 1);
    if (s === t && !n)
      i++;
    else if (s !== t && n)
      i++;
    else
      break;
  }
  return l.slice(0, e - i);
}
function de(l, t) {
  if (l.indexOf(t[1]) === -1)
    return -1;
  const n = l.length;
  let e = 0, i = 0;
  for (; i < n; i++)
    if (l[i] === "\\")
      i++;
    else if (l[i] === t[0])
      e++;
    else if (l[i] === t[1] && (e--, e < 0))
      return i;
  return -1;
}
function ke(l, t) {
  !l || l.silent || (t && console.warn("marked(): callback is deprecated since version 5.0.0, should not be used and will be removed in the future. Read more here: https://marked.js.org/using_pro#async"), (l.sanitize || l.sanitizer) && console.warn("marked(): sanitize and sanitizer parameters are deprecated since version 0.7.0, should not be used and will be removed in the future. Read more here: https://marked.js.org/#/USING_ADVANCED.md#options"), (l.highlight || l.langPrefix !== "language-") && console.warn("marked(): highlight and langPrefix parameters are deprecated since version 5.0.0, should not be used and will be removed in the future. Instead use https://www.npmjs.com/package/marked-highlight."), l.mangle && console.warn("marked(): mangle parameter is enabled by default, but is deprecated since version 5.0.0, and will be removed in the future. To clear this warning, install https://www.npmjs.com/package/marked-mangle, or disable by setting `{mangle: false}`."), l.baseUrl && console.warn("marked(): baseUrl parameter is deprecated since version 5.0.0, should not be used and will be removed in the future. Instead use https://www.npmjs.com/package/marked-base-url."), l.smartypants && console.warn("marked(): smartypants parameter is deprecated since version 5.0.0, should not be used and will be removed in the future. Instead use https://www.npmjs.com/package/marked-smartypants."), l.xhtml && console.warn("marked(): xhtml parameter is deprecated since version 5.0.0, should not be used and will be removed in the future. Instead use https://www.npmjs.com/package/marked-xhtml."), (l.headerIds || l.headerPrefix) && console.warn("marked(): headerIds and headerPrefix parameters enabled by default, but are deprecated since version 5.0.0, and will be removed in the future. To clear this warning, install  https://www.npmjs.com/package/marked-gfm-heading-id, or disable by setting `{headerIds: false}`."));
}
function F(l, t, n, e) {
  const i = t.href, s = t.title ? b(t.title) : null, r = l[1].replace(/\\([\[\]])/g, "$1");
  if (l[0].charAt(0) !== "!") {
    e.state.inLink = !0;
    const a = {
      type: "link",
      raw: n,
      href: i,
      title: s,
      text: r,
      tokens: e.inlineTokens(r)
    };
    return e.state.inLink = !1, a;
  }
  return {
    type: "image",
    raw: n,
    href: i,
    title: s,
    text: b(r)
  };
}
function me(l, t) {
  const n = l.match(/^(\s+)(?:```)/);
  if (n === null)
    return t;
  const e = n[1];
  return t.split(`
`).map((i) => {
    const s = i.match(/^\s+/);
    if (s === null)
      return i;
    const [r] = s;
    return r.length >= e.length ? i.slice(e.length) : i;
  }).join(`
`);
}
class Z {
  constructor(t) {
    this.options = t || A;
  }
  space(t) {
    const n = this.rules.block.newline.exec(t);
    if (n && n[0].length > 0)
      return {
        type: "space",
        raw: n[0]
      };
  }
  code(t) {
    const n = this.rules.block.code.exec(t);
    if (n) {
      const e = n[0].replace(/^ {1,4}/gm, "");
      return {
        type: "code",
        raw: n[0],
        codeBlockStyle: "indented",
        text: this.options.pedantic ? e : P(e, `
`)
      };
    }
  }
  fences(t) {
    const n = this.rules.block.fences.exec(t);
    if (n) {
      const e = n[0], i = me(e, n[3] || "");
      return {
        type: "code",
        raw: e,
        lang: n[2] ? n[2].trim().replace(this.rules.inline._escapes, "$1") : n[2],
        text: i
      };
    }
  }
  heading(t) {
    const n = this.rules.block.heading.exec(t);
    if (n) {
      let e = n[2].trim();
      if (/#$/.test(e)) {
        const i = P(e, "#");
        (this.options.pedantic || !i || / $/.test(i)) && (e = i.trim());
      }
      return {
        type: "heading",
        raw: n[0],
        depth: n[1].length,
        text: e,
        tokens: this.lexer.inline(e)
      };
    }
  }
  hr(t) {
    const n = this.rules.block.hr.exec(t);
    if (n)
      return {
        type: "hr",
        raw: n[0]
      };
  }
  blockquote(t) {
    const n = this.rules.block.blockquote.exec(t);
    if (n) {
      const e = n[0].replace(/^ *>[ \t]?/gm, ""), i = this.lexer.state.top;
      this.lexer.state.top = !0;
      const s = this.lexer.blockTokens(e);
      return this.lexer.state.top = i, {
        type: "blockquote",
        raw: n[0],
        tokens: s,
        text: e
      };
    }
  }
  list(t) {
    let n = this.rules.block.list.exec(t);
    if (n) {
      let e, i, s, r, a, o, p, f, k, g, c, y, _ = n[1].trim();
      const I = _.length > 1, x = {
        type: "list",
        raw: "",
        ordered: I,
        start: I ? +_.slice(0, -1) : "",
        loose: !1,
        items: []
      };
      _ = I ? `\\d{1,9}\\${_.slice(-1)}` : `\\${_}`, this.options.pedantic && (_ = I ? _ : "[*+-]");
      const w = new RegExp(`^( {0,3}${_})((?:[	 ][^\\n]*)?(?:\\n|$))`);
      for (; t && (y = !1, !(!(n = w.exec(t)) || this.rules.block.hr.test(t))); ) {
        if (e = n[0], t = t.substring(e.length), f = n[2].split(`
`, 1)[0].replace(/^\t+/, (R) => " ".repeat(3 * R.length)), k = t.split(`
`, 1)[0], this.options.pedantic ? (r = 2, c = f.trimLeft()) : (r = n[2].search(/[^ ]/), r = r > 4 ? 1 : r, c = f.slice(r), r += n[1].length), o = !1, !f && /^ *$/.test(k) && (e += k + `
`, t = t.substring(k.length + 1), y = !0), !y) {
          const R = new RegExp(`^ {0,${Math.min(3, r - 1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ 	][^\\n]*)?(?:\\n|$))`), $ = new RegExp(`^ {0,${Math.min(3, r - 1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`), z = new RegExp(`^ {0,${Math.min(3, r - 1)}}(?:\`\`\`|~~~)`), E = new RegExp(`^ {0,${Math.min(3, r - 1)}}#`);
          for (; t && (g = t.split(`
`, 1)[0], k = g, this.options.pedantic && (k = k.replace(/^ {1,4}(?=( {4})*[^ ])/g, "  ")), !(z.test(k) || E.test(k) || R.test(k) || $.test(t))); ) {
            if (k.search(/[^ ]/) >= r || !k.trim())
              c += `
` + k.slice(r);
            else {
              if (o || f.search(/[^ ]/) >= 4 || z.test(f) || E.test(f) || $.test(f))
                break;
              c += `
` + k;
            }
            !o && !k.trim() && (o = !0), e += g + `
`, t = t.substring(g.length + 1), f = k.slice(r);
          }
        }
        x.loose || (p ? x.loose = !0 : /\n *\n *$/.test(e) && (p = !0)), this.options.gfm && (i = /^\[[ xX]\] /.exec(c), i && (s = i[0] !== "[ ] ", c = c.replace(/^\[[ xX]\] +/, ""))), x.items.push({
          type: "list_item",
          raw: e,
          task: !!i,
          checked: s,
          loose: !1,
          text: c
        }), x.raw += e;
      }
      x.items[x.items.length - 1].raw = e.trimRight(), x.items[x.items.length - 1].text = c.trimRight(), x.raw = x.raw.trimRight();
      const v = x.items.length;
      for (a = 0; a < v; a++)
        if (this.lexer.state.top = !1, x.items[a].tokens = this.lexer.blockTokens(x.items[a].text, []), !x.loose) {
          const R = x.items[a].tokens.filter((z) => z.type === "space"), $ = R.length > 0 && R.some((z) => /\n.*\n/.test(z.raw));
          x.loose = $;
        }
      if (x.loose)
        for (a = 0; a < v; a++)
          x.items[a].loose = !0;
      return x;
    }
  }
  html(t) {
    const n = this.rules.block.html.exec(t);
    if (n) {
      const e = {
        type: "html",
        block: !0,
        raw: n[0],
        pre: !this.options.sanitizer && (n[1] === "pre" || n[1] === "script" || n[1] === "style"),
        text: n[0]
      };
      if (this.options.sanitize) {
        const i = this.options.sanitizer ? this.options.sanitizer(n[0]) : b(n[0]);
        e.type = "paragraph", e.text = i, e.tokens = this.lexer.inline(i);
      }
      return e;
    }
  }
  def(t) {
    const n = this.rules.block.def.exec(t);
    if (n) {
      const e = n[1].toLowerCase().replace(/\s+/g, " "), i = n[2] ? n[2].replace(/^<(.*)>$/, "$1").replace(this.rules.inline._escapes, "$1") : "", s = n[3] ? n[3].substring(1, n[3].length - 1).replace(this.rules.inline._escapes, "$1") : n[3];
      return {
        type: "def",
        tag: e,
        raw: n[0],
        href: i,
        title: s
      };
    }
  }
  table(t) {
    const n = this.rules.block.table.exec(t);
    if (n) {
      const e = {
        type: "table",
        header: H(n[1]).map((i) => ({ text: i })),
        align: n[2].replace(/^ *|\| *$/g, "").split(/ *\| */),
        rows: n[3] && n[3].trim() ? n[3].replace(/\n[ \t]*$/, "").split(`
`) : []
      };
      if (e.header.length === e.align.length) {
        e.raw = n[0];
        let i = e.align.length, s, r, a, o;
        for (s = 0; s < i; s++)
          /^ *-+: *$/.test(e.align[s]) ? e.align[s] = "right" : /^ *:-+: *$/.test(e.align[s]) ? e.align[s] = "center" : /^ *:-+ *$/.test(e.align[s]) ? e.align[s] = "left" : e.align[s] = null;
        for (i = e.rows.length, s = 0; s < i; s++)
          e.rows[s] = H(e.rows[s], e.header.length).map((p) => ({ text: p }));
        for (i = e.header.length, r = 0; r < i; r++)
          e.header[r].tokens = this.lexer.inline(e.header[r].text);
        for (i = e.rows.length, r = 0; r < i; r++)
          for (o = e.rows[r], a = 0; a < o.length; a++)
            o[a].tokens = this.lexer.inline(o[a].text);
        return e;
      }
    }
  }
  lheading(t) {
    const n = this.rules.block.lheading.exec(t);
    if (n)
      return {
        type: "heading",
        raw: n[0],
        depth: n[2].charAt(0) === "=" ? 1 : 2,
        text: n[1],
        tokens: this.lexer.inline(n[1])
      };
  }
  paragraph(t) {
    const n = this.rules.block.paragraph.exec(t);
    if (n) {
      const e = n[1].charAt(n[1].length - 1) === `
` ? n[1].slice(0, -1) : n[1];
      return {
        type: "paragraph",
        raw: n[0],
        text: e,
        tokens: this.lexer.inline(e)
      };
    }
  }
  text(t) {
    const n = this.rules.block.text.exec(t);
    if (n)
      return {
        type: "text",
        raw: n[0],
        text: n[0],
        tokens: this.lexer.inline(n[0])
      };
  }
  escape(t) {
    const n = this.rules.inline.escape.exec(t);
    if (n)
      return {
        type: "escape",
        raw: n[0],
        text: b(n[1])
      };
  }
  tag(t) {
    const n = this.rules.inline.tag.exec(t);
    if (n)
      return !this.lexer.state.inLink && /^<a /i.test(n[0]) ? this.lexer.state.inLink = !0 : this.lexer.state.inLink && /^<\/a>/i.test(n[0]) && (this.lexer.state.inLink = !1), !this.lexer.state.inRawBlock && /^<(pre|code|kbd|script)(\s|>)/i.test(n[0]) ? this.lexer.state.inRawBlock = !0 : this.lexer.state.inRawBlock && /^<\/(pre|code|kbd|script)(\s|>)/i.test(n[0]) && (this.lexer.state.inRawBlock = !1), {
        type: this.options.sanitize ? "text" : "html",
        raw: n[0],
        inLink: this.lexer.state.inLink,
        inRawBlock: this.lexer.state.inRawBlock,
        block: !1,
        text: this.options.sanitize ? this.options.sanitizer ? this.options.sanitizer(n[0]) : b(n[0]) : n[0]
      };
  }
  link(t) {
    const n = this.rules.inline.link.exec(t);
    if (n) {
      const e = n[2].trim();
      if (!this.options.pedantic && /^</.test(e)) {
        if (!/>$/.test(e))
          return;
        const r = P(e.slice(0, -1), "\\");
        if ((e.length - r.length) % 2 === 0)
          return;
      } else {
        const r = de(n[2], "()");
        if (r > -1) {
          const o = (n[0].indexOf("!") === 0 ? 5 : 4) + n[1].length + r;
          n[2] = n[2].substring(0, r), n[0] = n[0].substring(0, o).trim(), n[3] = "";
        }
      }
      let i = n[2], s = "";
      if (this.options.pedantic) {
        const r = /^([^'"]*[^\s])\s+(['"])(.*)\2/.exec(i);
        r && (i = r[1], s = r[3]);
      } else
        s = n[3] ? n[3].slice(1, -1) : "";
      return i = i.trim(), /^</.test(i) && (this.options.pedantic && !/>$/.test(e) ? i = i.slice(1) : i = i.slice(1, -1)), F(n, {
        href: i && i.replace(this.rules.inline._escapes, "$1"),
        title: s && s.replace(this.rules.inline._escapes, "$1")
      }, n[0], this.lexer);
    }
  }
  reflink(t, n) {
    let e;
    if ((e = this.rules.inline.reflink.exec(t)) || (e = this.rules.inline.nolink.exec(t))) {
      let i = (e[2] || e[1]).replace(/\s+/g, " ");
      if (i = n[i.toLowerCase()], !i) {
        const s = e[0].charAt(0);
        return {
          type: "text",
          raw: s,
          text: s
        };
      }
      return F(e, i, e[0], this.lexer);
    }
  }
  emStrong(t, n, e = "") {
    let i = this.rules.inline.emStrong.lDelim.exec(t);
    if (!i || i[3] && e.match(/[\p{L}\p{N}]/u)) return;
    if (!(i[1] || i[2] || "") || !e || this.rules.inline.punctuation.exec(e)) {
      const r = i[0].length - 1;
      let a, o, p = r, f = 0;
      const k = i[0][0] === "*" ? this.rules.inline.emStrong.rDelimAst : this.rules.inline.emStrong.rDelimUnd;
      for (k.lastIndex = 0, n = n.slice(-1 * t.length + r); (i = k.exec(n)) != null; ) {
        if (a = i[1] || i[2] || i[3] || i[4] || i[5] || i[6], !a) continue;
        if (o = a.length, i[3] || i[4]) {
          p += o;
          continue;
        } else if ((i[5] || i[6]) && r % 3 && !((r + o) % 3)) {
          f += o;
          continue;
        }
        if (p -= o, p > 0) continue;
        o = Math.min(o, o + p + f);
        const g = t.slice(0, r + i.index + o + 1);
        if (Math.min(r, o) % 2) {
          const y = g.slice(1, -1);
          return {
            type: "em",
            raw: g,
            text: y,
            tokens: this.lexer.inlineTokens(y)
          };
        }
        const c = g.slice(2, -2);
        return {
          type: "strong",
          raw: g,
          text: c,
          tokens: this.lexer.inlineTokens(c)
        };
      }
    }
  }
  codespan(t) {
    const n = this.rules.inline.code.exec(t);
    if (n) {
      let e = n[2].replace(/\n/g, " ");
      const i = /[^ ]/.test(e), s = /^ /.test(e) && / $/.test(e);
      return i && s && (e = e.substring(1, e.length - 1)), e = b(e, !0), {
        type: "codespan",
        raw: n[0],
        text: e
      };
    }
  }
  br(t) {
    const n = this.rules.inline.br.exec(t);
    if (n)
      return {
        type: "br",
        raw: n[0]
      };
  }
  del(t) {
    const n = this.rules.inline.del.exec(t);
    if (n)
      return {
        type: "del",
        raw: n[0],
        text: n[2],
        tokens: this.lexer.inlineTokens(n[2])
      };
  }
  autolink(t, n) {
    const e = this.rules.inline.autolink.exec(t);
    if (e) {
      let i, s;
      return e[2] === "@" ? (i = b(this.options.mangle ? n(e[1]) : e[1]), s = "mailto:" + i) : (i = b(e[1]), s = i), {
        type: "link",
        raw: e[0],
        text: i,
        href: s,
        tokens: [
          {
            type: "text",
            raw: i,
            text: i
          }
        ]
      };
    }
  }
  url(t, n) {
    let e;
    if (e = this.rules.inline.url.exec(t)) {
      let i, s;
      if (e[2] === "@")
        i = b(this.options.mangle ? n(e[0]) : e[0]), s = "mailto:" + i;
      else {
        let r;
        do
          r = e[0], e[0] = this.rules.inline._backpedal.exec(e[0])[0];
        while (r !== e[0]);
        i = b(e[0]), e[1] === "www." ? s = "http://" + e[0] : s = e[0];
      }
      return {
        type: "link",
        raw: e[0],
        text: i,
        href: s,
        tokens: [
          {
            type: "text",
            raw: i,
            text: i
          }
        ]
      };
    }
  }
  inlineText(t, n) {
    const e = this.rules.inline.text.exec(t);
    if (e) {
      let i;
      return this.lexer.state.inRawBlock ? i = this.options.sanitize ? this.options.sanitizer ? this.options.sanitizer(e[0]) : b(e[0]) : e[0] : i = b(this.options.smartypants ? n(e[0]) : e[0]), {
        type: "text",
        raw: e[0],
        text: i
      };
    }
  }
}
const u = {
  newline: /^(?: *(?:\n|$))+/,
  code: /^( {4}[^\n]+(?:\n(?: *(?:\n|$))*)?)+/,
  fences: /^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,
  hr: /^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,
  heading: /^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,
  blockquote: /^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/,
  list: /^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/,
  html: "^ {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|$))",
  def: /^ {0,3}\[(label)\]: *(?:\n *)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n *)?| *\n *)(title))? *(?:\n+|$)/,
  table: D,
  lheading: /^((?:(?!^bull ).|\n(?!\n|bull ))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,
  // regex template, placeholders will be replaced according to different paragraph
  // interruption rules of commonmark and the original markdown spec:
  _paragraph: /^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,
  text: /^[^\n]+/
};
u._label = /(?!\s*\])(?:\\.|[^\[\]\\])+/;
u._title = /(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/;
u.def = m(u.def).replace("label", u._label).replace("title", u._title).getRegex();
u.bullet = /(?:[*+-]|\d{1,9}[.)])/;
u.listItemStart = m(/^( *)(bull) */).replace("bull", u.bullet).getRegex();
u.list = m(u.list).replace(/bull/g, u.bullet).replace("hr", "\\n+(?=\\1?(?:(?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$))").replace("def", "\\n+(?=" + u.def.source + ")").getRegex();
u._tag = "address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|section|source|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul";
u._comment = /<!--(?!-?>)[\s\S]*?(?:-->|$)/;
u.html = m(u.html, "i").replace("comment", u._comment).replace("tag", u._tag).replace("attribute", / +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex();
u.lheading = m(u.lheading).replace(/bull/g, u.bullet).getRegex();
u.paragraph = m(u._paragraph).replace("hr", u.hr).replace("heading", " {0,3}#{1,6} ").replace("|lheading", "").replace("|table", "").replace("blockquote", " {0,3}>").replace("fences", " {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list", " {0,3}(?:[*+-]|1[.)]) ").replace("html", "</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag", u._tag).getRegex();
u.blockquote = m(u.blockquote).replace("paragraph", u.paragraph).getRegex();
u.normal = { ...u };
u.gfm = {
  ...u.normal,
  table: "^ *([^\\n ].*\\|.*)\\n {0,3}(?:\\| *)?(:?-+:? *(?:\\| *:?-+:? *)*)(?:\\| *)?(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)"
  // Cells
};
u.gfm.table = m(u.gfm.table).replace("hr", u.hr).replace("heading", " {0,3}#{1,6} ").replace("blockquote", " {0,3}>").replace("code", " {4}[^\\n]").replace("fences", " {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list", " {0,3}(?:[*+-]|1[.)]) ").replace("html", "</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag", u._tag).getRegex();
u.gfm.paragraph = m(u._paragraph).replace("hr", u.hr).replace("heading", " {0,3}#{1,6} ").replace("|lheading", "").replace("table", u.gfm.table).replace("blockquote", " {0,3}>").replace("fences", " {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list", " {0,3}(?:[*+-]|1[.)]) ").replace("html", "</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag", u._tag).getRegex();
u.pedantic = {
  ...u.normal,
  html: m(
    `^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`
  ).replace("comment", u._comment).replace(/tag/g, "(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),
  def: /^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,
  heading: /^(#{1,6})(.*)(?:\n+|$)/,
  fences: D,
  // fences not supported
  lheading: /^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,
  paragraph: m(u.normal._paragraph).replace("hr", u.hr).replace("heading", ` *#{1,6} *[^
]`).replace("lheading", u.lheading).replace("blockquote", " {0,3}>").replace("|fences", "").replace("|list", "").replace("|html", "").getRegex()
};
const h = {
  escape: /^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,
  autolink: /^<(scheme:[^\s\x00-\x1f<>]*|email)>/,
  url: D,
  tag: "^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>",
  // CDATA section
  link: /^!?\[(label)\]\(\s*(href)(?:\s+(title))?\s*\)/,
  reflink: /^!?\[(label)\]\[(ref)\]/,
  nolink: /^!?\[(ref)\](?:\[\])?/,
  reflinkSearch: "reflink|nolink(?!\\()",
  emStrong: {
    lDelim: /^(?:\*+(?:((?!\*)[punct])|[^\s*]))|^_+(?:((?!_)[punct])|([^\s_]))/,
    //         (1) and (2) can only be a Right Delimiter. (3) and (4) can only be Left.  (5) and (6) can be either Left or Right.
    //         | Skip orphan inside strong      | Consume to delim | (1) #***              | (2) a***#, a***                    | (3) #***a, ***a                  | (4) ***#                 | (5) #***#                         | (6) a***a
    rDelimAst: /^[^_*]*?__[^_*]*?\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\*)[punct](\*+)(?=[\s]|$)|[^punct\s](\*+)(?!\*)(?=[punct\s]|$)|(?!\*)[punct\s](\*+)(?=[^punct\s])|[\s](\*+)(?!\*)(?=[punct])|(?!\*)[punct](\*+)(?!\*)(?=[punct])|[^punct\s](\*+)(?=[^punct\s])/,
    rDelimUnd: /^[^_*]*?\*\*[^_*]*?_[^_*]*?(?=\*\*)|[^_]+(?=[^_])|(?!_)[punct](_+)(?=[\s]|$)|[^punct\s](_+)(?!_)(?=[punct\s]|$)|(?!_)[punct\s](_+)(?=[^punct\s])|[\s](_+)(?!_)(?=[punct])|(?!_)[punct](_+)(?!_)(?=[punct])/
    // ^- Not allowed for _
  },
  code: /^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,
  br: /^( {2,}|\\)\n(?!\s*$)/,
  del: D,
  text: /^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,
  punctuation: /^((?![*_])[\spunctuation])/
};
h._punctuation = "\\p{P}$+<=>`^|~";
h.punctuation = m(h.punctuation, "u").replace(/punctuation/g, h._punctuation).getRegex();
h.blockSkip = /\[[^[\]]*?\]\([^\(\)]*?\)|`[^`]*?`|<[^<>]*?>/g;
h.anyPunctuation = /\\[punct]/g;
h._escapes = /\\([punct])/g;
h._comment = m(u._comment).replace("(?:-->|$)", "-->").getRegex();
h.emStrong.lDelim = m(h.emStrong.lDelim, "u").replace(/punct/g, h._punctuation).getRegex();
h.emStrong.rDelimAst = m(h.emStrong.rDelimAst, "gu").replace(/punct/g, h._punctuation).getRegex();
h.emStrong.rDelimUnd = m(h.emStrong.rDelimUnd, "gu").replace(/punct/g, h._punctuation).getRegex();
h.anyPunctuation = m(h.anyPunctuation, "gu").replace(/punct/g, h._punctuation).getRegex();
h._escapes = m(h._escapes, "gu").replace(/punct/g, h._punctuation).getRegex();
h._scheme = /[a-zA-Z][a-zA-Z0-9+.-]{1,31}/;
h._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])?)+(?![-_])/;
h.autolink = m(h.autolink).replace("scheme", h._scheme).replace("email", h._email).getRegex();
h._attribute = /\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/;
h.tag = m(h.tag).replace("comment", h._comment).replace("attribute", h._attribute).getRegex();
h._label = /(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/;
h._href = /<(?:\\.|[^\n<>\\])+>|[^\s\x00-\x1f]*/;
h._title = /"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/;
h.link = m(h.link).replace("label", h._label).replace("href", h._href).replace("title", h._title).getRegex();
h.reflink = m(h.reflink).replace("label", h._label).replace("ref", u._label).getRegex();
h.nolink = m(h.nolink).replace("ref", u._label).getRegex();
h.reflinkSearch = m(h.reflinkSearch, "g").replace("reflink", h.reflink).replace("nolink", h.nolink).getRegex();
h.normal = { ...h };
h.pedantic = {
  ...h.normal,
  strong: {
    start: /^__|\*\*/,
    middle: /^__(?=\S)([\s\S]*?\S)__(?!_)|^\*\*(?=\S)([\s\S]*?\S)\*\*(?!\*)/,
    endAst: /\*\*(?!\*)/g,
    endUnd: /__(?!_)/g
  },
  em: {
    start: /^_|\*/,
    middle: /^()\*(?=\S)([\s\S]*?\S)\*(?!\*)|^_(?=\S)([\s\S]*?\S)_(?!_)/,
    endAst: /\*(?!\*)/g,
    endUnd: /_(?!_)/g
  },
  link: m(/^!?\[(label)\]\((.*?)\)/).replace("label", h._label).getRegex(),
  reflink: m(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label", h._label).getRegex()
};
h.gfm = {
  ...h.normal,
  escape: m(h.escape).replace("])", "~|])").getRegex(),
  _extended_email: /[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/,
  url: /^((?:ftp|https?):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/,
  _backpedal: /(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,
  del: /^(~~?)(?=[^\s~])([\s\S]*?[^\s~])\1(?=[^~]|$)/,
  text: /^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|https?:\/\/|ftp:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/
};
h.gfm.url = m(h.gfm.url, "i").replace("email", h.gfm._extended_email).getRegex();
h.breaks = {
  ...h.gfm,
  br: m(h.br).replace("{2,}", "*").getRegex(),
  text: m(h.gfm.text).replace("\\b_", "\\b_| {2,}\\n").replace(/\{2,\}/g, "*").getRegex()
};
function xe(l) {
  return l.replace(/---/g, "—").replace(/--/g, "–").replace(/(^|[-\u2014/(\[{"\s])'/g, "$1‘").replace(/'/g, "’").replace(/(^|[-\u2014/(\[{\u2018\s])"/g, "$1“").replace(/"/g, "”").replace(/\.{3}/g, "…");
}
function X(l) {
  let t = "", n, e;
  const i = l.length;
  for (n = 0; n < i; n++)
    e = l.charCodeAt(n), Math.random() > 0.5 && (e = "x" + e.toString(16)), t += "&#" + e + ";";
  return t;
}
class S {
  constructor(t) {
    this.tokens = [], this.tokens.links = /* @__PURE__ */ Object.create(null), this.options = t || A, this.options.tokenizer = this.options.tokenizer || new Z(), this.tokenizer = this.options.tokenizer, this.tokenizer.options = this.options, this.tokenizer.lexer = this, this.inlineQueue = [], this.state = {
      inLink: !1,
      inRawBlock: !1,
      top: !0
    };
    const n = {
      block: u.normal,
      inline: h.normal
    };
    this.options.pedantic ? (n.block = u.pedantic, n.inline = h.pedantic) : this.options.gfm && (n.block = u.gfm, this.options.breaks ? n.inline = h.breaks : n.inline = h.gfm), this.tokenizer.rules = n;
  }
  /**
   * Expose Rules
   */
  static get rules() {
    return {
      block: u,
      inline: h
    };
  }
  /**
   * Static Lex Method
   */
  static lex(t, n) {
    return new S(n).lex(t);
  }
  /**
   * Static Lex Inline Method
   */
  static lexInline(t, n) {
    return new S(n).inlineTokens(t);
  }
  /**
   * Preprocessing
   */
  lex(t) {
    t = t.replace(/\r\n|\r/g, `
`), this.blockTokens(t, this.tokens);
    let n;
    for (; n = this.inlineQueue.shift(); )
      this.inlineTokens(n.src, n.tokens);
    return this.tokens;
  }
  /**
   * Lexing
   */
  blockTokens(t, n = []) {
    this.options.pedantic ? t = t.replace(/\t/g, "    ").replace(/^ +$/gm, "") : t = t.replace(/^( *)(\t+)/gm, (a, o, p) => o + "    ".repeat(p.length));
    let e, i, s, r;
    for (; t; )
      if (!(this.options.extensions && this.options.extensions.block && this.options.extensions.block.some((a) => (e = a.call({ lexer: this }, t, n)) ? (t = t.substring(e.raw.length), n.push(e), !0) : !1))) {
        if (e = this.tokenizer.space(t)) {
          t = t.substring(e.raw.length), e.raw.length === 1 && n.length > 0 ? n[n.length - 1].raw += `
` : n.push(e);
          continue;
        }
        if (e = this.tokenizer.code(t)) {
          t = t.substring(e.raw.length), i = n[n.length - 1], i && (i.type === "paragraph" || i.type === "text") ? (i.raw += `
` + e.raw, i.text += `
` + e.text, this.inlineQueue[this.inlineQueue.length - 1].src = i.text) : n.push(e);
          continue;
        }
        if (e = this.tokenizer.fences(t)) {
          t = t.substring(e.raw.length), n.push(e);
          continue;
        }
        if (e = this.tokenizer.heading(t)) {
          t = t.substring(e.raw.length), n.push(e);
          continue;
        }
        if (e = this.tokenizer.hr(t)) {
          t = t.substring(e.raw.length), n.push(e);
          continue;
        }
        if (e = this.tokenizer.blockquote(t)) {
          t = t.substring(e.raw.length), n.push(e);
          continue;
        }
        if (e = this.tokenizer.list(t)) {
          t = t.substring(e.raw.length), n.push(e);
          continue;
        }
        if (e = this.tokenizer.html(t)) {
          t = t.substring(e.raw.length), n.push(e);
          continue;
        }
        if (e = this.tokenizer.def(t)) {
          t = t.substring(e.raw.length), i = n[n.length - 1], i && (i.type === "paragraph" || i.type === "text") ? (i.raw += `
` + e.raw, i.text += `
` + e.raw, this.inlineQueue[this.inlineQueue.length - 1].src = i.text) : this.tokens.links[e.tag] || (this.tokens.links[e.tag] = {
            href: e.href,
            title: e.title
          });
          continue;
        }
        if (e = this.tokenizer.table(t)) {
          t = t.substring(e.raw.length), n.push(e);
          continue;
        }
        if (e = this.tokenizer.lheading(t)) {
          t = t.substring(e.raw.length), n.push(e);
          continue;
        }
        if (s = t, this.options.extensions && this.options.extensions.startBlock) {
          let a = 1 / 0;
          const o = t.slice(1);
          let p;
          this.options.extensions.startBlock.forEach(function(f) {
            p = f.call({ lexer: this }, o), typeof p == "number" && p >= 0 && (a = Math.min(a, p));
          }), a < 1 / 0 && a >= 0 && (s = t.substring(0, a + 1));
        }
        if (this.state.top && (e = this.tokenizer.paragraph(s))) {
          i = n[n.length - 1], r && i.type === "paragraph" ? (i.raw += `
` + e.raw, i.text += `
` + e.text, this.inlineQueue.pop(), this.inlineQueue[this.inlineQueue.length - 1].src = i.text) : n.push(e), r = s.length !== t.length, t = t.substring(e.raw.length);
          continue;
        }
        if (e = this.tokenizer.text(t)) {
          t = t.substring(e.raw.length), i = n[n.length - 1], i && i.type === "text" ? (i.raw += `
` + e.raw, i.text += `
` + e.text, this.inlineQueue.pop(), this.inlineQueue[this.inlineQueue.length - 1].src = i.text) : n.push(e);
          continue;
        }
        if (t) {
          const a = "Infinite loop on byte: " + t.charCodeAt(0);
          if (this.options.silent) {
            console.error(a);
            break;
          } else
            throw new Error(a);
        }
      }
    return this.state.top = !0, n;
  }
  inline(t, n = []) {
    return this.inlineQueue.push({ src: t, tokens: n }), n;
  }
  /**
   * Lexing/Compiling
   */
  inlineTokens(t, n = []) {
    let e, i, s, r = t, a, o, p;
    if (this.tokens.links) {
      const f = Object.keys(this.tokens.links);
      if (f.length > 0)
        for (; (a = this.tokenizer.rules.inline.reflinkSearch.exec(r)) != null; )
          f.includes(a[0].slice(a[0].lastIndexOf("[") + 1, -1)) && (r = r.slice(0, a.index) + "[" + "a".repeat(a[0].length - 2) + "]" + r.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex));
    }
    for (; (a = this.tokenizer.rules.inline.blockSkip.exec(r)) != null; )
      r = r.slice(0, a.index) + "[" + "a".repeat(a[0].length - 2) + "]" + r.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);
    for (; (a = this.tokenizer.rules.inline.anyPunctuation.exec(r)) != null; )
      r = r.slice(0, a.index) + "++" + r.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);
    for (; t; )
      if (o || (p = ""), o = !1, !(this.options.extensions && this.options.extensions.inline && this.options.extensions.inline.some((f) => (e = f.call({ lexer: this }, t, n)) ? (t = t.substring(e.raw.length), n.push(e), !0) : !1))) {
        if (e = this.tokenizer.escape(t)) {
          t = t.substring(e.raw.length), n.push(e);
          continue;
        }
        if (e = this.tokenizer.tag(t)) {
          t = t.substring(e.raw.length), i = n[n.length - 1], i && e.type === "text" && i.type === "text" ? (i.raw += e.raw, i.text += e.text) : n.push(e);
          continue;
        }
        if (e = this.tokenizer.link(t)) {
          t = t.substring(e.raw.length), n.push(e);
          continue;
        }
        if (e = this.tokenizer.reflink(t, this.tokens.links)) {
          t = t.substring(e.raw.length), i = n[n.length - 1], i && e.type === "text" && i.type === "text" ? (i.raw += e.raw, i.text += e.text) : n.push(e);
          continue;
        }
        if (e = this.tokenizer.emStrong(t, r, p)) {
          t = t.substring(e.raw.length), n.push(e);
          continue;
        }
        if (e = this.tokenizer.codespan(t)) {
          t = t.substring(e.raw.length), n.push(e);
          continue;
        }
        if (e = this.tokenizer.br(t)) {
          t = t.substring(e.raw.length), n.push(e);
          continue;
        }
        if (e = this.tokenizer.del(t)) {
          t = t.substring(e.raw.length), n.push(e);
          continue;
        }
        if (e = this.tokenizer.autolink(t, X)) {
          t = t.substring(e.raw.length), n.push(e);
          continue;
        }
        if (!this.state.inLink && (e = this.tokenizer.url(t, X))) {
          t = t.substring(e.raw.length), n.push(e);
          continue;
        }
        if (s = t, this.options.extensions && this.options.extensions.startInline) {
          let f = 1 / 0;
          const k = t.slice(1);
          let g;
          this.options.extensions.startInline.forEach(function(c) {
            g = c.call({ lexer: this }, k), typeof g == "number" && g >= 0 && (f = Math.min(f, g));
          }), f < 1 / 0 && f >= 0 && (s = t.substring(0, f + 1));
        }
        if (e = this.tokenizer.inlineText(s, xe)) {
          t = t.substring(e.raw.length), e.raw.slice(-1) !== "_" && (p = e.raw.slice(-1)), o = !0, i = n[n.length - 1], i && i.type === "text" ? (i.raw += e.raw, i.text += e.text) : n.push(e);
          continue;
        }
        if (t) {
          const f = "Infinite loop on byte: " + t.charCodeAt(0);
          if (this.options.silent) {
            console.error(f);
            break;
          } else
            throw new Error(f);
        }
      }
    return n;
  }
}
class B {
  constructor(t) {
    this.options = t || A;
  }
  code(t, n, e) {
    const i = (n || "").match(/\S*/)[0];
    if (this.options.highlight) {
      const s = this.options.highlight(t, i);
      s != null && s !== t && (e = !0, t = s);
    }
    return t = t.replace(/\n$/, "") + `
`, i ? '<pre><code class="' + this.options.langPrefix + b(i) + '">' + (e ? t : b(t, !0)) + `</code></pre>
` : "<pre><code>" + (e ? t : b(t, !0)) + `</code></pre>
`;
  }
  /**
   * @param {string} quote
   */
  blockquote(t) {
    return `<blockquote>
${t}</blockquote>
`;
  }
  html(t, n) {
    return t;
  }
  /**
   * @param {string} text
   * @param {string} level
   * @param {string} raw
   * @param {any} slugger
   */
  heading(t, n, e, i) {
    if (this.options.headerIds) {
      const s = this.options.headerPrefix + i.slug(e);
      return `<h${n} id="${s}">${t}</h${n}>
`;
    }
    return `<h${n}>${t}</h${n}>
`;
  }
  hr() {
    return this.options.xhtml ? `<hr/>
` : `<hr>
`;
  }
  list(t, n, e) {
    const i = n ? "ol" : "ul", s = n && e !== 1 ? ' start="' + e + '"' : "";
    return "<" + i + s + `>
` + t + "</" + i + `>
`;
  }
  /**
   * @param {string} text
   */
  listitem(t) {
    return `<li>${t}</li>
`;
  }
  checkbox(t) {
    return "<input " + (t ? 'checked="" ' : "") + 'disabled="" type="checkbox"' + (this.options.xhtml ? " /" : "") + "> ";
  }
  /**
   * @param {string} text
   */
  paragraph(t) {
    return `<p>${t}</p>
`;
  }
  /**
   * @param {string} header
   * @param {string} body
   */
  table(t, n) {
    return n && (n = `<tbody>${n}</tbody>`), `<table>
<thead>
` + t + `</thead>
` + n + `</table>
`;
  }
  /**
   * @param {string} content
   */
  tablerow(t) {
    return `<tr>
${t}</tr>
`;
  }
  tablecell(t, n) {
    const e = n.header ? "th" : "td";
    return (n.align ? `<${e} align="${n.align}">` : `<${e}>`) + t + `</${e}>
`;
  }
  /**
   * span level renderer
   * @param {string} text
   */
  strong(t) {
    return `<strong>${t}</strong>`;
  }
  /**
   * @param {string} text
   */
  em(t) {
    return `<em>${t}</em>`;
  }
  /**
   * @param {string} text
   */
  codespan(t) {
    return `<code>${t}</code>`;
  }
  br() {
    return this.options.xhtml ? "<br/>" : "<br>";
  }
  /**
   * @param {string} text
   */
  del(t) {
    return `<del>${t}</del>`;
  }
  /**
   * @param {string} href
   * @param {string} title
   * @param {string} text
   */
  link(t, n, e) {
    if (t = N(this.options.sanitize, this.options.baseUrl, t), t === null)
      return e;
    let i = '<a href="' + t + '"';
    return n && (i += ' title="' + n + '"'), i += ">" + e + "</a>", i;
  }
  /**
   * @param {string} href
   * @param {string} title
   * @param {string} text
   */
  image(t, n, e) {
    if (t = N(this.options.sanitize, this.options.baseUrl, t), t === null)
      return e;
    let i = `<img src="${t}" alt="${e}"`;
    return n && (i += ` title="${n}"`), i += this.options.xhtml ? "/>" : ">", i;
  }
  text(t) {
    return t;
  }
}
class O {
  // no need for block level renderers
  strong(t) {
    return t;
  }
  em(t) {
    return t;
  }
  codespan(t) {
    return t;
  }
  del(t) {
    return t;
  }
  html(t) {
    return t;
  }
  text(t) {
    return t;
  }
  link(t, n, e) {
    return "" + e;
  }
  image(t, n, e) {
    return "" + e;
  }
  br() {
    return "";
  }
}
class j {
  constructor() {
    this.seen = {};
  }
  /**
   * @param {string} value
   */
  serialize(t) {
    return t.toLowerCase().trim().replace(/<[!\/a-z].*?>/ig, "").replace(/[\u2000-\u206F\u2E00-\u2E7F\\'!"#$%&()*+,./:;<=>?@[\]^`{|}~]/g, "").replace(/\s/g, "-");
  }
  /**
   * Finds the next safe (unique) slug to use
   * @param {string} originalSlug
   * @param {boolean} isDryRun
   */
  getNextSafeSlug(t, n) {
    let e = t, i = 0;
    if (this.seen.hasOwnProperty(e)) {
      i = this.seen[t];
      do
        i++, e = t + "-" + i;
      while (this.seen.hasOwnProperty(e));
    }
    return n || (this.seen[t] = i, this.seen[e] = 0), e;
  }
  /**
   * Convert string to unique id
   * @param {object} [options]
   * @param {boolean} [options.dryrun] Generates the next unique slug without
   * updating the internal accumulator.
   */
  slug(t, n = {}) {
    const e = this.serialize(t);
    return this.getNextSafeSlug(e, n.dryrun);
  }
}
class T {
  constructor(t) {
    this.options = t || A, this.options.renderer = this.options.renderer || new B(), this.renderer = this.options.renderer, this.renderer.options = this.options, this.textRenderer = new O(), this.slugger = new j();
  }
  /**
   * Static Parse Method
   */
  static parse(t, n) {
    return new T(n).parse(t);
  }
  /**
   * Static Parse Inline Method
   */
  static parseInline(t, n) {
    return new T(n).parseInline(t);
  }
  /**
   * Parse Loop
   */
  parse(t, n = !0) {
    let e = "", i, s, r, a, o, p, f, k, g, c, y, _, I, x, w, v, R, $, z;
    const E = t.length;
    for (i = 0; i < E; i++) {
      if (c = t[i], this.options.extensions && this.options.extensions.renderers && this.options.extensions.renderers[c.type] && (z = this.options.extensions.renderers[c.type].call({ parser: this }, c), z !== !1 || !["space", "hr", "heading", "code", "table", "blockquote", "list", "html", "paragraph", "text"].includes(c.type))) {
        e += z || "";
        continue;
      }
      switch (c.type) {
        case "space":
          continue;
        case "hr": {
          e += this.renderer.hr();
          continue;
        }
        case "heading": {
          e += this.renderer.heading(
            this.parseInline(c.tokens),
            c.depth,
            Y(this.parseInline(c.tokens, this.textRenderer)),
            this.slugger
          );
          continue;
        }
        case "code": {
          e += this.renderer.code(
            c.text,
            c.lang,
            c.escaped
          );
          continue;
        }
        case "table": {
          for (k = "", f = "", a = c.header.length, s = 0; s < a; s++)
            f += this.renderer.tablecell(
              this.parseInline(c.header[s].tokens),
              { header: !0, align: c.align[s] }
            );
          for (k += this.renderer.tablerow(f), g = "", a = c.rows.length, s = 0; s < a; s++) {
            for (p = c.rows[s], f = "", o = p.length, r = 0; r < o; r++)
              f += this.renderer.tablecell(
                this.parseInline(p[r].tokens),
                { header: !1, align: c.align[r] }
              );
            g += this.renderer.tablerow(f);
          }
          e += this.renderer.table(k, g);
          continue;
        }
        case "blockquote": {
          g = this.parse(c.tokens), e += this.renderer.blockquote(g);
          continue;
        }
        case "list": {
          for (y = c.ordered, _ = c.start, I = c.loose, a = c.items.length, g = "", s = 0; s < a; s++)
            w = c.items[s], v = w.checked, R = w.task, x = "", w.task && ($ = this.renderer.checkbox(v), I ? w.tokens.length > 0 && w.tokens[0].type === "paragraph" ? (w.tokens[0].text = $ + " " + w.tokens[0].text, w.tokens[0].tokens && w.tokens[0].tokens.length > 0 && w.tokens[0].tokens[0].type === "text" && (w.tokens[0].tokens[0].text = $ + " " + w.tokens[0].tokens[0].text)) : w.tokens.unshift({
              type: "text",
              text: $
            }) : x += $), x += this.parse(w.tokens, I), g += this.renderer.listitem(x, R, v);
          e += this.renderer.list(g, y, _);
          continue;
        }
        case "html": {
          e += this.renderer.html(c.text, c.block);
          continue;
        }
        case "paragraph": {
          e += this.renderer.paragraph(this.parseInline(c.tokens));
          continue;
        }
        case "text": {
          for (g = c.tokens ? this.parseInline(c.tokens) : c.text; i + 1 < E && t[i + 1].type === "text"; )
            c = t[++i], g += `
` + (c.tokens ? this.parseInline(c.tokens) : c.text);
          e += n ? this.renderer.paragraph(g) : g;
          continue;
        }
        default: {
          const U = 'Token with "' + c.type + '" type was not found.';
          if (this.options.silent) {
            console.error(U);
            return;
          } else
            throw new Error(U);
        }
      }
    }
    return e;
  }
  /**
   * Parse Inline Tokens
   */
  parseInline(t, n) {
    n = n || this.renderer;
    let e = "", i, s, r;
    const a = t.length;
    for (i = 0; i < a; i++) {
      if (s = t[i], this.options.extensions && this.options.extensions.renderers && this.options.extensions.renderers[s.type] && (r = this.options.extensions.renderers[s.type].call({ parser: this }, s), r !== !1 || !["escape", "html", "link", "image", "strong", "em", "codespan", "br", "del", "text"].includes(s.type))) {
        e += r || "";
        continue;
      }
      switch (s.type) {
        case "escape": {
          e += n.text(s.text);
          break;
        }
        case "html": {
          e += n.html(s.text);
          break;
        }
        case "link": {
          e += n.link(s.href, s.title, this.parseInline(s.tokens, n));
          break;
        }
        case "image": {
          e += n.image(s.href, s.title, s.text);
          break;
        }
        case "strong": {
          e += n.strong(this.parseInline(s.tokens, n));
          break;
        }
        case "em": {
          e += n.em(this.parseInline(s.tokens, n));
          break;
        }
        case "codespan": {
          e += n.codespan(s.text);
          break;
        }
        case "br": {
          e += n.br();
          break;
        }
        case "del": {
          e += n.del(this.parseInline(s.tokens, n));
          break;
        }
        case "text": {
          e += n.text(s.text);
          break;
        }
        default: {
          const o = 'Token with "' + s.type + '" type was not found.';
          if (this.options.silent) {
            console.error(o);
            return;
          } else
            throw new Error(o);
        }
      }
    }
    return e;
  }
}
class q {
  constructor(t) {
    this.options = t || A;
  }
  static passThroughHooks = /* @__PURE__ */ new Set([
    "preprocess",
    "postprocess"
  ]);
  /**
   * Process markdown before marked
   */
  preprocess(t) {
    return t;
  }
  /**
   * Process HTML after marked is finished
   */
  postprocess(t) {
    return t;
  }
}
class we {
  defaults = M();
  options = this.setOptions;
  parse = this.#e(S.lex, T.parse);
  parseInline = this.#e(S.lexInline, T.parseInline);
  Parser = T;
  parser = T.parse;
  Renderer = B;
  TextRenderer = O;
  Lexer = S;
  lexer = S.lex;
  Tokenizer = Z;
  Slugger = j;
  Hooks = q;
  constructor(...t) {
    this.use(...t);
  }
  walkTokens(t, n) {
    let e = [];
    for (const i of t)
      switch (e = e.concat(n.call(this, i)), i.type) {
        case "table": {
          for (const s of i.header)
            e = e.concat(this.walkTokens(s.tokens, n));
          for (const s of i.rows)
            for (const r of s)
              e = e.concat(this.walkTokens(r.tokens, n));
          break;
        }
        case "list": {
          e = e.concat(this.walkTokens(i.items, n));
          break;
        }
        default:
          this.defaults.extensions && this.defaults.extensions.childTokens && this.defaults.extensions.childTokens[i.type] ? this.defaults.extensions.childTokens[i.type].forEach((s) => {
            e = e.concat(this.walkTokens(i[s], n));
          }) : i.tokens && (e = e.concat(this.walkTokens(i.tokens, n)));
      }
    return e;
  }
  use(...t) {
    const n = this.defaults.extensions || { renderers: {}, childTokens: {} };
    return t.forEach((e) => {
      const i = { ...e };
      if (i.async = this.defaults.async || i.async || !1, e.extensions && (e.extensions.forEach((s) => {
        if (!s.name)
          throw new Error("extension name required");
        if (s.renderer) {
          const r = n.renderers[s.name];
          r ? n.renderers[s.name] = function(...a) {
            let o = s.renderer.apply(this, a);
            return o === !1 && (o = r.apply(this, a)), o;
          } : n.renderers[s.name] = s.renderer;
        }
        if (s.tokenizer) {
          if (!s.level || s.level !== "block" && s.level !== "inline")
            throw new Error("extension level must be 'block' or 'inline'");
          n[s.level] ? n[s.level].unshift(s.tokenizer) : n[s.level] = [s.tokenizer], s.start && (s.level === "block" ? n.startBlock ? n.startBlock.push(s.start) : n.startBlock = [s.start] : s.level === "inline" && (n.startInline ? n.startInline.push(s.start) : n.startInline = [s.start]));
        }
        s.childTokens && (n.childTokens[s.name] = s.childTokens);
      }), i.extensions = n), e.renderer) {
        const s = this.defaults.renderer || new B(this.defaults);
        for (const r in e.renderer) {
          const a = s[r];
          s[r] = (...o) => {
            let p = e.renderer[r].apply(s, o);
            return p === !1 && (p = a.apply(s, o)), p;
          };
        }
        i.renderer = s;
      }
      if (e.tokenizer) {
        const s = this.defaults.tokenizer || new Z(this.defaults);
        for (const r in e.tokenizer) {
          const a = s[r];
          s[r] = (...o) => {
            let p = e.tokenizer[r].apply(s, o);
            return p === !1 && (p = a.apply(s, o)), p;
          };
        }
        i.tokenizer = s;
      }
      if (e.hooks) {
        const s = this.defaults.hooks || new q();
        for (const r in e.hooks) {
          const a = s[r];
          q.passThroughHooks.has(r) ? s[r] = (o) => {
            if (this.defaults.async)
              return Promise.resolve(e.hooks[r].call(s, o)).then((f) => a.call(s, f));
            const p = e.hooks[r].call(s, o);
            return a.call(s, p);
          } : s[r] = (...o) => {
            let p = e.hooks[r].apply(s, o);
            return p === !1 && (p = a.apply(s, o)), p;
          };
        }
        i.hooks = s;
      }
      if (e.walkTokens) {
        const s = this.defaults.walkTokens;
        i.walkTokens = function(r) {
          let a = [];
          return a.push(e.walkTokens.call(this, r)), s && (a = a.concat(s.call(this, r))), a;
        };
      }
      this.defaults = { ...this.defaults, ...i };
    }), this;
  }
  setOptions(t) {
    return this.defaults = { ...this.defaults, ...t }, this;
  }
  #e(t, n) {
    return (e, i, s) => {
      typeof i == "function" && (s = i, i = null);
      const r = { ...i };
      i = { ...this.defaults, ...r };
      const a = this.#t(i.silent, i.async, s);
      if (typeof e > "u" || e === null)
        return a(new Error("marked(): input parameter is undefined or null"));
      if (typeof e != "string")
        return a(new Error("marked(): input parameter is of type " + Object.prototype.toString.call(e) + ", string expected"));
      if (ke(i, s), i.hooks && (i.hooks.options = i), s) {
        const o = i.highlight;
        let p;
        try {
          i.hooks && (e = i.hooks.preprocess(e)), p = t(e, i);
        } catch (g) {
          return a(g);
        }
        const f = (g) => {
          let c;
          if (!g)
            try {
              i.walkTokens && this.walkTokens(p, i.walkTokens), c = n(p, i), i.hooks && (c = i.hooks.postprocess(c));
            } catch (y) {
              g = y;
            }
          return i.highlight = o, g ? a(g) : s(null, c);
        };
        if (!o || o.length < 3 || (delete i.highlight, !p.length)) return f();
        let k = 0;
        this.walkTokens(p, (g) => {
          g.type === "code" && (k++, setTimeout(() => {
            o(g.text, g.lang, (c, y) => {
              if (c)
                return f(c);
              y != null && y !== g.text && (g.text = y, g.escaped = !0), k--, k === 0 && f();
            });
          }, 0));
        }), k === 0 && f();
        return;
      }
      if (i.async)
        return Promise.resolve(i.hooks ? i.hooks.preprocess(e) : e).then((o) => t(o, i)).then((o) => i.walkTokens ? Promise.all(this.walkTokens(o, i.walkTokens)).then(() => o) : o).then((o) => n(o, i)).then((o) => i.hooks ? i.hooks.postprocess(o) : o).catch(a);
      try {
        i.hooks && (e = i.hooks.preprocess(e));
        const o = t(e, i);
        i.walkTokens && this.walkTokens(o, i.walkTokens);
        let p = n(o, i);
        return i.hooks && (p = i.hooks.postprocess(p)), p;
      } catch (o) {
        return a(o);
      }
    };
  }
  #t(t, n, e) {
    return (i) => {
      if (i.message += `
Please report this to https://github.com/markedjs/marked.`, t) {
        const s = "<p>An error occurred:</p><pre>" + b(i.message + "", !0) + "</pre>";
        if (n)
          return Promise.resolve(s);
        if (e) {
          e(null, s);
          return;
        }
        return s;
      }
      if (n)
        return Promise.reject(i);
      if (e) {
        e(i);
        return;
      }
      throw i;
    };
  }
}
const C = new we(A);
function d(l, t, n) {
  return C.parse(l, t, n);
}
d.options = d.setOptions = function(l) {
  return C.setOptions(l), d.defaults = C.defaults, V(d.defaults), d;
};
d.getDefaults = M;
d.defaults = A;
d.use = function(...l) {
  return C.use(...l), d.defaults = C.defaults, V(d.defaults), d;
};
d.walkTokens = function(l, t) {
  return C.walkTokens(l, t);
};
d.parseInline = C.parseInline;
d.Parser = T;
d.parser = T.parse;
d.Renderer = B;
d.TextRenderer = O;
d.Lexer = S;
d.lexer = S.lex;
d.Tokenizer = Z;
d.Slugger = j;
d.Hooks = q;
d.parse = d;
d.options;
d.setOptions;
d.use;
d.walkTokens;
d.parseInline;
T.parse;
S.lex;
d.use({
  gfm: !0,
  breaks: !0,
  async: !1,
  mangle: !1,
  headerIds: !1,
  renderer: {
    link(l, t, n) {
      return `<calcite-link href="${l}" title="${t ?? n}" target="Arcade Help">${n}</calcite-link>`;
    }
  }
});
function Re(l) {
  return l == null ? "" : d.parse(typeof l == "string" ? l : l.value);
}
export {
  ze as a,
  ie as b,
  Re as c,
  Se as g,
  Te as o
};
