import { u as C } from "./vendor/recharts.js";
import { t as fe } from "./isEmpty.js";
import { a as Tr, d as Ke, h as G, i as Lr, m as kr, r as Mr } from "./chunk-5PVQY5BW.js";
import { i as Ze, n as t, r as v } from "./chunk-AGHRB4JF.js";
import { F as X, G as Ar, H as Ir, J as Cr, M as Y, N as te, S as Fr, T as er, X as Rr, Y as Z, Z as $r, c as Or, f as rr, g as zr, h as Vr, l as ge, n as Pr, p as ae, r as Gr, t as Nr, w as Hr, x as ie, y as H, z as qr } from "./chunk-ICPOFSXX.js";
import { t as Br } from "./chunk-426QAEUC.js";
import { i as Ur, o as jr } from "./chunk-U2HBQHQK.js";
import { n as Xr } from "./chunk-336JU56O.js";
import { n as Yr, t as Qr } from "./chunk-XPW4576I.js";
var tr = "comm", ar = "rule", ir = "decl", Wr = "@import", Jr = "@namespace", Kr = "@keyframes", Zr = "@layer", nr = Math.abs, ce = String.fromCharCode;
function sr(e) {
  return e.trim();
}
function B(e, r, a) {
  return e.replace(r, a);
}
function et(e, r, a) {
  return e.indexOf(r, a);
}
function O(e, r) {
  return e.charCodeAt(r) | 0;
}
function z(e, r, a) {
  return e.slice(r, a);
}
function k(e) {
  return e.length;
}
function rt(e) {
  return e.length;
}
function q(e, r) {
  return r.push(e), e;
}
var W = 1, V = 1, or = 0, b = 0, p = 0, P = "";
function le(e, r, a, i, n, s, m, l) {
  return {
    value: e,
    root: r,
    parent: a,
    type: i,
    props: n,
    children: s,
    line: W,
    column: V,
    length: m,
    return: "",
    siblings: l
  };
}
function tt() {
  return p;
}
function at() {
  return p = b > 0 ? O(P, --b) : 0, V--, p === 10 && (V = 1, W--), p;
}
function _() {
  return p = b < or ? O(P, b++) : 0, V++, p === 10 && (V = 1, W++), p;
}
function F() {
  return O(P, b);
}
function U() {
  return b;
}
function J(e, r) {
  return z(P, e, r);
}
function N(e) {
  switch (e) {
    case 0:
    case 9:
    case 10:
    case 13:
    case 32:
      return 5;
    case 33:
    case 43:
    case 44:
    case 47:
    case 62:
    case 64:
    case 126:
    case 59:
    case 123:
    case 125:
      return 4;
    case 58:
      return 3;
    case 34:
    case 39:
    case 40:
    case 91:
      return 2;
    case 41:
    case 93:
      return 1;
  }
  return 0;
}
function it(e) {
  return W = V = 1, or = k(P = e), b = 0, [];
}
function nt(e) {
  return P = "", e;
}
function ee(e) {
  return sr(J(b - 1, ne(e === 91 ? e + 2 : e === 40 ? e + 1 : e)));
}
function st(e) {
  for (; (p = F()) && p < 33; ) _();
  return N(e) > 2 || N(p) > 3 ? "" : " ";
}
function ot(e, r) {
  for (; --r && _() && !(p < 48 || p > 102 || p > 57 && p < 65 || p > 70 && p < 97); ) ;
  return J(e, U() + (r < 6 && F() == 32 && _() == 32));
}
function ne(e) {
  for (; _(); ) switch (p) {
    case e:
      return b;
    case 34:
    case 39:
      e !== 34 && e !== 39 && ne(p);
      break;
    case 40:
      e === 41 && ne(e);
      break;
    case 92:
      _();
      break;
  }
  return b;
}
function dt(e, r) {
  for (; _() && e + p !== 57; ) if (e + p === 84 && F() === 47) break;
  return "/*" + J(r, b - 1) + "*" + ce(e === 47 ? e : _());
}
function ct(e) {
  for (; !N(F()); ) _();
  return J(e, b);
}
function lt(e) {
  return nt(j("", null, null, null, [""], e = it(e), 0, [0], e));
}
function j(e, r, a, i, n, s, m, l, c) {
  for (var f = 0, h = 0, o = m, w = 0, x = 0, D = 0, u = 1, M = 1, E = 1, g = 0, S = "", A = n, T = s, y = i, d = S; M; ) switch (D = g, g = _()) {
    case 40:
      if (D != 108 && O(d, o - 1) == 58) {
        et(d += B(ee(g), "&", "&\f"), "&\f", nr(f ? l[f - 1] : 0)) != -1 && (E = -1);
        break;
      }
    case 34:
    case 39:
    case 91:
      d += ee(g);
      break;
    case 9:
    case 10:
    case 13:
    case 32:
      d += st(D);
      break;
    case 92:
      d += ot(U() - 1, 7);
      continue;
    case 47:
      switch (F()) {
        case 42:
        case 47:
          q(mt(dt(_(), U()), r, a, c), c), (N(D || 1) == 5 || N(F() || 1) == 5) && k(d) && z(d, -1, void 0) !== " " && (d += " ");
          break;
        default:
          d += "/";
      }
      break;
    case 123 * u:
      l[f++] = k(d) * E;
    case 125 * u:
    case 59:
    case 0:
      switch (g) {
        case 0:
        case 125:
          M = 0;
        case 59 + h:
          E == -1 && (d = B(d, /\f/g, "")), x > 0 && (k(d) - o || u === 0 && D === 47) && q(x > 32 ? ve(d + ";", i, a, o - 1, c) : ve(B(d, " ", "") + ";", i, a, o - 2, c), c);
          break;
        case 59:
          d += ";";
        default:
          if (q(y = pe(d, r, a, f, h, n, l, S, A = [], T = [], o, s), s), g === 123) if (h === 0) j(d, r, y, y, A, s, o, l, T);
          else {
            switch (w) {
              case 99:
                if (O(d, 3) === 110) break;
              case 108:
                if (O(d, 2) === 97) break;
              default:
                h = 0;
              case 100:
              case 109:
              case 115:
            }
            h ? j(e, y, y, i && q(pe(e, y, y, 0, 0, n, l, S, n, A = [], o, T), T), n, T, o, l, i ? A : T) : j(d, y, y, y, [""], T, 0, l, T);
          }
      }
      f = h = x = 0, u = E = 1, S = d = "", o = m;
      break;
    case 58:
      o = 1 + k(d), x = D;
    default:
      if (u < 1) {
        if (g == 123) --u;
        else if (g == 125 && u++ == 0 && at() == 125) continue;
      }
      switch (d += ce(g), g * u) {
        case 38:
          E = h > 0 ? 1 : (d += "\f", -1);
          break;
        case 44:
          l[f++] = (k(d) - 1) * E, E = 1;
          break;
        case 64:
          F() === 45 && (d += ee(_())), w = F(), h = o = k(S = d += ct(U())), g++;
          break;
        case 45:
          D === 45 && k(d) == 2 && (u = 0);
      }
  }
  return s;
}
function pe(e, r, a, i, n, s, m, l, c, f, h, o) {
  for (var w = n - 1, x = n === 0 ? s : [""], D = rt(x), u = 0, M = 0, E = 0; u < i; ++u) for (var g = 0, S = z(e, w + 1, w = nr(M = m[u])), A = e; g < D; ++g) (A = sr(M > 0 ? x[g] + " " + S : B(S, /&\f/g, x[g]))) && (c[E++] = A);
  return le(e, r, a, n === 0 ? ar : l, c, f, h, o);
}
function mt(e, r, a, i) {
  return le(e, r, a, tr, ce(tt()), z(e, 2, -2), 0, i);
}
function ve(e, r, a, i, n) {
  return le(e, r, a, ir, z(e, 0, i), z(e, i + 1, -1), i, n);
}
function se(e, r) {
  for (var a = "", i = 0; i < e.length; i++) a += r(e[i], i, e, r) || "";
  return a;
}
function ut(e, r, a, i) {
  switch (e.type) {
    case Zr:
      if (e.children.length) break;
    case Wr:
    case Jr:
    case ir:
      return e.return = e.return || e.value;
    case tr:
      return "";
    case Kr:
      return e.return = e.value + "{" + se(e.children, i) + "}";
    case ar:
      if (!k(e.value = e.props.join(","))) return "";
  }
  return k(a = se(e.children, i)) ? e.return = e.value + "{" + a + "}" : "";
}
var he = "c4", ft = {
  id: he,
  detector: /* @__PURE__ */ t((e) => /^\s*C4Context|C4Container|C4Component|C4Dynamic|C4Deployment/.test(e), "detector"),
  loader: /* @__PURE__ */ t(async () => {
    const { diagram: e } = await import("./c4Diagram-AHTNJAMY.js");
    return {
      id: he,
      diagram: e
    };
  }, "loader")
}, we = "flowchart", gt = {
  id: we,
  detector: /* @__PURE__ */ t((e, r) => r?.flowchart?.defaultRenderer === "dagre-wrapper" || r?.flowchart?.defaultRenderer === "elk" ? !1 : /^\s*graph/.test(e), "detector"),
  loader: /* @__PURE__ */ t(async () => {
    const { diagram: e } = await import("./flowDiagram-DWJPFMVM.js");
    return {
      id: we,
      diagram: e
    };
  }, "loader")
}, ye = "flowchart-v2", pt = {
  id: ye,
  detector: /* @__PURE__ */ t((e, r) => r?.flowchart?.defaultRenderer === "dagre-d3" ? !1 : (r?.flowchart?.defaultRenderer === "elk" && (r.layout = "elk"), /^\s*graph/.test(e) && r?.flowchart?.defaultRenderer === "dagre-wrapper" ? !0 : /^\s*flowchart/.test(e)), "detector"),
  loader: /* @__PURE__ */ t(async () => {
    const { diagram: e } = await import("./flowDiagram-DWJPFMVM.js");
    return {
      id: ye,
      diagram: e
    };
  }, "loader")
}, be = "er", vt = {
  id: be,
  detector: /* @__PURE__ */ t((e) => /^\s*erDiagram/.test(e), "detector"),
  loader: /* @__PURE__ */ t(async () => {
    const { diagram: e } = await import("./erDiagram-SMLLAGMA.js");
    return {
      id: be,
      diagram: e
    };
  }, "loader")
}, De = "gitGraph", ht = {
  id: De,
  detector: /* @__PURE__ */ t((e) => /^\s*gitGraph/.test(e), "detector"),
  loader: /* @__PURE__ */ t(async () => {
    const { diagram: e } = await import("./gitGraphDiagram-UUTBAWPF.js");
    return {
      id: De,
      diagram: e
    };
  }, "loader")
}, Ee = "gantt", wt = {
  id: Ee,
  detector: /* @__PURE__ */ t((e) => /^\s*gantt/.test(e), "detector"),
  loader: /* @__PURE__ */ t(async () => {
    const { diagram: e } = await import("./ganttDiagram-T4ZO3ILL.js");
    return {
      id: Ee,
      diagram: e
    };
  }, "loader")
}, Se = "info", yt = {
  id: Se,
  detector: /* @__PURE__ */ t((e) => /^\s*info/.test(e), "detector"),
  loader: /* @__PURE__ */ t(async () => {
    const { diagram: e } = await import("./infoDiagram-42DDH7IO.js");
    return {
      id: Se,
      diagram: e
    };
  }, "loader")
}, _e = "pie", bt = {
  id: _e,
  detector: /* @__PURE__ */ t((e) => /^\s*pie/.test(e), "detector"),
  loader: /* @__PURE__ */ t(async () => {
    const { diagram: e } = await import("./pieDiagram-DEJITSTG.js");
    return {
      id: _e,
      diagram: e
    };
  }, "loader")
}, xe = "quadrantChart", Dt = {
  id: xe,
  detector: /* @__PURE__ */ t((e) => /^\s*quadrantChart/.test(e), "detector"),
  loader: /* @__PURE__ */ t(async () => {
    const { diagram: e } = await import("./quadrantDiagram-34T5L4WZ.js");
    return {
      id: xe,
      diagram: e
    };
  }, "loader")
}, Te = "xychart", Et = {
  id: Te,
  detector: /* @__PURE__ */ t((e) => /^\s*xychart(-beta)?/.test(e), "detector"),
  loader: /* @__PURE__ */ t(async () => {
    const { diagram: e } = await import("./xychartDiagram-5P7HB3ND.js");
    return {
      id: Te,
      diagram: e
    };
  }, "loader")
}, Le = "requirement", St = {
  id: Le,
  detector: /* @__PURE__ */ t((e) => /^\s*requirement(Diagram)?/.test(e), "detector"),
  loader: /* @__PURE__ */ t(async () => {
    const { diagram: e } = await import("./requirementDiagram-MS252O5E.js");
    return {
      id: Le,
      diagram: e
    };
  }, "loader")
}, ke = "sequence", _t = {
  id: ke,
  detector: /* @__PURE__ */ t((e) => /^\s*sequenceDiagram/.test(e), "detector"),
  loader: /* @__PURE__ */ t(async () => {
    const { diagram: e } = await import("./sequenceDiagram-FGHM5R23.js");
    return {
      id: ke,
      diagram: e
    };
  }, "loader")
}, Me = "class", xt = {
  id: Me,
  detector: /* @__PURE__ */ t((e, r) => r?.class?.defaultRenderer === "dagre-wrapper" ? !1 : /^\s*classDiagram/.test(e), "detector"),
  loader: /* @__PURE__ */ t(async () => {
    const { diagram: e } = await import("./classDiagram-6PBFFD2Q.js");
    return {
      id: Me,
      diagram: e
    };
  }, "loader")
}, Ae = "classDiagram", Tt = {
  id: Ae,
  detector: /* @__PURE__ */ t((e, r) => /^\s*classDiagram/.test(e) && r?.class?.defaultRenderer === "dagre-wrapper" ? !0 : /^\s*classDiagram-v2/.test(e), "detector"),
  loader: /* @__PURE__ */ t(async () => {
    const { diagram: e } = await import("./classDiagram-v2-HSJHXN6E.js");
    return {
      id: Ae,
      diagram: e
    };
  }, "loader")
}, Ie = "state", Lt = {
  id: Ie,
  detector: /* @__PURE__ */ t((e, r) => r?.state?.defaultRenderer === "dagre-wrapper" ? !1 : /^\s*stateDiagram/.test(e), "detector"),
  loader: /* @__PURE__ */ t(async () => {
    const { diagram: e } = await import("./stateDiagram-FHFEXIEX.js");
    return {
      id: Ie,
      diagram: e
    };
  }, "loader")
}, Ce = "stateDiagram", kt = {
  id: Ce,
  detector: /* @__PURE__ */ t((e, r) => !!(/^\s*stateDiagram-v2/.test(e) || /^\s*stateDiagram/.test(e) && r?.state?.defaultRenderer === "dagre-wrapper"), "detector"),
  loader: /* @__PURE__ */ t(async () => {
    const { diagram: e } = await import("./stateDiagram-v2-QKLJ7IA2.js");
    return {
      id: Ce,
      diagram: e
    };
  }, "loader")
}, Fe = "journey", Mt = {
  id: Fe,
  detector: /* @__PURE__ */ t((e) => /^\s*journey/.test(e), "detector"),
  loader: /* @__PURE__ */ t(async () => {
    const { diagram: e } = await import("./journeyDiagram-VCZTEJTY.js");
    return {
      id: Fe,
      diagram: e
    };
  }, "loader")
}, dr = { draw: /* @__PURE__ */ t((e, r, a) => {
  v.debug(`rendering svg for syntax error
`);
  const i = Br(r), n = i.append("g");
  i.attr("viewBox", "0 0 2412 512"), Or(i, 100, 512, !0), n.append("path").attr("class", "error-icon").attr("d", "m411.313,123.313c6.25-6.25 6.25-16.375 0-22.625s-16.375-6.25-22.625,0l-32,32-9.375,9.375-20.688-20.688c-12.484-12.5-32.766-12.5-45.25,0l-16,16c-1.261,1.261-2.304,2.648-3.31,4.051-21.739-8.561-45.324-13.426-70.065-13.426-105.867,0-192,86.133-192,192s86.133,192 192,192 192-86.133 192-192c0-24.741-4.864-48.327-13.426-70.065 1.402-1.007 2.79-2.049 4.051-3.31l16-16c12.5-12.492 12.5-32.758 0-45.25l-20.688-20.688 9.375-9.375 32.001-31.999zm-219.313,100.687c-52.938,0-96,43.063-96,96 0,8.836-7.164,16-16,16s-16-7.164-16-16c0-70.578 57.422-128 128-128 8.836,0 16,7.164 16,16s-7.164,16-16,16z"), n.append("path").attr("class", "error-icon").attr("d", "m459.02,148.98c-6.25-6.25-16.375-6.25-22.625,0s-6.25,16.375 0,22.625l16,16c3.125,3.125 7.219,4.688 11.313,4.688 4.094,0 8.188-1.563 11.313-4.688 6.25-6.25 6.25-16.375 0-22.625l-16.001-16z"), n.append("path").attr("class", "error-icon").attr("d", "m340.395,75.605c3.125,3.125 7.219,4.688 11.313,4.688 4.094,0 8.188-1.563 11.313-4.688 6.25-6.25 6.25-16.375 0-22.625l-16-16c-6.25-6.25-16.375-6.25-22.625,0s-6.25,16.375 0,22.625l15.999,16z"), n.append("path").attr("class", "error-icon").attr("d", "m400,64c8.844,0 16-7.164 16-16v-32c0-8.836-7.156-16-16-16-8.844,0-16,7.164-16,16v32c0,8.836 7.156,16 16,16z"), n.append("path").attr("class", "error-icon").attr("d", "m496,96.586h-32c-8.844,0-16,7.164-16,16 0,8.836 7.156,16 16,16h32c8.844,0 16-7.164 16-16 0-8.836-7.156-16-16-16z"), n.append("path").attr("class", "error-icon").attr("d", "m436.98,75.605c3.125,3.125 7.219,4.688 11.313,4.688 4.094,0 8.188-1.563 11.313-4.688l32-32c6.25-6.25 6.25-16.375 0-22.625s-16.375-6.25-22.625,0l-32,32c-6.251,6.25-6.251,16.375-0.001,22.625z"), n.append("text").attr("class", "error-text").attr("x", 1440).attr("y", 250).attr("font-size", "150px").style("text-anchor", "middle").text("Syntax error in text"), n.append("text").attr("class", "error-text").attr("x", 1250).attr("y", 400).attr("font-size", "100px").style("text-anchor", "middle").text(`mermaid version ${a}`);
}, "draw") }, At = dr, It = {
  db: {},
  renderer: dr,
  parser: { parse: /* @__PURE__ */ t(() => {
  }, "parse") }
}, Re = "flowchart-elk", Ct = {
  id: Re,
  detector: /* @__PURE__ */ t((e, r = {}) => /^\s*flowchart-elk/.test(e) || /^\s*(flowchart|graph)/.test(e) && r?.flowchart?.defaultRenderer === "elk" ? (r.layout = "elk", !0) : !1, "detector"),
  loader: /* @__PURE__ */ t(async () => {
    const { diagram: e } = await import("./flowDiagram-DWJPFMVM.js");
    return {
      id: Re,
      diagram: e
    };
  }, "loader")
}, $e = "timeline", Ft = {
  id: $e,
  detector: /* @__PURE__ */ t((e) => /^\s*timeline/.test(e), "detector"),
  loader: /* @__PURE__ */ t(async () => {
    const { diagram: e } = await import("./timeline-definition-GMOUNBTQ.js");
    return {
      id: $e,
      diagram: e
    };
  }, "loader")
}, Oe = "mindmap", Rt = {
  id: Oe,
  detector: /* @__PURE__ */ t((e) => /^\s*mindmap/.test(e), "detector"),
  loader: /* @__PURE__ */ t(async () => {
    const { diagram: e } = await import("./mindmap-definition-QFDTVHPH.js");
    return {
      id: Oe,
      diagram: e
    };
  }, "loader")
}, ze = "kanban", $t = {
  id: ze,
  detector: /* @__PURE__ */ t((e) => /^\s*kanban/.test(e), "detector"),
  loader: /* @__PURE__ */ t(async () => {
    const { diagram: e } = await import("./kanban-definition-6JOO6SKY.js");
    return {
      id: ze,
      diagram: e
    };
  }, "loader")
}, Ve = "sankey", Ot = {
  id: Ve,
  detector: /* @__PURE__ */ t((e) => /^\s*sankey(-beta)?/.test(e), "detector"),
  loader: /* @__PURE__ */ t(async () => {
    const { diagram: e } = await import("./sankeyDiagram-XADWPNL6.js");
    return {
      id: Ve,
      diagram: e
    };
  }, "loader")
}, Pe = "packet", zt = {
  id: Pe,
  detector: /* @__PURE__ */ t((e) => /^\s*packet(-beta)?/.test(e), "detector"),
  loader: /* @__PURE__ */ t(async () => {
    const { diagram: e } = await import("./diagram-TYMM5635.js");
    return {
      id: Pe,
      diagram: e
    };
  }, "loader")
}, Ge = "radar", Vt = {
  id: Ge,
  detector: /* @__PURE__ */ t((e) => /^\s*radar-beta/.test(e), "detector"),
  loader: /* @__PURE__ */ t(async () => {
    const { diagram: e } = await import("./diagram-MMDJMWI5.js");
    return {
      id: Ge,
      diagram: e
    };
  }, "loader")
}, Ne = "block", Pt = {
  id: Ne,
  detector: /* @__PURE__ */ t((e) => /^\s*block(-beta)?/.test(e), "detector"),
  loader: /* @__PURE__ */ t(async () => {
    const { diagram: e } = await import("./blockDiagram-DXYQGD6D.js");
    return {
      id: Ne,
      diagram: e
    };
  }, "loader")
}, He = "treeView", Gt = {
  id: He,
  detector: /* @__PURE__ */ t((e) => /^\s*treeView-beta/.test(e), "detector"),
  loader: /* @__PURE__ */ t(async () => {
    const { diagram: e } = await import("./diagram-5BDNPKRD.js");
    return {
      id: He,
      diagram: e
    };
  }, "loader")
}, qe = "architecture", Nt = {
  id: qe,
  detector: /* @__PURE__ */ t((e) => /^\s*architecture/.test(e), "detector"),
  loader: /* @__PURE__ */ t(async () => {
    const { diagram: e } = await import("./architectureDiagram-Q4EWVU46.js");
    return {
      id: qe,
      diagram: e
    };
  }, "loader")
}, Be = "ishikawa", Ht = {
  id: Be,
  detector: /* @__PURE__ */ t((e) => /^\s*ishikawa(-beta)?\b/i.test(e), "detector"),
  loader: /* @__PURE__ */ t(async () => {
    const { diagram: e } = await import("./ishikawaDiagram-UXIWVN3A.js");
    return {
      id: Be,
      diagram: e
    };
  }, "loader")
}, Ue = "venn", qt = {
  id: Ue,
  detector: /* @__PURE__ */ t((e) => /^\s*venn-beta/.test(e), "detector"),
  loader: /* @__PURE__ */ t(async () => {
    const { diagram: e } = await import("./vennDiagram-DHZGUBPP.js");
    return {
      id: Ue,
      diagram: e
    };
  }, "loader")
}, je = "treemap", Bt = {
  id: je,
  detector: /* @__PURE__ */ t((e) => /^\s*treemap/.test(e), "detector"),
  loader: /* @__PURE__ */ t(async () => {
    const { diagram: e } = await import("./diagram-G4DWMVQ6.js");
    return {
      id: je,
      diagram: e
    };
  }, "loader")
}, Xe = "wardley-beta", Ut = {
  id: Xe,
  detector: /* @__PURE__ */ t((e) => /^\s*wardley-beta/i.test(e), "detector"),
  loader: /* @__PURE__ */ t(async () => {
    const { diagram: e } = await import("./wardleyDiagram-NUSXRM2D.js");
    return {
      id: Xe,
      diagram: e
    };
  }, "loader")
}, Ye = !1, K = /* @__PURE__ */ t(() => {
  Ye || (Ye = !0, Y("error", It, (e) => e.toLowerCase().trim() === "error"), Y("---", {
    db: { clear: /* @__PURE__ */ t(() => {
    }, "clear") },
    styles: {},
    renderer: { draw: /* @__PURE__ */ t(() => {
    }, "draw") },
    parser: { parse: /* @__PURE__ */ t(() => {
      throw new Error("Diagrams beginning with --- are not valid. If you were trying to use a YAML front-matter, please ensure that you've correctly opened and closed the YAML front-matter with un-indented `---` blocks");
    }, "parse") },
    init: /* @__PURE__ */ t(() => null, "init")
  }, (e) => e.toLowerCase().trimStart().startsWith("---")), te(Ct, Rt, Nt), te(ft, $t, Tt, xt, vt, wt, yt, bt, St, _t, pt, gt, Ft, ht, kt, Lt, Mt, Dt, Ot, zt, Et, Pt, Gt, Vt, Ht, Bt, qt, Ut));
}, "addDiagrams"), jt = /* @__PURE__ */ t(async () => {
  v.debug("Loading registered diagrams");
  const e = (await Promise.allSettled(Object.entries(ae).map(async ([r, { detector: a, loader: i }]) => {
    if (i)
      try {
        ie(r);
      } catch {
        try {
          const { diagram: n, id: s } = await i();
          Y(s, n, a);
        } catch (n) {
          throw v.error(`Failed to load external diagram with key ${r}. Removing from detectors.`), delete ae[r], n;
        }
      }
  }))).filter((r) => r.status === "rejected");
  if (e.length > 0) {
    v.error(`Failed to load ${e.length} external diagrams`);
    for (const r of e) v.error(r);
    throw new Error(`Failed to load ${e.length} external diagrams`);
  }
}, "loadRegisteredDiagrams"), Xt = "graphics-document document";
function cr(e, r) {
  e.attr("role", Xt), r !== "" && e.attr("aria-roledescription", r);
}
t(cr, "setA11yDiagramInfo");
function lr(e, r, a, i) {
  if (e.insert !== void 0) {
    if (a) {
      const n = `chart-desc-${i}`;
      e.attr("aria-describedby", n), e.insert("desc", ":first-child").attr("id", n).text(a);
    }
    if (r) {
      const n = `chart-title-${i}`;
      e.attr("aria-labelledby", n), e.insert("title", ":first-child").attr("id", n).text(r);
    }
  }
}
t(lr, "addSVGa11yTitleDescription");
var oe = class mr {
  constructor(r, a, i, n, s) {
    this.type = r, this.text = a, this.db = i, this.parser = n, this.renderer = s;
  }
  static {
    t(this, "Diagram");
  }
  static async fromText(r, a = {}) {
    const i = H(), n = rr(r, i);
    r = Tr(r) + `
`;
    try {
      ie(n);
    } catch {
      const f = Fr(n);
      if (!f) throw new Nr(`Diagram ${n} not found.`);
      const { id: h, diagram: o } = await f();
      Y(h, o);
    }
    const { db: s, parser: m, renderer: l, init: c } = ie(n);
    return m.parser && (m.parser.yy = s), s.clear?.(), c?.(i), a.title && s.setDiagramTitle?.(a.title), await m.parse(r), new mr(n, r, s, m, l);
  }
  async render(r, a) {
    await this.renderer.draw(this.text, r, a, this);
  }
  getParser() {
    return this.parser;
  }
  getType() {
    return this.type;
  }
}, Qe = [], Yt = /* @__PURE__ */ t(() => {
  Qe.forEach((e) => {
    e();
  }), Qe = [];
}, "attachFunctions"), Qt = /* @__PURE__ */ t((e) => e.replace(/^\s*%%(?!{)[^\n]+\n?/gm, "").trimStart(), "cleanupComments");
function ur(e) {
  const r = e.match(zr);
  if (!r) return {
    text: e,
    metadata: {}
  };
  let a = Yr(r[1], { schema: Qr }) ?? {};
  a = typeof a == "object" && !Array.isArray(a) ? a : {};
  const i = {};
  return a.displayMode && (i.displayMode = a.displayMode.toString()), a.title && (i.title = a.title.toString()), a.config && (i.config = a.config), {
    text: e.slice(r[0].length),
    metadata: i
  };
}
t(ur, "extractFrontMatter");
var Wt = /* @__PURE__ */ t((e) => e.replace(/\r\n?/g, `
`).replace(/<(\w+)([^>]*)>/g, (r, a, i) => "<" + a + i.replace(/="([^"]*)"/g, "='$1'") + ">"), "cleanupText"), Jt = /* @__PURE__ */ t((e) => {
  const { text: r, metadata: a } = ur(e), { displayMode: i, title: n, config: s = {} } = a;
  return i && (s.gantt || (s.gantt = {}), s.gantt.displayMode = i), {
    title: n,
    config: s,
    text: r
  };
}, "processFrontmatter"), Kt = /* @__PURE__ */ t((e) => {
  const r = G.detectInit(e) ?? {}, a = G.detectDirective(e, "wrap");
  return Array.isArray(a) ? r.wrap = a.some(({ type: i }) => i === "wrap") : a?.type === "wrap" && (r.wrap = !0), {
    text: kr(e),
    directive: r
  };
}, "processDirectives");
function me(e) {
  const r = Jt(Wt(e)), a = Kt(r.text), i = Mr(r.config, a.directive);
  return e = Qt(a.text), {
    code: e,
    title: r.title,
    config: i
  };
}
t(me, "preprocessDiagram");
function fr(e) {
  const r = new TextEncoder().encode(e), a = Array.from(r, (i) => String.fromCodePoint(i)).join("");
  return btoa(a);
}
t(fr, "toBase64");
var Zt = 5e4, ea = "graph TB;a[Maximum text size in diagram exceeded];style a fill:#faa", ra = "sandbox", ta = "loose", aa = "http://www.w3.org/2000/svg", ia = "http://www.w3.org/1999/xlink", na = "http://www.w3.org/1999/xhtml", sa = "100%", oa = "100%", da = "border:0;margin:0;", ca = "margin:0", la = "allow-top-navigation-by-user-activation allow-popups", ma = 'The "iframe" tag is not supported by your browser.', ua = ["foreignobject"], fa = ["dominant-baseline"];
function ue(e) {
  const r = me(e);
  return X(), Pr(r.config ?? {}), r;
}
t(ue, "processAndSetConfigs");
async function gr(e, r) {
  K();
  try {
    const { code: a, config: i } = ue(e);
    return {
      diagramType: (await vr(a)).type,
      config: i
    };
  } catch (a) {
    if (r?.suppressErrors) return !1;
    throw a;
  }
}
t(gr, "parse");
var We = /* @__PURE__ */ t((e, r, a = []) => `
.${e} ${r} { ${a.join(" !important; ")} !important; }`, "cssImportantStyles"), ga = /* @__PURE__ */ t((e, r = /* @__PURE__ */ new Map()) => {
  let a = "";
  if (e.themeCSS !== void 0 && (a += `
${e.themeCSS}`), e.fontFamily !== void 0 && (a += `
:root { --mermaid-font-family: ${e.fontFamily}}`), e.altFontFamily !== void 0 && (a += `
:root { --mermaid-alt-font-family: ${e.altFontFamily}}`), r instanceof Map) {
    const i = Hr(e) ? ["> *", "span"] : [
      "rect",
      "polygon",
      "ellipse",
      "circle",
      "path"
    ];
    r.forEach((n) => {
      fe(n.styles) || i.forEach((s) => {
        a += We(n.id, s, n.styles);
      }), fe(n.textStyles) || (a += We(n.id, "tspan", (n?.textStyles || []).map((s) => s.replace("color", "fill"))));
    });
  }
  return a;
}, "createCssStyles"), pa = /* @__PURE__ */ t((e, r, a, i) => se(lt(`${i}{${Cr(r, ga(e, a), {
  ...e.themeVariables,
  theme: e.theme,
  look: e.look
}, i)}}`), ut), "createUserStyles"), va = /* @__PURE__ */ t((e = "", r, a) => {
  let i = e;
  return !a && !r && (i = i.replace(/marker-end="url\([\d+./:=?A-Za-z-]*?#/g, 'marker-end="url(#')), i = Lr(i), i = i.replace(/<br>/g, "<br/>"), i;
}, "cleanUpSvgCode"), ha = /* @__PURE__ */ t((e = "", r) => `<iframe style="width:${sa};height:${r?.viewBox?.baseVal?.height ? r.viewBox.baseVal.height + "px" : oa};${da}" src="data:text/html;charset=UTF-8;base64,${fr(`<body style="${ca}">${e}</body>`)}" sandbox="${la}">
  ${ma}
</iframe>`, "putIntoIFrame"), Je = /* @__PURE__ */ t((e, r, a, i, n) => {
  const s = e.append("div");
  s.attr("id", a), i && s.attr("style", i);
  const m = s.append("svg").attr("id", r).attr("width", "100%").attr("xmlns", aa);
  return n && m.attr("xmlns:xlink", n), m.append("g"), e;
}, "appendDivSvgG");
function de(e, r) {
  return e.append("iframe").attr("id", r).attr("style", "width: 100%; height: 100%;").attr("sandbox", "");
}
t(de, "sandboxedIframe");
var wa = /* @__PURE__ */ t((e, r, a, i) => {
  e.getElementById(r)?.remove(), e.getElementById(a)?.remove(), e.getElementById(i)?.remove();
}, "removeExistingElements"), ya = /* @__PURE__ */ t(async function(e, r, a) {
  K();
  const i = ue(r);
  r = i.code;
  const n = H();
  v.debug(n), r.length > (n?.maxTextSize ?? Zt) && (r = ea);
  const s = "#" + e, m = "i" + e, l = "#" + m, c = "d" + e, f = "#" + c, h = /* @__PURE__ */ t(() => {
    const L = C(w ? l : f).node();
    L && "remove" in L && L.remove();
  }, "removeTempElements");
  let o = C("body");
  const w = n.securityLevel === ra, x = n.securityLevel === ta, D = n.fontFamily;
  a !== void 0 ? (a && (a.innerHTML = ""), w ? (o = C(de(C(a), m).nodes()[0].contentDocument.body), o.node().style.margin = 0) : o = C(a), Je(o, e, c, `font-family: ${D}`, ia)) : (wa(document, e, c, m), w ? (o = C(de(C("body"), m).nodes()[0].contentDocument.body), o.node().style.margin = 0) : o = C("body"), Je(o, e, c));
  let u, M;
  try {
    u = await oe.fromText(r, { title: i.title });
  } catch (L) {
    if (n.suppressErrorRendering)
      throw h(), L;
    u = await oe.fromText("error"), M = L;
  }
  const E = o.select(f).node(), g = u.type, S = E.firstChild, A = S.firstChild, T = u.renderer.getClasses?.(r, u), y = pa(n, g, T, s), d = document.createElement("style");
  d.innerHTML = y, S.insertBefore(d, A);
  try {
    await u.renderer.draw(r, e, "11.14.0", u);
  } catch (L) {
    throw n.suppressErrorRendering ? h() : At.draw(r, e, "11.14.0"), L;
  }
  const Sr = o.select(`${f} svg`), _r = u.db.getAccTitle?.(), xr = u.db.getAccDescription?.();
  hr(g, Sr, _r, xr), o.select(`[id="${e}"]`).selectAll("foreignobject > *").attr("xmlns", na);
  let R = o.select(f).node().innerHTML;
  if (v.debug("config.arrowMarkerAbsolute", n.arrowMarkerAbsolute), R = va(R, w, Vr(n.arrowMarkerAbsolute)), w) {
    const L = o.select(f + " svg").node();
    R = ha(R, L);
  } else x || (R = $r.sanitize(R, {
    ADD_TAGS: ua,
    ADD_ATTR: fa,
    HTML_INTEGRATION_POINTS: { foreignobject: !0 }
  }));
  if (Yt(), M) throw M;
  return h(), {
    diagramType: g,
    svg: R,
    bindFunctions: u.db.bindFunctions
  };
}, "render");
function pr(e = {}) {
  const r = Gr({}, e);
  r?.fontFamily && !r.themeVariables?.fontFamily && (r.themeVariables || (r.themeVariables = {}), r.themeVariables.fontFamily = r.fontFamily), qr(r), r?.theme && r.theme in Z ? r.themeVariables = Z[r.theme].getThemeVariables(r.themeVariables) : r && (r.themeVariables = Z.default.getThemeVariables(r.themeVariables)), Ze((typeof r == "object" ? Ar(r) : er()).logLevel), K();
}
t(pr, "initialize");
var vr = /* @__PURE__ */ t((e, r = {}) => {
  const { code: a } = me(e);
  return oe.fromText(a, r);
}, "getDiagramFromText");
function hr(e, r, a, i) {
  cr(r, e), lr(r, a, i, r.attr("id"));
}
t(hr, "addA11yInfo");
var $ = Object.freeze({
  render: ya,
  parse: gr,
  getDiagramFromText: vr,
  initialize: pr,
  getConfig: H,
  setConfig: Ir,
  getSiteConfig: er,
  updateSiteConfig: Rr,
  reset: /* @__PURE__ */ t(() => {
    X();
  }, "reset"),
  globalReset: /* @__PURE__ */ t(() => {
    X(ge);
  }, "globalReset"),
  defaultConfig: ge
});
Ze(H().logLevel);
X(H());
var ba = /* @__PURE__ */ t((e, r, a) => {
  v.warn(e), Ke(e) ? (a && a(e.str, e.hash), r.push({
    ...e,
    message: e.str,
    error: e
  })) : (a && a(e), e instanceof Error && r.push({
    str: e.message,
    message: e.message,
    hash: e.name,
    error: e
  }));
}, "handleError"), wr = /* @__PURE__ */ t(async function(e = { querySelector: ".mermaid" }) {
  try {
    await Da(e);
  } catch (r) {
    if (Ke(r) && v.error(r.str), I.parseError && I.parseError(r), !e.suppressErrors)
      throw v.error("Use the suppressErrors option to suppress these errors"), r;
  }
}, "run"), Da = /* @__PURE__ */ t(async function({ postRenderCallback: e, querySelector: r, nodes: a } = { querySelector: ".mermaid" }) {
  const i = $.getConfig();
  v.debug(`${e ? "" : "No "}Callback function found`);
  let n;
  if (a) n = a;
  else if (r) n = document.querySelectorAll(r);
  else throw new Error("Nodes and querySelector are both undefined");
  v.debug(`Found ${n.length} diagrams`), i?.startOnLoad !== void 0 && (v.debug("Start On Load: " + i?.startOnLoad), $.updateSiteConfig({ startOnLoad: i?.startOnLoad }));
  const s = new G.InitIDGenerator(i.deterministicIds, i.deterministicIDSeed);
  let m;
  const l = [];
  for (const c of Array.from(n)) {
    if (v.info("Rendering diagram: " + c.id), c.getAttribute("data-processed")) continue;
    c.setAttribute("data-processed", "true");
    const f = `mermaid-${s.next()}`;
    m = c.innerHTML, m = jr(G.entityDecode(m)).trim().replace(/<br\s*\/?>/gi, "<br/>");
    const h = G.detectInit(m);
    h && v.debug("Detected early reinit: ", h);
    try {
      const { svg: o, bindFunctions: w } = await Er(f, m, c);
      c.innerHTML = o, e && await e(f), w && w(c);
    } catch (o) {
      ba(o, l, I.parseError);
    }
  }
  if (l.length > 0) throw l[0];
}, "runThrowsErrors"), yr = /* @__PURE__ */ t(function(e) {
  $.initialize(e);
}, "initialize"), Ea = /* @__PURE__ */ t(async function(e, r, a) {
  v.warn("mermaid.init is deprecated. Please use run instead."), e && yr(e);
  const i = {
    postRenderCallback: a,
    querySelector: ".mermaid"
  };
  typeof r == "string" ? i.querySelector = r : r && (r instanceof HTMLElement ? i.nodes = [r] : i.nodes = r), await wr(i);
}, "init"), Sa = /* @__PURE__ */ t(async (e, { lazyLoad: r = !0 } = {}) => {
  K(), te(...e), r === !1 && await jt();
}, "registerExternalDiagrams"), br = /* @__PURE__ */ t(function() {
  if (I.startOnLoad) {
    const { startOnLoad: e } = $.getConfig();
    e && I.run().catch((r) => v.error("Mermaid failed to initialize", r));
  }
}, "contentLoaded");
typeof document < "u" && window.addEventListener("load", br, !1);
var _a = /* @__PURE__ */ t(function(e) {
  I.parseError = e;
}, "setParseErrorHandler"), Q = [], re = !1, Dr = /* @__PURE__ */ t(async () => {
  if (!re) {
    for (re = !0; Q.length > 0; ) {
      const e = Q.shift();
      if (e) try {
        await e();
      } catch (r) {
        v.error("Error executing queue", r);
      }
    }
    re = !1;
  }
}, "executeQueue"), xa = /* @__PURE__ */ t(async (e, r) => new Promise((a, i) => {
  const n = /* @__PURE__ */ t(() => new Promise((s, m) => {
    $.parse(e, r).then((l) => {
      s(l), a(l);
    }, (l) => {
      v.error("Error parsing", l), I.parseError?.(l), m(l), i(l);
    });
  }), "performCall");
  Q.push(n), Dr().catch(i);
}), "parse"), Er = /* @__PURE__ */ t((e, r, a) => new Promise((i, n) => {
  const s = /* @__PURE__ */ t(() => new Promise((m, l) => {
    $.render(e, r, a).then((c) => {
      m(c), i(c);
    }, (c) => {
      v.error("Error parsing", c), I.parseError?.(c), l(c), n(c);
    });
  }), "performCall");
  Q.push(s), Dr().catch(n);
}), "render"), I = {
  startOnLoad: !0,
  mermaidAPI: $,
  parse: xa,
  render: Er,
  init: Ea,
  run: wr,
  registerExternalDiagrams: Sa,
  registerLayoutLoaders: Xr,
  initialize: yr,
  parseError: void 0,
  contentLoaded: br,
  setParseErrorHandler: _a,
  detectType: rr,
  registerIconPacks: Ur,
  getRegisteredDiagramsMetadata: /* @__PURE__ */ t(() => Object.keys(ae).map((e) => ({ id: e })), "getRegisteredDiagramsMetadata")
}, $a = I;
export {
  $a as default
};

//# sourceMappingURL=mermaid.core.js.map