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

    .disabled, .disabled circle, .disabled text {
      fill: lightgray;
    }
    .disabled text {
      fill: #efefef;
    }
    [data-look="neo"].mindmap-node.section-${n - 1} rect, [data-look="neo"].mindmap-node.section-${n - 1} path, [data-look="neo"].mindmap-node.section-${n - 1} circle, [data-look="neo"].mindmap-node.section-${n - 1} polygon {
      fill: ${t === "redux" || t === "redux-dark" || t === "neutral" ? i.mainBkg : i["cScale" + n]};
      stroke: ${t === "redux" || t === "redux-dark" ? i.nodeBorder : i["cScale" + n]};
      stroke-width: ${i.strokeWidth ?? 2}px;
    }
    [data-look="neo"].section-edge-${n - 1}{
      stroke: ${t != null && t.includes("redux") || t === "neo-dark" ? i.nodeBorder : i["cScale" + n]};
    }
    [data-look="neo"].mindmap-node.section-${n - 1} text {
     fill: ${t === "redux" || t === "redux-dark" ? i.nodeBorder : i["cScaleLabel" + (t === "neutral" ? 1 : n)]};
    }
    `;
  }
  return d;
}, "genSections"), kt = /* @__PURE__ */ c((i, t, r) => {
  let d = "";
  for (let n = 0; n < i; n++) d += `
    [data-look="neo"].mindmap-node.section-${n - 1} rect, [data-look="neo"].mindmap-node.section-${n - 1} path, [data-look="neo"].mindmap-node.section-${n - 1} circle, [data-look="neo"].mindmap-node.section-${n - 1} polygon {
      stroke: url(${t}-gradient);
      fill: ${r};
    }
    .section-${n - 1} line {
      stroke-width: 0;
    }`;
  return d;
}, "genGradient"), xt = {
  get db() {
    return new _t();
  },
  renderer: Et,
  parser: mt,
  styles: /* @__PURE__ */ c((i) => {
    let { theme: t } = i, r = i.svgId, d = i.dropShadow ? i.dropShadow.replace("url(#drop-shadow)", `url(${r}-drop-shadow)`) : "none";
    return `
  .edge {
    stroke-width: 3;
  }
  ${bt(i)}
  .section-root rect, .section-root path, .section-root circle, .section-root polygon  {
    fill: ${i.git0};
  }
  .section-root text {
    fill: ${i.gitBranchLabel0};
  }
  .section-root span {
    color: ${t != null && t.includes("redux") ? i.nodeBorder : i.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: ${d};
  }
  [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: ${t != null && t.includes("redux") ? i.mainBkg : i.git0};
  }
  [data-look="neo"].mindmap-node.section-root .text-inner-tspan {
    fill:  ${t != null && t.includes("redux") ? i.nodeBorder : i["cScaleLabel" + +(t === "neutral")]};
  }
  ${i.useGradient && r && i.mainBkg ? kt(i.THEME_COLOR_LIMIT, r, i.mainBkg) : ""}
`;
  }, "getStyles")
};
export {
  xt as diagram
};
