import { _objectSpread2 } from "../../_virtual/_@oxc-project_runtime@0.122.0/helpers/objectSpread2.js";
import { _asyncToGenerator } from "../../_virtual/_@oxc-project_runtime@0.122.0/helpers/asyncToGenerator.js";
import { request } from "../../utils/index.js";
//#region src/components/shoppingCart/server.ts
const getProducts = function() {
	var _ref = _asyncToGenerator(function* (params) {
		const { ids, isGift = false, schedule_date } = params;
		const queryParams = {
			skip: 1,
			num: (ids === null || ids === void 0 ? void 0 : ids.length) || 100,
			status: "published",
			ids: ids || [],
			open_quotation: 1,
			schedule_date: schedule_date || void 0,
			open_bundle: 1,
			is_eject: 1,
			open_deposit: 1,
			force_ignore_cache_flag: 1,
			is_append_product_description: 1,
			with_category_tree: 1,
			category_ids: [],
			collection: [],
			with_count: ["bundleGroup", "optionGroup"],
			exclude_extension_type: [
				"product_party",
				"product_event",
				"product_series_event",
				"product_package_ticket",
				"ticket",
				"event_item"
			],
			with: [
				"category",
				"collection",
				"resourceRelation",
				"bundleGroup.bundleItem",
				"optionGroup.optionItem",
				"variantGroup.variantItem"
			]
		};
		let { data } = yield request.getRequest().post("/shop/product/query", queryParams, {
			fullResult: true,
			useCache: true
		});
		let lists = [];
		if (isGift) {
			var _data$list;
			lists = data === null || data === void 0 || (_data$list = data.list) === null || _data$list === void 0 ? void 0 : _data$list.map((item) => {
				const originPrice = (item === null || item === void 0 ? void 0 : item.price) || 0;
				return _objectSpread2(_objectSpread2({}, item), {}, {
					price: 0,
					base_price: 0,
					origin_price: originPrice,
					total: 0,
					origin_total: originPrice,
					_extend: {
						price: 0,
						total: 0,
						origin_total: originPrice,
						quantity: (item === null || item === void 0 ? void 0 : item.num) || 1
					},
					_initPrice: (item === null || item === void 0 ? void 0 : item.price) || 0
				});
			});
		} else {
			var _data$list2;
			lists = lists = data === null || data === void 0 || (_data$list2 = data.list) === null || _data$list2 === void 0 ? void 0 : _data$list2.map((item) => {
				const originPrice = (item === null || item === void 0 ? void 0 : item.origin_price) || 0;
				return _objectSpread2(_objectSpread2({}, item), {}, {
					total: (item === null || item === void 0 ? void 0 : item.price) || 0,
					origin_total: originPrice,
					_extend: {
						price: (item === null || item === void 0 ? void 0 : item.price) || 0,
						total: (item === null || item === void 0 ? void 0 : item.price) || 0,
						origin_total: originPrice,
						quantity: (item === null || item === void 0 ? void 0 : item.num) || 1
					}
				});
			});
		}
		return lists || [];
	});
	return function getProducts(_x) {
		return _ref.apply(this, arguments);
	};
}();
const getProductDetail = function() {
	var _ref2 = _asyncToGenerator(function* (params) {
		const { id, is_eject = 1 } = params;
		const queryParams = { is_eject };
		let { data } = yield request.getRequest().get(`/shop/product/query/${id}`, queryParams, {
			fullResult: true,
			useCache: true
		});
		return data || {};
	});
	return function getProductDetail(_x2) {
		return _ref2.apply(this, arguments);
	};
}();
//#endregion
export { getProductDetail, getProducts };
