import { a5 as un, a6 as an, a4 as cn, a7 as Q, a8 as _, a9 as H, aa as rn, ab as en, ac as q, ad as i, a2 as P, ae as sn, af as tn, ag as on } from "./index-CNUFa5l3.js";
function yn(s) {
  return s.innerRadius;
}
function ln(s) {
  return s.outerRadius;
}
function fn(s) {
  return s.startAngle;
}
function xn(s) {
  return s.endAngle;
}
function gn(s) {
  return s && s.padAngle;
}
function pn(s, h, D, w, v, d, F, e) {
  var E = D - s, u = w - h, n = F - v, x = e - d, r = x * E - n * u;
  if (!(r * r < 1e-12)) return r = (n * (h - d) - x * (s - v)) / r, [s + r * E, h + r * u];
}
function X(s, h, D, w, v, d, F) {
  var e = s - D, E = h - w, u = (F ? d : -d) / q(e * e + E * E), n = u * E, x = -u * e, r = s + n, c = h + x, y = D + n, l = w + x, I = (r + y) / 2, o = (c + l) / 2, g = y - r, f = l - c, T = g * g + f * f, b = v - d, k = r * l - y * c, O = (f < 0 ? -1 : 1) * q(sn(0, b * b * T - k * k)), S = (k * f - g * O) / T, R = (-k * g - f * O) / T, A = (k * f + g * O) / T, p = (-k * g + f * O) / T, m = S - I, a = R - o, t = A - I, L = p - o;
  return m * m + a * a > t * t + L * L && (S = A, R = p), {
    cx: S,
    cy: R,
    x01: -n,
    y01: -x,
    x11: S * (v / b - 1),
    y11: R * (v / b - 1)
  };
}
function hn() {
  var s = yn, h = ln, D = P(0), w = null, v = fn, d = xn, F = gn, e = null, E = un(u);
  function u() {
    var n, x, r = +s.apply(this, arguments), c = +h.apply(this, arguments), y = v.apply(this, arguments) - an, l = d.apply(this, arguments) - an, I = rn(l - y), o = l > y;
    if (e || (e = n = E()), c < r && (x = c, c = r, r = x), !(c > 1e-12)) e.moveTo(0, 0);
    else if (I > cn - 1e-12) e.moveTo(c * Q(y), c * _(y)), e.arc(0, 0, c, y, l, !o), r > 1e-12 && (e.moveTo(r * Q(l), r * _(l)), e.arc(0, 0, r, l, y, o));
    else {
      var g = y, f = l, T = y, b = l, k = I, O = I, S = F.apply(this, arguments) / 2, R = S > 1e-12 && (w ? +w.apply(this, arguments) : q(r * r + c * c)), A = H(rn(c - r) / 2, +D.apply(this, arguments)), p = A, m = A, a, t;
      if (R > 1e-12) {
        var L = tn(R / r * _(S)), J = tn(R / c * _(S));
        (k -= L * 2) > 1e-12 ? (L *= o ? 1 : -1, T += L, b -= L) : (k = 0, T = b = (y + l) / 2), (O -= J * 2) > 1e-12 ? (J *= o ? 1 : -1, g += J, f -= J) : (O = 0, g = f = (y + l) / 2);
      }
      var Z = c * Q(g), j = c * _(g), M = r * Q(b), N = r * _(b);
      if (A > 1e-12) {
        var U = c * Q(f), W = c * _(f), Y = r * Q(T), G = r * _(T), C;
        if (I < en) if (C = pn(Z, j, Y, G, U, W, M, N)) {
          var K = Z - C[0], $ = j - C[1], z = U - C[0], B = W - C[1], V = 1 / _(on((K * z + $ * B) / (q(K * K + $ * $) * q(z * z + B * B))) / 2), nn = q(C[0] * C[0] + C[1] * C[1]);
          p = H(A, (r - nn) / (V - 1)), m = H(A, (c - nn) / (V + 1));
        } else p = m = 0;
      }
      O > 1e-12 ? m > 1e-12 ? (a = X(Y, G, Z, j, c, m, o), t = X(U, W, M, N, c, m, o), e.moveTo(a.cx + a.x01, a.cy + a.y01), m < A ? e.arc(a.cx, a.cy, m, i(a.y01, a.x01), i(t.y01, t.x01), !o) : (e.arc(a.cx, a.cy, m, i(a.y01, a.x01), i(a.y11, a.x11), !o), e.arc(0, 0, c, i(a.cy + a.y11, a.cx + a.x11), i(t.cy + t.y11, t.cx + t.x11), !o), e.arc(t.cx, t.cy, m, i(t.y11, t.x11), i(t.y01, t.x01), !o))) : (e.moveTo(Z, j), e.arc(0, 0, c, g, f, !o)) : e.moveTo(Z, j), !(r > 1e-12) || !(k > 1e-12) ? e.lineTo(M, N) : p > 1e-12 ? (a = X(M, N, U, W, r, -p, o), t = X(Z, j, Y, G, r, -p, o), e.lineTo(a.cx + a.x01, a.cy + a.y01), p < A ? e.arc(a.cx, a.cy, p, i(a.y01, a.x01), i(t.y01, t.x01), !o) : (e.arc(a.cx, a.cy, p, i(a.y01, a.x01), i(a.y11, a.x11), !o), e.arc(0, 0, r, i(a.cy + a.y11, a.cx + a.x11), i(t.cy + t.y11, t.cx + t.x11), o), e.arc(t.cx, t.cy, p, i(t.y11, t.x11), i(t.y01, t.x01), !o))) : e.arc(0, 0, r, b, T, o);
    }
    if (e.closePath(), n) return e = null, n + "" || null;
  }
  return u.centroid = function() {
    var n = (+s.apply(this, arguments) + +h.apply(this, arguments)) / 2, x = (+v.apply(this, arguments) + +d.apply(this, arguments)) / 2 - en / 2;
    return [Q(x) * n, _(x) * n];
  }, u.innerRadius = function(n) {
    return arguments.length ? (s = typeof n == "function" ? n : P(+n), u) : s;
  }, u.outerRadius = function(n) {
    return arguments.length ? (h = typeof n == "function" ? n : P(+n), u) : h;
  }, u.cornerRadius = function(n) {
    return arguments.length ? (D = typeof n == "function" ? n : P(+n), u) : D;
  }, u.padRadius = function(n) {
    return arguments.length ? (w = n == null ? null : typeof n == "function" ? n : P(+n), u) : w;
  }, u.startAngle = function(n) {
    return arguments.length ? (v = typeof n == "function" ? n : P(+n), u) : v;
  }, u.endAngle = function(n) {
    return arguments.length ? (d = typeof n == "function" ? n : P(+n), u) : d;
  }, u.padAngle = function(n) {
    return arguments.length ? (F = typeof n == "function" ? n : P(+n), u) : F;
  }, u.context = function(n) {
    return arguments.length ? (e = n ?? null, u) : e;
  }, u;
}
export {
  hn as x
};
