import { resolveVideoEmbed } from "@/lib/video";

/**
 * Simplest possible video section: give it a link, it plays. Nothing else to
 * configure. See `projectVideos` in `src/data/site.ts` for where the link
 * per project goes.
 */
export function ProjectVideo({ url }: { url: string }) {
  const embed = resolveVideoEmbed(url);
  if (!embed) return null;

  return (
    <div className="relative aspect-video w-full overflow-hidden bg-ink">
      {embed.kind === "iframe" ? (
        <iframe
          src={embed.src}
          title="ویدیوی پروژه"
          className="absolute inset-0 h-full w-full"
          allow="autoplay; fullscreen; picture-in-picture"
          allowFullScreen
          loading="lazy"
        />
      ) : (
        // eslint-disable-next-line jsx-a11y/media-has-caption
        <video src={embed.src} controls playsInline className="absolute inset-0 h-full w-full" />
      )}
    </div>
  );
}
