import{Dn as e,En as t,Hn as n,On as r,Vn as i,Vt as a,Wn as o,ir as s,jn as c,kn as l,nt as u,rr as d,wn as f,xn as p}from"./index-CQjDndvX.js";import{t as m}from"./mermaid-parser.core-BA94RXK1.js";import{t as h}from"./chunk-4BX2VUAB-CWoklDfR.js";import{t as g}from"./chunk-QZHKN3VN-Bs6jS1BY.js";var _=new g(()=>({cnt:1,stack:[{id:0,level:-1,name:`/`,children:[]}]})),v=d(()=>{_.reset(),p()},`clear`),y=d(()=>_.records.stack[0],`getRoot`),b=d(()=>_.records.cnt,`getCount`),x=t.treeView,S={clear:v,addNode:d((e,t)=>{for(;e<=_.records.stack[_.records.stack.length-1].level;)_.records.stack.pop();let n={id:_.records.cnt++,level:e,name:t,children:[]};_.records.stack[_.records.stack.length-1].children.push(n),_.records.stack.push(n)},`addNode`),getRoot:y,getCount:b,getConfig:d(()=>u(x,l().treeView),`getConfig`),getAccTitle:r,getAccDescription:e,getDiagramTitle:c,setAccDescription:i,setAccTitle:n,setDiagramTitle:o},C=d(e=>{h(e,S),e.nodes.map(e=>S.addNode(e.indent?parseInt(e.indent):0,e.name))},`populate`),w={parse:d(async e=>{let t=await m(`treeView`,e);s.debug(t),C(t)},`parse`)},T=d((e,t,n,r,i)=>{let a=r.append(`text`).text(n.name).attr(`dominant-baseline`,`middle`).attr(`class`,`treeView-node-label`),{height:o,width:s}=a.node().getBBox(),c=o+i.paddingY*2,l=s+i.paddingX*2;a.attr(`x`,e+i.paddingX),a.attr(`y`,t+c/2),n.BBox={x:e,y:t,width:l,height:c}},`positionLabel`),E=d((e,t,n,r,i,a)=>e.append(`line`).attr(`x1`,t).attr(`y1`,n).attr(`x2`,r).attr(`y2`,i).attr(`stroke-width`,a).attr(`class`,`treeView-node-line`),`positionLine`),D=d((e,t,n)=>{let r=0,i=0,a=d((e,t,n,a)=>{let o=a*(n.rowIndent+n.paddingX);T(o,r,t,e,n);let{height:s,width:c}=t.BBox;E(e,o-n.rowIndent,r+s/2,o,r+s/2,n.lineThickness),i=Math.max(i,o+c),r+=s},`drawNode`),o=d((t,r=0)=>{a(e,t,n,r),t.children.forEach(e=>{o(e,r+1)});let{x:i,y:s,height:c}=t.BBox;if(t.children.length){let{y:r,height:a}=t.children[t.children.length-1].BBox;E(e,i+n.paddingX,s+c,i+n.paddingX,r+a/2+n.lineThickness/2,n.lineThickness)}},`processNode`);return o(t),{totalHeight:r,totalWidth:i}},`drawTree`),O={draw:d((e,t,n,r)=>{s.debug(`Rendering treeView diagram
`+e);let i=r.db,o=i.getRoot(),c=i.getConfig(),l=a(t),u=l.append(`g`);u.attr(`class`,`tree-view`);let{totalHeight:d,totalWidth:p}=D(u,o,c);l.attr(`viewBox`,`-${c.lineThickness/2} 0 ${p} ${d}`),f(l,d,p,c.useMaxWidth)},`draw`)},k={labelFontSize:`16px`,labelColor:`black`,lineColor:`black`},A={db:S,renderer:O,parser:w,styles:d(({treeView:e})=>{let{labelFontSize:t,labelColor:n,lineColor:r}=u(k,e);return`
    .treeView-node-label {
        font-size: ${t};
        fill: ${n};
    }
    .treeView-node-line {
        stroke: ${r};
    }
    `},`styles`)};export{A as diagram};