"use strict";
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
const jsxRuntime = require("react/jsx-runtime");
const React = require("react");
require("clsx");
const useProps = require("../../../core/MantineProvider/use-props/use-props.cjs");
const createPolymorphicComponent = require("../../../core/factory/create-polymorphic-component.cjs");
const Pagination_context = require("../Pagination.context.cjs");
const Pagination_icons = require("../Pagination.icons.cjs");
const PaginationControl = require("../PaginationControl/PaginationControl.cjs");
function createEdgeComponent({ icon, name, action, type }) {
  const defaultProps = { icon };
  const Component = React.forwardRef((props, ref) => {
    const { icon: _icon, ...others } = useProps.useProps(name, defaultProps, props);
    const Icon = _icon;
    const ctx = Pagination_context.usePaginationContext();
    const disabled = type === "next" ? ctx.active === ctx.total : ctx.active === 1;
    return /* @__PURE__ */ jsxRuntime.jsx(
      PaginationControl.PaginationControl,
      {
        disabled: ctx.disabled || disabled,
        ref,
        onClick: ctx[action],
        withPadding: false,
        ...others,
        children: /* @__PURE__ */ jsxRuntime.jsx(
          Icon,
          {
            className: "mantine-rotate-rtl",
            style: {
              width: "calc(var(--pagination-control-size) / 1.8)",
              height: "calc(var(--pagination-control-size) / 1.8)"
            }
          }
        )
      }
    );
  });
  Component.displayName = `@mantine/core/${name}`;
  return createPolymorphicComponent.createPolymorphicComponent(Component);
}
const PaginationNext = createEdgeComponent({
  icon: Pagination_icons.PaginationNextIcon,
  name: "PaginationNext",
  action: "onNext",
  type: "next"
});
const PaginationPrevious = createEdgeComponent({
  icon: Pagination_icons.PaginationPreviousIcon,
  name: "PaginationPrevious",
  action: "onPrevious",
  type: "previous"
});
const PaginationFirst = createEdgeComponent({
  icon: Pagination_icons.PaginationFirstIcon,
  name: "PaginationFirst",
  action: "onFirst",
  type: "previous"
});
const PaginationLast = createEdgeComponent({
  icon: Pagination_icons.PaginationLastIcon,
  name: "PaginationLast",
  action: "onLast",
  type: "next"
});
exports.PaginationFirst = PaginationFirst;
exports.PaginationLast = PaginationLast;
exports.PaginationNext = PaginationNext;
exports.PaginationPrevious = PaginationPrevious;
exports.createEdgeComponent = createEdgeComponent;
