import { Ct as K, _t as Q, at as k, bt as tt, ct as et, dt as rt, ft as nt, gt as it, ht as at, it as st, lt as ot, mt as lt, nt as ct, ot as ut, pt as ft, rt as dt, st as ht, u as gt, ut as vt, vt as mt, yt as pt } from "./vendor/recharts.js";
import { A as yt, B, F as xt, H as bt, O as _t, R as Mt, S as wt, U as $t, V as T, b as I, c as St, g as Ct, i as Ot, j as Pt, l as At, n as Lt, p as R, r as Tt, s as It, t as Et, u as w, y as Ft } from "./isArrayLikeObject.js";
import { n as o, r as v } from "./chunk-AGHRB4JF.js";
import { I as Bt, f as Rt, m as b, r as W, s as $ } from "./chunk-ICPOFSXX.js";
import { t as Wt } from "./dist2.js";
var jt = "[object Object]", Nt = Function.prototype, Ht = Object.prototype, j = Nt.toString, Dt = Ht.hasOwnProperty, zt = j.call(Object);
function Ut(e) {
  if (!bt(e) || $t(e) != jt) return !1;
  var t = At(e);
  if (t === null) return !0;
  var r = Dt.call(t, "constructor") && t.constructor;
  return typeof r == "function" && r instanceof r && j.call(r) == zt;
}
function _(e, t, r) {
  (r !== void 0 && !yt(e[t], r) || r === void 0 && !(t in e)) && Pt(e, t, r);
}
function M(e, t) {
  if (!(t === "constructor" && typeof e[t] == "function") && t != "__proto__")
    return e[t];
}
function Xt(e) {
  return _t(e, R(e));
}
function Yt(e, t, r, n, i, a, s) {
  var l = M(e, r), c = M(t, r), f = s.get(c);
  if (f) {
    _(e, r, f);
    return;
  }
  var u = a ? a(l, c, r + "", e, t, s) : void 0, d = u === void 0;
  if (d) {
    var g = T(c), h = !g && Ft(c), p = !g && !h && Ct(c);
    u = c, g || h || p ? T(l) ? u = l : Et(l) ? u = xt(l) : h ? (d = !1, u = It(c, !0)) : p ? (d = !1, u = Ot(c, !0)) : u = [] : Ut(c) || I(c) ? (u = l, I(l) ? u = Xt(l) : (!B(l) || Mt(l)) && (u = Tt(c))) : d = !1;
  }
  d && (s.set(c, u), i(u, c, n, a, s), s.delete(c)), _(e, r, u);
}
function N(e, t, r, n, i) {
  e !== t && Lt(t, function(a, s) {
    if (i || (i = new St()), B(a)) Yt(e, t, s, r, N, n, i);
    else {
      var l = n ? n(M(e, s), a, s + "", e, t, i) : void 0;
      l === void 0 && (l = a), _(e, s, l);
    }
  }, R);
}
var Gt = wt(function(e, t, r) {
  N(e, t, r);
}), qt = Wt();
var Jt = {
  curveBasis: mt,
  curveBasisClosed: Q,
  curveBasisOpen: it,
  curveBumpX: pt,
  curveBumpY: tt,
  curveBundle: at,
  curveCardinalClosed: ft,
  curveCardinalOpen: nt,
  curveCardinal: lt,
  curveCatmullRomClosed: vt,
  curveCatmullRomOpen: ot,
  curveCatmullRom: rt,
  curveLinear: K,
  curveLinearClosed: et,
  curveMonotoneX: ut,
  curveMonotoneY: ht,
  curveNatural: k,
  curveStep: st,
  curveStepAfter: ct,
  curveStepBefore: dt
}, Vt = /\s*(?:(\w+)(?=:):|(\w+))\s*(?:(\w+)|((?:(?!}%{2}).|\r?\n)*))?\s*(?:}%{2})?/gi, Zt = /* @__PURE__ */ o(function(e, t) {
  const r = H(e, /(?:init\b)|(?:initialize\b)/);
  let n = {};
  if (Array.isArray(r)) {
    const s = r.map((l) => l.args);
    Bt(s), n = W(n, [...s]);
  } else n = r.args;
  if (!n) return;
  let i = Rt(e, t);
  const a = "config";
  return n[a] !== void 0 && (i === "flowchart-v2" && (i = "flowchart"), n[i] = n[a], delete n[a]), n;
}, "detectInit"), H = /* @__PURE__ */ o(function(e, t = null) {
  try {
    const r = new RegExp(`[%]{2}(?![{]${Vt.source})(?=[}][%]{2}).*
`, "ig");
    e = e.trim().replace(r, "").replace(/'/gm, '"'), v.debug(`Detecting diagram directive${t !== null ? " type:" + t : ""} based on the text:${e}`);
    let n;
    const i = [];
    for (; (n = b.exec(e)) !== null; )
      if (n.index === b.lastIndex && b.lastIndex++, n && !t || t && n[1]?.match(t) || t && n[2]?.match(t)) {
        const a = n[1] ? n[1] : n[2], s = n[3] ? n[3].trim() : n[4] ? JSON.parse(n[4].trim()) : null;
        i.push({
          type: a,
          args: s
        });
      }
    return i.length === 0 ? {
      type: e,
      args: null
    } : i.length === 1 ? i[0] : i;
  } catch (r) {
    return v.error(`ERROR: ${r.message} - Unable to parse directive type: '${t}' based on the text: '${e}'`), {
      type: void 0,
      args: null
    };
  }
}, "detectDirective"), me = /* @__PURE__ */ o(function(e) {
  return e.replace(b, "");
}, "removeDirectives"), Kt = /* @__PURE__ */ o(function(e, t) {
  for (const [r, n] of t.entries()) if (n.match(e)) return r;
  return -1;
}, "isSubstringInArray");
function D(e, t) {
  return e ? Jt[`curve${e.charAt(0).toUpperCase() + e.slice(1)}`] ?? t : t;
}
o(D, "interpolateToCurve");
function z(e, t) {
  const r = e.trim();
  if (r)
    return t.securityLevel !== "loose" ? (0, qt.sanitizeUrl)(r) : r;
}
o(z, "formatUrl");
var Qt = /* @__PURE__ */ o((e, ...t) => {
  const r = e.split("."), n = r.length - 1, i = r[n];
  let a = window;
  for (let s = 0; s < n; s++)
    if (a = a[r[s]], !a) {
      v.error(`Function name: ${e} not found in window`);
      return;
    }
  a[i](...t);
}, "runFunc");
function S(e, t) {
  return !e || !t ? 0 : Math.sqrt(Math.pow(t.x - e.x, 2) + Math.pow(t.y - e.y, 2));
}
o(S, "distance");
function U(e) {
  let t, r = 0;
  return e.forEach((n) => {
    r += S(n, t), t = n;
  }), C(e, r / 2);
}
o(U, "traverseEdge");
function X(e) {
  return e.length === 1 ? e[0] : U(e);
}
o(X, "calcLabelPosition");
var E = /* @__PURE__ */ o((e, t = 2) => {
  const r = Math.pow(10, t);
  return Math.round(e * r) / r;
}, "roundNumber"), C = /* @__PURE__ */ o((e, t) => {
  let r, n = t;
  for (const i of e) {
    if (r) {
      const a = S(i, r);
      if (a === 0) return r;
      if (a < n) n -= a;
      else {
        const s = n / a;
        if (s <= 0) return r;
        if (s >= 1) return {
          x: i.x,
          y: i.y
        };
        if (s > 0 && s < 1) return {
          x: E((1 - s) * r.x + s * i.x, 5),
          y: E((1 - s) * r.y + s * i.y, 5)
        };
      }
    }
    r = i;
  }
  throw new Error("Could not find a suitable point for the given distance");
}, "calculatePoint"), kt = /* @__PURE__ */ o((e, t, r) => {
  v.info(`our points ${JSON.stringify(t)}`), t[0] !== r && (t = t.reverse());
  const n = C(t, 25), i = e ? 10 : 5, a = Math.atan2(t[0].y - n.y, t[0].x - n.x), s = {
    x: 0,
    y: 0
  };
  return s.x = Math.sin(a) * i + (t[0].x + n.x) / 2, s.y = -Math.cos(a) * i + (t[0].y + n.y) / 2, s;
}, "calcCardinalityPosition");
function Y(e, t, r) {
  const n = structuredClone(r);
  v.info("our points", n), t !== "start_left" && t !== "start_right" && n.reverse();
  const i = C(n, 25 + e), a = 10 + e * 0.5, s = Math.atan2(n[0].y - i.y, n[0].x - i.x), l = {
    x: 0,
    y: 0
  };
  return t === "start_left" ? (l.x = Math.sin(s + Math.PI) * a + (n[0].x + i.x) / 2, l.y = -Math.cos(s + Math.PI) * a + (n[0].y + i.y) / 2) : t === "end_right" ? (l.x = Math.sin(s - Math.PI) * a + (n[0].x + i.x) / 2 - 5, l.y = -Math.cos(s - Math.PI) * a + (n[0].y + i.y) / 2 - 5) : t === "end_left" ? (l.x = Math.sin(s) * a + (n[0].x + i.x) / 2 - 5, l.y = -Math.cos(s) * a + (n[0].y + i.y) / 2 - 5) : (l.x = Math.sin(s) * a + (n[0].x + i.x) / 2, l.y = -Math.cos(s) * a + (n[0].y + i.y) / 2), l;
}
o(Y, "calcTerminalLabelPosition");
function G(e) {
  let t = "", r = "";
  for (const n of e) n !== void 0 && (n.startsWith("color:") || n.startsWith("text-align:") ? r = r + n + ";" : t = t + n + ";");
  return {
    style: t,
    labelStyle: r
  };
}
o(G, "getStylesFromArray");
var F = 0, te = /* @__PURE__ */ o(() => (F++, "id-" + Math.random().toString(36).substr(2, 12) + "-" + F), "generateId");
function q(e) {
  let t = "";
  const r = "0123456789abcdef";
  for (let i = 0; i < e; i++) t += r.charAt(Math.floor(Math.random() * 16));
  return t;
}
o(q, "makeRandomHex");
var ee = /* @__PURE__ */ o((e) => q(e.length), "random"), re = /* @__PURE__ */ o(function() {
  return {
    x: 0,
    y: 0,
    fill: void 0,
    anchor: "start",
    style: "#666",
    width: 100,
    height: 100,
    textMargin: 0,
    rx: 0,
    ry: 0,
    valign: void 0,
    text: ""
  };
}, "getTextObj"), ne = /* @__PURE__ */ o(function(e, t) {
  const r = t.text.replace($.lineBreakRegex, " "), [, n] = P(t.fontSize), i = e.append("text");
  i.attr("x", t.x), i.attr("y", t.y), i.style("text-anchor", t.anchor), i.style("font-family", t.fontFamily), i.style("font-size", n), i.style("font-weight", t.fontWeight), i.attr("fill", t.fill), t.class !== void 0 && i.attr("class", t.class);
  const a = i.append("tspan");
  return a.attr("x", t.x + t.textMargin * 2), a.attr("fill", t.fill), a.text(r), i;
}, "drawSimpleText"), ie = w((e, t, r) => {
  if (!e || (r = Object.assign({
    fontSize: 12,
    fontWeight: 400,
    fontFamily: "Arial",
    joinWith: "<br/>"
  }, r), $.lineBreakRegex.test(e))) return e;
  const n = e.split(" ").filter(Boolean), i = [];
  let a = "";
  return n.forEach((s, l) => {
    const c = m(`${s} `, r), f = m(a, r);
    if (c > t) {
      const { hyphenatedStrings: u, remainingWord: d } = ae(s, t, "-", r);
      i.push(a, ...u), a = d;
    } else f + c >= t ? (i.push(a), a = s) : a = [a, s].filter(Boolean).join(" ");
    l + 1 === n.length && i.push(a);
  }), i.filter((s) => s !== "").join(r.joinWith);
}, (e, t, r) => `${e}${t}${r.fontSize}${r.fontWeight}${r.fontFamily}${r.joinWith}`), ae = w((e, t, r = "-", n) => {
  n = Object.assign({
    fontSize: 12,
    fontWeight: 400,
    fontFamily: "Arial",
    margin: 0
  }, n);
  const i = [...e], a = [];
  let s = "";
  return i.forEach((l, c) => {
    const f = `${s}${l}`;
    if (m(f, n) >= t) {
      const u = c + 1, d = i.length === u, g = `${f}${r}`;
      a.push(d ? f : g), s = "";
    } else s = f;
  }), {
    hyphenatedStrings: a,
    remainingWord: s
  };
}, (e, t, r = "-", n) => `${e}${t}${r}${n.fontSize}${n.fontWeight}${n.fontFamily}`);
function J(e, t) {
  return O(e, t).height;
}
o(J, "calculateTextHeight");
function m(e, t) {
  return O(e, t).width;
}
o(m, "calculateTextWidth");
var O = w((e, t) => {
  const { fontSize: r = 12, fontFamily: n = "Arial", fontWeight: i = 400 } = t;
  if (!e) return {
    width: 0,
    height: 0
  };
  const [, a] = P(r), s = ["sans-serif", n], l = e.split($.lineBreakRegex), c = [], f = gt("body");
  if (!f.remove) return {
    width: 0,
    height: 0,
    lineHeight: 0
  };
  const u = f.append("svg");
  for (const d of s) {
    let g = 0;
    const h = {
      width: 0,
      height: 0,
      lineHeight: 0
    };
    for (const p of l) {
      const A = re();
      A.text = p || "​";
      const L = ne(u, A).style("font-size", a).style("font-weight", i).style("font-family", d), y = (L._groups || L)[0][0].getBBox();
      if (y.width === 0 && y.height === 0) throw new Error("svg element not in render tree");
      h.width = Math.round(Math.max(h.width, y.width)), g = Math.round(y.height), h.height += g, h.lineHeight = Math.round(Math.max(h.lineHeight, g));
    }
    c.push(h);
  }
  return u.remove(), c[isNaN(c[1].height) || isNaN(c[1].width) || isNaN(c[1].lineHeight) || c[0].height > c[1].height && c[0].width > c[1].width && c[0].lineHeight > c[1].lineHeight ? 0 : 1];
}, (e, t) => `${e}${t.fontSize}${t.fontWeight}${t.fontFamily}`), se = class {
  constructor(e = !1, t) {
    this.count = 0, this.count = t ? t.length : 0, this.next = e ? () => this.count++ : () => Date.now();
  }
  static {
    o(this, "InitIDGenerator");
  }
}, x, oe = /* @__PURE__ */ o(function(e) {
  return x = x || document.createElement("div"), e = escape(e).replace(/%26/g, "&").replace(/%23/g, "#").replace(/%3B/g, ";"), x.innerHTML = e, unescape(x.textContent);
}, "entityDecode");
function le(e) {
  return "str" in e;
}
o(le, "isDetailedError");
var ce = /* @__PURE__ */ o((e, t, r, n) => {
  if (!n) return;
  const i = e.node()?.getBBox();
  i && e.append("text").text(n).attr("text-anchor", "middle").attr("x", i.x + i.width / 2).attr("y", -r).attr("class", t);
}, "insertTitle"), P = /* @__PURE__ */ o((e) => {
  if (typeof e == "number") return [e, e + "px"];
  const t = parseInt(e ?? "", 10);
  return Number.isNaN(t) ? [void 0, void 0] : e === String(t) ? [t, e + "px"] : [t, e];
}, "parseFontSize");
function V(e, t) {
  return Gt({}, e, t);
}
o(V, "cleanAndMerge");
var pe = {
  assignWithDepth: W,
  wrapLabel: ie,
  calculateTextHeight: J,
  calculateTextWidth: m,
  calculateTextDimensions: O,
  cleanAndMerge: V,
  detectInit: Zt,
  detectDirective: H,
  isSubstringInArray: Kt,
  interpolateToCurve: D,
  calcLabelPosition: X,
  calcCardinalityPosition: kt,
  calcTerminalLabelPosition: Y,
  formatUrl: z,
  getStylesFromArray: G,
  generateId: te,
  random: ee,
  runFunc: Qt,
  entityDecode: oe,
  insertTitle: ce,
  isLabelCoordinateInPath: Z,
  parseFontSize: P,
  InitIDGenerator: se
}, ye = /* @__PURE__ */ o(function(e) {
  let t = e;
  return t = t.replace(/style.*:\S*#.*;/g, function(r) {
    return r.substring(0, r.length - 1);
  }), t = t.replace(/classDef.*:\S*#.*;/g, function(r) {
    return r.substring(0, r.length - 1);
  }), t = t.replace(/#\w+;/g, function(r) {
    const n = r.substring(1, r.length - 1);
    return /^\+?\d+$/.test(n) ? "ﬂ°°" + n + "¶ß" : "ﬂ°" + n + "¶ß";
  }), t;
}, "encodeEntities"), xe = /* @__PURE__ */ o(function(e) {
  return e.replace(/ﬂ°°/g, "&#").replace(/ﬂ°/g, "&").replace(/¶ß/g, ";");
}, "decodeEntities"), be = /* @__PURE__ */ o((e, t, { counter: r = 0, prefix: n, suffix: i }, a) => a || `${n ? `${n}_` : ""}${e}_${t}_${r}${i ? `_${i}` : ""}`, "getEdgeId");
function ue(e) {
  return e ?? null;
}
o(ue, "handleUndefinedAttr");
function Z(e, t) {
  const r = Math.round(e.x), n = Math.round(e.y), i = t.replace(/(\d+\.\d+)/g, (a) => Math.round(parseFloat(a)).toString());
  return i.includes(r.toString()) || i.includes(n.toString());
}
o(Z, "isLabelCoordinateInPath");
export {
  Gt as _,
  ye as a,
  G as c,
  le as d,
  P as f,
  ie as g,
  pe as h,
  xe as i,
  ue as l,
  me as m,
  m as n,
  te as o,
  ee as p,
  V as r,
  be as s,
  J as t,
  D as u
};

//# sourceMappingURL=chunk-5PVQY5BW.js.map