---
import { getCollection } from 'astro:content'
import Layout from '../../layouts/Layout.astro'
import QuestListing from '../../components/listings/questListingLine.astro'
import DatabaseSection from '../../layouts/databaseSection.astro'
import SmallTitle from '../../components/smallTitle.astro'

const description =
  'One of the most anticipated events of 2024 - Teslafest. Were the two weeks of time enough for all those quests, even with a parallel lottery?'
const fulldata = await getCollection('teslafest')
const groups = await getCollection('teslafestgroups')

let combined = fulldata
for (const group of groups) {
  combined = combined.filter((data) => !data.id.startsWith(group.id))
}
combined = combined.concat(groups as any)

combined.sort(
  (a, b) =>
    b.data.info.releaseDate.valueOf() - a.data.info.releaseDate.valueOf() ||
    b.data.info.releaseNumber - a.data.info.releaseNumber
)

console.log(combined)
---

<Layout
  title="Teslafest - FGO TA"
  currentpage="teslafest"
  descriptionOverride={description}
>
  <SmallTitle maintext="TESLA­FEST" subtext={description} fadeout={true} />
  <DatabaseSection title="NA Runs" titlehidden={true} displayLine={true}>
    {
      combined.map((quest) => { return (<QuestListing {...{ ...quest.data.info, slug: quest.id }} baseurl="teslafest" />)})
    }
  </DatabaseSection>
</Layout>

<style></style>
