import{s as e,a as t,b as r,g as o,c as n,d as s,_ as a,e as i,l as d,f as c,h as l,i as p,j as g,k as h}from"./cc0da28d5-DhCu_vCs.js";import{p as m}from"./c3bb327b0-QvptWrEu.js";import{I as w}from"./ce1e71a2e-DgIMnWvb.js";import{p as b}from"./c68b7746e-CnsdryAg.js";import"./vendor-react-AXa6hZO5.js";import"./vendor-lodash-BKAXkXVe.js";import"./c2764ca9d-5rijQG1V.js";import"./c606eaf84-CNZBcau1.js";import"./cec18ad9a-DiLjrOUd.js";import"./vendor-radix-glKlawmm.js";import"./vendor-zod-CMvj0_Fd.js";import"./vendor-intl-BdADXLLt.js";import"./vendor-zustand-CcZsBpBq.js";import"./vendor-icons-Dy3Nea9p.js";import"./vendor-motion-0BJMgYoH.js";import"./vendor-infra-CFC-WJ8N.js";import"./vendor-router-BSYVf8By.js";import"./vendor-query-D7SPXjZv.js";import"./vendor-growthbook-XJcBFzji.js";import"./cbf688cef-vOanPwNn.js";var j=new w(()=>({cnt:1,stack:[{id:0,level:-1,name:"/",children:[]}]})),k=a(()=>{j.reset(),h()},"clear"),v=a(()=>j.records.stack[0],"getRoot"),x=a(()=>j.records.cnt,"getCount"),f=g.treeView,u=a(()=>i(f,p().treeView),"getConfig"),B={clear:k,addNode:a((e,t)=>{for(;e<=j.records.stack[j.records.stack.length-1].level;)j.records.stack.pop();const r={id:j.records.cnt++,level:e,name:t,children:[]};j.records.stack[j.records.stack.length-1].children.push(r),j.records.stack.push(r)},"addNode"),getRoot:v,getCount:x,getConfig:u,getAccTitle:s,getAccDescription:n,getDiagramTitle:o,setAccDescription:r,setAccTitle:t,setDiagramTitle:e},y=a(e=>{m(e,B),e.nodes.map(e=>B.addNode(e.indent?parseInt(e.indent):0,e.name))},"populate"),C={parse:a(async e=>{const t=await b("treeView",e);d.debug(t),y(t)},"parse")},T=a((e,t,r,o,n)=>{const s=o.append("text").text(r.name).attr("dominant-baseline","middle").attr("class","treeView-node-label"),{height:a,width:i}=s.node().getBBox(),d=a+2*n.paddingY,c=i+2*n.paddingX;s.attr("x",e+n.paddingX),s.attr("y",t+d/2),r.BBox={x:e,y:t,width:c,height:d}},"positionLabel"),V=a((e,t,r,o,n,s)=>e.append("line").attr("x1",t).attr("y1",r).attr("x2",o).attr("y2",n).attr("stroke-width",s).attr("class","treeView-node-line"),"positionLine"),$=a((e,t,r)=>{let o=0,n=0;const s=a((e,t,r,s)=>{const a=s*(r.rowIndent+r.paddingX);T(a,o,t,e,r);const{height:i,width:d}=t.BBox;V(e,a-r.rowIndent,o+i/2,a,o+i/2,r.lineThickness),n=Math.max(n,a+d),o+=i},"drawNode"),i=a((t,o=0)=>{s(e,t,r,o),t.children.forEach(e=>{i(e,o+1)});const{x:n,y:a,height:d}=t.BBox;if(t.children.length){const{y:o,height:s}=t.children[t.children.length-1].BBox;V(e,n+r.paddingX,a+d,n+r.paddingX,o+s/2+r.lineThickness/2,r.lineThickness)}},"processNode");return i(t),{totalHeight:o,totalWidth:n}},"drawTree"),z={labelFontSize:"16px",labelColor:"black",lineColor:"black"},N={db:B,renderer:{draw:a((e,t,r,o)=>{d.debug("Rendering treeView diagram\n"+e);const n=o.db,s=n.getRoot(),a=n.getConfig(),i=c(t),p=i.append("g");p.attr("class","tree-view");const{totalHeight:g,totalWidth:h}=$(p,s,a);i.attr("viewBox",`-${a.lineThickness/2} 0 ${h} ${g}`),l(i,g,h,a.useMaxWidth)},"draw")},parser:C,styles:a(({treeView:e})=>{const{labelFontSize:t,labelColor:r,lineColor:o}=i(z,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{N as diagram};
