import{i as e,r as t}from"./c25d902c2-Dbv6uExJ.js";import{i as r}from"./c3880bcbc-D5xW2M9A.js";import{t as a}from"./cd9160391-Dd_q4fPR.js";import{H as n,K as o,U as i,a as s,b as d,c,f as l,v as g,w as h,y as p}from"./c255cf682-BhczLtlf.js";import{t as m}from"./c88bd5d31-D8edEScf.js";import{t as w}from"./c3bb327b0-MVV9JtOk.js";import{t as b}from"./ce1e71a2e-D7Fi_EVK.js";var x=new b(()=>({cnt:1,stack:[{id:0,level:-1,name:"/",children:[]}]})),f=t(()=>{x.reset(),s()},"clear"),k=t(()=>x.records.stack[0],"getRoot"),B=t(()=>x.records.cnt,"getCount"),u=l.treeView,y={clear:f,addNode:t((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:k,getCount:B,getConfig:t(()=>r(u,d().treeView),"getConfig"),getAccTitle:p,getAccDescription:g,getDiagramTitle:h,setAccDescription:n,setAccTitle:i,setDiagramTitle:o},C=t(e=>{w(e,y),e.nodes.map(e=>y.addNode(e.indent?parseInt(e.indent):0,e.name))},"populate"),T={parse:t(async t=>{const r=await a("treeView",t);e.debug(r),C(r)},"parse")},V=t((e,t,r,a,n)=>{const o=a.append("text").text(r.name).attr("dominant-baseline","middle").attr("class","treeView-node-label"),{height:i,width:s}=o.node().getBBox(),d=i+2*n.paddingY,c=s+2*n.paddingX;o.attr("x",e+n.paddingX),o.attr("y",t+d/2),r.BBox={x:e,y:t,width:c,height:d}},"positionLabel"),j=t((e,t,r,a,n,o)=>e.append("line").attr("x1",t).attr("y1",r).attr("x2",a).attr("y2",n).attr("stroke-width",o).attr("class","treeView-node-line"),"positionLine"),v=t((e,r,a)=>{let n=0,o=0;const i=t((e,t,r,a)=>{const i=a*(r.rowIndent+r.paddingX);V(i,n,t,e,r);const{height:s,width:d}=t.BBox;j(e,i-r.rowIndent,n+s/2,i,n+s/2,r.lineThickness),o=Math.max(o,i+d),n+=s},"drawNode"),s=t((t,r=0)=>{i(e,t,a,r),t.children.forEach(e=>{s(e,r+1)});const{x:n,y:o,height:d}=t.BBox;if(t.children.length){const{y:r,height:i}=t.children[t.children.length-1].BBox;j(e,n+a.paddingX,o+d,n+a.paddingX,r+i/2+a.lineThickness/2,a.lineThickness)}},"processNode");return s(r),{totalHeight:n,totalWidth:o}},"drawTree"),$={labelFontSize:"16px",labelColor:"black",lineColor:"black"},N={db:y,renderer:{draw:t((t,r,a,n)=>{e.debug("Rendering treeView diagram\n"+t);const o=n.db,i=o.getRoot(),s=o.getConfig(),d=m(r),l=d.append("g");l.attr("class","tree-view");const{totalHeight:g,totalWidth:h}=v(l,i,s);d.attr("viewBox",`-${s.lineThickness/2} 0 ${h} ${g}`),c(d,g,h,s.useMaxWidth)},"draw")},parser:T,styles:t(({treeView:e})=>{const{labelFontSize:t,labelColor:a,lineColor:n}=r($,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{N as diagram};