/**
 * Consent context definition — shared by the provider and hooks.
 *
 * Phase 4: extracted from index.tsx.
 */

import { createContext } from 'react';
import type { ConsentManager } from '../core/ConsentManager';
import type {
  ConsentCategories,
  ConsentCategory,
  ConsentState,
} from '../types';

export interface ConsentContextValue {
  /** ConsentManager Instanz */
  manager: ConsentManager | null;
  /** Aktueller Consent-State */
  consent: ConsentState | null;
  /** Ist SDK initialisiert? */
  isInitialized: boolean;
  /** Wird geladen? */
  isLoading: boolean;
  /** Ist Banner sichtbar? */
  isBannerVisible: boolean;
  /** Wird Consent benoetigt? */
  needsConsent: boolean;
  /** Consent fuer Kategorie pruefen */
  hasConsent: (category: ConsentCategory) => boolean;
  /** Alle akzeptieren */
  acceptAll: () => Promise<void>;
  /** Alle ablehnen */
  rejectAll: () => Promise<void>;
  /** Auswahl speichern */
  saveSelection: (categories: Partial<ConsentCategories>) => Promise<void>;
  /** Banner anzeigen */
  showBanner: () => void;
  /** Banner verstecken */
  hideBanner: () => void;
  /** Einstellungen oeffnen */
  showSettings: () => void;
}

export const ConsentContext = createContext<ConsentContextValue | null>(null);
