import{i as e,r as t}from"./src-BDl8sfw0.js";import{r as n}from"./chunk-5PVQY5BW-DCfXzsp0.js";import{t as r}from"./mermaid-parser.core-Bk0deEGf.js";import{B as i,C as a,V as o,W as s,_ as c,a as l,c as u,d,v as f,y as p}from"./chunk-ICPOFSXX-D5QQ8L5C.js";import{t as m}from"./chunk-426QAEUC-2-Wnc5K3.js";import{t as h}from"./chunk-4BX2VUAB-C7QIoTzk.js";import{t as g}from"./chunk-QZHKN3VN-JsMs84JG.js";var _=new g(()=>({cnt:1,stack:[{id:0,level:-1,name:`/`,children:[]}]})),v=t(()=>{_.reset(),l()},`clear`),y=t(()=>_.records.stack[0],`getRoot`),b=t(()=>_.records.cnt,`getCount`),x=d.treeView,S={clear:v,addNode:t((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:t(()=>n(x,p().treeView),`getConfig`),getAccTitle:f,getAccDescription:c,getDiagramTitle:a,setAccDescription:i,setAccTitle:o,setDiagramTitle:s},C=t(e=>{h(e,S),e.nodes.map(e=>S.addNode(e.indent?parseInt(e.indent):0,e.name))},`populate`),w={parse:t(async t=>{let n=await r(`treeView`,t);e.debug(n),C(n)},`parse`)},T=t((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=t((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=t((e,n,r)=>{let i=0,a=0,o=t((e,t,n,r)=>{let o=r*(n.rowIndent+n.paddingX);T(o,i,t,e,n);let{height:s,width:c}=t.BBox;E(e,o-n.rowIndent,i+s/2,o,i+s/2,n.lineThickness),a=Math.max(a,o+c),i+=s},`drawNode`),s=t((t,n=0)=>{o(e,t,r,n),t.children.forEach(e=>{s(e,n+1)});let{x:i,y:a,height:c}=t.BBox;if(t.children.length){let{y:n,height:o}=t.children[t.children.length-1].BBox;E(e,i+r.paddingX,a+c,i+r.paddingX,n+o/2+r.lineThickness/2,r.lineThickness)}},`processNode`);return s(n),{totalHeight:i,totalWidth:a}},`drawTree`),O={draw:t((t,n,r,i)=>{e.debug(`Rendering treeView diagram
`+t);let a=i.db,o=a.getRoot(),s=a.getConfig(),c=m(n),l=c.append(`g`);l.attr(`class`,`tree-view`);let{totalHeight:d,totalWidth:f}=D(l,o,s);c.attr(`viewBox`,`-${s.lineThickness/2} 0 ${f} ${d}`),u(c,d,f,s.useMaxWidth)},`draw`)},k={labelFontSize:`16px`,labelColor:`black`,lineColor:`black`},A={db:S,renderer:O,parser:w,styles:t(({treeView:e})=>{let{labelFontSize:t,labelColor:r,lineColor:i}=n(k,e);return`
    .treeView-node-label {
        font-size: ${t};
        fill: ${r};
    }
    .treeView-node-line {
        stroke: ${i};
    }
    `},`styles`)};export{A as diagram};
//# sourceMappingURL=diagram-5BDNPKRD-D377Sus7.js.map