import{s as e}from"./rolldown-runtime-C5c2KzVm.js";import"./lucide-C4oWPzu4.js";import{a as t,t as n}from"./src-CaF7C-tn.js";import"./purify.es-BI1OWkCK.js";import{d as r}from"./step-7IFzWEMw.js";import{t as i}from"./line-BV54ujJu.js";import{t as a}from"./dagre-t-mlF8Ny.js";import{t as o}from"./graphlib-mnK_OidP.js";import{B as s,D as c,R as l,T as u,_ as d,l as f}from"./mermaid-7ea9cbd6-CTdxebQd.js";import{n as p,r as m,t as h}from"./styles-b4e223ce-BwKjtmN4.js";e(t(),1),s();var g=0,_=function(e,t,n,a,o){let s=function(e){switch(e){case o.db.relationType.AGGREGATION:return`aggregation`;case o.db.relationType.EXTENSION:return`extension`;case o.db.relationType.COMPOSITION:return`composition`;case o.db.relationType.DEPENDENCY:return`dependency`;case o.db.relationType.LOLLIPOP:return`lollipop`}};t.points=t.points.filter(e=>!Number.isNaN(e.y));let c=t.points,d=i().x(function(e){return e.x}).y(function(e){return e.y}).curve(r),f=e.append(`path`).attr(`d`,d(c)).attr(`id`,`edge`+g).attr(`class`,`relation`),p=``;a.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+`#`+s(n.relation.type1)+`Start)`),n.relation.type2!==`none`&&f.attr(`marker-end`,`url(`+p+`#`+s(n.relation.type2)+`End)`);let m,h,_=t.points.length,v=l.calcLabelPosition(t.points);m=v.x,h=v.y;let y,b,x,S;if(_%2!=0&&_>1){let e=l.calcCardinalityPosition(n.relation.type1!==`none`,t.points,t.points[0]),r=l.calcCardinalityPosition(n.relation.type2!==`none`,t.points,t.points[_-1]);u.debug(`cardinality_1_point `+JSON.stringify(e)),u.debug(`cardinality_2_point `+JSON.stringify(r)),y=e.x,b=e.y,x=r.x,S=r.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 i=r.node().getBBox();t.insert(`rect`,`:first-child`).attr(`class`,`box`).attr(`x`,i.x-a.padding/2).attr(`y`,i.y-a.padding/2).attr(`width`,i.width+a.padding).attr(`height`,i.height+a.padding)}u.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,r){u.debug(`Rendering class `,t,n);let i=t.id,a={id:i,label:t.id,width:0,height:0},o=e.append(`g`).attr(`id`,r.db.lookUpDomId(i)).attr(`class`,`classGroup`),s;s=t.link?o.append(`svg:a`).attr(`xlink:href`,t.link).attr(`target`,t.linkTarget).append(`text`).attr(`y`,n.textHeight+n.padding).attr(`x`,0):o.append(`text`).attr(`y`,n.textHeight+n.padding).attr(`x`,0);let c=!0;t.annotations.forEach(function(e){let t=s.append(`tspan`).text(`«`+e+`»`);c||t.attr(`dy`,n.textHeight),c=!1});let l=y(t),d=s.append(`tspan`).text(l).attr(`class`,`title`);c||d.attr(`dy`,n.textHeight);let f=s.node().getBBox().height,p,m,h;if(t.members.length>0){p=o.append(`line`).attr(`x1`,0).attr(`y1`,n.padding+f+n.dividerMargin/2).attr(`y2`,n.padding+f+n.dividerMargin/2);let e=o.append(`text`).attr(`x`,n.padding).attr(`y`,f+n.dividerMargin+n.textHeight).attr(`fill`,`white`).attr(`class`,`classText`);c=!0,t.members.forEach(function(t){x(e,t,c,n),c=!1}),m=e.node().getBBox()}if(t.methods.length>0){h=o.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=o.append(`text`).attr(`x`,n.padding).attr(`y`,f+2*n.dividerMargin+m.height+n.textHeight).attr(`fill`,`white`).attr(`class`,`classText`);c=!0,t.methods.forEach(function(t){x(e,t,c,n),c=!1})}let g=o.node().getBBox();var _=` `;t.cssClasses.length>0&&(_+=t.cssClasses.join(` `));let v=o.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 s.node().childNodes.forEach(function(e){e.setAttribute(`x`,(v-e.getBBox().width)/2)}),t.tooltip&&s.insert(`title`).text(t.tooltip),p&&p.attr(`x2`,v),h&&h.attr(`x2`,v),a.width=v,a.height=g.height+n.padding+.5*n.dividerMargin,a},y=function(e){let t=e.id;return e.type&&(t+=`<`+c(e.type)+`>`),t},b=function(e,t,n,r){u.debug(`Rendering note `,t,n);let i=t.id,a={id:i,text:t.text,width:0,height:0},o=e.append(`g`).attr(`id`,i).attr(`class`,`classGroup`),s=o.append(`text`).attr(`y`,n.textHeight+n.padding).attr(`x`,0),c=JSON.parse(`"${t.text}"`).split(`
`);c.forEach(function(e){u.debug(`Adding line: ${e}`),s.append(`tspan`).text(e).attr(`class`,`title`).attr(`dy`,n.textHeight)});let l=o.node().getBBox(),d=o.insert(`rect`,`:first-child`).attr(`x`,0).attr(`y`,0).attr(`width`,l.width+2*n.padding).attr(`height`,l.height+c.length*n.textHeight+n.padding+.5*n.dividerMargin).node().getBBox().width;return s.node().childNodes.forEach(function(e){e.setAttribute(`x`,(d-e.getBBox().width)/2)}),a.width=d,a.height=l.height+c.length*n.textHeight+n.padding+.5*n.dividerMargin,a},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,r,i){let s=d().class;C={},u.info(`Rendering diagram `+e);let c=d().securityLevel,l;c===`sandbox`&&(l=n(`#i`+t));let p=n(c===`sandbox`?l.nodes()[0].contentDocument.body:`body`),m=p.select(`[id='${t}']`);E(m);let h=new o({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),u.info(`Org height: `+n.height)}i.db.getRelations().forEach(function(e){u.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){u.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`)}),a(h),h.nodes().forEach(function(e){e!==void 0&&h.node(e)!==void 0&&(u.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&&(u.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;f(m,b,y,s.useMaxWidth);let x=`${v.x-w} ${v.y-w} ${y} ${b}`;u.debug(`viewBox ${x}`),m.attr(`viewBox`,x)}},styles:m,init:e=>{e.class||={},e.class.arrowMarkerAbsolute=e.arrowMarkerAbsolute,h.clear()}};export{D as diagram};