export type HourlyInfo = {
    temperature: number;
    hour: number;
    weather: string;
};

export type WeatherName = keyof typeof validWeatherNames;

export type SeasonName = 'winter' | 'summer' | 'spring' | 'fall' | 'Winter' | 'Summer' | 'Spring' | 'Fall' | 'all' | 'none';

export type WeekForecastObject = Array<{
    hourlyWeather: Array<WeatherName>;
    hourlyTemperature: Array<number>;
}>;

export type DayForecastObject = {
    hourlyWeather: Array<WeatherName>;
    hourlyTemperature: Array<number>;
};

export type PossibleWeathers = Array<{
    name: WeatherName;
    min: number;
    max: number;
    weight: number;
    maxConsecutive: number;
    mostCommonIn: Array<SeasonName>;
    onlyIn: Array<SeasonName>;
    commonTimes: Array<string>;
    notFrom: Array<WeatherName>;
    similarWeathers: Array<WeatherName>;
    leadsTo: Array<WeatherName>;
    greatestTemperatureChangeModifier: {
        morning: {
            rise: number;
            fall: number;
        };
        afternoon: {
            rise: number;
            fall: number;
        };
        evening: {
            rise: number;
            fall: number;
        };
        night: {
            rise: number;
            fall: number;
        };
    };
}>;

export type weatherPropertiesType = {
    name: WeatherName;
    min: number;
    max: number;
    weight: number;
    maxConsecutive: number;
    mostCommonIn: Array<string>;
    onlyIn: Array<string>;
    commonTimes: Array<string>;
    notFrom: Array<WeatherName>;
    similarWeathers: Array<WeatherName>;
    leadsTo: Array<WeatherName>;
    greatestTemperatureChangeModifier: {
        morning: {
            rise: number;
            fall: number;
        };
        night: {
            rise: number;
            fall: number;
        };
        evening: {
            rise: number;
            fall: number;
        };
        afternoon: {
            rise: number;
            fall: number;
        };
    };
};

