/**
 * Card Generator Configuration
 * 卡类型配置
 */

const CARD_TYPES = {
  unionpay: {
    name: '中国银联 (UnionPay)',
    // 支持多个前缀，避免短时间内重复使用同一BIN触发风控
    prefixes: [
      '622836754',  // 原始BIN（已验证可用）
      '622836740', '622836741', '622836742', '622836743',
      '622836744', '622836745', '622836746', '622836747',
      '622836748', '622836749', '622836750', '622836751',
      '622836752', '622836753', '622836755', '622836756',
      '622836757', '622836758', '622836759'
    ],
    length: 16,
    cvvLength: 3,
    useLuhn: true  // 使用Luhn算法校验
  },
  visa: {
    name: 'Visa',
    prefix: '4',
    length: 16,
    cvvLength: 3,
    useLuhn: true
  },
  mastercard: {
    name: 'MasterCard',
    prefix: '5',
    length: 16,
    cvvLength: 3,
    useLuhn: true
  },
  amex: {
    name: 'American Express',
    prefix: '34',
    length: 15,
    cvvLength: 4,
    useLuhn: true
  },
  discover: {
    name: 'Discover',
    prefix: '6011',
    length: 16,
    cvvLength: 3,
    useLuhn: true
  }
};

/**
 * 有效期配置
 */
const EXPIRY_CONFIG = {
  minYear: 26,  // 2026
  maxYear: 30,  // 2030
  minMonth: 1,
  maxMonth: 12
};

/**
 * 输出格式配置
 */
const OUTPUT_FORMATS = {
  pipe: {
    name: 'Pipe分隔 (|)',
    formatter: (card) => `${card.number}|${card.month}|${card.year}|${card.cvv}`
  },
  json: {
    name: 'JSON格式',
    formatter: (card) => JSON.stringify(card, null, 2)
  },
  csv: {
    name: 'CSV格式',
    formatter: (card) => `${card.number},${card.month},${card.year},${card.cvv}`
  },
  pretty: {
    name: '美化格式',
    formatter: (card) => `
Card Number: ${card.number}
Expiry Date: ${card.month}/${card.year}
CVV: ${card.cvv}
Type: ${card.type}
    `.trim()
  }
};

module.exports = {
  CARD_TYPES,
  EXPIRY_CONFIG,
  OUTPUT_FORMATS
};
