import { d as dispatch, s as select, e as event, a as dragDisable, n as nopropagation, b as noevent, y as yesdrag, c as customEvent, m as mouse, f as touch, g as map, h as timer, z as zoom } from "./zoom-d67a025a.es.js";
import Vue, { defineComponent } from "vue";
import { I as Icon, c as createPopper, n as normalizeComponent } from "./index-d387159c.es.js";
import "moment";
import "v-tooltip";
import "@cldcvr/flow-aws-icon";
import "@cldcvr/flow-gcp-icon";
import "@cldcvr/flow-product-icon";
import "@cldcvr/flow-system-icon";
import "lodash-es";
import "vee-validate";
function constant$1(x2) {
  return function() {
    return x2;
  };
}
function DragEvent(target, type, subject, id, active, x2, y2, dx, dy, dispatch2) {
  this.target = target;
  this.type = type;
  this.subject = subject;
  this.identifier = id;
  this.active = active;
  this.x = x2;
  this.y = y2;
  this.dx = dx;
  this.dy = dy;
  this._ = dispatch2;
}
DragEvent.prototype.on = function() {
  var value = this._.on.apply(this._, arguments);
  return value === this._ ? this : value;
};
function defaultFilter() {
  return !event.ctrlKey && !event.button;
}
function defaultContainer() {
  return this.parentNode;
}
function defaultSubject(d) {
  return d == null ? { x: event.x, y: event.y } : d;
}
function defaultTouchable() {
  return navigator.maxTouchPoints || "ontouchstart" in this;
}
function drag() {
  var filter = defaultFilter, container = defaultContainer, subject = defaultSubject, touchable = defaultTouchable, gestures = {}, listeners = dispatch("start", "drag", "end"), active = 0, mousedownx, mousedowny, mousemoving, touchending, clickDistance2 = 0;
  function drag2(selection) {
    selection.on("mousedown.drag", mousedowned).filter(touchable).on("touchstart.drag", touchstarted).on("touchmove.drag", touchmoved).on("touchend.drag touchcancel.drag", touchended).style("touch-action", "none").style("-webkit-tap-highlight-color", "rgba(0,0,0,0)");
  }
  function mousedowned() {
    if (touchending || !filter.apply(this, arguments))
      return;
    var gesture = beforestart("mouse", container.apply(this, arguments), mouse, this, arguments);
    if (!gesture)
      return;
    select(event.view).on("mousemove.drag", mousemoved, true).on("mouseup.drag", mouseupped, true);
    dragDisable(event.view);
    nopropagation();
    mousemoving = false;
    mousedownx = event.clientX;
    mousedowny = event.clientY;
    gesture("start");
  }
  function mousemoved() {
    noevent();
    if (!mousemoving) {
      var dx = event.clientX - mousedownx, dy = event.clientY - mousedowny;
      mousemoving = dx * dx + dy * dy > clickDistance2;
    }
    gestures.mouse("drag");
  }
  function mouseupped() {
    select(event.view).on("mousemove.drag mouseup.drag", null);
    yesdrag(event.view, mousemoving);
    noevent();
    gestures.mouse("end");
  }
  function touchstarted() {
    if (!filter.apply(this, arguments))
      return;
    var touches = event.changedTouches, c = container.apply(this, arguments), n = touches.length, i, gesture;
    for (i = 0; i < n; ++i) {
      if (gesture = beforestart(touches[i].identifier, c, touch, this, arguments)) {
        nopropagation();
        gesture("start");
      }
    }
  }
  function touchmoved() {
    var touches = event.changedTouches, n = touches.length, i, gesture;
    for (i = 0; i < n; ++i) {
      if (gesture = gestures[touches[i].identifier]) {
        noevent();
        gesture("drag");
      }
    }
  }
  function touchended() {
    var touches = event.changedTouches, n = touches.length, i, gesture;
    if (touchending)
      clearTimeout(touchending);
    touchending = setTimeout(function() {
      touchending = null;
    }, 500);
    for (i = 0; i < n; ++i) {
      if (gesture = gestures[touches[i].identifier]) {
        nopropagation();
        gesture("end");
      }
    }
  }
  function beforestart(id, container2, point, that, args) {
    var p = point(container2, id), s, dx, dy, sublisteners = listeners.copy();
    if (!customEvent(new DragEvent(drag2, "beforestart", s, id, active, p[0], p[1], 0, 0, sublisteners), function() {
      if ((event.subject = s = subject.apply(that, args)) == null)
        return false;
      dx = s.x - p[0] || 0;
      dy = s.y - p[1] || 0;
      return true;
    }))
      return;
    return function gesture(type) {
      var p0 = p, n;
      switch (type) {
        case "start":
          gestures[id] = gesture, n = active++;
          break;
        case "end":
          delete gestures[id], --active;
        case "drag":
          p = point(container2, id), n = active;
          break;
      }
      customEvent(new DragEvent(drag2, type, s, id, n, p[0] + dx, p[1] + dy, p[0] - p0[0], p[1] - p0[1], sublisteners), sublisteners.apply, sublisteners, [type, that, args]);
    };
  }
  drag2.filter = function(_) {
    return arguments.length ? (filter = typeof _ === "function" ? _ : constant$1(!!_), drag2) : filter;
  };
  drag2.container = function(_) {
    return arguments.length ? (container = typeof _ === "function" ? _ : constant$1(_), drag2) : container;
  };
  drag2.subject = function(_) {
    return arguments.length ? (subject = typeof _ === "function" ? _ : constant$1(_), drag2) : subject;
  };
  drag2.touchable = function(_) {
    return arguments.length ? (touchable = typeof _ === "function" ? _ : constant$1(!!_), drag2) : touchable;
  };
  drag2.on = function() {
    var value = listeners.on.apply(listeners, arguments);
    return value === listeners ? drag2 : value;
  };
  drag2.clickDistance = function(_) {
    return arguments.length ? (clickDistance2 = (_ = +_) * _, drag2) : Math.sqrt(clickDistance2);
  };
  return drag2;
}
function constant(x2) {
  return function() {
    return x2;
  };
}
function jiggle() {
  return (Math.random() - 0.5) * 1e-6;
}
function tree_add(d) {
  var x2 = +this._x.call(null, d), y2 = +this._y.call(null, d);
  return add(this.cover(x2, y2), x2, y2, d);
}
function add(tree, x2, y2, d) {
  if (isNaN(x2) || isNaN(y2))
    return tree;
  var parent, node = tree._root, leaf = { data: d }, x0 = tree._x0, y0 = tree._y0, x1 = tree._x1, y1 = tree._y1, xm, ym, xp, yp, right, bottom, i, j;
  if (!node)
    return tree._root = leaf, tree;
  while (node.length) {
    if (right = x2 >= (xm = (x0 + x1) / 2))
      x0 = xm;
    else
      x1 = xm;
    if (bottom = y2 >= (ym = (y0 + y1) / 2))
      y0 = ym;
    else
      y1 = ym;
    if (parent = node, !(node = node[i = bottom << 1 | right]))
      return parent[i] = leaf, tree;
  }
  xp = +tree._x.call(null, node.data);
  yp = +tree._y.call(null, node.data);
  if (x2 === xp && y2 === yp)
    return leaf.next = node, parent ? parent[i] = leaf : tree._root = leaf, tree;
  do {
    parent = parent ? parent[i] = new Array(4) : tree._root = new Array(4);
    if (right = x2 >= (xm = (x0 + x1) / 2))
      x0 = xm;
    else
      x1 = xm;
    if (bottom = y2 >= (ym = (y0 + y1) / 2))
      y0 = ym;
    else
      y1 = ym;
  } while ((i = bottom << 1 | right) === (j = (yp >= ym) << 1 | xp >= xm));
  return parent[j] = node, parent[i] = leaf, tree;
}
function addAll(data) {
  var d, i, n = data.length, x2, y2, xz = new Array(n), yz = new Array(n), x0 = Infinity, y0 = Infinity, x1 = -Infinity, y1 = -Infinity;
  for (i = 0; i < n; ++i) {
    if (isNaN(x2 = +this._x.call(null, d = data[i])) || isNaN(y2 = +this._y.call(null, d)))
      continue;
    xz[i] = x2;
    yz[i] = y2;
    if (x2 < x0)
      x0 = x2;
    if (x2 > x1)
      x1 = x2;
    if (y2 < y0)
      y0 = y2;
    if (y2 > y1)
      y1 = y2;
  }
  if (x0 > x1 || y0 > y1)
    return this;
  this.cover(x0, y0).cover(x1, y1);
  for (i = 0; i < n; ++i) {
    add(this, xz[i], yz[i], data[i]);
  }
  return this;
}
function tree_cover(x2, y2) {
  if (isNaN(x2 = +x2) || isNaN(y2 = +y2))
    return this;
  var x0 = this._x0, y0 = this._y0, x1 = this._x1, y1 = this._y1;
  if (isNaN(x0)) {
    x1 = (x0 = Math.floor(x2)) + 1;
    y1 = (y0 = Math.floor(y2)) + 1;
  } else {
    var z = x1 - x0, node = this._root, parent, i;
    while (x0 > x2 || x2 >= x1 || y0 > y2 || y2 >= y1) {
      i = (y2 < y0) << 1 | x2 < x0;
      parent = new Array(4), parent[i] = node, node = parent, z *= 2;
      switch (i) {
        case 0:
          x1 = x0 + z, y1 = y0 + z;
          break;
        case 1:
          x0 = x1 - z, y1 = y0 + z;
          break;
        case 2:
          x1 = x0 + z, y0 = y1 - z;
          break;
        case 3:
          x0 = x1 - z, y0 = y1 - z;
          break;
      }
    }
    if (this._root && this._root.length)
      this._root = node;
  }
  this._x0 = x0;
  this._y0 = y0;
  this._x1 = x1;
  this._y1 = y1;
  return this;
}
function tree_data() {
  var data = [];
  this.visit(function(node) {
    if (!node.length)
      do
        data.push(node.data);
      while (node = node.next);
  });
  return data;
}
function tree_extent(_) {
  return arguments.length ? this.cover(+_[0][0], +_[0][1]).cover(+_[1][0], +_[1][1]) : isNaN(this._x0) ? void 0 : [[this._x0, this._y0], [this._x1, this._y1]];
}
function Quad(node, x0, y0, x1, y1) {
  this.node = node;
  this.x0 = x0;
  this.y0 = y0;
  this.x1 = x1;
  this.y1 = y1;
}
function tree_find(x2, y2, radius) {
  var data, x0 = this._x0, y0 = this._y0, x1, y1, x22, y22, x3 = this._x1, y3 = this._y1, quads = [], node = this._root, q, i;
  if (node)
    quads.push(new Quad(node, x0, y0, x3, y3));
  if (radius == null)
    radius = Infinity;
  else {
    x0 = x2 - radius, y0 = y2 - radius;
    x3 = x2 + radius, y3 = y2 + radius;
    radius *= radius;
  }
  while (q = quads.pop()) {
    if (!(node = q.node) || (x1 = q.x0) > x3 || (y1 = q.y0) > y3 || (x22 = q.x1) < x0 || (y22 = q.y1) < y0)
      continue;
    if (node.length) {
      var xm = (x1 + x22) / 2, ym = (y1 + y22) / 2;
      quads.push(
        new Quad(node[3], xm, ym, x22, y22),
        new Quad(node[2], x1, ym, xm, y22),
        new Quad(node[1], xm, y1, x22, ym),
        new Quad(node[0], x1, y1, xm, ym)
      );
      if (i = (y2 >= ym) << 1 | x2 >= xm) {
        q = quads[quads.length - 1];
        quads[quads.length - 1] = quads[quads.length - 1 - i];
        quads[quads.length - 1 - i] = q;
      }
    } else {
      var dx = x2 - +this._x.call(null, node.data), dy = y2 - +this._y.call(null, node.data), d2 = dx * dx + dy * dy;
      if (d2 < radius) {
        var d = Math.sqrt(radius = d2);
        x0 = x2 - d, y0 = y2 - d;
        x3 = x2 + d, y3 = y2 + d;
        data = node.data;
      }
    }
  }
  return data;
}
function tree_remove(d) {
  if (isNaN(x2 = +this._x.call(null, d)) || isNaN(y2 = +this._y.call(null, d)))
    return this;
  var parent, node = this._root, retainer, previous, next, x0 = this._x0, y0 = this._y0, x1 = this._x1, y1 = this._y1, x2, y2, xm, ym, right, bottom, i, j;
  if (!node)
    return this;
  if (node.length)
    while (true) {
      if (right = x2 >= (xm = (x0 + x1) / 2))
        x0 = xm;
      else
        x1 = xm;
      if (bottom = y2 >= (ym = (y0 + y1) / 2))
        y0 = ym;
      else
        y1 = ym;
      if (!(parent = node, node = node[i = bottom << 1 | right]))
        return this;
      if (!node.length)
        break;
      if (parent[i + 1 & 3] || parent[i + 2 & 3] || parent[i + 3 & 3])
        retainer = parent, j = i;
    }
  while (node.data !== d)
    if (!(previous = node, node = node.next))
      return this;
  if (next = node.next)
    delete node.next;
  if (previous)
    return next ? previous.next = next : delete previous.next, this;
  if (!parent)
    return this._root = next, this;
  next ? parent[i] = next : delete parent[i];
  if ((node = parent[0] || parent[1] || parent[2] || parent[3]) && node === (parent[3] || parent[2] || parent[1] || parent[0]) && !node.length) {
    if (retainer)
      retainer[j] = node;
    else
      this._root = node;
  }
  return this;
}
function removeAll(data) {
  for (var i = 0, n = data.length; i < n; ++i)
    this.remove(data[i]);
  return this;
}
function tree_root() {
  return this._root;
}
function tree_size() {
  var size = 0;
  this.visit(function(node) {
    if (!node.length)
      do
        ++size;
      while (node = node.next);
  });
  return size;
}
function tree_visit(callback) {
  var quads = [], q, node = this._root, child, x0, y0, x1, y1;
  if (node)
    quads.push(new Quad(node, this._x0, this._y0, this._x1, this._y1));
  while (q = quads.pop()) {
    if (!callback(node = q.node, x0 = q.x0, y0 = q.y0, x1 = q.x1, y1 = q.y1) && node.length) {
      var xm = (x0 + x1) / 2, ym = (y0 + y1) / 2;
      if (child = node[3])
        quads.push(new Quad(child, xm, ym, x1, y1));
      if (child = node[2])
        quads.push(new Quad(child, x0, ym, xm, y1));
      if (child = node[1])
        quads.push(new Quad(child, xm, y0, x1, ym));
      if (child = node[0])
        quads.push(new Quad(child, x0, y0, xm, ym));
    }
  }
  return this;
}
function tree_visitAfter(callback) {
  var quads = [], next = [], q;
  if (this._root)
    quads.push(new Quad(this._root, this._x0, this._y0, this._x1, this._y1));
  while (q = quads.pop()) {
    var node = q.node;
    if (node.length) {
      var child, x0 = q.x0, y0 = q.y0, x1 = q.x1, y1 = q.y1, xm = (x0 + x1) / 2, ym = (y0 + y1) / 2;
      if (child = node[0])
        quads.push(new Quad(child, x0, y0, xm, ym));
      if (child = node[1])
        quads.push(new Quad(child, xm, y0, x1, ym));
      if (child = node[2])
        quads.push(new Quad(child, x0, ym, xm, y1));
      if (child = node[3])
        quads.push(new Quad(child, xm, ym, x1, y1));
    }
    next.push(q);
  }
  while (q = next.pop()) {
    callback(q.node, q.x0, q.y0, q.x1, q.y1);
  }
  return this;
}
function defaultX(d) {
  return d[0];
}
function tree_x(_) {
  return arguments.length ? (this._x = _, this) : this._x;
}
function defaultY(d) {
  return d[1];
}
function tree_y(_) {
  return arguments.length ? (this._y = _, this) : this._y;
}
function quadtree(nodes, x2, y2) {
  var tree = new Quadtree(x2 == null ? defaultX : x2, y2 == null ? defaultY : y2, NaN, NaN, NaN, NaN);
  return nodes == null ? tree : tree.addAll(nodes);
}
function Quadtree(x2, y2, x0, y0, x1, y1) {
  this._x = x2;
  this._y = y2;
  this._x0 = x0;
  this._y0 = y0;
  this._x1 = x1;
  this._y1 = y1;
  this._root = void 0;
}
function leaf_copy(leaf) {
  var copy = { data: leaf.data }, next = copy;
  while (leaf = leaf.next)
    next = next.next = { data: leaf.data };
  return copy;
}
var treeProto = quadtree.prototype = Quadtree.prototype;
treeProto.copy = function() {
  var copy = new Quadtree(this._x, this._y, this._x0, this._y0, this._x1, this._y1), node = this._root, nodes, child;
  if (!node)
    return copy;
  if (!node.length)
    return copy._root = leaf_copy(node), copy;
  nodes = [{ source: node, target: copy._root = new Array(4) }];
  while (node = nodes.pop()) {
    for (var i = 0; i < 4; ++i) {
      if (child = node.source[i]) {
        if (child.length)
          nodes.push({ source: child, target: node.target[i] = new Array(4) });
        else
          node.target[i] = leaf_copy(child);
      }
    }
  }
  return copy;
};
treeProto.add = tree_add;
treeProto.addAll = addAll;
treeProto.cover = tree_cover;
treeProto.data = tree_data;
treeProto.extent = tree_extent;
treeProto.find = tree_find;
treeProto.remove = tree_remove;
treeProto.removeAll = removeAll;
treeProto.root = tree_root;
treeProto.size = tree_size;
treeProto.visit = tree_visit;
treeProto.visitAfter = tree_visitAfter;
treeProto.x = tree_x;
treeProto.y = tree_y;
function x$1(d) {
  return d.x + d.vx;
}
function y$1(d) {
  return d.y + d.vy;
}
function collide(radius) {
  var nodes, radii, strength = 1, iterations = 1;
  if (typeof radius !== "function")
    radius = constant(radius == null ? 1 : +radius);
  function force() {
    var i, n = nodes.length, tree, node, xi, yi, ri, ri2;
    for (var k = 0; k < iterations; ++k) {
      tree = quadtree(nodes, x$1, y$1).visitAfter(prepare);
      for (i = 0; i < n; ++i) {
        node = nodes[i];
        ri = radii[node.index], ri2 = ri * ri;
        xi = node.x + node.vx;
        yi = node.y + node.vy;
        tree.visit(apply);
      }
    }
    function apply(quad, x0, y0, x1, y1) {
      var data = quad.data, rj = quad.r, r = ri + rj;
      if (data) {
        if (data.index > node.index) {
          var x2 = xi - data.x - data.vx, y2 = yi - data.y - data.vy, l = x2 * x2 + y2 * y2;
          if (l < r * r) {
            if (x2 === 0)
              x2 = jiggle(), l += x2 * x2;
            if (y2 === 0)
              y2 = jiggle(), l += y2 * y2;
            l = (r - (l = Math.sqrt(l))) / l * strength;
            node.vx += (x2 *= l) * (r = (rj *= rj) / (ri2 + rj));
            node.vy += (y2 *= l) * r;
            data.vx -= x2 * (r = 1 - r);
            data.vy -= y2 * r;
          }
        }
        return;
      }
      return x0 > xi + r || x1 < xi - r || y0 > yi + r || y1 < yi - r;
    }
  }
  function prepare(quad) {
    if (quad.data)
      return quad.r = radii[quad.data.index];
    for (var i = quad.r = 0; i < 4; ++i) {
      if (quad[i] && quad[i].r > quad.r) {
        quad.r = quad[i].r;
      }
    }
  }
  function initialize() {
    if (!nodes)
      return;
    var i, n = nodes.length, node;
    radii = new Array(n);
    for (i = 0; i < n; ++i)
      node = nodes[i], radii[node.index] = +radius(node, i, nodes);
  }
  force.initialize = function(_) {
    nodes = _;
    initialize();
  };
  force.iterations = function(_) {
    return arguments.length ? (iterations = +_, force) : iterations;
  };
  force.strength = function(_) {
    return arguments.length ? (strength = +_, force) : strength;
  };
  force.radius = function(_) {
    return arguments.length ? (radius = typeof _ === "function" ? _ : constant(+_), initialize(), force) : radius;
  };
  return force;
}
function index(d) {
  return d.index;
}
function find(nodeById, nodeId) {
  var node = nodeById.get(nodeId);
  if (!node)
    throw new Error("missing: " + nodeId);
  return node;
}
function link(links) {
  var id = index, strength = defaultStrength, strengths, distance = constant(30), distances, nodes, count, bias, iterations = 1;
  if (links == null)
    links = [];
  function defaultStrength(link2) {
    return 1 / Math.min(count[link2.source.index], count[link2.target.index]);
  }
  function force(alpha) {
    for (var k = 0, n = links.length; k < iterations; ++k) {
      for (var i = 0, link2, source, target, x2, y2, l, b; i < n; ++i) {
        link2 = links[i], source = link2.source, target = link2.target;
        x2 = target.x + target.vx - source.x - source.vx || jiggle();
        y2 = target.y + target.vy - source.y - source.vy || jiggle();
        l = Math.sqrt(x2 * x2 + y2 * y2);
        l = (l - distances[i]) / l * alpha * strengths[i];
        x2 *= l, y2 *= l;
        target.vx -= x2 * (b = bias[i]);
        target.vy -= y2 * b;
        source.vx += x2 * (b = 1 - b);
        source.vy += y2 * b;
      }
    }
  }
  function initialize() {
    if (!nodes)
      return;
    var i, n = nodes.length, m = links.length, nodeById = map(nodes, id), link2;
    for (i = 0, count = new Array(n); i < m; ++i) {
      link2 = links[i], link2.index = i;
      if (typeof link2.source !== "object")
        link2.source = find(nodeById, link2.source);
      if (typeof link2.target !== "object")
        link2.target = find(nodeById, link2.target);
      count[link2.source.index] = (count[link2.source.index] || 0) + 1;
      count[link2.target.index] = (count[link2.target.index] || 0) + 1;
    }
    for (i = 0, bias = new Array(m); i < m; ++i) {
      link2 = links[i], bias[i] = count[link2.source.index] / (count[link2.source.index] + count[link2.target.index]);
    }
    strengths = new Array(m), initializeStrength();
    distances = new Array(m), initializeDistance();
  }
  function initializeStrength() {
    if (!nodes)
      return;
    for (var i = 0, n = links.length; i < n; ++i) {
      strengths[i] = +strength(links[i], i, links);
    }
  }
  function initializeDistance() {
    if (!nodes)
      return;
    for (var i = 0, n = links.length; i < n; ++i) {
      distances[i] = +distance(links[i], i, links);
    }
  }
  force.initialize = function(_) {
    nodes = _;
    initialize();
  };
  force.links = function(_) {
    return arguments.length ? (links = _, initialize(), force) : links;
  };
  force.id = function(_) {
    return arguments.length ? (id = _, force) : id;
  };
  force.iterations = function(_) {
    return arguments.length ? (iterations = +_, force) : iterations;
  };
  force.strength = function(_) {
    return arguments.length ? (strength = typeof _ === "function" ? _ : constant(+_), initializeStrength(), force) : strength;
  };
  force.distance = function(_) {
    return arguments.length ? (distance = typeof _ === "function" ? _ : constant(+_), initializeDistance(), force) : distance;
  };
  return force;
}
function x(d) {
  return d.x;
}
function y(d) {
  return d.y;
}
var initialRadius = 10, initialAngle = Math.PI * (3 - Math.sqrt(5));
function simulation(nodes) {
  var simulation2, alpha = 1, alphaMin = 1e-3, alphaDecay = 1 - Math.pow(alphaMin, 1 / 300), alphaTarget = 0, velocityDecay = 0.6, forces = map(), stepper = timer(step), event2 = dispatch("tick", "end");
  if (nodes == null)
    nodes = [];
  function step() {
    tick();
    event2.call("tick", simulation2);
    if (alpha < alphaMin) {
      stepper.stop();
      event2.call("end", simulation2);
    }
  }
  function tick(iterations) {
    var i, n = nodes.length, node;
    if (iterations === void 0)
      iterations = 1;
    for (var k = 0; k < iterations; ++k) {
      alpha += (alphaTarget - alpha) * alphaDecay;
      forces.each(function(force) {
        force(alpha);
      });
      for (i = 0; i < n; ++i) {
        node = nodes[i];
        if (node.fx == null)
          node.x += node.vx *= velocityDecay;
        else
          node.x = node.fx, node.vx = 0;
        if (node.fy == null)
          node.y += node.vy *= velocityDecay;
        else
          node.y = node.fy, node.vy = 0;
      }
    }
    return simulation2;
  }
  function initializeNodes() {
    for (var i = 0, n = nodes.length, node; i < n; ++i) {
      node = nodes[i], node.index = i;
      if (node.fx != null)
        node.x = node.fx;
      if (node.fy != null)
        node.y = node.fy;
      if (isNaN(node.x) || isNaN(node.y)) {
        var radius = initialRadius * Math.sqrt(i), angle = i * initialAngle;
        node.x = radius * Math.cos(angle);
        node.y = radius * Math.sin(angle);
      }
      if (isNaN(node.vx) || isNaN(node.vy)) {
        node.vx = node.vy = 0;
      }
    }
  }
  function initializeForce(force) {
    if (force.initialize)
      force.initialize(nodes);
    return force;
  }
  initializeNodes();
  return simulation2 = {
    tick,
    restart: function() {
      return stepper.restart(step), simulation2;
    },
    stop: function() {
      return stepper.stop(), simulation2;
    },
    nodes: function(_) {
      return arguments.length ? (nodes = _, initializeNodes(), forces.each(initializeForce), simulation2) : nodes;
    },
    alpha: function(_) {
      return arguments.length ? (alpha = +_, simulation2) : alpha;
    },
    alphaMin: function(_) {
      return arguments.length ? (alphaMin = +_, simulation2) : alphaMin;
    },
    alphaDecay: function(_) {
      return arguments.length ? (alphaDecay = +_, simulation2) : +alphaDecay;
    },
    alphaTarget: function(_) {
      return arguments.length ? (alphaTarget = +_, simulation2) : alphaTarget;
    },
    velocityDecay: function(_) {
      return arguments.length ? (velocityDecay = 1 - _, simulation2) : 1 - velocityDecay;
    },
    force: function(name, _) {
      return arguments.length > 1 ? (_ == null ? forces.remove(name) : forces.set(name, initializeForce(_)), simulation2) : forces.get(name);
    },
    find: function(x2, y2, radius) {
      var i = 0, n = nodes.length, dx, dy, d2, node, closest;
      if (radius == null)
        radius = Infinity;
      else
        radius *= radius;
      for (i = 0; i < n; ++i) {
        node = nodes[i];
        dx = x2 - node.x;
        dy = y2 - node.y;
        d2 = dx * dx + dy * dy;
        if (d2 < radius)
          closest = node, radius = d2;
      }
      return closest;
    },
    on: function(name, _) {
      return arguments.length > 1 ? (event2.on(name, _), simulation2) : event2.on(name);
    }
  };
}
function manyBody() {
  var nodes, node, alpha, strength = constant(-30), strengths, distanceMin2 = 1, distanceMax2 = Infinity, theta2 = 0.81;
  function force(_) {
    var i, n = nodes.length, tree = quadtree(nodes, x, y).visitAfter(accumulate);
    for (alpha = _, i = 0; i < n; ++i)
      node = nodes[i], tree.visit(apply);
  }
  function initialize() {
    if (!nodes)
      return;
    var i, n = nodes.length, node2;
    strengths = new Array(n);
    for (i = 0; i < n; ++i)
      node2 = nodes[i], strengths[node2.index] = +strength(node2, i, nodes);
  }
  function accumulate(quad) {
    var strength2 = 0, q, c, weight = 0, x2, y2, i;
    if (quad.length) {
      for (x2 = y2 = i = 0; i < 4; ++i) {
        if ((q = quad[i]) && (c = Math.abs(q.value))) {
          strength2 += q.value, weight += c, x2 += c * q.x, y2 += c * q.y;
        }
      }
      quad.x = x2 / weight;
      quad.y = y2 / weight;
    } else {
      q = quad;
      q.x = q.data.x;
      q.y = q.data.y;
      do
        strength2 += strengths[q.data.index];
      while (q = q.next);
    }
    quad.value = strength2;
  }
  function apply(quad, x1, _, x2) {
    if (!quad.value)
      return true;
    var x3 = quad.x - node.x, y2 = quad.y - node.y, w = x2 - x1, l = x3 * x3 + y2 * y2;
    if (w * w / theta2 < l) {
      if (l < distanceMax2) {
        if (x3 === 0)
          x3 = jiggle(), l += x3 * x3;
        if (y2 === 0)
          y2 = jiggle(), l += y2 * y2;
        if (l < distanceMin2)
          l = Math.sqrt(distanceMin2 * l);
        node.vx += x3 * quad.value * alpha / l;
        node.vy += y2 * quad.value * alpha / l;
      }
      return true;
    } else if (quad.length || l >= distanceMax2)
      return;
    if (quad.data !== node || quad.next) {
      if (x3 === 0)
        x3 = jiggle(), l += x3 * x3;
      if (y2 === 0)
        y2 = jiggle(), l += y2 * y2;
      if (l < distanceMin2)
        l = Math.sqrt(distanceMin2 * l);
    }
    do
      if (quad.data !== node) {
        w = strengths[quad.data.index] * alpha / l;
        node.vx += x3 * w;
        node.vy += y2 * w;
      }
    while (quad = quad.next);
  }
  force.initialize = function(_) {
    nodes = _;
    initialize();
  };
  force.strength = function(_) {
    return arguments.length ? (strength = typeof _ === "function" ? _ : constant(+_), initialize(), force) : strength;
  };
  force.distanceMin = function(_) {
    return arguments.length ? (distanceMin2 = _ * _, force) : Math.sqrt(distanceMin2);
  };
  force.distanceMax = function(_) {
    return arguments.length ? (distanceMax2 = _ * _, force) : Math.sqrt(distanceMax2);
  };
  force.theta = function(_) {
    return arguments.length ? (theta2 = _ * _, force) : Math.sqrt(theta2);
  };
  return force;
}
var render = function() {
  var _vm = this;
  var _h = _vm.$createElement;
  var _c = _vm._self._c || _h;
  return _c("div", {
    staticClass: "node-net-container"
  }, [_c("div", {
    ref: "nodenet",
    staticClass: "node-net",
    attrs: {
      "id": _vm.id
    }
  }), _vm._t("default"), _c("div", {
    staticClass: "node-net-overlay",
    attrs: {
      "open": _vm.overlay
    },
    on: {
      "click": function($event) {
        $event.stopPropagation();
        return _vm.togglePopOver($event);
      }
    }
  })], 2);
};
var staticRenderFns = [];
var Cluster_vue_vue_type_style_index_0_lang = "";
const __vue2_script = defineComponent({
  name: "Cluster",
  components: {
    Icon
  },
  props: {
    nodes: {
      type: Array,
      default: () => []
    },
    nodeRadius: {
      type: Number,
      default: 30
    },
    nodeNames: {
      type: Boolean,
      default: true
    },
    resetOnDrag: {
      type: Boolean,
      default: false
    }
  },
  data() {
    return {
      id: "nodeNetwork",
      lineageRef: null,
      currentPopper: null,
      overlay: false
    };
  },
  watch: {
    nodes: {
      handler: "init",
      deep: true
    },
    links: {
      handler: "init",
      deep: true
    },
    nodeRadius: {
      handler: "init"
    },
    nodeNames: {
      handler() {
        document.querySelectorAll(`#${this.id} .net-node-labels`).forEach((label) => {
          if (!this.nodeNames) {
            label.classList.add("hide");
          } else {
            label.classList.remove("hide");
          }
        });
      }
    }
  },
  beforeMount() {
    this.id = this.generateId();
    this.icon = Vue.extend(Icon);
  },
  mounted() {
    this.init();
  },
  methods: {
    appendArrows(svg) {
      svg.append("svg:defs").append("svg:marker").attr("id", "arrow").attr("viewBox", "0 -8 16 16").attr("refX", 15).attr("refY", 0).attr("markerWidth", 8).attr("markerHeight", 8).attr("orient", "auto").attr("fill", "var(--dashboard-font-light)").append("svg:path").attr("d", "M0,-8L16,0L0,8");
      svg.append("svg:defs").append("svg:marker").attr("id", "arrow-error").attr("viewBox", "0 -8 16 16").attr("refX", 15).attr("refY", 0).attr("markerWidth", 8).attr("markerHeight", 8).attr("orient", "auto").attr("fill", "var(--dashboard-danger)").append("svg:path").attr("d", "M0,-8L16,0L0,8");
      svg.append("svg:defs").append("svg:marker").attr("id", "arrow-warning").attr("viewBox", "0 -8 16 16").attr("refX", 15).attr("refY", 0).attr("markerWidth", 8).attr("markerHeight", 8).attr("orient", "auto").attr("fill", "var(--dashboard-warning)").append("svg:path").attr("d", "M0,-8L16,0L0,8");
    },
    getGraphData() {
      const nodes = [];
      const links = [];
      function addLinks(child, parent) {
        if (child.relation && typeof child.relation === "string") {
          links.push({ source: parent.id, target: child.id, label: child.relation });
        } else if (child.relation && typeof child.relation === "object") {
          if (child.relation.from && typeof child.relation.from === "string") {
            links.push({ source: parent.id, target: child.id, label: child.relation.from });
          } else if (child.relation.from && typeof child.relation.from === "object") {
            links.push({
              source: parent.id,
              target: child.id,
              label: child.relation.from.name,
              state: child.relation.from.state
            });
          }
          if (child.relation.to && typeof child.relation.to === "string") {
            links.push({ source: child.id, target: parent.id, label: child.relation.to });
          } else if (child.relation.to && typeof child.relation.to === "object") {
            links.push({
              source: child.id,
              target: parent.id,
              label: child.relation.to.name,
              state: child.relation.to.state
            });
          }
        }
        if (typeof child.otherRelations === "object" && Array.isArray(child.otherRelations)) {
          child.otherRelations.forEach((r) => {
            const source = Object.keys(r)[0];
            if (r[source] && typeof r[source] === "string") {
              links.push({ source, target: child.id, label: r[source] });
            } else if (r[source] && typeof r[source] === "object") {
              links.push({
                source,
                target: child.id,
                label: r[source].name,
                state: r[source].state
              });
            }
          });
        }
      }
      function addNodes(nodelist, parent) {
        nodelist.forEach((n) => {
          addLinks(n, parent);
          if (n.children && n.children.length > 0) {
            addNodes(n.children, n);
            if (n.collapsed) {
              n._children = n.children;
              n.children = null;
            }
          }
          nodes.push(n);
        });
      }
      addNodes(this.nodes, null);
      return {
        nodes,
        links
      };
    },
    getComputedLinks(linkContainer) {
      return linkContainer.append("svg:path").attr("class", "node-link").attr("fill", "transparent").attr("stroke-width", "1px").attr("marker-end", function(d) {
        if (d.state === "error") {
          return "url(#arrow-error)";
        } else if (d.state === "warning") {
          return "url(#arrow-warning)";
        }
        return "url(#arrow)";
      }).attr("id", function(d) {
        return `${d.source.id.replace(/ /g, "_")}-${d.target.id.replace(/ /g, "_")}`;
      }).attr("stroke", function(d) {
        if (d.state === "error") {
          return "var(--dashboard-danger)";
        } else if (d.state === "warning") {
          return "var(--dashboard-warning)";
        } else if (d.state === "primary") {
          return "var(--dashboard-primary)";
        } else if (d.state === "success") {
          return "var(--dashboard-success)";
        } else if (d.state === "selected") {
          return "var(--dashboard-font-dark)";
        }
        return "var(--dashboard-font-light)";
      });
    },
    getLinkLabels(linkContainer) {
      linkContainer.append("svg:text").attr("dx", 20).attr("dy", 3).append("textPath").attr("class", "link-label-wrapper").attr("text-anchor", "middle").attr("startOffset", "50%").attr("stroke", "var(--dashboard-background)").attr("stroke-width", "12px").attr("xlink:href", function(d) {
        return `#${d.source.id.replace(/ /g, "_")}-${d.target.id.replace(/ /g, "_")}`;
      }).text(function(d) {
        return d.label;
      });
      return linkContainer.append("svg:text").attr("dx", 20).attr("dy", 3).append("textPath").attr("class", "link-label").attr("text-anchor", "middle").attr("startOffset", "50%").attr("fill", function(d) {
        if (d.state === "selected") {
          return "var(--dashboard-font-dark)";
        }
        return "var(--dashboard-font-light)";
      }).attr("xlink:href", function(d) {
        return `#${d.source.id.replace(/ /g, "_")}-${d.target.id.replace(/ /g, "_")}`;
      }).text(function(d) {
        return d.label;
      });
    },
    getNodes(container, graph, nodeRadius) {
      return container.append("g").attr("class", "net-nodes").selectAll("g").data(graph.nodes).enter().append("circle").attr("class", "node-circle").attr("r", nodeRadius).attr("id", function(d) {
        return d.id.replace(/ /g, "_");
      }).attr("fill", function(d) {
        if (d.root) {
          return "var(--dashboard-primary)";
        }
        return "var(--dashboard-element)";
      });
    },
    getNodeLabels(container, graph) {
      return container.append("g").attr("class", "net-node-labels").classed("hide", !this.nodeNames).selectAll("g").data(graph.nodes).enter().append("text").attr("text-anchor", "middle").attr("class", "node-label").text(function(d) {
        return d.name;
      });
    },
    getNodeStates(container, graph, nodeRadius) {
      return container.append("g").attr("class", "net-node-states").selectAll("g").data(graph.nodes).enter().append("circle").attr("class", "node-state-circle").attr("r", nodeRadius - 3).attr("fill", "transparent").attr("stroke", function(d) {
        if (d.state === "error") {
          return "var(--dashboard-danger)";
        } else if (d.state === "warning") {
          return "var(--dashboard-warning)";
        } else if (d.state === "primary") {
          return "var(--dashboard-primary)";
        } else if (d.state === "success") {
          return "var(--dashboard-success)";
        } else if (d.state === "selected") {
          return "var(--dashboard-font-dark)";
        } else {
          return "transparent";
        }
      }).attr("stroke-width", 1);
    },
    getNodeStateCountCircle(container, graph) {
      return container.append("g").attr("class", "net-node-state-counts").selectAll("g").data(graph.nodes).enter().append("circle").attr("class", "node-state-count-circle").attr("r", 8).classed("hide", function(d) {
        return !d.collapsed;
      }).attr("fill", function(d) {
        if (d.state === "error") {
          return "var(--dashboard-danger)";
        } else if (d.state === "warning") {
          return "var(--dashboard-warning)";
        } else if (d.state === "primary") {
          return "var(--dashboard-primary)";
        } else if (d.state === "success") {
          return "var(--dashboard-success)";
        } else if (d.state === "selected") {
          return "var(--dashboard-font-dark)";
        } else {
          return "var(--dashboard-font-light)";
        }
      });
    },
    getNodeChildCounts(container, graph) {
      return container.append("g").attr("class", "net-node-child-counts").selectAll("g").data(graph.nodes).enter().append("text").attr("class", "node-state-child-count").attr("text-anchor", "middle").classed("hide", function(d) {
        return !d.collapsed;
      }).text(function(d) {
        if (d._children && d._children.length > 0) {
          return d._children.length;
        }
        return 0;
      });
    },
    getNodeIcons(container, graph, nodeRadius) {
      return container.append("g").attr("class", "node-icons").selectAll("g").data(graph.nodes).enter().append("foreignObject").attr("width", nodeRadius * 2).attr("height", nodeRadius * 2).html((d) => {
        if (d.icon) {
          let propsData = { type: "filled", effects: false };
          if (typeof d.icon === "string") {
            propsData.name = d.icon;
          } else if (typeof d.icon === "object") {
            propsData = { ...propsData, ...d.icon };
          }
          const iconInstance = new this.icon({
            propsData
          });
          return iconInstance.$mount().$el.outerHTML;
        } else {
          return "";
        }
      });
    },
    getLineage(graph, linkWidth) {
      return simulation(graph.nodes).force("charge", manyBody().strength(-1500)).force(
        "link",
        link(graph.links).id(function(d) {
          return d.id;
        }).distance(linkWidth).strength(1)
      ).force("collide", collide(70));
    },
    init() {
      const nodeRadius = this.nodeRadius;
      const linkWidth = 180;
      const width = this.$refs.nodenet.offsetWidth;
      const height = this.$refs.nodenet.offsetHeight;
      const wrapper = document.getElementById(this.id);
      wrapper.innerHTML = "";
      const svg = select(`#${this.id}`).append("svg").attr("width", width).attr("height", height);
      const container = svg.append("g");
      svg.call(
        zoom().scaleExtent([0.1, 4]).on("zoom", function() {
          container.attr("transform", event.transform);
        })
      ).on("dblclick.zoom", null);
      this.appendArrows(svg);
      const graph = this.getGraphData();
      const rootNodeIndex = graph.nodes.findIndex((x2) => x2.root);
      if (rootNodeIndex > -1) {
        graph.nodes[rootNodeIndex].fx = width / 2;
        graph.nodes[rootNodeIndex].fy = height / 2;
      }
      this.lineageRef = this.getLineage(graph, linkWidth).on("tick", updatePositions);
      const adjlist = [];
      graph.links.forEach(function(d) {
        adjlist[`${d.source.index}-${d.target.index}`] = true;
        adjlist[`${d.target.index}-${d.source.index}`] = true;
      });
      function neigh(a, b) {
        return a == b || adjlist[`${a}-${b}`];
      }
      const linkContainer = container.append("g").attr("class", "links").selectAll("g").data(graph.links).enter().append("g");
      const computedLinks = this.getComputedLinks(linkContainer);
      const labels = this.getLinkLabels(linkContainer);
      const computedNodes = this.getNodes(container, graph, nodeRadius);
      let nodeNames = null;
      nodeNames = this.getNodeLabels(container, graph);
      const nodeIcons = this.getNodeIcons(container, graph, nodeRadius);
      const computedNodeStates = this.getNodeStates(container, graph, nodeRadius);
      const computedNodeStateCountCircles = this.getNodeStateCountCircle(container, graph);
      const childCounts = this.getNodeChildCounts(container, graph);
      computedNodes.on("mouseover", focus).on("mouseout", unfocus).on("click", this.handleClick).on("dblclick", this.handleDbClick).on("contextmenu", this.handleRightClick);
      computedNodes.call(
        drag().on("start", this.dragstarted).on("drag", this.dragged).on("end", this.dragended)
      );
      function focus() {
        const index2 = select(event.target).datum().index;
        const nofocusopacity = 0.4;
        computedNodes.style("opacity", function(o) {
          return neigh(index2, o.index) ? 1 : nofocusopacity;
        });
        if (nodeNames) {
          nodeNames.style("opacity", function(o) {
            return neigh(index2, o.index) ? 1 : nofocusopacity;
          });
        }
        computedNodeStates.style("opacity", function(o) {
          return neigh(index2, o.index) ? 1 : nofocusopacity;
        });
        computedNodeStateCountCircles.style("opacity", function(o) {
          return neigh(index2, o.index) ? 1 : nofocusopacity;
        });
        childCounts.style("opacity", function(o) {
          return neigh(index2, o.index) ? 1 : nofocusopacity;
        });
        nodeIcons.style("opacity", function(o) {
          return neigh(index2, o.index) ? 1 : nofocusopacity;
        });
        computedLinks.style("opacity", function(o) {
          return o.source.index == index2 || o.target.index == index2 ? 1 : nofocusopacity;
        });
        labels.style("opacity", function(o) {
          return o.source.index == index2 || o.target.index == index2 ? 1 : nofocusopacity;
        });
      }
      function unfocus() {
        computedNodes.style("opacity", 1);
        computedNodeStates.style("opacity", 1);
        computedNodeStateCountCircles.style("opacity", 1);
        childCounts.style("opacity", 1);
        if (nodeNames) {
          nodeNames.style("opacity", 1);
        }
        nodeIcons.style("opacity", 1);
        computedLinks.style("opacity", 1);
        labels.style("opacity", 1);
      }
      function fixna(x2) {
        if (isFinite(x2)) {
          return x2;
        }
        return 0;
      }
      function updatePositions() {
        computedNodes.call(function(node) {
          node.attr("transform", function(d) {
            return `translate(${fixna(d.x)},${fixna(d.y)})`;
          });
        });
        computedNodeStates.call(function(node) {
          node.attr("transform", function(d) {
            return `translate(${fixna(d.x)},${fixna(d.y)})`;
          });
        });
        computedNodeStateCountCircles.call(function(node) {
          node.attr("transform", function(d) {
            return `translate(${fixna(d.x + nodeRadius - 12)},${fixna(d.y - nodeRadius + 12)})`;
          });
        });
        childCounts.call(function(node) {
          node.attr("transform", function(d) {
            return `translate(${fixna(d.x + nodeRadius - 12)},${fixna(d.y - nodeRadius + 15)})`;
          });
        });
        if (nodeNames) {
          nodeNames.call(function(node) {
            node.attr("transform", function(d) {
              return `translate(${fixna(d.x)},${fixna(d.y + nodeRadius + 14)})`;
            });
          });
        }
        nodeIcons.call(function(icon) {
          icon.attr("transform", function(d) {
            return `translate(${fixna(d.x - nodeRadius)},${fixna(d.y - nodeRadius)})`;
          });
        });
        computedLinks.call(function(link2) {
          link2.attr("d", function(d) {
            const diffX = d.target.x - d.source.x;
            const diffY = d.target.y - d.source.y;
            const pathLength = Math.sqrt(diffX * diffX + diffY * diffY);
            const pathAngle = pathLength - 60;
            const t_radius = nodeRadius + 6;
            const dx = d.target.x - d.source.x;
            const dy = d.target.y - d.source.y;
            const gamma = Math.atan2(dy, dx);
            const tx = d.target.x - Math.cos(gamma) * t_radius;
            const ty = d.target.y - Math.sin(gamma) * t_radius;
            return `M${d.source.x},${d.source.y}A${pathAngle},${pathAngle} 0 0,1 ${+tx},${ty}`;
          });
        });
      }
    },
    handleClick() {
      this.$emit("click", select(event.target).datum());
    },
    handleRightClick() {
      event.stopPropagation();
      event.preventDefault();
      const d = select(event.target).datum();
      this.togglePopOver(d);
    },
    togglePopOver(d = {}) {
      document.querySelectorAll("[popover-for]").forEach((el) => {
        el.style.display = "none";
      });
      const target = document.querySelector(`#${d.id}`);
      const content = document.querySelector(`[popover-for='${d.id}']`);
      if (content) {
        content.style.display = "block";
      }
      if (target && content && this.currentPopper == null) {
        this.overlay = true;
        this.currentPopper = createPopper(target, content, {
          placement: "auto",
          strategy: "fixed",
          modifiers: [
            {
              name: "offset",
              options: {
                offset: [-100, 10]
              }
            }
          ]
        });
      } else {
        this.overlay = false;
        if (this.currentPopper) {
          this.currentPopper.destroy();
          this.currentPopper = null;
        }
        if (content) {
          content.style.display = "none";
        }
      }
    },
    handleDbClick() {
      const d = select(event.target).datum();
      if (d.children) {
        d.collapsed = true;
        d._children = d.children;
        d.children = null;
      } else {
        d.collapsed = false;
        d.children = d._children;
        d._children = null;
      }
      this.init();
      this.$emit("dblclick", select(event.target).datum());
    },
    dragstarted(d) {
      event.sourceEvent.stopPropagation();
      if (!event.active) {
        this.lineageRef.alphaTarget(0.3).restart();
      }
      d.fx = d.x;
      d.fy = d.y;
      this.$emit("dragstart", d);
    },
    dragged(d) {
      d.fx = event.x;
      d.fy = event.y;
      this.$emit("dragged", d);
    },
    dragended(d) {
      if (this.resetOnDrag) {
        if (!event.active) {
          this.lineageRef.alphaTarget(0);
        }
        d.fx = null;
        d.fy = null;
      }
      this.$emit("dragend", d);
    },
    generateId() {
      let id = "";
      const chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
      const charsLength = chars.length;
      for (let i = 0; i < 10; i++) {
        id += chars.charAt(Math.floor(Math.random() * charsLength));
      }
      return id;
    }
  }
});
const __cssModules = {};
var __component__ = /* @__PURE__ */ normalizeComponent(
  __vue2_script,
  render,
  staticRenderFns,
  false,
  __vue2_injectStyles,
  null,
  null,
  null
);
function __vue2_injectStyles(context) {
  for (let o in __cssModules) {
    this[o] = __cssModules[o];
  }
}
var Cluster = /* @__PURE__ */ function() {
  return __component__.exports;
}();
export { Cluster as default };
//# sourceMappingURL=Cluster-e928cf99.es.js.map
