(e)
| 4 | `+this.showPosition(),{text:"",token:null,line:this.yylineno});return this},"reject"),less:h(function(o){this.unput(this.match.slice(o))},"less"),pastInput:h(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:h(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:h(function(){var o=this.pastInput(),c=new Array(o.length+1).join("-");return o+this.upcomingInput()+` |
| 5 | `+c+"^"},"showPosition"),test_match:h(function(o,c){var n,g,b;if(this.options.backtrack_lexer&&(b={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&&(b.yylloc.range=this.yylloc.range.slice(0))),g=o[0].match(/(?:\r\n?|\n).*/g),g&&(this.yylineno+=g.length),this.yylloc={first_line:this.yylloc.last_line,last_line:this.yylineno+1,first_column:this.yylloc.last_column,last_column:g?g[g.length-1].length-g[g.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],n=this.performAction.call(this,this.yy,this,c,this.conditionStack[this.conditionStack.length-1]),this.done&&this._input&&(this.done=!1),n)return n;if(this._backtrack){for(var i in b)this[i]=b[i];return!1}return!1},"test_match"),next:h(function(){if(this.done)return this.EOF;this._input||(this.done=!0);var o,c,n,g;this._more||(this.yytext="",this.match="");for(var b=this._currentRules(),i=0;i<b.length;i++)if(n=this._input.match(this.rules[b[i]]),n&&(!c||n[0].length>c[0].length)){if(c=n,g=i,this.options.backtrack_lexer){if(o=this.test_match(n,b[i]),o!==!1)return o;if(this._backtrack){c=!1;continue}else return!1}else if(!this.options.flex)break}return c?(o=this.test_match(c,b[g]),o!==!1?o:!1):this._input===""?this.EOF:this.parseError("Lexical error on line "+(this.yylineno+1)+`. Unrecognized text. |
| 6 | `+this.showPosition(),{text:"",token:null,line:this.yylineno})},"next"),lex:h(function(){var c=this.next();return c||this.lex()},"lex"),begin:h(function(c){this.conditionStack.push(c)},"begin"),popState:h(function(){var c=this.conditionStack.length-1;return c>0?this.conditionStack.pop():this.conditionStack[0]},"popState"),_currentRules:h(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:h(function(c){return c=this.conditionStack.length-1-Math.abs(c||0),c>=0?this.conditionStack[c]:"INITIAL"},"topState"),pushState:h(function(c){this.begin(c)},"pushState"),stateStackSize:h(function(){return this.conditionStack.length},"stateStackSize"),options:{"case-insensitive":!0},performAction:h(function(c,n,g,b){var i=b;switch(g){case 0:return 38;case 1:return 40;case 2:return 39;case 3:return 44;case 4:return 51;case 5:return 52;case 6:return 53;case 7:return 54;case 8:break;case 9:break;case 10:return 5;case 11:break;case 12:break;case 13:break;case 14:break;case 15:return this.pushState("SCALE"),17;break;case 16:return 18;case 17:this.popState();break;case 18:return this.begin("acc_title"),33;break;case 19:return this.popState(),"acc_title_value";break;case 20:return this.begin("acc_descr"),35;break;case 21:return this.popState(),"acc_descr_value";break;case 22:this.begin("acc_descr_multiline");break;case 23:this.popState();break;case 24:return"acc_descr_multiline_value";case 25:return this.pushState("CLASSDEF"),41;break;case 26:return this.popState(),this.pushState("CLASSDEFID"),"DEFAULT_CLASSDEF_ID";break;case 27:return this.popState(),this.pushState("CLASSDEFID"),42;break;case 28:return this.popState(),43;break;case 29:return this.pushState("CLASS"),48;break;case 30:return this.popState(),this.pushState("CLASS_STYLE"),49;break;case 31:return this.popState(),50;break;case 32:return this.pushState("STYLE"),45;break;case 33:return this.popState(),this.pushState("STYLEDEF_STYLES"),46;break;case 34:return this.popState(),47;break;case 35:return this.pushState("SCALE"),17;break;case 36:return 18;case 37:this.popState();break;case 38:this.pushState("STATE");break;case 39:return this.popState(),n.yytext=n.yytext.slice(0,-8).trim(),25;break;case 40:return this.popState(),n.yytext=n.yytext.slice(0,-8).trim(),26;break;case 41:return this.popState(),n.yytext=n.yytext.slice(0,-10).trim(),27;break;case 42:return this.popState(),n.yytext=n.yytext.slice(0,-8).trim(),25;break;case 43:return this.popState(),n.yytext=n.yytext.slice(0,-8).trim(),26;break;case 44:return this.popState(),n.yytext=n.yytext.slice(0,-10).trim(),27;break;case 45:return 51;case 46:return 52;case 47:return 53;case 48:return 54;case 49:this.pushState("STATE_STRING");break;case 50:return this.pushState("STATE_ID"),"AS";break;case 51:return this.popState(),"ID";break;case 52:this.popState();break;case 53:return"STATE_DESCR";case 54:return 19;case 55:this.popState();break;case 56:return this.popState(),this.pushState("struct"),20;break;case 57:break;case 58:return this.popState(),21;break;case 59:break;case 60:return this.begin("NOTE"),29;break;case 61:return this.popState(),this.pushState("NOTE_ID"),59;break;case 62:return this.popState(),this.pushState("NOTE_ID"),60;break;case 63:this.popState(),this.pushState("FLOATING_NOTE");break;case 64:return this.popState(),this.pushState("FLOATING_NOTE_ID"),"AS";break;case 65:break;case 66:return"NOTE_TEXT";case 67:return this.popState(),"ID";break;case 68:return this.popState(),this.pushState("NOTE_TEXT"),24;break;case 69:return this.popState(),n.yytext=n.yytext.substr(2).trim(),31;break;case 70:return this.popState(),n.yytext=n.yytext.slice(0,-8).trim(),31;break;case 71:return 6;case 72:return 6;case 73:return 16;case 74:return 57;case 75:return 24;case 76:return n.yytext=n.yytext.trim(),14;break;case 77:return 15;case 78:return 28;case 79:return 58;case 80:return 5;case 81:return"INVALID"}},"anonymous"),rules:[/^(?:click\b)/i,/^(?:href\b)/i,/^(?:"[^"]*")/i,/^(?:default\b)/i,/^(?:.*direction\s+TB[^\n]*)/i,/^(?:.*direction\s+BT[^\n]*)/i,/^(?:.*direction\s+RL[^\n]*)/i,/^(?:.*direction\s+LR[^\n]*)/i,/^(?:%%(?!\{)[^\n]*)/i,/^(?:[^\}]%%[^\n]*)/i,/^(?:[\n]+)/i,/^(?:[\s]+)/i,/^(?:((?!\n)\s)+)/i,/^(?:#[^\n]*)/i,/^(?:%[^\n]*)/i,/^(?:scale\s+)/i,/^(?:\d+)/i,/^(?:\s+width\b)/i,/^(?:accTitle\s*:\s*)/i,/^(?:(?!\n||)*[^\n]*)/i,/^(?:accDescr\s*:\s*)/i,/^(?:(?!\n||)*[^\n]*)/i,/^(?:accDescr\s*\{\s*)/i,/^(?:[\}])/i,/^(?:[^\}]*)/i,/^(?:classDef\s+)/i,/^(?:DEFAULT\s+)/i,/^(?:\w+\s+)/i,/^(?:[^\n]*)/i,/^(?:class\s+)/i,/^(?:(\w+)+((,\s*\w+)*))/i,/^(?:[^\n]*)/i,/^(?:style\s+)/i,/^(?:[\w,]+\s+)/i,/^(?:[^\n]*)/i,/^(?:scale\s+)/i,/^(?:\d+)/i,/^(?:\s+width\b)/i,/^(?:state\s+)/i,/^(?:.*<<fork>>)/i,/^(?:.*<<join>>)/i,/^(?:.*<<choice>>)/i,/^(?:.*\[\[fork\]\])/i,/^(?:.*\[\[join\]\])/i,/^(?:.*\[\[choice\]\])/i,/^(?:.*direction\s+TB[^\n]*)/i,/^(?:.*direction\s+BT[^\n]*)/i,/^(?:.*direction\s+RL[^\n]*)/i,/^(?:.*direction\s+LR[^\n]*)/i,/^(?:["])/i,/^(?:\s*as\s+)/i,/^(?:[^\n\{]*)/i,/^(?:["])/i,/^(?:[^"]*)/i,/^(?:[^\n\s\{]+)/i,/^(?:\n)/i,/^(?:\{)/i,/^(?:%%(?!\{)[^\n]*)/i,/^(?:\})/i,/^(?:[\n])/i,/^(?:note\s+)/i,/^(?:left of\b)/i,/^(?:right of\b)/i,/^(?:")/i,/^(?:\s*as\s*)/i,/^(?:["])/i,/^(?:[^"]*)/i,/^(?:[^\n]*)/i,/^(?:\s*[^:\n\s\-]+)/i,/^(?:\s*:[^:\n;]+)/i,/^(?:[\s\S]*?end note\b)/i,/^(?:stateDiagram\s+)/i,/^(?:stateDiagram-v2\s+)/i,/^(?:hide empty description\b)/i,/^(?:\[\*\])/i,/^(?:[^:\n\s\-\{]+)/i,/^(?:\s*:(?:[^:\n;]|:[^:\n;])+)/i,/^(?:-->)/i,/^(?:--)/i,/^(?::::)/i,/^(?:$)/i,/^(?:.)/i],conditions:{LINE:{rules:[12,13],inclusive:!1},struct:{rules:[12,13,25,29,32,38,45,46,47,48,57,58,59,60,74,75,76,77,78],inclusive:!1},FLOATING_NOTE_ID:{rules:[67],inclusive:!1},FLOATING_NOTE:{rules:[64,65,66],inclusive:!1},NOTE_TEXT:{rules:[69,70],inclusive:!1},NOTE_ID:{rules:[68],inclusive:!1},NOTE:{rules:[61,62,63],inclusive:!1},STYLEDEF_STYLEOPTS:{rules:[],inclusive:!1},STYLEDEF_STYLES:{rules:[34],inclusive:!1},STYLE_IDS:{rules:[],inclusive:!1},STYLE:{rules:[33],inclusive:!1},CLASS_STYLE:{rules:[31],inclusive:!1},CLASS:{rules:[30],inclusive:!1},CLASSDEFID:{rules:[28],inclusive:!1},CLASSDEF:{rules:[26,27],inclusive:!1},acc_descr_multiline:{rules:[23,24],inclusive:!1},acc_descr:{rules:[21],inclusive:!1},acc_title:{rules:[19],inclusive:!1},SCALE:{rules:[16,17,36,37],inclusive:!1},ALIAS:{rules:[],inclusive:!1},STATE_ID:{rules:[51],inclusive:!1},STATE_STRING:{rules:[52,53],inclusive:!1},FORK_STATE:{rules:[],inclusive:!1},STATE:{rules:[12,13,39,40,41,42,43,44,49,50,54,55,56],inclusive:!1},ID:{rules:[12,13],inclusive:!1},INITIAL:{rules:[0,1,2,3,4,5,6,7,8,9,10,11,13,14,15,18,20,22,25,29,32,35,38,56,60,71,72,73,74,75,76,77,79,80,81],inclusive:!0}}};return Y})();gt.lexer=he;function ct(){this.yy={}}return h(ct,"Parser"),ct.prototype=gt,gt.Parser=ct,new ct})();vt.parser=vt;var We=vt,pe="TB",qt="TB",jt="dir",K="state",z="root",Ct="relation",Se="classDef",ye="style",ge="applyClass",Z="default",Qt="divider",Zt="fill:none",te="fill: #333",ee="c",se="markdown",ie="normal",mt="rect",Dt="rectWithTitle",Te="stateStart",be="stateEnd",Ht="divider",Wt="roundedWithTitle",Ee="note",_e="noteGroup",tt="statediagram",ke="state",me=`${tt}-${ke}`,re="transition",De="note",ve="note-edge",Ce=`${re} ${ve}`,Ae=`${tt}-${De}`,xe="cluster",Le=`${tt}-${xe}`,Ie="cluster-alt",Oe=`${tt}-${Ie}`,ae="parent",ne="note",Re="state",At="----",Ne=`${At}${ne}`,zt=`${At}${ae}`,oe=h((t,e=qt)=>{if(!t.doc)return e;let s=e;for(let a of t.doc)a.stmt==="dir"&&(s=a.value);return s},"getDir"),we=h(function(t,e){return e.db.getClasses()},"getClasses"),$e=h(function(t,e,s,a){return Ot(this,null,function*(){k.info("REF0:"),k.info("Drawing state diagram (v2)",e);let{securityLevel:r,state:u,layout:d}=w();a.db.extract(a.db.getRootDocV2());let S=a.db.getData(),f=Mt(e,r);S.type=a.type,S.layoutAlgorithm=d,S.nodeSpacing=u?.nodeSpacing||50,S.rankSpacing=u?.rankSpacing||50,S.markers=["barb"],S.diagramId=e,yield Vt(S,f);let T=8;try{(typeof a.db.getLinks=="function"?a.db.getLinks():new Map).forEach((_,x)=>{let v=typeof x=="string"?x:typeof x?.id=="string"?x.id:"";if(!v){k.warn("\u26A0\uFE0F Invalid or missing stateId from key:",JSON.stringify(x));return}let p=f.node()?.querySelectorAll("g"),D;if(p?.forEach(I=>{I.textContent?.trim()===v&&(D=I)}),!D){k.warn("\u26A0\uFE0F Could not find node matching text:",v);return}let R=D.parentNode;if(!R){k.warn("\u26A0\uFE0F Node has no parent, cannot wrap:",v);return}let L=document.createElementNS("http://www.w3.org/2000/svg","a"),$=_.url.replace(/^"+|"+$/g,"");if(L.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",$),L.setAttribute("target","_blank"),_.tooltip){let I=_.tooltip.replace(/^"+|"+$/g,"");L.setAttribute("title",I)}R.replaceChild(L,D),L.appendChild(D),k.info("\u{1F517} Wrapped node in <a> tag for:",v,_.url)})}catch(E){k.error("\u274C Error injecting clickable links:",E)}Gt.insertTitle(f,"statediagramTitleText",u?.titleTopMargin??25,a.db.getDiagramTitle()),Ut(f,T,tt,u?.useMaxWidth??!0)})},"draw"),ze={getClasses:we,draw:$e,getDir:oe},St=new Map,G=0;function yt(t="",e=0,s="",a=At){let r=s!==null&&s.length>0?`${a}${s}`:"";return`${Re}-${t}${r}-${e}`}h(yt,"stateDomId");var Pe=h((t,e,s,a,r,u,d,S)=>{k.trace("items",e),e.forEach(f=>{switch(f.stmt){case K:Q(t,f,s,a,r,u,d,S);break;case Z:Q(t,f,s,a,r,u,d,S);break;case Ct:{Q(t,f.state1,s,a,r,u,d,S),Q(t,f.state2,s,a,r,u,d,S);let T={id:"edge"+G,start:f.state1.id,end:f.state2.id,arrowhead:"normal",arrowTypeEnd:"arrow_barb",style:Zt,labelStyle:"",label:B.sanitizeText(f.description??"",w()),arrowheadStyle:te,labelpos:ee,labelType:se,thickness:ie,classes:re,look:d};r.push(T),G++}break}})},"setupDoc"),Kt=h((t,e=qt)=>{let s=e;if(t.doc)for(let a of t.doc)a.stmt==="dir"&&(s=a.value);return s},"getDir");function q(t,e,s){if(!e.id||e.id==="</join></fork>"||e.id==="</choice>")return;e.cssClasses&&(Array.isArray(e.cssCompiledStyles)||(e.cssCompiledStyles=[]),e.cssClasses.split(" ").forEach(r=>{let u=s.get(r);u&&(e.cssCompiledStyles=[...e.cssCompiledStyles??[],...u.styles])}));let a=t.find(r=>r.id===e.id);a?Object.assign(a,e):t.push(e)}h(q,"insertOrUpdateNode");function le(t){return t?.classes?.join(" ")??""}h(le,"getClassesFromDbInfo");function ce(t){return t?.styles??[]}h(ce,"getStylesFromDbInfo");var Q=h((t,e,s,a,r,u,d,S)=>{let f=e.id,T=s.get(f),E=le(T),_=ce(T),x=w();if(k.info("dataFetcher parsedItem",e,T,_),f!=="root"){let v=mt;e.start===!0?v=Te:e.start===!1&&(v=be),e.type!==Z&&(v=e.type),St.get(f)||St.set(f,{id:f,shape:v,description:B.sanitizeText(f,x),cssClasses:`${E} ${me}`,cssStyles:_});let p=St.get(f);e.description&&(Array.isArray(p.description)?(p.shape=Dt,p.description.push(e.description)):p.description?.length&&p.description.length>0?(p.shape=Dt,p.description===f?p.description=[e.description]:p.description=[p.description,e.description]):(p.shape=mt,p.description=e.description),p.description=B.sanitizeTextOrArray(p.description,x)),p.description?.length===1&&p.shape===Dt&&(p.type==="group"?p.shape=Wt:p.shape=mt),!p.type&&e.doc&&(k.info("Setting cluster for XCX",f,Kt(e)),p.type="group",p.isGroup=!0,p.dir=Kt(e),p.shape=e.type===Qt?Ht:Wt,p.cssClasses=`${p.cssClasses} ${Le} ${u?Oe:""}`);let D={labelStyle:"",shape:p.shape,label:p.description,cssClasses:p.cssClasses,cssCompiledStyles:[],cssStyles:p.cssStyles,id:f,dir:p.dir,domId:yt(f,G),type:p.type,isGroup:p.type==="group",padding:8,rx:10,ry:10,look:d,labelType:"markdown"};if(D.shape===Ht&&(D.label=""),t&&t.id!=="root"&&(k.trace("Setting node ",f," to be child of its parent ",t.id),D.parentId=t.id),D.centerLabel=!0,e.note){let R={labelStyle:"",shape:Ee,label:e.note.text,labelType:"markdown",cssClasses:Ae,cssStyles:[],cssCompiledStyles:[],id:f+Ne+"-"+G,domId:yt(f,G,ne),type:p.type,isGroup:p.type==="group",padding:x.flowchart?.padding,look:d,position:e.note.position},L=f+zt,$={labelStyle:"",shape:_e,label:e.note.text,cssClasses:p.cssClasses,cssStyles:[],id:f+zt,domId:yt(f,G,ae),type:"group",isGroup:!0,padding:16,look:d,position:e.note.position};G++,$.id=L,R.parentId=L,q(a,$,S),q(a,R,S),q(a,D,S);let I=f,P=R.id;e.note.position==="left of"&&(I=R.id,P=f),r.push({id:I+"-"+P,start:I,end:P,arrowhead:"none",arrowTypeEnd:"",style:Zt,labelStyle:"",classes:Ce,arrowheadStyle:te,labelpos:ee,labelType:se,thickness:ie,look:d})}else q(a,D,S)}e.doc&&(k.trace("Adding nodes children "),Pe(e,e.doc,s,a,r,!u,d,S))},"dataFetcher"),Fe=h(()=>{St.clear(),G=0},"reset"),A={START_NODE:"[*]",START_TYPE:"start",END_NODE:"[*]",END_TYPE:"end",COLOR_KEYWORD:"color",FILL_KEYWORD:"fill",BG_FILL:"bgFill",STYLECLASS_SEP:","},Xt=h(()=>new Map,"newClassesList"),Jt=h(()=>({relations:[],states:new Map,documents:{}}),"newDoc"),pt=h(t=>JSON.parse(JSON.stringify(t)),"clone"),Ke=class{constructor(e){this.version=e,this.nodes=[],this.edges=[],this.rootDoc=[],this.classes=Xt(),this.documents={root:Jt()},this.currentDocument=this.documents.root,this.startEndCount=0,this.dividerCnt=0,this.links=new Map,this.getAccTitle=wt,this.setAccTitle=Nt,this.getAccDescription=Pt,this.setAccDescription=$t,this.setDiagramTitle=Ft,this.getDiagramTitle=Yt,this.clear(),this.setRootDoc=this.setRootDoc.bind(this),this.getDividerId=this.getDividerId.bind(this),this.setDirection=this.setDirection.bind(this),this.trimColon=this.trimColon.bind(this)}static{h(this,"StateDB")}static{this.relationType={AGGREGATION:0,EXTENSION:1,COMPOSITION:2,DEPENDENCY:3}}extract(e){this.clear(!0);for(let r of Array.isArray(e)?e:e.doc)switch(r.stmt){case K:this.addState(r.id.trim(),r.type,r.doc,r.description,r.note);break;case Ct:this.addRelation(r.state1,r.state2,r.description);break;case Se:this.addStyleClass(r.id.trim(),r.classes);break;case ye:this.handleStyleDef(r);break;case ge:this.setCssClass(r.id.trim(),r.styleClass);break;case"click":this.addLink(r.id,r.url,r.tooltip);break}let s=this.getStates(),a=w();Fe(),Q(void 0,this.getRootDocV2(),s,this.nodes,this.edges,!0,a.look,this.classes);for(let r of this.nodes)if(Array.isArray(r.label)){if(r.description=r.label.slice(1),r.isGroup&&r.description.length>0)throw new Error(`Group nodes can only have label. Remove the additional description for node [${r.id}]`);r.label=r.label[0]}}handleStyleDef(e){let s=e.id.trim().split(","),a=e.styleClass.split(",");for(let r of s){let u=this.getState(r);if(!u){let d=r.trim();this.addState(d),u=this.getState(d)}u&&(u.styles=a.map(d=>d.replace(/;/g,"")?.trim()))}}setRootDoc(e){k.info("Setting root doc",e),this.rootDoc=e,this.version===1?this.extract(e):this.extract(this.getRootDocV2())}docTranslator(e,s,a){if(s.stmt===Ct){this.docTranslator(e,s.state1,!0),this.docTranslator(e,s.state2,!1);return}if(s.stmt===K&&(s.id===A.START_NODE?(s.id=e.id+(a?"_start":"_end"),s.start=a):s.id=s.id.trim()),s.stmt!==z&&s.stmt!==K||!s.doc)return;let r=[],u=[];for(let d of s.doc)if(d.type===Qt){let S=pt(d);S.doc=pt(u),r.push(S),u=[]}else u.push(d);if(r.length>0&&u.length>0){let d={stmt:K,id:Bt(),type:"divider",doc:pt(u)};r.push(pt(d)),s.doc=r}s.doc.forEach(d=>this.docTranslator(s,d,!0))}getRootDocV2(){return this.docTranslator({id:z,stmt:z},{id:z,stmt:z,doc:this.rootDoc},!0),{id:z,doc:this.rootDoc}}addState(e,s=Z,a=void 0,r=void 0,u=void 0,d=void 0,S=void 0,f=void 0){let T=e?.trim();if(!this.currentDocument.states.has(T))k.info("Adding state ",T,r),this.currentDocument.states.set(T,{stmt:K,id:T,descriptions:[],type:s,doc:a,note:u,classes:[],styles:[],textStyles:[]});else{let E=this.currentDocument.states.get(T);if(!E)throw new Error(`State not found: ${T}`);E.doc||(E.doc=a),E.type||(E.type=s)}if(r&&(k.info("Setting state description",T,r),(Array.isArray(r)?r:[r]).forEach(_=>this.addDescription(T,_.trim()))),u){let E=this.currentDocument.states.get(T);if(!E)throw new Error(`State not found: ${T}`);E.note=u,E.note.text=B.sanitizeText(E.note.text,w())}d&&(k.info("Setting state classes",T,d),(Array.isArray(d)?d:[d]).forEach(_=>this.setCssClass(T,_.trim()))),S&&(k.info("Setting state styles",T,S),(Array.isArray(S)?S:[S]).forEach(_=>this.setStyle(T,_.trim()))),f&&(k.info("Setting state styles",T,S),(Array.isArray(f)?f:[f]).forEach(_=>this.setTextStyle(T,_.trim())))}clear(e){this.nodes=[],this.edges=[],this.documents={root:Jt()},this.currentDocument=this.documents.root,this.startEndCount=0,this.classes=Xt(),e||(this.links=new Map,Rt())}getState(e){return this.currentDocument.states.get(e)}getStates(){return this.currentDocument.states}logDocuments(){k.info("Documents = ",this.documents)}getRelations(){return this.currentDocument.relations}addLink(e,s,a){this.links.set(e,{url:s,tooltip:a}),k.warn("Adding link",e,s,a)}getLinks(){return this.links}startIdIfNeeded(e=""){return e===A.START_NODE?(this.startEndCount++,`${A.START_TYPE}${this.startEndCount}`):e}startTypeIfNeeded(e="",s=Z){return e===A.START_NODE?A.START_TYPE:s}endIdIfNeeded(e=""){return e===A.END_NODE?(this.startEndCount++,`${A.END_TYPE}${this.startEndCount}`):e}endTypeIfNeeded(e="",s=Z){return e===A.END_NODE?A.END_TYPE:s}addRelationObjs(e,s,a=""){let r=this.startIdIfNeeded(e.id.trim()),u=this.startTypeIfNeeded(e.id.trim(),e.type),d=this.startIdIfNeeded(s.id.trim()),S=this.startTypeIfNeeded(s.id.trim(),s.type);this.addState(r,u,e.doc,e.description,e.note,e.classes,e.styles,e.textStyles),this.addState(d,S,s.doc,s.description,s.note,s.classes,s.styles,s.textStyles),this.currentDocument.relations.push({id1:r,id2:d,relationTitle:B.sanitizeText(a,w())})}addRelation(e,s,a){if(typeof e=="object"&&typeof s=="object")this.addRelationObjs(e,s,a);else if(typeof e=="string"&&typeof s=="string"){let r=this.startIdIfNeeded(e.trim()),u=this.startTypeIfNeeded(e),d=this.endIdIfNeeded(s.trim()),S=this.endTypeIfNeeded(s);this.addState(r,u),this.addState(d,S),this.currentDocument.relations.push({id1:r,id2:d,relationTitle:a?B.sanitizeText(a,w()):void 0})}}addDescription(e,s){let a=this.currentDocument.states.get(e),r=s.startsWith(":")?s.replace(":","").trim():s;a?.descriptions?.push(B.sanitizeText(r,w()))}cleanupLabel(e){return e.startsWith(":")?e.slice(2).trim():e.trim()}getDividerId(){return this.dividerCnt++,`divider-id-${this.dividerCnt}`}addStyleClass(e,s=""){this.classes.has(e)||this.classes.set(e,{id:e,styles:[],textStyles:[]});let a=this.classes.get(e);s&&a&&s.split(A.STYLECLASS_SEP).forEach(r=>{let u=r.replace(/([^;]*);/,"$1").trim();if(RegExp(A.COLOR_KEYWORD).exec(r)){let S=u.replace(A.FILL_KEYWORD,A.BG_FILL).replace(A.COLOR_KEYWORD,A.FILL_KEYWORD);a.textStyles.push(S)}a.styles.push(u)})}getClasses(){return this.classes}setCssClass(e,s){e.split(",").forEach(a=>{let r=this.getState(a);if(!r){let u=a.trim();this.addState(u),r=this.getState(u)}r?.classes?.push(s)})}setStyle(e,s){this.getState(e)?.styles?.push(s)}setTextStyle(e,s){this.getState(e)?.textStyles?.push(s)}getDirectionStatement(){return this.rootDoc.find(e=>e.stmt===jt)}getDirection(){return this.getDirectionStatement()?.value??pe}setDirection(e){let s=this.getDirectionStatement();s?s.value=e:this.rootDoc.unshift({stmt:jt,value:e})}trimColon(e){return e.startsWith(":")?e.slice(1).trim():e.trim()}getData(){let e=w();return{nodes:this.nodes,edges:this.edges,other:{},config:e,direction:oe(this.getRootDocV2())}}getConfig(){return w().state}},Ye=h(t=>` |
| 7 | defs #statediagram-barbEnd { |
| 8 | fill: ${t.transitionColor}; |
| 9 | stroke: ${t.transitionColor}; |
no test coverage detected