import { z, defineCollection } from 'astro:content'

// Individual TA entries
const entry = z.object({
  title: z.string(),
  link: z.string().url(),
  date: z.string().transform((str) => new Date(str)),
  servant: z.string(),
  turns: z.string(),
  runner: z.string(),
})

// Individual quest info block
const quest = z.object({
  questTitle: z.string(),
  description: z.string(),
  data: z.array(entry),
})

// Basic info block for page
const info = z.object({
  title: z.string(),
  releaseDate: z.string().transform((str) => new Date(str)),
  shortdescription: z.string(),
  releaseNumber: z.number().default(1),
  type: z.enum(["quest", "event", "group"]).default("quest")
})

// Combined ta data collection schema
const taData = defineCollection({
  type: 'data',
  schema: z.object({
    info: info,
    quests: z.array(quest),
  }),
})

const groupDescription = defineCollection({
  type: 'data',
  schema: z.object({ info: info }),
})

const changes = defineCollection({
  type: 'data',
  schema: z.object({
    info: info,
    link: z.string().url(),
    color: z.string(),
  }),
})

export const collections = {
  taInfoData: taData,
  teslafest: taData,
  groups: groupDescription,
  teslafestgroups: groupDescription,
  changes: changes,
}
