require("../../../_virtual/_rolldown/runtime.js");
const require_formatTime = require("./formatTime.js");
let _pisell_utils = require("@pisell/utils");
//#region src/components/ticketBooking/utils/formatProductMessage.ts
const formatProductMessage = (product, utils) => {
	const { product_option_string, options, bundle, currency_symbol, start_date, end_date, holder_id, holders, multiResources } = product;
	let str = "";
	if (start_date && end_date) str += `${require_formatTime.getServiceTime(product, start_date, utils)} \n`;
	if (holder_id && Array.isArray(holders)) {
		const targetHolder = holders.find((holder) => holder.id === holder_id);
		if (targetHolder === null || targetHolder === void 0 ? void 0 : targetHolder.label) str += `${targetHolder.label} \n`;
	}
	if (Array.isArray(multiResources) && multiResources.length > 0) multiResources.forEach((resource) => {
		const { id: ids, lists } = resource;
		if (Array.isArray(ids)) ids.forEach((id) => {
			const targetRes = lists.find((l) => l.id === id);
			if (targetRes === null || targetRes === void 0 ? void 0 : targetRes.label) str += `${targetRes === null || targetRes === void 0 ? void 0 : targetRes.label} \n`;
		});
		else {
			const targetRes = lists.find((l) => l.id === ids);
			if (targetRes === null || targetRes === void 0 ? void 0 : targetRes.label) str += `${targetRes === null || targetRes === void 0 ? void 0 : targetRes.label} \n`;
		}
	});
	if (product_option_string) str += `${product_option_string}\n`;
	if (Array.isArray(options) && options.length) options.forEach((opt) => {
		str += `${opt.name}  ${(0, _pisell_utils.formatAmount)(opt === null || opt === void 0 ? void 0 : opt.price, 2, currency_symbol)} x ${opt.num}\n`;
	});
	if (Array.isArray(bundle) && bundle.length) bundle.forEach((item) => {
		str += `${item.title}  ${(0, _pisell_utils.formatAmount)(item.price, 2, currency_symbol)} x ${item.num}\n`;
		const bundleOptions = item === null || item === void 0 ? void 0 : item.options;
		if (Array.isArray(bundleOptions) && bundleOptions.length) bundleOptions.forEach((opt) => {
			str += `  ${opt === null || opt === void 0 ? void 0 : opt.name}  ${(0, _pisell_utils.formatAmount)(opt === null || opt === void 0 ? void 0 : opt.price, 2, currency_symbol)} x ${opt === null || opt === void 0 ? void 0 : opt.num}\n`;
		});
	});
	return str;
};
//#endregion
exports.default = formatProductMessage;
