"""Service for calculating product pricing based on pack counts."""
from typing import Dict

def calculate_pack_prices(msp: float) -> Dict[int, float]:
    """
    Calculate violation pricing threshold for each pack count.
    
    Formula:
    - 1 pack: MSP * 1 - 10% = MSP * 0.9
    - 2 packs: MSP * 2 - 20% = MSP * 1.6
    - 3 packs: MSP * 3 - 33% = MSP * 2.01
    - 4 packs: MSP * 4 - 35% = MSP * 2.6
    - 5+ packs: MSP * pack_count - 35% = MSP * pack_count * 0.65
    
    Args:
        msp: Base Minimum Selling Price (single unit)
    
    Returns:
        Dictionary mapping pack count to calculated minimum price
    """
    pack_configs = {
        1: {"multiplier": 1, "discount": 0.10},    # MSP * 1 - 10%
        2: {"multiplier": 2, "discount": 0.20},    # MSP * 2 - 20%
        3: {"multiplier": 3, "discount": 0.33},    # MSP * 3 - 33%
        4: {"multiplier": 4, "discount": 0.35},    # MSP * 4 - 35%
        5: {"multiplier": 5, "discount": 0.35},    # MSP * 5 - 35%
        6: {"multiplier": 6, "discount": 0.35},    # MSP * 6 - 35%
        12: {"multiplier": 12, "discount": 0.35},  # MSP * 12 - 35%
    }
    
    pack_prices = {}
    for pack_count, config in pack_configs.items():
        base_price = msp * config["multiplier"]
        discount_amount = base_price * config["discount"]
        price = base_price - discount_amount
        pack_prices[pack_count] = round(price, 2)
    
    return pack_prices


def get_pack_price(msp: float, pack_count: int) -> float:
    """
    Get the violation pricing threshold for a specific pack count.
    
    Args:
        msp: Base Minimum Selling Price
        pack_count: Number of packs (1, 2, 3, 4, 5, 6, or 12)
    
    Returns:
        Calculated minimum price for that pack count
    """
    prices = calculate_pack_prices(msp)
    return prices.get(pack_count, 0)