import{p as x,b as f,s as C,q as B,g as T,a as y,_ as s,F as u,l as k,I as V,e as _,D,G as N,z as S}from"./mermaid.core-BDjhC0aB.js";import{p as I}from"./chunk-4BX2VUAB-C6cO8XKg.js";import{I as $}from"./chunk-QZHKN3VN-DX_QU77M.js";import{p as z}from"./wardley-RL74JXVD-BcQ8SDTw.js";import"./index-CstErxPE.js";import"./string-Bl2zznvy.js";import"./min-CXbaDcZd.js";import"./_baseUniq-cJOho3Bt.js";var d=new $(()=>({cnt:1,stack:[{id:0,level:-1,name:"/",children:[]}]})),A=s(()=>{d.reset(),S()},"clear"),X=s(()=>d.records.stack[0],"getRoot"),H=s(()=>d.records.cnt,"getCount"),L=N.treeView,R=s(()=>u(L,D().treeView),"getConfig"),W=s((e,t)=>{for(;e<=d.records.stack[d.records.stack.length-1].level;)d.records.stack.pop();const a={id:d.records.cnt++,level:e,name:t,children:[]};d.records.stack[d.records.stack.length-1].children.push(a),d.records.stack.push(a)},"addNode"),E={clear:A,addNode:W,getRoot:X,getCount:H,getConfig:R,getAccTitle:y,getAccDescription:T,getDiagramTitle:B,setAccDescription:C,setAccTitle:f,setDiagramTitle:x},w=E,F=s(e=>{I(e,w),e.nodes.map(t=>w.addNode(t.indent?parseInt(t.indent):0,t.name))},"populate"),M={parse:s(async e=>{const t=await z("treeView",e);k.debug(t),F(t)},"parse")},Y=s((e,t,a,i,o)=>{const c=i.append("text").text(a.name).attr("dominant-baseline","middle").attr("class","treeView-node-label"),{height:p,width:r}=c.node().getBBox(),l=p+o.paddingY*2,n=r+o.paddingX*2;c.attr("x",e+o.paddingX),c.attr("y",t+l/2),a.BBox={x:e,y:t,width:n,height:l}},"positionLabel"),b=s((e,t,a,i,o,c)=>e.append("line").attr("x1",t).attr("y1",a).attr("x2",i).attr("y2",o).attr("stroke-width",c).attr("class","treeView-node-line"),"positionLine"),q=s((e,t,a)=>{let i=0,o=0;const c=s((r,l,n,h)=>{const v=h*(n.rowIndent+n.paddingX);Y(v,i,l,r,n);const{height:g,width:m}=l.BBox;b(r,v-n.rowIndent,i+g/2,v,i+g/2,n.lineThickness),o=Math.max(o,v+m),i+=g},"drawNode"),p=s((r,l=0)=>{c(e,r,a,l),r.children.forEach(g=>{p(g,l+1)});const{x:n,y:h,height:v}=r.BBox;if(r.children.length){const{y:g,height:m}=r.children[r.children.length-1].BBox;b(e,n+a.paddingX,h+v,n+a.paddingX,g+m/2+a.lineThickness/2,a.lineThickness)}},"processNode");return p(t),{totalHeight:i,totalWidth:o}},"drawTree"),G=s((e,t,a,i)=>{k.debug(`Rendering treeView diagram
`+e);const o=i.db,c=o.getRoot(),p=o.getConfig(),r=V(t),l=r.append("g");l.attr("class","tree-view");const{totalHeight:n,totalWidth:h}=q(l,c,p);r.attr("viewBox",`-${p.lineThickness/2} 0 ${h} ${n}`),_(r,n,h,p.useMaxWidth)},"draw"),j={draw:G},J=j,K={labelFontSize:"16px",labelColor:"black",lineColor:"black"},O=s(({treeView:e})=>{const{labelFontSize:t,labelColor:a,lineColor:i}=u(K,e);return`
    .treeView-node-label {
        font-size: ${t};
        fill: ${a};
    }
    .treeView-node-line {
        stroke: ${i};
    }
    `},"styles"),P=O,ie={db:w,renderer:J,parser:M,styles:P};export{ie as diagram};
