@asyncapi/studio
Version:
One place that allows you to develop an AsyncAPI document, validate it, convert it to the latest version, preview the documentation and visualize the events flow.
24 lines • 11.6 kB
JavaScript
exports.id=4009,exports.ids=[4009],exports.modules={47642:e=>{function t(e){var t=Error("Cannot find module '"+e+"'");throw t.code="MODULE_NOT_FOUND",t}t.keys=()=>[],t.resolve=t,t.id=47642,e.exports=t},53657:(e,t,a)=>{"use strict";function l(e,t){e.accDescr&&t.setAccDescription?.(e.accDescr),e.accTitle&&t.setAccTitle?.(e.accTitle),e.title&&t.setDiagramTitle?.(e.title)}a.d(t,{A:()=>l}),(0,a(17605).eW)(l,"populateCommonDb")},76786:(e,t,a)=>{"use strict";a.d(t,{j:()=>r});var l=a(51635),s=a(17605),r=(0,s.eW)((e,t,a,r)=>{e.attr("class",a);let{width:o,height:c,x:d,y:p}=i(e,t);(0,l.v2)(e,c,o,r);let h=n(d,p,o,c,t);e.attr("viewBox",h),s.cM.debug(`viewBox configured: ${h} with padding: ${t}`)},"setupViewPortForSVG"),i=(0,s.eW)((e,t)=>{let a=e.node()?.getBBox()||{width:0,height:0,x:0,y:0};return{width:a.width+2*t,height:a.height+2*t,x:a.x,y:a.y}},"calculateDimensionsWithPadding"),n=(0,s.eW)((e,t,a,l,s)=>`${e-s} ${t-s} ${a} ${l}`,"createViewBox")},56910:(e,t,a)=>{"use strict";a.d(t,{diagram:()=>b});var l=a(51892),s=a(76786),r=a(65732),i=a(53657),n=a(63951),o=a(51635),c=a(17605),d=a(79358),p=a(25329),h=class{constructor(){this.nodes=[],this.levels=new Map,this.outerNodes=[],this.classes=new Map,this.setAccTitle=o.GN,this.getAccTitle=o.eu,this.setDiagramTitle=o.g2,this.getDiagramTitle=o.Kr,this.getAccDescription=o.Mx,this.setAccDescription=o.U$}static{(0,c.eW)(this,"TreeMapDB")}getNodes(){return this.nodes}getConfig(){let e=o.vZ,t=(0,o.iE)();return(0,n.Rb)({...e.treemap,...t.treemap??{}})}addNode(e,t){this.nodes.push(e),this.levels.set(e,t),0===t&&(this.outerNodes.push(e),this.root??=e)}getRoot(){return{name:"",children:this.outerNodes}}addClass(e,t){let a=this.classes.get(e)??{id:e,styles:[],textStyles:[]},l=t.replace(/\\,/g,"\xa7\xa7\xa7").replace(/,/g,";").replace(/§§§/g,",").split(";");l&&l.forEach(e=>{(0,r.Fh)(e)&&(a?.textStyles?a.textStyles.push(e):a.textStyles=[e]),a?.styles?a.styles.push(e):a.styles=[e]}),this.classes.set(e,a)}getClasses(){return this.classes}getStylesForClass(e){return this.classes.get(e)?.styles??[]}clear(){(0,o.ZH)(),this.nodes=[],this.levels=new Map,this.outerNodes=[],this.classes=new Map,this.root=void 0}};function m(e){if(!e.length)return[];let t=[],a=[];return e.forEach(e=>{let l={name:e.name,children:"Leaf"===e.type?void 0:[]};for(l.classSelector=e?.classSelector,e?.cssCompiledStyles&&(l.cssCompiledStyles=e.cssCompiledStyles),"Leaf"===e.type&&void 0!==e.value&&(l.value=e.value);a.length>0&&a[a.length-1].level>=e.level;)a.pop();if(0===a.length)t.push(l);else{let e=a[a.length-1].node;e.children?e.children.push(l):e.children=[l]}"Leaf"!==e.type&&a.push({node:l,level:e.level})}),t}(0,c.eW)(m,"buildHierarchy");var y=(0,c.eW)((e,t)=>{(0,i.A)(e,t);let a=[];for(let a of e.TreemapRows??[])"ClassDefStatement"===a.$type&&t.addClass(a.className??"",a.styleText??"");for(let l of e.TreemapRows??[]){let e=l.item;if(!e)continue;let s=l.indent?parseInt(l.indent):0,r=u(e),i=e.classSelector?t.getStylesForClass(e.classSelector):[],n=i.length>0?i:void 0,o={level:s,name:r,type:e.$type,value:e.value,classSelector:e.classSelector,cssCompiledStyles:n};a.push(o)}let l=m(a),s=(0,c.eW)((e,a)=>{for(let l of e)t.addNode(l,a),l.children&&l.children.length>0&&s(l.children,a+1)},"addNodesRecursively");s(l,0)},"populate"),u=(0,c.eW)(e=>e.name?String(e.name):"","getItemName"),f={parser:{yy:void 0},parse:(0,c.eW)(async e=>{try{let t=d.Qc,a=await t("treemap",e);c.cM.debug("Treemap AST:",a);let l=f.parser?.yy;if(!(l instanceof h))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.");y(a,l)}catch(e){throw c.cM.error("Error parsing treemap:",e),e}},"parse")},g=(0,c.eW)((e,t,a,i)=>{let n;let d=i.db,h=d.getConfig(),m=h.padding??10,y=d.getDiagramTitle(),u=d.getRoot(),{themeVariables:f}=(0,o.iE)();if(!u)return;let g=y?30:0,S=(0,l.P)(t),x=h.nodeWidth?10*h.nodeWidth:960,b=h.nodeHeight?10*h.nodeHeight:500,v=b+g;S.attr("viewBox",`0 0 ${x} ${v}`),(0,o.v2)(S,v,x,h.useMaxWidth);try{let e=h.valueFormat||",";if("$0,0"===e)n=(0,c.eW)(e=>"$"+(0,p.WUZ)(",")(e),"valueFormat");else if(e.startsWith("$")&&e.includes(",")){let t=/\.\d+/.exec(e),a=t?t[0]:"";n=(0,c.eW)(e=>"$"+(0,p.WUZ)(","+a)(e),"valueFormat")}else if(e.startsWith("$")){let t=e.substring(1);n=(0,c.eW)(e=>"$"+(0,p.WUZ)(t||"")(e),"valueFormat")}else n=(0,p.WUZ)(e)}catch(e){c.cM.error("Error creating format function:",e),n=(0,p.WUZ)(",")}let $=(0,p.PKp)().range(["transparent",f.cScale0,f.cScale1,f.cScale2,f.cScale3,f.cScale4,f.cScale5,f.cScale6,f.cScale7,f.cScale8,f.cScale9,f.cScale10,f.cScale11]),C=(0,p.PKp)().range(["transparent",f.cScalePeer0,f.cScalePeer1,f.cScalePeer2,f.cScalePeer3,f.cScalePeer4,f.cScalePeer5,f.cScalePeer6,f.cScalePeer7,f.cScalePeer8,f.cScalePeer9,f.cScalePeer10,f.cScalePeer11]),w=(0,p.PKp)().range([f.cScaleLabel0,f.cScaleLabel1,f.cScaleLabel2,f.cScaleLabel3,f.cScaleLabel4,f.cScaleLabel5,f.cScaleLabel6,f.cScaleLabel7,f.cScaleLabel8,f.cScaleLabel9,f.cScaleLabel10,f.cScaleLabel11]);y&&S.append("text").attr("x",x/2).attr("y",g/2).attr("class","treemapTitle").attr("text-anchor","middle").attr("dominant-baseline","middle").text(y);let W=S.append("g").attr("transform",`translate(0, ${g})`).attr("class","treemapContainer"),L=(0,p.bT9)(u).sum(e=>e.value??0).sort((e,t)=>(t.value??0)-(e.value??0)),T=(0,p.pNI)().size([x,b]).paddingTop(e=>e.children&&e.children.length>0?35:0).paddingInner(m).paddingLeft(e=>e.children&&e.children.length>0?10:0).paddingRight(e=>e.children&&e.children.length>0?10:0).paddingBottom(e=>e.children&&e.children.length>0?10:0).round(!0)(L),M=T.descendants().filter(e=>e.children&&e.children.length>0),k=W.selectAll(".treemapSection").data(M).enter().append("g").attr("class","treemapSection").attr("transform",e=>`translate(${e.x0},${e.y0})`);k.append("rect").attr("width",e=>e.x1-e.x0).attr("height",25).attr("class","treemapSectionHeader").attr("fill","none").attr("fill-opacity",.6).attr("stroke-width",.6).attr("style",e=>0===e.depth?"display: none;":""),k.append("clipPath").attr("id",(e,a)=>`clip-section-${t}-${a}`).append("rect").attr("width",e=>Math.max(0,e.x1-e.x0-12)).attr("height",25),k.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=>$(e.data.name)).attr("fill-opacity",.6).attr("stroke",e=>C(e.data.name)).attr("stroke-width",2).attr("stroke-opacity",.4).attr("style",e=>{if(0===e.depth)return"display: none;";let t=(0,r.UG)({cssCompiledStyles:e.data.cssCompiledStyles});return t.nodeStyles+";"+t.borderStyles.join(";")}),k.append("text").attr("class","treemapSectionLabel").attr("x",6).attr("y",12.5).attr("dominant-baseline","middle").text(e=>0===e.depth?"":e.data.name).attr("font-weight","bold").attr("style",e=>0===e.depth?"display: none;":"dominant-baseline: middle; font-size: 12px; fill:"+w(e.data.name)+"; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;"+(0,r.UG)({cssCompiledStyles:e.data.cssCompiledStyles}).labelStyles.replace("color:","fill:")).each(function(e){if(0===e.depth)return;let t=(0,p.Ys)(this),a=e.data.name;t.text(a);let l=e.x1-e.x0,s=Math.max(15,!1!==h.showValues&&e.value?l-10-30-10-6:l-6-6),r=t.node();if(r.getComputedTextLength()>s){let e=a;for(;e.length>0;){if(0===(e=a.substring(0,e.length-1)).length){t.text("..."),r.getComputedTextLength()>s&&t.text("");break}if(t.text(e+"..."),r.getComputedTextLength()<=s)break}}}),!1!==h.showValues&&k.append("text").attr("class","treemapSectionValue").attr("x",e=>e.x1-e.x0-10).attr("y",12.5).attr("text-anchor","end").attr("dominant-baseline","middle").text(e=>e.value?n(e.value):"").attr("font-style","italic").attr("style",e=>0===e.depth?"display: none;":"text-anchor: end; dominant-baseline: middle; font-size: 10px; fill:"+w(e.data.name)+"; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;"+(0,r.UG)({cssCompiledStyles:e.data.cssCompiledStyles}).labelStyles.replace("color:","fill:"));let P=T.leaves(),z=W.selectAll(".treemapLeafGroup").data(P).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})`);z.append("rect").attr("width",e=>e.x1-e.x0).attr("height",e=>e.y1-e.y0).attr("class","treemapLeaf").attr("fill",e=>e.parent?$(e.parent.data.name):$(e.data.name)).attr("style",e=>(0,r.UG)({cssCompiledStyles:e.data.cssCompiledStyles}).nodeStyles).attr("fill-opacity",.3).attr("stroke",e=>e.parent?$(e.parent.data.name):$(e.data.name)).attr("stroke-width",3),z.append("clipPath").attr("id",(e,a)=>`clip-${t}-${a}`).append("rect").attr("width",e=>Math.max(0,e.x1-e.x0-4)).attr("height",e=>Math.max(0,e.y1-e.y0-4)),z.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:"+w(e.data.name)+";"+(0,r.UG)({cssCompiledStyles:e.data.cssCompiledStyles}).labelStyles.replace("color:","fill:")).attr("clip-path",(e,a)=>`url(#clip-${t}-${a})`).text(e=>e.data.name).each(function(e){let t=(0,p.Ys)(this),a=e.x1-e.x0,l=e.y1-e.y0,s=t.node(),r=a-8,i=l-8;if(r<10||i<10){t.style("display","none");return}let n=parseInt(t.style("font-size"),10);for(;s.getComputedTextLength()>r&&n>8;)n--,t.style("font-size",`${n}px`);let o=Math.max(6,Math.min(28,Math.round(.6*n))),c=n+2+o;for(;c>i&&n>8&&(!((o=Math.max(6,Math.min(28,Math.round(.6*--n))))<6)||8!==n);)t.style("font-size",`${n}px`),c=n+2+o;t.style("font-size",`${n}px`),(s.getComputedTextLength()>r||n<8||i<n)&&t.style("display","none")}),!1!==h.showValues&&z.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:"+w(e.data.name)+";"+(0,r.UG)({cssCompiledStyles:e.data.cssCompiledStyles}).labelStyles.replace("color:","fill:")).attr("clip-path",(e,a)=>`url(#clip-${t}-${a})`).text(e=>e.value?n(e.value):"").each(function(e){let t=(0,p.Ys)(this),a=this.parentNode;if(!a){t.style("display","none");return}let l=(0,p.Ys)(a).select(".treemapLabel");if(l.empty()||"none"===l.style("display")){t.style("display","none");return}let s=parseFloat(l.style("font-size")),r=Math.max(6,Math.min(28,Math.round(.6*s)));t.style("font-size",`${r}px`);let i=(e.y1-e.y0)/2+s/2+2;t.attr("y",i);let n=e.x1-e.x0,o=e.y1-e.y0;t.node().getComputedTextLength()>n-8||i+r>o-4||r<6?t.style("display","none"):t.style("display",null)});let F=h.diagramPadding??8;(0,s.j)(S,F,"flowchart",h?.useMaxWidth||!1)},"draw"),S=(0,c.eW)(function(e,t){return t.db.getClasses()},"getClasses"),x={sectionStrokeColor:"black",sectionStrokeWidth:"1",sectionFillColor:"#efefef",leafStrokeColor:"black",leafStrokeWidth:"1",leafFillColor:"#efefef",labelColor:"black",labelFontSize:"12px",valueFontSize:"10px",valueColor:"black",titleColor:"black",titleFontSize:"14px"},b={parser:f,get db(){return new h},renderer:{draw:g,getClasses:S},styles:(0,c.eW)(({treemap:e}={})=>{let t=(0,n.Rb)(x,e);return`
.treemapNode.section {
stroke: ${t.sectionStrokeColor};
stroke-width: ${t.sectionStrokeWidth};
fill: ${t.sectionFillColor};
}
.treemapNode.leaf {
stroke: ${t.leafStrokeColor};
stroke-width: ${t.leafStrokeWidth};
fill: ${t.leafFillColor};
}
.treemapLabel {
fill: ${t.labelColor};
font-size: ${t.labelFontSize};
}
.treemapValue {
fill: ${t.valueColor};
font-size: ${t.valueFontSize};
}
.treemapTitle {
fill: ${t.titleColor};
font-size: ${t.titleFontSize};
}
`},"getStyles")}}};