UNPKG

46 kBJavaScriptView Raw
1import { c as getConfig, s as setAccTitle, g as getAccTitle, b as setAccDescription, a as getAccDescription, m as mermaidAPI, l as log, v as clear$1, i as configureSvgSize, e as common } from "./mermaid-a953d906.js";
2import { select, line } from "d3";
3import { layout } from "dagre-d3-es/src/dagre/index.js";
4import * as graphlib from "dagre-d3-es/src/graphlib/index.js";
5import "ts-dedent";
6import "dayjs/esm/index.js";
7import "@braintree/sanitize-url";
8import "dompurify";
9import "khroma";
10import "lodash-es/memoize.js";
11import "stylis";
12import "lodash-es/isEmpty.js";
13var parser = function() {
14 var o = function(k, v, o2, l) {
15 for (o2 = o2 || {}, l = k.length; l--; o2[k[l]] = v)
16 ;
17 return o2;
18 }, $V0 = [1, 3], $V1 = [1, 5], $V2 = [1, 6], $V3 = [1, 7], $V4 = [1, 8], $V5 = [5, 6, 8, 14, 16, 18, 19, 40, 41, 42, 43, 44, 45, 53, 71, 72], $V6 = [1, 22], $V7 = [2, 13], $V8 = [1, 26], $V9 = [1, 27], $Va = [1, 28], $Vb = [1, 29], $Vc = [1, 30], $Vd = [1, 31], $Ve = [1, 24], $Vf = [1, 32], $Vg = [1, 33], $Vh = [1, 36], $Vi = [71, 72], $Vj = [5, 8, 14, 16, 18, 19, 40, 41, 42, 43, 44, 45, 53, 60, 62, 71, 72], $Vk = [1, 56], $Vl = [1, 57], $Vm = [1, 58], $Vn = [1, 59], $Vo = [1, 60], $Vp = [1, 61], $Vq = [1, 62], $Vr = [62, 63], $Vs = [1, 74], $Vt = [1, 70], $Vu = [1, 71], $Vv = [1, 72], $Vw = [1, 73], $Vx = [1, 75], $Vy = [1, 79], $Vz = [1, 80], $VA = [1, 77], $VB = [1, 78], $VC = [5, 8, 14, 16, 18, 19, 40, 41, 42, 43, 44, 45, 53, 71, 72];
19 var parser2 = {
20 trace: function trace() {
21 },
22 yy: {},
23 symbols_: { "error": 2, "start": 3, "directive": 4, "NEWLINE": 5, "RD": 6, "diagram": 7, "EOF": 8, "openDirective": 9, "typeDirective": 10, "closeDirective": 11, ":": 12, "argDirective": 13, "acc_title": 14, "acc_title_value": 15, "acc_descr": 16, "acc_descr_value": 17, "acc_descr_multiline_value": 18, "open_directive": 19, "type_directive": 20, "arg_directive": 21, "close_directive": 22, "requirementDef": 23, "elementDef": 24, "relationshipDef": 25, "requirementType": 26, "requirementName": 27, "STRUCT_START": 28, "requirementBody": 29, "ID": 30, "COLONSEP": 31, "id": 32, "TEXT": 33, "text": 34, "RISK": 35, "riskLevel": 36, "VERIFYMTHD": 37, "verifyType": 38, "STRUCT_STOP": 39, "REQUIREMENT": 40, "FUNCTIONAL_REQUIREMENT": 41, "INTERFACE_REQUIREMENT": 42, "PERFORMANCE_REQUIREMENT": 43, "PHYSICAL_REQUIREMENT": 44, "DESIGN_CONSTRAINT": 45, "LOW_RISK": 46, "MED_RISK": 47, "HIGH_RISK": 48, "VERIFY_ANALYSIS": 49, "VERIFY_DEMONSTRATION": 50, "VERIFY_INSPECTION": 51, "VERIFY_TEST": 52, "ELEMENT": 53, "elementName": 54, "elementBody": 55, "TYPE": 56, "type": 57, "DOCREF": 58, "ref": 59, "END_ARROW_L": 60, "relationship": 61, "LINE": 62, "END_ARROW_R": 63, "CONTAINS": 64, "COPIES": 65, "DERIVES": 66, "SATISFIES": 67, "VERIFIES": 68, "REFINES": 69, "TRACES": 70, "unqString": 71, "qString": 72, "$accept": 0, "$end": 1 },
24 terminals_: { 2: "error", 5: "NEWLINE", 6: "RD", 8: "EOF", 12: ":", 14: "acc_title", 15: "acc_title_value", 16: "acc_descr", 17: "acc_descr_value", 18: "acc_descr_multiline_value", 19: "open_directive", 20: "type_directive", 21: "arg_directive", 22: "close_directive", 28: "STRUCT_START", 30: "ID", 31: "COLONSEP", 33: "TEXT", 35: "RISK", 37: "VERIFYMTHD", 39: "STRUCT_STOP", 40: "REQUIREMENT", 41: "FUNCTIONAL_REQUIREMENT", 42: "INTERFACE_REQUIREMENT", 43: "PERFORMANCE_REQUIREMENT", 44: "PHYSICAL_REQUIREMENT", 45: "DESIGN_CONSTRAINT", 46: "LOW_RISK", 47: "MED_RISK", 48: "HIGH_RISK", 49: "VERIFY_ANALYSIS", 50: "VERIFY_DEMONSTRATION", 51: "VERIFY_INSPECTION", 52: "VERIFY_TEST", 53: "ELEMENT", 56: "TYPE", 58: "DOCREF", 60: "END_ARROW_L", 62: "LINE", 63: "END_ARROW_R", 64: "CONTAINS", 65: "COPIES", 66: "DERIVES", 67: "SATISFIES", 68: "VERIFIES", 69: "REFINES", 70: "TRACES", 71: "unqString", 72: "qString" },
25 productions_: [0, [3, 3], [3, 2], [3, 4], [4, 3], [4, 5], [4, 2], [4, 2], [4, 1], [9, 1], [10, 1], [13, 1], [11, 1], [7, 0], [7, 2], [7, 2], [7, 2], [7, 2], [7, 2], [23, 5], [29, 5], [29, 5], [29, 5], [29, 5], [29, 2], [29, 1], [26, 1], [26, 1], [26, 1], [26, 1], [26, 1], [26, 1], [36, 1], [36, 1], [36, 1], [38, 1], [38, 1], [38, 1], [38, 1], [24, 5], [55, 5], [55, 5], [55, 2], [55, 1], [25, 5], [25, 5], [61, 1], [61, 1], [61, 1], [61, 1], [61, 1], [61, 1], [61, 1], [27, 1], [27, 1], [32, 1], [32, 1], [34, 1], [34, 1], [54, 1], [54, 1], [57, 1], [57, 1], [59, 1], [59, 1]],
26 performAction: function anonymous(yytext, yyleng, yylineno, yy, yystate, $$, _$) {
27 var $0 = $$.length - 1;
28 switch (yystate) {
29 case 6:
30 this.$ = $$[$0].trim();
31 yy.setAccTitle(this.$);
32 break;
33 case 7:
34 case 8:
35 this.$ = $$[$0].trim();
36 yy.setAccDescription(this.$);
37 break;
38 case 9:
39 yy.parseDirective("%%{", "open_directive");
40 break;
41 case 10:
42 yy.parseDirective($$[$0], "type_directive");
43 break;
44 case 11:
45 $$[$0] = $$[$0].trim().replace(/'/g, '"');
46 yy.parseDirective($$[$0], "arg_directive");
47 break;
48 case 12:
49 yy.parseDirective("}%%", "close_directive", "pie");
50 break;
51 case 13:
52 this.$ = [];
53 break;
54 case 19:
55 yy.addRequirement($$[$0 - 3], $$[$0 - 4]);
56 break;
57 case 20:
58 yy.setNewReqId($$[$0 - 2]);
59 break;
60 case 21:
61 yy.setNewReqText($$[$0 - 2]);
62 break;
63 case 22:
64 yy.setNewReqRisk($$[$0 - 2]);
65 break;
66 case 23:
67 yy.setNewReqVerifyMethod($$[$0 - 2]);
68 break;
69 case 26:
70 this.$ = yy.RequirementType.REQUIREMENT;
71 break;
72 case 27:
73 this.$ = yy.RequirementType.FUNCTIONAL_REQUIREMENT;
74 break;
75 case 28:
76 this.$ = yy.RequirementType.INTERFACE_REQUIREMENT;
77 break;
78 case 29:
79 this.$ = yy.RequirementType.PERFORMANCE_REQUIREMENT;
80 break;
81 case 30:
82 this.$ = yy.RequirementType.PHYSICAL_REQUIREMENT;
83 break;
84 case 31:
85 this.$ = yy.RequirementType.DESIGN_CONSTRAINT;
86 break;
87 case 32:
88 this.$ = yy.RiskLevel.LOW_RISK;
89 break;
90 case 33:
91 this.$ = yy.RiskLevel.MED_RISK;
92 break;
93 case 34:
94 this.$ = yy.RiskLevel.HIGH_RISK;
95 break;
96 case 35:
97 this.$ = yy.VerifyType.VERIFY_ANALYSIS;
98 break;
99 case 36:
100 this.$ = yy.VerifyType.VERIFY_DEMONSTRATION;
101 break;
102 case 37:
103 this.$ = yy.VerifyType.VERIFY_INSPECTION;
104 break;
105 case 38:
106 this.$ = yy.VerifyType.VERIFY_TEST;
107 break;
108 case 39:
109 yy.addElement($$[$0 - 3]);
110 break;
111 case 40:
112 yy.setNewElementType($$[$0 - 2]);
113 break;
114 case 41:
115 yy.setNewElementDocRef($$[$0 - 2]);
116 break;
117 case 44:
118 yy.addRelationship($$[$0 - 2], $$[$0], $$[$0 - 4]);
119 break;
120 case 45:
121 yy.addRelationship($$[$0 - 2], $$[$0 - 4], $$[$0]);
122 break;
123 case 46:
124 this.$ = yy.Relationships.CONTAINS;
125 break;
126 case 47:
127 this.$ = yy.Relationships.COPIES;
128 break;
129 case 48:
130 this.$ = yy.Relationships.DERIVES;
131 break;
132 case 49:
133 this.$ = yy.Relationships.SATISFIES;
134 break;
135 case 50:
136 this.$ = yy.Relationships.VERIFIES;
137 break;
138 case 51:
139 this.$ = yy.Relationships.REFINES;
140 break;
141 case 52:
142 this.$ = yy.Relationships.TRACES;
143 break;
144 }
145 },
146 table: [{ 3: 1, 4: 2, 6: $V0, 9: 4, 14: $V1, 16: $V2, 18: $V3, 19: $V4 }, { 1: [3] }, { 3: 10, 4: 2, 5: [1, 9], 6: $V0, 9: 4, 14: $V1, 16: $V2, 18: $V3, 19: $V4 }, { 5: [1, 11] }, { 10: 12, 20: [1, 13] }, { 15: [1, 14] }, { 17: [1, 15] }, o($V5, [2, 8]), { 20: [2, 9] }, { 3: 16, 4: 2, 6: $V0, 9: 4, 14: $V1, 16: $V2, 18: $V3, 19: $V4 }, { 1: [2, 2] }, { 4: 21, 5: $V6, 7: 17, 8: $V7, 9: 4, 14: $V1, 16: $V2, 18: $V3, 19: $V4, 23: 18, 24: 19, 25: 20, 26: 23, 32: 25, 40: $V8, 41: $V9, 42: $Va, 43: $Vb, 44: $Vc, 45: $Vd, 53: $Ve, 71: $Vf, 72: $Vg }, { 11: 34, 12: [1, 35], 22: $Vh }, o([12, 22], [2, 10]), o($V5, [2, 6]), o($V5, [2, 7]), { 1: [2, 1] }, { 8: [1, 37] }, { 4: 21, 5: $V6, 7: 38, 8: $V7, 9: 4, 14: $V1, 16: $V2, 18: $V3, 19: $V4, 23: 18, 24: 19, 25: 20, 26: 23, 32: 25, 40: $V8, 41: $V9, 42: $Va, 43: $Vb, 44: $Vc, 45: $Vd, 53: $Ve, 71: $Vf, 72: $Vg }, { 4: 21, 5: $V6, 7: 39, 8: $V7, 9: 4, 14: $V1, 16: $V2, 18: $V3, 19: $V4, 23: 18, 24: 19, 25: 20, 26: 23, 32: 25, 40: $V8, 41: $V9, 42: $Va, 43: $Vb, 44: $Vc, 45: $Vd, 53: $Ve, 71: $Vf, 72: $Vg }, { 4: 21, 5: $V6, 7: 40, 8: $V7, 9: 4, 14: $V1, 16: $V2, 18: $V3, 19: $V4, 23: 18, 24: 19, 25: 20, 26: 23, 32: 25, 40: $V8, 41: $V9, 42: $Va, 43: $Vb, 44: $Vc, 45: $Vd, 53: $Ve, 71: $Vf, 72: $Vg }, { 4: 21, 5: $V6, 7: 41, 8: $V7, 9: 4, 14: $V1, 16: $V2, 18: $V3, 19: $V4, 23: 18, 24: 19, 25: 20, 26: 23, 32: 25, 40: $V8, 41: $V9, 42: $Va, 43: $Vb, 44: $Vc, 45: $Vd, 53: $Ve, 71: $Vf, 72: $Vg }, { 4: 21, 5: $V6, 7: 42, 8: $V7, 9: 4, 14: $V1, 16: $V2, 18: $V3, 19: $V4, 23: 18, 24: 19, 25: 20, 26: 23, 32: 25, 40: $V8, 41: $V9, 42: $Va, 43: $Vb, 44: $Vc, 45: $Vd, 53: $Ve, 71: $Vf, 72: $Vg }, { 27: 43, 71: [1, 44], 72: [1, 45] }, { 54: 46, 71: [1, 47], 72: [1, 48] }, { 60: [1, 49], 62: [1, 50] }, o($Vi, [2, 26]), o($Vi, [2, 27]), o($Vi, [2, 28]), o($Vi, [2, 29]), o($Vi, [2, 30]), o($Vi, [2, 31]), o($Vj, [2, 55]), o($Vj, [2, 56]), o($V5, [2, 4]), { 13: 51, 21: [1, 52] }, o($V5, [2, 12]), { 1: [2, 3] }, { 8: [2, 14] }, { 8: [2, 15] }, { 8: [2, 16] }, { 8: [2, 17] }, { 8: [2, 18] }, { 28: [1, 53] }, { 28: [2, 53] }, { 28: [2, 54] }, { 28: [1, 54] }, { 28: [2, 59] }, { 28: [2, 60] }, { 61: 55, 64: $Vk, 65: $Vl, 66: $Vm, 67: $Vn, 68: $Vo, 69: $Vp, 70: $Vq }, { 61: 63, 64: $Vk, 65: $Vl, 66: $Vm, 67: $Vn, 68: $Vo, 69: $Vp, 70: $Vq }, { 11: 64, 22: $Vh }, { 22: [2, 11] }, { 5: [1, 65] }, { 5: [1, 66] }, { 62: [1, 67] }, o($Vr, [2, 46]), o($Vr, [2, 47]), o($Vr, [2, 48]), o($Vr, [2, 49]), o($Vr, [2, 50]), o($Vr, [2, 51]), o($Vr, [2, 52]), { 63: [1, 68] }, o($V5, [2, 5]), { 5: $Vs, 29: 69, 30: $Vt, 33: $Vu, 35: $Vv, 37: $Vw, 39: $Vx }, { 5: $Vy, 39: $Vz, 55: 76, 56: $VA, 58: $VB }, { 32: 81, 71: $Vf, 72: $Vg }, { 32: 82, 71: $Vf, 72: $Vg }, o($VC, [2, 19]), { 31: [1, 83] }, { 31: [1, 84] }, { 31: [1, 85] }, { 31: [1, 86] }, { 5: $Vs, 29: 87, 30: $Vt, 33: $Vu, 35: $Vv, 37: $Vw, 39: $Vx }, o($VC, [2, 25]), o($VC, [2, 39]), { 31: [1, 88] }, { 31: [1, 89] }, { 5: $Vy, 39: $Vz, 55: 90, 56: $VA, 58: $VB }, o($VC, [2, 43]), o($VC, [2, 44]), o($VC, [2, 45]), { 32: 91, 71: $Vf, 72: $Vg }, { 34: 92, 71: [1, 93], 72: [1, 94] }, { 36: 95, 46: [1, 96], 47: [1, 97], 48: [1, 98] }, { 38: 99, 49: [1, 100], 50: [1, 101], 51: [1, 102], 52: [1, 103] }, o($VC, [2, 24]), { 57: 104, 71: [1, 105], 72: [1, 106] }, { 59: 107, 71: [1, 108], 72: [1, 109] }, o($VC, [2, 42]), { 5: [1, 110] }, { 5: [1, 111] }, { 5: [2, 57] }, { 5: [2, 58] }, { 5: [1, 112] }, { 5: [2, 32] }, { 5: [2, 33] }, { 5: [2, 34] }, { 5: [1, 113] }, { 5: [2, 35] }, { 5: [2, 36] }, { 5: [2, 37] }, { 5: [2, 38] }, { 5: [1, 114] }, { 5: [2, 61] }, { 5: [2, 62] }, { 5: [1, 115] }, { 5: [2, 63] }, { 5: [2, 64] }, { 5: $Vs, 29: 116, 30: $Vt, 33: $Vu, 35: $Vv, 37: $Vw, 39: $Vx }, { 5: $Vs, 29: 117, 30: $Vt, 33: $Vu, 35: $Vv, 37: $Vw, 39: $Vx }, { 5: $Vs, 29: 118, 30: $Vt, 33: $Vu, 35: $Vv, 37: $Vw, 39: $Vx }, { 5: $Vs, 29: 119, 30: $Vt, 33: $Vu, 35: $Vv, 37: $Vw, 39: $Vx }, { 5: $Vy, 39: $Vz, 55: 120, 56: $VA, 58: $VB }, { 5: $Vy, 39: $Vz, 55: 121, 56: $VA, 58: $VB }, o($VC, [2, 20]), o($VC, [2, 21]), o($VC, [2, 22]), o($VC, [2, 23]), o($VC, [2, 40]), o($VC, [2, 41])],
147 defaultActions: { 8: [2, 9], 10: [2, 2], 16: [2, 1], 37: [2, 3], 38: [2, 14], 39: [2, 15], 40: [2, 16], 41: [2, 17], 42: [2, 18], 44: [2, 53], 45: [2, 54], 47: [2, 59], 48: [2, 60], 52: [2, 11], 93: [2, 57], 94: [2, 58], 96: [2, 32], 97: [2, 33], 98: [2, 34], 100: [2, 35], 101: [2, 36], 102: [2, 37], 103: [2, 38], 105: [2, 61], 106: [2, 62], 108: [2, 63], 109: [2, 64] },
148 parseError: function parseError(str, hash) {
149 if (hash.recoverable) {
150 this.trace(str);
151 } else {
152 var error = new Error(str);
153 error.hash = hash;
154 throw error;
155 }
156 },
157 parse: function parse(input) {
158 var self = this, stack = [0], tstack = [], vstack = [null], lstack = [], table = this.table, yytext = "", yylineno = 0, yyleng = 0, TERROR = 2, EOF = 1;
159 var args = lstack.slice.call(arguments, 1);
160 var lexer2 = Object.create(this.lexer);
161 var sharedState = { yy: {} };
162 for (var k in this.yy) {
163 if (Object.prototype.hasOwnProperty.call(this.yy, k)) {
164 sharedState.yy[k] = this.yy[k];
165 }
166 }
167 lexer2.setInput(input, sharedState.yy);
168 sharedState.yy.lexer = lexer2;
169 sharedState.yy.parser = this;
170 if (typeof lexer2.yylloc == "undefined") {
171 lexer2.yylloc = {};
172 }
173 var yyloc = lexer2.yylloc;
174 lstack.push(yyloc);
175 var ranges = lexer2.options && lexer2.options.ranges;
176 if (typeof sharedState.yy.parseError === "function") {
177 this.parseError = sharedState.yy.parseError;
178 } else {
179 this.parseError = Object.getPrototypeOf(this).parseError;
180 }
181 function lex() {
182 var token;
183 token = tstack.pop() || lexer2.lex() || EOF;
184 if (typeof token !== "number") {
185 if (token instanceof Array) {
186 tstack = token;
187 token = tstack.pop();
188 }
189 token = self.symbols_[token] || token;
190 }
191 return token;
192 }
193 var symbol, state, action, r, yyval = {}, p, len, newState, expected;
194 while (true) {
195 state = stack[stack.length - 1];
196 if (this.defaultActions[state]) {
197 action = this.defaultActions[state];
198 } else {
199 if (symbol === null || typeof symbol == "undefined") {
200 symbol = lex();
201 }
202 action = table[state] && table[state][symbol];
203 }
204 if (typeof action === "undefined" || !action.length || !action[0]) {
205 var errStr = "";
206 expected = [];
207 for (p in table[state]) {
208 if (this.terminals_[p] && p > TERROR) {
209 expected.push("'" + this.terminals_[p] + "'");
210 }
211 }
212 if (lexer2.showPosition) {
213 errStr = "Parse error on line " + (yylineno + 1) + ":\n" + lexer2.showPosition() + "\nExpecting " + expected.join(", ") + ", got '" + (this.terminals_[symbol] || symbol) + "'";
214 } else {
215 errStr = "Parse error on line " + (yylineno + 1) + ": Unexpected " + (symbol == EOF ? "end of input" : "'" + (this.terminals_[symbol] || symbol) + "'");
216 }
217 this.parseError(errStr, {
218 text: lexer2.match,
219 token: this.terminals_[symbol] || symbol,
220 line: lexer2.yylineno,
221 loc: yyloc,
222 expected
223 });
224 }
225 if (action[0] instanceof Array && action.length > 1) {
226 throw new Error("Parse Error: multiple actions possible at state: " + state + ", token: " + symbol);
227 }
228 switch (action[0]) {
229 case 1:
230 stack.push(symbol);
231 vstack.push(lexer2.yytext);
232 lstack.push(lexer2.yylloc);
233 stack.push(action[1]);
234 symbol = null;
235 {
236 yyleng = lexer2.yyleng;
237 yytext = lexer2.yytext;
238 yylineno = lexer2.yylineno;
239 yyloc = lexer2.yylloc;
240 }
241 break;
242 case 2:
243 len = this.productions_[action[1]][1];
244 yyval.$ = vstack[vstack.length - len];
245 yyval._$ = {
246 first_line: lstack[lstack.length - (len || 1)].first_line,
247 last_line: lstack[lstack.length - 1].last_line,
248 first_column: lstack[lstack.length - (len || 1)].first_column,
249 last_column: lstack[lstack.length - 1].last_column
250 };
251 if (ranges) {
252 yyval._$.range = [
253 lstack[lstack.length - (len || 1)].range[0],
254 lstack[lstack.length - 1].range[1]
255 ];
256 }
257 r = this.performAction.apply(yyval, [
258 yytext,
259 yyleng,
260 yylineno,
261 sharedState.yy,
262 action[1],
263 vstack,
264 lstack
265 ].concat(args));
266 if (typeof r !== "undefined") {
267 return r;
268 }
269 if (len) {
270 stack = stack.slice(0, -1 * len * 2);
271 vstack = vstack.slice(0, -1 * len);
272 lstack = lstack.slice(0, -1 * len);
273 }
274 stack.push(this.productions_[action[1]][0]);
275 vstack.push(yyval.$);
276 lstack.push(yyval._$);
277 newState = table[stack[stack.length - 2]][stack[stack.length - 1]];
278 stack.push(newState);
279 break;
280 case 3:
281 return true;
282 }
283 }
284 return true;
285 }
286 };
287 var lexer = function() {
288 var lexer2 = {
289 EOF: 1,
290 parseError: function parseError(str, hash) {
291 if (this.yy.parser) {
292 this.yy.parser.parseError(str, hash);
293 } else {
294 throw new Error(str);
295 }
296 },
297 // resets the lexer, sets new input
298 setInput: function(input, yy) {
299 this.yy = yy || this.yy || {};
300 this._input = input;
301 this._more = this._backtrack = this.done = false;
302 this.yylineno = this.yyleng = 0;
303 this.yytext = this.matched = this.match = "";
304 this.conditionStack = ["INITIAL"];
305 this.yylloc = {
306 first_line: 1,
307 first_column: 0,
308 last_line: 1,
309 last_column: 0
310 };
311 if (this.options.ranges) {
312 this.yylloc.range = [0, 0];
313 }
314 this.offset = 0;
315 return this;
316 },
317 // consumes and returns one char from the input
318 input: function() {
319 var ch = this._input[0];
320 this.yytext += ch;
321 this.yyleng++;
322 this.offset++;
323 this.match += ch;
324 this.matched += ch;
325 var lines = ch.match(/(?:\r\n?|\n).*/g);
326 if (lines) {
327 this.yylineno++;
328 this.yylloc.last_line++;
329 } else {
330 this.yylloc.last_column++;
331 }
332 if (this.options.ranges) {
333 this.yylloc.range[1]++;
334 }
335 this._input = this._input.slice(1);
336 return ch;
337 },
338 // unshifts one char (or a string) into the input
339 unput: function(ch) {
340 var len = ch.length;
341 var lines = ch.split(/(?:\r\n?|\n)/g);
342 this._input = ch + this._input;
343 this.yytext = this.yytext.substr(0, this.yytext.length - len);
344 this.offset -= len;
345 var oldLines = this.match.split(/(?:\r\n?|\n)/g);
346 this.match = this.match.substr(0, this.match.length - 1);
347 this.matched = this.matched.substr(0, this.matched.length - 1);
348 if (lines.length - 1) {
349 this.yylineno -= lines.length - 1;
350 }
351 var r = this.yylloc.range;
352 this.yylloc = {
353 first_line: this.yylloc.first_line,
354 last_line: this.yylineno + 1,
355 first_column: this.yylloc.first_column,
356 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
357 };
358 if (this.options.ranges) {
359 this.yylloc.range = [r[0], r[0] + this.yyleng - len];
360 }
361 this.yyleng = this.yytext.length;
362 return this;
363 },
364 // When called from action, caches matched text and appends it on next action
365 more: function() {
366 this._more = true;
367 return this;
368 },
369 // 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.
370 reject: function() {
371 if (this.options.backtrack_lexer) {
372 this._backtrack = true;
373 } else {
374 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(), {
375 text: "",
376 token: null,
377 line: this.yylineno
378 });
379 }
380 return this;
381 },
382 // retain first n characters of the match
383 less: function(n) {
384 this.unput(this.match.slice(n));
385 },
386 // displays already matched input, i.e. for error messages
387 pastInput: function() {
388 var past = this.matched.substr(0, this.matched.length - this.match.length);
389 return (past.length > 20 ? "..." : "") + past.substr(-20).replace(/\n/g, "");
390 },
391 // displays upcoming input, i.e. for error messages
392 upcomingInput: function() {
393 var next = this.match;
394 if (next.length < 20) {
395 next += this._input.substr(0, 20 - next.length);
396 }
397 return (next.substr(0, 20) + (next.length > 20 ? "..." : "")).replace(/\n/g, "");
398 },
399 // displays the character position where the lexing error occurred, i.e. for error messages
400 showPosition: function() {
401 var pre = this.pastInput();
402 var c = new Array(pre.length + 1).join("-");
403 return pre + this.upcomingInput() + "\n" + c + "^";
404 },
405 // test the lexed token: return FALSE when not a match, otherwise return token
406 test_match: function(match, indexed_rule) {
407 var token, lines, backup;
408 if (this.options.backtrack_lexer) {
409 backup = {
410 yylineno: this.yylineno,
411 yylloc: {
412 first_line: this.yylloc.first_line,
413 last_line: this.last_line,
414 first_column: this.yylloc.first_column,
415 last_column: this.yylloc.last_column
416 },
417 yytext: this.yytext,
418 match: this.match,
419 matches: this.matches,
420 matched: this.matched,
421 yyleng: this.yyleng,
422 offset: this.offset,
423 _more: this._more,
424 _input: this._input,
425 yy: this.yy,
426 conditionStack: this.conditionStack.slice(0),
427 done: this.done
428 };
429 if (this.options.ranges) {
430 backup.yylloc.range = this.yylloc.range.slice(0);
431 }
432 }
433 lines = match[0].match(/(?:\r\n?|\n).*/g);
434 if (lines) {
435 this.yylineno += lines.length;
436 }
437 this.yylloc = {
438 first_line: this.yylloc.last_line,
439 last_line: this.yylineno + 1,
440 first_column: this.yylloc.last_column,
441 last_column: lines ? lines[lines.length - 1].length - lines[lines.length - 1].match(/\r?\n?/)[0].length : this.yylloc.last_column + match[0].length
442 };
443 this.yytext += match[0];
444 this.match += match[0];
445 this.matches = match;
446 this.yyleng = this.yytext.length;
447 if (this.options.ranges) {
448 this.yylloc.range = [this.offset, this.offset += this.yyleng];
449 }
450 this._more = false;
451 this._backtrack = false;
452 this._input = this._input.slice(match[0].length);
453 this.matched += match[0];
454 token = this.performAction.call(this, this.yy, this, indexed_rule, this.conditionStack[this.conditionStack.length - 1]);
455 if (this.done && this._input) {
456 this.done = false;
457 }
458 if (token) {
459 return token;
460 } else if (this._backtrack) {
461 for (var k in backup) {
462 this[k] = backup[k];
463 }
464 return false;
465 }
466 return false;
467 },
468 // return next match in input
469 next: function() {
470 if (this.done) {
471 return this.EOF;
472 }
473 if (!this._input) {
474 this.done = true;
475 }
476 var token, match, tempMatch, index;
477 if (!this._more) {
478 this.yytext = "";
479 this.match = "";
480 }
481 var rules = this._currentRules();
482 for (var i = 0; i < rules.length; i++) {
483 tempMatch = this._input.match(this.rules[rules[i]]);
484 if (tempMatch && (!match || tempMatch[0].length > match[0].length)) {
485 match = tempMatch;
486 index = i;
487 if (this.options.backtrack_lexer) {
488 token = this.test_match(tempMatch, rules[i]);
489 if (token !== false) {
490 return token;
491 } else if (this._backtrack) {
492 match = false;
493 continue;
494 } else {
495 return false;
496 }
497 } else if (!this.options.flex) {
498 break;
499 }
500 }
501 }
502 if (match) {
503 token = this.test_match(match, rules[index]);
504 if (token !== false) {
505 return token;
506 }
507 return false;
508 }
509 if (this._input === "") {
510 return this.EOF;
511 } else {
512 return this.parseError("Lexical error on line " + (this.yylineno + 1) + ". Unrecognized text.\n" + this.showPosition(), {
513 text: "",
514 token: null,
515 line: this.yylineno
516 });
517 }
518 },
519 // return next match that has a token
520 lex: function lex() {
521 var r = this.next();
522 if (r) {
523 return r;
524 } else {
525 return this.lex();
526 }
527 },
528 // activates a new lexer condition state (pushes the new lexer condition state onto the condition stack)
529 begin: function begin(condition) {
530 this.conditionStack.push(condition);
531 },
532 // pop the previously active lexer condition state off the condition stack
533 popState: function popState() {
534 var n = this.conditionStack.length - 1;
535 if (n > 0) {
536 return this.conditionStack.pop();
537 } else {
538 return this.conditionStack[0];
539 }
540 },
541 // produce the lexer rule set which is active for the currently active lexer condition state
542 _currentRules: function _currentRules() {
543 if (this.conditionStack.length && this.conditionStack[this.conditionStack.length - 1]) {
544 return this.conditions[this.conditionStack[this.conditionStack.length - 1]].rules;
545 } else {
546 return this.conditions["INITIAL"].rules;
547 }
548 },
549 // return the currently active lexer condition state; when an index argument is provided it produces the N-th previous condition state, if available
550 topState: function topState(n) {
551 n = this.conditionStack.length - 1 - Math.abs(n || 0);
552 if (n >= 0) {
553 return this.conditionStack[n];
554 } else {
555 return "INITIAL";
556 }
557 },
558 // alias for begin(condition)
559 pushState: function pushState(condition) {
560 this.begin(condition);
561 },
562 // return the number of states currently on the stack
563 stateStackSize: function stateStackSize() {
564 return this.conditionStack.length;
565 },
566 options: { "case-insensitive": true },
567 performAction: function anonymous(yy, yy_, $avoiding_name_collisions, YY_START) {
568 switch ($avoiding_name_collisions) {
569 case 0:
570 this.begin("open_directive");
571 return 19;
572 case 1:
573 this.begin("type_directive");
574 return 20;
575 case 2:
576 this.popState();
577 this.begin("arg_directive");
578 return 12;
579 case 3:
580 this.popState();
581 this.popState();
582 return 22;
583 case 4:
584 return 21;
585 case 5:
586 return "title";
587 case 6:
588 this.begin("acc_title");
589 return 14;
590 case 7:
591 this.popState();
592 return "acc_title_value";
593 case 8:
594 this.begin("acc_descr");
595 return 16;
596 case 9:
597 this.popState();
598 return "acc_descr_value";
599 case 10:
600 this.begin("acc_descr_multiline");
601 break;
602 case 11:
603 this.popState();
604 break;
605 case 12:
606 return "acc_descr_multiline_value";
607 case 13:
608 return 5;
609 case 14:
610 break;
611 case 15:
612 break;
613 case 16:
614 break;
615 case 17:
616 return 8;
617 case 18:
618 return 6;
619 case 19:
620 return 28;
621 case 20:
622 return 39;
623 case 21:
624 return 31;
625 case 22:
626 return 30;
627 case 23:
628 return 33;
629 case 24:
630 return 35;
631 case 25:
632 return 37;
633 case 26:
634 return 40;
635 case 27:
636 return 41;
637 case 28:
638 return 42;
639 case 29:
640 return 43;
641 case 30:
642 return 44;
643 case 31:
644 return 45;
645 case 32:
646 return 46;
647 case 33:
648 return 47;
649 case 34:
650 return 48;
651 case 35:
652 return 49;
653 case 36:
654 return 50;
655 case 37:
656 return 51;
657 case 38:
658 return 52;
659 case 39:
660 return 53;
661 case 40:
662 return 64;
663 case 41:
664 return 65;
665 case 42:
666 return 66;
667 case 43:
668 return 67;
669 case 44:
670 return 68;
671 case 45:
672 return 69;
673 case 46:
674 return 70;
675 case 47:
676 return 56;
677 case 48:
678 return 58;
679 case 49:
680 return 60;
681 case 50:
682 return 63;
683 case 51:
684 return 62;
685 case 52:
686 this.begin("string");
687 break;
688 case 53:
689 this.popState();
690 break;
691 case 54:
692 return "qString";
693 case 55:
694 yy_.yytext = yy_.yytext.trim();
695 return 71;
696 }
697 },
698 rules: [/^(?:%%\{)/i, /^(?:((?:(?!\}%%)[^:.])*))/i, /^(?::)/i, /^(?:\}%%)/i, /^(?:((?:(?!\}%%).|\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, /^(?:(\r?\n)+)/i, /^(?:\s+)/i, /^(?:#[^\n]*)/i, /^(?:%[^\n]*)/i, /^(?:$)/i, /^(?:requirementDiagram\b)/i, /^(?:\{)/i, /^(?:\})/i, /^(?::)/i, /^(?:id\b)/i, /^(?:text\b)/i, /^(?:risk\b)/i, /^(?:verifyMethod\b)/i, /^(?:requirement\b)/i, /^(?:functionalRequirement\b)/i, /^(?:interfaceRequirement\b)/i, /^(?:performanceRequirement\b)/i, /^(?:physicalRequirement\b)/i, /^(?:designConstraint\b)/i, /^(?:low\b)/i, /^(?:medium\b)/i, /^(?:high\b)/i, /^(?:analysis\b)/i, /^(?:demonstration\b)/i, /^(?:inspection\b)/i, /^(?:test\b)/i, /^(?:element\b)/i, /^(?:contains\b)/i, /^(?:copies\b)/i, /^(?:derives\b)/i, /^(?:satisfies\b)/i, /^(?:verifies\b)/i, /^(?:refines\b)/i, /^(?:traces\b)/i, /^(?:type\b)/i, /^(?:docref\b)/i, /^(?:<-)/i, /^(?:->)/i, /^(?:-)/i, /^(?:["])/i, /^(?:["])/i, /^(?:[^"]*)/i, /^(?:[\w][^\r\n\{\<\>\-\=]*)/i],
699 conditions: { "acc_descr_multiline": { "rules": [11, 12], "inclusive": false }, "acc_descr": { "rules": [9], "inclusive": false }, "acc_title": { "rules": [7], "inclusive": false }, "close_directive": { "rules": [], "inclusive": false }, "arg_directive": { "rules": [3, 4], "inclusive": false }, "type_directive": { "rules": [2, 3], "inclusive": false }, "open_directive": { "rules": [1], "inclusive": false }, "unqString": { "rules": [], "inclusive": false }, "token": { "rules": [], "inclusive": false }, "string": { "rules": [53, 54], "inclusive": false }, "INITIAL": { "rules": [0, 5, 6, 8, 10, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 55], "inclusive": true } }
700 };
701 return lexer2;
702 }();
703 parser2.lexer = lexer;
704 function Parser() {
705 this.yy = {};
706 }
707 Parser.prototype = parser2;
708 parser2.Parser = Parser;
709 return new Parser();
710}();
711parser.parser = parser;
712const parser$1 = parser;
713let relations = [];
714let latestRequirement = {};
715let requirements = {};
716let latestElement = {};
717let elements = {};
718const RequirementType = {
719 REQUIREMENT: "Requirement",
720 FUNCTIONAL_REQUIREMENT: "Functional Requirement",
721 INTERFACE_REQUIREMENT: "Interface Requirement",
722 PERFORMANCE_REQUIREMENT: "Performance Requirement",
723 PHYSICAL_REQUIREMENT: "Physical Requirement",
724 DESIGN_CONSTRAINT: "Design Constraint"
725};
726const RiskLevel = {
727 LOW_RISK: "Low",
728 MED_RISK: "Medium",
729 HIGH_RISK: "High"
730};
731const VerifyType = {
732 VERIFY_ANALYSIS: "Analysis",
733 VERIFY_DEMONSTRATION: "Demonstration",
734 VERIFY_INSPECTION: "Inspection",
735 VERIFY_TEST: "Test"
736};
737const Relationships = {
738 CONTAINS: "contains",
739 COPIES: "copies",
740 DERIVES: "derives",
741 SATISFIES: "satisfies",
742 VERIFIES: "verifies",
743 REFINES: "refines",
744 TRACES: "traces"
745};
746const parseDirective = function(statement, context, type) {
747 mermaidAPI.parseDirective(this, statement, context, type);
748};
749const addRequirement = (name, type) => {
750 if (requirements[name] === void 0) {
751 requirements[name] = {
752 name,
753 type,
754 id: latestRequirement.id,
755 text: latestRequirement.text,
756 risk: latestRequirement.risk,
757 verifyMethod: latestRequirement.verifyMethod
758 };
759 }
760 latestRequirement = {};
761 return requirements[name];
762};
763const getRequirements = () => requirements;
764const setNewReqId = (id) => {
765 if (latestRequirement !== void 0) {
766 latestRequirement.id = id;
767 }
768};
769const setNewReqText = (text) => {
770 if (latestRequirement !== void 0) {
771 latestRequirement.text = text;
772 }
773};
774const setNewReqRisk = (risk) => {
775 if (latestRequirement !== void 0) {
776 latestRequirement.risk = risk;
777 }
778};
779const setNewReqVerifyMethod = (verifyMethod) => {
780 if (latestRequirement !== void 0) {
781 latestRequirement.verifyMethod = verifyMethod;
782 }
783};
784const addElement = (name) => {
785 if (elements[name] === void 0) {
786 elements[name] = {
787 name,
788 type: latestElement.type,
789 docRef: latestElement.docRef
790 };
791 log.info("Added new requirement: ", name);
792 }
793 latestElement = {};
794 return elements[name];
795};
796const getElements = () => elements;
797const setNewElementType = (type) => {
798 if (latestElement !== void 0) {
799 latestElement.type = type;
800 }
801};
802const setNewElementDocRef = (docRef) => {
803 if (latestElement !== void 0) {
804 latestElement.docRef = docRef;
805 }
806};
807const addRelationship = (type, src, dst) => {
808 relations.push({
809 type,
810 src,
811 dst
812 });
813};
814const getRelationships = () => relations;
815const clear = () => {
816 relations = [];
817 latestRequirement = {};
818 requirements = {};
819 latestElement = {};
820 elements = {};
821 clear$1();
822};
823const db = {
824 RequirementType,
825 RiskLevel,
826 VerifyType,
827 Relationships,
828 parseDirective,
829 getConfig: () => getConfig().req,
830 addRequirement,
831 getRequirements,
832 setNewReqId,
833 setNewReqText,
834 setNewReqRisk,
835 setNewReqVerifyMethod,
836 setAccTitle,
837 getAccTitle,
838 setAccDescription,
839 getAccDescription,
840 addElement,
841 getElements,
842 setNewElementType,
843 setNewElementDocRef,
844 addRelationship,
845 getRelationships,
846 clear
847};
848const getStyles = (options) => `
849
850 marker {
851 fill: ${options.relationColor};
852 stroke: ${options.relationColor};
853 }
854
855 marker.cross {
856 stroke: ${options.lineColor};
857 }
858
859 svg {
860 font-family: ${options.fontFamily};
861 font-size: ${options.fontSize};
862 }
863
864 .reqBox {
865 fill: ${options.requirementBackground};
866 fill-opacity: 1.0;
867 stroke: ${options.requirementBorderColor};
868 stroke-width: ${options.requirementBorderSize};
869 }
870
871 .reqTitle, .reqLabel{
872 fill: ${options.requirementTextColor};
873 }
874 .reqLabelBox {
875 fill: ${options.relationLabelBackground};
876 fill-opacity: 1.0;
877 }
878
879 .req-title-line {
880 stroke: ${options.requirementBorderColor};
881 stroke-width: ${options.requirementBorderSize};
882 }
883 .relationshipLine {
884 stroke: ${options.relationColor};
885 stroke-width: 1;
886 }
887 .relationshipLabel {
888 fill: ${options.relationLabelColor};
889 }
890
891`;
892const styles = getStyles;
893const ReqMarkers = {
894 CONTAINS: "contains",
895 ARROW: "arrow"
896};
897const insertLineEndings = (parentNode, conf2) => {
898 let containsNode = parentNode.append("defs").append("marker").attr("id", ReqMarkers.CONTAINS + "_line_ending").attr("refX", 0).attr("refY", conf2.line_height / 2).attr("markerWidth", conf2.line_height).attr("markerHeight", conf2.line_height).attr("orient", "auto").append("g");
899 containsNode.append("circle").attr("cx", conf2.line_height / 2).attr("cy", conf2.line_height / 2).attr("r", conf2.line_height / 2).attr("fill", "none");
900 containsNode.append("line").attr("x1", 0).attr("x2", conf2.line_height).attr("y1", conf2.line_height / 2).attr("y2", conf2.line_height / 2).attr("stroke-width", 1);
901 containsNode.append("line").attr("y1", 0).attr("y2", conf2.line_height).attr("x1", conf2.line_height / 2).attr("x2", conf2.line_height / 2).attr("stroke-width", 1);
902 parentNode.append("defs").append("marker").attr("id", ReqMarkers.ARROW + "_line_ending").attr("refX", conf2.line_height).attr("refY", 0.5 * conf2.line_height).attr("markerWidth", conf2.line_height).attr("markerHeight", conf2.line_height).attr("orient", "auto").append("path").attr(
903 "d",
904 `M0,0
905 L${conf2.line_height},${conf2.line_height / 2}
906 M${conf2.line_height},${conf2.line_height / 2}
907 L0,${conf2.line_height}`
908 ).attr("stroke-width", 1);
909};
910const markers = {
911 ReqMarkers,
912 insertLineEndings
913};
914let conf = {};
915let relCnt = 0;
916const newRectNode = (parentNode, id) => {
917 return parentNode.insert("rect", "#" + id).attr("class", "req reqBox").attr("x", 0).attr("y", 0).attr("width", conf.rect_min_width + "px").attr("height", conf.rect_min_height + "px");
918};
919const newTitleNode = (parentNode, id, txts) => {
920 let x = conf.rect_min_width / 2;
921 let title = parentNode.append("text").attr("class", "req reqLabel reqTitle").attr("id", id).attr("x", x).attr("y", conf.rect_padding).attr("dominant-baseline", "hanging");
922 let i = 0;
923 txts.forEach((textStr) => {
924 if (i == 0) {
925 title.append("tspan").attr("text-anchor", "middle").attr("x", conf.rect_min_width / 2).attr("dy", 0).text(textStr);
926 } else {
927 title.append("tspan").attr("text-anchor", "middle").attr("x", conf.rect_min_width / 2).attr("dy", conf.line_height * 0.75).text(textStr);
928 }
929 i++;
930 });
931 let yPadding = 1.5 * conf.rect_padding;
932 let linePadding = i * conf.line_height * 0.75;
933 let totalY = yPadding + linePadding;
934 parentNode.append("line").attr("class", "req-title-line").attr("x1", "0").attr("x2", conf.rect_min_width).attr("y1", totalY).attr("y2", totalY);
935 return {
936 titleNode: title,
937 y: totalY
938 };
939};
940const newBodyNode = (parentNode, id, txts, yStart) => {
941 let body = parentNode.append("text").attr("class", "req reqLabel").attr("id", id).attr("x", conf.rect_padding).attr("y", yStart).attr("dominant-baseline", "hanging");
942 let currentRow = 0;
943 const charLimit = 30;
944 let wrappedTxts = [];
945 txts.forEach((textStr) => {
946 let currentTextLen = textStr.length;
947 while (currentTextLen > charLimit && currentRow < 3) {
948 let firstPart = textStr.substring(0, charLimit);
949 textStr = textStr.substring(charLimit, textStr.length);
950 currentTextLen = textStr.length;
951 wrappedTxts[wrappedTxts.length] = firstPart;
952 currentRow++;
953 }
954 if (currentRow == 3) {
955 let lastStr = wrappedTxts[wrappedTxts.length - 1];
956 wrappedTxts[wrappedTxts.length - 1] = lastStr.substring(0, lastStr.length - 4) + "...";
957 } else {
958 wrappedTxts[wrappedTxts.length] = textStr;
959 }
960 currentRow = 0;
961 });
962 wrappedTxts.forEach((textStr) => {
963 body.append("tspan").attr("x", conf.rect_padding).attr("dy", conf.line_height).text(textStr);
964 });
965 return body;
966};
967const addEdgeLabel = (parentNode, svgPath, conf2, txt) => {
968 const len = svgPath.node().getTotalLength();
969 const labelPoint = svgPath.node().getPointAtLength(len * 0.5);
970 const labelId = "rel" + relCnt;
971 relCnt++;
972 const labelNode = parentNode.append("text").attr("class", "req relationshipLabel").attr("id", labelId).attr("x", labelPoint.x).attr("y", labelPoint.y).attr("text-anchor", "middle").attr("dominant-baseline", "middle").text(txt);
973 const labelBBox = labelNode.node().getBBox();
974 parentNode.insert("rect", "#" + labelId).attr("class", "req reqLabelBox").attr("x", labelPoint.x - labelBBox.width / 2).attr("y", labelPoint.y - labelBBox.height / 2).attr("width", labelBBox.width).attr("height", labelBBox.height).attr("fill", "white").attr("fill-opacity", "85%");
975};
976const drawRelationshipFromLayout = function(svg, rel, g, insert, diagObj) {
977 const edge = g.edge(elementString(rel.src), elementString(rel.dst));
978 const lineFunction = line().x(function(d) {
979 return d.x;
980 }).y(function(d) {
981 return d.y;
982 });
983 const svgPath = svg.insert("path", "#" + insert).attr("class", "er relationshipLine").attr("d", lineFunction(edge.points)).attr("fill", "none");
984 if (rel.type == diagObj.db.Relationships.CONTAINS) {
985 svgPath.attr(
986 "marker-start",
987 "url(" + common.getUrl(conf.arrowMarkerAbsolute) + "#" + rel.type + "_line_ending)"
988 );
989 } else {
990 svgPath.attr("stroke-dasharray", "10,7");
991 svgPath.attr(
992 "marker-end",
993 "url(" + common.getUrl(conf.arrowMarkerAbsolute) + "#" + markers.ReqMarkers.ARROW + "_line_ending)"
994 );
995 }
996 addEdgeLabel(svg, svgPath, conf, `<<${rel.type}>>`);
997 return;
998};
999const drawReqs = (reqs, graph, svgNode) => {
1000 Object.keys(reqs).forEach((reqName) => {
1001 let req = reqs[reqName];
1002 reqName = elementString(reqName);
1003 log.info("Added new requirement: ", reqName);
1004 const groupNode = svgNode.append("g").attr("id", reqName);
1005 const textId = "req-" + reqName;
1006 const rectNode = newRectNode(groupNode, textId);
1007 let titleNodeInfo = newTitleNode(groupNode, reqName + "_title", [
1008 `<<${req.type}>>`,
1009 `${req.name}`
1010 ]);
1011 newBodyNode(
1012 groupNode,
1013 reqName + "_body",
1014 [
1015 `Id: ${req.id}`,
1016 `Text: ${req.text}`,
1017 `Risk: ${req.risk}`,
1018 `Verification: ${req.verifyMethod}`
1019 ],
1020 titleNodeInfo.y
1021 );
1022 const rectBBox = rectNode.node().getBBox();
1023 graph.setNode(reqName, {
1024 width: rectBBox.width,
1025 height: rectBBox.height,
1026 shape: "rect",
1027 id: reqName
1028 });
1029 });
1030};
1031const drawElements = (els, graph, svgNode) => {
1032 Object.keys(els).forEach((elName) => {
1033 let el = els[elName];
1034 const id = elementString(elName);
1035 const groupNode = svgNode.append("g").attr("id", id);
1036 const textId = "element-" + id;
1037 const rectNode = newRectNode(groupNode, textId);
1038 let titleNodeInfo = newTitleNode(groupNode, textId + "_title", [`<<Element>>`, `${elName}`]);
1039 newBodyNode(
1040 groupNode,
1041 textId + "_body",
1042 [`Type: ${el.type || "Not Specified"}`, `Doc Ref: ${el.docRef || "None"}`],
1043 titleNodeInfo.y
1044 );
1045 const rectBBox = rectNode.node().getBBox();
1046 graph.setNode(id, {
1047 width: rectBBox.width,
1048 height: rectBBox.height,
1049 shape: "rect",
1050 id
1051 });
1052 });
1053};
1054const addRelationships = (relationships, g) => {
1055 relationships.forEach(function(r) {
1056 let src = elementString(r.src);
1057 let dst = elementString(r.dst);
1058 g.setEdge(src, dst, { relationship: r });
1059 });
1060 return relationships;
1061};
1062const adjustEntities = function(svgNode, graph) {
1063 graph.nodes().forEach(function(v) {
1064 if (v !== void 0 && graph.node(v) !== void 0) {
1065 svgNode.select("#" + v);
1066 svgNode.select("#" + v).attr(
1067 "transform",
1068 "translate(" + (graph.node(v).x - graph.node(v).width / 2) + "," + (graph.node(v).y - graph.node(v).height / 2) + " )"
1069 );
1070 }
1071 });
1072 return;
1073};
1074const elementString = (str) => {
1075 return str.replace(/\s/g, "").replace(/\./g, "_");
1076};
1077const draw = (text, id, _version, diagObj) => {
1078 conf = getConfig().requirement;
1079 diagObj.db.clear();
1080 diagObj.parser.parse(text);
1081 const securityLevel = conf.securityLevel;
1082 let sandboxElement;
1083 if (securityLevel === "sandbox") {
1084 sandboxElement = select("#i" + id);
1085 }
1086 const root = securityLevel === "sandbox" ? select(sandboxElement.nodes()[0].contentDocument.body) : select("body");
1087 const svg = root.select(`[id='${id}']`);
1088 markers.insertLineEndings(svg, conf);
1089 const g = new graphlib.Graph({
1090 multigraph: false,
1091 compound: false,
1092 directed: true
1093 }).setGraph({
1094 rankdir: conf.layoutDirection,
1095 marginx: 20,
1096 marginy: 20,
1097 nodesep: 100,
1098 edgesep: 100,
1099 ranksep: 100
1100 }).setDefaultEdgeLabel(function() {
1101 return {};
1102 });
1103 let requirements2 = diagObj.db.getRequirements();
1104 let elements2 = diagObj.db.getElements();
1105 let relationships = diagObj.db.getRelationships();
1106 drawReqs(requirements2, g, svg);
1107 drawElements(elements2, g, svg);
1108 addRelationships(relationships, g);
1109 layout(g);
1110 adjustEntities(svg, g);
1111 relationships.forEach(function(rel) {
1112 drawRelationshipFromLayout(svg, rel, g, id, diagObj);
1113 });
1114 const padding = conf.rect_padding;
1115 const svgBounds = svg.node().getBBox();
1116 const width = svgBounds.width + padding * 2;
1117 const height = svgBounds.height + padding * 2;
1118 configureSvgSize(svg, height, width, conf.useMaxWidth);
1119 svg.attr("viewBox", `${svgBounds.x - padding} ${svgBounds.y - padding} ${width} ${height}`);
1120};
1121const renderer = {
1122 draw
1123};
1124const diagram = {
1125 parser: parser$1,
1126 db,
1127 renderer,
1128 styles
1129};
1130export {
1131 diagram
1132};
1133
\No newline at end of file