import { a_ as rn, a$ as an, b0 as l, aZ as on, b1 as j, b2 as F, b3 as E, b4 as un, aX as D, b5 as cn, b6 as X, b7 as y, b8 as sn, b9 as yn, ba as en } from "./index-BDD0CD9m.js";
function fn(r) {
  return r.innerRadius;
}
function ln(r) {
  return r.outerRadius;
}
function gn(r) {
  return r.startAngle;
}
function pn(r) {
  return r.endAngle;
}
function xn(r) {
  return r && r.padAngle;
}
function mn(r, d, C, P, v, b, H, a) {
  var W = C - r, s = P - d, n = H - v, p = a - b, u = p * W - n * s;
  if (!(u * u < l))
    return u = (n * (d - b) - p * (r - v)) / u, [r + u * W, d + u * s];
}
function N(r, d, C, P, v, b, H) {
  var a = r - C, W = d - P, s = (H ? b : -b) / X(a * a + W * W), n = s * W, p = -s * a, u = r + n, i = d + p, e = C + n, f = P + p, I = (u + e) / 2, o = (i + f) / 2, x = e - u, g = f - i, T = x * x + g * g, A = v - b, O = u * f - e * i, _ = (g < 0 ? -1 : 1) * X(yn(0, A * A * T - O * O)), $ = (O * g - x * _) / T, B = (-O * x - g * _) / T, R = (O * g + x * _) / T, m = (-O * x + g * _) / T, h = $ - I, t = B - o, c = R - I, L = m - o;
  return h * h + t * t > c * c + L * L && ($ = R, B = m), {
    cx: $,
    cy: B,
    x01: -n,
    y01: -p,
    x11: $ * (v / A - 1),
    y11: B * (v / A - 1)
  };
}
function dn() {
  var r = fn, d = ln, C = D(0), P = null, v = gn, b = pn, H = xn, a = null, W = rn(s);
  function s() {
    var n, p, u = +r.apply(this, arguments), i = +d.apply(this, arguments), e = v.apply(this, arguments) - an, f = b.apply(this, arguments) - an, I = un(f - e), o = f > e;
    if (a || (a = n = W()), i < u && (p = i, i = u, u = p), !(i > l)) a.moveTo(0, 0);
    else if (I > on - l)
      a.moveTo(i * j(e), i * F(e)), a.arc(0, 0, i, e, f, !o), u > l && (a.moveTo(u * j(f), u * F(f)), a.arc(0, 0, u, f, e, o));
    else {
      var x = e, g = f, T = e, A = f, O = I, _ = I, $ = H.apply(this, arguments) / 2, B = $ > l && (P ? +P.apply(this, arguments) : X(u * u + i * i)), R = E(un(i - u) / 2, +C.apply(this, arguments)), m = R, h = R, t, c;
      if (B > l) {
        var L = sn(B / u * F($)), Z = sn(B / i * F($));
        (O -= L * 2) > l ? (L *= o ? 1 : -1, T += L, A -= L) : (O = 0, T = A = (e + f) / 2), (_ -= Z * 2) > l ? (Z *= o ? 1 : -1, x += Z, g -= Z) : (_ = 0, x = g = (e + f) / 2);
      }
      var z = i * j(x), S = i * F(x), k = u * j(A), G = u * F(A);
      if (R > l) {
        var Y = i * j(g), M = i * F(g), Q = u * j(T), U = u * F(T), q;
        if (I < cn)
          if (q = mn(z, S, Q, U, Y, M, k, G)) {
            var V = z - q[0], w = S - q[1], J = Y - q[0], K = M - q[1], nn = 1 / F(en((V * J + w * K) / (X(V * V + w * w) * X(J * J + K * K))) / 2), tn = X(q[0] * q[0] + q[1] * q[1]);
            m = E(R, (u - tn) / (nn - 1)), h = E(R, (i - tn) / (nn + 1));
          } else
            m = h = 0;
      }
      _ > l ? h > l ? (t = N(Q, U, z, S, i, h, o), c = N(Y, M, k, G, i, h, o), a.moveTo(t.cx + t.x01, t.cy + t.y01), h < R ? a.arc(t.cx, t.cy, h, y(t.y01, t.x01), y(c.y01, c.x01), !o) : (a.arc(t.cx, t.cy, h, y(t.y01, t.x01), y(t.y11, t.x11), !o), a.arc(0, 0, i, y(t.cy + t.y11, t.cx + t.x11), y(c.cy + c.y11, c.cx + c.x11), !o), a.arc(c.cx, c.cy, h, y(c.y11, c.x11), y(c.y01, c.x01), !o))) : (a.moveTo(z, S), a.arc(0, 0, i, x, g, !o)) : a.moveTo(z, S), !(u > l) || !(O > l) ? a.lineTo(k, G) : m > l ? (t = N(k, G, Y, M, u, -m, o), c = N(z, S, Q, U, u, -m, o), a.lineTo(t.cx + t.x01, t.cy + t.y01), m < R ? a.arc(t.cx, t.cy, m, y(t.y01, t.x01), y(c.y01, c.x01), !o) : (a.arc(t.cx, t.cy, m, y(t.y01, t.x01), y(t.y11, t.x11), !o), a.arc(0, 0, u, y(t.cy + t.y11, t.cx + t.x11), y(c.cy + c.y11, c.cx + c.x11), o), a.arc(c.cx, c.cy, m, y(c.y11, c.x11), y(c.y01, c.x01), !o))) : a.arc(0, 0, u, A, T, o);
    }
    if (a.closePath(), n) return a = null, n + "" || null;
  }
  return s.centroid = function() {
    var n = (+r.apply(this, arguments) + +d.apply(this, arguments)) / 2, p = (+v.apply(this, arguments) + +b.apply(this, arguments)) / 2 - cn / 2;
    return [j(p) * n, F(p) * n];
  }, s.innerRadius = function(n) {
    return arguments.length ? (r = typeof n == "function" ? n : D(+n), s) : r;
  }, s.outerRadius = function(n) {
    return arguments.length ? (d = typeof n == "function" ? n : D(+n), s) : d;
  }, s.cornerRadius = function(n) {
    return arguments.length ? (C = typeof n == "function" ? n : D(+n), s) : C;
  }, s.padRadius = function(n) {
    return arguments.length ? (P = n == null ? null : typeof n == "function" ? n : D(+n), s) : P;
  }, s.startAngle = function(n) {
    return arguments.length ? (v = typeof n == "function" ? n : D(+n), s) : v;
  }, s.endAngle = function(n) {
    return arguments.length ? (b = typeof n == "function" ? n : D(+n), s) : b;
  }, s.padAngle = function(n) {
    return arguments.length ? (H = typeof n == "function" ? n : D(+n), s) : H;
  }, s.context = function(n) {
    return arguments.length ? (a = n ?? null, s) : a;
  }, s;
}
export {
  dn as h
};
