@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.
1 lines • 6.1 kB
JavaScript
"use strict";exports.id=9386,exports.ids=[9386],exports.modules={42318:(e,t,s)=>{s.d(t,{k:()=>v});var i=s(30253),r=s(46877),n=s(26013),h=s(28317),o=s(53639),d=s(31023),u=s(14408),a=s(74873),_=s(2338),l=s(78144),c=s(29848),p=(0,_.Z)(function(e){return(0,l.Z)((0,a.Z)(e,1,c.Z,!0))}),g=s(69407),f=s(63471);class v{constructor(e={}){this._isDirected=!Object.prototype.hasOwnProperty.call(e,"directed")||e.directed,this._isMultigraph=!!Object.prototype.hasOwnProperty.call(e,"multigraph")&&e.multigraph,this._isCompound=!!Object.prototype.hasOwnProperty.call(e,"compound")&&e.compound,this._label=void 0,this._defaultNodeLabelFn=i.Z(void 0),this._defaultEdgeLabelFn=i.Z(void 0),this._nodes={},this._isCompound&&(this._parent={},this._children={},this._children["\0"]={}),this._in={},this._preds={},this._out={},this._sucs={},this._edgeObjs={},this._edgeLabels={}}isDirected(){return this._isDirected}isMultigraph(){return this._isMultigraph}isCompound(){return this._isCompound}setGraph(e){return this._label=e,this}graph(){return this._label}setDefaultNodeLabel(e){return r.Z(e)||(e=i.Z(e)),this._defaultNodeLabelFn=e,this}nodeCount(){return this._nodeCount}nodes(){return n.Z(this._nodes)}sources(){var e=this;return h.Z(this.nodes(),function(t){return o.Z(e._in[t])})}sinks(){var e=this;return h.Z(this.nodes(),function(t){return o.Z(e._out[t])})}setNodes(e,t){var s=arguments,i=this;return d.Z(e,function(e){s.length>1?i.setNode(e,t):i.setNode(e)}),this}setNode(e,t){return Object.prototype.hasOwnProperty.call(this._nodes,e)?arguments.length>1&&(this._nodes[e]=t):(this._nodes[e]=arguments.length>1?t:this._defaultNodeLabelFn(e),this._isCompound&&(this._parent[e]="\0",this._children[e]={},this._children["\0"][e]=!0),this._in[e]={},this._preds[e]={},this._out[e]={},this._sucs[e]={},++this._nodeCount),this}node(e){return this._nodes[e]}hasNode(e){return Object.prototype.hasOwnProperty.call(this._nodes,e)}removeNode(e){if(Object.prototype.hasOwnProperty.call(this._nodes,e)){var t=e=>this.removeEdge(this._edgeObjs[e]);delete this._nodes[e],this._isCompound&&(this._removeFromParentsChildList(e),delete this._parent[e],d.Z(this.children(e),e=>{this.setParent(e)}),delete this._children[e]),d.Z(n.Z(this._in[e]),t),delete this._in[e],delete this._preds[e],d.Z(n.Z(this._out[e]),t),delete this._out[e],delete this._sucs[e],--this._nodeCount}return this}setParent(e,t){if(!this._isCompound)throw Error("Cannot set parent in a non-compound graph");if(u.Z(t))t="\0";else{t+="";for(var s=t;!u.Z(s);s=this.parent(s))if(s===e)throw Error("Setting "+t+" as parent of "+e+" would create a cycle");this.setNode(t)}return this.setNode(e),this._removeFromParentsChildList(e),this._parent[e]=t,this._children[t][e]=!0,this}_removeFromParentsChildList(e){delete this._children[this._parent[e]][e]}parent(e){if(this._isCompound){var t=this._parent[e];if("\0"!==t)return t}}children(e){if(u.Z(e)&&(e="\0"),this._isCompound){var t=this._children[e];if(t)return n.Z(t)}else if("\0"===e)return this.nodes();else if(this.hasNode(e))return[]}predecessors(e){var t=this._preds[e];if(t)return n.Z(t)}successors(e){var t=this._sucs[e];if(t)return n.Z(t)}neighbors(e){var t=this.predecessors(e);if(t)return p(t,this.successors(e))}isLeaf(e){return 0===(this.isDirected()?this.successors(e):this.neighbors(e)).length}filterNodes(e){var t=new this.constructor({directed:this._isDirected,multigraph:this._isMultigraph,compound:this._isCompound});t.setGraph(this.graph());var s=this;d.Z(this._nodes,function(s,i){e(i)&&t.setNode(i,s)}),d.Z(this._edgeObjs,function(e){t.hasNode(e.v)&&t.hasNode(e.w)&&t.setEdge(e,s.edge(e))});var i={};return this._isCompound&&d.Z(t.nodes(),function(e){t.setParent(e,function e(r){var n=s.parent(r);return void 0===n||t.hasNode(n)?(i[r]=n,n):n in i?i[n]:e(n)}(e))}),t}setDefaultEdgeLabel(e){return r.Z(e)||(e=i.Z(e)),this._defaultEdgeLabelFn=e,this}edgeCount(){return this._edgeCount}edges(){return g.Z(this._edgeObjs)}setPath(e,t){var s=this,i=arguments;return f.Z(e,function(e,r){return i.length>1?s.setEdge(e,r,t):s.setEdge(e,r),r}),this}setEdge(){var e,t,s,i,r=!1,n=arguments[0];"object"==typeof n&&null!==n&&"v"in n?(e=n.v,t=n.w,s=n.name,2==arguments.length&&(i=arguments[1],r=!0)):(e=n,t=arguments[1],s=arguments[3],arguments.length>2&&(i=arguments[2],r=!0)),e=""+e,t=""+t,u.Z(s)||(s=""+s);var h=m(this._isDirected,e,t,s);if(Object.prototype.hasOwnProperty.call(this._edgeLabels,h))return r&&(this._edgeLabels[h]=i),this;if(!u.Z(s)&&!this._isMultigraph)throw Error("Cannot set a named edge when isMultigraph = false");this.setNode(e),this.setNode(t),this._edgeLabels[h]=r?i:this._defaultEdgeLabelFn(e,t,s);var o=function(e,t,s,i){var r=""+t,n=""+s;if(!e&&r>n){var h=r;r=n,n=h}var o={v:r,w:n};return i&&(o.name=i),o}(this._isDirected,e,t,s);return e=o.v,t=o.w,Object.freeze(o),this._edgeObjs[h]=o,Z(this._preds[t],e),Z(this._sucs[e],t),this._in[t][h]=o,this._out[e][h]=o,this._edgeCount++,this}edge(e,t,s){var i=1==arguments.length?C(this._isDirected,arguments[0]):m(this._isDirected,e,t,s);return this._edgeLabels[i]}hasEdge(e,t,s){var i=1==arguments.length?C(this._isDirected,arguments[0]):m(this._isDirected,e,t,s);return Object.prototype.hasOwnProperty.call(this._edgeLabels,i)}removeEdge(e,t,s){var i=1==arguments.length?C(this._isDirected,arguments[0]):m(this._isDirected,e,t,s),r=this._edgeObjs[i];return r&&(e=r.v,t=r.w,delete this._edgeLabels[i],delete this._edgeObjs[i],b(this._preds[t],e),b(this._sucs[e],t),delete this._in[t][i],delete this._out[e][i],this._edgeCount--),this}inEdges(e,t){var s=this._in[e];if(s){var i=g.Z(s);return t?h.Z(i,function(e){return e.v===t}):i}}outEdges(e,t){var s=this._out[e];if(s){var i=g.Z(s);return t?h.Z(i,function(e){return e.w===t}):i}}nodeEdges(e,t){var s=this.inEdges(e,t);if(s)return s.concat(this.outEdges(e,t))}}function Z(e,t){e[t]?e[t]++:e[t]=1}function b(e,t){--e[t]||delete e[t]}function m(e,t,s,i){var r=""+t,n=""+s;if(!e&&r>n){var h=r;r=n,n=h}return r+"\x01"+n+"\x01"+(u.Z(i)?"\0":i)}function C(e,t){return m(e,t.v,t.w,t.name)}v.prototype._nodeCount=0,v.prototype._edgeCount=0},19386:(e,t,s)=>{s.d(t,{k:()=>i.k});var i=s(42318)}};