import { o as P } from "./accessors.BHk36ecy.js";
function Z() {
  return 0;
}
function Q(r) {
  return function() {
    return r;
  };
}
const T = 1664525, U = 1013904223, D = 4294967296;
function V() {
  let r = 1;
  return () => (r = (T * r + U) % D) / D;
}
function X(r) {
  return typeof r == "object" && "length" in r ? r : Array.from(r);
}
function Y(r, u) {
  let n = r.length, e, t;
  for (; n; )
    t = u() * n-- | 0, e = r[n], r[n] = r[t], r[t] = e;
  return r;
}
function $(r, u) {
  for (var n = 0, e = (r = Y(Array.from(r), u)).length, t = [], i, f; n < e; )
    i = r[n], f && K(f, i) ? ++n : (f = B(t = b(t, i)), n = 0);
  return f;
}
function b(r, u) {
  var n, e;
  if (R(u, r)) return [u];
  for (n = 0; n < r.length; ++n)
    if (_(u, r[n]) && R(h(r[n], u), r))
      return [r[n], u];
  for (n = 0; n < r.length - 1; ++n)
    for (e = n + 1; e < r.length; ++e)
      if (_(h(r[n], r[e]), u) && _(h(r[n], u), r[e]) && _(h(r[e], u), r[n]) && R(O(r[n], r[e], u), r))
        return [r[n], r[e], u];
  throw new Error();
}
function _(r, u) {
  var n = r.r - u.r, e = u.x - r.x, t = u.y - r.y;
  return n < 0 || n * n < e * e + t * t;
}
function K(r, u) {
  var n = r.r - u.r + Math.max(r.r, u.r, 1) * 1e-9, e = u.x - r.x, t = u.y - r.y;
  return n > 0 && n * n > e * e + t * t;
}
function R(r, u) {
  for (var n = 0; n < u.length; ++n)
    if (!K(r, u[n]))
      return !1;
  return !0;
}
function B(r) {
  switch (r.length) {
    case 1:
      return rr(r[0]);
    case 2:
      return h(r[0], r[1]);
    case 3:
      return O(r[0], r[1], r[2]);
  }
}
function rr(r) {
  return {
    x: r.x,
    y: r.y,
    r: r.r
  };
}
function h(r, u) {
  var n = r.x, e = r.y, t = r.r, i = u.x, f = u.y, s = u.r, o = i - n, a = f - e, x = s - t, y = Math.sqrt(o * o + a * a);
  return {
    x: (n + i + o / y * x) / 2,
    y: (e + f + a / y * x) / 2,
    r: (y + t + s) / 2
  };
}
function O(r, u, n) {
  var e = r.x, t = r.y, i = r.r, f = u.x, s = u.y, o = u.r, a = n.x, x = n.y, y = n.r, c = e - f, M = e - a, A = t - s, k = t - x, E = o - i, N = y - i, W = e * e + t * t - i * i, z = W - f * f - s * s + o * o, L = W - a * a - x * x + y * y, l = M * A - c * k, d = (A * L - k * z) / (l * 2) - e, v = (k * E - A * N) / l, g = (M * z - c * L) / (l * 2) - t, m = (c * N - M * E) / l, q = v * v + m * m - 1, p = 2 * (i + d * v + g * m), S = d * d + g * g - i * i, j = -(Math.abs(q) > 1e-6 ? (p + Math.sqrt(p * p - 4 * q * S)) / (2 * q) : S / p);
  return {
    x: e + d + v * j,
    y: t + g + m * j,
    r: j
  };
}
function F(r, u, n) {
  var e = r.x - u.x, t, i, f = r.y - u.y, s, o, a = e * e + f * f;
  a ? (i = u.r + n.r, i *= i, o = r.r + n.r, o *= o, i > o ? (t = (a + o - i) / (2 * a), s = Math.sqrt(Math.max(0, o / a - t * t)), n.x = r.x - t * e - s * f, n.y = r.y - t * f + s * e) : (t = (a + i - o) / (2 * a), s = Math.sqrt(Math.max(0, i / a - t * t)), n.x = u.x + t * e - s * f, n.y = u.y + t * f + s * e)) : (n.x = u.x + n.r, n.y = u.y);
}
function G(r, u) {
  var n = r.r + u.r - 1e-6, e = u.x - r.x, t = u.y - r.y;
  return n > 0 && n * n > e * e + t * t;
}
function H(r) {
  var u = r._, n = r.next._, e = u.r + n.r, t = (u.x * n.r + n.x * u.r) / e, i = (u.y * n.r + n.y * u.r) / e;
  return t * t + i * i;
}
function w(r) {
  this._ = r, this.next = null, this.previous = null;
}
function nr(r, u) {
  if (!(i = (r = X(r)).length)) return 0;
  var n, e, t, i, f, s, o, a, x, y, c;
  if (n = r[0], n.x = 0, n.y = 0, !(i > 1)) return n.r;
  if (e = r[1], n.x = -e.r, e.x = n.r, e.y = 0, !(i > 2)) return n.r + e.r;
  F(e, n, t = r[2]), n = new w(n), e = new w(e), t = new w(t), n.next = t.previous = e, e.next = n.previous = t, t.next = e.previous = n;
  r: for (o = 3; o < i; ++o) {
    F(n._, e._, t = r[o]), t = new w(t), a = e.next, x = n.previous, y = e._.r, c = n._.r;
    do
      if (y <= c) {
        if (G(a._, t._)) {
          e = a, n.next = e, e.previous = n, --o;
          continue r;
        }
        y += a._.r, a = a.next;
      } else {
        if (G(x._, t._)) {
          n = x, n.next = e, e.previous = n, --o;
          continue r;
        }
        c += x._.r, x = x.previous;
      }
    while (a !== x.next);
    for (t.previous = n, t.next = e, n.next = e.previous = e = t, f = H(n); (t = t.next) !== e; )
      (s = H(t)) < f && (n = t, f = s);
    e = n.next;
  }
  for (n = [e._], t = e; (t = t.next) !== e; ) n.push(t._);
  for (t = $(n, u), o = 0; o < i; ++o) n = r[o], n.x -= t.x, n.y -= t.y;
  return t.r;
}
function tr(r) {
  return Math.sqrt(r.value);
}
function ur() {
  var r = null, u = 1, n = 1, e = Z;
  function t(i) {
    const f = V();
    return i.x = u / 2, i.y = n / 2, r ? i.eachBefore(I(r)).eachAfter(C(e, 0.5, f)).eachBefore(J(1)) : i.eachBefore(I(tr)).eachAfter(C(Z, 1, f)).eachAfter(C(e, i.r / Math.min(u, n), f)).eachBefore(J(Math.min(u, n) / (2 * i.r))), i;
  }
  return t.radius = function(i) {
    return arguments.length ? (r = P(i), t) : r;
  }, t.size = function(i) {
    return arguments.length ? (u = +i[0], n = +i[1], t) : [u, n];
  }, t.padding = function(i) {
    return arguments.length ? (e = typeof i == "function" ? i : Q(+i), t) : e;
  }, t;
}
function I(r) {
  return function(u) {
    u.children || (u.r = Math.max(0, +r(u) || 0));
  };
}
function C(r, u, n) {
  return function(e) {
    if (t = e.children) {
      var t, i, f = t.length, s = r(e) * u || 0, o;
      if (s) for (i = 0; i < f; ++i) t[i].r += s;
      if (o = nr(t, n), s) for (i = 0; i < f; ++i) t[i].r -= s;
      e.r = o + s;
    }
  };
}
function J(r) {
  return function(u) {
    var n = u.parent;
    u.r *= r, n && (u.x = n.x + r * u.x, u.y = n.y + r * u.y);
  };
}
export {
  Q as a,
  Z as c,
  ur as i
};
