import { jsx as a, jsxs as F } from "react/jsx-runtime";
import { useRef as Z } from "react";
import { Container as K } from "semantic-ui-react";
import { connect as Q } from "react-redux";
import W from "../data/DataConsumer.js";
import { unsetFilter as X, setFilter as Y } from "../reducers/data.js";
import { parse as k } from "../utils/parseUtils.js";
import _ from "./DataProvider.js";
import ee from "./BigNumberGroup.js";
const te = (r) => {
  const {
    editing: d = !1,
    unique: o,
    intl: u,
    "data-csv": m = "",
    "data-dimension1": e = "none",
    "data-dimension2": l = "none",
    "data-dvz-proxy-dataset-id": c,
    "data-no-data-message": b = "No data matches your selection",
    "data-view-mode": v = "info",
    "data-height": n,
    "data-app": t,
    "data-measures": f = "{}",
    "data-group": S,
    "data-parent": i,
    "data-block-name": s,
    "data-filters": P = "[]",
    "data-number-font-size": w = 20,
    "data-label-font-size": z = 20,
    "data-unselected-number-color": I = "#000000",
    "data-unselected-label-color": A = "#000000",
    "data-unselected-background-color": B = "#fdfdfdff",
    "data-number-color": N = "#000000",
    "data-label-color": y = "#000000",
    "data-background-color": D = "#ffffffff",
    "data-label": j = "",
    "data-wait-for-filters": G = "false",
    "data-n-columns": M = 4,
    "data-sort": J = "alpha",
    "data-order": E = "asc",
    "data-show-zero-values": U = "false",
    hasParentFilters: $,
    effectiveFilter: q,
    appliedFilters: H,
    parentAppliedFilters: L,
    onSetFilter: O,
    onUnSetFilter: R
  } = r, T = Z(null), V = d ? n - 80 : n - 40, x = { dvzProxyDatasetId: c }, h = k(P) || {};
  h && h.forEach && h.forEach((p) => {
    p.value != null && p.value.filter((C) => C != null && C.toString().trim() != "").length > 0 && (x[p.param] = p.value);
  });
  const g = [];
  return e != "none" && g.push(e), l != "none" && g.push(l), /* @__PURE__ */ a("div", { ref: T, children: /* @__PURE__ */ F(K, { fluid: !0, style: { padding: "0px", margin: "0px", height: `${n}px` }, children: [
    (!t || t === "csv") && /* @__PURE__ */ F("p", { children: [
      /* @__PURE__ */ a("h2", { children: "Big Filter:" }),
      /* @__PURE__ */ a("h4", { children: "Please select an API! " })
    ] }),
    t !== "csv" && e == "none" && /* @__PURE__ */ F("p", { children: [
      /* @__PURE__ */ a("h2", { children: "Big Filter:" }),
      /* @__PURE__ */ a("h4", { children: "Please select dimension! " })
    ] }),
    t && e != "none" && /* @__PURE__ */ a(
      _,
      {
        style: { height: `${V}px` },
        blockName: s,
        params: x,
        app: t,
        useAncestor: !0,
        parent: i,
        editing: d,
        waitForFilters: G === "true",
        store: [t, o],
        source: g.join("/"),
        children: /* @__PURE__ */ a(W, { noDataMessage: /* @__PURE__ */ a("h1", { children: "No data" }), children: /* @__PURE__ */ a(
          ee,
          {
            nColumns: M,
            parent: i,
            sort: J,
            order: E,
            showZeroValues: U,
            onSetFilter: O,
            onUnSetFilter: R,
            appliedFilters: H,
            height: n,
            intl: u,
            app: t,
            group: S,
            blockName: s,
            measures: k(f),
            label: j,
            numberFontSize: w,
            labelFontSize: z,
            numberColor: N,
            labelColor: y,
            backgroundColor: D,
            unselectedNumberColor: I,
            unselectedLabelColor: A,
            unselectedBackgroundColor: B,
            hasParentFilters: $,
            effectiveFilter: q,
            parentAppliedFilters: L,
            dimension1: e,
            dimension2: l
          }
        ) })
      }
    )
  ] }) });
}, ae = (r, d) => {
  const { "data-app": o, "data-group": u, "data-block-name": m, "data-parent": e, "data-dimension1": l } = d, c = u, b = e || m + Math.random(0, 1), v = m, n = r.getIn(["data", "filters", o, v]), t = e != "" && e != null, f = r.getIn(["data", "filters", o, c]) ? r.getIn(["data", "filters", o, c]).toJS() : {};
  let i = (t ? r.getIn(["data", "filters", o, b]) : null) ? Object.values(r.getIn(["data", "filters", o, e]).toJS())[0] : [], s = n ? n.toJS()[l] : [];
  return {
    hasParentFilters: t,
    //util flag
    effectiveFilter: f,
    //all filter toghether
    parentAppliedFilters: i || [],
    //parent applied filter
    appliedFilters: s || []
    //self applied filters
  };
}, re = {
  onSetFilter: Y,
  onUnSetFilter: X
}, me = Q(ae, re)(te);
export {
  me as default
};
