import { _objectSpread2 } from "../../_virtual/_@oxc-project_runtime@0.122.0/helpers/objectSpread2.js";
import { getPisellComponentsThemeConfig } from "../../theme/pisell-components.js";
import React from "react";
import { getDisplayState } from "@pisell/utils";
import { ConfigProvider, Rate } from "antd";
import "./PisellRating.less";
//#region src/components/pisellRating/PisellRating.tsx
/**
* PisellRating 评分组件
* 
* 基于 Ant Design Rate 组件开发，提供直观的星级评分交互。
* 支持只读、编辑、禁用三种状态。
* 
* @param props 组件 Props
* 
* @example
* // 基础使用
* const [rating, setRating] = useState(0);
* <PisellRating value={rating} onChange={setRating} />
* 
* @example
* // 只读态
* <PisellRating mode="read" value={4.5} allowHalf />
* 
* @example
* // 带评分描述
* <PisellRating
*   value={rating}
*   onChange={setRating}
*   tooltips={['很差', '差', '一般', '好', '很好']}
* />
*/
const PisellRating = (props) => {
	const { mode = "edit", disabled = false, value, defaultValue, onChange, count, max = count !== null && count !== void 0 ? count : 5, allowHalf = false, allowClear = true, character, tooltips, showValue = false, showCount = false, reviewCount, size = 20, color = "#fadb14", unselectedColor = "#d9d9d9", onHoverChange, onFocus, onBlur, className, style, "aria-label": ariaLabel, id } = props;
	const displayState = getDisplayState(mode, disabled);
	const isReadOnly = displayState === "read";
	const isDisabled = displayState === "disabled";
	const rateStyle = _objectSpread2({
		fontSize: size,
		color
	}, style);
	const theme = getPisellComponentsThemeConfig();
	return /* @__PURE__ */ React.createElement(ConfigProvider, { theme }, /* @__PURE__ */ React.createElement("div", {
		className: `pisell-rating pisell-rating-${displayState} ${className || ""}`,
		id
	}, /* @__PURE__ */ React.createElement(Rate, {
		value,
		defaultValue,
		onChange,
		onHoverChange,
		onFocus,
		onBlur,
		count: max,
		allowHalf,
		allowClear,
		character,
		tooltips,
		disabled: isReadOnly || isDisabled,
		style: rateStyle,
		"aria-label": ariaLabel
	}), showValue && value !== void 0 && /* @__PURE__ */ React.createElement("span", {
		className: "pisell-rating-value",
		style: { marginLeft: 8 }
	}, value.toFixed(allowHalf ? 1 : 0)), showCount && reviewCount !== void 0 && /* @__PURE__ */ React.createElement("span", {
		className: "pisell-rating-count",
		style: {
			marginLeft: 8,
			color: "#999"
		}
	}, "(", reviewCount, " 人评价)")));
};
var PisellRating_default = React.memo(PisellRating, (prevProps, nextProps) => {
	return prevProps.value === nextProps.value && prevProps.mode === nextProps.mode && prevProps.disabled === nextProps.disabled;
});
//#endregion
export { PisellRating_default as default };
