/**
 * @license MIT
 * author: Cube Dev Team
 * @cube-dev/ui-kit v0.0.0-canary-3803e7e
 * Released under the MIT license.
 */

import { useMemo } from 'react';
import { usePersistentNotificationsContext } from './NotificationContext.js';
/**
 * Hook to access the persistent notifications list.
 *
 * Items are ordered newest first (by `createdAt`, descending).
 *
 * @example
 * ```tsx
 * const { items, count, remove, clear } = usePersistentNotifications();
 *
 * return (
 *   <div>
 *     <span>Notifications ({count})</span>
 *     {items.map(item => (
 *       <div key={item.id}>
 *         {item.title}
 *         <button onClick={() => remove(item.id)}>Remove</button>
 *       </div>
 *     ))}
 *     <button onClick={clear}>Clear all</button>
 *   </div>
 * );
 * ```
 */
export function usePersistentNotifications() {
    const { persistentItems, removePersistentItem, clearPersistentItems, markAllAsRead, } = usePersistentNotificationsContext();
    return useMemo(() => ({
        items: persistentItems,
        count: persistentItems.length,
        remove: removePersistentItem,
        clear: clearPersistentItems,
        markAllAsRead,
    }), [persistentItems]);
}
/**
 * Hook to get total and unread counts for persistent notifications.
 *
 * - `total` — number of items in the persistent list.
 * - `unread` — items that haven't been seen in `PersistentNotificationsList` yet.
 *
 * @example
 * ```tsx
 * const { total, unread } = useNotificationsCount();
 * return <Badge count={unread} />;
 * ```
 */
export function useNotificationsCount() {
    const { persistentItems } = usePersistentNotificationsContext();
    return useMemo(() => ({
        total: persistentItems.length,
        unread: persistentItems.filter((i) => !i.isRead).length,
    }), [persistentItems]);
}

        