require("../../../../../_virtual/_rolldown/runtime.js");
const require_objectSpread2 = require("../../../../../_virtual/_@oxc-project_runtime@0.122.0/helpers/objectSpread2.js");
const require_utils = require("../../utils.js");
let _pisell_utils = require("@pisell/utils");
let _pisell_materials = require("@pisell/materials");
//#region src/components/pay/toC/PaymentMethods/WalletPass/utils.ts
const voucherTime = (data) => {
	const config = _pisell_materials.globalConfig.getConfig();
	if (data === null || data === void 0 ? void 0 : data.expire_date) return (0, _pisell_utils.formatDate)(data === null || data === void 0 ? void 0 : data.expire_date, (config === null || config === void 0 ? void 0 : config.locale) === "en" ? "DD/MM/YYYY" : "YYYY-MM-DD");
	return _pisell_utils.locales.getText("tocPay.text.walletPassPermanent");
};
const formatMachineCodeServer2CardList = (data, selectId = []) => {
	return (data || []).map((item) => {
		var _item$shop, _item$unified_message, _item$product, _item$custom_schedule, _item$metadata;
		return {
			id: item.id,
			name: item.product_name,
			storeName: (_item$shop = item.shop) === null || _item$shop === void 0 ? void 0 : _item$shop.name,
			balance: item.balance_par_value,
			redeem: require_utils.getAvailableMaxAmount(item),
			showRedeem: selectId.includes(item.id),
			showBalanceSymbol: item.tag !== "point_card",
			showDetail: false,
			showQrCode: false,
			code: item.code,
			disabled: (0, _pisell_utils.isNumber)(item._unified_available_status) ? !item._unified_available_status : !item.unified_available_status,
			disabledReason: (0, _pisell_utils.isNumber)(item._unified_available_status) ? item.reason : (_item$unified_message = item.unified_messages) === null || _item$unified_message === void 0 ? void 0 : _item$unified_message.title,
			cover: (_item$product = item.product) === null || _item$product === void 0 ? void 0 : _item$product.cover,
			qrCode: item.code,
			validDate: voucherTime(item),
			originData: item,
			scheduleList: ((_item$custom_schedule = item.custom_schedule_snapshot) === null || _item$custom_schedule === void 0 ? void 0 : _item$custom_schedule.data) || [],
			validDateBySchedule: ((_item$metadata = item.metadata) === null || _item$metadata === void 0 ? void 0 : _item$metadata.validity_type) === "custom_schedule_validity"
		};
	});
};
const getDataByIds = (arr, ids) => {
	return arr.filter((item) => ids.includes(item.id));
};
/**
* 判断是否是wallet code
* @param val 
* @returns 
*/
const getIsWalletCode = (val) => {
	return val.startsWith("WL");
};
const formatWalletPassWithUniquePaymentNumber = (currentWalletPass) => {
	return require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({}, currentWalletPass), {}, { cards: ((currentWalletPass === null || currentWalletPass === void 0 ? void 0 : currentWalletPass.cards) || []).map((item) => {
		return require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({}, item), {}, { metadata: require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({}, item.metadata || {}), {}, { unique_payment_number: (0, _pisell_utils.getUniqueId)() }) });
	}) });
};
//#endregion
exports.formatMachineCodeServer2CardList = formatMachineCodeServer2CardList;
exports.formatWalletPassWithUniquePaymentNumber = formatWalletPassWithUniquePaymentNumber;
exports.getDataByIds = getDataByIds;
exports.getIsWalletCode = getIsWalletCode;
