All Downloads are FREE. Search and download functionalities are using the official Maven repository.

package.dist.chunks.mermaid.esm.min.chunk-6XGRHI2A.mjs Maven / Gradle / Ivy

Go to download

Markdown-ish syntax for generating flowcharts, mindmaps, sequence diagrams, class diagrams, gantt charts, git graphs and more.

There is a newer version: 11.4.0
Show newest version
import{D as l,L,Q as y,b as a,n as _,p as m,x as o,z as E}from"./chunk-BKDDFIKN.mjs";import{d as v}from"./chunk-YPUTD6PB.mjs";import{O as g,e as C}from"./chunk-6BY5RJGC.mjs";import{a as u}from"./chunk-GTKDMUJJ.mjs";var j="\0",f="\0",D="",b=class{static{u(this,"Graph")}constructor(e={}){this._isDirected=o(e,"directed")?e.directed:!0,this._isMultigraph=o(e,"multigraph")?e.multigraph:!1,this._isCompound=o(e,"compound")?e.compound:!1,this._label=void 0,this._defaultNodeLabelFn=g(void 0),this._defaultEdgeLabelFn=g(void 0),this._nodes={},this._isCompound&&(this._parent={},this._children={},this._children[f]={}),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 C(e)||(e=g(e)),this._defaultNodeLabelFn=e,this}nodeCount(){return this._nodeCount}nodes(){return a(this._nodes)}sources(){var e=this;return m(this.nodes(),function(t){return v(e._in[t])})}sinks(){var e=this;return m(this.nodes(),function(t){return v(e._out[t])})}setNodes(e,t){var s=arguments,i=this;return _(e,function(r){s.length>1?i.setNode(r,t):i.setNode(r)}),this}setNode(e,t){return o(this._nodes,e)?(arguments.length>1&&(this._nodes[e]=t),this):(this._nodes[e]=arguments.length>1?t:this._defaultNodeLabelFn(e),this._isCompound&&(this._parent[e]=f,this._children[e]={},this._children[f][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 o(this._nodes,e)}removeNode(e){var t=this;if(o(this._nodes,e)){var s=u(function(i){t.removeEdge(t._edgeObjs[i])},"removeEdge");delete this._nodes[e],this._isCompound&&(this._removeFromParentsChildList(e),delete this._parent[e],_(this.children(e),function(i){t.setParent(i)}),delete this._children[e]),_(a(this._in[e]),s),delete this._in[e],delete this._preds[e],_(a(this._out[e]),s),delete this._out[e],delete this._sucs[e],--this._nodeCount}return this}setParent(e,t){if(!this._isCompound)throw new Error("Cannot set parent in a non-compound graph");if(l(t))t=f;else{t+="";for(var s=t;!l(s);s=this.parent(s))if(s===e)throw new 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(t!==f)return t}}children(e){if(l(e)&&(e=f),this._isCompound){var t=this._children[e];if(t)return a(t)}else{if(e===f)return this.nodes();if(this.hasNode(e))return[]}}predecessors(e){var t=this._preds[e];if(t)return a(t)}successors(e){var t=this._sucs[e];if(t)return a(t)}neighbors(e){var t=this.predecessors(e);if(t)return y(t,this.successors(e))}isLeaf(e){var t;return this.isDirected()?t=this.successors(e):t=this.neighbors(e),t.length===0}filterNodes(e){var t=new this.constructor({directed:this._isDirected,multigraph:this._isMultigraph,compound:this._isCompound});t.setGraph(this.graph());var s=this;_(this._nodes,function(n,h){e(h)&&t.setNode(h,n)}),_(this._edgeObjs,function(n){t.hasNode(n.v)&&t.hasNode(n.w)&&t.setEdge(n,s.edge(n))});var i={};function r(n){var h=s.parent(n);return h===void 0||t.hasNode(h)?(i[n]=h,h):h in i?i[h]:r(h)}return u(r,"findParent"),this._isCompound&&_(t.nodes(),function(n){t.setParent(n,r(n))}),t}setDefaultEdgeLabel(e){return C(e)||(e=g(e)),this._defaultEdgeLabelFn=e,this}edgeCount(){return this._edgeCount}edges(){return E(this._edgeObjs)}setPath(e,t){var s=this,i=arguments;return L(e,function(r,n){return i.length>1?s.setEdge(r,n,t):s.setEdge(r,n),n}),this}setEdge(){var e,t,s,i,r=!1,n=arguments[0];typeof n=="object"&&n!==null&&"v"in n?(e=n.v,t=n.w,s=n.name,arguments.length===2&&(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,l(s)||(s=""+s);var h=p(this._isDirected,e,t,s);if(o(this._edgeLabels,h))return r&&(this._edgeLabels[h]=i),this;if(!l(s)&&!this._isMultigraph)throw new 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 c=P(this._isDirected,e,t,s);return e=c.v,t=c.w,Object.freeze(c),this._edgeObjs[h]=c,O(this._preds[t],e),O(this._sucs[e],t),this._in[t][h]=c,this._out[e][h]=c,this._edgeCount++,this}edge(e,t,s){var i=arguments.length===1?N(this._isDirected,arguments[0]):p(this._isDirected,e,t,s);return this._edgeLabels[i]}hasEdge(e,t,s){var i=arguments.length===1?N(this._isDirected,arguments[0]):p(this._isDirected,e,t,s);return o(this._edgeLabels,i)}removeEdge(e,t,s){var i=arguments.length===1?N(this._isDirected,arguments[0]):p(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],F(this._preds[t],e),F(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=E(s);return t?m(i,function(r){return r.v===t}):i}}outEdges(e,t){var s=this._out[e];if(s){var i=E(s);return t?m(i,function(r){return r.w===t}):i}}nodeEdges(e,t){var s=this.inEdges(e,t);if(s)return s.concat(this.outEdges(e,t))}};b.prototype._nodeCount=0;b.prototype._edgeCount=0;function O(d,e){d[e]?d[e]++:d[e]=1}u(O,"incrementOrInitEntry");function F(d,e){--d[e]||delete d[e]}u(F,"decrementOrRemoveEntry");function p(d,e,t,s){var i=""+e,r=""+t;if(!d&&i>r){var n=i;i=r,r=n}return i+D+r+D+(l(s)?j:s)}u(p,"edgeArgsToId");function P(d,e,t,s){var i=""+e,r=""+t;if(!d&&i>r){var n=i;i=r,r=n}var h={v:i,w:r};return s&&(h.name=s),h}u(P,"edgeArgsToObj");function N(d,e){return p(d,e.v,e.w,e.name)}u(N,"edgeObjToId");export{b as a};




© 2015 - 2024 Weber Informatics LLC | Privacy Policy