import{aS as x,aQ as f,aP as C,$ as B,V as T,W as y,a as s,r as b,at as k,aO as V,B as S,X as N,s as _,O as $}from"./mermaid.core-xrkbuqlf.js";import{p as D}from"./chunk-4BX2VUAB-DY2COvV-.js";import{I as X}from"./chunk-QZHKN3VN-BzsIqlq1.js";import{p as A}from"./wardley-L42UT6IY-C-OZ4RVP.js";import"./index-CaICnERr.js";var l=new X(()=>({cnt:1,stack:[{id:0,level:-1,name:"/",children:[]}]})),I=s(()=>{l.reset(),_()},"clear"),W=s(()=>l.records.stack[0],"getRoot"),z=s(()=>l.records.cnt,"getCount"),H=$.treeView,L=s(()=>b(H,N().treeView),"getConfig"),R=s((e,t)=>{for(;e<=l.records.stack[l.records.stack.length-1].level;)l.records.stack.pop();const a={id:l.records.cnt++,level:e,name:t,children:[]};l.records.stack[l.records.stack.length-1].children.push(a),l.records.stack.push(a)},"addNode"),E={clear:I,addNode:R,getRoot:W,getCount:z,getConfig:L,getAccTitle:y,getAccDescription:T,getDiagramTitle:B,setAccDescription:C,setAccTitle:f,setDiagramTitle:x},m=E,M=s(e=>{D(e,m),e.nodes.map(t=>m.addNode(t.indent?parseInt(t.indent):0,t.name))},"populate"),F={parse:s(async e=>{const t=await A("treeView",e);k.debug(t),M(t)},"parse")},O=s((e,t,a,n,o)=>{const c=n.append("text").text(a.name).attr("dominant-baseline","middle").attr("class","treeView-node-label"),{height:g,width:r}=c.node().getBBox(),d=g+o.paddingY*2,i=r+o.paddingX*2;c.attr("x",e+o.paddingX),c.attr("y",t+d/2),a.BBox={x:e,y:t,width:i,height:d}},"positionLabel"),u=s((e,t,a,n,o,c)=>e.append("line").attr("x1",t).attr("y1",a).attr("x2",n).attr("y2",o).attr("stroke-width",c).attr("class","treeView-node-line"),"positionLine"),Y=s((e,t,a)=>{let n=0,o=0;const c=s((r,d,i,h)=>{const v=h*(i.rowIndent+i.paddingX);O(v,n,d,r,i);const{height:p,width:w}=d.BBox;u(r,v-i.rowIndent,n+p/2,v,n+p/2,i.lineThickness),o=Math.max(o,v+w),n+=p},"drawNode"),g=s((r,d=0)=>{c(e,r,a,d),r.children.forEach(p=>{g(p,d+1)});const{x:i,y:h,height:v}=r.BBox;if(r.children.length){const{y:p,height:w}=r.children[r.children.length-1].BBox;u(e,i+a.paddingX,h+v,i+a.paddingX,p+w/2+a.lineThickness/2,a.lineThickness)}},"processNode");return g(t),{totalHeight:n,totalWidth:o}},"drawTree"),P=s((e,t,a,n)=>{k.debug(`Rendering treeView diagram
`+e);const o=n.db,c=o.getRoot(),g=o.getConfig(),r=V(t),d=r.append("g");d.attr("class","tree-view");const{totalHeight:i,totalWidth:h}=Y(d,c,g);r.attr("viewBox",`-${g.lineThickness/2} 0 ${h} ${i}`),S(r,i,h,g.useMaxWidth)},"draw"),Q={draw:P},j=Q,q={labelFontSize:"16px",labelColor:"black",lineColor:"black"},G=s(({treeView:e})=>{const{labelFontSize:t,labelColor:a,lineColor:n}=b(q,e);return`
    .treeView-node-label {
        font-size: ${t};
        fill: ${a};
    }
    .treeView-node-line {
        stroke: ${n};
    }
    `},"styles"),J=G,ae={db:m,renderer:j,parser:F,styles:J};export{ae as diagram};