export const possibleWeathers: PossibleWeathers = [
    {
        name: 'extrasunny',
        min: 15,
        max: 45,
        weight: 3,
        maxConsecutive: 24,
        mostCommonIn: ['summer', 'fall'],
        onlyIn: ['all'],
        commonTimes: ['all'],
        notFrom: ['rain', 'thunder', 'snow', 'snowlight', 'xmas', 'halloween', 'blizzard'],
        similarWeathers: ['clear'],
        leadsTo: ['clear', 'foggy'],
        greatestTemperatureChangeModifier: {
            morning: { rise: 2, fall: 0 },
            afternoon: { rise: 1.5, fall: 0 },
            evening: { rise: 0.5, fall: 0 },
            night: { rise: 0, fall: 0 },
        },
    },
    {
        name: 'clear',
        min: 8,
        max: 40,
        weight: 2,
        maxConsecutive: 24,
        mostCommonIn: ['all'],
        onlyIn: ['all'],
        commonTimes: ['all'],
        notFrom: ['thunder', 'blizzard'],
        similarWeathers: ['extrasunny'],
        leadsTo: ['extrasunny', 'clouds', 'foggy', 'overcast'],
        greatestTemperatureChangeModifier: {
            morning: { rise: 1, fall: 0 },
            afternoon: { rise: 1, fall: 0 },
            evening: { rise: 0.5, fall: -0.5 },
            night: { rise: 0, fall: -0.5 },
        },
    },
    {
        name: 'clouds',
        min: 8,
        max: 30,
        weight: -1,
        maxConsecutive: 4,
        mostCommonIn: ['winter', 'spring'],
        onlyIn: ['winter', 'spring'],
        commonTimes: ['all'],
        notFrom: ['blizzard'],
        similarWeathers: ['clear', 'overcast'],
        leadsTo: ['clear', 'overcast', 'rain'],
        greatestTemperatureChangeModifier: {
            morning: { rise: 0.3, fall: 0 },
            afternoon: { rise: 0.5, fall: 0 },
            evening: { rise: 0.2, fall: -0.5 },
            night: { rise: 0, fall: -0.5 },
        },
    },
    {
        name: 'smog',
        min: 20,
        max: 35,
        weight: -2,
        maxConsecutive: 4,
        mostCommonIn: ['summer', 'fall'],
        onlyIn: ['spring', 'summer', 'fall'],
        commonTimes: ['afternoon', 'evening'],
        notFrom: ['thunder', 'blizzard', 'rain'],
        similarWeathers: [],
        leadsTo: ['clear', 'clouds'],
        greatestTemperatureChangeModifier: {
            morning: { rise: 0, fall: 0 },
            afternoon: { rise: 0.3, fall: 0 },
            evening: { rise: 0, fall: 0 },
            night: { rise: 0, fall: 0 },
        },
    },
    {
        name: 'foggy',
        min: 12,
        max: 22,
        weight: 0,
        maxConsecutive: 4,
        mostCommonIn: ['spring', 'summer'],
        onlyIn: ['spring', 'summer', 'fall'],
        commonTimes: ['morning', 'night'],
        notFrom: ['thunder', 'blizzard', 'rain', 'extrasunny'],
        similarWeathers: ['overcast'],
        leadsTo: ['clear', 'extrasunny', 'overcast'],
        greatestTemperatureChangeModifier: {
            morning: { rise: -0.5, fall: -1 },
            afternoon: { rise: 0, fall: 0 },
            evening: { rise: 0, fall: 0 },
            night: { rise: 0, fall: -0.8 },
        },
    },
    {
        name: 'overcast',
        min: 8,
        max: 31,
        weight: -1,
        maxConsecutive: 6,
        mostCommonIn: ['winter', 'spring'],
        onlyIn: ['winter', 'spring'],
        commonTimes: ['morning', 'afternoon'],
        notFrom: ['thunder', 'blizzard'],
        similarWeathers: ['clouds', 'foggy'],
        leadsTo: ['clouds', 'clear', 'rain'],
        greatestTemperatureChangeModifier: {
            morning: { rise: -0.3, fall: -0.5 },
            afternoon: { rise: -0.3, fall: -0.5 },
            evening: { rise: 0, fall: -1 },
            night: { rise: 0, fall: -1 },
        },
    },
    {
        name: 'rain',
        min: 8,
        max: 20,
        weight: -3,
        maxConsecutive: 6,
        mostCommonIn: ['winter'],
        onlyIn: ['winter'],
        commonTimes: ['all'],
        notFrom: ['blizzard', 'extrasunny', 'smog', 'foggy'],
        similarWeathers: ['clouds', 'overcast'],
        leadsTo: ['overcast', 'clouds', 'clearing'],
        greatestTemperatureChangeModifier: {
            morning: { rise: 0, fall: -1 },
            afternoon: { rise: 0, fall: -0.5 },
            evening: { rise: 0, fall: -0.5 },
            night: { rise: 0, fall: -1 },
        },
    },
    {
        name: 'thunder',
        min: 10,
        max: 22,
        weight: -6,
        maxConsecutive: 2,
        mostCommonIn: ['winter'],
        onlyIn: ['winter'],
        commonTimes: ['afternoon', 'evening'],
        notFrom: ['snow', 'snowlight', 'blizzard', 'smog', 'clear', 'xmas', 'extrasunny', 'foggy'],
        similarWeathers: ['rain'],
        leadsTo: ['rain', 'overcast'],
        greatestTemperatureChangeModifier: {
            morning: { rise: 0, fall: -2 },
            afternoon: { rise: 0, fall: -1.5 },
            evening: { rise: 0, fall: -2 },
            night: { rise: -1, fall: -2 },
        },
    },
    {
        name: 'clearing',
        min: 10,
        max: 24,
        weight: -1,
        maxConsecutive: 2,
        mostCommonIn: ['winter', 'spring'],
        onlyIn: ['winter', 'spring'],
        commonTimes: ['afternoon', 'evening'],
        notFrom: ['thunder', 'blizzard'],
        similarWeathers: ['clouds', 'foggy'],
        leadsTo: ['clear', 'extrasunny'],
        greatestTemperatureChangeModifier: {
            morning: { rise: 0.3, fall: -0.5 },
            afternoon: { rise: 0.5, fall: -0.5 },
            evening: { rise: 0, fall: -1 },
            night: { rise: 0, fall: -1 },
        },
    },
    {
        name: 'snow',
        min: -5,
        max: 2,
        weight: -100,
        maxConsecutive: 0,
        mostCommonIn: [],
        onlyIn: ['winter'],
        commonTimes: [],
        notFrom: ['thunder', 'rain', 'extrasunny', 'clearing', 'clear'],
        similarWeathers: [],
        leadsTo: [],
        greatestTemperatureChangeModifier: {
            morning: { rise: 0, fall: 0 },
            afternoon: { rise: 0, fall: 0 },
            evening: { rise: 0, fall: 0 },
            night: { rise: 0, fall: 0 },
        },
    },
    {
        name: 'blizzard',
        min: -10,
        max: 0,
        weight: -100,
        maxConsecutive: 0,
        mostCommonIn: [],
        onlyIn: ['winter'],
        commonTimes: [],
        notFrom: [],
        similarWeathers: [],
        leadsTo: [],
        greatestTemperatureChangeModifier: {
            morning: { rise: 0, fall: 0 },
            afternoon: { rise: 0, fall: 0 },
            evening: { rise: 0, fall: 0 },
            night: { rise: 0, fall: 0 },
        },
    },
    {
        name: 'snowlight',
        min: -10,
        max: 5,
        weight: -100,
        maxConsecutive: 0,
        mostCommonIn: [],
        onlyIn: ['winter'],
        commonTimes: [],
        notFrom: [],
        similarWeathers: [],
        leadsTo: [],
        greatestTemperatureChangeModifier: {
            morning: { rise: 0, fall: 0 },
            afternoon: { rise: 0, fall: 0 },
            evening: { rise: 0, fall: 0 },
            night: { rise: 0, fall: 0 },
        },
    },
    {
        name: 'xmas',
        min: -10,
        max: 5,
        weight: -100,
        maxConsecutive: 0,
        mostCommonIn: [],
        onlyIn: ['winter'],
        commonTimes: [],
        notFrom: [],
        similarWeathers: [],
        leadsTo: [],
        greatestTemperatureChangeModifier: {
            morning: { rise: 0, fall: 0 },
            afternoon: { rise: 0, fall: 0 },
            evening: { rise: 0, fall: 0 },
            night: { rise: 0, fall: 0 },
        },
    },
    {
        name: 'halloween',
        min: 15,
        max: 25,
        weight: -100,
        maxConsecutive: 0,
        mostCommonIn: [],
        onlyIn: [],
        commonTimes: [],
        notFrom: [],
        similarWeathers: [],
        leadsTo: [],
        greatestTemperatureChangeModifier: {
            morning: { rise: 0, fall: 0 },
            afternoon: { rise: 0, fall: 0 },
            evening: { rise: 0, fall: 0 },
            night: { rise: 0, fall: 0 },
        },
    },
];

