const require_runtime = require("../../../../_virtual/_rolldown/runtime.js");
const require_useContext = require("../../hooks/useContext.js");
const require_index = require("../Empty/index.js");
const require_index$1 = require("../SelectHolderModal/index.js");
const require_index$2 = require("../Cart/index.js");
let react = require("react");
react = require_runtime.__toESM(react);
let classnames = require("classnames");
classnames = require_runtime.__toESM(classnames);
require("./index.less");
//#region src/components/shoppingCart/components/Render/index.tsx
const Content = () => {
	const { state, onChange } = require_useContext.useContext();
	const selectPetRef = (0, react.useRef)();
	const [pet, setPet] = (0, react.useState)([]);
	const { isEmpty, className, holders, products, isEdit, platform } = state;
	/**
	* @title: 监听holder发生变化
	* @description:
	* @return {*}
	* @Author: WangHan
	* @Date: 2024-12-09 18:06
	*/
	(0, react.useEffect)(() => {
		let _holders = holders === null || holders === void 0 ? void 0 : holders.filter((item) => (item === null || item === void 0 ? void 0 : item.key) > 0);
		if ((_holders === null || _holders === void 0 ? void 0 : _holders.length) && !(pet === null || pet === void 0 ? void 0 : pet.length) && (products === null || products === void 0 ? void 0 : products.length) && !isEdit && platform !== "h5") if (_holders.length === 1) {
			var _holders$;
			onChange(products, "update_holders", (_holders$ = _holders[0]) === null || _holders$ === void 0 ? void 0 : _holders$.key);
			return;
		} else {
			var _selectPetRef$current, _selectPetRef$current2;
			(_selectPetRef$current = selectPetRef.current) === null || _selectPetRef$current === void 0 || (_selectPetRef$current2 = _selectPetRef$current.open) === null || _selectPetRef$current2 === void 0 || _selectPetRef$current2.call(_selectPetRef$current, {
				products,
				holders
			});
		}
		setPet(_holders);
	}, [holders]);
	return /* @__PURE__ */ react.default.createElement(react.default.Fragment, null, /* @__PURE__ */ react.default.createElement("div", { className: (0, classnames.default)("pisell-lowcode__shopping-cart-wrap", className) }, isEmpty ? /* @__PURE__ */ react.default.createElement(require_index.default, null) : /* @__PURE__ */ react.default.createElement(require_index$2.default, null)), /* @__PURE__ */ react.default.createElement(require_index$1.default, {
		ref: selectPetRef,
		onChange
	}));
};
//#endregion
exports.default = Content;
