<script lang="ts">
	// Simplest transition: render whatever the parent gave us, full-bleed, with a CSS
	// opacity fade. Tied to the parent's `{#key}` block — when the src changes, the
	// parent re-mounts this component and the `in:` transition runs.

	interface Props {
		src: string;
		isVideo: boolean;
		durationMs: number;
		/** Fired when a video slide finishes so the parent can advance early. */
		onended?: () => void;
	}

	let { src, isVideo, durationMs, onended }: Props = $props();
</script>

<div
	class="absolute inset-0 flex items-center justify-center bg-black"
	style="animation: crossfade-in {durationMs}ms ease-out forwards;"
>
	{#if isVideo}
		<!-- svelte-ignore a11y_media_has_caption -->
		<video {src} autoplay muted playsinline {onended} class="h-full w-full object-contain"></video>
	{:else}
		<img {src} alt="" class="h-full w-full object-contain" />
	{/if}
</div>

<style>
	@keyframes crossfade-in {
		from {
			opacity: 0;
		}
		to {
			opacity: 1;
		}
	}
</style>
