import { jsx as r, jsxs as x, Fragment as pe } from "react/jsx-runtime";
import { useState as B, useEffect as ge, Fragment as je } from "react";
import Ht from "./Tooltip.js";
import { ResponsiveBar as Tt } from "@nivo/bar";
import { injectIntl as At } from "react-intl";
import { useTheme as _t } from "@nivo/theming";
import { line as Re } from "d3-shape";
import Ye from "./LineLayer.js";
import be from "papaparse";
import St from "../../layout/FlexWrapDetector.js";
import ve from "../../utils/deviceType.js";
const jt = "middle", Rt = "top", W = "#66676d", Ke = "#dddddd", Yt = "none", Q = "_Color", Kt = ({
  editing: y,
  legends: X,
  marginLeft: Pe,
  marginTop: j,
  marginRight: Xe,
  marginBottom: R,
  options: u,
  intl: b,
  format: g,
  colors: H,
  groupMode: O,
  height: Ce,
  showLegends: G,
  legendPosition: v,
  tickRotation: z,
  offsetText: ee,
  tickColor: te,
  layout: o,
  reverse: T,
  offsetY: qe,
  csvLineLayerData: Ne,
  tooltip: ae,
  lineLayerEnabled: ne,
  overlays: A,
  maxValue: le,
  valueScale: Ze,
  colorGenerator: N,
  legendLabel: Ie,
  overrideTickColor: Je,
  fixedMinValue: re,
  fixedMaxValue: se,
  barPadding: Ue,
  barLabelPosition: ke,
  barInnerPadding: Qe,
  tooltipEnabled: Ge,
  xLabelColor: D,
  barLabelColor: C,
  legendCheckBack: k,
  legendLabelBack: ie,
  legendLabelColor: ce,
  highlightXAxisLine: et,
  showTickLine: Y,
  showRightAxis: tt,
  offsetRight: at,
  offsetBottom: Le,
  confidenceIntervals: de,
  showGroupTotal: nt,
  groupTotalLabel: we,
  groupTotalFormat: De,
  groupTotalMeasure: Fe,
  groupTotalOffset: E,
  groupTotalFixedPosition: q,
  tooltipEnableMarkdown: lt,
  xAxisTickValues: rt,
  yAxisTickValues: st,
  mobileCustomization: it,
  minMaxClamp: Pt,
  reverseLegend: ct,
  enableGridY: dt,
  enableGridX: ht,
  customAxisFormat: F,
  previewMode: $,
  showLegendsInColumns: Xt = !1,
  numberOfLegendColumns: Ct = 4
}) => {
  var Se;
  const Me = ["mobile", "tablet", "midTablet"].includes(
    ve()
  ), Z = ["tablet", "midTablet"].includes(ve()), J = ve() === "mobile", he = 30, me = 15, m = JSON.parse(
    decodeURIComponent(it)
  ), Oe = Me && ((m == null ? void 0 : m.showCustomization) ?? !1), _ = Oe && $ !== "Desktop", S = !y && Oe, ue = () => C === "null" || C === null || !C ? "#000000" : C, [L, mt] = B([]), { colorBy: K } = H, ze = {};
  A.forEach((e, t) => {
    ze[t] = !0;
  });
  const [I, ut] = B(ze), [Ee, ft] = B(50), [qt, $e] = B(j), [Zt, Ve] = B(0), [Be, We] = B(R), [He, ot] = B(!1);
  ge(() => {
    let e, t;
    return e = requestAnimationFrame(() => {
      e = requestAnimationFrame(() => {
        t = setTimeout(() => {
          ot(!0);
        }, 50);
      });
    }), () => {
      cancelAnimationFrame(e), clearTimeout(t);
    };
  }, []);
  const P = ((e, t, s, i, a) => {
    let c = [];
    return e.data && (c = t.colorBy === "index" ? e.data.map((l) => {
      let n, d = !0;
      return s.indexOf(l[e.indexBy]) > -1 ? (d = !1, n = i) : n = l[Q] ? l[Q] : a.getColor(l.id, l), {
        enabled: d,
        color: n,
        id: l[e.indexBy],
        label: l[e.indexBy]
      };
    }) : e.keys.map((l) => {
      let n, d = !0;
      return s.indexOf(l) > -1 ? (d = !1, n = i) : n = a.getColorByKey(l), {
        enabled: d,
        color: n,
        id: l,
        label: l
      };
    })), c;
  })(
    u,
    H,
    L,
    Yt,
    N
  ), Te = () => (ct && P.reverse(), /* @__PURE__ */ x(pe, { children: [
    G && P.map((e) => /* @__PURE__ */ x(
      "div",
      {
        className: `legend item ${e.enabled ? "" : "ignore"}`,
        onClick: () => Lt(e.id),
        children: [
          k && /* @__PURE__ */ r(
            "input",
            {
              className: e.enabled ? "" : "ignore",
              type: "checkbox",
              checked: e.enabled,
              style: {
                backgroundColor: k ? K === "values" ? te : e.color : "none",
                color: "#000"
              }
            }
          ),
          !k && /* @__PURE__ */ r(
            "input",
            {
              type: "checkbox",
              checked: e.enabled,
              style: {
                color: "#000"
              }
            }
          ),
          k && /* @__PURE__ */ r(
            "span",
            {
              className: "checkmark-with-bg",
              style: { backgroundColor: e.color }
            }
          ),
          !k && /* @__PURE__ */ r("span", { className: "checkmark" }),
          ie && /* @__PURE__ */ r(
            "label",
            {
              className: e.enabled ? "" : "ignore",
              style: {
                backgroundColor: K === "values" ? te : e.color,
                color: ce
              },
              children: e.label
            }
          ),
          !ie && /* @__PURE__ */ r(
            "label",
            {
              className: e.enabled ? "" : "ignore",
              style: {
                color: ce
              },
              children: e.label
            }
          )
        ]
      }
    )),
    K === "values" && /* @__PURE__ */ x("div", { className: "legend item", children: [
      /* @__PURE__ */ r(
        "label",
        {
          className: "range min",
          style: {
            backgroundColor: N.getColorByValue(
              N.minValue
            ),
            color: "#fff"
          }
        }
      ),
      /* @__PURE__ */ r("label", { children: b.formatNumber(
        g.style === "percent" ? N.minValue / 100 : N.minValue,
        {
          ...g,
          minimumFractionDigits: 0
        }
      ) })
    ] }),
    K === "values" && /* @__PURE__ */ x("div", { className: "legend item", children: [
      /* @__PURE__ */ r(
        "label",
        {
          className: "range max",
          style: {
            backgroundColor: N.getColorByValue(
              N.maxValue
            ),
            color: "#fff"
          },
          children: " "
        }
      ),
      /* @__PURE__ */ r("label", { children: b.formatNumber(
        g.style === "percent" ? N.maxValue / 100 : N.maxValue,
        {
          ...g,
          minimumFractionDigits: 0
        }
      ) })
    ] }),
    G && ne && A.map((e, t) => /* @__PURE__ */ x("div", { className: "legend item", onClick: () => wt(t), children: [
      /* @__PURE__ */ r(
        "input",
        {
          className: k && I[t] ? "" : "ignore",
          type: "checkbox",
          checked: I[t],
          style: {
            backgroundColor: I[t] && k === !0 ? e.lineColor : "none",
            color: "#000"
          }
        }
      ),
      /* @__PURE__ */ r(
        "span",
        {
          className: k ? "checkmark-with-bg" : "checkmark",
          style: {
            backgroundColor: I[t] && k === !0 ? e.lineColor : "none"
          }
        }
      ),
      /* @__PURE__ */ r(
        "label",
        {
          className: I[t] ? "" : "ignore",
          style: {
            backgroundColor: I[t] && ie === !0 ? e.lineColor : "none",
            color: ce
          },
          children: e.title
        }
      )
    ] }))
  ] }));
  ge(() => {
    (() => {
      const s = 5 * Math.max(P.length - 5, 0);
      ft(s);
    })();
  }, [P]), ge(() => {
    $e(j), We(R);
  }, [v, j, R]);
  const yt = {
    bottom: `-${Ee}px`
  }, xt = {
    bottom: `-${Ee}px`,
    gap: "0px"
    // top: "0px",
  }, pt = (e) => fe(e, "1 0", Ke, "Y"), gt = (e) => fe(e, "4 4", W, "X"), bt = (e) => fe(e, "1 0", Ke, "X"), vt = (e) => {
    const t = P.find((s) => s.id === e.value);
    return t ? t.color : "#FFFFFF";
  }, Nt = (e) => {
    const { yScale: t, xScale: s, bars: i } = e;
    return /* @__PURE__ */ r(je, { children: i.filter((a) => a.data.value != null).map((a) => {
      let c = a.data.indexValue;
      u.dimensionsMetadata && u.dimensionsMetadata.size > 1 && (c = a.data.id);
      const l = de.filter(
        (n) => n.serieLabel == c
      )[0];
      if (l && l.low && l.high)
        if (o === "horizontal") {
          const n = s(parseFloat(l.low)), d = s(parseFloat(l.high));
          return /* @__PURE__ */ x("g", { children: [
            /* @__PURE__ */ r(
              "line",
              {
                x1: n,
                x2: d,
                y1: a.y + a.height / 2,
                y2: a.y + a.height / 2,
                strokeWidth: 1,
                stroke: W
              }
            ),
            /* @__PURE__ */ r(
              "line",
              {
                x1: n,
                x2: n,
                y1: a.y + a.height / 2 - 3,
                y2: a.y + a.height / 2 + 3,
                strokeWidth: 1,
                stroke: W
              }
            ),
            /* @__PURE__ */ r(
              "line",
              {
                x1: d,
                x2: d,
                y1: a.y + a.height / 2 - 3,
                y2: a.y + a.height / 2 + 3,
                strokeWidth: 1,
                stroke: W
              }
            )
          ] });
        } else {
          const n = t(parseFloat(l.low)), d = t(parseFloat(l.high));
          return /* @__PURE__ */ x("g", { children: [
            /* @__PURE__ */ r(
              "line",
              {
                y1: n,
                y2: d,
                x1: a.x + a.width / 2,
                x2: a.x + a.width / 2,
                strokeWidth: 1,
                stroke: W
              }
            ),
            /* @__PURE__ */ r(
              "line",
              {
                y1: n,
                y2: n,
                x1: a.x + a.width / 2 - 3,
                x2: a.x + a.width / 2 + 3,
                strokeWidth: 1,
                stroke: W
              }
            ),
            /* @__PURE__ */ r(
              "line",
              {
                y1: d,
                y2: d,
                x1: a.x + a.width / 2 - 3,
                x2: a.x + a.width / 2 + 3,
                strokeWidth: 1,
                stroke: W
              }
            )
          ] });
        }
    }) });
  }, fe = (e, t, s, i) => {
    const { yScale: a, innerWidth: c, innerHeight: l } = e;
    let n, d;
    return i == "X" ? (n = [0, c], d = Re().x((f, V) => V === 0 ? -10 : f).y(() => a(0))) : (n = [0, l], d = Re().x(() => 0).y((f) => f)), /* @__PURE__ */ r(je, { children: /* @__PURE__ */ r(
      "path",
      {
        d: d(n),
        fill: "none",
        stroke: s,
        style: { pointerEvents: "none", strokeDasharray: t }
      }
    ) });
  }, M = (e, t) => L ? (H.colorBy === "index" || H.colorBy === "id" || H.colorBy === "values") && !t ? e.filter((s) => L.indexOf(s[u.indexBy]) === -1) : e ? e.filter((s) => L.indexOf(s) === -1) : [] : e, It = (e) => {
    const t = _t();
    if (!e.value) return "";
    const s = Object.assign({}, e);
    (S || _) && xe.includes(String(s.value)) && (s.value = "");
    let i;
    Je ? i = te : i = vt(e);
    let a = [], c = "";
    if (_ || S) {
      const n = String(s.value).split(" ");
      let d = 25;
      y && $ === "Mobile" || J && !y ? d = (m == null ? void 0 : m.mobileMaxTickLength) ?? 25 : y && $ === "Tablet" || Z && !y ? d = (m == null ? void 0 : m.tabletMaxTickLength) ?? 25 : window.matchMedia("(min-width: 768px) and (max-width: 1250px)").matches && !y && (d = 15), n.forEach((f) => {
        c.length + String(f).length <= d ? c += (c ? " " : "") + f : (a.push(c), c = f);
      }), c && a.push(c);
    } else
      a = [s.value];
    let l = 12;
    return J ? l = (m == null ? void 0 : m.mobileYAxisLineHeight) ?? 12 : Z && (l = (m == null ? void 0 : m.tabletYAxisLineHeight) ?? 12), z > 0 && z < 180 ? /* @__PURE__ */ x("g", { transform: `translate(${e.x},${e.y + 30})`, children: [
      Y && /* @__PURE__ */ r(
        "line",
        {
          stroke: i,
          strokeWidth: 1.5,
          y1: -32,
          y2: -12
        }
      ),
      /* @__PURE__ */ r("g", { transform: `translate(0, ${e.y + ee})`, children: a.map((n, d) => /* @__PURE__ */ r(
        "text",
        {
          transform: `rotate(${z})`,
          textAnchor: "start",
          y: typeof e.value == "number" ? 0 : d * l,
          dominantBaseline: "middle",
          style: {
            ...t.axis.ticks.text,
            fill: D === "null" ? "black" : D,
            fontSize: "12px",
            fontFamily: "sans-serif"
          },
          children: n
        },
        n
      )) })
    ] }) : z > 180 && z < 360 ? /* @__PURE__ */ x("g", { transform: `translate(${e.x},${e.y + 30})`, children: [
      Y && /* @__PURE__ */ r(
        "line",
        {
          stroke: i,
          strokeWidth: 1.5,
          y1: -32,
          y2: -12
        }
      ),
      /* @__PURE__ */ r("g", { transform: `translate(0, ${e.y + ee})`, children: a.map((n, d) => /* @__PURE__ */ r(
        "text",
        {
          transform: `rotate(${z})`,
          textAnchor: "end",
          y: typeof e.value == "number" ? 0 : d * l,
          dominantBaseline: "middle",
          style: {
            ...t.axis.ticks.text,
            fill: D === "null" ? "black" : D,
            fontSize: "12px",
            fontFamily: "sans-serif"
          },
          children: n
        },
        d
      )) })
    ] }) : /* @__PURE__ */ x("g", { transform: `translate(${e.x},${e.y + 30})`, children: [
      Y && /* @__PURE__ */ r(
        "line",
        {
          stroke: i,
          strokeWidth: 1.5,
          y1: -32,
          y2: -12
        }
      ),
      /* @__PURE__ */ r("g", { transform: `translate(0, ${e.y + ee})`, children: a.map((n, d) => /* @__PURE__ */ r(
        "text",
        {
          transform: `rotate(${z})`,
          textAnchor: "middle",
          y: typeof e.value == "number" ? 0 : d * l,
          dominantBaseline: "middle",
          style: {
            ...t.axis.ticks.text,
            fill: D === "null" ? "black" : D,
            fontSize: "12px",
            fontFamily: "sans-serif"
          },
          children: n
        },
        d
      )) })
    ] });
  }, kt = (e) => {
    if (!e.value || (_ || S) && xe.includes(String(e.value)))
      return "";
    let t = e.value;
    if (o === "vertical") {
      const n = F || g;
      t = b.formatNumber(
        n.style === "percent" ? t / 100 : t,
        {
          ...n
        }
      );
    }
    let s = 25;
    y && $ === "Mobile" || J && !y ? s = (m == null ? void 0 : m.mobileMaxTickLength) ?? 25 : y && $ === "Tablet" || Z && !y ? s = (m == null ? void 0 : m.tabletMaxTickLength) ?? 25 : window.matchMedia("(min-width: 768px) and (max-width: 1250px)").matches && !y && (s = 15);
    const i = typeof t == "string" ? t.split(" ") : [t], a = [];
    let c = "";
    i.forEach((n) => {
      c.length + String(n).length <= s ? c += (c ? " " : "") + n : (a.push(c), c = n);
    }), c && a.push(c);
    let l = 12;
    return y && $ === "Mobile" || J && !y ? l = (m == null ? void 0 : m.mobileYAxisLineHeight) ?? 12 : (y && $ === "Tablet" || Z && !y) && (l = (m == null ? void 0 : m.tabletYAxisLineHeight) ?? 12), /* @__PURE__ */ x("g", { transform: `translate(${e.x},${e.y})`, children: [
      /* @__PURE__ */ r("line", { x1: -5, x2: 0, y1: 0, y2: 0, stroke: "#000", strokeWidth: 1 }),
      a.map((n, d) => /* @__PURE__ */ r(
        "text",
        {
          x: -10,
          y: typeof t == "number" ? 0 : d * l,
          textAnchor: "end",
          dominantBaseline: "middle",
          style: {
            fill: D === "null" ? "black" : D,
            fontSize: "12px",
            fontFamily: "sans-serif"
          },
          children: n
        },
        n
      ))
    ] });
  }, Lt = (e) => {
    const t = L.slice();
    if (t.indexOf(e) > -1) {
      const s = t.indexOf(e);
      t.splice(s, 1);
    } else
      t.push(e);
    mt(t);
  }, wt = (e) => {
    const t = Object.assign({}, I);
    t[e] = !t[e], ut(t);
  }, Dt = ({ bars: e }) => /* @__PURE__ */ r("g", { children: e.map((t) => {
    const { width: s, height: i, y: a, x: c, data: l } = t;
    if (o === "horizontal" && i <= me || o === "vertical" && s <= he)
      return;
    const n = l.value ? b.formatNumber(
      g.style === "percent" ? l.value / 100 : l.value,
      g
    ) : "", d = n.length;
    let f, V;
    if (o === "vertical" && s >= he || o === "horizontal" && i >= me)
      return o === "vertical" ? (f = a - 6, V = c + s / 2 - d * 3.5) : (f = a + i / 2 + 4, V = c + s + 5), /* @__PURE__ */ r(
        "text",
        {
          y: f,
          x: V,
          style: { fill: ue() },
          children: `${n}`
        }
      );
  }) }), Ft = (e) => {
    const t = u.data.filter((i) => L.indexOf(i[u.indexBy]) == -1).map((i) => i[u.indexBy]), { bars: s } = e;
    return /* @__PURE__ */ r("g", { children: t.filter(
      (i) => s.filter((a) => a.data.indexValue == i).length > 0
    ).map((i) => {
      var U;
      const a = s.filter((h) => h.data.indexValue == i);
      let c = "right", l = 0, n = 0;
      if (o == "horizontal")
        O === "stacked" ? (q ? l = e.innerWidth - 20 : (l = a.map((h) => h.width).reduce((h, p) => h + p), T && (l = e.innerWidth - l)), n = e.yScale(i) + a[0].height / 2) : (q ? l = e.innerWidth : (l = a.map((h) => h.width).reduce((h, p) => h > p ? h : p), T && (l = e.innerWidth - l)), n = e.yScale(i) + a.map((h) => h.height).reduce((h, p) => h + p) / 2), l = l + parseInt(E) + 5;
      else if (c = "middle", O === "stacked")
        l = e.xScale(i) + a[0].width / 2, q ? n = n - parseInt(E) : T ? n = parseInt(E) + a.map((h) => h.height).reduce((h, p) => h + p) + 14 : n = e.innerHeight - parseInt(E) - a.map((h) => h.height).reduce((h, p) => h + p) - 5;
      else if (l = e.xScale(i) + a.map((h) => h.width).reduce((h, p) => h + p) / 2, T && (n = e.innerHeight), q)
        n = n - parseInt(E);
      else {
        if (a.length % 2 == 1) {
          const h = Math.floor(a.length / 2);
          n = a[h].height;
        } else {
          const h = a.length / 2;
          n = Math.max(
            a[h].height,
            a[h - 1].height
          );
        }
        T ? n = n + 14 + parseInt(E) : n = e.innerHeight - n - parseInt(E) - 5;
      }
      const d = u.data.filter(
        (h) => h[u.indexBy] === i
      )[0];
      let f = d.parent_variables ? d.parent_variables[Fe] : d[Fe];
      const V = K !== "index" ? (U = L == null ? void 0 : L.map((h) => d[h])) == null ? void 0 : U.reduce((h, p) => h + p, 0) : 0;
      return f -= V, /* @__PURE__ */ r("text", { y: n, x: l, style: { fill: ue() }, children: /* @__PURE__ */ x("tspan", { textAnchor: c, children: [
        we ? we + " " : "",
        b.formatNumber(
          De.style === "percent" ? f / 100 : f,
          De
        )
      ] }) });
    }) });
  }, Mt = {
    top: j,
    right: Xe,
    bottom: R,
    left: Pe
  };
  let oe;
  Ne && (oe = be.parse(Ne, {
    header: !1,
    dynamicTyping: !0
  }), Math.max(...oe.data.map((e) => e[1])), Math.min(...oe.data.map((e) => e[1])));
  const Ae = () => {
    const e = [];
    if (de && de.forEach((t) => {
      t.low && e.push(parseFloat(t.low)), t.high && e.push(parseFloat(t.high));
    }), u.data) {
      const t = M(u.data, !1), s = M(u.keys, !0);
      t.forEach((i) => {
        s.forEach((a) => {
          i[a] && e.push(i[a]);
        });
      });
    }
    return ne && A && A.forEach((t, s) => {
      if (I[s] !== !1)
        if (t.app === "csv" && t.csvLineLayerData) {
          const i = be.parse(t.csvLineLayerData, {
            header: !1,
            dynamicTyping: !0
          });
          i.data && i.data.filter((a) => a[1] !== null && typeof a[1] == "number").forEach((a) => e.push(a[1]));
        } else t.measure[0] && u.data && u.data.forEach((i) => {
          var c;
          const a = (c = i.variables) == null ? void 0 : c[t.measure[0]];
          a !== null && typeof a == "number" && e.push(a);
        });
    }), e;
  }, Ot = () => {
    const e = Ae(), t = e.length > 0 ? Math.max(...e) : 0;
    if (le === "fixed" && se !== null && se !== "")
      return Number(se);
    if (O === "stacked" && le !== "fixed") {
      const s = M(u.data, !1), i = M(u.keys, !0);
      let a = i.length > 0 ? i : u.keys;
      const c = Math.max(
        ...s.map((l) => a.map((n) => l[n] ? l[n] : 0)).map((l) => l.length > 0 ? l.reduce((n, d) => n + d, 0) : 0)
      );
      return Math.max(c, t) * 1.1;
    }
    return t * 1.05;
  }, zt = () => {
    const e = Ae(), t = e.length > 0 ? Math.min(...e) : 0;
    return le === "fixed" && re !== null && String(re) !== "" ? Number(re) : t > 0 ? t * 0.9 : t * 1.1;
  }, Et = Number(Ot()), $t = Number(zt()), Vt = Math.min(0, $t), Bt = Math.max(0, Et), w = ["grid", "axes", "bars"];
  nt && w.push(Ft), w.push(pt), w.push(bt), ne && A && A.forEach((e, t) => {
    if (I[t] == !0 || I[t] == null) {
      const { csvLineLayerData: s, lineColor: i, tooltip: a } = e;
      if (e.app == "csv") {
        const c = be.parse(s, {
          header: !1,
          dynamicTyping: !0
        });
        if (c.data && c.data.filter((l) => l[1] !== null).length > 0) {
          c.data = c.data.filter(
            (n) => n[1] !== null
          );
          const l = Ye(
            c,
            i,
            o,
            O,
            M(u.keys, !0),
            a,
            e.title,
            ""
          );
          w.push(l);
        }
      } else if (e.measure[0]) {
        const c = {}, l = u.data.map((f) => [
          f[u.indexBy],
          f.variables[e.measure[0]]
        ]), n = u.metadata.measures ? u.metadata.measures.filter((f) => f.value == e.measure[0]) : [];
        c.data = l;
        const d = Ye(
          c,
          i,
          o,
          O,
          M(u.keys, !0),
          a,
          e.title,
          n.length > 0 ? n[0].label : ""
        );
        w.push(d);
      }
    }
  }), ke === Rt && w.push(Dt), et && w.push(gt), w.push(Nt);
  let ye = parseInt(st);
  const _e = () => /* @__PURE__ */ r(pe, { children: G && Ie && /* @__PURE__ */ r("div", { className: "legend item", children: /* @__PURE__ */ r("label", { className: "legend-title", children: Ie }) }) }), xe = [];
  if (S || _) {
    ye = Number.parseInt(m.yAxisTickValues);
    const e = new Map(
      Object.entries(((Se = m == null ? void 0 : m.labels) == null ? void 0 : Se.xAxis) ?? {})
    );
    for (const [t, s] of e)
      s || xe.push(t);
  }
  let Wt = parseInt(Ce + "") - Be;
  return /* @__PURE__ */ r("div", { style: { height: Wt + "px" }, className: "bar-chart", children: (u == null ? void 0 : u.data) && u.data.length > 0 && /* @__PURE__ */ x(pe, { children: [
    /* @__PURE__ */ r(
      Tt,
      {
        colorBy: H.colorBy,
        animate: !0,
        enableLabel: ke == jt,
        ...u,
        maxValue: Bt,
        minValue: Vt,
        keys: M(u.keys, !0),
        data: M(u.data, !1),
        groupMode: O || "grouped",
        margin: Mt,
        innerPadding: Qe,
        valueScale: { type: Ze, clamp: !0 },
        colors: (e) => e && e.data[Q] ? e.data[Q] : N.getColor(e.id, e.data),
        borderColor: "#000",
        reverse: T,
        axisTop: null,
        axisRight: tt ? {
          tickSize: o == "horizontal" && Y || o === "vertical" ? 5 : 0,
          tickPadding: 5,
          tickRotation: 0,
          tickValues: ye,
          legend: X.right,
          legendPosition: "middle",
          legendOffset: parseInt(at),
          format: (e) => {
            if (!e) return "";
            if (o == "vertical") {
              const t = F || g;
              return b.formatNumber(
                t.style === "percent" ? e / 100 : e,
                {
                  ...t
                }
              );
            }
            return e;
          }
        } : null,
        axisBottom: (_ || S) && (m == null ? void 0 : m.xAxisDisabled) === !0 ? null : o === "horizontal" ? {
          legend: X.bottom,
          legendPosition: "middle",
          legendOffset: parseInt(Le),
          tickPadding: 5,
          tickRotation: 0,
          tickValues: parseInt(rt),
          format: (e) => {
            if (!e) return "";
            if (o == "horizontal") {
              const t = F || g;
              return b.formatNumber(
                t.style === "percent" ? e / 100 : e,
                {
                  ...t
                }
              );
            }
            return e;
          }
        } : {
          legend: X.bottom,
          legendPosition: "middle",
          legendOffset: parseInt(Le),
          renderTick: It
        },
        axisLeft: {
          tickSize: o === "horizontal" && Y || o === "vertical" ? 5 : 0,
          tickPadding: 5,
          tickRotation: 0,
          tickValues: ye,
          legend: X.left,
          legendPosition: "middle",
          legendOffset: Number.parseInt(qe),
          ..._ || S ? { renderTick: kt } : {
            format: (e) => {
              if (!e) return "";
              if (o === "vertical") {
                const t = F || g;
                return b.formatNumber(
                  t.style === "percent" ? e / 100 : e,
                  {
                    ...t
                  }
                );
              }
              return e;
            }
          }
        },
        enableGridY: dt,
        enableGridX: ht,
        layout: o,
        labelSkipWidth: he,
        labelSkipHeight: me,
        padding: Ue,
        labelTextColor: ue(),
        label: (e) => b.formatNumber(
          g.style === "percent" && e.value ? e.value / 100 : e.value,
          g
        ),
        layers: w,
        onMouseEnter: (e) => {
        },
        onMouseLeave: (e) => {
        },
        motionStiffness: 130,
        motionDamping: 15,
        tooltip: (e) => Ge && ae && ae.trim().length > 0 ? /* @__PURE__ */ r(
          Ht,
          {
            intl: b,
            format: g,
            d: e,
            tooltip: ae,
            tooltipEnableMarkdown: lt
          }
        ) : null,
        theme: {
          tooltip: {
            basic: {
              whiteSpace: "pre",
              display: "flex",
              alignItems: "center"
            },
            container: {
              background: "transparent",
              boxShadow: ""
            },
            table: {},
            tableCell: { padding: "3px 5px" }
          }
        }
      }
    ),
    (v === "top" || v === "bottom") && He && /* @__PURE__ */ r(
      "div",
      {
        className: `legends container has-standard-12-font-size ${v}`,
        style: v === "bottom" ? { marginBottom: `${Be}px` } : {},
        children: /* @__PURE__ */ x("div", { className: "legend-sections", children: [
          /* @__PURE__ */ r("div", { className: "title-section", children: _e() }),
          /* @__PURE__ */ r(
            St,
            {
              onWrapChange: (e) => {
                if (v === "top" && Me) {
                  const t = j + e / 2 * 40;
                  $e(t), Ve(e);
                } else
                  We(R + e / 2 * 25), Ve(e);
              },
              className: "legends container has-standard-12-font-size items-section",
              children: Te()
            }
          )
        ] })
      }
    ),
    (v === "right" || v === "left") && He && /* @__PURE__ */ x(
      "div",
      {
        className: `legends container has-standard-12-font-size  ${v}`,
        style: v === "right" ? yt : xt,
        children: [
          _e(),
          Te()
        ]
      }
    )
  ] }) });
}, ca = At(Kt);
export {
  ca as default
};
