import { d as Jt } from "./chunk-WVR4S24B-C4HIWky3-CkJ0DHSJ.js";
import { d as te } from "./chunk-NRVI72HA-DxsqT4Dt-Bo_vu9qn.js";
import { _ as d, l as T, g as P, al as ee, am as se, a7 as ie, a8 as re, a6 as ae, a5 as ne, an as oe, ao as le, bl as ce, ag as K, at as he } from "./index-BDD0CD9m.js";
var Dt = function() {
  var t = /* @__PURE__ */ d(function(B, r, a, y) {
    for (a = a || {}, y = B.length; y--; a[B[y]] = r) ;
    return a;
  }, "o"), e = [1, 2], n = [1, 3], s = [1, 4], c = [2, 4], o = [1, 9], f = [1, 11], m = [1, 16], u = [1, 17], S = [1, 18], E = [1, 19], g = [1, 33], O = [1, 20], L = [1, 21], R = [1, 22], D = [1, 23], I = [1, 24], h = [1, 26], C = [1, 27], v = [1, 28], w = [1, 29], M = [1, 30], Y = [1, 31], G = [1, 32], it = [1, 35], rt = [1, 36], at = [1, 37], nt = [1, 38], V = [1, 34], p = [1, 4, 5, 16, 17, 19, 21, 22, 24, 25, 26, 27, 28, 29, 33, 35, 37, 38, 41, 45, 48, 51, 52, 53, 54, 57], ot = [1, 4, 5, 14, 15, 16, 17, 19, 21, 22, 24, 25, 26, 27, 28, 29, 33, 35, 37, 38, 39, 40, 41, 45, 48, 51, 52, 53, 54, 57], $t = [4, 5, 16, 17, 19, 21, 22, 24, 25, 26, 27, 28, 29, 33, 35, 37, 38, 41, 45, 48, 51, 52, 53, 54, 57], gt = {
    trace: /* @__PURE__ */ d(function() {
    }, "trace"),
    yy: {},
    symbols_: { error: 2, start: 3, SPACE: 4, NL: 5, SD: 6, document: 7, line: 8, statement: 9, classDefStatement: 10, styleStatement: 11, cssClassStatement: 12, idStatement: 13, DESCR: 14, "-->": 15, HIDE_EMPTY: 16, scale: 17, WIDTH: 18, COMPOSIT_STATE: 19, STRUCT_START: 20, STRUCT_STOP: 21, STATE_DESCR: 22, AS: 23, ID: 24, FORK: 25, JOIN: 26, CHOICE: 27, CONCURRENT: 28, note: 29, notePosition: 30, NOTE_TEXT: 31, direction: 32, acc_title: 33, acc_title_value: 34, acc_descr: 35, acc_descr_value: 36, acc_descr_multiline_value: 37, CLICK: 38, STRING: 39, HREF: 40, classDef: 41, CLASSDEF_ID: 42, CLASSDEF_STYLEOPTS: 43, DEFAULT: 44, style: 45, STYLE_IDS: 46, STYLEDEF_STYLEOPTS: 47, class: 48, CLASSENTITY_IDS: 49, STYLECLASS: 50, direction_tb: 51, direction_bt: 52, direction_rl: 53, direction_lr: 54, eol: 55, ";": 56, EDGE_STATE: 57, STYLE_SEPARATOR: 58, left_of: 59, right_of: 60, $accept: 0, $end: 1 },
    terminals_: { 2: "error", 4: "SPACE", 5: "NL", 6: "SD", 14: "DESCR", 15: "-->", 16: "HIDE_EMPTY", 17: "scale", 18: "WIDTH", 19: "COMPOSIT_STATE", 20: "STRUCT_START", 21: "STRUCT_STOP", 22: "STATE_DESCR", 23: "AS", 24: "ID", 25: "FORK", 26: "JOIN", 27: "CHOICE", 28: "CONCURRENT", 29: "note", 31: "NOTE_TEXT", 33: "acc_title", 34: "acc_title_value", 35: "acc_descr", 36: "acc_descr_value", 37: "acc_descr_multiline_value", 38: "CLICK", 39: "STRING", 40: "HREF", 41: "classDef", 42: "CLASSDEF_ID", 43: "CLASSDEF_STYLEOPTS", 44: "DEFAULT", 45: "style", 46: "STYLE_IDS", 47: "STYLEDEF_STYLEOPTS", 48: "class", 49: "CLASSENTITY_IDS", 50: "STYLECLASS", 51: "direction_tb", 52: "direction_bt", 53: "direction_rl", 54: "direction_lr", 56: ";", 57: "EDGE_STATE", 58: "STYLE_SEPARATOR", 59: "left_of", 60: "right_of" },
    productions_: [0, [3, 2], [3, 2], [3, 2], [7, 0], [7, 2], [8, 2], [8, 1], [8, 1], [9, 1], [9, 1], [9, 1], [9, 1], [9, 2], [9, 3], [9, 4], [9, 1], [9, 2], [9, 1], [9, 4], [9, 3], [9, 6], [9, 1], [9, 1], [9, 1], [9, 1], [9, 4], [9, 4], [9, 1], [9, 2], [9, 2], [9, 1], [9, 5], [9, 5], [10, 3], [10, 3], [11, 3], [12, 3], [32, 1], [32, 1], [32, 1], [32, 1], [55, 1], [55, 1], [13, 1], [13, 1], [13, 3], [13, 3], [30, 1], [30, 1]],
    performAction: /* @__PURE__ */ d(function(B, r, a, y, _, i, x) {
      var l = i.length - 1;
      switch (_) {
        case 3:
          return y.setRootDoc(i[l]), i[l];
        case 4:
          this.$ = [];
          break;
        case 5:
          i[l] != "nl" && (i[l - 1].push(i[l]), this.$ = i[l - 1]);
          break;
        case 6:
        case 7:
          this.$ = i[l];
          break;
        case 8:
          this.$ = "nl";
          break;
        case 12:
          this.$ = i[l];
          break;
        case 13:
          const Q = i[l - 1];
          Q.description = y.trimColon(i[l]), this.$ = Q;
          break;
        case 14:
          this.$ = { stmt: "relation", state1: i[l - 2], state2: i[l] };
          break;
        case 15:
          const St = y.trimColon(i[l]);
          this.$ = { stmt: "relation", state1: i[l - 3], state2: i[l - 1], description: St };
          break;
        case 19:
          this.$ = { stmt: "state", id: i[l - 3], type: "default", description: "", doc: i[l - 1] };
          break;
        case 20:
          var z = i[l], X = i[l - 2].trim();
          if (i[l].match(":")) {
            var ct = i[l].split(":");
            z = ct[0], X = [X, ct[1]];
          }
          this.$ = { stmt: "state", id: z, type: "default", description: X };
          break;
        case 21:
          this.$ = { stmt: "state", id: i[l - 3], type: "default", description: i[l - 5], doc: i[l - 1] };
          break;
        case 22:
          this.$ = { stmt: "state", id: i[l], type: "fork" };
          break;
        case 23:
          this.$ = { stmt: "state", id: i[l], type: "join" };
          break;
        case 24:
          this.$ = { stmt: "state", id: i[l], type: "choice" };
          break;
        case 25:
          this.$ = { stmt: "state", id: y.getDividerId(), type: "divider" };
          break;
        case 26:
          this.$ = { stmt: "state", id: i[l - 1].trim(), note: { position: i[l - 2].trim(), text: i[l].trim() } };
          break;
        case 29:
          this.$ = i[l].trim(), y.setAccTitle(this.$);
          break;
        case 30:
        case 31:
          this.$ = i[l].trim(), y.setAccDescription(this.$);
          break;
        case 32:
          this.$ = {
            stmt: "click",
            id: i[l - 3],
            url: i[l - 2],
            tooltip: i[l - 1]
          };
          break;
        case 33:
          this.$ = {
            stmt: "click",
            id: i[l - 3],
            url: i[l - 1],
            tooltip: ""
          };
          break;
        case 34:
        case 35:
          this.$ = { stmt: "classDef", id: i[l - 1].trim(), classes: i[l].trim() };
          break;
        case 36:
          this.$ = { stmt: "style", id: i[l - 1].trim(), styleClass: i[l].trim() };
          break;
        case 37:
          this.$ = { stmt: "applyClass", id: i[l - 1].trim(), styleClass: i[l].trim() };
          break;
        case 38:
          y.setDirection("TB"), this.$ = { stmt: "dir", value: "TB" };
          break;
        case 39:
          y.setDirection("BT"), this.$ = { stmt: "dir", value: "BT" };
          break;
        case 40:
          y.setDirection("RL"), this.$ = { stmt: "dir", value: "RL" };
          break;
        case 41:
          y.setDirection("LR"), this.$ = { stmt: "dir", value: "LR" };
          break;
        case 44:
        case 45:
          this.$ = { stmt: "state", id: i[l].trim(), type: "default", description: "" };
          break;
        case 46:
          this.$ = { stmt: "state", id: i[l - 2].trim(), classes: [i[l].trim()], type: "default", description: "" };
          break;
        case 47:
          this.$ = { stmt: "state", id: i[l - 2].trim(), classes: [i[l].trim()], type: "default", description: "" };
          break;
      }
    }, "anonymous"),
    table: [{ 3: 1, 4: e, 5: n, 6: s }, { 1: [3] }, { 3: 5, 4: e, 5: n, 6: s }, { 3: 6, 4: e, 5: n, 6: s }, t([1, 4, 5, 16, 17, 19, 22, 24, 25, 26, 27, 28, 29, 33, 35, 37, 38, 41, 45, 48, 51, 52, 53, 54, 57], c, { 7: 7 }), { 1: [2, 1] }, { 1: [2, 2] }, { 1: [2, 3], 4: o, 5: f, 8: 8, 9: 10, 10: 12, 11: 13, 12: 14, 13: 15, 16: m, 17: u, 19: S, 22: E, 24: g, 25: O, 26: L, 27: R, 28: D, 29: I, 32: 25, 33: h, 35: C, 37: v, 38: w, 41: M, 45: Y, 48: G, 51: it, 52: rt, 53: at, 54: nt, 57: V }, t(p, [2, 5]), { 9: 39, 10: 12, 11: 13, 12: 14, 13: 15, 16: m, 17: u, 19: S, 22: E, 24: g, 25: O, 26: L, 27: R, 28: D, 29: I, 32: 25, 33: h, 35: C, 37: v, 38: w, 41: M, 45: Y, 48: G, 51: it, 52: rt, 53: at, 54: nt, 57: V }, t(p, [2, 7]), t(p, [2, 8]), t(p, [2, 9]), t(p, [2, 10]), t(p, [2, 11]), t(p, [2, 12], { 14: [1, 40], 15: [1, 41] }), t(p, [2, 16]), { 18: [1, 42] }, t(p, [2, 18], { 20: [1, 43] }), { 23: [1, 44] }, t(p, [2, 22]), t(p, [2, 23]), t(p, [2, 24]), t(p, [2, 25]), { 30: 45, 31: [1, 46], 59: [1, 47], 60: [1, 48] }, t(p, [2, 28]), { 34: [1, 49] }, { 36: [1, 50] }, t(p, [2, 31]), { 13: 51, 24: g, 57: V }, { 42: [1, 52], 44: [1, 53] }, { 46: [1, 54] }, { 49: [1, 55] }, t(ot, [2, 44], { 58: [1, 56] }), t(ot, [2, 45], { 58: [1, 57] }), t(p, [2, 38]), t(p, [2, 39]), t(p, [2, 40]), t(p, [2, 41]), t(p, [2, 6]), t(p, [2, 13]), { 13: 58, 24: g, 57: V }, t(p, [2, 17]), t($t, c, { 7: 59 }), { 24: [1, 60] }, { 24: [1, 61] }, { 23: [1, 62] }, { 24: [2, 48] }, { 24: [2, 49] }, t(p, [2, 29]), t(p, [2, 30]), { 39: [1, 63], 40: [1, 64] }, { 43: [1, 65] }, { 43: [1, 66] }, { 47: [1, 67] }, { 50: [1, 68] }, { 24: [1, 69] }, { 24: [1, 70] }, t(p, [2, 14], { 14: [1, 71] }), { 4: o, 5: f, 8: 8, 9: 10, 10: 12, 11: 13, 12: 14, 13: 15, 16: m, 17: u, 19: S, 21: [1, 72], 22: E, 24: g, 25: O, 26: L, 27: R, 28: D, 29: I, 32: 25, 33: h, 35: C, 37: v, 38: w, 41: M, 45: Y, 48: G, 51: it, 52: rt, 53: at, 54: nt, 57: V }, t(p, [2, 20], { 20: [1, 73] }), { 31: [1, 74] }, { 24: [1, 75] }, { 39: [1, 76] }, { 39: [1, 77] }, t(p, [2, 34]), t(p, [2, 35]), t(p, [2, 36]), t(p, [2, 37]), t(ot, [2, 46]), t(ot, [2, 47]), t(p, [2, 15]), t(p, [2, 19]), t($t, c, { 7: 78 }), t(p, [2, 26]), t(p, [2, 27]), { 5: [1, 79] }, { 5: [1, 80] }, { 4: o, 5: f, 8: 8, 9: 10, 10: 12, 11: 13, 12: 14, 13: 15, 16: m, 17: u, 19: S, 21: [1, 81], 22: E, 24: g, 25: O, 26: L, 27: R, 28: D, 29: I, 32: 25, 33: h, 35: C, 37: v, 38: w, 41: M, 45: Y, 48: G, 51: it, 52: rt, 53: at, 54: nt, 57: V }, t(p, [2, 32]), t(p, [2, 33]), t(p, [2, 21])],
    defaultActions: { 5: [2, 1], 6: [2, 2], 47: [2, 48], 48: [2, 49] },
    parseError: /* @__PURE__ */ d(function(B, r) {
      if (r.recoverable)
        this.trace(B);
      else {
        var a = new Error(B);
        throw a.hash = r, a;
      }
    }, "parseError"),
    parse: /* @__PURE__ */ d(function(B) {
      var r = this, a = [0], y = [], _ = [null], i = [], x = this.table, l = "", z = 0, X = 0, ct = 2, Q = 1, St = i.slice.call(arguments, 1), b = Object.create(this.lexer), U = { yy: {} };
      for (var mt in this.yy)
        Object.prototype.hasOwnProperty.call(this.yy, mt) && (U.yy[mt] = this.yy[mt]);
      b.setInput(B, U.yy), U.yy.lexer = b, U.yy.parser = this, typeof b.yylloc > "u" && (b.yylloc = {});
      var _t = b.yylloc;
      i.push(_t);
      var Zt = b.options && b.options.ranges;
      typeof U.yy.parseError == "function" ? this.parseError = U.yy.parseError : this.parseError = Object.getPrototypeOf(this).parseError;
      function Qt(A) {
        a.length = a.length - 2 * A, _.length = _.length - A, i.length = i.length - A;
      }
      d(Qt, "popStack");
      function Ct() {
        var A;
        return A = y.pop() || b.lex() || Q, typeof A != "number" && (A instanceof Array && (y = A, A = y.pop()), A = r.symbols_[A] || A), A;
      }
      d(Ct, "lex");
      for (var $, W, N, Tt, q = {}, ht, F, At, dt; ; ) {
        if (W = a[a.length - 1], this.defaultActions[W] ? N = this.defaultActions[W] : (($ === null || typeof $ > "u") && ($ = Ct()), N = x[W] && x[W][$]), typeof N > "u" || !N.length || !N[0]) {
          var bt = "";
          dt = [];
          for (ht in x[W])
            this.terminals_[ht] && ht > ct && dt.push("'" + this.terminals_[ht] + "'");
          b.showPosition ? bt = "Parse error on line " + (z + 1) + `:
` + b.showPosition() + `
Expecting ` + dt.join(", ") + ", got '" + (this.terminals_[$] || $) + "'" : bt = "Parse error on line " + (z + 1) + ": Unexpected " + ($ == Q ? "end of input" : "'" + (this.terminals_[$] || $) + "'"), this.parseError(bt, {
            text: b.match,
            token: this.terminals_[$] || $,
            line: b.yylineno,
            loc: _t,
            expected: dt
          });
        }
        if (N[0] instanceof Array && N.length > 1)
          throw new Error("Parse Error: multiple actions possible at state: " + W + ", token: " + $);
        switch (N[0]) {
          case 1:
            a.push($), _.push(b.yytext), i.push(b.yylloc), a.push(N[1]), $ = null, X = b.yyleng, l = b.yytext, z = b.yylineno, _t = b.yylloc;
            break;
          case 2:
            if (F = this.productions_[N[1]][1], q.$ = _[_.length - F], q._$ = {
              first_line: i[i.length - (F || 1)].first_line,
              last_line: i[i.length - 1].last_line,
              first_column: i[i.length - (F || 1)].first_column,
              last_column: i[i.length - 1].last_column
            }, Zt && (q._$.range = [
              i[i.length - (F || 1)].range[0],
              i[i.length - 1].range[1]
            ]), Tt = this.performAction.apply(q, [
              l,
              X,
              z,
              U.yy,
              N[1],
              _,
              i
            ].concat(St)), typeof Tt < "u")
              return Tt;
            F && (a = a.slice(0, -1 * F * 2), _ = _.slice(0, -1 * F), i = i.slice(0, -1 * F)), a.push(this.productions_[N[1]][0]), _.push(q.$), i.push(q._$), At = x[a[a.length - 2]][a[a.length - 1]], a.push(At);
            break;
          case 3:
            return !0;
        }
      }
      return !0;
    }, "parse")
  }, Ht = /* @__PURE__ */ function() {
    var B = {
      EOF: 1,
      parseError: /* @__PURE__ */ d(function(r, a) {
        if (this.yy.parser)
          this.yy.parser.parseError(r, a);
        else
          throw new Error(r);
      }, "parseError"),
      // resets the lexer, sets new input
      setInput: /* @__PURE__ */ d(function(r, a) {
        return this.yy = a || this.yy || {}, this._input = r, 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__ */ d(function() {
        var r = this._input[0];
        this.yytext += r, this.yyleng++, this.offset++, this.match += r, this.matched += r;
        var a = r.match(/(?:\r\n?|\n).*/g);
        return a ? (this.yylineno++, this.yylloc.last_line++) : this.yylloc.last_column++, this.options.ranges && this.yylloc.range[1]++, this._input = this._input.slice(1), r;
      }, "input"),
      // unshifts one char (or a string) into the input
      unput: /* @__PURE__ */ d(function(r) {
        var a = r.length, y = r.split(/(?:\r\n?|\n)/g);
        this._input = r + this._input, this.yytext = this.yytext.substr(0, this.yytext.length - a), this.offset -= a;
        var _ = 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), y.length - 1 && (this.yylineno -= y.length - 1);
        var i = 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: y ? (y.length === _.length ? this.yylloc.first_column : 0) + _[_.length - y.length].length - y[0].length : this.yylloc.first_column - a
        }, this.options.ranges && (this.yylloc.range = [i[0], i[0] + this.yyleng - a]), this.yyleng = this.yytext.length, this;
      }, "unput"),
      // When called from action, caches matched text and appends it on next action
      more: /* @__PURE__ */ d(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__ */ 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"),
      // retain first n characters of the match
      less: /* @__PURE__ */ d(function(r) {
        this.unput(this.match.slice(r));
      }, "less"),
      // displays already matched input, i.e. for error messages
      pastInput: /* @__PURE__ */ d(function() {
        var r = this.matched.substr(0, this.matched.length - this.match.length);
        return (r.length > 20 ? "..." : "") + r.substr(-20).replace(/\n/g, "");
      }, "pastInput"),
      // displays upcoming input, i.e. for error messages
      upcomingInput: /* @__PURE__ */ d(function() {
        var r = this.match;
        return r.length < 20 && (r += this._input.substr(0, 20 - r.length)), (r.substr(0, 20) + (r.length > 20 ? "..." : "")).replace(/\n/g, "");
      }, "upcomingInput"),
      // displays the character position where the lexing error occurred, i.e. for error messages
      showPosition: /* @__PURE__ */ d(function() {
        var r = this.pastInput(), a = new Array(r.length + 1).join("-");
        return r + this.upcomingInput() + `
` + a + "^";
      }, "showPosition"),
      // test the lexed token: return FALSE when not a match, otherwise return token
      test_match: /* @__PURE__ */ d(function(r, a) {
        var y, _, i;
        if (this.options.backtrack_lexer && (i = {
          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 && (i.yylloc.range = this.yylloc.range.slice(0))), _ = r[0].match(/(?:\r\n?|\n).*/g), _ && (this.yylineno += _.length), this.yylloc = {
          first_line: this.yylloc.last_line,
          last_line: this.yylineno + 1,
          first_column: this.yylloc.last_column,
          last_column: _ ? _[_.length - 1].length - _[_.length - 1].match(/\r?\n?/)[0].length : this.yylloc.last_column + r[0].length
        }, this.yytext += r[0], this.match += r[0], this.matches = r, 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(r[0].length), this.matched += r[0], y = this.performAction.call(this, this.yy, this, a, this.conditionStack[this.conditionStack.length - 1]), this.done && this._input && (this.done = !1), y)
          return y;
        if (this._backtrack) {
          for (var x in i)
            this[x] = i[x];
          return !1;
        }
        return !1;
      }, "test_match"),
      // return next match in input
      next: /* @__PURE__ */ d(function() {
        if (this.done)
          return this.EOF;
        this._input || (this.done = !0);
        var r, a, y, _;
        this._more || (this.yytext = "", this.match = "");
        for (var i = this._currentRules(), x = 0; x < i.length; x++)
          if (y = this._input.match(this.rules[i[x]]), y && (!a || y[0].length > a[0].length)) {
            if (a = y, _ = x, this.options.backtrack_lexer) {
              if (r = this.test_match(y, i[x]), r !== !1)
                return r;
              if (this._backtrack) {
                a = !1;
                continue;
              } else
                return !1;
            } else if (!this.options.flex)
              break;
          }
        return a ? (r = this.test_match(a, i[_]), r !== !1 ? r : !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__ */ d(function() {
        var r = this.next();
        return r || this.lex();
      }, "lex"),
      // activates a new lexer condition state (pushes the new lexer condition state onto the condition stack)
      begin: /* @__PURE__ */ d(function(r) {
        this.conditionStack.push(r);
      }, "begin"),
      // pop the previously active lexer condition state off the condition stack
      popState: /* @__PURE__ */ d(function() {
        var r = this.conditionStack.length - 1;
        return r > 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__ */ 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"),
      // 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__ */ d(function(r) {
        return r = this.conditionStack.length - 1 - Math.abs(r || 0), r >= 0 ? this.conditionStack[r] : "INITIAL";
      }, "topState"),
      // alias for begin(condition)
      pushState: /* @__PURE__ */ d(function(r) {
        this.begin(r);
      }, "pushState"),
      // return the number of states currently on the stack
      stateStackSize: /* @__PURE__ */ d(function() {
        return this.conditionStack.length;
      }, "stateStackSize"),
      options: { "case-insensitive": !0 },
      performAction: /* @__PURE__ */ d(function(r, a, y, _) {
        switch (y) {
          case 0:
            return 38;
          case 1:
            return 40;
          case 2:
            return 39;
          case 3:
            return 44;
          case 4:
            return 51;
          case 5:
            return 52;
          case 6:
            return 53;
          case 7:
            return 54;
          case 8:
            break;
          case 9:
            break;
          case 10:
            return 5;
          case 11:
            break;
          case 12:
            break;
          case 13:
            break;
          case 14:
            break;
          case 15:
            return this.pushState("SCALE"), 17;
          case 16:
            return 18;
          case 17:
            this.popState();
            break;
          case 18:
            return this.begin("acc_title"), 33;
          case 19:
            return this.popState(), "acc_title_value";
          case 20:
            return this.begin("acc_descr"), 35;
          case 21:
            return this.popState(), "acc_descr_value";
          case 22:
            this.begin("acc_descr_multiline");
            break;
          case 23:
            this.popState();
            break;
          case 24:
            return "acc_descr_multiline_value";
          case 25:
            return this.pushState("CLASSDEF"), 41;
          case 26:
            return this.popState(), this.pushState("CLASSDEFID"), "DEFAULT_CLASSDEF_ID";
          case 27:
            return this.popState(), this.pushState("CLASSDEFID"), 42;
          case 28:
            return this.popState(), 43;
          case 29:
            return this.pushState("CLASS"), 48;
          case 30:
            return this.popState(), this.pushState("CLASS_STYLE"), 49;
          case 31:
            return this.popState(), 50;
          case 32:
            return this.pushState("STYLE"), 45;
          case 33:
            return this.popState(), this.pushState("STYLEDEF_STYLES"), 46;
          case 34:
            return this.popState(), 47;
          case 35:
            return this.pushState("SCALE"), 17;
          case 36:
            return 18;
          case 37:
            this.popState();
            break;
          case 38:
            this.pushState("STATE");
            break;
          case 39:
            return this.popState(), a.yytext = a.yytext.slice(0, -8).trim(), 25;
          case 40:
            return this.popState(), a.yytext = a.yytext.slice(0, -8).trim(), 26;
          case 41:
            return this.popState(), a.yytext = a.yytext.slice(0, -10).trim(), 27;
          case 42:
            return this.popState(), a.yytext = a.yytext.slice(0, -8).trim(), 25;
          case 43:
            return this.popState(), a.yytext = a.yytext.slice(0, -8).trim(), 26;
          case 44:
            return this.popState(), a.yytext = a.yytext.slice(0, -10).trim(), 27;
          case 45:
            return 51;
          case 46:
            return 52;
          case 47:
            return 53;
          case 48:
            return 54;
          case 49:
            this.pushState("STATE_STRING");
            break;
          case 50:
            return this.pushState("STATE_ID"), "AS";
          case 51:
            return this.popState(), "ID";
          case 52:
            this.popState();
            break;
          case 53:
            return "STATE_DESCR";
          case 54:
            return 19;
          case 55:
            this.popState();
            break;
          case 56:
            return this.popState(), this.pushState("struct"), 20;
          case 57:
            break;
          case 58:
            return this.popState(), 21;
          case 59:
            break;
          case 60:
            return this.begin("NOTE"), 29;
          case 61:
            return this.popState(), this.pushState("NOTE_ID"), 59;
          case 62:
            return this.popState(), this.pushState("NOTE_ID"), 60;
          case 63:
            this.popState(), this.pushState("FLOATING_NOTE");
            break;
          case 64:
            return this.popState(), this.pushState("FLOATING_NOTE_ID"), "AS";
          case 65:
            break;
          case 66:
            return "NOTE_TEXT";
          case 67:
            return this.popState(), "ID";
          case 68:
            return this.popState(), this.pushState("NOTE_TEXT"), 24;
          case 69:
            return this.popState(), a.yytext = a.yytext.substr(2).trim(), 31;
          case 70:
            return this.popState(), a.yytext = a.yytext.slice(0, -8).trim(), 31;
          case 71:
            return 6;
          case 72:
            return 6;
          case 73:
            return 16;
          case 74:
            return 57;
          case 75:
            return 24;
          case 76:
            return a.yytext = a.yytext.trim(), 14;
          case 77:
            return 15;
          case 78:
            return 28;
          case 79:
            return 58;
          case 80:
            return 5;
          case 81:
            return "INVALID";
        }
      }, "anonymous"),
      rules: [/^(?:click\b)/i, /^(?:href\b)/i, /^(?:"[^"]*")/i, /^(?:default\b)/i, /^(?:.*direction\s+TB[^\n]*)/i, /^(?:.*direction\s+BT[^\n]*)/i, /^(?:.*direction\s+RL[^\n]*)/i, /^(?:.*direction\s+LR[^\n]*)/i, /^(?:%%(?!\{)[^\n]*)/i, /^(?:[^\}]%%[^\n]*)/i, /^(?:[\n]+)/i, /^(?:[\s]+)/i, /^(?:((?!\n)\s)+)/i, /^(?:#[^\n]*)/i, /^(?:%[^\n]*)/i, /^(?:scale\s+)/i, /^(?:\d+)/i, /^(?:\s+width\b)/i, /^(?:accTitle\s*:\s*)/i, /^(?:(?!\n||)*[^\n]*)/i, /^(?:accDescr\s*:\s*)/i, /^(?:(?!\n||)*[^\n]*)/i, /^(?:accDescr\s*\{\s*)/i, /^(?:[\}])/i, /^(?:[^\}]*)/i, /^(?:classDef\s+)/i, /^(?:DEFAULT\s+)/i, /^(?:\w+\s+)/i, /^(?:[^\n]*)/i, /^(?:class\s+)/i, /^(?:(\w+)+((,\s*\w+)*))/i, /^(?:[^\n]*)/i, /^(?:style\s+)/i, /^(?:[\w,]+\s+)/i, /^(?:[^\n]*)/i, /^(?:scale\s+)/i, /^(?:\d+)/i, /^(?:\s+width\b)/i, /^(?:state\s+)/i, /^(?:.*<<fork>>)/i, /^(?:.*<<join>>)/i, /^(?:.*<<choice>>)/i, /^(?:.*\[\[fork\]\])/i, /^(?:.*\[\[join\]\])/i, /^(?:.*\[\[choice\]\])/i, /^(?:.*direction\s+TB[^\n]*)/i, /^(?:.*direction\s+BT[^\n]*)/i, /^(?:.*direction\s+RL[^\n]*)/i, /^(?:.*direction\s+LR[^\n]*)/i, /^(?:["])/i, /^(?:\s*as\s+)/i, /^(?:[^\n\{]*)/i, /^(?:["])/i, /^(?:[^"]*)/i, /^(?:[^\n\s\{]+)/i, /^(?:\n)/i, /^(?:\{)/i, /^(?:%%(?!\{)[^\n]*)/i, /^(?:\})/i, /^(?:[\n])/i, /^(?:note\s+)/i, /^(?:left of\b)/i, /^(?:right of\b)/i, /^(?:")/i, /^(?:\s*as\s*)/i, /^(?:["])/i, /^(?:[^"]*)/i, /^(?:[^\n]*)/i, /^(?:\s*[^:\n\s\-]+)/i, /^(?:\s*:[^:\n;]+)/i, /^(?:[\s\S]*?end note\b)/i, /^(?:stateDiagram\s+)/i, /^(?:stateDiagram-v2\s+)/i, /^(?:hide empty description\b)/i, /^(?:\[\*\])/i, /^(?:[^:\n\s\-\{]+)/i, /^(?:\s*:[^:\n;]+)/i, /^(?:-->)/i, /^(?:--)/i, /^(?::::)/i, /^(?:$)/i, /^(?:.)/i],
      conditions: { LINE: { rules: [12, 13], inclusive: !1 }, struct: { rules: [12, 13, 25, 29, 32, 38, 45, 46, 47, 48, 57, 58, 59, 60, 74, 75, 76, 77, 78], inclusive: !1 }, FLOATING_NOTE_ID: { rules: [67], inclusive: !1 }, FLOATING_NOTE: { rules: [64, 65, 66], inclusive: !1 }, NOTE_TEXT: { rules: [69, 70], inclusive: !1 }, NOTE_ID: { rules: [68], inclusive: !1 }, NOTE: { rules: [61, 62, 63], inclusive: !1 }, STYLEDEF_STYLEOPTS: { rules: [], inclusive: !1 }, STYLEDEF_STYLES: { rules: [34], inclusive: !1 }, STYLE_IDS: { rules: [], inclusive: !1 }, STYLE: { rules: [33], inclusive: !1 }, CLASS_STYLE: { rules: [31], inclusive: !1 }, CLASS: { rules: [30], inclusive: !1 }, CLASSDEFID: { rules: [28], inclusive: !1 }, CLASSDEF: { rules: [26, 27], inclusive: !1 }, acc_descr_multiline: { rules: [23, 24], inclusive: !1 }, acc_descr: { rules: [21], inclusive: !1 }, acc_title: { rules: [19], inclusive: !1 }, SCALE: { rules: [16, 17, 36, 37], inclusive: !1 }, ALIAS: { rules: [], inclusive: !1 }, STATE_ID: { rules: [51], inclusive: !1 }, STATE_STRING: { rules: [52, 53], inclusive: !1 }, FORK_STATE: { rules: [], inclusive: !1 }, STATE: { rules: [12, 13, 39, 40, 41, 42, 43, 44, 49, 50, 54, 55, 56], inclusive: !1 }, ID: { rules: [12, 13], inclusive: !1 }, INITIAL: { rules: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 14, 15, 18, 20, 22, 25, 29, 32, 35, 38, 56, 60, 71, 72, 73, 74, 75, 76, 77, 79, 80, 81], inclusive: !0 } }
    };
    return B;
  }();
  gt.lexer = Ht;
  function lt() {
    this.yy = {};
  }
  return d(lt, "Parser"), lt.prototype = gt, gt.Parser = lt, new lt();
}();
Dt.parser = Dt;
var Ye = Dt, de = "TB", Pt = "TB", Lt = "dir", Z = "state", H = "root", vt = "relation", ue = "classDef", pe = "style", ye = "applyClass", et = "default", Ft = "divider", Yt = "fill:none", Gt = "fill: #333", jt = "c", Mt = "text", zt = "normal", kt = "rect", Et = "rectWithTitle", fe = "stateStart", ge = "stateEnd", It = "divider", Nt = "roundedWithTitle", Se = "note", me = "noteGroup", st = "statediagram", _e = "state", Te = `${st}-${_e}`, Ut = "transition", be = "note", ke = "note-edge", Ee = `${Ut} ${ke}`, De = `${st}-${be}`, ve = "cluster", xe = `${st}-${ve}`, $e = "cluster-alt", Ce = `${st}-${$e}`, Wt = "parent", Kt = "note", Ae = "state", xt = "----", Le = `${xt}${Kt}`, Ot = `${xt}${Wt}`, Vt = /* @__PURE__ */ d((t, e = Pt) => {
  if (!t.doc)
    return e;
  let n = e;
  for (const s of t.doc)
    s.stmt === "dir" && (n = s.value);
  return n;
}, "getDir"), Ie = /* @__PURE__ */ d(function(t, e) {
  return e.db.getClasses();
}, "getClasses"), Ne = /* @__PURE__ */ d(async function(t, e, n, s) {
  T.info("REF0:"), T.info("Drawing state diagram (v2)", e);
  const { securityLevel: c, state: o, layout: f } = P();
  s.db.extract(s.db.getRootDocV2());
  const m = s.db.getData(), u = Jt(e, c);
  m.type = s.type, m.layoutAlgorithm = f, m.nodeSpacing = (o == null ? void 0 : o.nodeSpacing) || 50, m.rankSpacing = (o == null ? void 0 : o.rankSpacing) || 50, m.markers = ["barb"], m.diagramId = e, await ee(m, u);
  const S = 8;
  try {
    (typeof s.db.getLinks == "function" ? s.db.getLinks() : /* @__PURE__ */ new Map()).forEach((E, g) => {
      var O;
      const L = typeof g == "string" ? g : typeof (g == null ? void 0 : g.id) == "string" ? g.id : "";
      if (!L) {
        T.warn("⚠️ Invalid or missing stateId from key:", JSON.stringify(g));
        return;
      }
      const R = (O = u.node()) == null ? void 0 : O.querySelectorAll("g");
      let D;
      if (R == null || R.forEach((v) => {
        var w;
        ((w = v.textContent) == null ? void 0 : w.trim()) === L && (D = v);
      }), !D) {
        T.warn("⚠️ Could not find node matching text:", L);
        return;
      }
      const I = D.parentNode;
      if (!I) {
        T.warn("⚠️ Node has no parent, cannot wrap:", L);
        return;
      }
      const h = document.createElementNS("http://www.w3.org/2000/svg", "a"), C = E.url.replace(/^"+|"+$/g, "");
      if (h.setAttributeNS("http://www.w3.org/1999/xlink", "xlink:href", C), h.setAttribute("target", "_blank"), E.tooltip) {
        const v = E.tooltip.replace(/^"+|"+$/g, "");
        h.setAttribute("title", v);
      }
      I.replaceChild(h, D), h.appendChild(D), T.info("🔗 Wrapped node in <a> tag for:", L, E.url);
    });
  } catch (E) {
    T.error("❌ Error injecting clickable links:", E);
  }
  se.insertTitle(
    u,
    "statediagramTitleText",
    (o == null ? void 0 : o.titleTopMargin) ?? 25,
    s.db.getDiagramTitle()
  ), te(u, S, st, (o == null ? void 0 : o.useMaxWidth) ?? !0);
}, "draw"), Ge = {
  getClasses: Ie,
  draw: Ne,
  getDir: Vt
}, yt = /* @__PURE__ */ new Map(), j = 0;
function ft(t = "", e = 0, n = "", s = xt) {
  const c = n !== null && n.length > 0 ? `${s}${n}` : "";
  return `${Ae}-${t}${c}-${e}`;
}
d(ft, "stateDomId");
var Oe = /* @__PURE__ */ d((t, e, n, s, c, o, f, m) => {
  T.trace("items", e), e.forEach((u) => {
    switch (u.stmt) {
      case Z:
        tt(t, u, n, s, c, o, f, m);
        break;
      case et:
        tt(t, u, n, s, c, o, f, m);
        break;
      case vt:
        {
          tt(
            t,
            u.state1,
            n,
            s,
            c,
            o,
            f,
            m
          ), tt(
            t,
            u.state2,
            n,
            s,
            c,
            o,
            f,
            m
          );
          const S = {
            id: "edge" + j,
            start: u.state1.id,
            end: u.state2.id,
            arrowhead: "normal",
            arrowTypeEnd: "arrow_barb",
            style: Yt,
            labelStyle: "",
            label: K.sanitizeText(u.description ?? "", P()),
            arrowheadStyle: Gt,
            labelpos: jt,
            labelType: Mt,
            thickness: zt,
            classes: Ut,
            look: f
          };
          c.push(S), j++;
        }
        break;
    }
  });
}, "setupDoc"), Rt = /* @__PURE__ */ d((t, e = Pt) => {
  let n = e;
  if (t.doc)
    for (const s of t.doc)
      s.stmt === "dir" && (n = s.value);
  return n;
}, "getDir");
function J(t, e, n) {
  if (!e.id || e.id === "</join></fork>" || e.id === "</choice>")
    return;
  e.cssClasses && (Array.isArray(e.cssCompiledStyles) || (e.cssCompiledStyles = []), e.cssClasses.split(" ").forEach((c) => {
    const o = n.get(c);
    o && (e.cssCompiledStyles = [...e.cssCompiledStyles ?? [], ...o.styles]);
  }));
  const s = t.find((c) => c.id === e.id);
  s ? Object.assign(s, e) : t.push(e);
}
d(J, "insertOrUpdateNode");
function Xt(t) {
  var e;
  return ((e = t == null ? void 0 : t.classes) == null ? void 0 : e.join(" ")) ?? "";
}
d(Xt, "getClassesFromDbInfo");
function qt(t) {
  return (t == null ? void 0 : t.styles) ?? [];
}
d(qt, "getStylesFromDbInfo");
var tt = /* @__PURE__ */ d((t, e, n, s, c, o, f, m) => {
  var u, S, E;
  const g = e.id, O = n.get(g), L = Xt(O), R = qt(O), D = P();
  if (T.info("dataFetcher parsedItem", e, O, R), g !== "root") {
    let I = kt;
    e.start === !0 ? I = fe : e.start === !1 && (I = ge), e.type !== et && (I = e.type), yt.get(g) || yt.set(g, {
      id: g,
      shape: I,
      description: K.sanitizeText(g, D),
      cssClasses: `${L} ${Te}`,
      cssStyles: R
    });
    const h = yt.get(g);
    e.description && (Array.isArray(h.description) ? (h.shape = Et, h.description.push(e.description)) : (u = h.description) != null && u.length && h.description.length > 0 ? (h.shape = Et, h.description === g ? h.description = [e.description] : h.description = [h.description, e.description]) : (h.shape = kt, h.description = e.description), h.description = K.sanitizeTextOrArray(h.description, D)), ((S = h.description) == null ? void 0 : S.length) === 1 && h.shape === Et && (h.type === "group" ? h.shape = Nt : h.shape = kt), !h.type && e.doc && (T.info("Setting cluster for XCX", g, Rt(e)), h.type = "group", h.isGroup = !0, h.dir = Rt(e), h.shape = e.type === Ft ? It : Nt, h.cssClasses = `${h.cssClasses} ${xe} ${o ? Ce : ""}`);
    const C = {
      labelStyle: "",
      shape: h.shape,
      label: h.description,
      cssClasses: h.cssClasses,
      cssCompiledStyles: [],
      cssStyles: h.cssStyles,
      id: g,
      dir: h.dir,
      domId: ft(g, j),
      type: h.type,
      isGroup: h.type === "group",
      padding: 8,
      rx: 10,
      ry: 10,
      look: f
    };
    if (C.shape === It && (C.label = ""), t && t.id !== "root" && (T.trace("Setting node ", g, " to be child of its parent ", t.id), C.parentId = t.id), C.centerLabel = !0, e.note) {
      const v = {
        labelStyle: "",
        shape: Se,
        label: e.note.text,
        cssClasses: De,
        // useHtmlLabels: false,
        cssStyles: [],
        cssCompiledStyles: [],
        id: g + Le + "-" + j,
        domId: ft(g, j, Kt),
        type: h.type,
        isGroup: h.type === "group",
        padding: (E = D.flowchart) == null ? void 0 : E.padding,
        look: f,
        position: e.note.position
      }, w = g + Ot, M = {
        labelStyle: "",
        shape: me,
        label: e.note.text,
        cssClasses: h.cssClasses,
        cssStyles: [],
        id: g + Ot,
        domId: ft(g, j, Wt),
        type: "group",
        isGroup: !0,
        padding: 16,
        //getConfig().flowchart.padding
        look: f,
        position: e.note.position
      };
      j++, M.id = w, v.parentId = w, J(s, M, m), J(s, v, m), J(s, C, m);
      let Y = g, G = v.id;
      e.note.position === "left of" && (Y = v.id, G = g), c.push({
        id: Y + "-" + G,
        start: Y,
        end: G,
        arrowhead: "none",
        arrowTypeEnd: "",
        style: Yt,
        labelStyle: "",
        classes: Ee,
        arrowheadStyle: Gt,
        labelpos: jt,
        labelType: Mt,
        thickness: zt,
        look: f
      });
    } else
      J(s, C, m);
  }
  e.doc && (T.trace("Adding nodes children "), Oe(e, e.doc, n, s, c, !o, f, m));
}, "dataFetcher"), Re = /* @__PURE__ */ d(() => {
  yt.clear(), j = 0;
}, "reset"), k = {
  START_NODE: "[*]",
  START_TYPE: "start",
  END_NODE: "[*]",
  END_TYPE: "end",
  COLOR_KEYWORD: "color",
  FILL_KEYWORD: "fill",
  BG_FILL: "bgFill",
  STYLECLASS_SEP: ","
}, wt = /* @__PURE__ */ d(() => /* @__PURE__ */ new Map(), "newClassesList"), Bt = /* @__PURE__ */ d(() => ({
  relations: [],
  states: /* @__PURE__ */ new Map(),
  documents: {}
}), "newDoc"), ut = /* @__PURE__ */ d((t) => JSON.parse(JSON.stringify(t)), "clone"), pt, je = (pt = class {
  constructor(t) {
    this.version = t, this.nodes = [], this.edges = [], this.rootDoc = [], this.classes = wt(), this.documents = { root: Bt() }, this.currentDocument = this.documents.root, this.startEndCount = 0, this.dividerCnt = 0, this.links = /* @__PURE__ */ new Map(), this.getAccTitle = ie, this.setAccTitle = re, this.getAccDescription = ae, this.setAccDescription = ne, this.setDiagramTitle = oe, this.getDiagramTitle = le, this.clear(), this.setRootDoc = this.setRootDoc.bind(this), this.getDividerId = this.getDividerId.bind(this), this.setDirection = this.setDirection.bind(this), this.trimColon = this.trimColon.bind(this);
  }
  /**
   * Convert all of the statements (stmts) that were parsed into states and relationships.
   * This is done because a state diagram may have nested sections,
   * where each section is a 'document' and has its own set of statements.
   * Ex: the section within a fork has its own statements, and incoming and outgoing statements
   * refer to the fork as a whole (document).
   * See the parser grammar:  the definition of a document is a document then a 'line', where a line can be a statement.
   * This will push the statement into the list of statements for the current document.
   */
  extract(t) {
    this.clear(!0);
    for (const s of Array.isArray(t) ? t : t.doc)
      switch (s.stmt) {
        case Z:
          this.addState(s.id.trim(), s.type, s.doc, s.description, s.note);
          break;
        case vt:
          this.addRelation(s.state1, s.state2, s.description);
          break;
        case ue:
          this.addStyleClass(s.id.trim(), s.classes);
          break;
        case pe:
          this.handleStyleDef(s);
          break;
        case ye:
          this.setCssClass(s.id.trim(), s.styleClass);
          break;
        case "click":
          this.addLink(s.id, s.url, s.tooltip);
          break;
      }
    const e = this.getStates(), n = P();
    Re(), tt(
      void 0,
      this.getRootDocV2(),
      e,
      this.nodes,
      this.edges,
      !0,
      n.look,
      this.classes
    );
    for (const s of this.nodes)
      if (Array.isArray(s.label)) {
        if (s.description = s.label.slice(1), s.isGroup && s.description.length > 0)
          throw new Error(
            `Group nodes can only have label. Remove the additional description for node [${s.id}]`
          );
        s.label = s.label[0];
      }
  }
  handleStyleDef(t) {
    const e = t.id.trim().split(","), n = t.styleClass.split(",");
    for (const s of e) {
      let c = this.getState(s);
      if (!c) {
        const o = s.trim();
        this.addState(o), c = this.getState(o);
      }
      c && (c.styles = n.map((o) => {
        var f;
        return (f = o.replace(/;/g, "")) == null ? void 0 : f.trim();
      }));
    }
  }
  setRootDoc(t) {
    T.info("Setting root doc", t), this.rootDoc = t, this.version === 1 ? this.extract(t) : this.extract(this.getRootDocV2());
  }
  docTranslator(t, e, n) {
    if (e.stmt === vt) {
      this.docTranslator(t, e.state1, !0), this.docTranslator(t, e.state2, !1);
      return;
    }
    if (e.stmt === Z && (e.id === k.START_NODE ? (e.id = t.id + (n ? "_start" : "_end"), e.start = n) : e.id = e.id.trim()), e.stmt !== H && e.stmt !== Z || !e.doc)
      return;
    const s = [];
    let c = [];
    for (const o of e.doc)
      if (o.type === Ft) {
        const f = ut(o);
        f.doc = ut(c), s.push(f), c = [];
      } else
        c.push(o);
    if (s.length > 0 && c.length > 0) {
      const o = {
        stmt: Z,
        id: ce(),
        type: "divider",
        doc: ut(c)
      };
      s.push(ut(o)), e.doc = s;
    }
    e.doc.forEach((o) => this.docTranslator(e, o, !0));
  }
  getRootDocV2() {
    return this.docTranslator(
      { id: H, stmt: H },
      { id: H, stmt: H, doc: this.rootDoc },
      !0
    ), { id: H, doc: this.rootDoc };
  }
  /**
   * Function called by parser when a node definition has been found.
   *
   * @param descr - description for the state. Can be a string or a list or strings
   * @param classes - class styles to apply to this state. Can be a string (1 style) or an array of styles. If it's just 1 class, convert it to an array of that 1 class.
   * @param styles - styles to apply to this state. Can be a string (1 style) or an array of styles. If it's just 1 style, convert it to an array of that 1 style.
   * @param textStyles - text styles to apply to this state. Can be a string (1 text test) or an array of text styles. If it's just 1 text style, convert it to an array of that 1 text style.
   */
  addState(t, e = et, n = void 0, s = void 0, c = void 0, o = void 0, f = void 0, m = void 0) {
    const u = t == null ? void 0 : t.trim();
    if (!this.currentDocument.states.has(u))
      T.info("Adding state ", u, s), this.currentDocument.states.set(u, {
        stmt: Z,
        id: u,
        descriptions: [],
        type: e,
        doc: n,
        note: c,
        classes: [],
        styles: [],
        textStyles: []
      });
    else {
      const S = this.currentDocument.states.get(u);
      if (!S)
        throw new Error(`State not found: ${u}`);
      S.doc || (S.doc = n), S.type || (S.type = e);
    }
    if (s && (T.info("Setting state description", u, s), (Array.isArray(s) ? s : [s]).forEach((S) => this.addDescription(u, S.trim()))), c) {
      const S = this.currentDocument.states.get(u);
      if (!S)
        throw new Error(`State not found: ${u}`);
      S.note = c, S.note.text = K.sanitizeText(S.note.text, P());
    }
    o && (T.info("Setting state classes", u, o), (Array.isArray(o) ? o : [o]).forEach((S) => this.setCssClass(u, S.trim()))), f && (T.info("Setting state styles", u, f), (Array.isArray(f) ? f : [f]).forEach((S) => this.setStyle(u, S.trim()))), m && (T.info("Setting state styles", u, f), (Array.isArray(m) ? m : [m]).forEach((S) => this.setTextStyle(u, S.trim())));
  }
  clear(t) {
    this.nodes = [], this.edges = [], this.documents = { root: Bt() }, this.currentDocument = this.documents.root, this.startEndCount = 0, this.classes = wt(), t || (this.links = /* @__PURE__ */ new Map(), he());
  }
  getState(t) {
    return this.currentDocument.states.get(t);
  }
  getStates() {
    return this.currentDocument.states;
  }
  logDocuments() {
    T.info("Documents = ", this.documents);
  }
  getRelations() {
    return this.currentDocument.relations;
  }
  /**
   * Adds a clickable link to a state.
   */
  addLink(t, e, n) {
    this.links.set(t, { url: e, tooltip: n }), T.warn("Adding link", t, e, n);
  }
  /**
   * Get all registered links.
   */
  getLinks() {
    return this.links;
  }
  /**
   * If the id is a start node ( [*] ), then return a new id constructed from
   * the start node name and the current start node count.
   * else return the given id
   */
  startIdIfNeeded(t = "") {
    return t === k.START_NODE ? (this.startEndCount++, `${k.START_TYPE}${this.startEndCount}`) : t;
  }
  /**
   * If the id is a start node ( [*] ), then return the start type ('start')
   * else return the given type
   */
  startTypeIfNeeded(t = "", e = et) {
    return t === k.START_NODE ? k.START_TYPE : e;
  }
  /**
   * If the id is an end node ( [*] ), then return a new id constructed from
   * the end node name and the current start_end node count.
   * else return the given id
   */
  endIdIfNeeded(t = "") {
    return t === k.END_NODE ? (this.startEndCount++, `${k.END_TYPE}${this.startEndCount}`) : t;
  }
  /**
   * If the id is an end node ( [*] ), then return the end type
   * else return the given type
   *
   */
  endTypeIfNeeded(t = "", e = et) {
    return t === k.END_NODE ? k.END_TYPE : e;
  }
  addRelationObjs(t, e, n = "") {
    const s = this.startIdIfNeeded(t.id.trim()), c = this.startTypeIfNeeded(t.id.trim(), t.type), o = this.startIdIfNeeded(e.id.trim()), f = this.startTypeIfNeeded(e.id.trim(), e.type);
    this.addState(
      s,
      c,
      t.doc,
      t.description,
      t.note,
      t.classes,
      t.styles,
      t.textStyles
    ), this.addState(
      o,
      f,
      e.doc,
      e.description,
      e.note,
      e.classes,
      e.styles,
      e.textStyles
    ), this.currentDocument.relations.push({
      id1: s,
      id2: o,
      relationTitle: K.sanitizeText(n, P())
    });
  }
  /**
   * Add a relation between two items.  The items may be full objects or just the string id of a state.
   */
  addRelation(t, e, n) {
    if (typeof t == "object" && typeof e == "object")
      this.addRelationObjs(t, e, n);
    else if (typeof t == "string" && typeof e == "string") {
      const s = this.startIdIfNeeded(t.trim()), c = this.startTypeIfNeeded(t), o = this.endIdIfNeeded(e.trim()), f = this.endTypeIfNeeded(e);
      this.addState(s, c), this.addState(o, f), this.currentDocument.relations.push({
        id1: s,
        id2: o,
        relationTitle: n ? K.sanitizeText(n, P()) : void 0
      });
    }
  }
  addDescription(t, e) {
    var n;
    const s = this.currentDocument.states.get(t), c = e.startsWith(":") ? e.replace(":", "").trim() : e;
    (n = s == null ? void 0 : s.descriptions) == null || n.push(K.sanitizeText(c, P()));
  }
  cleanupLabel(t) {
    return t.startsWith(":") ? t.slice(2).trim() : t.trim();
  }
  getDividerId() {
    return this.dividerCnt++, `divider-id-${this.dividerCnt}`;
  }
  /**
   * Called when the parser comes across a (style) class definition
   * @example classDef my-style fill:#f96;
   *
   * @param id - the id of this (style) class
   * @param styleAttributes - the string with 1 or more style attributes (each separated by a comma)
   */
  addStyleClass(t, e = "") {
    this.classes.has(t) || this.classes.set(t, { id: t, styles: [], textStyles: [] });
    const n = this.classes.get(t);
    e && n && e.split(k.STYLECLASS_SEP).forEach((s) => {
      const c = s.replace(/([^;]*);/, "$1").trim();
      if (RegExp(k.COLOR_KEYWORD).exec(s)) {
        const o = c.replace(k.FILL_KEYWORD, k.BG_FILL).replace(k.COLOR_KEYWORD, k.FILL_KEYWORD);
        n.textStyles.push(o);
      }
      n.styles.push(c);
    });
  }
  getClasses() {
    return this.classes;
  }
  /**
   * Add a (style) class or css class to a state with the given id.
   * If the state isn't already in the list of known states, add it.
   * Might be called by parser when a style class or CSS class should be applied to a state
   *
   * @param itemIds - The id or a list of ids of the item(s) to apply the css class to
   * @param cssClassName - CSS class name
   */
  setCssClass(t, e) {
    t.split(",").forEach((n) => {
      var s;
      let c = this.getState(n);
      if (!c) {
        const o = n.trim();
        this.addState(o), c = this.getState(o);
      }
      (s = c == null ? void 0 : c.classes) == null || s.push(e);
    });
  }
  /**
   * Add a style to a state with the given id.
   * @example style stateId fill:#f9f,stroke:#333,stroke-width:4px
   *   where 'style' is the keyword
   *   stateId is the id of a state
   *   the rest of the string is the styleText (all of the attributes to be applied to the state)
   *
   * @param itemId - The id of item to apply the style to
   * @param styleText - the text of the attributes for the style
   */
  setStyle(t, e) {
    var n, s;
    (s = (n = this.getState(t)) == null ? void 0 : n.styles) == null || s.push(e);
  }
  /**
   * Add a text style to a state with the given id
   *
   * @param itemId - The id of item to apply the css class to
   * @param cssClassName - CSS class name
   */
  setTextStyle(t, e) {
    var n, s;
    (s = (n = this.getState(t)) == null ? void 0 : n.textStyles) == null || s.push(e);
  }
  /**
   * Finds the direction statement in the root document.
   * @returns the direction statement if present
   */
  getDirectionStatement() {
    return this.rootDoc.find((t) => t.stmt === Lt);
  }
  getDirection() {
    var t;
    return ((t = this.getDirectionStatement()) == null ? void 0 : t.value) ?? de;
  }
  setDirection(t) {
    const e = this.getDirectionStatement();
    e ? e.value = t : this.rootDoc.unshift({ stmt: Lt, value: t });
  }
  trimColon(t) {
    return t.startsWith(":") ? t.slice(1).trim() : t.trim();
  }
  getData() {
    const t = P();
    return {
      nodes: this.nodes,
      edges: this.edges,
      other: {},
      config: t,
      direction: Vt(this.getRootDocV2())
    };
  }
  getConfig() {
    return P().state;
  }
}, d(pt, "StateDB"), pt.relationType = {
  AGGREGATION: 0,
  EXTENSION: 1,
  COMPOSITION: 2,
  DEPENDENCY: 3
}, pt), we = /* @__PURE__ */ d((t) => `
defs #statediagram-barbEnd {
    fill: ${t.transitionColor};
    stroke: ${t.transitionColor};
  }
g.stateGroup text {
  fill: ${t.nodeBorder};
  stroke: none;
  font-size: 10px;
}
g.stateGroup text {
  fill: ${t.textColor};
  stroke: none;
  font-size: 10px;

}
g.stateGroup .state-title {
  font-weight: bolder;
  fill: ${t.stateLabelColor};
}

g.stateGroup rect {
  fill: ${t.mainBkg};
  stroke: ${t.nodeBorder};
}

g.stateGroup line {
  stroke: ${t.lineColor};
  stroke-width: 1;
}

.transition {
  stroke: ${t.transitionColor};
  stroke-width: 1;
  fill: none;
}

.stateGroup .composit {
  fill: ${t.background};
  border-bottom: 1px
}

.stateGroup .alt-composit {
  fill: #e0e0e0;
  border-bottom: 1px
}

.state-note {
  stroke: ${t.noteBorderColor};
  fill: ${t.noteBkgColor};

  text {
    fill: ${t.noteTextColor};
    stroke: none;
    font-size: 10px;
  }
}

.stateLabel .box {
  stroke: none;
  stroke-width: 0;
  fill: ${t.mainBkg};
  opacity: 0.5;
}

.edgeLabel .label rect {
  fill: ${t.labelBackgroundColor};
  opacity: 0.5;
}
.edgeLabel {
  background-color: ${t.edgeLabelBackground};
  p {
    background-color: ${t.edgeLabelBackground};
  }
  rect {
    opacity: 0.5;
    background-color: ${t.edgeLabelBackground};
    fill: ${t.edgeLabelBackground};
  }
  text-align: center;
}
.edgeLabel .label text {
  fill: ${t.transitionLabelColor || t.tertiaryTextColor};
}
.label div .edgeLabel {
  color: ${t.transitionLabelColor || t.tertiaryTextColor};
}

.stateLabel text {
  fill: ${t.stateLabelColor};
  font-size: 10px;
  font-weight: bold;
}

.node circle.state-start {
  fill: ${t.specialStateColor};
  stroke: ${t.specialStateColor};
}

.node .fork-join {
  fill: ${t.specialStateColor};
  stroke: ${t.specialStateColor};
}

.node circle.state-end {
  fill: ${t.innerEndBackground};
  stroke: ${t.background};
  stroke-width: 1.5
}
.end-state-inner {
  fill: ${t.compositeBackground || t.background};
  // stroke: ${t.background};
  stroke-width: 1.5
}

.node rect {
  fill: ${t.stateBkg || t.mainBkg};
  stroke: ${t.stateBorder || t.nodeBorder};
  stroke-width: 1px;
}
.node polygon {
  fill: ${t.mainBkg};
  stroke: ${t.stateBorder || t.nodeBorder};;
  stroke-width: 1px;
}
#statediagram-barbEnd {
  fill: ${t.lineColor};
}

.statediagram-cluster rect {
  fill: ${t.compositeTitleBackground};
  stroke: ${t.stateBorder || t.nodeBorder};
  stroke-width: 1px;
}

.cluster-label, .nodeLabel {
  color: ${t.stateLabelColor};
  // line-height: 1;
}

.statediagram-cluster rect.outer {
  rx: 5px;
  ry: 5px;
}
.statediagram-state .divider {
  stroke: ${t.stateBorder || t.nodeBorder};
}

.statediagram-state .title-state {
  rx: 5px;
  ry: 5px;
}
.statediagram-cluster.statediagram-cluster .inner {
  fill: ${t.compositeBackground || t.background};
}
.statediagram-cluster.statediagram-cluster-alt .inner {
  fill: ${t.altBackground ? t.altBackground : "#efefef"};
}

.statediagram-cluster .inner {
  rx:0;
  ry:0;
}

.statediagram-state rect.basic {
  rx: 5px;
  ry: 5px;
}
.statediagram-state rect.divider {
  stroke-dasharray: 10,10;
  fill: ${t.altBackground ? t.altBackground : "#efefef"};
}

.note-edge {
  stroke-dasharray: 5;
}

.statediagram-note rect {
  fill: ${t.noteBkgColor};
  stroke: ${t.noteBorderColor};
  stroke-width: 1px;
  rx: 0;
  ry: 0;
}
.statediagram-note rect {
  fill: ${t.noteBkgColor};
  stroke: ${t.noteBorderColor};
  stroke-width: 1px;
  rx: 0;
  ry: 0;
}

.statediagram-note text {
  fill: ${t.noteTextColor};
}

.statediagram-note .nodeLabel {
  color: ${t.noteTextColor};
}
.statediagram .edgeLabel {
  color: red; // ${t.noteTextColor};
}

#dependencyStart, #dependencyEnd {
  fill: ${t.lineColor};
  stroke: ${t.lineColor};
  stroke-width: 1;
}

.statediagramTitleText {
  text-anchor: middle;
  font-size: 18px;
  fill: ${t.textColor};
}
`, "getStyles"), Me = we;
export {
  Ye as B,
  je as M,
  Me as U,
  Ge as V
};
