livebook/static/assets/classDiagram-v2-d4efdcc3-NAMGACT7.js
2024-01-24 15:02:24 +00:00

2 lines
4.9 KiB
JavaScript

import{a as P,b as N,c as $}from"./chunk-HSKGEAOU.js";import{a as z}from"./chunk-YDUJKTJQ.js";import"./chunk-RNCRXQUO.js";import"./chunk-RB5OF3IH.js";import"./chunk-BZUL2CAN.js";import{j as G}from"./chunk-SWZYHCA4.js";import{$a as i,E as L,Fa as d,I as U,Ka as D,Pa as E,Qa as q,Ya as F,b as K,c as Q,cb as H,h as w}from"./chunk-KR7JTV7U.js";import{a as S,h as T}from"./chunk-3V74GZ4F.js";var it=T(K(),1),rt=T(Q(),1),ct=T(U(),1);var C=n=>D.sanitizeText(n,i()),_={dividerMargin:10,padding:5,textHeight:10,curve:void 0},X=function(n,o,f,s){let t=Object.keys(n);d.info("keys:",t),d.info(n),t.forEach(function(r){var p;var l,c;let e=n[r],y={shape:"rect",id:e.id,domId:e.domId,labelText:C(e.id),labelStyle:"",style:"fill: none; stroke: black",padding:(p=(l=i().flowchart)==null?void 0:l.padding)!=null?p:(c=i().class)==null?void 0:c.padding};o.setNode(e.id,y),W(e.classes,o,f,s,e.id),d.info("setNode",y)})},W=function(n,o,f,s,t){let r=Object.keys(n);d.info("keys:",r),d.info(n),r.filter(l=>n[l].parent==t).forEach(function(l){var g,m;var c,e;let a=n[l],y=a.cssClasses.join(" "),p={labelStyle:"",style:""},v=(g=a.label)!=null?g:a.id,b=0,h="class_box",u={labelStyle:p.labelStyle,shape:h,labelText:C(v),classData:a,rx:b,ry:b,class:y,style:p.style,id:a.id,domId:a.domId,tooltip:s.db.getTooltip(a.id,t)||"",haveCallback:a.haveCallback,link:a.link,width:a.type==="group"?500:void 0,type:a.type,padding:(m=(c=i().flowchart)==null?void 0:c.padding)!=null?m:(e=i().class)==null?void 0:e.padding};o.setNode(a.id,u),t&&o.setParent(a.id,t),d.info("setNode",u)})},Y=function(n,o,f,s){d.info(n),n.forEach(function(t,r){var m;var l,c;let e=t,a="",y={labelStyle:"",style:""},p=e.text,v=0,b="note",h={labelStyle:y.labelStyle,shape:b,labelText:C(p),noteData:e,rx:v,ry:v,class:a,style:y.style,id:e.id,domId:e.id,tooltip:"",type:"note",padding:(m=(l=i().flowchart)==null?void 0:l.padding)!=null?m:(c=i().class)==null?void 0:c.padding};if(o.setNode(e.id,h),d.info("setNode",h),!e.class||!(e.class in s))return;let u=f+r,g={id:`edgeNote${u}`,classes:"relation",pattern:"dotted",arrowhead:"none",startLabelRight:"",endLabelLeft:"",arrowTypeStart:"none",arrowTypeEnd:"none",style:"fill:none",labelStyle:"",curve:E(_.curve,L)};o.setEdge(e.id,e.class,g,u)})},Z=function(n,o){let f=i().flowchart,s=0;n.forEach(function(t){var c;var r;s++;let l={classes:"relation",pattern:t.relation.lineType==1?"dashed":"solid",id:"id"+s,arrowhead:t.type==="arrow_open"?"none":"normal",startLabelRight:t.relationTitle1==="none"?"":t.relationTitle1,endLabelLeft:t.relationTitle2==="none"?"":t.relationTitle2,arrowTypeStart:V(t.relation.type1),arrowTypeEnd:V(t.relation.type2),style:"fill:none",labelStyle:"",curve:E(f==null?void 0:f.curve,L)};if(d.info(l,t),t.style!==void 0){let e=q(t.style);l.style=e.style,l.labelStyle=e.labelStyle}t.text=t.title,t.text===void 0?t.style!==void 0&&(l.arrowheadStyle="fill: #333"):(l.arrowheadStyle="fill: #333",l.labelpos="c",((c=(r=i().flowchart)==null?void 0:r.htmlLabels)!=null?c:i().htmlLabels)?(l.labelType="html",l.label='<span class="edgeLabel">'+t.text+"</span>"):(l.labelType="text",l.label=t.text.replace(D.lineBreakRegex,`
`),t.style===void 0&&(l.style=l.style||"stroke: #333; stroke-width: 1.5px;fill:none"),l.labelStyle=l.labelStyle.replace("color:","fill:"))),o.setEdge(t.id1,t.id2,l,s)})},j=function(n){_=S(S({},_),n)},O=async function(n,o,f,s){var m,A,I,M;d.info("Drawing class - ",o);let t=(m=i().flowchart)!=null?m:i().class,r=i().securityLevel;d.info("config:",t);let l=(A=t==null?void 0:t.nodeSpacing)!=null?A:50,c=(I=t==null?void 0:t.rankSpacing)!=null?I:50,e=new G({multigraph:!0,compound:!0}).setGraph({rankdir:s.db.getDirection(),nodesep:l,ranksep:c,marginx:8,marginy:8}).setDefaultEdgeLabel(function(){return{}}),a=s.db.getNamespaces(),y=s.db.getClasses(),p=s.db.getRelations(),v=s.db.getNotes();d.info(p),X(a,e,o,s),W(y,e,o,s),Z(p,e),Y(v,e,p.length+1,y);let b;r==="sandbox"&&(b=w("#i"+o));let h=r==="sandbox"?w(b.nodes()[0].contentDocument.body):w("body"),u=h.select(`[id="${o}"]`),g=h.select("#"+o+" g");if(await z(g,e,["aggregation","extension","composition","dependency","lollipop"],"classDiagram",o),F.insertTitle(u,"classTitleText",(M=t==null?void 0:t.titleTopMargin)!=null?M:5,s.db.getDiagramTitle()),H(e,u,t==null?void 0:t.diagramPadding,t==null?void 0:t.useMaxWidth),!(t!=null&&t.htmlLabels)){let R=r==="sandbox"?b.nodes()[0].contentDocument:document,J=R.querySelectorAll('[id="'+o+'"] .edgeLabel .label');for(let k of J){let B=k.getBBox(),x=R.createElementNS("http://www.w3.org/2000/svg","rect");x.setAttribute("rx",0),x.setAttribute("ry",0),x.setAttribute("width",B.width),x.setAttribute("height",B.height),k.insertBefore(x,k.firstChild)}}};function V(n){let o;switch(n){case 0:o="aggregation";break;case 1:o="extension";break;case 2:o="composition";break;case 3:o="dependency";break;case 4:o="lollipop";break;default:o="none"}return o}var tt={setConf:j,draw:O},yt={parser:P,db:N,renderer:tt,styles:$,init:n=>{n.class||(n.class={}),n.class.arrowMarkerAbsolute=n.arrowMarkerAbsolute,N.clear()}};export{yt as diagram};