import { _ as u, aj as Et, ak as kt, a6 as bt, a5 as Ot, a7 as Rt, a8 as Nt, g as z, l as Q, a9 as rt, ao as xt, aa as Tt, aq as At, ay as Mt, az as wt, aA as St } from "./index-CMZig9xg.js";
import { L as Dt } from "./graph-BYZMvqpu-BXRs5843.js";
import { o as $t } from "./layout-BHI4imdk-CESYC-il.js";
const Lt = /^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;
function vt(t) {
  return typeof t == "string" && Lt.test(t);
}
const M = [];
for (let t = 0; t < 256; ++t)
  M.push((t + 256).toString(16).slice(1));
function It(t, e = 0) {
  return M[t[e + 0]] + M[t[e + 1]] + M[t[e + 2]] + M[t[e + 3]] + "-" + M[t[e + 4]] + M[t[e + 5]] + "-" + M[t[e + 6]] + M[t[e + 7]] + "-" + M[t[e + 8]] + M[t[e + 9]] + "-" + M[t[e + 10]] + M[t[e + 11]] + M[t[e + 12]] + M[t[e + 13]] + M[t[e + 14]] + M[t[e + 15]];
}
function Ct(t) {
  if (!vt(t))
    throw TypeError("Invalid UUID");
  let e;
  const r = new Uint8Array(16);
  return r[0] = (e = parseInt(t.slice(0, 8), 16)) >>> 24, r[1] = e >>> 16 & 255, r[2] = e >>> 8 & 255, r[3] = e & 255, r[4] = (e = parseInt(t.slice(9, 13), 16)) >>> 8, r[5] = e & 255, r[6] = (e = parseInt(t.slice(14, 18), 16)) >>> 8, r[7] = e & 255, r[8] = (e = parseInt(t.slice(19, 23), 16)) >>> 8, r[9] = e & 255, r[10] = (e = parseInt(t.slice(24, 36), 16)) / 1099511627776 & 255, r[11] = e / 4294967296 & 255, r[12] = e >>> 24 & 255, r[13] = e >>> 16 & 255, r[14] = e >>> 8 & 255, r[15] = e & 255, r;
}
function Pt(t) {
  t = unescape(encodeURIComponent(t));
  const e = [];
  for (let r = 0; r < t.length; ++r)
    e.push(t.charCodeAt(r));
  return e;
}
const Yt = "6ba7b810-9dad-11d1-80b4-00c04fd430c8", Zt = "6ba7b811-9dad-11d1-80b4-00c04fd430c8";
function Bt(t, e, r) {
  function y(c, _, h, l) {
    var d;
    if (typeof c == "string" && (c = Pt(c)), typeof _ == "string" && (_ = Ct(_)), ((d = _) === null || d === void 0 ? void 0 : d.length) !== 16)
      throw TypeError("Namespace must be array-like (16 iterable integer values, 0-255)");
    let m = new Uint8Array(16 + c.length);
    if (m.set(_), m.set(c, _.length), m = r(m), m[6] = m[6] & 15 | e, m[8] = m[8] & 63 | 128, h) {
      l = l || 0;
      for (let g = 0; g < 16; ++g)
        h[l + g] = m[g];
      return h;
    }
    return It(m);
  }
  try {
    y.name = t;
  } catch {
  }
  return y.DNS = Yt, y.URL = Zt, y;
}
function Ft(t, e, r, y) {
  switch (t) {
    case 0:
      return e & r ^ ~e & y;
    case 1:
      return e ^ r ^ y;
    case 2:
      return e & r ^ e & y ^ r & y;
    case 3:
      return e ^ r ^ y;
  }
}
function at(t, e) {
  return t << e | t >>> 32 - e;
}
function zt(t) {
  const e = [1518500249, 1859775393, 2400959708, 3395469782], r = [1732584193, 4023233417, 2562383102, 271733878, 3285377520];
  if (typeof t == "string") {
    const h = unescape(encodeURIComponent(t));
    t = [];
    for (let l = 0; l < h.length; ++l)
      t.push(h.charCodeAt(l));
  } else Array.isArray(t) || (t = Array.prototype.slice.call(t));
  t.push(128);
  const y = t.length / 4 + 2, c = Math.ceil(y / 16), _ = new Array(c);
  for (let h = 0; h < c; ++h) {
    const l = new Uint32Array(16);
    for (let d = 0; d < 16; ++d)
      l[d] = t[h * 64 + d * 4] << 24 | t[h * 64 + d * 4 + 1] << 16 | t[h * 64 + d * 4 + 2] << 8 | t[h * 64 + d * 4 + 3];
    _[h] = l;
  }
  _[c - 1][14] = (t.length - 1) * 8 / Math.pow(2, 32), _[c - 1][14] = Math.floor(_[c - 1][14]), _[c - 1][15] = (t.length - 1) * 8 & 4294967295;
  for (let h = 0; h < c; ++h) {
    const l = new Uint32Array(80);
    for (let f = 0; f < 16; ++f)
      l[f] = _[h][f];
    for (let f = 16; f < 80; ++f)
      l[f] = at(l[f - 3] ^ l[f - 8] ^ l[f - 14] ^ l[f - 16], 1);
    let d = r[0], m = r[1], g = r[2], E = r[3], k = r[4];
    for (let f = 0; f < 80; ++f) {
      const x = Math.floor(f / 20), w = at(d, 5) + Ft(x, m, g, E) + k + e[x] + l[f] >>> 0;
      k = E, E = g, g = at(m, 30) >>> 0, m = d, d = w;
    }
    r[0] = r[0] + d >>> 0, r[1] = r[1] + m >>> 0, r[2] = r[2] + g >>> 0, r[3] = r[3] + E >>> 0, r[4] = r[4] + k >>> 0;
  }
  return [r[0] >> 24 & 255, r[0] >> 16 & 255, r[0] >> 8 & 255, r[0] & 255, r[1] >> 24 & 255, r[1] >> 16 & 255, r[1] >> 8 & 255, r[1] & 255, r[2] >> 24 & 255, r[2] >> 16 & 255, r[2] >> 8 & 255, r[2] & 255, r[3] >> 24 & 255, r[3] >> 16 & 255, r[3] >> 8 & 255, r[3] & 255, r[4] >> 24 & 255, r[4] >> 16 & 255, r[4] >> 8 & 255, r[4] & 255];
}
const Kt = Bt("v5", 80, zt);
var it = function() {
  var t = /* @__PURE__ */ u(function(S, i, s, n) {
    for (s = s || {}, n = S.length; n--; s[S[n]] = i) ;
    return s;
  }, "o"), e = [6, 8, 10, 20, 22, 24, 26, 27, 28], r = [1, 10], y = [1, 11], c = [1, 12], _ = [1, 13], h = [1, 14], l = [1, 15], d = [1, 21], m = [1, 22], g = [1, 23], E = [1, 24], k = [1, 25], f = [6, 8, 10, 13, 15, 18, 19, 20, 22, 24, 26, 27, 28, 41, 42, 43, 44, 45], x = [1, 34], w = [27, 28, 46, 47], Y = [41, 42, 43, 44, 45], Z = [17, 34], B = [1, 54], T = [1, 53], D = [17, 34, 36, 38], O = {
    trace: /* @__PURE__ */ u(function() {
    }, "trace"),
    yy: {},
    symbols_: { error: 2, start: 3, ER_DIAGRAM: 4, document: 5, EOF: 6, line: 7, SPACE: 8, statement: 9, NEWLINE: 10, entityName: 11, relSpec: 12, ":": 13, role: 14, BLOCK_START: 15, attributes: 16, BLOCK_STOP: 17, SQS: 18, SQE: 19, title: 20, title_value: 21, acc_title: 22, acc_title_value: 23, acc_descr: 24, acc_descr_value: 25, acc_descr_multiline_value: 26, ALPHANUM: 27, ENTITY_NAME: 28, attribute: 29, attributeType: 30, attributeName: 31, attributeKeyTypeList: 32, attributeComment: 33, ATTRIBUTE_WORD: 34, attributeKeyType: 35, COMMA: 36, ATTRIBUTE_KEY: 37, COMMENT: 38, cardinality: 39, relType: 40, ZERO_OR_ONE: 41, ZERO_OR_MORE: 42, ONE_OR_MORE: 43, ONLY_ONE: 44, MD_PARENT: 45, NON_IDENTIFYING: 46, IDENTIFYING: 47, WORD: 48, $accept: 0, $end: 1 },
    terminals_: { 2: "error", 4: "ER_DIAGRAM", 6: "EOF", 8: "SPACE", 10: "NEWLINE", 13: ":", 15: "BLOCK_START", 17: "BLOCK_STOP", 18: "SQS", 19: "SQE", 20: "title", 21: "title_value", 22: "acc_title", 23: "acc_title_value", 24: "acc_descr", 25: "acc_descr_value", 26: "acc_descr_multiline_value", 27: "ALPHANUM", 28: "ENTITY_NAME", 34: "ATTRIBUTE_WORD", 36: "COMMA", 37: "ATTRIBUTE_KEY", 38: "COMMENT", 41: "ZERO_OR_ONE", 42: "ZERO_OR_MORE", 43: "ONE_OR_MORE", 44: "ONLY_ONE", 45: "MD_PARENT", 46: "NON_IDENTIFYING", 47: "IDENTIFYING", 48: "WORD" },
    productions_: [0, [3, 3], [5, 0], [5, 2], [7, 2], [7, 1], [7, 1], [7, 1], [9, 5], [9, 4], [9, 3], [9, 1], [9, 7], [9, 6], [9, 4], [9, 2], [9, 2], [9, 2], [9, 1], [11, 1], [11, 1], [16, 1], [16, 2], [29, 2], [29, 3], [29, 3], [29, 4], [30, 1], [31, 1], [32, 1], [32, 3], [35, 1], [33, 1], [12, 3], [39, 1], [39, 1], [39, 1], [39, 1], [39, 1], [40, 1], [40, 1], [14, 1], [14, 1], [14, 1]],
    performAction: /* @__PURE__ */ u(function(S, i, s, n, p, a, A) {
      var o = a.length - 1;
      switch (p) {
        case 1:
          break;
        case 2:
          this.$ = [];
          break;
        case 3:
          a[o - 1].push(a[o]), this.$ = a[o - 1];
          break;
        case 4:
        case 5:
          this.$ = a[o];
          break;
        case 6:
        case 7:
          this.$ = [];
          break;
        case 8:
          n.addEntity(a[o - 4]), n.addEntity(a[o - 2]), n.addRelationship(a[o - 4], a[o], a[o - 2], a[o - 3]);
          break;
        case 9:
          n.addEntity(a[o - 3]), n.addAttributes(a[o - 3], a[o - 1]);
          break;
        case 10:
          n.addEntity(a[o - 2]);
          break;
        case 11:
          n.addEntity(a[o]);
          break;
        case 12:
          n.addEntity(a[o - 6], a[o - 4]), n.addAttributes(a[o - 6], a[o - 1]);
          break;
        case 13:
          n.addEntity(a[o - 5], a[o - 3]);
          break;
        case 14:
          n.addEntity(a[o - 3], a[o - 1]);
          break;
        case 15:
        case 16:
          this.$ = a[o].trim(), n.setAccTitle(this.$);
          break;
        case 17:
        case 18:
          this.$ = a[o].trim(), n.setAccDescription(this.$);
          break;
        case 19:
        case 43:
          this.$ = a[o];
          break;
        case 20:
        case 41:
        case 42:
          this.$ = a[o].replace(/"/g, "");
          break;
        case 21:
        case 29:
          this.$ = [a[o]];
          break;
        case 22:
          a[o].push(a[o - 1]), this.$ = a[o];
          break;
        case 23:
          this.$ = { attributeType: a[o - 1], attributeName: a[o] };
          break;
        case 24:
          this.$ = { attributeType: a[o - 2], attributeName: a[o - 1], attributeKeyTypeList: a[o] };
          break;
        case 25:
          this.$ = { attributeType: a[o - 2], attributeName: a[o - 1], attributeComment: a[o] };
          break;
        case 26:
          this.$ = { attributeType: a[o - 3], attributeName: a[o - 2], attributeKeyTypeList: a[o - 1], attributeComment: a[o] };
          break;
        case 27:
        case 28:
        case 31:
          this.$ = a[o];
          break;
        case 30:
          a[o - 2].push(a[o]), this.$ = a[o - 2];
          break;
        case 32:
          this.$ = a[o].replace(/"/g, "");
          break;
        case 33:
          this.$ = { cardA: a[o], relType: a[o - 1], cardB: a[o - 2] };
          break;
        case 34:
          this.$ = n.Cardinality.ZERO_OR_ONE;
          break;
        case 35:
          this.$ = n.Cardinality.ZERO_OR_MORE;
          break;
        case 36:
          this.$ = n.Cardinality.ONE_OR_MORE;
          break;
        case 37:
          this.$ = n.Cardinality.ONLY_ONE;
          break;
        case 38:
          this.$ = n.Cardinality.MD_PARENT;
          break;
        case 39:
          this.$ = n.Identification.NON_IDENTIFYING;
          break;
        case 40:
          this.$ = n.Identification.IDENTIFYING;
          break;
      }
    }, "anonymous"),
    table: [{ 3: 1, 4: [1, 2] }, { 1: [3] }, t(e, [2, 2], { 5: 3 }), { 6: [1, 4], 7: 5, 8: [1, 6], 9: 7, 10: [1, 8], 11: 9, 20: r, 22: y, 24: c, 26: _, 27: h, 28: l }, t(e, [2, 7], { 1: [2, 1] }), t(e, [2, 3]), { 9: 16, 11: 9, 20: r, 22: y, 24: c, 26: _, 27: h, 28: l }, t(e, [2, 5]), t(e, [2, 6]), t(e, [2, 11], { 12: 17, 39: 20, 15: [1, 18], 18: [1, 19], 41: d, 42: m, 43: g, 44: E, 45: k }), { 21: [1, 26] }, { 23: [1, 27] }, { 25: [1, 28] }, t(e, [2, 18]), t(f, [2, 19]), t(f, [2, 20]), t(e, [2, 4]), { 11: 29, 27: h, 28: l }, { 16: 30, 17: [1, 31], 29: 32, 30: 33, 34: x }, { 11: 35, 27: h, 28: l }, { 40: 36, 46: [1, 37], 47: [1, 38] }, t(w, [2, 34]), t(w, [2, 35]), t(w, [2, 36]), t(w, [2, 37]), t(w, [2, 38]), t(e, [2, 15]), t(e, [2, 16]), t(e, [2, 17]), { 13: [1, 39] }, { 17: [1, 40] }, t(e, [2, 10]), { 16: 41, 17: [2, 21], 29: 32, 30: 33, 34: x }, { 31: 42, 34: [1, 43] }, { 34: [2, 27] }, { 19: [1, 44] }, { 39: 45, 41: d, 42: m, 43: g, 44: E, 45: k }, t(Y, [2, 39]), t(Y, [2, 40]), { 14: 46, 27: [1, 49], 28: [1, 48], 48: [1, 47] }, t(e, [2, 9]), { 17: [2, 22] }, t(Z, [2, 23], { 32: 50, 33: 51, 35: 52, 37: B, 38: T }), t([17, 34, 37, 38], [2, 28]), t(e, [2, 14], { 15: [1, 55] }), t([27, 28], [2, 33]), t(e, [2, 8]), t(e, [2, 41]), t(e, [2, 42]), t(e, [2, 43]), t(Z, [2, 24], { 33: 56, 36: [1, 57], 38: T }), t(Z, [2, 25]), t(D, [2, 29]), t(Z, [2, 32]), t(D, [2, 31]), { 16: 58, 17: [1, 59], 29: 32, 30: 33, 34: x }, t(Z, [2, 26]), { 35: 60, 37: B }, { 17: [1, 61] }, t(e, [2, 13]), t(D, [2, 30]), t(e, [2, 12])],
    defaultActions: { 34: [2, 27], 41: [2, 22] },
    parseError: /* @__PURE__ */ u(function(S, i) {
      if (i.recoverable)
        this.trace(S);
      else {
        var s = new Error(S);
        throw s.hash = i, s;
      }
    }, "parseError"),
    parse: /* @__PURE__ */ u(function(S) {
      var i = this, s = [0], n = [], p = [null], a = [], A = this.table, o = "", G = 0, ot = 0, _t = 2, lt = 1, ft = a.slice.call(arguments, 1), N = Object.create(this.lexer), K = { yy: {} };
      for (var q in this.yy)
        Object.prototype.hasOwnProperty.call(this.yy, q) && (K.yy[q] = this.yy[q]);
      N.setInput(S, K.yy), K.yy.lexer = N, K.yy.parser = this, typeof N.yylloc > "u" && (N.yylloc = {});
      var J = N.yylloc;
      a.push(J);
      var gt = N.options && N.options.ranges;
      typeof K.yy.parseError == "function" ? this.parseError = K.yy.parseError : this.parseError = Object.getPrototypeOf(this).parseError;
      function mt(L) {
        s.length = s.length - 2 * L, p.length = p.length - L, a.length = a.length - L;
      }
      u(mt, "popStack");
      function ct() {
        var L;
        return L = n.pop() || N.lex() || lt, typeof L != "number" && (L instanceof Array && (n = L, L = n.pop()), L = i.symbols_[L] || L), L;
      }
      u(ct, "lex");
      for (var $, U, I, tt, j = {}, X, F, ht, V; ; ) {
        if (U = s[s.length - 1], this.defaultActions[U] ? I = this.defaultActions[U] : (($ === null || typeof $ > "u") && ($ = ct()), I = A[U] && A[U][$]), typeof I > "u" || !I.length || !I[0]) {
          var et = "";
          V = [];
          for (X in A[U])
            this.terminals_[X] && X > _t && V.push("'" + this.terminals_[X] + "'");
          N.showPosition ? et = "Parse error on line " + (G + 1) + `:
` + N.showPosition() + `
Expecting ` + V.join(", ") + ", got '" + (this.terminals_[$] || $) + "'" : et = "Parse error on line " + (G + 1) + ": Unexpected " + ($ == lt ? "end of input" : "'" + (this.terminals_[$] || $) + "'"), this.parseError(et, {
            text: N.match,
            token: this.terminals_[$] || $,
            line: N.yylineno,
            loc: J,
            expected: V
          });
        }
        if (I[0] instanceof Array && I.length > 1)
          throw new Error("Parse Error: multiple actions possible at state: " + U + ", token: " + $);
        switch (I[0]) {
          case 1:
            s.push($), p.push(N.yytext), a.push(N.yylloc), s.push(I[1]), $ = null, ot = N.yyleng, o = N.yytext, G = N.yylineno, J = N.yylloc;
            break;
          case 2:
            if (F = this.productions_[I[1]][1], j.$ = p[p.length - F], j._$ = {
              first_line: a[a.length - (F || 1)].first_line,
              last_line: a[a.length - 1].last_line,
              first_column: a[a.length - (F || 1)].first_column,
              last_column: a[a.length - 1].last_column
            }, gt && (j._$.range = [
              a[a.length - (F || 1)].range[0],
              a[a.length - 1].range[1]
            ]), tt = this.performAction.apply(j, [
              o,
              ot,
              G,
              K.yy,
              I[1],
              p,
              a
            ].concat(ft)), typeof tt < "u")
              return tt;
            F && (s = s.slice(0, -1 * F * 2), p = p.slice(0, -1 * F), a = a.slice(0, -1 * F)), s.push(this.productions_[I[1]][0]), p.push(j.$), a.push(j._$), ht = A[s[s.length - 2]][s[s.length - 1]], s.push(ht);
            break;
          case 3:
            return !0;
        }
      }
      return !0;
    }, "parse")
  }, R = /* @__PURE__ */ function() {
    var S = {
      EOF: 1,
      parseError: /* @__PURE__ */ u(function(i, s) {
        if (this.yy.parser)
          this.yy.parser.parseError(i, s);
        else
          throw new Error(i);
      }, "parseError"),
      // resets the lexer, sets new input
      setInput: /* @__PURE__ */ u(function(i, s) {
        return this.yy = s || this.yy || {}, this._input = i, this._more = this._backtrack = this.done = !1, this.yylineno = this.yyleng = 0, this.yytext = this.matched = this.match = "", this.conditionStack = ["INITIAL"], this.yylloc = {
          first_line: 1,
          first_column: 0,
          last_line: 1,
          last_column: 0
        }, this.options.ranges && (this.yylloc.range = [0, 0]), this.offset = 0, this;
      }, "setInput"),
      // consumes and returns one char from the input
      input: /* @__PURE__ */ u(function() {
        var i = this._input[0];
        this.yytext += i, this.yyleng++, this.offset++, this.match += i, this.matched += i;
        var s = i.match(/(?:\r\n?|\n).*/g);
        return s ? (this.yylineno++, this.yylloc.last_line++) : this.yylloc.last_column++, this.options.ranges && this.yylloc.range[1]++, this._input = this._input.slice(1), i;
      }, "input"),
      // unshifts one char (or a string) into the input
      unput: /* @__PURE__ */ u(function(i) {
        var s = i.length, n = i.split(/(?:\r\n?|\n)/g);
        this._input = i + this._input, this.yytext = this.yytext.substr(0, this.yytext.length - s), this.offset -= s;
        var p = this.match.split(/(?:\r\n?|\n)/g);
        this.match = this.match.substr(0, this.match.length - 1), this.matched = this.matched.substr(0, this.matched.length - 1), n.length - 1 && (this.yylineno -= n.length - 1);
        var a = this.yylloc.range;
        return this.yylloc = {
          first_line: this.yylloc.first_line,
          last_line: this.yylineno + 1,
          first_column: this.yylloc.first_column,
          last_column: n ? (n.length === p.length ? this.yylloc.first_column : 0) + p[p.length - n.length].length - n[0].length : this.yylloc.first_column - s
        }, this.options.ranges && (this.yylloc.range = [a[0], a[0] + this.yyleng - s]), this.yyleng = this.yytext.length, this;
      }, "unput"),
      // When called from action, caches matched text and appends it on next action
      more: /* @__PURE__ */ u(function() {
        return this._more = !0, this;
      }, "more"),
      // When called from action, signals the lexer that this rule fails to match the input, so the next matching rule (regex) should be tested instead.
      reject: /* @__PURE__ */ u(function() {
        if (this.options.backtrack_lexer)
          this._backtrack = !0;
        else
          return this.parseError("Lexical error on line " + (this.yylineno + 1) + `. You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).
` + this.showPosition(), {
            text: "",
            token: null,
            line: this.yylineno
          });
        return this;
      }, "reject"),
      // retain first n characters of the match
      less: /* @__PURE__ */ u(function(i) {
        this.unput(this.match.slice(i));
      }, "less"),
      // displays already matched input, i.e. for error messages
      pastInput: /* @__PURE__ */ u(function() {
        var i = this.matched.substr(0, this.matched.length - this.match.length);
        return (i.length > 20 ? "..." : "") + i.substr(-20).replace(/\n/g, "");
      }, "pastInput"),
      // displays upcoming input, i.e. for error messages
      upcomingInput: /* @__PURE__ */ u(function() {
        var i = this.match;
        return i.length < 20 && (i += this._input.substr(0, 20 - i.length)), (i.substr(0, 20) + (i.length > 20 ? "..." : "")).replace(/\n/g, "");
      }, "upcomingInput"),
      // displays the character position where the lexing error occurred, i.e. for error messages
      showPosition: /* @__PURE__ */ u(function() {
        var i = this.pastInput(), s = new Array(i.length + 1).join("-");
        return i + this.upcomingInput() + `
` + s + "^";
      }, "showPosition"),
      // test the lexed token: return FALSE when not a match, otherwise return token
      test_match: /* @__PURE__ */ u(function(i, s) {
        var n, p, a;
        if (this.options.backtrack_lexer && (a = {
          yylineno: this.yylineno,
          yylloc: {
            first_line: this.yylloc.first_line,
            last_line: this.last_line,
            first_column: this.yylloc.first_column,
            last_column: this.yylloc.last_column
          },
          yytext: this.yytext,
          match: this.match,
          matches: this.matches,
          matched: this.matched,
          yyleng: this.yyleng,
          offset: this.offset,
          _more: this._more,
          _input: this._input,
          yy: this.yy,
          conditionStack: this.conditionStack.slice(0),
          done: this.done
        }, this.options.ranges && (a.yylloc.range = this.yylloc.range.slice(0))), p = i[0].match(/(?:\r\n?|\n).*/g), p && (this.yylineno += p.length), this.yylloc = {
          first_line: this.yylloc.last_line,
          last_line: this.yylineno + 1,
          first_column: this.yylloc.last_column,
          last_column: p ? p[p.length - 1].length - p[p.length - 1].match(/\r?\n?/)[0].length : this.yylloc.last_column + i[0].length
        }, this.yytext += i[0], this.match += i[0], this.matches = i, this.yyleng = this.yytext.length, this.options.ranges && (this.yylloc.range = [this.offset, this.offset += this.yyleng]), this._more = !1, this._backtrack = !1, this._input = this._input.slice(i[0].length), this.matched += i[0], n = this.performAction.call(this, this.yy, this, s, this.conditionStack[this.conditionStack.length - 1]), this.done && this._input && (this.done = !1), n)
          return n;
        if (this._backtrack) {
          for (var A in a)
            this[A] = a[A];
          return !1;
        }
        return !1;
      }, "test_match"),
      // return next match in input
      next: /* @__PURE__ */ u(function() {
        if (this.done)
          return this.EOF;
        this._input || (this.done = !0);
        var i, s, n, p;
        this._more || (this.yytext = "", this.match = "");
        for (var a = this._currentRules(), A = 0; A < a.length; A++)
          if (n = this._input.match(this.rules[a[A]]), n && (!s || n[0].length > s[0].length)) {
            if (s = n, p = A, this.options.backtrack_lexer) {
              if (i = this.test_match(n, a[A]), i !== !1)
                return i;
              if (this._backtrack) {
                s = !1;
                continue;
              } else
                return !1;
            } else if (!this.options.flex)
              break;
          }
        return s ? (i = this.test_match(s, a[p]), i !== !1 ? i : !1) : this._input === "" ? this.EOF : this.parseError("Lexical error on line " + (this.yylineno + 1) + `. Unrecognized text.
` + this.showPosition(), {
          text: "",
          token: null,
          line: this.yylineno
        });
      }, "next"),
      // return next match that has a token
      lex: /* @__PURE__ */ u(function() {
        var i = this.next();
        return i || this.lex();
      }, "lex"),
      // activates a new lexer condition state (pushes the new lexer condition state onto the condition stack)
      begin: /* @__PURE__ */ u(function(i) {
        this.conditionStack.push(i);
      }, "begin"),
      // pop the previously active lexer condition state off the condition stack
      popState: /* @__PURE__ */ u(function() {
        var i = this.conditionStack.length - 1;
        return i > 0 ? this.conditionStack.pop() : this.conditionStack[0];
      }, "popState"),
      // produce the lexer rule set which is active for the currently active lexer condition state
      _currentRules: /* @__PURE__ */ u(function() {
        return this.conditionStack.length && this.conditionStack[this.conditionStack.length - 1] ? this.conditions[this.conditionStack[this.conditionStack.length - 1]].rules : this.conditions.INITIAL.rules;
      }, "_currentRules"),
      // return the currently active lexer condition state; when an index argument is provided it produces the N-th previous condition state, if available
      topState: /* @__PURE__ */ u(function(i) {
        return i = this.conditionStack.length - 1 - Math.abs(i || 0), i >= 0 ? this.conditionStack[i] : "INITIAL";
      }, "topState"),
      // alias for begin(condition)
      pushState: /* @__PURE__ */ u(function(i) {
        this.begin(i);
      }, "pushState"),
      // return the number of states currently on the stack
      stateStackSize: /* @__PURE__ */ u(function() {
        return this.conditionStack.length;
      }, "stateStackSize"),
      options: { "case-insensitive": !0 },
      performAction: /* @__PURE__ */ u(function(i, s, n, p) {
        switch (n) {
          case 0:
            return this.begin("acc_title"), 22;
          case 1:
            return this.popState(), "acc_title_value";
          case 2:
            return this.begin("acc_descr"), 24;
          case 3:
            return this.popState(), "acc_descr_value";
          case 4:
            this.begin("acc_descr_multiline");
            break;
          case 5:
            this.popState();
            break;
          case 6:
            return "acc_descr_multiline_value";
          case 7:
            return 10;
          case 8:
            break;
          case 9:
            return 8;
          case 10:
            return 28;
          case 11:
            return 48;
          case 12:
            return 4;
          case 13:
            return this.begin("block"), 15;
          case 14:
            return 36;
          case 15:
            break;
          case 16:
            return 37;
          case 17:
            return 34;
          case 18:
            return 34;
          case 19:
            return 38;
          case 20:
            break;
          case 21:
            return this.popState(), 17;
          case 22:
            return s.yytext[0];
          case 23:
            return 18;
          case 24:
            return 19;
          case 25:
            return 41;
          case 26:
            return 43;
          case 27:
            return 43;
          case 28:
            return 43;
          case 29:
            return 41;
          case 30:
            return 41;
          case 31:
            return 42;
          case 32:
            return 42;
          case 33:
            return 42;
          case 34:
            return 42;
          case 35:
            return 42;
          case 36:
            return 43;
          case 37:
            return 42;
          case 38:
            return 43;
          case 39:
            return 44;
          case 40:
            return 44;
          case 41:
            return 44;
          case 42:
            return 44;
          case 43:
            return 41;
          case 44:
            return 42;
          case 45:
            return 43;
          case 46:
            return 45;
          case 47:
            return 46;
          case 48:
            return 47;
          case 49:
            return 47;
          case 50:
            return 46;
          case 51:
            return 46;
          case 52:
            return 46;
          case 53:
            return 27;
          case 54:
            return s.yytext[0];
          case 55:
            return 6;
        }
      }, "anonymous"),
      rules: [/^(?:accTitle\s*:\s*)/i, /^(?:(?!\n||)*[^\n]*)/i, /^(?:accDescr\s*:\s*)/i, /^(?:(?!\n||)*[^\n]*)/i, /^(?:accDescr\s*\{\s*)/i, /^(?:[\}])/i, /^(?:[^\}]*)/i, /^(?:[\n]+)/i, /^(?:\s+)/i, /^(?:[\s]+)/i, /^(?:"[^"%\r\n\v\b\\]+")/i, /^(?:"[^"]*")/i, /^(?:erDiagram\b)/i, /^(?:\{)/i, /^(?:,)/i, /^(?:\s+)/i, /^(?:\b((?:PK)|(?:FK)|(?:UK))\b)/i, /^(?:(.*?)[~](.*?)*[~])/i, /^(?:[\*A-Za-z_][A-Za-z0-9\-_\[\]\(\)]*)/i, /^(?:"[^"]*")/i, /^(?:[\n]+)/i, /^(?:\})/i, /^(?:.)/i, /^(?:\[)/i, /^(?:\])/i, /^(?:one or zero\b)/i, /^(?:one or more\b)/i, /^(?:one or many\b)/i, /^(?:1\+)/i, /^(?:\|o\b)/i, /^(?:zero or one\b)/i, /^(?:zero or more\b)/i, /^(?:zero or many\b)/i, /^(?:0\+)/i, /^(?:\}o\b)/i, /^(?:many\(0\))/i, /^(?:many\(1\))/i, /^(?:many\b)/i, /^(?:\}\|)/i, /^(?:one\b)/i, /^(?:only one\b)/i, /^(?:1\b)/i, /^(?:\|\|)/i, /^(?:o\|)/i, /^(?:o\{)/i, /^(?:\|\{)/i, /^(?:\s*u\b)/i, /^(?:\.\.)/i, /^(?:--)/i, /^(?:to\b)/i, /^(?:optionally to\b)/i, /^(?:\.-)/i, /^(?:-\.)/i, /^(?:[A-Za-z_][A-Za-z0-9\-_]*)/i, /^(?:.)/i, /^(?:$)/i],
      conditions: { acc_descr_multiline: { rules: [5, 6], inclusive: !1 }, acc_descr: { rules: [3], inclusive: !1 }, acc_title: { rules: [1], inclusive: !1 }, block: { rules: [14, 15, 16, 17, 18, 19, 20, 21, 22], inclusive: !1 }, INITIAL: { rules: [0, 2, 4, 7, 8, 9, 10, 11, 12, 13, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55], inclusive: !0 } }
    };
    return S;
  }();
  O.lexer = R;
  function v() {
    this.yy = {};
  }
  return u(v, "Parser"), v.prototype = O, O.Parser = v, new v();
}();
it.parser = it;
var Ut = it, H = /* @__PURE__ */ new Map(), st = [], Ht = {
  ZERO_OR_ONE: "ZERO_OR_ONE",
  ZERO_OR_MORE: "ZERO_OR_MORE",
  ONE_OR_MORE: "ONE_OR_MORE",
  ONLY_ONE: "ONLY_ONE",
  MD_PARENT: "MD_PARENT"
}, jt = {
  NON_IDENTIFYING: "NON_IDENTIFYING",
  IDENTIFYING: "IDENTIFYING"
}, dt = /* @__PURE__ */ u(function(t, e = void 0) {
  return H.has(t) ? !H.get(t).alias && e && (H.get(t).alias = e, Q.info(`Add alias '${e}' to entity '${t}'`)) : (H.set(t, { attributes: [], alias: e }), Q.info("Added new entity :", t)), H.get(t);
}, "addEntity"), Qt = /* @__PURE__ */ u(() => H, "getEntities"), Wt = /* @__PURE__ */ u(function(t, e) {
  let r = dt(t), y;
  for (y = e.length - 1; y >= 0; y--)
    r.attributes.push(e[y]), Q.debug("Added attribute ", e[y].attributeName);
}, "addAttributes"), Gt = /* @__PURE__ */ u(function(t, e, r, y) {
  let c = {
    entityA: t,
    roleA: e,
    entityB: r,
    relSpec: y
  };
  st.push(c), Q.debug("Added new relationship :", c);
}, "addRelationship"), Xt = /* @__PURE__ */ u(() => st, "getRelationships"), Vt = /* @__PURE__ */ u(function() {
  H = /* @__PURE__ */ new Map(), st = [], At();
}, "clear"), qt = {
  Cardinality: Ht,
  Identification: jt,
  getConfig: /* @__PURE__ */ u(() => z().er, "getConfig"),
  addEntity: dt,
  addAttributes: Wt,
  getEntities: Qt,
  addRelationship: Gt,
  getRelationships: Xt,
  clear: Vt,
  setAccTitle: Nt,
  getAccTitle: Rt,
  setAccDescription: Ot,
  getAccDescription: bt,
  setDiagramTitle: kt,
  getDiagramTitle: Et
}, C = {
  ONLY_ONE_START: "ONLY_ONE_START",
  ONLY_ONE_END: "ONLY_ONE_END",
  ZERO_OR_ONE_START: "ZERO_OR_ONE_START",
  ZERO_OR_ONE_END: "ZERO_OR_ONE_END",
  ONE_OR_MORE_START: "ONE_OR_MORE_START",
  ONE_OR_MORE_END: "ONE_OR_MORE_END",
  ZERO_OR_MORE_START: "ZERO_OR_MORE_START",
  ZERO_OR_MORE_END: "ZERO_OR_MORE_END",
  MD_PARENT_END: "MD_PARENT_END",
  MD_PARENT_START: "MD_PARENT_START"
}, Jt = /* @__PURE__ */ u(function(t, e) {
  let r;
  t.append("defs").append("marker").attr("id", C.MD_PARENT_START).attr("refX", 0).attr("refY", 7).attr("markerWidth", 190).attr("markerHeight", 240).attr("orient", "auto").append("path").attr("d", "M 18,7 L9,13 L1,7 L9,1 Z"), t.append("defs").append("marker").attr("id", C.MD_PARENT_END).attr("refX", 19).attr("refY", 7).attr("markerWidth", 20).attr("markerHeight", 28).attr("orient", "auto").append("path").attr("d", "M 18,7 L9,13 L1,7 L9,1 Z"), t.append("defs").append("marker").attr("id", C.ONLY_ONE_START).attr("refX", 0).attr("refY", 9).attr("markerWidth", 18).attr("markerHeight", 18).attr("orient", "auto").append("path").attr("stroke", e.stroke).attr("fill", "none").attr("d", "M9,0 L9,18 M15,0 L15,18"), t.append("defs").append("marker").attr("id", C.ONLY_ONE_END).attr("refX", 18).attr("refY", 9).attr("markerWidth", 18).attr("markerHeight", 18).attr("orient", "auto").append("path").attr("stroke", e.stroke).attr("fill", "none").attr("d", "M3,0 L3,18 M9,0 L9,18"), r = t.append("defs").append("marker").attr("id", C.ZERO_OR_ONE_START).attr("refX", 0).attr("refY", 9).attr("markerWidth", 30).attr("markerHeight", 18).attr("orient", "auto"), r.append("circle").attr("stroke", e.stroke).attr("fill", "white").attr("cx", 21).attr("cy", 9).attr("r", 6), r.append("path").attr("stroke", e.stroke).attr("fill", "none").attr("d", "M9,0 L9,18"), r = t.append("defs").append("marker").attr("id", C.ZERO_OR_ONE_END).attr("refX", 30).attr("refY", 9).attr("markerWidth", 30).attr("markerHeight", 18).attr("orient", "auto"), r.append("circle").attr("stroke", e.stroke).attr("fill", "white").attr("cx", 9).attr("cy", 9).attr("r", 6), r.append("path").attr("stroke", e.stroke).attr("fill", "none").attr("d", "M21,0 L21,18"), t.append("defs").append("marker").attr("id", C.ONE_OR_MORE_START).attr("refX", 18).attr("refY", 18).attr("markerWidth", 45).attr("markerHeight", 36).attr("orient", "auto").append("path").attr("stroke", e.stroke).attr("fill", "none").attr("d", "M0,18 Q 18,0 36,18 Q 18,36 0,18 M42,9 L42,27"), t.append("defs").append("marker").attr("id", C.ONE_OR_MORE_END).attr("refX", 27).attr("refY", 18).attr("markerWidth", 45).attr("markerHeight", 36).attr("orient", "auto").append("path").attr("stroke", e.stroke).attr("fill", "none").attr("d", "M3,9 L3,27 M9,18 Q27,0 45,18 Q27,36 9,18"), r = t.append("defs").append("marker").attr("id", C.ZERO_OR_MORE_START).attr("refX", 18).attr("refY", 18).attr("markerWidth", 57).attr("markerHeight", 36).attr("orient", "auto"), r.append("circle").attr("stroke", e.stroke).attr("fill", "white").attr("cx", 48).attr("cy", 18).attr("r", 6), r.append("path").attr("stroke", e.stroke).attr("fill", "none").attr("d", "M0,18 Q18,0 36,18 Q18,36 0,18"), r = t.append("defs").append("marker").attr("id", C.ZERO_OR_MORE_END).attr("refX", 39).attr("refY", 18).attr("markerWidth", 57).attr("markerHeight", 36).attr("orient", "auto"), r.append("circle").attr("stroke", e.stroke).attr("fill", "white").attr("cx", 9).attr("cy", 18).attr("r", 6), r.append("path").attr("stroke", e.stroke).attr("fill", "none").attr("d", "M21,18 Q39,0 57,18 Q39,36 21,18");
}, "insertMarkers"), P = {
  ERMarkers: C,
  insertMarkers: Jt
}, te = /[^\dA-Za-z](\W)*/g, b = {}, W = /* @__PURE__ */ new Map(), ee = /* @__PURE__ */ u(function(t) {
  const e = Object.keys(t);
  for (const r of e)
    b[r] = t[r];
}, "setConf"), re = /* @__PURE__ */ u((t, e, r) => {
  const y = b.entityPadding / 3, c = b.entityPadding / 3, _ = b.fontSize * 0.85, h = e.node().getBBox(), l = [];
  let d = !1, m = !1, g = 0, E = 0, k = 0, f = 0, x = h.height + y * 2, w = 1;
  r.forEach((T) => {
    T.attributeKeyTypeList !== void 0 && T.attributeKeyTypeList.length > 0 && (d = !0), T.attributeComment !== void 0 && (m = !0);
  }), r.forEach((T) => {
    const D = `${e.node().id}-attr-${w}`;
    let O = 0;
    const R = St(T.attributeType), v = t.append("text").classed("er entityLabel", !0).attr("id", `${D}-type`).attr("x", 0).attr("y", 0).style("dominant-baseline", "middle").style("text-anchor", "left").style("font-family", z().fontFamily).style("font-size", _ + "px").text(R), S = t.append("text").classed("er entityLabel", !0).attr("id", `${D}-name`).attr("x", 0).attr("y", 0).style("dominant-baseline", "middle").style("text-anchor", "left").style("font-family", z().fontFamily).style("font-size", _ + "px").text(T.attributeName), i = {};
    i.tn = v, i.nn = S;
    const s = v.node().getBBox(), n = S.node().getBBox();
    if (g = Math.max(g, s.width), E = Math.max(E, n.width), O = Math.max(s.height, n.height), d) {
      const p = T.attributeKeyTypeList !== void 0 ? T.attributeKeyTypeList.join(",") : "", a = t.append("text").classed("er entityLabel", !0).attr("id", `${D}-key`).attr("x", 0).attr("y", 0).style("dominant-baseline", "middle").style("text-anchor", "left").style("font-family", z().fontFamily).style("font-size", _ + "px").text(p);
      i.kn = a;
      const A = a.node().getBBox();
      k = Math.max(k, A.width), O = Math.max(O, A.height);
    }
    if (m) {
      const p = t.append("text").classed("er entityLabel", !0).attr("id", `${D}-comment`).attr("x", 0).attr("y", 0).style("dominant-baseline", "middle").style("text-anchor", "left").style("font-family", z().fontFamily).style("font-size", _ + "px").text(T.attributeComment || "");
      i.cn = p;
      const a = p.node().getBBox();
      f = Math.max(f, a.width), O = Math.max(O, a.height);
    }
    i.height = O, l.push(i), x += O + y * 2, w += 1;
  });
  let Y = 4;
  d && (Y += 2), m && (Y += 2);
  const Z = g + E + k + f, B = {
    width: Math.max(
      b.minEntityWidth,
      Math.max(
        h.width + b.entityPadding * 2,
        Z + c * Y
      )
    ),
    height: r.length > 0 ? x : Math.max(b.minEntityHeight, h.height + b.entityPadding * 2)
  };
  if (r.length > 0) {
    const T = Math.max(
      0,
      (B.width - Z - c * Y) / (Y / 2)
    );
    e.attr(
      "transform",
      "translate(" + B.width / 2 + "," + (y + h.height / 2) + ")"
    );
    let D = h.height + y * 2, O = "attributeBoxOdd";
    l.forEach((R) => {
      const v = D + y + R.height / 2;
      R.tn.attr("transform", "translate(" + c + "," + v + ")");
      const S = t.insert("rect", "#" + R.tn.node().id).classed(`er ${O}`, !0).attr("x", 0).attr("y", D).attr("width", g + c * 2 + T).attr("height", R.height + y * 2), i = parseFloat(S.attr("x")) + parseFloat(S.attr("width"));
      R.nn.attr(
        "transform",
        "translate(" + (i + c) + "," + v + ")"
      );
      const s = t.insert("rect", "#" + R.nn.node().id).classed(`er ${O}`, !0).attr("x", i).attr("y", D).attr("width", E + c * 2 + T).attr("height", R.height + y * 2);
      let n = parseFloat(s.attr("x")) + parseFloat(s.attr("width"));
      if (d) {
        R.kn.attr(
          "transform",
          "translate(" + (n + c) + "," + v + ")"
        );
        const p = t.insert("rect", "#" + R.kn.node().id).classed(`er ${O}`, !0).attr("x", n).attr("y", D).attr("width", k + c * 2 + T).attr("height", R.height + y * 2);
        n = parseFloat(p.attr("x")) + parseFloat(p.attr("width"));
      }
      m && (R.cn.attr(
        "transform",
        "translate(" + (n + c) + "," + v + ")"
      ), t.insert("rect", "#" + R.cn.node().id).classed(`er ${O}`, "true").attr("x", n).attr("y", D).attr("width", f + c * 2 + T).attr("height", R.height + y * 2)), D += R.height + y * 2, O = O === "attributeBoxOdd" ? "attributeBoxEven" : "attributeBoxOdd";
    });
  } else
    B.height = Math.max(b.minEntityHeight, x), e.attr("transform", "translate(" + B.width / 2 + "," + B.height / 2 + ")");
  return B;
}, "drawAttributes"), ae = /* @__PURE__ */ u(function(t, e, r) {
  const y = [...e.keys()];
  let c;
  return y.forEach(function(_) {
    const h = pt(_, "entity");
    W.set(_, h);
    const l = t.append("g").attr("id", h);
    c = c === void 0 ? h : c;
    const d = "text-" + h, m = l.append("text").classed("er entityLabel", !0).attr("id", d).attr("x", 0).attr("y", 0).style("dominant-baseline", "middle").style("text-anchor", "middle").style("font-family", z().fontFamily).style("font-size", b.fontSize + "px").text(e.get(_).alias ?? _), { width: g, height: E } = re(
      l,
      m,
      e.get(_).attributes
    ), k = l.insert("rect", "#" + d).classed("er entityBox", !0).attr("x", 0).attr("y", 0).attr("width", g).attr("height", E).node().getBBox();
    r.setNode(h, {
      width: k.width,
      height: k.height,
      shape: "rect",
      id: h
    });
  }), c;
}, "drawEntities"), ie = /* @__PURE__ */ u(function(t, e) {
  e.nodes().forEach(function(r) {
    r !== void 0 && e.node(r) !== void 0 && t.select("#" + r).attr(
      "transform",
      "translate(" + (e.node(r).x - e.node(r).width / 2) + "," + (e.node(r).y - e.node(r).height / 2) + " )"
    );
  });
}, "adjustEntities"), yt = /* @__PURE__ */ u(function(t) {
  return (t.entityA + t.roleA + t.entityB).replace(/\s/g, "");
}, "getEdgeName"), ne = /* @__PURE__ */ u(function(t, e) {
  return t.forEach(function(r) {
    e.setEdge(
      W.get(r.entityA),
      W.get(r.entityB),
      { relationship: r },
      yt(r)
    );
  }), t;
}, "addRelationships"), ut = 0, se = /* @__PURE__ */ u(function(t, e, r, y, c) {
  ut++;
  const _ = r.edge(
    W.get(e.entityA),
    W.get(e.entityB),
    yt(e)
  ), h = Mt().x(function(w) {
    return w.x;
  }).y(function(w) {
    return w.y;
  }).curve(wt), l = t.insert("path", "#" + y).classed("er relationshipLine", !0).attr("d", h(_.points)).style("stroke", b.stroke).style("fill", "none");
  e.relSpec.relType === c.db.Identification.NON_IDENTIFYING && l.attr("stroke-dasharray", "8,8");
  let d = "";
  switch (b.arrowMarkerAbsolute && (d = window.location.protocol + "//" + window.location.host + window.location.pathname + window.location.search, d = d.replace(/\(/g, "\\("), d = d.replace(/\)/g, "\\)")), e.relSpec.cardA) {
    case c.db.Cardinality.ZERO_OR_ONE:
      l.attr("marker-end", "url(" + d + "#" + P.ERMarkers.ZERO_OR_ONE_END + ")");
      break;
    case c.db.Cardinality.ZERO_OR_MORE:
      l.attr("marker-end", "url(" + d + "#" + P.ERMarkers.ZERO_OR_MORE_END + ")");
      break;
    case c.db.Cardinality.ONE_OR_MORE:
      l.attr("marker-end", "url(" + d + "#" + P.ERMarkers.ONE_OR_MORE_END + ")");
      break;
    case c.db.Cardinality.ONLY_ONE:
      l.attr("marker-end", "url(" + d + "#" + P.ERMarkers.ONLY_ONE_END + ")");
      break;
    case c.db.Cardinality.MD_PARENT:
      l.attr("marker-end", "url(" + d + "#" + P.ERMarkers.MD_PARENT_END + ")");
      break;
  }
  switch (e.relSpec.cardB) {
    case c.db.Cardinality.ZERO_OR_ONE:
      l.attr(
        "marker-start",
        "url(" + d + "#" + P.ERMarkers.ZERO_OR_ONE_START + ")"
      );
      break;
    case c.db.Cardinality.ZERO_OR_MORE:
      l.attr(
        "marker-start",
        "url(" + d + "#" + P.ERMarkers.ZERO_OR_MORE_START + ")"
      );
      break;
    case c.db.Cardinality.ONE_OR_MORE:
      l.attr(
        "marker-start",
        "url(" + d + "#" + P.ERMarkers.ONE_OR_MORE_START + ")"
      );
      break;
    case c.db.Cardinality.ONLY_ONE:
      l.attr("marker-start", "url(" + d + "#" + P.ERMarkers.ONLY_ONE_START + ")");
      break;
    case c.db.Cardinality.MD_PARENT:
      l.attr("marker-start", "url(" + d + "#" + P.ERMarkers.MD_PARENT_START + ")");
      break;
  }
  const m = l.node().getTotalLength(), g = l.node().getPointAtLength(m * 0.5), E = "rel" + ut, k = e.roleA.split(/<br ?\/>/g), f = t.append("text").classed("er relationshipLabel", !0).attr("id", E).attr("x", g.x).attr("y", g.y).style("text-anchor", "middle").style("dominant-baseline", "middle").style("font-family", z().fontFamily).style("font-size", b.fontSize + "px");
  if (k.length == 1)
    f.text(e.roleA);
  else {
    const w = -(k.length - 1) * 0.5;
    k.forEach((Y, Z) => {
      f.append("tspan").attr("x", g.x).attr("dy", `${Z === 0 ? w : 1}em`).text(Y);
    });
  }
  const x = f.node().getBBox();
  t.insert("rect", "#" + E).classed("er relationshipLabelBox", !0).attr("x", g.x - x.width / 2).attr("y", g.y - x.height / 2).attr("width", x.width).attr("height", x.height);
}, "drawRelationshipFromLayout"), oe = /* @__PURE__ */ u(function(t, e, r, y) {
  b = z().er, Q.info("Drawing ER diagram");
  const c = z().securityLevel;
  let _;
  c === "sandbox" && (_ = rt("#i" + e));
  const h = (c === "sandbox" ? rt(_.nodes()[0].contentDocument.body) : rt("body")).select(`[id='${e}']`);
  P.insertMarkers(h, b);
  let l;
  l = new Dt({
    multigraph: !0,
    directed: !0,
    compound: !1
  }).setGraph({
    rankdir: b.layoutDirection,
    marginx: 20,
    marginy: 20,
    nodesep: 100,
    edgesep: 100,
    ranksep: 100
  }).setDefaultEdgeLabel(function() {
    return {};
  });
  const d = ae(h, y.db.getEntities(), l), m = ne(y.db.getRelationships(), l);
  $t(l), ie(h, l), m.forEach(function(x) {
    se(h, x, l, d, y);
  });
  const g = b.diagramPadding;
  xt.insertTitle(h, "entityTitleText", b.titleTopMargin, y.db.getDiagramTitle());
  const E = h.node().getBBox(), k = E.width + g * 2, f = E.height + g * 2;
  Tt(h, f, k, b.useMaxWidth), h.attr("viewBox", `${E.x - g} ${E.y - g} ${k} ${f}`);
}, "draw"), le = "28e9f9db-3c8d-5aa5-9faf-44286ae5937c";
function pt(t = "", e = "") {
  const r = t.replace(te, "");
  return `${nt(e)}${nt(r)}${Kt(
    t,
    le
  )}`;
}
u(pt, "generateId");
function nt(t = "") {
  return t.length > 0 ? `${t}-` : "";
}
u(nt, "strWithHyphen");
var ce = {
  setConf: ee,
  draw: oe
}, he = /* @__PURE__ */ u((t) => `
  .entityBox {
    fill: ${t.mainBkg};
    stroke: ${t.nodeBorder};
  }

  .attributeBoxOdd {
    fill: ${t.attributeBackgroundColorOdd};
    stroke: ${t.nodeBorder};
  }

  .attributeBoxEven {
    fill:  ${t.attributeBackgroundColorEven};
    stroke: ${t.nodeBorder};
  }

  .relationshipLabelBox {
    fill: ${t.tertiaryColor};
    opacity: 0.7;
    background-color: ${t.tertiaryColor};
      rect {
        opacity: 0.5;
      }
  }

    .relationshipLine {
      stroke: ${t.lineColor};
    }

  .entityTitleText {
    text-anchor: middle;
    font-size: 18px;
    fill: ${t.textColor};
  }    
  #MD_PARENT_START {
    fill: #f5f5f5 !important;
    stroke: ${t.lineColor} !important;
    stroke-width: 1;
  }
  #MD_PARENT_END {
    fill: #f5f5f5 !important;
    stroke: ${t.lineColor} !important;
    stroke-width: 1;
  }
  
`, "getStyles"), ue = he, _e = {
  parser: Ut,
  db: qt,
  renderer: ce,
  styles: ue
};
export {
  _e as diagram
};
