All Downloads are FREE. Search and download functionalities are using the official Maven repository.

package.dist.chunks.mermaid.esm.min.classDiagram-AMI2HWAO.mjs Maven / Gradle / Ivy

Go to download

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

There is a newer version: 11.4.0
Show newest version
import{a as P,b as _,c as X}from"./chunk-OXEAGKI4.mjs";import{a as I}from"./chunk-BOP2KBYH.mjs";import{a as G}from"./chunk-6XGRHI2A.mjs";import{m as B}from"./chunk-INOGIEW4.mjs";import"./chunk-TI4EEUUG.mjs";import{Ca as A,Ga as W,H as v,M as C,X as H,b as h,fa as T}from"./chunk-DMXVZUOD.mjs";import"./chunk-BKDDFIKN.mjs";import"./chunk-YPUTD6PB.mjs";import"./chunk-6BY5RJGC.mjs";import{a as y}from"./chunk-GTKDMUJJ.mjs";var Y=0,Z=y(function(i,r,t,s,p){let g=y(function(e){switch(e){case p.db.relationType.AGGREGATION:return"aggregation";case p.db.relationType.EXTENSION:return"extension";case p.db.relationType.COMPOSITION:return"composition";case p.db.relationType.DEPENDENCY:return"dependency";case p.db.relationType.LOLLIPOP:return"lollipop"}},"getRelationType");r.points=r.points.filter(e=>!Number.isNaN(e.y));let o=r.points,c=A().x(function(e){return e.x}).y(function(e){return e.y}).curve(W),n=i.append("path").attr("d",c(o)).attr("id","edge"+Y).attr("class","relation"),a="";s.arrowMarkerAbsolute&&(a=window.location.protocol+"//"+window.location.host+window.location.pathname+window.location.search,a=a.replace(/\(/g,"\\("),a=a.replace(/\)/g,"\\)")),t.relation.lineType==1&&n.attr("class","relation dashed-line"),t.relation.lineType==10&&n.attr("class","relation dotted-line"),t.relation.type1!=="none"&&n.attr("marker-start","url("+a+"#"+g(t.relation.type1)+"Start)"),t.relation.type2!=="none"&&n.attr("marker-end","url("+a+"#"+g(t.relation.type2)+"End)");let m,x,u=r.points.length,k=B.calcLabelPosition(r.points);m=k.x,x=k.y;let f,w,b,L;if(u%2!==0&&u>1){let e=B.calcCardinalityPosition(t.relation.type1!=="none",r.points,r.points[0]),d=B.calcCardinalityPosition(t.relation.type2!=="none",r.points,r.points[u-1]);h.debug("cardinality_1_point "+JSON.stringify(e)),h.debug("cardinality_2_point "+JSON.stringify(d)),f=e.x,w=e.y,b=d.x,L=d.y}if(t.title!==void 0){let e=i.append("g").attr("class","classLabel"),d=e.append("text").attr("class","label").attr("x",m).attr("y",x).attr("fill","red").attr("text-anchor","middle").text(t.title);window.label=d;let l=d.node().getBBox();e.insert("rect",":first-child").attr("class","box").attr("x",l.x-s.padding/2).attr("y",l.y-s.padding/2).attr("width",l.width+s.padding).attr("height",l.height+s.padding)}h.info("Rendering relation "+JSON.stringify(t)),t.relationTitle1!==void 0&&t.relationTitle1!=="none"&&i.append("g").attr("class","cardinality").append("text").attr("class","type1").attr("x",f).attr("y",w).attr("fill","black").attr("font-size","6").text(t.relationTitle1),t.relationTitle2!==void 0&&t.relationTitle2!=="none"&&i.append("g").attr("class","cardinality").append("text").attr("class","type2").attr("x",b).attr("y",L).attr("fill","black").attr("font-size","6").text(t.relationTitle2),Y++},"drawEdge"),R=y(function(i,r,t,s){h.debug("Rendering class ",r,t);let p=r.id,g={id:p,label:r.id,width:0,height:0},o=i.append("g").attr("id",s.db.lookUpDomId(p)).attr("class","classGroup"),c;r.link?c=o.append("svg:a").attr("xlink:href",r.link).attr("target",r.linkTarget).append("text").attr("y",t.textHeight+t.padding).attr("x",0):c=o.append("text").attr("y",t.textHeight+t.padding).attr("x",0);let n=!0;r.annotations.forEach(function(d){let l=c.append("tspan").text("\xAB"+d+"\xBB");n||l.attr("dy",t.textHeight),n=!1});let a=J(r),m=c.append("tspan").text(a).attr("class","title");n||m.attr("dy",t.textHeight);let x=c.node().getBBox().height,u,k,f;if(r.members.length>0){u=o.append("line").attr("x1",0).attr("y1",t.padding+x+t.dividerMargin/2).attr("y2",t.padding+x+t.dividerMargin/2);let d=o.append("text").attr("x",t.padding).attr("y",x+t.dividerMargin+t.textHeight).attr("fill","white").attr("class","classText");n=!0,r.members.forEach(function(l){$(d,l,n,t),n=!1}),k=d.node().getBBox()}if(r.methods.length>0){f=o.append("line").attr("x1",0).attr("y1",t.padding+x+t.dividerMargin+k.height).attr("y2",t.padding+x+t.dividerMargin+k.height);let d=o.append("text").attr("x",t.padding).attr("y",x+2*t.dividerMargin+k.height+t.textHeight).attr("fill","white").attr("class","classText");n=!0,r.methods.forEach(function(l){$(d,l,n,t),n=!1})}let w=o.node().getBBox();var b=" ";r.cssClasses.length>0&&(b=b+r.cssClasses.join(" "));let e=o.insert("rect",":first-child").attr("x",0).attr("y",0).attr("width",w.width+2*t.padding).attr("height",w.height+t.padding+.5*t.dividerMargin).attr("class",b).node().getBBox().width;return c.node().childNodes.forEach(function(d){d.setAttribute("x",(e-d.getBBox().width)/2)}),r.tooltip&&c.insert("title").text(r.tooltip),u&&u.attr("x2",e),f&&f.attr("x2",e),g.width=e,g.height=w.height+t.padding+.5*t.dividerMargin,g},"drawClass"),J=y(function(i){let r=i.id;return i.type&&(r+="<"+v(i.type)+">"),r},"getClassTitleString"),F=y(function(i,r,t,s){h.debug("Rendering note ",r,t);let p=r.id,g={id:p,text:r.text,width:0,height:0},o=i.append("g").attr("id",p).attr("class","classGroup"),c=o.append("text").attr("y",t.textHeight+t.padding).attr("x",0),n=JSON.parse(`"${r.text}"`).split(`
`);n.forEach(function(u){h.debug(`Adding line: ${u}`),c.append("tspan").text(u).attr("class","title").attr("dy",t.textHeight)});let a=o.node().getBBox(),x=o.insert("rect",":first-child").attr("x",0).attr("y",0).attr("width",a.width+2*t.padding).attr("height",a.height+n.length*t.textHeight+t.padding+.5*t.dividerMargin).node().getBBox().width;return c.node().childNodes.forEach(function(u){u.setAttribute("x",(x-u.getBBox().width)/2)}),g.width=x,g.height=a.height+n.length*t.textHeight+t.padding+.5*t.dividerMargin,g},"drawNote"),$=y(function(i,r,t,s){let{displayText:p,cssStyle:g}=r.getDisplayDetails(),o=i.append("tspan").attr("x",s.padding).text(p);g!==""&&o.attr("style",r.cssStyle),t||o.attr("dy",s.textHeight)},"addTspan"),M={getClassTitleString:J,drawClass:R,drawEdge:Z,drawNote:F};var S={},N=20,E=y(function(i){let r=Object.entries(S).find(t=>t[1].label===i);if(r)return r[0]},"getGraphId"),U=y(function(i){i.append("defs").append("marker").attr("id","extensionStart").attr("class","extension").attr("refX",0).attr("refY",7).attr("markerWidth",190).attr("markerHeight",240).attr("orient","auto").append("path").attr("d","M 1,7 L18,13 V 1 Z"),i.append("defs").append("marker").attr("id","extensionEnd").attr("refX",19).attr("refY",7).attr("markerWidth",20).attr("markerHeight",28).attr("orient","auto").append("path").attr("d","M 1,1 V 13 L18,7 Z"),i.append("defs").append("marker").attr("id","compositionStart").attr("class","extension").attr("refX",0).attr("refY",7).attr("markerWidth",190).attr("markerHeight",240).attr("orient","auto").append("path").attr("d","M 18,7 L9,13 L1,7 L9,1 Z"),i.append("defs").append("marker").attr("id","compositionEnd").attr("refX",19).attr("refY",7).attr("markerWidth",20).attr("markerHeight",28).attr("orient","auto").append("path").attr("d","M 18,7 L9,13 L1,7 L9,1 Z"),i.append("defs").append("marker").attr("id","aggregationStart").attr("class","extension").attr("refX",0).attr("refY",7).attr("markerWidth",190).attr("markerHeight",240).attr("orient","auto").append("path").attr("d","M 18,7 L9,13 L1,7 L9,1 Z"),i.append("defs").append("marker").attr("id","aggregationEnd").attr("refX",19).attr("refY",7).attr("markerWidth",20).attr("markerHeight",28).attr("orient","auto").append("path").attr("d","M 18,7 L9,13 L1,7 L9,1 Z"),i.append("defs").append("marker").attr("id","dependencyStart").attr("class","extension").attr("refX",0).attr("refY",7).attr("markerWidth",190).attr("markerHeight",240).attr("orient","auto").append("path").attr("d","M 5,7 L9,13 L1,7 L9,1 Z"),i.append("defs").append("marker").attr("id","dependencyEnd").attr("refX",19).attr("refY",7).attr("markerWidth",20).attr("markerHeight",28).attr("orient","auto").append("path").attr("d","M 18,7 L9,13 L14,7 L9,1 Z")},"insertMarkers"),z=y(function(i,r,t,s){let p=H().class;S={},h.info("Rendering diagram "+i);let g=H().securityLevel,o;g==="sandbox"&&(o=T("#i"+r));let c=g==="sandbox"?T(o.nodes()[0].contentDocument.body):T("body"),n=c.select(`[id='${r}']`);U(n);let a=new G({multigraph:!0});a.setGraph({isMultiGraph:!0}),a.setDefaultEdgeLabel(function(){return{}});let m=s.db.getClasses(),x=[...m.keys()];for(let e of x){let d=m.get(e),l=M.drawClass(n,d,p,s);S[l.id]=l,a.setNode(l.id,l),h.info("Org height: "+l.height)}s.db.getRelations().forEach(function(e){h.info("tjoho"+E(e.id1)+E(e.id2)+JSON.stringify(e)),a.setEdge(E(e.id1),E(e.id2),{relation:e},e.title||"DEFAULT")}),s.db.getNotes().forEach(function(e){h.debug(`Adding note: ${JSON.stringify(e)}`);let d=M.drawNote(n,e,p,s);S[d.id]=d,a.setNode(d.id,d),e.class&&m.has(e.class)&&a.setEdge(e.id,E(e.class),{relation:{id1:e.id,id2:e.class,relation:{type1:"none",type2:"none",lineType:10}}},"DEFAULT")}),I(a),a.nodes().forEach(function(e){e!==void 0&&a.node(e)!==void 0&&(h.debug("Node "+e+": "+JSON.stringify(a.node(e))),c.select("#"+(s.db.lookUpDomId(e)||e)).attr("transform","translate("+(a.node(e).x-a.node(e).width/2)+","+(a.node(e).y-a.node(e).height/2)+" )"))}),a.edges().forEach(function(e){e!==void 0&&a.edge(e)!==void 0&&(h.debug("Edge "+e.v+" -> "+e.w+": "+JSON.stringify(a.edge(e))),M.drawEdge(n,a.edge(e),a.edge(e).relation,p,s))});let f=n.node().getBBox(),w=f.width+N*2,b=f.height+N*2;C(n,b,w,p.useMaxWidth);let L=`${f.x-N} ${f.y-N} ${w} ${b}`;h.debug(`viewBox ${L}`),n.attr("viewBox",L)},"draw"),O={draw:z};var ht={parser:P,db:_,renderer:O,styles:X,init:y(i=>{i.class||(i.class={}),i.class.arrowMarkerAbsolute=i.arrowMarkerAbsolute,_.clear()},"init")};export{ht as diagram};




© 2015 - 2024 Weber Informatics LLC | Privacy Policy