import { j as t } from "../../../_virtual/jsx-runtime.js";
import { useEffect as u } from "react";
import { ResultsArea as x } from "../styles.js";
import { defaultResultsText as r } from "../constants.js";
import { Pagination as c } from "../../Pagination/index.js";
import { getId as d, unitJSX as I } from "../../../utils/index.js";
const R = ({
  footer: a,
  currentPage: i,
  setCurrentPage: o,
  numberOfRows: n,
  variant: m,
  "data-testid": l,
  "data-trackid": P
}) => {
  var e, g;
  const s = d(l), p = d(P);
  return u(() => {
    a.variant === "pagination" && a.pagination && typeof a.pagination.onChangePage == "function" && a.pagination.onChangePage(i);
  }, [i]), a.variant === "pagination" ? /* @__PURE__ */ t.jsxs(t.Fragment, { children: [
    a.pagination && a.pagination.displayResults && /* @__PURE__ */ t.jsxs(
      x,
      {
        "data-testid": s("results"),
        "data-trackid": p("results"),
        children: [
          ((e = a.pagination.resultsText) == null ? void 0 : e.indicator) || r.indicator,
          " ",
          i * a.pagination.rowsPerPage - a.pagination.rowsPerPage + 1,
          " ",
          "- ",
          i * a.pagination.rowsPerPage,
          " ",
          ((g = a.pagination.resultsText) == null ? void 0 : g.preposition) || r.preposition,
          " ",
          a.pagination.totalNumberOfItems || n
        ]
      }
    ),
    !a.pagination.externalPagination && /* @__PURE__ */ t.jsx(
      c,
      {
        variant: m,
        currentPage: i,
        rowsPerPage: a.pagination.rowsPerPage,
        totalItems: a.pagination.totalNumberOfItems || n,
        paginationLimiter: a.pagination.widePaginationLimiter,
        onChangePage: o,
        "data-testid": s(),
        "data-trackid": p()
      }
    )
  ] }) : I;
};
export {
  R as default
};
