import { trainData } from "@/data";
import { getTrainRouteSchema, getRouteFAQSchema, SITE_INFO } from "@/lib/schemas";
import DhakaToRajbariClient from "./DhakaToRajbariClient";

export const metadata = {
  title: "Dhaka to Rajbari Train Schedule 2026 | ঢাকা থেকে রাজবাড়ী ট্রেনের সময়সূচী | Ticket Price & Booking",
  description:
    "Dhaka to Rajbari train schedule, ticket price, and time table 2026. Multiple trains daily including Sundarban Express, Benapole Express. Book tickets online. ঢাকা থেকে রাজবাড়ী ট্রেনের সময়সূচী ও ভাড়া।",
  keywords: [
    "dhaka to rajbari train",
    "dhaka to rajbari train schedule",
    "dhaka to rajbari ticket price",
    "dhaka to rajbari train time",
    "ঢাকা থেকে রাজবাড়ী ট্রেন",
    "dhaka rajbari train",
    "rajbari train from dhaka",
    "sundarban express dhaka to rajbari",
    "benapole express schedule",
  ],
  openGraph: {
    title: "Dhaka to Rajbari Train Schedule 2026 | Trains of Rajbari",
    description:
      "Complete Dhaka to Rajbari train schedule with ticket prices, booking info, and route details.",
    url: `${SITE_INFO.url}/dhaka-to-rajbari`,
    images: [{ url: "/logo.png" }],
  },
  alternates: {
    canonical: `${SITE_INFO.url}/dhaka-to-rajbari`,
  },
};

export default function DhakaToRajbariPage() {
  const availableTrains = trainData.filter((t) => {
    const routes = t.data.routes;
    const sourceIndex = routes.findIndex(
      (r) => r.city.toLowerCase().replace(/_/g, "") === "dhaka"
    );
    const destIndex = routes.findIndex(
      (r) => r.city.toLowerCase().replace(/_/g, "") === "rajbari"
    );
    return sourceIndex !== -1 && destIndex !== -1 && destIndex > sourceIndex;
  });

  const schemas = [
    getTrainRouteSchema({
      fromStation: "Dhaka",
      toStation: "Rajbari",
      banglaFrom: "ঢাকা",
      banglaTo: "রাজবাড়ী",
      distance: "150 km",
      duration: "3-4 hours",
      availableTrains: availableTrains.length,
      url: `${SITE_INFO.url}/dhaka-to-rajbari`,
    }),
    getRouteFAQSchema({
      fromStation: "Dhaka",
      toStation: "Rajbari",
      availableTrains: availableTrains.length,
      duration: "3-4 hours",
      distance: "150 km",
    }),
  ];

  return (
    <>
      {schemas.map((schema, i) => (
        <script
          key={i}
          type="application/ld+json"
          dangerouslySetInnerHTML={{ __html: JSON.stringify(schema) }}
        />
      ))}
      <DhakaToRajbariClient />
    </>
  );
}
