import { jsxs as S, jsx as s } from "react/jsx-runtime";
import { useState as g, useEffect as u } from "react";
import { connect as x } from "react-redux";
import { Container as A, Icon as F } from "semantic-ui-react";
import { applyFilter as v } from "../reducers/data.js";
const j = (t) => {
  const {
    editing: l = !1,
    "data-group": e,
    onApply: a,
    "data-app": m = "csv",
    "data-label": h = "Apply",
    filters: o,
    initialFilters: y,
    apply: c
  } = t, [f, d] = g(!1), [I, b] = g(y), C = (n, p) => {
    for (let i in p) {
      if (n[i].length !== p[i].length)
        return !0;
      for (let r = 0; r < n[i].length; r++)
        if (n[i][r] !== p[i][r])
          return !0;
    }
    return !1;
  };
  return u(() => {
    const n = C(o, I);
    n && d(n), b(o);
  }, [o]), u(() => {
    c != null && d(!1);
  }, [c]), /* @__PURE__ */ S(
    A,
    {
      fluid: !0,
      className: `data-filters-apply ignore ${f ? "" : "disabled"} ${l ? "editing" : ""}`,
      onClick: (n) => {
        f && a({ app: m, group: e });
      },
      children: [
        /* @__PURE__ */ s("span", { children: h }),
        /* @__PURE__ */ s("span", { children: /* @__PURE__ */ s(F, { name: "chevron circle right", className: "custom-apply-icon" }) })
      ]
    }
  );
}, k = (t, l) => {
  const {
    "data-group": e,
    "data-app": a = "csv"
  } = l;
  return {
    apply: t.getIn(["data", "filters-settings", a, e, "apply"]),
    filters: t.getIn(["data", "filters", a, e]) ? t.getIn(["data", "filters", a, e]).toJS() : {},
    initialFilters: t.getIn(["data", "filters", "initial", a, e]) ? t.getIn(["data", "filters", "initial", a, e]).toJS() : {}
  };
}, E = {
  onApply: v
}, T = x(k, E)(j);
export {
  T as default
};
