import{s as e,a as t,b as a,g as n,c as r,d as s,_ as i,e as o,l as d,f as c,h as l,i as g,j as h,k as p}from"./cdc703e4c-BSbwV-KL.js";import{p as w}from"./c3bb327b0-BRmKf5S2.js";import{I as m}from"./ce1e71a2e-DRjZ2f5I.js";import{p as b}from"./c30627899-0I02GfqT.js";import"./vendor-react-Dp9pL_Wn.js";import"./cd78d010c-COlwQ5g4.js";import"./cf163d9fe-2lhqfhfB.js";var k=new m(()=>({cnt:1,stack:[{id:0,level:-1,name:"/",children:[]}]})),x=i(()=>{k.reset(),h()},"clear"),f=i(()=>k.records.stack[0],"getRoot"),B=i(()=>k.records.cnt,"getCount"),u=p.treeView,y=i(()=>o(u,g().treeView),"getConfig"),C={clear:x,addNode:i((e,t)=>{for(;e<=k.records.stack[k.records.stack.length-1].level;)k.records.stack.pop();const a={id:k.records.cnt++,level:e,name:t,children:[]};k.records.stack[k.records.stack.length-1].children.push(a),k.records.stack.push(a)},"addNode"),getRoot:f,getCount:B,getConfig:y,getAccTitle:s,getAccDescription:r,getDiagramTitle:n,setAccDescription:a,setAccTitle:t,setDiagramTitle:e},T=i(e=>{w(e,C),e.nodes.map(e=>C.addNode(e.indent?parseInt(e.indent):0,e.name))},"populate"),V={parse:i(async e=>{const t=await b("treeView",e);d.debug(t),T(t)},"parse")},j=i((e,t,a,n,r)=>{const s=n.append("text").text(a.name).attr("dominant-baseline","middle").attr("class","treeView-node-label"),{height:i,width:o}=s.node().getBBox(),d=i+2*r.paddingY,c=o+2*r.paddingX;s.attr("x",e+r.paddingX),s.attr("y",t+d/2),a.BBox={x:e,y:t,width:c,height:d}},"positionLabel"),v=i((e,t,a,n,r,s)=>e.append("line").attr("x1",t).attr("y1",a).attr("x2",n).attr("y2",r).attr("stroke-width",s).attr("class","treeView-node-line"),"positionLine"),$=i((e,t,a)=>{let n=0,r=0;const s=i((e,t,a,s)=>{const i=s*(a.rowIndent+a.paddingX);j(i,n,t,e,a);const{height:o,width:d}=t.BBox;v(e,i-a.rowIndent,n+o/2,i,n+o/2,a.lineThickness),r=Math.max(r,i+d),n+=o},"drawNode"),o=i((t,n=0)=>{s(e,t,a,n),t.children.forEach(e=>{o(e,n+1)});const{x:r,y:i,height:d}=t.BBox;if(t.children.length){const{y:n,height:s}=t.children[t.children.length-1].BBox;v(e,r+a.paddingX,i+d,r+a.paddingX,n+s/2+a.lineThickness/2,a.lineThickness)}},"processNode");return o(t),{totalHeight:n,totalWidth:r}},"drawTree"),N={labelFontSize:"16px",labelColor:"black",lineColor:"black"},X={db:C,renderer:{draw:i((e,t,a,n)=>{d.debug("Rendering treeView diagram\n"+e);const r=n.db,s=r.getRoot(),i=r.getConfig(),o=c(t),g=o.append("g");g.attr("class","tree-view");const{totalHeight:h,totalWidth:p}=$(g,s,i);o.attr("viewBox",`-${i.lineThickness/2} 0 ${p} ${h}`),l(o,h,p,i.useMaxWidth)},"draw")},parser:V,styles:i(({treeView:e})=>{const{labelFontSize:t,labelColor:a,lineColor:n}=o(N,e);return`\n    .treeView-node-label {\n        font-size: ${t};\n        fill: ${a};\n    }\n    .treeView-node-line {\n        stroke: ${n};\n    }\n    `},"styles")};export{X as diagram};
