import{Y as M,K as L,z as j}from"./layers.D6ZcS9R8-BW7hrDph.js";import{l as c,g as d,d as x,u as B,Y as O,_ as E,$ as A,a0 as D,j as C}from"./layers.BZB96jSA-CsU0gdWj.js";import{p as R}from"./layers.BJDrjORS-D7qNnv43.js";import{x as Y}from"./layers.DlIEuyDi-D-1n6Mnu.js";import"./layers.YoByaZrc-DQ8FBM0v.js";import"./layers.D4T8fTcj-DBcMM7Bd.js";import"./index-26FXPGkN.js";import"./TaskPanel-1n1xV0vy.js";import"./tasks-BMVBejH2.js";import"./index-DlWqcwmX.js";import"./IconUser-CkQmhwMi.js";import"./Textarea-C8aNW3Hx.js";import"./get-env-uyVen0u2.js";import"./IconChevronLeft-FAloe5QL.js";import"./use-resize-observer-6Qm_8hWl.js";import"./useTaskTypesData-CFzDcAWE.js";import"./ColorSwatch-CtoYH4Cn.js";import"./Typography-PKUzf06x.js";import"./clamp-CUTWWzXs.js";import"./Select-C1WMqk5R.js";import"./SegmentedControl-BeEuUkOb.js";import"./IconGripVertical-COCN8Vqa.js";import"./IconAt-Bca7mi74.js";import"./IconTableOff-DmQNoB2C.js";import"./Accordion-z2XcZ0M6.js";import"./union-DoflI9J8.js";import"./reduce-Htc8hg3K.js";import"./layers.BhAZ7G1v-CIpb-ELT.js";import"./layers.DTAeZhab-D4JfxuUt.js";import"./layers.D1mqEtmL-CquewxdH.js";import"./layers.CqVTtuYm-C3YJfAyO.js";import"./layers.DLwuMfdd-B0oSrkCJ.js";const k=i=>C.sanitizeText(i,d());let w={dividerMargin:10,padding:5,textHeight:10,curve:void 0};const z=function(i,t,y,n){const e=Object.keys(i);c.info("keys:",e),c.info(i),e.forEach(function(r){var l,s;const o=i[r],a={shape:"rect",id:o.id,domId:o.domId,labelText:k(o.id),labelStyle:"",style:"fill: none; stroke: black",padding:((l=d().flowchart)==null?void 0:l.padding)??((s=d().class)==null?void 0:s.padding)};t.setNode(o.id,a),$(o.classes,t,y,n,o.id),c.info("setNode",a)})},$=function(i,t,y,n,e){const r=Object.keys(i);c.info("keys:",r),c.info(i),r.filter(l=>i[l].parent==e).forEach(function(l){var s,o;const a=i[l],m=a.cssClasses.join(" "),b=E(a.styles),g=a.label??a.id,p=0,f={labelStyle:b.labelStyle,shape:"class_box",labelText:k(g),classData:a,rx:p,ry:p,class:m,style:b.style,id:a.id,domId:a.domId,tooltip:n.db.getTooltip(a.id,e)||"",haveCallback:a.haveCallback,link:a.link,width:a.type==="group"?500:void 0,type:a.type,padding:((s=d().flowchart)==null?void 0:s.padding)??((o=d().class)==null?void 0:o.padding)};t.setNode(a.id,f),e&&t.setParent(a.id,e),c.info("setNode",f)})},q=function(i,t,y,n){c.info(i),i.forEach(function(e,r){var l,s;const o=e,a="",m={labelStyle:"",style:""},b=o.text,g=0,p={labelStyle:m.labelStyle,shape:"note",labelText:k(b),noteData:o,rx:g,ry:g,class:a,style:m.style,id:o.id,domId:o.id,tooltip:"",type:"note",padding:((l=d().flowchart)==null?void 0:l.padding)??((s=d().class)==null?void 0:s.padding)};if(t.setNode(o.id,p),c.info("setNode",p),!o.class||!(o.class in n))return;const f=y+r,h={id:`edgeNote${f}`,classes:"relation",pattern:"dotted",arrowhead:"none",startLabelRight:"",endLabelLeft:"",arrowTypeStart:"none",arrowTypeEnd:"none",style:"fill:none",labelStyle:"",curve:A(w.curve,D)};t.setEdge(o.id,o.class,h,f)})},H=function(i,t){const y=d().flowchart;let n=0;i.forEach(function(e){var r;n++;const l={classes:"relation",pattern:e.relation.lineType==1?"dashed":"solid",id:`id_${e.id1}_${e.id2}_${n}`,arrowhead:e.type==="arrow_open"?"none":"normal",startLabelRight:e.relationTitle1==="none"?"":e.relationTitle1,endLabelLeft:e.relationTitle2==="none"?"":e.relationTitle2,arrowTypeStart:N(e.relation.type1),arrowTypeEnd:N(e.relation.type2),style:"fill:none",labelStyle:"",curve:A(y==null?void 0:y.curve,D)};if(c.info(l,e),e.style!==void 0){const s=E(e.style);l.style=s.style,l.labelStyle=s.labelStyle}e.text=e.title,e.text===void 0?e.style!==void 0&&(l.arrowheadStyle="fill: #333"):(l.arrowheadStyle="fill: #333",l.labelpos="c",((r=d().flowchart)==null?void 0:r.htmlLabels)??d().htmlLabels?(l.labelType="html",l.label='<span class="edgeLabel">'+e.text+"</span>"):(l.labelType="text",l.label=e.text.replace(C.lineBreakRegex,`
`),e.style===void 0&&(l.style=l.style||"stroke: #333; stroke-width: 1.5px;fill:none"),l.labelStyle=l.labelStyle.replace("color:","fill:"))),t.setEdge(e.id1,e.id2,l,n)})},K=function(i){w={...w,...i}},P=async function(i,t,y,n){c.info("Drawing class - ",t);const e=d().flowchart??d().class,r=d().securityLevel;c.info("config:",e);const l=(e==null?void 0:e.nodeSpacing)??50,s=(e==null?void 0:e.rankSpacing)??50,o=new R({multigraph:!0,compound:!0}).setGraph({rankdir:n.db.getDirection(),nodesep:l,ranksep:s,marginx:8,marginy:8}).setDefaultEdgeLabel(function(){return{}}),a=n.db.getNamespaces(),m=n.db.getClasses(),b=n.db.getRelations(),g=n.db.getNotes();c.info(b),z(a,o,t,n),$(m,o,t,n),H(b,o),q(g,o,b.length+1,m);let p;r==="sandbox"&&(p=x("#i"+t));const f=r==="sandbox"?x(p.nodes()[0].contentDocument.body):x("body"),h=f.select(`[id="${t}"]`),_=f.select("#"+t+" g");if(await Y(_,o,["aggregation","extension","composition","dependency","lollipop"],"classDiagram",t),B.insertTitle(h,"classTitleText",(e==null?void 0:e.titleTopMargin)??5,n.db.getDiagramTitle()),O(o,h,e==null?void 0:e.diagramPadding,e==null?void 0:e.useMaxWidth),!(e!=null&&e.htmlLabels)){const T=r==="sandbox"?p.nodes()[0].contentDocument:document,I=T.querySelectorAll('[id="'+t+'"] .edgeLabel .label');for(const v of I){const S=v.getBBox(),u=T.createElementNS("http://www.w3.org/2000/svg","rect");u.setAttribute("rx",0),u.setAttribute("ry",0),u.setAttribute("width",S.width),u.setAttribute("height",S.height),v.insertBefore(u,v.firstChild)}}};function N(i){let t;switch(i){case 0:t="aggregation";break;case 1:t="extension";break;case 2:t="composition";break;case 3:t="dependency";break;case 4:t="lollipop";break;default:t="none"}return t}const W={setConf:K,draw:P},Se={parser:j,db:L,renderer:W,styles:M,init:i=>{i.class||(i.class={}),i.class.arrowMarkerAbsolute=i.arrowMarkerAbsolute,L.clear()}};export{Se as diagram};
