namespace Meezi.Infrastructure.Data;

/// <summary>
/// Unsplash fallbacks per Food-101 class folder name (Kaggle dataset layout).
/// Used when menu-image-manifest.json has no entry or local JPEG was not imported.
/// </summary>
public static class Food101ImageFallbacks
{
    private static readonly Dictionary<string, string> ClassUrls = new(StringComparer.OrdinalIgnoreCase)
    {
        ["apple_pie"] = "https://images.unsplash.com/photo-1535920527002-b43e668c3097?w=600",
        ["avocado_toast"] = "https://images.unsplash.com/photo-1541519221064-49632fb3380e?w=600",
        ["baklava"] = "https://images.unsplash.com/photo-1598110756419-84b30681f41f?w=600",
        ["beef_carpaccio"] = "https://images.unsplash.com/photo-1600891963295-d66a269b9202?w=600",
        ["beef_tartare"] = "https://images.unsplash.com/photo-1600891963295-d66a269b9202?w=600",
        ["beet_salad"] = "https://images.unsplash.com/photo-1512621776951-a57141f2eefd?w=600",
        ["bruschetta"] = "https://images.unsplash.com/photo-1572695157366-8486c5880882?w=600",
        ["brownie"] = "https://images.unsplash.com/photo-1606313564200-e75d5e30476e?w=600",
        ["caesar_salad"] = "https://images.unsplash.com/photo-1546793665-c74683f339c1?w=600",
        ["caprese_salad"] = "https://images.unsplash.com/photo-1592417817098-8fd3d9eb14a5?w=600",
        ["cappuccino"] = "https://images.unsplash.com/photo-1572442388796-11668a67e3d0?w=600",
        ["carrot_cake"] = "https://images.unsplash.com/photo-1621303837534-610466b814da?w=600",
        ["cheesecake"] = "https://images.unsplash.com/photo-1524351199678-941a58cfcc36?w=600",
        ["chocolate_cake"] = "https://images.unsplash.com/photo-1578985545062-69928b1d9587?w=600",
        ["churros"] = "https://images.unsplash.com/photo-1627482299165-0883a056a48f?w=600",
        ["club_sandwich"] = "https://images.unsplash.com/photo-1528735602780-2552fd46c7af?w=600",
        ["creme_brulee"] = "https://images.unsplash.com/photo-1470309864661-683be0ef7eaf?w=600",
        ["croque_madame"] = "https://images.unsplash.com/photo-1555507036342-9231d37c10f3?w=600",
        ["cup_cakes"] = "https://images.unsplash.com/photo-1614707267537-b85a1e38f271?w=600",
        ["donuts"] = "https://images.unsplash.com/photo-1551024506-0bccd28d3071?w=600",
        ["dumplings"] = "https://images.unsplash.com/photo-1496116218417-1a781a1c08c2?w=600",
        ["edamame"] = "https://images.unsplash.com/photo-1459411621453-7b03977d4a4d?w=600",
        ["eggs_benedict"] = "https://images.unsplash.com/photo-1608039819502-3d5a2a2e0b0e?w=600",
        ["espresso"] = "https://images.unsplash.com/photo-1509042239860-f550ce710b93?w=600&auto=format&fit=crop",
        ["falafel"] = "https://images.unsplash.com/photo-1601050690597-df5748fb5cee?w=600",
        ["french_fries"] = "https://images.unsplash.com/photo-1573080496219-76b9e6909700?w=600",
        ["french_toast"] = "https://images.unsplash.com/photo-1484723091739-30a329e1f0c4?w=600",
        ["fried_calamari"] = "https://images.unsplash.com/photo-1599487488170-d11ec9c172f0?w=600",
        ["garlic_bread"] = "https://images.unsplash.com/photo-1619535852122-9f0362cc8b0e?w=600",
        ["gnocchi"] = "https://images.unsplash.com/photo-1551183053-bf33a48c970a?w=600",
        ["greek_salad"] = "https://images.unsplash.com/photo-1540189549336-e6e99c3679fe?w=600",
        ["grilled_cheese_sandwich"] = "https://images.unsplash.com/photo-1528735602780-2552fd46c7af?w=600",
        ["grilled_salmon"] = "https://images.unsplash.com/photo-1467003909585-2f8a72700288?w=600",
        ["guacamole"] = "https://images.unsplash.com/photo-1529084963126-48f862a7038c?w=600",
        ["hamburger"] = "https://images.unsplash.com/photo-1568901346375-23c9450c58cd?w=600",
        ["hot_and_sour_soup"] = "https://images.unsplash.com/photo-1547592160-23ac45744acd?w=600",
        ["hot_dog"] = "https://images.unsplash.com/photo-1612392062631-94de6c5a533f?w=600",
        ["hummus"] = "https://images.unsplash.com/photo-1626208082043-e6319abfeec2?w=600",
        ["ice_cream"] = "https://images.unsplash.com/photo-1563805042-7684c019e1cb?w=600",
        ["iced_coffee"] = "https://images.unsplash.com/photo-1517487881594-2787aeee8f58?w=600&auto=format&fit=crop",
        ["lasagna"] = "https://images.unsplash.com/photo-1574894709920-11b28e7367e3?w=600",
        ["latte"] = "https://images.unsplash.com/photo-1461023058943-07fcbe16d735?w=600",
        ["lemonade"] = "https://images.unsplash.com/photo-1523672990561-64c16245f769?w=600",
        ["lobster_bisque"] = "https://images.unsplash.com/photo-1547592160-23ac45744acd?w=600",
        ["macaroni_and_cheese"] = "https://images.unsplash.com/photo-1543339493-18da843d4cb4?w=600",
        ["miso_soup"] = "https://images.unsplash.com/photo-1556679343-c7306c1976bc?w=600",
        ["mocha"] = "https://images.unsplash.com/photo-1577887233537-a81b387b125e?w=600",
        ["mushroom_risotto"] = "https://images.unsplash.com/photo-1476124362071-b9f2c96ef2db?w=600",
        ["nachos"] = "https://images.unsplash.com/photo-1513459032971-41fd1e48ff3c?w=600",
        ["omelette"] = "https://images.unsplash.com/photo-1525351484343-752d43d363f1?w=600",
        ["onion_rings"] = "https://images.unsplash.com/photo-1630431341973-02b95b531aa4?w=600",
        ["oysters"] = "https://images.unsplash.com/photo-1514392043407-4f468d2f5c9e?w=600",
        ["paella"] = "https://images.unsplash.com/photo-1534084650011-4c4d81e8ca4b?w=600",
        ["pancakes"] = "https://images.unsplash.com/photo-1567620905732-2d1ec7ab7440?w=600",
        ["panna_cotta"] = "https://images.unsplash.com/photo-1488477181946-6428a029177a?w=600",
        ["pasta_carbonara"] = "https://images.unsplash.com/photo-1621996346565-e3dbc646d9a9?w=600",
        ["pho"] = "https://images.unsplash.com/photo-1591814468924-caf36d123dd6?w=600",
        ["pizza"] = "https://images.unsplash.com/photo-1513104890138-7c749659a591?w=600",
        ["pork_chop"] = "https://images.unsplash.com/photo-1432139558640-143f293648c5?w=600",
        ["prime_rib"] = "https://images.unsplash.com/photo-1546833999-b9f581a1996d?w=600",
        ["ramen"] = "https://images.unsplash.com/photo-1569718212165-3a8278d5f624?w=600",
        ["risotto"] = "https://images.unsplash.com/photo-1476124362071-b9f2c96ef2db?w=600",
        ["samosa"] = "https://images.unsplash.com/photo-1601050690597-df5748fb5cee?w=600",
        ["sashimi"] = "https://images.unsplash.com/photo-1579584425555-c3ce17fd4351?w=600",
        ["scallops"] = "https://images.unsplash.com/photo-1599021452684-36e82be5777f?w=600",
        ["shawarma"] = "https://images.unsplash.com/photo-1529006557810-274adbcb39d8?w=600",
        ["smoothie"] = "https://images.unsplash.com/photo-1505252585463-0433371f7f6b?w=600",
        ["spaghetti_bolognese"] = "https://images.unsplash.com/photo-1622973536968-77544a8a4e0e?w=600",
        ["spaghetti_carbonara"] = "https://images.unsplash.com/photo-1612874741227-866d1aeeecd1?w=600",
        ["spring_rolls"] = "https://images.unsplash.com/photo-1526318896985-4d29c0903299?w=600",
        ["steak"] = "https://images.unsplash.com/photo-1600891963295-d66a269b9202?w=600",
        ["strawberry_shortcake"] = "https://images.unsplash.com/photo-1464349095436-e59b7d591c4f?w=600",
        ["sushi"] = "https://images.unsplash.com/photo-1579584425555-c3ce17fd4351?w=600",
        ["tacos"] = "https://images.unsplash.com/photo-1565299585323-38174c4aab1e?w=600",
        ["tiramisu"] = "https://images.unsplash.com/photo-1571877227200-a0d98ea607e9?w=600",
        ["tuna_tartare"] = "https://images.unsplash.com/photo-1544025162-d766942659778?w=600",
        ["waffles"] = "https://images.unsplash.com/photo-1567818735240-7acbb4b7e34c?w=600",
    };

    public static bool TryGetUrl(string food101Class, out string url)
    {
        if (ClassUrls.TryGetValue(food101Class, out var found) && !string.IsNullOrWhiteSpace(found))
        {
            url = found;
            return true;
        }

        url = "";
        return false;
    }

    public static string Resolve(string? food101Class, MenuItemVisualKind kind)
    {
        if (!string.IsNullOrWhiteSpace(food101Class) && TryGetUrl(food101Class, out var url))
            return url;

        return MenuItemImageDefaults.GetDefaultImageUrl(kind);
    }
}
