export const prices: Record<string, number> = { normal: 11.0, imax: 15.0, vip: 12.0, dbox: 16.0 };

export const seatLayouts = {
    "Kino 1": { rows: 6, left: 3, right: 7, vipRows: [5], dbox: [] },
    "Kino 2": { rows: 7, left: 5, right: 5, vipRows: [6], dbox: [] },
    "Deluxe 1": { rows: 10, left: 7, right: 8, vipRows: [9], dbox: [{ r: 4, c: 5, w: 4 }] },
    IMAX: { rows: 15, left: 10, right: 10, vipRows: [], dbox: [], isImax: true }
};

export const movieCatalog = [
    { title: "Zoomania 2", genre: "Animation", duration: 108, poster: "/img/Zoomania-2.jpg", backdrop: "/img/Zoomania-2.jpg", fsk: "0", description: "Die Fortsetzung des beliebten Animationsabenteuers." },
    { title: "Der Austronaut", genre: "Sci-Fi", duration: 124, poster: "/img/derAustronaut.jpg", backdrop: "/img/derAustronaut.jpg", fsk: "12", description: "Ein einsamer Astronaut kämpft um sein Überleben." },
    { title: "Spider-Man", genre: "Action", duration: 133, poster: "/img/spidermannewday.jpg", backdrop: "/img/spidermannewday.jpg", fsk: "12", description: "Ein neues Abenteuer des freundlichen Spinnenmanns." },
    { title: "Scream VII", genre: "Horror", duration: 115, poster: "/img/screamvii.jpg", backdrop: "/img/screamvii.jpg", fsk: "18", description: "Ghostface ist zurück und gefährlicher als je zuvor." },
    { title: "Gangster Gang 2", genre: "Animation", duration: 95, poster: "/img/gangstergang2.png", backdrop: "/img/gangstergang2.png", fsk: "6", description: "Die Gangster Gang ist wieder unterwegs." }
];

export const hallRotation = ["IMAX", "Deluxe 1", "Kino 1", "Kino 2"];

export const timePatterns = [
    ["13:00", "15:20", "17:40", "20:00", "22:20"],
    ["13:00", "14:50", "17:10", "19:30", "21:50"],
    ["13:00", "15:10", "17:30", "19:50", "22:10"],
    ["13:00", "16:00", "18:20", "20:40"]
];

export const weekdayShort = ["So", "Mo", "Di", "Mi", "Do", "Fr", "Sa"];

// Shared State
export const cart: unknown[] = JSON.parse(typeof window !== 'undefined' ? (localStorage.getItem("eagleCart") || '[]') : '[]');
export let occupiedSeatsData = JSON.parse(typeof window !== 'undefined' ? (localStorage.getItem("eagleOccupied") || '{}') : '{}');
export const users: unknown[] = JSON.parse(typeof window !== 'undefined' ? (localStorage.getItem("eagleUsers") || '[]') : '[]');
export let currentUser: unknown = JSON.parse(typeof window !== 'undefined' ? (localStorage.getItem("currentUser") || 'null') : 'null');

export function updateCart(newCart: unknown[]) {
    cart.splice(0, cart.length, ...newCart);
    if (typeof window !== 'undefined') {
        localStorage.setItem("eagleCart", JSON.stringify(cart));
    }
}

export function updateOccupiedSeats(newData: unknown) {
    occupiedSeatsData = newData;
    if (typeof window !== 'undefined') {
        localStorage.setItem("eagleOccupied", JSON.stringify(occupiedSeatsData));
    }
}

export function emptyCart() {
    cart.length = 0;
    if (typeof window !== 'undefined') {
        localStorage.setItem("eagleCart", JSON.stringify(cart));
    }
}

export function persistUsers() {
    if (typeof window !== 'undefined') localStorage.setItem("eagleUsers", JSON.stringify(users));
}

export function persistCurrentUser(user: unknown) {
    currentUser = user;
    if (typeof window !== 'undefined') {
        if (currentUser) localStorage.setItem("currentUser", JSON.stringify(currentUser));
        else localStorage.removeItem("currentUser");
    }
}

export interface User {
    firstName: string;
    lastName: string;
    email: string;
    hashedPassword: string;
    orders: unknown[];
    paymentMethods: unknown[];
}

export interface MovieInterface {
    id: number;
    title: string;
    genre: string;
    duration: number;
    fsk: string;
    description: string;
    poster: string;
    backdrop: string;
    rating: number;
    year: string;
}

export interface ITMDBResponse {
  page: number;
  results: unknown[];
  total_pages: number;
  total_results: number;
}

export interface ITMDBMovie {
    id: number;
    title: string;
    poster_path: string;
    vote_average: number;
    release_date: string;
    genre_ids: number[];
    runtime: number;
    age_rating: string;
    overview: string;
    backdrop_path: string;
}