import { PREFIX } from "../../status.js";
import React, { useMemo } from "react";
import { locales } from "@pisell/utils";
//#region src/plus/productSelect/ProductCard/SkuCard/components/Stock/index.tsx
const Stock = ({ props }) => {
	const { dataSource, skuTextConfig } = props;
	const { isOpen, fontSize, fontWeight, color, customText } = (skuTextConfig === null || skuTextConfig === void 0 ? void 0 : skuTextConfig.skuStockConfig) || {};
	if (!isOpen) return null;
	if (customText) return customText;
	const finalStyle = useMemo(() => {
		return {
			fontSize,
			fontWeight,
			color
		};
	}, [
		fontSize,
		fontWeight,
		color
	]);
	/**
	* @title: 库存文本
	* @description:
	* @param {*} useMemo
	* @return {*}
	* @Author: WangHan
	* @Date: 2025-09-08 15:31
	*/
	const stockText = useMemo(() => {
		if ((dataSource === null || dataSource === void 0 ? void 0 : dataSource.is_track) === 0) return null;
		return `${locales.getText("pisell2.sku-card.stock")}: ${dataSource === null || dataSource === void 0 ? void 0 : dataSource.stock_quantity}`;
	}, [dataSource === null || dataSource === void 0 ? void 0 : dataSource.stock_quantity, dataSource === null || dataSource === void 0 ? void 0 : dataSource.is_track]);
	return !!(dataSource === null || dataSource === void 0 ? void 0 : dataSource.is_track) ? /* @__PURE__ */ React.createElement("div", {
		className: `${PREFIX}__card-stock`,
		style: finalStyle
	}, stockText) : null;
};
//#endregion
export { Stock as default };
