'use client';

/**
 * Fallback `<iframe>` for arbitrary embed URLs that don't fit a known
 * provider. Rendered *outside* the media-chrome controls (no
 * `slot="media"`) because there is no JS bridge between the iframe
 * contents and `<MediaController>`. Consumers should pass
 * `controls={false}` for iframe sources, or live with a non-functional
 * control bar — we hide it via CSS in `VideoPlayer.tsx`.
 */

import type { IframeSource } from '../types';

export interface IframeCanvasProps {
  readonly source: IframeSource;
}

const DEFAULT_ALLOW =
  'accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share';

export function IframeCanvas({ source }: IframeCanvasProps) {
  return (
    <iframe
      slot="media"
      src={source.url}
      title={source.title ?? 'Embedded video'}
      allow={source.allow ?? DEFAULT_ALLOW}
      allowFullScreen
      referrerPolicy="strict-origin-when-cross-origin"
      className="absolute inset-0 h-full w-full border-0"
    />
  );
}
