import{i as e}from"./chunk-5ZQYHXKU-DvdZmVCt.js";import{i as t,r}from"./src-DpGjM0Pj.js";import{t as n}from"./mermaid-parser.core-DV0MmAGy.js";import{H as a,K as o,U as s,a as i,b as d,c,f as l,v as h,w as g,y as p}from"./chunk-CSCIHK7Q-D7tKG3Mp.js";import{t as m}from"./chunk-WU5MYG2G-GKCpIGbc.js";import{t as w}from"./chunk-4BX2VUAB-Bb82jOh3.js";import{t as k}from"./chunk-QZHKN3VN-CjxfAIY4.js";var x=new k(()=>({cnt:1,stack:[{id:0,level:-1,name:"/",children:[]}]})),b=r(()=>{x.reset(),i()},"clear"),f=r(()=>x.records.stack[0],"getRoot"),u=r(()=>x.records.cnt,"getCount"),B=l.treeView,C={clear:b,addNode:r((e,t)=>{for(;e<=x.records.stack[x.records.stack.length-1].level;)x.records.stack.pop();const r={id:x.records.cnt++,level:e,name:t,children:[]};x.records.stack[x.records.stack.length-1].children.push(r),x.records.stack.push(r)},"addNode"),getRoot:f,getCount:u,getConfig:r(()=>e(B,d().treeView),"getConfig"),getAccTitle:p,getAccDescription:h,getDiagramTitle:g,setAccDescription:a,setAccTitle:s,setDiagramTitle:o},V=r(e=>{w(e,C),e.nodes.map(e=>C.addNode(e.indent?parseInt(e.indent):0,e.name))},"populate"),y={parse:r(async e=>{const r=await n("treeView",e);t.debug(r),V(r)},"parse")},T=r((e,t,r,n,a)=>{const o=n.append("text").text(r.name).attr("dominant-baseline","middle").attr("class","treeView-node-label"),{height:s,width:i}=o.node().getBBox(),d=s+2*a.paddingY,c=i+2*a.paddingX;o.attr("x",e+a.paddingX),o.attr("y",t+d/2),r.BBox={x:e,y:t,width:c,height:d}},"positionLabel"),j=r((e,t,r,n,a,o)=>e.append("line").attr("x1",t).attr("y1",r).attr("x2",n).attr("y2",a).attr("stroke-width",o).attr("class","treeView-node-line"),"positionLine"),v=r((e,t,n)=>{let a=0,o=0;const s=r((e,t,r,n)=>{const s=n*(r.rowIndent+r.paddingX);T(s,a,t,e,r);const{height:i,width:d}=t.BBox;j(e,s-r.rowIndent,a+i/2,s,a+i/2,r.lineThickness),o=Math.max(o,s+d),a+=i},"drawNode"),i=r((t,r=0)=>{s(e,t,n,r),t.children.forEach(e=>{i(e,r+1)});const{x:a,y:o,height:d}=t.BBox;if(t.children.length){const{y:r,height:s}=t.children[t.children.length-1].BBox;j(e,a+n.paddingX,o+d,a+n.paddingX,r+s/2+n.lineThickness/2,n.lineThickness)}},"processNode");return i(t),{totalHeight:a,totalWidth:o}},"drawTree"),N={labelFontSize:"16px",labelColor:"black",lineColor:"black"},X={db:C,renderer:{draw:r((e,r,n,a)=>{t.debug("Rendering treeView diagram\n"+e);const o=a.db,s=o.getRoot(),i=o.getConfig(),d=m(r),l=d.append("g");l.attr("class","tree-view");const{totalHeight:h,totalWidth:g}=v(l,s,i);d.attr("viewBox",`-${i.lineThickness/2} 0 ${g} ${h}`),c(d,h,g,i.useMaxWidth)},"draw")},parser:y,styles:r(({treeView:t})=>{const{labelFontSize:r,labelColor:n,lineColor:a}=e(N,t);return`\n    .treeView-node-label {\n        font-size: ${r};\n        fill: ${n};\n    }\n    .treeView-node-line {\n        stroke: ${a};\n    }\n    `},"styles")};export{X as diagram};