import { LayoutPageStickyContainer, Stack, Button } from "@contember/ui";
import { memo, useCallback } from "react";
import { dataGridDictionary } from "../dataGridDictionary.js";
import { jsxDEV, Fragment } from "react/jsx-dev-runtime";
import { useMessageFormatter } from "../../../../../../i18n/useMessageFormatter.js";
var _jsxFileName = "/__w/interface/interface/packages/admin/src/components/bindingFacade/collections/DataGrid/base/DataGridContainer/DataGridContainerFooter.tsx";
const DataGridContainerFooter = memo(({
  desiredState,
  pagesCount,
  pagingSummary,
  updatePaging
}) => {
  const {
    paging: {
      pageIndex,
      itemsPerPage
    }
  } = desiredState;
  const formatMessage = useMessageFormatter(dataGridDictionary);
  const goToFirstPageClick = useCallback(() => {
    updatePaging({
      type: "goToFirstPage"
    });
  }, [updatePaging]);
  const goToPreviousPageClick = useCallback(() => {
    updatePaging({
      type: "goToPreviousPage"
    });
  }, [updatePaging]);
  const goToNextPageClick = useCallback(() => {
    updatePaging({
      type: "goToNextPage"
    });
  }, [updatePaging]);
  const goToLastPageClick = useCallback(() => {
    pagesCount !== void 0 && updatePaging({
      type: "goToPage",
      newPageIndex: pagesCount - 1
    });
  }, [pagesCount, updatePaging]);
  return /* @__PURE__ */ jsxDEV(LayoutPageStickyContainer, {
    left: "var(--cui-layout-page-padding-left)",
    right: "var(--cui-layout-page-padding-right)",
    children: /* @__PURE__ */ jsxDEV(Stack, {
      wrap: true,
      align: "center",
      direction: "horizontal",
      justify: "space-between",
      children: [/* @__PURE__ */ jsxDEV(Stack, {
        direction: "horizontal",
        justify: "space-between",
        gap: "small",
        children: [/* @__PURE__ */ jsxDEV(Button, {
          distinction: "seamless",
          disabled: pageIndex === 0,
          onClick: goToFirstPageClick,
          children: formatMessage("dataGrid.paging.first")
        }, void 0, false, {
          fileName: _jsxFileName,
          lineNumber: 47,
          columnNumber: 6
        }, void 0), /* @__PURE__ */ jsxDEV(Button, {
          disabled: pageIndex === 0,
          onClick: goToPreviousPageClick,
          children: formatMessage("dataGrid.paging.previous")
        }, void 0, false, {
          fileName: _jsxFileName,
          lineNumber: 54,
          columnNumber: 6
        }, void 0), itemsPerPage !== null && /* @__PURE__ */ jsxDEV(Fragment, {
          children: [/* @__PURE__ */ jsxDEV(Button, {
            disabled: pagesCount === void 0 || pagesCount <= pageIndex + 1,
            onClick: goToNextPageClick,
            children: formatMessage("dataGrid.paging.next")
          }, void 0, false, {
            fileName: _jsxFileName,
            lineNumber: 62,
            columnNumber: 8
          }, void 0), /* @__PURE__ */ jsxDEV(Button, {
            distinction: "seamless",
            disabled: pagesCount === void 0 || pagesCount <= pageIndex + 1,
            onClick: goToLastPageClick,
            children: formatMessage("dataGrid.paging.last")
          }, void 0, false, {
            fileName: _jsxFileName,
            lineNumber: 68,
            columnNumber: 8
          }, void 0)]
        }, void 0, true)]
      }, void 0, true, {
        fileName: _jsxFileName,
        lineNumber: 46,
        columnNumber: 5
      }, void 0), /* @__PURE__ */ jsxDEV("div", {
        children: pagingSummary
      }, void 0, false, {
        fileName: _jsxFileName,
        lineNumber: 78,
        columnNumber: 5
      }, void 0)]
    }, void 0, true, {
      fileName: _jsxFileName,
      lineNumber: 45,
      columnNumber: 4
    }, void 0)
  }, void 0, false, {
    fileName: _jsxFileName,
    lineNumber: 41,
    columnNumber: 3
  }, void 0);
});
DataGridContainerFooter.displayName = "DataGridContainerFooter";
export {
  DataGridContainerFooter
};
//# sourceMappingURL=DataGridContainerFooter.js.map
