import { Experience } from "./constants";

export function generateOrganizationSchema() {
  return {
    "@context": "https://schema.org",
    "@type": "TravelAgency",
    name: "The Anatolian Edit",
    description: "Curated experiences on Istanbul's Asian side",
    url: "https://theanatolianedit.com",
    logo: "https://theanatolianedit.com/icons/logo.svg",
    areaServed: {
      "@type": "City",
      name: "Istanbul",
      addressCountry: "TR",
    },
    address: {
      "@type": "PostalAddress",
      streetAddress: "Caferağa Mahallesi",
      addressLocality: "Kadıköy",
      addressRegion: "Istanbul",
      postalCode: "34710",
      addressCountry: "TR",
    },
    geo: {
      "@type": "GeoCoordinates",
      latitude: 40.9833,
      longitude: 29.0333,
    },
    telephone: "+905551234567",
    email: "hello@theanatolianedit.com",
    priceRange: "€€",
    openingHoursSpecification: {
      "@type": "OpeningHoursSpecification",
      dayOfWeek: [
        "Monday", "Tuesday", "Wednesday", "Thursday",
        "Friday", "Saturday", "Sunday",
      ],
      opens: "08:00",
      closes: "22:00",
    },
    paymentAccepted: "Credit Card, Cash",
    aggregateRating: {
      "@type": "AggregateRating",
      ratingValue: "4.9",
      reviewCount: "200",
      bestRating: "5",
    },
    sameAs: ["https://www.instagram.com/theanatolianedit"],
  };
}

export function generateLocalBusinessSchema() {
  return {
    "@context": "https://schema.org",
    "@type": "LocalBusiness",
    name: "The Anatolian Edit",
    description: "Curated tour experiences on Istanbul's Asian side",
    url: "https://theanatolianedit.com",
    address: {
      "@type": "PostalAddress",
      streetAddress: "Caferağa Mahallesi",
      addressLocality: "Kadıköy",
      addressRegion: "Istanbul",
      postalCode: "34710",
      addressCountry: "TR",
    },
    geo: {
      "@type": "GeoCoordinates",
      latitude: 40.9833,
      longitude: 29.0333,
    },
    telephone: "+905551234567",
    priceRange: "€€",
    openingHoursSpecification: {
      "@type": "OpeningHoursSpecification",
      dayOfWeek: [
        "Monday", "Tuesday", "Wednesday", "Thursday",
        "Friday", "Saturday", "Sunday",
      ],
      opens: "08:00",
      closes: "22:00",
    },
  };
}

export function generateTouristTripSchema(experience: Experience) {
  return {
    "@context": "https://schema.org",
    "@type": "TouristTrip",
    name: `${experience.name} — ${experience.tagline}`,
    description: experience.hook,
    touristType: "Cultural tourism",
    itinerary: experience.itinerary
      ? {
          "@type": "ItemList",
          itemListElement: experience.itinerary.map((stop, index) => ({
            "@type": "ListItem",
            position: index + 1,
            name: `${stop.time} — ${stop.title}`,
            description: stop.description,
          })),
        }
      : undefined,
    offers: {
      "@type": "Offer",
      price: experience.price.toString(),
      priceCurrency: experience.currency,
      availability: "https://schema.org/InStock",
      validFrom: "2024-01-01",
    },
    provider: {
      "@type": "TravelAgency",
      name: "The Anatolian Edit",
      url: "https://theanatolianedit.com",
    },
  };
}

export function generateFAQSchema(faqs: { question: string; answer: string }[]) {
  return {
    "@context": "https://schema.org",
    "@type": "FAQPage",
    mainEntity: faqs.map((faq) => ({
      "@type": "Question",
      name: faq.question,
      acceptedAnswer: {
        "@type": "Answer",
        text: faq.answer,
      },
    })),
  };
}

export function generateBreadcrumbSchema(
  items: { name: string; url: string }[]
) {
  return {
    "@context": "https://schema.org",
    "@type": "BreadcrumbList",
    itemListElement: items.map((item, index) => ({
      "@type": "ListItem",
      position: index + 1,
      name: item.name,
      item: item.url,
    })),
  };
}

export function generateAggregateRatingSchema() {
  return {
    "@context": "https://schema.org",
    "@type": "Product",
    name: "The Anatolian Edit Experiences",
    aggregateRating: {
      "@type": "AggregateRating",
      ratingValue: "4.9",
      reviewCount: "200",
      bestRating: "5",
      worstRating: "1",
    },
  };
}
