/** 面额配置唯一键，用于数量映射 */
export var getDenominationId = function getDenominationId(item) {
  return "".concat(item.currency_code, "-").concat(item.denomination_type, "-").concat(item.denomination_value);
};

/** 按小数位规范化金额，避免浮点误差 */
export var normalizeAmount = function normalizeAmount(value, precision) {
  var numberValue = Number(String(value !== null && value !== void 0 ? value : 0).replace(/,/g, ''));
  if (!Number.isFinite(numberValue)) {
    return 0;
  }
  var factor = Math.pow(10, precision);
  return Math.round(numberValue * factor) / factor;
};

/** 业务规则：是否可作为有效面额参与点钞 */
export var isEffectiveDenomination = function isEffectiveDenomination(item) {
  if (item.is_enabled === false) {
    return false;
  }
  if (item.effective_status === false || item.effective_status === 'inactive') {
    return false;
  }
  return true;
};

/** 当前币种下已启用且排序后的面额列表 */
export var getEffectiveDenominationsForCurrency = function getEffectiveDenominationsForCurrency(denominations, currencyCode) {
  return denominations.filter(function (item) {
    return item.currency_code === currencyCode && isEffectiveDenomination(item);
  }).sort(function (a, b) {
    return a.sort_order - b.sort_order;
  });
};
export var buildEmptyQuantities = function buildEmptyQuantities(items) {
  return items.reduce(function (acc, item) {
    acc[getDenominationId(item)] = 0;
    return acc;
  }, {});
};