24 lines
15 KiB
JavaScript
24 lines
15 KiB
JavaScript
import{n as e,r as t}from"./chunk-AGHRB4JF-Fz9kp2Fp.js";import{D as n,H as r,K as i,U as a,a as o,b as s,c,f as l,v as u,w as d,y as f}from"./chunk-CSCIHK7Q-VDPd5eNJ.js";import{t as p}from"./ordinal-hYBb2elL.js";import{Q as m}from"./src-BrOGWJpF.js";import{t as h}from"./defaultLocale-C8Fc0cco.js";import{i as g}from"./chunk-5ZQYHXKU-D-OgLpMs.js";import{t as _}from"./chunk-WU5MYG2G-h67ucwKy.js";import{i as v,n as y}from"./chunk-NZK2D7GU-Cte2JwiA.js";import{t as b}from"./mermaid-parser.core-919mtcVP.js";import{t as x}from"./chunk-4BX2VUAB-DnDF0gw2.js";import{t as S}from"./chunk-2J33WTMH-CruGLWY_.js";function C(e){var t=0,n=e.children,r=n&&n.length;if(!r)t=1;else for(;--r>=0;)t+=n[r].value;e.value=t}function w(){return this.eachAfter(C)}function T(e,t){let n=-1;for(let r of this)e.call(t,r,++n,this);return this}function E(e,t){for(var n=this,r=[n],i,a,o=-1;n=r.pop();)if(e.call(t,n,++o,this),i=n.children)for(a=i.length-1;a>=0;--a)r.push(i[a]);return this}function D(e,t){for(var n=this,r=[n],i=[],a,o,s,c=-1;n=r.pop();)if(i.push(n),a=n.children)for(o=0,s=a.length;o<s;++o)r.push(a[o]);for(;n=i.pop();)e.call(t,n,++c,this);return this}function O(e,t){let n=-1;for(let r of this)if(e.call(t,r,++n,this))return r}function k(e){return this.eachAfter(function(t){for(var n=+e(t.data)||0,r=t.children,i=r&&r.length;--i>=0;)n+=r[i].value;t.value=n})}function A(e){return this.eachBefore(function(t){t.children&&t.children.sort(e)})}function j(e){for(var t=this,n=M(t,e),r=[t];t!==n;)t=t.parent,r.push(t);for(var i=r.length;e!==n;)r.splice(i,0,e),e=e.parent;return r}function M(e,t){if(e===t)return e;var n=e.ancestors(),r=t.ancestors(),i=null;for(e=n.pop(),t=r.pop();e===t;)i=e,e=n.pop(),t=r.pop();return i}function N(){for(var e=this,t=[e];e=e.parent;)t.push(e);return t}function P(){return Array.from(this)}function F(){var e=[];return this.eachBefore(function(t){t.children||e.push(t)}),e}function I(){var e=this,t=[];return e.each(function(n){n!==e&&t.push({source:n.parent,target:n})}),t}function*L(){var e=this,t,n=[e],r,i,a;do for(t=n.reverse(),n=[];e=t.pop();)if(yield e,r=e.children)for(i=0,a=r.length;i<a;++i)n.push(r[i]);while(n.length)}function R(e,t){e instanceof Map?(e=[void 0,e],t===void 0&&(t=V)):t===void 0&&(t=B);for(var n=new W(e),r,i=[n],a,o,s,c;r=i.pop();)if((o=t(r.data))&&(c=(o=Array.from(o)).length))for(r.children=o,s=c-1;s>=0;--s)i.push(a=o[s]=new W(o[s])),a.parent=r,a.depth=r.depth+1;return n.eachBefore(U)}function z(){return R(this).eachBefore(H)}function B(e){return e.children}function V(e){return Array.isArray(e)?e[1]:null}function H(e){e.data.value!==void 0&&(e.value=e.data.value),e.data=e.data.data}function U(e){var t=0;do e.height=t;while((e=e.parent)&&e.height<++t)}function W(e){this.data=e,this.depth=this.height=0,this.parent=null}W.prototype=R.prototype={constructor:W,count:w,each:T,eachAfter:D,eachBefore:E,find:O,sum:k,sort:A,path:j,ancestors:N,descendants:P,leaves:F,links:I,copy:z,[Symbol.iterator]:L};function G(e){if(typeof e!=`function`)throw Error();return e}function K(){return 0}function q(e){return function(){return e}}function J(e){e.x0=Math.round(e.x0),e.y0=Math.round(e.y0),e.x1=Math.round(e.x1),e.y1=Math.round(e.y1)}function ee(e,t,n,r,i){for(var a=e.children,o,s=-1,c=a.length,l=e.value&&(r-t)/e.value;++s<c;)o=a[s],o.y0=n,o.y1=i,o.x0=t,o.x1=t+=o.value*l}function te(e,t,n,r,i){for(var a=e.children,o,s=-1,c=a.length,l=e.value&&(i-n)/e.value;++s<c;)o=a[s],o.x0=t,o.x1=r,o.y0=n,o.y1=n+=o.value*l}var ne=(1+Math.sqrt(5))/2;function re(e,t,n,r,i,a){for(var o=[],s=t.children,c,l,u=0,d=0,f=s.length,p,m,h=t.value,g,_,v,y,b,x,S;u<f;){p=i-n,m=a-r;do g=s[d++].value;while(!g&&d<f);for(_=v=g,x=Math.max(m/p,p/m)/(h*e),S=g*g*x,b=Math.max(v/S,S/_);d<f;++d){if(g+=l=s[d].value,l<_&&(_=l),l>v&&(v=l),S=g*g*x,y=Math.max(v/S,S/_),y>b){g-=l;break}b=y}o.push(c={value:g,dice:p<m,children:s.slice(u,d)}),c.dice?ee(c,n,r,i,h?r+=m*g/h:a):te(c,n,r,h?n+=p*g/h:i,a),h-=g,u=d}return o}var ie=(function e(t){function n(e,n,r,i,a){re(t,e,n,r,i,a)}return n.ratio=function(t){return e((t=+t)>1?t:1)},n})(ne);function ae(){var e=ie,t=!1,n=1,r=1,i=[0],a=K,o=K,s=K,c=K,l=K;function u(e){return e.x0=e.y0=0,e.x1=n,e.y1=r,e.eachBefore(d),i=[0],t&&e.eachBefore(J),e}function d(t){var n=i[t.depth],r=t.x0+n,u=t.y0+n,d=t.x1-n,f=t.y1-n;d<r&&(r=d=(r+d)/2),f<u&&(u=f=(u+f)/2),t.x0=r,t.y0=u,t.x1=d,t.y1=f,t.children&&(n=i[t.depth+1]=a(t)/2,r+=l(t)-n,u+=o(t)-n,d-=s(t)-n,f-=c(t)-n,d<r&&(r=d=(r+d)/2),f<u&&(u=f=(u+f)/2),e(t,r,u,d,f))}return u.round=function(e){return arguments.length?(t=!!e,u):t},u.size=function(e){return arguments.length?(n=+e[0],r=+e[1],u):[n,r]},u.tile=function(t){return arguments.length?(e=G(t),u):e},u.padding=function(e){return arguments.length?u.paddingInner(e).paddingOuter(e):u.paddingInner()},u.paddingInner=function(e){return arguments.length?(a=typeof e==`function`?e:q(+e),u):a},u.paddingOuter=function(e){return arguments.length?u.paddingTop(e).paddingRight(e).paddingBottom(e).paddingLeft(e):u.paddingTop()},u.paddingTop=function(e){return arguments.length?(o=typeof e==`function`?e:q(+e),u):o},u.paddingRight=function(e){return arguments.length?(s=typeof e==`function`?e:q(+e),u):s},u.paddingBottom=function(e){return arguments.length?(c=typeof e==`function`?e:q(+e),u):c},u.paddingLeft=function(e){return arguments.length?(l=typeof e==`function`?e:q(+e),u):l},u}var Y=class{constructor(){this.nodes=[],this.levels=new Map,this.outerNodes=[],this.classes=new Map,this.setAccTitle=a,this.getAccTitle=f,this.setDiagramTitle=i,this.getDiagramTitle=d,this.getAccDescription=u,this.setAccDescription=r}static{e(this,`TreeMapDB`)}getNodes(){return this.nodes}getConfig(){let e=l,t=s();return g({...e.treemap,...t.treemap??{}})}addNode(e,t){this.nodes.push(e),this.levels.set(e,t),t===0&&(this.outerNodes.push(e),this.root??=e)}getRoot(){return{name:``,children:this.outerNodes}}addClass(e,t){let n=this.classes.get(e)??{id:e,styles:[],textStyles:[]},r=t.replace(/\\,/g,`§§§`).replace(/,/g,`;`).replace(/§§§/g,`,`).split(`;`);r&&r.forEach(e=>{y(e)&&(n?.textStyles?n.textStyles.push(e):n.textStyles=[e]),n?.styles?n.styles.push(e):n.styles=[e]}),this.classes.set(e,n)}getClasses(){return this.classes}getStylesForClass(e){return this.classes.get(e)?.styles??[]}clear(){o(),this.nodes=[],this.levels=new Map,this.outerNodes=[],this.classes=new Map,this.root=void 0}};function X(e){if(!e.length)return[];let t=[],n=[];return e.forEach(e=>{let r={name:e.name,children:e.type===`Leaf`?void 0:[]};for(r.classSelector=e?.classSelector,e?.cssCompiledStyles&&(r.cssCompiledStyles=e.cssCompiledStyles),e.type===`Leaf`&&e.value!==void 0&&(r.value=e.value);n.length>0&&n[n.length-1].level>=e.level;)n.pop();if(n.length===0)t.push(r);else{let e=n[n.length-1].node;e.children?e.children.push(r):e.children=[r]}e.type!==`Leaf`&&n.push({node:r,level:e.level})}),t}e(X,`buildHierarchy`);var oe=e((t,n)=>{x(t,n);let r=[];for(let e of t.TreemapRows??[])e.$type===`ClassDefStatement`&&n.addClass(e.className??``,e.styleText??``);for(let e of t.TreemapRows??[]){let t=e.item;if(!t)continue;let i=e.indent?parseInt(e.indent):0,a=se(t),o=t.classSelector?n.getStylesForClass(t.classSelector):[],s=o.length>0?o:void 0,c={level:i,name:a,type:t.$type,value:t.value,classSelector:t.classSelector,cssCompiledStyles:s};r.push(c)}let i=X(r),a=e((e,t)=>{for(let r of e)n.addNode(r,t),r.children&&r.children.length>0&&a(r.children,t+1)},`addNodesRecursively`);a(i,0)},`populate`),se=e(e=>e.name?String(e.name):``,`getItemName`),Z={parser:{yy:void 0},parse:e(async e=>{try{let n=await b(`treemap`,e);t.debug(`Treemap AST:`,n);let r=Z.parser?.yy;if(!(r instanceof Y))throw 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.`);oe(n,r)}catch(e){throw t.error(`Error parsing treemap:`,e),e}},`parse`)},ce=10,Q=10,$=25,le={draw:e((n,r,i,a)=>{let o=a.db,l=o.getConfig(),u=l.padding??ce,d=o.getDiagramTitle(),f=o.getRoot(),{themeVariables:g}=s();if(!f)return;let y=d?30:0,b=_(r),x=l.nodeWidth?l.nodeWidth*Q:960,C=l.nodeHeight?l.nodeHeight*Q:500,w=x,T=C+y;b.attr(`viewBox`,`0 0 ${w} ${T}`),c(b,T,w,l.useMaxWidth);let E;try{let t=l.valueFormat||`,`;if(t===`$0,0`)E=e(e=>`$`+h(`,`)(e),`valueFormat`);else if(t.startsWith(`$`)&&t.includes(`,`)){let n=/\.\d+/.exec(t),r=n?n[0]:``;E=e(e=>`$`+h(`,`+r)(e),`valueFormat`)}else if(t.startsWith(`$`)){let n=t.substring(1);E=e(e=>`$`+h(n||``)(e),`valueFormat`)}else E=h(t)}catch(e){t.error(`Error creating format function:`,e),E=h(`,`)}let D=p().range([`transparent`,g.cScale0,g.cScale1,g.cScale2,g.cScale3,g.cScale4,g.cScale5,g.cScale6,g.cScale7,g.cScale8,g.cScale9,g.cScale10,g.cScale11]),O=p().range([`transparent`,g.cScalePeer0,g.cScalePeer1,g.cScalePeer2,g.cScalePeer3,g.cScalePeer4,g.cScalePeer5,g.cScalePeer6,g.cScalePeer7,g.cScalePeer8,g.cScalePeer9,g.cScalePeer10,g.cScalePeer11]),k=p().range([g.cScaleLabel0,g.cScaleLabel1,g.cScaleLabel2,g.cScaleLabel3,g.cScaleLabel4,g.cScaleLabel5,g.cScaleLabel6,g.cScaleLabel7,g.cScaleLabel8,g.cScaleLabel9,g.cScaleLabel10,g.cScaleLabel11]);d&&b.append(`text`).attr(`x`,w/2).attr(`y`,y/2).attr(`class`,`treemapTitle`).attr(`text-anchor`,`middle`).attr(`dominant-baseline`,`middle`).text(d);let A=b.append(`g`).attr(`transform`,`translate(0, ${y})`).attr(`class`,`treemapContainer`),j=R(f).sum(e=>e.value??0).sort((e,t)=>(t.value??0)-(e.value??0)),M=ae().size([x,C]).paddingTop(e=>e.children&&e.children.length>0?$+Q:0).paddingInner(u).paddingLeft(e=>e.children&&e.children.length>0?Q:0).paddingRight(e=>e.children&&e.children.length>0?Q:0).paddingBottom(e=>e.children&&e.children.length>0?Q:0).round(!0)(j),N=M.descendants().filter(e=>e.children&&e.children.length>0),P=A.selectAll(`.treemapSection`).data(N).enter().append(`g`).attr(`class`,`treemapSection`).attr(`transform`,e=>`translate(${e.x0},${e.y0})`);P.append(`rect`).attr(`width`,e=>e.x1-e.x0).attr(`height`,$).attr(`class`,`treemapSectionHeader`).attr(`fill`,`none`).attr(`fill-opacity`,.6).attr(`stroke-width`,.6).attr(`style`,e=>e.depth===0?`display: none;`:``),P.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`,$),P.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=>D(e.data.name)).attr(`fill-opacity`,.6).attr(`stroke`,e=>O(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(`;`)}),P.append(`text`).attr(`class`,`treemapSectionLabel`).attr(`x`,6).attr(`y`,$/2).attr(`dominant-baseline`,`middle`).text(e=>e.depth===0?``:e.data.name).attr(`font-weight`,`bold`).attr(`style`,e=>e.depth===0?`display: none;`:`dominant-baseline: middle; font-size: 12px; fill:`+k(e.data.name)+`; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;`+v({cssCompiledStyles:e.data.cssCompiledStyles}).labelStyles.replace(`color:`,`fill:`)).each(function(e){if(e.depth===0)return;let t=m(this),n=e.data.name;t.text(n);let r=e.x1-e.x0,i;i=l.showValues!==!1&&e.value?r-10-30-10-6:r-6-6;let a=Math.max(15,i),o=t.node();if(o.getComputedTextLength()>a){let e=n;for(;e.length>0;){if(e=n.substring(0,e.length-1),e.length===0){t.text(`...`),o.getComputedTextLength()>a&&t.text(``);break}if(t.text(e+`...`),o.getComputedTextLength()<=a)break}}}),l.showValues!==!1&&P.append(`text`).attr(`class`,`treemapSectionValue`).attr(`x`,e=>e.x1-e.x0-10).attr(`y`,$/2).attr(`text-anchor`,`end`).attr(`dominant-baseline`,`middle`).text(e=>e.value?E(e.value):``).attr(`font-style`,`italic`).attr(`style`,e=>e.depth===0?`display: none;`:`text-anchor: end; dominant-baseline: middle; font-size: 10px; fill:`+k(e.data.name)+`; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;`+v({cssCompiledStyles:e.data.cssCompiledStyles}).labelStyles.replace(`color:`,`fill:`));let F=M.leaves(),I=A.selectAll(`.treemapLeafGroup`).data(F).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})`);I.append(`rect`).attr(`width`,e=>e.x1-e.x0).attr(`height`,e=>e.y1-e.y0).attr(`class`,`treemapLeaf`).attr(`fill`,e=>e.parent?D(e.parent.data.name):D(e.data.name)).attr(`style`,e=>v({cssCompiledStyles:e.data.cssCompiledStyles}).nodeStyles).attr(`fill-opacity`,.3).attr(`stroke`,e=>e.parent?D(e.parent.data.name):D(e.data.name)).attr(`stroke-width`,3),I.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)),I.append(`text`).attr(`class`,`treemapLabel`).attr(`x`,e=>(e.x1-e.x0)/2).attr(`y`,e=>(e.y1-e.y0)/2).attr(`style`,e=>`text-anchor: middle; dominant-baseline: middle; font-size: 38px;fill:`+k(e.data.name)+`;`+v({cssCompiledStyles:e.data.cssCompiledStyles}).labelStyles.replace(`color:`,`fill:`)).attr(`clip-path`,(e,t)=>`url(#clip-${r}-${t})`).text(e=>e.data.name).each(function(e){let t=m(this),n=e.x1-e.x0,r=e.y1-e.y0,i=t.node(),a=n-8,o=r-8;if(a<10||o<10){t.style(`display`,`none`);return}let s=parseInt(t.style(`font-size`),10),c=.6;for(;i.getComputedTextLength()>a&&s>8;)s--,t.style(`font-size`,`${s}px`);let l=Math.max(6,Math.min(28,Math.round(s*c))),u=s+2+l;for(;u>o&&s>8&&(s--,l=Math.max(6,Math.min(28,Math.round(s*c))),!(l<6&&s===8));)t.style(`font-size`,`${s}px`),u=s+2+l;t.style(`font-size`,`${s}px`),(i.getComputedTextLength()>a||s<8||o<s)&&t.style(`display`,`none`)}),l.showValues!==!1&&I.append(`text`).attr(`class`,`treemapValue`).attr(`x`,e=>(e.x1-e.x0)/2).attr(`y`,function(e){return(e.y1-e.y0)/2}).attr(`style`,e=>`text-anchor: middle; dominant-baseline: hanging; font-size: 28px;fill:`+k(e.data.name)+`;`+v({cssCompiledStyles:e.data.cssCompiledStyles}).labelStyles.replace(`color:`,`fill:`)).attr(`clip-path`,(e,t)=>`url(#clip-${r}-${t})`).text(e=>e.value?E(e.value):``).each(function(e){let t=m(this),n=this.parentNode;if(!n){t.style(`display`,`none`);return}let r=m(n).select(`.treemapLabel`);if(r.empty()||r.style(`display`)===`none`){t.style(`display`,`none`);return}let i=parseFloat(r.style(`font-size`)),a=Math.max(6,Math.min(28,Math.round(i*.6)));t.style(`font-size`,`${a}px`);let o=(e.y1-e.y0)/2+i/2+2;t.attr(`y`,o);let s=e.x1-e.x0,c=e.y1-e.y0-4,l=s-8;t.node().getComputedTextLength()>l||o+a>c||a<6?t.style(`display`,`none`):t.style(`display`,null)}),S(b,l.diagramPadding??8,`flowchart`,l?.useMaxWidth||!1)},`draw`),getClasses:e(function(e,t){return t.db.getClasses()},`getClasses`)},ue={sectionStrokeColor:`black`,sectionStrokeWidth:`1`,sectionFillColor:`#efefef`,leafStrokeColor:`black`,leafStrokeWidth:`1`,leafFillColor:`#efefef`,labelFontSize:`12px`,valueFontSize:`10px`,titleFontSize:`14px`},de={parser:Z,get db(){return new Y},renderer:le,styles:e(({treemap:e}={})=>{let t=g(n(),s().themeVariables),r=g(ue,e),i=r.titleColor??t.titleColor,a=r.labelColor??t.textColor,o=r.valueColor??t.textColor;return`
|
|
.treemapNode.section {
|
|
stroke: ${r.sectionStrokeColor};
|
|
stroke-width: ${r.sectionStrokeWidth};
|
|
fill: ${r.sectionFillColor};
|
|
}
|
|
.treemapNode.leaf {
|
|
stroke: ${r.leafStrokeColor};
|
|
stroke-width: ${r.leafStrokeWidth};
|
|
fill: ${r.leafFillColor};
|
|
}
|
|
.treemapLabel {
|
|
fill: ${a};
|
|
font-size: ${r.labelFontSize};
|
|
}
|
|
.treemapValue {
|
|
fill: ${o};
|
|
font-size: ${r.valueFontSize};
|
|
}
|
|
.treemapTitle {
|
|
fill: ${i};
|
|
font-size: ${r.titleFontSize};
|
|
}
|
|
`},`getStyles`)};export{de as diagram}; |