const require_runtime = require("../../_virtual/_rolldown/runtime.js");
const require_objectSpread2 = require("../../_virtual/_@oxc-project_runtime@0.122.0/helpers/objectSpread2.js");
const require_objectWithoutProperties = require("../../_virtual/_@oxc-project_runtime@0.122.0/helpers/objectWithoutProperties.js");
const require_useEngineContext = require("../../hooks/useEngineContext.js");
const require_index = require("../cardPro/index.js");
const require_index$1 = require("./components/Header/DeleteButton/index.js");
const require_index$2 = require("./components/Header/index.js");
const require_index$3 = require("./components/Time/index.js");
const require_index$4 = require("./components/AmountFooter/index.js");
const require_index$5 = require("./components/Note/index.js");
const require_index$6 = require("./components/Packages/index.js");
const require_index$7 = require("./components/Sales/index.js");
const require_index$8 = require("./components/MultiDay/index.js");
const require_index$9 = require("./components/Action/index.js");
const require_useOpenNote = require("./hooks/useOpenNote.js");
const require_locales = require("./locales.js");
const require_status = require("./status.js");
const require_index$10 = require("./components/Warning/index.js");
const require_index$11 = require("./cartSkuCard/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/index.tsx
const _excluded = [
	"dataSource",
	"isShowImage",
	"isShowHolder",
	"isShowNote",
	"isShowDelete",
	"isShowAmountFooter",
	"isShowPackageNote",
	"isShowEditProduct",
	"scenario",
	"onEditProduct",
	"onAction",
	"onDelete",
	"onNote",
	"onLike",
	"onCard",
	"onChangeResource",
	"onChangeHolder"
];
const ProductCard = (props) => {
	var _utils$storage, _dataSource$items;
	const utils = require_useEngineContext.default().appHelper.utils || {};
	const { dataSource = require_status.defaultValue.dataSource, isShowImage = require_status.defaultValue.isShowImage, isShowHolder = require_status.defaultValue.isShowHolder, isShowNote = require_status.defaultValue.isShowNote, isShowDelete = require_status.defaultValue.isShowDelete, isShowAmountFooter = require_status.defaultValue.isShowAmountFooter, isShowPackageNote = require_status.defaultValue.isShowPackageNote, isShowEditProduct = require_status.defaultValue.isShowEditProduct, scenario, onEditProduct, onAction, onDelete, onNote, onLike, onCard, onChangeResource, onChangeHolder } = props, other = require_objectWithoutProperties._objectWithoutProperties(props, _excluded);
	const useOpenNoteRef = (0, react.useRef)();
	const locale = (utils === null || utils === void 0 || (_utils$storage = utils.storage) === null || _utils$storage === void 0 ? void 0 : _utils$storage.get("umi_locale")) || localStorage.getItem("umi_locale");
	_pisell_utils.locales.init(require_locales.default, locale || "en");
	const { image, bundle, relation_products, _id, isShowAction, actionText, errorMessage, isNormalProduct, osWarnTips = [] } = dataSource;
	/**
	* @title: 显示图片
	* @description:
	* @param {*} useMemo
	* @return {*}
	* @Author: WangHan
	* @Date: 2024-11-21 19:33
	*/
	const showImage = (0, react.useMemo)(() => {
		return isShowImage && image;
	}, [isShowImage, image]);
	/**
	* @title: 是否隐藏footer分割线
	* @description:
	* @param {*} useMemo
	* @return {*}
	* @Author: WangHan
	* @Date: 2024-11-23 13:30
	*/
	const hideDivider = (0, react.useMemo)(() => {
		return (bundle === null || bundle === void 0 ? void 0 : bundle.length) || (relation_products === null || relation_products === void 0 ? void 0 : relation_products.length);
	}, [bundle, relation_products]);
	return /* @__PURE__ */ react.default.createElement("div", {
		className: (0, classnames.default)("pisell-lowcode-product-card-wrap", { ["pisell-lowcode-product-card-disabled"]: dataSource === null || dataSource === void 0 ? void 0 : dataSource.disabled }),
		id: dataSource === null || dataSource === void 0 ? void 0 : dataSource.rowKey
	}, (dataSource === null || dataSource === void 0 ? void 0 : dataSource.disabled) && /* @__PURE__ */ react.default.createElement("div", { className: "delete-btn-wrapper" }, /* @__PURE__ */ react.default.createElement(require_index$1.default, { onDelete: () => onDelete === null || onDelete === void 0 ? void 0 : onDelete(dataSource) })), /* @__PURE__ */ react.default.createElement(require_index.default, {
		className: (0, classnames.default)("pisell-lowcode-product-card", {
			["pisell-lowcode-product-card-image"]: !showImage && scenario !== "booking2",
			["pisell-lowcode-normal-product-card"]: !showImage && isNormalProduct && scenario !== "booking2",
			["pisell-lowcode-product-card-image-booking2"]: scenario === "booking2"
		}),
		key: _id
	}, /* @__PURE__ */ react.default.createElement(react.default.Fragment, null, /* @__PURE__ */ react.default.createElement("div", { onClick: (e) => {
		e.preventDefault();
		e.stopPropagation();
		onCard === null || onCard === void 0 || onCard(dataSource);
	} }, /* @__PURE__ */ react.default.createElement(require_index$2.default, require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({}, other), {}, {
		item: dataSource,
		isShowImage,
		isShowDelete,
		isShowEditProduct,
		showImage,
		onEditProduct: () => onEditProduct === null || onEditProduct === void 0 ? void 0 : onEditProduct(dataSource),
		onDelete: () => {
			onDelete === null || onDelete === void 0 || onDelete(dataSource);
		}
	})), /* @__PURE__ */ react.default.createElement(require_index$3.default, {
		item: dataSource,
		isShowHolder,
		isShowChangeResource: other === null || other === void 0 ? void 0 : other.isShowChangeResource,
		isShowChangeHolder: other === null || other === void 0 ? void 0 : other.isShowChangeHolder,
		holderMode: other === null || other === void 0 ? void 0 : other.holderMode,
		onLike: (item) => onLike === null || onLike === void 0 ? void 0 : onLike(item),
		changeResource: onChangeResource,
		changeHolder: onChangeHolder,
		onAddHolder: other === null || other === void 0 ? void 0 : other.onAddHolder,
		isShowAddHolderButton: other === null || other === void 0 ? void 0 : other.isShowAddHolderButton,
		onClearResource: other === null || other === void 0 ? void 0 : other.onClearResource,
		onClearHolder: other === null || other === void 0 ? void 0 : other.onClearHolder
	}), /* @__PURE__ */ react.default.createElement(require_index$6.default, {
		item: dataSource,
		isShowPackageNote
	}), /* @__PURE__ */ react.default.createElement(require_index$7.default, {
		item: dataSource,
		isShowNote
	}), ((_dataSource$items = dataSource.items) === null || _dataSource$items === void 0 ? void 0 : _dataSource$items.length) ? /* @__PURE__ */ react.default.createElement(require_index$8.default, {
		dataSource,
		hideDivider
	}) : /* @__PURE__ */ react.default.createElement(require_index$4.default, {
		item: dataSource,
		hideDivider,
		type: "total"
	}), isShowNote ? /* @__PURE__ */ react.default.createElement(require_index$5.default, require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({}, other), {}, {
		item: dataSource,
		openNote: () => {
			useOpenNoteRef.current.open({ item: dataSource });
		}
	})) : null, isShowAction && actionText ? /* @__PURE__ */ react.default.createElement(require_index$9.default, {
		item: dataSource,
		onAction: () => onAction === null || onAction === void 0 ? void 0 : onAction(dataSource)
	}) : null, /* @__PURE__ */ react.default.createElement(require_index$10.default, {
		errorMessage,
		osWarnTips
	})), /* @__PURE__ */ react.default.createElement(require_useOpenNote.default, {
		ref: useOpenNoteRef,
		onNoteChange: (e) => {
			onNote === null || onNote === void 0 || onNote(require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({}, dataSource), {}, { note: e || "" }));
		}
	}))));
};
ProductCard.V2 = require_index$11.default;
//#endregion
exports.default = ProductCard;
