export declare const DEFAULT_BASE_URL: string;

export declare class ProspectApisError extends Error {
  status: number;
  code: string | null;
  body: unknown;
}

export interface VerifyResult {
  email: string;
  status: "valid" | "invalid" | "catch-all" | "unknown";
  reason: string | null;
  reason_text: string;
  score: number;
  recommendation: "send" | "send_with_caution" | "retry_later" | "do_not_send";
  charged: boolean;
  flags: string[];
  smtp_code: number | null;
  catch_all_tier: string | null;
  did_you_mean: string | null;
  mail_provider: string | null;
  checked_at: string;
}

export interface VerifyResponse { data: VerifyResult[]; count: number; charged_count: number; amount_usd: number; depth: "full" | "quick" }

export interface FindResponse {
  status: "found" | "catch_all" | "unknown" | "not_found";
  email: string | null;
  pattern: string | null;
  best_guess: string | null;
  domain: string;
  charged: boolean;
  amount_usd: number;
  checked: Array<{ email: string; pattern: string; status: string; reason: string | null }>;
}

export interface DomainInfo {
  domain: string;
  exists: boolean | null;
  accepts_mail: boolean | null;
  null_mx: boolean;
  mx: Array<{ preference: number | null; host: string }>;
  mail_provider: string | null;
  spf: boolean | null;
  dmarc: "reject" | "quarantine" | "none" | "missing" | null;
  disposable: boolean;
  free_provider: boolean;
  parked: boolean;
  catch_all: boolean | null;
  catch_all_checked_at: string | null;
  domain_age_days: number | null;
  new_domain: boolean;
  did_you_mean: string | null;
  checked_at: string;
}

export interface VerifyJob {
  id: string;
  status: "queued" | "running" | "completed" | "cancelled";
  total: number;
  done: number;
  charged_count: number;
  amount_usd: number;
  callback_url: string | null;
  callback_status: "delivered" | "failed" | null;
  created_at: string;
  completed_at: string | null;
  secret?: string;
}

export type EmailItem = string | { email: string; first_name?: string; last_name?: string };

export declare class ProspectApis {
  constructor(opts?: { apiKey?: string; baseUrl?: string; fetch?: typeof fetch; timeoutMs?: number });
  request<T = unknown>(method: string, path: string, opts?: { query?: Record<string, unknown>; body?: unknown; idempotencyKey?: string; raw?: boolean }): Promise<T>;
  verifyEmails(emails: EmailItem[], opts?: { depth?: "full" | "quick"; idempotencyKey?: string }): Promise<VerifyResponse>;
  findEmail(person: { firstName: string; lastName?: string; domain: string }, opts?: { idempotencyKey?: string }): Promise<FindResponse>;
  checkDomain(domain: string): Promise<DomainInfo>;
  reportOutcomes(outcomes: Array<{ email: string; outcome: "bounced" | "delivered" }>): Promise<{ stored: number; bounce_credits: number; credited_usd: number }>;
  verifyStats(opts?: { days?: number }): Promise<Record<string, unknown>>;
  cleanList(emails: string[], opts?: { idempotencyKey?: string }): Promise<{
    keep: string[]; review: Array<{ email: string; reason: string; did_you_mean: string | null }>;
    remove: Array<{ email: string; reason: string; reason_text: string }>; malformed: string[]; not_checked: string[];
    counts: Record<string, number>; amount_usd: number; note: string }>;
  createVerifyJob(emails: EmailItem[], opts?: { callbackUrl?: string; sample?: number; monitorDays?: number; idempotencyKey?: string }): Promise<VerifyJob>;
  stopVerifyJob(id: string): Promise<VerifyJob>;
  getVerifyJob(id: string): Promise<VerifyJob>;
  verifyJobResults(id: string, opts?: { cursor?: number; limit?: number; format?: "json" | "csv" }): Promise<{ job: VerifyJob; data: VerifyResult[]; next_cursor: number | null } | string>;
  allVerifyJobResults(id: string): AsyncGenerator<VerifyResult>;
  waitForVerifyJob(id: string, opts?: { intervalMs?: number; timeoutMs?: number }): Promise<VerifyJob>;
  searchFunding(query?: Record<string, string | number>): Promise<Record<string, unknown>>;
  getFunding(id: string): Promise<Record<string, unknown>>;
  submitResearch(body: Record<string, unknown>, opts?: { idempotencyKey?: string }): Promise<Record<string, unknown>>;
  getResearch(id: string): Promise<Record<string, unknown>>;
  createWatchlist(body: Record<string, unknown>): Promise<Record<string, unknown>>;
  listWatchlists(): Promise<Record<string, unknown>>;
  getWatchlist(id: string): Promise<Record<string, unknown>>;
  deleteWatchlist(id: string): Promise<Record<string, unknown>>;
  account(): Promise<Record<string, unknown>>;
  pricing(): Promise<Record<string, unknown>>;
}

export default ProspectApis;
