import{s as e,a as t,b as r,g as o,c as n,d as i,_ as s,e as a,l as d,f as c,h as l,i as p,j as m,k as g}from"./cdc703e4c-Bq_4r6yK.js";import{p as h}from"./c3bb327b0-BRjx-f9Q.js";import{I as j}from"./ce1e71a2e-BxIfhA2x.js";import{p as v}from"./c30627899-CmZFDLac.js";import"./vendor-react-Dp9pL_Wn.js";import"./c2764ca9d-CReY3H-1.js";import"./c32c0d97f-BRKlKuDE.js";import"./c6eedc03a-CsEFTfjy.js";import"./vendor-ant-cds-bBedrtIN.js";import"./vendor-base-ui-DNypCIlh.js";import"./vendor-radix-Ch96tRrt.js";import"./vendor-base-5_f7mmWg.js";import"./vendor-virtual-DRz8lJfQ.js";import"./vendor-intl-D2wGIp4M.js";import"./vendor-zod-0xcuG3aM.js";import"./vendor-zustand-BeF8W8xk.js";import"./vendor-icons-CokWnmlw.js";import"./vendor-lodash-BvMLws5K.js";import"./vendor-router-qG5OCEmI.js";import"./vendor-query-BwvgHhJ1.js";import"./vendor-zod-v3-CZy0YPWu.js";import"./vendor-motion-EDlUw66k.js";import"./vendor-luxon-CZxT8ieM.js";import"./vendor-growthbook-C66YtMMX.js";import"./vendor-infra-DayZK7Ds.js";import"./c4b350ac1-D-GnjzHA.js";var w=new j(()=>({cnt:1,stack:[{id:0,level:-1,name:"/",children:[]}]})),b=s(()=>{w.reset(),m()},"clear"),k=s(()=>w.records.stack[0],"getRoot"),x=s(()=>w.records.cnt,"getCount"),f=g.treeView,u=s(()=>a(f,p().treeView),"getConfig"),B={clear:b,addNode:s((e,t)=>{for(;e<=w.records.stack[w.records.stack.length-1].level;)w.records.stack.pop();const r={id:w.records.cnt++,level:e,name:t,children:[]};w.records.stack[w.records.stack.length-1].children.push(r),w.records.stack.push(r)},"addNode"),getRoot:k,getCount:x,getConfig:u,getAccTitle:i,getAccDescription:n,getDiagramTitle:o,setAccDescription:r,setAccTitle:t,setDiagramTitle:e},y=s(e=>{h(e,B),e.nodes.map(e=>B.addNode(e.indent?parseInt(e.indent):0,e.name))},"populate"),C={parse:s(async e=>{const t=await v("treeView",e);d.debug(t),y(t)},"parse")},T=s((e,t,r,o,n)=>{const i=o.append("text").text(r.name).attr("dominant-baseline","middle").attr("class","treeView-node-label"),{height:s,width:a}=i.node().getBBox(),d=s+2*n.paddingY,c=a+2*n.paddingX;i.attr("x",e+n.paddingX),i.attr("y",t+d/2),r.BBox={x:e,y:t,width:c,height:d}},"positionLabel"),V=s((e,t,r,o,n,i)=>e.append("line").attr("x1",t).attr("y1",r).attr("x2",o).attr("y2",n).attr("stroke-width",i).attr("class","treeView-node-line"),"positionLine"),z=s((e,t,r)=>{let o=0,n=0;const i=s((e,t,r,i)=>{const s=i*(r.rowIndent+r.paddingX);T(s,o,t,e,r);const{height:a,width:d}=t.BBox;V(e,s-r.rowIndent,o+a/2,s,o+a/2,r.lineThickness),n=Math.max(n,s+d),o+=a},"drawNode"),a=s((t,o=0)=>{i(e,t,r,o),t.children.forEach(e=>{a(e,o+1)});const{x:n,y:s,height:d}=t.BBox;if(t.children.length){const{y:o,height:i}=t.children[t.children.length-1].BBox;V(e,n+r.paddingX,s+d,n+r.paddingX,o+i/2+r.lineThickness/2,r.lineThickness)}},"processNode");return a(t),{totalHeight:o,totalWidth:n}},"drawTree"),D={labelFontSize:"16px",labelColor:"black",lineColor:"black"},X={db:B,renderer:{draw:s((e,t,r,o)=>{d.debug("Rendering treeView diagram\n"+e);const n=o.db,i=n.getRoot(),s=n.getConfig(),a=c(t),p=a.append("g");p.attr("class","tree-view");const{totalHeight:m,totalWidth:g}=z(p,i,s);a.attr("viewBox",`-${s.lineThickness/2} 0 ${g} ${m}`),l(a,m,g,s.useMaxWidth)},"draw")},parser:C,styles:s(({treeView:e})=>{const{labelFontSize:t,labelColor:r,lineColor:o}=a(D,e);return`\n    .treeView-node-label {\n        font-size: ${t};\n        fill: ${r};\n    }\n    .treeView-node-line {\n        stroke: ${o};\n    }\n    `},"styles")};export{X as diagram};
