import"./chunk-DseTPa7n.js";import{t as e}from"./dist-C9I7GKwI.js";import{O as t,Rt as n,T as r,Ut as i,_ as a,l as o,z as s,zt as c}from"./mermaid-b5860b54-0Lyr29sO.js";import{d as l}from"./step-CltBpEWI.js";import{t as u}from"./line-CJPnuAmr.js";import{t as d}from"./graphlib-78OoZqt6.js";import{t as f}from"./dagre-JFNtiDgC.js";import{n as p,r as m,t as h}from"./styles-9a916d00-B8beHA8k.js";i(),e(),n();var g=0,_=function(e,t,n,i,a){let o=function(e){switch(e){case a.db.relationType.AGGREGATION:return`aggregation`;case a.db.relationType.EXTENSION:return`extension`;case a.db.relationType.COMPOSITION:return`composition`;case a.db.relationType.DEPENDENCY:return`dependency`;case a.db.relationType.LOLLIPOP:return`lollipop`}};t.points=t.points.filter(e=>!Number.isNaN(e.y));let c=t.points,d=u().x(function(e){return e.x}).y(function(e){return e.y}).curve(l),f=e.append(`path`).attr(`d`,d(c)).attr(`id`,`edge`+g).attr(`class`,`relation`),p=``;i.arrowMarkerAbsolute&&(p=window.location.protocol+`//`+window.location.host+window.location.pathname+window.location.search,p=p.replace(/\(/g,`\\(`),p=p.replace(/\)/g,`\\)`)),n.relation.lineType==1&&f.attr(`class`,`relation dashed-line`),n.relation.lineType==10&&f.attr(`class`,`relation dotted-line`),n.relation.type1!==`none`&&f.attr(`marker-start`,`url(`+p+`#`+o(n.relation.type1)+`Start)`),n.relation.type2!==`none`&&f.attr(`marker-end`,`url(`+p+`#`+o(n.relation.type2)+`End)`);let m,h,_=t.points.length,v=s.calcLabelPosition(t.points);m=v.x,h=v.y;let y,b,x,S;if(_%2!=0&&_>1){let e=s.calcCardinalityPosition(n.relation.type1!==`none`,t.points,t.points[0]),i=s.calcCardinalityPosition(n.relation.type2!==`none`,t.points,t.points[_-1]);r.debug(`cardinality_1_point `+JSON.stringify(e)),r.debug(`cardinality_2_point `+JSON.stringify(i)),y=e.x,b=e.y,x=i.x,S=i.y}if(n.title!==void 0){let t=e.append(`g`).attr(`class`,`classLabel`),r=t.append(`text`).attr(`class`,`label`).attr(`x`,m).attr(`y`,h).attr(`fill`,`red`).attr(`text-anchor`,`middle`).text(n.title);window.label=r;let a=r.node().getBBox();t.insert(`rect`,`:first-child`).attr(`class`,`box`).attr(`x`,a.x-i.padding/2).attr(`y`,a.y-i.padding/2).attr(`width`,a.width+i.padding).attr(`height`,a.height+i.padding)}r.info(`Rendering relation `+JSON.stringify(n)),n.relationTitle1!==void 0&&n.relationTitle1!==`none`&&e.append(`g`).attr(`class`,`cardinality`).append(`text`).attr(`class`,`type1`).attr(`x`,y).attr(`y`,b).attr(`fill`,`black`).attr(`font-size`,`6`).text(n.relationTitle1),n.relationTitle2!==void 0&&n.relationTitle2!==`none`&&e.append(`g`).attr(`class`,`cardinality`).append(`text`).attr(`class`,`type2`).attr(`x`,x).attr(`y`,S).attr(`fill`,`black`).attr(`font-size`,`6`).text(n.relationTitle2),g++},v=function(e,t,n,i){r.debug(`Rendering class `,t,n);let a=t.id,o={id:a,label:t.id,width:0,height:0},s=e.append(`g`).attr(`id`,i.db.lookUpDomId(a)).attr(`class`,`classGroup`),c;c=t.link?s.append(`svg:a`).attr(`xlink:href`,t.link).attr(`target`,t.linkTarget).append(`text`).attr(`y`,n.textHeight+n.padding).attr(`x`,0):s.append(`text`).attr(`y`,n.textHeight+n.padding).attr(`x`,0);let l=!0;t.annotations.forEach(function(e){let t=c.append(`tspan`).text(`«`+e+`»`);l||t.attr(`dy`,n.textHeight),l=!1});let u=y(t),d=c.append(`tspan`).text(u).attr(`class`,`title`);l||d.attr(`dy`,n.textHeight);let f=c.node().getBBox().height,p,m,h;if(t.members.length>0){p=s.append(`line`).attr(`x1`,0).attr(`y1`,n.padding+f+n.dividerMargin/2).attr(`y2`,n.padding+f+n.dividerMargin/2);let e=s.append(`text`).attr(`x`,n.padding).attr(`y`,f+n.dividerMargin+n.textHeight).attr(`fill`,`white`).attr(`class`,`classText`);l=!0,t.members.forEach(function(t){x(e,t,l,n),l=!1}),m=e.node().getBBox()}if(t.methods.length>0){h=s.append(`line`).attr(`x1`,0).attr(`y1`,n.padding+f+n.dividerMargin+m.height).attr(`y2`,n.padding+f+n.dividerMargin+m.height);let e=s.append(`text`).attr(`x`,n.padding).attr(`y`,f+2*n.dividerMargin+m.height+n.textHeight).attr(`fill`,`white`).attr(`class`,`classText`);l=!0,t.methods.forEach(function(t){x(e,t,l,n),l=!1})}let g=s.node().getBBox();var _=` `;t.cssClasses.length>0&&(_+=t.cssClasses.join(` `));let v=s.insert(`rect`,`:first-child`).attr(`x`,0).attr(`y`,0).attr(`width`,g.width+2*n.padding).attr(`height`,g.height+n.padding+.5*n.dividerMargin).attr(`class`,_).node().getBBox().width;return c.node().childNodes.forEach(function(e){e.setAttribute(`x`,(v-e.getBBox().width)/2)}),t.tooltip&&c.insert(`title`).text(t.tooltip),p&&p.attr(`x2`,v),h&&h.attr(`x2`,v),o.width=v,o.height=g.height+n.padding+.5*n.dividerMargin,o},y=function(e){let n=e.id;return e.type&&(n+=`<`+t(e.type)+`>`),n},b=function(e,t,n,i){r.debug(`Rendering note `,t,n);let a=t.id,o={id:a,text:t.text,width:0,height:0},s=e.append(`g`).attr(`id`,a).attr(`class`,`classGroup`),c=s.append(`text`).attr(`y`,n.textHeight+n.padding).attr(`x`,0),l=JSON.parse(`"${t.text}"`).split(`
`);l.forEach(function(e){r.debug(`Adding line: ${e}`),c.append(`tspan`).text(e).attr(`class`,`title`).attr(`dy`,n.textHeight)});let u=s.node().getBBox(),d=s.insert(`rect`,`:first-child`).attr(`x`,0).attr(`y`,0).attr(`width`,u.width+2*n.padding).attr(`height`,u.height+l.length*n.textHeight+n.padding+.5*n.dividerMargin).node().getBBox().width;return c.node().childNodes.forEach(function(e){e.setAttribute(`x`,(d-e.getBBox().width)/2)}),o.width=d,o.height=u.height+l.length*n.textHeight+n.padding+.5*n.dividerMargin,o},x=function(e,t,n,r){let{displayText:i,cssStyle:a}=t.getDisplayDetails(),o=e.append(`tspan`).attr(`x`,r.padding).text(i);a!==``&&o.attr(`style`,t.cssStyle),n||o.attr(`dy`,r.textHeight)},S={getClassTitleString:y,drawClass:v,drawEdge:_,drawNote:b},C={},w=20,T=function(e){let t=Object.entries(C).find(t=>t[1].label===e);if(t)return t[0]},E=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`)},D={parser:p,db:h,renderer:{draw:function(e,t,n,i){let s=a().class;C={},r.info(`Rendering diagram `+e);let l=a().securityLevel,u;l===`sandbox`&&(u=c(`#i`+t));let p=c(l===`sandbox`?u.nodes()[0].contentDocument.body:`body`),m=p.select(`[id='${t}']`);E(m);let h=new d({multigraph:!0});h.setGraph({isMultiGraph:!0}),h.setDefaultEdgeLabel(function(){return{}});let g=i.db.getClasses(),_=Object.keys(g);for(let e of _){let t=g[e],n=S.drawClass(m,t,s,i);C[n.id]=n,h.setNode(n.id,n),r.info(`Org height: `+n.height)}i.db.getRelations().forEach(function(e){r.info(`tjoho`+T(e.id1)+T(e.id2)+JSON.stringify(e)),h.setEdge(T(e.id1),T(e.id2),{relation:e},e.title||`DEFAULT`)}),i.db.getNotes().forEach(function(e){r.debug(`Adding note: ${JSON.stringify(e)}`);let t=S.drawNote(m,e,s,i);C[t.id]=t,h.setNode(t.id,t),e.class&&e.class in g&&h.setEdge(e.id,T(e.class),{relation:{id1:e.id,id2:e.class,relation:{type1:`none`,type2:`none`,lineType:10}}},`DEFAULT`)}),f(h),h.nodes().forEach(function(e){e!==void 0&&h.node(e)!==void 0&&(r.debug(`Node `+e+`: `+JSON.stringify(h.node(e))),p.select(`#`+(i.db.lookUpDomId(e)||e)).attr(`transform`,`translate(`+(h.node(e).x-h.node(e).width/2)+`,`+(h.node(e).y-h.node(e).height/2)+` )`))}),h.edges().forEach(function(e){e!==void 0&&h.edge(e)!==void 0&&(r.debug(`Edge `+e.v+` -> `+e.w+`: `+JSON.stringify(h.edge(e))),S.drawEdge(m,h.edge(e),h.edge(e).relation,s,i))});let v=m.node().getBBox(),y=v.width+w*2,b=v.height+w*2;o(m,b,y,s.useMaxWidth);let x=`${v.x-w} ${v.y-w} ${y} ${b}`;r.debug(`viewBox ${x}`),m.attr(`viewBox`,x)}},styles:m,init:e=>{e.class||={},e.class.arrowMarkerAbsolute=e.arrowMarkerAbsolute,h.clear()}};export{D as diagram};