UNPKG

134 kBJavaScriptView Raw
1import { g as getAccTitle, A as getDiagramTitle, z as setDiagramTitle, c as getConfig, s as setAccTitle, b as setAccDescription, a as getAccDescription, m as mermaidAPI, B as clear$1, l as log, d as sanitizeText, e as sanitizeUrl_1, f as common, T as parseFontSize, a2 as addFunction, h as assignWithDepth, j as select, k as configureSvgSize, x as utils } from "./mermaid-4b4b971d.js";
2import { d as drawRect$1, a as drawBackgroundRect$1, b as drawEmbeddedImage, c as drawImage, e as getTextObj$1, g as getNoteRect$1 } from "./svgDrawCommon-ca4e6afc.js";
3import { s as selectAll } from "./selectAll-f3da6cb0.js";
4var parser = function() {
5 var o = function(k, v, o2, l) {
6 for (o2 = o2 || {}, l = k.length; l--; o2[k[l]] = v)
7 ;
8 return o2;
9 }, $V0 = [1, 2], $V1 = [1, 3], $V2 = [1, 5], $V3 = [1, 7], $V4 = [2, 5], $V5 = [1, 15], $V6 = [1, 17], $V7 = [1, 19], $V8 = [1, 21], $V9 = [1, 22], $Va = [1, 23], $Vb = [1, 29], $Vc = [1, 30], $Vd = [1, 31], $Ve = [1, 32], $Vf = [1, 33], $Vg = [1, 34], $Vh = [1, 35], $Vi = [1, 36], $Vj = [1, 37], $Vk = [1, 38], $Vl = [1, 39], $Vm = [1, 40], $Vn = [1, 41], $Vo = [1, 43], $Vp = [1, 44], $Vq = [1, 46], $Vr = [1, 47], $Vs = [1, 48], $Vt = [1, 49], $Vu = [1, 50], $Vv = [1, 51], $Vw = [1, 54], $Vx = [1, 4, 5, 19, 21, 23, 26, 28, 34, 35, 36, 38, 40, 41, 42, 43, 44, 46, 48, 49, 51, 52, 53, 54, 55, 57, 58, 63, 64, 65, 66, 74, 84], $Vy = [4, 5, 21, 55, 57], $Vz = [4, 5, 19, 21, 23, 26, 28, 34, 35, 36, 38, 40, 41, 42, 43, 44, 46, 48, 49, 51, 55, 57, 58, 63, 64, 65, 66, 74, 84], $VA = [4, 5, 19, 21, 23, 26, 28, 34, 35, 36, 38, 40, 41, 42, 43, 44, 46, 48, 49, 51, 54, 55, 57, 58, 63, 64, 65, 66, 74, 84], $VB = [4, 5, 19, 21, 23, 26, 28, 34, 35, 36, 38, 40, 41, 42, 43, 44, 46, 48, 49, 51, 53, 55, 57, 58, 63, 64, 65, 66, 74, 84], $VC = [4, 5, 19, 21, 23, 26, 28, 34, 35, 36, 38, 40, 41, 42, 43, 44, 46, 48, 49, 51, 52, 55, 57, 58, 63, 64, 65, 66, 74, 84], $VD = [72, 73, 74], $VE = [1, 128], $VF = [1, 4, 5, 7, 19, 21, 23, 26, 28, 34, 35, 36, 38, 40, 41, 42, 43, 44, 46, 48, 49, 51, 52, 53, 54, 55, 57, 58, 63, 64, 65, 66, 74, 84];
10 var parser2 = {
11 trace: function trace() {
12 },
13 yy: {},
14 symbols_: { "error": 2, "start": 3, "SPACE": 4, "NEWLINE": 5, "directive": 6, "SD": 7, "document": 8, "line": 9, "statement": 10, "box_section": 11, "box_line": 12, "participant_statement": 13, "openDirective": 14, "typeDirective": 15, "closeDirective": 16, ":": 17, "argDirective": 18, "box": 19, "restOfLine": 20, "end": 21, "signal": 22, "autonumber": 23, "NUM": 24, "off": 25, "activate": 26, "actor": 27, "deactivate": 28, "note_statement": 29, "links_statement": 30, "link_statement": 31, "properties_statement": 32, "details_statement": 33, "title": 34, "legacy_title": 35, "acc_title": 36, "acc_title_value": 37, "acc_descr": 38, "acc_descr_value": 39, "acc_descr_multiline_value": 40, "loop": 41, "rect": 42, "opt": 43, "alt": 44, "else_sections": 45, "par": 46, "par_sections": 47, "par_over": 48, "critical": 49, "option_sections": 50, "break": 51, "option": 52, "and": 53, "else": 54, "participant": 55, "AS": 56, "participant_actor": 57, "note": 58, "placement": 59, "text2": 60, "over": 61, "actor_pair": 62, "links": 63, "link": 64, "properties": 65, "details": 66, "spaceList": 67, ",": 68, "left_of": 69, "right_of": 70, "signaltype": 71, "+": 72, "-": 73, "ACTOR": 74, "SOLID_OPEN_ARROW": 75, "DOTTED_OPEN_ARROW": 76, "SOLID_ARROW": 77, "DOTTED_ARROW": 78, "SOLID_CROSS": 79, "DOTTED_CROSS": 80, "SOLID_POINT": 81, "DOTTED_POINT": 82, "TXT": 83, "open_directive": 84, "type_directive": 85, "arg_directive": 86, "close_directive": 87, "$accept": 0, "$end": 1 },
15 terminals_: { 2: "error", 4: "SPACE", 5: "NEWLINE", 7: "SD", 17: ":", 19: "box", 20: "restOfLine", 21: "end", 23: "autonumber", 24: "NUM", 25: "off", 26: "activate", 28: "deactivate", 34: "title", 35: "legacy_title", 36: "acc_title", 37: "acc_title_value", 38: "acc_descr", 39: "acc_descr_value", 40: "acc_descr_multiline_value", 41: "loop", 42: "rect", 43: "opt", 44: "alt", 46: "par", 48: "par_over", 49: "critical", 51: "break", 52: "option", 53: "and", 54: "else", 55: "participant", 56: "AS", 57: "participant_actor", 58: "note", 61: "over", 63: "links", 64: "link", 65: "properties", 66: "details", 68: ",", 69: "left_of", 70: "right_of", 72: "+", 73: "-", 74: "ACTOR", 75: "SOLID_OPEN_ARROW", 76: "DOTTED_OPEN_ARROW", 77: "SOLID_ARROW", 78: "DOTTED_ARROW", 79: "SOLID_CROSS", 80: "DOTTED_CROSS", 81: "SOLID_POINT", 82: "DOTTED_POINT", 83: "TXT", 84: "open_directive", 85: "type_directive", 86: "arg_directive", 87: "close_directive" },
16 productions_: [0, [3, 2], [3, 2], [3, 2], [3, 2], [8, 0], [8, 2], [9, 2], [9, 1], [9, 1], [11, 0], [11, 2], [12, 2], [12, 1], [12, 1], [6, 4], [6, 6], [10, 1], [10, 4], [10, 2], [10, 4], [10, 3], [10, 3], [10, 2], [10, 3], [10, 3], [10, 2], [10, 2], [10, 2], [10, 2], [10, 2], [10, 1], [10, 1], [10, 2], [10, 2], [10, 1], [10, 4], [10, 4], [10, 4], [10, 4], [10, 4], [10, 4], [10, 4], [10, 4], [10, 1], [50, 1], [50, 4], [47, 1], [47, 4], [45, 1], [45, 4], [13, 5], [13, 3], [13, 5], [13, 3], [29, 4], [29, 4], [30, 3], [31, 3], [32, 3], [33, 3], [67, 2], [67, 1], [62, 3], [62, 1], [59, 1], [59, 1], [22, 5], [22, 5], [22, 4], [27, 1], [71, 1], [71, 1], [71, 1], [71, 1], [71, 1], [71, 1], [71, 1], [71, 1], [60, 1], [14, 1], [15, 1], [18, 1], [16, 1]],
17 performAction: function anonymous(yytext, yyleng, yylineno, yy, yystate, $$, _$) {
18 var $0 = $$.length - 1;
19 switch (yystate) {
20 case 4:
21 yy.apply($$[$0]);
22 return $$[$0];
23 case 5:
24 case 10:
25 this.$ = [];
26 break;
27 case 6:
28 case 11:
29 $$[$0 - 1].push($$[$0]);
30 this.$ = $$[$0 - 1];
31 break;
32 case 7:
33 case 8:
34 case 12:
35 case 13:
36 this.$ = $$[$0];
37 break;
38 case 9:
39 case 14:
40 this.$ = [];
41 break;
42 case 18:
43 $$[$0 - 1].unshift({ type: "boxStart", boxData: yy.parseBoxData($$[$0 - 2]) });
44 $$[$0 - 1].push({ type: "boxEnd", boxText: $$[$0 - 2] });
45 this.$ = $$[$0 - 1];
46 break;
47 case 20:
48 this.$ = { type: "sequenceIndex", sequenceIndex: Number($$[$0 - 2]), sequenceIndexStep: Number($$[$0 - 1]), sequenceVisible: true, signalType: yy.LINETYPE.AUTONUMBER };
49 break;
50 case 21:
51 this.$ = { type: "sequenceIndex", sequenceIndex: Number($$[$0 - 1]), sequenceIndexStep: 1, sequenceVisible: true, signalType: yy.LINETYPE.AUTONUMBER };
52 break;
53 case 22:
54 this.$ = { type: "sequenceIndex", sequenceVisible: false, signalType: yy.LINETYPE.AUTONUMBER };
55 break;
56 case 23:
57 this.$ = { type: "sequenceIndex", sequenceVisible: true, signalType: yy.LINETYPE.AUTONUMBER };
58 break;
59 case 24:
60 this.$ = { type: "activeStart", signalType: yy.LINETYPE.ACTIVE_START, actor: $$[$0 - 1] };
61 break;
62 case 25:
63 this.$ = { type: "activeEnd", signalType: yy.LINETYPE.ACTIVE_END, actor: $$[$0 - 1] };
64 break;
65 case 31:
66 yy.setDiagramTitle($$[$0].substring(6));
67 this.$ = $$[$0].substring(6);
68 break;
69 case 32:
70 yy.setDiagramTitle($$[$0].substring(7));
71 this.$ = $$[$0].substring(7);
72 break;
73 case 33:
74 this.$ = $$[$0].trim();
75 yy.setAccTitle(this.$);
76 break;
77 case 34:
78 case 35:
79 this.$ = $$[$0].trim();
80 yy.setAccDescription(this.$);
81 break;
82 case 36:
83 $$[$0 - 1].unshift({ type: "loopStart", loopText: yy.parseMessage($$[$0 - 2]), signalType: yy.LINETYPE.LOOP_START });
84 $$[$0 - 1].push({ type: "loopEnd", loopText: $$[$0 - 2], signalType: yy.LINETYPE.LOOP_END });
85 this.$ = $$[$0 - 1];
86 break;
87 case 37:
88 $$[$0 - 1].unshift({ type: "rectStart", color: yy.parseMessage($$[$0 - 2]), signalType: yy.LINETYPE.RECT_START });
89 $$[$0 - 1].push({ type: "rectEnd", color: yy.parseMessage($$[$0 - 2]), signalType: yy.LINETYPE.RECT_END });
90 this.$ = $$[$0 - 1];
91 break;
92 case 38:
93 $$[$0 - 1].unshift({ type: "optStart", optText: yy.parseMessage($$[$0 - 2]), signalType: yy.LINETYPE.OPT_START });
94 $$[$0 - 1].push({ type: "optEnd", optText: yy.parseMessage($$[$0 - 2]), signalType: yy.LINETYPE.OPT_END });
95 this.$ = $$[$0 - 1];
96 break;
97 case 39:
98 $$[$0 - 1].unshift({ type: "altStart", altText: yy.parseMessage($$[$0 - 2]), signalType: yy.LINETYPE.ALT_START });
99 $$[$0 - 1].push({ type: "altEnd", signalType: yy.LINETYPE.ALT_END });
100 this.$ = $$[$0 - 1];
101 break;
102 case 40:
103 $$[$0 - 1].unshift({ type: "parStart", parText: yy.parseMessage($$[$0 - 2]), signalType: yy.LINETYPE.PAR_START });
104 $$[$0 - 1].push({ type: "parEnd", signalType: yy.LINETYPE.PAR_END });
105 this.$ = $$[$0 - 1];
106 break;
107 case 41:
108 $$[$0 - 1].unshift({ type: "parStart", parText: yy.parseMessage($$[$0 - 2]), signalType: yy.LINETYPE.PAR_OVER_START });
109 $$[$0 - 1].push({ type: "parEnd", signalType: yy.LINETYPE.PAR_END });
110 this.$ = $$[$0 - 1];
111 break;
112 case 42:
113 $$[$0 - 1].unshift({ type: "criticalStart", criticalText: yy.parseMessage($$[$0 - 2]), signalType: yy.LINETYPE.CRITICAL_START });
114 $$[$0 - 1].push({ type: "criticalEnd", signalType: yy.LINETYPE.CRITICAL_END });
115 this.$ = $$[$0 - 1];
116 break;
117 case 43:
118 $$[$0 - 1].unshift({ type: "breakStart", breakText: yy.parseMessage($$[$0 - 2]), signalType: yy.LINETYPE.BREAK_START });
119 $$[$0 - 1].push({ type: "breakEnd", optText: yy.parseMessage($$[$0 - 2]), signalType: yy.LINETYPE.BREAK_END });
120 this.$ = $$[$0 - 1];
121 break;
122 case 46:
123 this.$ = $$[$0 - 3].concat([{ type: "option", optionText: yy.parseMessage($$[$0 - 1]), signalType: yy.LINETYPE.CRITICAL_OPTION }, $$[$0]]);
124 break;
125 case 48:
126 this.$ = $$[$0 - 3].concat([{ type: "and", parText: yy.parseMessage($$[$0 - 1]), signalType: yy.LINETYPE.PAR_AND }, $$[$0]]);
127 break;
128 case 50:
129 this.$ = $$[$0 - 3].concat([{ type: "else", altText: yy.parseMessage($$[$0 - 1]), signalType: yy.LINETYPE.ALT_ELSE }, $$[$0]]);
130 break;
131 case 51:
132 $$[$0 - 3].type = "addParticipant";
133 $$[$0 - 3].description = yy.parseMessage($$[$0 - 1]);
134 this.$ = $$[$0 - 3];
135 break;
136 case 52:
137 $$[$0 - 1].type = "addParticipant";
138 this.$ = $$[$0 - 1];
139 break;
140 case 53:
141 $$[$0 - 3].type = "addActor";
142 $$[$0 - 3].description = yy.parseMessage($$[$0 - 1]);
143 this.$ = $$[$0 - 3];
144 break;
145 case 54:
146 $$[$0 - 1].type = "addActor";
147 this.$ = $$[$0 - 1];
148 break;
149 case 55:
150 this.$ = [$$[$0 - 1], { type: "addNote", placement: $$[$0 - 2], actor: $$[$0 - 1].actor, text: $$[$0] }];
151 break;
152 case 56:
153 $$[$0 - 2] = [].concat($$[$0 - 1], $$[$0 - 1]).slice(0, 2);
154 $$[$0 - 2][0] = $$[$0 - 2][0].actor;
155 $$[$0 - 2][1] = $$[$0 - 2][1].actor;
156 this.$ = [$$[$0 - 1], { type: "addNote", placement: yy.PLACEMENT.OVER, actor: $$[$0 - 2].slice(0, 2), text: $$[$0] }];
157 break;
158 case 57:
159 this.$ = [$$[$0 - 1], { type: "addLinks", actor: $$[$0 - 1].actor, text: $$[$0] }];
160 break;
161 case 58:
162 this.$ = [$$[$0 - 1], { type: "addALink", actor: $$[$0 - 1].actor, text: $$[$0] }];
163 break;
164 case 59:
165 this.$ = [$$[$0 - 1], { type: "addProperties", actor: $$[$0 - 1].actor, text: $$[$0] }];
166 break;
167 case 60:
168 this.$ = [$$[$0 - 1], { type: "addDetails", actor: $$[$0 - 1].actor, text: $$[$0] }];
169 break;
170 case 63:
171 this.$ = [$$[$0 - 2], $$[$0]];
172 break;
173 case 64:
174 this.$ = $$[$0];
175 break;
176 case 65:
177 this.$ = yy.PLACEMENT.LEFTOF;
178 break;
179 case 66:
180 this.$ = yy.PLACEMENT.RIGHTOF;
181 break;
182 case 67:
183 this.$ = [
184 $$[$0 - 4],
185 $$[$0 - 1],
186 { type: "addMessage", from: $$[$0 - 4].actor, to: $$[$0 - 1].actor, signalType: $$[$0 - 3], msg: $$[$0] },
187 { type: "activeStart", signalType: yy.LINETYPE.ACTIVE_START, actor: $$[$0 - 1] }
188 ];
189 break;
190 case 68:
191 this.$ = [
192 $$[$0 - 4],
193 $$[$0 - 1],
194 { type: "addMessage", from: $$[$0 - 4].actor, to: $$[$0 - 1].actor, signalType: $$[$0 - 3], msg: $$[$0] },
195 { type: "activeEnd", signalType: yy.LINETYPE.ACTIVE_END, actor: $$[$0 - 4] }
196 ];
197 break;
198 case 69:
199 this.$ = [$$[$0 - 3], $$[$0 - 1], { type: "addMessage", from: $$[$0 - 3].actor, to: $$[$0 - 1].actor, signalType: $$[$0 - 2], msg: $$[$0] }];
200 break;
201 case 70:
202 this.$ = { type: "addParticipant", actor: $$[$0] };
203 break;
204 case 71:
205 this.$ = yy.LINETYPE.SOLID_OPEN;
206 break;
207 case 72:
208 this.$ = yy.LINETYPE.DOTTED_OPEN;
209 break;
210 case 73:
211 this.$ = yy.LINETYPE.SOLID;
212 break;
213 case 74:
214 this.$ = yy.LINETYPE.DOTTED;
215 break;
216 case 75:
217 this.$ = yy.LINETYPE.SOLID_CROSS;
218 break;
219 case 76:
220 this.$ = yy.LINETYPE.DOTTED_CROSS;
221 break;
222 case 77:
223 this.$ = yy.LINETYPE.SOLID_POINT;
224 break;
225 case 78:
226 this.$ = yy.LINETYPE.DOTTED_POINT;
227 break;
228 case 79:
229 this.$ = yy.parseMessage($$[$0].trim().substring(1));
230 break;
231 case 80:
232 yy.parseDirective("%%{", "open_directive");
233 break;
234 case 81:
235 yy.parseDirective($$[$0], "type_directive");
236 break;
237 case 82:
238 $$[$0] = $$[$0].trim().replace(/'/g, '"');
239 yy.parseDirective($$[$0], "arg_directive");
240 break;
241 case 83:
242 yy.parseDirective("}%%", "close_directive", "sequence");
243 break;
244 }
245 },
246 table: [{ 3: 1, 4: $V0, 5: $V1, 6: 4, 7: $V2, 14: 6, 84: $V3 }, { 1: [3] }, { 3: 8, 4: $V0, 5: $V1, 6: 4, 7: $V2, 14: 6, 84: $V3 }, { 3: 9, 4: $V0, 5: $V1, 6: 4, 7: $V2, 14: 6, 84: $V3 }, { 3: 10, 4: $V0, 5: $V1, 6: 4, 7: $V2, 14: 6, 84: $V3 }, o([1, 4, 5, 19, 23, 26, 28, 34, 35, 36, 38, 40, 41, 42, 43, 44, 46, 48, 49, 51, 55, 57, 58, 63, 64, 65, 66, 74, 84], $V4, { 8: 11 }), { 15: 12, 85: [1, 13] }, { 85: [2, 80] }, { 1: [2, 1] }, { 1: [2, 2] }, { 1: [2, 3] }, { 1: [2, 4], 4: $V5, 5: $V6, 6: 42, 9: 14, 10: 16, 13: 18, 14: 6, 19: $V7, 22: 20, 23: $V8, 26: $V9, 27: 45, 28: $Va, 29: 24, 30: 25, 31: 26, 32: 27, 33: 28, 34: $Vb, 35: $Vc, 36: $Vd, 38: $Ve, 40: $Vf, 41: $Vg, 42: $Vh, 43: $Vi, 44: $Vj, 46: $Vk, 48: $Vl, 49: $Vm, 51: $Vn, 55: $Vo, 57: $Vp, 58: $Vq, 63: $Vr, 64: $Vs, 65: $Vt, 66: $Vu, 74: $Vv, 84: $V3 }, { 16: 52, 17: [1, 53], 87: $Vw }, o([17, 87], [2, 81]), o($Vx, [2, 6]), { 6: 42, 10: 55, 13: 18, 14: 6, 19: $V7, 22: 20, 23: $V8, 26: $V9, 27: 45, 28: $Va, 29: 24, 30: 25, 31: 26, 32: 27, 33: 28, 34: $Vb, 35: $Vc, 36: $Vd, 38: $Ve, 40: $Vf, 41: $Vg, 42: $Vh, 43: $Vi, 44: $Vj, 46: $Vk, 48: $Vl, 49: $Vm, 51: $Vn, 55: $Vo, 57: $Vp, 58: $Vq, 63: $Vr, 64: $Vs, 65: $Vt, 66: $Vu, 74: $Vv, 84: $V3 }, o($Vx, [2, 8]), o($Vx, [2, 9]), o($Vx, [2, 17]), { 20: [1, 56] }, { 5: [1, 57] }, { 5: [1, 60], 24: [1, 58], 25: [1, 59] }, { 27: 61, 74: $Vv }, { 27: 62, 74: $Vv }, { 5: [1, 63] }, { 5: [1, 64] }, { 5: [1, 65] }, { 5: [1, 66] }, { 5: [1, 67] }, o($Vx, [2, 31]), o($Vx, [2, 32]), { 37: [1, 68] }, { 39: [1, 69] }, o($Vx, [2, 35]), { 20: [1, 70] }, { 20: [1, 71] }, { 20: [1, 72] }, { 20: [1, 73] }, { 20: [1, 74] }, { 20: [1, 75] }, { 20: [1, 76] }, { 20: [1, 77] }, o($Vx, [2, 44]), { 27: 78, 74: $Vv }, { 27: 79, 74: $Vv }, { 71: 80, 75: [1, 81], 76: [1, 82], 77: [1, 83], 78: [1, 84], 79: [1, 85], 80: [1, 86], 81: [1, 87], 82: [1, 88] }, { 59: 89, 61: [1, 90], 69: [1, 91], 70: [1, 92] }, { 27: 93, 74: $Vv }, { 27: 94, 74: $Vv }, { 27: 95, 74: $Vv }, { 27: 96, 74: $Vv }, o([5, 56, 68, 75, 76, 77, 78, 79, 80, 81, 82, 83], [2, 70]), { 5: [1, 97] }, { 18: 98, 86: [1, 99] }, { 5: [2, 83] }, o($Vx, [2, 7]), o($Vy, [2, 10], { 11: 100 }), o($Vx, [2, 19]), { 5: [1, 102], 24: [1, 101] }, { 5: [1, 103] }, o($Vx, [2, 23]), { 5: [1, 104] }, { 5: [1, 105] }, o($Vx, [2, 26]), o($Vx, [2, 27]), o($Vx, [2, 28]), o($Vx, [2, 29]), o($Vx, [2, 30]), o($Vx, [2, 33]), o($Vx, [2, 34]), o($Vz, $V4, { 8: 106 }), o($Vz, $V4, { 8: 107 }), o($Vz, $V4, { 8: 108 }), o($VA, $V4, { 45: 109, 8: 110 }), o($VB, $V4, { 47: 111, 8: 112 }), o($VB, $V4, { 8: 112, 47: 113 }), o($VC, $V4, { 50: 114, 8: 115 }), o($Vz, $V4, { 8: 116 }), { 5: [1, 118], 56: [1, 117] }, { 5: [1, 120], 56: [1, 119] }, { 27: 123, 72: [1, 121], 73: [1, 122], 74: $Vv }, o($VD, [2, 71]), o($VD, [2, 72]), o($VD, [2, 73]), o($VD, [2, 74]), o($VD, [2, 75]), o($VD, [2, 76]), o($VD, [2, 77]), o($VD, [2, 78]), { 27: 124, 74: $Vv }, { 27: 126, 62: 125, 74: $Vv }, { 74: [2, 65] }, { 74: [2, 66] }, { 60: 127, 83: $VE }, { 60: 129, 83: $VE }, { 60: 130, 83: $VE }, { 60: 131, 83: $VE }, o($VF, [2, 15]), { 16: 132, 87: $Vw }, { 87: [2, 82] }, { 4: [1, 135], 5: [1, 137], 12: 134, 13: 136, 21: [1, 133], 55: $Vo, 57: $Vp }, { 5: [1, 138] }, o($Vx, [2, 21]), o($Vx, [2, 22]), o($Vx, [2, 24]), o($Vx, [2, 25]), { 4: $V5, 5: $V6, 6: 42, 9: 14, 10: 16, 13: 18, 14: 6, 19: $V7, 21: [1, 139], 22: 20, 23: $V8, 26: $V9, 27: 45, 28: $Va, 29: 24, 30: 25, 31: 26, 32: 27, 33: 28, 34: $Vb, 35: $Vc, 36: $Vd, 38: $Ve, 40: $Vf, 41: $Vg, 42: $Vh, 43: $Vi, 44: $Vj, 46: $Vk, 48: $Vl, 49: $Vm, 51: $Vn, 55: $Vo, 57: $Vp, 58: $Vq, 63: $Vr, 64: $Vs, 65: $Vt, 66: $Vu, 74: $Vv, 84: $V3 }, { 4: $V5, 5: $V6, 6: 42, 9: 14, 10: 16, 13: 18, 14: 6, 19: $V7, 21: [1, 140], 22: 20, 23: $V8, 26: $V9, 27: 45, 28: $Va, 29: 24, 30: 25, 31: 26, 32: 27, 33: 28, 34: $Vb, 35: $Vc, 36: $Vd, 38: $Ve, 40: $Vf, 41: $Vg, 42: $Vh, 43: $Vi, 44: $Vj, 46: $Vk, 48: $Vl, 49: $Vm, 51: $Vn, 55: $Vo, 57: $Vp, 58: $Vq, 63: $Vr, 64: $Vs, 65: $Vt, 66: $Vu, 74: $Vv, 84: $V3 }, { 4: $V5, 5: $V6, 6: 42, 9: 14, 10: 16, 13: 18, 14: 6, 19: $V7, 21: [1, 141], 22: 20, 23: $V8, 26: $V9, 27: 45, 28: $Va, 29: 24, 30: 25, 31: 26, 32: 27, 33: 28, 34: $Vb, 35: $Vc, 36: $Vd, 38: $Ve, 40: $Vf, 41: $Vg, 42: $Vh, 43: $Vi, 44: $Vj, 46: $Vk, 48: $Vl, 49: $Vm, 51: $Vn, 55: $Vo, 57: $Vp, 58: $Vq, 63: $Vr, 64: $Vs, 65: $Vt, 66: $Vu, 74: $Vv, 84: $V3 }, { 21: [1, 142] }, { 4: $V5, 5: $V6, 6: 42, 9: 14, 10: 16, 13: 18, 14: 6, 19: $V7, 21: [2, 49], 22: 20, 23: $V8, 26: $V9, 27: 45, 28: $Va, 29: 24, 30: 25, 31: 26, 32: 27, 33: 28, 34: $Vb, 35: $Vc, 36: $Vd, 38: $Ve, 40: $Vf, 41: $Vg, 42: $Vh, 43: $Vi, 44: $Vj, 46: $Vk, 48: $Vl, 49: $Vm, 51: $Vn, 54: [1, 143], 55: $Vo, 57: $Vp, 58: $Vq, 63: $Vr, 64: $Vs, 65: $Vt, 66: $Vu, 74: $Vv, 84: $V3 }, { 21: [1, 144] }, { 4: $V5, 5: $V6, 6: 42, 9: 14, 10: 16, 13: 18, 14: 6, 19: $V7, 21: [2, 47], 22: 20, 23: $V8, 26: $V9, 27: 45, 28: $Va, 29: 24, 30: 25, 31: 26, 32: 27, 33: 28, 34: $Vb, 35: $Vc, 36: $Vd, 38: $Ve, 40: $Vf, 41: $Vg, 42: $Vh, 43: $Vi, 44: $Vj, 46: $Vk, 48: $Vl, 49: $Vm, 51: $Vn, 53: [1, 145], 55: $Vo, 57: $Vp, 58: $Vq, 63: $Vr, 64: $Vs, 65: $Vt, 66: $Vu, 74: $Vv, 84: $V3 }, { 21: [1, 146] }, { 21: [1, 147] }, { 4: $V5, 5: $V6, 6: 42, 9: 14, 10: 16, 13: 18, 14: 6, 19: $V7, 21: [2, 45], 22: 20, 23: $V8, 26: $V9, 27: 45, 28: $Va, 29: 24, 30: 25, 31: 26, 32: 27, 33: 28, 34: $Vb, 35: $Vc, 36: $Vd, 38: $Ve, 40: $Vf, 41: $Vg, 42: $Vh, 43: $Vi, 44: $Vj, 46: $Vk, 48: $Vl, 49: $Vm, 51: $Vn, 52: [1, 148], 55: $Vo, 57: $Vp, 58: $Vq, 63: $Vr, 64: $Vs, 65: $Vt, 66: $Vu, 74: $Vv, 84: $V3 }, { 4: $V5, 5: $V6, 6: 42, 9: 14, 10: 16, 13: 18, 14: 6, 19: $V7, 21: [1, 149], 22: 20, 23: $V8, 26: $V9, 27: 45, 28: $Va, 29: 24, 30: 25, 31: 26, 32: 27, 33: 28, 34: $Vb, 35: $Vc, 36: $Vd, 38: $Ve, 40: $Vf, 41: $Vg, 42: $Vh, 43: $Vi, 44: $Vj, 46: $Vk, 48: $Vl, 49: $Vm, 51: $Vn, 55: $Vo, 57: $Vp, 58: $Vq, 63: $Vr, 64: $Vs, 65: $Vt, 66: $Vu, 74: $Vv, 84: $V3 }, { 20: [1, 150] }, o($Vx, [2, 52]), { 20: [1, 151] }, o($Vx, [2, 54]), { 27: 152, 74: $Vv }, { 27: 153, 74: $Vv }, { 60: 154, 83: $VE }, { 60: 155, 83: $VE }, { 60: 156, 83: $VE }, { 68: [1, 157], 83: [2, 64] }, { 5: [2, 57] }, { 5: [2, 79] }, { 5: [2, 58] }, { 5: [2, 59] }, { 5: [2, 60] }, { 5: [1, 158] }, o($Vx, [2, 18]), o($Vy, [2, 11]), { 13: 159, 55: $Vo, 57: $Vp }, o($Vy, [2, 13]), o($Vy, [2, 14]), o($Vx, [2, 20]), o($Vx, [2, 36]), o($Vx, [2, 37]), o($Vx, [2, 38]), o($Vx, [2, 39]), { 20: [1, 160] }, o($Vx, [2, 40]), { 20: [1, 161] }, o($Vx, [2, 41]), o($Vx, [2, 42]), { 20: [1, 162] }, o($Vx, [2, 43]), { 5: [1, 163] }, { 5: [1, 164] }, { 60: 165, 83: $VE }, { 60: 166, 83: $VE }, { 5: [2, 69] }, { 5: [2, 55] }, { 5: [2, 56] }, { 27: 167, 74: $Vv }, o($VF, [2, 16]), o($Vy, [2, 12]), o($VA, $V4, { 8: 110, 45: 168 }), o($VB, $V4, { 8: 112, 47: 169 }), o($VC, $V4, { 8: 115, 50: 170 }), o($Vx, [2, 51]), o($Vx, [2, 53]), { 5: [2, 67] }, { 5: [2, 68] }, { 83: [2, 63] }, { 21: [2, 50] }, { 21: [2, 48] }, { 21: [2, 46] }],
247 defaultActions: { 7: [2, 80], 8: [2, 1], 9: [2, 2], 10: [2, 3], 54: [2, 83], 91: [2, 65], 92: [2, 66], 99: [2, 82], 127: [2, 57], 128: [2, 79], 129: [2, 58], 130: [2, 59], 131: [2, 60], 154: [2, 69], 155: [2, 55], 156: [2, 56], 165: [2, 67], 166: [2, 68], 167: [2, 63], 168: [2, 50], 169: [2, 48], 170: [2, 46] },
248 parseError: function parseError(str, hash) {
249 if (hash.recoverable) {
250 this.trace(str);
251 } else {
252 var error = new Error(str);
253 error.hash = hash;
254 throw error;
255 }
256 },
257 parse: function parse(input) {
258 var self = this, stack = [0], tstack = [], vstack = [null], lstack = [], table = this.table, yytext = "", yylineno = 0, yyleng = 0, TERROR = 2, EOF = 1;
259 var args = lstack.slice.call(arguments, 1);
260 var lexer2 = Object.create(this.lexer);
261 var sharedState = { yy: {} };
262 for (var k in this.yy) {
263 if (Object.prototype.hasOwnProperty.call(this.yy, k)) {
264 sharedState.yy[k] = this.yy[k];
265 }
266 }
267 lexer2.setInput(input, sharedState.yy);
268 sharedState.yy.lexer = lexer2;
269 sharedState.yy.parser = this;
270 if (typeof lexer2.yylloc == "undefined") {
271 lexer2.yylloc = {};
272 }
273 var yyloc = lexer2.yylloc;
274 lstack.push(yyloc);
275 var ranges = lexer2.options && lexer2.options.ranges;
276 if (typeof sharedState.yy.parseError === "function") {
277 this.parseError = sharedState.yy.parseError;
278 } else {
279 this.parseError = Object.getPrototypeOf(this).parseError;
280 }
281 function lex() {
282 var token;
283 token = tstack.pop() || lexer2.lex() || EOF;
284 if (typeof token !== "number") {
285 if (token instanceof Array) {
286 tstack = token;
287 token = tstack.pop();
288 }
289 token = self.symbols_[token] || token;
290 }
291 return token;
292 }
293 var symbol, state, action, r, yyval = {}, p, len, newState, expected;
294 while (true) {
295 state = stack[stack.length - 1];
296 if (this.defaultActions[state]) {
297 action = this.defaultActions[state];
298 } else {
299 if (symbol === null || typeof symbol == "undefined") {
300 symbol = lex();
301 }
302 action = table[state] && table[state][symbol];
303 }
304 if (typeof action === "undefined" || !action.length || !action[0]) {
305 var errStr = "";
306 expected = [];
307 for (p in table[state]) {
308 if (this.terminals_[p] && p > TERROR) {
309 expected.push("'" + this.terminals_[p] + "'");
310 }
311 }
312 if (lexer2.showPosition) {
313 errStr = "Parse error on line " + (yylineno + 1) + ":\n" + lexer2.showPosition() + "\nExpecting " + expected.join(", ") + ", got '" + (this.terminals_[symbol] || symbol) + "'";
314 } else {
315 errStr = "Parse error on line " + (yylineno + 1) + ": Unexpected " + (symbol == EOF ? "end of input" : "'" + (this.terminals_[symbol] || symbol) + "'");
316 }
317 this.parseError(errStr, {
318 text: lexer2.match,
319 token: this.terminals_[symbol] || symbol,
320 line: lexer2.yylineno,
321 loc: yyloc,
322 expected
323 });
324 }
325 if (action[0] instanceof Array && action.length > 1) {
326 throw new Error("Parse Error: multiple actions possible at state: " + state + ", token: " + symbol);
327 }
328 switch (action[0]) {
329 case 1:
330 stack.push(symbol);
331 vstack.push(lexer2.yytext);
332 lstack.push(lexer2.yylloc);
333 stack.push(action[1]);
334 symbol = null;
335 {
336 yyleng = lexer2.yyleng;
337 yytext = lexer2.yytext;
338 yylineno = lexer2.yylineno;
339 yyloc = lexer2.yylloc;
340 }
341 break;
342 case 2:
343 len = this.productions_[action[1]][1];
344 yyval.$ = vstack[vstack.length - len];
345 yyval._$ = {
346 first_line: lstack[lstack.length - (len || 1)].first_line,
347 last_line: lstack[lstack.length - 1].last_line,
348 first_column: lstack[lstack.length - (len || 1)].first_column,
349 last_column: lstack[lstack.length - 1].last_column
350 };
351 if (ranges) {
352 yyval._$.range = [
353 lstack[lstack.length - (len || 1)].range[0],
354 lstack[lstack.length - 1].range[1]
355 ];
356 }
357 r = this.performAction.apply(yyval, [
358 yytext,
359 yyleng,
360 yylineno,
361 sharedState.yy,
362 action[1],
363 vstack,
364 lstack
365 ].concat(args));
366 if (typeof r !== "undefined") {
367 return r;
368 }
369 if (len) {
370 stack = stack.slice(0, -1 * len * 2);
371 vstack = vstack.slice(0, -1 * len);
372 lstack = lstack.slice(0, -1 * len);
373 }
374 stack.push(this.productions_[action[1]][0]);
375 vstack.push(yyval.$);
376 lstack.push(yyval._$);
377 newState = table[stack[stack.length - 2]][stack[stack.length - 1]];
378 stack.push(newState);
379 break;
380 case 3:
381 return true;
382 }
383 }
384 return true;
385 }
386 };
387 var lexer = function() {
388 var lexer2 = {
389 EOF: 1,
390 parseError: function parseError(str, hash) {
391 if (this.yy.parser) {
392 this.yy.parser.parseError(str, hash);
393 } else {
394 throw new Error(str);
395 }
396 },
397 // resets the lexer, sets new input
398 setInput: function(input, yy) {
399 this.yy = yy || this.yy || {};
400 this._input = input;
401 this._more = this._backtrack = this.done = false;
402 this.yylineno = this.yyleng = 0;
403 this.yytext = this.matched = this.match = "";
404 this.conditionStack = ["INITIAL"];
405 this.yylloc = {
406 first_line: 1,
407 first_column: 0,
408 last_line: 1,
409 last_column: 0
410 };
411 if (this.options.ranges) {
412 this.yylloc.range = [0, 0];
413 }
414 this.offset = 0;
415 return this;
416 },
417 // consumes and returns one char from the input
418 input: function() {
419 var ch = this._input[0];
420 this.yytext += ch;
421 this.yyleng++;
422 this.offset++;
423 this.match += ch;
424 this.matched += ch;
425 var lines = ch.match(/(?:\r\n?|\n).*/g);
426 if (lines) {
427 this.yylineno++;
428 this.yylloc.last_line++;
429 } else {
430 this.yylloc.last_column++;
431 }
432 if (this.options.ranges) {
433 this.yylloc.range[1]++;
434 }
435 this._input = this._input.slice(1);
436 return ch;
437 },
438 // unshifts one char (or a string) into the input
439 unput: function(ch) {
440 var len = ch.length;
441 var lines = ch.split(/(?:\r\n?|\n)/g);
442 this._input = ch + this._input;
443 this.yytext = this.yytext.substr(0, this.yytext.length - len);
444 this.offset -= len;
445 var oldLines = this.match.split(/(?:\r\n?|\n)/g);
446 this.match = this.match.substr(0, this.match.length - 1);
447 this.matched = this.matched.substr(0, this.matched.length - 1);
448 if (lines.length - 1) {
449 this.yylineno -= lines.length - 1;
450 }
451 var r = this.yylloc.range;
452 this.yylloc = {
453 first_line: this.yylloc.first_line,
454 last_line: this.yylineno + 1,
455 first_column: this.yylloc.first_column,
456 last_column: lines ? (lines.length === oldLines.length ? this.yylloc.first_column : 0) + oldLines[oldLines.length - lines.length].length - lines[0].length : this.yylloc.first_column - len
457 };
458 if (this.options.ranges) {
459 this.yylloc.range = [r[0], r[0] + this.yyleng - len];
460 }
461 this.yyleng = this.yytext.length;
462 return this;
463 },
464 // When called from action, caches matched text and appends it on next action
465 more: function() {
466 this._more = true;
467 return this;
468 },
469 // 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.
470 reject: function() {
471 if (this.options.backtrack_lexer) {
472 this._backtrack = true;
473 } else {
474 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).\n" + this.showPosition(), {
475 text: "",
476 token: null,
477 line: this.yylineno
478 });
479 }
480 return this;
481 },
482 // retain first n characters of the match
483 less: function(n) {
484 this.unput(this.match.slice(n));
485 },
486 // displays already matched input, i.e. for error messages
487 pastInput: function() {
488 var past = this.matched.substr(0, this.matched.length - this.match.length);
489 return (past.length > 20 ? "..." : "") + past.substr(-20).replace(/\n/g, "");
490 },
491 // displays upcoming input, i.e. for error messages
492 upcomingInput: function() {
493 var next = this.match;
494 if (next.length < 20) {
495 next += this._input.substr(0, 20 - next.length);
496 }
497 return (next.substr(0, 20) + (next.length > 20 ? "..." : "")).replace(/\n/g, "");
498 },
499 // displays the character position where the lexing error occurred, i.e. for error messages
500 showPosition: function() {
501 var pre = this.pastInput();
502 var c = new Array(pre.length + 1).join("-");
503 return pre + this.upcomingInput() + "\n" + c + "^";
504 },
505 // test the lexed token: return FALSE when not a match, otherwise return token
506 test_match: function(match, indexed_rule) {
507 var token, lines, backup;
508 if (this.options.backtrack_lexer) {
509 backup = {
510 yylineno: this.yylineno,
511 yylloc: {
512 first_line: this.yylloc.first_line,
513 last_line: this.last_line,
514 first_column: this.yylloc.first_column,
515 last_column: this.yylloc.last_column
516 },
517 yytext: this.yytext,
518 match: this.match,
519 matches: this.matches,
520 matched: this.matched,
521 yyleng: this.yyleng,
522 offset: this.offset,
523 _more: this._more,
524 _input: this._input,
525 yy: this.yy,
526 conditionStack: this.conditionStack.slice(0),
527 done: this.done
528 };
529 if (this.options.ranges) {
530 backup.yylloc.range = this.yylloc.range.slice(0);
531 }
532 }
533 lines = match[0].match(/(?:\r\n?|\n).*/g);
534 if (lines) {
535 this.yylineno += lines.length;
536 }
537 this.yylloc = {
538 first_line: this.yylloc.last_line,
539 last_line: this.yylineno + 1,
540 first_column: this.yylloc.last_column,
541 last_column: lines ? lines[lines.length - 1].length - lines[lines.length - 1].match(/\r?\n?/)[0].length : this.yylloc.last_column + match[0].length
542 };
543 this.yytext += match[0];
544 this.match += match[0];
545 this.matches = match;
546 this.yyleng = this.yytext.length;
547 if (this.options.ranges) {
548 this.yylloc.range = [this.offset, this.offset += this.yyleng];
549 }
550 this._more = false;
551 this._backtrack = false;
552 this._input = this._input.slice(match[0].length);
553 this.matched += match[0];
554 token = this.performAction.call(this, this.yy, this, indexed_rule, this.conditionStack[this.conditionStack.length - 1]);
555 if (this.done && this._input) {
556 this.done = false;
557 }
558 if (token) {
559 return token;
560 } else if (this._backtrack) {
561 for (var k in backup) {
562 this[k] = backup[k];
563 }
564 return false;
565 }
566 return false;
567 },
568 // return next match in input
569 next: function() {
570 if (this.done) {
571 return this.EOF;
572 }
573 if (!this._input) {
574 this.done = true;
575 }
576 var token, match, tempMatch, index;
577 if (!this._more) {
578 this.yytext = "";
579 this.match = "";
580 }
581 var rules = this._currentRules();
582 for (var i = 0; i < rules.length; i++) {
583 tempMatch = this._input.match(this.rules[rules[i]]);
584 if (tempMatch && (!match || tempMatch[0].length > match[0].length)) {
585 match = tempMatch;
586 index = i;
587 if (this.options.backtrack_lexer) {
588 token = this.test_match(tempMatch, rules[i]);
589 if (token !== false) {
590 return token;
591 } else if (this._backtrack) {
592 match = false;
593 continue;
594 } else {
595 return false;
596 }
597 } else if (!this.options.flex) {
598 break;
599 }
600 }
601 }
602 if (match) {
603 token = this.test_match(match, rules[index]);
604 if (token !== false) {
605 return token;
606 }
607 return false;
608 }
609 if (this._input === "") {
610 return this.EOF;
611 } else {
612 return this.parseError("Lexical error on line " + (this.yylineno + 1) + ". Unrecognized text.\n" + this.showPosition(), {
613 text: "",
614 token: null,
615 line: this.yylineno
616 });
617 }
618 },
619 // return next match that has a token
620 lex: function lex() {
621 var r = this.next();
622 if (r) {
623 return r;
624 } else {
625 return this.lex();
626 }
627 },
628 // activates a new lexer condition state (pushes the new lexer condition state onto the condition stack)
629 begin: function begin(condition) {
630 this.conditionStack.push(condition);
631 },
632 // pop the previously active lexer condition state off the condition stack
633 popState: function popState() {
634 var n = this.conditionStack.length - 1;
635 if (n > 0) {
636 return this.conditionStack.pop();
637 } else {
638 return this.conditionStack[0];
639 }
640 },
641 // produce the lexer rule set which is active for the currently active lexer condition state
642 _currentRules: function _currentRules() {
643 if (this.conditionStack.length && this.conditionStack[this.conditionStack.length - 1]) {
644 return this.conditions[this.conditionStack[this.conditionStack.length - 1]].rules;
645 } else {
646 return this.conditions["INITIAL"].rules;
647 }
648 },
649 // return the currently active lexer condition state; when an index argument is provided it produces the N-th previous condition state, if available
650 topState: function topState(n) {
651 n = this.conditionStack.length - 1 - Math.abs(n || 0);
652 if (n >= 0) {
653 return this.conditionStack[n];
654 } else {
655 return "INITIAL";
656 }
657 },
658 // alias for begin(condition)
659 pushState: function pushState(condition) {
660 this.begin(condition);
661 },
662 // return the number of states currently on the stack
663 stateStackSize: function stateStackSize() {
664 return this.conditionStack.length;
665 },
666 options: { "case-insensitive": true },
667 performAction: function anonymous(yy, yy_, $avoiding_name_collisions, YY_START) {
668 switch ($avoiding_name_collisions) {
669 case 0:
670 this.begin("open_directive");
671 return 84;
672 case 1:
673 this.begin("type_directive");
674 return 85;
675 case 2:
676 this.popState();
677 this.begin("arg_directive");
678 return 17;
679 case 3:
680 this.popState();
681 this.popState();
682 return 87;
683 case 4:
684 return 86;
685 case 5:
686 return 5;
687 case 6:
688 break;
689 case 7:
690 break;
691 case 8:
692 break;
693 case 9:
694 break;
695 case 10:
696 break;
697 case 11:
698 return 24;
699 case 12:
700 this.begin("LINE");
701 return 19;
702 case 13:
703 this.begin("ID");
704 return 55;
705 case 14:
706 this.begin("ID");
707 return 57;
708 case 15:
709 yy_.yytext = yy_.yytext.trim();
710 this.begin("ALIAS");
711 return 74;
712 case 16:
713 this.popState();
714 this.popState();
715 this.begin("LINE");
716 return 56;
717 case 17:
718 this.popState();
719 this.popState();
720 return 5;
721 case 18:
722 this.begin("LINE");
723 return 41;
724 case 19:
725 this.begin("LINE");
726 return 42;
727 case 20:
728 this.begin("LINE");
729 return 43;
730 case 21:
731 this.begin("LINE");
732 return 44;
733 case 22:
734 this.begin("LINE");
735 return 54;
736 case 23:
737 this.begin("LINE");
738 return 46;
739 case 24:
740 this.begin("LINE");
741 return 48;
742 case 25:
743 this.begin("LINE");
744 return 53;
745 case 26:
746 this.begin("LINE");
747 return 49;
748 case 27:
749 this.begin("LINE");
750 return 52;
751 case 28:
752 this.begin("LINE");
753 return 51;
754 case 29:
755 this.popState();
756 return 20;
757 case 30:
758 return 21;
759 case 31:
760 return 69;
761 case 32:
762 return 70;
763 case 33:
764 return 63;
765 case 34:
766 return 64;
767 case 35:
768 return 65;
769 case 36:
770 return 66;
771 case 37:
772 return 61;
773 case 38:
774 return 58;
775 case 39:
776 this.begin("ID");
777 return 26;
778 case 40:
779 this.begin("ID");
780 return 28;
781 case 41:
782 return 34;
783 case 42:
784 return 35;
785 case 43:
786 this.begin("acc_title");
787 return 36;
788 case 44:
789 this.popState();
790 return "acc_title_value";
791 case 45:
792 this.begin("acc_descr");
793 return 38;
794 case 46:
795 this.popState();
796 return "acc_descr_value";
797 case 47:
798 this.begin("acc_descr_multiline");
799 break;
800 case 48:
801 this.popState();
802 break;
803 case 49:
804 return "acc_descr_multiline_value";
805 case 50:
806 return 7;
807 case 51:
808 return 23;
809 case 52:
810 return 25;
811 case 53:
812 return 68;
813 case 54:
814 return 5;
815 case 55:
816 yy_.yytext = yy_.yytext.trim();
817 return 74;
818 case 56:
819 return 77;
820 case 57:
821 return 78;
822 case 58:
823 return 75;
824 case 59:
825 return 76;
826 case 60:
827 return 79;
828 case 61:
829 return 80;
830 case 62:
831 return 81;
832 case 63:
833 return 82;
834 case 64:
835 return 83;
836 case 65:
837 return 72;
838 case 66:
839 return 73;
840 case 67:
841 return 5;
842 case 68:
843 return "INVALID";
844 }
845 },
846 rules: [/^(?:%%\{)/i, /^(?:((?:(?!\}%%)[^:.])*))/i, /^(?::)/i, /^(?:\}%%)/i, /^(?:((?:(?!\}%%).|\n)*))/i, /^(?:[\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, /^(?:[^\->:\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],
847 conditions: { "acc_descr_multiline": { "rules": [48, 49], "inclusive": false }, "acc_descr": { "rules": [46], "inclusive": false }, "acc_title": { "rules": [44], "inclusive": false }, "open_directive": { "rules": [1, 8], "inclusive": false }, "type_directive": { "rules": [2, 3, 8], "inclusive": false }, "arg_directive": { "rules": [3, 4, 8], "inclusive": false }, "ID": { "rules": [7, 8, 15], "inclusive": false }, "ALIAS": { "rules": [7, 8, 16, 17], "inclusive": false }, "LINE": { "rules": [7, 8, 29], "inclusive": false }, "INITIAL": { "rules": [0, 5, 6, 8, 9, 10, 11, 12, 13, 14, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 45, 47, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68], "inclusive": true } }
848 };
849 return lexer2;
850 }();
851 parser2.lexer = lexer;
852 function Parser() {
853 this.yy = {};
854 }
855 Parser.prototype = parser2;
856 parser2.Parser = Parser;
857 return new Parser();
858}();
859parser.parser = parser;
860const parser$1 = parser;
861let prevActor = void 0;
862let actors = {};
863let boxes = [];
864let messages = [];
865let sequenceNumbersEnabled = false;
866let wrapEnabled;
867let currentBox = void 0;
868const parseDirective = function(statement, context, type) {
869 mermaidAPI.parseDirective(this, statement, context, type);
870};
871const addBox = function(data) {
872 boxes.push({
873 name: data.text,
874 wrap: data.wrap === void 0 && autoWrap() || !!data.wrap,
875 fill: data.color,
876 actorKeys: []
877 });
878 currentBox = boxes.slice(-1)[0];
879};
880const addActor = function(id, name, description, type) {
881 let assignedBox = currentBox;
882 const old = actors[id];
883 if (old) {
884 if (currentBox && old.box && currentBox !== old.box) {
885 throw new Error(
886 "A same participant should only be defined in one Box: " + old.name + " can't be in '" + old.box.name + "' and in '" + currentBox.name + "' at the same time."
887 );
888 }
889 assignedBox = old.box ? old.box : currentBox;
890 old.box = assignedBox;
891 if (old && name === old.name && description == null) {
892 return;
893 }
894 }
895 if (description == null || description.text == null) {
896 description = { text: name, wrap: null, type };
897 }
898 if (type == null || description.text == null) {
899 description = { text: name, wrap: null, type };
900 }
901 actors[id] = {
902 box: assignedBox,
903 name,
904 description: description.text,
905 wrap: description.wrap === void 0 && autoWrap() || !!description.wrap,
906 prevActor,
907 links: {},
908 properties: {},
909 actorCnt: null,
910 rectData: null,
911 type: type || "participant"
912 };
913 if (prevActor && actors[prevActor]) {
914 actors[prevActor].nextActor = id;
915 }
916 if (currentBox) {
917 currentBox.actorKeys.push(id);
918 }
919 prevActor = id;
920};
921const activationCount = (part) => {
922 let i;
923 let count = 0;
924 for (i = 0; i < messages.length; i++) {
925 if (messages[i].type === LINETYPE.ACTIVE_START && messages[i].from.actor === part) {
926 count++;
927 }
928 if (messages[i].type === LINETYPE.ACTIVE_END && messages[i].from.actor === part) {
929 count--;
930 }
931 }
932 return count;
933};
934const addMessage = function(idFrom, idTo, message, answer) {
935 messages.push({
936 from: idFrom,
937 to: idTo,
938 message: message.text,
939 wrap: message.wrap === void 0 && autoWrap() || !!message.wrap,
940 answer
941 });
942};
943const addSignal = function(idFrom, idTo, message = { text: void 0, wrap: void 0 }, messageType) {
944 if (messageType === LINETYPE.ACTIVE_END) {
945 const cnt = activationCount(idFrom.actor);
946 if (cnt < 1) {
947 let error = new Error("Trying to inactivate an inactive participant (" + idFrom.actor + ")");
948 error.hash = {
949 text: "->>-",
950 token: "->>-",
951 line: "1",
952 loc: { first_line: 1, last_line: 1, first_column: 1, last_column: 1 },
953 expected: ["'ACTIVE_PARTICIPANT'"]
954 };
955 throw error;
956 }
957 }
958 messages.push({
959 from: idFrom,
960 to: idTo,
961 message: message.text,
962 wrap: message.wrap === void 0 && autoWrap() || !!message.wrap,
963 type: messageType
964 });
965 return true;
966};
967const hasAtLeastOneBox = function() {
968 return boxes.length > 0;
969};
970const hasAtLeastOneBoxWithTitle = function() {
971 return boxes.some((b) => b.name);
972};
973const getMessages = function() {
974 return messages;
975};
976const getBoxes = function() {
977 return boxes;
978};
979const getActors = function() {
980 return actors;
981};
982const getActor = function(id) {
983 return actors[id];
984};
985const getActorKeys = function() {
986 return Object.keys(actors);
987};
988const enableSequenceNumbers = function() {
989 sequenceNumbersEnabled = true;
990};
991const disableSequenceNumbers = function() {
992 sequenceNumbersEnabled = false;
993};
994const showSequenceNumbers = () => sequenceNumbersEnabled;
995const setWrap = function(wrapSetting) {
996 wrapEnabled = wrapSetting;
997};
998const autoWrap = () => {
999 if (wrapEnabled !== void 0) {
1000 return wrapEnabled;
1001 }
1002 return getConfig().sequence.wrap;
1003};
1004const clear = function() {
1005 actors = {};
1006 boxes = [];
1007 messages = [];
1008 sequenceNumbersEnabled = false;
1009 clear$1();
1010};
1011const parseMessage = function(str) {
1012 const _str = str.trim();
1013 const message = {
1014 text: _str.replace(/^:?(?:no)?wrap:/, "").trim(),
1015 wrap: _str.match(/^:?wrap:/) !== null ? true : _str.match(/^:?nowrap:/) !== null ? false : void 0
1016 };
1017 log.debug("parseMessage:", message);
1018 return message;
1019};
1020const parseBoxData = function(str) {
1021 const match = str.match(/^((?:rgba?|hsla?)\s*\(.*\)|\w*)(.*)$/);
1022 let color = match != null && match[1] ? match[1].trim() : "transparent";
1023 let title = match != null && match[2] ? match[2].trim() : void 0;
1024 if (window && window.CSS) {
1025 if (!window.CSS.supports("color", color)) {
1026 color = "transparent";
1027 title = str.trim();
1028 }
1029 } else {
1030 const style = new Option().style;
1031 style.color = color;
1032 if (style.color !== color) {
1033 color = "transparent";
1034 title = str.trim();
1035 }
1036 }
1037 const boxData = {
1038 color,
1039 text: title !== void 0 ? sanitizeText(title.replace(/^:?(?:no)?wrap:/, ""), getConfig()) : void 0,
1040 wrap: title !== void 0 ? title.match(/^:?wrap:/) !== null ? true : title.match(/^:?nowrap:/) !== null ? false : void 0 : void 0
1041 };
1042 return boxData;
1043};
1044const LINETYPE = {
1045 SOLID: 0,
1046 DOTTED: 1,
1047 NOTE: 2,
1048 SOLID_CROSS: 3,
1049 DOTTED_CROSS: 4,
1050 SOLID_OPEN: 5,
1051 DOTTED_OPEN: 6,
1052 LOOP_START: 10,
1053 LOOP_END: 11,
1054 ALT_START: 12,
1055 ALT_ELSE: 13,
1056 ALT_END: 14,
1057 OPT_START: 15,
1058 OPT_END: 16,
1059 ACTIVE_START: 17,
1060 ACTIVE_END: 18,
1061 PAR_START: 19,
1062 PAR_AND: 20,
1063 PAR_END: 21,
1064 RECT_START: 22,
1065 RECT_END: 23,
1066 SOLID_POINT: 24,
1067 DOTTED_POINT: 25,
1068 AUTONUMBER: 26,
1069 CRITICAL_START: 27,
1070 CRITICAL_OPTION: 28,
1071 CRITICAL_END: 29,
1072 BREAK_START: 30,
1073 BREAK_END: 31,
1074 PAR_OVER_START: 32
1075};
1076const ARROWTYPE = {
1077 FILLED: 0,
1078 OPEN: 1
1079};
1080const PLACEMENT = {
1081 LEFTOF: 0,
1082 RIGHTOF: 1,
1083 OVER: 2
1084};
1085const addNote = function(actor, placement, message) {
1086 ({
1087 actor,
1088 placement,
1089 message: message.text,
1090 wrap: message.wrap === void 0 && autoWrap() || !!message.wrap
1091 });
1092 const actors2 = [].concat(actor, actor);
1093 messages.push({
1094 from: actors2[0],
1095 to: actors2[1],
1096 message: message.text,
1097 wrap: message.wrap === void 0 && autoWrap() || !!message.wrap,
1098 type: LINETYPE.NOTE,
1099 placement
1100 });
1101};
1102const addLinks = function(actorId, text) {
1103 const actor = getActor(actorId);
1104 try {
1105 let sanitizedText = sanitizeText(text.text, getConfig());
1106 sanitizedText = sanitizedText.replace(/&amp;/g, "&");
1107 sanitizedText = sanitizedText.replace(/&equals;/g, "=");
1108 const links = JSON.parse(sanitizedText);
1109 insertLinks(actor, links);
1110 } catch (e) {
1111 log.error("error while parsing actor link text", e);
1112 }
1113};
1114const addALink = function(actorId, text) {
1115 const actor = getActor(actorId);
1116 try {
1117 const links = {};
1118 let sanitizedText = sanitizeText(text.text, getConfig());
1119 var sep = sanitizedText.indexOf("@");
1120 sanitizedText = sanitizedText.replace(/&amp;/g, "&");
1121 sanitizedText = sanitizedText.replace(/&equals;/g, "=");
1122 var label = sanitizedText.slice(0, sep - 1).trim();
1123 var link = sanitizedText.slice(sep + 1).trim();
1124 links[label] = link;
1125 insertLinks(actor, links);
1126 } catch (e) {
1127 log.error("error while parsing actor link text", e);
1128 }
1129};
1130function insertLinks(actor, links) {
1131 if (actor.links == null) {
1132 actor.links = links;
1133 } else {
1134 for (let key in links) {
1135 actor.links[key] = links[key];
1136 }
1137 }
1138}
1139const addProperties = function(actorId, text) {
1140 const actor = getActor(actorId);
1141 try {
1142 let sanitizedText = sanitizeText(text.text, getConfig());
1143 const properties = JSON.parse(sanitizedText);
1144 insertProperties(actor, properties);
1145 } catch (e) {
1146 log.error("error while parsing actor properties text", e);
1147 }
1148};
1149function insertProperties(actor, properties) {
1150 if (actor.properties == null) {
1151 actor.properties = properties;
1152 } else {
1153 for (let key in properties) {
1154 actor.properties[key] = properties[key];
1155 }
1156 }
1157}
1158function boxEnd() {
1159 currentBox = void 0;
1160}
1161const addDetails = function(actorId, text) {
1162 const actor = getActor(actorId);
1163 const elem = document.getElementById(text.text);
1164 try {
1165 const text2 = elem.innerHTML;
1166 const details = JSON.parse(text2);
1167 if (details["properties"]) {
1168 insertProperties(actor, details["properties"]);
1169 }
1170 if (details["links"]) {
1171 insertLinks(actor, details["links"]);
1172 }
1173 } catch (e) {
1174 log.error("error while parsing actor details text", e);
1175 }
1176};
1177const getActorProperty = function(actor, key) {
1178 if (actor !== void 0 && actor.properties !== void 0) {
1179 return actor.properties[key];
1180 }
1181 return void 0;
1182};
1183const apply = function(param) {
1184 if (Array.isArray(param)) {
1185 param.forEach(function(item) {
1186 apply(item);
1187 });
1188 } else {
1189 switch (param.type) {
1190 case "sequenceIndex":
1191 messages.push({
1192 from: void 0,
1193 to: void 0,
1194 message: {
1195 start: param.sequenceIndex,
1196 step: param.sequenceIndexStep,
1197 visible: param.sequenceVisible
1198 },
1199 wrap: false,
1200 type: param.signalType
1201 });
1202 break;
1203 case "addParticipant":
1204 addActor(param.actor, param.actor, param.description, "participant");
1205 break;
1206 case "addActor":
1207 addActor(param.actor, param.actor, param.description, "actor");
1208 break;
1209 case "activeStart":
1210 addSignal(param.actor, void 0, void 0, param.signalType);
1211 break;
1212 case "activeEnd":
1213 addSignal(param.actor, void 0, void 0, param.signalType);
1214 break;
1215 case "addNote":
1216 addNote(param.actor, param.placement, param.text);
1217 break;
1218 case "addLinks":
1219 addLinks(param.actor, param.text);
1220 break;
1221 case "addALink":
1222 addALink(param.actor, param.text);
1223 break;
1224 case "addProperties":
1225 addProperties(param.actor, param.text);
1226 break;
1227 case "addDetails":
1228 addDetails(param.actor, param.text);
1229 break;
1230 case "addMessage":
1231 addSignal(param.from, param.to, param.msg, param.signalType);
1232 break;
1233 case "boxStart":
1234 addBox(param.boxData);
1235 break;
1236 case "boxEnd":
1237 boxEnd();
1238 break;
1239 case "loopStart":
1240 addSignal(void 0, void 0, param.loopText, param.signalType);
1241 break;
1242 case "loopEnd":
1243 addSignal(void 0, void 0, void 0, param.signalType);
1244 break;
1245 case "rectStart":
1246 addSignal(void 0, void 0, param.color, param.signalType);
1247 break;
1248 case "rectEnd":
1249 addSignal(void 0, void 0, void 0, param.signalType);
1250 break;
1251 case "optStart":
1252 addSignal(void 0, void 0, param.optText, param.signalType);
1253 break;
1254 case "optEnd":
1255 addSignal(void 0, void 0, void 0, param.signalType);
1256 break;
1257 case "altStart":
1258 addSignal(void 0, void 0, param.altText, param.signalType);
1259 break;
1260 case "else":
1261 addSignal(void 0, void 0, param.altText, param.signalType);
1262 break;
1263 case "altEnd":
1264 addSignal(void 0, void 0, void 0, param.signalType);
1265 break;
1266 case "setAccTitle":
1267 setAccTitle(param.text);
1268 break;
1269 case "parStart":
1270 addSignal(void 0, void 0, param.parText, param.signalType);
1271 break;
1272 case "and":
1273 addSignal(void 0, void 0, param.parText, param.signalType);
1274 break;
1275 case "parEnd":
1276 addSignal(void 0, void 0, void 0, param.signalType);
1277 break;
1278 case "criticalStart":
1279 addSignal(void 0, void 0, param.criticalText, param.signalType);
1280 break;
1281 case "option":
1282 addSignal(void 0, void 0, param.optionText, param.signalType);
1283 break;
1284 case "criticalEnd":
1285 addSignal(void 0, void 0, void 0, param.signalType);
1286 break;
1287 case "breakStart":
1288 addSignal(void 0, void 0, param.breakText, param.signalType);
1289 break;
1290 case "breakEnd":
1291 addSignal(void 0, void 0, void 0, param.signalType);
1292 break;
1293 }
1294 }
1295};
1296const db = {
1297 addActor,
1298 addMessage,
1299 addSignal,
1300 addLinks,
1301 addDetails,
1302 addProperties,
1303 autoWrap,
1304 setWrap,
1305 enableSequenceNumbers,
1306 disableSequenceNumbers,
1307 showSequenceNumbers,
1308 getMessages,
1309 getActors,
1310 getActor,
1311 getActorKeys,
1312 getActorProperty,
1313 getAccTitle,
1314 getBoxes,
1315 getDiagramTitle,
1316 setDiagramTitle,
1317 parseDirective,
1318 getConfig: () => getConfig().sequence,
1319 clear,
1320 parseMessage,
1321 parseBoxData,
1322 LINETYPE,
1323 ARROWTYPE,
1324 PLACEMENT,
1325 addNote,
1326 setAccTitle,
1327 apply,
1328 setAccDescription,
1329 getAccDescription,
1330 hasAtLeastOneBox,
1331 hasAtLeastOneBoxWithTitle
1332};
1333const getStyles = (options) => `.actor {
1334 stroke: ${options.actorBorder};
1335 fill: ${options.actorBkg};
1336 }
1337
1338 text.actor > tspan {
1339 fill: ${options.actorTextColor};
1340 stroke: none;
1341 }
1342
1343 .actor-line {
1344 stroke: ${options.actorLineColor};
1345 }
1346
1347 .messageLine0 {
1348 stroke-width: 1.5;
1349 stroke-dasharray: none;
1350 stroke: ${options.signalColor};
1351 }
1352
1353 .messageLine1 {
1354 stroke-width: 1.5;
1355 stroke-dasharray: 2, 2;
1356 stroke: ${options.signalColor};
1357 }
1358
1359 #arrowhead path {
1360 fill: ${options.signalColor};
1361 stroke: ${options.signalColor};
1362 }
1363
1364 .sequenceNumber {
1365 fill: ${options.sequenceNumberColor};
1366 }
1367
1368 #sequencenumber {
1369 fill: ${options.signalColor};
1370 }
1371
1372 #crosshead path {
1373 fill: ${options.signalColor};
1374 stroke: ${options.signalColor};
1375 }
1376
1377 .messageText {
1378 fill: ${options.signalTextColor};
1379 stroke: none;
1380 }
1381
1382 .labelBox {
1383 stroke: ${options.labelBoxBorderColor};
1384 fill: ${options.labelBoxBkgColor};
1385 }
1386
1387 .labelText, .labelText > tspan {
1388 fill: ${options.labelTextColor};
1389 stroke: none;
1390 }
1391
1392 .loopText, .loopText > tspan {
1393 fill: ${options.loopTextColor};
1394 stroke: none;
1395 }
1396
1397 .loopLine {
1398 stroke-width: 2px;
1399 stroke-dasharray: 2, 2;
1400 stroke: ${options.labelBoxBorderColor};
1401 fill: ${options.labelBoxBorderColor};
1402 }
1403
1404 .note {
1405 //stroke: #decc93;
1406 stroke: ${options.noteBorderColor};
1407 fill: ${options.noteBkgColor};
1408 }
1409
1410 .noteText, .noteText > tspan {
1411 fill: ${options.noteTextColor};
1412 stroke: none;
1413 }
1414
1415 .activation0 {
1416 fill: ${options.activationBkgColor};
1417 stroke: ${options.activationBorderColor};
1418 }
1419
1420 .activation1 {
1421 fill: ${options.activationBkgColor};
1422 stroke: ${options.activationBorderColor};
1423 }
1424
1425 .activation2 {
1426 fill: ${options.activationBkgColor};
1427 stroke: ${options.activationBorderColor};
1428 }
1429
1430 .actorPopupMenu {
1431 position: absolute;
1432 }
1433
1434 .actorPopupMenuPanel {
1435 position: absolute;
1436 fill: ${options.actorBkg};
1437 box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
1438 filter: drop-shadow(3px 5px 2px rgb(0 0 0 / 0.4));
1439}
1440 .actor-man line {
1441 stroke: ${options.actorBorder};
1442 fill: ${options.actorBkg};
1443 }
1444 .actor-man circle, line {
1445 stroke: ${options.actorBorder};
1446 fill: ${options.actorBkg};
1447 stroke-width: 2px;
1448 }
1449`;
1450const styles = getStyles;
1451const drawRect = function(elem, rectData) {
1452 return drawRect$1(elem, rectData);
1453};
1454const addPopupInteraction = (id, actorCnt2) => {
1455 addFunction(() => {
1456 const arr = document.querySelectorAll(id);
1457 if (arr.length === 0) {
1458 return;
1459 }
1460 arr[0].addEventListener("mouseover", function() {
1461 popupMenuUpFunc("actor" + actorCnt2 + "_popup");
1462 });
1463 arr[0].addEventListener("mouseout", function() {
1464 popupMenuDownFunc("actor" + actorCnt2 + "_popup");
1465 });
1466 });
1467};
1468const drawPopup = function(elem, actor, minMenuWidth, textAttrs, forceMenus) {
1469 if (actor.links === void 0 || actor.links === null || Object.keys(actor.links).length === 0) {
1470 return { height: 0, width: 0 };
1471 }
1472 const links = actor.links;
1473 const actorCnt2 = actor.actorCnt;
1474 const rectData = actor.rectData;
1475 var displayValue = "none";
1476 if (forceMenus) {
1477 displayValue = "block !important";
1478 }
1479 const g = elem.append("g");
1480 g.attr("id", "actor" + actorCnt2 + "_popup");
1481 g.attr("class", "actorPopupMenu");
1482 g.attr("display", displayValue);
1483 addPopupInteraction("#actor" + actorCnt2 + "_popup", actorCnt2);
1484 var actorClass = "";
1485 if (rectData.class !== void 0) {
1486 actorClass = " " + rectData.class;
1487 }
1488 let menuWidth = rectData.width > minMenuWidth ? rectData.width : minMenuWidth;
1489 const rectElem = g.append("rect");
1490 rectElem.attr("class", "actorPopupMenuPanel" + actorClass);
1491 rectElem.attr("x", rectData.x);
1492 rectElem.attr("y", rectData.height);
1493 rectElem.attr("fill", rectData.fill);
1494 rectElem.attr("stroke", rectData.stroke);
1495 rectElem.attr("width", menuWidth);
1496 rectElem.attr("height", rectData.height);
1497 rectElem.attr("rx", rectData.rx);
1498 rectElem.attr("ry", rectData.ry);
1499 if (links != null) {
1500 var linkY = 20;
1501 for (let key in links) {
1502 var linkElem = g.append("a");
1503 var sanitizedLink = sanitizeUrl_1(links[key]);
1504 linkElem.attr("xlink:href", sanitizedLink);
1505 linkElem.attr("target", "_blank");
1506 _drawMenuItemTextCandidateFunc(textAttrs)(
1507 key,
1508 linkElem,
1509 rectData.x + 10,
1510 rectData.height + linkY,
1511 menuWidth,
1512 20,
1513 { class: "actor" },
1514 textAttrs
1515 );
1516 linkY += 30;
1517 }
1518 }
1519 rectElem.attr("height", linkY);
1520 return { height: rectData.height + linkY, width: menuWidth };
1521};
1522const popupMenu = function(popid) {
1523 return "var pu = document.getElementById('" + popid + "'); if (pu != null) { pu.style.display = 'block'; }";
1524};
1525const popdownMenu = function(popid) {
1526 return "var pu = document.getElementById('" + popid + "'); if (pu != null) { pu.style.display = 'none'; }";
1527};
1528const popupMenuUpFunc = function(popupId) {
1529 var pu = document.getElementById(popupId);
1530 if (pu != null) {
1531 pu.style.display = "block";
1532 }
1533};
1534const popupMenuDownFunc = function(popupId) {
1535 var pu = document.getElementById(popupId);
1536 if (pu != null) {
1537 pu.style.display = "none";
1538 }
1539};
1540const drawText = function(elem, textData) {
1541 let prevTextHeight = 0;
1542 let textHeight = 0;
1543 const lines = textData.text.split(common.lineBreakRegex);
1544 const [_textFontSize, _textFontSizePx] = parseFontSize(textData.fontSize);
1545 let textElems = [];
1546 let dy = 0;
1547 let yfunc = () => textData.y;
1548 if (textData.valign !== void 0 && textData.textMargin !== void 0 && textData.textMargin > 0) {
1549 switch (textData.valign) {
1550 case "top":
1551 case "start":
1552 yfunc = () => Math.round(textData.y + textData.textMargin);
1553 break;
1554 case "middle":
1555 case "center":
1556 yfunc = () => Math.round(textData.y + (prevTextHeight + textHeight + textData.textMargin) / 2);
1557 break;
1558 case "bottom":
1559 case "end":
1560 yfunc = () => Math.round(
1561 textData.y + (prevTextHeight + textHeight + 2 * textData.textMargin) - textData.textMargin
1562 );
1563 break;
1564 }
1565 }
1566 if (textData.anchor !== void 0 && textData.textMargin !== void 0 && textData.width !== void 0) {
1567 switch (textData.anchor) {
1568 case "left":
1569 case "start":
1570 textData.x = Math.round(textData.x + textData.textMargin);
1571 textData.anchor = "start";
1572 textData.dominantBaseline = "middle";
1573 textData.alignmentBaseline = "middle";
1574 break;
1575 case "middle":
1576 case "center":
1577 textData.x = Math.round(textData.x + textData.width / 2);
1578 textData.anchor = "middle";
1579 textData.dominantBaseline = "middle";
1580 textData.alignmentBaseline = "middle";
1581 break;
1582 case "right":
1583 case "end":
1584 textData.x = Math.round(textData.x + textData.width - textData.textMargin);
1585 textData.anchor = "end";
1586 textData.dominantBaseline = "middle";
1587 textData.alignmentBaseline = "middle";
1588 break;
1589 }
1590 }
1591 for (let [i, line] of lines.entries()) {
1592 if (textData.textMargin !== void 0 && textData.textMargin === 0 && _textFontSize !== void 0) {
1593 dy = i * _textFontSize;
1594 }
1595 const textElem = elem.append("text");
1596 textElem.attr("x", textData.x);
1597 textElem.attr("y", yfunc());
1598 if (textData.anchor !== void 0) {
1599 textElem.attr("text-anchor", textData.anchor).attr("dominant-baseline", textData.dominantBaseline).attr("alignment-baseline", textData.alignmentBaseline);
1600 }
1601 if (textData.fontFamily !== void 0) {
1602 textElem.style("font-family", textData.fontFamily);
1603 }
1604 if (_textFontSizePx !== void 0) {
1605 textElem.style("font-size", _textFontSizePx);
1606 }
1607 if (textData.fontWeight !== void 0) {
1608 textElem.style("font-weight", textData.fontWeight);
1609 }
1610 if (textData.fill !== void 0) {
1611 textElem.attr("fill", textData.fill);
1612 }
1613 if (textData.class !== void 0) {
1614 textElem.attr("class", textData.class);
1615 }
1616 if (textData.dy !== void 0) {
1617 textElem.attr("dy", textData.dy);
1618 } else if (dy !== 0) {
1619 textElem.attr("dy", dy);
1620 }
1621 if (textData.tspan) {
1622 const span = textElem.append("tspan");
1623 span.attr("x", textData.x);
1624 if (textData.fill !== void 0) {
1625 span.attr("fill", textData.fill);
1626 }
1627 span.text(line);
1628 } else {
1629 textElem.text(line);
1630 }
1631 if (textData.valign !== void 0 && textData.textMargin !== void 0 && textData.textMargin > 0) {
1632 textHeight += (textElem._groups || textElem)[0][0].getBBox().height;
1633 prevTextHeight = textHeight;
1634 }
1635 textElems.push(textElem);
1636 }
1637 return textElems;
1638};
1639const drawLabel = function(elem, txtObject) {
1640 function genPoints(x, y, width, height, cut) {
1641 return x + "," + y + " " + (x + width) + "," + y + " " + (x + width) + "," + (y + height - cut) + " " + (x + width - cut * 1.2) + "," + (y + height) + " " + x + "," + (y + height);
1642 }
1643 const polygon = elem.append("polygon");
1644 polygon.attr("points", genPoints(txtObject.x, txtObject.y, txtObject.width, txtObject.height, 7));
1645 polygon.attr("class", "labelBox");
1646 txtObject.y = txtObject.y + txtObject.height / 2;
1647 drawText(elem, txtObject);
1648 return polygon;
1649};
1650let actorCnt = -1;
1651const fixLifeLineHeights = (diagram2, bounds2) => {
1652 if (!diagram2.selectAll) {
1653 return;
1654 }
1655 diagram2.selectAll(".actor-line").attr("class", "200").attr("y2", bounds2 - 55);
1656};
1657const drawActorTypeParticipant = function(elem, actor, conf2, isFooter) {
1658 const center = actor.x + actor.width / 2;
1659 const centerY = actor.y + 5;
1660 const boxpluslineGroup = elem.append("g");
1661 var g = boxpluslineGroup;
1662 if (!isFooter) {
1663 actorCnt++;
1664 g.append("line").attr("id", "actor" + actorCnt).attr("x1", center).attr("y1", centerY).attr("x2", center).attr("y2", 2e3).attr("class", "actor-line").attr("stroke-width", "0.5px").attr("stroke", "#999");
1665 g = boxpluslineGroup.append("g");
1666 actor.actorCnt = actorCnt;
1667 if (actor.links != null) {
1668 g.attr("id", "root-" + actorCnt);
1669 addPopupInteraction("#root-" + actorCnt, actorCnt);
1670 }
1671 }
1672 const rect = getNoteRect$1();
1673 var cssclass = "actor";
1674 if (actor.properties != null && actor.properties["class"]) {
1675 cssclass = actor.properties["class"];
1676 } else {
1677 rect.fill = "#eaeaea";
1678 }
1679 rect.x = actor.x;
1680 rect.y = actor.y;
1681 rect.width = actor.width;
1682 rect.height = actor.height;
1683 rect.class = cssclass;
1684 rect.rx = 3;
1685 rect.ry = 3;
1686 const rectElem = drawRect(g, rect);
1687 actor.rectData = rect;
1688 if (actor.properties != null && actor.properties["icon"]) {
1689 const iconSrc = actor.properties["icon"].trim();
1690 if (iconSrc.charAt(0) === "@") {
1691 drawEmbeddedImage(g, rect.x + rect.width - 20, rect.y + 10, iconSrc.substr(1));
1692 } else {
1693 drawImage(g, rect.x + rect.width - 20, rect.y + 10, iconSrc);
1694 }
1695 }
1696 _drawTextCandidateFunc(conf2)(
1697 actor.description,
1698 g,
1699 rect.x,
1700 rect.y,
1701 rect.width,
1702 rect.height,
1703 { class: "actor" },
1704 conf2
1705 );
1706 let height = actor.height;
1707 if (rectElem.node) {
1708 const bounds2 = rectElem.node().getBBox();
1709 actor.height = bounds2.height;
1710 height = bounds2.height;
1711 }
1712 return height;
1713};
1714const drawActorTypeActor = function(elem, actor, conf2, isFooter) {
1715 const center = actor.x + actor.width / 2;
1716 const centerY = actor.y + 80;
1717 if (!isFooter) {
1718 actorCnt++;
1719 elem.append("line").attr("id", "actor" + actorCnt).attr("x1", center).attr("y1", centerY).attr("x2", center).attr("y2", 2e3).attr("class", "actor-line").attr("stroke-width", "0.5px").attr("stroke", "#999");
1720 }
1721 const actElem = elem.append("g");
1722 actElem.attr("class", "actor-man");
1723 const rect = getNoteRect$1();
1724 rect.x = actor.x;
1725 rect.y = actor.y;
1726 rect.fill = "#eaeaea";
1727 rect.width = actor.width;
1728 rect.height = actor.height;
1729 rect.class = "actor";
1730 rect.rx = 3;
1731 rect.ry = 3;
1732 actElem.append("line").attr("id", "actor-man-torso" + actorCnt).attr("x1", center).attr("y1", actor.y + 25).attr("x2", center).attr("y2", actor.y + 45);
1733 actElem.append("line").attr("id", "actor-man-arms" + actorCnt).attr("x1", center - 18).attr("y1", actor.y + 33).attr("x2", center + 18).attr("y2", actor.y + 33);
1734 actElem.append("line").attr("x1", center - 18).attr("y1", actor.y + 60).attr("x2", center).attr("y2", actor.y + 45);
1735 actElem.append("line").attr("x1", center).attr("y1", actor.y + 45).attr("x2", center + 16).attr("y2", actor.y + 60);
1736 const circle = actElem.append("circle");
1737 circle.attr("cx", actor.x + actor.width / 2);
1738 circle.attr("cy", actor.y + 10);
1739 circle.attr("r", 15);
1740 circle.attr("width", actor.width);
1741 circle.attr("height", actor.height);
1742 const bounds2 = actElem.node().getBBox();
1743 actor.height = bounds2.height;
1744 _drawTextCandidateFunc(conf2)(
1745 actor.description,
1746 actElem,
1747 rect.x,
1748 rect.y + 35,
1749 rect.width,
1750 rect.height,
1751 { class: "actor" },
1752 conf2
1753 );
1754 return actor.height;
1755};
1756const drawActor = function(elem, actor, conf2, isFooter) {
1757 switch (actor.type) {
1758 case "actor":
1759 return drawActorTypeActor(elem, actor, conf2, isFooter);
1760 case "participant":
1761 return drawActorTypeParticipant(elem, actor, conf2, isFooter);
1762 }
1763};
1764const drawBox = function(elem, box, conf2) {
1765 const boxplustextGroup = elem.append("g");
1766 const g = boxplustextGroup;
1767 drawBackgroundRect(g, box);
1768 if (box.name) {
1769 _drawTextCandidateFunc(conf2)(
1770 box.name,
1771 g,
1772 box.x,
1773 box.y + (box.textMaxHeight || 0) / 2,
1774 box.width,
1775 0,
1776 { class: "text" },
1777 conf2
1778 );
1779 }
1780 g.lower();
1781};
1782const anchorElement = function(elem) {
1783 return elem.append("g");
1784};
1785const drawActivation = function(elem, bounds2, verticalPos, conf2, actorActivations2) {
1786 const rect = getNoteRect$1();
1787 const g = bounds2.anchored;
1788 rect.x = bounds2.startx;
1789 rect.y = bounds2.starty;
1790 rect.class = "activation" + actorActivations2 % 3;
1791 rect.width = bounds2.stopx - bounds2.startx;
1792 rect.height = verticalPos - bounds2.starty;
1793 drawRect(g, rect);
1794};
1795const drawLoop = function(elem, loopModel, labelText, conf2) {
1796 const {
1797 boxMargin,
1798 boxTextMargin,
1799 labelBoxHeight,
1800 labelBoxWidth,
1801 messageFontFamily: fontFamily,
1802 messageFontSize: fontSize,
1803 messageFontWeight: fontWeight
1804 } = conf2;
1805 const g = elem.append("g");
1806 const drawLoopLine = function(startx, starty, stopx, stopy) {
1807 return g.append("line").attr("x1", startx).attr("y1", starty).attr("x2", stopx).attr("y2", stopy).attr("class", "loopLine");
1808 };
1809 drawLoopLine(loopModel.startx, loopModel.starty, loopModel.stopx, loopModel.starty);
1810 drawLoopLine(loopModel.stopx, loopModel.starty, loopModel.stopx, loopModel.stopy);
1811 drawLoopLine(loopModel.startx, loopModel.stopy, loopModel.stopx, loopModel.stopy);
1812 drawLoopLine(loopModel.startx, loopModel.starty, loopModel.startx, loopModel.stopy);
1813 if (loopModel.sections !== void 0) {
1814 loopModel.sections.forEach(function(item) {
1815 drawLoopLine(loopModel.startx, item.y, loopModel.stopx, item.y).style(
1816 "stroke-dasharray",
1817 "3, 3"
1818 );
1819 });
1820 }
1821 let txt = getTextObj$1();
1822 txt.text = labelText;
1823 txt.x = loopModel.startx;
1824 txt.y = loopModel.starty;
1825 txt.fontFamily = fontFamily;
1826 txt.fontSize = fontSize;
1827 txt.fontWeight = fontWeight;
1828 txt.anchor = "middle";
1829 txt.valign = "middle";
1830 txt.tspan = false;
1831 txt.width = labelBoxWidth || 50;
1832 txt.height = labelBoxHeight || 20;
1833 txt.textMargin = boxTextMargin;
1834 txt.class = "labelText";
1835 drawLabel(g, txt);
1836 txt = getTextObj();
1837 txt.text = loopModel.title;
1838 txt.x = loopModel.startx + labelBoxWidth / 2 + (loopModel.stopx - loopModel.startx) / 2;
1839 txt.y = loopModel.starty + boxMargin + boxTextMargin;
1840 txt.anchor = "middle";
1841 txt.valign = "middle";
1842 txt.textMargin = boxTextMargin;
1843 txt.class = "loopText";
1844 txt.fontFamily = fontFamily;
1845 txt.fontSize = fontSize;
1846 txt.fontWeight = fontWeight;
1847 txt.wrap = true;
1848 let textElem = drawText(g, txt);
1849 if (loopModel.sectionTitles !== void 0) {
1850 loopModel.sectionTitles.forEach(function(item, idx) {
1851 if (item.message) {
1852 txt.text = item.message;
1853 txt.x = loopModel.startx + (loopModel.stopx - loopModel.startx) / 2;
1854 txt.y = loopModel.sections[idx].y + boxMargin + boxTextMargin;
1855 txt.class = "loopText";
1856 txt.anchor = "middle";
1857 txt.valign = "middle";
1858 txt.tspan = false;
1859 txt.fontFamily = fontFamily;
1860 txt.fontSize = fontSize;
1861 txt.fontWeight = fontWeight;
1862 txt.wrap = loopModel.wrap;
1863 textElem = drawText(g, txt);
1864 let sectionHeight = Math.round(
1865 textElem.map((te) => (te._groups || te)[0][0].getBBox().height).reduce((acc, curr) => acc + curr)
1866 );
1867 loopModel.sections[idx].height += sectionHeight - (boxMargin + boxTextMargin);
1868 }
1869 });
1870 }
1871 loopModel.height = Math.round(loopModel.stopy - loopModel.starty);
1872 return g;
1873};
1874const drawBackgroundRect = function(elem, bounds2) {
1875 drawBackgroundRect$1(elem, bounds2);
1876};
1877const insertDatabaseIcon = function(elem) {
1878 elem.append("defs").append("symbol").attr("id", "database").attr("fill-rule", "evenodd").attr("clip-rule", "evenodd").append("path").attr("transform", "scale(.5)").attr(
1879 "d",
1880 "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"
1881 );
1882};
1883const insertComputerIcon = function(elem) {
1884 elem.append("defs").append("symbol").attr("id", "computer").attr("width", "24").attr("height", "24").append("path").attr("transform", "scale(.5)").attr(
1885 "d",
1886 "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"
1887 );
1888};
1889const insertClockIcon = function(elem) {
1890 elem.append("defs").append("symbol").attr("id", "clock").attr("width", "24").attr("height", "24").append("path").attr("transform", "scale(.5)").attr(
1891 "d",
1892 "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"
1893 );
1894};
1895const insertArrowHead = function(elem) {
1896 elem.append("defs").append("marker").attr("id", "arrowhead").attr("refX", 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");
1897};
1898const insertArrowFilledHead = function(elem) {
1899 elem.append("defs").append("marker").attr("id", "filled-head").attr("refX", 18).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");
1900};
1901const insertSequenceNumber = function(elem) {
1902 elem.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);
1903};
1904const insertArrowCrossHead = function(elem) {
1905 const defs = elem.append("defs");
1906 const marker = defs.append("marker").attr("id", "crosshead").attr("markerWidth", 15).attr("markerHeight", 8).attr("orient", "auto").attr("refX", 4).attr("refY", 5);
1907 marker.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");
1908};
1909const getTextObj = function() {
1910 return {
1911 x: 0,
1912 y: 0,
1913 fill: void 0,
1914 anchor: void 0,
1915 style: "#666",
1916 width: void 0,
1917 height: void 0,
1918 textMargin: 0,
1919 rx: 0,
1920 ry: 0,
1921 tspan: true,
1922 valign: void 0
1923 };
1924};
1925const getNoteRect = function() {
1926 return {
1927 x: 0,
1928 y: 0,
1929 fill: "#EDF2AE",
1930 stroke: "#666",
1931 width: 100,
1932 anchor: "start",
1933 height: 100,
1934 rx: 0,
1935 ry: 0
1936 };
1937};
1938const _drawTextCandidateFunc = function() {
1939 function byText(content, g, x, y, width, height, textAttrs) {
1940 const text = g.append("text").attr("x", x + width / 2).attr("y", y + height / 2 + 5).style("text-anchor", "middle").text(content);
1941 _setTextAttrs(text, textAttrs);
1942 }
1943 function byTspan(content, g, x, y, width, height, textAttrs, conf2) {
1944 const { actorFontSize, actorFontFamily, actorFontWeight } = conf2;
1945 const [_actorFontSize, _actorFontSizePx] = parseFontSize(actorFontSize);
1946 const lines = content.split(common.lineBreakRegex);
1947 for (let i = 0; i < lines.length; i++) {
1948 const dy = i * _actorFontSize - _actorFontSize * (lines.length - 1) / 2;
1949 const text = g.append("text").attr("x", x + width / 2).attr("y", y).style("text-anchor", "middle").style("font-size", _actorFontSizePx).style("font-weight", actorFontWeight).style("font-family", actorFontFamily);
1950 text.append("tspan").attr("x", x + width / 2).attr("dy", dy).text(lines[i]);
1951 text.attr("y", y + height / 2).attr("dominant-baseline", "central").attr("alignment-baseline", "central");
1952 _setTextAttrs(text, textAttrs);
1953 }
1954 }
1955 function byFo(content, g, x, y, width, height, textAttrs, conf2) {
1956 const s = g.append("switch");
1957 const f = s.append("foreignObject").attr("x", x).attr("y", y).attr("width", width).attr("height", height);
1958 const text = f.append("xhtml:div").style("display", "table").style("height", "100%").style("width", "100%");
1959 text.append("div").style("display", "table-cell").style("text-align", "center").style("vertical-align", "middle").text(content);
1960 byTspan(content, s, x, y, width, height, textAttrs, conf2);
1961 _setTextAttrs(text, textAttrs);
1962 }
1963 function _setTextAttrs(toText, fromTextAttrsDict) {
1964 for (const key in fromTextAttrsDict) {
1965 if (fromTextAttrsDict.hasOwnProperty(key)) {
1966 toText.attr(key, fromTextAttrsDict[key]);
1967 }
1968 }
1969 }
1970 return function(conf2) {
1971 return conf2.textPlacement === "fo" ? byFo : conf2.textPlacement === "old" ? byText : byTspan;
1972 };
1973}();
1974const _drawMenuItemTextCandidateFunc = function() {
1975 function byText(content, g, x, y, width, height, textAttrs) {
1976 const text = g.append("text").attr("x", x).attr("y", y).style("text-anchor", "start").text(content);
1977 _setTextAttrs(text, textAttrs);
1978 }
1979 function byTspan(content, g, x, y, width, height, textAttrs, conf2) {
1980 const { actorFontSize, actorFontFamily, actorFontWeight } = conf2;
1981 const lines = content.split(common.lineBreakRegex);
1982 for (let i = 0; i < lines.length; i++) {
1983 const dy = i * actorFontSize - actorFontSize * (lines.length - 1) / 2;
1984 const text = g.append("text").attr("x", x).attr("y", y).style("text-anchor", "start").style("font-size", actorFontSize).style("font-weight", actorFontWeight).style("font-family", actorFontFamily);
1985 text.append("tspan").attr("x", x).attr("dy", dy).text(lines[i]);
1986 text.attr("y", y + height / 2).attr("dominant-baseline", "central").attr("alignment-baseline", "central");
1987 _setTextAttrs(text, textAttrs);
1988 }
1989 }
1990 function byFo(content, g, x, y, width, height, textAttrs, conf2) {
1991 const s = g.append("switch");
1992 const f = s.append("foreignObject").attr("x", x).attr("y", y).attr("width", width).attr("height", height);
1993 const text = f.append("xhtml:div").style("display", "table").style("height", "100%").style("width", "100%");
1994 text.append("div").style("display", "table-cell").style("text-align", "center").style("vertical-align", "middle").text(content);
1995 byTspan(content, s, x, y, width, height, textAttrs, conf2);
1996 _setTextAttrs(text, textAttrs);
1997 }
1998 function _setTextAttrs(toText, fromTextAttrsDict) {
1999 for (const key in fromTextAttrsDict) {
2000 if (fromTextAttrsDict.hasOwnProperty(key)) {
2001 toText.attr(key, fromTextAttrsDict[key]);
2002 }
2003 }
2004 }
2005 return function(conf2) {
2006 return conf2.textPlacement === "fo" ? byFo : conf2.textPlacement === "old" ? byText : byTspan;
2007 };
2008}();
2009const svgDraw = {
2010 drawRect,
2011 drawText,
2012 drawLabel,
2013 drawActor,
2014 drawBox,
2015 drawPopup,
2016 anchorElement,
2017 drawActivation,
2018 drawLoop,
2019 drawBackgroundRect,
2020 insertArrowHead,
2021 insertArrowFilledHead,
2022 insertSequenceNumber,
2023 insertArrowCrossHead,
2024 insertDatabaseIcon,
2025 insertComputerIcon,
2026 insertClockIcon,
2027 getTextObj,
2028 getNoteRect,
2029 popupMenu,
2030 popdownMenu,
2031 fixLifeLineHeights,
2032 sanitizeUrl: sanitizeUrl_1
2033};
2034let conf = {};
2035const bounds = {
2036 data: {
2037 startx: void 0,
2038 stopx: void 0,
2039 starty: void 0,
2040 stopy: void 0
2041 },
2042 verticalPos: 0,
2043 sequenceItems: [],
2044 activations: [],
2045 models: {
2046 getHeight: function() {
2047 return Math.max.apply(
2048 null,
2049 this.actors.length === 0 ? [0] : this.actors.map((actor) => actor.height || 0)
2050 ) + (this.loops.length === 0 ? 0 : this.loops.map((it) => it.height || 0).reduce((acc, h) => acc + h)) + (this.messages.length === 0 ? 0 : this.messages.map((it) => it.height || 0).reduce((acc, h) => acc + h)) + (this.notes.length === 0 ? 0 : this.notes.map((it) => it.height || 0).reduce((acc, h) => acc + h));
2051 },
2052 clear: function() {
2053 this.actors = [];
2054 this.boxes = [];
2055 this.loops = [];
2056 this.messages = [];
2057 this.notes = [];
2058 },
2059 addBox: function(boxModel) {
2060 this.boxes.push(boxModel);
2061 },
2062 addActor: function(actorModel) {
2063 this.actors.push(actorModel);
2064 },
2065 addLoop: function(loopModel) {
2066 this.loops.push(loopModel);
2067 },
2068 addMessage: function(msgModel) {
2069 this.messages.push(msgModel);
2070 },
2071 addNote: function(noteModel) {
2072 this.notes.push(noteModel);
2073 },
2074 lastActor: function() {
2075 return this.actors[this.actors.length - 1];
2076 },
2077 lastLoop: function() {
2078 return this.loops[this.loops.length - 1];
2079 },
2080 lastMessage: function() {
2081 return this.messages[this.messages.length - 1];
2082 },
2083 lastNote: function() {
2084 return this.notes[this.notes.length - 1];
2085 },
2086 actors: [],
2087 boxes: [],
2088 loops: [],
2089 messages: [],
2090 notes: []
2091 },
2092 init: function() {
2093 this.sequenceItems = [];
2094 this.activations = [];
2095 this.models.clear();
2096 this.data = {
2097 startx: void 0,
2098 stopx: void 0,
2099 starty: void 0,
2100 stopy: void 0
2101 };
2102 this.verticalPos = 0;
2103 setConf(getConfig());
2104 },
2105 updateVal: function(obj, key, val, fun) {
2106 if (obj[key] === void 0) {
2107 obj[key] = val;
2108 } else {
2109 obj[key] = fun(val, obj[key]);
2110 }
2111 },
2112 updateBounds: function(startx, starty, stopx, stopy) {
2113 const _self = this;
2114 let cnt = 0;
2115 function updateFn(type) {
2116 return function updateItemBounds(item) {
2117 cnt++;
2118 const n = _self.sequenceItems.length - cnt + 1;
2119 _self.updateVal(item, "starty", starty - n * conf.boxMargin, Math.min);
2120 _self.updateVal(item, "stopy", stopy + n * conf.boxMargin, Math.max);
2121 _self.updateVal(bounds.data, "startx", startx - n * conf.boxMargin, Math.min);
2122 _self.updateVal(bounds.data, "stopx", stopx + n * conf.boxMargin, Math.max);
2123 if (!(type === "activation")) {
2124 _self.updateVal(item, "startx", startx - n * conf.boxMargin, Math.min);
2125 _self.updateVal(item, "stopx", stopx + n * conf.boxMargin, Math.max);
2126 _self.updateVal(bounds.data, "starty", starty - n * conf.boxMargin, Math.min);
2127 _self.updateVal(bounds.data, "stopy", stopy + n * conf.boxMargin, Math.max);
2128 }
2129 };
2130 }
2131 this.sequenceItems.forEach(updateFn());
2132 this.activations.forEach(updateFn("activation"));
2133 },
2134 insert: function(startx, starty, stopx, stopy) {
2135 const _startx = common.getMin(startx, stopx);
2136 const _stopx = common.getMax(startx, stopx);
2137 const _starty = common.getMin(starty, stopy);
2138 const _stopy = common.getMax(starty, stopy);
2139 this.updateVal(bounds.data, "startx", _startx, Math.min);
2140 this.updateVal(bounds.data, "starty", _starty, Math.min);
2141 this.updateVal(bounds.data, "stopx", _stopx, Math.max);
2142 this.updateVal(bounds.data, "stopy", _stopy, Math.max);
2143 this.updateBounds(_startx, _starty, _stopx, _stopy);
2144 },
2145 newActivation: function(message, diagram2, actors2) {
2146 const actorRect = actors2[message.from.actor];
2147 const stackedSize = actorActivations(message.from.actor).length || 0;
2148 const x = actorRect.x + actorRect.width / 2 + (stackedSize - 1) * conf.activationWidth / 2;
2149 this.activations.push({
2150 startx: x,
2151 starty: this.verticalPos + 2,
2152 stopx: x + conf.activationWidth,
2153 stopy: void 0,
2154 actor: message.from.actor,
2155 anchored: svgDraw.anchorElement(diagram2)
2156 });
2157 },
2158 endActivation: function(message) {
2159 const lastActorActivationIdx = this.activations.map(function(activation) {
2160 return activation.actor;
2161 }).lastIndexOf(message.from.actor);
2162 return this.activations.splice(lastActorActivationIdx, 1)[0];
2163 },
2164 createLoop: function(title = { message: void 0, wrap: false, width: void 0 }, fill) {
2165 return {
2166 startx: void 0,
2167 starty: this.verticalPos,
2168 stopx: void 0,
2169 stopy: void 0,
2170 title: title.message,
2171 wrap: title.wrap,
2172 width: title.width,
2173 height: 0,
2174 fill
2175 };
2176 },
2177 newLoop: function(title = { message: void 0, wrap: false, width: void 0 }, fill) {
2178 this.sequenceItems.push(this.createLoop(title, fill));
2179 },
2180 endLoop: function() {
2181 return this.sequenceItems.pop();
2182 },
2183 isLoopOverlap: function() {
2184 return this.sequenceItems.length ? this.sequenceItems[this.sequenceItems.length - 1].overlap : false;
2185 },
2186 addSectionToLoop: function(message) {
2187 const loop = this.sequenceItems.pop();
2188 loop.sections = loop.sections || [];
2189 loop.sectionTitles = loop.sectionTitles || [];
2190 loop.sections.push({ y: bounds.getVerticalPos(), height: 0 });
2191 loop.sectionTitles.push(message);
2192 this.sequenceItems.push(loop);
2193 },
2194 saveVerticalPos: function() {
2195 if (this.isLoopOverlap()) {
2196 this.savedVerticalPos = this.verticalPos;
2197 }
2198 },
2199 resetVerticalPos: function() {
2200 if (this.isLoopOverlap()) {
2201 this.verticalPos = this.savedVerticalPos;
2202 }
2203 },
2204 bumpVerticalPos: function(bump) {
2205 this.verticalPos = this.verticalPos + bump;
2206 this.data.stopy = common.getMax(this.data.stopy, this.verticalPos);
2207 },
2208 getVerticalPos: function() {
2209 return this.verticalPos;
2210 },
2211 getBounds: function() {
2212 return { bounds: this.data, models: this.models };
2213 }
2214};
2215const drawNote = function(elem, noteModel) {
2216 bounds.bumpVerticalPos(conf.boxMargin);
2217 noteModel.height = conf.boxMargin;
2218 noteModel.starty = bounds.getVerticalPos();
2219 const rect = getNoteRect$1();
2220 rect.x = noteModel.startx;
2221 rect.y = noteModel.starty;
2222 rect.width = noteModel.width || conf.width;
2223 rect.class = "note";
2224 const g = elem.append("g");
2225 const rectElem = svgDraw.drawRect(g, rect);
2226 const textObj = getTextObj$1();
2227 textObj.x = noteModel.startx;
2228 textObj.y = noteModel.starty;
2229 textObj.width = rect.width;
2230 textObj.dy = "1em";
2231 textObj.text = noteModel.message;
2232 textObj.class = "noteText";
2233 textObj.fontFamily = conf.noteFontFamily;
2234 textObj.fontSize = conf.noteFontSize;
2235 textObj.fontWeight = conf.noteFontWeight;
2236 textObj.anchor = conf.noteAlign;
2237 textObj.textMargin = conf.noteMargin;
2238 textObj.valign = "center";
2239 const textElem = drawText(g, textObj);
2240 const textHeight = Math.round(
2241 textElem.map((te) => (te._groups || te)[0][0].getBBox().height).reduce((acc, curr) => acc + curr)
2242 );
2243 rectElem.attr("height", textHeight + 2 * conf.noteMargin);
2244 noteModel.height += textHeight + 2 * conf.noteMargin;
2245 bounds.bumpVerticalPos(textHeight + 2 * conf.noteMargin);
2246 noteModel.stopy = noteModel.starty + textHeight + 2 * conf.noteMargin;
2247 noteModel.stopx = noteModel.startx + rect.width;
2248 bounds.insert(noteModel.startx, noteModel.starty, noteModel.stopx, noteModel.stopy);
2249 bounds.models.addNote(noteModel);
2250};
2251const messageFont = (cnf) => {
2252 return {
2253 fontFamily: cnf.messageFontFamily,
2254 fontSize: cnf.messageFontSize,
2255 fontWeight: cnf.messageFontWeight
2256 };
2257};
2258const noteFont = (cnf) => {
2259 return {
2260 fontFamily: cnf.noteFontFamily,
2261 fontSize: cnf.noteFontSize,
2262 fontWeight: cnf.noteFontWeight
2263 };
2264};
2265const actorFont = (cnf) => {
2266 return {
2267 fontFamily: cnf.actorFontFamily,
2268 fontSize: cnf.actorFontSize,
2269 fontWeight: cnf.actorFontWeight
2270 };
2271};
2272function boundMessage(_diagram, msgModel) {
2273 bounds.bumpVerticalPos(10);
2274 const { startx, stopx, message } = msgModel;
2275 const lines = common.splitBreaks(message).length;
2276 const textDims = utils.calculateTextDimensions(message, messageFont(conf));
2277 const lineHeight = textDims.height / lines;
2278 msgModel.height += lineHeight;
2279 bounds.bumpVerticalPos(lineHeight);
2280 let lineStartY;
2281 let totalOffset = textDims.height - 10;
2282 const textWidth = textDims.width;
2283 if (startx === stopx) {
2284 lineStartY = bounds.getVerticalPos() + totalOffset;
2285 if (!conf.rightAngles) {
2286 totalOffset += conf.boxMargin;
2287 lineStartY = bounds.getVerticalPos() + totalOffset;
2288 }
2289 totalOffset += 30;
2290 const dx = common.getMax(textWidth / 2, conf.width / 2);
2291 bounds.insert(
2292 startx - dx,
2293 bounds.getVerticalPos() - 10 + totalOffset,
2294 stopx + dx,
2295 bounds.getVerticalPos() + 30 + totalOffset
2296 );
2297 } else {
2298 totalOffset += conf.boxMargin;
2299 lineStartY = bounds.getVerticalPos() + totalOffset;
2300 bounds.insert(startx, lineStartY - 10, stopx, lineStartY);
2301 }
2302 bounds.bumpVerticalPos(totalOffset);
2303 msgModel.height += totalOffset;
2304 msgModel.stopy = msgModel.starty + msgModel.height;
2305 bounds.insert(msgModel.fromBounds, msgModel.starty, msgModel.toBounds, msgModel.stopy);
2306 return lineStartY;
2307}
2308const drawMessage = function(diagram2, msgModel, lineStartY, diagObj) {
2309 const { startx, stopx, starty, message, type, sequenceIndex, sequenceVisible } = msgModel;
2310 const textDims = utils.calculateTextDimensions(message, messageFont(conf));
2311 const textObj = getTextObj$1();
2312 textObj.x = startx;
2313 textObj.y = starty + 10;
2314 textObj.width = stopx - startx;
2315 textObj.class = "messageText";
2316 textObj.dy = "1em";
2317 textObj.text = message;
2318 textObj.fontFamily = conf.messageFontFamily;
2319 textObj.fontSize = conf.messageFontSize;
2320 textObj.fontWeight = conf.messageFontWeight;
2321 textObj.anchor = conf.messageAlign;
2322 textObj.valign = "center";
2323 textObj.textMargin = conf.wrapPadding;
2324 textObj.tspan = false;
2325 drawText(diagram2, textObj);
2326 const textWidth = textDims.width;
2327 let line;
2328 if (startx === stopx) {
2329 if (conf.rightAngles) {
2330 line = diagram2.append("path").attr(
2331 "d",
2332 `M ${startx},${lineStartY} H ${startx + common.getMax(conf.width / 2, textWidth / 2)} V ${lineStartY + 25} H ${startx}`
2333 );
2334 } else {
2335 line = diagram2.append("path").attr(
2336 "d",
2337 "M " + startx + "," + lineStartY + " C " + (startx + 60) + "," + (lineStartY - 10) + " " + (startx + 60) + "," + (lineStartY + 30) + " " + startx + "," + (lineStartY + 20)
2338 );
2339 }
2340 } else {
2341 line = diagram2.append("line");
2342 line.attr("x1", startx);
2343 line.attr("y1", lineStartY);
2344 line.attr("x2", stopx);
2345 line.attr("y2", lineStartY);
2346 }
2347 if (type === diagObj.db.LINETYPE.DOTTED || type === diagObj.db.LINETYPE.DOTTED_CROSS || type === diagObj.db.LINETYPE.DOTTED_POINT || type === diagObj.db.LINETYPE.DOTTED_OPEN) {
2348 line.style("stroke-dasharray", "3, 3");
2349 line.attr("class", "messageLine1");
2350 } else {
2351 line.attr("class", "messageLine0");
2352 }
2353 let url = "";
2354 if (conf.arrowMarkerAbsolute) {
2355 url = window.location.protocol + "//" + window.location.host + window.location.pathname + window.location.search;
2356 url = url.replace(/\(/g, "\\(");
2357 url = url.replace(/\)/g, "\\)");
2358 }
2359 line.attr("stroke-width", 2);
2360 line.attr("stroke", "none");
2361 line.style("fill", "none");
2362 if (type === diagObj.db.LINETYPE.SOLID || type === diagObj.db.LINETYPE.DOTTED) {
2363 line.attr("marker-end", "url(" + url + "#arrowhead)");
2364 }
2365 if (type === diagObj.db.LINETYPE.SOLID_POINT || type === diagObj.db.LINETYPE.DOTTED_POINT) {
2366 line.attr("marker-end", "url(" + url + "#filled-head)");
2367 }
2368 if (type === diagObj.db.LINETYPE.SOLID_CROSS || type === diagObj.db.LINETYPE.DOTTED_CROSS) {
2369 line.attr("marker-end", "url(" + url + "#crosshead)");
2370 }
2371 if (sequenceVisible || conf.showSequenceNumbers) {
2372 line.attr("marker-start", "url(" + url + "#sequencenumber)");
2373 diagram2.append("text").attr("x", startx).attr("y", lineStartY + 4).attr("font-family", "sans-serif").attr("font-size", "12px").attr("text-anchor", "middle").attr("class", "sequenceNumber").text(sequenceIndex);
2374 }
2375};
2376const drawActors = function(diagram2, actors2, actorKeys, verticalPos, configuration, messages2, isFooter) {
2377 if (configuration.hideUnusedParticipants === true) {
2378 const newActors = /* @__PURE__ */ new Set();
2379 messages2.forEach((message) => {
2380 newActors.add(message.from);
2381 newActors.add(message.to);
2382 });
2383 actorKeys = actorKeys.filter((actorKey) => newActors.has(actorKey));
2384 }
2385 let prevWidth = 0;
2386 let prevMargin = 0;
2387 let maxHeight = 0;
2388 let prevBox = void 0;
2389 for (const actorKey of actorKeys) {
2390 const actor = actors2[actorKey];
2391 const box = actor.box;
2392 if (prevBox && prevBox != box) {
2393 if (!isFooter) {
2394 bounds.models.addBox(prevBox);
2395 }
2396 prevMargin += conf.boxMargin + prevBox.margin;
2397 }
2398 if (box && box != prevBox) {
2399 if (!isFooter) {
2400 box.x = prevWidth + prevMargin;
2401 box.y = verticalPos;
2402 }
2403 prevMargin += box.margin;
2404 }
2405 actor.width = actor.width || conf.width;
2406 actor.height = common.getMax(actor.height || conf.height, conf.height);
2407 actor.margin = actor.margin || conf.actorMargin;
2408 actor.x = prevWidth + prevMargin;
2409 actor.y = bounds.getVerticalPos();
2410 const height = svgDraw.drawActor(diagram2, actor, conf, isFooter);
2411 maxHeight = common.getMax(maxHeight, height);
2412 bounds.insert(actor.x, verticalPos, actor.x + actor.width, actor.height);
2413 prevWidth += actor.width + prevMargin;
2414 if (actor.box) {
2415 actor.box.width = prevWidth + box.margin - actor.box.x;
2416 }
2417 prevMargin = actor.margin;
2418 prevBox = actor.box;
2419 bounds.models.addActor(actor);
2420 }
2421 if (prevBox && !isFooter) {
2422 bounds.models.addBox(prevBox);
2423 }
2424 bounds.bumpVerticalPos(maxHeight);
2425};
2426const drawActorsPopup = function(diagram2, actors2, actorKeys, doc) {
2427 let maxHeight = 0;
2428 let maxWidth = 0;
2429 for (const actorKey of actorKeys) {
2430 const actor = actors2[actorKey];
2431 const minMenuWidth = getRequiredPopupWidth(actor);
2432 const menuDimensions = svgDraw.drawPopup(
2433 diagram2,
2434 actor,
2435 minMenuWidth,
2436 conf,
2437 conf.forceMenus,
2438 doc
2439 );
2440 if (menuDimensions.height > maxHeight) {
2441 maxHeight = menuDimensions.height;
2442 }
2443 if (menuDimensions.width + actor.x > maxWidth) {
2444 maxWidth = menuDimensions.width + actor.x;
2445 }
2446 }
2447 return { maxHeight, maxWidth };
2448};
2449const setConf = function(cnf) {
2450 assignWithDepth(conf, cnf);
2451 if (cnf.fontFamily) {
2452 conf.actorFontFamily = conf.noteFontFamily = conf.messageFontFamily = cnf.fontFamily;
2453 }
2454 if (cnf.fontSize) {
2455 conf.actorFontSize = conf.noteFontSize = conf.messageFontSize = cnf.fontSize;
2456 }
2457 if (cnf.fontWeight) {
2458 conf.actorFontWeight = conf.noteFontWeight = conf.messageFontWeight = cnf.fontWeight;
2459 }
2460};
2461const actorActivations = function(actor) {
2462 return bounds.activations.filter(function(activation) {
2463 return activation.actor === actor;
2464 });
2465};
2466const activationBounds = function(actor, actors2) {
2467 const actorObj = actors2[actor];
2468 const activations = actorActivations(actor);
2469 const left = activations.reduce(function(acc, activation) {
2470 return common.getMin(acc, activation.startx);
2471 }, actorObj.x + actorObj.width / 2);
2472 const right = activations.reduce(function(acc, activation) {
2473 return common.getMax(acc, activation.stopx);
2474 }, actorObj.x + actorObj.width / 2);
2475 return [left, right];
2476};
2477function adjustLoopHeightForWrap(loopWidths, msg, preMargin, postMargin, addLoopFn) {
2478 bounds.bumpVerticalPos(preMargin);
2479 let heightAdjust = postMargin;
2480 if (msg.id && msg.message && loopWidths[msg.id]) {
2481 const loopWidth = loopWidths[msg.id].width;
2482 const textConf = messageFont(conf);
2483 msg.message = utils.wrapLabel(`[${msg.message}]`, loopWidth - 2 * conf.wrapPadding, textConf);
2484 msg.width = loopWidth;
2485 msg.wrap = true;
2486 const textDims = utils.calculateTextDimensions(msg.message, textConf);
2487 const totalOffset = common.getMax(textDims.height, conf.labelBoxHeight);
2488 heightAdjust = postMargin + totalOffset;
2489 log.debug(`${totalOffset} - ${msg.message}`);
2490 }
2491 addLoopFn(msg);
2492 bounds.bumpVerticalPos(heightAdjust);
2493}
2494const draw = function(_text, id, _version, diagObj) {
2495 const { securityLevel, sequence } = getConfig();
2496 conf = sequence;
2497 diagObj.db.clear();
2498 diagObj.parser.parse(_text);
2499 let sandboxElement;
2500 if (securityLevel === "sandbox") {
2501 sandboxElement = select("#i" + id);
2502 }
2503 const root = securityLevel === "sandbox" ? select(sandboxElement.nodes()[0].contentDocument.body) : select("body");
2504 const doc = securityLevel === "sandbox" ? sandboxElement.nodes()[0].contentDocument : document;
2505 bounds.init();
2506 log.debug(diagObj.db);
2507 const diagram2 = securityLevel === "sandbox" ? root.select(`[id="${id}"]`) : select(`[id="${id}"]`);
2508 const actors2 = diagObj.db.getActors();
2509 const boxes2 = diagObj.db.getBoxes();
2510 const actorKeys = diagObj.db.getActorKeys();
2511 const messages2 = diagObj.db.getMessages();
2512 const title = diagObj.db.getDiagramTitle();
2513 const hasBoxes = diagObj.db.hasAtLeastOneBox();
2514 const hasBoxTitles = diagObj.db.hasAtLeastOneBoxWithTitle();
2515 const maxMessageWidthPerActor = getMaxMessageWidthPerActor(actors2, messages2, diagObj);
2516 conf.height = calculateActorMargins(actors2, maxMessageWidthPerActor, boxes2);
2517 svgDraw.insertComputerIcon(diagram2);
2518 svgDraw.insertDatabaseIcon(diagram2);
2519 svgDraw.insertClockIcon(diagram2);
2520 if (hasBoxes) {
2521 bounds.bumpVerticalPos(conf.boxMargin);
2522 if (hasBoxTitles) {
2523 bounds.bumpVerticalPos(boxes2[0].textMaxHeight);
2524 }
2525 }
2526 drawActors(diagram2, actors2, actorKeys, 0, conf, messages2, false);
2527 const loopWidths = calculateLoopBounds(messages2, actors2, maxMessageWidthPerActor, diagObj);
2528 svgDraw.insertArrowHead(diagram2);
2529 svgDraw.insertArrowCrossHead(diagram2);
2530 svgDraw.insertArrowFilledHead(diagram2);
2531 svgDraw.insertSequenceNumber(diagram2);
2532 function activeEnd(msg, verticalPos) {
2533 const activationData = bounds.endActivation(msg);
2534 if (activationData.starty + 18 > verticalPos) {
2535 activationData.starty = verticalPos - 6;
2536 verticalPos += 12;
2537 }
2538 svgDraw.drawActivation(
2539 diagram2,
2540 activationData,
2541 verticalPos,
2542 conf,
2543 actorActivations(msg.from.actor).length
2544 );
2545 bounds.insert(activationData.startx, verticalPos - 10, activationData.stopx, verticalPos);
2546 }
2547 let sequenceIndex = 1;
2548 let sequenceIndexStep = 1;
2549 const messagesToDraw = [];
2550 messages2.forEach(function(msg) {
2551 let loopModel, noteModel, msgModel;
2552 switch (msg.type) {
2553 case diagObj.db.LINETYPE.NOTE:
2554 bounds.resetVerticalPos();
2555 noteModel = msg.noteModel;
2556 drawNote(diagram2, noteModel);
2557 break;
2558 case diagObj.db.LINETYPE.ACTIVE_START:
2559 bounds.newActivation(msg, diagram2, actors2);
2560 break;
2561 case diagObj.db.LINETYPE.ACTIVE_END:
2562 activeEnd(msg, bounds.getVerticalPos());
2563 break;
2564 case diagObj.db.LINETYPE.LOOP_START:
2565 adjustLoopHeightForWrap(
2566 loopWidths,
2567 msg,
2568 conf.boxMargin,
2569 conf.boxMargin + conf.boxTextMargin,
2570 (message) => bounds.newLoop(message)
2571 );
2572 break;
2573 case diagObj.db.LINETYPE.LOOP_END:
2574 loopModel = bounds.endLoop();
2575 svgDraw.drawLoop(diagram2, loopModel, "loop", conf);
2576 bounds.bumpVerticalPos(loopModel.stopy - bounds.getVerticalPos());
2577 bounds.models.addLoop(loopModel);
2578 break;
2579 case diagObj.db.LINETYPE.RECT_START:
2580 adjustLoopHeightForWrap(
2581 loopWidths,
2582 msg,
2583 conf.boxMargin,
2584 conf.boxMargin,
2585 (message) => bounds.newLoop(void 0, message.message)
2586 );
2587 break;
2588 case diagObj.db.LINETYPE.RECT_END:
2589 loopModel = bounds.endLoop();
2590 svgDraw.drawBackgroundRect(diagram2, loopModel);
2591 bounds.models.addLoop(loopModel);
2592 bounds.bumpVerticalPos(loopModel.stopy - bounds.getVerticalPos());
2593 break;
2594 case diagObj.db.LINETYPE.OPT_START:
2595 adjustLoopHeightForWrap(
2596 loopWidths,
2597 msg,
2598 conf.boxMargin,
2599 conf.boxMargin + conf.boxTextMargin,
2600 (message) => bounds.newLoop(message)
2601 );
2602 break;
2603 case diagObj.db.LINETYPE.OPT_END:
2604 loopModel = bounds.endLoop();
2605 svgDraw.drawLoop(diagram2, loopModel, "opt", conf);
2606 bounds.bumpVerticalPos(loopModel.stopy - bounds.getVerticalPos());
2607 bounds.models.addLoop(loopModel);
2608 break;
2609 case diagObj.db.LINETYPE.ALT_START:
2610 adjustLoopHeightForWrap(
2611 loopWidths,
2612 msg,
2613 conf.boxMargin,
2614 conf.boxMargin + conf.boxTextMargin,
2615 (message) => bounds.newLoop(message)
2616 );
2617 break;
2618 case diagObj.db.LINETYPE.ALT_ELSE:
2619 adjustLoopHeightForWrap(
2620 loopWidths,
2621 msg,
2622 conf.boxMargin + conf.boxTextMargin,
2623 conf.boxMargin,
2624 (message) => bounds.addSectionToLoop(message)
2625 );
2626 break;
2627 case diagObj.db.LINETYPE.ALT_END:
2628 loopModel = bounds.endLoop();
2629 svgDraw.drawLoop(diagram2, loopModel, "alt", conf);
2630 bounds.bumpVerticalPos(loopModel.stopy - bounds.getVerticalPos());
2631 bounds.models.addLoop(loopModel);
2632 break;
2633 case diagObj.db.LINETYPE.PAR_START:
2634 case diagObj.db.LINETYPE.PAR_OVER_START:
2635 adjustLoopHeightForWrap(
2636 loopWidths,
2637 msg,
2638 conf.boxMargin,
2639 conf.boxMargin + conf.boxTextMargin,
2640 (message) => bounds.newLoop(message)
2641 );
2642 bounds.saveVerticalPos();
2643 break;
2644 case diagObj.db.LINETYPE.PAR_AND:
2645 adjustLoopHeightForWrap(
2646 loopWidths,
2647 msg,
2648 conf.boxMargin + conf.boxTextMargin,
2649 conf.boxMargin,
2650 (message) => bounds.addSectionToLoop(message)
2651 );
2652 break;
2653 case diagObj.db.LINETYPE.PAR_END:
2654 loopModel = bounds.endLoop();
2655 svgDraw.drawLoop(diagram2, loopModel, "par", conf);
2656 bounds.bumpVerticalPos(loopModel.stopy - bounds.getVerticalPos());
2657 bounds.models.addLoop(loopModel);
2658 break;
2659 case diagObj.db.LINETYPE.AUTONUMBER:
2660 sequenceIndex = msg.message.start || sequenceIndex;
2661 sequenceIndexStep = msg.message.step || sequenceIndexStep;
2662 if (msg.message.visible) {
2663 diagObj.db.enableSequenceNumbers();
2664 } else {
2665 diagObj.db.disableSequenceNumbers();
2666 }
2667 break;
2668 case diagObj.db.LINETYPE.CRITICAL_START:
2669 adjustLoopHeightForWrap(
2670 loopWidths,
2671 msg,
2672 conf.boxMargin,
2673 conf.boxMargin + conf.boxTextMargin,
2674 (message) => bounds.newLoop(message)
2675 );
2676 break;
2677 case diagObj.db.LINETYPE.CRITICAL_OPTION:
2678 adjustLoopHeightForWrap(
2679 loopWidths,
2680 msg,
2681 conf.boxMargin + conf.boxTextMargin,
2682 conf.boxMargin,
2683 (message) => bounds.addSectionToLoop(message)
2684 );
2685 break;
2686 case diagObj.db.LINETYPE.CRITICAL_END:
2687 loopModel = bounds.endLoop();
2688 svgDraw.drawLoop(diagram2, loopModel, "critical", conf);
2689 bounds.bumpVerticalPos(loopModel.stopy - bounds.getVerticalPos());
2690 bounds.models.addLoop(loopModel);
2691 break;
2692 case diagObj.db.LINETYPE.BREAK_START:
2693 adjustLoopHeightForWrap(
2694 loopWidths,
2695 msg,
2696 conf.boxMargin,
2697 conf.boxMargin + conf.boxTextMargin,
2698 (message) => bounds.newLoop(message)
2699 );
2700 break;
2701 case diagObj.db.LINETYPE.BREAK_END:
2702 loopModel = bounds.endLoop();
2703 svgDraw.drawLoop(diagram2, loopModel, "break", conf);
2704 bounds.bumpVerticalPos(loopModel.stopy - bounds.getVerticalPos());
2705 bounds.models.addLoop(loopModel);
2706 break;
2707 default:
2708 try {
2709 bounds.resetVerticalPos();
2710 msgModel = msg.msgModel;
2711 msgModel.starty = bounds.getVerticalPos();
2712 msgModel.sequenceIndex = sequenceIndex;
2713 msgModel.sequenceVisible = diagObj.db.showSequenceNumbers();
2714 const lineStartY = boundMessage(diagram2, msgModel);
2715 messagesToDraw.push({ messageModel: msgModel, lineStartY });
2716 bounds.models.addMessage(msgModel);
2717 } catch (e) {
2718 log.error("error while drawing message", e);
2719 }
2720 }
2721 if ([
2722 diagObj.db.LINETYPE.SOLID_OPEN,
2723 diagObj.db.LINETYPE.DOTTED_OPEN,
2724 diagObj.db.LINETYPE.SOLID,
2725 diagObj.db.LINETYPE.DOTTED,
2726 diagObj.db.LINETYPE.SOLID_CROSS,
2727 diagObj.db.LINETYPE.DOTTED_CROSS,
2728 diagObj.db.LINETYPE.SOLID_POINT,
2729 diagObj.db.LINETYPE.DOTTED_POINT
2730 ].includes(msg.type)) {
2731 sequenceIndex = sequenceIndex + sequenceIndexStep;
2732 }
2733 });
2734 messagesToDraw.forEach((e) => drawMessage(diagram2, e.messageModel, e.lineStartY, diagObj));
2735 if (conf.mirrorActors) {
2736 bounds.bumpVerticalPos(conf.boxMargin * 2);
2737 drawActors(diagram2, actors2, actorKeys, bounds.getVerticalPos(), conf, messages2, true);
2738 bounds.bumpVerticalPos(conf.boxMargin);
2739 fixLifeLineHeights(diagram2, bounds.getVerticalPos());
2740 }
2741 bounds.models.boxes.forEach(function(box2) {
2742 box2.height = bounds.getVerticalPos() - box2.y;
2743 bounds.insert(box2.x, box2.y, box2.x + box2.width, box2.height);
2744 box2.startx = box2.x;
2745 box2.starty = box2.y;
2746 box2.stopx = box2.startx + box2.width;
2747 box2.stopy = box2.starty + box2.height;
2748 box2.stroke = "rgb(0,0,0, 0.5)";
2749 svgDraw.drawBox(diagram2, box2, conf);
2750 });
2751 if (hasBoxes) {
2752 bounds.bumpVerticalPos(conf.boxMargin);
2753 }
2754 const requiredBoxSize = drawActorsPopup(diagram2, actors2, actorKeys, doc);
2755 const { bounds: box } = bounds.getBounds();
2756 log.debug("For line height fix Querying: #" + id + " .actor-line");
2757 const actorLines = selectAll("#" + id + " .actor-line");
2758 actorLines.attr("y2", box.stopy);
2759 let boxHeight = box.stopy - box.starty;
2760 if (boxHeight < requiredBoxSize.maxHeight) {
2761 boxHeight = requiredBoxSize.maxHeight;
2762 }
2763 let height = boxHeight + 2 * conf.diagramMarginY;
2764 if (conf.mirrorActors) {
2765 height = height - conf.boxMargin + conf.bottomMarginAdj;
2766 }
2767 let boxWidth = box.stopx - box.startx;
2768 if (boxWidth < requiredBoxSize.maxWidth) {
2769 boxWidth = requiredBoxSize.maxWidth;
2770 }
2771 const width = boxWidth + 2 * conf.diagramMarginX;
2772 if (title) {
2773 diagram2.append("text").text(title).attr("x", (box.stopx - box.startx) / 2 - 2 * conf.diagramMarginX).attr("y", -25);
2774 }
2775 configureSvgSize(diagram2, height, width, conf.useMaxWidth);
2776 const extraVertForTitle = title ? 40 : 0;
2777 diagram2.attr(
2778 "viewBox",
2779 box.startx - conf.diagramMarginX + " -" + (conf.diagramMarginY + extraVertForTitle) + " " + width + " " + (height + extraVertForTitle)
2780 );
2781 log.debug(`models:`, bounds.models);
2782};
2783function getMaxMessageWidthPerActor(actors2, messages2, diagObj) {
2784 const maxMessageWidthPerActor = {};
2785 messages2.forEach(function(msg) {
2786 if (actors2[msg.to] && actors2[msg.from]) {
2787 const actor = actors2[msg.to];
2788 if (msg.placement === diagObj.db.PLACEMENT.LEFTOF && !actor.prevActor) {
2789 return;
2790 }
2791 if (msg.placement === diagObj.db.PLACEMENT.RIGHTOF && !actor.nextActor) {
2792 return;
2793 }
2794 const isNote = msg.placement !== void 0;
2795 const isMessage = !isNote;
2796 const textFont = isNote ? noteFont(conf) : messageFont(conf);
2797 const wrappedMessage = msg.wrap ? utils.wrapLabel(msg.message, conf.width - 2 * conf.wrapPadding, textFont) : msg.message;
2798 const messageDimensions = utils.calculateTextDimensions(wrappedMessage, textFont);
2799 const messageWidth = messageDimensions.width + 2 * conf.wrapPadding;
2800 if (isMessage && msg.from === actor.nextActor) {
2801 maxMessageWidthPerActor[msg.to] = common.getMax(
2802 maxMessageWidthPerActor[msg.to] || 0,
2803 messageWidth
2804 );
2805 } else if (isMessage && msg.from === actor.prevActor) {
2806 maxMessageWidthPerActor[msg.from] = common.getMax(
2807 maxMessageWidthPerActor[msg.from] || 0,
2808 messageWidth
2809 );
2810 } else if (isMessage && msg.from === msg.to) {
2811 maxMessageWidthPerActor[msg.from] = common.getMax(
2812 maxMessageWidthPerActor[msg.from] || 0,
2813 messageWidth / 2
2814 );
2815 maxMessageWidthPerActor[msg.to] = common.getMax(
2816 maxMessageWidthPerActor[msg.to] || 0,
2817 messageWidth / 2
2818 );
2819 } else if (msg.placement === diagObj.db.PLACEMENT.RIGHTOF) {
2820 maxMessageWidthPerActor[msg.from] = common.getMax(
2821 maxMessageWidthPerActor[msg.from] || 0,
2822 messageWidth
2823 );
2824 } else if (msg.placement === diagObj.db.PLACEMENT.LEFTOF) {
2825 maxMessageWidthPerActor[actor.prevActor] = common.getMax(
2826 maxMessageWidthPerActor[actor.prevActor] || 0,
2827 messageWidth
2828 );
2829 } else if (msg.placement === diagObj.db.PLACEMENT.OVER) {
2830 if (actor.prevActor) {
2831 maxMessageWidthPerActor[actor.prevActor] = common.getMax(
2832 maxMessageWidthPerActor[actor.prevActor] || 0,
2833 messageWidth / 2
2834 );
2835 }
2836 if (actor.nextActor) {
2837 maxMessageWidthPerActor[msg.from] = common.getMax(
2838 maxMessageWidthPerActor[msg.from] || 0,
2839 messageWidth / 2
2840 );
2841 }
2842 }
2843 }
2844 });
2845 log.debug("maxMessageWidthPerActor:", maxMessageWidthPerActor);
2846 return maxMessageWidthPerActor;
2847}
2848const getRequiredPopupWidth = function(actor) {
2849 let requiredPopupWidth = 0;
2850 const textFont = actorFont(conf);
2851 for (const key in actor.links) {
2852 const labelDimensions = utils.calculateTextDimensions(key, textFont);
2853 const labelWidth = labelDimensions.width + 2 * conf.wrapPadding + 2 * conf.boxMargin;
2854 if (requiredPopupWidth < labelWidth) {
2855 requiredPopupWidth = labelWidth;
2856 }
2857 }
2858 return requiredPopupWidth;
2859};
2860function calculateActorMargins(actors2, actorToMessageWidth, boxes2) {
2861 let maxHeight = 0;
2862 Object.keys(actors2).forEach((prop) => {
2863 const actor = actors2[prop];
2864 if (actor.wrap) {
2865 actor.description = utils.wrapLabel(
2866 actor.description,
2867 conf.width - 2 * conf.wrapPadding,
2868 actorFont(conf)
2869 );
2870 }
2871 const actDims = utils.calculateTextDimensions(actor.description, actorFont(conf));
2872 actor.width = actor.wrap ? conf.width : common.getMax(conf.width, actDims.width + 2 * conf.wrapPadding);
2873 actor.height = actor.wrap ? common.getMax(actDims.height, conf.height) : conf.height;
2874 maxHeight = common.getMax(maxHeight, actor.height);
2875 });
2876 for (const actorKey in actorToMessageWidth) {
2877 const actor = actors2[actorKey];
2878 if (!actor) {
2879 continue;
2880 }
2881 const nextActor = actors2[actor.nextActor];
2882 if (!nextActor) {
2883 const messageWidth2 = actorToMessageWidth[actorKey];
2884 const actorWidth2 = messageWidth2 + conf.actorMargin - actor.width / 2;
2885 actor.margin = common.getMax(actorWidth2, conf.actorMargin);
2886 continue;
2887 }
2888 const messageWidth = actorToMessageWidth[actorKey];
2889 const actorWidth = messageWidth + conf.actorMargin - actor.width / 2 - nextActor.width / 2;
2890 actor.margin = common.getMax(actorWidth, conf.actorMargin);
2891 }
2892 let maxBoxHeight = 0;
2893 boxes2.forEach((box) => {
2894 const textFont = messageFont(conf);
2895 let totalWidth = box.actorKeys.reduce((total, aKey) => {
2896 return total += actors2[aKey].width + (actors2[aKey].margin || 0);
2897 }, 0);
2898 totalWidth -= 2 * conf.boxTextMargin;
2899 if (box.wrap) {
2900 box.name = utils.wrapLabel(box.name, totalWidth - 2 * conf.wrapPadding, textFont);
2901 }
2902 const boxMsgDimensions = utils.calculateTextDimensions(box.name, textFont);
2903 maxBoxHeight = common.getMax(boxMsgDimensions.height, maxBoxHeight);
2904 const minWidth = common.getMax(totalWidth, boxMsgDimensions.width + 2 * conf.wrapPadding);
2905 box.margin = conf.boxTextMargin;
2906 if (totalWidth < minWidth) {
2907 const missing = (minWidth - totalWidth) / 2;
2908 box.margin += missing;
2909 }
2910 });
2911 boxes2.forEach((box) => box.textMaxHeight = maxBoxHeight);
2912 return common.getMax(maxHeight, conf.height);
2913}
2914const buildNoteModel = function(msg, actors2, diagObj) {
2915 const startx = actors2[msg.from].x;
2916 const stopx = actors2[msg.to].x;
2917 const shouldWrap = msg.wrap && msg.message;
2918 let textDimensions = utils.calculateTextDimensions(
2919 shouldWrap ? utils.wrapLabel(msg.message, conf.width, noteFont(conf)) : msg.message,
2920 noteFont(conf)
2921 );
2922 const noteModel = {
2923 width: shouldWrap ? conf.width : common.getMax(conf.width, textDimensions.width + 2 * conf.noteMargin),
2924 height: 0,
2925 startx: actors2[msg.from].x,
2926 stopx: 0,
2927 starty: 0,
2928 stopy: 0,
2929 message: msg.message
2930 };
2931 if (msg.placement === diagObj.db.PLACEMENT.RIGHTOF) {
2932 noteModel.width = shouldWrap ? common.getMax(conf.width, textDimensions.width) : common.getMax(
2933 actors2[msg.from].width / 2 + actors2[msg.to].width / 2,
2934 textDimensions.width + 2 * conf.noteMargin
2935 );
2936 noteModel.startx = startx + (actors2[msg.from].width + conf.actorMargin) / 2;
2937 } else if (msg.placement === diagObj.db.PLACEMENT.LEFTOF) {
2938 noteModel.width = shouldWrap ? common.getMax(conf.width, textDimensions.width + 2 * conf.noteMargin) : common.getMax(
2939 actors2[msg.from].width / 2 + actors2[msg.to].width / 2,
2940 textDimensions.width + 2 * conf.noteMargin
2941 );
2942 noteModel.startx = startx - noteModel.width + (actors2[msg.from].width - conf.actorMargin) / 2;
2943 } else if (msg.to === msg.from) {
2944 textDimensions = utils.calculateTextDimensions(
2945 shouldWrap ? utils.wrapLabel(
2946 msg.message,
2947 common.getMax(conf.width, actors2[msg.from].width),
2948 noteFont(conf)
2949 ) : msg.message,
2950 noteFont(conf)
2951 );
2952 noteModel.width = shouldWrap ? common.getMax(conf.width, actors2[msg.from].width) : common.getMax(
2953 actors2[msg.from].width,
2954 conf.width,
2955 textDimensions.width + 2 * conf.noteMargin
2956 );
2957 noteModel.startx = startx + (actors2[msg.from].width - noteModel.width) / 2;
2958 } else {
2959 noteModel.width = Math.abs(startx + actors2[msg.from].width / 2 - (stopx + actors2[msg.to].width / 2)) + conf.actorMargin;
2960 noteModel.startx = startx < stopx ? startx + actors2[msg.from].width / 2 - conf.actorMargin / 2 : stopx + actors2[msg.to].width / 2 - conf.actorMargin / 2;
2961 }
2962 if (shouldWrap) {
2963 noteModel.message = utils.wrapLabel(
2964 msg.message,
2965 noteModel.width - 2 * conf.wrapPadding,
2966 noteFont(conf)
2967 );
2968 }
2969 log.debug(
2970 `NM:[${noteModel.startx},${noteModel.stopx},${noteModel.starty},${noteModel.stopy}:${noteModel.width},${noteModel.height}=${msg.message}]`
2971 );
2972 return noteModel;
2973};
2974const buildMessageModel = function(msg, actors2, diagObj) {
2975 let process = false;
2976 if ([
2977 diagObj.db.LINETYPE.SOLID_OPEN,
2978 diagObj.db.LINETYPE.DOTTED_OPEN,
2979 diagObj.db.LINETYPE.SOLID,
2980 diagObj.db.LINETYPE.DOTTED,
2981 diagObj.db.LINETYPE.SOLID_CROSS,
2982 diagObj.db.LINETYPE.DOTTED_CROSS,
2983 diagObj.db.LINETYPE.SOLID_POINT,
2984 diagObj.db.LINETYPE.DOTTED_POINT
2985 ].includes(msg.type)) {
2986 process = true;
2987 }
2988 if (!process) {
2989 return {};
2990 }
2991 const fromBounds = activationBounds(msg.from, actors2);
2992 const toBounds = activationBounds(msg.to, actors2);
2993 const fromIdx = fromBounds[0] <= toBounds[0] ? 1 : 0;
2994 const toIdx = fromBounds[0] < toBounds[0] ? 0 : 1;
2995 const allBounds = [...fromBounds, ...toBounds];
2996 const boundedWidth = Math.abs(toBounds[toIdx] - fromBounds[fromIdx]);
2997 if (msg.wrap && msg.message) {
2998 msg.message = utils.wrapLabel(
2999 msg.message,
3000 common.getMax(boundedWidth + 2 * conf.wrapPadding, conf.width),
3001 messageFont(conf)
3002 );
3003 }
3004 const msgDims = utils.calculateTextDimensions(msg.message, messageFont(conf));
3005 return {
3006 width: common.getMax(
3007 msg.wrap ? 0 : msgDims.width + 2 * conf.wrapPadding,
3008 boundedWidth + 2 * conf.wrapPadding,
3009 conf.width
3010 ),
3011 height: 0,
3012 startx: fromBounds[fromIdx],
3013 stopx: toBounds[toIdx],
3014 starty: 0,
3015 stopy: 0,
3016 message: msg.message,
3017 type: msg.type,
3018 wrap: msg.wrap,
3019 fromBounds: Math.min.apply(null, allBounds),
3020 toBounds: Math.max.apply(null, allBounds)
3021 };
3022};
3023const calculateLoopBounds = function(messages2, actors2, _maxWidthPerActor, diagObj) {
3024 const loops = {};
3025 const stack = [];
3026 let current, noteModel, msgModel;
3027 messages2.forEach(function(msg) {
3028 msg.id = utils.random({ length: 10 });
3029 switch (msg.type) {
3030 case diagObj.db.LINETYPE.LOOP_START:
3031 case diagObj.db.LINETYPE.ALT_START:
3032 case diagObj.db.LINETYPE.OPT_START:
3033 case diagObj.db.LINETYPE.PAR_START:
3034 case diagObj.db.LINETYPE.PAR_OVER_START:
3035 case diagObj.db.LINETYPE.CRITICAL_START:
3036 case diagObj.db.LINETYPE.BREAK_START:
3037 stack.push({
3038 id: msg.id,
3039 msg: msg.message,
3040 from: Number.MAX_SAFE_INTEGER,
3041 to: Number.MIN_SAFE_INTEGER,
3042 width: 0
3043 });
3044 break;
3045 case diagObj.db.LINETYPE.ALT_ELSE:
3046 case diagObj.db.LINETYPE.PAR_AND:
3047 case diagObj.db.LINETYPE.CRITICAL_OPTION:
3048 if (msg.message) {
3049 current = stack.pop();
3050 loops[current.id] = current;
3051 loops[msg.id] = current;
3052 stack.push(current);
3053 }
3054 break;
3055 case diagObj.db.LINETYPE.LOOP_END:
3056 case diagObj.db.LINETYPE.ALT_END:
3057 case diagObj.db.LINETYPE.OPT_END:
3058 case diagObj.db.LINETYPE.PAR_END:
3059 case diagObj.db.LINETYPE.CRITICAL_END:
3060 case diagObj.db.LINETYPE.BREAK_END:
3061 current = stack.pop();
3062 loops[current.id] = current;
3063 break;
3064 case diagObj.db.LINETYPE.ACTIVE_START:
3065 {
3066 const actorRect = actors2[msg.from ? msg.from.actor : msg.to.actor];
3067 const stackedSize = actorActivations(msg.from ? msg.from.actor : msg.to.actor).length;
3068 const x = actorRect.x + actorRect.width / 2 + (stackedSize - 1) * conf.activationWidth / 2;
3069 const toAdd = {
3070 startx: x,
3071 stopx: x + conf.activationWidth,
3072 actor: msg.from.actor,
3073 enabled: true
3074 };
3075 bounds.activations.push(toAdd);
3076 }
3077 break;
3078 case diagObj.db.LINETYPE.ACTIVE_END:
3079 {
3080 const lastActorActivationIdx = bounds.activations.map((a) => a.actor).lastIndexOf(msg.from.actor);
3081 delete bounds.activations.splice(lastActorActivationIdx, 1)[0];
3082 }
3083 break;
3084 }
3085 const isNote = msg.placement !== void 0;
3086 if (isNote) {
3087 noteModel = buildNoteModel(msg, actors2, diagObj);
3088 msg.noteModel = noteModel;
3089 stack.forEach((stk) => {
3090 current = stk;
3091 current.from = common.getMin(current.from, noteModel.startx);
3092 current.to = common.getMax(current.to, noteModel.startx + noteModel.width);
3093 current.width = common.getMax(current.width, Math.abs(current.from - current.to)) - conf.labelBoxWidth;
3094 });
3095 } else {
3096 msgModel = buildMessageModel(msg, actors2, diagObj);
3097 msg.msgModel = msgModel;
3098 if (msgModel.startx && msgModel.stopx && stack.length > 0) {
3099 stack.forEach((stk) => {
3100 current = stk;
3101 if (msgModel.startx === msgModel.stopx) {
3102 const from = actors2[msg.from];
3103 const to = actors2[msg.to];
3104 current.from = common.getMin(
3105 from.x - msgModel.width / 2,
3106 from.x - from.width / 2,
3107 current.from
3108 );
3109 current.to = common.getMax(
3110 to.x + msgModel.width / 2,
3111 to.x + from.width / 2,
3112 current.to
3113 );
3114 current.width = common.getMax(current.width, Math.abs(current.to - current.from)) - conf.labelBoxWidth;
3115 } else {
3116 current.from = common.getMin(msgModel.startx, current.from);
3117 current.to = common.getMax(msgModel.stopx, current.to);
3118 current.width = common.getMax(current.width, msgModel.width) - conf.labelBoxWidth;
3119 }
3120 });
3121 }
3122 }
3123 });
3124 bounds.activations = [];
3125 log.debug("Loop type widths:", loops);
3126 return loops;
3127};
3128const renderer = {
3129 bounds,
3130 drawActors,
3131 drawActorsPopup,
3132 setConf,
3133 draw
3134};
3135const diagram = {
3136 parser: parser$1,
3137 db,
3138 renderer,
3139 styles
3140};
3141export {
3142 diagram
3143};