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

const FROM = "dhaka";
const TO = "pangsha";

export const metadata = {
  title: "Dhaka to Pangsha Train Schedule & Ticket Price | ঢাকা থেকে পাংশা",
  description: "Dhaka to Pangsha train schedule, ticket price, and time table. Check all trains from Dhaka to Pangsha including Sundarban Express, Benapole Express. ঢাকা থেকে পাংশা ট্রেনের সময়সূচী।",
  keywords: ["Dhaka to Pangsha train", "Dhaka to Pangsha train schedule", "Dhaka to Pangsha ticket price", "ঢাকা থেকে পাংশা", "trains of rajbari", "bangladesh railway schedule"],
  openGraph: {
    title: "Dhaka to Pangsha Train Schedule | Trains of Rajbari",
    description: "Complete Dhaka to Pangsha train schedule with ticket prices and route details.",
    url: `${SITE_INFO.url}/dhaka-to-pangsha`,
  },
  alternates: { canonical: `${SITE_INFO.url}/dhaka-to-pangsha` },
};

export default function DhakaToPangshaPage() {
  const count = trainData.filter((t) => {
    const routes = t.data.routes;
    const s = routes.findIndex((r) => r.city.toLowerCase().replace(/_/g, "") === FROM);
    const d = routes.findIndex((r) => r.city.toLowerCase().replace(/_/g, "") === TO);
    return d !== -1 && d > s;
  }).length;

  const schemas = [
    getTrainRouteSchema({ fromStation: "Dhaka", toStation: "Pangsha", banglaFrom: "ঢাকা", banglaTo: "পাংশা", distance: "170 km", duration: "4-5 hrs", availableTrains: count, url: `${SITE_INFO.url}/dhaka-to-pangsha` }),
    getRouteFAQSchema({ fromStation: "Dhaka", toStation: "Pangsha", availableTrains: count, duration: "4-5 hrs", distance: "170 km" }),
  ];

  return (
    <>
      {schemas.map((s, i) => (
        <script key={i} type="application/ld+json" dangerouslySetInnerHTML={{ __html: JSON.stringify(s) }} />
      ))}
      <TrainRouteClient fromStation="dhaka" toStation="pangsha" banglaFrom="ঢাকা" banglaTo="পাংশা" distance="170 km" duration="4-5 hrs" />
    </>
  );
}
