UNPKG

mermaid

Version:

Markdown-ish syntax for generating flowcharts, mindmaps, sequence diagrams, class diagrams, gantt charts, git graphs and more.

8 lines (7 loc) 43.3 kB
import{a as Kt}from"./chunk-S4TE5DX6.mjs";import{d as qt}from"./chunk-TINYC7RT.mjs";import"./chunk-TDFULVG6.mjs";import{o as Rt}from"./chunk-QADHU5CF.mjs";import"./chunk-ZZ52EIBP.mjs";import{B as Wt,P as Ft,T as Nt,U as jt,V as Gt,W as Ht,X as $t,Y as Ut,Z as Tt,h as zt,j as Ot,u as ct}from"./chunk-FE53TMRB.mjs";import{H as kt,b as ht,n as wt,o as St}from"./chunk-L2B47AAZ.mjs";import{a as s}from"./chunk-QVIEFLGF.mjs";var _t=(function(){var i=s(function(Y,l,c,p){for(c=c||{},p=Y.length;p--;c[Y[p]]=l);return c},"o"),t=[1,10,12,14,16,18,19,21,23],e=[2,6],a=[1,3],n=[1,5],r=[1,6],h=[1,7],b=[1,5,10,12,14,16,18,19,21,23,36,37,38],x=[1,25],d=[1,26],S=[1,28],k=[1,29],P=[1,30],V=[1,31],z=[1,32],E=[1,33],O=[1,34],W=[1,35],F=[1,36],y=[1,37],L=[1,43],g=[1,42],j=[1,47],B=[1,50],A=[1,10,12,14,16,18,19,21,23,36,37,38],G=[1,10,12,14,16,18,19,21,23,24,26,28,29,36,37,38],_=[1,10,12,14,16,18,19,21,23,24,26,28,29,36,37,38,42,43,44,45,46,47,48,49,50,51],K=[1,65],w=[26,28],C={trace:s(function(){},"trace"),yy:{},symbols_:{error:2,start:3,eol:4,XYCHART:5,chartConfig:6,document:7,CHART_ORIENTATION:8,statement:9,title:10,text:11,X_AXIS:12,parseXAxis:13,Y_AXIS:14,parseYAxis:15,LINE:16,plotData:17,BAR:18,acc_title:19,acc_title_value:20,acc_descr:21,acc_descr_value:22,acc_descr_multiline_value:23,SQUARE_BRACES_START:24,dataPoints:25,SQUARE_BRACES_END:26,dataPoint:27,COMMA:28,NUMBER_WITH_DECIMAL:29,STR:30,xAxisData:31,bandData:32,ARROW_DELIMITER:33,commaSeparatedTexts:34,yAxisData:35,NEWLINE:36,SEMI:37,EOF:38,alphaNum:39,MD_STR:40,alphaNumToken:41,AMP:42,NUM:43,ALPHA:44,PLUS:45,EQUALS:46,MULT:47,DOT:48,BRKT:49,MINUS:50,UNDERSCORE:51,$accept:0,$end:1},terminals_:{2:"error",5:"XYCHART",8:"CHART_ORIENTATION",10:"title",12:"X_AXIS",14:"Y_AXIS",16:"LINE",18:"BAR",19:"acc_title",20:"acc_title_value",21:"acc_descr",22:"acc_descr_value",23:"acc_descr_multiline_value",24:"SQUARE_BRACES_START",26:"SQUARE_BRACES_END",28:"COMMA",29:"NUMBER_WITH_DECIMAL",30:"STR",33:"ARROW_DELIMITER",36:"NEWLINE",37:"SEMI",38:"EOF",40:"MD_STR",42:"AMP",43:"NUM",44:"ALPHA",45:"PLUS",46:"EQUALS",47:"MULT",48:"DOT",49:"BRKT",50:"MINUS",51:"UNDERSCORE"},productions_:[0,[3,2],[3,3],[3,2],[3,1],[6,1],[7,0],[7,2],[9,2],[9,2],[9,2],[9,2],[9,2],[9,3],[9,2],[9,3],[9,2],[9,2],[9,1],[17,3],[25,3],[25,1],[27,2],[27,1],[13,1],[13,2],[13,1],[31,1],[31,3],[32,3],[34,3],[34,1],[15,1],[15,2],[15,1],[35,3],[4,1],[4,1],[4,1],[11,1],[11,1],[11,1],[39,1],[39,2],[41,1],[41,1],[41,1],[41,1],[41,1],[41,1],[41,1],[41,1],[41,1],[41,1]],performAction:s(function(l,c,p,u,D,o,$){var m=o.length-1;switch(D){case 5:u.setOrientation(o[m]);break;case 9:u.setDiagramTitle(o[m].text.trim());break;case 12:u.setLineData({text:"",type:"text"},o[m]);break;case 13:u.setLineData(o[m-1],o[m]);break;case 14:u.setBarData({text:"",type:"text"},o[m]);break;case 15:u.setBarData(o[m-1],o[m]);break;case 16:this.$=o[m].trim(),u.setAccTitle(this.$);break;case 17:case 18:this.$=o[m].trim(),u.setAccDescription(this.$);break;case 19:this.$=o[m-1];break;case 20:case 30:this.$=[o[m-2],...o[m]];break;case 21:case 31:this.$=[o[m]];break;case 22:this.$={value:Number(o[m-1]),label:o[m]};break;case 23:this.$={value:Number(o[m]),label:""};break;case 24:u.setXAxisTitle(o[m]);break;case 25:u.setXAxisTitle(o[m-1]);break;case 26:u.setXAxisTitle({type:"text",text:""});break;case 27:u.setXAxisBand(o[m]);break;case 28:u.setXAxisRangeData(Number(o[m-2]),Number(o[m]));break;case 29:this.$=o[m-1];break;case 32:u.setYAxisTitle(o[m]);break;case 33:u.setYAxisTitle(o[m-1]);break;case 34:u.setYAxisTitle({type:"text",text:""});break;case 35:u.setYAxisRangeData(Number(o[m-2]),Number(o[m]));break;case 39:this.$={text:o[m],type:"text"};break;case 40:this.$={text:o[m],type:"text"};break;case 41:this.$={text:o[m],type:"markdown"};break;case 42:this.$=o[m];break;case 43:this.$=o[m-1]+""+o[m];break}},"anonymous"),table:[i(t,e,{3:1,4:2,7:4,5:a,36:n,37:r,38:h}),{1:[3]},i(t,e,{4:2,7:4,3:8,5:a,36:n,37:r,38:h}),i(t,e,{4:2,7:4,6:9,3:10,5:a,8:[1,11],36:n,37:r,38:h}),{1:[2,4],9:12,10:[1,13],12:[1,14],14:[1,15],16:[1,16],18:[1,17],19:[1,18],21:[1,19],23:[1,20]},i(b,[2,36]),i(b,[2,37]),i(b,[2,38]),{1:[2,1]},i(t,e,{4:2,7:4,3:21,5:a,36:n,37:r,38:h}),{1:[2,3]},i(b,[2,5]),i(t,[2,7],{4:22,36:n,37:r,38:h}),{11:23,30:x,39:24,40:d,41:27,42:S,43:k,44:P,45:V,46:z,47:E,48:O,49:W,50:F,51:y},{11:39,13:38,24:L,29:g,30:x,31:40,32:41,39:24,40:d,41:27,42:S,43:k,44:P,45:V,46:z,47:E,48:O,49:W,50:F,51:y},{11:45,15:44,29:j,30:x,35:46,39:24,40:d,41:27,42:S,43:k,44:P,45:V,46:z,47:E,48:O,49:W,50:F,51:y},{11:49,17:48,24:B,30:x,39:24,40:d,41:27,42:S,43:k,44:P,45:V,46:z,47:E,48:O,49:W,50:F,51:y},{11:52,17:51,24:B,30:x,39:24,40:d,41:27,42:S,43:k,44:P,45:V,46:z,47:E,48:O,49:W,50:F,51:y},{20:[1,53]},{22:[1,54]},i(A,[2,18]),{1:[2,2]},i(A,[2,8]),i(A,[2,9]),i(G,[2,39],{41:55,42:S,43:k,44:P,45:V,46:z,47:E,48:O,49:W,50:F,51:y}),i(G,[2,40]),i(G,[2,41]),i(_,[2,42]),i(_,[2,44]),i(_,[2,45]),i(_,[2,46]),i(_,[2,47]),i(_,[2,48]),i(_,[2,49]),i(_,[2,50]),i(_,[2,51]),i(_,[2,52]),i(_,[2,53]),i(A,[2,10]),i(A,[2,24],{32:41,31:56,24:L,29:g}),i(A,[2,26]),i(A,[2,27]),{33:[1,57]},{11:59,30:x,34:58,39:24,40:d,41:27,42:S,43:k,44:P,45:V,46:z,47:E,48:O,49:W,50:F,51:y},i(A,[2,11]),i(A,[2,32],{35:60,29:j}),i(A,[2,34]),{33:[1,61]},i(A,[2,12]),{17:62,24:B},{25:63,27:64,29:K},i(A,[2,14]),{17:66,24:B},i(A,[2,16]),i(A,[2,17]),i(_,[2,43]),i(A,[2,25]),{29:[1,67]},{26:[1,68]},{26:[2,31],28:[1,69]},i(A,[2,33]),{29:[1,70]},i(A,[2,13]),{26:[1,71]},{26:[2,21],28:[1,72]},i(w,[2,23],{30:[1,73]}),i(A,[2,15]),i(A,[2,28]),i(A,[2,29]),{11:59,30:x,34:74,39:24,40:d,41:27,42:S,43:k,44:P,45:V,46:z,47:E,48:O,49:W,50:F,51:y},i(A,[2,35]),i(A,[2,19]),{25:75,27:64,29:K},i(w,[2,22]),{26:[2,30]},{26:[2,20]}],defaultActions:{8:[2,1],10:[2,3],21:[2,2],74:[2,30],75:[2,20]},parseError:s(function(l,c){if(c.recoverable)this.trace(l);else{var p=new Error(l);throw p.hash=c,p}},"parseError"),parse:s(function(l){var c=this,p=[0],u=[],D=[null],o=[],$=this.table,m="",ot=0,It=0,Bt=0,ge=2,Mt=1,pe=o.slice.call(arguments,1),R=Object.create(this.lexer),U={yy:{}};for(var bt in this.yy)Object.prototype.hasOwnProperty.call(this.yy,bt)&&(U.yy[bt]=this.yy[bt]);R.setInput(l,U.yy),U.yy.lexer=R,U.yy.parser=this,typeof R.yylloc>"u"&&(R.yylloc={});var yt=R.yylloc;o.push(yt);var ue=R.options&&R.options.ranges;typeof U.yy.parseError=="function"?this.parseError=U.yy.parseError:this.parseError=Object.getPrototypeOf(this).parseError;function Xe(X){p.length=p.length-2*X,D.length=D.length-X,o.length=o.length-X}s(Xe,"popStack");function xe(){var X;return X=u.pop()||R.lex()||Mt,typeof X!="number"&&(X instanceof Array&&(u=X,X=u.pop()),X=c.symbols_[X]||X),X}s(xe,"lex");for(var v,Ct,q,I,Ye,At,Q={},rt,N,Vt,lt;;){if(q=p[p.length-1],this.defaultActions[q]?I=this.defaultActions[q]:((v===null||typeof v>"u")&&(v=xe()),I=$[q]&&$[q][v]),typeof I>"u"||!I.length||!I[0]){var Dt="";lt=[];for(rt in $[q])this.terminals_[rt]&&rt>ge&&lt.push("'"+this.terminals_[rt]+"'");R.showPosition?Dt="Parse error on line "+(ot+1)+`: `+R.showPosition()+` Expecting `+lt.join(", ")+", got '"+(this.terminals_[v]||v)+"'":Dt="Parse error on line "+(ot+1)+": Unexpected "+(v==Mt?"end of input":"'"+(this.terminals_[v]||v)+"'"),this.parseError(Dt,{text:R.match,token:this.terminals_[v]||v,line:R.yylineno,loc:yt,expected:lt})}if(I[0]instanceof Array&&I.length>1)throw new Error("Parse Error: multiple actions possible at state: "+q+", token: "+v);switch(I[0]){case 1:p.push(v),D.push(R.yytext),o.push(R.yylloc),p.push(I[1]),v=null,Ct?(v=Ct,Ct=null):(It=R.yyleng,m=R.yytext,ot=R.yylineno,yt=R.yylloc,Bt>0&&Bt--);break;case 2:if(N=this.productions_[I[1]][1],Q.$=D[D.length-N],Q._$={first_line:o[o.length-(N||1)].first_line,last_line:o[o.length-1].last_line,first_column:o[o.length-(N||1)].first_column,last_column:o[o.length-1].last_column},ue&&(Q._$.range=[o[o.length-(N||1)].range[0],o[o.length-1].range[1]]),At=this.performAction.apply(Q,[m,It,ot,U.yy,I[1],D,o].concat(pe)),typeof At<"u")return At;N&&(p=p.slice(0,-1*N*2),D=D.slice(0,-1*N),o=o.slice(0,-1*N)),p.push(this.productions_[I[1]][0]),D.push(Q.$),o.push(Q._$),Vt=$[p[p.length-2]][p[p.length-1]],p.push(Vt);break;case 3:return!0}}return!0},"parse")},M=(function(){var Y={EOF:1,parseError:s(function(c,p){if(this.yy.parser)this.yy.parser.parseError(c,p);else throw new Error(c)},"parseError"),setInput:s(function(l,c){return this.yy=c||this.yy||{},this._input=l,this._more=this._backtrack=this.done=!1,this.yylineno=this.yyleng=0,this.yytext=this.matched=this.match="",this.conditionStack=["INITIAL"],this.yylloc={first_line:1,first_column:0,last_line:1,last_column:0},this.options.ranges&&(this.yylloc.range=[0,0]),this.offset=0,this},"setInput"),input:s(function(){var l=this._input[0];this.yytext+=l,this.yyleng++,this.offset++,this.match+=l,this.matched+=l;var c=l.match(/(?:\r\n?|\n).*/g);return c?(this.yylineno++,this.yylloc.last_line++):this.yylloc.last_column++,this.options.ranges&&this.yylloc.range[1]++,this._input=this._input.slice(1),l},"input"),unput:s(function(l){var c=l.length,p=l.split(/(?:\r\n?|\n)/g);this._input=l+this._input,this.yytext=this.yytext.substr(0,this.yytext.length-c),this.offset-=c;var u=this.match.split(/(?:\r\n?|\n)/g);this.match=this.match.substr(0,this.match.length-1),this.matched=this.matched.substr(0,this.matched.length-1),p.length-1&&(this.yylineno-=p.length-1);var D=this.yylloc.range;return this.yylloc={first_line:this.yylloc.first_line,last_line:this.yylineno+1,first_column:this.yylloc.first_column,last_column:p?(p.length===u.length?this.yylloc.first_column:0)+u[u.length-p.length].length-p[0].length:this.yylloc.first_column-c},this.options.ranges&&(this.yylloc.range=[D[0],D[0]+this.yyleng-c]),this.yyleng=this.yytext.length,this},"unput"),more:s(function(){return this._more=!0,this},"more"),reject:s(function(){if(this.options.backtrack_lexer)this._backtrack=!0;else return this.parseError("Lexical error on line "+(this.yylineno+1)+`. You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true). `+this.showPosition(),{text:"",token:null,line:this.yylineno});return this},"reject"),less:s(function(l){this.unput(this.match.slice(l))},"less"),pastInput:s(function(){var l=this.matched.substr(0,this.matched.length-this.match.length);return(l.length>20?"...":"")+l.substr(-20).replace(/\n/g,"")},"pastInput"),upcomingInput:s(function(){var l=this.match;return l.length<20&&(l+=this._input.substr(0,20-l.length)),(l.substr(0,20)+(l.length>20?"...":"")).replace(/\n/g,"")},"upcomingInput"),showPosition:s(function(){var l=this.pastInput(),c=new Array(l.length+1).join("-");return l+this.upcomingInput()+` `+c+"^"},"showPosition"),test_match:s(function(l,c){var p,u,D;if(this.options.backtrack_lexer&&(D={yylineno:this.yylineno,yylloc:{first_line:this.yylloc.first_line,last_line:this.last_line,first_column:this.yylloc.first_column,last_column:this.yylloc.last_column},yytext:this.yytext,match:this.match,matches:this.matches,matched:this.matched,yyleng:this.yyleng,offset:this.offset,_more:this._more,_input:this._input,yy:this.yy,conditionStack:this.conditionStack.slice(0),done:this.done},this.options.ranges&&(D.yylloc.range=this.yylloc.range.slice(0))),u=l[0].match(/(?:\r\n?|\n).*/g),u&&(this.yylineno+=u.length),this.yylloc={first_line:this.yylloc.last_line,last_line:this.yylineno+1,first_column:this.yylloc.last_column,last_column:u?u[u.length-1].length-u[u.length-1].match(/\r?\n?/)[0].length:this.yylloc.last_column+l[0].length},this.yytext+=l[0],this.match+=l[0],this.matches=l,this.yyleng=this.yytext.length,this.options.ranges&&(this.yylloc.range=[this.offset,this.offset+=this.yyleng]),this._more=!1,this._backtrack=!1,this._input=this._input.slice(l[0].length),this.matched+=l[0],p=this.performAction.call(this,this.yy,this,c,this.conditionStack[this.conditionStack.length-1]),this.done&&this._input&&(this.done=!1),p)return p;if(this._backtrack){for(var o in D)this[o]=D[o];return!1}return!1},"test_match"),next:s(function(){if(this.done)return this.EOF;this._input||(this.done=!0);var l,c,p,u;this._more||(this.yytext="",this.match="");for(var D=this._currentRules(),o=0;o<D.length;o++)if(p=this._input.match(this.rules[D[o]]),p&&(!c||p[0].length>c[0].length)){if(c=p,u=o,this.options.backtrack_lexer){if(l=this.test_match(p,D[o]),l!==!1)return l;if(this._backtrack){c=!1;continue}else return!1}else if(!this.options.flex)break}return c?(l=this.test_match(c,D[u]),l!==!1?l:!1):this._input===""?this.EOF:this.parseError("Lexical error on line "+(this.yylineno+1)+`. Unrecognized text. `+this.showPosition(),{text:"",token:null,line:this.yylineno})},"next"),lex:s(function(){var c=this.next();return c||this.lex()},"lex"),begin:s(function(c){this.conditionStack.push(c)},"begin"),popState:s(function(){var c=this.conditionStack.length-1;return c>0?this.conditionStack.pop():this.conditionStack[0]},"popState"),_currentRules:s(function(){return this.conditionStack.length&&this.conditionStack[this.conditionStack.length-1]?this.conditions[this.conditionStack[this.conditionStack.length-1]].rules:this.conditions.INITIAL.rules},"_currentRules"),topState:s(function(c){return c=this.conditionStack.length-1-Math.abs(c||0),c>=0?this.conditionStack[c]:"INITIAL"},"topState"),pushState:s(function(c){this.begin(c)},"pushState"),stateStackSize:s(function(){return this.conditionStack.length},"stateStackSize"),options:{"case-insensitive":!0},performAction:s(function(c,p,u,D){var o=D;switch(u){case 0:break;case 1:break;case 2:return this.popState(),36;break;case 3:return this.popState(),36;break;case 4:return 36;case 5:break;case 6:return 10;case 7:return this.pushState("acc_title"),19;break;case 8:return this.popState(),"acc_title_value";break;case 9:return this.pushState("acc_descr"),21;break;case 10:return this.popState(),"acc_descr_value";break;case 11:this.pushState("acc_descr_multiline");break;case 12:this.popState();break;case 13:return"acc_descr_multiline_value";case 14:return 5;case 15:return 5;case 16:return 8;case 17:return this.pushState("axis_data"),"X_AXIS";break;case 18:return this.pushState("axis_data"),"Y_AXIS";break;case 19:return this.pushState("axis_band_data"),24;break;case 20:return 33;case 21:return this.pushState("data"),16;break;case 22:return this.pushState("data"),18;break;case 23:return this.pushState("data_inner"),24;break;case 24:return 29;case 25:return this.popState(),26;break;case 26:this.popState();break;case 27:this.pushState("string");break;case 28:this.popState();break;case 29:return"STR";case 30:return 24;case 31:return 26;case 32:return 44;case 33:return"COLON";case 34:return 45;case 35:return 28;case 36:return 46;case 37:return 47;case 38:return 49;case 39:return 51;case 40:return 48;case 41:return 42;case 42:return 50;case 43:return 43;case 44:break;case 45:return 37;case 46:return 38}},"anonymous"),rules:[/^(?:%%(?!\{)[^\n]*)/i,/^(?:[^\}]%%[^\n]*)/i,/^(?:(\r?\n))/i,/^(?:(\r?\n))/i,/^(?:[\n\r]+)/i,/^(?:%%[^\n]*)/i,/^(?:title\b)/i,/^(?:accTitle\s*:\s*)/i,/^(?:(?!\n||)*[^\n]*)/i,/^(?:accDescr\s*:\s*)/i,/^(?:(?!\n||)*[^\n]*)/i,/^(?:accDescr\s*\{\s*)/i,/^(?:\})/i,/^(?:[^\}]*)/i,/^(?:xychart-beta\b)/i,/^(?:xychart\b)/i,/^(?:(?:vertical|horizontal))/i,/^(?:x-axis\b)/i,/^(?:y-axis\b)/i,/^(?:\[)/i,/^(?:-->)/i,/^(?:line\b)/i,/^(?:bar\b)/i,/^(?:\[)/i,/^(?:[+-]?(?:\d+(?:\.\d+)?|\.\d+))/i,/^(?:\])/i,/^(?:(?:`\) \{ this\.pushState\(md_string\); \}\n<md_string>\(\?:\(\?!`"\)\.\)\+ \{ return MD_STR; \}\n<md_string>\(\?:`))/i,/^(?:["])/i,/^(?:["])/i,/^(?:[^"]*)/i,/^(?:\[)/i,/^(?:\])/i,/^(?:[A-Za-z]+)/i,/^(?::)/i,/^(?:\+)/i,/^(?:,)/i,/^(?:=)/i,/^(?:\*)/i,/^(?:#)/i,/^(?:[\_])/i,/^(?:\.)/i,/^(?:&)/i,/^(?:-)/i,/^(?:[0-9]+)/i,/^(?:\s+)/i,/^(?:;)/i,/^(?:$)/i],conditions:{data_inner:{rules:[0,1,4,5,6,7,9,11,14,15,16,17,18,21,22,24,25,26,27,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46],inclusive:!0},data:{rules:[0,1,3,4,5,6,7,9,11,14,15,16,17,18,21,22,23,26,27,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46],inclusive:!0},axis_band_data:{rules:[0,1,4,5,6,7,9,11,14,15,16,17,18,21,22,25,26,27,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46],inclusive:!0},axis_data:{rules:[0,1,2,4,5,6,7,9,11,14,15,16,17,18,19,20,21,22,24,26,27,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46],inclusive:!0},acc_descr_multiline:{rules:[12,13],inclusive:!1},acc_descr:{rules:[10],inclusive:!1},acc_title:{rules:[8],inclusive:!1},title:{rules:[],inclusive:!1},md_string:{rules:[],inclusive:!1},string:{rules:[28,29],inclusive:!1},INITIAL:{rules:[0,1,4,5,6,7,9,11,14,15,16,17,18,21,22,26,27,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46],inclusive:!0}}};return Y})();C.lexer=M;function T(){this.yy={}}return s(T,"Parser"),T.prototype=C,C.Parser=T,new T})();_t.parser=_t;var Qt=_t;function et(i){return i.type==="bar"}s(et,"isBarPlot");function it(i){return i.type==="band"}s(it,"isBandAxisData");function Z(i){return i.type==="linear"}s(Z,"isLinearAxisData");var H=class{constructor(t){this.parentGroup=t}static{s(this,"TextDimensionCalculatorWithFont")}getMaxDimension(t,e){if(!this.parentGroup)return{width:t.reduce((r,h)=>Math.max(h.length,r),0)*e,height:e};let a={width:0,height:0},n=this.parentGroup.append("g").attr("visibility","hidden").attr("font-size",e);for(let r of t){let h=qt(n,1,r),b=h?h.width:r.length*e,x=h?h.height:e;a.width=Math.max(a.width,b),a.height=Math.max(a.height,x)}return n.remove(),a}};var J=class{constructor(t,e,a,n){this.axisConfig=t;this.title=e;this.textDimensionCalculator=a;this.axisThemeConfig=n;this.boundingRect={x:0,y:0,width:0,height:0};this.axisPosition="left";this.showTitle=!1;this.showLabel=!1;this.showTick=!1;this.showAxisLine=!1;this.outerPadding=0;this.titleTextHeight=0;this.labelTextHeight=0;this.normalizedLabelRotationInRad=0;this.range=[0,10],this.boundingRect={x:0,y:0,width:0,height:0},this.axisPosition="left",this.normalizedLabelRotationInRad=this.axisConfig.labelRotation>=-90&&this.axisConfig.labelRotation<=90?this.axisConfig.labelRotation*Math.PI/180:0}static{s(this,"BaseAxis")}setRange(t){this.range=t,this.axisPosition==="left"||this.axisPosition==="right"?this.boundingRect.height=t[1]-t[0]:this.boundingRect.width=t[1]-t[0],this.recalculateScale()}getRange(){return[this.range[0]+this.outerPadding,this.range[1]-this.outerPadding]}setAxisPosition(t){this.axisPosition=t,this.setRange(this.range)}getTickDistance(){let t=this.getRange();return Math.abs(t[0]-t[1])/this.getTickValues().length}getAxisOuterPadding(){return this.outerPadding}getLabelDimension(){return this.textDimensionCalculator.getMaxDimension(this.getTickValues().map(t=>t.toString()),this.axisConfig.labelFontSize)}recalculateOuterPaddingToDrawBar(){.7*this.getTickDistance()>this.outerPadding*2&&(this.outerPadding=Math.floor(.7*this.getTickDistance()/2)),this.recalculateScale()}calculateSpaceIfDrawnHorizontally(t){let e=t.height;if(this.axisConfig.showAxisLine&&e>this.axisConfig.axisLineWidth&&(e-=this.axisConfig.axisLineWidth,this.showAxisLine=!0),this.axisConfig.showLabel){let a=this.getLabelDimension(),n=.2*t.width;this.outerPadding=Math.min(a.width/2,n);let r=a.height;this.axisPosition==="bottom"&&this.normalizedLabelRotationInRad!==0&&(r=Math.max(r,Math.abs(Math.sin(this.normalizedLabelRotationInRad)*a.width)+Math.abs(Math.cos(this.normalizedLabelRotationInRad)*a.height))),r+=this.axisConfig.labelPadding*2,this.labelTextHeight=a.height,r<=e&&(e-=r,this.showLabel=!0)}if(this.axisConfig.showTick&&e>=this.axisConfig.tickLength&&(this.showTick=!0,e-=this.axisConfig.tickLength),this.axisConfig.showTitle&&this.title){let a=this.textDimensionCalculator.getMaxDimension([this.title],this.axisConfig.titleFontSize),n=a.height+this.axisConfig.titlePadding*2;this.titleTextHeight=a.height,n<=e&&(e-=n,this.showTitle=!0)}this.boundingRect.width=t.width,this.boundingRect.height=t.height-e}calculateSpaceIfDrawnVertical(t){let e=t.width;if(this.axisConfig.showAxisLine&&e>this.axisConfig.axisLineWidth&&(e-=this.axisConfig.axisLineWidth,this.showAxisLine=!0),this.axisConfig.showLabel){let a=this.getLabelDimension(),n=.2*t.height;this.outerPadding=Math.min(a.height/2,n);let r=a.width+this.axisConfig.labelPadding*2;r<=e&&(e-=r,this.showLabel=!0)}if(this.axisConfig.showTick&&e>=this.axisConfig.tickLength&&(this.showTick=!0,e-=this.axisConfig.tickLength),this.axisConfig.showTitle&&this.title){let a=this.textDimensionCalculator.getMaxDimension([this.title],this.axisConfig.titleFontSize),n=a.height+this.axisConfig.titlePadding*2;this.titleTextHeight=a.height,n<=e&&(e-=n,this.showTitle=!0)}this.boundingRect.width=t.width-e,this.boundingRect.height=t.height}calculateSpace(t){return this.axisPosition==="left"||this.axisPosition==="right"?this.calculateSpaceIfDrawnVertical(t):this.calculateSpaceIfDrawnHorizontally(t),this.recalculateScale(),{width:this.boundingRect.width,height:this.boundingRect.height}}setBoundingBoxXY(t){this.boundingRect.x=t.x,this.boundingRect.y=t.y}calculateOffsetByRotation(t){let e=this.normalizedLabelRotationInRad;return e===0?0:Math.sin(e)*this.getLabelDimension()[t]/2}getDrawableElementsForLeftAxis(){let t=[];if(this.showAxisLine){let e=this.boundingRect.x+this.boundingRect.width-this.axisConfig.axisLineWidth/2;t.push({type:"path",groupTexts:["left-axis","axisl-line"],data:[{path:`M ${e},${this.boundingRect.y} L ${e},${this.boundingRect.y+this.boundingRect.height} `,strokeFill:this.axisThemeConfig.axisLineColor,strokeWidth:this.axisConfig.axisLineWidth}]})}if(this.showLabel&&t.push({type:"text",groupTexts:["left-axis","label"],data:this.getTickValues().map(e=>({text:e.toString(),x:this.boundingRect.x+this.boundingRect.width-(this.showLabel?this.axisConfig.labelPadding:0)-(this.showTick?this.axisConfig.tickLength:0)-(this.showAxisLine?this.axisConfig.axisLineWidth:0),y:this.getScaleValue(e),fill:this.axisThemeConfig.labelColor,fontSize:this.axisConfig.labelFontSize,rotation:0,verticalPos:"middle",horizontalPos:"right"}))}),this.showTick){let e=this.boundingRect.x+this.boundingRect.width-(this.showAxisLine?this.axisConfig.axisLineWidth:0);t.push({type:"path",groupTexts:["left-axis","ticks"],data:this.getTickValues().map(a=>({path:`M ${e},${this.getScaleValue(a)} L ${e-this.axisConfig.tickLength},${this.getScaleValue(a)}`,strokeFill:this.axisThemeConfig.tickColor,strokeWidth:this.axisConfig.tickWidth}))})}return this.showTitle&&t.push({type:"text",groupTexts:["left-axis","title"],data:[{text:this.title,x:this.boundingRect.x+this.axisConfig.titlePadding,y:this.boundingRect.y+this.boundingRect.height/2,fill:this.axisThemeConfig.titleColor,fontSize:this.axisConfig.titleFontSize,rotation:270,verticalPos:"top",horizontalPos:"center"}]}),t}getDrawableElementsForBottomAxis(){let t=[];if(this.showAxisLine){let e=this.boundingRect.y+this.axisConfig.axisLineWidth/2;t.push({type:"path",groupTexts:["bottom-axis","axis-line"],data:[{path:`M ${this.boundingRect.x},${e} L ${this.boundingRect.x+this.boundingRect.width},${e}`,strokeFill:this.axisThemeConfig.axisLineColor,strokeWidth:this.axisConfig.axisLineWidth}]})}if(this.showLabel&&t.push({type:"text",groupTexts:["bottom-axis","label"],data:this.getTickValues().map(e=>({text:e.toString(),x:this.getScaleValue(e)+this.calculateOffsetByRotation("height"),y:this.boundingRect.y+this.axisConfig.labelPadding+(this.showTick?this.axisConfig.tickLength:0)+(this.showAxisLine?this.axisConfig.axisLineWidth:0)+Math.abs(this.calculateOffsetByRotation("width")),fill:this.axisThemeConfig.labelColor,fontSize:this.axisConfig.labelFontSize,rotation:this.normalizedLabelRotationInRad*180/Math.PI,verticalPos:"top",horizontalPos:"center"}))}),this.showTick){let e=this.boundingRect.y+(this.showAxisLine?this.axisConfig.axisLineWidth:0);t.push({type:"path",groupTexts:["bottom-axis","ticks"],data:this.getTickValues().map(a=>({path:`M ${this.getScaleValue(a)},${e} L ${this.getScaleValue(a)},${e+this.axisConfig.tickLength}`,strokeFill:this.axisThemeConfig.tickColor,strokeWidth:this.axisConfig.tickWidth}))})}return this.showTitle&&t.push({type:"text",groupTexts:["bottom-axis","title"],data:[{text:this.title,x:this.range[0]+(this.range[1]-this.range[0])/2,y:this.boundingRect.y+this.boundingRect.height-this.axisConfig.titlePadding-this.titleTextHeight,fill:this.axisThemeConfig.titleColor,fontSize:this.axisConfig.titleFontSize,rotation:0,verticalPos:"top",horizontalPos:"center"}]}),t}getDrawableElementsForTopAxis(){let t=[];if(this.showAxisLine){let e=this.boundingRect.y+this.boundingRect.height-this.axisConfig.axisLineWidth/2;t.push({type:"path",groupTexts:["top-axis","axis-line"],data:[{path:`M ${this.boundingRect.x},${e} L ${this.boundingRect.x+this.boundingRect.width},${e}`,strokeFill:this.axisThemeConfig.axisLineColor,strokeWidth:this.axisConfig.axisLineWidth}]})}if(this.showLabel&&t.push({type:"text",groupTexts:["top-axis","label"],data:this.getTickValues().map(e=>({text:e.toString(),x:this.getScaleValue(e),y:this.boundingRect.y+(this.showTitle?this.titleTextHeight+this.axisConfig.titlePadding*2:0)+this.axisConfig.labelPadding,fill:this.axisThemeConfig.labelColor,fontSize:this.axisConfig.labelFontSize,rotation:0,verticalPos:"top",horizontalPos:"center"}))}),this.showTick){let e=this.boundingRect.y;t.push({type:"path",groupTexts:["top-axis","ticks"],data:this.getTickValues().map(a=>({path:`M ${this.getScaleValue(a)},${e+this.boundingRect.height-(this.showAxisLine?this.axisConfig.axisLineWidth:0)} L ${this.getScaleValue(a)},${e+this.boundingRect.height-this.axisConfig.tickLength-(this.showAxisLine?this.axisConfig.axisLineWidth:0)}`,strokeFill:this.axisThemeConfig.tickColor,strokeWidth:this.axisConfig.tickWidth}))})}return this.showTitle&&t.push({type:"text",groupTexts:["top-axis","title"],data:[{text:this.title,x:this.boundingRect.x+this.boundingRect.width/2,y:this.boundingRect.y+this.axisConfig.titlePadding,fill:this.axisThemeConfig.titleColor,fontSize:this.axisConfig.titleFontSize,rotation:0,verticalPos:"top",horizontalPos:"center"}]}),t}getDrawableElements(){if(this.axisPosition==="left")return this.getDrawableElementsForLeftAxis();if(this.axisPosition==="right")throw Error("Drawing of right axis is not implemented");return this.axisPosition==="bottom"?this.getDrawableElementsForBottomAxis():this.axisPosition==="top"?this.getDrawableElementsForTopAxis():[]}};var gt=class extends J{static{s(this,"BandAxis")}constructor(t,e,a,n,r){super(t,n,r,e),this.categories=a,this.scale=wt().domain(this.categories).range(this.getRange())}setRange(t){super.setRange(t)}recalculateScale(){this.scale=wt().domain(this.categories).range(this.getRange()).paddingInner(1).paddingOuter(0).align(.5),ht.trace("BandAxis axis final categories, range: ",this.categories,this.getRange())}getTickValues(){return this.categories}getScaleValue(t){return this.scale(t)??this.getRange()[0]}};var pt=class extends J{static{s(this,"LinearAxis")}constructor(t,e,a,n,r){super(t,n,r,e),this.domain=a,this.scale=St().domain(this.domain).range(this.getRange())}getTickValues(){return this.scale.ticks()}recalculateScale(){let t=[...this.domain];this.axisPosition==="left"&&t.reverse(),this.scale=St().domain(t).range(this.getRange())}getScaleValue(t){return this.scale(t)}};function Pt(i,t,e,a){let n=new H(a);return it(i)?new gt(t,e,i.categories,i.title,n):new pt(t,e,[i.min,i.max],i.title,n)}s(Pt,"getAxis");var vt=class{constructor(t,e,a,n){this.textDimensionCalculator=t;this.chartConfig=e;this.chartData=a;this.chartThemeConfig=n;this.boundingRect={x:0,y:0,width:0,height:0},this.showChartTitle=!1}static{s(this,"ChartTitle")}setBoundingBoxXY(t){this.boundingRect.x=t.x,this.boundingRect.y=t.y}calculateSpace(t){let e=this.textDimensionCalculator.getMaxDimension([this.chartData.title],this.chartConfig.titleFontSize),a=Math.max(e.width,t.width),n=e.height+2*this.chartConfig.titlePadding;return e.width<=a&&e.height<=n&&this.chartConfig.showTitle&&this.chartData.title&&(this.boundingRect.width=a,this.boundingRect.height=n,this.showChartTitle=!0),{width:this.boundingRect.width,height:this.boundingRect.height}}getDrawableElements(){let t=[];return this.showChartTitle&&t.push({groupTexts:["chart-title"],type:"text",data:[{fontSize:this.chartConfig.titleFontSize,text:this.chartData.title,verticalPos:"middle",horizontalPos:"center",x:this.boundingRect.x+this.boundingRect.width/2,y:this.boundingRect.y+this.boundingRect.height/2,fill:this.chartThemeConfig.titleColor,rotation:0}]}),t}};function Zt(i,t,e,a){let n=new H(a);return new vt(n,i,t,e)}s(Zt,"getChartTitleComponent");var me=.75,de=.5,fe=.35;function Jt(i){return{fontSize:i,markerSize:i*me,markerSpacing:i*fe,itemSpacing:i*de}}s(Jt,"getLegendLayout");var Et=class{constructor(t,e,a,n){this.textDimensionCalculator=t;this.chartConfig=e;this.chartData=a;this.chartThemeConfig=n;this.boundingRect={x:0,y:0,width:0,height:0};this.visiblePlots=[]}static{s(this,"ChartLegend")}setBoundingBoxXY(t){this.boundingRect.x=t.x,this.boundingRect.y=t.y}calculateSpace(t){if(this.visiblePlots=this.chartConfig.showLegend?this.chartData.plots.filter(d=>d.title):[],this.visiblePlots.length===0)return this.boundingRect.width=0,this.boundingRect.height=0,{width:0,height:0};let{fontSize:e,markerSize:a,markerSpacing:n,itemSpacing:r}=Jt(this.chartConfig.legendFontSize),h=this.textDimensionCalculator.getMaxDimension(this.visiblePlots.map(d=>d.title),e),b=this.chartConfig.legendPadding*2+a+n+h.width,x=this.chartConfig.legendPadding*2+this.visiblePlots.length*e+(this.visiblePlots.length-1)*r;return b<=t.width&&x<=t.height?(this.boundingRect.width=b,this.boundingRect.height=x):(this.visiblePlots=[],this.boundingRect.width=0,this.boundingRect.height=0),{width:this.boundingRect.width,height:this.boundingRect.height}}getDrawableElements(){if(this.visiblePlots.length===0)return[];let{fontSize:t,markerSize:e,markerSpacing:a,itemSpacing:n}=Jt(this.chartConfig.legendFontSize),r=t+n,h=this.boundingRect.x+this.chartConfig.legendPadding,b=this.boundingRect.y+this.chartConfig.legendPadding,x=[],d=[];for(let[S,k]of this.visiblePlots.entries())if(et(k))x.push({x:h,y:b+S*r,width:e,height:e,fill:k.fill,strokeFill:k.fill,strokeWidth:0});else{let P=b+S*r+e/2;d.push({path:`M ${h},${P} L ${h+e},${P}`,strokeFill:k.strokeFill,strokeWidth:k.strokeWidth})}return[{groupTexts:["legend","markers"],type:"rect",data:x},{groupTexts:["legend","markers"],type:"path",data:d},{groupTexts:["legend","label"],type:"text",data:this.visiblePlots.map((S,k)=>({text:S.title,x:h+e+a,y:b+k*r+e/2,fill:this.chartThemeConfig.legendTextColor,fontSize:t,rotation:0,verticalPos:"middle",horizontalPos:"left"}))}]}};function te(i,t,e,a){let n=new H(a);return new Et(n,i,t,e)}s(te,"getChartLegendComponent");var ut=class{constructor(t,e,a,n,r){this.plotData=t;this.xAxis=e;this.yAxis=a;this.orientation=n;this.plotIndex=r}static{s(this,"LinePlot")}getDrawableElement(){let t=this.plotData.data.map(n=>[this.xAxis.getScaleValue(n[0]),this.yAxis.getScaleValue(n[1])]),e;if(this.orientation==="horizontal"?e=kt().y(n=>n[0]).x(n=>n[1])(t):e=kt().x(n=>n[0]).y(n=>n[1])(t),!e)return[];let a=[{groupTexts:["plot",`line-plot-${this.plotIndex}`],type:"path",data:[{path:e,strokeFill:this.plotData.strokeFill,strokeWidth:this.plotData.strokeWidth}]}];if(this.plotData.pointLabels&&this.plotData.pointLabels.length>0){let h=[];for(let[b,[x,d]]of t.entries()){let S=this.plotData.pointLabels[b];S&&(this.orientation==="horizontal"?h.push({x:d+10,y:x,text:S,fill:this.plotData.strokeFill,verticalPos:"middle",horizontalPos:"left",fontSize:12,rotation:0}):h.push({x,y:d-10,text:S,fill:this.plotData.strokeFill,verticalPos:"middle",horizontalPos:"center",fontSize:12,rotation:0}))}h.length>0&&a.push({groupTexts:["plot",`line-plot-${this.plotIndex}`,"labels"],type:"text",data:h})}return a}};var xt=class{constructor(t,e,a,n,r,h){this.barData=t;this.boundingRect=e;this.xAxis=a;this.yAxis=n;this.orientation=r;this.plotIndex=h}static{s(this,"BarPlot")}getDrawableElement(){let t=this.barData.data.map(r=>[this.xAxis.getScaleValue(r[0]),this.yAxis.getScaleValue(r[1])]),a=Math.min(this.xAxis.getAxisOuterPadding()*2,this.xAxis.getTickDistance())*(1-.05),n=a/2;return this.orientation==="horizontal"?[{groupTexts:["plot",`bar-plot-${this.plotIndex}`],type:"rect",data:t.map(r=>({x:this.boundingRect.x,y:r[0]-n,height:a,width:r[1]-this.boundingRect.x,fill:this.barData.fill,strokeWidth:0,strokeFill:this.barData.fill}))}]:[{groupTexts:["plot",`bar-plot-${this.plotIndex}`],type:"rect",data:t.map(r=>({x:r[0]-n,y:r[1],width:a,height:this.boundingRect.y+this.boundingRect.height-r[1],fill:this.barData.fill,strokeWidth:0,strokeFill:this.barData.fill}))}]}};var Lt=class{constructor(t,e,a){this.chartConfig=t;this.chartData=e;this.chartThemeConfig=a;this.boundingRect={x:0,y:0,width:0,height:0}}static{s(this,"BasePlot")}setAxes(t,e){this.xAxis=t,this.yAxis=e}setBoundingBoxXY(t){this.boundingRect.x=t.x,this.boundingRect.y=t.y}calculateSpace(t){return this.boundingRect.width=t.width,this.boundingRect.height=t.height,{width:this.boundingRect.width,height:this.boundingRect.height}}getDrawableElements(){if(!(this.xAxis&&this.yAxis))throw Error("Axes must be passed to render Plots");let t=[];for(let[e,a]of this.chartData.plots.entries())switch(a.type){case"line":{let n=new ut(a,this.xAxis,this.yAxis,this.chartConfig.chartOrientation,e);t.push(...n.getDrawableElement())}break;case"bar":{let n=new xt(a,this.boundingRect,this.xAxis,this.yAxis,this.chartConfig.chartOrientation,e);t.push(...n.getDrawableElement())}break}return t}};function ee(i,t,e){return new Lt(i,t,e)}s(ee,"getPlotComponent");var mt=class{constructor(t,e,a,n){this.chartConfig=t;this.chartData=e;this.componentStore={title:Zt(t,e,a,n),plot:ee(t,e,a),legend:te(t,e,a,n),xAxis:Pt(e.xAxis,t.xAxis,{titleColor:a.xAxisTitleColor,labelColor:a.xAxisLabelColor,tickColor:a.xAxisTickColor,axisLineColor:a.xAxisLineColor},n),yAxis:Pt(e.yAxis,t.yAxis,{titleColor:a.yAxisTitleColor,labelColor:a.yAxisLabelColor,tickColor:a.yAxisTickColor,axisLineColor:a.yAxisLineColor},n)}}static{s(this,"Orchestrator")}calculateVerticalSpace(){let t=this.chartConfig.width,e=this.chartConfig.height,a=0,n=0,r={width:0,height:0},h=Math.floor(t*this.chartConfig.plotReservedSpacePercent/100),b=Math.floor(e*this.chartConfig.plotReservedSpacePercent/100),x=this.componentStore.plot.calculateSpace({width:h,height:b});t-=x.width,e-=x.height,x=this.componentStore.title.calculateSpace({width:this.chartConfig.width,height:e}),n=x.height,e-=x.height,this.componentStore.xAxis.setAxisPosition("bottom"),x=this.componentStore.xAxis.calculateSpace({width:t,height:e}),e-=x.height,this.componentStore.yAxis.setAxisPosition("left"),x=this.componentStore.yAxis.calculateSpace({width:t,height:e}),a=x.width,t-=x.width,r=this.componentStore.legend.calculateSpace({width:t,height:b}),t-=r.width,t>0&&(h+=t,t=0),e>0&&(b+=e,e=0),this.componentStore.plot.calculateSpace({width:h,height:b}),this.componentStore.plot.setBoundingBoxXY({x:a,y:n}),this.componentStore.legend.setBoundingBoxXY({x:a+h,y:n+Math.max((b-r.height)/2,0)}),this.componentStore.xAxis.setRange([a,a+h]),this.componentStore.xAxis.setBoundingBoxXY({x:a,y:n+b}),this.componentStore.yAxis.setRange([n,n+b]),this.componentStore.yAxis.setBoundingBoxXY({x:0,y:n}),this.chartData.plots.some(d=>et(d))&&this.componentStore.xAxis.recalculateOuterPaddingToDrawBar()}calculateHorizontalSpace(){let t=this.chartConfig.width,e=this.chartConfig.height,a=0,n=0,r=0,h={width:0,height:0},b=Math.floor(t*this.chartConfig.plotReservedSpacePercent/100),x=Math.floor(e*this.chartConfig.plotReservedSpacePercent/100),d=this.componentStore.plot.calculateSpace({width:b,height:x});t-=d.width,e-=d.height,d=this.componentStore.title.calculateSpace({width:this.chartConfig.width,height:e}),a=d.height,e-=d.height,this.componentStore.xAxis.setAxisPosition("left"),d=this.componentStore.xAxis.calculateSpace({width:t,height:e}),t-=d.width,n=d.width,this.componentStore.yAxis.setAxisPosition("top"),d=this.componentStore.yAxis.calculateSpace({width:t,height:e}),e-=d.height,r=a+d.height,h=this.componentStore.legend.calculateSpace({width:t,height:x}),t-=h.width,t>0&&(b+=t,t=0),e>0&&(x+=e,e=0),this.componentStore.plot.calculateSpace({width:b,height:x}),this.componentStore.plot.setBoundingBoxXY({x:n,y:r}),this.componentStore.legend.setBoundingBoxXY({x:n+b,y:r+Math.max((x-h.height)/2,0)}),this.componentStore.yAxis.setRange([n,n+b]),this.componentStore.yAxis.setBoundingBoxXY({x:n,y:a}),this.componentStore.xAxis.setRange([r,r+x]),this.componentStore.xAxis.setBoundingBoxXY({x:0,y:r}),this.chartData.plots.some(S=>et(S))&&this.componentStore.xAxis.recalculateOuterPaddingToDrawBar()}calculateSpace(){this.chartConfig.chartOrientation==="horizontal"?this.calculateHorizontalSpace():this.calculateVerticalSpace()}getDrawableElement(){this.calculateSpace();let t=[];this.componentStore.plot.setAxes(this.componentStore.xAxis,this.componentStore.yAxis);for(let e of Object.values(this.componentStore))t.push(...e.getDrawableElements());return t}};var dt=class{static{s(this,"XYChartBuilder")}static build(t,e,a,n){return new mt(t,e,a,n).getDrawableElement()}};var at=0,ie,nt=ne(),st=ae(),f=se(),Xt=st.plotColorPalette.split(",").map(i=>i.trim()),ft=!1,Yt=!1;function ae(){let i=zt(),t=ct();return Rt(i.xyChart,t.themeVariables.xyChart)}s(ae,"getChartDefaultThemeConfig");function ne(){let i=ct();return Rt(Ot.xyChart,i.xyChart)}s(ne,"getChartDefaultConfig");function se(){return{yAxis:{type:"linear",title:"",min:1/0,max:-1/0},xAxis:{type:"band",title:"",categories:[]},title:"",plots:[]}}s(se,"getChartDefaultData");function tt(i){let t=ct();return Wt(i.trim(),t)}s(tt,"textSanitizer");function be(i){ie=i}s(be,"setTmpSVGG");function ye(i){i==="horizontal"?nt.chartOrientation="horizontal":nt.chartOrientation="vertical"}s(ye,"setOrientation");function Ce(i){f.xAxis.title=tt(i.text)}s(Ce,"setXAxisTitle");function oe(i,t){f.xAxis={type:"linear",title:f.xAxis.title,min:i,max:t},ft=!0}s(oe,"setXAxisRangeData");function Ae(i){f.xAxis={type:"band",title:f.xAxis.title,categories:i.map(t=>tt(t.text))},ft=!0}s(Ae,"setXAxisBand");function De(i){f.yAxis.title=tt(i.text)}s(De,"setYAxisTitle");function Te(i,t){f.yAxis={type:"linear",title:f.yAxis.title,min:i,max:t},Yt=!0}s(Te,"setYAxisRangeData");function we(i){let t=Math.min(...i),e=Math.max(...i),a=Z(f.yAxis)?f.yAxis.min:1/0,n=Z(f.yAxis)?f.yAxis.max:-1/0;f.yAxis={type:"linear",title:f.yAxis.title,min:Math.min(a,t),max:Math.max(n,e)}}s(we,"setYAxisRangeFromPlotData");function re(i){let t=[];if(i.length===0)return t;if(!ft){let e=Z(f.xAxis)?f.xAxis.min:1/0,a=Z(f.xAxis)?f.xAxis.max:-1/0;oe(Math.min(e,1),Math.max(a,i.length))}if(it(f.xAxis)&&i.length>f.xAxis.categories.length&&(i=i.slice(0,f.xAxis.categories.length)),Yt||we(i),it(f.xAxis)&&(t=f.xAxis.categories.map((e,a)=>[e,i[a]])),Z(f.xAxis)){let e=f.xAxis.min,a=f.xAxis.max;if(i.length===1)t=[[`${e}`,i[0]]];else{let n=(a-e)/(i.length-1);t=i.map((r,h)=>[`${e+h*n}`,r])}}return t}s(re,"transformDataWithoutCategory");function le(i){return Xt[i===0?0:i%Xt.length]}s(le,"getPlotColorFromPalette");function Se(i,t){let e=t.map(h=>h.value),a=t.map(h=>h.label?tt(h.label):""),n=re(e),r=a.some(h=>h!=="");f.plots.push({type:"line",title:tt(i.text),strokeFill:le(at),strokeWidth:2,data:n,...r?{pointLabels:a}:{}}),at++}s(Se,"setLineData");function ke(i,t){let e=t.map(n=>n.value),a=re(e);f.plots.push({type:"bar",title:tt(i.text),fill:le(at),data:a}),at++}s(ke,"setBarData");function Re(){if(f.plots.length===0)throw Error("No Plot to render, please provide a plot with some data");return f.title=Tt(),dt.build(nt,f,st,ie)}s(Re,"getDrawableElem");function _e(){return st}s(_e,"getChartThemeConfig");function Pe(){return nt}s(Pe,"getChartConfig");function ve(){return f}s(ve,"getXYChartData");var Ee=s(function(){Nt(),at=0,nt=ne(),f=se(),st=ae(),Xt=st.plotColorPalette.split(",").map(i=>i.trim()),ft=!1,Yt=!1},"clear"),he={getDrawableElem:Re,clear:Ee,setAccTitle:jt,getAccTitle:Gt,setDiagramTitle:Ut,getDiagramTitle:Tt,getAccDescription:$t,setAccDescription:Ht,setOrientation:ye,setXAxisTitle:Ce,setXAxisRangeData:oe,setXAxisBand:Ae,setYAxisTitle:De,setYAxisRangeData:Te,setLineData:Se,setBarData:ke,setTmpSVGG:be,getChartThemeConfig:_e,getChartConfig:Pe,getXYChartData:ve};var Le=s((i,t,e,a)=>{let n=a.db,r=n.getChartThemeConfig(),h=n.getChartConfig(),b=n.getXYChartData().plots[0].data.map(y=>y[1]);function x(y){return y==="top"?"text-before-edge":"middle"}s(x,"getDominantBaseLine");function d(y){return y==="left"?"start":y==="right"?"end":"middle"}s(d,"getTextAnchor");function S(y){return`translate(${y.x}, ${y.y}) rotate(${y.rotation||0})`}s(S,"getTextTransformation"),ht.debug(`Rendering xychart chart `+i);let k=Kt(t),P=k.append("g").attr("class","main"),V=P.append("rect").attr("width",h.width).attr("height",h.height).attr("class","background");Ft(k,h.height,h.width,!0),k.attr("viewBox",`0 0 ${h.width} ${h.height}`),V.attr("fill",r.backgroundColor),n.setTmpSVGG(k.append("g").attr("class","mermaid-tmp-group"));let z=n.getDrawableElem(),E={};function O(y){let L=P,g="";for(let[j]of y.entries()){let B=P;j>0&&E[g]&&(B=E[g]),g+=y[j],L=E[g],L||(L=E[g]=B.append("g").attr("class",y[j]))}return L}s(O,"getGroup");for(let y of z){if(y.data.length===0)continue;let L=O(y.groupTexts);switch(y.type){case"rect":if(L.selectAll("rect").data(y.data).enter().append("rect").attr("x",g=>g.x).attr("y",g=>g.y).attr("width",g=>g.width).attr("height",g=>g.height).attr("fill",g=>g.fill).attr("stroke",g=>g.strokeFill).attr("stroke-width",g=>g.strokeWidth),h.showDataLabel){let g=h.showDataLabelOutsideBar;if(h.chartOrientation==="horizontal"){let G=function(C,M){let{data:T,label:Y}=C;return M*Y.length*.7<=T.width-10};var W=G;s(G,"fitsHorizontally");let j=.7,B=10,A=y.data.map((C,M)=>({data:C,label:b[M].toString()})).filter(C=>C.data.width>0&&C.data.height>0),_=A.map(C=>{let{data:M}=C,T=M.height*.7;for(;!G(C,T)&&T>0;)T-=1;return T}),K=Math.floor(Math.min(..._)),w=s(C=>g?C.data.x+C.data.width+10:C.data.x+C.data.width-10,"determineLabelXPosition");L.selectAll("text").data(A).enter().append("text").attr("x",w).attr("y",C=>C.data.y+C.data.height/2).attr("text-anchor",g?"start":"end").attr("dominant-baseline","middle").attr("fill",r.dataLabelColor).attr("font-size",`${K}px`).text(C=>C.label)}else{let A=function(w,C,M){let{data:T,label:Y}=w,c=C*Y.length*.7,p=T.x+T.width/2,u=p-c/2,D=p+c/2,o=u>=T.x&&D<=T.x+T.width,$=T.y+M+C<=T.y+T.height;return o&&$};var F=A;s(A,"fitsInBar");let j=10,B=y.data.map((w,C)=>({data:w,label:b[C].toString()})).filter(w=>w.data.width>0&&w.data.height>0),G=B.map(w=>{let{data:C,label:M}=w,T=C.width/(M.length*.7);for(;!A(w,T,10)&&T>0;)T-=1;return T}),_=Math.floor(Math.min(...G)),K=s(w=>g?w.data.y-10:w.data.y+10,"determineLabelYPosition");L.selectAll("text").data(B).enter().append("text").attr("x",w=>w.data.x+w.data.width/2).attr("y",K).attr("text-anchor","middle").attr("dominant-baseline",g?"auto":"hanging").attr("fill",r.dataLabelColor).attr("font-size",`${_}px`).text(w=>w.label)}}break;case"text":L.selectAll("text").data(y.data).enter().append("text").attr("x",0).attr("y",0).attr("fill",g=>g.fill).attr("font-size",g=>g.fontSize).attr("dominant-baseline",g=>x(g.verticalPos)).attr("text-anchor",g=>d(g.horizontalPos)).attr("transform",g=>S(g)).text(g=>g.text);break;case"path":L.selectAll("path").data(y.data).enter().append("path").attr("d",g=>g.path).attr("fill",g=>g.fill?g.fill:"none").attr("stroke",g=>g.strokeFill).attr("stroke-width",g=>g.strokeWidth);break}}},"draw"),ce={draw:Le};var qi={parser:Qt,db:he,renderer:ce};export{qi as diagram};