mermaid
Version:
Markdown-ish syntax for generating flowcharts, mindmaps, sequence diagrams, class diagrams, gantt charts, git graphs and more.
141 lines (124 loc) • 41.3 kB
JavaScript
import{a as Oe}from"./chunk-BOZ75642.mjs";import{a as Ne}from"./chunk-MFYRHTYG.mjs";import{C as Te}from"./chunk-D36F7FYG.mjs";import{g as we,h as _e,i as Be,j as Ce}from"./chunk-OCMJQKYE.mjs";import{b as se,e as Ie}from"./chunk-MNT3HHAC.mjs";import"./chunk-TECWHJ6D.mjs";import"./chunk-F6PIGZHG.mjs";import"./chunk-JGXDHUYS.mjs";import"./chunk-TINYC7RT.mjs";import"./chunk-TDFULVG6.mjs";import{b as Se,c as Le,d as ye,f as Ee,g as De}from"./chunk-MIE3LDYP.mjs";import{a as xe,f as ke}from"./chunk-QADHU5CF.mjs";import"./chunk-ZZ52EIBP.mjs";import{$ as X,H as fe,P as be,T as me,b as de,c as pe,u as A}from"./chunk-FE53TMRB.mjs";import{b as L,h as W}from"./chunk-L2B47AAZ.mjs";import{a as c}from"./chunk-QVIEFLGF.mjs";var ie=(function(){var e=c(function(N,u,s,o){for(s=s||{},o=N.length;o--;s[N[o]]=u);return s},"o"),a=[1,15],l=[1,7],n=[1,13],g=[1,14],p=[1,19],t=[1,16],h=[1,17],x=[1,18],k=[8,30],b=[8,10,21,28,29,30,31,39,43,46],f=[1,23],S=[1,24],E=[8,10,15,16,21,28,29,30,31,39,43,46],m=[8,10,15,16,21,27,28,29,30,31,39,43,46],w=[1,49],D={trace:c(function(){},"trace"),yy:{},symbols_:{error:2,spaceLines:3,SPACELINE:4,NL:5,separator:6,SPACE:7,EOF:8,start:9,BLOCK_DIAGRAM_KEY:10,document:11,stop:12,statement:13,link:14,LINK:15,START_LINK:16,LINK_LABEL:17,STR:18,nodeStatement:19,columnsStatement:20,SPACE_BLOCK:21,blockStatement:22,classDefStatement:23,cssClassStatement:24,styleStatement:25,node:26,SIZE:27,COLUMNS:28,"id-block":29,end:30,NODE_ID:31,nodeShapeNLabel:32,dirList:33,DIR:34,NODE_DSTART:35,NODE_DEND:36,BLOCK_ARROW_START:37,BLOCK_ARROW_END:38,classDef:39,CLASSDEF_ID:40,CLASSDEF_STYLEOPTS:41,DEFAULT:42,class:43,CLASSENTITY_IDS:44,STYLECLASS:45,style:46,STYLE_ENTITY_IDS:47,STYLE_DEFINITION_DATA:48,$accept:0,$end:1},terminals_:{2:"error",4:"SPACELINE",5:"NL",7:"SPACE",8:"EOF",10:"BLOCK_DIAGRAM_KEY",15:"LINK",16:"START_LINK",17:"LINK_LABEL",18:"STR",21:"SPACE_BLOCK",27:"SIZE",28:"COLUMNS",29:"id-block",30:"end",31:"NODE_ID",34:"DIR",35:"NODE_DSTART",36:"NODE_DEND",37:"BLOCK_ARROW_START",38:"BLOCK_ARROW_END",39:"classDef",40:"CLASSDEF_ID",41:"CLASSDEF_STYLEOPTS",42:"DEFAULT",43:"class",44:"CLASSENTITY_IDS",45:"STYLECLASS",46:"style",47:"STYLE_ENTITY_IDS",48:"STYLE_DEFINITION_DATA"},productions_:[0,[3,1],[3,2],[3,2],[6,1],[6,1],[6,1],[9,3],[12,1],[12,1],[12,2],[12,2],[11,1],[11,2],[14,1],[14,4],[13,1],[13,1],[13,1],[13,1],[13,1],[13,1],[13,1],[19,3],[19,2],[19,1],[20,1],[22,4],[22,3],[26,1],[26,2],[33,1],[33,2],[32,3],[32,4],[23,3],[23,3],[24,3],[25,3]],performAction:c(function(u,s,o,d,y,r,K){var i=r.length-1;switch(y){case 4:d.getLogger().debug("Rule: separator (NL) ");break;case 5:d.getLogger().debug("Rule: separator (Space) ");break;case 6:d.getLogger().debug("Rule: separator (EOF) ");break;case 7:d.getLogger().debug("Rule: hierarchy: ",r[i-1]),d.setHierarchy(r[i-1]);break;case 8:d.getLogger().debug("Stop NL ");break;case 9:d.getLogger().debug("Stop EOF ");break;case 10:d.getLogger().debug("Stop NL2 ");break;case 11:d.getLogger().debug("Stop EOF2 ");break;case 12:d.getLogger().debug("Rule: statement: ",r[i]),typeof r[i].length=="number"?this.$=r[i]:this.$=[r[i]];break;case 13:d.getLogger().debug("Rule: statement #2: ",r[i-1]),this.$=[r[i-1]].concat(r[i]);break;case 14:d.getLogger().debug("Rule: link: ",r[i],u),this.$={edgeTypeStr:r[i],label:""};break;case 15:d.getLogger().debug("Rule: LABEL link: ",r[i-3],r[i-1],r[i]),this.$={edgeTypeStr:r[i],label:r[i-1]};break;case 18:let F=parseInt(r[i]),V=d.generateId();this.$={id:V,type:"space",label:"",width:F,children:[]};break;case 23:d.getLogger().debug("Rule: (nodeStatement link node) ",r[i-2],r[i-1],r[i]," typestr: ",r[i-1].edgeTypeStr);let j=d.edgeStrToEdgeData(r[i-1].edgeTypeStr),J=d.edgeStrToEdgeStartData(r[i-1].edgeTypeStr),G=d.edgeStrToThickness(r[i-1].edgeTypeStr),Z=d.edgeStrToPattern(r[i-1].edgeTypeStr);this.$=[{id:r[i-2].id,label:r[i-2].label,type:r[i-2].type,directions:r[i-2].directions},{id:r[i-2].id+"-"+r[i].id,start:r[i-2].id,end:r[i].id,label:r[i-1].label,type:"edge",thickness:G,pattern:Z,directions:r[i].directions,arrowTypeEnd:j,arrowTypeStart:J},{id:r[i].id,label:r[i].label,type:d.typeStr2Type(r[i].typeStr),directions:r[i].directions}];break;case 24:d.getLogger().debug("Rule: nodeStatement (abc88 node size) ",r[i-1],r[i]),this.$={id:r[i-1].id,label:r[i-1].label,type:d.typeStr2Type(r[i-1].typeStr),directions:r[i-1].directions,widthInColumns:parseInt(r[i],10)};break;case 25:d.getLogger().debug("Rule: nodeStatement (node) ",r[i]),this.$={id:r[i].id,label:r[i].label,type:d.typeStr2Type(r[i].typeStr),directions:r[i].directions,widthInColumns:1};break;case 26:d.getLogger().debug("APA123",this?this:"na"),d.getLogger().debug("COLUMNS: ",r[i]),this.$={type:"column-setting",columns:r[i]==="auto"?-1:parseInt(r[i])};break;case 27:d.getLogger().debug("Rule: id-block statement : ",r[i-2],r[i-1]);let _=d.generateId();this.$={...r[i-2],type:"composite",children:r[i-1]};break;case 28:d.getLogger().debug("Rule: blockStatement : ",r[i-2],r[i-1],r[i]);let R=d.generateId();this.$={id:R,type:"composite",label:"",children:r[i-1]};break;case 29:d.getLogger().debug("Rule: node (NODE_ID separator): ",r[i]),this.$={id:r[i]};break;case 30:d.getLogger().debug("Rule: node (NODE_ID nodeShapeNLabel separator): ",r[i-1],r[i]),this.$={id:r[i-1],label:r[i].label,typeStr:r[i].typeStr,directions:r[i].directions};break;case 31:d.getLogger().debug("Rule: dirList: ",r[i]),this.$=[r[i]];break;case 32:d.getLogger().debug("Rule: dirList: ",r[i-1],r[i]),this.$=[r[i-1]].concat(r[i]);break;case 33:d.getLogger().debug("Rule: nodeShapeNLabel: ",r[i-2],r[i-1],r[i]),this.$={typeStr:r[i-2]+r[i],label:r[i-1]};break;case 34:d.getLogger().debug("Rule: BLOCK_ARROW nodeShapeNLabel: ",r[i-3],r[i-2]," #3:",r[i-1],r[i]),this.$={typeStr:r[i-3]+r[i],label:r[i-2],directions:r[i-1]};break;case 35:case 36:this.$={type:"classDef",id:r[i-1].trim(),css:r[i].trim()};break;case 37:this.$={type:"applyClass",id:r[i-1].trim(),styleClass:r[i].trim()};break;case 38:this.$={type:"applyStyles",id:r[i-1].trim(),stylesStr:r[i].trim()};break}},"anonymous"),table:[{9:1,10:[1,2]},{1:[3]},{10:a,11:3,13:4,19:5,20:6,21:l,22:8,23:9,24:10,25:11,26:12,28:n,29:g,31:p,39:t,43:h,46:x},{8:[1,20]},e(k,[2,12],{13:4,19:5,20:6,22:8,23:9,24:10,25:11,26:12,11:21,10:a,21:l,28:n,29:g,31:p,39:t,43:h,46:x}),e(b,[2,16],{14:22,15:f,16:S}),e(b,[2,17]),e(b,[2,18]),e(b,[2,19]),e(b,[2,20]),e(b,[2,21]),e(b,[2,22]),e(E,[2,25],{27:[1,25]}),e(b,[2,26]),{19:26,26:12,31:p},{10:a,11:27,13:4,19:5,20:6,21:l,22:8,23:9,24:10,25:11,26:12,28:n,29:g,31:p,39:t,43:h,46:x},{40:[1,28],42:[1,29]},{44:[1,30]},{47:[1,31]},e(m,[2,29],{32:32,35:[1,33],37:[1,34]}),{1:[2,7]},e(k,[2,13]),{26:35,31:p},{31:[2,14]},{17:[1,36]},e(E,[2,24]),{10:a,11:37,13:4,14:22,15:f,16:S,19:5,20:6,21:l,22:8,23:9,24:10,25:11,26:12,28:n,29:g,31:p,39:t,43:h,46:x},{30:[1,38]},{41:[1,39]},{41:[1,40]},{45:[1,41]},{48:[1,42]},e(m,[2,30]),{18:[1,43]},{18:[1,44]},e(E,[2,23]),{18:[1,45]},{30:[1,46]},e(b,[2,28]),e(b,[2,35]),e(b,[2,36]),e(b,[2,37]),e(b,[2,38]),{36:[1,47]},{33:48,34:w},{15:[1,50]},e(b,[2,27]),e(m,[2,33]),{38:[1,51]},{33:52,34:w,38:[2,31]},{31:[2,15]},e(m,[2,34]),{38:[2,32]}],defaultActions:{20:[2,7],23:[2,14],50:[2,15],52:[2,32]},parseError:c(function(u,s){if(s.recoverable)this.trace(u);else{var o=new Error(u);throw o.hash=s,o}},"parseError"),parse:c(function(u){var s=this,o=[0],d=[],y=[null],r=[],K=this.table,i="",F=0,V=0,j=0,J=2,G=1,Z=r.slice.call(arguments,1),_=Object.create(this.lexer),R={yy:{}};for(var Q in this.yy)Object.prototype.hasOwnProperty.call(this.yy,Q)&&(R.yy[Q]=this.yy[Q]);_.setInput(u,R.yy),R.yy.lexer=_,R.yy.parser=this,typeof _.yylloc>"u"&&(_.yylloc={});var $=_.yylloc;r.push($);var Ze=_.options&&_.options.ranges;typeof R.yy.parseError=="function"?this.parseError=R.yy.parseError:this.parseError=Object.getPrototypeOf(this).parseError;function Ot(I){o.length=o.length-2*I,y.length=y.length-I,r.length=r.length-I}c(Ot,"popStack");function Qe(){var I;return I=d.pop()||_.lex()||G,typeof I!="number"&&(I instanceof Array&&(d=I,I=d.pop()),I=s.symbols_[I]||I),I}c(Qe,"lex");for(var C,ee,P,T,zt,te,M={},H,v,ue,U;;){if(P=o[o.length-1],this.defaultActions[P]?T=this.defaultActions[P]:((C===null||typeof C>"u")&&(C=Qe()),T=K[P]&&K[P][C]),typeof T>"u"||!T.length||!T[0]){var re="";U=[];for(H in K[P])this.terminals_[H]&&H>J&&U.push("'"+this.terminals_[H]+"'");_.showPosition?re="Parse error on line "+(F+1)+`:
`+_.showPosition()+`
Expecting `+U.join(", ")+", got '"+(this.terminals_[C]||C)+"'":re="Parse error on line "+(F+1)+": Unexpected "+(C==G?"end of input":"'"+(this.terminals_[C]||C)+"'"),this.parseError(re,{text:_.match,token:this.terminals_[C]||C,line:_.yylineno,loc:$,expected:U})}if(T[0]instanceof Array&&T.length>1)throw new Error("Parse Error: multiple actions possible at state: "+P+", token: "+C);switch(T[0]){case 1:o.push(C),y.push(_.yytext),r.push(_.yylloc),o.push(T[1]),C=null,ee?(C=ee,ee=null):(V=_.yyleng,i=_.yytext,F=_.yylineno,$=_.yylloc,j>0&&j--);break;case 2:if(v=this.productions_[T[1]][1],M.$=y[y.length-v],M._$={first_line:r[r.length-(v||1)].first_line,last_line:r[r.length-1].last_line,first_column:r[r.length-(v||1)].first_column,last_column:r[r.length-1].last_column},Ze&&(M._$.range=[r[r.length-(v||1)].range[0],r[r.length-1].range[1]]),te=this.performAction.apply(M,[i,V,F,R.yy,T[1],y,r].concat(Z)),typeof te<"u")return te;v&&(o=o.slice(0,-1*v*2),y=y.slice(0,-1*v),r=r.slice(0,-1*v)),o.push(this.productions_[T[1]][0]),y.push(M.$),r.push(M._$),ue=K[o[o.length-2]][o[o.length-1]],o.push(ue);break;case 3:return!0}}return!0},"parse")},B=(function(){var N={EOF:1,parseError:c(function(s,o){if(this.yy.parser)this.yy.parser.parseError(s,o);else throw new Error(s)},"parseError"),setInput:c(function(u,s){return this.yy=s||this.yy||{},this._input=u,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:c(function(){var u=this._input[0];this.yytext+=u,this.yyleng++,this.offset++,this.match+=u,this.matched+=u;var s=u.match(/(?:\r\n?|\n).*/g);return s?(this.yylineno++,this.yylloc.last_line++):this.yylloc.last_column++,this.options.ranges&&this.yylloc.range[1]++,this._input=this._input.slice(1),u},"input"),unput:c(function(u){var s=u.length,o=u.split(/(?:\r\n?|\n)/g);this._input=u+this._input,this.yytext=this.yytext.substr(0,this.yytext.length-s),this.offset-=s;var d=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),o.length-1&&(this.yylineno-=o.length-1);var y=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:o?(o.length===d.length?this.yylloc.first_column:0)+d[d.length-o.length].length-o[0].length:this.yylloc.first_column-s},this.options.ranges&&(this.yylloc.range=[y[0],y[0]+this.yyleng-s]),this.yyleng=this.yytext.length,this},"unput"),more:c(function(){return this._more=!0,this},"more"),reject:c(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:c(function(u){this.unput(this.match.slice(u))},"less"),pastInput:c(function(){var u=this.matched.substr(0,this.matched.length-this.match.length);return(u.length>20?"...":"")+u.substr(-20).replace(/\n/g,"")},"pastInput"),upcomingInput:c(function(){var u=this.match;return u.length<20&&(u+=this._input.substr(0,20-u.length)),(u.substr(0,20)+(u.length>20?"...":"")).replace(/\n/g,"")},"upcomingInput"),showPosition:c(function(){var u=this.pastInput(),s=new Array(u.length+1).join("-");return u+this.upcomingInput()+`
`+s+"^"},"showPosition"),test_match:c(function(u,s){var o,d,y;if(this.options.backtrack_lexer&&(y={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&&(y.yylloc.range=this.yylloc.range.slice(0))),d=u[0].match(/(?:\r\n?|\n).*/g),d&&(this.yylineno+=d.length),this.yylloc={first_line:this.yylloc.last_line,last_line:this.yylineno+1,first_column:this.yylloc.last_column,last_column:d?d[d.length-1].length-d[d.length-1].match(/\r?\n?/)[0].length:this.yylloc.last_column+u[0].length},this.yytext+=u[0],this.match+=u[0],this.matches=u,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(u[0].length),this.matched+=u[0],o=this.performAction.call(this,this.yy,this,s,this.conditionStack[this.conditionStack.length-1]),this.done&&this._input&&(this.done=!1),o)return o;if(this._backtrack){for(var r in y)this[r]=y[r];return!1}return!1},"test_match"),next:c(function(){if(this.done)return this.EOF;this._input||(this.done=!0);var u,s,o,d;this._more||(this.yytext="",this.match="");for(var y=this._currentRules(),r=0;r<y.length;r++)if(o=this._input.match(this.rules[y[r]]),o&&(!s||o[0].length>s[0].length)){if(s=o,d=r,this.options.backtrack_lexer){if(u=this.test_match(o,y[r]),u!==!1)return u;if(this._backtrack){s=!1;continue}else return!1}else if(!this.options.flex)break}return s?(u=this.test_match(s,y[d]),u!==!1?u:!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:c(function(){var s=this.next();return s||this.lex()},"lex"),begin:c(function(s){this.conditionStack.push(s)},"begin"),popState:c(function(){var s=this.conditionStack.length-1;return s>0?this.conditionStack.pop():this.conditionStack[0]},"popState"),_currentRules:c(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:c(function(s){return s=this.conditionStack.length-1-Math.abs(s||0),s>=0?this.conditionStack[s]:"INITIAL"},"topState"),pushState:c(function(s){this.begin(s)},"pushState"),stateStackSize:c(function(){return this.conditionStack.length},"stateStackSize"),options:{},performAction:c(function(s,o,d,y){var r=y;switch(d){case 0:return s.getLogger().debug("Found block-beta"),10;break;case 1:return s.getLogger().debug("Found id-block"),29;break;case 2:return s.getLogger().debug("Found block"),10;break;case 3:s.getLogger().debug(".",o.yytext);break;case 4:s.getLogger().debug("_",o.yytext);break;case 5:return 5;case 6:return o.yytext=-1,28;break;case 7:return o.yytext=o.yytext.replace(/columns\s+/,""),s.getLogger().debug("COLUMNS (LEX)",o.yytext),28;break;case 8:this.pushState("md_string");break;case 9:return"MD_STR";case 10:this.popState();break;case 11:this.pushState("string");break;case 12:s.getLogger().debug("LEX: POPPING STR:",o.yytext),this.popState();break;case 13:return s.getLogger().debug("LEX: STR end:",o.yytext),"STR";break;case 14:return o.yytext=o.yytext.replace(/space\:/,""),s.getLogger().debug("SPACE NUM (LEX)",o.yytext),21;break;case 15:return o.yytext="1",s.getLogger().debug("COLUMNS (LEX)",o.yytext),21;break;case 16:return 42;case 17:return"LINKSTYLE";case 18:return"INTERPOLATE";case 19:return this.pushState("CLASSDEF"),39;break;case 20:return this.popState(),this.pushState("CLASSDEFID"),"DEFAULT_CLASSDEF_ID";break;case 21:return this.popState(),this.pushState("CLASSDEFID"),40;break;case 22:return this.popState(),41;break;case 23:return this.pushState("CLASS"),43;break;case 24:return this.popState(),this.pushState("CLASS_STYLE"),44;break;case 25:return this.popState(),45;break;case 26:return this.pushState("STYLE_STMNT"),46;break;case 27:return this.popState(),this.pushState("STYLE_DEFINITION"),47;break;case 28:return this.popState(),48;break;case 29:return this.pushState("acc_title"),"acc_title";break;case 30:return this.popState(),"acc_title_value";break;case 31:return this.pushState("acc_descr"),"acc_descr";break;case 32:return this.popState(),"acc_descr_value";break;case 33:this.pushState("acc_descr_multiline");break;case 34:this.popState();break;case 35:return"acc_descr_multiline_value";case 36:return 30;case 37:return this.popState(),s.getLogger().debug("Lex: (("),"NODE_DEND";break;case 38:return this.popState(),s.getLogger().debug("Lex: (("),"NODE_DEND";break;case 39:return this.popState(),s.getLogger().debug("Lex: ))"),"NODE_DEND";break;case 40:return this.popState(),s.getLogger().debug("Lex: (("),"NODE_DEND";break;case 41:return this.popState(),s.getLogger().debug("Lex: (("),"NODE_DEND";break;case 42:return this.popState(),s.getLogger().debug("Lex: (-"),"NODE_DEND";break;case 43:return this.popState(),s.getLogger().debug("Lex: -)"),"NODE_DEND";break;case 44:return this.popState(),s.getLogger().debug("Lex: (("),"NODE_DEND";break;case 45:return this.popState(),s.getLogger().debug("Lex: ]]"),"NODE_DEND";break;case 46:return this.popState(),s.getLogger().debug("Lex: ("),"NODE_DEND";break;case 47:return this.popState(),s.getLogger().debug("Lex: ])"),"NODE_DEND";break;case 48:return this.popState(),s.getLogger().debug("Lex: /]"),"NODE_DEND";break;case 49:return this.popState(),s.getLogger().debug("Lex: /]"),"NODE_DEND";break;case 50:return this.popState(),s.getLogger().debug("Lex: )]"),"NODE_DEND";break;case 51:return this.popState(),s.getLogger().debug("Lex: )"),"NODE_DEND";break;case 52:return this.popState(),s.getLogger().debug("Lex: ]>"),"NODE_DEND";break;case 53:return this.popState(),s.getLogger().debug("Lex: ]"),"NODE_DEND";break;case 54:return s.getLogger().debug("Lexa: -)"),this.pushState("NODE"),35;break;case 55:return s.getLogger().debug("Lexa: (-"),this.pushState("NODE"),35;break;case 56:return s.getLogger().debug("Lexa: ))"),this.pushState("NODE"),35;break;case 57:return s.getLogger().debug("Lexa: )"),this.pushState("NODE"),35;break;case 58:return s.getLogger().debug("Lex: ((("),this.pushState("NODE"),35;break;case 59:return s.getLogger().debug("Lexa: )"),this.pushState("NODE"),35;break;case 60:return s.getLogger().debug("Lexa: )"),this.pushState("NODE"),35;break;case 61:return s.getLogger().debug("Lexa: )"),this.pushState("NODE"),35;break;case 62:return s.getLogger().debug("Lexc: >"),this.pushState("NODE"),35;break;case 63:return s.getLogger().debug("Lexa: (["),this.pushState("NODE"),35;break;case 64:return s.getLogger().debug("Lexa: )"),this.pushState("NODE"),35;break;case 65:return this.pushState("NODE"),35;break;case 66:return this.pushState("NODE"),35;break;case 67:return this.pushState("NODE"),35;break;case 68:return this.pushState("NODE"),35;break;case 69:return this.pushState("NODE"),35;break;case 70:return this.pushState("NODE"),35;break;case 71:return this.pushState("NODE"),35;break;case 72:return s.getLogger().debug("Lexa: ["),this.pushState("NODE"),35;break;case 73:return this.pushState("BLOCK_ARROW"),s.getLogger().debug("LEX ARR START"),37;break;case 74:return s.getLogger().debug("Lex: NODE_ID",o.yytext),31;break;case 75:return s.getLogger().debug("Lex: EOF",o.yytext),8;break;case 76:this.pushState("md_string");break;case 77:this.pushState("md_string");break;case 78:return"NODE_DESCR";case 79:this.popState();break;case 80:s.getLogger().debug("Lex: Starting string"),this.pushState("string");break;case 81:s.getLogger().debug("LEX ARR: Starting string"),this.pushState("string");break;case 82:return s.getLogger().debug("LEX: NODE_DESCR:",o.yytext),"NODE_DESCR";break;case 83:s.getLogger().debug("LEX POPPING"),this.popState();break;case 84:s.getLogger().debug("Lex: =>BAE"),this.pushState("ARROW_DIR");break;case 85:return o.yytext=o.yytext.replace(/^,\s*/,""),s.getLogger().debug("Lex (right): dir:",o.yytext),"DIR";break;case 86:return o.yytext=o.yytext.replace(/^,\s*/,""),s.getLogger().debug("Lex (left):",o.yytext),"DIR";break;case 87:return o.yytext=o.yytext.replace(/^,\s*/,""),s.getLogger().debug("Lex (x):",o.yytext),"DIR";break;case 88:return o.yytext=o.yytext.replace(/^,\s*/,""),s.getLogger().debug("Lex (y):",o.yytext),"DIR";break;case 89:return o.yytext=o.yytext.replace(/^,\s*/,""),s.getLogger().debug("Lex (up):",o.yytext),"DIR";break;case 90:return o.yytext=o.yytext.replace(/^,\s*/,""),s.getLogger().debug("Lex (down):",o.yytext),"DIR";break;case 91:return o.yytext="]>",s.getLogger().debug("Lex (ARROW_DIR end):",o.yytext),this.popState(),this.popState(),"BLOCK_ARROW_END";break;case 92:return s.getLogger().debug("Lex: LINK","#"+o.yytext+"#"),15;break;case 93:return s.getLogger().debug("Lex: LINK",o.yytext),15;break;case 94:return s.getLogger().debug("Lex: LINK",o.yytext),15;break;case 95:return s.getLogger().debug("Lex: LINK",o.yytext),15;break;case 96:return s.getLogger().debug("Lex: START_LINK",o.yytext),this.pushState("LLABEL"),16;break;case 97:return s.getLogger().debug("Lex: START_LINK",o.yytext),this.pushState("LLABEL"),16;break;case 98:return s.getLogger().debug("Lex: START_LINK",o.yytext),this.pushState("LLABEL"),16;break;case 99:this.pushState("md_string");break;case 100:return s.getLogger().debug("Lex: Starting string"),this.pushState("string"),"LINK_LABEL";break;case 101:return this.popState(),s.getLogger().debug("Lex: LINK","#"+o.yytext+"#"),15;break;case 102:return this.popState(),s.getLogger().debug("Lex: LINK",o.yytext),15;break;case 103:return this.popState(),s.getLogger().debug("Lex: LINK",o.yytext),15;break;case 104:return s.getLogger().debug("Lex: COLON",o.yytext),o.yytext=o.yytext.slice(1),27;break}},"anonymous"),rules:[/^(?:block-beta\b)/,/^(?:block:)/,/^(?:block\b)/,/^(?:[\s]+)/,/^(?:[\n]+)/,/^(?:((\u000D\u000A)|(\u000A)))/,/^(?:columns\s+auto\b)/,/^(?:columns\s+[\d]+)/,/^(?:["][`])/,/^(?:[^`"]+)/,/^(?:[`]["])/,/^(?:["])/,/^(?:["])/,/^(?:[^"]*)/,/^(?:space[:]\d+)/,/^(?:space\b)/,/^(?:default\b)/,/^(?:linkStyle\b)/,/^(?:interpolate\b)/,/^(?:classDef\s+)/,/^(?:DEFAULT\s+)/,/^(?:\w+\s+)/,/^(?:[^\n]*)/,/^(?:class\s+)/,/^(?:(\w+)+((,\s*\w+)*))/,/^(?:[^\n]*)/,/^(?:style\s+)/,/^(?:(\w+)+((,\s*\w+)*))/,/^(?:[^\n]*)/,/^(?:accTitle\s*:\s*)/,/^(?:(?!\n||)*[^\n]*)/,/^(?:accDescr\s*:\s*)/,/^(?:(?!\n||)*[^\n]*)/,/^(?:accDescr\s*\{\s*)/,/^(?:[\}])/,/^(?:[^\}]*)/,/^(?:end\b\s*)/,/^(?:\(\(\()/,/^(?:\)\)\))/,/^(?:[\)]\))/,/^(?:\}\})/,/^(?:\})/,/^(?:\(-)/,/^(?:-\))/,/^(?:\(\()/,/^(?:\]\])/,/^(?:\()/,/^(?:\]\))/,/^(?:\\\])/,/^(?:\/\])/,/^(?:\)\])/,/^(?:[\)])/,/^(?:\]>)/,/^(?:[\]])/,/^(?:-\))/,/^(?:\(-)/,/^(?:\)\))/,/^(?:\))/,/^(?:\(\(\()/,/^(?:\(\()/,/^(?:\{\{)/,/^(?:\{)/,/^(?:>)/,/^(?:\(\[)/,/^(?:\()/,/^(?:\[\[)/,/^(?:\[\|)/,/^(?:\[\()/,/^(?:\)\)\))/,/^(?:\[\\)/,/^(?:\[\/)/,/^(?:\[\\)/,/^(?:\[)/,/^(?:<\[)/,/^(?:[^\(\[\n\-\)\{\}\s\<\>:=]+)/,/^(?:$)/,/^(?:["][`])/,/^(?:["][`])/,/^(?:[^`"]+)/,/^(?:[`]["])/,/^(?:["])/,/^(?:["])/,/^(?:[^"]+)/,/^(?:["])/,/^(?:\]>\s*\()/,/^(?:,?\s*right\s*)/,/^(?:,?\s*left\s*)/,/^(?:,?\s*x\s*)/,/^(?:,?\s*y\s*)/,/^(?:,?\s*up\s*)/,/^(?:,?\s*down\s*)/,/^(?:\)\s*)/,/^(?:\s*[xo<]?--+[-xo>]\s*)/,/^(?:\s*[xo<]?==+[=xo>]\s*)/,/^(?:\s*[xo<]?-?\.+-[xo>]?\s*)/,/^(?:\s*~~[\~]+\s*)/,/^(?:\s*[xo<]?--\s*)/,/^(?:\s*[xo<]?==\s*)/,/^(?:\s*[xo<]?-\.\s*)/,/^(?:["][`])/,/^(?:["])/,/^(?:\s*[xo<]?--+[-xo>]\s*)/,/^(?:\s*[xo<]?==+[=xo>]\s*)/,/^(?:\s*[xo<]?-?\.+-[xo>]?\s*)/,/^(?::\d+)/],conditions:{STYLE_DEFINITION:{rules:[28],inclusive:!1},STYLE_STMNT:{rules:[27],inclusive:!1},CLASSDEFID:{rules:[22],inclusive:!1},CLASSDEF:{rules:[20,21],inclusive:!1},CLASS_STYLE:{rules:[25],inclusive:!1},CLASS:{rules:[24],inclusive:!1},LLABEL:{rules:[99,100,101,102,103],inclusive:!1},ARROW_DIR:{rules:[85,86,87,88,89,90,91],inclusive:!1},BLOCK_ARROW:{rules:[76,81,84],inclusive:!1},NODE:{rules:[37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,77,80],inclusive:!1},md_string:{rules:[9,10,78,79],inclusive:!1},space:{rules:[],inclusive:!1},string:{rules:[12,13,82,83],inclusive:!1},acc_descr_multiline:{rules:[34,35],inclusive:!1},acc_descr:{rules:[32],inclusive:!1},acc_title:{rules:[30],inclusive:!1},INITIAL:{rules:[0,1,2,3,4,5,6,7,8,11,14,15,16,17,18,19,23,26,29,31,33,36,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,92,93,94,95,96,97,98,104],inclusive:!0}}};return N})();D.lexer=B;function O(){this.yy={}}return c(O,"Parser"),O.prototype=D,D.Parser=O,new O})();ie.parser=ie;var ze=ie;var z=new Map,oe=[],ne=new Map,Ae="color",Re="fill",et="bgFill",Pe=",",q=new Map,ae="",tt=c(e=>fe.sanitizeText(e,X()),"sanitizeText"),rt=c(function(e,a=""){let l=q.get(e);l||(l={id:e,styles:[],textStyles:[]},q.set(e,l)),a?.split(Pe).forEach(n=>{let g=n.replace(/([^;]*);/,"$1").trim();if(RegExp(Ae).exec(n)){let t=g.replace(Re,et).replace(Ae,Re);l.textStyles.push(t)}l.styles.push(g)})},"addStyleClass"),st=c(function(e,a=""){let l=z.get(e);a!=null&&(l.styles=a.split(Pe))},"addStyle2Node"),it=c(function(e,a){e.split(",").forEach(function(l){let n=z.get(l);if(n===void 0){let g=l.trim();n={id:g,type:"na",children:[]},z.set(g,n)}n.classes||(n.classes=[]),n.classes.push(a)})},"setCssClass"),Fe=0,Me=c((e,a)=>{let l=e.flat(),n=[],p=l.find(t=>t?.type==="column-setting")?.columns??-1;for(let t of l){if(typeof p=="number"&&p>0&&t.type!=="column-setting"&&typeof t.widthInColumns=="number"&&t.widthInColumns>p&&L.warn(`Block ${t.id} width ${t.widthInColumns} exceeds configured column width ${p}`),t.label&&(t.label=tt(t.label)),t.type==="classDef"){rt(t.id,t.css);continue}if(t.type==="applyClass"){it(t.id,t?.styleClass??"");continue}if(t.type==="applyStyles"){t?.stylesStr&&st(t.id,t?.stylesStr);continue}if(t.type==="column-setting")a.columns=t.columns??-1;else if(t.type==="edge"){let h=(ne.get(t.id)??0)+1;ne.set(t.id,h),t.id=h+"-"+t.id,oe.push(t)}else{t.label||(t.type==="composite"?t.label="":t.label=t.id);let h=z.get(t.id);if(h===void 0?(t.type==="composite"&&(t.colorIndex=Fe++),z.set(t.id,t)):(t.type!=="na"&&(h.type=t.type),t.label!==t.id&&(h.label=t.label)),t.children&&Me(t.children,t),t.type==="space"){let x=t.width??1;for(let k=0;k<x;k++){let b=xe(t);b.id=b.id+"-"+k,z.set(b.id,b),n.push(b)}}else h===void 0&&n.push(t)}}a.children=n},"populateBlockDatabase"),le=[],Y={id:"root",type:"composite",children:[],columns:-1},nt=c(()=>{L.debug("Clear called"),me(),Y={id:"root",type:"composite",children:[],columns:-1},z=new Map([["root",Y]]),le=[],q=new Map,oe=[],ne=new Map,ae="",Fe=0},"clear");function ot(e){switch(L.debug("typeStr2Type",e),e){case"[]":return"square";case"()":return L.debug("we have a round"),"round";case"(())":return"circle";case">]":return"rect_left_inv_arrow";case"{}":return"diamond";case"{{}}":return"hexagon";case"([])":return"stadium";case"[[]]":return"subroutine";case"[()]":return"cylinder";case"((()))":return"doublecircle";case"[//]":return"lean_right";case"[\\\\]":return"lean_left";case"[/\\]":return"trapezoid";case"[\\/]":return"inv_trapezoid";case"<[]>":return"block_arrow";default:return"na"}}c(ot,"typeStr2Type");function at(e){switch(L.debug("typeStr2Type",e),e){case"==":return"thick";default:return"normal"}}c(at,"edgeTypeStr2Type");function lt(e){switch(e.trim().slice(-1)){case"x":return"arrow_cross";case"o":return"arrow_circle";case">":return"arrow_point";default:return""}}c(lt,"edgeStrToEdgeData");function ct(e){switch(e.trim().charAt(0)){case"x":return"arrow_cross";case"o":return"arrow_circle";case"<":return"arrow_point";default:return"arrow_open"}}c(ct,"edgeStrToEdgeStartData");function gt(e){return e.includes("==")?"thick":"normal"}c(gt,"edgeStrToThickness");function ht(e){return e.includes(".-")?"dotted":"solid"}c(ht,"edgeStrToPattern");var ve=0,ut=c(()=>(ve++,"id-"+Math.random().toString(36).substr(2,12)+"-"+ve),"generateId"),dt=c(e=>{Y.children=e,Me(e,Y),le=Y.children},"setHierarchy"),pt=c(e=>{let a=z.get(e);return a?a.columns?a.columns:a.children?a.children.length:-1:-1},"getColumns"),ft=c(()=>[...z.values()],"getBlocksFlat"),bt=c(()=>le||[],"getBlocks"),mt=c(()=>oe,"getEdges"),xt=c(e=>z.get(e),"getBlock"),kt=c(e=>{z.set(e.id,e)},"setBlock"),St=c(e=>{ae=e},"setDiagramId"),Lt=c(()=>ae,"getDiagramId"),yt=c(()=>L,"getLogger"),Et=c(function(){return q},"getClasses"),Dt={getConfig:c(()=>A().block,"getConfig"),typeStr2Type:ot,edgeTypeStr2Type:at,edgeStrToEdgeData:lt,edgeStrToEdgeStartData:ct,edgeStrToThickness:gt,edgeStrToPattern:ht,getLogger:yt,getBlocksFlat:ft,getBlocks:bt,getEdges:mt,setHierarchy:dt,getBlock:xt,setBlock:kt,getColumns:pt,getClasses:Et,clear:nt,generateId:ut,setDiagramId:St,getDiagramId:Lt},Ke=Dt;var wt=c(e=>{let{theme:a,bkgColorArray:l,borderColorArray:n}=e;if(!Le(a,n))return"";let g=ye(e.look),p=Se(l),t="";for(let h=0;h<Ee(e.THEME_COLOR_LIMIT,n);h++){let x=n[h%n.length],k=p?`fill: ${l[h%l.length]};`:"",b=`[data-look="${g}"][data-color-id="color-${h}"]`;t+=`
${b}.node rect.composite {
stroke: ${x};
${k}
}
`}return t},"genColor"),ce=c((e,a)=>{let l=pe,n=l(e,"r"),g=l(e,"g"),p=l(e,"b");return de(n,g,p,a)},"fade"),_t=c(e=>`${wt(e)}
.label {
font-family: ${e.fontFamily};
color: ${e.nodeTextColor||e.textColor};
}
.cluster-label text {
fill: ${e.titleColor};
}
.cluster-label span {
color: ${e.titleColor};
}
.label text,span {
fill: ${e.nodeTextColor||e.textColor};
color: ${e.nodeTextColor||e.textColor};
}
.node rect,
.node circle,
.node ellipse,
.node polygon,
.node path {
fill: ${e.mainBkg};
stroke: ${e.nodeBorder};
/* From the theme, as every other diagram does. Pinned at 1px here, so block drew a
thinner border than an identical flowchart node under any theme asking for more --
the neo theme asks for 2. Nothing downstream corrected it: the neo rules set stroke
and filter, never stroke-width. */
stroke-width: ${e.strokeWidth??1}px;
}
.flowchart-label text {
text-anchor: middle;
}
// .flowchart-label .text-outer-tspan {
// text-anchor: middle;
// }
// .flowchart-label .text-inner-tspan {
// text-anchor: start;
// }
.node .label {
text-align: center;
}
.node.clickable {
cursor: pointer;
}
.arrowheadPath {
fill: ${e.arrowheadColor};
}
.edgePaths .path {
stroke: ${e.lineColor};
stroke-width: 2.0px;
}
.flowchart-link {
stroke: ${e.lineColor};
fill: none;
}
.edgeLabel {
background-color: ${e.edgeLabelBackground};
/*
* This is for backward compatibility with existing code that didn't
* add a \`<p>\` around edge labels.
*
* TODO: We should probably remove this in a future release.
*/
p {
margin: 0;
padding: 0;
display: inline;
}
rect {
opacity: 0.5;
background-color: ${e.edgeLabelBackground};
fill: ${e.edgeLabelBackground};
}
text-align: center;
}
/* For html labels only */
.labelBkg {
background-color: ${e.edgeLabelBackground};
}
.node .cluster {
// fill: ${ce(e.mainBkg,.5)};
fill: ${ce(e.clusterBkg,.5)};
stroke: ${ce(e.clusterBorder,.2)};
box-shadow: rgba(50, 50, 93, 0.25) 0px 13px 27px -5px, rgba(0, 0, 0, 0.3) 0px 8px 16px -8px;
stroke-width: 1px;
}
.cluster text {
fill: ${e.titleColor};
}
.cluster span {
color: ${e.titleColor};
}
/* .cluster div {
color: ${e.titleColor};
} */
div.mermaidTooltip {
position: absolute;
text-align: center;
max-width: 200px;
padding: 2px;
font-family: ${e.fontFamily};
font-size: 12px;
background: ${e.tertiaryColor};
border: 1px solid ${e.border2};
border-radius: 2px;
pointer-events: none;
z-index: 100;
}
.flowchartTitleText {
text-anchor: middle;
font-size: 18px;
fill: ${e.textColor};
}
${Oe()}
`,"getStyles"),We=_t;function Ye(e,a){if(e===0||!Number.isInteger(e))throw new Error("Columns must be an integer !== 0.");if(a<0||!Number.isInteger(a))throw new Error("Position must be a non-negative integer."+a);if(e<0)return{px:a,py:0};if(e===1)return{px:0,py:a};let l=a%e,n=Math.floor(a/e);return{px:l,py:n}}c(Ye,"calculateBlockPosition");var Bt=c(e=>{let a=0,l=0;for(let n of e.children){let{width:g,height:p,x:t,y:h}=n.size??{width:0,height:0,x:0,y:0};if(L.debug("getMaxChildSize abc95 child:",n.id,"width:",g,"height:",p,"x:",t,"y:",h,n.type),n.type==="space")continue;let x=g/(n.widthInColumns??1);x>a&&(a=x),p>l&&(l=p)}return{width:a,height:l}},"getMaxChildSize");function ge(e,a,l=0,n=0,g=8){L.debug("setBlockSizes abc95 (start)",e.id,e?.size?.x,"block width =",e?.size,"siblingWidth",l),e?.size?.width||(e.size={width:l,height:n,x:0,y:0});let p=0,t=0;if(e.children?.length>0){for(let m of e.children)ge(m,a,0,0,g);let h=Bt(e);p=h.width,t=h.height,L.debug("setBlockSizes abc95 maxWidth of",e.id,":s children is ",p,t);for(let m of e.children)m.size&&(L.debug(`abc95 Setting size of children of ${e.id} id=${m.id} ${p} ${t} ${JSON.stringify(m.size)}`),m.size.width=p*(m.widthInColumns??1)+g*((m.widthInColumns??1)-1),m.size.height=t,m.size.x=0,m.size.y=0,L.debug(`abc95 updating size of ${e.id} children child:${m.id} maxWidth:${p} maxHeight:${t}`));for(let m of e.children)ge(m,a,p,t,g);let x=e.columns??-1,k=0;for(let m of e.children)k+=m.widthInColumns??1;let b=e.children.length;x>0&&x<k&&(b=x);let f=Math.ceil(k/b),S=b*(p+g)+g,E=f*(t+g)+g;if(S<l){L.debug(`Detected to small sibling: abc95 ${e.id} siblingWidth ${l} siblingHeight ${n} width ${S}`),S=l,E=n;let m=(l-b*g-g)/b,w=(n-f*g-g)/f;L.debug("Size indata abc88",e.id,"childWidth",m,"maxWidth",p),L.debug("Size indata abc88",e.id,"childHeight",w,"maxHeight",t),L.debug("Size indata abc88 xSize",b,"padding",g);for(let D of e.children)D.size&&(D.size.width=m,D.size.height=w,D.size.x=0,D.size.y=0)}if(L.debug(`abc95 (finale calc) ${e.id} xSize ${b} ySize ${f} columns ${x}${e.children.length} width=${Math.max(S,e.size?.width||0)}`),S<(e?.size?.width||0)){S=e?.size?.width||0;let m=x>0?Math.min(e.children.length,x):e.children.length;if(m>0){let w=(S-m*g-g)/m;L.debug("abc95 (growing to fit) width",e.id,S,e.size?.width,w);for(let D of e.children)D.size&&(D.size.width=w)}}e.size={width:S,height:E,x:0,y:0}}L.debug("setBlockSizes abc94 (done)",e.id,e?.size?.x,e?.size?.width,e?.size?.y,e?.size?.height)}c(ge,"setBlockSizes");function Ve(e,a,l=8){L.debug(`abc85 layout blocks (=>layoutBlocks) ${e.id} x: ${e?.size?.x} y: ${e?.size?.y} width: ${e?.size?.width}`);let n=e.columns??-1;if(L.debug("layoutBlocks columns abc95",e.id,"=>",n,e),e.children&&e.children.length>0){let g=e?.children[0]?.size?.width??0,p=e.children.length*g+(e.children.length-1)*l;L.debug("widthOfChildren 88",p,"posX");let t=new Map;{let f=0;for(let S of e.children){if(!S.size)continue;let{py:E}=Ye(n,f),m=t.get(E)??0;S.size.height>m&&t.set(E,S.size.height);let w=S?.widthInColumns??1;n>0&&(w=Math.min(w,n-f%n)),f+=w}}let h=new Map;{let f=0,S=[...t.keys()].sort((E,m)=>E-m);for(let E of S)h.set(E,f),f+=(t.get(E)??0)+l}let x=0;L.debug("abc91 block?.size?.x",e.id,e?.size?.x);let k=e?.size?.x?e?.size?.x+(-e?.size?.width/2||0):-l,b=0;for(let f of e.children){let S=e;if(!f.size)continue;let{width:E,height:m}=f.size,{px:w,py:D}=Ye(n,x);if(D!=b&&(b=D,k=e?.size?.x?e?.size?.x+(-e?.size?.width/2||0):-l,L.debug("New row in layout for block",e.id," and child ",f.id,b)),L.debug(`abc89 layout blocks (child) id: ${f.id} Pos: ${x} (px, py) ${w},${D} (${S?.size?.x},${S?.size?.y}) parent: ${S.id} width: ${E}${l}`),S.size){let O=E/2;f.size.x=k+l+O,L.debug(`abc91 layout blocks (calc) px, pyid:${f.id} startingPos=X${k} new startingPosX${f.size.x} ${O} padding=${l} width=${E} halfWidth=${O} => x:${f.size.x} y:${f.size.y} ${f.widthInColumns} (width * (child?.w || 1)) / 2 ${E*(f?.widthInColumns??1)/2}`),k=f.size.x+O;let N=h.get(D)??0,u=t.get(D)??m;f.size.y=S.size.y-S.size.height/2+N+u/2+l,L.debug(`abc88 layout blocks (calc) px, pyid:${f.id}startingPosX${k}${l}${O}=>x:${f.size.x}y:${f.size.y}${f.widthInColumns}(width * (child?.w || 1)) / 2${E*(f?.widthInColumns??1)/2}`)}f.children&&Ve(f,a,l);let B=f?.widthInColumns??1;n>0&&(B=Math.min(B,n-x%n)),x+=B,L.debug("abc88 columnsPos",f,x)}}L.debug(`layout blocks (<==layoutBlocks) ${e.id} x: ${e?.size?.x} y: ${e?.size?.y} width: ${e?.size?.width}`)}c(Ve,"layoutBlocks");function je(e,{minX:a,minY:l,maxX:n,maxY:g}={minX:0,minY:0,maxX:0,maxY:0}){if(e.size&&e.id!=="root"){let{x:p,y:t,width:h,height:x}=e.size;p-h/2<a&&(a=p-h/2),t-x/2<l&&(l=t-x/2),p+h/2>n&&(n=p+h/2),t+x/2>g&&(g=t+x/2)}if(e.children)for(let p of e.children)({minX:a,minY:l,maxX:n,maxY:g}=je(p,{minX:a,minY:l,maxX:n,maxY:g}));return{minX:a,minY:l,maxX:n,maxY:g}}c(je,"findBounds");function Ge(e){let a=e.getBlock("root");if(!a)return;let l=X()?.block?.padding??8;ge(a,e,0,0,l),Ve(a,e,l),L.debug("getBlocks",JSON.stringify(a,null,2));let{minX:n,minY:g,maxX:p,maxY:t}=je(a),h=t-g,x=p-n;return{x:n,y:g,width:x,height:h}}c(Ge,"layout");function He(e,a,l=!1){let n=e,g="default";(n?.classes?.length||0)>0&&(g=(n?.classes??[]).join(" ")),g=g+" flowchart-label";let p=(n?.classes??[]).flatMap(m=>a.getClasses().get(m)?.styles??[]),t=0,h="rect",x;switch(n.type){case"round":t=5,h="rect";break;case"composite":t=0,h="composite",x=0;break;case"square":h="rect";break;case"diamond":h="question";break;case"hexagon":h="hexagon";break;case"block_arrow":h="block_arrow";break;case"odd":h="rect_left_inv_arrow";break;case"lean_right":h="lean_right";break;case"lean_left":h="lean_left";break;case"trapezoid":h="trapezoid";break;case"inv_trapezoid":h="inv_trapezoid";break;case"rect_left_inv_arrow":h="rect_left_inv_arrow";break;case"circle":h="circle";break;case"ellipse":h="ellipse";break;case"stadium":h="stadium";break;case"subroutine":h="subroutine";break;case"cylinder":h="cylinder";break;case"group":h="rect";break;case"doublecircle":h="doublecircle";break;default:h="rect"}let k=ke(n?.styles??[]),b=n.label,f=n.size??{width:0,height:0,x:0,y:0},S=a.getDiagramId();return{labelStyle:k.labelStyle,shape:h,label:b,labelText:b,rx:t,ry:t,class:g,cssClasses:g,cssStyles:n?.styles??[],cssCompiledStyles:p,style:k.style,id:n.id,domId:S?`${S}-${n.id}`:n.id,isGroup:!1,directions:n.directions,width:f.width||void 0,height:f.height||void 0,wrappingWidth:f.width||Number.POSITIVE_INFINITY,x:f.x,y:f.y,positioned:l,intersect:void 0,padding:x??A()?.block?.padding??0,widthInColumns:n.widthInColumns??1,colorIndex:n.colorIndex,look:A().look}}c(He,"getNodeFromBlock");async function Ct(e,a,l){let n=He(a,l,!1);if(a.type==="group")return;let g=A(),p=await se(e,n,{config:g}),t=p.node()?.getBBox()??{width:0,height:0},h=l.getBlock(n.id);h.size={width:t.width,height:t.height,x:0,y:0,node:p},l.setBlock(h),p.remove()}c(Ct,"calculateBlockSize");async function It(e,a,l){let n=He(a,l,!0);if(l.getBlock(n.id).type!=="space"){let p=A(),t=await se(e,n,{config:p});n.colorIndex!==void 0&&De(t,n.colorIndex,p.theme,p.themeVariables?.borderColorArray),a.intersect=n?.intersect,Ie(n)}}c(It,"insertBlockPositioned");async function he(e,a,l,n){for(let g of a)await n(e,g,l),g.children&&await he(e,g.children,l,n)}c(he,"performOperations");async function Ue(e,a,l){await he(e,a,l,Ct)}c(Ue,"calculateBlockSizes");async function Xe(e,a,l){await he(e,a,l,It)}c(Xe,"insertBlocks");async function qe(e,a,l,n,g){let p=new Te({multigraph:!0,compound:!0});p.setGraph({rankdir:"TB",nodesep:10,ranksep:10,marginx:8,marginy:8});for(let t of l)t.size&&p.setNode(t.id,{width:t.size.width,height:t.size.height,intersect:t.intersect});for(let t of a)if(t.start&&t.end){let h=n.getBlock(t.start),x=n.getBlock(t.end);if(h?.size&&x?.size){let k=h.size,b=x.size,f=[{x:k.x,y:k.y},{x:k.x+(b.x-k.x)/2,y:k.y+(b.y-k.y)/2},{x:b.x,y:b.y}],S=g?`${g}-${t.id}`:t.id,E=t.thickness==="thick"?"edge-thickness-thick":"edge-thickness-normal",m=t.pattern==="dotted"?"edge-pattern-dotted":"edge-pattern-solid",w=`${E} ${m} flowchart-link LS-a1 LE-b1`;Be(e,{...t,id:S,arrowTypeEnd:t.arrowTypeEnd,arrowTypeStart:t.arrowTypeStart,points:f,classes:w},{},"block",p.node(t.start),p.node(t.end),g),t.label&&(await we(e,{...t,label:t.label,labelStyle:"stroke: #333; stroke-width: 1.5px;fill:none;",arrowTypeEnd:t.arrowTypeEnd,arrowTypeStart:t.arrowTypeStart,points:f,classes:w}),_e({...t,x:f[1].x,y:f[1].y},{originalPath:f}))}}}c(qe,"insertEdges");var Nt=c(function(e,a){return a.db.getClasses()},"getClasses"),Tt=c(async function(e,a,l,n){let{securityLevel:g,block:p}=A(),t=n.db;t.setDiagramId(a);let h;g==="sandbox"&&(h=W("#i"+a));let x=g==="sandbox"?W(h.nodes()[0].contentDocument.body):W("body"),k=g==="sandbox"?x.select(`[id="${a}"]`):W(`[id="${a}"]`);Ne(k,A()),Ce(k,["point","circle","cross"],n.type,a);let f=t.getBlocks(),S=t.getBlocksFlat(),E=t.getEdges(),m=k.insert("g").attr("class","block");await Ue(m,f,t);let w=Ge(t);await Xe(m,f,t),await qe(m,E,S,t,a);let D=m.node()?.getBBox(),B=D&&Number.isFinite(D.width)&&Number.isFinite(D.height)?D:w;if(B){let O=Math.max(1,Math.round(.125*(B.width/B.height))),N=B.height+O+10,u=B.width+10,{useMaxWidth:s}=p;be(k,N,u,!!s),L.debug("Here Bounds",w,B),k.attr("viewBox",`${B.x-5} ${B.y-5} ${B.width+10} ${B.height+10}`)}},"draw"),Je={draw:Tt,getClasses:Nt};var kr={parser:ze,db:Ke,renderer:Je,styles:We};export{kr as diagram};