import { jsx as o, jsxs as W } from "react/jsx-runtime";
import { ResponsiveContainer as X, BarChart as Y, CartesianGrid as _, XAxis as $, YAxis as F, Legend as g, Bar as H, Cell as N, Brush as T } from "recharts";
import { isObject as u } from "es-toolkit/compat";
import { mapGridOptions as q, CURSOR_BACKGROUND_COLOR as E, getColor as s, getFromDefaultColors as f } from "./chartHelper.js";
import I from "./ChartTooltip.js";
import { getLegendDefaultProps as J } from "./Legend.js";
import { renderAxis as M } from "./XAxis.js";
import { getBarDefaultProps as Q } from "./Bar.js";
const lo = (C) => {
  const {
    width: V,
    height: Z,
    data: l = [],
    dataUnit: p,
    dataKey: x = "value",
    layout: A = "horizontal",
    legend: r = !1,
    bars: O = [],
    xAxisOptions: y,
    yAxisOptions: B,
    additionalAxes: P = [],
    gridOptions: D,
    containerOptions: w,
    showGrid: v = !1,
    showXAxis: R = !0,
    showYAxis: G = !0,
    useDataColors: L = !1,
    brush: b = !1,
    tooltip: n = !0,
    ...j
  } = C, k = u(n) ? n.props : {}, c = u(r) ? { ...J(), ...r.props } : {}, t = c, h = t?.content, m = {
    layout: t?.layout,
    align: t?.align,
    verticalAlign: t?.verticalAlign,
    width: t?.width,
    height: t?.height
  };
  return /* @__PURE__ */ o(
    X,
    {
      minHeight: 100,
      minWidth: 100,
      initialDimension: { width: 100, height: 100 },
      ...w,
      children: /* @__PURE__ */ W(Y, { layout: A, data: l, ...j, children: [
        v && /* @__PURE__ */ o(_, { strokeDasharray: "3 3", ...q(D) }),
        /* @__PURE__ */ o($, { hide: !R, dataKey: x, ...y }),
        /* @__PURE__ */ o(F, { hide: !G, unit: p, ...B }),
        P.map(M),
        n && /* @__PURE__ */ o(I, { cursor: { fill: E }, ...k }),
        r && h && /* @__PURE__ */ o(
          g,
          {
            ...m,
            content: () => {
              const i = {
                items: t.items,
                iconSize: t?.iconSize ?? 12,
                resolveColor: (a, e) => s(a?.color) || f(e),
                ...m
              };
              return t.content(i);
            }
          }
        ),
        r && !h && // series-based: just forward the formatter to Recharts
        /* @__PURE__ */ o(g, { ...c }),
        O.map((i) => {
          const a = { ...Q(), ...i.props }, { color: e, ...z } = a, S = e && s(e);
          return /* @__PURE__ */ o(H, { unit: p, ...z, fill: S, children: L && l.map((U, d) => {
            const K = s(U.color) || f(d);
            return /* @__PURE__ */ o(N, { fill: K }, `cell-${d}`);
          }) }, i.key);
        }),
        b && /* @__PURE__ */ o(T, { stroke: s("gray") })
      ] })
    }
  );
};
export {
  lo as default
};
//# sourceMappingURL=BarChart.js.map
