import { g as ae } from "./chunk-55IACEB6-DBpJS3kQ.js";
import { s as oe } from "./chunk-QN33PNHL-BRFlZAd6.js";
import { _ as c, l as O, o as ce, r as le, E as B, c as H, i as U, af as he, ag as ge, W as de, X as ue, Y as pe } from "./index-M5uZ_ndG.js";
var W = (function() {
  var r = /* @__PURE__ */ c(function(L, s, t, a) {
    for (t = t || {}, a = L.length; a--; t[L[a]] = s) ;
    return t;
  }, "o"), e = [1, 4], i = [1, 13], l = [1, 12], f = [1, 15], h = [1, 16], p = [1, 20], m = [1, 19], u = [6, 7, 8], N = [1, 26], z = [1, 24], X = [1, 25], _ = [6, 7, 11], Y = [1, 6, 13, 15, 16, 19, 22], q = [1, 33], J = [1, 34], I = [1, 6, 7, 11, 13, 15, 16, 19, 22], F = {
    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(s, t, a, o, d, n, R) {
      var g = n.length - 1;
      switch (d) {
        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: ", n[g].id), o.addNode(n[g - 1].length, n[g].id, n[g].descr, n[g].type);
          break;
        case 16:
          o.getLogger().trace("Icon: ", n[g]), o.decorateNode({ icon: n[g] });
          break;
        case 17:
        case 21:
          o.decorateNode({ class: n[g] });
          break;
        case 18:
          o.getLogger().trace("SPACELIST");
          break;
        case 19:
          o.getLogger().trace("Node: ", n[g].id), o.addNode(0, n[g].id, n[g].descr, n[g].type);
          break;
        case 20:
          o.decorateNode({ icon: n[g] });
          break;
        case 25:
          o.getLogger().trace("node found ..", n[g - 2]), this.$ = { id: n[g - 1], descr: n[g - 1], type: o.getType(n[g - 2], n[g]) };
          break;
        case 26:
          this.$ = { id: n[g], descr: n[g], type: o.nodeType.DEFAULT };
          break;
        case 27:
          o.getLogger().trace("node found ..", n[g - 3]), this.$ = { id: n[g - 3], descr: n[g - 1], type: o.getType(n[g - 2], n[g]) };
          break;
      }
    }, "anonymous"),
    table: [{ 3: 1, 4: 2, 5: 3, 6: [1, 5], 8: e }, { 1: [3] }, { 1: [2, 1] }, { 4: 6, 6: [1, 7], 7: [1, 8], 8: e }, { 6: i, 7: [1, 10], 9: 9, 12: 11, 13: l, 14: 14, 15: f, 16: h, 17: 17, 18: 18, 19: p, 22: m }, r(u, [2, 3]), { 1: [2, 2] }, r(u, [2, 4]), r(u, [2, 5]), { 1: [2, 6], 6: i, 12: 21, 13: l, 14: 14, 15: f, 16: h, 17: 17, 18: 18, 19: p, 22: m }, { 6: i, 9: 22, 12: 11, 13: l, 14: 14, 15: f, 16: h, 17: 17, 18: 18, 19: p, 22: m }, { 6: N, 7: z, 10: 23, 11: X }, r(_, [2, 22], { 17: 17, 18: 18, 14: 27, 15: [1, 28], 16: [1, 29], 19: p, 22: m }), r(_, [2, 18]), r(_, [2, 19]), r(_, [2, 20]), r(_, [2, 21]), r(_, [2, 23]), r(_, [2, 24]), r(_, [2, 26], { 19: [1, 30] }), { 20: [1, 31] }, { 6: N, 7: z, 10: 32, 11: X }, { 1: [2, 7], 6: i, 12: 21, 13: l, 14: 14, 15: f, 16: h, 17: 17, 18: 18, 19: p, 22: m }, r(Y, [2, 14], { 7: q, 11: J }), r(I, [2, 8]), r(I, [2, 9]), r(I, [2, 10]), r(_, [2, 15]), r(_, [2, 16]), r(_, [2, 17]), { 20: [1, 35] }, { 21: [1, 36] }, r(Y, [2, 13], { 7: q, 11: J }), r(I, [2, 11]), r(I, [2, 12]), { 21: [1, 37] }, r(_, [2, 25]), r(_, [2, 27])],
    defaultActions: { 2: [2, 1], 6: [2, 2] },
    parseError: /* @__PURE__ */ c(function(s, t) {
      if (t.recoverable)
        this.trace(s);
      else {
        var a = new Error(s);
        throw a.hash = t, a;
      }
    }, "parseError"),
    parse: /* @__PURE__ */ c(function(s) {
      var t = this, a = [0], o = [], d = [null], n = [], R = this.table, g = "", w = 0, K = 0, ie = 2, Q = 1, se = n.slice.call(arguments, 1), y = Object.create(this.lexer), x = { yy: {} };
      for (var V in this.yy)
        Object.prototype.hasOwnProperty.call(this.yy, V) && (x.yy[V] = this.yy[V]);
      y.setInput(s, x.yy), x.yy.lexer = y, x.yy.parser = this, typeof y.yylloc > "u" && (y.yylloc = {});
      var G = y.yylloc;
      n.push(G);
      var ne = y.options && y.options.ranges;
      typeof x.yy.parseError == "function" ? this.parseError = x.yy.parseError : this.parseError = Object.getPrototypeOf(this).parseError;
      function re(b) {
        a.length = a.length - 2 * b, d.length = d.length - b, n.length = n.length - b;
      }
      c(re, "popStack");
      function Z() {
        var b;
        return b = o.pop() || y.lex() || Q, typeof b != "number" && (b instanceof Array && (o = b, b = o.pop()), b = t.symbols_[b] || b), b;
      }
      c(Z, "lex");
      for (var E, v, S, j, T = {}, P, D, ee, M; ; ) {
        if (v = a[a.length - 1], this.defaultActions[v] ? S = this.defaultActions[v] : ((E === null || typeof E > "u") && (E = Z()), S = R[v] && R[v][E]), typeof S > "u" || !S.length || !S[0]) {
          var $ = "";
          M = [];
          for (P in R[v])
            this.terminals_[P] && P > ie && M.push("'" + this.terminals_[P] + "'");
          y.showPosition ? $ = "Parse error on line " + (w + 1) + `:
` + y.showPosition() + `
Expecting ` + M.join(", ") + ", got '" + (this.terminals_[E] || E) + "'" : $ = "Parse error on line " + (w + 1) + ": Unexpected " + (E == Q ? "end of input" : "'" + (this.terminals_[E] || E) + "'"), this.parseError($, {
            text: y.match,
            token: this.terminals_[E] || E,
            line: y.yylineno,
            loc: G,
            expected: M
          });
        }
        if (S[0] instanceof Array && S.length > 1)
          throw new Error("Parse Error: multiple actions possible at state: " + v + ", token: " + E);
        switch (S[0]) {
          case 1:
            a.push(E), d.push(y.yytext), n.push(y.yylloc), a.push(S[1]), E = null, K = y.yyleng, g = y.yytext, w = y.yylineno, G = y.yylloc;
            break;
          case 2:
            if (D = this.productions_[S[1]][1], T.$ = d[d.length - D], T._$ = {
              first_line: n[n.length - (D || 1)].first_line,
              last_line: n[n.length - 1].last_line,
              first_column: n[n.length - (D || 1)].first_column,
              last_column: n[n.length - 1].last_column
            }, ne && (T._$.range = [
              n[n.length - (D || 1)].range[0],
              n[n.length - 1].range[1]
            ]), j = this.performAction.apply(T, [
              g,
              K,
              w,
              x.yy,
              S[1],
              d,
              n
            ].concat(se)), typeof j < "u")
              return j;
            D && (a = a.slice(0, -1 * D * 2), d = d.slice(0, -1 * D), n = n.slice(0, -1 * D)), a.push(this.productions_[S[1]][0]), d.push(T.$), n.push(T._$), ee = R[a[a.length - 2]][a[a.length - 1]], a.push(ee);
            break;
          case 3:
            return !0;
        }
      }
      return !0;
    }, "parse")
  }, te = /* @__PURE__ */ (function() {
    var L = {
      EOF: 1,
      parseError: /* @__PURE__ */ c(function(t, a) {
        if (this.yy.parser)
          this.yy.parser.parseError(t, a);
        else
          throw new Error(t);
      }, "parseError"),
      // resets the lexer, sets new input
      setInput: /* @__PURE__ */ c(function(s, t) {
        return this.yy = t || 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"),
      // consumes and returns one char from the input
      input: /* @__PURE__ */ c(function() {
        var s = this._input[0];
        this.yytext += s, this.yyleng++, this.offset++, this.match += s, this.matched += s;
        var t = s.match(/(?:\r\n?|\n).*/g);
        return t ? (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"),
      // unshifts one char (or a string) into the input
      unput: /* @__PURE__ */ c(function(s) {
        var t = s.length, a = s.split(/(?:\r\n?|\n)/g);
        this._input = s + this._input, this.yytext = this.yytext.substr(0, this.yytext.length - t), this.offset -= t;
        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 d = 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 - t
        }, this.options.ranges && (this.yylloc.range = [d[0], d[0] + this.yyleng - t]), this.yyleng = this.yytext.length, this;
      }, "unput"),
      // When called from action, caches matched text and appends it on next action
      more: /* @__PURE__ */ c(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__ */ 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"),
      // retain first n characters of the match
      less: /* @__PURE__ */ c(function(s) {
        this.unput(this.match.slice(s));
      }, "less"),
      // displays already matched input, i.e. for error messages
      pastInput: /* @__PURE__ */ c(function() {
        var s = this.matched.substr(0, this.matched.length - this.match.length);
        return (s.length > 20 ? "..." : "") + s.substr(-20).replace(/\n/g, "");
      }, "pastInput"),
      // displays upcoming input, i.e. for error messages
      upcomingInput: /* @__PURE__ */ c(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"),
      // displays the character position where the lexing error occurred, i.e. for error messages
      showPosition: /* @__PURE__ */ c(function() {
        var s = this.pastInput(), t = new Array(s.length + 1).join("-");
        return s + this.upcomingInput() + `
` + t + "^";
      }, "showPosition"),
      // test the lexed token: return FALSE when not a match, otherwise return token
      test_match: /* @__PURE__ */ c(function(s, t) {
        var a, o, d;
        if (this.options.backtrack_lexer && (d = {
          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 && (d.yylloc.range = this.yylloc.range.slice(0))), o = s[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 + 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], a = this.performAction.call(this, this.yy, this, t, this.conditionStack[this.conditionStack.length - 1]), this.done && this._input && (this.done = !1), a)
          return a;
        if (this._backtrack) {
          for (var n in d)
            this[n] = d[n];
          return !1;
        }
        return !1;
      }, "test_match"),
      // return next match in input
      next: /* @__PURE__ */ c(function() {
        if (this.done)
          return this.EOF;
        this._input || (this.done = !0);
        var s, t, a, o;
        this._more || (this.yytext = "", this.match = "");
        for (var d = this._currentRules(), n = 0; n < d.length; n++)
          if (a = this._input.match(this.rules[d[n]]), a && (!t || a[0].length > t[0].length)) {
            if (t = a, o = n, this.options.backtrack_lexer) {
              if (s = this.test_match(a, d[n]), s !== !1)
                return s;
              if (this._backtrack) {
                t = !1;
                continue;
              } else
                return !1;
            } else if (!this.options.flex)
              break;
          }
        return t ? (s = this.test_match(t, d[o]), 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"),
      // return next match that has a token
      lex: /* @__PURE__ */ c(function() {
        var t = this.next();
        return t || this.lex();
      }, "lex"),
      // activates a new lexer condition state (pushes the new lexer condition state onto the condition stack)
      begin: /* @__PURE__ */ c(function(t) {
        this.conditionStack.push(t);
      }, "begin"),
      // pop the previously active lexer condition state off the condition stack
      popState: /* @__PURE__ */ c(function() {
        var t = this.conditionStack.length - 1;
        return t > 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__ */ 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"),
      // 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__ */ c(function(t) {
        return t = this.conditionStack.length - 1 - Math.abs(t || 0), t >= 0 ? this.conditionStack[t] : "INITIAL";
      }, "topState"),
      // alias for begin(condition)
      pushState: /* @__PURE__ */ c(function(t) {
        this.begin(t);
      }, "pushState"),
      // return the number of states currently on the stack
      stateStackSize: /* @__PURE__ */ c(function() {
        return this.conditionStack.length;
      }, "stateStackSize"),
      options: { "case-insensitive": !0 },
      performAction: /* @__PURE__ */ c(function(t, a, o, d) {
        switch (o) {
          case 0:
            return t.getLogger().trace("Found comment", a.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:
            t.getLogger().trace("Begin icon"), this.begin("ICON");
            break;
          case 6:
            return t.getLogger().trace("SPACELINE"), 6;
          case 7:
            return 7;
          case 8:
            return 15;
          case 9:
            t.getLogger().trace("end icon"), this.popState();
            break;
          case 10:
            return t.getLogger().trace("Exploding node"), this.begin("NODE"), 19;
          case 11:
            return t.getLogger().trace("Cloud"), this.begin("NODE"), 19;
          case 12:
            return t.getLogger().trace("Explosion Bang"), this.begin("NODE"), 19;
          case 13:
            return t.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:
            t.getLogger().trace("Starting NSTR"), this.begin("NSTR");
            break;
          case 25:
            return t.getLogger().trace("description:", a.yytext), "NODE_DESCR";
          case 26:
            this.popState();
            break;
          case 27:
            return this.popState(), t.getLogger().trace("node end ))"), "NODE_DEND";
          case 28:
            return this.popState(), t.getLogger().trace("node end )"), "NODE_DEND";
          case 29:
            return this.popState(), t.getLogger().trace("node end ...", a.yytext), "NODE_DEND";
          case 30:
            return this.popState(), t.getLogger().trace("node end (("), "NODE_DEND";
          case 31:
            return this.popState(), t.getLogger().trace("node end (-"), "NODE_DEND";
          case 32:
            return this.popState(), t.getLogger().trace("node end (-"), "NODE_DEND";
          case 33:
            return this.popState(), t.getLogger().trace("node end (("), "NODE_DEND";
          case 34:
            return this.popState(), t.getLogger().trace("node end (("), "NODE_DEND";
          case 35:
            return t.getLogger().trace("Long description:", a.yytext), 20;
          case 36:
            return t.getLogger().trace("Long description:", a.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 } }
    };
    return L;
  })();
  F.lexer = te;
  function A() {
    this.yy = {};
  }
  return c(A, "Parser"), A.prototype = F, F.Parser = A, new A();
})();
W.parser = W;
var fe = W, k = {
  DEFAULT: 0,
  NO_BORDER: 0,
  ROUNDED_RECT: 1,
  RECT: 2,
  CIRCLE: 3,
  CLOUD: 4,
  BANG: 5,
  HEXAGON: 6
}, C, ye = (C = class {
  constructor() {
    this.nodes = [], this.count = 0, this.elements = {}, this.getLogger = this.getLogger.bind(this), this.nodeType = k, 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(e) {
    for (let i = this.nodes.length - 1; i >= 0; i--)
      if (this.nodes[i].level < e)
        return this.nodes[i];
    return null;
  }
  getMindmap() {
    return this.nodes.length > 0 ? this.nodes[0] : null;
  }
  addNode(e, i, l, f) {
    O.info("addNode", e, i, l, f);
    let h = !1;
    this.nodes.length === 0 ? (this.baseLevel = e, e = 0, h = !0) : this.baseLevel !== void 0 && (e = e - this.baseLevel, h = !1);
    const p = H();
    let m = p.mindmap?.padding ?? B.mindmap.padding;
    switch (f) {
      case this.nodeType.ROUNDED_RECT:
      case this.nodeType.RECT:
      case this.nodeType.HEXAGON:
        m *= 2;
        break;
    }
    const u = {
      id: this.count++,
      nodeId: U(i, p),
      level: e,
      descr: U(l, p),
      type: f,
      children: [],
      width: p.mindmap?.maxNodeWidth ?? B.mindmap.maxNodeWidth,
      padding: m,
      isRoot: h
    }, N = this.getParent(e);
    if (N)
      N.children.push(u), this.nodes.push(u);
    else if (h)
      this.nodes.push(u);
    else
      throw new Error(
        `There can be only one root. No parent could be found for ("${u.descr}")`
      );
  }
  getType(e, i) {
    switch (O.debug("In get type", e, i), e) {
      case "[":
        return this.nodeType.RECT;
      case "(":
        return i === ")" ? 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, i) {
    this.elements[e] = i;
  }
  getElementById(e) {
    return this.elements[e];
  }
  decorateNode(e) {
    if (!e)
      return;
    const i = H(), l = this.nodes[this.nodes.length - 1];
    e.icon && (l.icon = U(e.icon, i)), e.class && (l.class = U(e.class, i));
  }
  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";
      // cspell: disable-line
      default:
        return "no-border";
    }
  }
  /**
   * Assign section numbers to nodes based on their position relative to root
   * @param node - The mindmap node to process
   * @param sectionNumber - The section number to assign (undefined for root)
   */
  assignSections(e, i) {
    if (e.level === 0 ? e.section = void 0 : e.section = i, e.children)
      for (const [l, f] of e.children.entries()) {
        const h = e.level === 0 ? l : i;
        this.assignSections(f, h);
      }
  }
  /**
   * Convert mindmap tree structure to flat array of nodes
   * @param node - The mindmap node to process
   * @param processedNodes - Array to collect processed nodes
   */
  flattenNodes(e, i) {
    const l = ["mindmap-node"];
    e.isRoot === !0 ? l.push("section-root", "section--1") : e.section !== void 0 && l.push(`section-${e.section}`), e.class && l.push(e.class);
    const f = l.join(" "), h = /* @__PURE__ */ c((m) => {
      switch (m) {
        case k.CIRCLE:
          return "mindmapCircle";
        case k.RECT:
          return "rect";
        case k.ROUNDED_RECT:
          return "rounded";
        case k.CLOUD:
          return "cloud";
        case k.BANG:
          return "bang";
        case k.HEXAGON:
          return "hexagon";
        case k.DEFAULT:
          return "defaultMindmapNode";
        case k.NO_BORDER:
        default:
          return "rect";
      }
    }, "getShapeFromType"), p = {
      id: e.id.toString(),
      domId: "node_" + e.id.toString(),
      label: e.descr,
      isGroup: !1,
      shape: h(e.type),
      width: e.width,
      height: e.height ?? 0,
      padding: e.padding,
      cssClasses: f,
      cssStyles: [],
      look: "default",
      icon: e.icon,
      x: e.x,
      y: e.y,
      // Mindmap-specific properties
      level: e.level,
      nodeId: e.nodeId,
      type: e.type,
      section: e.section
    };
    if (i.push(p), e.children)
      for (const m of e.children)
        this.flattenNodes(m, i);
  }
  /**
   * Generate edges from parent-child relationships in mindmap tree
   * @param node - The mindmap node to process
   * @param edges - Array to collect edges
   */
  generateEdges(e, i) {
    if (e.children)
      for (const l of e.children) {
        let f = "edge";
        l.section !== void 0 && (f += ` section-edge-${l.section}`);
        const h = e.level + 1;
        f += ` edge-depth-${h}`;
        const p = {
          id: `edge_${e.id}_${l.id}`,
          start: e.id.toString(),
          end: l.id.toString(),
          type: "normal",
          curve: "basis",
          thickness: "normal",
          look: "default",
          classes: f,
          // Store mindmap-specific data
          depth: e.level,
          section: l.section
        };
        i.push(p), this.generateEdges(l, i);
      }
  }
  /**
   * Get structured data for layout algorithms
   * Following the pattern established by ER diagrams
   * @returns Structured data containing nodes, edges, and config
   */
  getData() {
    const e = this.getMindmap(), i = H(), f = he().layout !== void 0, h = i;
    if (f || (h.layout = "cose-bilkent"), !e)
      return {
        nodes: [],
        edges: [],
        config: h
      };
    O.debug("getData: mindmapRoot", e, i), this.assignSections(e);
    const p = [], m = [];
    this.flattenNodes(e, p), this.generateEdges(e, m), O.debug(
      `getData: processed ${p.length} nodes and ${m.length} edges`
    );
    const u = /* @__PURE__ */ new Map();
    for (const N of p)
      u.set(N.id, {
        shape: N.shape,
        width: N.width,
        height: N.height,
        padding: N.padding
      });
    return {
      nodes: p,
      edges: m,
      config: h,
      // Store the root node for mindmap-specific layout algorithms
      rootNode: e,
      // Properties required by dagre layout algorithm
      markers: ["point"],
      // Mindmaps don't use markers
      direction: "TB",
      // Top-to-bottom direction for mindmaps
      nodeSpacing: 50,
      // Default spacing between nodes
      rankSpacing: 50,
      // Default spacing between ranks
      // Add shapes for ELK compatibility
      shapes: Object.fromEntries(u),
      // Additional properties that layout algorithms might expect
      type: "mindmap",
      diagramId: "mindmap-" + ge()
    };
  }
  // Expose logger to grammar
  getLogger() {
    return O;
  }
}, c(C, "MindmapDB"), C), me = /* @__PURE__ */ c(async (r, e, i, l) => {
  O.debug(`Rendering mindmap diagram
` + r);
  const f = l.db, h = f.getData(), p = ae(e, h.config.securityLevel);
  h.type = l.type, h.layoutAlgorithm = ce(h.config.layout, {
    fallback: "cose-bilkent"
  }), h.diagramId = e, f.getMindmap() && (h.nodes.forEach((u) => {
    u.shape === "rounded" ? (u.radius = 15, u.taper = 15, u.stroke = "none", u.width = 0, u.padding = 15) : u.shape === "circle" ? u.padding = 10 : u.shape === "rect" && (u.width = 0, u.padding = 10);
  }), await le(h, p), oe(
    p,
    h.config.mindmap?.padding ?? B.mindmap.padding,
    "mindmapDiagram",
    h.config.mindmap?.useMaxWidth ?? B.mindmap.useMaxWidth
  ));
}, "draw"), Ee = {
  draw: me
}, _e = /* @__PURE__ */ c((r) => {
  let e = "";
  for (let i = 0; i < r.THEME_COLOR_LIMIT; i++)
    r["lineColor" + i] = r["lineColor" + i] || r["cScaleInv" + i], de(r["lineColor" + i]) ? r["lineColor" + i] = ue(r["lineColor" + i], 20) : r["lineColor" + i] = pe(r["lineColor" + i], 20);
  for (let i = 0; i < r.THEME_COLOR_LIMIT; i++) {
    const l = "" + (17 - 3 * i);
    e += `
    .section-${i - 1} rect, .section-${i - 1} path, .section-${i - 1} circle, .section-${i - 1} polygon, .section-${i - 1} path  {
      fill: ${r["cScale" + i]};
    }
    .section-${i - 1} text {
     fill: ${r["cScaleLabel" + i]};
    }
    .node-icon-${i - 1} {
      font-size: 40px;
      color: ${r["cScaleLabel" + i]};
    }
    .section-edge-${i - 1}{
      stroke: ${r["cScale" + i]};
    }
    .edge-depth-${i - 1}{
      stroke-width: ${l};
    }
    .section-${i - 1} line {
      stroke: ${r["cScaleInv" + i]} ;
      stroke-width: 3;
    }

    .disabled, .disabled circle, .disabled text {
      fill: lightgray;
    }
    .disabled text {
      fill: #efefef;
    }
    `;
  }
  return e;
}, "genSections"), be = /* @__PURE__ */ c((r) => `
  .edge {
    stroke-width: 3;
  }
  ${_e(r)}
  .section-root rect, .section-root path, .section-root circle, .section-root polygon  {
    fill: ${r.git0};
  }
  .section-root text {
    fill: ${r.gitBranchLabel0};
  }
  .section-root span {
    color: ${r.gitBranchLabel0};
  }
  .section-2 span {
    color: ${r.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;
  }
`, "getStyles"), Se = be, Le = {
  get db() {
    return new ye();
  },
  renderer: Ee,
  parser: fe,
  styles: Se
};
export {
  Le as diagram
};
