UNPKG

mermaid

Version:

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

121 lines (110 loc) 30.9 kB
import{a as wt}from"./chunk-S4TE5DX6.mjs";import{c as _t,f as Y}from"./chunk-MIE3LDYP.mjs";import{n as kt}from"./chunk-QADHU5CF.mjs";import"./chunk-ZZ52EIBP.mjs";import{$ as Q,Q as J,T as xt,_ as bt,d as ft,e as mt,f as yt,u as st}from"./chunk-FE53TMRB.mjs";import{F as ot,b as w,h as j}from"./chunk-L2B47AAZ.mjs";import{a,d as qt}from"./chunk-QVIEFLGF.mjs";var at=(function(){var e=a(function(b,o,d,l){for(d=d||{},l=b.length;l--;d[b[l]]=o);return d},"o"),t=[6,11,13,14,15,17,19,20,23,24],i=[1,12],r=[1,13],n=[1,14],h=[1,15],c=[1,16],s=[1,19],f=[1,20],g={trace:a(function(){},"trace"),yy:{},symbols_:{error:2,start:3,timeline_header:4,document:5,EOF:6,timeline:7,timeline_lr:8,timeline_td:9,line:10,SPACE:11,statement:12,NEWLINE:13,title:14,acc_title:15,acc_title_value:16,acc_descr:17,acc_descr_value:18,acc_descr_multiline_value:19,section:20,period_statement:21,event_statement:22,period:23,event:24,$accept:0,$end:1},terminals_:{2:"error",6:"EOF",7:"timeline",8:"timeline_lr",9:"timeline_td",11:"SPACE",13:"NEWLINE",14:"title",15:"acc_title",16:"acc_title_value",17:"acc_descr",18:"acc_descr_value",19:"acc_descr_multiline_value",20:"section",23:"period",24:"event"},productions_:[0,[3,3],[4,1],[4,1],[4,1],[5,0],[5,2],[10,2],[10,1],[10,1],[10,1],[12,1],[12,2],[12,2],[12,1],[12,1],[12,1],[12,1],[21,1],[22,1]],performAction:a(function(o,d,l,p,y,u,v){var k=u.length-1;switch(y){case 1:return u[k-1];case 3:p.setDirection("LR");break;case 4:p.setDirection("TD");break;case 5:this.$=[];break;case 6:u[k-1].push(u[k]),this.$=u[k-1];break;case 7:case 8:this.$=u[k];break;case 9:case 10:this.$=[];break;case 11:p.getCommonDb().setDiagramTitle(u[k].substr(6)),this.$=u[k].substr(6);break;case 12:this.$=u[k].trim(),p.getCommonDb().setAccTitle(this.$);break;case 13:case 14:this.$=u[k].trim(),p.getCommonDb().setAccDescription(this.$);break;case 15:p.addSection(u[k].substr(8)),this.$=u[k].substr(8);break;case 18:p.addTask(u[k],0,""),this.$=u[k];break;case 19:p.addEvent(u[k].substr(2)),this.$=u[k];break}},"anonymous"),table:[{3:1,4:2,7:[1,3],8:[1,4],9:[1,5]},{1:[3]},e(t,[2,5],{5:6}),e(t,[2,2]),e(t,[2,3]),e(t,[2,4]),{6:[1,7],10:8,11:[1,9],12:10,13:[1,11],14:i,15:r,17:n,19:h,20:c,21:17,22:18,23:s,24:f},e(t,[2,10],{1:[2,1]}),e(t,[2,6]),{12:21,14:i,15:r,17:n,19:h,20:c,21:17,22:18,23:s,24:f},e(t,[2,8]),e(t,[2,9]),e(t,[2,11]),{16:[1,22]},{18:[1,23]},e(t,[2,14]),e(t,[2,15]),e(t,[2,16]),e(t,[2,17]),e(t,[2,18]),e(t,[2,19]),e(t,[2,7]),e(t,[2,12]),e(t,[2,13])],defaultActions:{},parseError:a(function(o,d){if(d.recoverable)this.trace(o);else{var l=new Error(o);throw l.hash=d,l}},"parseError"),parse:a(function(o){var d=this,l=[0],p=[],y=[null],u=[],v=this.table,k="",H=0,V=0,P=0,O=2,L=1,B=u.slice.call(arguments,1),T=Object.create(this.lexer),C={yy:{}};for(var R in this.yy)Object.prototype.hasOwnProperty.call(this.yy,R)&&(C.yy[R]=this.yy[R]);T.setInput(o,C.yy),C.yy.lexer=T,C.yy.parser=this,typeof T.yylloc>"u"&&(T.yylloc={});var D=T.yylloc;u.push(D);var $=T.options&&T.options.ranges;typeof C.yy.parseError=="function"?this.parseError=C.yy.parseError:this.parseError=Object.getPrototypeOf(this).parseError;function _(W){l.length=l.length-2*W,y.length=y.length-W,u.length=u.length-W}a(_,"popStack");function E(){var W;return W=p.pop()||T.lex()||L,typeof W!="number"&&(W instanceof Array&&(p=W,W=p.pop()),W=d.symbols_[W]||W),W}a(E,"lex");for(var S,I,A,N,rt,X,z={},Z,F,gt,q;;){if(A=l[l.length-1],this.defaultActions[A]?N=this.defaultActions[A]:((S===null||typeof S>"u")&&(S=E()),N=v[A]&&v[A][S]),typeof N>"u"||!N.length||!N[0]){var it="";q=[];for(Z in v[A])this.terminals_[Z]&&Z>O&&q.push("'"+this.terminals_[Z]+"'");T.showPosition?it="Parse error on line "+(H+1)+`: `+T.showPosition()+` Expecting `+q.join(", ")+", got '"+(this.terminals_[S]||S)+"'":it="Parse error on line "+(H+1)+": Unexpected "+(S==L?"end of input":"'"+(this.terminals_[S]||S)+"'"),this.parseError(it,{text:T.match,token:this.terminals_[S]||S,line:T.yylineno,loc:D,expected:q})}if(N[0]instanceof Array&&N.length>1)throw new Error("Parse Error: multiple actions possible at state: "+A+", token: "+S);switch(N[0]){case 1:l.push(S),y.push(T.yytext),u.push(T.yylloc),l.push(N[1]),S=null,I?(S=I,I=null):(V=T.yyleng,k=T.yytext,H=T.yylineno,D=T.yylloc,P>0&&P--);break;case 2:if(F=this.productions_[N[1]][1],z.$=y[y.length-F],z._$={first_line:u[u.length-(F||1)].first_line,last_line:u[u.length-1].last_line,first_column:u[u.length-(F||1)].first_column,last_column:u[u.length-1].last_column},$&&(z._$.range=[u[u.length-(F||1)].range[0],u[u.length-1].range[1]]),X=this.performAction.apply(z,[k,V,H,C.yy,N[1],y,u].concat(B)),typeof X<"u")return X;F&&(l=l.slice(0,-1*F*2),y=y.slice(0,-1*F),u=u.slice(0,-1*F)),l.push(this.productions_[N[1]][0]),y.push(z.$),u.push(z._$),gt=v[l[l.length-2]][l[l.length-1]],l.push(gt);break;case 3:return!0}}return!0},"parse")},x=(function(){var b={EOF:1,parseError:a(function(d,l){if(this.yy.parser)this.yy.parser.parseError(d,l);else throw new Error(d)},"parseError"),setInput:a(function(o,d){return this.yy=d||this.yy||{},this._input=o,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:a(function(){var o=this._input[0];this.yytext+=o,this.yyleng++,this.offset++,this.match+=o,this.matched+=o;var d=o.match(/(?:\r\n?|\n).*/g);return d?(this.yylineno++,this.yylloc.last_line++):this.yylloc.last_column++,this.options.ranges&&this.yylloc.range[1]++,this._input=this._input.slice(1),o},"input"),unput:a(function(o){var d=o.length,l=o.split(/(?:\r\n?|\n)/g);this._input=o+this._input,this.yytext=this.yytext.substr(0,this.yytext.length-d),this.offset-=d;var p=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),l.length-1&&(this.yylineno-=l.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:l?(l.length===p.length?this.yylloc.first_column:0)+p[p.length-l.length].length-l[0].length:this.yylloc.first_column-d},this.options.ranges&&(this.yylloc.range=[y[0],y[0]+this.yyleng-d]),this.yyleng=this.yytext.length,this},"unput"),more:a(function(){return this._more=!0,this},"more"),reject:a(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:a(function(o){this.unput(this.match.slice(o))},"less"),pastInput:a(function(){var o=this.matched.substr(0,this.matched.length-this.match.length);return(o.length>20?"...":"")+o.substr(-20).replace(/\n/g,"")},"pastInput"),upcomingInput:a(function(){var o=this.match;return o.length<20&&(o+=this._input.substr(0,20-o.length)),(o.substr(0,20)+(o.length>20?"...":"")).replace(/\n/g,"")},"upcomingInput"),showPosition:a(function(){var o=this.pastInput(),d=new Array(o.length+1).join("-");return o+this.upcomingInput()+` `+d+"^"},"showPosition"),test_match:a(function(o,d){var l,p,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))),p=o[0].match(/(?:\r\n?|\n).*/g),p&&(this.yylineno+=p.length),this.yylloc={first_line:this.yylloc.last_line,last_line:this.yylineno+1,first_column:this.yylloc.last_column,last_column:p?p[p.length-1].length-p[p.length-1].match(/\r?\n?/)[0].length:this.yylloc.last_column+o[0].length},this.yytext+=o[0],this.match+=o[0],this.matches=o,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(o[0].length),this.matched+=o[0],l=this.performAction.call(this,this.yy,this,d,this.conditionStack[this.conditionStack.length-1]),this.done&&this._input&&(this.done=!1),l)return l;if(this._backtrack){for(var u in y)this[u]=y[u];return!1}return!1},"test_match"),next:a(function(){if(this.done)return this.EOF;this._input||(this.done=!0);var o,d,l,p;this._more||(this.yytext="",this.match="");for(var y=this._currentRules(),u=0;u<y.length;u++)if(l=this._input.match(this.rules[y[u]]),l&&(!d||l[0].length>d[0].length)){if(d=l,p=u,this.options.backtrack_lexer){if(o=this.test_match(l,y[u]),o!==!1)return o;if(this._backtrack){d=!1;continue}else return!1}else if(!this.options.flex)break}return d?(o=this.test_match(d,y[p]),o!==!1?o:!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:a(function(){var d=this.next();return d||this.lex()},"lex"),begin:a(function(d){this.conditionStack.push(d)},"begin"),popState:a(function(){var d=this.conditionStack.length-1;return d>0?this.conditionStack.pop():this.conditionStack[0]},"popState"),_currentRules:a(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:a(function(d){return d=this.conditionStack.length-1-Math.abs(d||0),d>=0?this.conditionStack[d]:"INITIAL"},"topState"),pushState:a(function(d){this.begin(d)},"pushState"),stateStackSize:a(function(){return this.conditionStack.length},"stateStackSize"),options:{"case-insensitive":!0},performAction:a(function(d,l,p,y){var u=y;switch(p){case 0:break;case 1:break;case 2:return 13;case 3:break;case 4:break;case 5:return 8;case 6:return 9;case 7:return 7;case 8:return 14;case 9:return this.begin("acc_title"),15;break;case 10:return this.popState(),"acc_title_value";break;case 11:return this.begin("acc_descr"),17;break;case 12:return this.popState(),"acc_descr_value";break;case 13:this.begin("acc_descr_multiline");break;case 14:this.popState();break;case 15:return"acc_descr_multiline_value";case 16:return 20;case 17:return 24;case 18:return 23;case 19:return 6;case 20:return"INVALID"}},"anonymous"),rules:[/^(?:%(?!\{)[^\n]*)/i,/^(?:[^\}]%%[^\n]*)/i,/^(?:[\n]+)/i,/^(?:\s+)/i,/^(?:#[^\n]*)/i,/^(?:timeline[ \t]+LR\b)/i,/^(?:timeline[ \t]+TD\b)/i,/^(?:timeline\b)/i,/^(?:title\s[^\n]+)/i,/^(?:accTitle\s*:\s*)/i,/^(?:(?!\n||)*[^\n]*)/i,/^(?:accDescr\s*:\s*)/i,/^(?:(?!\n||)*[^\n]*)/i,/^(?:accDescr\s*\{\s*)/i,/^(?:[\}])/i,/^(?:[^\}]*)/i,/^(?:section\s[^:\n]+)/i,/^(?::\s(?:[^:\n]|:(?!\s))+)/i,/^(?:[^#:\n]+)/i,/^(?:$)/i,/^(?:.)/i],conditions:{acc_descr_multiline:{rules:[14,15],inclusive:!1},acc_descr:{rules:[12],inclusive:!1},acc_title:{rules:[10],inclusive:!1},INITIAL:{rules:[0,1,2,3,4,5,6,7,8,9,11,13,16,17,18,19,20],inclusive:!0}}};return b})();g.lexer=x;function m(){this.yy={}}return a(m,"Parser"),m.prototype=g,g.Parser=m,new m})();at.parser=at;var vt=at;var ht={};qt(ht,{addEvent:()=>Ct,addSection:()=>It,addTask:()=>At,addTaskOrg:()=>Bt,clear:()=>$t,default:()=>Jt,getCommonDb:()=>Et,getDirection:()=>Ht,getSections:()=>Mt,getTasks:()=>Lt,setDirection:()=>Nt});var K="",Tt=0,ct="LR",lt=[],tt=[],U=[],Et=a(()=>bt,"getCommonDb"),$t=a(function(){lt.length=0,tt.length=0,K="",U.length=0,ct="LR",xt()},"clear"),Nt=a(function(e){ct=e},"setDirection"),Ht=a(function(){return ct},"getDirection"),It=a(function(e){K=e,lt.push(e)},"addSection"),Mt=a(function(){return lt},"getSections"),Lt=a(function(){let e=St(),t=100,i=0;for(;!e&&i<t;)e=St(),i++;return tt.push(...U),tt},"getTasks"),At=a(function(e,t,i){let r={id:Tt++,section:K,type:K,task:e,score:t||0,events:i?[i]:[]};U.push(r)},"addTask"),Ct=a(function(e){U.find(i=>i.id===Tt-1).events.push(e)},"addEvent"),Bt=a(function(e){let t={section:K,type:K,description:e,task:e,classes:[]};tt.push(t)},"addTaskOrg"),St=a(function(){let e=a(function(i){return U[i].processed},"compileTask"),t=!0;for(let[i,r]of U.entries())e(i),t=t&&r.processed;return t},"compileTasks"),Jt={clear:$t,getCommonDb:Et,getDirection:Ht,setDirection:Nt,addSection:It,getSections:Mt,getTasks:Lt,addTask:At,addTaskOrg:Bt,addEvent:Ct};var Wt=0,et=a(function(e,t){let i=e.append("rect");return i.attr("x",t.x),i.attr("y",t.y),i.attr("fill",t.fill),i.attr("stroke",t.stroke),i.attr("width",t.width),i.attr("height",t.height),i.attr("rx",t.rx),i.attr("ry",t.ry),t.class!==void 0&&i.attr("class",t.class),i},"drawRect"),Qt=a(function(e,t){let r=e.append("circle").attr("cx",t.cx).attr("cy",t.cy).attr("class","face").attr("r",15).attr("stroke-width",2).attr("overflow","visible"),n=e.append("g");n.append("circle").attr("cx",t.cx-15/3).attr("cy",t.cy-15/3).attr("r",1.5).attr("stroke-width",2).attr("fill","#666").attr("stroke","#666"),n.append("circle").attr("cx",t.cx+15/3).attr("cy",t.cy-15/3).attr("r",1.5).attr("stroke-width",2).attr("fill","#666").attr("stroke","#666");function h(f){let g=ot().startAngle(Math.PI/2).endAngle(3*(Math.PI/2)).innerRadius(7.5).outerRadius(6.8181818181818175);f.append("path").attr("class","mouth").attr("d",g).attr("transform","translate("+t.cx+","+(t.cy+2)+")")}a(h,"smile");function c(f){let g=ot().startAngle(3*Math.PI/2).endAngle(5*(Math.PI/2)).innerRadius(7.5).outerRadius(6.8181818181818175);f.append("path").attr("class","mouth").attr("d",g).attr("transform","translate("+t.cx+","+(t.cy+7)+")")}a(c,"sad");function s(f){f.append("line").attr("class","mouth").attr("stroke",2).attr("x1",t.cx-5).attr("y1",t.cy+7).attr("x2",t.cx+5).attr("y2",t.cy+7).attr("class","mouth").attr("stroke-width","1px").attr("stroke","#666")}return a(s,"ambivalent"),t.score>3?h(n):t.score<3?c(n):s(n),r},"drawFace"),Yt=a(function(e,t){let i=e.append("circle");return i.attr("cx",t.cx),i.attr("cy",t.cy),i.attr("class","actor-"+t.pos),i.attr("fill",t.fill),i.attr("stroke",t.stroke),i.attr("r",t.r),i.class!==void 0&&i.attr("class",i.class),t.title!==void 0&&i.append("title").text(t.title),i},"drawCircle"),Vt=a(function(e,t){let i=t.text.replace(/<br\s*\/?>/gi," "),r=e.append("text");r.attr("x",t.x),r.attr("y",t.y),r.attr("class","legend"),r.style("text-anchor",t.anchor),t.class!==void 0&&r.attr("class",t.class);let n=r.append("tspan");return n.attr("x",t.x+t.textMargin*2),n.text(i),r},"drawText"),te=a(function(e,t){function i(n,h,c,s,f){return n+","+h+" "+(n+c)+","+h+" "+(n+c)+","+(h+s-f)+" "+(n+c-f*1.2)+","+(h+s)+" "+n+","+(h+s)}a(i,"genPoints");let r=e.append("polygon");r.attr("points",i(t.x,t.y,50,20,7)),r.attr("class","labelBox"),t.y=t.y+t.labelMargin,t.x=t.x+.5*t.labelMargin,Vt(e,t)},"drawLabel"),ee=a(function(e,t,i){let r=e.append("g"),n=ut();n.x=t.x,n.y=t.y,n.fill=t.fill,n.width=i.width,n.height=i.height,n.class="journey-section section-type-"+t.num,n.rx=3,n.ry=3,et(r,n),Pt(i)(t.text,r,n.x,n.y,n.width,n.height,{class:"journey-section section-type-"+t.num},i,t.colour)},"drawSection"),dt=-1,ne=a(function(e,t,i,r){let n=t.x+i.width/2,h=e.append("g");dt++,h.append("line").attr("id",r+"-task"+dt).attr("x1",n).attr("y1",t.y).attr("x2",n).attr("y2",450).attr("class","task-line").attr("stroke-width","1px").attr("stroke-dasharray","4 2").attr("stroke","#666"),Qt(h,{cx:n,cy:300+(5-t.score)*30,score:t.score});let s=ut();s.x=t.x,s.y=t.y,s.fill=t.fill,s.width=i.width,s.height=i.height,s.class="task task-type-"+t.num,s.rx=3,s.ry=3,et(h,s),Pt(i)(t.task,h,s.x,s.y,s.width,s.height,{class:"task"},i,t.colour)},"drawTask"),re=a(function(e,t){et(e,{x:t.startx,y:t.starty,width:t.stopx-t.startx,height:t.stopy-t.starty,fill:t.fill,class:"rect"}).lower()},"drawBackgroundRect"),ie=a(function(){return{x:0,y:0,fill:void 0,"text-anchor":"start",width:100,height:100,textMargin:0,rx:0,ry:0}},"getTextObj"),ut=a(function(){return{x:0,y:0,width:100,anchor:"start",height:100,rx:0,ry:0}},"getNoteRect"),Pt=(function(){function e(n,h,c,s,f,g,x,m){let b=h.append("text").attr("x",c+f/2).attr("y",s+g/2+5).style("font-color",m).style("text-anchor","middle").text(n);r(b,x)}a(e,"byText");function t(n,h,c,s,f,g,x,m,b){let{taskFontSize:o,taskFontFamily:d}=m,l=n.split(/<br\s*\/?>/gi);for(let p=0;p<l.length;p++){let y=p*o-o*(l.length-1)/2,u=h.append("text").attr("x",c+f/2).attr("y",s).attr("fill",b).style("text-anchor","middle").style("font-size",o).style("font-family",d);u.append("tspan").attr("x",c+f/2).attr("dy",y).text(l[p]),u.attr("y",s+g/2).attr("dominant-baseline","central").attr("alignment-baseline","central"),r(u,x)}}a(t,"byTspan");function i(n,h,c,s,f,g,x,m){let b=h.append("switch"),d=b.append("foreignObject").attr("x",c).attr("y",s).attr("width",f).attr("height",g).attr("position","fixed").append("xhtml:div").style("display","table").style("height","100%").style("width","100%");d.append("div").attr("class","label").style("display","table-cell").style("text-align","center").style("vertical-align","middle").text(n),t(n,b,c,s,f,g,x,m),r(d,x)}a(i,"byFo");function r(n,h){for(let c in h)c in h&&n.attr(c,h[c])}return a(r,"_setTextAttrs"),function(n){return n.textPlacement==="fo"?i:n.textPlacement==="old"?e:t}})(),se=a(function(e,t){Wt=0,dt=-1,e.append("defs").append("marker").attr("id",t+"-arrowhead").attr("refX",5).attr("refY",2).attr("markerWidth",6).attr("markerHeight",4).attr("orient","auto").append("path").attr("d","M 0,0 V 4 L6,2 Z")},"initGraphics");function Rt(e,t){e.each(function(){var i=j(this),r=i.text().split(/(\s+|<br>)/).reverse(),n,h=[],c=1.1,s=i.attr("y"),f=parseFloat(i.attr("dy")),g=i.text(null).append("tspan").attr("x",0).attr("y",s).attr("dy",f+"em");for(let x=0;x<r.length;x++)n=r[r.length-1-x],h.push(n),g.text(h.join(" ").trim()),(g.node().getComputedTextLength()>t||n==="<br>")&&(h.pop(),g.text(h.join(" ").trim()),n==="<br>"?h=[""]:h=[n],g=i.append("tspan").attr("x",0).attr("y",s).attr("dy",c+"em").text(n))})}a(Rt,"wrap");var oe=a(function(e,t,i,r,n,h=!1){let{theme:c,look:s}=r,f=c?.includes("redux"),g=r?.themeVariables?.THEME_COLOR_LIMIT??12,x=i%g-1,m=e.append("g");t.section=x,m.attr("class",(t.class?t.class+" ":"")+"timeline-node "+("section-"+x));let b=m.append("g"),o=m.append("g"),l=o.append("text").text(t.descr).attr("dy","1em").attr("alignment-baseline","middle").attr("dominant-baseline","middle").attr("text-anchor","middle").call(Rt,t.width).node().getBBox(),p=r.fontSize?.replace?r.fontSize.replace("px",""):r.fontSize;if(t.height=l.height+p*1.1*.5+t.padding,t.height=Math.max(t.height,t.maxHeight),t.width=t.width+2*t.padding,o.attr("transform","translate("+t.width/2+", "+t.padding/2+")"),f&&o.attr("transform",`translate(${t.width/2}, ${h?t.padding/2+3:t.padding})`),ce(b,t,x,n,r),s==="neo"&&(m.attr("data-look","neo"),f)){let y=c.includes("dark"),u=e.node()?.ownerSVGElement??e.node(),v=j(u),k=v.attr("id")??"",H=k?`${k}-drop-shadow`:"drop-shadow";if(v.select(`#${H}`).empty()){let V=v.select("defs");(V.empty()?v.append("defs"):V).append("filter").attr("id",H).attr("height","130%").attr("width","130%").append("feDropShadow").attr("dx","4").attr("dy","4").attr("stdDeviation",0).attr("flood-opacity",y?"0.2":"0.06").attr("flood-color",y?"#FFFFFF":"#000000")}}return t},"drawNode"),ae=a(function(e,t,i){let r=e.append("g"),h=r.append("text").text(t.descr).attr("dy","1em").attr("alignment-baseline","middle").attr("dominant-baseline","middle").attr("text-anchor","middle").call(Rt,t.width).node().getBBox(),c=i.fontSize?.replace?i.fontSize.replace("px",""):i.fontSize;return r.remove(),h.height+c*1.1*.5+t.padding},"getVirtualNodeHeight"),ce=a(function(e,t,i,r,n){let{theme:h}=n,c=h?.includes("redux")?0:5,s=5,f=c>0?`M0 ${t.height-s} v${-t.height+2*s} q0,-${c},${c},-${c} h${t.width-2*s} q${c},0,${c},${c} v${t.height-s} H0 Z`:`M0 ${t.height-s} v${-(t.height-s)} h${t.width} v${t.height} H0 Z`;e.append("path").attr("id",r+"-node-"+Wt++).attr("class","node-bkg node-"+t.type).attr("d",f),h?.includes("redux")||e.append("line").attr("class","node-line-"+i).attr("x1",0).attr("y1",t.height).attr("x2",t.width).attr("y2",t.height)},"defaultBkg"),M={drawRect:et,drawCircle:Yt,drawSection:ee,drawText:Vt,drawLabel:te,drawTask:ne,drawBackgroundRect:re,getTextObj:ie,getNoteRect:ut,initGraphics:se,drawNode:oe,getVirtualNodeHeight:ae};var le=a(function(e,t,i,r){let n=Q(),{look:h,theme:c,themeVariables:s}=n,{useGradient:f,gradientStart:g,gradientStop:x}=s,m=n.timeline?.leftMargin??50;w.debug("timeline",r.db);let b=n.securityLevel,o;b==="sandbox"&&(o=j("#i"+t));let l=(b==="sandbox"?j(o.nodes()[0].contentDocument.body):j("body")).select("#"+t);l.append("g");let p=r.db.getTasks(),y=r.db.getCommonDb().getDiagramTitle();w.debug("task",p),M.initGraphics(l,t);let u=r.db.getSections();w.debug("sections",u);let v=0,k=0,H=0,V=0,P=50+m,O=50;V=50;let L=0,B=!0;u.forEach(function($){let _={number:L,descr:$,section:L,width:150,padding:20,maxHeight:v},E=M.getVirtualNodeHeight(l,_,n);w.debug("sectionHeight before draw",E),v=Math.max(v,E+20)});let T=0,C=0;w.debug("tasks.length",p.length);for(let[$,_]of p.entries()){let E={number:$,descr:_,section:_.section,width:150,padding:20,maxHeight:k},S=M.getVirtualNodeHeight(l,E,n);w.debug("taskHeight before draw",S),k=Math.max(k,S+20),T=Math.max(T,_.events.length);let I=0;for(let A of _.events){let N={descr:A,section:_.section,number:_.section,width:150,padding:20,maxHeight:50};I+=M.getVirtualNodeHeight(l,N,n)}_.events.length>0&&(I+=(_.events.length-1)*10),C=Math.max(C,I)}w.debug("maxSectionHeight before draw",v),w.debug("maxTaskHeight before draw",k),u&&u.length>0?u.forEach($=>{let _=p.filter(A=>A.section===$),E={number:L,descr:$,section:L,width:200*Math.max(_.length,1)-50,padding:20,maxHeight:v};w.debug("sectionNode",E);let S=l.append("g"),I=M.drawNode(S,E,L,n,t);w.debug("sectionNode output",I),S.attr("transform",`translate(${P}, ${V})`),O+=v+50,_.length>0&&Ft(l,_,L,P,O,k,n,T,C,v,!1,t),P+=200*Math.max(_.length,1),O=V,L++}):(B=!1,Ft(l,p,L,P,O,k,n,T,C,v,!0,t));let R=l.node().getBBox();if(w.debug("bounds",R),y&&l.append("text").text(y).attr("x",h==="neo"?R.x*2+m:R.width/2-m).attr("font-size","4ex").attr("font-weight","bold").attr("y",20),H=B?v+k+150:k+100,l.append("g").attr("class","lineWrapper").append("line").attr("x1",m).attr("y1",H).attr("x2",R.width+3*m).attr("y2",H).attr("stroke-width",4).attr("stroke","black").attr("marker-end",`url(#${t}-arrowhead)`),h==="neo"&&f&&c!=="neutral"){let $=l.select("defs"),E=($.empty()?l.append("defs"):$).append("linearGradient").attr("id",l.attr("id")+"-gradient").attr("gradientUnits","objectBoundingBox").attr("x1","0%").attr("y1","0%").attr("x2","100%").attr("y2","0%");E.append("stop").attr("offset","0%").attr("stop-color",g).attr("stop-opacity",1),E.append("stop").attr("offset","100%").attr("stop-color",x).attr("stop-opacity",1)}J(void 0,l,n.timeline?.padding??50,n.timeline?.useMaxWidth??!1)},"draw"),Ft=a(function(e,t,i,r,n,h,c,s,f,g,x,m){for(let b of t){let o={descr:b.task,section:i,number:i,width:150,padding:20,maxHeight:h};w.debug("taskNode",o);let d=e.append("g").attr("class","taskWrapper"),p=M.drawNode(d,o,i,c,m).height;if(w.debug("taskHeight after draw",p),d.attr("transform",`translate(${r}, ${n})`),h=Math.max(h,p),b.events){let y=e.append("g").attr("class","lineWrapper"),u=h;n+=100,u=u+he(e,b.events,i,r,n,c,m),n-=100,y.append("line").attr("x1",r+190/2).attr("y1",n+h).attr("x2",r+190/2).attr("y2",n+h+100+f+100).attr("stroke-width",2).attr("stroke","black").attr("marker-end",`url(#${m}-arrowhead)`).attr("stroke-dasharray","5,5")}r=r+200,x&&!c.timeline?.disableMulticolor&&i++}n=n-10},"drawTasks"),he=a(function(e,t,i,r,n,h,c){let s=0,f=n;n=n+100;for(let g of t){let x={descr:g,section:i,number:i,width:150,padding:20,maxHeight:50};w.debug("eventNode",x);let m=e.append("g").attr("class","eventWrapper"),o=M.drawNode(m,x,i,h,c,!0).height;s=s+o,m.attr("transform",`translate(${r}, ${n})`),n=n+10+o}return n=f,s},"drawEvents"),Gt={setConf:a(()=>{},"setConf"),draw:le};var nt=200,G=5,de=nt+G*2,pt=nt+100,ue=pt+G*2,jt=10,pe=0,zt=20,Kt=20,Ot=30,Ut=50,ge=a(function(e,t,i,r){let n=Q(),h=n.timeline?.leftMargin??50;w.debug("timeline",r.db);let c=wt(t);c.append("g");let s=r.db.getTasks(),f=r.db.getCommonDb().getDiagramTitle();w.debug("task",s),M.initGraphics(c);let g=r.db.getSections();w.debug("sections",g);let x=0,m=0,b=50+h,o=50,d=o,l=b,p=de+Kt,y=ue+Ut,u=l+p,v=0,k=g&&g.length>0,H=k?u:b+p,V=Math.max(50,p+y-G*2);g.forEach(function($){let _={number:v,descr:$,section:v,width:V,padding:G,maxHeight:x},E=M.getVirtualNodeHeight(c,_,n);w.debug("sectionHeight before draw",E),x=Math.max(x,E)});let P=0;w.debug("tasks.length",s.length);for(let[$,_]of s.entries()){let E={number:$,descr:_,section:_.section,width:nt,padding:G,maxHeight:m},S=M.getVirtualNodeHeight(c,E,n);w.debug("taskHeight before draw",S),m=Math.max(m,S);let I=0;for(let A of _.events){let N={descr:A,section:_.section,number:_.section,width:pt,padding:G,maxHeight:50};I+=M.getVirtualNodeHeight(c,N,n)}_.events.length>0&&(I+=(_.events.length-1)*jt),P=Math.max(P,I)+pe}w.debug("maxSectionHeight before draw",x),w.debug("maxTaskHeight before draw",m);let L=Math.max(m,P)+Ot;k?g.forEach($=>{let _=s.filter(z=>z.section===$),E={number:v,descr:$,section:v,width:V,padding:G,maxHeight:x};w.debug("sectionNode",E);let S=c.append("g"),I=M.drawNode(S,E,v,n);w.debug("sectionNode output",I);let A=H-p;S.attr("transform",`translate(${A}, ${o})`);let N=o+I.height+zt;_.length>0&&Dt(c,_,v,H,N,m,n,L,!1);let rt=_.length,X=I.height+zt+L*Math.max(rt,1)-(rt>0?Ot*2:0);o+=X,v++}):Dt(c,s,v,H,o,m,n,L,!0);let B=c.node()?.getBBox();if(!B)throw new Error("bbox not found");if(w.debug("bounds",B),f){if(c.append("text").text(f).attr("x",B.width/2-h).attr("font-size","4ex").attr("font-weight","bold").attr("y",20),B=c.node()?.getBBox(),!B)throw new Error("bbox not found");w.debug("bounds after title",B)}let[T]=kt(n.fontSize),C=(T??16)*2,R=(T??16)*.5+20,D=c.append("g").attr("class","lineWrapper");D.append("line").attr("x1",H).attr("y1",d-C).attr("x2",H).attr("y2",B.y+B.height+R).attr("stroke-width",4).attr("stroke","black").attr("marker-end","url(#arrowhead)"),D.lower(),J(void 0,c,n.timeline?.padding??50,n.timeline?.useMaxWidth??!1)},"draw"),Dt=a(function(e,t,i,r,n,h,c,s,f){for(let g of t){let x={descr:g.task,section:i,number:i,width:nt,padding:G,maxHeight:h};w.debug("taskNode",x);let m=e.append("g").attr("class","taskWrapper"),b=M.drawNode(m,x,i,c),o=b.height;w.debug("taskHeight after draw",o);let d=r-Kt-b.width;if(m.attr("transform",`translate(${d}, ${n})`),h=Math.max(h,o),g.events&&g.events.length>0){let l=n,p=r+Ut;fe(e,g.events,i,r,p,l,c)}n=n+s,f&&!c.timeline?.disableMulticolor&&i++}},"drawTasks"),fe=a(function(e,t,i,r,n,h,c){let s=h;for(let f of t){let g={descr:f,section:i,number:i,width:pt,padding:G,maxHeight:0};w.debug("eventNode",g);let x=e.append("g").attr("class","eventWrapper"),b=M.drawNode(x,g,i,c).height;x.attr("transform",`translate(${n}, ${s})`);let o=e.append("g").attr("class","lineWrapper"),d=s+b/2;o.append("line").attr("x1",r).attr("y1",d).attr("x2",n).attr("y2",d).attr("stroke-width",2).attr("stroke","black").attr("marker-end","url(#arrowhead)").attr("stroke-dasharray","5,5"),s=s+b+jt}return s-h},"drawEvents"),Xt={setConf:a(()=>{},"setConf"),draw:ge};var me=a(e=>{let{theme:t}=st(),i=t?.includes("dark"),r=_t(t,e.borderColorArray),n=e.svgId?.replace(/^#/,"")??"",h=n?`url(#${n}-drop-shadow)`:e.dropShadow??"none",c="";for(let s=0;s<Y(e.THEME_COLOR_LIMIT);s++){let f=`${17-3*s}`,g=r?e.borderColorArray[s%e.borderColorArray.length]:void 0,x=g??e.mainBkg,m=g??e.nodeBorder;c+=` .section-${s-1} rect, .section-${s-1} path, .section-${s-1} circle { fill: ${i&&r?e.mainBkg:x}; stroke: ${m}; stroke-width: ${e.strokeWidth}; filter: ${h}; } .section-${s-1} text { fill: ${e.nodeBorder}; font-weight: ${e.fontWeight} } .node-icon-${s-1} { font-size: 40px; color: ${e["cScaleLabel"+s]}; } .section-edge-${s-1} { stroke: ${e["cScale"+s]}; } .edge-depth-${s-1} { stroke-width: ${f}; } .section-${s-1} line { stroke: ${e["cScaleInv"+s]}; stroke-width: 3; } .lineWrapper line { stroke: ${e.nodeBorder}; stroke-width:${e.strokeWidth} } .disabled, .disabled circle, .disabled text { fill: ${e.tertiaryColor??"lightgray"}; } .disabled text { fill: ${e.clusterBorder??"#efefef"}; } `}return c},"genReduxSections"),ye=a(e=>{let t="",i=Y(e.THEME_COLOR_LIMIT);for(let r=0;r<i;r++)e["lineColor"+r]=e["lineColor"+r]??e["cScaleInv"+r],ft(e["lineColor"+r])?e["lineColor"+r]=mt(e["lineColor"+r],20):e["lineColor"+r]=yt(e["lineColor"+r],20);for(let r=0;r<i;r++){let n=""+(17-3*r);t+=` .section-${r-1} rect, .section-${r-1} path, .section-${r-1} circle, .section-${r-1} path { fill: ${e["cScale"+r]}; } .section-${r-1} text { fill: ${e["cScaleLabel"+r]}; } .node-icon-${r-1} { font-size: 40px; color: ${e["cScaleLabel"+r]}; } .section-edge-${r-1}{ stroke: ${e["cScale"+r]}; } .edge-depth-${r-1}{ stroke-width: ${n}; } .section-${r-1} line { stroke: ${e["cScaleInv"+r]} ; stroke-width: 3; } .lineWrapper line{ stroke: ${e["cScaleLabel"+r]} ; } .disabled, .disabled circle, .disabled text { fill: ${e.tertiaryColor??"lightgray"}; } .disabled text { fill: ${e.clusterBorder??"#efefef"}; } `}return t},"genSections"),xe=a(e=>{let{theme:t}=st(),i=t?.includes("redux"),r=t==="neutral",n=e.svgId?.replace(/^#/,"")??"",h="";if(e.useGradient&&n&&e.THEME_COLOR_LIMIT&&!r){let c=Y(e.THEME_COLOR_LIMIT);for(let s=0;s<c;s++)h+=` .section-${s-1}[data-look="neo"] rect, .section-${s-1}[data-look="neo"] path, .section-${s-1}[data-look="neo"] circle { fill: ${e.mainBkg}; stroke: url(#${n}-gradient); stroke-width: 2; } .section-${s-1}[data-look="neo"] line { stroke: url(#${n}-gradient); stroke-width: 2; }`}return` .edge { stroke-width: 3; } ${i?me(e):ye(e)} ${h} .section-root rect, .section-root path, .section-root circle { fill: ${e.git0}; } .section-root text { fill: ${e.gitBranchLabel0}; } .icon-container { height:100%; display: flex; justify-content: center; align-items: center; } .edge { fill: none; } .eventWrapper { filter: brightness(120%); } `},"getStyles"),Zt=xe;var be={setConf:a(()=>{},"setConf"),draw:a((e,t,i,r)=>(r?.db?.getDirection?.()??"LR")==="TD"?Xt.draw(e,t,i,r):Gt.draw(e,t,i,r),"draw")},qe={db:ht,renderer:be,parser:vt,styles:Zt};export{qe as diagram};