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