var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
  for (var name in all)
    __defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
  if (from && typeof from === "object" || typeof from === "function") {
    for (let key of __getOwnPropNames(from))
      if (!__hasOwnProp.call(to, key) && key !== except)
        __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  }
  return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);

// src/components/pay/toC/PaymentMethods/WalletPass/utils.ts
var utils_exports = {};
__export(utils_exports, {
  formatMachineCodeServer2CardList: () => formatMachineCodeServer2CardList,
  getDataByIds: () => getDataByIds
});
module.exports = __toCommonJS(utils_exports);
var import_utils = require("@pisell/utils");
var import_materials = require("@pisell/materials");
var import_utils2 = require("../../utils");
var voucherTime = (data) => {
  const config = import_materials.globalConfig.getConfig();
  if (data == null ? void 0 : data.expire_date) {
    return (0, import_utils.formatDate)(
      data == null ? void 0 : data.expire_date,
      (config == null ? void 0 : config.locale) === "en" ? "DD/MM/YYYY" : "YYYY-MM-DD"
    );
  }
  return import_utils.locales.getText("tocPay.text.walletPassPermanent");
};
var formatMachineCodeServer2CardList = (data, selectId = []) => {
  return (data || []).map((item) => {
    var _a, _b, _c;
    return {
      id: item.id,
      name: item.product_name,
      storeName: (_a = item.shop) == null ? void 0 : _a.name,
      balance: item.balance_par_value,
      redeem: (0, import_utils2.getAvailableMaxAmount)(item),
      showRedeem: selectId.includes(item.id),
      showBalanceSymbol: item.tag !== "point_card",
      // balanceTitle: item.tag !== 'point_card' ? "" : "",
      // redeemTitle: item.tag !== 'point_card' ? "" : "",
      showDetail: false,
      showQrCode: false,
      code: item.code,
      disabled: !item.unified_available_status,
      disabledReason: (_b = item.unified_messages) == null ? void 0 : _b.title,
      cover: (_c = item.product) == null ? void 0 : _c.cover,
      qrCode: item.code,
      validDate: voucherTime(item),
      originData: item
    };
  });
};
var getDataByIds = (arr, ids) => {
  return arr.filter((item) => ids.includes(item.id));
};
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  formatMachineCodeServer2CardList,
  getDataByIds
});
