/**
 * Moderation Queue Type Definitions
 * 
 * This file contains all TypeScript types and interfaces used by the moderation queue system.
 * Extracted from ModerationQueue.tsx to improve maintainability and reusability.
 */

/**
 * Photo display interface for moderation queue
 */
export interface PhotoForDisplay {
  id: string;
  url: string;
  cloudflare_image_url: string;
  filename: string;
  caption?: string | null;
  title?: string | null;
  date_taken?: string | null;
  order_index: number;
}

/**
 * Location data interface
 */
export interface LocationData {
  id: string;
  city?: string | null;
  state_province?: string | null;
  country: string;
  formatted_address?: string | null;
}

/**
 * Park submission item data
 */
export interface ParkItemData {
  park_id?: string;
  name: string;
  slug: string;
  description?: string;
  park_type: string;
  status: string;
  location_id?: string;
  operator_id?: string;
  property_owner_id?: string;
  opening_date?: string;
  closing_date?: string;
  source_url?: string;
  submission_notes?: string;
}

/**
 * Ride submission item data
 */
export interface RideItemData {
  ride_id?: string;
  name: string;
  slug: string;
  park_id: string;
  manufacturer_id?: string;
  designer_id?: string;
  model_id?: string;
  ride_type: string;
  status: string;
  opening_date?: string;
  closing_date?: string;
  source_url?: string;
  submission_notes?: string;
}

/**
 * Company submission item data
 */
export interface CompanyItemData {
  company_id?: string;
  name: string;
  slug: string;
  company_type: string;
  country?: string;
  founded_year?: number;
  source_url?: string;
  submission_notes?: string;
}

/**
 * Ride model submission item data
 */
export interface RideModelItemData {
  model_id?: string;
  name: string;
  slug: string;
  manufacturer_id: string;
  model_type: string;
  source_url?: string;
  submission_notes?: string;
}

/**
 * Photo submission item data
 */
export interface PhotoItemData {
  photo_url: string;
  cloudflare_image_id?: string;
  caption?: string;
  title?: string;
  order_index?: number;
  source_url?: string;
  submission_notes?: string;
}

/**
 * Union type for all submission item data
 */
export type SubmissionItemData = 
  | ParkItemData 
  | RideItemData 
  | CompanyItemData 
  | RideModelItemData
  | PhotoItemData;

/**
 * Represents a single item in the moderation queue.
 * Can be either a review or a content submission.
 */
export interface ModerationItem {
  /** Unique identifier for the item */
  id: string;
  
  /** Type of moderation item */
  type: 'review' | 'content_submission';
  
  /** Raw content data (structure varies by type) */
  content: any;
  
  /** Timestamp when the item was created */
  created_at: string;
  
  /** Timestamp when the item was last updated */
  updated_at?: string;
  
  /** ID of the user who submitted this item */
  user_id: string;
  
  /** Current status of the item */
  status: string;
  
  /** Type of submission (e.g., 'park', 'ride', 'review') */
  submission_type?: string;
  
  /** Profile information of the submitting user */
  user_profile?: {
    username: string;
    display_name?: string;
    avatar_url?: string;
  };
  
  /** Display name of the entity being modified */
  entity_name?: string;
  
  /** Display name of the park (for ride submissions) */
  park_name?: string;
  
  /** Timestamp when the item was reviewed */
  reviewed_at?: string;
  
  /** ID of the moderator who reviewed this item */
  reviewer_id?: string;
  
  /** Username of the moderator who reviewed this item */
  reviewed_by?: string;
  
  /** Notes left by the reviewing moderator */
  reviewer_notes?: string;
  
  /** Profile information of the reviewing moderator */
  reviewer_profile?: {
    username: string;
    display_name?: string;
    avatar_url?: string;
  };
  
  /** Whether this submission has been escalated for senior review */
  escalated?: boolean;
  
  /** ID of the moderator this item is assigned to */
  assigned_to?: string;
  
  /** Timestamp until which this item is locked by a moderator */
  locked_until?: string;
  
  /** Internal flag indicating item is being removed (optimistic update) */
  _removing?: boolean;
  
  /** Sub-items for composite submissions */
  submission_items?: Array<{
    id: string;
    item_type: string;
    item_data: SubmissionItemData;
    original_data?: SubmissionItemData;
    status: string;
  }>;
}

/**
 * Filter options for entity types in the moderation queue
 */
export type EntityFilter = 'all' | 'reviews' | 'submissions' | 'photos';

/**
 * Filter options for submission status in the moderation queue
 */
export type StatusFilter = 'all' | 'pending' | 'partially_approved' | 'flagged' | 'approved' | 'rejected';

/**
 * Available tabs in the moderation interface
 */
export type QueueTab = 'mainQueue' | 'archive';

/**
 * Available fields for sorting the moderation queue
 */
export type SortField = 'created_at' | 'submission_type' | 'status';

/**
 * Sort direction
 */
export type SortDirection = 'asc' | 'desc';

/**
 * Configuration for sorting the moderation queue
 */
export interface SortConfig {
  /** Field to sort by */
  field: SortField;
  /** Sort direction */
  direction: SortDirection;
}

/**
 * Loading states for the moderation queue
 */
export type LoadingState = 'initial' | 'loading' | 'refreshing' | 'ready';

/**
 * Ref interface for the ModerationQueue component
 * Allows parent components to trigger actions imperatively
 */
export interface ModerationQueueRef {
  /** Manually refresh the queue data */
  refresh: () => void;
}
