import { g as Te, C as ye, B as Ee, c as lt, s as Jt, b as be, a as me, D as we, l as K, d as Pt, j as v, e as ve, h as kt, i as _e, z as B, m as Zt, X as Qt, a3 as ke } from "./main-8k4vh9Gc.js";
import { d as Pe, a as Le, g as Lt, b as Ie, c as Ae, e as Yt } from "./svgDrawCommon-0ee1b4e9-Cr_H5frk.js";
var Ct = function() {
  var t = function(ct, w, k, L) {
    for (k = k || {}, L = ct.length; L--; k[ct[L]] = w)
      ;
    return k;
  }, e = [1, 2], o = [1, 3], s = [1, 4], r = [2, 4], a = [1, 9], l = [1, 11], h = [1, 13], p = [1, 14], i = [1, 16], g = [1, 17], E = [1, 18], u = [1, 24], x = [1, 25], m = [1, 26], P = [1, 27], A = [1, 28], D = [1, 29], S = [1, 30], W = [1, 31], M = [1, 32], tt = [1, 33], q = [1, 34], X = [1, 35], Z = [1, 36], z = [1, 37], F = [1, 38], O = [1, 39], G = [1, 41], H = [1, 42], J = [1, 43], Q = [1, 44], j = [1, 45], y = [1, 46], _ = [1, 4, 5, 13, 14, 16, 18, 21, 23, 29, 30, 31, 33, 35, 36, 37, 38, 39, 41, 43, 44, 46, 47, 48, 49, 50, 52, 53, 54, 59, 60, 61, 62, 70], I = [4, 5, 16, 50, 52, 53], ht = [4, 5, 13, 14, 16, 18, 21, 23, 29, 30, 31, 33, 35, 36, 37, 38, 39, 41, 43, 44, 46, 50, 52, 53, 54, 59, 60, 61, 62, 70], et = [4, 5, 13, 14, 16, 18, 21, 23, 29, 30, 31, 33, 35, 36, 37, 38, 39, 41, 43, 44, 46, 49, 50, 52, 53, 54, 59, 60, 61, 62, 70], N = [4, 5, 13, 14, 16, 18, 21, 23, 29, 30, 31, 33, 35, 36, 37, 38, 39, 41, 43, 44, 46, 48, 50, 52, 53, 54, 59, 60, 61, 62, 70], zt = [4, 5, 13, 14, 16, 18, 21, 23, 29, 30, 31, 33, 35, 36, 37, 38, 39, 41, 43, 44, 46, 47, 50, 52, 53, 54, 59, 60, 61, 62, 70], ot = [68, 69, 70], it = [1, 120], At = {
    trace: function() {
    },
    yy: {},
    symbols_: { error: 2, start: 3, SPACE: 4, NEWLINE: 5, SD: 6, document: 7, line: 8, statement: 9, box_section: 10, box_line: 11, participant_statement: 12, create: 13, box: 14, restOfLine: 15, end: 16, signal: 17, autonumber: 18, NUM: 19, off: 20, activate: 21, actor: 22, deactivate: 23, note_statement: 24, links_statement: 25, link_statement: 26, properties_statement: 27, details_statement: 28, title: 29, legacy_title: 30, acc_title: 31, acc_title_value: 32, acc_descr: 33, acc_descr_value: 34, acc_descr_multiline_value: 35, loop: 36, rect: 37, opt: 38, alt: 39, else_sections: 40, par: 41, par_sections: 42, par_over: 43, critical: 44, option_sections: 45, break: 46, option: 47, and: 48, else: 49, participant: 50, AS: 51, participant_actor: 52, destroy: 53, note: 54, placement: 55, text2: 56, over: 57, actor_pair: 58, links: 59, link: 60, properties: 61, details: 62, spaceList: 63, ",": 64, left_of: 65, right_of: 66, signaltype: 67, "+": 68, "-": 69, ACTOR: 70, SOLID_OPEN_ARROW: 71, DOTTED_OPEN_ARROW: 72, SOLID_ARROW: 73, DOTTED_ARROW: 74, SOLID_CROSS: 75, DOTTED_CROSS: 76, SOLID_POINT: 77, DOTTED_POINT: 78, TXT: 79, $accept: 0, $end: 1 },
    terminals_: { 2: "error", 4: "SPACE", 5: "NEWLINE", 6: "SD", 13: "create", 14: "box", 15: "restOfLine", 16: "end", 18: "autonumber", 19: "NUM", 20: "off", 21: "activate", 23: "deactivate", 29: "title", 30: "legacy_title", 31: "acc_title", 32: "acc_title_value", 33: "acc_descr", 34: "acc_descr_value", 35: "acc_descr_multiline_value", 36: "loop", 37: "rect", 38: "opt", 39: "alt", 41: "par", 43: "par_over", 44: "critical", 46: "break", 47: "option", 48: "and", 49: "else", 50: "participant", 51: "AS", 52: "participant_actor", 53: "destroy", 54: "note", 57: "over", 59: "links", 60: "link", 61: "properties", 62: "details", 64: ",", 65: "left_of", 66: "right_of", 68: "+", 69: "-", 70: "ACTOR", 71: "SOLID_OPEN_ARROW", 72: "DOTTED_OPEN_ARROW", 73: "SOLID_ARROW", 74: "DOTTED_ARROW", 75: "SOLID_CROSS", 76: "DOTTED_CROSS", 77: "SOLID_POINT", 78: "DOTTED_POINT", 79: "TXT" },
    productions_: [0, [3, 2], [3, 2], [3, 2], [7, 0], [7, 2], [8, 2], [8, 1], [8, 1], [10, 0], [10, 2], [11, 2], [11, 1], [11, 1], [9, 1], [9, 2], [9, 4], [9, 2], [9, 4], [9, 3], [9, 3], [9, 2], [9, 3], [9, 3], [9, 2], [9, 2], [9, 2], [9, 2], [9, 2], [9, 1], [9, 1], [9, 2], [9, 2], [9, 1], [9, 4], [9, 4], [9, 4], [9, 4], [9, 4], [9, 4], [9, 4], [9, 4], [45, 1], [45, 4], [42, 1], [42, 4], [40, 1], [40, 4], [12, 5], [12, 3], [12, 5], [12, 3], [12, 3], [24, 4], [24, 4], [25, 3], [26, 3], [27, 3], [28, 3], [63, 2], [63, 1], [58, 3], [58, 1], [55, 1], [55, 1], [17, 5], [17, 5], [17, 4], [22, 1], [67, 1], [67, 1], [67, 1], [67, 1], [67, 1], [67, 1], [67, 1], [67, 1], [56, 1]],
    performAction: function(w, k, L, T, R, c, Et) {
      var d = c.length - 1;
      switch (R) {
        case 3:
          return T.apply(c[d]), c[d];
        case 4:
        case 9:
          this.$ = [];
          break;
        case 5:
        case 10:
          c[d - 1].push(c[d]), this.$ = c[d - 1];
          break;
        case 6:
        case 7:
        case 11:
        case 12:
          this.$ = c[d];
          break;
        case 8:
        case 13:
          this.$ = [];
          break;
        case 15:
          c[d].type = "createParticipant", this.$ = c[d];
          break;
        case 16:
          c[d - 1].unshift({ type: "boxStart", boxData: T.parseBoxData(c[d - 2]) }), c[d - 1].push({ type: "boxEnd", boxText: c[d - 2] }), this.$ = c[d - 1];
          break;
        case 18:
          this.$ = { type: "sequenceIndex", sequenceIndex: Number(c[d - 2]), sequenceIndexStep: Number(c[d - 1]), sequenceVisible: !0, signalType: T.LINETYPE.AUTONUMBER };
          break;
        case 19:
          this.$ = { type: "sequenceIndex", sequenceIndex: Number(c[d - 1]), sequenceIndexStep: 1, sequenceVisible: !0, signalType: T.LINETYPE.AUTONUMBER };
          break;
        case 20:
          this.$ = { type: "sequenceIndex", sequenceVisible: !1, signalType: T.LINETYPE.AUTONUMBER };
          break;
        case 21:
          this.$ = { type: "sequenceIndex", sequenceVisible: !0, signalType: T.LINETYPE.AUTONUMBER };
          break;
        case 22:
          this.$ = { type: "activeStart", signalType: T.LINETYPE.ACTIVE_START, actor: c[d - 1] };
          break;
        case 23:
          this.$ = { type: "activeEnd", signalType: T.LINETYPE.ACTIVE_END, actor: c[d - 1] };
          break;
        case 29:
          T.setDiagramTitle(c[d].substring(6)), this.$ = c[d].substring(6);
          break;
        case 30:
          T.setDiagramTitle(c[d].substring(7)), this.$ = c[d].substring(7);
          break;
        case 31:
          this.$ = c[d].trim(), T.setAccTitle(this.$);
          break;
        case 32:
        case 33:
          this.$ = c[d].trim(), T.setAccDescription(this.$);
          break;
        case 34:
          c[d - 1].unshift({ type: "loopStart", loopText: T.parseMessage(c[d - 2]), signalType: T.LINETYPE.LOOP_START }), c[d - 1].push({ type: "loopEnd", loopText: c[d - 2], signalType: T.LINETYPE.LOOP_END }), this.$ = c[d - 1];
          break;
        case 35:
          c[d - 1].unshift({ type: "rectStart", color: T.parseMessage(c[d - 2]), signalType: T.LINETYPE.RECT_START }), c[d - 1].push({ type: "rectEnd", color: T.parseMessage(c[d - 2]), signalType: T.LINETYPE.RECT_END }), this.$ = c[d - 1];
          break;
        case 36:
          c[d - 1].unshift({ type: "optStart", optText: T.parseMessage(c[d - 2]), signalType: T.LINETYPE.OPT_START }), c[d - 1].push({ type: "optEnd", optText: T.parseMessage(c[d - 2]), signalType: T.LINETYPE.OPT_END }), this.$ = c[d - 1];
          break;
        case 37:
          c[d - 1].unshift({ type: "altStart", altText: T.parseMessage(c[d - 2]), signalType: T.LINETYPE.ALT_START }), c[d - 1].push({ type: "altEnd", signalType: T.LINETYPE.ALT_END }), this.$ = c[d - 1];
          break;
        case 38:
          c[d - 1].unshift({ type: "parStart", parText: T.parseMessage(c[d - 2]), signalType: T.LINETYPE.PAR_START }), c[d - 1].push({ type: "parEnd", signalType: T.LINETYPE.PAR_END }), this.$ = c[d - 1];
          break;
        case 39:
          c[d - 1].unshift({ type: "parStart", parText: T.parseMessage(c[d - 2]), signalType: T.LINETYPE.PAR_OVER_START }), c[d - 1].push({ type: "parEnd", signalType: T.LINETYPE.PAR_END }), this.$ = c[d - 1];
          break;
        case 40:
          c[d - 1].unshift({ type: "criticalStart", criticalText: T.parseMessage(c[d - 2]), signalType: T.LINETYPE.CRITICAL_START }), c[d - 1].push({ type: "criticalEnd", signalType: T.LINETYPE.CRITICAL_END }), this.$ = c[d - 1];
          break;
        case 41:
          c[d - 1].unshift({ type: "breakStart", breakText: T.parseMessage(c[d - 2]), signalType: T.LINETYPE.BREAK_START }), c[d - 1].push({ type: "breakEnd", optText: T.parseMessage(c[d - 2]), signalType: T.LINETYPE.BREAK_END }), this.$ = c[d - 1];
          break;
        case 43:
          this.$ = c[d - 3].concat([{ type: "option", optionText: T.parseMessage(c[d - 1]), signalType: T.LINETYPE.CRITICAL_OPTION }, c[d]]);
          break;
        case 45:
          this.$ = c[d - 3].concat([{ type: "and", parText: T.parseMessage(c[d - 1]), signalType: T.LINETYPE.PAR_AND }, c[d]]);
          break;
        case 47:
          this.$ = c[d - 3].concat([{ type: "else", altText: T.parseMessage(c[d - 1]), signalType: T.LINETYPE.ALT_ELSE }, c[d]]);
          break;
        case 48:
          c[d - 3].draw = "participant", c[d - 3].type = "addParticipant", c[d - 3].description = T.parseMessage(c[d - 1]), this.$ = c[d - 3];
          break;
        case 49:
          c[d - 1].draw = "participant", c[d - 1].type = "addParticipant", this.$ = c[d - 1];
          break;
        case 50:
          c[d - 3].draw = "actor", c[d - 3].type = "addParticipant", c[d - 3].description = T.parseMessage(c[d - 1]), this.$ = c[d - 3];
          break;
        case 51:
          c[d - 1].draw = "actor", c[d - 1].type = "addParticipant", this.$ = c[d - 1];
          break;
        case 52:
          c[d - 1].type = "destroyParticipant", this.$ = c[d - 1];
          break;
        case 53:
          this.$ = [c[d - 1], { type: "addNote", placement: c[d - 2], actor: c[d - 1].actor, text: c[d] }];
          break;
        case 54:
          c[d - 2] = [].concat(c[d - 1], c[d - 1]).slice(0, 2), c[d - 2][0] = c[d - 2][0].actor, c[d - 2][1] = c[d - 2][1].actor, this.$ = [c[d - 1], { type: "addNote", placement: T.PLACEMENT.OVER, actor: c[d - 2].slice(0, 2), text: c[d] }];
          break;
        case 55:
          this.$ = [c[d - 1], { type: "addLinks", actor: c[d - 1].actor, text: c[d] }];
          break;
        case 56:
          this.$ = [c[d - 1], { type: "addALink", actor: c[d - 1].actor, text: c[d] }];
          break;
        case 57:
          this.$ = [c[d - 1], { type: "addProperties", actor: c[d - 1].actor, text: c[d] }];
          break;
        case 58:
          this.$ = [c[d - 1], { type: "addDetails", actor: c[d - 1].actor, text: c[d] }];
          break;
        case 61:
          this.$ = [c[d - 2], c[d]];
          break;
        case 62:
          this.$ = c[d];
          break;
        case 63:
          this.$ = T.PLACEMENT.LEFTOF;
          break;
        case 64:
          this.$ = T.PLACEMENT.RIGHTOF;
          break;
        case 65:
          this.$ = [
            c[d - 4],
            c[d - 1],
            { type: "addMessage", from: c[d - 4].actor, to: c[d - 1].actor, signalType: c[d - 3], msg: c[d], activate: !0 },
            { type: "activeStart", signalType: T.LINETYPE.ACTIVE_START, actor: c[d - 1] }
          ];
          break;
        case 66:
          this.$ = [
            c[d - 4],
            c[d - 1],
            { type: "addMessage", from: c[d - 4].actor, to: c[d - 1].actor, signalType: c[d - 3], msg: c[d] },
            { type: "activeEnd", signalType: T.LINETYPE.ACTIVE_END, actor: c[d - 4] }
          ];
          break;
        case 67:
          this.$ = [c[d - 3], c[d - 1], { type: "addMessage", from: c[d - 3].actor, to: c[d - 1].actor, signalType: c[d - 2], msg: c[d] }];
          break;
        case 68:
          this.$ = { type: "addParticipant", actor: c[d] };
          break;
        case 69:
          this.$ = T.LINETYPE.SOLID_OPEN;
          break;
        case 70:
          this.$ = T.LINETYPE.DOTTED_OPEN;
          break;
        case 71:
          this.$ = T.LINETYPE.SOLID;
          break;
        case 72:
          this.$ = T.LINETYPE.DOTTED;
          break;
        case 73:
          this.$ = T.LINETYPE.SOLID_CROSS;
          break;
        case 74:
          this.$ = T.LINETYPE.DOTTED_CROSS;
          break;
        case 75:
          this.$ = T.LINETYPE.SOLID_POINT;
          break;
        case 76:
          this.$ = T.LINETYPE.DOTTED_POINT;
          break;
        case 77:
          this.$ = T.parseMessage(c[d].trim().substring(1));
          break;
      }
    },
    table: [{ 3: 1, 4: e, 5: o, 6: s }, { 1: [3] }, { 3: 5, 4: e, 5: o, 6: s }, { 3: 6, 4: e, 5: o, 6: s }, t([1, 4, 5, 13, 14, 18, 21, 23, 29, 30, 31, 33, 35, 36, 37, 38, 39, 41, 43, 44, 46, 50, 52, 53, 54, 59, 60, 61, 62, 70], r, { 7: 7 }), { 1: [2, 1] }, { 1: [2, 2] }, { 1: [2, 3], 4: a, 5: l, 8: 8, 9: 10, 12: 12, 13: h, 14: p, 17: 15, 18: i, 21: g, 22: 40, 23: E, 24: 19, 25: 20, 26: 21, 27: 22, 28: 23, 29: u, 30: x, 31: m, 33: P, 35: A, 36: D, 37: S, 38: W, 39: M, 41: tt, 43: q, 44: X, 46: Z, 50: z, 52: F, 53: O, 54: G, 59: H, 60: J, 61: Q, 62: j, 70: y }, t(_, [2, 5]), { 9: 47, 12: 12, 13: h, 14: p, 17: 15, 18: i, 21: g, 22: 40, 23: E, 24: 19, 25: 20, 26: 21, 27: 22, 28: 23, 29: u, 30: x, 31: m, 33: P, 35: A, 36: D, 37: S, 38: W, 39: M, 41: tt, 43: q, 44: X, 46: Z, 50: z, 52: F, 53: O, 54: G, 59: H, 60: J, 61: Q, 62: j, 70: y }, t(_, [2, 7]), t(_, [2, 8]), t(_, [2, 14]), { 12: 48, 50: z, 52: F, 53: O }, { 15: [1, 49] }, { 5: [1, 50] }, { 5: [1, 53], 19: [1, 51], 20: [1, 52] }, { 22: 54, 70: y }, { 22: 55, 70: y }, { 5: [1, 56] }, { 5: [1, 57] }, { 5: [1, 58] }, { 5: [1, 59] }, { 5: [1, 60] }, t(_, [2, 29]), t(_, [2, 30]), { 32: [1, 61] }, { 34: [1, 62] }, t(_, [2, 33]), { 15: [1, 63] }, { 15: [1, 64] }, { 15: [1, 65] }, { 15: [1, 66] }, { 15: [1, 67] }, { 15: [1, 68] }, { 15: [1, 69] }, { 15: [1, 70] }, { 22: 71, 70: y }, { 22: 72, 70: y }, { 22: 73, 70: y }, { 67: 74, 71: [1, 75], 72: [1, 76], 73: [1, 77], 74: [1, 78], 75: [1, 79], 76: [1, 80], 77: [1, 81], 78: [1, 82] }, { 55: 83, 57: [1, 84], 65: [1, 85], 66: [1, 86] }, { 22: 87, 70: y }, { 22: 88, 70: y }, { 22: 89, 70: y }, { 22: 90, 70: y }, t([5, 51, 64, 71, 72, 73, 74, 75, 76, 77, 78, 79], [2, 68]), t(_, [2, 6]), t(_, [2, 15]), t(I, [2, 9], { 10: 91 }), t(_, [2, 17]), { 5: [1, 93], 19: [1, 92] }, { 5: [1, 94] }, t(_, [2, 21]), { 5: [1, 95] }, { 5: [1, 96] }, t(_, [2, 24]), t(_, [2, 25]), t(_, [2, 26]), t(_, [2, 27]), t(_, [2, 28]), t(_, [2, 31]), t(_, [2, 32]), t(ht, r, { 7: 97 }), t(ht, r, { 7: 98 }), t(ht, r, { 7: 99 }), t(et, r, { 40: 100, 7: 101 }), t(N, r, { 42: 102, 7: 103 }), t(N, r, { 7: 103, 42: 104 }), t(zt, r, { 45: 105, 7: 106 }), t(ht, r, { 7: 107 }), { 5: [1, 109], 51: [1, 108] }, { 5: [1, 111], 51: [1, 110] }, { 5: [1, 112] }, { 22: 115, 68: [1, 113], 69: [1, 114], 70: y }, t(ot, [2, 69]), t(ot, [2, 70]), t(ot, [2, 71]), t(ot, [2, 72]), t(ot, [2, 73]), t(ot, [2, 74]), t(ot, [2, 75]), t(ot, [2, 76]), { 22: 116, 70: y }, { 22: 118, 58: 117, 70: y }, { 70: [2, 63] }, { 70: [2, 64] }, { 56: 119, 79: it }, { 56: 121, 79: it }, { 56: 122, 79: it }, { 56: 123, 79: it }, { 4: [1, 126], 5: [1, 128], 11: 125, 12: 127, 16: [1, 124], 50: z, 52: F, 53: O }, { 5: [1, 129] }, t(_, [2, 19]), t(_, [2, 20]), t(_, [2, 22]), t(_, [2, 23]), { 4: a, 5: l, 8: 8, 9: 10, 12: 12, 13: h, 14: p, 16: [1, 130], 17: 15, 18: i, 21: g, 22: 40, 23: E, 24: 19, 25: 20, 26: 21, 27: 22, 28: 23, 29: u, 30: x, 31: m, 33: P, 35: A, 36: D, 37: S, 38: W, 39: M, 41: tt, 43: q, 44: X, 46: Z, 50: z, 52: F, 53: O, 54: G, 59: H, 60: J, 61: Q, 62: j, 70: y }, { 4: a, 5: l, 8: 8, 9: 10, 12: 12, 13: h, 14: p, 16: [1, 131], 17: 15, 18: i, 21: g, 22: 40, 23: E, 24: 19, 25: 20, 26: 21, 27: 22, 28: 23, 29: u, 30: x, 31: m, 33: P, 35: A, 36: D, 37: S, 38: W, 39: M, 41: tt, 43: q, 44: X, 46: Z, 50: z, 52: F, 53: O, 54: G, 59: H, 60: J, 61: Q, 62: j, 70: y }, { 4: a, 5: l, 8: 8, 9: 10, 12: 12, 13: h, 14: p, 16: [1, 132], 17: 15, 18: i, 21: g, 22: 40, 23: E, 24: 19, 25: 20, 26: 21, 27: 22, 28: 23, 29: u, 30: x, 31: m, 33: P, 35: A, 36: D, 37: S, 38: W, 39: M, 41: tt, 43: q, 44: X, 46: Z, 50: z, 52: F, 53: O, 54: G, 59: H, 60: J, 61: Q, 62: j, 70: y }, { 16: [1, 133] }, { 4: a, 5: l, 8: 8, 9: 10, 12: 12, 13: h, 14: p, 16: [2, 46], 17: 15, 18: i, 21: g, 22: 40, 23: E, 24: 19, 25: 20, 26: 21, 27: 22, 28: 23, 29: u, 30: x, 31: m, 33: P, 35: A, 36: D, 37: S, 38: W, 39: M, 41: tt, 43: q, 44: X, 46: Z, 49: [1, 134], 50: z, 52: F, 53: O, 54: G, 59: H, 60: J, 61: Q, 62: j, 70: y }, { 16: [1, 135] }, { 4: a, 5: l, 8: 8, 9: 10, 12: 12, 13: h, 14: p, 16: [2, 44], 17: 15, 18: i, 21: g, 22: 40, 23: E, 24: 19, 25: 20, 26: 21, 27: 22, 28: 23, 29: u, 30: x, 31: m, 33: P, 35: A, 36: D, 37: S, 38: W, 39: M, 41: tt, 43: q, 44: X, 46: Z, 48: [1, 136], 50: z, 52: F, 53: O, 54: G, 59: H, 60: J, 61: Q, 62: j, 70: y }, { 16: [1, 137] }, { 16: [1, 138] }, { 4: a, 5: l, 8: 8, 9: 10, 12: 12, 13: h, 14: p, 16: [2, 42], 17: 15, 18: i, 21: g, 22: 40, 23: E, 24: 19, 25: 20, 26: 21, 27: 22, 28: 23, 29: u, 30: x, 31: m, 33: P, 35: A, 36: D, 37: S, 38: W, 39: M, 41: tt, 43: q, 44: X, 46: Z, 47: [1, 139], 50: z, 52: F, 53: O, 54: G, 59: H, 60: J, 61: Q, 62: j, 70: y }, { 4: a, 5: l, 8: 8, 9: 10, 12: 12, 13: h, 14: p, 16: [1, 140], 17: 15, 18: i, 21: g, 22: 40, 23: E, 24: 19, 25: 20, 26: 21, 27: 22, 28: 23, 29: u, 30: x, 31: m, 33: P, 35: A, 36: D, 37: S, 38: W, 39: M, 41: tt, 43: q, 44: X, 46: Z, 50: z, 52: F, 53: O, 54: G, 59: H, 60: J, 61: Q, 62: j, 70: y }, { 15: [1, 141] }, t(_, [2, 49]), { 15: [1, 142] }, t(_, [2, 51]), t(_, [2, 52]), { 22: 143, 70: y }, { 22: 144, 70: y }, { 56: 145, 79: it }, { 56: 146, 79: it }, { 56: 147, 79: it }, { 64: [1, 148], 79: [2, 62] }, { 5: [2, 55] }, { 5: [2, 77] }, { 5: [2, 56] }, { 5: [2, 57] }, { 5: [2, 58] }, t(_, [2, 16]), t(I, [2, 10]), { 12: 149, 50: z, 52: F, 53: O }, t(I, [2, 12]), t(I, [2, 13]), t(_, [2, 18]), t(_, [2, 34]), t(_, [2, 35]), t(_, [2, 36]), t(_, [2, 37]), { 15: [1, 150] }, t(_, [2, 38]), { 15: [1, 151] }, t(_, [2, 39]), t(_, [2, 40]), { 15: [1, 152] }, t(_, [2, 41]), { 5: [1, 153] }, { 5: [1, 154] }, { 56: 155, 79: it }, { 56: 156, 79: it }, { 5: [2, 67] }, { 5: [2, 53] }, { 5: [2, 54] }, { 22: 157, 70: y }, t(I, [2, 11]), t(et, r, { 7: 101, 40: 158 }), t(N, r, { 7: 103, 42: 159 }), t(zt, r, { 7: 106, 45: 160 }), t(_, [2, 48]), t(_, [2, 50]), { 5: [2, 65] }, { 5: [2, 66] }, { 79: [2, 61] }, { 16: [2, 47] }, { 16: [2, 45] }, { 16: [2, 43] }],
    defaultActions: { 5: [2, 1], 6: [2, 2], 85: [2, 63], 86: [2, 64], 119: [2, 55], 120: [2, 77], 121: [2, 56], 122: [2, 57], 123: [2, 58], 145: [2, 67], 146: [2, 53], 147: [2, 54], 155: [2, 65], 156: [2, 66], 157: [2, 61], 158: [2, 47], 159: [2, 45], 160: [2, 43] },
    parseError: function(w, k) {
      if (k.recoverable)
        this.trace(w);
      else {
        var L = new Error(w);
        throw L.hash = k, L;
      }
    },
    parse: function(w) {
      var k = this, L = [0], T = [], R = [null], c = [], Et = this.table, d = "", wt = 0, Ht = 0, ue = 2, Ut = 1, fe = c.slice.call(arguments, 1), Y = Object.create(this.lexer), dt = { yy: {} };
      for (var St in this.yy)
        Object.prototype.hasOwnProperty.call(this.yy, St) && (dt.yy[St] = this.yy[St]);
      Y.setInput(w, dt.yy), dt.yy.lexer = Y, dt.yy.parser = this, typeof Y.yylloc > "u" && (Y.yylloc = {});
      var Mt = Y.yylloc;
      c.push(Mt);
      var ge = Y.options && Y.options.ranges;
      typeof dt.yy.parseError == "function" ? this.parseError = dt.yy.parseError : this.parseError = Object.getPrototypeOf(this).parseError;
      function xe() {
        var nt;
        return nt = T.pop() || Y.lex() || Ut, typeof nt != "number" && (nt instanceof Array && (T = nt, nt = T.pop()), nt = k.symbols_[nt] || nt), nt;
      }
      for (var U, pt, $, Rt, xt = {}, vt, at, Kt, _t; ; ) {
        if (pt = L[L.length - 1], this.defaultActions[pt] ? $ = this.defaultActions[pt] : ((U === null || typeof U > "u") && (U = xe()), $ = Et[pt] && Et[pt][U]), typeof $ > "u" || !$.length || !$[0]) {
          var Dt = "";
          _t = [];
          for (vt in Et[pt])
            this.terminals_[vt] && vt > ue && _t.push("'" + this.terminals_[vt] + "'");
          Y.showPosition ? Dt = "Parse error on line " + (wt + 1) + `:
` + Y.showPosition() + `
Expecting ` + _t.join(", ") + ", got '" + (this.terminals_[U] || U) + "'" : Dt = "Parse error on line " + (wt + 1) + ": Unexpected " + (U == Ut ? "end of input" : "'" + (this.terminals_[U] || U) + "'"), this.parseError(Dt, {
            text: Y.match,
            token: this.terminals_[U] || U,
            line: Y.yylineno,
            loc: Mt,
            expected: _t
          });
        }
        if ($[0] instanceof Array && $.length > 1)
          throw new Error("Parse Error: multiple actions possible at state: " + pt + ", token: " + U);
        switch ($[0]) {
          case 1:
            L.push(U), R.push(Y.yytext), c.push(Y.yylloc), L.push($[1]), U = null, Ht = Y.yyleng, d = Y.yytext, wt = Y.yylineno, Mt = Y.yylloc;
            break;
          case 2:
            if (at = this.productions_[$[1]][1], xt.$ = R[R.length - at], xt._$ = {
              first_line: c[c.length - (at || 1)].first_line,
              last_line: c[c.length - 1].last_line,
              first_column: c[c.length - (at || 1)].first_column,
              last_column: c[c.length - 1].last_column
            }, ge && (xt._$.range = [
              c[c.length - (at || 1)].range[0],
              c[c.length - 1].range[1]
            ]), Rt = this.performAction.apply(xt, [
              d,
              Ht,
              wt,
              dt.yy,
              $[1],
              R,
              c
            ].concat(fe)), typeof Rt < "u")
              return Rt;
            at && (L = L.slice(0, -1 * at * 2), R = R.slice(0, -1 * at), c = c.slice(0, -1 * at)), L.push(this.productions_[$[1]][0]), R.push(xt.$), c.push(xt._$), Kt = Et[L[L.length - 2]][L[L.length - 1]], L.push(Kt);
            break;
          case 3:
            return !0;
        }
      }
      return !0;
    }
  }, pe = /* @__PURE__ */ function() {
    var ct = {
      EOF: 1,
      parseError: function(k, L) {
        if (this.yy.parser)
          this.yy.parser.parseError(k, L);
        else
          throw new Error(k);
      },
      // resets the lexer, sets new input
      setInput: function(w, k) {
        return this.yy = k || this.yy || {}, this._input = w, 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;
      },
      // consumes and returns one char from the input
      input: function() {
        var w = this._input[0];
        this.yytext += w, this.yyleng++, this.offset++, this.match += w, this.matched += w;
        var k = w.match(/(?:\r\n?|\n).*/g);
        return k ? (this.yylineno++, this.yylloc.last_line++) : this.yylloc.last_column++, this.options.ranges && this.yylloc.range[1]++, this._input = this._input.slice(1), w;
      },
      // unshifts one char (or a string) into the input
      unput: function(w) {
        var k = w.length, L = w.split(/(?:\r\n?|\n)/g);
        this._input = w + this._input, this.yytext = this.yytext.substr(0, this.yytext.length - k), this.offset -= k;
        var T = 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), L.length - 1 && (this.yylineno -= L.length - 1);
        var R = 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: L ? (L.length === T.length ? this.yylloc.first_column : 0) + T[T.length - L.length].length - L[0].length : this.yylloc.first_column - k
        }, this.options.ranges && (this.yylloc.range = [R[0], R[0] + this.yyleng - k]), this.yyleng = this.yytext.length, this;
      },
      // When called from action, caches matched text and appends it on next action
      more: function() {
        return this._more = !0, this;
      },
      // 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: 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;
      },
      // retain first n characters of the match
      less: function(w) {
        this.unput(this.match.slice(w));
      },
      // displays already matched input, i.e. for error messages
      pastInput: function() {
        var w = this.matched.substr(0, this.matched.length - this.match.length);
        return (w.length > 20 ? "..." : "") + w.substr(-20).replace(/\n/g, "");
      },
      // displays upcoming input, i.e. for error messages
      upcomingInput: function() {
        var w = this.match;
        return w.length < 20 && (w += this._input.substr(0, 20 - w.length)), (w.substr(0, 20) + (w.length > 20 ? "..." : "")).replace(/\n/g, "");
      },
      // displays the character position where the lexing error occurred, i.e. for error messages
      showPosition: function() {
        var w = this.pastInput(), k = new Array(w.length + 1).join("-");
        return w + this.upcomingInput() + `
` + k + "^";
      },
      // test the lexed token: return FALSE when not a match, otherwise return token
      test_match: function(w, k) {
        var L, T, R;
        if (this.options.backtrack_lexer && (R = {
          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 && (R.yylloc.range = this.yylloc.range.slice(0))), T = w[0].match(/(?:\r\n?|\n).*/g), T && (this.yylineno += T.length), this.yylloc = {
          first_line: this.yylloc.last_line,
          last_line: this.yylineno + 1,
          first_column: this.yylloc.last_column,
          last_column: T ? T[T.length - 1].length - T[T.length - 1].match(/\r?\n?/)[0].length : this.yylloc.last_column + w[0].length
        }, this.yytext += w[0], this.match += w[0], this.matches = w, 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(w[0].length), this.matched += w[0], L = this.performAction.call(this, this.yy, this, k, this.conditionStack[this.conditionStack.length - 1]), this.done && this._input && (this.done = !1), L)
          return L;
        if (this._backtrack) {
          for (var c in R)
            this[c] = R[c];
          return !1;
        }
        return !1;
      },
      // return next match in input
      next: function() {
        if (this.done)
          return this.EOF;
        this._input || (this.done = !0);
        var w, k, L, T;
        this._more || (this.yytext = "", this.match = "");
        for (var R = this._currentRules(), c = 0; c < R.length; c++)
          if (L = this._input.match(this.rules[R[c]]), L && (!k || L[0].length > k[0].length)) {
            if (k = L, T = c, this.options.backtrack_lexer) {
              if (w = this.test_match(L, R[c]), w !== !1)
                return w;
              if (this._backtrack) {
                k = !1;
                continue;
              } else
                return !1;
            } else if (!this.options.flex)
              break;
          }
        return k ? (w = this.test_match(k, R[T]), w !== !1 ? w : !1) : this._input === "" ? this.EOF : this.parseError("Lexical error on line " + (this.yylineno + 1) + `. Unrecognized text.
` + this.showPosition(), {
          text: "",
          token: null,
          line: this.yylineno
        });
      },
      // return next match that has a token
      lex: function() {
        var k = this.next();
        return k || this.lex();
      },
      // activates a new lexer condition state (pushes the new lexer condition state onto the condition stack)
      begin: function(k) {
        this.conditionStack.push(k);
      },
      // pop the previously active lexer condition state off the condition stack
      popState: function() {
        var k = this.conditionStack.length - 1;
        return k > 0 ? this.conditionStack.pop() : this.conditionStack[0];
      },
      // produce the lexer rule set which is active for the currently active lexer condition state
      _currentRules: function() {
        return this.conditionStack.length && this.conditionStack[this.conditionStack.length - 1] ? this.conditions[this.conditionStack[this.conditionStack.length - 1]].rules : this.conditions.INITIAL.rules;
      },
      // return the currently active lexer condition state; when an index argument is provided it produces the N-th previous condition state, if available
      topState: function(k) {
        return k = this.conditionStack.length - 1 - Math.abs(k || 0), k >= 0 ? this.conditionStack[k] : "INITIAL";
      },
      // alias for begin(condition)
      pushState: function(k) {
        this.begin(k);
      },
      // return the number of states currently on the stack
      stateStackSize: function() {
        return this.conditionStack.length;
      },
      options: { "case-insensitive": !0 },
      performAction: function(k, L, T, R) {
        switch (T) {
          case 0:
            return 5;
          case 1:
            break;
          case 2:
            break;
          case 3:
            break;
          case 4:
            break;
          case 5:
            break;
          case 6:
            return 19;
          case 7:
            return this.begin("LINE"), 14;
          case 8:
            return this.begin("ID"), 50;
          case 9:
            return this.begin("ID"), 52;
          case 10:
            return 13;
          case 11:
            return this.begin("ID"), 53;
          case 12:
            return L.yytext = L.yytext.trim(), this.begin("ALIAS"), 70;
          case 13:
            return this.popState(), this.popState(), this.begin("LINE"), 51;
          case 14:
            return this.popState(), this.popState(), 5;
          case 15:
            return this.begin("LINE"), 36;
          case 16:
            return this.begin("LINE"), 37;
          case 17:
            return this.begin("LINE"), 38;
          case 18:
            return this.begin("LINE"), 39;
          case 19:
            return this.begin("LINE"), 49;
          case 20:
            return this.begin("LINE"), 41;
          case 21:
            return this.begin("LINE"), 43;
          case 22:
            return this.begin("LINE"), 48;
          case 23:
            return this.begin("LINE"), 44;
          case 24:
            return this.begin("LINE"), 47;
          case 25:
            return this.begin("LINE"), 46;
          case 26:
            return this.popState(), 15;
          case 27:
            return 16;
          case 28:
            return 65;
          case 29:
            return 66;
          case 30:
            return 59;
          case 31:
            return 60;
          case 32:
            return 61;
          case 33:
            return 62;
          case 34:
            return 57;
          case 35:
            return 54;
          case 36:
            return this.begin("ID"), 21;
          case 37:
            return this.begin("ID"), 23;
          case 38:
            return 29;
          case 39:
            return 30;
          case 40:
            return this.begin("acc_title"), 31;
          case 41:
            return this.popState(), "acc_title_value";
          case 42:
            return this.begin("acc_descr"), 33;
          case 43:
            return this.popState(), "acc_descr_value";
          case 44:
            this.begin("acc_descr_multiline");
            break;
          case 45:
            this.popState();
            break;
          case 46:
            return "acc_descr_multiline_value";
          case 47:
            return 6;
          case 48:
            return 18;
          case 49:
            return 20;
          case 50:
            return 64;
          case 51:
            return 5;
          case 52:
            return L.yytext = L.yytext.trim(), 70;
          case 53:
            return 73;
          case 54:
            return 74;
          case 55:
            return 71;
          case 56:
            return 72;
          case 57:
            return 75;
          case 58:
            return 76;
          case 59:
            return 77;
          case 60:
            return 78;
          case 61:
            return 79;
          case 62:
            return 68;
          case 63:
            return 69;
          case 64:
            return 5;
          case 65:
            return "INVALID";
        }
      },
      rules: [/^(?:[\n]+)/i, /^(?:\s+)/i, /^(?:((?!\n)\s)+)/i, /^(?:#[^\n]*)/i, /^(?:%(?!\{)[^\n]*)/i, /^(?:[^\}]%%[^\n]*)/i, /^(?:[0-9]+(?=[ \n]+))/i, /^(?:box\b)/i, /^(?:participant\b)/i, /^(?:actor\b)/i, /^(?:create\b)/i, /^(?:destroy\b)/i, /^(?:[^\->:\n,;]+?([\-]*[^\->:\n,;]+?)*?(?=((?!\n)\s)+as(?!\n)\s|[#\n;]|$))/i, /^(?:as\b)/i, /^(?:(?:))/i, /^(?:loop\b)/i, /^(?:rect\b)/i, /^(?:opt\b)/i, /^(?:alt\b)/i, /^(?:else\b)/i, /^(?:par\b)/i, /^(?:par_over\b)/i, /^(?:and\b)/i, /^(?:critical\b)/i, /^(?:option\b)/i, /^(?:break\b)/i, /^(?:(?:[:]?(?:no)?wrap)?[^#\n;]*)/i, /^(?:end\b)/i, /^(?:left of\b)/i, /^(?:right of\b)/i, /^(?:links\b)/i, /^(?:link\b)/i, /^(?:properties\b)/i, /^(?:details\b)/i, /^(?:over\b)/i, /^(?:note\b)/i, /^(?:activate\b)/i, /^(?:deactivate\b)/i, /^(?:title\s[^#\n;]+)/i, /^(?:title:\s[^#\n;]+)/i, /^(?:accTitle\s*:\s*)/i, /^(?:(?!\n||)*[^\n]*)/i, /^(?:accDescr\s*:\s*)/i, /^(?:(?!\n||)*[^\n]*)/i, /^(?:accDescr\s*\{\s*)/i, /^(?:[\}])/i, /^(?:[^\}]*)/i, /^(?:sequenceDiagram\b)/i, /^(?:autonumber\b)/i, /^(?:off\b)/i, /^(?:,)/i, /^(?:;)/i, /^(?:[^\+\->:\n,;]+((?!(-x|--x|-\)|--\)))[\-]*[^\+\->:\n,;]+)*)/i, /^(?:->>)/i, /^(?:-->>)/i, /^(?:->)/i, /^(?:-->)/i, /^(?:-[x])/i, /^(?:--[x])/i, /^(?:-[\)])/i, /^(?:--[\)])/i, /^(?::(?:(?:no)?wrap)?[^#\n;]+)/i, /^(?:\+)/i, /^(?:-)/i, /^(?:$)/i, /^(?:.)/i],
      conditions: { acc_descr_multiline: { rules: [45, 46], inclusive: !1 }, acc_descr: { rules: [43], inclusive: !1 }, acc_title: { rules: [41], inclusive: !1 }, ID: { rules: [2, 3, 12], inclusive: !1 }, ALIAS: { rules: [2, 3, 13, 14], inclusive: !1 }, LINE: { rules: [2, 3, 26], inclusive: !1 }, INITIAL: { rules: [0, 1, 3, 4, 5, 6, 7, 8, 9, 10, 11, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 42, 44, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65], inclusive: !0 } }
    };
    return ct;
  }();
  At.lexer = pe;
  function Nt() {
    this.yy = {};
  }
  return Nt.prototype = At, At.Parser = Nt, new Nt();
}();
Ct.parser = Ct;
const Ne = Ct;
class Se {
  /**
   * @param init - Function that creates the default state.
   */
  constructor(e) {
    this.init = e, this.records = this.init();
  }
  reset() {
    this.records = this.init();
  }
}
const b = new Se(() => ({
  prevActor: void 0,
  actors: {},
  createdActors: {},
  destroyedActors: {},
  boxes: [],
  messages: [],
  notes: [],
  sequenceNumbersEnabled: !1,
  wrapEnabled: void 0,
  currentBox: void 0,
  lastCreated: void 0,
  lastDestroyed: void 0
})), Me = function(t) {
  b.records.boxes.push({
    name: t.text,
    wrap: t.wrap === void 0 && ft() || !!t.wrap,
    fill: t.color,
    actorKeys: []
  }), b.records.currentBox = b.records.boxes.slice(-1)[0];
}, Vt = function(t, e, o, s) {
  let r = b.records.currentBox;
  const a = b.records.actors[t];
  if (a) {
    if (b.records.currentBox && a.box && b.records.currentBox !== a.box)
      throw new Error(
        "A same participant should only be defined in one Box: " + a.name + " can't be in '" + a.box.name + "' and in '" + b.records.currentBox.name + "' at the same time."
      );
    if (r = a.box ? a.box : b.records.currentBox, a.box = r, a && e === a.name && o == null)
      return;
  }
  (o == null || o.text == null) && (o = { text: e, wrap: null, type: s }), (s == null || o.text == null) && (o = { text: e, wrap: null, type: s }), b.records.actors[t] = {
    box: r,
    name: e,
    description: o.text,
    wrap: o.wrap === void 0 && ft() || !!o.wrap,
    prevActor: b.records.prevActor,
    links: {},
    properties: {},
    actorCnt: null,
    rectData: null,
    type: s || "participant"
  }, b.records.prevActor && b.records.actors[b.records.prevActor] && (b.records.actors[b.records.prevActor].nextActor = t), b.records.currentBox && b.records.currentBox.actorKeys.push(t), b.records.prevActor = t;
}, Re = (t) => {
  let e, o = 0;
  for (e = 0; e < b.records.messages.length; e++)
    b.records.messages[e].type === bt.ACTIVE_START && b.records.messages[e].from.actor === t && o++, b.records.messages[e].type === bt.ACTIVE_END && b.records.messages[e].from.actor === t && o--;
  return o;
}, De = function(t, e, o, s) {
  b.records.messages.push({
    from: t,
    to: e,
    message: o.text,
    wrap: o.wrap === void 0 && ft() || !!o.wrap,
    answer: s
  });
}, C = function(t, e, o = { text: void 0, wrap: void 0 }, s, r = !1) {
  if (s === bt.ACTIVE_END && Re(t.actor) < 1) {
    let l = new Error("Trying to inactivate an inactive participant (" + t.actor + ")");
    throw l.hash = {
      text: "->>-",
      token: "->>-",
      line: "1",
      loc: { first_line: 1, last_line: 1, first_column: 1, last_column: 1 },
      expected: ["'ACTIVE_PARTICIPANT'"]
    }, l;
  }
  return b.records.messages.push({
    from: t,
    to: e,
    message: o.text,
    wrap: o.wrap === void 0 && ft() || !!o.wrap,
    type: s,
    activate: r
  }), !0;
}, Ce = function() {
  return b.records.boxes.length > 0;
}, Ve = function() {
  return b.records.boxes.some((t) => t.name);
}, Oe = function() {
  return b.records.messages;
}, Be = function() {
  return b.records.boxes;
}, Ye = function() {
  return b.records.actors;
}, Fe = function() {
  return b.records.createdActors;
}, We = function() {
  return b.records.destroyedActors;
}, mt = function(t) {
  return b.records.actors[t];
}, qe = function() {
  return Object.keys(b.records.actors);
}, ze = function() {
  b.records.sequenceNumbersEnabled = !0;
}, He = function() {
  b.records.sequenceNumbersEnabled = !1;
}, Ue = () => b.records.sequenceNumbersEnabled, Ke = function(t) {
  b.records.wrapEnabled = t;
}, ft = () => b.records.wrapEnabled !== void 0 ? b.records.wrapEnabled : lt().sequence.wrap, Xe = function() {
  b.reset(), we();
}, Ge = function(t) {
  const e = t.trim(), o = {
    text: e.replace(/^:?(?:no)?wrap:/, "").trim(),
    wrap: e.match(/^:?wrap:/) !== null ? !0 : e.match(/^:?nowrap:/) !== null ? !1 : void 0
  };
  return K.debug("parseMessage:", o), o;
}, Je = function(t) {
  const e = t.match(/^((?:rgba?|hsla?)\s*\(.*\)|\w*)(.*)$/);
  let o = e != null && e[1] ? e[1].trim() : "transparent", s = e != null && e[2] ? e[2].trim() : void 0;
  if (window && window.CSS)
    window.CSS.supports("color", o) || (o = "transparent", s = t.trim());
  else {
    const r = new Option().style;
    r.color = o, r.color !== o && (o = "transparent", s = t.trim());
  }
  return {
    color: o,
    text: s !== void 0 ? Pt(s.replace(/^:?(?:no)?wrap:/, ""), lt()) : void 0,
    wrap: s !== void 0 ? s.match(/^:?wrap:/) !== null ? !0 : s.match(/^:?nowrap:/) !== null ? !1 : void 0 : void 0
  };
}, bt = {
  SOLID: 0,
  DOTTED: 1,
  NOTE: 2,
  SOLID_CROSS: 3,
  DOTTED_CROSS: 4,
  SOLID_OPEN: 5,
  DOTTED_OPEN: 6,
  LOOP_START: 10,
  LOOP_END: 11,
  ALT_START: 12,
  ALT_ELSE: 13,
  ALT_END: 14,
  OPT_START: 15,
  OPT_END: 16,
  ACTIVE_START: 17,
  ACTIVE_END: 18,
  PAR_START: 19,
  PAR_AND: 20,
  PAR_END: 21,
  RECT_START: 22,
  RECT_END: 23,
  SOLID_POINT: 24,
  DOTTED_POINT: 25,
  AUTONUMBER: 26,
  CRITICAL_START: 27,
  CRITICAL_OPTION: 28,
  CRITICAL_END: 29,
  BREAK_START: 30,
  BREAK_END: 31,
  PAR_OVER_START: 32
}, Ze = {
  FILLED: 0,
  OPEN: 1
}, Qe = {
  LEFTOF: 0,
  RIGHTOF: 1,
  OVER: 2
}, jt = function(t, e, o) {
  const s = {
    actor: t,
    placement: e,
    message: o.text,
    wrap: o.wrap === void 0 && ft() || !!o.wrap
  }, r = [].concat(t, t);
  b.records.notes.push(s), b.records.messages.push({
    from: r[0],
    to: r[1],
    message: o.text,
    wrap: o.wrap === void 0 && ft() || !!o.wrap,
    type: bt.NOTE,
    placement: e
  });
}, $t = function(t, e) {
  const o = mt(t);
  try {
    let s = Pt(e.text, lt());
    s = s.replace(/&amp;/g, "&"), s = s.replace(/&equals;/g, "=");
    const r = JSON.parse(s);
    Ft(o, r);
  } catch (s) {
    K.error("error while parsing actor link text", s);
  }
}, je = function(t, e) {
  const o = mt(t);
  try {
    const l = {};
    let h = Pt(e.text, lt());
    var s = h.indexOf("@");
    h = h.replace(/&amp;/g, "&"), h = h.replace(/&equals;/g, "=");
    var r = h.slice(0, s - 1).trim(), a = h.slice(s + 1).trim();
    l[r] = a, Ft(o, l);
  } catch (l) {
    K.error("error while parsing actor link text", l);
  }
};
function Ft(t, e) {
  if (t.links == null)
    t.links = e;
  else
    for (let o in e)
      t.links[o] = e[o];
}
const te = function(t, e) {
  const o = mt(t);
  try {
    let s = Pt(e.text, lt());
    const r = JSON.parse(s);
    ee(o, r);
  } catch (s) {
    K.error("error while parsing actor properties text", s);
  }
};
function ee(t, e) {
  if (t.properties == null)
    t.properties = e;
  else
    for (let o in e)
      t.properties[o] = e[o];
}
function $e() {
  b.records.currentBox = void 0;
}
const se = function(t, e) {
  const o = mt(t), s = document.getElementById(e.text);
  try {
    const r = s.innerHTML, a = JSON.parse(r);
    a.properties && ee(o, a.properties), a.links && Ft(o, a.links);
  } catch (r) {
    K.error("error while parsing actor details text", r);
  }
}, t0 = function(t, e) {
  if (t !== void 0 && t.properties !== void 0)
    return t.properties[e];
}, re = function(t) {
  if (Array.isArray(t))
    t.forEach(function(e) {
      re(e);
    });
  else
    switch (t.type) {
      case "sequenceIndex":
        b.records.messages.push({
          from: void 0,
          to: void 0,
          message: {
            start: t.sequenceIndex,
            step: t.sequenceIndexStep,
            visible: t.sequenceVisible
          },
          wrap: !1,
          type: t.signalType
        });
        break;
      case "addParticipant":
        Vt(t.actor, t.actor, t.description, t.draw);
        break;
      case "createParticipant":
        if (b.records.actors[t.actor])
          throw new Error(
            "It is not possible to have actors with the same id, even if one is destroyed before the next is created. Use 'AS' aliases to simulate the behavior"
          );
        b.records.lastCreated = t.actor, Vt(t.actor, t.actor, t.description, t.draw), b.records.createdActors[t.actor] = b.records.messages.length;
        break;
      case "destroyParticipant":
        b.records.lastDestroyed = t.actor, b.records.destroyedActors[t.actor] = b.records.messages.length;
        break;
      case "activeStart":
        C(t.actor, void 0, void 0, t.signalType);
        break;
      case "activeEnd":
        C(t.actor, void 0, void 0, t.signalType);
        break;
      case "addNote":
        jt(t.actor, t.placement, t.text);
        break;
      case "addLinks":
        $t(t.actor, t.text);
        break;
      case "addALink":
        je(t.actor, t.text);
        break;
      case "addProperties":
        te(t.actor, t.text);
        break;
      case "addDetails":
        se(t.actor, t.text);
        break;
      case "addMessage":
        if (b.records.lastCreated) {
          if (t.to !== b.records.lastCreated)
            throw new Error(
              "The created participant " + b.records.lastCreated + " does not have an associated creating message after its declaration. Please check the sequence diagram."
            );
          b.records.lastCreated = void 0;
        } else if (b.records.lastDestroyed) {
          if (t.to !== b.records.lastDestroyed && t.from !== b.records.lastDestroyed)
            throw new Error(
              "The destroyed participant " + b.records.lastDestroyed + " does not have an associated destroying message after its declaration. Please check the sequence diagram."
            );
          b.records.lastDestroyed = void 0;
        }
        C(t.from, t.to, t.msg, t.signalType, t.activate);
        break;
      case "boxStart":
        Me(t.boxData);
        break;
      case "boxEnd":
        $e();
        break;
      case "loopStart":
        C(void 0, void 0, t.loopText, t.signalType);
        break;
      case "loopEnd":
        C(void 0, void 0, void 0, t.signalType);
        break;
      case "rectStart":
        C(void 0, void 0, t.color, t.signalType);
        break;
      case "rectEnd":
        C(void 0, void 0, void 0, t.signalType);
        break;
      case "optStart":
        C(void 0, void 0, t.optText, t.signalType);
        break;
      case "optEnd":
        C(void 0, void 0, void 0, t.signalType);
        break;
      case "altStart":
        C(void 0, void 0, t.altText, t.signalType);
        break;
      case "else":
        C(void 0, void 0, t.altText, t.signalType);
        break;
      case "altEnd":
        C(void 0, void 0, void 0, t.signalType);
        break;
      case "setAccTitle":
        Jt(t.text);
        break;
      case "parStart":
        C(void 0, void 0, t.parText, t.signalType);
        break;
      case "and":
        C(void 0, void 0, t.parText, t.signalType);
        break;
      case "parEnd":
        C(void 0, void 0, void 0, t.signalType);
        break;
      case "criticalStart":
        C(void 0, void 0, t.criticalText, t.signalType);
        break;
      case "option":
        C(void 0, void 0, t.optionText, t.signalType);
        break;
      case "criticalEnd":
        C(void 0, void 0, void 0, t.signalType);
        break;
      case "breakStart":
        C(void 0, void 0, t.breakText, t.signalType);
        break;
      case "breakEnd":
        C(void 0, void 0, void 0, t.signalType);
        break;
    }
}, Xt = {
  addActor: Vt,
  addMessage: De,
  addSignal: C,
  addLinks: $t,
  addDetails: se,
  addProperties: te,
  autoWrap: ft,
  setWrap: Ke,
  enableSequenceNumbers: ze,
  disableSequenceNumbers: He,
  showSequenceNumbers: Ue,
  getMessages: Oe,
  getActors: Ye,
  getCreatedActors: Fe,
  getDestroyedActors: We,
  getActor: mt,
  getActorKeys: qe,
  getActorProperty: t0,
  getAccTitle: Te,
  getBoxes: Be,
  getDiagramTitle: ye,
  setDiagramTitle: Ee,
  getConfig: () => lt().sequence,
  clear: Xe,
  parseMessage: Ge,
  parseBoxData: Je,
  LINETYPE: bt,
  ARROWTYPE: Ze,
  PLACEMENT: Qe,
  addNote: jt,
  setAccTitle: Jt,
  apply: re,
  setAccDescription: be,
  getAccDescription: me,
  hasAtLeastOneBox: Ce,
  hasAtLeastOneBoxWithTitle: Ve
}, e0 = (t) => `.actor {
    stroke: ${t.actorBorder};
    fill: ${t.actorBkg};
  }

  text.actor > tspan {
    fill: ${t.actorTextColor};
    stroke: none;
  }

  .actor-line {
    stroke: ${t.actorLineColor};
  }

  .messageLine0 {
    stroke-width: 1.5;
    stroke-dasharray: none;
    stroke: ${t.signalColor};
  }

  .messageLine1 {
    stroke-width: 1.5;
    stroke-dasharray: 2, 2;
    stroke: ${t.signalColor};
  }

  #arrowhead path {
    fill: ${t.signalColor};
    stroke: ${t.signalColor};
  }

  .sequenceNumber {
    fill: ${t.sequenceNumberColor};
  }

  #sequencenumber {
    fill: ${t.signalColor};
  }

  #crosshead path {
    fill: ${t.signalColor};
    stroke: ${t.signalColor};
  }

  .messageText {
    fill: ${t.signalTextColor};
    stroke: none;
  }

  .labelBox {
    stroke: ${t.labelBoxBorderColor};
    fill: ${t.labelBoxBkgColor};
  }

  .labelText, .labelText > tspan {
    fill: ${t.labelTextColor};
    stroke: none;
  }

  .loopText, .loopText > tspan {
    fill: ${t.loopTextColor};
    stroke: none;
  }

  .loopLine {
    stroke-width: 2px;
    stroke-dasharray: 2, 2;
    stroke: ${t.labelBoxBorderColor};
    fill: ${t.labelBoxBorderColor};
  }

  .note {
    //stroke: #decc93;
    stroke: ${t.noteBorderColor};
    fill: ${t.noteBkgColor};
  }

  .noteText, .noteText > tspan {
    fill: ${t.noteTextColor};
    stroke: none;
  }

  .activation0 {
    fill: ${t.activationBkgColor};
    stroke: ${t.activationBorderColor};
  }

  .activation1 {
    fill: ${t.activationBkgColor};
    stroke: ${t.activationBorderColor};
  }

  .activation2 {
    fill: ${t.activationBkgColor};
    stroke: ${t.activationBorderColor};
  }

  .actorPopupMenu {
    position: absolute;
  }

  .actorPopupMenuPanel {
    position: absolute;
    fill: ${t.actorBkg};
    box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
    filter: drop-shadow(3px 5px 2px rgb(0 0 0 / 0.4));
}
  .actor-man line {
    stroke: ${t.actorBorder};
    fill: ${t.actorBkg};
  }
  .actor-man circle, line {
    stroke: ${t.actorBorder};
    fill: ${t.actorBkg};
    stroke-width: 2px;
  }
`, s0 = e0, ut = 18 * 2, ie = "actor-top", ae = "actor-bottom", Wt = function(t, e) {
  return Pe(t, e);
}, r0 = function(t, e, o, s, r) {
  if (e.links === void 0 || e.links === null || Object.keys(e.links).length === 0)
    return { height: 0, width: 0 };
  const a = e.links, l = e.actorCnt, h = e.rectData;
  var p = "none";
  r && (p = "block !important");
  const i = t.append("g");
  i.attr("id", "actor" + l + "_popup"), i.attr("class", "actorPopupMenu"), i.attr("display", p);
  var g = "";
  h.class !== void 0 && (g = " " + h.class);
  let E = h.width > o ? h.width : o;
  const u = i.append("rect");
  if (u.attr("class", "actorPopupMenuPanel" + g), u.attr("x", h.x), u.attr("y", h.height), u.attr("fill", h.fill), u.attr("stroke", h.stroke), u.attr("width", E), u.attr("height", h.height), u.attr("rx", h.rx), u.attr("ry", h.ry), a != null) {
    var x = 20;
    for (let A in a) {
      var m = i.append("a"), P = Zt.sanitizeUrl(a[A]);
      m.attr("xlink:href", P), m.attr("target", "_blank"), b0(s)(
        A,
        m,
        h.x + 10,
        h.height + x,
        E,
        20,
        { class: "actor" },
        s
      ), x += 30;
    }
  }
  return u.attr("height", x), { height: h.height + x, width: E };
}, i0 = function(t) {
  return "var pu = document.getElementById('" + t + "'); if (pu != null) { pu.style.display = pu.style.display == 'block' ? 'none' : 'block'; }";
}, yt = function(t, e) {
  let o = 0, s = 0;
  const r = e.text.split(v.lineBreakRegex), [a, l] = Qt(e.fontSize);
  let h = [], p = 0, i = () => e.y;
  if (e.valign !== void 0 && e.textMargin !== void 0 && e.textMargin > 0)
    switch (e.valign) {
      case "top":
      case "start":
        i = () => Math.round(e.y + e.textMargin);
        break;
      case "middle":
      case "center":
        i = () => Math.round(e.y + (o + s + e.textMargin) / 2);
        break;
      case "bottom":
      case "end":
        i = () => Math.round(
          e.y + (o + s + 2 * e.textMargin) - e.textMargin
        );
        break;
    }
  if (e.anchor !== void 0 && e.textMargin !== void 0 && e.width !== void 0)
    switch (e.anchor) {
      case "left":
      case "start":
        e.x = Math.round(e.x + e.textMargin), e.anchor = "start", e.dominantBaseline = "middle", e.alignmentBaseline = "middle";
        break;
      case "middle":
      case "center":
        e.x = Math.round(e.x + e.width / 2), e.anchor = "middle", e.dominantBaseline = "middle", e.alignmentBaseline = "middle";
        break;
      case "right":
      case "end":
        e.x = Math.round(e.x + e.width - e.textMargin), e.anchor = "end", e.dominantBaseline = "middle", e.alignmentBaseline = "middle";
        break;
    }
  for (let [g, E] of r.entries()) {
    e.textMargin !== void 0 && e.textMargin === 0 && a !== void 0 && (p = g * a);
    const u = t.append("text");
    u.attr("x", e.x), u.attr("y", i()), e.anchor !== void 0 && u.attr("text-anchor", e.anchor).attr("dominant-baseline", e.dominantBaseline).attr("alignment-baseline", e.alignmentBaseline), e.fontFamily !== void 0 && u.style("font-family", e.fontFamily), l !== void 0 && u.style("font-size", l), e.fontWeight !== void 0 && u.style("font-weight", e.fontWeight), e.fill !== void 0 && u.attr("fill", e.fill), e.class !== void 0 && u.attr("class", e.class), e.dy !== void 0 ? u.attr("dy", e.dy) : p !== 0 && u.attr("dy", p);
    const x = E || ke;
    if (e.tspan) {
      const m = u.append("tspan");
      m.attr("x", e.x), e.fill !== void 0 && m.attr("fill", e.fill), m.text(x);
    } else
      u.text(x);
    e.valign !== void 0 && e.textMargin !== void 0 && e.textMargin > 0 && (s += (u._groups || u)[0][0].getBBox().height, o = s), h.push(u);
  }
  return h;
}, ne = function(t, e) {
  function o(r, a, l, h, p) {
    return r + "," + a + " " + (r + l) + "," + a + " " + (r + l) + "," + (a + h - p) + " " + (r + l - p * 1.2) + "," + (a + h) + " " + r + "," + (a + h);
  }
  const s = t.append("polygon");
  return s.attr("points", o(e.x, e.y, e.width, e.height, 7)), s.attr("class", "labelBox"), e.y = e.y + e.height / 2, yt(t, e), s;
};
let rt = -1;
const oe = (t, e, o, s) => {
  t.select && o.forEach((r) => {
    const a = e[r], l = t.select("#actor" + a.actorCnt);
    !s.mirrorActors && a.stopy ? l.attr("y2", a.stopy + a.height / 2) : s.mirrorActors && l.attr("y2", a.stopy);
  });
}, a0 = function(t, e, o, s) {
  const r = s ? e.stopy : e.starty, a = e.x + e.width / 2, l = r + 5, h = t.append("g").lower();
  var p = h;
  s || (rt++, Object.keys(e.links || {}).length && !o.forceMenus && p.attr("onclick", i0(`actor${rt}_popup`)).attr("cursor", "pointer"), p.append("line").attr("id", "actor" + rt).attr("x1", a).attr("y1", l).attr("x2", a).attr("y2", 2e3).attr("class", "actor-line").attr("class", "200").attr("stroke-width", "0.5px").attr("stroke", "#999"), p = h.append("g"), e.actorCnt = rt, e.links != null && p.attr("id", "root-" + rt));
  const i = Lt();
  var g = "actor";
  e.properties != null && e.properties.class ? g = e.properties.class : i.fill = "#eaeaea", s ? g += ` ${ae}` : g += ` ${ie}`, i.x = e.x, i.y = r, i.width = e.width, i.height = e.height, i.class = g, i.rx = 3, i.ry = 3;
  const E = Wt(p, i);
  if (e.rectData = i, e.properties != null && e.properties.icon) {
    const x = e.properties.icon.trim();
    x.charAt(0) === "@" ? Ie(p, i.x + i.width - 20, i.y + 10, x.substr(1)) : Ae(p, i.x + i.width - 20, i.y + 10, x);
  }
  qt(o)(
    e.description,
    p,
    i.x,
    i.y,
    i.width,
    i.height,
    { class: "actor" },
    o
  );
  let u = e.height;
  if (E.node) {
    const x = E.node().getBBox();
    e.height = x.height, u = x.height;
  }
  return u;
}, n0 = function(t, e, o, s) {
  const r = s ? e.stopy : e.starty, a = e.x + e.width / 2, l = r + 80;
  t.lower(), s || (rt++, t.append("line").attr("id", "actor" + rt).attr("x1", a).attr("y1", l).attr("x2", a).attr("y2", 2e3).attr("class", "actor-line").attr("class", "200").attr("stroke-width", "0.5px").attr("stroke", "#999"), e.actorCnt = rt);
  const h = t.append("g");
  let p = "actor-man";
  s ? p += ` ${ae}` : p += ` ${ie}`, h.attr("class", p);
  const i = Lt();
  i.x = e.x, i.y = r, i.fill = "#eaeaea", i.width = e.width, i.height = e.height, i.class = "actor", i.rx = 3, i.ry = 3, h.append("line").attr("id", "actor-man-torso" + rt).attr("x1", a).attr("y1", r + 25).attr("x2", a).attr("y2", r + 45), h.append("line").attr("id", "actor-man-arms" + rt).attr("x1", a - ut / 2).attr("y1", r + 33).attr("x2", a + ut / 2).attr("y2", r + 33), h.append("line").attr("x1", a - ut / 2).attr("y1", r + 60).attr("x2", a).attr("y2", r + 45), h.append("line").attr("x1", a).attr("y1", r + 45).attr("x2", a + ut / 2 - 2).attr("y2", r + 60);
  const g = h.append("circle");
  g.attr("cx", e.x + e.width / 2), g.attr("cy", r + 10), g.attr("r", 15), g.attr("width", e.width), g.attr("height", e.height);
  const E = h.node().getBBox();
  return e.height = E.height, qt(o)(
    e.description,
    h,
    i.x,
    i.y + 35,
    i.width,
    i.height,
    { class: "actor" },
    o
  ), e.height;
}, o0 = function(t, e, o, s) {
  switch (e.type) {
    case "actor":
      return n0(t, e, o, s);
    case "participant":
      return a0(t, e, o, s);
  }
}, c0 = function(t, e, o) {
  const r = t.append("g");
  ce(r, e), e.name && qt(o)(
    e.name,
    r,
    e.x,
    e.y + (e.textMaxHeight || 0) / 2,
    e.width,
    0,
    { class: "text" },
    o
  ), r.lower();
}, l0 = function(t) {
  return t.append("g");
}, h0 = function(t, e, o, s, r) {
  const a = Lt(), l = e.anchored;
  a.x = e.startx, a.y = e.starty, a.class = "activation" + r % 3, a.width = e.stopx - e.startx, a.height = o - e.starty, Wt(l, a);
}, d0 = function(t, e, o, s) {
  const {
    boxMargin: r,
    boxTextMargin: a,
    labelBoxHeight: l,
    labelBoxWidth: h,
    messageFontFamily: p,
    messageFontSize: i,
    messageFontWeight: g
  } = s, E = t.append("g"), u = function(P, A, D, S) {
    return E.append("line").attr("x1", P).attr("y1", A).attr("x2", D).attr("y2", S).attr("class", "loopLine");
  };
  u(e.startx, e.starty, e.stopx, e.starty), u(e.stopx, e.starty, e.stopx, e.stopy), u(e.startx, e.stopy, e.stopx, e.stopy), u(e.startx, e.starty, e.startx, e.stopy), e.sections !== void 0 && e.sections.forEach(function(P) {
    u(e.startx, P.y, e.stopx, P.y).style(
      "stroke-dasharray",
      "3, 3"
    );
  });
  let x = Yt();
  x.text = o, x.x = e.startx, x.y = e.starty, x.fontFamily = p, x.fontSize = i, x.fontWeight = g, x.anchor = "middle", x.valign = "middle", x.tspan = !1, x.width = h || 50, x.height = l || 20, x.textMargin = a, x.class = "labelText", ne(E, x), x = le(), x.text = e.title, x.x = e.startx + h / 2 + (e.stopx - e.startx) / 2, x.y = e.starty + r + a, x.anchor = "middle", x.valign = "middle", x.textMargin = a, x.class = "loopText", x.fontFamily = p, x.fontSize = i, x.fontWeight = g, x.wrap = !0;
  let m = yt(E, x);
  return e.sectionTitles !== void 0 && e.sectionTitles.forEach(function(P, A) {
    if (P.message) {
      x.text = P.message, x.x = e.startx + (e.stopx - e.startx) / 2, x.y = e.sections[A].y + r + a, x.class = "loopText", x.anchor = "middle", x.valign = "middle", x.tspan = !1, x.fontFamily = p, x.fontSize = i, x.fontWeight = g, x.wrap = e.wrap, m = yt(E, x);
      let D = Math.round(
        m.map((S) => (S._groups || S)[0][0].getBBox().height).reduce((S, W) => S + W)
      );
      e.sections[A].height += D - (r + a);
    }
  }), e.height = Math.round(e.stopy - e.starty), E;
}, ce = function(t, e) {
  Le(t, e);
}, p0 = function(t) {
  t.append("defs").append("symbol").attr("id", "database").attr("fill-rule", "evenodd").attr("clip-rule", "evenodd").append("path").attr("transform", "scale(.5)").attr(
    "d",
    "M12.258.001l.256.004.255.005.253.008.251.01.249.012.247.015.246.016.242.019.241.02.239.023.236.024.233.027.231.028.229.031.225.032.223.034.22.036.217.038.214.04.211.041.208.043.205.045.201.046.198.048.194.05.191.051.187.053.183.054.18.056.175.057.172.059.168.06.163.061.16.063.155.064.15.066.074.033.073.033.071.034.07.034.069.035.068.035.067.035.066.035.064.036.064.036.062.036.06.036.06.037.058.037.058.037.055.038.055.038.053.038.052.038.051.039.05.039.048.039.047.039.045.04.044.04.043.04.041.04.04.041.039.041.037.041.036.041.034.041.033.042.032.042.03.042.029.042.027.042.026.043.024.043.023.043.021.043.02.043.018.044.017.043.015.044.013.044.012.044.011.045.009.044.007.045.006.045.004.045.002.045.001.045v17l-.001.045-.002.045-.004.045-.006.045-.007.045-.009.044-.011.045-.012.044-.013.044-.015.044-.017.043-.018.044-.02.043-.021.043-.023.043-.024.043-.026.043-.027.042-.029.042-.03.042-.032.042-.033.042-.034.041-.036.041-.037.041-.039.041-.04.041-.041.04-.043.04-.044.04-.045.04-.047.039-.048.039-.05.039-.051.039-.052.038-.053.038-.055.038-.055.038-.058.037-.058.037-.06.037-.06.036-.062.036-.064.036-.064.036-.066.035-.067.035-.068.035-.069.035-.07.034-.071.034-.073.033-.074.033-.15.066-.155.064-.16.063-.163.061-.168.06-.172.059-.175.057-.18.056-.183.054-.187.053-.191.051-.194.05-.198.048-.201.046-.205.045-.208.043-.211.041-.214.04-.217.038-.22.036-.223.034-.225.032-.229.031-.231.028-.233.027-.236.024-.239.023-.241.02-.242.019-.246.016-.247.015-.249.012-.251.01-.253.008-.255.005-.256.004-.258.001-.258-.001-.256-.004-.255-.005-.253-.008-.251-.01-.249-.012-.247-.015-.245-.016-.243-.019-.241-.02-.238-.023-.236-.024-.234-.027-.231-.028-.228-.031-.226-.032-.223-.034-.22-.036-.217-.038-.214-.04-.211-.041-.208-.043-.204-.045-.201-.046-.198-.048-.195-.05-.19-.051-.187-.053-.184-.054-.179-.056-.176-.057-.172-.059-.167-.06-.164-.061-.159-.063-.155-.064-.151-.066-.074-.033-.072-.033-.072-.034-.07-.034-.069-.035-.068-.035-.067-.035-.066-.035-.064-.036-.063-.036-.062-.036-.061-.036-.06-.037-.058-.037-.057-.037-.056-.038-.055-.038-.053-.038-.052-.038-.051-.039-.049-.039-.049-.039-.046-.039-.046-.04-.044-.04-.043-.04-.041-.04-.04-.041-.039-.041-.037-.041-.036-.041-.034-.041-.033-.042-.032-.042-.03-.042-.029-.042-.027-.042-.026-.043-.024-.043-.023-.043-.021-.043-.02-.043-.018-.044-.017-.043-.015-.044-.013-.044-.012-.044-.011-.045-.009-.044-.007-.045-.006-.045-.004-.045-.002-.045-.001-.045v-17l.001-.045.002-.045.004-.045.006-.045.007-.045.009-.044.011-.045.012-.044.013-.044.015-.044.017-.043.018-.044.02-.043.021-.043.023-.043.024-.043.026-.043.027-.042.029-.042.03-.042.032-.042.033-.042.034-.041.036-.041.037-.041.039-.041.04-.041.041-.04.043-.04.044-.04.046-.04.046-.039.049-.039.049-.039.051-.039.052-.038.053-.038.055-.038.056-.038.057-.037.058-.037.06-.037.061-.036.062-.036.063-.036.064-.036.066-.035.067-.035.068-.035.069-.035.07-.034.072-.034.072-.033.074-.033.151-.066.155-.064.159-.063.164-.061.167-.06.172-.059.176-.057.179-.056.184-.054.187-.053.19-.051.195-.05.198-.048.201-.046.204-.045.208-.043.211-.041.214-.04.217-.038.22-.036.223-.034.226-.032.228-.031.231-.028.234-.027.236-.024.238-.023.241-.02.243-.019.245-.016.247-.015.249-.012.251-.01.253-.008.255-.005.256-.004.258-.001.258.001zm-9.258 20.499v.01l.001.021.003.021.004.022.005.021.006.022.007.022.009.023.01.022.011.023.012.023.013.023.015.023.016.024.017.023.018.024.019.024.021.024.022.025.023.024.024.025.052.049.056.05.061.051.066.051.07.051.075.051.079.052.084.052.088.052.092.052.097.052.102.051.105.052.11.052.114.051.119.051.123.051.127.05.131.05.135.05.139.048.144.049.147.047.152.047.155.047.16.045.163.045.167.043.171.043.176.041.178.041.183.039.187.039.19.037.194.035.197.035.202.033.204.031.209.03.212.029.216.027.219.025.222.024.226.021.23.02.233.018.236.016.24.015.243.012.246.01.249.008.253.005.256.004.259.001.26-.001.257-.004.254-.005.25-.008.247-.011.244-.012.241-.014.237-.016.233-.018.231-.021.226-.021.224-.024.22-.026.216-.027.212-.028.21-.031.205-.031.202-.034.198-.034.194-.036.191-.037.187-.039.183-.04.179-.04.175-.042.172-.043.168-.044.163-.045.16-.046.155-.046.152-.047.148-.048.143-.049.139-.049.136-.05.131-.05.126-.05.123-.051.118-.052.114-.051.11-.052.106-.052.101-.052.096-.052.092-.052.088-.053.083-.051.079-.052.074-.052.07-.051.065-.051.06-.051.056-.05.051-.05.023-.024.023-.025.021-.024.02-.024.019-.024.018-.024.017-.024.015-.023.014-.024.013-.023.012-.023.01-.023.01-.022.008-.022.006-.022.006-.022.004-.022.004-.021.001-.021.001-.021v-4.127l-.077.055-.08.053-.083.054-.085.053-.087.052-.09.052-.093.051-.095.05-.097.05-.1.049-.102.049-.105.048-.106.047-.109.047-.111.046-.114.045-.115.045-.118.044-.12.043-.122.042-.124.042-.126.041-.128.04-.13.04-.132.038-.134.038-.135.037-.138.037-.139.035-.142.035-.143.034-.144.033-.147.032-.148.031-.15.03-.151.03-.153.029-.154.027-.156.027-.158.026-.159.025-.161.024-.162.023-.163.022-.165.021-.166.02-.167.019-.169.018-.169.017-.171.016-.173.015-.173.014-.175.013-.175.012-.177.011-.178.01-.179.008-.179.008-.181.006-.182.005-.182.004-.184.003-.184.002h-.37l-.184-.002-.184-.003-.182-.004-.182-.005-.181-.006-.179-.008-.179-.008-.178-.01-.176-.011-.176-.012-.175-.013-.173-.014-.172-.015-.171-.016-.17-.017-.169-.018-.167-.019-.166-.02-.165-.021-.163-.022-.162-.023-.161-.024-.159-.025-.157-.026-.156-.027-.155-.027-.153-.029-.151-.03-.15-.03-.148-.031-.146-.032-.145-.033-.143-.034-.141-.035-.14-.035-.137-.037-.136-.037-.134-.038-.132-.038-.13-.04-.128-.04-.126-.041-.124-.042-.122-.042-.12-.044-.117-.043-.116-.045-.113-.045-.112-.046-.109-.047-.106-.047-.105-.048-.102-.049-.1-.049-.097-.05-.095-.05-.093-.052-.09-.051-.087-.052-.085-.053-.083-.054-.08-.054-.077-.054v4.127zm0-5.654v.011l.001.021.003.021.004.021.005.022.006.022.007.022.009.022.01.022.011.023.012.023.013.023.015.024.016.023.017.024.018.024.019.024.021.024.022.024.023.025.024.024.052.05.056.05.061.05.066.051.07.051.075.052.079.051.084.052.088.052.092.052.097.052.102.052.105.052.11.051.114.051.119.052.123.05.127.051.131.05.135.049.139.049.144.048.147.048.152.047.155.046.16.045.163.045.167.044.171.042.176.042.178.04.183.04.187.038.19.037.194.036.197.034.202.033.204.032.209.03.212.028.216.027.219.025.222.024.226.022.23.02.233.018.236.016.24.014.243.012.246.01.249.008.253.006.256.003.259.001.26-.001.257-.003.254-.006.25-.008.247-.01.244-.012.241-.015.237-.016.233-.018.231-.02.226-.022.224-.024.22-.025.216-.027.212-.029.21-.03.205-.032.202-.033.198-.035.194-.036.191-.037.187-.039.183-.039.179-.041.175-.042.172-.043.168-.044.163-.045.16-.045.155-.047.152-.047.148-.048.143-.048.139-.05.136-.049.131-.05.126-.051.123-.051.118-.051.114-.052.11-.052.106-.052.101-.052.096-.052.092-.052.088-.052.083-.052.079-.052.074-.051.07-.052.065-.051.06-.05.056-.051.051-.049.023-.025.023-.024.021-.025.02-.024.019-.024.018-.024.017-.024.015-.023.014-.023.013-.024.012-.022.01-.023.01-.023.008-.022.006-.022.006-.022.004-.021.004-.022.001-.021.001-.021v-4.139l-.077.054-.08.054-.083.054-.085.052-.087.053-.09.051-.093.051-.095.051-.097.05-.1.049-.102.049-.105.048-.106.047-.109.047-.111.046-.114.045-.115.044-.118.044-.12.044-.122.042-.124.042-.126.041-.128.04-.13.039-.132.039-.134.038-.135.037-.138.036-.139.036-.142.035-.143.033-.144.033-.147.033-.148.031-.15.03-.151.03-.153.028-.154.028-.156.027-.158.026-.159.025-.161.024-.162.023-.163.022-.165.021-.166.02-.167.019-.169.018-.169.017-.171.016-.173.015-.173.014-.175.013-.175.012-.177.011-.178.009-.179.009-.179.007-.181.007-.182.005-.182.004-.184.003-.184.002h-.37l-.184-.002-.184-.003-.182-.004-.182-.005-.181-.007-.179-.007-.179-.009-.178-.009-.176-.011-.176-.012-.175-.013-.173-.014-.172-.015-.171-.016-.17-.017-.169-.018-.167-.019-.166-.02-.165-.021-.163-.022-.162-.023-.161-.024-.159-.025-.157-.026-.156-.027-.155-.028-.153-.028-.151-.03-.15-.03-.148-.031-.146-.033-.145-.033-.143-.033-.141-.035-.14-.036-.137-.036-.136-.037-.134-.038-.132-.039-.13-.039-.128-.04-.126-.041-.124-.042-.122-.043-.12-.043-.117-.044-.116-.044-.113-.046-.112-.046-.109-.046-.106-.047-.105-.048-.102-.049-.1-.049-.097-.05-.095-.051-.093-.051-.09-.051-.087-.053-.085-.052-.083-.054-.08-.054-.077-.054v4.139zm0-5.666v.011l.001.02.003.022.004.021.005.022.006.021.007.022.009.023.01.022.011.023.012.023.013.023.015.023.016.024.017.024.018.023.019.024.021.025.022.024.023.024.024.025.052.05.056.05.061.05.066.051.07.051.075.052.079.051.084.052.088.052.092.052.097.052.102.052.105.051.11.052.114.051.119.051.123.051.127.05.131.05.135.05.139.049.144.048.147.048.152.047.155.046.16.045.163.045.167.043.171.043.176.042.178.04.183.04.187.038.19.037.194.036.197.034.202.033.204.032.209.03.212.028.216.027.219.025.222.024.226.021.23.02.233.018.236.017.24.014.243.012.246.01.249.008.253.006.256.003.259.001.26-.001.257-.003.254-.006.25-.008.247-.01.244-.013.241-.014.237-.016.233-.018.231-.02.226-.022.224-.024.22-.025.216-.027.212-.029.21-.03.205-.032.202-.033.198-.035.194-.036.191-.037.187-.039.183-.039.179-.041.175-.042.172-.043.168-.044.163-.045.16-.045.155-.047.152-.047.148-.048.143-.049.139-.049.136-.049.131-.051.126-.05.123-.051.118-.052.114-.051.11-.052.106-.052.101-.052.096-.052.092-.052.088-.052.083-.052.079-.052.074-.052.07-.051.065-.051.06-.051.056-.05.051-.049.023-.025.023-.025.021-.024.02-.024.019-.024.018-.024.017-.024.015-.023.014-.024.013-.023.012-.023.01-.022.01-.023.008-.022.006-.022.006-.022.004-.022.004-.021.001-.021.001-.021v-4.153l-.077.054-.08.054-.083.053-.085.053-.087.053-.09.051-.093.051-.095.051-.097.05-.1.049-.102.048-.105.048-.106.048-.109.046-.111.046-.114.046-.115.044-.118.044-.12.043-.122.043-.124.042-.126.041-.128.04-.13.039-.132.039-.134.038-.135.037-.138.036-.139.036-.142.034-.143.034-.144.033-.147.032-.148.032-.15.03-.151.03-.153.028-.154.028-.156.027-.158.026-.159.024-.161.024-.162.023-.163.023-.165.021-.166.02-.167.019-.169.018-.169.017-.171.016-.173.015-.173.014-.175.013-.175.012-.177.01-.178.01-.179.009-.179.007-.181.006-.182.006-.182.004-.184.003-.184.001-.185.001-.185-.001-.184-.001-.184-.003-.182-.004-.182-.006-.181-.006-.179-.007-.179-.009-.178-.01-.176-.01-.176-.012-.175-.013-.173-.014-.172-.015-.171-.016-.17-.017-.169-.018-.167-.019-.166-.02-.165-.021-.163-.023-.162-.023-.161-.024-.159-.024-.157-.026-.156-.027-.155-.028-.153-.028-.151-.03-.15-.03-.148-.032-.146-.032-.145-.033-.143-.034-.141-.034-.14-.036-.137-.036-.136-.037-.134-.038-.132-.039-.13-.039-.128-.041-.126-.041-.124-.041-.122-.043-.12-.043-.117-.044-.116-.044-.113-.046-.112-.046-.109-.046-.106-.048-.105-.048-.102-.048-.1-.05-.097-.049-.095-.051-.093-.051-.09-.052-.087-.052-.085-.053-.083-.053-.08-.054-.077-.054v4.153zm8.74-8.179l-.257.004-.254.005-.25.008-.247.011-.244.012-.241.014-.237.016-.233.018-.231.021-.226.022-.224.023-.22.026-.216.027-.212.028-.21.031-.205.032-.202.033-.198.034-.194.036-.191.038-.187.038-.183.04-.179.041-.175.042-.172.043-.168.043-.163.045-.16.046-.155.046-.152.048-.148.048-.143.048-.139.049-.136.05-.131.05-.126.051-.123.051-.118.051-.114.052-.11.052-.106.052-.101.052-.096.052-.092.052-.088.052-.083.052-.079.052-.074.051-.07.052-.065.051-.06.05-.056.05-.051.05-.023.025-.023.024-.021.024-.02.025-.019.024-.018.024-.017.023-.015.024-.014.023-.013.023-.012.023-.01.023-.01.022-.008.022-.006.023-.006.021-.004.022-.004.021-.001.021-.001.021.001.021.001.021.004.021.004.022.006.021.006.023.008.022.01.022.01.023.012.023.013.023.014.023.015.024.017.023.018.024.019.024.02.025.021.024.023.024.023.025.051.05.056.05.06.05.065.051.07.052.074.051.079.052.083.052.088.052.092.052.096.052.101.052.106.052.11.052.114.052.118.051.123.051.126.051.131.05.136.05.139.049.143.048.148.048.152.048.155.046.16.046.163.045.168.043.172.043.175.042.179.041.183.04.187.038.191.038.194.036.198.034.202.033.205.032.21.031.212.028.216.027.22.026.224.023.226.022.231.021.233.018.237.016.241.014.244.012.247.011.25.008.254.005.257.004.26.001.26-.001.257-.004.254-.005.25-.008.247-.011.244-.012.241-.014.237-.016.233-.018.231-.021.226-.022.224-.023.22-.026.216-.027.212-.028.21-.031.205-.032.202-.033.198-.034.194-.036.191-.038.187-.038.183-.04.179-.041.175-.042.172-.043.168-.043.163-.045.16-.046.155-.046.152-.048.148-.048.143-.048.139-.049.136-.05.131-.05.126-.051.123-.051.118-.051.114-.052.11-.052.106-.052.101-.052.096-.052.092-.052.088-.052.083-.052.079-.052.074-.051.07-.052.065-.051.06-.05.056-.05.051-.05.023-.025.023-.024.021-.024.02-.025.019-.024.018-.024.017-.023.015-.024.014-.023.013-.023.012-.023.01-.023.01-.022.008-.022.006-.023.006-.021.004-.022.004-.021.001-.021.001-.021-.001-.021-.001-.021-.004-.021-.004-.022-.006-.021-.006-.023-.008-.022-.01-.022-.01-.023-.012-.023-.013-.023-.014-.023-.015-.024-.017-.023-.018-.024-.019-.024-.02-.025-.021-.024-.023-.024-.023-.025-.051-.05-.056-.05-.06-.05-.065-.051-.07-.052-.074-.051-.079-.052-.083-.052-.088-.052-.092-.052-.096-.052-.101-.052-.106-.052-.11-.052-.114-.052-.118-.051-.123-.051-.126-.051-.131-.05-.136-.05-.139-.049-.143-.048-.148-.048-.152-.048-.155-.046-.16-.046-.163-.045-.168-.043-.172-.043-.175-.042-.179-.041-.183-.04-.187-.038-.191-.038-.194-.036-.198-.034-.202-.033-.205-.032-.21-.031-.212-.028-.216-.027-.22-.026-.224-.023-.226-.022-.231-.021-.233-.018-.237-.016-.241-.014-.244-.012-.247-.011-.25-.008-.254-.005-.257-.004-.26-.001-.26.001z"
  );
}, u0 = function(t) {
  t.append("defs").append("symbol").attr("id", "computer").attr("width", "24").attr("height", "24").append("path").attr("transform", "scale(.5)").attr(
    "d",
    "M2 2v13h20v-13h-20zm18 11h-16v-9h16v9zm-10.228 6l.466-1h3.524l.467 1h-4.457zm14.228 3h-24l2-6h2.104l-1.33 4h18.45l-1.297-4h2.073l2 6zm-5-10h-14v-7h14v7z"
  );
}, f0 = function(t) {
  t.append("defs").append("symbol").attr("id", "clock").attr("width", "24").attr("height", "24").append("path").attr("transform", "scale(.5)").attr(
    "d",
    "M12 2c5.514 0 10 4.486 10 10s-4.486 10-10 10-10-4.486-10-10 4.486-10 10-10zm0-2c-6.627 0-12 5.373-12 12s5.373 12 12 12 12-5.373 12-12-5.373-12-12-12zm5.848 12.459c.202.038.202.333.001.372-1.907.361-6.045 1.111-6.547 1.111-.719 0-1.301-.582-1.301-1.301 0-.512.77-5.447 1.125-7.445.034-.192.312-.181.343.014l.985 6.238 5.394 1.011z"
  );
}, g0 = function(t) {
  t.append("defs").append("marker").attr("id", "arrowhead").attr("refX", 7.9).attr("refY", 5).attr("markerUnits", "userSpaceOnUse").attr("markerWidth", 12).attr("markerHeight", 12).attr("orient", "auto").append("path").attr("d", "M 0 0 L 10 5 L 0 10 z");
}, x0 = function(t) {
  t.append("defs").append("marker").attr("id", "filled-head").attr("refX", 15.5).attr("refY", 7).attr("markerWidth", 20).attr("markerHeight", 28).attr("orient", "auto").append("path").attr("d", "M 18,7 L9,13 L14,7 L9,1 Z");
}, T0 = function(t) {
  t.append("defs").append("marker").attr("id", "sequencenumber").attr("refX", 15).attr("refY", 15).attr("markerWidth", 60).attr("markerHeight", 40).attr("orient", "auto").append("circle").attr("cx", 15).attr("cy", 15).attr("r", 6);
}, y0 = function(t) {
  t.append("defs").append("marker").attr("id", "crosshead").attr("markerWidth", 15).attr("markerHeight", 8).attr("orient", "auto").attr("refX", 4).attr("refY", 4.5).append("path").attr("fill", "none").attr("stroke", "#000000").style("stroke-dasharray", "0, 0").attr("stroke-width", "1pt").attr("d", "M 1,2 L 6,7 M 6,2 L 1,7");
}, le = function() {
  return {
    x: 0,
    y: 0,
    fill: void 0,
    anchor: void 0,
    style: "#666",
    width: void 0,
    height: void 0,
    textMargin: 0,
    rx: 0,
    ry: 0,
    tspan: !0,
    valign: void 0
  };
}, E0 = function() {
  return {
    x: 0,
    y: 0,
    fill: "#EDF2AE",
    stroke: "#666",
    width: 100,
    anchor: "start",
    height: 100,
    rx: 0,
    ry: 0
  };
}, qt = /* @__PURE__ */ function() {
  function t(r, a, l, h, p, i, g) {
    const E = a.append("text").attr("x", l + p / 2).attr("y", h + i / 2 + 5).style("text-anchor", "middle").text(r);
    s(E, g);
  }
  function e(r, a, l, h, p, i, g, E) {
    const { actorFontSize: u, actorFontFamily: x, actorFontWeight: m } = E, [P, A] = Qt(u), D = r.split(v.lineBreakRegex);
    for (let S = 0; S < D.length; S++) {
      const W = S * P - P * (D.length - 1) / 2, M = a.append("text").attr("x", l + p / 2).attr("y", h).style("text-anchor", "middle").style("font-size", A).style("font-weight", m).style("font-family", x);
      M.append("tspan").attr("x", l + p / 2).attr("dy", W).text(D[S]), M.attr("y", h + i / 2).attr("dominant-baseline", "central").attr("alignment-baseline", "central"), s(M, g);
    }
  }
  function o(r, a, l, h, p, i, g, E) {
    const u = a.append("switch"), m = u.append("foreignObject").attr("x", l).attr("y", h).attr("width", p).attr("height", i).append("xhtml:div").style("display", "table").style("height", "100%").style("width", "100%");
    m.append("div").style("display", "table-cell").style("text-align", "center").style("vertical-align", "middle").text(r), e(r, u, l, h, p, i, g, E), s(m, g);
  }
  function s(r, a) {
    for (const l in a)
      a.hasOwnProperty(l) && r.attr(l, a[l]);
  }
  return function(r) {
    return r.textPlacement === "fo" ? o : r.textPlacement === "old" ? t : e;
  };
}(), b0 = /* @__PURE__ */ function() {
  function t(r, a, l, h, p, i, g) {
    const E = a.append("text").attr("x", l).attr("y", h).style("text-anchor", "start").text(r);
    s(E, g);
  }
  function e(r, a, l, h, p, i, g, E) {
    const { actorFontSize: u, actorFontFamily: x, actorFontWeight: m } = E, P = r.split(v.lineBreakRegex);
    for (let A = 0; A < P.length; A++) {
      const D = A * u - u * (P.length - 1) / 2, S = a.append("text").attr("x", l).attr("y", h).style("text-anchor", "start").style("font-size", u).style("font-weight", m).style("font-family", x);
      S.append("tspan").attr("x", l).attr("dy", D).text(P[A]), S.attr("y", h + i / 2).attr("dominant-baseline", "central").attr("alignment-baseline", "central"), s(S, g);
    }
  }
  function o(r, a, l, h, p, i, g, E) {
    const u = a.append("switch"), m = u.append("foreignObject").attr("x", l).attr("y", h).attr("width", p).attr("height", i).append("xhtml:div").style("display", "table").style("height", "100%").style("width", "100%");
    m.append("div").style("display", "table-cell").style("text-align", "center").style("vertical-align", "middle").text(r), e(r, u, l, h, p, i, g, E), s(m, g);
  }
  function s(r, a) {
    for (const l in a)
      a.hasOwnProperty(l) && r.attr(l, a[l]);
  }
  return function(r) {
    return r.textPlacement === "fo" ? o : r.textPlacement === "old" ? t : e;
  };
}(), V = {
  drawRect: Wt,
  drawText: yt,
  drawLabel: ne,
  drawActor: o0,
  drawBox: c0,
  drawPopup: r0,
  anchorElement: l0,
  drawActivation: h0,
  drawLoop: d0,
  drawBackgroundRect: ce,
  insertArrowHead: g0,
  insertArrowFilledHead: x0,
  insertSequenceNumber: T0,
  insertArrowCrossHead: y0,
  insertDatabaseIcon: p0,
  insertComputerIcon: u0,
  insertClockIcon: f0,
  getTextObj: le,
  getNoteRect: E0,
  fixLifeLineHeights: oe,
  sanitizeUrl: Zt.sanitizeUrl
};
let n = {};
const f = {
  data: {
    startx: void 0,
    stopx: void 0,
    starty: void 0,
    stopy: void 0
  },
  verticalPos: 0,
  sequenceItems: [],
  activations: [],
  models: {
    getHeight: function() {
      return Math.max.apply(
        null,
        this.actors.length === 0 ? [0] : this.actors.map((t) => t.height || 0)
      ) + (this.loops.length === 0 ? 0 : this.loops.map((t) => t.height || 0).reduce((t, e) => t + e)) + (this.messages.length === 0 ? 0 : this.messages.map((t) => t.height || 0).reduce((t, e) => t + e)) + (this.notes.length === 0 ? 0 : this.notes.map((t) => t.height || 0).reduce((t, e) => t + e));
    },
    clear: function() {
      this.actors = [], this.boxes = [], this.loops = [], this.messages = [], this.notes = [];
    },
    addBox: function(t) {
      this.boxes.push(t);
    },
    addActor: function(t) {
      this.actors.push(t);
    },
    addLoop: function(t) {
      this.loops.push(t);
    },
    addMessage: function(t) {
      this.messages.push(t);
    },
    addNote: function(t) {
      this.notes.push(t);
    },
    lastActor: function() {
      return this.actors[this.actors.length - 1];
    },
    lastLoop: function() {
      return this.loops[this.loops.length - 1];
    },
    lastMessage: function() {
      return this.messages[this.messages.length - 1];
    },
    lastNote: function() {
      return this.notes[this.notes.length - 1];
    },
    actors: [],
    boxes: [],
    loops: [],
    messages: [],
    notes: []
  },
  init: function() {
    this.sequenceItems = [], this.activations = [], this.models.clear(), this.data = {
      startx: void 0,
      stopx: void 0,
      starty: void 0,
      stopy: void 0
    }, this.verticalPos = 0, de(lt());
  },
  updateVal: function(t, e, o, s) {
    t[e] === void 0 ? t[e] = o : t[e] = s(o, t[e]);
  },
  updateBounds: function(t, e, o, s) {
    const r = this;
    let a = 0;
    function l(h) {
      return function(i) {
        a++;
        const g = r.sequenceItems.length - a + 1;
        r.updateVal(i, "starty", e - g * n.boxMargin, Math.min), r.updateVal(i, "stopy", s + g * n.boxMargin, Math.max), r.updateVal(f.data, "startx", t - g * n.boxMargin, Math.min), r.updateVal(f.data, "stopx", o + g * n.boxMargin, Math.max), h !== "activation" && (r.updateVal(i, "startx", t - g * n.boxMargin, Math.min), r.updateVal(i, "stopx", o + g * n.boxMargin, Math.max), r.updateVal(f.data, "starty", e - g * n.boxMargin, Math.min), r.updateVal(f.data, "stopy", s + g * n.boxMargin, Math.max));
      };
    }
    this.sequenceItems.forEach(l()), this.activations.forEach(l("activation"));
  },
  insert: function(t, e, o, s) {
    const r = v.getMin(t, o), a = v.getMax(t, o), l = v.getMin(e, s), h = v.getMax(e, s);
    this.updateVal(f.data, "startx", r, Math.min), this.updateVal(f.data, "starty", l, Math.min), this.updateVal(f.data, "stopx", a, Math.max), this.updateVal(f.data, "stopy", h, Math.max), this.updateBounds(r, l, a, h);
  },
  newActivation: function(t, e, o) {
    const s = o[t.from.actor], r = It(t.from.actor).length || 0, a = s.x + s.width / 2 + (r - 1) * n.activationWidth / 2;
    this.activations.push({
      startx: a,
      starty: this.verticalPos + 2,
      stopx: a + n.activationWidth,
      stopy: void 0,
      actor: t.from.actor,
      anchored: V.anchorElement(e)
    });
  },
  endActivation: function(t) {
    const e = this.activations.map(function(o) {
      return o.actor;
    }).lastIndexOf(t.from.actor);
    return this.activations.splice(e, 1)[0];
  },
  createLoop: function(t = { message: void 0, wrap: !1, width: void 0 }, e) {
    return {
      startx: void 0,
      starty: this.verticalPos,
      stopx: void 0,
      stopy: void 0,
      title: t.message,
      wrap: t.wrap,
      width: t.width,
      height: 0,
      fill: e
    };
  },
  newLoop: function(t = { message: void 0, wrap: !1, width: void 0 }, e) {
    this.sequenceItems.push(this.createLoop(t, e));
  },
  endLoop: function() {
    return this.sequenceItems.pop();
  },
  isLoopOverlap: function() {
    return this.sequenceItems.length ? this.sequenceItems[this.sequenceItems.length - 1].overlap : !1;
  },
  addSectionToLoop: function(t) {
    const e = this.sequenceItems.pop();
    e.sections = e.sections || [], e.sectionTitles = e.sectionTitles || [], e.sections.push({ y: f.getVerticalPos(), height: 0 }), e.sectionTitles.push(t), this.sequenceItems.push(e);
  },
  saveVerticalPos: function() {
    this.isLoopOverlap() && (this.savedVerticalPos = this.verticalPos);
  },
  resetVerticalPos: function() {
    this.isLoopOverlap() && (this.verticalPos = this.savedVerticalPos);
  },
  bumpVerticalPos: function(t) {
    this.verticalPos = this.verticalPos + t, this.data.stopy = v.getMax(this.data.stopy, this.verticalPos);
  },
  getVerticalPos: function() {
    return this.verticalPos;
  },
  getBounds: function() {
    return { bounds: this.data, models: this.models };
  }
}, m0 = function(t, e) {
  f.bumpVerticalPos(n.boxMargin), e.height = n.boxMargin, e.starty = f.getVerticalPos();
  const o = Lt();
  o.x = e.startx, o.y = e.starty, o.width = e.width || n.width, o.class = "note";
  const s = t.append("g"), r = V.drawRect(s, o), a = Yt();
  a.x = e.startx, a.y = e.starty, a.width = o.width, a.dy = "1em", a.text = e.message, a.class = "noteText", a.fontFamily = n.noteFontFamily, a.fontSize = n.noteFontSize, a.fontWeight = n.noteFontWeight, a.anchor = n.noteAlign, a.textMargin = n.noteMargin, a.valign = "center";
  const l = yt(s, a), h = Math.round(
    l.map((p) => (p._groups || p)[0][0].getBBox().height).reduce((p, i) => p + i)
  );
  r.attr("height", h + 2 * n.noteMargin), e.height += h + 2 * n.noteMargin, f.bumpVerticalPos(h + 2 * n.noteMargin), e.stopy = e.starty + h + 2 * n.noteMargin, e.stopx = e.startx + o.width, f.insert(e.startx, e.starty, e.stopx, e.stopy), f.models.addNote(e);
}, gt = (t) => ({
  fontFamily: t.messageFontFamily,
  fontSize: t.messageFontSize,
  fontWeight: t.messageFontWeight
}), Tt = (t) => ({
  fontFamily: t.noteFontFamily,
  fontSize: t.noteFontSize,
  fontWeight: t.noteFontWeight
}), Ot = (t) => ({
  fontFamily: t.actorFontFamily,
  fontSize: t.actorFontSize,
  fontWeight: t.actorFontWeight
});
function w0(t, e) {
  f.bumpVerticalPos(10);
  const { startx: o, stopx: s, message: r } = e, a = v.splitBreaks(r).length, l = B.calculateTextDimensions(r, gt(n)), h = l.height / a;
  e.height += h, f.bumpVerticalPos(h);
  let p, i = l.height - 10;
  const g = l.width;
  if (o === s) {
    p = f.getVerticalPos() + i, n.rightAngles || (i += n.boxMargin, p = f.getVerticalPos() + i), i += 30;
    const E = v.getMax(g / 2, n.width / 2);
    f.insert(
      o - E,
      f.getVerticalPos() - 10 + i,
      s + E,
      f.getVerticalPos() + 30 + i
    );
  } else
    i += n.boxMargin, p = f.getVerticalPos() + i, f.insert(o, p - 10, s, p);
  return f.bumpVerticalPos(i), e.height += i, e.stopy = e.starty + e.height, f.insert(e.fromBounds, e.starty, e.toBounds, e.stopy), p;
}
const v0 = function(t, e, o, s) {
  const { startx: r, stopx: a, starty: l, message: h, type: p, sequenceIndex: i, sequenceVisible: g } = e, E = B.calculateTextDimensions(h, gt(n)), u = Yt();
  u.x = r, u.y = l + 10, u.width = a - r, u.class = "messageText", u.dy = "1em", u.text = h, u.fontFamily = n.messageFontFamily, u.fontSize = n.messageFontSize, u.fontWeight = n.messageFontWeight, u.anchor = n.messageAlign, u.valign = "center", u.textMargin = n.wrapPadding, u.tspan = !1, yt(t, u);
  const x = E.width;
  let m;
  r === a ? n.rightAngles ? m = t.append("path").attr(
    "d",
    `M  ${r},${o} H ${r + v.getMax(n.width / 2, x / 2)} V ${o + 25} H ${r}`
  ) : m = t.append("path").attr(
    "d",
    "M " + r + "," + o + " C " + (r + 60) + "," + (o - 10) + " " + (r + 60) + "," + (o + 30) + " " + r + "," + (o + 20)
  ) : (m = t.append("line"), m.attr("x1", r), m.attr("y1", o), m.attr("x2", a), m.attr("y2", o)), p === s.db.LINETYPE.DOTTED || p === s.db.LINETYPE.DOTTED_CROSS || p === s.db.LINETYPE.DOTTED_POINT || p === s.db.LINETYPE.DOTTED_OPEN ? (m.style("stroke-dasharray", "3, 3"), m.attr("class", "messageLine1")) : m.attr("class", "messageLine0");
  let P = "";
  n.arrowMarkerAbsolute && (P = window.location.protocol + "//" + window.location.host + window.location.pathname + window.location.search, P = P.replace(/\(/g, "\\("), P = P.replace(/\)/g, "\\)")), m.attr("stroke-width", 2), m.attr("stroke", "none"), m.style("fill", "none"), (p === s.db.LINETYPE.SOLID || p === s.db.LINETYPE.DOTTED) && m.attr("marker-end", "url(" + P + "#arrowhead)"), (p === s.db.LINETYPE.SOLID_POINT || p === s.db.LINETYPE.DOTTED_POINT) && m.attr("marker-end", "url(" + P + "#filled-head)"), (p === s.db.LINETYPE.SOLID_CROSS || p === s.db.LINETYPE.DOTTED_CROSS) && m.attr("marker-end", "url(" + P + "#crosshead)"), (g || n.showSequenceNumbers) && (m.attr("marker-start", "url(" + P + "#sequencenumber)"), t.append("text").attr("x", r).attr("y", o + 4).attr("font-family", "sans-serif").attr("font-size", "12px").attr("text-anchor", "middle").attr("class", "sequenceNumber").text(i));
}, _0 = function(t, e, o, s, r, a, l) {
  let h = 0, p = 0, i, g = 0;
  for (const E of s) {
    const u = e[E], x = u.box;
    i && i != x && (f.models.addBox(i), p += n.boxMargin + i.margin), x && x != i && (x.x = h + p, x.y = r, p += x.margin), u.width = u.width || n.width, u.height = v.getMax(u.height || n.height, n.height), u.margin = u.margin || n.actorMargin, g = v.getMax(g, u.height), o[u.name] && (p += u.width / 2), u.x = h + p, u.starty = f.getVerticalPos(), f.insert(u.x, r, u.x + u.width, u.height), h += u.width + p, u.box && (u.box.width = h + x.margin - u.box.x), p = u.margin, i = u.box, f.models.addActor(u);
  }
  i && !l && f.models.addBox(i), f.bumpVerticalPos(g);
}, Bt = function(t, e, o, s) {
  if (s) {
    let r = 0;
    f.bumpVerticalPos(n.boxMargin * 2);
    for (const a of o) {
      const l = e[a];
      l.stopy || (l.stopy = f.getVerticalPos());
      const h = V.drawActor(t, l, n, !0);
      r = v.getMax(r, h);
    }
    f.bumpVerticalPos(r + n.boxMargin);
  } else
    for (const r of o) {
      const a = e[r];
      V.drawActor(t, a, n, !1);
    }
}, he = function(t, e, o, s) {
  let r = 0, a = 0;
  for (const l of o) {
    const h = e[l], p = I0(h), i = V.drawPopup(
      t,
      h,
      p,
      n,
      n.forceMenus,
      s
    );
    i.height > r && (r = i.height), i.width + h.x > a && (a = i.width + h.x);
  }
  return { maxHeight: r, maxWidth: a };
}, de = function(t) {
  ve(n, t), t.fontFamily && (n.actorFontFamily = n.noteFontFamily = n.messageFontFamily = t.fontFamily), t.fontSize && (n.actorFontSize = n.noteFontSize = n.messageFontSize = t.fontSize), t.fontWeight && (n.actorFontWeight = n.noteFontWeight = n.messageFontWeight = t.fontWeight);
}, It = function(t) {
  return f.activations.filter(function(e) {
    return e.actor === t;
  });
}, Gt = function(t, e) {
  const o = e[t], s = It(t), r = s.reduce(function(l, h) {
    return v.getMin(l, h.startx);
  }, o.x + o.width / 2 - 1), a = s.reduce(function(l, h) {
    return v.getMax(l, h.stopx);
  }, o.x + o.width / 2 + 1);
  return [r, a];
};
function st(t, e, o, s, r) {
  f.bumpVerticalPos(o);
  let a = s;
  if (e.id && e.message && t[e.id]) {
    const l = t[e.id].width, h = gt(n);
    e.message = B.wrapLabel(`[${e.message}]`, l - 2 * n.wrapPadding, h), e.width = l, e.wrap = !0;
    const p = B.calculateTextDimensions(e.message, h), i = v.getMax(p.height, n.labelBoxHeight);
    a = s + i, K.debug(`${i} - ${e.message}`);
  }
  r(e), f.bumpVerticalPos(a);
}
function k0(t, e, o, s, r, a, l) {
  function h(i, g) {
    i.x < r[t.from].x ? (f.insert(
      e.stopx - g,
      e.starty,
      e.startx,
      e.stopy + i.height / 2 + n.noteMargin
    ), e.stopx = e.stopx + g) : (f.insert(
      e.startx,
      e.starty,
      e.stopx + g,
      e.stopy + i.height / 2 + n.noteMargin
    ), e.stopx = e.stopx - g);
  }
  function p(i, g) {
    i.x < r[t.to].x ? (f.insert(
      e.startx - g,
      e.starty,
      e.stopx,
      e.stopy + i.height / 2 + n.noteMargin
    ), e.startx = e.startx + g) : (f.insert(
      e.stopx,
      e.starty,
      e.startx + g,
      e.stopy + i.height / 2 + n.noteMargin
    ), e.startx = e.startx - g);
  }
  if (a[t.to] == s) {
    const i = r[t.to], g = i.type == "actor" ? ut / 2 + 3 : i.width / 2 + 3;
    h(i, g), i.starty = o - i.height / 2, f.bumpVerticalPos(i.height / 2);
  } else if (l[t.from] == s) {
    const i = r[t.from];
    if (n.mirrorActors) {
      const g = i.type == "actor" ? ut / 2 : i.width / 2;
      p(i, g);
    }
    i.stopy = o - i.height / 2, f.bumpVerticalPos(i.height / 2);
  } else if (l[t.to] == s) {
    const i = r[t.to];
    if (n.mirrorActors) {
      const g = i.type == "actor" ? ut / 2 + 3 : i.width / 2 + 3;
      h(i, g);
    }
    i.stopy = o - i.height / 2, f.bumpVerticalPos(i.height / 2);
  }
}
const P0 = function(t, e, o, s) {
  const { securityLevel: r, sequence: a } = lt();
  n = a;
  let l;
  r === "sandbox" && (l = kt("#i" + e));
  const h = r === "sandbox" ? kt(l.nodes()[0].contentDocument.body) : kt("body"), p = r === "sandbox" ? l.nodes()[0].contentDocument : document;
  f.init(), K.debug(s.db);
  const i = r === "sandbox" ? h.select(`[id="${e}"]`) : kt(`[id="${e}"]`), g = s.db.getActors(), E = s.db.getCreatedActors(), u = s.db.getDestroyedActors(), x = s.db.getBoxes();
  let m = s.db.getActorKeys();
  const P = s.db.getMessages(), A = s.db.getDiagramTitle(), D = s.db.hasAtLeastOneBox(), S = s.db.hasAtLeastOneBoxWithTitle(), W = L0(g, P, s);
  if (n.height = A0(g, W, x), V.insertComputerIcon(i), V.insertDatabaseIcon(i), V.insertClockIcon(i), D && (f.bumpVerticalPos(n.boxMargin), S && f.bumpVerticalPos(x[0].textMaxHeight)), n.hideUnusedParticipants === !0) {
    const y = /* @__PURE__ */ new Set();
    P.forEach((_) => {
      y.add(_.from), y.add(_.to);
    }), m = m.filter((_) => y.has(_));
  }
  _0(i, g, E, m, 0, P, !1);
  const M = M0(P, g, W, s);
  V.insertArrowHead(i), V.insertArrowCrossHead(i), V.insertArrowFilledHead(i), V.insertSequenceNumber(i);
  function tt(y, _) {
    const I = f.endActivation(y);
    I.starty + 18 > _ && (I.starty = _ - 6, _ += 12), V.drawActivation(
      i,
      I,
      _,
      n,
      It(y.from.actor).length
    ), f.insert(I.startx, _ - 10, I.stopx, _);
  }
  let q = 1, X = 1;
  const Z = [], z = [];
  P.forEach(function(y, _) {
    let I, ht, et;
    switch (y.type) {
      case s.db.LINETYPE.NOTE:
        f.resetVerticalPos(), ht = y.noteModel, m0(i, ht);
        break;
      case s.db.LINETYPE.ACTIVE_START:
        f.newActivation(y, i, g);
        break;
      case s.db.LINETYPE.ACTIVE_END:
        tt(y, f.getVerticalPos());
        break;
      case s.db.LINETYPE.LOOP_START:
        st(
          M,
          y,
          n.boxMargin,
          n.boxMargin + n.boxTextMargin,
          (N) => f.newLoop(N)
        );
        break;
      case s.db.LINETYPE.LOOP_END:
        I = f.endLoop(), V.drawLoop(i, I, "loop", n), f.bumpVerticalPos(I.stopy - f.getVerticalPos()), f.models.addLoop(I);
        break;
      case s.db.LINETYPE.RECT_START:
        st(
          M,
          y,
          n.boxMargin,
          n.boxMargin,
          (N) => f.newLoop(void 0, N.message)
        );
        break;
      case s.db.LINETYPE.RECT_END:
        I = f.endLoop(), z.push(I), f.models.addLoop(I), f.bumpVerticalPos(I.stopy - f.getVerticalPos());
        break;
      case s.db.LINETYPE.OPT_START:
        st(
          M,
          y,
          n.boxMargin,
          n.boxMargin + n.boxTextMargin,
          (N) => f.newLoop(N)
        );
        break;
      case s.db.LINETYPE.OPT_END:
        I = f.endLoop(), V.drawLoop(i, I, "opt", n), f.bumpVerticalPos(I.stopy - f.getVerticalPos()), f.models.addLoop(I);
        break;
      case s.db.LINETYPE.ALT_START:
        st(
          M,
          y,
          n.boxMargin,
          n.boxMargin + n.boxTextMargin,
          (N) => f.newLoop(N)
        );
        break;
      case s.db.LINETYPE.ALT_ELSE:
        st(
          M,
          y,
          n.boxMargin + n.boxTextMargin,
          n.boxMargin,
          (N) => f.addSectionToLoop(N)
        );
        break;
      case s.db.LINETYPE.ALT_END:
        I = f.endLoop(), V.drawLoop(i, I, "alt", n), f.bumpVerticalPos(I.stopy - f.getVerticalPos()), f.models.addLoop(I);
        break;
      case s.db.LINETYPE.PAR_START:
      case s.db.LINETYPE.PAR_OVER_START:
        st(
          M,
          y,
          n.boxMargin,
          n.boxMargin + n.boxTextMargin,
          (N) => f.newLoop(N)
        ), f.saveVerticalPos();
        break;
      case s.db.LINETYPE.PAR_AND:
        st(
          M,
          y,
          n.boxMargin + n.boxTextMargin,
          n.boxMargin,
          (N) => f.addSectionToLoop(N)
        );
        break;
      case s.db.LINETYPE.PAR_END:
        I = f.endLoop(), V.drawLoop(i, I, "par", n), f.bumpVerticalPos(I.stopy - f.getVerticalPos()), f.models.addLoop(I);
        break;
      case s.db.LINETYPE.AUTONUMBER:
        q = y.message.start || q, X = y.message.step || X, y.message.visible ? s.db.enableSequenceNumbers() : s.db.disableSequenceNumbers();
        break;
      case s.db.LINETYPE.CRITICAL_START:
        st(
          M,
          y,
          n.boxMargin,
          n.boxMargin + n.boxTextMargin,
          (N) => f.newLoop(N)
        );
        break;
      case s.db.LINETYPE.CRITICAL_OPTION:
        st(
          M,
          y,
          n.boxMargin + n.boxTextMargin,
          n.boxMargin,
          (N) => f.addSectionToLoop(N)
        );
        break;
      case s.db.LINETYPE.CRITICAL_END:
        I = f.endLoop(), V.drawLoop(i, I, "critical", n), f.bumpVerticalPos(I.stopy - f.getVerticalPos()), f.models.addLoop(I);
        break;
      case s.db.LINETYPE.BREAK_START:
        st(
          M,
          y,
          n.boxMargin,
          n.boxMargin + n.boxTextMargin,
          (N) => f.newLoop(N)
        );
        break;
      case s.db.LINETYPE.BREAK_END:
        I = f.endLoop(), V.drawLoop(i, I, "break", n), f.bumpVerticalPos(I.stopy - f.getVerticalPos()), f.models.addLoop(I);
        break;
      default:
        try {
          et = y.msgModel, et.starty = f.getVerticalPos(), et.sequenceIndex = q, et.sequenceVisible = s.db.showSequenceNumbers();
          const N = w0(i, et);
          k0(
            y,
            et,
            N,
            _,
            g,
            E,
            u
          ), Z.push({ messageModel: et, lineStartY: N }), f.models.addMessage(et);
        } catch (N) {
          K.error("error while drawing message", N);
        }
    }
    [
      s.db.LINETYPE.SOLID_OPEN,
      s.db.LINETYPE.DOTTED_OPEN,
      s.db.LINETYPE.SOLID,
      s.db.LINETYPE.DOTTED,
      s.db.LINETYPE.SOLID_CROSS,
      s.db.LINETYPE.DOTTED_CROSS,
      s.db.LINETYPE.SOLID_POINT,
      s.db.LINETYPE.DOTTED_POINT
    ].includes(y.type) && (q = q + X);
  }), K.debug("createdActors", E), K.debug("destroyedActors", u), Bt(i, g, m, !1), Z.forEach((y) => v0(i, y.messageModel, y.lineStartY, s)), n.mirrorActors && Bt(i, g, m, !0), z.forEach((y) => V.drawBackgroundRect(i, y)), oe(i, g, m, n), f.models.boxes.forEach(function(y) {
    y.height = f.getVerticalPos() - y.y, f.insert(y.x, y.y, y.x + y.width, y.height), y.startx = y.x, y.starty = y.y, y.stopx = y.startx + y.width, y.stopy = y.starty + y.height, y.stroke = "rgb(0,0,0, 0.5)", V.drawBox(i, y, n);
  }), D && f.bumpVerticalPos(n.boxMargin);
  const F = he(i, g, m, p), { bounds: O } = f.getBounds();
  let G = O.stopy - O.starty;
  G < F.maxHeight && (G = F.maxHeight);
  let H = G + 2 * n.diagramMarginY;
  n.mirrorActors && (H = H - n.boxMargin + n.bottomMarginAdj);
  let J = O.stopx - O.startx;
  J < F.maxWidth && (J = F.maxWidth);
  const Q = J + 2 * n.diagramMarginX;
  A && i.append("text").text(A).attr("x", (O.stopx - O.startx) / 2 - 2 * n.diagramMarginX).attr("y", -25), _e(i, H, Q, n.useMaxWidth);
  const j = A ? 40 : 0;
  i.attr(
    "viewBox",
    O.startx - n.diagramMarginX + " -" + (n.diagramMarginY + j) + " " + Q + " " + (H + j)
  ), K.debug("models:", f.models);
};
function L0(t, e, o) {
  const s = {};
  return e.forEach(function(r) {
    if (t[r.to] && t[r.from]) {
      const a = t[r.to];
      if (r.placement === o.db.PLACEMENT.LEFTOF && !a.prevActor || r.placement === o.db.PLACEMENT.RIGHTOF && !a.nextActor)
        return;
      const l = r.placement !== void 0, h = !l, p = l ? Tt(n) : gt(n), i = r.wrap ? B.wrapLabel(r.message, n.width - 2 * n.wrapPadding, p) : r.message, E = B.calculateTextDimensions(i, p).width + 2 * n.wrapPadding;
      h && r.from === a.nextActor ? s[r.to] = v.getMax(
        s[r.to] || 0,
        E
      ) : h && r.from === a.prevActor ? s[r.from] = v.getMax(
        s[r.from] || 0,
        E
      ) : h && r.from === r.to ? (s[r.from] = v.getMax(
        s[r.from] || 0,
        E / 2
      ), s[r.to] = v.getMax(
        s[r.to] || 0,
        E / 2
      )) : r.placement === o.db.PLACEMENT.RIGHTOF ? s[r.from] = v.getMax(
        s[r.from] || 0,
        E
      ) : r.placement === o.db.PLACEMENT.LEFTOF ? s[a.prevActor] = v.getMax(
        s[a.prevActor] || 0,
        E
      ) : r.placement === o.db.PLACEMENT.OVER && (a.prevActor && (s[a.prevActor] = v.getMax(
        s[a.prevActor] || 0,
        E / 2
      )), a.nextActor && (s[r.from] = v.getMax(
        s[r.from] || 0,
        E / 2
      )));
    }
  }), K.debug("maxMessageWidthPerActor:", s), s;
}
const I0 = function(t) {
  let e = 0;
  const o = Ot(n);
  for (const s in t.links) {
    const a = B.calculateTextDimensions(s, o).width + 2 * n.wrapPadding + 2 * n.boxMargin;
    e < a && (e = a);
  }
  return e;
};
function A0(t, e, o) {
  let s = 0;
  Object.keys(t).forEach((a) => {
    const l = t[a];
    l.wrap && (l.description = B.wrapLabel(
      l.description,
      n.width - 2 * n.wrapPadding,
      Ot(n)
    ));
    const h = B.calculateTextDimensions(l.description, Ot(n));
    l.width = l.wrap ? n.width : v.getMax(n.width, h.width + 2 * n.wrapPadding), l.height = l.wrap ? v.getMax(h.height, n.height) : n.height, s = v.getMax(s, l.height);
  });
  for (const a in e) {
    const l = t[a];
    if (!l)
      continue;
    const h = t[l.nextActor];
    if (!h) {
      const E = e[a] + n.actorMargin - l.width / 2;
      l.margin = v.getMax(E, n.actorMargin);
      continue;
    }
    const i = e[a] + n.actorMargin - l.width / 2 - h.width / 2;
    l.margin = v.getMax(i, n.actorMargin);
  }
  let r = 0;
  return o.forEach((a) => {
    const l = gt(n);
    let h = a.actorKeys.reduce((g, E) => g += t[E].width + (t[E].margin || 0), 0);
    h -= 2 * n.boxTextMargin, a.wrap && (a.name = B.wrapLabel(a.name, h - 2 * n.wrapPadding, l));
    const p = B.calculateTextDimensions(a.name, l);
    r = v.getMax(p.height, r);
    const i = v.getMax(h, p.width + 2 * n.wrapPadding);
    if (a.margin = n.boxTextMargin, h < i) {
      const g = (i - h) / 2;
      a.margin += g;
    }
  }), o.forEach((a) => a.textMaxHeight = r), v.getMax(s, n.height);
}
const N0 = function(t, e, o) {
  const s = e[t.from].x, r = e[t.to].x, a = t.wrap && t.message;
  let l = B.calculateTextDimensions(
    a ? B.wrapLabel(t.message, n.width, Tt(n)) : t.message,
    Tt(n)
  );
  const h = {
    width: a ? n.width : v.getMax(n.width, l.width + 2 * n.noteMargin),
    height: 0,
    startx: e[t.from].x,
    stopx: 0,
    starty: 0,
    stopy: 0,
    message: t.message
  };
  return t.placement === o.db.PLACEMENT.RIGHTOF ? (h.width = a ? v.getMax(n.width, l.width) : v.getMax(
    e[t.from].width / 2 + e[t.to].width / 2,
    l.width + 2 * n.noteMargin
  ), h.startx = s + (e[t.from].width + n.actorMargin) / 2) : t.placement === o.db.PLACEMENT.LEFTOF ? (h.width = a ? v.getMax(n.width, l.width + 2 * n.noteMargin) : v.getMax(
    e[t.from].width / 2 + e[t.to].width / 2,
    l.width + 2 * n.noteMargin
  ), h.startx = s - h.width + (e[t.from].width - n.actorMargin) / 2) : t.to === t.from ? (l = B.calculateTextDimensions(
    a ? B.wrapLabel(
      t.message,
      v.getMax(n.width, e[t.from].width),
      Tt(n)
    ) : t.message,
    Tt(n)
  ), h.width = a ? v.getMax(n.width, e[t.from].width) : v.getMax(
    e[t.from].width,
    n.width,
    l.width + 2 * n.noteMargin
  ), h.startx = s + (e[t.from].width - h.width) / 2) : (h.width = Math.abs(s + e[t.from].width / 2 - (r + e[t.to].width / 2)) + n.actorMargin, h.startx = s < r ? s + e[t.from].width / 2 - n.actorMargin / 2 : r + e[t.to].width / 2 - n.actorMargin / 2), a && (h.message = B.wrapLabel(
    t.message,
    h.width - 2 * n.wrapPadding,
    Tt(n)
  )), K.debug(
    `NM:[${h.startx},${h.stopx},${h.starty},${h.stopy}:${h.width},${h.height}=${t.message}]`
  ), h;
}, S0 = function(t, e, o) {
  if (![
    o.db.LINETYPE.SOLID_OPEN,
    o.db.LINETYPE.DOTTED_OPEN,
    o.db.LINETYPE.SOLID,
    o.db.LINETYPE.DOTTED,
    o.db.LINETYPE.SOLID_CROSS,
    o.db.LINETYPE.DOTTED_CROSS,
    o.db.LINETYPE.SOLID_POINT,
    o.db.LINETYPE.DOTTED_POINT
  ].includes(t.type))
    return {};
  const [s, r] = Gt(t.from, e), [a, l] = Gt(t.to, e), h = s <= a, p = h ? r : s;
  let i = h ? a : l;
  const g = Math.abs(a - l) > 2, E = (P) => h ? -P : P;
  t.from === t.to ? i = p : (t.activate && !g && (i += E(n.activationWidth / 2 - 1)), [o.db.LINETYPE.SOLID_OPEN, o.db.LINETYPE.DOTTED_OPEN].includes(t.type) || (i += E(3)));
  const u = [s, r, a, l], x = Math.abs(p - i);
  t.wrap && t.message && (t.message = B.wrapLabel(
    t.message,
    v.getMax(x + 2 * n.wrapPadding, n.width),
    gt(n)
  ));
  const m = B.calculateTextDimensions(t.message, gt(n));
  return {
    width: v.getMax(
      t.wrap ? 0 : m.width + 2 * n.wrapPadding,
      x + 2 * n.wrapPadding,
      n.width
    ),
    height: 0,
    startx: p,
    stopx: i,
    starty: 0,
    stopy: 0,
    message: t.message,
    type: t.type,
    wrap: t.wrap,
    fromBounds: Math.min.apply(null, u),
    toBounds: Math.max.apply(null, u)
  };
}, M0 = function(t, e, o, s) {
  const r = {}, a = [];
  let l, h, p;
  return t.forEach(function(i) {
    switch (i.id = B.random({ length: 10 }), i.type) {
      case s.db.LINETYPE.LOOP_START:
      case s.db.LINETYPE.ALT_START:
      case s.db.LINETYPE.OPT_START:
      case s.db.LINETYPE.PAR_START:
      case s.db.LINETYPE.PAR_OVER_START:
      case s.db.LINETYPE.CRITICAL_START:
      case s.db.LINETYPE.BREAK_START:
        a.push({
          id: i.id,
          msg: i.message,
          from: Number.MAX_SAFE_INTEGER,
          to: Number.MIN_SAFE_INTEGER,
          width: 0
        });
        break;
      case s.db.LINETYPE.ALT_ELSE:
      case s.db.LINETYPE.PAR_AND:
      case s.db.LINETYPE.CRITICAL_OPTION:
        i.message && (l = a.pop(), r[l.id] = l, r[i.id] = l, a.push(l));
        break;
      case s.db.LINETYPE.LOOP_END:
      case s.db.LINETYPE.ALT_END:
      case s.db.LINETYPE.OPT_END:
      case s.db.LINETYPE.PAR_END:
      case s.db.LINETYPE.CRITICAL_END:
      case s.db.LINETYPE.BREAK_END:
        l = a.pop(), r[l.id] = l;
        break;
      case s.db.LINETYPE.ACTIVE_START:
        {
          const E = e[i.from ? i.from.actor : i.to.actor], u = It(i.from ? i.from.actor : i.to.actor).length, x = E.x + E.width / 2 + (u - 1) * n.activationWidth / 2, m = {
            startx: x,
            stopx: x + n.activationWidth,
            actor: i.from.actor,
            enabled: !0
          };
          f.activations.push(m);
        }
        break;
      case s.db.LINETYPE.ACTIVE_END:
        {
          const E = f.activations.map((u) => u.actor).lastIndexOf(i.from.actor);
          delete f.activations.splice(E, 1)[0];
        }
        break;
    }
    i.placement !== void 0 ? (h = N0(i, e, s), i.noteModel = h, a.forEach((E) => {
      l = E, l.from = v.getMin(l.from, h.startx), l.to = v.getMax(l.to, h.startx + h.width), l.width = v.getMax(l.width, Math.abs(l.from - l.to)) - n.labelBoxWidth;
    })) : (p = S0(i, e, s), i.msgModel = p, p.startx && p.stopx && a.length > 0 && a.forEach((E) => {
      if (l = E, p.startx === p.stopx) {
        const u = e[i.from], x = e[i.to];
        l.from = v.getMin(
          u.x - p.width / 2,
          u.x - u.width / 2,
          l.from
        ), l.to = v.getMax(
          x.x + p.width / 2,
          x.x + u.width / 2,
          l.to
        ), l.width = v.getMax(l.width, Math.abs(l.to - l.from)) - n.labelBoxWidth;
      } else
        l.from = v.getMin(p.startx, l.from), l.to = v.getMax(p.stopx, l.to), l.width = v.getMax(l.width, p.width) - n.labelBoxWidth;
    }));
  }), f.activations = [], K.debug("Loop type widths:", r), r;
}, R0 = {
  bounds: f,
  drawActors: Bt,
  drawActorsPopup: he,
  setConf: de,
  draw: P0
}, V0 = {
  parser: Ne,
  db: Xt,
  renderer: R0,
  styles: s0,
  init: ({ wrap: t }) => {
    Xt.setWrap(t);
  }
};
export {
  V0 as diagram
};
//# sourceMappingURL=sequenceDiagram-c18d009d-CfOh3XpY.js.map
