UNPKG

53.2 kBJavaScriptView Raw
1import { Z as getThemeVariables, W as defaultConfig, l as log, s as setAccTitle, g as getAccTitle, C as setDiagramTitle, D as getDiagramTitle, a as getAccDescription, b as setAccDescription, c as getConfig, E as clear$1, d as sanitizeText, j as d3select, k as configureSvgSize } from "./mermaid-dcacb631.js";
2import { l as linear } from "./linear-0ad15847.js";
3import "./init-cc95ec8e.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, 3], $V1 = [1, 4], $V2 = [1, 5], $V3 = [1, 6], $V4 = [1, 7], $V5 = [1, 5, 13, 15, 17, 19, 20, 25, 27, 28, 29, 30, 31, 32, 33, 34, 37, 38, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50], $V6 = [1, 5, 6, 13, 15, 17, 19, 20, 25, 27, 28, 29, 30, 31, 32, 33, 34, 37, 38, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50], $V7 = [32, 33, 34], $V8 = [2, 7], $V9 = [1, 13], $Va = [1, 17], $Vb = [1, 18], $Vc = [1, 19], $Vd = [1, 20], $Ve = [1, 21], $Vf = [1, 22], $Vg = [1, 23], $Vh = [1, 24], $Vi = [1, 25], $Vj = [1, 26], $Vk = [1, 27], $Vl = [1, 30], $Vm = [1, 31], $Vn = [1, 32], $Vo = [1, 33], $Vp = [1, 34], $Vq = [1, 35], $Vr = [1, 36], $Vs = [1, 37], $Vt = [1, 38], $Vu = [1, 39], $Vv = [1, 40], $Vw = [1, 41], $Vx = [1, 42], $Vy = [1, 57], $Vz = [1, 58], $VA = [5, 22, 26, 32, 33, 34, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51];
10 var parser2 = {
11 trace: function trace() {
12 },
13 yy: {},
14 symbols_: { "error": 2, "start": 3, "eol": 4, "SPACE": 5, "QUADRANT": 6, "document": 7, "line": 8, "statement": 9, "axisDetails": 10, "quadrantDetails": 11, "points": 12, "title": 13, "title_value": 14, "acc_title": 15, "acc_title_value": 16, "acc_descr": 17, "acc_descr_value": 18, "acc_descr_multiline_value": 19, "section": 20, "text": 21, "point_start": 22, "point_x": 23, "point_y": 24, "X-AXIS": 25, "AXIS-TEXT-DELIMITER": 26, "Y-AXIS": 27, "QUADRANT_1": 28, "QUADRANT_2": 29, "QUADRANT_3": 30, "QUADRANT_4": 31, "NEWLINE": 32, "SEMI": 33, "EOF": 34, "alphaNumToken": 35, "textNoTagsToken": 36, "STR": 37, "MD_STR": 38, "alphaNum": 39, "PUNCTUATION": 40, "AMP": 41, "NUM": 42, "ALPHA": 43, "COMMA": 44, "PLUS": 45, "EQUALS": 46, "MULT": 47, "DOT": 48, "BRKT": 49, "UNDERSCORE": 50, "MINUS": 51, "$accept": 0, "$end": 1 },
15 terminals_: { 2: "error", 5: "SPACE", 6: "QUADRANT", 13: "title", 14: "title_value", 15: "acc_title", 16: "acc_title_value", 17: "acc_descr", 18: "acc_descr_value", 19: "acc_descr_multiline_value", 20: "section", 22: "point_start", 23: "point_x", 24: "point_y", 25: "X-AXIS", 26: "AXIS-TEXT-DELIMITER", 27: "Y-AXIS", 28: "QUADRANT_1", 29: "QUADRANT_2", 30: "QUADRANT_3", 31: "QUADRANT_4", 32: "NEWLINE", 33: "SEMI", 34: "EOF", 37: "STR", 38: "MD_STR", 40: "PUNCTUATION", 41: "AMP", 42: "NUM", 43: "ALPHA", 44: "COMMA", 45: "PLUS", 46: "EQUALS", 47: "MULT", 48: "DOT", 49: "BRKT", 50: "UNDERSCORE", 51: "MINUS" },
16 productions_: [0, [3, 2], [3, 2], [3, 2], [7, 0], [7, 2], [8, 2], [9, 0], [9, 2], [9, 1], [9, 1], [9, 1], [9, 2], [9, 2], [9, 2], [9, 1], [9, 1], [12, 4], [10, 4], [10, 3], [10, 2], [10, 4], [10, 3], [10, 2], [11, 2], [11, 2], [11, 2], [11, 2], [4, 1], [4, 1], [4, 1], [21, 1], [21, 2], [21, 1], [21, 1], [39, 1], [39, 2], [35, 1], [35, 1], [35, 1], [35, 1], [35, 1], [35, 1], [35, 1], [35, 1], [35, 1], [35, 1], [35, 1], [36, 1], [36, 1], [36, 1]],
17 performAction: function anonymous(yytext, yyleng, yylineno, yy, yystate, $$, _$) {
18 var $0 = $$.length - 1;
19 switch (yystate) {
20 case 12:
21 this.$ = $$[$0].trim();
22 yy.setDiagramTitle(this.$);
23 break;
24 case 13:
25 this.$ = $$[$0].trim();
26 yy.setAccTitle(this.$);
27 break;
28 case 14:
29 case 15:
30 this.$ = $$[$0].trim();
31 yy.setAccDescription(this.$);
32 break;
33 case 16:
34 yy.addSection($$[$0].substr(8));
35 this.$ = $$[$0].substr(8);
36 break;
37 case 17:
38 yy.addPoint($$[$0 - 3], $$[$0 - 1], $$[$0]);
39 break;
40 case 18:
41 yy.setXAxisLeftText($$[$0 - 2]);
42 yy.setXAxisRightText($$[$0]);
43 break;
44 case 19:
45 $$[$0 - 1].text += " ⟶ ";
46 yy.setXAxisLeftText($$[$0 - 1]);
47 break;
48 case 20:
49 yy.setXAxisLeftText($$[$0]);
50 break;
51 case 21:
52 yy.setYAxisBottomText($$[$0 - 2]);
53 yy.setYAxisTopText($$[$0]);
54 break;
55 case 22:
56 $$[$0 - 1].text += " ⟶ ";
57 yy.setYAxisBottomText($$[$0 - 1]);
58 break;
59 case 23:
60 yy.setYAxisBottomText($$[$0]);
61 break;
62 case 24:
63 yy.setQuadrant1Text($$[$0]);
64 break;
65 case 25:
66 yy.setQuadrant2Text($$[$0]);
67 break;
68 case 26:
69 yy.setQuadrant3Text($$[$0]);
70 break;
71 case 27:
72 yy.setQuadrant4Text($$[$0]);
73 break;
74 case 31:
75 this.$ = { text: $$[$0], type: "text" };
76 break;
77 case 32:
78 this.$ = { text: $$[$0 - 1].text + "" + $$[$0], type: $$[$0 - 1].type };
79 break;
80 case 33:
81 this.$ = { text: $$[$0], type: "text" };
82 break;
83 case 34:
84 this.$ = { text: $$[$0], type: "markdown" };
85 break;
86 case 35:
87 this.$ = $$[$0];
88 break;
89 case 36:
90 this.$ = $$[$0 - 1] + "" + $$[$0];
91 break;
92 }
93 },
94 table: [{ 3: 1, 4: 2, 5: $V0, 6: $V1, 32: $V2, 33: $V3, 34: $V4 }, { 1: [3] }, { 3: 8, 4: 2, 5: $V0, 6: $V1, 32: $V2, 33: $V3, 34: $V4 }, { 3: 9, 4: 2, 5: $V0, 6: $V1, 32: $V2, 33: $V3, 34: $V4 }, o($V5, [2, 4], { 7: 10 }), o($V6, [2, 28]), o($V6, [2, 29]), o($V6, [2, 30]), { 1: [2, 1] }, { 1: [2, 2] }, o($V7, $V8, { 8: 11, 9: 12, 10: 14, 11: 15, 12: 16, 21: 28, 35: 29, 1: [2, 3], 5: $V9, 13: $Va, 15: $Vb, 17: $Vc, 19: $Vd, 20: $Ve, 25: $Vf, 27: $Vg, 28: $Vh, 29: $Vi, 30: $Vj, 31: $Vk, 37: $Vl, 38: $Vm, 40: $Vn, 41: $Vo, 42: $Vp, 43: $Vq, 44: $Vr, 45: $Vs, 46: $Vt, 47: $Vu, 48: $Vv, 49: $Vw, 50: $Vx }), o($V5, [2, 5]), { 4: 43, 32: $V2, 33: $V3, 34: $V4 }, o($V7, $V8, { 10: 14, 11: 15, 12: 16, 21: 28, 35: 29, 9: 44, 5: $V9, 13: $Va, 15: $Vb, 17: $Vc, 19: $Vd, 20: $Ve, 25: $Vf, 27: $Vg, 28: $Vh, 29: $Vi, 30: $Vj, 31: $Vk, 37: $Vl, 38: $Vm, 40: $Vn, 41: $Vo, 42: $Vp, 43: $Vq, 44: $Vr, 45: $Vs, 46: $Vt, 47: $Vu, 48: $Vv, 49: $Vw, 50: $Vx }), o($V7, [2, 9]), o($V7, [2, 10]), o($V7, [2, 11]), { 14: [1, 45] }, { 16: [1, 46] }, { 18: [1, 47] }, o($V7, [2, 15]), o($V7, [2, 16]), { 21: 48, 35: 29, 37: $Vl, 38: $Vm, 40: $Vn, 41: $Vo, 42: $Vp, 43: $Vq, 44: $Vr, 45: $Vs, 46: $Vt, 47: $Vu, 48: $Vv, 49: $Vw, 50: $Vx }, { 21: 49, 35: 29, 37: $Vl, 38: $Vm, 40: $Vn, 41: $Vo, 42: $Vp, 43: $Vq, 44: $Vr, 45: $Vs, 46: $Vt, 47: $Vu, 48: $Vv, 49: $Vw, 50: $Vx }, { 21: 50, 35: 29, 37: $Vl, 38: $Vm, 40: $Vn, 41: $Vo, 42: $Vp, 43: $Vq, 44: $Vr, 45: $Vs, 46: $Vt, 47: $Vu, 48: $Vv, 49: $Vw, 50: $Vx }, { 21: 51, 35: 29, 37: $Vl, 38: $Vm, 40: $Vn, 41: $Vo, 42: $Vp, 43: $Vq, 44: $Vr, 45: $Vs, 46: $Vt, 47: $Vu, 48: $Vv, 49: $Vw, 50: $Vx }, { 21: 52, 35: 29, 37: $Vl, 38: $Vm, 40: $Vn, 41: $Vo, 42: $Vp, 43: $Vq, 44: $Vr, 45: $Vs, 46: $Vt, 47: $Vu, 48: $Vv, 49: $Vw, 50: $Vx }, { 21: 53, 35: 29, 37: $Vl, 38: $Vm, 40: $Vn, 41: $Vo, 42: $Vp, 43: $Vq, 44: $Vr, 45: $Vs, 46: $Vt, 47: $Vu, 48: $Vv, 49: $Vw, 50: $Vx }, { 5: $Vy, 22: [1, 54], 35: 56, 36: 55, 40: $Vn, 41: $Vo, 42: $Vp, 43: $Vq, 44: $Vr, 45: $Vs, 46: $Vt, 47: $Vu, 48: $Vv, 49: $Vw, 50: $Vx, 51: $Vz }, o($VA, [2, 31]), o($VA, [2, 33]), o($VA, [2, 34]), o($VA, [2, 37]), o($VA, [2, 38]), o($VA, [2, 39]), o($VA, [2, 40]), o($VA, [2, 41]), o($VA, [2, 42]), o($VA, [2, 43]), o($VA, [2, 44]), o($VA, [2, 45]), o($VA, [2, 46]), o($VA, [2, 47]), o($V5, [2, 6]), o($V7, [2, 8]), o($V7, [2, 12]), o($V7, [2, 13]), o($V7, [2, 14]), o($V7, [2, 20], { 36: 55, 35: 56, 5: $Vy, 26: [1, 59], 40: $Vn, 41: $Vo, 42: $Vp, 43: $Vq, 44: $Vr, 45: $Vs, 46: $Vt, 47: $Vu, 48: $Vv, 49: $Vw, 50: $Vx, 51: $Vz }), o($V7, [2, 23], { 36: 55, 35: 56, 5: $Vy, 26: [1, 60], 40: $Vn, 41: $Vo, 42: $Vp, 43: $Vq, 44: $Vr, 45: $Vs, 46: $Vt, 47: $Vu, 48: $Vv, 49: $Vw, 50: $Vx, 51: $Vz }), o($V7, [2, 24], { 36: 55, 35: 56, 5: $Vy, 40: $Vn, 41: $Vo, 42: $Vp, 43: $Vq, 44: $Vr, 45: $Vs, 46: $Vt, 47: $Vu, 48: $Vv, 49: $Vw, 50: $Vx, 51: $Vz }), o($V7, [2, 25], { 36: 55, 35: 56, 5: $Vy, 40: $Vn, 41: $Vo, 42: $Vp, 43: $Vq, 44: $Vr, 45: $Vs, 46: $Vt, 47: $Vu, 48: $Vv, 49: $Vw, 50: $Vx, 51: $Vz }), o($V7, [2, 26], { 36: 55, 35: 56, 5: $Vy, 40: $Vn, 41: $Vo, 42: $Vp, 43: $Vq, 44: $Vr, 45: $Vs, 46: $Vt, 47: $Vu, 48: $Vv, 49: $Vw, 50: $Vx, 51: $Vz }), o($V7, [2, 27], { 36: 55, 35: 56, 5: $Vy, 40: $Vn, 41: $Vo, 42: $Vp, 43: $Vq, 44: $Vr, 45: $Vs, 46: $Vt, 47: $Vu, 48: $Vv, 49: $Vw, 50: $Vx, 51: $Vz }), { 23: [1, 61] }, o($VA, [2, 32]), o($VA, [2, 48]), o($VA, [2, 49]), o($VA, [2, 50]), o($V7, [2, 19], { 35: 29, 21: 62, 37: $Vl, 38: $Vm, 40: $Vn, 41: $Vo, 42: $Vp, 43: $Vq, 44: $Vr, 45: $Vs, 46: $Vt, 47: $Vu, 48: $Vv, 49: $Vw, 50: $Vx }), o($V7, [2, 22], { 35: 29, 21: 63, 37: $Vl, 38: $Vm, 40: $Vn, 41: $Vo, 42: $Vp, 43: $Vq, 44: $Vr, 45: $Vs, 46: $Vt, 47: $Vu, 48: $Vv, 49: $Vw, 50: $Vx }), { 24: [1, 64] }, o($V7, [2, 18], { 36: 55, 35: 56, 5: $Vy, 40: $Vn, 41: $Vo, 42: $Vp, 43: $Vq, 44: $Vr, 45: $Vs, 46: $Vt, 47: $Vu, 48: $Vv, 49: $Vw, 50: $Vx, 51: $Vz }), o($V7, [2, 21], { 36: 55, 35: 56, 5: $Vy, 40: $Vn, 41: $Vo, 42: $Vp, 43: $Vq, 44: $Vr, 45: $Vs, 46: $Vt, 47: $Vu, 48: $Vv, 49: $Vw, 50: $Vx, 51: $Vz }), o($V7, [2, 17])],
95 defaultActions: { 8: [2, 1], 9: [2, 2] },
96 parseError: function parseError(str, hash) {
97 if (hash.recoverable) {
98 this.trace(str);
99 } else {
100 var error = new Error(str);
101 error.hash = hash;
102 throw error;
103 }
104 },
105 parse: function parse(input) {
106 var self = this, stack = [0], tstack = [], vstack = [null], lstack = [], table = this.table, yytext = "", yylineno = 0, yyleng = 0, TERROR = 2, EOF = 1;
107 var args = lstack.slice.call(arguments, 1);
108 var lexer2 = Object.create(this.lexer);
109 var sharedState = { yy: {} };
110 for (var k in this.yy) {
111 if (Object.prototype.hasOwnProperty.call(this.yy, k)) {
112 sharedState.yy[k] = this.yy[k];
113 }
114 }
115 lexer2.setInput(input, sharedState.yy);
116 sharedState.yy.lexer = lexer2;
117 sharedState.yy.parser = this;
118 if (typeof lexer2.yylloc == "undefined") {
119 lexer2.yylloc = {};
120 }
121 var yyloc = lexer2.yylloc;
122 lstack.push(yyloc);
123 var ranges = lexer2.options && lexer2.options.ranges;
124 if (typeof sharedState.yy.parseError === "function") {
125 this.parseError = sharedState.yy.parseError;
126 } else {
127 this.parseError = Object.getPrototypeOf(this).parseError;
128 }
129 function lex() {
130 var token;
131 token = tstack.pop() || lexer2.lex() || EOF;
132 if (typeof token !== "number") {
133 if (token instanceof Array) {
134 tstack = token;
135 token = tstack.pop();
136 }
137 token = self.symbols_[token] || token;
138 }
139 return token;
140 }
141 var symbol, state, action, r, yyval = {}, p, len, newState, expected;
142 while (true) {
143 state = stack[stack.length - 1];
144 if (this.defaultActions[state]) {
145 action = this.defaultActions[state];
146 } else {
147 if (symbol === null || typeof symbol == "undefined") {
148 symbol = lex();
149 }
150 action = table[state] && table[state][symbol];
151 }
152 if (typeof action === "undefined" || !action.length || !action[0]) {
153 var errStr = "";
154 expected = [];
155 for (p in table[state]) {
156 if (this.terminals_[p] && p > TERROR) {
157 expected.push("'" + this.terminals_[p] + "'");
158 }
159 }
160 if (lexer2.showPosition) {
161 errStr = "Parse error on line " + (yylineno + 1) + ":\n" + lexer2.showPosition() + "\nExpecting " + expected.join(", ") + ", got '" + (this.terminals_[symbol] || symbol) + "'";
162 } else {
163 errStr = "Parse error on line " + (yylineno + 1) + ": Unexpected " + (symbol == EOF ? "end of input" : "'" + (this.terminals_[symbol] || symbol) + "'");
164 }
165 this.parseError(errStr, {
166 text: lexer2.match,
167 token: this.terminals_[symbol] || symbol,
168 line: lexer2.yylineno,
169 loc: yyloc,
170 expected
171 });
172 }
173 if (action[0] instanceof Array && action.length > 1) {
174 throw new Error("Parse Error: multiple actions possible at state: " + state + ", token: " + symbol);
175 }
176 switch (action[0]) {
177 case 1:
178 stack.push(symbol);
179 vstack.push(lexer2.yytext);
180 lstack.push(lexer2.yylloc);
181 stack.push(action[1]);
182 symbol = null;
183 {
184 yyleng = lexer2.yyleng;
185 yytext = lexer2.yytext;
186 yylineno = lexer2.yylineno;
187 yyloc = lexer2.yylloc;
188 }
189 break;
190 case 2:
191 len = this.productions_[action[1]][1];
192 yyval.$ = vstack[vstack.length - len];
193 yyval._$ = {
194 first_line: lstack[lstack.length - (len || 1)].first_line,
195 last_line: lstack[lstack.length - 1].last_line,
196 first_column: lstack[lstack.length - (len || 1)].first_column,
197 last_column: lstack[lstack.length - 1].last_column
198 };
199 if (ranges) {
200 yyval._$.range = [
201 lstack[lstack.length - (len || 1)].range[0],
202 lstack[lstack.length - 1].range[1]
203 ];
204 }
205 r = this.performAction.apply(yyval, [
206 yytext,
207 yyleng,
208 yylineno,
209 sharedState.yy,
210 action[1],
211 vstack,
212 lstack
213 ].concat(args));
214 if (typeof r !== "undefined") {
215 return r;
216 }
217 if (len) {
218 stack = stack.slice(0, -1 * len * 2);
219 vstack = vstack.slice(0, -1 * len);
220 lstack = lstack.slice(0, -1 * len);
221 }
222 stack.push(this.productions_[action[1]][0]);
223 vstack.push(yyval.$);
224 lstack.push(yyval._$);
225 newState = table[stack[stack.length - 2]][stack[stack.length - 1]];
226 stack.push(newState);
227 break;
228 case 3:
229 return true;
230 }
231 }
232 return true;
233 }
234 };
235 var lexer = function() {
236 var lexer2 = {
237 EOF: 1,
238 parseError: function parseError(str, hash) {
239 if (this.yy.parser) {
240 this.yy.parser.parseError(str, hash);
241 } else {
242 throw new Error(str);
243 }
244 },
245 // resets the lexer, sets new input
246 setInput: function(input, yy) {
247 this.yy = yy || this.yy || {};
248 this._input = input;
249 this._more = this._backtrack = this.done = false;
250 this.yylineno = this.yyleng = 0;
251 this.yytext = this.matched = this.match = "";
252 this.conditionStack = ["INITIAL"];
253 this.yylloc = {
254 first_line: 1,
255 first_column: 0,
256 last_line: 1,
257 last_column: 0
258 };
259 if (this.options.ranges) {
260 this.yylloc.range = [0, 0];
261 }
262 this.offset = 0;
263 return this;
264 },
265 // consumes and returns one char from the input
266 input: function() {
267 var ch = this._input[0];
268 this.yytext += ch;
269 this.yyleng++;
270 this.offset++;
271 this.match += ch;
272 this.matched += ch;
273 var lines = ch.match(/(?:\r\n?|\n).*/g);
274 if (lines) {
275 this.yylineno++;
276 this.yylloc.last_line++;
277 } else {
278 this.yylloc.last_column++;
279 }
280 if (this.options.ranges) {
281 this.yylloc.range[1]++;
282 }
283 this._input = this._input.slice(1);
284 return ch;
285 },
286 // unshifts one char (or a string) into the input
287 unput: function(ch) {
288 var len = ch.length;
289 var lines = ch.split(/(?:\r\n?|\n)/g);
290 this._input = ch + this._input;
291 this.yytext = this.yytext.substr(0, this.yytext.length - len);
292 this.offset -= len;
293 var oldLines = this.match.split(/(?:\r\n?|\n)/g);
294 this.match = this.match.substr(0, this.match.length - 1);
295 this.matched = this.matched.substr(0, this.matched.length - 1);
296 if (lines.length - 1) {
297 this.yylineno -= lines.length - 1;
298 }
299 var r = this.yylloc.range;
300 this.yylloc = {
301 first_line: this.yylloc.first_line,
302 last_line: this.yylineno + 1,
303 first_column: this.yylloc.first_column,
304 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
305 };
306 if (this.options.ranges) {
307 this.yylloc.range = [r[0], r[0] + this.yyleng - len];
308 }
309 this.yyleng = this.yytext.length;
310 return this;
311 },
312 // When called from action, caches matched text and appends it on next action
313 more: function() {
314 this._more = true;
315 return this;
316 },
317 // 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.
318 reject: function() {
319 if (this.options.backtrack_lexer) {
320 this._backtrack = true;
321 } else {
322 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(), {
323 text: "",
324 token: null,
325 line: this.yylineno
326 });
327 }
328 return this;
329 },
330 // retain first n characters of the match
331 less: function(n) {
332 this.unput(this.match.slice(n));
333 },
334 // displays already matched input, i.e. for error messages
335 pastInput: function() {
336 var past = this.matched.substr(0, this.matched.length - this.match.length);
337 return (past.length > 20 ? "..." : "") + past.substr(-20).replace(/\n/g, "");
338 },
339 // displays upcoming input, i.e. for error messages
340 upcomingInput: function() {
341 var next = this.match;
342 if (next.length < 20) {
343 next += this._input.substr(0, 20 - next.length);
344 }
345 return (next.substr(0, 20) + (next.length > 20 ? "..." : "")).replace(/\n/g, "");
346 },
347 // displays the character position where the lexing error occurred, i.e. for error messages
348 showPosition: function() {
349 var pre = this.pastInput();
350 var c = new Array(pre.length + 1).join("-");
351 return pre + this.upcomingInput() + "\n" + c + "^";
352 },
353 // test the lexed token: return FALSE when not a match, otherwise return token
354 test_match: function(match, indexed_rule) {
355 var token, lines, backup;
356 if (this.options.backtrack_lexer) {
357 backup = {
358 yylineno: this.yylineno,
359 yylloc: {
360 first_line: this.yylloc.first_line,
361 last_line: this.last_line,
362 first_column: this.yylloc.first_column,
363 last_column: this.yylloc.last_column
364 },
365 yytext: this.yytext,
366 match: this.match,
367 matches: this.matches,
368 matched: this.matched,
369 yyleng: this.yyleng,
370 offset: this.offset,
371 _more: this._more,
372 _input: this._input,
373 yy: this.yy,
374 conditionStack: this.conditionStack.slice(0),
375 done: this.done
376 };
377 if (this.options.ranges) {
378 backup.yylloc.range = this.yylloc.range.slice(0);
379 }
380 }
381 lines = match[0].match(/(?:\r\n?|\n).*/g);
382 if (lines) {
383 this.yylineno += lines.length;
384 }
385 this.yylloc = {
386 first_line: this.yylloc.last_line,
387 last_line: this.yylineno + 1,
388 first_column: this.yylloc.last_column,
389 last_column: lines ? lines[lines.length - 1].length - lines[lines.length - 1].match(/\r?\n?/)[0].length : this.yylloc.last_column + match[0].length
390 };
391 this.yytext += match[0];
392 this.match += match[0];
393 this.matches = match;
394 this.yyleng = this.yytext.length;
395 if (this.options.ranges) {
396 this.yylloc.range = [this.offset, this.offset += this.yyleng];
397 }
398 this._more = false;
399 this._backtrack = false;
400 this._input = this._input.slice(match[0].length);
401 this.matched += match[0];
402 token = this.performAction.call(this, this.yy, this, indexed_rule, this.conditionStack[this.conditionStack.length - 1]);
403 if (this.done && this._input) {
404 this.done = false;
405 }
406 if (token) {
407 return token;
408 } else if (this._backtrack) {
409 for (var k in backup) {
410 this[k] = backup[k];
411 }
412 return false;
413 }
414 return false;
415 },
416 // return next match in input
417 next: function() {
418 if (this.done) {
419 return this.EOF;
420 }
421 if (!this._input) {
422 this.done = true;
423 }
424 var token, match, tempMatch, index;
425 if (!this._more) {
426 this.yytext = "";
427 this.match = "";
428 }
429 var rules = this._currentRules();
430 for (var i = 0; i < rules.length; i++) {
431 tempMatch = this._input.match(this.rules[rules[i]]);
432 if (tempMatch && (!match || tempMatch[0].length > match[0].length)) {
433 match = tempMatch;
434 index = i;
435 if (this.options.backtrack_lexer) {
436 token = this.test_match(tempMatch, rules[i]);
437 if (token !== false) {
438 return token;
439 } else if (this._backtrack) {
440 match = false;
441 continue;
442 } else {
443 return false;
444 }
445 } else if (!this.options.flex) {
446 break;
447 }
448 }
449 }
450 if (match) {
451 token = this.test_match(match, rules[index]);
452 if (token !== false) {
453 return token;
454 }
455 return false;
456 }
457 if (this._input === "") {
458 return this.EOF;
459 } else {
460 return this.parseError("Lexical error on line " + (this.yylineno + 1) + ". Unrecognized text.\n" + this.showPosition(), {
461 text: "",
462 token: null,
463 line: this.yylineno
464 });
465 }
466 },
467 // return next match that has a token
468 lex: function lex() {
469 var r = this.next();
470 if (r) {
471 return r;
472 } else {
473 return this.lex();
474 }
475 },
476 // activates a new lexer condition state (pushes the new lexer condition state onto the condition stack)
477 begin: function begin(condition) {
478 this.conditionStack.push(condition);
479 },
480 // pop the previously active lexer condition state off the condition stack
481 popState: function popState() {
482 var n = this.conditionStack.length - 1;
483 if (n > 0) {
484 return this.conditionStack.pop();
485 } else {
486 return this.conditionStack[0];
487 }
488 },
489 // produce the lexer rule set which is active for the currently active lexer condition state
490 _currentRules: function _currentRules() {
491 if (this.conditionStack.length && this.conditionStack[this.conditionStack.length - 1]) {
492 return this.conditions[this.conditionStack[this.conditionStack.length - 1]].rules;
493 } else {
494 return this.conditions["INITIAL"].rules;
495 }
496 },
497 // return the currently active lexer condition state; when an index argument is provided it produces the N-th previous condition state, if available
498 topState: function topState(n) {
499 n = this.conditionStack.length - 1 - Math.abs(n || 0);
500 if (n >= 0) {
501 return this.conditionStack[n];
502 } else {
503 return "INITIAL";
504 }
505 },
506 // alias for begin(condition)
507 pushState: function pushState(condition) {
508 this.begin(condition);
509 },
510 // return the number of states currently on the stack
511 stateStackSize: function stateStackSize() {
512 return this.conditionStack.length;
513 },
514 options: { "case-insensitive": true },
515 performAction: function anonymous(yy, yy_, $avoiding_name_collisions, YY_START) {
516 switch ($avoiding_name_collisions) {
517 case 0:
518 break;
519 case 1:
520 break;
521 case 2:
522 return 32;
523 case 3:
524 break;
525 case 4:
526 this.begin("title");
527 return 13;
528 case 5:
529 this.popState();
530 return "title_value";
531 case 6:
532 this.begin("acc_title");
533 return 15;
534 case 7:
535 this.popState();
536 return "acc_title_value";
537 case 8:
538 this.begin("acc_descr");
539 return 17;
540 case 9:
541 this.popState();
542 return "acc_descr_value";
543 case 10:
544 this.begin("acc_descr_multiline");
545 break;
546 case 11:
547 this.popState();
548 break;
549 case 12:
550 return "acc_descr_multiline_value";
551 case 13:
552 return 25;
553 case 14:
554 return 27;
555 case 15:
556 return 26;
557 case 16:
558 return 28;
559 case 17:
560 return 29;
561 case 18:
562 return 30;
563 case 19:
564 return 31;
565 case 20:
566 this.begin("md_string");
567 break;
568 case 21:
569 return "MD_STR";
570 case 22:
571 this.popState();
572 break;
573 case 23:
574 this.begin("string");
575 break;
576 case 24:
577 this.popState();
578 break;
579 case 25:
580 return "STR";
581 case 26:
582 this.begin("point_start");
583 return 22;
584 case 27:
585 this.begin("point_x");
586 return 23;
587 case 28:
588 this.popState();
589 break;
590 case 29:
591 this.popState();
592 this.begin("point_y");
593 break;
594 case 30:
595 this.popState();
596 return 24;
597 case 31:
598 return 6;
599 case 32:
600 return 43;
601 case 33:
602 return "COLON";
603 case 34:
604 return 45;
605 case 35:
606 return 44;
607 case 36:
608 return 46;
609 case 37:
610 return 46;
611 case 38:
612 return 47;
613 case 39:
614 return 49;
615 case 40:
616 return 50;
617 case 41:
618 return 48;
619 case 42:
620 return 41;
621 case 43:
622 return 51;
623 case 44:
624 return 42;
625 case 45:
626 return 5;
627 case 46:
628 return 33;
629 case 47:
630 return 40;
631 case 48:
632 return 34;
633 }
634 },
635 rules: [/^(?:%%(?!\{)[^\n]*)/i, /^(?:[^\}]%%[^\n]*)/i, /^(?:[\n\r]+)/i, /^(?:%%[^\n]*)/i, /^(?:title\b)/i, /^(?:(?!\n||)*[^\n]*)/i, /^(?:accTitle\s*:\s*)/i, /^(?:(?!\n||)*[^\n]*)/i, /^(?:accDescr\s*:\s*)/i, /^(?:(?!\n||)*[^\n]*)/i, /^(?:accDescr\s*\{\s*)/i, /^(?:[\}])/i, /^(?:[^\}]*)/i, /^(?: *x-axis *)/i, /^(?: *y-axis *)/i, /^(?: *--+> *)/i, /^(?: *quadrant-1 *)/i, /^(?: *quadrant-2 *)/i, /^(?: *quadrant-3 *)/i, /^(?: *quadrant-4 *)/i, /^(?:["][`])/i, /^(?:[^`"]+)/i, /^(?:[`]["])/i, /^(?:["])/i, /^(?:["])/i, /^(?:[^"]*)/i, /^(?:\s*:\s*\[\s*)/i, /^(?:(1)|(0(.\d+)?))/i, /^(?:\s*\] *)/i, /^(?:\s*,\s*)/i, /^(?:(1)|(0(.\d+)?))/i, /^(?: *quadrantChart *)/i, /^(?:[A-Za-z]+)/i, /^(?::)/i, /^(?:\+)/i, /^(?:,)/i, /^(?:=)/i, /^(?:=)/i, /^(?:\*)/i, /^(?:#)/i, /^(?:[\_])/i, /^(?:\.)/i, /^(?:&)/i, /^(?:-)/i, /^(?:[0-9]+)/i, /^(?:\s)/i, /^(?:;)/i, /^(?:[!"#$%&'*+,-.`?\\_/])/i, /^(?:$)/i],
636 conditions: { "point_y": { "rules": [30], "inclusive": false }, "point_x": { "rules": [29], "inclusive": false }, "point_start": { "rules": [27, 28], "inclusive": false }, "acc_descr_multiline": { "rules": [11, 12], "inclusive": false }, "acc_descr": { "rules": [9], "inclusive": false }, "acc_title": { "rules": [7], "inclusive": false }, "title": { "rules": [5], "inclusive": false }, "md_string": { "rules": [21, 22], "inclusive": false }, "string": { "rules": [24, 25], "inclusive": false }, "INITIAL": { "rules": [0, 1, 2, 3, 4, 6, 8, 10, 13, 14, 15, 16, 17, 18, 19, 20, 23, 26, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48], "inclusive": true } }
637 };
638 return lexer2;
639 }();
640 parser2.lexer = lexer;
641 function Parser() {
642 this.yy = {};
643 }
644 Parser.prototype = parser2;
645 parser2.Parser = Parser;
646 return new Parser();
647}();
648parser.parser = parser;
649const parser$1 = parser;
650const defaultThemeVariables = getThemeVariables();
651class QuadrantBuilder {
652 constructor() {
653 this.config = this.getDefaultConfig();
654 this.themeConfig = this.getDefaultThemeConfig();
655 this.data = this.getDefaultData();
656 }
657 getDefaultData() {
658 return {
659 titleText: "",
660 quadrant1Text: "",
661 quadrant2Text: "",
662 quadrant3Text: "",
663 quadrant4Text: "",
664 xAxisLeftText: "",
665 xAxisRightText: "",
666 yAxisBottomText: "",
667 yAxisTopText: "",
668 points: []
669 };
670 }
671 getDefaultConfig() {
672 var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r;
673 return {
674 showXAxis: true,
675 showYAxis: true,
676 showTitle: true,
677 chartHeight: ((_a = defaultConfig.quadrantChart) == null ? void 0 : _a.chartWidth) || 500,
678 chartWidth: ((_b = defaultConfig.quadrantChart) == null ? void 0 : _b.chartHeight) || 500,
679 titlePadding: ((_c = defaultConfig.quadrantChart) == null ? void 0 : _c.titlePadding) || 10,
680 titleFontSize: ((_d = defaultConfig.quadrantChart) == null ? void 0 : _d.titleFontSize) || 20,
681 quadrantPadding: ((_e = defaultConfig.quadrantChart) == null ? void 0 : _e.quadrantPadding) || 5,
682 xAxisLabelPadding: ((_f = defaultConfig.quadrantChart) == null ? void 0 : _f.xAxisLabelPadding) || 5,
683 yAxisLabelPadding: ((_g = defaultConfig.quadrantChart) == null ? void 0 : _g.yAxisLabelPadding) || 5,
684 xAxisLabelFontSize: ((_h = defaultConfig.quadrantChart) == null ? void 0 : _h.xAxisLabelFontSize) || 16,
685 yAxisLabelFontSize: ((_i = defaultConfig.quadrantChart) == null ? void 0 : _i.yAxisLabelFontSize) || 16,
686 quadrantLabelFontSize: ((_j = defaultConfig.quadrantChart) == null ? void 0 : _j.quadrantLabelFontSize) || 16,
687 quadrantTextTopPadding: ((_k = defaultConfig.quadrantChart) == null ? void 0 : _k.quadrantTextTopPadding) || 5,
688 pointTextPadding: ((_l = defaultConfig.quadrantChart) == null ? void 0 : _l.pointTextPadding) || 5,
689 pointLabelFontSize: ((_m = defaultConfig.quadrantChart) == null ? void 0 : _m.pointLabelFontSize) || 12,
690 pointRadius: ((_n = defaultConfig.quadrantChart) == null ? void 0 : _n.pointRadius) || 5,
691 xAxisPosition: ((_o = defaultConfig.quadrantChart) == null ? void 0 : _o.xAxisPosition) || "top",
692 yAxisPosition: ((_p = defaultConfig.quadrantChart) == null ? void 0 : _p.yAxisPosition) || "left",
693 quadrantInternalBorderStrokeWidth: ((_q = defaultConfig.quadrantChart) == null ? void 0 : _q.quadrantInternalBorderStrokeWidth) || 1,
694 quadrantExternalBorderStrokeWidth: ((_r = defaultConfig.quadrantChart) == null ? void 0 : _r.quadrantExternalBorderStrokeWidth) || 2
695 };
696 }
697 getDefaultThemeConfig() {
698 return {
699 quadrant1Fill: defaultThemeVariables.quadrant1Fill,
700 quadrant2Fill: defaultThemeVariables.quadrant2Fill,
701 quadrant3Fill: defaultThemeVariables.quadrant3Fill,
702 quadrant4Fill: defaultThemeVariables.quadrant4Fill,
703 quadrant1TextFill: defaultThemeVariables.quadrant1TextFill,
704 quadrant2TextFill: defaultThemeVariables.quadrant2TextFill,
705 quadrant3TextFill: defaultThemeVariables.quadrant3TextFill,
706 quadrant4TextFill: defaultThemeVariables.quadrant4TextFill,
707 quadrantPointFill: defaultThemeVariables.quadrantPointFill,
708 quadrantPointTextFill: defaultThemeVariables.quadrantPointTextFill,
709 quadrantXAxisTextFill: defaultThemeVariables.quadrantXAxisTextFill,
710 quadrantYAxisTextFill: defaultThemeVariables.quadrantYAxisTextFill,
711 quadrantTitleFill: defaultThemeVariables.quadrantTitleFill,
712 quadrantInternalBorderStrokeFill: defaultThemeVariables.quadrantInternalBorderStrokeFill,
713 quadrantExternalBorderStrokeFill: defaultThemeVariables.quadrantExternalBorderStrokeFill
714 };
715 }
716 clear() {
717 this.config = this.getDefaultConfig();
718 this.themeConfig = this.getDefaultThemeConfig();
719 this.data = this.getDefaultData();
720 log.info("clear called");
721 }
722 setData(data) {
723 this.data = { ...this.data, ...data };
724 }
725 addPoints(points) {
726 this.data.points = [...points, ...this.data.points];
727 }
728 setConfig(config2) {
729 log.trace("setConfig called with: ", config2);
730 this.config = { ...this.config, ...config2 };
731 }
732 setThemeConfig(themeConfig) {
733 log.trace("setThemeConfig called with: ", themeConfig);
734 this.themeConfig = { ...this.themeConfig, ...themeConfig };
735 }
736 calculateSpace(xAxisPosition, showXAxis, showYAxis, showTitle) {
737 const xAxisSpaceCalculation = this.config.xAxisLabelPadding * 2 + this.config.xAxisLabelFontSize;
738 const xAxisSpace = {
739 top: xAxisPosition === "top" && showXAxis ? xAxisSpaceCalculation : 0,
740 bottom: xAxisPosition === "bottom" && showXAxis ? xAxisSpaceCalculation : 0
741 };
742 const yAxisSpaceCalculation = this.config.yAxisLabelPadding * 2 + this.config.yAxisLabelFontSize;
743 const yAxisSpace = {
744 left: this.config.yAxisPosition === "left" && showYAxis ? yAxisSpaceCalculation : 0,
745 right: this.config.yAxisPosition === "right" && showYAxis ? yAxisSpaceCalculation : 0
746 };
747 const titleSpaceCalculation = this.config.titleFontSize + this.config.titlePadding * 2;
748 const titleSpace = {
749 top: showTitle ? titleSpaceCalculation : 0
750 };
751 const quadrantLeft = this.config.quadrantPadding + yAxisSpace.left;
752 const quadrantTop = this.config.quadrantPadding + xAxisSpace.top + titleSpace.top;
753 const quadrantWidth = this.config.chartWidth - this.config.quadrantPadding * 2 - yAxisSpace.left - yAxisSpace.right;
754 const quadrantHeight = this.config.chartHeight - this.config.quadrantPadding * 2 - xAxisSpace.top - xAxisSpace.bottom - titleSpace.top;
755 const quadrantHalfWidth = quadrantWidth / 2;
756 const quadrantHalfHeight = quadrantHeight / 2;
757 const quadrantSpace = {
758 quadrantLeft,
759 quadrantTop,
760 quadrantWidth,
761 quadrantHalfWidth,
762 quadrantHeight,
763 quadrantHalfHeight
764 };
765 return {
766 xAxisSpace,
767 yAxisSpace,
768 titleSpace,
769 quadrantSpace
770 };
771 }
772 getAxisLabels(xAxisPosition, showXAxis, showYAxis, spaceData) {
773 const { quadrantSpace, titleSpace } = spaceData;
774 const {
775 quadrantHalfHeight,
776 quadrantHeight,
777 quadrantLeft,
778 quadrantHalfWidth,
779 quadrantTop,
780 quadrantWidth
781 } = quadrantSpace;
782 const drawXAxisLabelsInMiddle = Boolean(this.data.xAxisRightText);
783 const drawYAxisLabelsInMiddle = Boolean(this.data.yAxisTopText);
784 const axisLabels = [];
785 if (this.data.xAxisLeftText && showXAxis) {
786 axisLabels.push({
787 text: this.data.xAxisLeftText,
788 fill: this.themeConfig.quadrantXAxisTextFill,
789 x: quadrantLeft + (drawXAxisLabelsInMiddle ? quadrantHalfWidth / 2 : 0),
790 y: xAxisPosition === "top" ? this.config.xAxisLabelPadding + titleSpace.top : this.config.xAxisLabelPadding + quadrantTop + quadrantHeight + this.config.quadrantPadding,
791 fontSize: this.config.xAxisLabelFontSize,
792 verticalPos: drawXAxisLabelsInMiddle ? "center" : "left",
793 horizontalPos: "top",
794 rotation: 0
795 });
796 }
797 if (this.data.xAxisRightText && showXAxis) {
798 axisLabels.push({
799 text: this.data.xAxisRightText,
800 fill: this.themeConfig.quadrantXAxisTextFill,
801 x: quadrantLeft + quadrantHalfWidth + (drawXAxisLabelsInMiddle ? quadrantHalfWidth / 2 : 0),
802 y: xAxisPosition === "top" ? this.config.xAxisLabelPadding + titleSpace.top : this.config.xAxisLabelPadding + quadrantTop + quadrantHeight + this.config.quadrantPadding,
803 fontSize: this.config.xAxisLabelFontSize,
804 verticalPos: drawXAxisLabelsInMiddle ? "center" : "left",
805 horizontalPos: "top",
806 rotation: 0
807 });
808 }
809 if (this.data.yAxisBottomText && showYAxis) {
810 axisLabels.push({
811 text: this.data.yAxisBottomText,
812 fill: this.themeConfig.quadrantYAxisTextFill,
813 x: this.config.yAxisPosition === "left" ? this.config.yAxisLabelPadding : this.config.yAxisLabelPadding + quadrantLeft + quadrantWidth + this.config.quadrantPadding,
814 y: quadrantTop + quadrantHeight - (drawYAxisLabelsInMiddle ? quadrantHalfHeight / 2 : 0),
815 fontSize: this.config.yAxisLabelFontSize,
816 verticalPos: drawYAxisLabelsInMiddle ? "center" : "left",
817 horizontalPos: "top",
818 rotation: -90
819 });
820 }
821 if (this.data.yAxisTopText && showYAxis) {
822 axisLabels.push({
823 text: this.data.yAxisTopText,
824 fill: this.themeConfig.quadrantYAxisTextFill,
825 x: this.config.yAxisPosition === "left" ? this.config.yAxisLabelPadding : this.config.yAxisLabelPadding + quadrantLeft + quadrantWidth + this.config.quadrantPadding,
826 y: quadrantTop + quadrantHalfHeight - (drawYAxisLabelsInMiddle ? quadrantHalfHeight / 2 : 0),
827 fontSize: this.config.yAxisLabelFontSize,
828 verticalPos: drawYAxisLabelsInMiddle ? "center" : "left",
829 horizontalPos: "top",
830 rotation: -90
831 });
832 }
833 return axisLabels;
834 }
835 getQuadrants(spaceData) {
836 const { quadrantSpace } = spaceData;
837 const { quadrantHalfHeight, quadrantLeft, quadrantHalfWidth, quadrantTop } = quadrantSpace;
838 const quadrants = [
839 {
840 text: {
841 text: this.data.quadrant1Text,
842 fill: this.themeConfig.quadrant1TextFill,
843 x: 0,
844 y: 0,
845 fontSize: this.config.quadrantLabelFontSize,
846 verticalPos: "center",
847 horizontalPos: "middle",
848 rotation: 0
849 },
850 x: quadrantLeft + quadrantHalfWidth,
851 y: quadrantTop,
852 width: quadrantHalfWidth,
853 height: quadrantHalfHeight,
854 fill: this.themeConfig.quadrant1Fill
855 },
856 {
857 text: {
858 text: this.data.quadrant2Text,
859 fill: this.themeConfig.quadrant2TextFill,
860 x: 0,
861 y: 0,
862 fontSize: this.config.quadrantLabelFontSize,
863 verticalPos: "center",
864 horizontalPos: "middle",
865 rotation: 0
866 },
867 x: quadrantLeft,
868 y: quadrantTop,
869 width: quadrantHalfWidth,
870 height: quadrantHalfHeight,
871 fill: this.themeConfig.quadrant2Fill
872 },
873 {
874 text: {
875 text: this.data.quadrant3Text,
876 fill: this.themeConfig.quadrant3TextFill,
877 x: 0,
878 y: 0,
879 fontSize: this.config.quadrantLabelFontSize,
880 verticalPos: "center",
881 horizontalPos: "middle",
882 rotation: 0
883 },
884 x: quadrantLeft,
885 y: quadrantTop + quadrantHalfHeight,
886 width: quadrantHalfWidth,
887 height: quadrantHalfHeight,
888 fill: this.themeConfig.quadrant3Fill
889 },
890 {
891 text: {
892 text: this.data.quadrant4Text,
893 fill: this.themeConfig.quadrant4TextFill,
894 x: 0,
895 y: 0,
896 fontSize: this.config.quadrantLabelFontSize,
897 verticalPos: "center",
898 horizontalPos: "middle",
899 rotation: 0
900 },
901 x: quadrantLeft + quadrantHalfWidth,
902 y: quadrantTop + quadrantHalfHeight,
903 width: quadrantHalfWidth,
904 height: quadrantHalfHeight,
905 fill: this.themeConfig.quadrant4Fill
906 }
907 ];
908 for (const quadrant of quadrants) {
909 quadrant.text.x = quadrant.x + quadrant.width / 2;
910 if (this.data.points.length === 0) {
911 quadrant.text.y = quadrant.y + quadrant.height / 2;
912 quadrant.text.horizontalPos = "middle";
913 } else {
914 quadrant.text.y = quadrant.y + this.config.quadrantTextTopPadding;
915 quadrant.text.horizontalPos = "top";
916 }
917 }
918 return quadrants;
919 }
920 getQuadrantPoints(spaceData) {
921 const { quadrantSpace } = spaceData;
922 const { quadrantHeight, quadrantLeft, quadrantTop, quadrantWidth } = quadrantSpace;
923 const xAxis = linear().domain([0, 1]).range([quadrantLeft, quadrantWidth + quadrantLeft]);
924 const yAxis = linear().domain([0, 1]).range([quadrantHeight + quadrantTop, quadrantTop]);
925 const points = this.data.points.map((point) => {
926 const props = {
927 x: xAxis(point.x),
928 y: yAxis(point.y),
929 fill: this.themeConfig.quadrantPointFill,
930 radius: this.config.pointRadius,
931 text: {
932 text: point.text,
933 fill: this.themeConfig.quadrantPointTextFill,
934 x: xAxis(point.x),
935 y: yAxis(point.y) + this.config.pointTextPadding,
936 verticalPos: "center",
937 horizontalPos: "top",
938 fontSize: this.config.pointLabelFontSize,
939 rotation: 0
940 }
941 };
942 return props;
943 });
944 return points;
945 }
946 getBorders(spaceData) {
947 const halfExternalBorderWidth = this.config.quadrantExternalBorderStrokeWidth / 2;
948 const { quadrantSpace } = spaceData;
949 const {
950 quadrantHalfHeight,
951 quadrantHeight,
952 quadrantLeft,
953 quadrantHalfWidth,
954 quadrantTop,
955 quadrantWidth
956 } = quadrantSpace;
957 const borderLines = [
958 // top border
959 {
960 strokeFill: this.themeConfig.quadrantExternalBorderStrokeFill,
961 strokeWidth: this.config.quadrantExternalBorderStrokeWidth,
962 x1: quadrantLeft - halfExternalBorderWidth,
963 y1: quadrantTop,
964 x2: quadrantLeft + quadrantWidth + halfExternalBorderWidth,
965 y2: quadrantTop
966 },
967 // right border
968 {
969 strokeFill: this.themeConfig.quadrantExternalBorderStrokeFill,
970 strokeWidth: this.config.quadrantExternalBorderStrokeWidth,
971 x1: quadrantLeft + quadrantWidth,
972 y1: quadrantTop + halfExternalBorderWidth,
973 x2: quadrantLeft + quadrantWidth,
974 y2: quadrantTop + quadrantHeight - halfExternalBorderWidth
975 },
976 // bottom border
977 {
978 strokeFill: this.themeConfig.quadrantExternalBorderStrokeFill,
979 strokeWidth: this.config.quadrantExternalBorderStrokeWidth,
980 x1: quadrantLeft - halfExternalBorderWidth,
981 y1: quadrantTop + quadrantHeight,
982 x2: quadrantLeft + quadrantWidth + halfExternalBorderWidth,
983 y2: quadrantTop + quadrantHeight
984 },
985 // left border
986 {
987 strokeFill: this.themeConfig.quadrantExternalBorderStrokeFill,
988 strokeWidth: this.config.quadrantExternalBorderStrokeWidth,
989 x1: quadrantLeft,
990 y1: quadrantTop + halfExternalBorderWidth,
991 x2: quadrantLeft,
992 y2: quadrantTop + quadrantHeight - halfExternalBorderWidth
993 },
994 // vertical inner border
995 {
996 strokeFill: this.themeConfig.quadrantInternalBorderStrokeFill,
997 strokeWidth: this.config.quadrantInternalBorderStrokeWidth,
998 x1: quadrantLeft + quadrantHalfWidth,
999 y1: quadrantTop + halfExternalBorderWidth,
1000 x2: quadrantLeft + quadrantHalfWidth,
1001 y2: quadrantTop + quadrantHeight - halfExternalBorderWidth
1002 },
1003 // horizontal inner border
1004 {
1005 strokeFill: this.themeConfig.quadrantInternalBorderStrokeFill,
1006 strokeWidth: this.config.quadrantInternalBorderStrokeWidth,
1007 x1: quadrantLeft + halfExternalBorderWidth,
1008 y1: quadrantTop + quadrantHalfHeight,
1009 x2: quadrantLeft + quadrantWidth - halfExternalBorderWidth,
1010 y2: quadrantTop + quadrantHalfHeight
1011 }
1012 ];
1013 return borderLines;
1014 }
1015 getTitle(showTitle) {
1016 if (showTitle) {
1017 return {
1018 text: this.data.titleText,
1019 fill: this.themeConfig.quadrantTitleFill,
1020 fontSize: this.config.titleFontSize,
1021 horizontalPos: "top",
1022 verticalPos: "center",
1023 rotation: 0,
1024 y: this.config.titlePadding,
1025 x: this.config.chartWidth / 2
1026 };
1027 }
1028 return;
1029 }
1030 build() {
1031 const showXAxis = this.config.showXAxis && !!(this.data.xAxisLeftText || this.data.xAxisRightText);
1032 const showYAxis = this.config.showYAxis && !!(this.data.yAxisTopText || this.data.yAxisBottomText);
1033 const showTitle = this.config.showTitle && !!this.data.titleText;
1034 const xAxisPosition = this.data.points.length > 0 ? "bottom" : this.config.xAxisPosition;
1035 const calculatedSpace = this.calculateSpace(xAxisPosition, showXAxis, showYAxis, showTitle);
1036 return {
1037 points: this.getQuadrantPoints(calculatedSpace),
1038 quadrants: this.getQuadrants(calculatedSpace),
1039 axisLabels: this.getAxisLabels(xAxisPosition, showXAxis, showYAxis, calculatedSpace),
1040 borderLines: this.getBorders(calculatedSpace),
1041 title: this.getTitle(showTitle)
1042 };
1043 }
1044}
1045const config = getConfig();
1046function textSanitizer(text) {
1047 return sanitizeText(text.trim(), config);
1048}
1049const quadrantBuilder = new QuadrantBuilder();
1050function setQuadrant1Text(textObj) {
1051 quadrantBuilder.setData({ quadrant1Text: textSanitizer(textObj.text) });
1052}
1053function setQuadrant2Text(textObj) {
1054 quadrantBuilder.setData({ quadrant2Text: textSanitizer(textObj.text) });
1055}
1056function setQuadrant3Text(textObj) {
1057 quadrantBuilder.setData({ quadrant3Text: textSanitizer(textObj.text) });
1058}
1059function setQuadrant4Text(textObj) {
1060 quadrantBuilder.setData({ quadrant4Text: textSanitizer(textObj.text) });
1061}
1062function setXAxisLeftText(textObj) {
1063 quadrantBuilder.setData({ xAxisLeftText: textSanitizer(textObj.text) });
1064}
1065function setXAxisRightText(textObj) {
1066 quadrantBuilder.setData({ xAxisRightText: textSanitizer(textObj.text) });
1067}
1068function setYAxisTopText(textObj) {
1069 quadrantBuilder.setData({ yAxisTopText: textSanitizer(textObj.text) });
1070}
1071function setYAxisBottomText(textObj) {
1072 quadrantBuilder.setData({ yAxisBottomText: textSanitizer(textObj.text) });
1073}
1074function addPoint(textObj, x, y) {
1075 quadrantBuilder.addPoints([{ x, y, text: textSanitizer(textObj.text) }]);
1076}
1077function setWidth(width) {
1078 quadrantBuilder.setConfig({ chartWidth: width });
1079}
1080function setHeight(height) {
1081 quadrantBuilder.setConfig({ chartHeight: height });
1082}
1083function getQuadrantData() {
1084 const config2 = getConfig();
1085 const { themeVariables, quadrantChart: quadrantChartConfig } = config2;
1086 if (quadrantChartConfig) {
1087 quadrantBuilder.setConfig(quadrantChartConfig);
1088 }
1089 quadrantBuilder.setThemeConfig({
1090 quadrant1Fill: themeVariables.quadrant1Fill,
1091 quadrant2Fill: themeVariables.quadrant2Fill,
1092 quadrant3Fill: themeVariables.quadrant3Fill,
1093 quadrant4Fill: themeVariables.quadrant4Fill,
1094 quadrant1TextFill: themeVariables.quadrant1TextFill,
1095 quadrant2TextFill: themeVariables.quadrant2TextFill,
1096 quadrant3TextFill: themeVariables.quadrant3TextFill,
1097 quadrant4TextFill: themeVariables.quadrant4TextFill,
1098 quadrantPointFill: themeVariables.quadrantPointFill,
1099 quadrantPointTextFill: themeVariables.quadrantPointTextFill,
1100 quadrantXAxisTextFill: themeVariables.quadrantXAxisTextFill,
1101 quadrantYAxisTextFill: themeVariables.quadrantYAxisTextFill,
1102 quadrantExternalBorderStrokeFill: themeVariables.quadrantExternalBorderStrokeFill,
1103 quadrantInternalBorderStrokeFill: themeVariables.quadrantInternalBorderStrokeFill,
1104 quadrantTitleFill: themeVariables.quadrantTitleFill
1105 });
1106 quadrantBuilder.setData({ titleText: getDiagramTitle() });
1107 return quadrantBuilder.build();
1108}
1109const clear = function() {
1110 quadrantBuilder.clear();
1111 clear$1();
1112};
1113const db = {
1114 setWidth,
1115 setHeight,
1116 setQuadrant1Text,
1117 setQuadrant2Text,
1118 setQuadrant3Text,
1119 setQuadrant4Text,
1120 setXAxisLeftText,
1121 setXAxisRightText,
1122 setYAxisTopText,
1123 setYAxisBottomText,
1124 addPoint,
1125 getQuadrantData,
1126 clear,
1127 setAccTitle,
1128 getAccTitle,
1129 setDiagramTitle,
1130 getDiagramTitle,
1131 getAccDescription,
1132 setAccDescription
1133};
1134const draw = (txt, id, _version, diagObj) => {
1135 var _a, _b, _c;
1136 function getDominantBaseLine(horizontalPos) {
1137 return horizontalPos === "top" ? "hanging" : "middle";
1138 }
1139 function getTextAnchor(verticalPos) {
1140 return verticalPos === "left" ? "start" : "middle";
1141 }
1142 function getTransformation(data) {
1143 return `translate(${data.x}, ${data.y}) rotate(${data.rotation || 0})`;
1144 }
1145 const conf = getConfig();
1146 log.debug("Rendering quadrant chart\n" + txt);
1147 const securityLevel = conf.securityLevel;
1148 let sandboxElement;
1149 if (securityLevel === "sandbox") {
1150 sandboxElement = d3select("#i" + id);
1151 }
1152 const root = securityLevel === "sandbox" ? d3select(sandboxElement.nodes()[0].contentDocument.body) : d3select("body");
1153 const svg = root.select(`[id="${id}"]`);
1154 const group = svg.append("g").attr("class", "main");
1155 const width = ((_a = conf.quadrantChart) == null ? void 0 : _a.chartWidth) || 500;
1156 const height = ((_b = conf.quadrantChart) == null ? void 0 : _b.chartHeight) || 500;
1157 configureSvgSize(svg, height, width, ((_c = conf.quadrantChart) == null ? void 0 : _c.useMaxWidth) || true);
1158 svg.attr("viewBox", "0 0 " + width + " " + height);
1159 diagObj.db.setHeight(height);
1160 diagObj.db.setWidth(width);
1161 const quadrantData = diagObj.db.getQuadrantData();
1162 const quadrantsGroup = group.append("g").attr("class", "quadrants");
1163 const borderGroup = group.append("g").attr("class", "border");
1164 const dataPointGroup = group.append("g").attr("class", "data-points");
1165 const labelGroup = group.append("g").attr("class", "labels");
1166 const titleGroup = group.append("g").attr("class", "title");
1167 if (quadrantData.title) {
1168 titleGroup.append("text").attr("x", 0).attr("y", 0).attr("fill", quadrantData.title.fill).attr("font-size", quadrantData.title.fontSize).attr("dominant-baseline", getDominantBaseLine(quadrantData.title.horizontalPos)).attr("text-anchor", getTextAnchor(quadrantData.title.verticalPos)).attr("transform", getTransformation(quadrantData.title)).text(quadrantData.title.text);
1169 }
1170 if (quadrantData.borderLines) {
1171 borderGroup.selectAll("line").data(quadrantData.borderLines).enter().append("line").attr("x1", (data) => data.x1).attr("y1", (data) => data.y1).attr("x2", (data) => data.x2).attr("y2", (data) => data.y2).style("stroke", (data) => data.strokeFill).style("stroke-width", (data) => data.strokeWidth);
1172 }
1173 const quadrants = quadrantsGroup.selectAll("g.quadrant").data(quadrantData.quadrants).enter().append("g").attr("class", "quadrant");
1174 quadrants.append("rect").attr("x", (data) => data.x).attr("y", (data) => data.y).attr("width", (data) => data.width).attr("height", (data) => data.height).attr("fill", (data) => data.fill);
1175 quadrants.append("text").attr("x", 0).attr("y", 0).attr("fill", (data) => data.text.fill).attr("font-size", (data) => data.text.fontSize).attr(
1176 "dominant-baseline",
1177 (data) => getDominantBaseLine(data.text.horizontalPos)
1178 ).attr("text-anchor", (data) => getTextAnchor(data.text.verticalPos)).attr("transform", (data) => getTransformation(data.text)).text((data) => data.text.text);
1179 const labels = labelGroup.selectAll("g.label").data(quadrantData.axisLabels).enter().append("g").attr("class", "label");
1180 labels.append("text").attr("x", 0).attr("y", 0).text((data) => data.text).attr("fill", (data) => data.fill).attr("font-size", (data) => data.fontSize).attr("dominant-baseline", (data) => getDominantBaseLine(data.horizontalPos)).attr("text-anchor", (data) => getTextAnchor(data.verticalPos)).attr("transform", (data) => getTransformation(data));
1181 const dataPoints = dataPointGroup.selectAll("g.data-point").data(quadrantData.points).enter().append("g").attr("class", "data-point");
1182 dataPoints.append("circle").attr("cx", (data) => data.x).attr("cy", (data) => data.y).attr("r", (data) => data.radius).attr("fill", (data) => data.fill);
1183 dataPoints.append("text").attr("x", 0).attr("y", 0).text((data) => data.text.text).attr("fill", (data) => data.text.fill).attr("font-size", (data) => data.text.fontSize).attr(
1184 "dominant-baseline",
1185 (data) => getDominantBaseLine(data.text.horizontalPos)
1186 ).attr("text-anchor", (data) => getTextAnchor(data.text.verticalPos)).attr("transform", (data) => getTransformation(data.text));
1187};
1188const renderer = {
1189 draw
1190};
1191const diagram = {
1192 parser: parser$1,
1193 db,
1194 renderer,
1195 styles: () => ""
1196};
1197export {
1198 diagram
1199};