import type { QuoteItem } from "@/modules/providers/quote-provider";

/** 契约驱动网络捕获产物 */
export type QuoteCaptureSignals = {
  /** 满足 rates 契约的 JSON 响应（normalize + shape-validated） */
  contractPayloads: Array<{ url: string; body: unknown }>;
  /** 全部 JSON 候选（debug only） */
  jsonPayloads: Array<{ url: string; body: unknown }>;
  /** submit 窗口 network trace（visibility） */
  networkTrace?: Array<{
    kind: "req" | "resp";
    url: string;
    method?: string;
    status?: number;
    contentType?: string;
  }>;
  /** 提交后页面 URL（仅诊断 telemetry） */
  resultUrl: string;
};

/** @deprecated 使用 contractPayloads */
export type LegacyQuoteCaptureSignals = {
  xhrPayloads: Array<{ url: string; body: unknown }>;
  resultUrl: string;
};

export type QuoteCaptureSource = "contract" | "lenient";

export type QuoteSubmitOptions = {
  skipAddressLock?: boolean;
  /** 仅 quote-strategy 在 Direct 失败后传入，禁止直接调用 Widget pipeline */
  widgetFallbackAfterDirectFailure?: boolean;
  /** MotherShip 候选已确认 blind 填址（与 RPA_BLIND_ADDRESS_FLOW 等效） */
  blindAddressFlow?: boolean;
};

export type QuoteDecodeResult = {
  items: QuoteItem[];
  source: QuoteCaptureSource;
};
