export default function ProfilePrestigeStats({ prestige }) {
  if (!prestige || !prestige.count) return null;

  const rows = [
    (() => {
      try {
        return BigInt(String(prestige.prBalance ?? 0)) > 0n;
      } catch {
        return false;
      }
    })()
      ? { label: 'Pr', value: <strong>{String(prestige.prBalance)}</strong> }
      : null,
    { label: 'Fortune', value: <strong>+{prestige.chanceBonus}%</strong> },
    { label: 'Yield', value: <strong>+{prestige.gainBonus}%</strong> },
    (prestige.wearBonus || 0) > 0 && {
      label: 'Polish',
      value: <strong>+{prestige.wearBonus}</strong>,
    },
    (prestige.openBonus || 0) > 0 && {
      label: 'Bulk',
      value: <strong>+{prestige.openBonus} opens</strong>,
    },
    (prestige.prBonus || 0) > 0 && {
      label: 'PR Farmer',
      value: <strong>+{prestige.prBonus}%</strong>,
    },
    (prestige.qualityBonus || 0) > 0 && {
      label: 'Quality',
      value: <strong>+{prestige.qualityBonus}</strong>,
    },
    (prestige.animReduction || 0) > 0 && {
      label: 'noTime',
      value: <strong>−{prestige.animReduction}%</strong>,
    },
    (prestige.refundChance || 0) > 0 && {
      label: 'Refund',
      value: <strong>{prestige.refundChance}%</strong>,
    },
    (prestige.respinChance || 0) > 0 && {
      label: 'Respin',
      value: <strong>{prestige.respinChance}%</strong>,
    },
    (prestige.vaultSlots || 0) > 0 && {
      label: 'Vault Capacity',
      value: <strong>+{prestige.vaultSlots}</strong>,
    },
    (prestige.offlineYield || 0) > 0 && {
      label: 'Offline Yield',
      value: <strong>+{prestige.offlineYield}%</strong>,
    },
    (prestige.onlineYield || 0) > 0 && {
      label: 'Online Yield',
      value: <strong>+{prestige.onlineYield}%</strong>,
    },
  ].filter(Boolean);

  return (
    <div className="prestige-profile-block">
      <div className="catalog-badges-head">
        <h3>Prestige</h3>
        <span className="catalog-badges-luck">×{prestige.count}</span>
      </div>
      <ul className="stat-list prestige-profile-stats">
        {rows.map((row) => (
          <li key={row.label}>
            {row.label} {row.value}
          </li>
        ))}
      </ul>
    </div>
  );
}
