const require_runtime = require("../../../../../../_virtual/_rolldown/runtime.js");
const require_index = require("../../../../components/pisellPriceText/index.js");
const require_status = require("../../status.js");
let react = require("react");
react = require_runtime.__toESM(react);
let _pisell_utils = require("@pisell/utils");
require("./index.less");
//#region src/plus/productSelect/ProductCard/SkuCard/components/Price/index.tsx
const Price = ({ props }) => {
	const { dataSource, skuTextConfig } = props;
	const { isOpen, isOriginPrice, isPrice, isTaxPrice, originPriceFontSize, originPriceFontWeight, originPriceColor, priceFontSize, priceFontWeight, priceColor, isCustomText, customTextType, customTextValue, customTextMinValue, customTextMaxValue, isShowZeroPrice, isShowFreePrice, isMiniPrice } = (skuTextConfig === null || skuTextConfig === void 0 ? void 0 : skuTextConfig.skuPriceConfig) || {};
	if (!isOpen) return null;
	const isShowPrice = (0, react.useMemo)(() => {
		if (!isPrice) return false;
		if (Number(dataSource === null || dataSource === void 0 ? void 0 : dataSource.price) === 0 && !isShowZeroPrice) return false;
		return true;
	}, [
		isPrice,
		isShowZeroPrice,
		dataSource === null || dataSource === void 0 ? void 0 : dataSource.price
	]);
	/**
	* @title: 价格文本
	* @description:
	* @param {*} useMemo
	* @return {*}
	* @Author: WangHan
	* @Date: 2025-09-18 16:23
	*/
	const priceText = (0, react.useMemo)(() => {
		if (!isShowPrice) return null;
		if (Number(dataSource === null || dataSource === void 0 ? void 0 : dataSource.price) === 0 && isShowFreePrice) return _pisell_utils.locales.getText("pisell2.sku-card.free");
		if (isCustomText) {
			if (customTextType === "from") return /* @__PURE__ */ react.default.createElement(require_index.default, {
				value: customTextValue || 0,
				isMini: true
			});
			if (customTextType === "end") return /* @__PURE__ */ react.default.createElement(require_index.default, {
				value: customTextValue || 0,
				isMini: true,
				customPrefixText: _pisell_utils.locales.getText("pisell2.sku-card.max"),
				customSuffixText: _pisell_utils.locales.getText("pisell2.sku-card.max")
			});
			if (customTextType === "range") return /* @__PURE__ */ react.default.createElement("div", { className: `${require_status.PREFIX}__card-price-range` }, /* @__PURE__ */ react.default.createElement(require_index.default, { value: customTextMinValue || 0 }), "~", /* @__PURE__ */ react.default.createElement(require_index.default, { value: customTextMaxValue || 0 }));
		}
		return /* @__PURE__ */ react.default.createElement(require_index.default, { value: (dataSource === null || dataSource === void 0 ? void 0 : dataSource.price) || 0 });
	}, [
		isShowPrice,
		dataSource === null || dataSource === void 0 ? void 0 : dataSource.price,
		isShowFreePrice,
		isCustomText,
		customTextType,
		customTextValue,
		customTextMinValue,
		customTextMaxValue
	]);
	const isShowOriginalPrice = (0, react.useMemo)(() => {
		if (!isOriginPrice) return false;
		const originalPrice = parseFloat(String((dataSource === null || dataSource === void 0 ? void 0 : dataSource.original_price) || 0));
		const price = parseFloat(String((dataSource === null || dataSource === void 0 ? void 0 : dataSource.price) || 0));
		if (isNaN(originalPrice) || isNaN(price)) return false;
		return originalPrice !== price;
	}, [
		isOriginPrice,
		dataSource === null || dataSource === void 0 ? void 0 : dataSource.original_price,
		dataSource === null || dataSource === void 0 ? void 0 : dataSource.price
	]);
	return /* @__PURE__ */ react.default.createElement("div", { className: `${require_status.PREFIX}__card-price-wrap` }, isShowPrice ? /* @__PURE__ */ react.default.createElement("div", {
		className: `${require_status.PREFIX}__card-price`,
		style: {
			fontSize: priceFontSize,
			fontWeight: priceFontWeight,
			color: priceColor
		}
	}, priceText) : null, isTaxPrice && parseFloat(String((dataSource === null || dataSource === void 0 ? void 0 : dataSource.tax_fee) || 0)) > 0 ? /* @__PURE__ */ react.default.createElement("div", { className: `${require_status.PREFIX}__card-tax-price` }, `(${_pisell_utils.locales.getText("pisell2.sku-card.gst")} : `, /* @__PURE__ */ react.default.createElement(require_index.default, {
		value: (dataSource === null || dataSource === void 0 ? void 0 : dataSource.tax_fee) || 0,
		isMini: isMiniPrice
	}), `)`) : null, isShowOriginalPrice ? /* @__PURE__ */ react.default.createElement("div", {
		className: `${require_status.PREFIX}__card-original-price`,
		style: {
			fontSize: originPriceFontSize,
			fontWeight: originPriceFontWeight,
			color: originPriceColor
		}
	}, /* @__PURE__ */ react.default.createElement(require_index.default, {
		value: (dataSource === null || dataSource === void 0 ? void 0 : dataSource.original_price) || 0,
		isMini: isMiniPrice
	})) : null);
};
//#endregion
exports.default = Price;
