"use strict";
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
const jsxRuntime = require("react/jsx-runtime");
require("react");
const getSize = require("../../../core/utils/get-size/get-size.cjs");
const createEventHandler = require("../../../core/utils/create-event-handler/create-event-handler.cjs");
const createVarsResolver = require("../../../core/styles-api/create-vars-resolver/create-vars-resolver.cjs");
require("clsx");
const getThemeColor = require("../../../core/MantineProvider/color-functions/get-theme-color/get-theme-color.cjs");
const getContrastColor = require("../../../core/MantineProvider/color-functions/get-contrast-color/get-contrast-color.cjs");
const getAutoContrastValue = require("../../../core/MantineProvider/color-functions/get-auto-contrast-value/get-auto-contrast-value.cjs");
const useProps = require("../../../core/MantineProvider/use-props/use-props.cjs");
const useStyles = require("../../../core/styles-api/use-styles/use-styles.cjs");
const Box = require("../../../core/Box/Box.cjs");
const factory = require("../../../core/factory/factory.cjs");
const Pagination_context = require("../Pagination.context.cjs");
const Pagination_module_css = require("../Pagination.module.css.cjs");
const usePagination = require("../../../../../../../../@mantine_hooks@7.15.2_react@18.3.1/node_modules/@mantine/hooks/esm/use-pagination/use-pagination.cjs");
const defaultProps = {
  siblings: 1,
  boundaries: 1
};
const varsResolver = createVarsResolver.createVarsResolver(
  (theme, { size, radius, color, autoContrast }) => ({
    root: {
      "--pagination-control-radius": radius === void 0 ? void 0 : getSize.getRadius(radius),
      "--pagination-control-size": getSize.getSize(size, "pagination-control-size"),
      "--pagination-control-fz": getSize.getFontSize(size),
      "--pagination-active-bg": color ? getThemeColor.getThemeColor(color, theme) : void 0,
      "--pagination-active-color": getAutoContrastValue.getAutoContrastValue(autoContrast, theme) ? getContrastColor.getContrastColor({ color, theme, autoContrast }) : void 0
    }
  })
);
const PaginationRoot = factory.factory((_props, ref) => {
  const props = useProps.useProps("PaginationRoot", defaultProps, _props);
  const {
    classNames,
    className,
    style,
    styles,
    unstyled,
    vars,
    total,
    value,
    defaultValue,
    onChange,
    disabled,
    siblings,
    boundaries,
    color,
    radius,
    onNextPage,
    onPreviousPage,
    onFirstPage,
    onLastPage,
    getItemProps,
    autoContrast,
    ...others
  } = props;
  const getStyles = useStyles.useStyles({
    name: "Pagination",
    classes: Pagination_module_css.default,
    props,
    className,
    style,
    classNames,
    styles,
    unstyled,
    vars,
    varsResolver
  });
  const { range, setPage, next, previous, active, first, last } = usePagination.usePagination({
    page: value,
    initialPage: defaultValue,
    onChange,
    total,
    siblings,
    boundaries
  });
  const handleNextPage = createEventHandler.createEventHandler(onNextPage, next);
  const handlePreviousPage = createEventHandler.createEventHandler(onPreviousPage, previous);
  const handleFirstPage = createEventHandler.createEventHandler(onFirstPage, first);
  const handleLastPage = createEventHandler.createEventHandler(onLastPage, last);
  return /* @__PURE__ */ jsxRuntime.jsx(
    Pagination_context.PaginationProvider,
    {
      value: {
        total,
        range,
        active,
        disabled,
        getItemProps,
        onChange: setPage,
        onNext: handleNextPage,
        onPrevious: handlePreviousPage,
        onFirst: handleFirstPage,
        onLast: handleLastPage,
        getStyles
      },
      children: /* @__PURE__ */ jsxRuntime.jsx(Box.Box, { ref, ...getStyles("root"), ...others })
    }
  );
});
PaginationRoot.classes = Pagination_module_css.default;
PaginationRoot.displayName = "@mantine/core/PaginationRoot";
exports.PaginationRoot = PaginationRoot;
