import type { PostType } from '@insta-monitor/core';

/** A post/reel as scraped from Instagram, before it gets a DB id. */
export interface ScrapedPost {
  shortcode: string;
  type: PostType;
  url: string;
  thumbnail: string | null;
  caption: string | null;
  /** ISO-8601 upload timestamp. */
  uploadedAt: string;
  viewCount: number | null;
  /** Current like count, or null when hidden/unavailable. */
  likeCount: number | null;
  /** Current comment count — the app records this as the day's snapshot. */
  commentCount: number;
}

/** A profile + its scraped posts, mappable to db account meta + post upserts. */
export interface ScrapedProfile {
  username: string;
  displayName: string | null;
  followerCount: number;
  postCount: number;
  posts: ScrapedPost[];
  /** True when web_profile_info failed: followerCount/postCount are placeholders,
   *  not fresh IG values — don't overwrite stored account meta with them. */
  metaMissing?: boolean;
  /** True when IG reports the account is private (is_private). With no posts served,
   *  the caller marks it a private channel instead of a collection failure. */
  isPrivate?: boolean;
}

export interface CollectorOptions {
  /** Path to the persisted Playwright storageState (login session). */
  sessionPath: string;
  headless?: boolean;
  navigationTimeoutMs?: number;
  /** Max scroll iterations when paginating a profile's posts (default 10). */
  maxScrolls?: number;
  /** Stop paginating once posts older than this many days are reached (the 수집 범위). */
  collectDays?: number;
  /** Only (re)fetch reel view counts for reels uploaded within this many days (default 3). */
  viewWindowDays?: number;
  /** Which browser build to launch: 'auto' (default) prefers real host Chrome when
   *  present (best anti-detection) and falls back to bundled Chromium; force with
   *  'chrome'/'chromium'. Real Chrome is the only thing that removes the headless
   *  WebGL/plugins fingerprint tells. */
  browserChannel?: 'chrome' | 'chromium' | 'auto';
}
