import{bv as O,a as j,d as ue,bw as W,bx as L,bc as c,b9 as $,by as J,bz as he,bA as fe,bB as de,bC as Q,bD as ce,bE as Z,g as v,bF as w,bp as X,bi as ge,bG as le,b as be,bH as _e,bI as pe,bJ as ye,bm as me,bK as Te,bh as je,bL as P,bM as Ae,bb as z,bN as Ee,bo as Ce,bO as S,bP as k,bQ as Oe,bR as we,b7 as Le,bS as Se,bt as E,b2 as M}from"./index-9c042f98.js";import{aq as G}from"./index-0e3b96e2.js";function Fe(){}function ee(t,e){for(var n=-1,r=t==null?0:t.length;++n-1}var U=O?O.isConcatSpreadable:void 0;function xe(t){return j(t)||ue(t)||!!(U&&t&&t[U])}function te(t,e,n,r,s){var i=-1,a=t.length;for(n||(n=xe),s||(s=[]);++i0&&n(o)?e>1?te(o,e-1,n,r,s):W(s,o):r||(s[s.length]=o)}return s}function De(t,e,n,r){var s=-1,i=t==null?0:t.length;for(r&&i&&(n=t[++s]);++s=fn){var A=e?null:hn(t);if(A)return k(A);a=!1,s=we,h=new Oe}else h=e?[]:o;e:for(;++r1?s.setNode(i,n):s.setNode(i)}),this}setNode(e,n){return l(this._nodes,e)?(arguments.length>1&&(this._nodes[e]=n),this):(this._nodes[e]=arguments.length>1?n:this._defaultNodeLabelFn(e),this._isCompound&&(this._parent[e]=p,this._children[e]={},this._children[p][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 l(this._nodes,e)}removeNode(e){var n=this;if(l(this._nodes,e)){var r=function(s){n.removeEdge(n._edgeObjs[s])};delete this._nodes[e],this._isCompound&&(this._removeFromParentsChildList(e),delete this._parent[e],_(this.children(e),function(s){n.setParent(s)}),delete this._children[e]),_(c(this._in[e]),r),delete this._in[e],delete this._preds[e],_(c(this._out[e]),r),delete this._out[e],delete this._sucs[e],--this._nodeCount}return this}setParent(e,n){if(!this._isCompound)throw new Error("Cannot set parent in a non-compound graph");if(y(n))n=p;else{n+="";for(var r=n;!y(r);r=this.parent(r))if(r===e)throw new Error("Setting "+n+" as parent of "+e+" would create a cycle");this.setNode(n)}return this.setNode(e),this._removeFromParentsChildList(e),this._parent[e]=n,this._children[n][e]=!0,this}_removeFromParentsChildList(e){delete this._children[this._parent[e]][e]}parent(e){if(this._isCompound){var n=this._parent[e];if(n!==p)return n}}children(e){if(y(e)&&(e=p),this._isCompound){var n=this._children[e];if(n)return c(n)}else{if(e===p)return this.nodes();if(this.hasNode(e))return[]}}predecessors(e){var n=this._preds[e];if(n)return c(n)}successors(e){var n=this._sucs[e];if(n)return c(n)}neighbors(e){var n=this.predecessors(e);if(n)return gn(n,this.successors(e))}isLeaf(e){var n;return this.isDirected()?n=this.successors(e):n=this.neighbors(e),n.length===0}filterNodes(e){var n=new this.constructor({directed:this._isDirected,multigraph:this._isMultigraph,compound:this._isCompound});n.setGraph(this.graph());var r=this;_(this._nodes,function(a,o){e(o)&&n.setNode(o,a)}),_(this._edgeObjs,function(a){n.hasNode(a.v)&&n.hasNode(a.w)&&n.setEdge(a,r.edge(a))});var s={};function i(a){var o=r.parent(a);return o===void 0||n.hasNode(o)?(s[a]=o,o):o in s?s[o]:i(o)}return this._isCompound&&_(n.nodes(),function(a){n.setParent(a,i(a))}),n}setDefaultEdgeLabel(e){return M(e)||(e=E(e)),this._defaultEdgeLabelFn=e,this}edgeCount(){return this._edgeCount}edges(){return I(this._edgeObjs)}setPath(e,n){var r=this,s=arguments;return an(e,function(i,a){return s.length>1?r.setEdge(i,a,n):r.setEdge(i,a),a}),this}setEdge(){var e,n,r,s,i=!1,a=arguments[0];typeof a=="object"&&a!==null&&"v"in a?(e=a.v,n=a.w,r=a.name,arguments.length===2&&(s=arguments[1],i=!0)):(e=a,n=arguments[1],r=arguments[3],arguments.length>2&&(s=arguments[2],i=!0)),e=""+e,n=""+n,y(r)||(r=""+r);var o=T(this._isDirected,e,n,r);if(l(this._edgeLabels,o))return i&&(this._edgeLabels[o]=s),this;if(!y(r)&&!this._isMultigraph)throw new Error("Cannot set a named edge when isMultigraph = false");this.setNode(e),this.setNode(n),this._edgeLabels[o]=i?s:this._defaultEdgeLabelFn(e,n,r);var h=bn(this._isDirected,e,n,r);return e=h.v,n=h.w,Object.freeze(h),this._edgeObjs[o]=h,Y(this._preds[n],e),Y(this._sucs[e],n),this._in[n][o]=h,this._out[e][o]=h,this._edgeCount++,this}edge(e,n,r){var s=arguments.length===1?N(this._isDirected,arguments[0]):T(this._isDirected,e,n,r);return this._edgeLabels[s]}hasEdge(e,n,r){var s=arguments.length===1?N(this._isDirected,arguments[0]):T(this._isDirected,e,n,r);return l(this._edgeLabels,s)}removeEdge(e,n,r){var s=arguments.length===1?N(this._isDirected,arguments[0]):T(this._isDirected,e,n,r),i=this._edgeObjs[s];return i&&(e=i.v,n=i.w,delete this._edgeLabels[s],delete this._edgeObjs[s],q(this._preds[n],e),q(this._sucs[e],n),delete this._in[n][s],delete this._out[e][s],this._edgeCount--),this}inEdges(e,n){var r=this._in[e];if(r){var s=I(r);return n?C(s,function(i){return i.v===n}):s}}outEdges(e,n){var r=this._out[e];if(r){var s=I(r);return n?C(s,function(i){return i.w===n}):s}}nodeEdges(e,n){var r=this.inEdges(e,n);if(r)return r.concat(this.outEdges(e,n))}}ae.prototype._nodeCount=0;ae.prototype._edgeCount=0;function Y(t,e){t[e]?t[e]++:t[e]=1}function q(t,e){--t[e]||delete t[e]}function T(t,e,n,r){var s=""+e,i=""+n;if(!t&&s>i){var a=s;s=i,i=a}return s+H+i+H+(y(r)?ln:r)}function bn(t,e,n,r){var s=""+e,i=""+n;if(!t&&s>i){var a=s;s=i,i=a}var o={v:s,w:i};return r&&(o.name=r),o}function N(t,e){return T(t,e.v,e.w,e.name)}export{ae as G,F as a,te as b,Ie as c,zt as d,C as e,_ as f,l as h,y as i,an as r,I as v};