25 lines
11 KiB
JavaScript
25 lines
11 KiB
JavaScript
|
|
import{a as me}from"./chunk-4KE642ED.mjs";import{a as pe}from"./chunk-353K7GK5.mjs";import"./chunk-DY3L2I7V.mjs";import"./chunk-6DHVG6KC.mjs";import"./chunk-EOITJJC2.mjs";import"./chunk-TLYDTAVK.mjs";import"./chunk-JXEFGRG2.mjs";import"./chunk-6XQQT3RD.mjs";import{a as de}from"./chunk-ASAHGCDZ.mjs";import{a as ce}from"./chunk-T244DUNM.mjs";import{c as ie,d as v}from"./chunk-5V7UUW6L.mjs";import{l as I}from"./chunk-EFRVIJHI.mjs";import"./chunk-THXVA4DE.mjs";import{L as Q,O as Z,P as ee,Q as te,R as ae,S as re,T as le,U as se,i as K,q as H}from"./chunk-KXVH62NG.mjs";import{b as M,h as V,j as L,k as oe,l as ne,m as _}from"./chunk-63GW7ZVL.mjs";import"./chunk-XW6ABFJP.mjs";import"./chunk-2XYWPRAO.mjs";import"./chunk-OMTJKCYW.mjs";import"./chunk-IQQE2MEC.mjs";import"./chunk-A4ITRWGT.mjs";import{a as p}from"./chunk-GTKDMUJJ.mjs";var $=class{constructor(){this.nodes=[];this.levels=new Map;this.outerNodes=[];this.classes=new Map;this.setAccTitle=ee;this.getAccTitle=te;this.setDiagramTitle=le;this.getDiagramTitle=se;this.getAccDescription=re;this.setAccDescription=ae}static{p(this,"TreeMapDB")}getNodes(){return this.nodes}getConfig(){let a=K,n=H();return I({...a.treemap,...n.treemap??{}})}addNode(a,n){this.nodes.push(a),this.levels.set(a,n),n===0&&(this.outerNodes.push(a),this.root??=a)}getRoot(){return{name:"",children:this.outerNodes}}addClass(a,n){let o=this.classes.get(a)??{id:a,styles:[],textStyles:[]},c=n.replace(/\\,/g,"\xA7\xA7\xA7").replace(/,/g,";").replace(/§§§/g,",").split(";");c&&c.forEach(l=>{ie(l)&&(o?.textStyles?o.textStyles.push(l):o.textStyles=[l]),o?.styles?o.styles.push(l):o.styles=[l]}),this.classes.set(a,o)}getClasses(){return this.classes}getStylesForClass(a){return this.classes.get(a)?.styles??[]}clear(){Z(),this.nodes=[],this.levels=new Map,this.outerNodes=[],this.classes=new Map,this.root=void 0}};function fe(m){if(!m.length)return[];let a=[],n=[];return m.forEach(o=>{let c={name:o.name,children:o.type==="Leaf"?void 0:[]};for(c.classSelector=o?.classSelector,o?.cssCompiledStyles&&(c.cssCompiledStyles=[o.cssCompiledStyles]),o.type==="Leaf"&&o.value!==void 0&&(c.value=o.value);n.length>0&&n[n.length-1].level>=o.level;)n.pop();if(n.length===0)a.push(c);else{let l=n[n.length-1].node;l.children?l.children.push(c):l.children=[c]}o.type!=="Leaf"&&n.push({node:c,level:o.level})}),a}p(fe,"buildHierarchy");var De=p((m,a)=>{me(m,a);let n=[];for(let l of m.TreemapRows??[])l.$type==="ClassDefStatement"&&a.addClass(l.className??"",l.styleText??"");for(let l of m.TreemapRows??[]){let d=l.item;if(!d)continue;let g=l.indent?parseInt(l.indent):0,W=ve(d),r=d.classSelector?a.getStylesForClass(d.classSelector):[],P=r.length>0?r.join(";"):void 0,T={level:g,name:W,type:d.$type,value:d.value,classSelector:d.classSelector,cssCompiledStyles:P};n.push(T)}let o=fe(n),c=p((l,d)=>{for(let g of l)a.addNode(g,d),g.children&&g.children.length>0&&c(g.children,d+1)},"addNodesRecursively");c(o,0)},"populate"),ve=p(m=>m.name?String(m.name):"","getItemName"),O={parser:{yy:void 0},parse:p(async m=>{try{let n=await pe("treemap",m);M.debug("Treemap AST:",n);let o=O.parser?.yy;if(!(o instanceof $))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.");De(n,o)}catch(a){throw M.error("Error parsing treemap:",a),a}},"parse")};var we=10,F=10,E=25,Ne=p((m,a,n,o)=>{let c=o.db,l=c.getConfig(),d=l.padding??we,g=c.getDiagramTitle(),W=c.getRoot(),{themeVariables:r}=H();if(!W)return;let P=g?30:0,T=de(a),X=l.nodeWidth?l.nodeWidth*F:960,Y=l.nodeHeight?l.nodeHeight*F:500,G=X,q=Y+P;T.attr("viewBox",`0 0 ${G} ${q}`),Q(T,q,G,l.useMaxWidth);let C;try{let e=l.valueFormat||",";if(e==="$0,0")C=p(t=>"$"+L(",")(t),"valueFormat");else if(e.startsWith("$")&&e.includes(",")){let t=/\.\d+/.exec(e),s=t?t[0]:"";C=p(f=>"$"+L(","+s)(f),"valueFormat")}else if(e.startsWith("$")){let t=e.substring(1);C=p(s=>"$"+L(t||"")(s),"valueFormat")}else C=L(e)}catch(e){M.error("Error creating format function:",e),C=L(",")}let A=_().range(["transparent",r.cScale0,r.cScale1,r
|
||
|
|
.treemapNode.section {
|
||
|
|
stroke: ${a.sectionStrokeColor};
|
||
|
|
stroke-width: ${a.sectionStrokeWidth};
|
||
|
|
fill: ${a.sectionFillColor};
|
||
|
|
}
|
||
|
|
.treemapNode.leaf {
|
||
|
|
stroke: ${a.leafStrokeColor};
|
||
|
|
stroke-width: ${a.leafStrokeWidth};
|
||
|
|
fill: ${a.leafFillColor};
|
||
|
|
}
|
||
|
|
.treemapLabel {
|
||
|
|
fill: ${a.labelColor};
|
||
|
|
font-size: ${a.labelFontSize};
|
||
|
|
}
|
||
|
|
.treemapValue {
|
||
|
|
fill: ${a.valueColor};
|
||
|
|
font-size: ${a.valueFontSize};
|
||
|
|
}
|
||
|
|
.treemapTitle {
|
||
|
|
fill: ${a.titleColor};
|
||
|
|
font-size: ${a.titleFontSize};
|
||
|
|
}
|
||
|
|
`},"getStyles"),ue=Fe;var pt={parser:O,get db(){return new $},renderer:ge,styles:ue};export{pt as diagram};
|