const require_objectSpread2 = require("../../_virtual/_@oxc-project_runtime@0.122.0/helpers/objectSpread2.js");
//#region src/components/shoppingCart/utils.ts
/**
* @title: 格式化购物车列表
* @description: 
* @param {any} state
* @return {*}
* @Author: WangHan
* @Date: 2024-11-28 16:52
*/
const formatCartList = (state) => {
	const { products, holders } = state;
	return holders === null || holders === void 0 ? void 0 : holders.map((holder) => {
		return require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({}, holder), {}, { products: products === null || products === void 0 ? void 0 : products.filter((product) => (product === null || product === void 0 ? void 0 : product.holder_id) === (holder === null || holder === void 0 ? void 0 : holder.key)) });
	});
};
/**
* @title: 是否是空页面
* @description: 
* @param {any} state
* @return {*}
* @Author: WangHan
* @Date: 2024-11-28 16:47
*/
const isEmptyStatus = (state) => {
	const { products, holders, isOpenGroup } = state;
	if (!isOpenGroup && !(products === null || products === void 0 ? void 0 : products.length)) return true;
	if (isOpenGroup && !(holders === null || holders === void 0 ? void 0 : holders.length)) return true;
	return false;
};
/**
* @title: 是否是商品列表页面
* @description: 
* @param {any} state
* @return {*}
* @Author: WangHan
* @Date: 2024-11-28 17:23
*/
const isProductList = (state) => {
	const { holders, isOpenGroup } = state;
	if (isOpenGroup && (holders === null || holders === void 0 ? void 0 : holders.length)) return false;
	return true;
};
/**
* @title: 格式化数据最终结果
* @description: 
* @param {any} state
* @return {*}
* @Author: WangHan
* @Date: 2024-11-28 18:35
*/
const formatState = (state) => {
	const _default = require_objectSpread2._objectSpread2({}, state);
	const _carts = formatCartList(_default);
	return {
		isEmpty: isEmptyStatus(_default),
		isProductList: isProductList(_default),
		carts: _carts
	};
};
/**
* @title: 格式化服务
* @description: 
* @param {any} service
* @param {number} id holder_id
* @return {*}
* @Author: WangHan
* @Date: 2024-12-09 22:47
*/
const formatService = (service, id) => {
	return service.map((item) => {
		return require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({}, item), {}, { holder_id: id });
	});
};
//#endregion
exports.formatService = formatService;
exports.formatState = formatState;
