@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.
64 lines (53 loc) • 17.4 kB
JavaScript
"use strict";exports.id=3421,exports.ids=[3421],exports.modules={63421:(t,e,i)=>{i.d(e,{diagram:()=>$});var s=i(51892),n=i(63951),a=i(51635),r=i(17605),l=i(28646),h=function(){var t=(0,r.eW)(function(t,e,i,s){for(i=i||{},s=t.length;s--;i[t[s]]=e);return i},"o"),e=[1,4],i=[1,14],s=[1,12],n=[1,13],a=[6,7,8],l=[1,20],h=[1,18],o=[1,19],c=[6,7,11],u=[1,6,13,14],y=[1,23],d=[1,24],p=[1,6,7,11,13,14],g={trace:(0,r.eW)(function(){},"trace"),yy:{},symbols_:{error:2,start:3,ishikawa:4,spaceLines:5,SPACELINE:6,NL:7,ISHIKAWA:8,document:9,stop:10,EOF:11,statement:12,SPACELIST:13,TEXT:14,$accept:0,$end:1},terminals_:{2:"error",6:"SPACELINE",7:"NL",8:"ISHIKAWA",11:"EOF",13:"SPACELIST",14:"TEXT"},productions_:[0,[3,1],[3,2],[5,1],[5,2],[5,2],[4,2],[4,3],[10,1],[10,1],[10,1],[10,2],[10,2],[9,3],[9,2],[12,2],[12,1],[12,1],[12,1]],performAction:(0,r.eW)(function(t,e,i,s,n,a,r){var l=a.length-1;switch(n){case 6:case 7:return s;case 15:s.addNode(a[l-1].length,a[l].trim());break;case 16:s.addNode(0,a[l].trim())}},"anonymous"),table:[{3:1,4:2,5:3,6:[1,5],8:e},{1:[3]},{1:[2,1]},{4:6,6:[1,7],7:[1,8],8:e},{6:i,7:[1,10],9:9,12:11,13:s,14:n},t(a,[2,3]),{1:[2,2]},t(a,[2,4]),t(a,[2,5]),{1:[2,6],6:i,12:15,13:s,14:n},{6:i,9:16,12:11,13:s,14:n},{6:l,7:h,10:17,11:o},t(c,[2,18],{14:[1,21]}),t(c,[2,16]),t(c,[2,17]),{6:l,7:h,10:22,11:o},{1:[2,7],6:i,12:15,13:s,14:n},t(u,[2,14],{7:y,11:d}),t(p,[2,8]),t(p,[2,9]),t(p,[2,10]),t(c,[2,15]),t(u,[2,13],{7:y,11:d}),t(p,[2,11]),t(p,[2,12])],defaultActions:{2:[2,1],6:[2,2]},parseError:(0,r.eW)(function(t,e){if(e.recoverable)this.trace(t);else{var i=Error(t);throw i.hash=e,i}},"parseError"),parse:(0,r.eW)(function(t){var e=this,i=[0],s=[],n=[null],a=[],l=this.table,h="",o=0,c=0,u=0,y=a.slice.call(arguments,1),d=Object.create(this.lexer),p={yy:{}};for(var g in this.yy)Object.prototype.hasOwnProperty.call(this.yy,g)&&(p.yy[g]=this.yy[g]);d.setInput(t,p.yy),p.yy.lexer=d,p.yy.parser=this,void 0===d.yylloc&&(d.yylloc={});var f=d.yylloc;a.push(f);var k=d.options&&d.options.ranges;function m(){var t;return"number"!=typeof(t=s.pop()||d.lex()||1)&&(t instanceof Array&&(t=(s=t).pop()),t=e.symbols_[t]||t),t}"function"==typeof p.yy.parseError?this.parseError=p.yy.parseError:this.parseError=Object.getPrototypeOf(this).parseError,(0,r.eW)(function(t){i.length=i.length-2*t,n.length=n.length-t,a.length=a.length-t},"popStack"),(0,r.eW)(m,"lex");for(var x,w,_,b,W,v,S,$,I,E={};;){if(_=i[i.length-1],this.defaultActions[_]?b=this.defaultActions[_]:(null==x&&(x=m()),b=l[_]&&l[_][x]),void 0===b||!b.length||!b[0]){var A="";for(v in I=[],l[_])this.terminals_[v]&&v>2&&I.push("'"+this.terminals_[v]+"'");A=d.showPosition?"Parse error on line "+(o+1)+":\n"+d.showPosition()+"\nExpecting "+I.join(", ")+", got '"+(this.terminals_[x]||x)+"'":"Parse error on line "+(o+1)+": Unexpected "+(1==x?"end of input":"'"+(this.terminals_[x]||x)+"'"),this.parseError(A,{text:d.match,token:this.terminals_[x]||x,line:d.yylineno,loc:f,expected:I})}if(b[0]instanceof Array&&b.length>1)throw Error("Parse Error: multiple actions possible at state: "+_+", token: "+x);switch(b[0]){case 1:i.push(x),n.push(d.yytext),a.push(d.yylloc),i.push(b[1]),x=null,w?(x=w,w=null):(c=d.yyleng,h=d.yytext,o=d.yylineno,f=d.yylloc,u>0&&u--);break;case 2:if(S=this.productions_[b[1]][1],E.$=n[n.length-S],E._$={first_line:a[a.length-(S||1)].first_line,last_line:a[a.length-1].last_line,first_column:a[a.length-(S||1)].first_column,last_column:a[a.length-1].last_column},k&&(E._$.range=[a[a.length-(S||1)].range[0],a[a.length-1].range[1]]),void 0!==(W=this.performAction.apply(E,[h,c,o,p.yy,b[1],n,a].concat(y))))return W;S&&(i=i.slice(0,-1*S*2),n=n.slice(0,-1*S),a=a.slice(0,-1*S)),i.push(this.productions_[b[1]][0]),n.push(E.$),a.push(E._$),$=l[i[i.length-2]][i[i.length-1]],i.push($);break;case 3:return!0}}return!0},"parse")},f={EOF:1,parseError:(0,r.eW)(function(t,e){if(this.yy.parser)this.yy.parser.parseError(t,e);else throw Error(t)},"parseError"),setInput:(0,r.eW)(function(t,e){return this.yy=e||this.yy||{},this._input=t,this._more=this._backtrack=this.done=!1,this.yylineno=this.yyleng=0,this.yytext=this.matched=this.match="",this.conditionStack=["INITIAL"],this.yylloc={first_line:1,first_column:0,last_line:1,last_column:0},this.options.ranges&&(this.yylloc.range=[0,0]),this.offset=0,this},"setInput"),input:(0,r.eW)(function(){var t=this._input[0];return this.yytext+=t,this.yyleng++,this.offset++,this.match+=t,this.matched+=t,t.match(/(?:\r\n?|\n).*/g)?(this.yylineno++,this.yylloc.last_line++):this.yylloc.last_column++,this.options.ranges&&this.yylloc.range[1]++,this._input=this._input.slice(1),t},"input"),unput:(0,r.eW)(function(t){var e=t.length,i=t.split(/(?:\r\n?|\n)/g);this._input=t+this._input,this.yytext=this.yytext.substr(0,this.yytext.length-e),this.offset-=e;var s=this.match.split(/(?:\r\n?|\n)/g);this.match=this.match.substr(0,this.match.length-1),this.matched=this.matched.substr(0,this.matched.length-1),i.length-1&&(this.yylineno-=i.length-1);var n=this.yylloc.range;return this.yylloc={first_line:this.yylloc.first_line,last_line:this.yylineno+1,first_column:this.yylloc.first_column,last_column:i?(i.length===s.length?this.yylloc.first_column:0)+s[s.length-i.length].length-i[0].length:this.yylloc.first_column-e},this.options.ranges&&(this.yylloc.range=[n[0],n[0]+this.yyleng-e]),this.yyleng=this.yytext.length,this},"unput"),more:(0,r.eW)(function(){return this._more=!0,this},"more"),reject:(0,r.eW)(function(){return this.options.backtrack_lexer?(this._backtrack=!0,this):this.parseError("Lexical error on line "+(this.yylineno+1)+". You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).\n"+this.showPosition(),{text:"",token:null,line:this.yylineno})},"reject"),less:(0,r.eW)(function(t){this.unput(this.match.slice(t))},"less"),pastInput:(0,r.eW)(function(){var t=this.matched.substr(0,this.matched.length-this.match.length);return(t.length>20?"...":"")+t.substr(-20).replace(/\n/g,"")},"pastInput"),upcomingInput:(0,r.eW)(function(){var t=this.match;return t.length<20&&(t+=this._input.substr(0,20-t.length)),(t.substr(0,20)+(t.length>20?"...":"")).replace(/\n/g,"")},"upcomingInput"),showPosition:(0,r.eW)(function(){var t=this.pastInput(),e=Array(t.length+1).join("-");return t+this.upcomingInput()+"\n"+e+"^"},"showPosition"),test_match:(0,r.eW)(function(t,e){var i,s,n;if(this.options.backtrack_lexer&&(n={yylineno:this.yylineno,yylloc:{first_line:this.yylloc.first_line,last_line:this.last_line,first_column:this.yylloc.first_column,last_column:this.yylloc.last_column},yytext:this.yytext,match:this.match,matches:this.matches,matched:this.matched,yyleng:this.yyleng,offset:this.offset,_more:this._more,_input:this._input,yy:this.yy,conditionStack:this.conditionStack.slice(0),done:this.done},this.options.ranges&&(n.yylloc.range=this.yylloc.range.slice(0))),(s=t[0].match(/(?:\r\n?|\n).*/g))&&(this.yylineno+=s.length),this.yylloc={first_line:this.yylloc.last_line,last_line:this.yylineno+1,first_column:this.yylloc.last_column,last_column:s?s[s.length-1].length-s[s.length-1].match(/\r?\n?/)[0].length:this.yylloc.last_column+t[0].length},this.yytext+=t[0],this.match+=t[0],this.matches=t,this.yyleng=this.yytext.length,this.options.ranges&&(this.yylloc.range=[this.offset,this.offset+=this.yyleng]),this._more=!1,this._backtrack=!1,this._input=this._input.slice(t[0].length),this.matched+=t[0],i=this.performAction.call(this,this.yy,this,e,this.conditionStack[this.conditionStack.length-1]),this.done&&this._input&&(this.done=!1),i)return i;if(this._backtrack)for(var a in n)this[a]=n[a];return!1},"test_match"),next:(0,r.eW)(function(){if(this.done)return this.EOF;this._input||(this.done=!0),this._more||(this.yytext="",this.match="");for(var t,e,i,s,n=this._currentRules(),a=0;a<n.length;a++)if((i=this._input.match(this.rules[n[a]]))&&(!e||i[0].length>e[0].length)){if(e=i,s=a,this.options.backtrack_lexer){if(!1!==(t=this.test_match(i,n[a])))return t;if(!this._backtrack)return!1;e=!1;continue}if(!this.options.flex)break}return e?!1!==(t=this.test_match(e,n[s]))&&t:""===this._input?this.EOF:this.parseError("Lexical error on line "+(this.yylineno+1)+". Unrecognized text.\n"+this.showPosition(),{text:"",token:null,line:this.yylineno})},"next"),lex:(0,r.eW)(function(){return this.next()||this.lex()},"lex"),begin:(0,r.eW)(function(t){this.conditionStack.push(t)},"begin"),popState:(0,r.eW)(function(){return this.conditionStack.length-1>0?this.conditionStack.pop():this.conditionStack[0]},"popState"),_currentRules:(0,r.eW)(function(){return this.conditionStack.length&&this.conditionStack[this.conditionStack.length-1]?this.conditions[this.conditionStack[this.conditionStack.length-1]].rules:this.conditions.INITIAL.rules},"_currentRules"),topState:(0,r.eW)(function(t){return(t=this.conditionStack.length-1-Math.abs(t||0))>=0?this.conditionStack[t]:"INITIAL"},"topState"),pushState:(0,r.eW)(function(t){this.begin(t)},"pushState"),stateStackSize:(0,r.eW)(function(){return this.conditionStack.length},"stateStackSize"),options:{"case-insensitive":!0},performAction:(0,r.eW)(function(t,e,i,s){switch(i){case 0:case 3:return 6;case 1:case 2:return 8;case 4:return 7;case 5:return 13;case 6:return 14;case 7:return 11}},"anonymous"),rules:[/^(?:\s*%%.*)/i,/^(?:ishikawa-beta\b)/i,/^(?:ishikawa\b)/i,/^(?:[\s]+[\n])/i,/^(?:[\n]+)/i,/^(?:[\s]+)/i,/^(?:[^\n]+)/i,/^(?:$)/i],conditions:{INITIAL:{rules:[0,1,2,3,4,5,6,7],inclusive:!0}}};function k(){this.yy={}}return g.lexer=f,(0,r.eW)(k,"Parser"),k.prototype=g,g.Parser=k,new k}();h.parser=h;var o=class{constructor(){this.stack=[],this.clear=this.clear.bind(this),this.addNode=this.addNode.bind(this),this.getRoot=this.getRoot.bind(this)}static{(0,r.eW)(this,"IshikawaDB")}clear(){this.root=void 0,this.stack=[],this.baseLevel=void 0,(0,a.ZH)()}getRoot(){return this.root}addNode(t,e){let i=a.SY.sanitizeText(e,(0,a.nV)());if(!this.root){this.baseLevel=t,this.root={text:i,children:[]},this.stack=[{level:0,node:this.root}],(0,a.g2)(i);return}let s=t-(this.baseLevel??0);for(s<=0&&(s=1);this.stack.length>1&&this.stack[this.stack.length-1].level>=s;)this.stack.pop();let n=this.stack[this.stack.length-1].node,r={text:i,children:[]};n.children.push(r),this.stack.push({level:s,node:r})}getAccTitle(){return(0,a.eu)()}setAccTitle(t){(0,a.GN)(t)}getAccDescription(){return(0,a.Mx)()}setAccDescription(t){(0,a.U$)(t)}getDiagramTitle(){return(0,a.Kr)()}setDiagramTitle(t){(0,a.g2)(t)}},c=82*Math.PI/180,u=Math.cos(c),y=Math.sin(c),d=(0,r.eW)((t,e,i)=>{let s=t.node().getBBox(),n=s.width+2*e,r=s.height+2*e;(0,a.v2)(t,r,n,i),t.attr("viewBox",`${s.x-e} ${s.y-e} ${n} ${r}`)},"applyPaddedViewBox"),p=(0,r.eW)((t,e,i,r)=>{let h=r.db.getRoot();if(!h)return;let o=(0,a.nV)(),{look:c,handDrawnSeed:u,themeVariables:y}=o,p=(0,n.VG)(o.fontSize)[0]??14,k="handDrawn"===c,m=h.children??[],x=o.ishikawa?.diagramPadding??20,_=o.ishikawa?.useMaxWidth??!1,b=(0,s.P)(e),W=b.append("g").attr("class","ishikawa"),v=k?l.Z.svg(b.node()):void 0,$=v?{roughSvg:v,seed:u??0,lineColor:y?.lineColor??"#333",fillColor:y?.mainBkg??"#fff"}:void 0,I=`ishikawa-arrow-${e}`;k||W.append("defs").append("marker").attr("id",I).attr("viewBox","0 0 10 10").attr("refX",0).attr("refY",5).attr("markerWidth",6).attr("markerHeight",6).attr("orient","auto").append("path").attr("d","M 10 0 L 0 5 L 10 10 Z").attr("class","ishikawa-arrow");let E=0,A=250,C=k?void 0:S(W,E,A,E,A,"ishikawa-spine");if(f(W,E,A,h.text,p,$),!m.length){k&&S(W,E,A,E,A,"ishikawa-spine",$),d(b,x,_);return}E-=20;let M=m.filter((t,e)=>e%2==0),L=m.filter((t,e)=>e%2==1),P=g(M),T=g(L),B=P.total+T.total,N=250,D=250;B>0&&(N=Math.max(75,P.total/B*500),D=Math.max(75,T.total/B*500));let O=2*p;N=Math.max(N,P.max*O),D=Math.max(D,T.max*O),A=Math.max(N,250),C&&C.attr("y1",A).attr("y2",A),W.select(".ishikawa-head-group").attr("transform",`translate(0,${A})`);let j=Math.ceil(m.length/2);for(let t=0;t<j;t++){let e=W.append("g").attr("class","ishikawa-pair");for(let[i,s,n]of[[m[2*t],-1,N],[m[2*t+1],1,D]])i&&w(e,i,E,A,s,n,p,$);E=e.selectAll("text").nodes().reduce((t,e)=>Math.min(t,e.getBBox().x),1/0)}if(k)S(W,E,A,0,A,"ishikawa-spine",$);else{C.attr("x1",E);let t=`url(#${I})`;W.selectAll("line.ishikawa-branch, line.ishikawa-sub-branch").attr("marker-start",t)}d(b,x,_)},"draw"),g=(0,r.eW)(t=>{let e=(0,r.eW)(t=>t.children.reduce((t,i)=>t+1+e(i),0),"countDescendants");return t.reduce((t,i)=>{let s=e(i);return t.total+=s,t.max=Math.max(t.max,s),t},{total:0,max:0})},"sideStats"),f=(0,r.eW)((t,e,i,s,n,a)=>{let r=t.append("g").attr("class","ishikawa-head-group").attr("transform",`translate(${e},${i})`),l=W(r,b(s,Math.max(6,Math.floor(110/(.6*n)))),0,0,"ishikawa-head-label","start",n),h=l.node().getBBox(),o=Math.max(60,h.width+6),c=Math.max(40,2*h.height+40),u=`M 0 ${-c/2} L 0 ${c/2} Q ${2.4*o} 0 0 ${-c/2} Z`;if(a){let t=a.roughSvg.path(u,{roughness:1.5,seed:a.seed,fill:a.fillColor,fillStyle:"hachure",fillWeight:2.5,hachureGap:5,stroke:a.lineColor,strokeWidth:2});r.insert(()=>t,":first-child").attr("class","ishikawa-head")}else r.insert("path",":first-child").attr("class","ishikawa-head").attr("d",u);l.attr("transform",`translate(${(o-h.width)/2-h.x+3},${-h.y-h.height/2})`)},"drawHead"),k=(0,r.eW)((t,e)=>{let i=[],s=[],n=(0,r.eW)((t,a,r)=>{for(let l of -1===e?[...t].reverse():t){let t=i.length,e=l.children??[];i.push({depth:r,text:b(l.text,15),parentIndex:a,childCount:e.length}),r%2==0?(s.push(t),e.length&&n(e,t,r+1)):(e.length&&n(e,t,r+1),s.push(t))}},"walk");return n(t,-1,2),{entries:i,yOrder:s}},"flattenTree"),m=(0,r.eW)((t,e,i,s,n,a,r)=>{let l=t.append("g").attr("class","ishikawa-label-group"),h=W(l,e,i,s+11*n,"ishikawa-label cause","middle",a).node().getBBox();if(r){let t=r.roughSvg.rectangle(h.x-20,h.y-2,h.width+40,h.height+4,{roughness:1.5,seed:r.seed,fill:r.fillColor,fillStyle:"hachure",fillWeight:2.5,hachureGap:5,stroke:r.lineColor,strokeWidth:2});l.insert(()=>t,":first-child").attr("class","ishikawa-label-box")}else l.insert("rect",":first-child").attr("class","ishikawa-label-box").attr("x",h.x-20).attr("y",h.y-2).attr("width",h.width+40).attr("height",h.height+4)},"drawCauseLabel"),x=(0,r.eW)((t,e,i,s,n,a)=>{let r=Math.sqrt(s*s+n*n);if(0===r)return;let l=s/r,h=n/r,o=-(6*h),c=6*l,u=`M ${e} ${i} L ${e-12*l+o} ${i-12*h+c} L ${e-12*l-o} ${i-12*h-c} Z`,y=a.roughSvg.path(u,{roughness:1,seed:a.seed,fill:a.lineColor,fillStyle:"solid",stroke:a.lineColor,strokeWidth:1});t.append(()=>y)},"drawArrowMarker"),w=(0,r.eW)((t,e,i,s,n,a,r,l)=>{let h=e.children??[],o=a*(h.length?1:.2),c=y*o*n,d=i+-u*o,p=s+c;if(S(t,i,s,d,p,"ishikawa-branch",l),l&&x(t,i,s,i-d,s-p,l),m(t,e.text,d,p,n,r,l),!h.length)return;let{entries:g,yOrder:f}=k(h,n),w=g.length,_=Array(w);for(let[t,e]of f.entries())_[e]=s+(t+1)/(w+1)*c;let b=new Map;b.set(-1,{x0:i,y0:s,x1:d,y1:p,childCount:h.length,childrenDrawn:0});let $=-u,I=y*n,E=n<0?"ishikawa-label up":"ishikawa-label down";for(let[e,i]of g.entries()){let s=_[e],n=b.get(i.parentIndex),a=t.append("g").attr("class","ishikawa-sub-group"),h=0,o=0,c=0;if(i.depth%2==0){let t=n.y1-n.y0;h=v(n.x0,n.x1,t?(s-n.y0)/t:.5),o=s,c=h-(i.childCount>0?60+5*i.childCount:30),S(a,h,s,c,s,"ishikawa-sub-branch",l),l&&x(a,h,s,1,0,l),W(a,i.text,c,s,"ishikawa-label align","end",r)}else{let t=n.childrenDrawn++;c=(h=v(n.x0,n.x1,(n.childCount-t)/(n.childCount+1)))+(s-(o=n.y0))/I*$,S(a,h,o,c,s,"ishikawa-sub-branch",l),l&&x(a,h,o,h-c,o-s,l),W(a,i.text,c,s,E,"end",r)}i.childCount>0&&b.set(e,{x0:h,y0:o,x1:c,y1:s,childCount:i.childCount,childrenDrawn:0})}},"drawBranch"),_=(0,r.eW)(t=>t.split(/<br\s*\/?>|\n/),"splitLines"),b=(0,r.eW)((t,e)=>{if(t.length<=e)return t;let i=[];for(let s of t.split(/\s+/)){let t=i.length-1;t>=0&&i[t].length+1+s.length<=e?i[t]+=" "+s:i.push(s)}return i.join("\n")},"wrapText"),W=(0,r.eW)((t,e,i,s,n,a,r)=>{let l=_(e),h=1.05*r,o=t.append("text").attr("class",n).attr("text-anchor",a).attr("x",i).attr("y",s-(l.length-1)*h/2);for(let[t,e]of l.entries())o.append("tspan").attr("x",i).attr("dy",0===t?0:h).text(e);return o},"drawMultilineText"),v=(0,r.eW)((t,e,i)=>t+(e-t)*i,"lerp"),S=(0,r.eW)((t,e,i,s,n,a,r)=>{if(r){let l=r.roughSvg.line(e,i,s,n,{roughness:1.5,seed:r.seed,stroke:r.lineColor,strokeWidth:2});t.append(()=>l).attr("class",a);return}return t.append("line").attr("class",a).attr("x1",e).attr("y1",i).attr("x2",s).attr("y2",n)},"drawLine"),$={parser:h,get db(){return new o},renderer:{draw:p},styles:(0,r.eW)(t=>`
.ishikawa .ishikawa-spine,
.ishikawa .ishikawa-branch,
.ishikawa .ishikawa-sub-branch {
stroke: ${t.lineColor};
stroke-width: 2;
fill: none;
}
.ishikawa .ishikawa-sub-branch {
stroke-width: 1;
}
.ishikawa .ishikawa-arrow {
fill: ${t.lineColor};
}
.ishikawa .ishikawa-head {
fill: ${t.mainBkg};
stroke: ${t.lineColor};
stroke-width: 2;
}
.ishikawa .ishikawa-label-box {
fill: ${t.mainBkg};
stroke: ${t.lineColor};
stroke-width: 2;
}
.ishikawa text {
font-family: ${t.fontFamily};
font-size: ${t.fontSize};
fill: ${t.textColor};
}
.ishikawa .ishikawa-head-label {
font-weight: 600;
text-anchor: middle;
dominant-baseline: middle;
font-size: 14px;
}
.ishikawa .ishikawa-label {
text-anchor: end;
}
.ishikawa .ishikawa-label.cause {
text-anchor: middle;
dominant-baseline: middle;
}
.ishikawa .ishikawa-label.align {
text-anchor: end;
dominant-baseline: middle;
}
.ishikawa .ishikawa-label.up {
dominant-baseline: baseline;
}
.ishikawa .ishikawa-label.down {
dominant-baseline: hanging;
}
`,"getStyles")}}};