import { jsx as c } from "@emotion/react/jsx-runtime";
import { useMemo as t } from "react";
import { CustomTablePagination as O } from "./subcomponents/CustomTablePagination/CustomTablePagination.js";
import { useModuleDictionary as T } from "@m4l/core";
import { PAGER_DICTIONARY as f } from "./dicctionary.js";
import { getComponentSlotRoot as v } from "../../utils/getComponentSlotRoot.js";
import { PAGER_KEY_COMPONENT as x } from "./constants.js";
import { PagerRootStyled as E } from "./slots/PagerSlots.js";
import { useComponentSize as N } from "@m4l/graphics";
function j(u) {
  const {
    totalRecords: a = 0,
    rowsPerPageOptions: p = [5, 10, 25],
    rowsPerPage: r = 25,
    page: s = 0,
    onPageChange: e,
    onRowsPerPageChange: m,
    labelRows: i,
    labelOf: l,
    size: h = "medium"
  } = u, g = t(() => Math.max(1, Math.ceil(a / r)), [a, r]), { currentSize: P } = N(h), { getLabel: o } = T(), R = t(() => Math.max(0, Math.min(s, g - 1)), [s, g]), d = t(() => l ?? o(f.of), [l, o]), C = t(() => i ?? o(f.rows), [i, o]), w = (n) => {
    m && n.value !== void 0 && m(n.value), e && e(0);
  }, b = (n, M) => {
    e && e(M);
  }, z = v(x);
  return /* @__PURE__ */ c(E, { className: z, size: P, role: "Pager-root", children: /* @__PURE__ */ c(
    O,
    {
      size: P,
      rowsPerPageOptions: p,
      count: a,
      rowsPerPage: r,
      page: R,
      onPageChange: b,
      onRowsPerPageChange: w,
      labelOf: d,
      labelTotalRows: C
    }
  ) });
}
export {
  j as Pager,
  j as default
};
