'use client';

import Script from 'next/script';

interface MinecraftServerStructuredData {
  '@context': string;
  '@type': 'VideoGameServer';
  name: string;
  url: string;
  description: string;
  game: {
    '@type': 'VideoGame';
    name: string;
    softwareVersion: string;
  };
  serverStatus: string;
  playersOnline: number;
  maximumAttendeeCapacity: number;
  areaServed: string;
  provider: {
    '@type': 'Organization';
    name: string;
  };
  application: {
    '@type': 'EntryPoint';
    urlTemplate: string;
    name: string;
  };
}

interface StructuredDataProps {
  serverData?: {
    playersOnline: number;
    maxPlayers?: number;
    version?: string;
    status?: string;
  };
}

export function MinecraftServerStructuredData({ serverData }: StructuredDataProps = {}) {
  const structuredData: MinecraftServerStructuredData = {
    '@context': 'https://schema.org',
    '@type': 'VideoGameServer',
    name: 'BiohazardVFX Minecraft Server',
    url: 'https://minecraft.biohazardvfx.com',
    description: 'Join BiohazardVFX, a 1.21.x Survival Minecraft server for VFX artists and creatives. Experience vanilla-first gameplay with community and whitelist access.',
    game: {
      '@type': 'VideoGame',
      name: 'Minecraft',
      softwareVersion: serverData?.version || '1.21.x',
    },
    serverStatus: serverData?.status || 'Online',
    playersOnline: serverData?.playersOnline || 0,
    maximumAttendeeCapacity: serverData?.maxPlayers || 20,
    areaServed: 'Worldwide',
    provider: {
      '@type': 'Organization',
      name: 'BiohazardVFX',
    },
    application: {
      '@type': 'EntryPoint',
      urlTemplate: 'minecraft://connect?ip=minecraft.biohazardvfx.com',
      name: 'Minecraft',
    },
  };

  return (
    <Script
      id="structured-data"
      type="application/ld+json"
      dangerouslySetInnerHTML={{ __html: JSON.stringify(structuredData) }}
    />
  );
}