@php
    // Usage: <x-avatar :user="$user" size="128" />
    $size = $size ?? 128;
    $profile = $user->profile ?? null;
    $hash = $profile->avatar_hash ?? null;
    $src = \App\Support\AvatarUrl::forUser((int) $user->id, $hash, (int) $size);
    $alt = $alt ?? ($user->username ?? 'avatar');
    $class = $class ?? 'rounded-full';
@endphp
<img src="{{ $src }}" alt="{{ $alt }}" loading="lazy" decoding="async" class="{{ $class }}" width="{{ $size }}" height="{{ $size }}">
