<script setup lang="ts">
// Home redirects straight to the search experience.
import type { ButtonProps } from '@nuxt/ui'
import { useSettingsStore } from '~/stores/settings'

// const { unlocked } = useDevMode()

// if( !unlocked ){
//   definePageMeta({
//     middleware: () => navigateTo('/estudios-biblicos', { redirectCode: 302 })
//   })
// }

const { $i18n } = useNuxtApp()
const t = $i18n.t

const release = releases[0]

const links = ref<ButtonProps[]>([
  {
    label: t('nav.tour'),
    icon: 'ph-student',
    color: 'error',
    class: 'hidden sm:flex',
    onClick: () => start( tourConfig )
  },
  {
    label: t('nav.bible_studies'),
    to: '/estudios-biblicos',
    icon: 'ph-books',
    color: 'primary'
  },
  {
    label: t('nav.conferences'),
    to: '/conferences',
    icon: 'ph-books',
    color: 'secondary'
  },
])

</script>

<template>

  <UDashboardPanel id="changelog-panel" grow>
    <UDashboardNavbar :title="t('nav.home')">
      <template #leading>
        <UDashboardSidebarCollapse />
      </template>
    </UDashboardNavbar>

    <UPage>
      <UPageHero title="Buscador Carpa"
        :description="$t('home.instructions')"
        :headline="`${release?.date}`" orientation="horizontal"
        :links="links"
        >

        <UPageCard variant="soft" icon="ph-git-branch" :title="release?.title" :description="release?.description">

          <template #header>
            v{{ release?.version }}
          </template>

          <!-- Lista de cambios -->
          <ul class="space-y-2">
            <li v-for="(change, i) in release?.changes" :key="i" class="flex items-start gap-2 text-sm">
              <UBadge :color="typeConfig[change.type].color as any" variant="subtle" size="xs" class="mt-0.5 shrink-0">
                {{ typeConfig[change.type].label }}
              </UBadge>
              <span class="text-default">{{ change.text }}</span>
            </li>
          </ul>
        </UPageCard>
      </UPageHero>

    </UPage>
  </UDashboardPanel>
</template>
