import{a as W,b as L,c as H}from"./chunk-JCZQFD5O.mjs";import{b as m}from"./chunk-M3OUVPMK.mjs";import"./chunk-MGPXXO54.mjs";import"./chunk-7HHNZHC5.mjs";import"./chunk-LT56AXER.mjs";import"./chunk-6WMSPMWD.mjs";import{a as g,c as a,p as k,s as N}from"./chunk-RKGGAEC6.mjs";import{select as y}from"d3";import{layout as $}from"dagre-d3-es/src/dagre/index.js";import*as X from"dagre-d3-es/src/graphlib/index.js";var u={},h=20,p=g(function(e){let i=Object.entries(u).find(x=>x[1].label===e);if(i)return i[0]},"getGraphId"),B=g(function(e){e.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"),e.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"),e.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"),e.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"),e.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"),e.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"),e.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"),e.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"),A=g(function(e,i,x,n){let f=k().class;u={},a.info("Rendering diagram "+e);let E=k().securityLevel,b;E==="sandbox"&&(b=y("#i"+i));let w=E==="sandbox"?y(b.nodes()[0].contentDocument.body):y("body"),o=w.select(`[id='${i}']`);B(o);let r=new X.Graph({multigraph:!0});r.setGraph({isMultiGraph:!0}),r.setDefaultEdgeLabel(function(){return{}});let l=n.db.getClasses(),Z=Object.keys(l);for(let t of Z){let d=l[t],s=m.drawClass(o,d,f,n);u[s.id]=s,r.setNode(s.id,s),a.info("Org height: "+s.height)}n.db.getRelations().forEach(function(t){a.info("tjoho"+p(t.id1)+p(t.id2)+JSON.stringify(t)),r.setEdge(p(t.id1),p(t.id2),{relation:t},t.title||"DEFAULT")}),n.db.getNotes().forEach(function(t){a.debug(`Adding note: ${JSON.stringify(t)}`);let d=m.drawNote(o,t,f,n);u[d.id]=d,r.setNode(d.id,d),t.class&&t.class in l&&r.setEdge(t.id,p(t.class),{relation:{id1:t.id,id2:t.class,relation:{type1:"none",type2:"none",lineType:10}}},"DEFAULT")}),$(r),r.nodes().forEach(function(t){t!==void 0&&r.node(t)!==void 0&&(a.debug("Node "+t+": "+JSON.stringify(r.node(t))),w.select("#"+(n.db.lookUpDomId(t)||t)).attr("transform","translate("+(r.node(t).x-r.node(t).width/2)+","+(r.node(t).y-r.node(t).height/2)+" )"))}),r.edges().forEach(function(t){t!==void 0&&r.edge(t)!==void 0&&(a.debug("Edge "+t.v+" -> "+t.w+": "+JSON.stringify(r.edge(t))),m.drawEdge(o,r.edge(t),r.edge(t).relation,f,n))});let c=o.node().getBBox(),M=c.width+h*2,D=c.height+h*2;N(o,D,M,f.useMaxWidth);let S=`${c.x-h} ${c.y-h} ${M} ${D}`;a.debug(`viewBox ${S}`),o.attr("viewBox",S)},"draw"),Y={draw:A};var K={parser:W,db:L,renderer:Y,styles:H,init:e=>{e.class||(e.class={}),e.class.arrowMarkerAbsolute=e.arrowMarkerAbsolute,L.clear()}};export{K as diagram};