mermaid
Version:
Markdown-ish syntax for generating flowcharts, mindmaps, sequence diagrams, class diagrams, gantt charts, git graphs and more.
100 lines (85 loc) • 31.1 kB
JavaScript
import{a as ee}from"./chunk-SDIBIOXT.mjs";import{a as re}from"./chunk-R2KH53MI.mjs";import{b as se,c as ie}from"./chunk-52IMQVNL.mjs";import"./chunk-MFYRHTYG.mjs";import"./chunk-JCBDXJ5W.mjs";import"./chunk-OCMJQKYE.mjs";import"./chunk-MNT3HHAC.mjs";import"./chunk-TECWHJ6D.mjs";import"./chunk-F6PIGZHG.mjs";import"./chunk-JGXDHUYS.mjs";import"./chunk-TINYC7RT.mjs";import"./chunk-TDFULVG6.mjs";import{a as ht,b as Xt,c as Jt,d as $t,e as te}from"./chunk-MIE3LDYP.mjs";import{p as Ht,s as Qt}from"./chunk-QADHU5CF.mjs";import"./chunk-ZZ52EIBP.mjs";import{$ as z,H as Pt,T as Yt,U as zt,V as Ut,W as jt,X as Kt,Y as Zt,Z as Wt,b as Bt,c as Ft}from"./chunk-FE53TMRB.mjs";import{b as A,h as qt}from"./chunk-L2B47AAZ.mjs";import{a as p,d as pe}from"./chunk-QVIEFLGF.mjs";var Ct=(function(){var s=p(function(F,n,c,d){for(c=c||{},d=F.length;d--;c[F[d]]=n);return c},"o"),a=[6,9,21,23,25,27,34,37,38,39,40,41,43,46,47,51,53,54,55],o=[2,2],l=[1,7],r=[1,9],u=[1,10],k=[1,11],g=[1,12],m=[1,30],N=[1,23],b=[1,24],f=[1,25],v=[1,26],D=[1,27],C=[1,19],x=[1,28],R=[1,29],O=[1,20],L=[1,18],w=[1,21],V=[1,22],Ot=[2,6],h=[6,9,21,23,25,27,33,34,37,38,39,40,41,43,46,47,51,53,54,55],dt=[1,36],pt=[1,37],bt=[1,38],ft=[1,39],gt=[1,40],K=[6,9,12,14,16,19,20,21,23,25,27,33,34,37,38,39,40,41,43,46,47,50,51,53,54,55,69,70,71,72,73],G=[1,46],M=[1,47],Z=[1,57],W=[43,51,53,54,55,74,75],q=[1,70],H=[1,68],B=[1,65],Q=[1,69],X=[1,71],tt=[6,9,12,16,21,23,25,27,33,34,37,38,39,40,41,43,44,45,46,47,51,52,53,54,55,69,70,71,72,73],et=[1,78],st=[1,77],it=[1,76],At=[69,70,71,72,73],vt=[1,91],Rt=[6,9,45,50],U=[6,9,12,44,45,50,51,52],rt=[1,101],at=[1,100],nt=[1,99],J=[18,61],It=[1,110],Dt=[1,109],Lt=[20,43,51,53,54,55],kt=[18,61,64,66],yt={trace:p(function(){},"trace"),yy:{},symbols_:{error:2,start:3,ER_DIAGRAM:4,document:5,EOF:6,line:7,statement:8,NEWLINE:9,entityName:10,relSpec:11,COLON:12,role:13,STYLE_SEPARATOR:14,idList:15,BLOCK_START:16,attributes:17,BLOCK_STOP:18,SQS:19,SQE:20,title:21,title_value:22,acc_title:23,acc_title_value:24,acc_descr:25,acc_descr_value:26,acc_descr_multiline_value:27,direction:28,classDefStatement:29,classStatement:30,styleStatement:31,subgraphHeader:32,END:33,SUBGRAPH:34,separator:35,subgraphTitle:36,direction_tb:37,direction_bt:38,direction_rl:39,direction_lr:40,CLASSDEF:41,stylesOpt:42,UNICODE_TEXT:43,STYLE_TEXT:44,COMMA:45,CLASS:46,STYLE:47,style:48,styleComponent:49,SEMI:50,NUM:51,BRKT:52,ENTITY_NAME:53,DECIMAL_NUM:54,ENTITY_ONE:55,attribute:56,attributeType:57,attributeName:58,attributeKeyTypeList:59,attributeComment:60,ATTRIBUTE_WORD:61,"?":62,attributeKeyType:63,",":64,ATTRIBUTE_KEY:65,COMMENT:66,cardinality:67,relType:68,ZERO_OR_ONE:69,ZERO_OR_MORE:70,ONE_OR_MORE:71,ONLY_ONE:72,MD_PARENT:73,NON_IDENTIFYING:74,IDENTIFYING:75,WORD:76,$accept:0,$end:1},terminals_:{2:"error",4:"ER_DIAGRAM",6:"EOF",9:"NEWLINE",12:"COLON",14:"STYLE_SEPARATOR",16:"BLOCK_START",18:"BLOCK_STOP",19:"SQS",20:"SQE",21:"title",22:"title_value",23:"acc_title",24:"acc_title_value",25:"acc_descr",26:"acc_descr_value",27:"acc_descr_multiline_value",33:"END",34:"SUBGRAPH",37:"direction_tb",38:"direction_bt",39:"direction_rl",40:"direction_lr",41:"CLASSDEF",43:"UNICODE_TEXT",44:"STYLE_TEXT",45:"COMMA",46:"CLASS",47:"STYLE",50:"SEMI",51:"NUM",52:"BRKT",53:"ENTITY_NAME",54:"DECIMAL_NUM",55:"ENTITY_ONE",61:"ATTRIBUTE_WORD",62:"?",64:",",65:"ATTRIBUTE_KEY",66:"COMMENT",69:"ZERO_OR_ONE",70:"ZERO_OR_MORE",71:"ONE_OR_MORE",72:"ONLY_ONE",73:"MD_PARENT",74:"NON_IDENTIFYING",75:"IDENTIFYING",76:"WORD"},productions_:[0,[3,3],[5,0],[5,2],[7,1],[7,1],[7,1],[8,5],[8,9],[8,7],[8,7],[8,4],[8,6],[8,3],[8,5],[8,1],[8,3],[8,7],[8,9],[8,6],[8,8],[8,4],[8,6],[8,2],[8,2],[8,2],[8,1],[8,1],[8,1],[8,1],[8,1],[8,3],[32,3],[32,6],[36,1],[36,2],[28,1],[28,1],[28,1],[28,1],[29,4],[15,1],[15,1],[15,3],[15,3],[30,3],[31,4],[42,1],[42,3],[48,1],[48,2],[35,1],[35,1],[35,1],[49,1],[49,1],[49,1],[49,1],[10,1],[10,1],[10,1],[10,1],[10,1],[17,1],[17,2],[56,2],[56,3],[56,3],[56,4],[57,1],[57,2],[58,1],[59,1],[59,3],[63,1],[60,1],[11,3],[67,1],[67,1],[67,1],[67,1],[67,1],[68,1],[68,1],[13,1],[13,1],[13,1]],performAction:p(function(n,c,d,i,y,t,$){var e=t.length-1;switch(y){case 1:break;case 2:this.$=[];break;case 3:this.$=t[e-1].concat(t[e]);break;case 4:this.$=t[e];break;case 5:case 6:this.$=[];break;case 7:i.addEntity(t[e-4]),i.addEntity(t[e-2]),i.addRelationship(t[e-4],t[e],t[e-2],t[e-3]),this.$=[t[e-4],t[e-2]];break;case 8:i.addEntity(t[e-8]),i.addEntity(t[e-4]),i.addRelationship(t[e-8],t[e],t[e-4],t[e-5]),i.setClass([t[e-8]],t[e-6]),i.setClass([t[e-4]],t[e-2]),this.$=[t[e-8],t[e-4]];break;case 9:i.addEntity(t[e-6]),i.addEntity(t[e-2]),i.addRelationship(t[e-6],t[e],t[e-2],t[e-3]),i.setClass([t[e-6]],t[e-4]),this.$=[t[e-6],t[e-2]];break;case 10:i.addEntity(t[e-6]),i.addEntity(t[e-4]),i.addRelationship(t[e-6],t[e],t[e-4],t[e-5]),i.setClass([t[e-4]],t[e-2]),this.$=[t[e-6],t[e-4]];break;case 11:i.addEntity(t[e-3]),i.addAttributes(t[e-3],t[e-1]),this.$=[t[e-3]];break;case 12:i.addEntity(t[e-5]),i.addAttributes(t[e-5],t[e-1]),i.setClass([t[e-5]],t[e-3]),this.$=[t[e-5]];break;case 13:i.addEntity(t[e-2]),this.$=[t[e-2]];break;case 14:i.addEntity(t[e-4]),i.setClass([t[e-4]],t[e-2]),this.$=[t[e-4]];break;case 15:i.addEntity(t[e]),this.$=[t[e]];break;case 16:i.addEntity(t[e-2]),i.setClass([t[e-2]],t[e]),this.$=[t[e-2]];break;case 17:i.addEntity(t[e-6],t[e-4]),i.addAttributes(t[e-6],t[e-1]),this.$=[t[e-6]];break;case 18:i.addEntity(t[e-8],t[e-6]),i.addAttributes(t[e-8],t[e-1]),i.setClass([t[e-8]],t[e-3]),this.$=[t[e-8]];break;case 19:i.addEntity(t[e-5],t[e-3]),this.$=[t[e-5]];break;case 20:i.addEntity(t[e-7],t[e-5]),i.setClass([t[e-7]],t[e-2]),this.$=[t[e-7]];break;case 21:i.addEntity(t[e-3],t[e-1]);break;case 22:i.addEntity(t[e-5],t[e-3]),i.setClass([t[e-5]],t[e]);break;case 23:case 24:this.$=t[e].trim(),i.setAccTitle(this.$);break;case 25:case 26:this.$=t[e].trim(),i.setAccDescription(this.$);break;case 27:i.subgraphDepth?this.$=t[e]:(i.setDirection(t[e].value),this.$=[]);break;case 31:i.subgraphDepth=(i.subgraphDepth||1)-1,this.$=i.addSubGraph({text:t[e-2].id},t[e-1],{text:t[e-2].text});break;case 32:i.subgraphDepth=(i.subgraphDepth||0)+1,this.$={id:t[e-1],text:t[e-1]};break;case 33:i.subgraphDepth=(i.subgraphDepth||0)+1,this.$={id:t[e-4],text:t[e-2]};break;case 34:case 59:case 60:case 61:case 62:case 86:this.$=t[e];break;case 35:this.$=t[e-1]+" "+t[e];break;case 36:this.$={stmt:"dir",value:"TB"};break;case 37:this.$={stmt:"dir",value:"BT"};break;case 38:this.$={stmt:"dir",value:"RL"};break;case 39:this.$={stmt:"dir",value:"LR"};break;case 40:this.$=t[e-3],i.addClass(t[e-2],t[e-1]);break;case 41:case 42:case 63:case 72:this.$=[t[e]];break;case 43:case 44:this.$=t[e-2].concat([t[e]]);break;case 45:this.$=t[e-2],i.setClass(t[e-1],t[e]);break;case 46:this.$=t[e-3],i.addCssStyles(t[e-2],t[e-1]);break;case 47:this.$=[t[e]];break;case 48:t[e-2].push(t[e]),this.$=t[e-2];break;case 50:this.$=t[e-1]+t[e];break;case 58:case 84:case 85:this.$=t[e].replace(/"/g,"");break;case 64:t[e].push(t[e-1]),this.$=t[e];break;case 65:this.$={type:t[e-1],name:t[e]};break;case 66:this.$={type:t[e-2],name:t[e-1],keys:t[e]};break;case 67:this.$={type:t[e-2],name:t[e-1],comment:t[e]};break;case 68:this.$={type:t[e-3],name:t[e-2],keys:t[e-1],comment:t[e]};break;case 69:case 71:case 74:this.$=t[e];break;case 70:this.$=t[e-1]+t[e];break;case 73:t[e-2].push(t[e]),this.$=t[e-2];break;case 75:this.$=t[e].replace(/"/g,"");break;case 76:this.$={cardA:t[e],relType:t[e-1],cardB:t[e-2]};break;case 77:this.$=i.Cardinality.ZERO_OR_ONE;break;case 78:this.$=i.Cardinality.ZERO_OR_MORE;break;case 79:this.$=i.Cardinality.ONE_OR_MORE;break;case 80:this.$=i.Cardinality.ONLY_ONE;break;case 81:this.$=i.Cardinality.MD_PARENT;break;case 82:this.$=i.Identification.NON_IDENTIFYING;break;case 83:this.$=i.Identification.IDENTIFYING;break}},"anonymous"),table:[{3:1,4:[1,2]},{1:[3]},s(a,o,{5:3}),{6:[1,4],7:5,8:6,9:l,10:8,21:r,23:u,25:k,27:g,28:13,29:14,30:15,31:16,32:17,34:m,37:N,38:b,39:f,40:v,41:D,43:C,46:x,47:R,51:O,53:L,54:w,55:V},s(a,Ot,{1:[2,1]}),s(h,[2,3]),s(h,[2,4]),s(h,[2,5]),s(h,[2,15],{11:31,67:35,14:[1,32],16:[1,33],19:[1,34],69:dt,70:pt,71:bt,72:ft,73:gt}),{22:[1,41]},{24:[1,42]},{26:[1,43]},s(h,[2,26]),s(h,[2,27]),s(h,[2,28]),s(h,[2,29]),s(h,[2,30]),s(h,o,{5:44}),s(K,[2,58]),s(K,[2,59]),s(K,[2,60]),s(K,[2,61]),s(K,[2,62]),s(h,[2,36]),s(h,[2,37]),s(h,[2,38]),s(h,[2,39]),{15:45,43:G,44:M},{15:48,43:G,44:M},{15:49,43:G,44:M},{10:50,43:C,51:O,53:L,54:w,55:V},{10:51,43:C,51:O,53:L,54:w,55:V},{15:52,43:G,44:M},{17:53,18:[1,54],56:55,57:56,61:Z},{10:58,43:C,51:O,53:L,54:w,55:V},{68:59,74:[1,60],75:[1,61]},s(W,[2,77]),s(W,[2,78]),s(W,[2,79]),s(W,[2,80]),s(W,[2,81]),s(h,[2,23]),s(h,[2,24]),s(h,[2,25]),{6:[1,63],7:5,8:6,9:l,10:8,21:r,23:u,25:k,27:g,28:13,29:14,30:15,31:16,32:17,33:[1,62],34:m,37:N,38:b,39:f,40:v,41:D,43:C,46:x,47:R,51:O,53:L,54:w,55:V},{12:q,42:64,44:H,45:B,48:66,49:67,51:Q,52:X},s(tt,[2,41]),s(tt,[2,42]),{15:72,43:G,44:M,45:B},{12:q,42:73,44:H,45:B,48:66,49:67,51:Q,52:X},{6:et,9:st,19:[1,75],35:74,50:it},{12:[1,79],14:[1,80]},s(h,[2,16],{67:35,11:81,16:[1,82],45:B,69:dt,70:pt,71:bt,72:ft,73:gt}),{18:[1,83]},s(h,[2,13]),{17:84,18:[2,63],56:55,57:56,61:Z},{58:85,61:[1,86]},{61:[2,69],62:[1,87]},{20:[1,88]},{67:89,69:dt,70:pt,71:bt,72:ft,73:gt},s(At,[2,82]),s(At,[2,83]),s(h,[2,31]),s(h,Ot),{6:et,9:st,35:90,45:vt,50:it},{43:[1,92],44:[1,93]},s(Rt,[2,47],{49:94,12:q,44:H,51:Q,52:X}),s(U,[2,49]),s(U,[2,54]),s(U,[2,55]),s(U,[2,56]),s(U,[2,57]),s(h,[2,45],{45:B}),{6:et,9:st,35:95,45:vt,50:it},s(h,[2,32]),{10:97,36:96,43:C,51:O,53:L,54:w,55:V},s(h,[2,51]),s(h,[2,52]),s(h,[2,53]),{13:98,43:rt,53:at,76:nt},{15:102,43:G,44:M},{10:103,43:C,51:O,53:L,54:w,55:V},{17:104,18:[1,105],56:55,57:56,61:Z},s(h,[2,11]),{18:[2,64]},s(J,[2,65],{59:106,60:107,63:108,65:It,66:Dt}),s([18,61,65,66],[2,71]),{61:[2,70]},s(h,[2,21],{14:[1,112],16:[1,111]}),s([43,51,53,54,55],[2,76]),s(h,[2,40]),{12:q,44:H,48:113,49:67,51:Q,52:X},s(tt,[2,43]),s(tt,[2,44]),s(U,[2,50]),s(h,[2,46]),{10:115,20:[1,114],43:C,51:O,53:L,54:w,55:V},s(Lt,[2,34]),s(h,[2,7]),s(h,[2,84]),s(h,[2,85]),s(h,[2,86]),{12:[1,116],45:B},{12:[1,118],14:[1,117]},{18:[1,119]},s(h,[2,14]),s(J,[2,66],{60:120,64:[1,121],66:Dt}),s(J,[2,67]),s(kt,[2,72]),s(J,[2,75]),s(kt,[2,74]),{17:122,18:[1,123],56:55,57:56,61:Z},{15:124,43:G,44:M},s(Rt,[2,48],{49:94,12:q,44:H,51:Q,52:X}),{6:et,9:st,35:125,50:it},s(Lt,[2,35]),{13:126,43:rt,53:at,76:nt},{15:127,43:G,44:M},{13:128,43:rt,53:at,76:nt},s(h,[2,12]),s(J,[2,68]),{63:129,65:It},{18:[1,130]},s(h,[2,19]),s(h,[2,22],{16:[1,131],45:B}),s(h,[2,33]),s(h,[2,10]),{12:[1,132],45:B},s(h,[2,9]),s(kt,[2,73]),s(h,[2,17]),{17:133,18:[1,134],56:55,57:56,61:Z},{13:135,43:rt,53:at,76:nt},{18:[1,136]},s(h,[2,20]),s(h,[2,8]),s(h,[2,18])],defaultActions:{84:[2,64],87:[2,70]},parseError:p(function(n,c){if(c.recoverable)this.trace(n);else{var d=new Error(n);throw d.hash=c,d}},"parseError"),parse:p(function(n){var c=this,d=[0],i=[],y=[null],t=[],$=this.table,e="",ot=0,wt=0,Vt=0,ce=2,Gt=1,he=t.slice.call(arguments,1),_=Object.create(this.lexer),P={yy:{}};for(var _t in this.yy)Object.prototype.hasOwnProperty.call(this.yy,_t)&&(P.yy[_t]=this.yy[_t]);_.setInput(n,P.yy),P.yy.lexer=_,P.yy.parser=this,typeof _.yylloc>"u"&&(_.yylloc={});var Et=_.yylloc;t.push(Et);var ue=_.options&&_.options.ranges;typeof P.yy.parseError=="function"?this.parseError=P.yy.parseError:this.parseError=Object.getPrototypeOf(this).parseError;function ke(S){d.length=d.length-2*S,y.length=y.length-S,t.length=t.length-S}p(ke,"popStack");function de(){var S;return S=i.pop()||_.lex()||Gt,typeof S!="number"&&(S instanceof Array&&(i=S,S=i.pop()),S=c.symbols_[S]||S),S}p(de,"lex");for(var E,St,Y,T,ye,Tt,j={},lt,I,Mt,ct;;){if(Y=d[d.length-1],this.defaultActions[Y]?T=this.defaultActions[Y]:((E===null||typeof E>"u")&&(E=de()),T=$[Y]&&$[Y][E]),typeof T>"u"||!T.length||!T[0]){var Nt="";ct=[];for(lt in $[Y])this.terminals_[lt]&<>ce&&ct.push("'"+this.terminals_[lt]+"'");_.showPosition?Nt="Parse error on line "+(ot+1)+`:
`+_.showPosition()+`
Expecting `+ct.join(", ")+", got '"+(this.terminals_[E]||E)+"'":Nt="Parse error on line "+(ot+1)+": Unexpected "+(E==Gt?"end of input":"'"+(this.terminals_[E]||E)+"'"),this.parseError(Nt,{text:_.match,token:this.terminals_[E]||E,line:_.yylineno,loc:Et,expected:ct})}if(T[0]instanceof Array&&T.length>1)throw new Error("Parse Error: multiple actions possible at state: "+Y+", token: "+E);switch(T[0]){case 1:d.push(E),y.push(_.yytext),t.push(_.yylloc),d.push(T[1]),E=null,St?(E=St,St=null):(wt=_.yyleng,e=_.yytext,ot=_.yylineno,Et=_.yylloc,Vt>0&&Vt--);break;case 2:if(I=this.productions_[T[1]][1],j.$=y[y.length-I],j._$={first_line:t[t.length-(I||1)].first_line,last_line:t[t.length-1].last_line,first_column:t[t.length-(I||1)].first_column,last_column:t[t.length-1].last_column},ue&&(j._$.range=[t[t.length-(I||1)].range[0],t[t.length-1].range[1]]),Tt=this.performAction.apply(j,[e,wt,ot,P.yy,T[1],y,t].concat(he)),typeof Tt<"u")return Tt;I&&(d=d.slice(0,-1*I*2),y=y.slice(0,-1*I),t=t.slice(0,-1*I)),d.push(this.productions_[T[1]][0]),y.push(j.$),t.push(j._$),Mt=$[d[d.length-2]][d[d.length-1]],d.push(Mt);break;case 3:return!0}}return!0},"parse")},le=(function(){var F={EOF:1,parseError:p(function(c,d){if(this.yy.parser)this.yy.parser.parseError(c,d);else throw new Error(c)},"parseError"),setInput:p(function(n,c){return this.yy=c||this.yy||{},this._input=n,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:p(function(){var n=this._input[0];this.yytext+=n,this.yyleng++,this.offset++,this.match+=n,this.matched+=n;var c=n.match(/(?:\r\n?|\n).*/g);return c?(this.yylineno++,this.yylloc.last_line++):this.yylloc.last_column++,this.options.ranges&&this.yylloc.range[1]++,this._input=this._input.slice(1),n},"input"),unput:p(function(n){var c=n.length,d=n.split(/(?:\r\n?|\n)/g);this._input=n+this._input,this.yytext=this.yytext.substr(0,this.yytext.length-c),this.offset-=c;var i=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),d.length-1&&(this.yylineno-=d.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:d?(d.length===i.length?this.yylloc.first_column:0)+i[i.length-d.length].length-d[0].length:this.yylloc.first_column-c},this.options.ranges&&(this.yylloc.range=[y[0],y[0]+this.yyleng-c]),this.yyleng=this.yytext.length,this},"unput"),more:p(function(){return this._more=!0,this},"more"),reject:p(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:p(function(n){this.unput(this.match.slice(n))},"less"),pastInput:p(function(){var n=this.matched.substr(0,this.matched.length-this.match.length);return(n.length>20?"...":"")+n.substr(-20).replace(/\n/g,"")},"pastInput"),upcomingInput:p(function(){var n=this.match;return n.length<20&&(n+=this._input.substr(0,20-n.length)),(n.substr(0,20)+(n.length>20?"...":"")).replace(/\n/g,"")},"upcomingInput"),showPosition:p(function(){var n=this.pastInput(),c=new Array(n.length+1).join("-");return n+this.upcomingInput()+`
`+c+"^"},"showPosition"),test_match:p(function(n,c){var d,i,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))),i=n[0].match(/(?:\r\n?|\n).*/g),i&&(this.yylineno+=i.length),this.yylloc={first_line:this.yylloc.last_line,last_line:this.yylineno+1,first_column:this.yylloc.last_column,last_column:i?i[i.length-1].length-i[i.length-1].match(/\r?\n?/)[0].length:this.yylloc.last_column+n[0].length},this.yytext+=n[0],this.match+=n[0],this.matches=n,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(n[0].length),this.matched+=n[0],d=this.performAction.call(this,this.yy,this,c,this.conditionStack[this.conditionStack.length-1]),this.done&&this._input&&(this.done=!1),d)return d;if(this._backtrack){for(var t in y)this[t]=y[t];return!1}return!1},"test_match"),next:p(function(){if(this.done)return this.EOF;this._input||(this.done=!0);var n,c,d,i;this._more||(this.yytext="",this.match="");for(var y=this._currentRules(),t=0;t<y.length;t++)if(d=this._input.match(this.rules[y[t]]),d&&(!c||d[0].length>c[0].length)){if(c=d,i=t,this.options.backtrack_lexer){if(n=this.test_match(d,y[t]),n!==!1)return n;if(this._backtrack){c=!1;continue}else return!1}else if(!this.options.flex)break}return c?(n=this.test_match(c,y[i]),n!==!1?n:!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:p(function(){var c=this.next();return c||this.lex()},"lex"),begin:p(function(c){this.conditionStack.push(c)},"begin"),popState:p(function(){var c=this.conditionStack.length-1;return c>0?this.conditionStack.pop():this.conditionStack[0]},"popState"),_currentRules:p(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:p(function(c){return c=this.conditionStack.length-1-Math.abs(c||0),c>=0?this.conditionStack[c]:"INITIAL"},"topState"),pushState:p(function(c){this.begin(c)},"pushState"),stateStackSize:p(function(){return this.conditionStack.length},"stateStackSize"),options:{"case-insensitive":!0},performAction:p(function(c,d,i,y){var t=y;switch(i){case 0:return this.begin("acc_title"),23;break;case 1:return this.popState(),"acc_title_value";break;case 2:return this.begin("acc_descr"),25;break;case 3:return this.popState(),"acc_descr_value";break;case 4:this.begin("acc_descr_multiline");break;case 5:this.popState();break;case 6:return"acc_descr_multiline_value";case 7:return 37;case 8:return 38;case 9:return 39;case 10:return 40;case 11:break;case 12:return 9;case 13:return 53;case 14:return 76;case 15:return 4;case 16:return this.begin("block"),16;break;case 17:return 52;case 18:return 52;case 19:return 45;case 20:return 14;case 21:return 12;case 22:break;case 23:return 65;case 24:return 61;case 25:return 61;case 26:this.begin("block_bq");break;case 27:return 61;case 28:this.popState();break;case 29:return 66;case 30:break;case 31:return this.popState(),18;break;case 32:return d.yytext[0];case 33:return 19;case 34:return 20;case 35:return this.begin("style"),47;break;case 36:return this.popState(),9;break;case 37:break;case 38:return 12;case 39:return 45;case 40:return 52;case 41:return this.begin("style"),41;break;case 42:return 46;case 43:return 34;case 44:return 33;case 45:return 69;case 46:return 71;case 47:return 71;case 48:return 71;case 49:return 69;case 50:return 69;case 51:return 70;case 52:return 70;case 53:return 70;case 54:return 70;case 55:return 70;case 56:return 71;case 57:return 70;case 58:return 71;case 59:return 72;case 60:return 72;case 61:return 54;case 62:return 72;case 63:return 72;case 64:return 72;case 65:return 55;case 66:return 51;case 67:return 72;case 68:return 69;case 69:return 70;case 70:return 71;case 71:return 73;case 72:return 74;case 73:return 75;case 74:return 75;case 75:return 74;case 76:return 74;case 77:return 74;case 78:return 44;case 79:return 50;case 80:return 43;case 81:return d.yytext[0];case 82:return 6}},"anonymous"),rules:[/^(?:accTitle\s*:\s*)/i,/^(?:(?!\n||)*[^\n]*)/i,/^(?:accDescr\s*:\s*)/i,/^(?:(?!\n||)*[^\n]*)/i,/^(?:accDescr\s*\{\s*)/i,/^(?:[\}])/i,/^(?:[^\}]*)/i,/^(?:.*direction\s+TB[^\n]*)/i,/^(?:.*direction\s+BT[^\n]*)/i,/^(?:.*direction\s+RL[^\n]*)/i,/^(?:.*direction\s+LR[^\n]*)/i,/^(?:[ \t\r]+)/i,/^(?:[\n]+)/i,/^(?:"[^"%\r\n\v\b\\]+")/i,/^(?:"[^"]*")/i,/^(?:erDiagram\b)/i,/^(?:\{)/i,/^(?:#)/i,/^(?:#)/i,/^(?:,)/i,/^(?::::)/i,/^(?::)/i,/^(?:\s+)/i,/^(?:\b((?:PK)|(?:FK)|(?:UK))\b)/i,/^(?:([^\s]*)[~].*[~]([^\s]*))/i,/^(?:([\*A-Za-z_\u00C0-\uFFFF][A-Za-z0-9\-\_\[\]\(\)\.,\u00C0-\uFFFF\*]*))/i,/^(?:[`])/i,/^(?:[^`]+)/i,/^(?:[`])/i,/^(?:"[^"]*")/i,/^(?:[\n]+)/i,/^(?:\})/i,/^(?:.)/i,/^(?:\[)/i,/^(?:\])/i,/^(?:style\b)/i,/^(?:[\n]+)/i,/^(?:\s+)/i,/^(?::)/i,/^(?:,)/i,/^(?:#)/i,/^(?:classDef\b)/i,/^(?:class\b)/i,/^(?:subgraph\b)/i,/^(?:end\b\s*)/i,/^(?:one or zero\b)/i,/^(?:one or more\b)/i,/^(?:one or many\b)/i,/^(?:1\+)/i,/^(?:\|o\b)/i,/^(?:zero or one\b)/i,/^(?:zero or more\b)/i,/^(?:zero or many\b)/i,/^(?:0\+)/i,/^(?:\}o\b)/i,/^(?:many\(0\))/i,/^(?:many\(1\))/i,/^(?:many\b)/i,/^(?:\}\|)/i,/^(?:one\b)/i,/^(?:only one\b)/i,/^(?:[0-9]+\.[0-9]+)/i,/^(?:1(?=\s+[A-Za-z_"']))/i,/^(?:1(?=\s+[0-9]))/i,/^(?:1(?=(--|\.\.|\.-|-\.)))/i,/^(?:1\b)/i,/^(?:[0-9]+)/i,/^(?:\|\|)/i,/^(?:o\|)/i,/^(?:o\{)/i,/^(?:\|\{)/i,/^(?:u(?=[\.\-\|]))/i,/^(?:\.\.)/i,/^(?:--)/i,/^(?:to\b)/i,/^(?:optionally to\b)/i,/^(?:\.-)/i,/^(?:-\.)/i,/^(?:([^\x00-\x7F]|\w|-|\*)+)/i,/^(?:;)/i,/^(?:([^\x00-\x7F]|\w|-|\*|\.)+)/i,/^(?:.)/i,/^(?:$)/i],conditions:{style:{rules:[36,37,38,39,40,78,79],inclusive:!1},acc_descr_multiline:{rules:[5,6],inclusive:!1},acc_descr:{rules:[3],inclusive:!1},acc_title:{rules:[1],inclusive:!1},block_bq:{rules:[27,28],inclusive:!1},block:{rules:[22,23,24,25,26,29,30,31,32],inclusive:!1},INITIAL:{rules:[0,2,4,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,33,34,35,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,80,81,82],inclusive:!0}}};return F})();yt.lexer=le;function mt(){this.yy={}}return p(mt,"Parser"),mt.prototype=yt,yt.Parser=mt,new mt})();Ct.parser=Ct;var ae=Ct;var ut=class{constructor(){this.entities=new Map;this.relationships=[];this.classes=new Map;this.subgraphDepth=0;this.subGraphs=[];this.subGraphLookup=new Map;this.subCount=0;this.direction="TB";this.Cardinality={ZERO_OR_ONE:"ZERO_OR_ONE",ZERO_OR_MORE:"ZERO_OR_MORE",ONE_OR_MORE:"ONE_OR_MORE",ONLY_ONE:"ONLY_ONE",MD_PARENT:"MD_PARENT"};this.Identification={NON_IDENTIFYING:"NON_IDENTIFYING",IDENTIFYING:"IDENTIFYING"};this.setAccTitle=zt;this.getAccTitle=Ut;this.setAccDescription=jt;this.getAccDescription=Kt;this.setDiagramTitle=Zt;this.getDiagramTitle=Wt;this.getConfig=p(()=>z().er,"getConfig");this.clear(),this.addEntity=this.addEntity.bind(this),this.addAttributes=this.addAttributes.bind(this),this.addRelationship=this.addRelationship.bind(this),this.setDirection=this.setDirection.bind(this),this.addCssStyles=this.addCssStyles.bind(this),this.addClass=this.addClass.bind(this),this.setClass=this.setClass.bind(this),this.setAccTitle=this.setAccTitle.bind(this),this.setAccDescription=this.setAccDescription.bind(this),this.addSubGraph=this.addSubGraph.bind(this)}static{p(this,"ErDB")}addEntity(a,o=""){return this.entities.has(a)?!this.entities.get(a)?.alias&&o&&(this.entities.get(a).alias=o,A.info(`Add alias '${o}' to entity '${a}'`)):(this.entities.set(a,{id:`entity-${a}-${this.entities.size}`,label:a,attributes:[],alias:o,shape:"erBox",look:z().look??"default",cssClasses:"default",cssStyles:[],labelType:"markdown"}),A.info("Added new entity :",a)),this.entities.get(a)}getEntity(a){return this.entities.get(a)}getEntities(){return this.entities}getClasses(){return this.classes}addAttributes(a,o){let l=this.addEntity(a),r;for(r=o.length-1;r>=0;r--)o[r].keys||(o[r].keys=[]),o[r].comment||(o[r].comment=""),l.attributes.push(o[r]),A.debug("Added attribute ",o[r].name)}addRelationship(a,o,l,r){let u;if(this.subGraphLookup.has(a))u=a;else{let m=this.addEntity(a);if(!m)return;u=m.id}let k;if(this.subGraphLookup.has(l))k=l;else{let m=this.addEntity(l);if(!m)return;k=m.id}let g={entityA:u,roleA:o,entityB:k,relSpec:r};this.relationships.push(g),A.debug("Added new relationship :",g)}getRelationships(){return this.relationships}getDirection(){return this.direction}setDirection(a){this.direction=a}getCompiledStyles(a){let o=[];for(let l of a){let r=this.classes.get(l);r?.styles&&(o=[...o,...r.styles??[]].map(u=>u.trim())),r?.textStyles&&(o=[...o,...r.textStyles??[]].map(u=>u.trim()))}return o}addCssStyles(a,o){for(let l of a){let r=this.entities.get(l),u=this.subGraphLookup.get(l);if(o){if(r)for(let k of o)r.cssStyles.push(k);if(u){u.cssStyles||(u.cssStyles=[]);for(let k of o)u.cssStyles.push(k)}}}}addClass(a,o){a.forEach(l=>{let r=this.classes.get(l);r===void 0&&(r={id:l,styles:[],textStyles:[]},this.classes.set(l,r)),o&&o.forEach(function(u){if(/color/.exec(u)){let k=u.replace("fill","bgFill");r.textStyles.push(k)}r.styles.push(u)})})}addSubGraph(a,o,l){let r=a.text.trim(),u=l.text,g=p(f=>{let v=new Set,D;return{nodeList:f.filter(x=>{if(x?.stmt)return x.stmt==="dir"&&(D=x.value),!1;if(typeof x!="string")return!1;let R=x.trim();return!R||v.has(R)?!1:(v.add(R),!0)}),dir:D}},"uniq")(o.flat()),m=g.nodeList,N=g.dir;r=r??"subGraph"+this.subCount,u=u||"",u=this.sanitizeText(u),this.subCount=this.subCount+1;let b={id:r,nodes:m,title:u.trim(),classes:[],cssStyles:[],dir:N,labelType:this.sanitizeNodeLabelType(l?.type)};return A.info("Adding",b.id,b.nodes,b.dir),b.nodes=this.makeUniq(b,this.subGraphs).nodes,this.subGraphs.push(b),this.subGraphLookup.set(r,b),r}getSubGraphs(){return this.subGraphs}setClass(a,o){for(let l of a){let r=this.entities.get(l);if(r)for(let k of o)r.cssClasses+=" "+k;let u=this.subGraphLookup.get(l);if(u)for(let k of o)u.classes.push(k)}}subgraphNodeCache(a){let o=new Set;for(let l of a)for(let r of l.nodes)o.add(r);return o}makeUniq(a,o){let l=this.subgraphNodeCache(o),r=[];return a.nodes.forEach((u,k)=>{l.has(u)?A.warn(`Entity '${u}' already belongs to another subgraph and will be ignored`):r.push(a.nodes[k])}),{nodes:r}}sanitizeText(a){return Pt.sanitizeText(a,z())}sanitizeNodeLabelType(a){switch(a){case"markdown":case"string":case"text":return a;default:return"markdown"}}clear(){this.entities=new Map,this.classes=new Map,this.relationships=[],this.subGraphs=[],this.subGraphLookup=new Map,this.subCount=0,this.subgraphDepth=0,Yt()}getData(){let a=[],o=[],l=z(),r=this.getSubGraphs(),u=new Map,k=new Map;for(let b=r.length-1;b>=0;b--){let f=r[b];f.nodes.length>0&&k.set(f.id,!0);for(let v of f.nodes)u.set(v,f.id)}for(let b=r.length-1;b>=0;b--){let f=r[b];a.push({id:f.id,label:f.title,labelStyle:"",labelType:f.labelType,parentId:u.get(f.id),padding:8,cssCompiledStyles:this.getCompiledStyles(f.classes),cssStyles:f.cssStyles,cssClasses:f.classes.join(" "),shape:"rect",dir:f.dir,isGroup:!0,look:l.look})}let g=new Set(r.map(b=>b.id)),m=0;for(let b of this.entities.keys()){if(g.has(b))continue;let f=this.entities.get(b);f&&(f.cssCompiledStyles=this.getCompiledStyles(f.cssClasses.split(" ")),f.colorIndex=m++,a.push({...f,parentId:u.get(b),isGroup:!1}))}let N=0;for(let b of this.relationships){let f={id:Qt(b.entityA,b.entityB,{prefix:"id",counter:N++}),type:"normal",curve:"basis",start:b.entityA,end:b.entityB,label:b.roleA,labelpos:"c",thickness:"normal",classes:"relationshipLine",arrowTypeStart:b.relSpec.cardB.toLowerCase(),arrowTypeEnd:b.relSpec.cardA.toLowerCase(),pattern:b.relSpec.relType=="IDENTIFYING"?"solid":"dashed",look:l.look,labelType:"markdown"};o.push(f)}return{nodes:a,edges:o,other:{},config:l,direction:this.direction}}};var xt={};pe(xt,{draw:()=>be});var be=p(async function(s,a,o,l){A.info("REF0:"),A.info("Drawing er diagram (unified)",a);let{securityLevel:r,er:u,layout:k}=z(),g=l.db.getData(),m=ee(a,r);g.type=l.type,g.layoutAlgorithm=ie(k),g.config.flowchart.nodeSpacing=u?.nodeSpacing||140,g.config.flowchart.rankSpacing=u?.rankSpacing||80,g.direction=l.db.getDirection();let{config:N}=g,{look:b}=N;b==="neo"?g.markers=["only_one_neo","zero_or_one_neo","one_or_more_neo","zero_or_more_neo"]:g.markers=["only_one","zero_or_one","one_or_more","zero_or_more"],g.diagramId=a,await se(g,m);let f=m.selectAll('[id*="-background"]');Array.from(f).length>0&&f.each(function(){let D=qt(this),x=D.attr("id").replace("-background",""),R=m.select(`#${CSS.escape(x)}`);if(!R.empty()){let O=R.attr("transform");D.attr("transform",O)}});let v=8;Ht.insertTitle(m,"erDiagramTitleText",u?.titleTopMargin??25,l.db.getDiagramTitle()),re(m,v,"erDiagram",u?.useMaxWidth??!0)},"draw");var ne=p((s,a)=>{let o=Ft,l=o(s,"r"),r=o(s,"g"),u=o(s,"b");return Bt(l,r,u,a)},"fade"),fe=p(s=>{let{theme:a,bkgColorArray:o,borderColorArray:l}=s;if(!Jt(a,l))return"";let r=$t(s.look),u=Xt(o),k="";for(let g=0;g<te(l);g++){let m=l[g],N=u?`fill: ${o[g%o.length]};`:"";k+=`
[data-look="${r}"][data-color-id="color-${g}"].node path {
stroke: ${m};
${N}
}
[data-look="${r}"][data-color-id="color-${g}"].node rect {
stroke: ${m};
${N}
}
`}return k},"genColor"),ge=p(s=>{let{look:a,theme:o,erEdgeLabelBackground:l,strokeWidth:r}=s;return`
${fe(s)}
.entityBox {
fill: ${s.mainBkg};
stroke: ${s.nodeBorder};
}
.relationshipLabelBox {
fill: ${s.tertiaryColor};
opacity: 0.7;
background-color: ${s.tertiaryColor};
rect {
opacity: 0.5;
}
}
.labelBkg {
background-color: ${ht.has(o)&&l?l:ne(s.tertiaryColor,.5)};
}
.edgeLabel {
background-color: ${ht.has(o)&&l?l:s.edgeLabelBackground};
}
.edgeLabel .label rect {
fill: ${ht.has(o)&&l?l:s.edgeLabelBackground};
}
.edgeLabel .label text {
fill: ${s.textColor};
}
.edgeLabel .label {
fill: ${s.nodeBorder};
font-size: 14px;
}
.label {
font-family: ${s.fontFamily};
color: ${s.nodeTextColor||s.textColor};
}
.edge-pattern-dashed {
stroke-dasharray: 8,8;
}
.node rect,
.node circle,
.node ellipse,
.node polygon
{
fill: ${s.mainBkg};
stroke: ${s.nodeBorder};
stroke-width: ${a==="neo"?r:"1px"};
}
.relationshipLine {
stroke: ${s.lineColor};
stroke-width: ${a==="neo"?r:"1px"};
fill: none;
}
.marker {
fill: none !important;
stroke: ${s.lineColor} !important;
stroke-width: 1;
}
[data-look=neo].labelBkg {
background-color: ${ne(s.tertiaryColor,.5)};
}
.cluster rect {
fill: ${s.clusterBkg??s.mainBkg};
stroke: ${s.clusterBorder??s.nodeBorder};
stroke-width: 1px;
}
.cluster text {
fill: ${s.titleColor??s.textColor};
}
.cluster-label text {
fill: ${s.titleColor??s.textColor};
}
`},"getStyles"),oe=ge;var Ue={parser:ae,get db(){return new ut},renderer:xt,styles:oe};export{Ue as diagram};