ranui
Version:
A framework-agnostic Web Components UI library built on native custom elements, with TypeScript types, light/dark theming, SSR and PWA support.
83 lines (82 loc) • 4.93 kB
JavaScript
import { n as z, t as sn } from "./path-Bja5PoYn.js";
import { a as o, c as en, d as un, f as w, i as an, l as ln, m as tn, n as rn, o as G, p as K, r as on, u as b } from "./dist-C0Fwsvsq.js";
function fn(l) {
return l.innerRadius;
}
function cn(l) {
return l.outerRadius;
}
function yn(l) {
return l.startAngle;
}
function gn(l) {
return l.endAngle;
}
function mn(l) {
return l && l.padAngle;
}
function pn(l, x, E, q, h, v, B, u) {
var I = E - l, i = q - x, n = B - h, g = u - v, a = g * I - n * i;
if (!(a * a < 1e-12))
return a = (n * (x - v) - g * (l - h)) / a, [l + a * I, x + a * i];
}
function V(l, x, E, q, h, v, B) {
var u = l - E, I = x - q, i = (B ? v : -v) / K(u * u + I * I), n = i * I, g = -i * u, a = l + n, s = x + g, f = E + n, c = q + g, C = (a + f) / 2, t = (s + c) / 2, m = f - a, y = c - s, A = m * m + y * y, R = h - v, T = a * c - f * s, O = (y < 0 ? -1 : 1) * K(ln(0, R * R * A - T * T)), S = (T * y - m * O) / A, j = (-T * m - y * O) / A, P = (T * y + m * O) / A, p = (-T * m + y * O) / A, d = S - C, e = j - t, r = P - C, F = p - t;
return d * d + e * e > r * r + F * F && (S = P, j = p), {
cx: S,
cy: j,
x01: -n,
y01: -g,
x11: S * (h / R - 1),
y11: j * (h / R - 1)
};
}
function vn() {
var l = fn, x = cn, E = z(0), q = null, h = yn, v = gn, B = mn, u = null, I = sn(i);
function i() {
var n, g, a = +l.apply(this, arguments), s = +x.apply(this, arguments), f = h.apply(this, arguments) - en, c = v.apply(this, arguments) - en, C = rn(c - f), t = c > f;
if (u || (u = n = I()), s < a && (g = s, s = a, a = g), !(s > 1e-12)) u.moveTo(0, 0);
else if (C > tn - 1e-12)
u.moveTo(s * G(f), s * w(f)), u.arc(0, 0, s, f, c, !t), a > 1e-12 && (u.moveTo(a * G(c), a * w(c)), u.arc(0, 0, a, c, f, t));
else {
var m = f, y = c, A = f, R = c, T = C, O = C, S = B.apply(this, arguments) / 2, j = S > 1e-12 && (q ? +q.apply(this, arguments) : K(a * a + s * s)), P = b(rn(s - a) / 2, +E.apply(this, arguments)), p = P, d = P, e, r;
if (j > 1e-12) {
var F = an(j / a * w(S)), L = an(j / s * w(S));
(T -= F * 2) > 1e-12 ? (F *= t ? 1 : -1, A += F, R -= F) : (T = 0, A = R = (f + c) / 2), (O -= L * 2) > 1e-12 ? (L *= t ? 1 : -1, m += L, y -= L) : (O = 0, m = y = (f + c) / 2);
}
var H = s * G(m), J = s * w(m), M = a * G(R), N = a * w(R);
if (P > 1e-12) {
var Q = s * G(y), U = s * w(y), W = a * G(A), X = a * w(A), D;
if (C < un) if (D = pn(H, J, W, X, Q, U, M, N)) {
var Y = H - D[0], Z = J - D[1], $ = Q - D[0], k = U - D[1], _ = 1 / w(on((Y * $ + Z * k) / (K(Y * Y + Z * Z) * K($ * $ + k * k))) / 2), nn = K(D[0] * D[0] + D[1] * D[1]);
p = b(P, (a - nn) / (_ - 1)), d = b(P, (s - nn) / (_ + 1));
} else p = d = 0;
}
O > 1e-12 ? d > 1e-12 ? (e = V(W, X, H, J, s, d, t), r = V(Q, U, M, N, s, d, t), u.moveTo(e.cx + e.x01, e.cy + e.y01), d < P ? u.arc(e.cx, e.cy, d, o(e.y01, e.x01), o(r.y01, r.x01), !t) : (u.arc(e.cx, e.cy, d, o(e.y01, e.x01), o(e.y11, e.x11), !t), u.arc(0, 0, s, o(e.cy + e.y11, e.cx + e.x11), o(r.cy + r.y11, r.cx + r.x11), !t), u.arc(r.cx, r.cy, d, o(r.y11, r.x11), o(r.y01, r.x01), !t))) : (u.moveTo(H, J), u.arc(0, 0, s, m, y, !t)) : u.moveTo(H, J), !(a > 1e-12) || !(T > 1e-12) ? u.lineTo(M, N) : p > 1e-12 ? (e = V(M, N, Q, U, a, -p, t), r = V(H, J, W, X, a, -p, t), u.lineTo(e.cx + e.x01, e.cy + e.y01), p < P ? u.arc(e.cx, e.cy, p, o(e.y01, e.x01), o(r.y01, r.x01), !t) : (u.arc(e.cx, e.cy, p, o(e.y01, e.x01), o(e.y11, e.x11), !t), u.arc(0, 0, a, o(e.cy + e.y11, e.cx + e.x11), o(r.cy + r.y11, r.cx + r.x11), t), u.arc(r.cx, r.cy, p, o(r.y11, r.x11), o(r.y01, r.x01), !t))) : u.arc(0, 0, a, R, A, t);
}
if (u.closePath(), n) return u = null, n + "" || null;
}
return i.centroid = function() {
var n = (+l.apply(this, arguments) + +x.apply(this, arguments)) / 2, g = (+h.apply(this, arguments) + +v.apply(this, arguments)) / 2 - un / 2;
return [G(g) * n, w(g) * n];
}, i.innerRadius = function(n) {
return arguments.length ? (l = typeof n == "function" ? n : z(+n), i) : l;
}, i.outerRadius = function(n) {
return arguments.length ? (x = typeof n == "function" ? n : z(+n), i) : x;
}, i.cornerRadius = function(n) {
return arguments.length ? (E = typeof n == "function" ? n : z(+n), i) : E;
}, i.padRadius = function(n) {
return arguments.length ? (q = n == null ? null : typeof n == "function" ? n : z(+n), i) : q;
}, i.startAngle = function(n) {
return arguments.length ? (h = typeof n == "function" ? n : z(+n), i) : h;
}, i.endAngle = function(n) {
return arguments.length ? (v = typeof n == "function" ? n : z(+n), i) : v;
}, i.padAngle = function(n) {
return arguments.length ? (B = typeof n == "function" ? n : z(+n), i) : B;
}, i.context = function(n) {
return arguments.length ? (u = n ?? null, i) : u;
}, i;
}
export {
vn as t
};