import { p as d, g as b, Z as w, e as te, N as ee, W as se, U as ie, K as re, G as ae, f as oe, i as ne, aq as le, a as K, H as ce } from "./index-CNUFa5l3.js";
import { n as he } from "./chunk-55IACEB6-DZn1aNO0-DML95e49.js";
import { r as de } from "./chunk-2J33WTMH-CBbjVzWb-D_ldye6t.js";
var Dt = function() {
  var t = /* @__PURE__ */ d(function(o, c, f, S) {
    for (f || (f = {}), S = o.length; S--; f[o[S]] = c) ;
    return f;
  }, "o"), e = [1, 2], s = [1, 3], a = [1, 4], r = [2, 4], n = [1, 9], h = [1, 11], y = [1, 16], p = [1, 17], _ = [1, 18], g = [1, 19], D = [1, 33], L = [1, 20], $ = [1, 21], R = [1, 22], C = [1, 23], O = [1, 24], u = [1, 26], E = [1, 27], I = [1, 28], G = [1, 29], W = [1, 30], Y = [1, 31], F = [1, 32], it = [1, 35], rt = [1, 36], at = [1, 37], ot = [1, 38], X = [1, 34], m = [
    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
  ], nt = [
    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
  ], Ct = [
    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
  ], mt = {
    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(o, c, f, S, k, i, j) {
      var l = i.length - 1;
      switch (k) {
        case 3:
          return S.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:
          let ht = i[l - 1];
          ht.description = S.trimColon(i[l]), this.$ = ht;
          break;
        case 14:
          this.$ = {
            stmt: "relation",
            state1: i[l - 2],
            state2: i[l]
          };
          break;
        case 15:
          let dt = S.trimColon(i[l]);
          this.$ = {
            stmt: "relation",
            state1: i[l - 3],
            state2: i[l - 1],
            description: dt
          };
          break;
        case 19:
          this.$ = {
            stmt: "state",
            id: i[l - 3],
            type: "default",
            description: "",
            doc: i[l - 1]
          };
          break;
        case 20:
          var z = i[l], J = i[l - 2].trim();
          if (i[l].match(":")) {
            var ct = i[l].split(":");
            z = ct[0], J = [J, ct[1]];
          }
          this.$ = {
            stmt: "state",
            id: z,
            type: "default",
            description: J
          };
          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: S.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(), S.setAccTitle(this.$);
          break;
        case 30:
        case 31:
          this.$ = i[l].trim(), S.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:
          S.setDirection("TB"), this.$ = {
            stmt: "dir",
            value: "TB"
          };
          break;
        case 39:
          S.setDirection("BT"), this.$ = {
            stmt: "dir",
            value: "BT"
          };
          break;
        case 40:
          S.setDirection("RL"), this.$ = {
            stmt: "dir",
            value: "RL"
          };
          break;
        case 41:
          S.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: s,
        6: a
      },
      { 1: [3] },
      {
        3: 5,
        4: e,
        5: s,
        6: a
      },
      {
        3: 6,
        4: e,
        5: s,
        6: a
      },
      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
      ], r, { 7: 7 }),
      { 1: [2, 1] },
      { 1: [2, 2] },
      {
        1: [2, 3],
        4: n,
        5: h,
        8: 8,
        9: 10,
        10: 12,
        11: 13,
        12: 14,
        13: 15,
        16: y,
        17: p,
        19: _,
        22: g,
        24: D,
        25: L,
        26: $,
        27: R,
        28: C,
        29: O,
        32: 25,
        33: u,
        35: E,
        37: I,
        38: G,
        41: W,
        45: Y,
        48: F,
        51: it,
        52: rt,
        53: at,
        54: ot,
        57: X
      },
      t(m, [2, 5]),
      {
        9: 39,
        10: 12,
        11: 13,
        12: 14,
        13: 15,
        16: y,
        17: p,
        19: _,
        22: g,
        24: D,
        25: L,
        26: $,
        27: R,
        28: C,
        29: O,
        32: 25,
        33: u,
        35: E,
        37: I,
        38: G,
        41: W,
        45: Y,
        48: F,
        51: it,
        52: rt,
        53: at,
        54: ot,
        57: X
      },
      t(m, [2, 7]),
      t(m, [2, 8]),
      t(m, [2, 9]),
      t(m, [2, 10]),
      t(m, [2, 11]),
      t(m, [2, 12], {
        14: [1, 40],
        15: [1, 41]
      }),
      t(m, [2, 16]),
      { 18: [1, 42] },
      t(m, [2, 18], { 20: [1, 43] }),
      { 23: [1, 44] },
      t(m, [2, 22]),
      t(m, [2, 23]),
      t(m, [2, 24]),
      t(m, [2, 25]),
      {
        30: 45,
        31: [1, 46],
        59: [1, 47],
        60: [1, 48]
      },
      t(m, [2, 28]),
      { 34: [1, 49] },
      { 36: [1, 50] },
      t(m, [2, 31]),
      {
        13: 51,
        24: D,
        57: X
      },
      {
        42: [1, 52],
        44: [1, 53]
      },
      { 46: [1, 54] },
      { 49: [1, 55] },
      t(nt, [2, 44], { 58: [1, 56] }),
      t(nt, [2, 45], { 58: [1, 57] }),
      t(m, [2, 38]),
      t(m, [2, 39]),
      t(m, [2, 40]),
      t(m, [2, 41]),
      t(m, [2, 6]),
      t(m, [2, 13]),
      {
        13: 58,
        24: D,
        57: X
      },
      t(m, [2, 17]),
      t(Ct, r, { 7: 59 }),
      { 24: [1, 60] },
      { 24: [1, 61] },
      { 23: [1, 62] },
      { 24: [2, 48] },
      { 24: [2, 49] },
      t(m, [2, 29]),
      t(m, [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(m, [2, 14], { 14: [1, 71] }),
      {
        4: n,
        5: h,
        8: 8,
        9: 10,
        10: 12,
        11: 13,
        12: 14,
        13: 15,
        16: y,
        17: p,
        19: _,
        21: [1, 72],
        22: g,
        24: D,
        25: L,
        26: $,
        27: R,
        28: C,
        29: O,
        32: 25,
        33: u,
        35: E,
        37: I,
        38: G,
        41: W,
        45: Y,
        48: F,
        51: it,
        52: rt,
        53: at,
        54: ot,
        57: X
      },
      t(m, [2, 20], { 20: [1, 73] }),
      { 31: [1, 74] },
      { 24: [1, 75] },
      { 39: [1, 76] },
      { 39: [1, 77] },
      t(m, [2, 34]),
      t(m, [2, 35]),
      t(m, [2, 36]),
      t(m, [2, 37]),
      t(nt, [2, 46]),
      t(nt, [2, 47]),
      t(m, [2, 15]),
      t(m, [2, 19]),
      t(Ct, r, { 7: 78 }),
      t(m, [2, 26]),
      t(m, [2, 27]),
      { 5: [1, 79] },
      { 5: [1, 80] },
      {
        4: n,
        5: h,
        8: 8,
        9: 10,
        10: 12,
        11: 13,
        12: 14,
        13: 15,
        16: y,
        17: p,
        19: _,
        21: [1, 81],
        22: g,
        24: D,
        25: L,
        26: $,
        27: R,
        28: C,
        29: O,
        32: 25,
        33: u,
        35: E,
        37: I,
        38: G,
        41: W,
        45: Y,
        48: F,
        51: it,
        52: rt,
        53: at,
        54: ot,
        57: X
      },
      t(m, [2, 32]),
      t(m, [2, 33]),
      t(m, [2, 21])
    ],
    defaultActions: {
      5: [2, 1],
      6: [2, 2],
      47: [2, 48],
      48: [2, 49]
    },
    parseError: /* @__PURE__ */ d(function(o, c) {
      if (c.recoverable) this.trace(o);
      else {
        var f = Error(o);
        throw f.hash = c, f;
      }
    }, "parseError"),
    parse: /* @__PURE__ */ d(function(o) {
      var c = this, f = [0], S = [], k = [null], i = [], j = this.table, l = "", z = 0, J = 0, ct = 0, ht = 2, dt = 1, qt = i.slice.call(arguments, 1), T = Object.create(this.lexer), U = { yy: {} };
      for (var St in this.yy) Object.prototype.hasOwnProperty.call(this.yy, St) && (U.yy[St] = this.yy[St]);
      T.setInput(o, U.yy), U.yy.lexer = T, U.yy.parser = this, T.yylloc === void 0 && (T.yylloc = {});
      var _t = T.yylloc;
      i.push(_t);
      var Zt = T.options && T.options.ranges;
      typeof U.yy.parseError == "function" ? this.parseError = U.yy.parseError : this.parseError = Object.getPrototypeOf(this).parseError;
      function Qt(N) {
        f.length -= 2 * N, k.length -= N, i.length -= N;
      }
      d(Qt, "popStack");
      function vt() {
        var N = S.pop() || T.lex() || dt;
        return typeof N != "number" && (N instanceof Array && (S = N, N = S.pop()), N = c.symbols_[N] || N), N;
      }
      d(vt, "lex");
      for (var v, kt, M, A, bt, V = {}, ut, B, Lt, pt; ; ) {
        if (M = f[f.length - 1], this.defaultActions[M] ? A = this.defaultActions[M] : (v ?? (v = vt()), A = j[M] && j[M][v]), A === void 0 || !A.length || !A[0]) {
          var It = "";
          for (ut in pt = [], j[M]) this.terminals_[ut] && ut > ht && pt.push("'" + this.terminals_[ut] + "'");
          It = T.showPosition ? "Parse error on line " + (z + 1) + `:
` + T.showPosition() + `
Expecting ` + pt.join(", ") + ", got '" + (this.terminals_[v] || v) + "'" : "Parse error on line " + (z + 1) + ": Unexpected " + (v == dt ? "end of input" : "'" + (this.terminals_[v] || v) + "'"), this.parseError(It, {
            text: T.match,
            token: this.terminals_[v] || v,
            line: T.yylineno,
            loc: _t,
            expected: pt
          });
        }
        if (A[0] instanceof Array && A.length > 1) throw Error("Parse Error: multiple actions possible at state: " + M + ", token: " + v);
        switch (A[0]) {
          case 1:
            f.push(v), k.push(T.yytext), i.push(T.yylloc), f.push(A[1]), v = null, kt ? (v = kt, kt = null) : (J = T.yyleng, l = T.yytext, z = T.yylineno, _t = T.yylloc, ct > 0);
            break;
          case 2:
            if (B = this.productions_[A[1]][1], V.$ = k[k.length - B], V._$ = {
              first_line: i[i.length - (B || 1)].first_line,
              last_line: i[i.length - 1].last_line,
              first_column: i[i.length - (B || 1)].first_column,
              last_column: i[i.length - 1].last_column
            }, Zt && (V._$.range = [i[i.length - (B || 1)].range[0], i[i.length - 1].range[1]]), bt = this.performAction.apply(V, [
              l,
              J,
              z,
              U.yy,
              A[1],
              k,
              i
            ].concat(qt)), bt !== void 0) return bt;
            B && (f = f.slice(0, -1 * B * 2), k = k.slice(0, -1 * B), i = i.slice(0, -1 * B)), f.push(this.productions_[A[1]][0]), k.push(V.$), i.push(V._$), Lt = j[f[f.length - 2]][f[f.length - 1]], f.push(Lt);
            break;
          case 3:
            return !0;
        }
      }
      return !0;
    }, "parse")
  };
  mt.lexer = /* @__PURE__ */ function() {
    return {
      EOF: 1,
      parseError: /* @__PURE__ */ d(function(o, c) {
        if (this.yy.parser) this.yy.parser.parseError(o, c);
        else throw Error(o);
      }, "parseError"),
      setInput: /* @__PURE__ */ d(function(o, c) {
        return this.yy = c || this.yy || {}, this._input = o, this._more = this._backtrack = this.done = !1, this.yylineno = this.yyleng = 0, this.yytext = this.matched = this.match = "", this.conditionStack = ["INITIAL"], this.yylloc = {
          first_line: 1,
          first_column: 0,
          last_line: 1,
          last_column: 0
        }, this.options.ranges && (this.yylloc.range = [0, 0]), this.offset = 0, this;
      }, "setInput"),
      input: /* @__PURE__ */ d(function() {
        var o = this._input[0];
        return this.yytext += o, this.yyleng++, this.offset++, this.match += o, this.matched += o, o.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), o;
      }, "input"),
      unput: /* @__PURE__ */ d(function(o) {
        var c = o.length, f = o.split(/(?:\r\n?|\n)/g);
        this._input = o + this._input, this.yytext = this.yytext.substr(0, this.yytext.length - c), this.offset -= c;
        var S = 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), f.length - 1 && (this.yylineno -= f.length - 1);
        var k = 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: f ? (f.length === S.length ? this.yylloc.first_column : 0) + S[S.length - f.length].length - f[0].length : this.yylloc.first_column - c
        }, this.options.ranges && (this.yylloc.range = [k[0], k[0] + this.yyleng - c]), this.yyleng = this.yytext.length, this;
      }, "unput"),
      more: /* @__PURE__ */ d(function() {
        return this._more = !0, this;
      }, "more"),
      reject: /* @__PURE__ */ d(function() {
        if (this.options.backtrack_lexer) this._backtrack = !0;
        else return this.parseError("Lexical error on line " + (this.yylineno + 1) + `. You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).
` + this.showPosition(), {
          text: "",
          token: null,
          line: this.yylineno
        });
        return this;
      }, "reject"),
      less: /* @__PURE__ */ d(function(o) {
        this.unput(this.match.slice(o));
      }, "less"),
      pastInput: /* @__PURE__ */ d(function() {
        var o = this.matched.substr(0, this.matched.length - this.match.length);
        return (o.length > 20 ? "..." : "") + o.substr(-20).replace(/\n/g, "");
      }, "pastInput"),
      upcomingInput: /* @__PURE__ */ d(function() {
        var o = this.match;
        return o.length < 20 && (o += this._input.substr(0, 20 - o.length)), (o.substr(0, 20) + (o.length > 20 ? "..." : "")).replace(/\n/g, "");
      }, "upcomingInput"),
      showPosition: /* @__PURE__ */ d(function() {
        var o = this.pastInput(), c = Array(o.length + 1).join("-");
        return o + this.upcomingInput() + `
` + c + "^";
      }, "showPosition"),
      test_match: /* @__PURE__ */ d(function(o, c) {
        var f, S, k;
        if (this.options.backtrack_lexer && (k = {
          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 && (k.yylloc.range = this.yylloc.range.slice(0))), S = o[0].match(/(?:\r\n?|\n).*/g), S && (this.yylineno += S.length), this.yylloc = {
          first_line: this.yylloc.last_line,
          last_line: this.yylineno + 1,
          first_column: this.yylloc.last_column,
          last_column: S ? S[S.length - 1].length - S[S.length - 1].match(/\r?\n?/)[0].length : this.yylloc.last_column + o[0].length
        }, this.yytext += o[0], this.match += o[0], this.matches = o, 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(o[0].length), this.matched += o[0], f = this.performAction.call(this, this.yy, this, c, this.conditionStack[this.conditionStack.length - 1]), this.done && this._input && (this.done = !1), f) return f;
        if (this._backtrack) {
          for (var i in k) this[i] = k[i];
          return !1;
        }
        return !1;
      }, "test_match"),
      next: /* @__PURE__ */ d(function() {
        if (this.done) return this.EOF;
        this._input || (this.done = !0);
        var o, c, f, S;
        this._more || (this.yytext = "", this.match = "");
        for (var k = this._currentRules(), i = 0; i < k.length; i++) if (f = this._input.match(this.rules[k[i]]), f && (!c || f[0].length > c[0].length)) {
          if (c = f, S = i, this.options.backtrack_lexer) {
            if (o = this.test_match(f, k[i]), o !== !1) return o;
            if (this._backtrack) {
              c = !1;
              continue;
            } else return !1;
          } else if (!this.options.flex) break;
        }
        return c ? (o = this.test_match(c, k[S]), o === !1 ? !1 : o) : this._input === "" ? this.EOF : this.parseError("Lexical error on line " + (this.yylineno + 1) + `. Unrecognized text.
` + this.showPosition(), {
          text: "",
          token: null,
          line: this.yylineno
        });
      }, "next"),
      lex: /* @__PURE__ */ d(function() {
        return this.next() || this.lex();
      }, "lex"),
      begin: /* @__PURE__ */ d(function(o) {
        this.conditionStack.push(o);
      }, "begin"),
      popState: /* @__PURE__ */ d(function() {
        return this.conditionStack.length - 1 > 0 ? this.conditionStack.pop() : this.conditionStack[0];
      }, "popState"),
      _currentRules: /* @__PURE__ */ d(function() {
        return this.conditionStack.length && this.conditionStack[this.conditionStack.length - 1] ? this.conditions[this.conditionStack[this.conditionStack.length - 1]].rules : this.conditions.INITIAL.rules;
      }, "_currentRules"),
      topState: /* @__PURE__ */ d(function(o) {
        return o = this.conditionStack.length - 1 - Math.abs(o || 0), o >= 0 ? this.conditionStack[o] : "INITIAL";
      }, "topState"),
      pushState: /* @__PURE__ */ d(function(o) {
        this.begin(o);
      }, "pushState"),
      stateStackSize: /* @__PURE__ */ d(function() {
        return this.conditionStack.length;
      }, "stateStackSize"),
      options: { "case-insensitive": !0 },
      performAction: /* @__PURE__ */ d(function(o, c, f, S) {
        function k() {
          let i = c.yytext.indexOf("%%");
          if (i === 0) return !1;
          if (i > 0) {
            let j = c.yytext.slice(0, i), l = c.yytext.slice(i);
            l && o.lexer.unput(l), c.yytext = j;
          }
          return !0;
        }
        switch (d(k, "processId"), f) {
          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:
            return 5;
          case 9:
            break;
          case 10:
            break;
          case 11:
            break;
          case 12:
            break;
          case 13:
            return this.pushState("SCALE"), 17;
          case 14:
            return 18;
          case 15:
            this.popState();
            break;
          case 16:
            return this.begin("acc_title"), 33;
          case 17:
            return this.popState(), "acc_title_value";
          case 18:
            return this.begin("acc_descr"), 35;
          case 19:
            return this.popState(), "acc_descr_value";
          case 20:
            this.begin("acc_descr_multiline");
            break;
          case 21:
            this.popState();
            break;
          case 22:
            return "acc_descr_multiline_value";
          case 23:
            return this.pushState("CLASSDEF"), 41;
          case 24:
            return this.popState(), this.pushState("CLASSDEFID"), "DEFAULT_CLASSDEF_ID";
          case 25:
            return this.popState(), this.pushState("CLASSDEFID"), 42;
          case 26:
            return this.popState(), 43;
          case 27:
            return this.pushState("CLASS"), 48;
          case 28:
            return this.popState(), this.pushState("CLASS_STYLE"), 49;
          case 29:
            return this.popState(), 50;
          case 30:
            return this.pushState("STYLE"), 45;
          case 31:
            return this.popState(), this.pushState("STYLEDEF_STYLES"), 46;
          case 32:
            return this.popState(), 47;
          case 33:
            return this.pushState("SCALE"), 17;
          case 34:
            return 18;
          case 35:
            this.popState();
            break;
          case 36:
            this.pushState("STATE");
            break;
          case 37:
            return this.popState(), c.yytext = c.yytext.slice(0, -8).trim(), 25;
          case 38:
            return this.popState(), c.yytext = c.yytext.slice(0, -8).trim(), 26;
          case 39:
            return this.popState(), c.yytext = c.yytext.slice(0, -10).trim(), 27;
          case 40:
            return this.popState(), c.yytext = c.yytext.slice(0, -8).trim(), 25;
          case 41:
            return this.popState(), c.yytext = c.yytext.slice(0, -8).trim(), 26;
          case 42:
            return this.popState(), c.yytext = c.yytext.slice(0, -10).trim(), 27;
          case 43:
            return 51;
          case 44:
            return 52;
          case 45:
            return 53;
          case 46:
            return 54;
          case 47:
            this.pushState("STATE_STRING");
            break;
          case 48:
            return this.pushState("STATE_ID"), "AS";
          case 49:
            return k() ? (this.popState(), "ID") : void 0;
          case 50:
            this.popState();
            break;
          case 51:
            return "STATE_DESCR";
          case 52:
            return 19;
          case 53:
            this.popState();
            break;
          case 54:
            return this.popState(), this.pushState("struct"), 20;
          case 55:
            return this.popState(), 21;
          case 56:
            break;
          case 57:
            return this.begin("NOTE"), 29;
          case 58:
            return this.popState(), this.pushState("NOTE_ID"), 59;
          case 59:
            return this.popState(), this.pushState("NOTE_ID"), 60;
          case 60:
            this.popState(), this.pushState("FLOATING_NOTE");
            break;
          case 61:
            return this.popState(), this.pushState("FLOATING_NOTE_ID"), "AS";
          case 62:
            break;
          case 63:
            return "NOTE_TEXT";
          case 64:
            return k() ? (this.popState(), "ID") : void 0;
          case 65:
            return k() ? (this.popState(), this.pushState("NOTE_TEXT"), 24) : void 0;
          case 66:
            return this.popState(), c.yytext = c.yytext.substr(2).trim(), 31;
          case 67:
            return this.popState(), c.yytext = c.yytext.slice(0, -8).trim(), 31;
          case 68:
            return 6;
          case 69:
            return 6;
          case 70:
            return 16;
          case 71:
            return 57;
          case 72:
            return k() ? 24 : void 0;
          case 73:
            return c.yytext = c.yytext.trim(), 14;
          case 74:
            return 15;
          case 75:
            return 28;
          case 76:
            return 58;
          case 77:
            return 5;
          case 78:
            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,
        /^(?:[\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,
        /^(?:\})/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]*?\n\s*end note\b)/i,
        /^(?:stateDiagram\s+)/i,
        /^(?:stateDiagram-v2\s+)/i,
        /^(?:hide empty description\b)/i,
        /^(?:\[\*\])/i,
        /^(?:[^:\n\s\-\{]+)/i,
        /^(?:\s*:(?:[^:\n;]|:[^:\n;])+)/i,
        /^(?:-->)/i,
        /^(?:--)/i,
        /^(?::::)/i,
        /^(?:$)/i,
        /^(?:.)/i
      ],
      conditions: {
        LINE: {
          rules: [
            10,
            11,
            12
          ],
          inclusive: !1
        },
        struct: {
          rules: [
            10,
            11,
            12,
            23,
            27,
            30,
            36,
            43,
            44,
            45,
            46,
            55,
            56,
            57,
            71,
            72,
            73,
            74,
            75,
            76
          ],
          inclusive: !1
        },
        FLOATING_NOTE_ID: {
          rules: [64],
          inclusive: !1
        },
        FLOATING_NOTE: {
          rules: [
            61,
            62,
            63
          ],
          inclusive: !1
        },
        NOTE_TEXT: {
          rules: [66, 67],
          inclusive: !1
        },
        NOTE_ID: {
          rules: [65],
          inclusive: !1
        },
        NOTE: {
          rules: [
            58,
            59,
            60
          ],
          inclusive: !1
        },
        STYLEDEF_STYLEOPTS: {
          rules: [],
          inclusive: !1
        },
        STYLEDEF_STYLES: {
          rules: [32],
          inclusive: !1
        },
        STYLE_IDS: {
          rules: [],
          inclusive: !1
        },
        STYLE: {
          rules: [31],
          inclusive: !1
        },
        CLASS_STYLE: {
          rules: [29],
          inclusive: !1
        },
        CLASS: {
          rules: [28],
          inclusive: !1
        },
        CLASSDEFID: {
          rules: [26],
          inclusive: !1
        },
        CLASSDEF: {
          rules: [24, 25],
          inclusive: !1
        },
        acc_descr_multiline: {
          rules: [21, 22],
          inclusive: !1
        },
        acc_descr: {
          rules: [19],
          inclusive: !1
        },
        acc_title: {
          rules: [17],
          inclusive: !1
        },
        SCALE: {
          rules: [
            14,
            15,
            34,
            35
          ],
          inclusive: !1
        },
        ALIAS: {
          rules: [],
          inclusive: !1
        },
        STATE_ID: {
          rules: [49],
          inclusive: !1
        },
        STATE_STRING: {
          rules: [50, 51],
          inclusive: !1
        },
        FORK_STATE: {
          rules: [],
          inclusive: !1
        },
        STATE: {
          rules: [
            10,
            11,
            12,
            37,
            38,
            39,
            40,
            41,
            42,
            47,
            48,
            52,
            53,
            54
          ],
          inclusive: !1
        },
        ID: {
          rules: [
            10,
            11,
            12
          ],
          inclusive: !1
        },
        INITIAL: {
          rules: [
            0,
            1,
            2,
            3,
            4,
            5,
            6,
            7,
            8,
            9,
            11,
            12,
            13,
            16,
            18,
            20,
            23,
            27,
            30,
            33,
            36,
            54,
            57,
            68,
            69,
            70,
            71,
            72,
            73,
            74,
            76,
            77,
            78
          ],
          inclusive: !0
        }
      }
    };
  }();
  function lt() {
    this.yy = {};
  }
  return d(lt, "Parser"), lt.prototype = mt, mt.Parser = lt, new lt();
}();
Dt.parser = Dt;
var Oe = Dt, ue = "TB", Ft = "TB", At = "dir", Z = "state", q = "root", xt = "relation", pe = "classDef", ye = "style", fe = "applyClass", et = "default", Pt = "divider", Gt = "fill:none", Wt = "fill: #333", jt = "c", zt = "markdown", Ut = "normal", Tt = "rect", Et = "rectWithTitle", ge = "stateStart", me = "stateEnd", Nt = "divider", Ot = "roundedWithTitle", Se = "note", _e = "noteGroup", st = "statediagram", ke = `${st}-state`, Mt = "transition", be = "note", Te = `${Mt} note-edge`, Ee = `${st}-${be}`, De = `${st}-cluster`, xe = `${st}-cluster-alt`, Kt = "parent", Ht = "note", $e = "state", $t = "----", Ce = `${$t}${Ht}`, wt = `${$t}${Kt}`, Xt = /* @__PURE__ */ d((t, e = Ft) => {
  if (!t.doc) return e;
  let s = e;
  for (let a of t.doc) a.stmt === "dir" && (s = a.value);
  return s;
}, "getDir"), we = {
  getClasses: /* @__PURE__ */ d(function(t, e) {
    return e.db.getClasses();
  }, "getClasses"),
  draw: /* @__PURE__ */ d(async function(t, e, s, a) {
    b.info("REF0:"), b.info("Drawing state diagram (v2)", e);
    let { securityLevel: r, state: n, layout: h } = w();
    a.db.extract(a.db.getRootDocV2());
    let y = a.db.getData(), p = he(e, r);
    y.type = a.type, y.layoutAlgorithm = h, y.nodeSpacing = (n == null ? void 0 : n.nodeSpacing) || 50, y.rankSpacing = (n == null ? void 0 : n.rankSpacing) || 50, w().look === "neo" ? y.markers = ["barbNeo"] : y.markers = ["barb"], y.diagramId = e, await te(y, p);
    try {
      (typeof a.db.getLinks == "function" ? a.db.getLinks() : /* @__PURE__ */ new Map()).forEach((_, g) => {
        var u;
        let D = typeof g == "string" ? g : typeof (g == null ? void 0 : g.id) == "string" ? g.id : "";
        if (!D) {
          b.warn("⚠️ Invalid or missing stateId from key:", JSON.stringify(g));
          return;
        }
        let L = (u = p.node()) == null ? void 0 : u.querySelectorAll("g"), $;
        if (L == null || L.forEach((E) => {
          var I;
          ((I = E.textContent) == null ? void 0 : I.trim()) === D && ($ = E);
        }), !$) {
          b.warn("⚠️ Could not find node matching text:", D);
          return;
        }
        let R = $.parentNode;
        if (!R) {
          b.warn("⚠️ Node has no parent, cannot wrap:", D);
          return;
        }
        let C = document.createElementNS("http://www.w3.org/2000/svg", "a"), O = _.url.replace(/^"+|"+$/g, "");
        if (C.setAttributeNS("http://www.w3.org/1999/xlink", "xlink:href", O), C.setAttribute("target", "_blank"), _.tooltip) {
          let E = _.tooltip.replace(/^"+|"+$/g, "");
          C.setAttribute("title", E);
        }
        R.replaceChild(C, $), C.appendChild($), b.info("🔗 Wrapped node in <a> tag for:", D, _.url);
      });
    } catch (_) {
      b.error("❌ Error injecting clickable links:", _);
    }
    ee.insertTitle(p, "statediagramTitleText", (n == null ? void 0 : n.titleTopMargin) ?? 25, a.db.getDiagramTitle()), de(p, 8, st, (n == null ? void 0 : n.useMaxWidth) ?? !0);
  }, "draw"),
  getDir: Xt
}, ft = /* @__PURE__ */ new Map(), P = 0;
function gt(t = "", e = 0, s = "", a = $t) {
  return `${$e}-${t}${s !== null && s.length > 0 ? `${a}${s}` : ""}-${e}`;
}
d(gt, "stateDomId");
var ve = /* @__PURE__ */ d((t, e, s, a, r, n, h, y) => {
  b.trace("items", e), e.forEach((p) => {
    switch (p.stmt) {
      case Z:
        tt(t, p, s, a, r, n, h, y);
        break;
      case et:
        tt(t, p, s, a, r, n, h, y);
        break;
      case xt:
        {
          tt(t, p.state1, s, a, r, n, h, y), tt(t, p.state2, s, a, r, n, h, y);
          let _ = h === "neo", g = {
            id: "edge" + P,
            start: p.state1.id,
            end: p.state2.id,
            arrowhead: "normal",
            arrowTypeEnd: _ ? "arrow_barb_neo" : "arrow_barb",
            style: Gt,
            labelStyle: "",
            label: K.sanitizeText(p.description ?? "", w()),
            arrowheadStyle: Wt,
            labelpos: jt,
            labelType: zt,
            thickness: Ut,
            classes: Mt,
            look: h
          };
          r.push(g), P++;
        }
        break;
    }
  });
}, "setupDoc"), Rt = /* @__PURE__ */ d((t, e = Ft) => {
  let s = e;
  if (t.doc) for (let a of t.doc) a.stmt === "dir" && (s = a.value);
  return s;
}, "getDir");
function Q(t, e, s) {
  if (!e.id || e.id === "</join></fork>" || e.id === "</choice>") return;
  e.cssClasses && (Array.isArray(e.cssCompiledStyles) || (e.cssCompiledStyles = []), e.cssClasses.split(" ").forEach((r) => {
    let n = s.get(r);
    n && (e.cssCompiledStyles = [...e.cssCompiledStyles ?? [], ...n.styles]);
  }));
  let a = t.find((r) => r.id === e.id);
  a ? Object.assign(a, e) : t.push(e);
}
d(Q, "insertOrUpdateNode");
function Jt(t) {
  var e;
  return ((e = t == null ? void 0 : t.classes) == null ? void 0 : e.join(" ")) ?? "";
}
d(Jt, "getClassesFromDbInfo");
function Vt(t) {
  return (t == null ? void 0 : t.styles) ?? [];
}
d(Vt, "getStylesFromDbInfo");
var tt = /* @__PURE__ */ d((t, e, s, a, r, n, h, y) => {
  var $, R, C;
  let p = e.id, _ = s.get(p), g = Jt(_), D = Vt(_), L = w();
  if (b.info("dataFetcher parsedItem", e, _, D), p !== "root") {
    let O = Tt;
    e.start === !0 ? O = ge : e.start === !1 && (O = me), e.type !== et && (O = e.type), ft.get(p) || ft.set(p, {
      id: p,
      shape: O,
      description: K.sanitizeText(p, L),
      cssClasses: `${g} ${ke}`,
      cssStyles: D
    });
    let u = ft.get(p);
    e.description && (Array.isArray(u.description) ? (u.shape = Et, u.description.push(e.description)) : ($ = u.description) != null && $.length && u.description.length > 0 ? (u.shape = Et, u.description === p ? u.description = [e.description] : u.description = [u.description, e.description]) : (u.shape = Tt, u.description = e.description), u.description = K.sanitizeTextOrArray(u.description, L)), ((R = u.description) == null ? void 0 : R.length) === 1 && u.shape === Et && (u.type === "group" ? u.shape = Ot : u.shape = Tt), !u.type && e.doc && (b.info("Setting cluster for XCX", p, Rt(e)), u.type = "group", u.isGroup = !0, u.dir = Rt(e), u.shape = e.type === Pt ? Nt : Ot, u.cssClasses = `${u.cssClasses} ${De} ${n ? xe : ""}`);
    let E = {
      labelStyle: "",
      shape: u.shape,
      label: u.description,
      cssClasses: u.cssClasses,
      cssCompiledStyles: [],
      cssStyles: u.cssStyles,
      id: p,
      dir: u.dir,
      domId: gt(p, P),
      type: u.type,
      isGroup: u.type === "group",
      padding: 8,
      rx: 10,
      ry: 10,
      look: h,
      labelType: "markdown"
    };
    if (E.shape === Nt && (E.label = ""), t && t.id !== "root" && (b.trace("Setting node ", p, " to be child of its parent ", t.id), E.parentId = t.id), E.centerLabel = !0, e.note) {
      let I = {
        labelStyle: "",
        shape: Se,
        label: e.note.text,
        labelType: "markdown",
        cssClasses: Ee,
        cssStyles: [],
        cssCompiledStyles: [],
        id: p + Ce + "-" + P,
        domId: gt(p, P, Ht),
        type: u.type,
        isGroup: u.type === "group",
        padding: (C = L.flowchart) == null ? void 0 : C.padding,
        look: h,
        position: e.note.position
      }, G = p + wt, W = {
        labelStyle: "",
        shape: _e,
        label: e.note.text,
        cssClasses: u.cssClasses,
        cssStyles: [],
        id: p + wt,
        domId: gt(p, P, Kt),
        type: "group",
        isGroup: !0,
        padding: 16,
        look: h,
        position: e.note.position
      };
      P++, W.id = G, I.parentId = G, Q(a, W, y), Q(a, I, y), Q(a, E, y);
      let Y = p, F = I.id;
      e.note.position === "left of" && (Y = I.id, F = p), r.push({
        id: Y + "-" + F,
        start: Y,
        end: F,
        arrowhead: "none",
        arrowTypeEnd: "",
        style: Gt,
        labelStyle: "",
        classes: Te,
        arrowheadStyle: Wt,
        labelpos: jt,
        labelType: zt,
        thickness: Ut,
        look: h
      });
    } else Q(a, E, y);
  }
  e.doc && (b.trace("Adding nodes children "), ve(e, e.doc, s, a, r, !n, h, y));
}, "dataFetcher"), Le = /* @__PURE__ */ d(() => {
  ft.clear(), P = 0;
}, "reset"), x = {
  START_NODE: "[*]",
  START_TYPE: "start",
  END_NODE: "[*]",
  END_TYPE: "end",
  COLOR_KEYWORD: "color",
  FILL_KEYWORD: "fill",
  BG_FILL: "bgFill",
  STYLECLASS_SEP: ","
}, Bt = /* @__PURE__ */ d(() => /* @__PURE__ */ new Map(), "newClassesList"), Yt = /* @__PURE__ */ d(() => ({
  relations: [],
  states: /* @__PURE__ */ new Map(),
  documents: {}
}), "newDoc"), yt = /* @__PURE__ */ d((t) => JSON.parse(JSON.stringify(t)), "clone"), H, Re = (H = class {
  constructor(e) {
    this.version = e, this.nodes = [], this.edges = [], this.rootDoc = [], this.classes = Bt(), this.documents = { root: Yt() }, this.currentDocument = this.documents.root, this.startEndCount = 0, this.dividerCnt = 0, this.links = /* @__PURE__ */ new Map(), this.getAccTitle = se, this.setAccTitle = ie, this.getAccDescription = re, this.setAccDescription = ae, this.setDiagramTitle = oe, this.getDiagramTitle = ne, 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);
  }
  extract(e) {
    this.clear(!0);
    for (let r of Array.isArray(e) ? e : e.doc) switch (r.stmt) {
      case Z:
        this.addState(r.id.trim(), r.type, r.doc, r.description, r.note);
        break;
      case xt:
        this.addRelation(r.state1, r.state2, r.description);
        break;
      case pe:
        this.addStyleClass(r.id.trim(), r.classes);
        break;
      case ye:
        this.handleStyleDef(r);
        break;
      case fe:
        this.setCssClass(r.id.trim(), r.styleClass);
        break;
      case "click":
        this.addLink(r.id, r.url, r.tooltip);
        break;
    }
    let s = this.getStates(), a = w();
    Le(), tt(void 0, this.getRootDocV2(), s, this.nodes, this.edges, !0, a.look, this.classes);
    for (let r of this.nodes) if (Array.isArray(r.label)) {
      if (r.description = r.label.slice(1), r.isGroup && r.description.length > 0) throw Error(`Group nodes can only have label. Remove the additional description for node [${r.id}]`);
      r.label = r.label[0];
    }
  }
  handleStyleDef(e) {
    let s = e.id.trim().split(","), a = e.styleClass.split(",");
    for (let r of s) {
      let n = this.getState(r);
      if (!n) {
        let h = r.trim();
        this.addState(h), n = this.getState(h);
      }
      n && (n.styles = a.map((h) => {
        var y;
        return (y = h.replace(/;/g, "")) == null ? void 0 : y.trim();
      }));
    }
  }
  setRootDoc(e) {
    b.info("Setting root doc", e), this.rootDoc = e, this.version === 1 ? this.extract(e) : this.extract(this.getRootDocV2());
  }
  docTranslator(e, s, a) {
    if (s.stmt === xt) {
      this.docTranslator(e, s.state1, !0), this.docTranslator(e, s.state2, !1);
      return;
    }
    if (s.stmt === Z && (s.id === x.START_NODE ? (s.id = e.id + (a ? "_start" : "_end"), s.start = a) : s.id = s.id.trim()), s.stmt !== q && s.stmt !== Z || !s.doc) return;
    let r = [], n = [];
    for (let h of s.doc) if (h.type === Pt) {
      let y = yt(h);
      y.doc = yt(n), r.push(y), n = [];
    } else n.push(h);
    if (r.length > 0 && n.length > 0) {
      let h = {
        stmt: Z,
        id: le(),
        type: "divider",
        doc: yt(n)
      };
      r.push(yt(h)), s.doc = r;
    }
    s.doc.forEach((h) => this.docTranslator(s, h, !0));
  }
  getRootDocV2() {
    return this.docTranslator({
      id: q,
      stmt: q
    }, {
      id: q,
      stmt: q,
      doc: this.rootDoc
    }, !0), {
      id: q,
      doc: this.rootDoc
    };
  }
  addState(e, s = et, a = void 0, r = void 0, n = void 0, h = void 0, y = void 0, p = void 0) {
    let _ = e == null ? void 0 : e.trim();
    if (!this.currentDocument.states.has(_)) b.info("Adding state ", _, r), this.currentDocument.states.set(_, {
      stmt: Z,
      id: _,
      descriptions: [],
      type: s,
      doc: a,
      note: n,
      classes: [],
      styles: [],
      textStyles: []
    });
    else {
      let g = this.currentDocument.states.get(_);
      if (!g) throw Error(`State not found: ${_}`);
      g.doc || (g.doc = a), g.type || (g.type = s);
    }
    if (r && (b.info("Setting state description", _, r), (Array.isArray(r) ? r : [r]).forEach((g) => this.addDescription(_, g.trim()))), n) {
      let g = this.currentDocument.states.get(_);
      if (!g) throw Error(`State not found: ${_}`);
      g.note = n, g.note.text = K.sanitizeText(g.note.text, w());
    }
    h && (b.info("Setting state classes", _, h), (Array.isArray(h) ? h : [h]).forEach((g) => this.setCssClass(_, g.trim()))), y && (b.info("Setting state styles", _, y), (Array.isArray(y) ? y : [y]).forEach((g) => this.setStyle(_, g.trim()))), p && (b.info("Setting state styles", _, y), (Array.isArray(p) ? p : [p]).forEach((g) => this.setTextStyle(_, g.trim())));
  }
  clear(e) {
    this.nodes = [], this.edges = [], this.documents = { root: Yt() }, this.currentDocument = this.documents.root, this.startEndCount = 0, this.classes = Bt(), e || (this.links = /* @__PURE__ */ new Map(), ce());
  }
  getState(e) {
    return this.currentDocument.states.get(e);
  }
  getStates() {
    return this.currentDocument.states;
  }
  logDocuments() {
    b.info("Documents = ", this.documents);
  }
  getRelations() {
    return this.currentDocument.relations;
  }
  addLink(e, s, a) {
    this.links.set(e, {
      url: s,
      tooltip: a
    }), b.warn("Adding link", e, s, a);
  }
  getLinks() {
    return this.links;
  }
  startIdIfNeeded(e = "") {
    return e === x.START_NODE ? (this.startEndCount++, `${x.START_TYPE}${this.startEndCount}`) : e;
  }
  startTypeIfNeeded(e = "", s = et) {
    return e === x.START_NODE ? x.START_TYPE : s;
  }
  endIdIfNeeded(e = "") {
    return e === x.END_NODE ? (this.startEndCount++, `${x.END_TYPE}${this.startEndCount}`) : e;
  }
  endTypeIfNeeded(e = "", s = et) {
    return e === x.END_NODE ? x.END_TYPE : s;
  }
  addRelationObjs(e, s, a = "") {
    let r = this.startIdIfNeeded(e.id.trim()), n = this.startTypeIfNeeded(e.id.trim(), e.type), h = this.startIdIfNeeded(s.id.trim()), y = this.startTypeIfNeeded(s.id.trim(), s.type);
    this.addState(r, n, e.doc, e.description, e.note, e.classes, e.styles, e.textStyles), this.addState(h, y, s.doc, s.description, s.note, s.classes, s.styles, s.textStyles), this.currentDocument.relations.push({
      id1: r,
      id2: h,
      relationTitle: K.sanitizeText(a, w())
    });
  }
  addRelation(e, s, a) {
    if (typeof e == "object" && typeof s == "object") this.addRelationObjs(e, s, a);
    else if (typeof e == "string" && typeof s == "string") {
      let r = this.startIdIfNeeded(e.trim()), n = this.startTypeIfNeeded(e), h = this.endIdIfNeeded(s.trim()), y = this.endTypeIfNeeded(s);
      this.addState(r, n), this.addState(h, y), this.currentDocument.relations.push({
        id1: r,
        id2: h,
        relationTitle: a ? K.sanitizeText(a, w()) : void 0
      });
    }
  }
  addDescription(e, s) {
    var n;
    let a = this.currentDocument.states.get(e), r = s.startsWith(":") ? s.replace(":", "").trim() : s;
    (n = a == null ? void 0 : a.descriptions) == null || n.push(K.sanitizeText(r, w()));
  }
  cleanupLabel(e) {
    return e.startsWith(":") ? e.slice(2).trim() : e.trim();
  }
  getDividerId() {
    return this.dividerCnt++, `divider-id-${this.dividerCnt}`;
  }
  addStyleClass(e, s = "") {
    this.classes.has(e) || this.classes.set(e, {
      id: e,
      styles: [],
      textStyles: []
    });
    let a = this.classes.get(e);
    s && a && s.split(x.STYLECLASS_SEP).forEach((r) => {
      let n = r.replace(/([^;]*);/, "$1").trim();
      if (RegExp(x.COLOR_KEYWORD).exec(r)) {
        let h = n.replace(x.FILL_KEYWORD, x.BG_FILL).replace(x.COLOR_KEYWORD, x.FILL_KEYWORD);
        a.textStyles.push(h);
      }
      a.styles.push(n);
    });
  }
  getClasses() {
    return this.classes;
  }
  setCssClass(e, s) {
    e.split(",").forEach((a) => {
      var n;
      let r = this.getState(a);
      if (!r) {
        let h = a.trim();
        this.addState(h), r = this.getState(h);
      }
      (n = r == null ? void 0 : r.classes) == null || n.push(s);
    });
  }
  setStyle(e, s) {
    var a, r;
    (r = (a = this.getState(e)) == null ? void 0 : a.styles) == null || r.push(s);
  }
  setTextStyle(e, s) {
    var a, r;
    (r = (a = this.getState(e)) == null ? void 0 : a.textStyles) == null || r.push(s);
  }
  getDirectionStatement() {
    return this.rootDoc.find((e) => e.stmt === At);
  }
  getDirection() {
    var e;
    return ((e = this.getDirectionStatement()) == null ? void 0 : e.value) ?? ue;
  }
  setDirection(e) {
    let s = this.getDirectionStatement();
    s ? s.value = e : this.rootDoc.unshift({
      stmt: At,
      value: e
    });
  }
  trimColon(e) {
    return e.startsWith(":") ? e.slice(1).trim() : e.trim();
  }
  getData() {
    let e = w();
    return {
      nodes: this.nodes,
      edges: this.edges,
      other: {},
      config: e,
      direction: Xt(this.getRootDocV2())
    };
  }
  getConfig() {
    return w().state;
  }
}, d(H, "StateDB"), H.relationType = {
  AGGREGATION: 0,
  EXTENSION: 1,
  COMPOSITION: 2,
  DEPENDENCY: 3
}, H), Be = /* @__PURE__ */ d((t) => `
defs [id$="-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: ${t.strokeWidth || 1};
}

.transition {
  stroke: ${t.transitionColor};
  stroke-width: ${t.strokeWidth || 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: ${t.strokeWidth || 1}px;
}
.node polygon {
  fill: ${t.mainBkg};
  stroke: ${t.stateBorder || t.nodeBorder};;
  stroke-width: ${t.strokeWidth || 1}px;
}
[id$="-barbEnd"] {
  fill: ${t.lineColor};
}

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

.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};
}

[id$="-dependencyStart"], [id$="-dependencyEnd"] {
  fill: ${t.lineColor};
  stroke: ${t.lineColor};
  stroke-width: ${t.strokeWidth || 1};
}

.statediagramTitleText {
  text-anchor: middle;
  font-size: 18px;
  fill: ${t.textColor};
}

[data-look="neo"].statediagram-cluster rect {
  fill: ${t.mainBkg};
  stroke: ${t.useGradient ? "url(" + t.svgId + "-gradient)" : t.stateBorder || t.nodeBorder};
  stroke-width: ${t.strokeWidth ?? 1};
}
[data-look="neo"].statediagram-cluster rect.outer {
  rx: ${t.radius}px;
  ry: ${t.radius}px;
  filter: ${t.dropShadow ? t.dropShadow.replace("url(#drop-shadow)", `url(${t.svgId}-drop-shadow)`) : "none"}
}
`, "getStyles");
export {
  Oe as _,
  we as p,
  Re as v,
  Be as y
};