export const WeatherSunsetSunriseTimes: Record<WeatherName, Record<string, number>> = {
    extrasunny: {
        sunrise: 6,
        sunset: 20,
    },
    clouds: {
        sunrise: 6,
        sunset: 20,
    },
    clear: {
        sunrise: 6,
        sunset: 20,
    },
    smog: {
        sunrise: 6,
        sunset: 20,
    },
    foggy: {
        sunrise: 6,
        sunset: 20,
    },
    halloween: {
        sunrise: 7,
        sunset: 19,
    },
    overcast: {
        sunrise: 6,
        sunset: 20,
    },
    rain: {
        sunrise: 6,
        sunset: 20,
    },
    thunder: {
        sunrise: 6,
        sunset: 20,
    },
    clearing: {
        sunrise: 6,
        sunset: 20,
    },
    snow: {
        sunrise: 5,
        sunset: 21,
    },
    xmas: {
        sunrise: 5,
        sunset: 21,
    },
    blizzard: {
        sunrise: 6,
        sunset: 20,
    },
    snowlight: {
        sunrise: 5,
        sunset: 21,
    },
    'no weather': {
        sunrise: 6,
        sunset: 20,
    },
};

export const monthlySunriseSunsetTimes = [
    // month
    { sunrise: 7, sunset: 17 }, // JAN
    { sunrise: 7, sunset: 18 }, // FEB
    { sunrise: 6, sunset: 19 }, // MAR
    { sunrise: 6, sunset: 19 }, // APR
    { sunrise: 6, sunset: 20 }, // MAY
    { sunrise: 6, sunset: 20 }, // JUN
    { sunrise: 6, sunset: 20 }, // JUL
    { sunrise: 6, sunset: 19 }, // AUG
    { sunrise: 7, sunset: 19 }, // SEP
    { sunrise: 7, sunset: 18 }, // OCT
    { sunrise: 6, sunset: 17 }, // NOV
    { sunrise: 7, sunset: 17 }, // DEC
];

export const validWeatherNames = {
    extrasunny: 'extrasunny',
    clear: 'clear',
    clouds: 'clouds',
    smog: 'smog',
    foggy: 'foggy',
    overcast: 'overcast',
    rain: 'rain',
    thunder: 'thunder',
    clearing: 'clearing',
    snow: 'snow',
    blizzard: 'blizzard',
    snowlight: 'snowlight',
    xmas: 'xmas',
    halloween: 'halloween',
    'no weather': 'no weather',
};

export const puddleCreators = {
    rain: 'rain',
    thunder: 'thunder',
    clearing: 'clearing',
};
