"use client"; import { ENDPOINTS } from "#/api/config"; import { useState, useEffect } from "react"; import { Swiper, SwiperSlide } from "swiper/react"; import "swiper/css"; import "swiper/css/navigation"; import "swiper/css/mousewheel"; import "swiper/css/scrollbar"; import { Navigation, Mousewheel, Scrollbar } from "swiper/modules"; import { Button } from "flowbite-react"; import { getAnonEpisodesWatched, saveAnonEpisodeWatched, } from "./ReleasePlayer"; interface Episode { id: number; position: number; name: string; is_watched: boolean; } interface Source { id: number; name: string; episodes_count: number; } export const EpisodeSelector = (props: { availableEpisodes: Episode[]; episode: Episode; setEpisode: any; source: Source; release_id: any; voiceover: any; token: string | null; }) => { let anonEpisodesWatched = getAnonEpisodesWatched( props.release_id, props.source.id, props.voiceover.id ); anonEpisodesWatched = anonEpisodesWatched[props.release_id][props.source.id][props.voiceover.id]; async function saveEpisodeToHistory(episode: Episode) { if (episode && props.token) { fetch( `${ENDPOINTS.statistic.addHistory}/${props.release_id}/${props.source.id}/${episode.position}?token=${props.token}` ); fetch( `${ENDPOINTS.statistic.markWatched}/${props.release_id}/${props.source.id}/${episode.position}?token=${props.token}` ); } } return (