const require_runtime = require("../../../../_virtual/_rolldown/runtime.js");
const require_index = require("../Packages/components/options/index.js");
const require_index$1 = require("./DeleteButton/index.js");
const require_index$2 = require("./EditButton/index.js");
let react = require("react");
react = require_runtime.__toESM(react);
let _pisell_utils = require("@pisell/utils");
let classnames = require("classnames");
classnames = require_runtime.__toESM(classnames);
require("./index.less");
//#region src/components/productCard/components/Header/index.tsx
const prefix = "pisell-lowcode-";
const Header = (props) => {
	const { isShowDelete, item, isShowImage, onDelete, disabledEdit, onEditProduct, isShowEditProduct } = props;
	const { id, options, bundle, product_option_string, image, name, price, symbol, disabled, relation_products, num = 1 } = item;
	/**
	* @title: 是否显示价格
	* @description:
	* @param {*} useMemo
	* @return {*}
	* @Author: WangHan
	* @Date: 2024-11-23 16:13
	*/
	const showPrice = (0, react.useMemo)(() => {
		return (bundle === null || bundle === void 0 ? void 0 : bundle.length) > 0 || (options === null || options === void 0 ? void 0 : options.length) > 0 || ((relation_products === null || relation_products === void 0 ? void 0 : relation_products.length) || 0) > 0;
	}, [
		bundle,
		options,
		relation_products
	]);
	/**
	* @title: 样式是否居中
	* @description:
	* @param {*} useMemo
	* @return {*}
	* @Author: WangHan
	* @Date: 2024-11-23 17:37
	*/
	const headerCenterStyle = (0, react.useMemo)(() => {
		return (options === null || options === void 0 ? void 0 : options.length) > 0 || product_option_string;
	}, [options, product_option_string]);
	/**
	* @title: 是否显示删除按钮
	* @description:
	* @param {*} useMemo
	* @return {*}
	* @Author: WangHan
	* @Date: 2025-06-11 15:14
	*/
	const showDelete = (0, react.useMemo)(() => {
		return isShowDelete && !disabledEdit && !disabled;
	}, [
		isShowDelete,
		disabledEdit,
		disabled
	]);
	const renderImage = () => {
		if (!isShowImage) return null;
		if (image) return /* @__PURE__ */ react.default.createElement("img", {
			src: _pisell_utils.image.ali(image, 64),
			className: `${prefix}product-header-cover`
		});
		const displayText = name ? name.slice(0, 2) : "";
		return /* @__PURE__ */ react.default.createElement("div", { className: `${prefix}product-header-cover-text` }, displayText);
	};
	return /* @__PURE__ */ react.default.createElement("div", { className: (0, classnames.default)(`${prefix}product-header`, headerCenterStyle && `${prefix}product-options-header`) }, showDelete ? /* @__PURE__ */ react.default.createElement(require_index$1.default, { onDelete }) : null, renderImage(), id ? /* @__PURE__ */ react.default.createElement("div", { className: (0, classnames.default)(`${prefix}product-right-wrap`, { [`${prefix}product-right-wrap-stretch`]: isShowEditProduct }) }, /* @__PURE__ */ react.default.createElement("div", { className: `${prefix}product-title` }, /* @__PURE__ */ react.default.createElement("span", { style: { paddingRight: showDelete ? "18px" : "0" } }, name), showPrice ? /* @__PURE__ */ react.default.createElement("span", { className: `${prefix}product-title-price` }, (0, _pisell_utils.formatAmount)(price, 2, symbol)) : null), product_option_string ? /* @__PURE__ */ react.default.createElement("span", { className: `${prefix}product-title-variant` }, product_option_string) : null, /* @__PURE__ */ react.default.createElement(require_index.default, {
		options,
		amountSymbol: symbol
	}), isShowEditProduct && !disabledEdit && !disabled ? /* @__PURE__ */ react.default.createElement(require_index$2.default, { onEdit: onEditProduct }) : null) : null);
};
//#endregion
exports.default = Header;
