import type { DemandWindows, InventoryEnvConfig, SkuDefinition } from "@/lib/inventoryRl/types";

export const DEFAULT_SKUS: SkuDefinition[] = [
  { id: "glazed", name: "Glazed Donut", category: "donuts", shelfLifeHours: 12, unitCost: 0.35, unitPrice: 1.29, minOrder: 12 },
  { id: "sprinkle", name: "Sprinkle Donut", category: "donuts", shelfLifeHours: 12, unitCost: 0.38, unitPrice: 1.39, minOrder: 12 },
  { id: "chocolate", name: "Chocolate Donut", category: "donuts", shelfLifeHours: 12, unitCost: 0.4, unitPrice: 1.49, minOrder: 12 },
  { id: "boston_cream", name: "Boston Cream", category: "donuts", shelfLifeHours: 12, unitCost: 0.42, unitPrice: 1.59, minOrder: 12 },
  { id: "jelly", name: "Jelly Donut", category: "donuts", shelfLifeHours: 12, unitCost: 0.38, unitPrice: 1.39, minOrder: 12 },
  { id: "bacon_egg_cheese", name: "Bacon Egg & Cheese", category: "sandwiches", shelfLifeHours: 4, unitCost: 1.2, unitPrice: 4.49, minOrder: 6 },
  { id: "sausage_egg_cheese", name: "Sausage Egg & Cheese", category: "sandwiches", shelfLifeHours: 4, unitCost: 1.1, unitPrice: 4.29, minOrder: 6 },
  { id: "turkey_cheddar", name: "Turkey Cheddar", category: "sandwiches", shelfLifeHours: 4, unitCost: 1.5, unitPrice: 5.49, minOrder: 6 },
  { id: "coffee_small", name: "Coffee Small", category: "beverages", shelfLifeHours: 2, unitCost: 0.25, unitPrice: 1.99, minOrder: 1 },
  { id: "coffee_medium", name: "Coffee Medium", category: "beverages", shelfLifeHours: 2, unitCost: 0.3, unitPrice: 2.49, minOrder: 1 },
  { id: "coffee_large", name: "Coffee Large", category: "beverages", shelfLifeHours: 2, unitCost: 0.35, unitPrice: 2.99, minOrder: 1 },
  // New category
  { id: "hash_browns", name: "Hash Browns", category: "snacks", shelfLifeHours: 3, unitCost: 0.5, unitPrice: 1.79, minOrder: 4 },
  { id: "muffin_blueberry", name: "Blueberry Muffin", category: "snacks", shelfLifeHours: 8, unitCost: 0.6, unitPrice: 2.59, minOrder: 4 },
];

export const DEFAULT_DEMAND_WINDOWS: DemandWindows = {
  pickupMorning: [6, 7, 8, 9],
  highDemandMorning: [6, 7, 8, 9, 10],
  highDemandLunch: [11, 12, 13, 14],
  slowAfternoon: [15, 16, 17],
  evening: [18, 19, 20],
};

export function defaultInventoryEnvConfig(): InventoryEnvConfig {
  return {
    skus: DEFAULT_SKUS,
    businessHours: { open: 5, close: 21 },
    demandWindows: DEFAULT_DEMAND_WINDOWS,
    capacity: 2200,
    maxOrderPerSku: 120,
    maxStepsPerEpisode: 16,
    wasteRatePerHour: 0.02,
    stockoutPenaltyMultiplier: 2.2,
    targetServiceLevel: 0.92,
    serviceShortfallPenaltyMultiplier: 1.75,
    laborCostPerUnit: 0,
    holdingCostPerUnit: 0.02,
  };
}

export function skuIdToIndex(skus: SkuDefinition[]): Map<string, number> {
  const map = new Map<string, number>();
  for (let i = 0; i < skus.length; i++) {
    map.set(skus[i]?.id ?? "", i);
  }
  return map;
}
