@php
    use App\Support\Diff\RbacRoleDefinitionDiffBuilder;

    $payload = is_array($getState()) ? $getState() : [];
    $diffKind = is_string($payload['diff_kind'] ?? null) ? (string) $payload['diff_kind'] : 'permission_change';
    $presentation = app(RbacRoleDefinitionDiffBuilder::class)->build($payload);
@endphp

<div class="space-y-4">
    <x-filament::section
        :heading="__('findings.rbac.detail_heading')"
        :description="__('findings.rbac.' . $diffKind)"
    >
        <div class="space-y-4">
            @include('filament.partials.diff.summary-badges', [
                'summary' => $presentation->summary,
            ])

            @if ($presentation->rows !== [])
                <div class="space-y-3">
                    @foreach ($presentation->rows as $row)
                        @include('filament.partials.diff.row', [
                            'row' => $row,
                            'compact' => false,
                            'dimUnchanged' => true,
                        ])
                    @endforeach
                </div>
            @endif

            <div class="rounded-lg border border-gray-200 bg-gray-50 p-3 text-sm text-gray-700 dark:border-white/10 dark:bg-gray-950 dark:text-gray-300">
                {{ __('findings.rbac.assignments_excluded') }}
                {{ __('findings.rbac.restore_unsupported') }}
            </div>
        </div>
    </x-filament::section>
</div>
