/**
 * Push notification client interfaces.
 *
 * NOTE: interfaces only - Agent 2D owns the implementation.
 *
 * Inject a PushClient via deps when calling review/notification workflows.
 * Agent 2D will create the concrete Web Push / VAPID client.
 */

export interface PushNotification {
  /** Short title shown in the OS notification tray. */
  title: string;
  /** Longer body text. */
  body: string;
  /** Optional URL to open on click. */
  url?: string;
  /** Optional icon URL. */
  icon?: string;
  /** Optional tag for grouping/replacing notifications. */
  tag?: string;
  /** Extra data passed to the service worker for in-app routing. */
  data?: Record<string, unknown>;
}

export interface PushClient {
  /**
   * Send a push notification to all active subscriptions for a user.
   *
   * Silently skips if the user has no active subscriptions.
   */
  sendToUser(userId: string, notification: PushNotification): Promise<void>;

  /**
   * Send a push notification to all active subscriptions for a vendor's owner.
   *
   * Silently skips if the vendor owner has no active subscriptions.
   */
  sendToVendor(vendorId: string, notification: PushNotification): Promise<void>;
}

/** Push notification event type tags for routing in the service worker. */
export const PUSH_EVENT = {
  WISHLIST_DEAL_EXPIRING: 'WISHLIST_DEAL_EXPIRING',
  FAVORITE_VENDOR_NEW_DEAL: 'FAVORITE_VENDOR_NEW_DEAL',
} as const;

export type PushEventType = (typeof PUSH_EVENT)[keyof typeof PUSH_EVENT];
