<?php

if (! function_exists('notifications_unread_count')) {
    /**
     * Unread in-app notification count for the signed-in user (0 when guest).
     */
    function notifications_unread_count(): int
    {
        $userId = (int) (session()->get('user_id') ?? 0);
        if ($userId < 1) {
            return 0;
        }

        return (new \App\Services\NotificationService())->unreadCount($userId);
    }
}

if (! function_exists('notifications_unread_badge')) {
    function notifications_unread_badge(): string
    {
        return \App\Services\NotificationService::formatBadge(notifications_unread_count());
    }
}
