/**
 * Typed query-key factory for Multideal.
 *
 * Use these keys for ALL useQuery / prefetchQuery / invalidateQueries calls.
 * Central registry prevents key drift between prefetch (server) and consume (client).
 */

export const qk = {
  cart: () => ['cart'] as const,
  profile: () => ['profile'] as const,
  notifications: () => ['notifications'] as const,
  /**
   * Personalisation data for a given route slug.
   * Previously `pageLayout`; renamed to `mhPage` to match the `mh-page` key
   * used by usePersonalization and CrossTabRefresher.
   */
  mhPage: (route: string) => ['mh-page', route] as const,
  /**
   * Vendor deal list keyed by tab (matches useVendorDeals queryKey shape).
   * Use `tab` values: 'active' | 'pending' | 'closed' | 'history'.
   */
  vendorDeals: (tab: string) => ['vendor-deals', tab] as const,
  /** Current vendor's profile (no id — scoped to authenticated vendor session). */
  vendorProfile: () => ['vendor-profile'] as const,
  /** Current vendor's business hours (saved through profile PATCH; invalidated together). */
  vendorHours: () => ['vendor-hours'] as const,
  favorites: () => ['favorites'] as const,
  wishlist: () => ['wishlist'] as const,
  purchases: () => ['purchases'] as const,
  /** Purchase context for the quick-buy dialog (keyed by deal id). */
  purchaseContext: (dealId: string) => ['purchase-context', dealId] as const,
  /** Hot deals per time window + locale. */
  hotDeals: (window: string, locale: string) => ['hot-deals', window, locale] as const,
  /** Single support/transaction case detail. */
  case: (caseId: string) => ['case', caseId] as const,
  /** Case list keyed by viewer role ('customer' | 'vendor'). */
  cases: (viewerRole: string) => ['cases', viewerRole] as const,
  /** Vendor deal drafts list (no params — scoped to authenticated vendor session). */
  vendorDrafts: () => ['vendor', 'drafts'] as const,
  /** Admin audit log for a vendor (keyed by vendor id). */
  adminVendorAudit: (vendorId: string) => ['admin-vendor-audit', vendorId] as const,
  /** Reviews for a vendor (keyed by vendor id). */
  vendorReviews: (vendorId: string) => ['vendor-reviews', vendorId] as const,
} as const;
