import { type BaseItemDto, BaseItemKind, } from "@jellyfin/sdk/lib/generated-client"; import Button from "@mui/material/Button"; import Chip from "@mui/material/Chip"; import { green, red, yellow } from "@mui/material/colors"; import Stack from "@mui/material/Stack"; import Typography from "@mui/material/Typography"; import { useNavigate } from "@tanstack/react-router"; import { useQuery } from "@tanstack/react-query"; import { motion, type Variants } from "motion/react"; import React from "react"; import { endsAt, getRuntime } from "@/utils/date/time"; import { getHeroPosterUrl, getItemImagesQueryOptions, resolveHeroArtwork, } from "@/utils/methods/heroArtwork"; import BlurhashCanvas from "../blurhash-canvas"; import { useApiInContext } from "@/utils/store/api"; import { useCarouselStore } from "@/utils/store/carousel"; import { useCentralStore } from "@/utils/store/central"; import LikeButton from "../buttons/likeButton"; import MarkPlayedButton from "../buttons/markPlayedButton"; import PlayButton from "../buttons/playButton"; import { getTypeIcon } from "../utils/iconsCollection"; import { getItemLinkOptions } from "@/utils/navigation/itemLink"; const MotionTypography = motion.create(Typography); const MotionStack = motion.create(Stack); const textVariants: Variants = { // No hidden start state: hero text must not blink on slide changes. initial: { x: 0, opacity: 1, }, animate: { x: 0, opacity: 1, transition: { duration: 0.35, ease: [0.2, 0, 0, 1] as const, }, }, exit: (direction: string) => ({ x: direction === "right" ? -40 : 40, opacity: 0, transition: { duration: 0.2, ease: "easeInOut", }, }), }; const CarouselSlide = ({ item }: { item: BaseItemDto }) => { const api = useApiInContext((s) => s.api); const navigate = useNavigate(); const user = useCentralStore((s) => s.currentUser); const handleMoreInfo = () => { if (item.Id) { navigate(getItemLinkOptions(item.Id, item.Type)); } }; const [animationDirection] = useCarouselStore((state) => [state.direction]); // Jellyfin stores several images per item (poster, thumb, backdrops). // Ask the server which ones exist and their real size, then pick the wide one. const imageInfos = useQuery(getItemImagesQueryOptions(api, item.Id)); const heroArtwork = resolveHeroArtwork(api, item, imageInfos.data); const heroPoster = heroArtwork?.isPortrait ? getHeroPosterUrl(api, item) : undefined; return (