import { jsx as e, jsxs as M } from "react/jsx-runtime";
import { Legend as C, ResponsiveContainer as O, PieChart as y, Pie as K, Cell as N } from "recharts";
import { isFunction as b } from "es-toolkit/predicate";
import { isObject as P } from "es-toolkit/compat";
import { getColor as L, getFromDefaultColors as k } from "./chartHelper.js";
import { getLegendDefaultProps as B } from "./Legend.js";
import H, { defaultFormatter as T } from "./ChartTooltip.js";
const A = Math.PI / 180, U = (d) => ({ cx: n = 0, cy: m = 0, midAngle: i = 0, innerRadius: a = 0, outerRadius: l = 0, value: r = 0 }) => {
  const o = a + (l - a) * 0.5, s = n + o * Math.cos(-i * A), c = m + o * Math.sin(-i * A);
  return /* @__PURE__ */ e("text", { x: s, y: c, fill: "white", textAnchor: s > n ? "start" : "end", dominantBaseline: "central", children: `${r} ${d}` });
}, S = (d) => {
  const {
    width: n,
    height: m,
    innerRadius: i,
    outerRadius: a,
    data: l = [],
    dataKey: r = "value",
    dataUnit: o = "",
    nameKey: s = "name",
    color: c,
    filled: u = !1,
    labels: $ = !0,
    innerLabels: g = !1,
    paddingAngle: x = 3,
    legend: p = /* @__PURE__ */ e(C, {}),
    tooltip: h = !0,
    pieOptions: D,
    containerOptions: R,
    ...j
  } = d, v = $ && (g ? U(o) : (t) => `${b(r) ? r(t) : t[r]} ${o}`), w = P(h) ? h.props : {}, F = P(p) ? { ...B(), ...p.props } : {};
  return /* @__PURE__ */ e(
    O,
    {
      minHeight: 100,
      minWidth: 100,
      initialDimension: { width: 100, height: 100 },
      ...R,
      children: /* @__PURE__ */ M(y, { width: n, height: m, ...j, children: [
        p && /* @__PURE__ */ e(
          C,
          {
            formatter: (t, f) => /* @__PURE__ */ e("span", { className: "text-color-darker", children: t }),
            ...F
          }
        ),
        /* @__PURE__ */ e(
          K,
          {
            data: l,
            isAnimationActive: !0,
            nameKey: s,
            dataKey: r,
            label: v,
            innerRadius: u ? 0 : i,
            outerRadius: a,
            paddingAngle: u ? 0 : x,
            labelLine: !g,
            ...D,
            children: l.map((t, f) => {
              const I = L(t.color) || k(f);
              return /* @__PURE__ */ e(N, { fill: b(c) ? L(c(t)) : I }, `cell-${f}`);
            })
          }
        ),
        h && /* @__PURE__ */ e(H, { formatter: T(o), ...w })
      ] })
    }
  );
};
export {
  S as default
};
//# sourceMappingURL=PieChart.js.map
