@props([
    'blocks' => [],
])

<div class="space-y-4">
    @foreach ($blocks as $block)
        @switch ($block['kind'] ?? '')
            @case('alert')
                <x-filament::callout
                    :color="$block['tone'] ?? 'warning'"
                    :description="$block['value'] ?? ''"
                />
                @break

            @case('text')
                <p class="text-sm leading-relaxed text-gray-600 dark:text-gray-400">
                    {{ $block['value'] ?? '' }}
                </p>
                @break

            @case('field')
                <div class="rounded-lg bg-gray-50 px-3 py-2 dark:bg-white/5">
                    <p class="text-xs text-gray-500 dark:text-gray-400">
                        {{ $block['label'] ?? '' }}
                    </p>
                    <p class="mt-1 text-sm text-gray-950 dark:text-white">
                        @if (filled($block['url'] ?? null))
                            <a href="{{ $block['url'] }}" class="fi-link fi-size-sm">
                                {{ $block['value'] ?? '' }}
                            </a>
                        @else
                            {{ $block['value'] ?? '' }}
                        @endif
                    </p>
                </div>
                @break

            @case('badge')
                <div class="rounded-lg bg-gray-50 px-3 py-2 dark:bg-white/5">
                    <p class="text-xs text-gray-500 dark:text-gray-400">
                        {{ $block['label'] ?? '' }}
                    </p>
                    <div class="mt-1">
                        <x-filament::badge :color="$block['tone'] ?? 'gray'" size="sm">
                            {{ $block['value'] ?? '' }}
                        </x-filament::badge>
                    </div>
                </div>
                @break

            @case('links')
                <div class="space-y-2">
                    @if (filled($block['label'] ?? null))
                        <p class="text-xs font-medium text-gray-500 dark:text-gray-400">
                            {{ $block['label'] }}
                        </p>
                    @endif

                    <div class="flex flex-wrap gap-2">
                        @foreach ($block['links'] ?? [] as $link)
                            <x-filament::button
                                tag="a"
                                :href="$link['url']"
                                size="sm"
                                color="gray"
                            >
                                {{ $link['label'] }}
                            </x-filament::button>
                        @endforeach
                    </div>
                </div>
                @break
        @endswitch
    @endforeach
</div>
