import { getText } from "../../../../locales/index.js";
import { _objectSpread2 } from "../../../../_virtual/_@oxc-project_runtime@0.122.0/helpers/objectSpread2.js";
import { _objectWithoutProperties } from "../../../../_virtual/_@oxc-project_runtime@0.122.0/helpers/objectWithoutProperties.js";
import Pagination from "../../../Pagination/index.js";
import withContainer from "../../utils/withContainer.js";
import React, { forwardRef, useMemo } from "react";
//#region src/components/pisellDataSourceContainer/components/Pagination/index.tsx
const _excluded = ["serverActions", "refManager"];
var Pagination_default = withContainer(forwardRef((props) => {
	const { serverActions: { list: listAction }, refManager } = props, otherProps = _objectWithoutProperties(props, _excluded);
	const { pagination, data } = listAction;
	/** 分页配置属性 */
	const paginationProps = useMemo(() => {
		return {
			showTotal: (total) => {
				return getText("table-pagination-total")((pagination === null || pagination === void 0 ? void 0 : pagination.pageNumber) || 1, Math.ceil(total / ((pagination === null || pagination === void 0 ? void 0 : pagination.pageSize) || 10)));
			},
			total: (data === null || data === void 0 ? void 0 : data.count) || 0,
			current: (pagination === null || pagination === void 0 ? void 0 : pagination.pageNumber) || 1,
			pageSize: (pagination === null || pagination === void 0 ? void 0 : pagination.pageSize) || 10,
			onChange: listAction.onPageChange
		};
	}, [
		pagination === null || pagination === void 0 ? void 0 : pagination.pageNumber,
		pagination === null || pagination === void 0 ? void 0 : pagination.pageSize,
		data === null || data === void 0 ? void 0 : data.count,
		listAction.onPageChange
	]);
	if (!pagination) {
		console.error("分页功能未启用");
		return null;
	}
	return /* @__PURE__ */ React.createElement(Pagination, _objectSpread2(_objectSpread2({}, otherProps), paginationProps));
}), "pagination");
//#endregion
export { Pagination_default as default };
