import React, { useMemo } from "react";
import classNames from "classnames";
//#region src/components/PisellCards/components/TextCard/components/TextContent.tsx
/**
* TextContent 文本内容组件
* 负责渲染主文本内容，处理文本省略逻辑
*
* @example
* ```tsx
* <TextContent
*   text="这是一段很长的文本内容"
*   textConfig={{
*     maxLines: 2,
*     ellipsis: true,
*     fontSize: 14,
*     color: '#333'
*   }}
* />
* ```
*/
const TextContent = (props) => {
	const { text, textConfig = {}, className, active } = props;
	const { maxLines = 1, ellipsis = true, fontSize, fontWeight, color, textAlign = "left", flex } = textConfig;
	/**
	* 计算文本样式
	* 处理字体大小、粗细、颜色和省略号
	*/
	const textStyle = useMemo(() => {
		var _active$style, _active$style3;
		const style = {
			textAlign,
			flex: flex !== null && flex !== void 0 ? flex : 1
		};
		if (fontSize) style.fontSize = fontSize;
		if (fontWeight) style.fontWeight = fontWeight;
		if (color) style.color = color;
		if ((active === null || active === void 0 ? void 0 : active.value) && (active === null || active === void 0 || (_active$style = active.style) === null || _active$style === void 0 ? void 0 : _active$style.color)) {
			var _active$style2;
			style.color = active === null || active === void 0 || (_active$style2 = active.style) === null || _active$style2 === void 0 ? void 0 : _active$style2.color;
		}
		if ((active === null || active === void 0 ? void 0 : active.value) && (active === null || active === void 0 || (_active$style3 = active.style) === null || _active$style3 === void 0 ? void 0 : _active$style3.fontWeight)) {
			var _active$style4;
			style.fontWeight = active === null || active === void 0 || (_active$style4 = active.style) === null || _active$style4 === void 0 ? void 0 : _active$style4.fontWeight;
		}
		if (ellipsis && maxLines === 1) {
			style.overflow = "hidden";
			style.textOverflow = "ellipsis";
			style.whiteSpace = "nowrap";
		}
		if (ellipsis && maxLines > 1) {
			style.overflow = "hidden";
			style.textOverflow = "-o-ellipsis-lastline";
			style.textOverflow = "ellipsis";
			style.display = "-webkit-box";
			style.WebkitLineClamp = maxLines;
			style.lineClamp = maxLines;
			style.WebkitBoxOrient = "vertical";
			style.whiteSpace = "normal";
		}
		return style;
	}, [
		active,
		fontSize,
		fontWeight,
		color,
		ellipsis,
		maxLines,
		textAlign,
		flex
	]);
	if (active === null || active === void 0 ? void 0 : active.value) console.log("textStyle11", textStyle);
	return /* @__PURE__ */ React.createElement("div", {
		className: classNames("text-card__content", className),
		style: textStyle
	}, text);
};
//#endregion
export { TextContent as default };
