﻿using System.Collections.Generic;
using System.Linq;

namespace McBits.LibNutrition
{
	public static class UsdaData
	{
		public static Dictionary<string, NutrientDefinition> NutrientDefinitions = new Dictionary<string, NutrientDefinition>();

		public static Dictionary<string, HashSet<NutrientData>> NutrientData = new Dictionary<string, HashSet<NutrientData>>();

		public static Dictionary<string, Food> FoodDescriptions = new Dictionary<string, Food>();

		public static Dictionary<string, HashSet<Weight>> FoodWeights = new Dictionary<string, HashSet<Weight>>();

		public static NutrientData GetNutrientForFood(string foodId, string nutrientId)
		{
			if (!NutrientData.TryGetValue(foodId, out var set))
				return null;

			return set.FirstOrDefault(item => item.NutrientId == nutrientId);
		}

		public static Dictionary<string, FoodGroup> FoodGroups = new Dictionary<string, FoodGroup>();
	}
}
