/**
 * Helper utility to accurately classify agricultural products.
 * Identifies whether a product is a Maize seed hybrid or non-maize product.
 */
export function isMaizeProduct(
  name?: string,
  description?: string,
  category?: string,
): boolean {
  const text =
    `${name || ''} ${description || ''} ${category || ''}`.toLowerCase();

  // Known non-maize crops, vegetables, and field crops
  const nonMaizeSCVarieties = [
    'sc select',
    'sc nduna',
    'sc serena',
    'sc w9101',
    'sc status',
    'sc spike',
    'sc safari',
    'sc serenade',
    'sc bounty',
    'sc smile',
    'sc sila',
    'sc shop o1',
    'xh102',
  ];

  for (const nonSc of nonMaizeSCVarieties) {
    if ((name || '').toLowerCase().includes(nonSc)) {
      return false;
    }
  }

  // Explicit Maize / Mealies indicators
  if (
    text.includes('white maize') ||
    text.includes('yellow maize') ||
    text.includes('maize seed') ||
    text.includes('mealies')
  ) {
    return true;
  }

  // Standard Seed Co hybrid maize codes:
  // SC 301, SC 303, SC 403, SC 419, SC 513, SC 529, SC 555, SC 608, SC 649, SC 657, SC 659, SC 661, SC 719, SC 727, SC 733
  if (
    /^SC\s*(301|303|403|419|513|529|555|608|649|657|659|661|719|727|733)(\b|\s|$)/i.test(
      (name || '').trim(),
    )
  ) {
    return true;
  }

  return false;
}
