import{a as de}from"./chunk-JQRUD6KW.mjs";import{a as me}from"./chunk-2T2R6R2M.mjs";import"./chunk-UP6H54XL.mjs";import"./chunk-UXSXWOXI.mjs";import"./chunk-C62D2QBJ.mjs";import"./chunk-CEXFNPSA.mjs";import"./chunk-RERM46MO.mjs";import"./chunk-J5EP6P6S.mjs";import"./chunk-RLI5ZMPA.mjs";import"./chunk-2UTLFMKG.mjs";import"./chunk-RKZBBQEN.mjs";import{a as fe}from"./chunk-LRIF4GLE.mjs";import{a as pe}from"./chunk-ZXARS5L4.mjs";import{c as ce,d as v}from"./chunk-T2UQINTJ.mjs";import{o as W}from"./chunk-QA3QBVWF.mjs";import"./chunk-KNLZD3CH.mjs";import{O as Z,S as ee,T as te,U as ae,V as re,W as se,X as le,Y as oe,h as K,j as Q,t as L}from"./chunk-67TQ5CYL.mjs";import{b as k,h as E,j as $,k as ne,l as ie,m as I}from"./chunk-7W6UQGC5.mjs";import"./chunk-KGYTTC2M.mjs";import"./chunk-4R4BOZG6.mjs";import{a as p}from"./chunk-AQ6EADP3.mjs";var F=class{constructor(){this.nodes=[];this.levels=new Map;this.outerNodes=[];this.classes=new Map;this.setAccTitle=te;this.getAccTitle=ae;this.setDiagramTitle=le;this.getDiagramTitle=oe;this.getAccDescription=se;this.setAccDescription=re}static{p(this,"TreeMapDB")}getNodes(){return this.nodes}getConfig(){let r=Q,i=L();return W({...r.treemap,...i.treemap??{}})}addNode(r,i){this.nodes.push(r),this.levels.set(r,i),i===0&&(this.outerNodes.push(r),this.root??=r)}getRoot(){return{name:"",children:this.outerNodes}}addClass(r,i){let l=this.classes.get(r)??{id:r,styles:[],textStyles:[]},o=i.replace(/\\,/g,"\xA7\xA7\xA7").replace(/,/g,";").replace(/ยงยงยง/g,",").split(";");o&&o.forEach(s=>{ce(s)&&(l?.textStyles?l.textStyles.push(s):l.textStyles=[s]),l?.styles?l.styles.push(s):l.styles=[s]}),this.classes.set(r,l)}getClasses(){return this.classes}getStylesForClass(r){return this.classes.get(r)?.styles??[]}clear(){ee(),this.nodes=[],this.levels=new Map,this.outerNodes=[],this.classes=new Map,this.root=void 0}};function ge(m){if(!m.length)return[];let r=[],i=[];return m.forEach(l=>{let o={name:l.name,children:l.type==="Leaf"?void 0:[]};for(o.classSelector=l?.classSelector,l?.cssCompiledStyles&&(o.cssCompiledStyles=l.cssCompiledStyles),l.type==="Leaf"&&l.value!==void 0&&(o.value=l.value);i.length>0&&i[i.length-1].level>=l.level;)i.pop();if(i.length===0)r.push(o);else{let s=i[i.length-1].node;s.children?s.children.push(o):s.children=[o]}l.type!=="Leaf"&&i.push({node:o,level:l.level})}),r}p(ge,"buildHierarchy");var ve=p((m,r)=>{de(m,r);let i=[];for(let s of m.TreemapRows??[])s.$type==="ClassDefStatement"&&r.addClass(s.className??"",s.styleText??"");for(let s of m.TreemapRows??[]){let d=s.item;if(!d)continue;let f=s.indent?parseInt(s.indent):0,R=we(d),a=d.classSelector?r.getStylesForClass(d.classSelector):[],A=a.length>0?a:void 0,T={level:f,name:R,type:d.$type,value:d.value,classSelector:d.classSelector,cssCompiledStyles:A};i.push(T)}let l=ge(i),o=p((s,d)=>{for(let f of s)r.addNode(f,d),f.children&&f.children.length>0&&o(f.children,d+1)},"addNodesRecursively");o(l,0)},"populate"),we=p(m=>m.name?String(m.name):"","getItemName"),O={parser:{yy:void 0},parse:p(async m=>{try{let i=await me("treemap",m);k.debug("Treemap AST:",i);let l=O.parser?.yy;if(!(l instanceof F))throw new Error("parser.parser?.yy was not a TreemapDB. This is due to a bug within Mermaid, please report this issue at https://github.com/mermaid-js/mermaid/issues.");ve(i,l)}catch(r){throw k.error("Error parsing treemap:",r),r}},"parse")};var Ne=10,P=10,B=25,Le=p((m,r,i,l)=>{let o=l.db,s=o.getConfig(),d=s.padding??Ne,f=o.getDiagramTitle(),R=o.getRoot(),{themeVariables:a}=L();if(!R)return;let A=f?30:0,T=fe(r),X=s.nodeWidth?s.nodeWidth*P:960,Y=s.nodeHeight?s.nodeHeight*P:500,G=X,q=Y+A;T.attr("viewBox",`0 0 ${G} ${q}`),Z(T,q,G,s.useMaxWidth);let C;try{let e=s.valueFormat||",";if(e==="$0,0")C=p(t=>"$"+$(",")(t),"valueFormat");else if(e.startsWith("$")&&e.includes(",")){let t=/\.\d+/.exec(e),n=t?t[0]:"";C=p(g=>"$"+$(","+n)(g),"valueFormat")}else if(e.startsWith("$")){let t=e.substring(1);C=p(n=>"$"+$(t||"")(n),"valueFormat")}else C=$(e)}catch(e){k.error("Error creating format function:",e),C=$(",")}let V=I().range(["transparent",a.cScale0,a.cScale1,a.cScale2,a.cScale3,a.cScale4,a.cScale5,a.cScale6,a.cScale7,a.cScale8,a.cScale9,a.cScale10,a.cScale11]),ye=I().range(["transparent",a.cScalePeer0,a.cScalePeer1,a.cScalePeer2,a.cScalePeer3,a.cScalePeer4,a.cScalePeer5,a.cScalePeer6,a.cScalePeer7,a.cScalePeer8,a.cScalePeer9,a.cScalePeer10,a.cScalePeer11]),H=I().range([a.cScaleLabel0,a.cScaleLabel1,a.cScaleLabel2,a.cScaleLabel3,a.cScaleLabel4,a.cScaleLabel5,a.cScaleLabel6,a.cScaleLabel7,a.cScaleLabel8,a.cScaleLabel9,a.cScaleLabel10,a.cScaleLabel11]);f&&T.append("text").attr("x",G/2).attr("y",A/2).attr("class","treemapTitle").attr("text-anchor","middle").attr("dominant-baseline","middle").text(f);let U=T.append("g").attr("transform",`translate(0, ${A})`).attr("class","treemapContainer"),Se=ne(R).sum(e=>e.value??0).sort((e,t)=>(t.value??0)-(e.value??0)),J=ie().size([X,Y]).paddingTop(e=>e.children&&e.children.length>0?B+P:0).paddingInner(d).paddingLeft(e=>e.children&&e.children.length>0?P:0).paddingRight(e=>e.children&&e.children.length>0?P:0).paddingBottom(e=>e.children&&e.children.length>0?P:0).round(!0)(Se),be=J.descendants().filter(e=>e.children&&e.children.length>0),z=U.selectAll(".treemapSection").data(be).enter().append("g").attr("class","treemapSection").attr("transform",e=>`translate(${e.x0},${e.y0})`);z.append("rect").attr("width",e=>e.x1-e.x0).attr("height",B).attr("class","treemapSectionHeader").attr("fill","none").attr("fill-opacity",.6).attr("stroke-width",.6).attr("style",e=>e.depth===0?"display: none;":""),z.append("clipPath").attr("id",(e,t)=>`clip-section-${r}-${t}`).append("rect").attr("width",e=>Math.max(0,e.x1-e.x0-12)).attr("height",B),z.append("rect").attr("width",e=>e.x1-e.x0).attr("height",e=>e.y1-e.y0).attr("class",(e,t)=>`treemapSection section${t}`).attr("fill",e=>V(e.data.name)).attr("fill-opacity",.6).attr("stroke",e=>ye(e.data.name)).attr("stroke-width",2).attr("stroke-opacity",.4).attr("style",e=>{if(e.depth===0)return"display: none;";let t=v({cssCompiledStyles:e.data.cssCompiledStyles});return t.nodeStyles+";"+t.borderStyles.join(";")}),z.append("text").attr("class","treemapSectionLabel").attr("x",6).attr("y",B/2).attr("dominant-baseline","middle").text(e=>e.depth===0?"":e.data.name).attr("font-weight","bold").attr("style",e=>{if(e.depth===0)return"display: none;";let t="dominant-baseline: middle; font-size: 12px; fill:"+H(e.data.name)+"; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;",n=v({cssCompiledStyles:e.data.cssCompiledStyles});return t+n.labelStyles.replace("color:","fill:")}).each(function(e){if(e.depth===0)return;let t=E(this),n=e.data.name;t.text(n);let g=e.x1-e.x0,y=6,S;s.showValues!==!1&&e.value?S=g-10-30-10-y:S=g-y-6;let u=Math.max(15,S),c=t.node();if(c.getComputedTextLength()>u){let h=n;for(;h.length>0;){if(h=n.substring(0,h.length-1),h.length===0){t.text("..."),c.getComputedTextLength()>u&&t.text("");break}if(t.text(h+"..."),c.getComputedTextLength()<=u)break}}}),s.showValues!==!1&&z.append("text").attr("class","treemapSectionValue").attr("x",e=>e.x1-e.x0-10).attr("y",B/2).attr("text-anchor","end").attr("dominant-baseline","middle").text(e=>e.value?C(e.value):"").attr("font-style","italic").attr("style",e=>{if(e.depth===0)return"display: none;";let t="text-anchor: end; dominant-baseline: middle; font-size: 10px; fill:"+H(e.data.name)+"; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;",n=v({cssCompiledStyles:e.data.cssCompiledStyles});return t+n.labelStyles.replace("color:","fill:")});let xe=J.leaves(),j=U.selectAll(".treemapLeafGroup").data(xe).enter().append("g").attr("class",(e,t)=>`treemapNode treemapLeafGroup leaf${t}${e.data.classSelector?` ${e.data.classSelector}`:""}x`).attr("transform",e=>`translate(${e.x0},${e.y0})`);j.append("rect").attr("width",e=>e.x1-e.x0).attr("height",e=>e.y1-e.y0).attr("class","treemapLeaf").attr("fill",e=>e.parent?V(e.parent.data.name):V(e.data.name)).attr("style",e=>v({cssCompiledStyles:e.data.cssCompiledStyles}).nodeStyles).attr("fill-opacity",.3).attr("stroke",e=>e.parent?V(e.parent.data.name):V(e.data.name)).attr("stroke-width",3),j.append("clipPath").attr("id",(e,t)=>`clip-${r}-${t}`).append("rect").attr("width",e=>Math.max(0,e.x1-e.x0-4)).attr("height",e=>Math.max(0,e.y1-e.y0-4)),j.append("text").attr("class","treemapLabel").attr("x",e=>(e.x1-e.x0)/2).attr("y",e=>(e.y1-e.y0)/2).attr("style",e=>{let t="text-anchor: middle; dominant-baseline: middle; font-size: 38px;fill:"+H(e.data.name)+";",n=v({cssCompiledStyles:e.data.cssCompiledStyles});return t+n.labelStyles.replace("color:","fill:")}).attr("clip-path",(e,t)=>`url(#clip-${r}-${t})`).text(e=>e.data.name).each(function(e){let t=E(this),n=e.x1-e.x0,g=e.y1-e.y0,y=t.node(),S=4,w=n-2*S,u=g-2*S;if(w<10||u<10){t.style("display","none");return}let c=parseInt(t.style("font-size"),10),D=8,b=28,h=.6,x=6,M=2;for(;y.getComputedTextLength()>w&&c>D;)c--,t.style("font-size",`${c}px`);let N=Math.max(x,Math.min(b,Math.round(c*h))),_=c+M+N;for(;_>u&&c>D&&(c--,N=Math.max(x,Math.min(b,Math.round(c*h))),!(Nu;t.style("font-size",`${c}px`),(y.getComputedTextLength()>w||c(t.x1-t.x0)/2).attr("y",function(t){return(t.y1-t.y0)/2}).attr("style",t=>{let n="text-anchor: middle; dominant-baseline: hanging; font-size: 28px;fill:"+H(t.data.name)+";",g=v({cssCompiledStyles:t.data.cssCompiledStyles});return n+g.labelStyles.replace("color:","fill:")}).attr("clip-path",(t,n)=>`url(#clip-${r}-${n})`).text(t=>t.value?C(t.value):"").each(function(t){let n=E(this),g=this.parentNode;if(!g){n.style("display","none");return}let y=E(g).select(".treemapLabel");if(y.empty()||y.style("display")==="none"){n.style("display","none");return}let S=parseFloat(y.style("font-size")),w=28,u=.6,c=6,D=2,b=Math.max(c,Math.min(w,Math.round(S*u)));n.style("font-size",`${b}px`);let x=(t.y1-t.y0)/2+S/2+D;n.attr("y",x);let M=t.x1-t.x0,Ce=t.y1-t.y0-4,De=M-8;n.node().getComputedTextLength()>De||x+b>Ce||b{let r=K(),i=L(),l=W(r,i.themeVariables),o=W(Fe,m),s=o.titleColor??l.titleColor,d=o.labelColor??l.textColor,f=o.valueColor??l.textColor;return` .treemapNode.section { stroke: ${o.sectionStrokeColor}; stroke-width: ${o.sectionStrokeWidth}; fill: ${o.sectionFillColor}; } .treemapNode.leaf { stroke: ${o.leafStrokeColor}; stroke-width: ${o.leafStrokeWidth}; fill: ${o.leafFillColor}; } .treemapLabel { fill: ${d}; font-size: ${o.labelFontSize}; } .treemapValue { fill: ${f}; font-size: ${o.valueFontSize}; } .treemapTitle { fill: ${s}; font-size: ${o.titleFontSize}; } `},"getStyles"),he=Pe;var ft={parser:O,get db(){return new F},renderer:ue,styles:he};export{ft as diagram};