<script setup>
    import { Link } from '@inertiajs/vue3';
    import { onMounted, defineProps } from 'vue';
    import { initFlowbite } from 'flowbite';

    const { block, blockData, frontpage } = defineProps({
        block: {
            type: Object,
            required: true,
        },
        blockData: {
            type: Object,
            default: () => ({})
        },
        frontpage: {
            type: Boolean
        }
    });

    onMounted(() => {
        initFlowbite();
    });
</script>

<template>
    <section :id="block.anchorName" class="relative block w-full h-screen overflow-hidden">
        <div class="absolute inset-0 bg-cover" :style="{ backgroundImage: `url('${block.image}')` }"></div>
        <div class="absolute inset-0 bg-black opacity-80"></div>
        <div class="absolute p-12 w-full overflow-auto" style="top: 0; bottom: 0;">
            <div class="flex-row justify-center items-center">
                <h1 class="text-center text-white font-arctic text-2xl md:text-4xl">{{ block.title || 'Tittel' }}</h1>
            </div>

            <div class="mx-auto max-w-[1280px]">
                <div class="col-6 d-flex flex-column sponsor-container">

                    <p v-if="block.showtext" class="text-gray-200">
                        {{ block.text || 'Intro tekst' }}
                    </p>

                    <div class="grid gap-4 grid-cols-1 md:grid-cols-2 lg:grid-cols-3 p-4 font-arctic text-xl md:text-2xl">
                        <!-- Sponsoroppføring -->
                        <Link v-for="(sponsor, index) in blockData.sponsors" :key="sponsor.id" :href="route('sponsor', sponsor.slug)" class="anchor sponsor-label text-gray-500 hover:text-gray-400 no-underline hover:underline">
                            {{ sponsor.name }}
                        </Link>
                    </div>

                    <p v-if="blockData.partners && blockData.partners.length && block.showpartnertext" class="text-gray-200 mt-2">
                        {{ block.partnertext || 'Partner intro tekst' }}
                    </p>

                    <div class="grid gap-4 grid-cols-1 md:grid-cols-2 lg:grid-cols-3 p-4 font-arctic text-xl md:text-2xl">
                        <!-- Sponsoroppføring -->
                        <Link v-for="(partner, index) in blockData.partners" :key="partner.id" :href="route('sponsor', partner.slug)" class="anchor sponsor-label text-gray-500 hover:text-gray-400 no-underline hover:underline">
                            {{ partner.name }}
                        </Link>
                    </div>                    
                </div>
            </div>
        </div>
    </section>
</template>