UNPKG

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