import { n as d, r as I } from "./chunk-AGHRB4JF.js";
import { $ as ae, L as V, O as ce, Q as le, b as $, d as F, tt as he, y as de } from "./chunk-ICPOFSXX.js";
import { t as ge } from "./chunk-55IACEB6.js";
import { t as ue } from "./chunk-EDXVE4YY.js";
import { r as pe, t as fe } from "./chunk-336JU56O.js";
var _ = [];
for (let e = 0; e < 256; ++e) _.push((e + 256).toString(16).slice(1));
function me(e, n = 0) {
  return (_[e[n + 0]] + _[e[n + 1]] + _[e[n + 2]] + _[e[n + 3]] + "-" + _[e[n + 4]] + _[e[n + 5]] + "-" + _[e[n + 6]] + _[e[n + 7]] + "-" + _[e[n + 8]] + _[e[n + 9]] + "-" + _[e[n + 10]] + _[e[n + 11]] + _[e[n + 12]] + _[e[n + 13]] + _[e[n + 14]] + _[e[n + 15]]).toLowerCase();
}
var ye = new Uint8Array(16);
function Ee() {
  return crypto.getRandomValues(ye);
}
function _e(e, n, c) {
  return !n && !e && crypto.randomUUID ? crypto.randomUUID() : ke(e, n, c);
}
function ke(e, n, c) {
  e = e || {};
  const o = e.random ?? e.rng?.() ?? Ee();
  if (o.length < 16) throw new Error("Random bytes length must be >= 16");
  if (o[6] = o[6] & 15 | 64, o[8] = o[8] & 63 | 128, n) {
    if (c = c || 0, c < 0 || c + 16 > n.length) throw new RangeError(`UUID byte range ${c}:${c + 15} is out of buffer bounds`);
    for (let t = 0; t < 16; ++t) n[c + t] = o[t];
    return n;
  }
  return me(o);
}
var Y = (function() {
  var e = /* @__PURE__ */ d(function(s, i, h, a) {
    for (h = h || {}, a = s.length; a--; h[s[a]] = i) ;
    return h;
  }, "o"), n = [1, 4], c = [1, 13], o = [1, 12], t = [1, 15], g = [1, 16], f = [1, 20], p = [1, 19], D = [
    6,
    7,
    8
  ], C = [1, 26], w = [1, 24], y = [1, 25], k = [
    6,
    7,
    11
  ], Q = [
    1,
    6,
    13,
    15,
    16,
    19,
    22
  ], q = [1, 33], J = [1, 34], R = [
    1,
    6,
    7,
    11,
    13,
    15,
    16,
    19,
    22
  ], G = {
    trace: /* @__PURE__ */ d(function() {
    }, "trace"),
    yy: {},
    symbols_: {
      error: 2,
      start: 3,
      mindMap: 4,
      spaceLines: 5,
      SPACELINE: 6,
      NL: 7,
      MINDMAP: 8,
      document: 9,
      stop: 10,
      EOF: 11,
      statement: 12,
      SPACELIST: 13,
      node: 14,
      ICON: 15,
      CLASS: 16,
      nodeWithId: 17,
      nodeWithoutId: 18,
      NODE_DSTART: 19,
      NODE_DESCR: 20,
      NODE_DEND: 21,
      NODE_ID: 22,
      $accept: 0,
      $end: 1
    },
    terminals_: {
      2: "error",
      6: "SPACELINE",
      7: "NL",
      8: "MINDMAP",
      11: "EOF",
      13: "SPACELIST",
      15: "ICON",
      16: "CLASS",
      19: "NODE_DSTART",
      20: "NODE_DESCR",
      21: "NODE_DEND",
      22: "NODE_ID"
    },
    productions_: [
      0,
      [3, 1],
      [3, 2],
      [5, 1],
      [5, 2],
      [5, 2],
      [4, 2],
      [4, 3],
      [10, 1],
      [10, 1],
      [10, 1],
      [10, 2],
      [10, 2],
      [9, 3],
      [9, 2],
      [12, 2],
      [12, 2],
      [12, 2],
      [12, 1],
      [12, 1],
      [12, 1],
      [12, 1],
      [12, 1],
      [14, 1],
      [14, 1],
      [18, 3],
      [17, 1],
      [17, 4]
    ],
    performAction: /* @__PURE__ */ d(function(i, h, a, l, m, r, A) {
      var u = r.length - 1;
      switch (m) {
        case 6:
        case 7:
          return l;
        case 8:
          l.getLogger().trace("Stop NL ");
          break;
        case 9:
          l.getLogger().trace("Stop EOF ");
          break;
        case 11:
          l.getLogger().trace("Stop NL2 ");
          break;
        case 12:
          l.getLogger().trace("Stop EOF2 ");
          break;
        case 15:
          l.getLogger().info("Node: ", r[u].id), l.addNode(r[u - 1].length, r[u].id, r[u].descr, r[u].type);
          break;
        case 16:
          l.getLogger().trace("Icon: ", r[u]), l.decorateNode({ icon: r[u] });
          break;
        case 17:
        case 21:
          l.decorateNode({ class: r[u] });
          break;
        case 18:
          l.getLogger().trace("SPACELIST");
          break;
        case 19:
          l.getLogger().trace("Node: ", r[u].id), l.addNode(0, r[u].id, r[u].descr, r[u].type);
          break;
        case 20:
          l.decorateNode({ icon: r[u] });
          break;
        case 25:
          l.getLogger().trace("node found ..", r[u - 2]), this.$ = {
            id: r[u - 1],
            descr: r[u - 1],
            type: l.getType(r[u - 2], r[u])
          };
          break;
        case 26:
          this.$ = {
            id: r[u],
            descr: r[u],
            type: l.nodeType.DEFAULT
          };
          break;
        case 27:
          l.getLogger().trace("node found ..", r[u - 3]), this.$ = {
            id: r[u - 3],
            descr: r[u - 1],
            type: l.getType(r[u - 2], r[u])
          };
          break;
      }
    }, "anonymous"),
    table: [
      {
        3: 1,
        4: 2,
        5: 3,
        6: [1, 5],
        8: n
      },
      { 1: [3] },
      { 1: [2, 1] },
      {
        4: 6,
        6: [1, 7],
        7: [1, 8],
        8: n
      },
      {
        6: c,
        7: [1, 10],
        9: 9,
        12: 11,
        13: o,
        14: 14,
        15: t,
        16: g,
        17: 17,
        18: 18,
        19: f,
        22: p
      },
      e(D, [2, 3]),
      { 1: [2, 2] },
      e(D, [2, 4]),
      e(D, [2, 5]),
      {
        1: [2, 6],
        6: c,
        12: 21,
        13: o,
        14: 14,
        15: t,
        16: g,
        17: 17,
        18: 18,
        19: f,
        22: p
      },
      {
        6: c,
        9: 22,
        12: 11,
        13: o,
        14: 14,
        15: t,
        16: g,
        17: 17,
        18: 18,
        19: f,
        22: p
      },
      {
        6: C,
        7: w,
        10: 23,
        11: y
      },
      e(k, [2, 22], {
        17: 17,
        18: 18,
        14: 27,
        15: [1, 28],
        16: [1, 29],
        19: f,
        22: p
      }),
      e(k, [2, 18]),
      e(k, [2, 19]),
      e(k, [2, 20]),
      e(k, [2, 21]),
      e(k, [2, 23]),
      e(k, [2, 24]),
      e(k, [2, 26], { 19: [1, 30] }),
      { 20: [1, 31] },
      {
        6: C,
        7: w,
        10: 32,
        11: y
      },
      {
        1: [2, 7],
        6: c,
        12: 21,
        13: o,
        14: 14,
        15: t,
        16: g,
        17: 17,
        18: 18,
        19: f,
        22: p
      },
      e(Q, [2, 14], {
        7: q,
        11: J
      }),
      e(R, [2, 8]),
      e(R, [2, 9]),
      e(R, [2, 10]),
      e(k, [2, 15]),
      e(k, [2, 16]),
      e(k, [2, 17]),
      { 20: [1, 35] },
      { 21: [1, 36] },
      e(Q, [2, 13], {
        7: q,
        11: J
      }),
      e(R, [2, 11]),
      e(R, [2, 12]),
      { 21: [1, 37] },
      e(k, [2, 25]),
      e(k, [2, 27])
    ],
    defaultActions: {
      2: [2, 1],
      6: [2, 2]
    },
    parseError: /* @__PURE__ */ d(function(i, h) {
      if (h.recoverable) this.trace(i);
      else {
        var a = new Error(i);
        throw a.hash = h, a;
      }
    }, "parseError"),
    parse: /* @__PURE__ */ d(function(i) {
      var h = this, a = [0], l = [], m = [null], r = [], A = this.table, u = "", P = 0, K = 0, Z = 0, ie = 2, ee = 1, se = r.slice.call(arguments, 1), E = Object.create(this.lexer), T = { yy: {} };
      for (var j in this.yy) Object.prototype.hasOwnProperty.call(this.yy, j) && (T.yy[j] = this.yy[j]);
      E.setInput(i, T.yy), T.yy.lexer = E, T.yy.parser = this, typeof E.yylloc > "u" && (E.yylloc = {});
      var H = E.yylloc;
      r.push(H);
      var re = E.options && E.options.ranges;
      typeof T.yy.parseError == "function" ? this.parseError = T.yy.parseError : this.parseError = Object.getPrototypeOf(this).parseError;
      function oe(N) {
        a.length = a.length - 2 * N, m.length = m.length - N, r.length = r.length - N;
      }
      d(oe, "popStack");
      function te() {
        var N = l.pop() || E.lex() || ee;
        return typeof N != "number" && (N instanceof Array && (l = N, N = l.pop()), N = h.symbols_[N] || N), N;
      }
      d(te, "lex");
      for (var b, W, v, S, z, O = {}, U, L, ne, M; ; ) {
        if (v = a[a.length - 1], this.defaultActions[v] ? S = this.defaultActions[v] : ((b === null || typeof b > "u") && (b = te()), S = A[v] && A[v][b]), typeof S > "u" || !S.length || !S[0]) {
          var X = "";
          M = [];
          for (U in A[v]) this.terminals_[U] && U > ie && M.push("'" + this.terminals_[U] + "'");
          E.showPosition ? X = "Parse error on line " + (P + 1) + `:
` + E.showPosition() + `
Expecting ` + M.join(", ") + ", got '" + (this.terminals_[b] || b) + "'" : X = "Parse error on line " + (P + 1) + ": Unexpected " + (b == ee ? "end of input" : "'" + (this.terminals_[b] || b) + "'"), this.parseError(X, {
            text: E.match,
            token: this.terminals_[b] || b,
            line: E.yylineno,
            loc: H,
            expected: M
          });
        }
        if (S[0] instanceof Array && S.length > 1) throw new Error("Parse Error: multiple actions possible at state: " + v + ", token: " + b);
        switch (S[0]) {
          case 1:
            a.push(b), m.push(E.yytext), r.push(E.yylloc), a.push(S[1]), b = null, W ? (b = W, W = null) : (K = E.yyleng, u = E.yytext, P = E.yylineno, H = E.yylloc, Z > 0 && Z--);
            break;
          case 2:
            if (L = this.productions_[S[1]][1], O.$ = m[m.length - L], O._$ = {
              first_line: r[r.length - (L || 1)].first_line,
              last_line: r[r.length - 1].last_line,
              first_column: r[r.length - (L || 1)].first_column,
              last_column: r[r.length - 1].last_column
            }, re && (O._$.range = [r[r.length - (L || 1)].range[0], r[r.length - 1].range[1]]), z = this.performAction.apply(O, [
              u,
              K,
              P,
              T.yy,
              S[1],
              m,
              r
            ].concat(se)), typeof z < "u") return z;
            L && (a = a.slice(0, -1 * L * 2), m = m.slice(0, -1 * L), r = r.slice(0, -1 * L)), a.push(this.productions_[S[1]][0]), m.push(O.$), r.push(O._$), ne = A[a[a.length - 2]][a[a.length - 1]], a.push(ne);
            break;
          case 3:
            return !0;
        }
      }
      return !0;
    }, "parse")
  };
  G.lexer = /* @__PURE__ */ (function() {
    return {
      EOF: 1,
      parseError: /* @__PURE__ */ d(function(i, h) {
        if (this.yy.parser) this.yy.parser.parseError(i, h);
        else throw new Error(i);
      }, "parseError"),
      setInput: /* @__PURE__ */ d(function(s, i) {
        return this.yy = i || this.yy || {}, this._input = s, 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"),
      input: /* @__PURE__ */ d(function() {
        var s = this._input[0];
        return this.yytext += s, this.yyleng++, this.offset++, this.match += s, this.matched += s, s.match(/(?:\r\n?|\n).*/g) ? (this.yylineno++, this.yylloc.last_line++) : this.yylloc.last_column++, this.options.ranges && this.yylloc.range[1]++, this._input = this._input.slice(1), s;
      }, "input"),
      unput: /* @__PURE__ */ d(function(s) {
        var i = s.length, h = s.split(/(?:\r\n?|\n)/g);
        this._input = s + this._input, this.yytext = this.yytext.substr(0, this.yytext.length - i), this.offset -= i;
        var a = 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), h.length - 1 && (this.yylineno -= h.length - 1);
        var l = 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: h ? (h.length === a.length ? this.yylloc.first_column : 0) + a[a.length - h.length].length - h[0].length : this.yylloc.first_column - i
        }, this.options.ranges && (this.yylloc.range = [l[0], l[0] + this.yyleng - i]), this.yyleng = this.yytext.length, this;
      }, "unput"),
      more: /* @__PURE__ */ d(function() {
        return this._more = !0, this;
      }, "more"),
      reject: /* @__PURE__ */ d(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"),
      less: /* @__PURE__ */ d(function(s) {
        this.unput(this.match.slice(s));
      }, "less"),
      pastInput: /* @__PURE__ */ d(function() {
        var s = this.matched.substr(0, this.matched.length - this.match.length);
        return (s.length > 20 ? "..." : "") + s.substr(-20).replace(/\n/g, "");
      }, "pastInput"),
      upcomingInput: /* @__PURE__ */ d(function() {
        var s = this.match;
        return s.length < 20 && (s += this._input.substr(0, 20 - s.length)), (s.substr(0, 20) + (s.length > 20 ? "..." : "")).replace(/\n/g, "");
      }, "upcomingInput"),
      showPosition: /* @__PURE__ */ d(function() {
        var s = this.pastInput(), i = new Array(s.length + 1).join("-");
        return s + this.upcomingInput() + `
` + i + "^";
      }, "showPosition"),
      test_match: /* @__PURE__ */ d(function(s, i) {
        var h, a, l;
        if (this.options.backtrack_lexer && (l = {
          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 && (l.yylloc.range = this.yylloc.range.slice(0))), a = s[0].match(/(?:\r\n?|\n).*/g), a && (this.yylineno += a.length), this.yylloc = {
          first_line: this.yylloc.last_line,
          last_line: this.yylineno + 1,
          first_column: this.yylloc.last_column,
          last_column: a ? a[a.length - 1].length - a[a.length - 1].match(/\r?\n?/)[0].length : this.yylloc.last_column + s[0].length
        }, this.yytext += s[0], this.match += s[0], this.matches = s, 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(s[0].length), this.matched += s[0], h = this.performAction.call(this, this.yy, this, i, this.conditionStack[this.conditionStack.length - 1]), this.done && this._input && (this.done = !1), h) return h;
        if (this._backtrack) {
          for (var m in l) this[m] = l[m];
          return !1;
        }
        return !1;
      }, "test_match"),
      next: /* @__PURE__ */ d(function() {
        if (this.done) return this.EOF;
        this._input || (this.done = !0);
        var s, i, h, a;
        this._more || (this.yytext = "", this.match = "");
        for (var l = this._currentRules(), m = 0; m < l.length; m++)
          if (h = this._input.match(this.rules[l[m]]), h && (!i || h[0].length > i[0].length)) {
            if (i = h, a = m, this.options.backtrack_lexer) {
              if (s = this.test_match(h, l[m]), s !== !1) return s;
              if (this._backtrack) {
                i = !1;
                continue;
              } else return !1;
            } else if (!this.options.flex) break;
          }
        return i ? (s = this.test_match(i, l[a]), s !== !1 ? s : !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"),
      lex: /* @__PURE__ */ d(function() {
        var i = this.next();
        return i || this.lex();
      }, "lex"),
      begin: /* @__PURE__ */ d(function(i) {
        this.conditionStack.push(i);
      }, "begin"),
      popState: /* @__PURE__ */ d(function() {
        return this.conditionStack.length - 1 > 0 ? this.conditionStack.pop() : this.conditionStack[0];
      }, "popState"),
      _currentRules: /* @__PURE__ */ d(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"),
      topState: /* @__PURE__ */ d(function(i) {
        return i = this.conditionStack.length - 1 - Math.abs(i || 0), i >= 0 ? this.conditionStack[i] : "INITIAL";
      }, "topState"),
      pushState: /* @__PURE__ */ d(function(i) {
        this.begin(i);
      }, "pushState"),
      stateStackSize: /* @__PURE__ */ d(function() {
        return this.conditionStack.length;
      }, "stateStackSize"),
      options: { "case-insensitive": !0 },
      performAction: /* @__PURE__ */ d(function(i, h, a, l) {
        switch (a) {
          case 0:
            return i.getLogger().trace("Found comment", h.yytext), 6;
          case 1:
            return 8;
          case 2:
            this.begin("CLASS");
            break;
          case 3:
            return this.popState(), 16;
          case 4:
            this.popState();
            break;
          case 5:
            i.getLogger().trace("Begin icon"), this.begin("ICON");
            break;
          case 6:
            return i.getLogger().trace("SPACELINE"), 6;
          case 7:
            return 7;
          case 8:
            return 15;
          case 9:
            i.getLogger().trace("end icon"), this.popState();
            break;
          case 10:
            return i.getLogger().trace("Exploding node"), this.begin("NODE"), 19;
          case 11:
            return i.getLogger().trace("Cloud"), this.begin("NODE"), 19;
          case 12:
            return i.getLogger().trace("Explosion Bang"), this.begin("NODE"), 19;
          case 13:
            return i.getLogger().trace("Cloud Bang"), this.begin("NODE"), 19;
          case 14:
            return this.begin("NODE"), 19;
          case 15:
            return this.begin("NODE"), 19;
          case 16:
            return this.begin("NODE"), 19;
          case 17:
            return this.begin("NODE"), 19;
          case 18:
            return 13;
          case 19:
            return 22;
          case 20:
            return 11;
          case 21:
            this.begin("NSTR2");
            break;
          case 22:
            return "NODE_DESCR";
          case 23:
            this.popState();
            break;
          case 24:
            i.getLogger().trace("Starting NSTR"), this.begin("NSTR");
            break;
          case 25:
            return i.getLogger().trace("description:", h.yytext), "NODE_DESCR";
          case 26:
            this.popState();
            break;
          case 27:
            return this.popState(), i.getLogger().trace("node end ))"), "NODE_DEND";
          case 28:
            return this.popState(), i.getLogger().trace("node end )"), "NODE_DEND";
          case 29:
            return this.popState(), i.getLogger().trace("node end ...", h.yytext), "NODE_DEND";
          case 30:
            return this.popState(), i.getLogger().trace("node end (("), "NODE_DEND";
          case 31:
            return this.popState(), i.getLogger().trace("node end (-"), "NODE_DEND";
          case 32:
            return this.popState(), i.getLogger().trace("node end (-"), "NODE_DEND";
          case 33:
            return this.popState(), i.getLogger().trace("node end (("), "NODE_DEND";
          case 34:
            return this.popState(), i.getLogger().trace("node end (("), "NODE_DEND";
          case 35:
            return i.getLogger().trace("Long description:", h.yytext), 20;
          case 36:
            return i.getLogger().trace("Long description:", h.yytext), 20;
        }
      }, "anonymous"),
      rules: [
        /^(?:\s*%%.*)/i,
        /^(?:mindmap\b)/i,
        /^(?::::)/i,
        /^(?:.+)/i,
        /^(?:\n)/i,
        /^(?:::icon\()/i,
        /^(?:[\s]+[\n])/i,
        /^(?:[\n]+)/i,
        /^(?:[^\)]+)/i,
        /^(?:\))/i,
        /^(?:-\))/i,
        /^(?:\(-)/i,
        /^(?:\)\))/i,
        /^(?:\))/i,
        /^(?:\(\()/i,
        /^(?:\{\{)/i,
        /^(?:\()/i,
        /^(?:\[)/i,
        /^(?:[\s]+)/i,
        /^(?:[^\(\[\n\)\{\}]+)/i,
        /^(?:$)/i,
        /^(?:["][`])/i,
        /^(?:[^`"]+)/i,
        /^(?:[`]["])/i,
        /^(?:["])/i,
        /^(?:[^"]+)/i,
        /^(?:["])/i,
        /^(?:[\)]\))/i,
        /^(?:[\)])/i,
        /^(?:[\]])/i,
        /^(?:\}\})/i,
        /^(?:\(-)/i,
        /^(?:-\))/i,
        /^(?:\(\()/i,
        /^(?:\()/i,
        /^(?:[^\)\]\(\}]+)/i,
        /^(?:.+(?!\(\())/i
      ],
      conditions: {
        CLASS: {
          rules: [3, 4],
          inclusive: !1
        },
        ICON: {
          rules: [8, 9],
          inclusive: !1
        },
        NSTR2: {
          rules: [22, 23],
          inclusive: !1
        },
        NSTR: {
          rules: [25, 26],
          inclusive: !1
        },
        NODE: {
          rules: [
            21,
            24,
            27,
            28,
            29,
            30,
            31,
            32,
            33,
            34,
            35,
            36
          ],
          inclusive: !1
        },
        INITIAL: {
          rules: [
            0,
            1,
            2,
            5,
            6,
            7,
            10,
            11,
            12,
            13,
            14,
            15,
            16,
            17,
            18,
            19,
            20
          ],
          inclusive: !0
        }
      }
    };
  })();
  function B() {
    this.yy = {};
  }
  return d(B, "Parser"), B.prototype = G, G.Parser = B, new B();
})();
Y.parser = Y;
var be = Y, Se = 12, x = {
  DEFAULT: 0,
  NO_BORDER: 0,
  ROUNDED_RECT: 1,
  RECT: 2,
  CIRCLE: 3,
  CLOUD: 4,
  BANG: 5,
  HEXAGON: 6
}, Ne = class {
  constructor() {
    this.nodes = [], this.count = 0, this.elements = {}, this.getLogger = this.getLogger.bind(this), this.nodeType = x, this.clear(), this.getType = this.getType.bind(this), this.getElementById = this.getElementById.bind(this), this.getParent = this.getParent.bind(this), this.getMindmap = this.getMindmap.bind(this), this.addNode = this.addNode.bind(this), this.decorateNode = this.decorateNode.bind(this);
  }
  static {
    d(this, "MindmapDB");
  }
  clear() {
    this.nodes = [], this.count = 0, this.elements = {}, this.baseLevel = void 0;
  }
  getParent(e) {
    for (let n = this.nodes.length - 1; n >= 0; n--) if (this.nodes[n].level < e) return this.nodes[n];
    return null;
  }
  getMindmap() {
    return this.nodes.length > 0 ? this.nodes[0] : null;
  }
  addNode(e, n, c, o) {
    I.info("addNode", e, n, c, o);
    let t = !1;
    this.nodes.length === 0 ? (this.baseLevel = e, e = 0, t = !0) : this.baseLevel !== void 0 && (e = e - this.baseLevel, t = !1);
    const g = $();
    let f = g.mindmap?.padding ?? F.mindmap.padding;
    switch (o) {
      case this.nodeType.ROUNDED_RECT:
      case this.nodeType.RECT:
      case this.nodeType.HEXAGON:
        f *= 2;
        break;
    }
    const p = {
      id: this.count++,
      nodeId: V(n, g),
      level: e,
      descr: V(c, g),
      type: o,
      children: [],
      width: g.mindmap?.maxNodeWidth ?? F.mindmap.maxNodeWidth,
      padding: f,
      isRoot: t
    }, D = this.getParent(e);
    if (D)
      D.children.push(p), this.nodes.push(p);
    else if (t) this.nodes.push(p);
    else throw new Error(`There can be only one root. No parent could be found for ("${p.descr}")`);
  }
  getType(e, n) {
    switch (I.debug("In get type", e, n), e) {
      case "[":
        return this.nodeType.RECT;
      case "(":
        return n === ")" ? this.nodeType.ROUNDED_RECT : this.nodeType.CLOUD;
      case "((":
        return this.nodeType.CIRCLE;
      case ")":
        return this.nodeType.CLOUD;
      case "))":
        return this.nodeType.BANG;
      case "{{":
        return this.nodeType.HEXAGON;
      default:
        return this.nodeType.DEFAULT;
    }
  }
  setElementForId(e, n) {
    this.elements[e] = n;
  }
  getElementById(e) {
    return this.elements[e];
  }
  decorateNode(e) {
    if (!e) return;
    const n = $(), c = this.nodes[this.nodes.length - 1];
    e.icon && (c.icon = V(e.icon, n)), e.class && (c.class = V(e.class, n));
  }
  type2Str(e) {
    switch (e) {
      case this.nodeType.DEFAULT:
        return "no-border";
      case this.nodeType.RECT:
        return "rect";
      case this.nodeType.ROUNDED_RECT:
        return "rounded-rect";
      case this.nodeType.CIRCLE:
        return "circle";
      case this.nodeType.CLOUD:
        return "cloud";
      case this.nodeType.BANG:
        return "bang";
      case this.nodeType.HEXAGON:
        return "hexgon";
      default:
        return "no-border";
    }
  }
  assignSections(e, n) {
    if (e.level === 0 ? e.section = void 0 : e.section = n, e.children) for (const [c, o] of e.children.entries()) {
      const t = e.level === 0 ? c % (Se - 1) : n;
      this.assignSections(o, t);
    }
  }
  flattenNodes(e, n) {
    const c = $(), o = ["mindmap-node"];
    e.isRoot === !0 ? o.push("section-root", "section--1") : e.section !== void 0 && o.push(`section-${e.section}`), e.class && o.push(e.class);
    const t = o.join(" "), g = /* @__PURE__ */ d((p) => {
      const D = (c.theme?.toLowerCase() ?? "").includes("redux");
      switch (p) {
        case x.CIRCLE:
          return "mindmapCircle";
        case x.RECT:
          return "rect";
        case x.ROUNDED_RECT:
          return "rounded";
        case x.CLOUD:
          return "cloud";
        case x.BANG:
          return "bang";
        case x.HEXAGON:
          return "hexagon";
        case x.DEFAULT:
          return D ? "rounded" : "defaultMindmapNode";
        case x.NO_BORDER:
        default:
          return "rect";
      }
    }, "getShapeFromType"), f = {
      id: e.id.toString(),
      domId: "node_" + e.id.toString(),
      label: e.descr,
      labelType: "markdown",
      isGroup: !1,
      shape: g(e.type),
      width: e.width,
      height: e.height ?? 0,
      padding: e.padding,
      cssClasses: t,
      cssStyles: [],
      look: c.look,
      icon: e.icon,
      x: e.x,
      y: e.y,
      level: e.level,
      nodeId: e.nodeId,
      type: e.type,
      section: e.section
    };
    if (n.push(f), e.children) for (const p of e.children) this.flattenNodes(p, n);
  }
  generateEdges(e, n) {
    if (!e.children) return;
    const c = $();
    for (const o of e.children) {
      let t = "edge";
      o.section !== void 0 && (t += ` section-edge-${o.section}`);
      const g = e.level + 1;
      t += ` edge-depth-${g}`;
      const f = {
        id: `edge_${e.id}_${o.id}`,
        start: e.id.toString(),
        end: o.id.toString(),
        type: "normal",
        curve: "basis",
        thickness: "normal",
        look: c.look,
        classes: t,
        depth: e.level,
        section: o.section
      };
      n.push(f), this.generateEdges(o, n);
    }
  }
  getData() {
    const e = this.getMindmap(), n = $(), c = ce().layout !== void 0, o = n;
    if (c || (o.layout = "cose-bilkent"), !e) return {
      nodes: [],
      edges: [],
      config: o
    };
    I.debug("getData: mindmapRoot", e, n), this.assignSections(e);
    const t = [], g = [];
    this.flattenNodes(e, t), this.generateEdges(e, g), I.debug(`getData: processed ${t.length} nodes and ${g.length} edges`);
    const f = /* @__PURE__ */ new Map();
    for (const p of t) f.set(p.id, {
      shape: p.shape,
      width: p.width,
      height: p.height,
      padding: p.padding
    });
    return {
      nodes: t,
      edges: g,
      config: o,
      rootNode: e,
      markers: ["point"],
      direction: "TB",
      nodeSpacing: 50,
      rankSpacing: 50,
      shapes: Object.fromEntries(f),
      type: "mindmap",
      diagramId: "mindmap-" + _e()
    };
  }
  getLogger() {
    return I;
  }
}, De = { draw: /* @__PURE__ */ d(async (e, n, c, o) => {
  I.debug(`Rendering mindmap diagram
` + e);
  const t = o.db, g = t.getData(), f = ge(n, g.config.securityLevel);
  if (g.type = o.type, g.layoutAlgorithm = fe(g.config.layout, { fallback: "cose-bilkent" }), g.diagramId = n, !t.getMindmap()) return;
  g.nodes.forEach((y) => {
    y.shape === "rounded" ? (y.radius = 15, y.taper = 15, y.stroke = "none", y.width = 0, y.padding = 15) : y.shape === "circle" ? y.padding = 10 : y.shape === "rect" ? (y.width = 0, y.padding = 10) : y.shape === "hexagon" && (y.width = 0, y.height = 0);
  }), await pe(g, f);
  const { themeVariables: p } = de(), { useGradient: D, gradientStart: C, gradientStop: w } = p;
  if (D && C && w) {
    const y = f.attr("id"), k = f.append("defs").append("linearGradient").attr("id", `${y}-gradient`).attr("gradientUnits", "objectBoundingBox").attr("x1", "0%").attr("y1", "0%").attr("x2", "100%").attr("y2", "0%");
    k.append("stop").attr("offset", "0%").attr("stop-color", C).attr("stop-opacity", 1), k.append("stop").attr("offset", "100%").attr("stop-color", w).attr("stop-opacity", 1);
  }
  ue(f, g.config.mindmap?.padding ?? F.mindmap.padding, "mindmapDiagram", g.config.mindmap?.useMaxWidth ?? F.mindmap.useMaxWidth);
}, "draw") }, Le = /* @__PURE__ */ d((e) => {
  const { theme: n, look: c } = e;
  let o = "";
  for (let t = 0; t < e.THEME_COLOR_LIMIT; t++)
    e["lineColor" + t] = e["lineColor" + t] || e["cScaleInv" + t], he(e["lineColor" + t]) ? e["lineColor" + t] = ae(e["lineColor" + t], 20) : e["lineColor" + t] = le(e["lineColor" + t], 20);
  for (let t = 0; t < e.THEME_COLOR_LIMIT; t++) {
    const g = "" + (c === "neo" ? Math.max(10 - (t - 1) * 2, 2) : 17 - 3 * t);
    o += `
    .section-${t - 1} rect, .section-${t - 1} path, .section-${t - 1} circle, .section-${t - 1} polygon, .section-${t - 1} path  {
      fill: ${e["cScale" + t]};
    }
    .section-${t - 1} text {
     fill: ${e["cScaleLabel" + t]};
    }
     .section-${t - 1} span {
     color: ${e["cScaleLabel" + t]};
    }
    .node-icon-${t - 1} {
      font-size: 40px;
      color: ${e["cScaleLabel" + t]};
    }
    .section-edge-${t - 1}{
      stroke: ${e["cScale" + t]};
    }
    .edge-depth-${t - 1}{
      stroke-width: ${g};
    }
    .section-${t - 1} line {
      stroke: ${e["cScaleInv" + t]} ;
      stroke-width: 3;
    }

    .disabled, .disabled circle, .disabled text {
      fill: lightgray;
    }
    .disabled text {
      fill: #efefef;
    }
    [data-look="neo"].mindmap-node.section-${t - 1} rect, [data-look="neo"].mindmap-node.section-${t - 1} path, [data-look="neo"].mindmap-node.section-${t - 1} circle, [data-look="neo"].mindmap-node.section-${t - 1} polygon {
      fill: ${n === "redux" || n === "redux-dark" || n === "neutral" ? e.mainBkg : e["cScale" + t]};
      stroke: ${n === "redux" || n === "redux-dark" ? e.nodeBorder : e["cScale" + t]};
      stroke-width: ${e.strokeWidth ?? 2}px;
    }
    [data-look="neo"].section-edge-${t - 1}{
      stroke: ${n?.includes("redux") || n === "neo-dark" ? e.nodeBorder : e["cScale" + t]};
    }
    [data-look="neo"].mindmap-node.section-${t - 1} text {
     fill: ${n === "redux" || n === "redux-dark" ? e.nodeBorder : e["cScaleLabel" + (n === "neutral" ? 1 : t)]};
    }
    `;
  }
  return o;
}, "genSections"), xe = /* @__PURE__ */ d((e, n, c) => {
  let o = "";
  for (let t = 0; t < e; t++) o += `
    [data-look="neo"].mindmap-node.section-${t - 1} rect, [data-look="neo"].mindmap-node.section-${t - 1} path, [data-look="neo"].mindmap-node.section-${t - 1} circle, [data-look="neo"].mindmap-node.section-${t - 1} polygon {
      stroke: url(${n}-gradient);
      fill: ${c};
    }
    .section-${t - 1} line {
      stroke-width: 0;
    }`;
  return o;
}, "genGradient"), we = {
  get db() {
    return new Ne();
  },
  renderer: De,
  parser: be,
  styles: /* @__PURE__ */ d((e) => {
    const { theme: n } = e, c = e.svgId, o = e.dropShadow ? e.dropShadow.replace("url(#drop-shadow)", `url(${c}-drop-shadow)`) : "none";
    return `
  .edge {
    stroke-width: 3;
  }
  ${Le(e)}
  .section-root rect, .section-root path, .section-root circle, .section-root polygon  {
    fill: ${e.git0};
  }
  .section-root text {
    fill: ${e.gitBranchLabel0};
  }
  .section-root span {
    color: ${n?.includes("redux") ? e.nodeBorder : e.gitBranchLabel0};
  }
  .icon-container {
    height:100%;
    display: flex;
    justify-content: center;
    align-items: center;
  }
  .edge {
    fill: none;
  }
  .mindmap-node-label {
    dy: 1em;
    alignment-baseline: middle;
    text-anchor: middle;
    dominant-baseline: middle;
    text-align: center;
  }
  [data-look="neo"].mindmap-node  {
    filter: ${o};
  }
  [data-look="neo"].mindmap-node.section-root rect, [data-look="neo"].mindmap-node.section-root path, [data-look="neo"].mindmap-node.section-root circle, [data-look="neo"].mindmap-node.section-root polygon  {
    fill: ${n?.includes("redux") ? e.mainBkg : e.git0};
  }
  [data-look="neo"].mindmap-node.section-root .text-inner-tspan {
    fill:  ${n?.includes("redux") ? e.nodeBorder : e["cScaleLabel" + (n === "neutral" ? 1 : 0)]};
  }
  ${e.useGradient && c && e.mainBkg ? xe(e.THEME_COLOR_LIMIT, c, e.mainBkg) : ""}
`;
  }, "getStyles")
};
export {
  we as diagram
};

//# sourceMappingURL=mindmap-definition-QFDTVHPH.js.map