@props([ 'data' => null, 'title' => null, 'icon' => null, 'bgColor' => 'bg-gray-800/30', 'borderColor' => 'border-gray-700/40', 'textColor' => 'text-gray-200', 'titleColor' => 'text-gray-300', 'iconColor' => 'text-gray-400', 'maxHeight' => 'max-h-32', 'collapsible' => true, 'copyable' => true, 'expandable' => true, 'startCollapsed' => false ]) @php $jsonId = 'json-' . uniqid(); $modalId = 'modal-' . uniqid(); // Process the data safely $processedData = null; $jsonString = ''; $hasError = false; $errorMessage = ''; try { if (is_null($data)) { $processedData = null; } elseif (is_array($data)) { $processedData = $data; } elseif (is_string($data)) { // Try to decode if it's a JSON string $decoded = json_decode($data, true); if (json_last_error() === JSON_ERROR_NONE) { $processedData = $decoded; } else { $processedData = $data; } } else { // For any other type, convert to string for safe display $processedData = (string) $data; } $jsonString = json_encode($processedData, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES); } catch (\Exception $e) { $hasError = true; $errorMessage = $e->getMessage(); $jsonString = '[Error displaying data: ' . $errorMessage . ']'; } @endphp @if($processedData !== null || $hasError)
@if($title)
@if($icon)
{!! $icon !!}
@endif {{ $title }}
@if($copyable && !$hasError) @endif @if($expandable && !$hasError) @endif @if($collapsible) @endif
@endif
@if($expandable && !$hasError) @endif @endif