@php
    $diagnostics = is_array($surface['diagnostics'] ?? null) ? $surface['diagnostics'] : [];
@endphp

<div
    data-shared-zone="diagnostics"
    class="rounded-lg border border-gray-200 bg-white p-4 shadow-sm dark:border-gray-800 dark:bg-gray-900"
>
    <div class="text-xs font-semibold uppercase tracking-wide text-gray-500 dark:text-gray-400">
        Diagnostics
    </div>

    <div class="mt-3 space-y-1 text-sm text-gray-700 dark:text-gray-200">
        <div>
            <span class="text-gray-500 dark:text-gray-400">Operation ID:</span>
            <span class="font-mono">{{ (int) ($diagnostics['operationRunId'] ?? 0) }}</span>
        </div>
        <div>
            <span class="text-gray-500 dark:text-gray-400">Flow:</span>
            <span class="font-mono">{{ (string) ($diagnostics['flow'] ?? '') }}</span>
        </div>
        @if (filled($diagnostics['completedAt'] ?? null))
            <div>
                <span class="text-gray-500 dark:text-gray-400">Completed:</span>
                <span>{{ $diagnostics['completedAt'] }}</span>
            </div>
        @endif
        @if (filled($diagnostics['fingerprint'] ?? null))
            <div>
                <span class="text-gray-500 dark:text-gray-400">Fingerprint:</span>
                <span class="font-mono text-xs break-all">{{ $diagnostics['fingerprint'] }}</span>
            </div>
        @endif
        @if (filled($diagnostics['previousRunUrl'] ?? null))
            <div>
                <a
                    href="{{ $diagnostics['previousRunUrl'] }}"
                    class="font-medium text-primary-600 hover:underline dark:text-primary-400"
                >
                    Open previous operation
                </a>
            </div>
        @endif
    </div>
</div>