import type { TranslationKey } from '../i18n/translations'

interface Demo {
  readonly slug: string
  readonly arcadeId: string
  readonly category: TranslationKey
  readonly title: TranslationKey
  readonly description: TranslationKey
  readonly ogImage: string
  readonly thumbnail: string
  readonly estimatedTime: TranslationKey
  readonly durationIso: string
  readonly difficulty: 'beginner' | 'intermediate' | 'advanced'
  readonly tags: readonly string[]
  readonly transcript?: TranslationKey
  readonly publishedDate: string
  readonly modifiedDate: string
  /**
   * Width / height of the Arcade demo's source recording (e.g. 1.93 for a
   * landscape screencast). Sizes the embed container to match so rounded
   * corners hug the content instead of empty letterbox space. Source from
   * Arcade's `_serializablePublicFlow.aspectRatio` (which is height/width —
   * invert it). Defaults to 16/9 if omitted.
   */
  readonly aspectRatio?: number
}

export const demos: readonly Demo[] = [
  {
    slug: 'image-to-video',
    arcadeId: 'F3CTalnGnR4R0qJIVMNX',
    category: 'demos.category.templates',
    title: 'demos.image-to-video.title',
    description: 'demos.image-to-video.description',
    transcript: 'demos.image-to-video.transcript',
    ogImage: '/images/demos/image-to-video-og.png',
    thumbnail: '/images/demos/image-to-video-thumb.webp',
    estimatedTime: 'demos.duration.2min',
    durationIso: 'PT2M',
    difficulty: 'beginner',
    tags: ['templates', 'image', 'video'],
    publishedDate: '2026-04-19',
    modifiedDate: '2026-04-19',
    aspectRatio: 1.931
  },
  {
    slug: 'workflow-templates',
    arcadeId: 'KhqcXDElnFWklo7ACBqE',
    category: 'demos.category.gettingStarted',
    title: 'demos.workflow-templates.title',
    description: 'demos.workflow-templates.description',
    transcript: 'demos.workflow-templates.transcript',
    ogImage: '/images/demos/workflow-templates-og.png',
    thumbnail: '/images/demos/workflow-templates-thumb.webp',
    estimatedTime: 'demos.duration.2min',
    durationIso: 'PT2M',
    difficulty: 'beginner',
    tags: ['getting-started', 'templates', 'workflow'],
    publishedDate: '2026-04-19',
    modifiedDate: '2026-04-19',
    aspectRatio: 1.931
  },
  {
    slug: 'community-workflows',
    arcadeId: 'mqZh17oWDuWIyhK0xwEV',
    category: 'demos.category.gettingStarted',
    title: 'demos.community-workflows.title',
    description: 'demos.community-workflows.description',
    transcript: 'demos.community-workflows.transcript',
    ogImage: '/images/demos/community-workflows-og.png',
    thumbnail: '/images/demos/community-workflows-thumb.webp',
    estimatedTime: 'demos.duration.2min',
    durationIso: 'PT2M',
    difficulty: 'beginner',
    tags: ['getting-started', 'community', 'workflow', 'hub'],
    publishedDate: '2026-05-04',
    modifiedDate: '2026-05-04',
    aspectRatio: 1.931
  }
]

export function getDemoBySlug(slug: string): Demo | undefined {
  return demos.find((demo) => demo.slug === slug)
}

export function getNextDemo(slug: string): Demo {
  if (demos.length === 0) {
    throw new Error('No demos configured')
  }
  const index = demos.findIndex((demo) => demo.slug === slug)
  if (index === -1) {
    throw new Error(`Unknown demo slug: ${slug}`)
  }
  return demos[(index + 1) % demos.length]
}
