import Specs from "../specs/index.js";
import Holders from "../holders/index.js";
import { PREFIX } from "../../index.js";
import React from "react";
import { formatAmount, image } from "@pisell/utils";
import classNames from "classnames";
import "./index.less";
//#region src/components/productCard/cartSkuCard/components/basicInfo/index.tsx
const BasicInfo = (props) => {
	const { isShowImage, dataSource = {}, style, isMainProduct, type } = props;
	const { image: image$1, bundle, options, product_option_string, name, price, symbol, total = 0, origin_total = 0, num = 1, holder_id, isFormSubject, totalDifference = 0 } = dataSource;
	const renderNumTag = () => {
		return /* @__PURE__ */ React.createElement("div", { className: classNames(`num-tag`, { "is-main": isMainProduct }) }, num < 100 ? num : "99+");
	};
	const hasSpecs = (bundle === null || bundle === void 0 ? void 0 : bundle.length) || (options === null || options === void 0 ? void 0 : options.length) || product_option_string;
	const renderImage = () => {
		if (!isShowImage) return null;
		if (image$1) return /* @__PURE__ */ React.createElement("img", {
			src: image.ali(image$1, 64),
			className: `product-cover`
		});
		const displayText = name ? name.slice(0, 2) : "";
		return /* @__PURE__ */ React.createElement("div", { className: `product-cover-text` }, displayText);
	};
	if (type === "a5") return /* @__PURE__ */ React.createElement("div", {
		className: `${PREFIX}__basic-info`,
		style: style || {}
	}, renderNumTag(), renderImage(), !isShowImage || !image$1 && !name ? /* @__PURE__ */ React.createElement("div", { style: { width: 20 } }) : null, /* @__PURE__ */ React.createElement("div", { className: `product-info` }, /* @__PURE__ */ React.createElement("div", { className: `product-name` }, name), (!holder_id || !(holder_id === null || holder_id === void 0 ? void 0 : holder_id.length)) && !isFormSubject ? /* @__PURE__ */ React.createElement("div", { className: `product-price` }, formatAmount(price, 2, symbol)) : /* @__PURE__ */ React.createElement(Holders, { dataSource })));
	return /* @__PURE__ */ React.createElement("div", {
		className: `${PREFIX}__basic-info`,
		style: style || {}
	}, renderNumTag(), renderImage(), !isShowImage || !image$1 && !name ? /* @__PURE__ */ React.createElement("div", { style: { width: 20 } }) : null, /* @__PURE__ */ React.createElement("div", { className: `product-info` }, /* @__PURE__ */ React.createElement("div", { className: `product-name` }, name), hasSpecs ? /* @__PURE__ */ React.createElement(Specs, { dataSource }) : /* @__PURE__ */ React.createElement("div", { className: `product-price` }, formatAmount(price, 2, symbol))), /* @__PURE__ */ React.createElement("div", { className: `product-amount` }, /* @__PURE__ */ React.createElement("div", { className: `total-amont` }, formatAmount(total * num - (totalDifference !== null && totalDifference !== void 0 ? totalDifference : 0), 2, symbol)), origin_total && Number(total) !== Number(origin_total) ? /* @__PURE__ */ React.createElement("div", { className: `origin-amount` }, formatAmount(origin_total * num, 2, symbol)) : null));
};
//#endregion
export { BasicInfo as default };
