const require_runtime = require("../../../../../../_virtual/_rolldown/runtime.js");
const require_objectSpread2 = require("../../../../../../_virtual/_@oxc-project_runtime@0.122.0/helpers/objectSpread2.js");
const require_status = require("../../status.js");
let react = require("react");
react = require_runtime.__toESM(react);
let _pisell_materials = require("@pisell/materials");
require("./index.less");
//#region src/plus/productSelect/ProductCard/SkuCard/components/Tags/index.tsx
const Tags = ({ props }) => {
	const { dataSource, skuTextConfig } = props;
	const { isOpen, marginX, isShowAll, maxCount, lists } = (skuTextConfig === null || skuTextConfig === void 0 ? void 0 : skuTextConfig.skuTagsConfig) || {};
	if (!isOpen) return null;
	const listsData = (0, react.useMemo)(() => {
		var _dataSource$tags;
		return ((dataSource === null || dataSource === void 0 || (_dataSource$tags = dataSource.tags) === null || _dataSource$tags === void 0 ? void 0 : _dataSource$tags.length) ? dataSource === null || dataSource === void 0 ? void 0 : dataSource.tags : lists) || [];
	}, [dataSource === null || dataSource === void 0 ? void 0 : dataSource.tags, lists]);
	/**
	* @title: 文本样式
	* @description:
	* @param {*} useCallback
	* @return {*}
	* @Author: WangHan
	* @Date: 2025-09-10 11:27
	*/
	const textStyle = (0, react.useCallback)((tag) => {
		return {
			fontSize: tag.fontSize,
			fontWeight: tag.fontWeight,
			color: tag.color
		};
	}, []);
	/**
	* @title: 标签样式
	* @description:
	* @param {*} useCallback
	* @return {*}
	* @Author: WangHan
	* @Date: 2025-09-10 11:27
	*/
	const tagStyle = (0, react.useCallback)((tag) => {
		return {
			background: tag.background,
			padding: `${tag.paddingY}px ${tag.paddingX}px`,
			borderRadius: tag.radius,
			border: tag.isBorder ? `${tag.borderWidth}px solid ${tag.borderColor}` : "none",
			margin: 0,
			lineHeight: "18px"
		};
	}, [marginX]);
	/**
	* @title: 处理标签数据
	* @description:
	* @param {*} useMemo
	* @return {*}
	* @Author: WangHan
	* @Date: 2025-09-11 10:59
	*/
	const listsResult = (0, react.useMemo)(() => {
		if (isShowAll) return listsData;
		return listsData.slice(0, maxCount);
	}, [
		listsData,
		isShowAll,
		maxCount
	]);
	if (listsData.length === 0) return null;
	return /* @__PURE__ */ react.default.createElement("div", {
		className: `${require_status.PREFIX}__card-tags`,
		style: { gap: `${marginX}px` }
	}, listsResult.map((tag, tagIndex) => /* @__PURE__ */ react.default.createElement(_pisell_materials.PisellTags, require_objectSpread2._objectSpread2({
		key: tagIndex,
		style: require_objectSpread2._objectSpread2({}, tagStyle(tag))
	}, tag.props), /* @__PURE__ */ react.default.createElement("span", { style: textStyle(tag) }, tag === null || tag === void 0 ? void 0 : tag.title))), (listsData === null || listsData === void 0 ? void 0 : listsData.length) > listsResult.length && /* @__PURE__ */ react.default.createElement("div", { className: `pisell-product-sku__card-tags-remaining` }, "+", (listsData === null || listsData === void 0 ? void 0 : listsData.length) - listsResult.length));
};
//#endregion
exports.default = Tags;
