/**
 * Developer-only debug collector for the Place Order / quote-execution flow.
 *
 * When enabled, the surrounding component pushes structured snapshots of every
 * meaningful step into a global store and exposes a small set of helpers on
 * `window` so a developer (or designer reporting a bug) can do this in the
 * browser console after a failed order:
 *
 *   window.getFailedExecutionData()   // copies sanitized JSON to clipboard
 *   window.getExecutionData()         // full store, sanitized + copied
 *   window.clearExecutionData()       // wipe the store and start fresh
 *
 * Enablement
 * ----------
 * Off by default. Partner apps opt in by setting `enableDebug: true` on
 * `AggUiConfig` (typically gated on a `NEXT_PUBLIC_AGG_ENABLE_DEBUG` env var
 * in the host app). When `enableDebug` is `false` the place-order component
 * never invokes `enableExecutionDebugInBrowser`, so this module installs no
 * window helpers and performs no side effects.
 *
 * What gets captured per attempt
 * ------------------------------
 *  - Quote request input + the selected route summary.
 *  - Order side (buy/sell), market/event identifiers, venue identifiers.
 *  - Normalized display steps and the raw DAG / websocket events that
 *    produced them.
 *  - Wallet-confirmation transitions.
 *  - Bridge / venue-execution metadata when present in the route.
 *  - Terminal status (`succeeded` / `failed` / `cancelled` / ...).
 *  - Errors, including the failed step / message / code when available.
 *  - Environment info: app + package versions if known, URL, user agent,
 *    capture timestamp.
 *
 * What is intentionally redacted
 * ------------------------------
 *  - JWTs, access/refresh tokens, raw `Authorization` headers, cookies.
 *  - Wallet signatures and private keys.
 *  - Passwords, API keys, generic `secret` values.
 *  - Email addresses (and any field whose name *contains* `email`).
 *  - Raw HTTP `headers` blobs (the Authorization line is never useful in a
 *    bug report and may carry session material).
 *  Any field name containing one of the patterns in `SENSITIVE_FIELD_PATTERNS`
 *  is replaced with the literal string `[redacted]` in the output. Cycles in
 *  the captured object graph are broken with `[circular]`.
 *
 * Example workflow for designers / testers reporting a bug
 * --------------------------------------------------------
 *  1. Reproduce the failed order in dev/staging/preview.
 *  2. Open DevTools → Console.
 *  3. Run: `window.getFailedExecutionData()`
 *  4. Paste the clipboard contents into the bug report (Linear / Slack).
 *  5. Optionally `window.clearExecutionData()` before the next reproduction
 *     so subsequent attempts start with an empty timeline.
 */
/**
 * Recursively redact known-sensitive fields. The output is a structurally
 * identical clone of the input where any sensitive value has been replaced
 * with the literal `[redacted]` marker. Non-sensitive fields pass through
 * unchanged.
 *
 * Cycle detection tracks only the current DFS path (parents of the node
 * currently being walked), not every node ever seen. That distinction
 * matters: shared references — e.g. the same `orderIds` array stored on
 * multiple `state_change` events, or the same selected-route object
 * referenced in two sibling fields — are NOT cycles and must serialize fully
 * each time. Only true ancestor self-references (`a.self = a`) are
 * collapsed to the literal `[circular]` marker.
 */
export declare const sanitizeExecutionDebugValue: <T>(input: T) => T;
export type ExecutionDebugStatus = "idle" | "quoting" | "executing" | "wallet_confirmation_required" | "succeeded" | "failed" | "cancelled";
export type ExecutionDebugQuoteSnapshot = {
    request?: unknown;
    response?: unknown;
    selectedRoute?: unknown;
    side?: "buy" | "sell";
    marketId?: string;
    eventId?: string;
    outcomeId?: string;
    venues?: string[];
    capturedAt: number;
};
export type ExecutionDebugEvent = {
    /** Stable category — useful for filtering. */
    kind: "quote_request" | "quote_response" | "execute_request" | "execute_response" | "state_change" | "ws_update" | "normalized_steps" | "wallet_confirmation" | "terminal_event" | "error";
    /** Free-form label distinguishing events of the same `kind`. */
    label?: string;
    data?: unknown;
    timestamp: number;
};
export type ExecutionDebugError = {
    message: string;
    name?: string;
    code?: string;
    stack?: string;
    failedStep?: string;
    data?: unknown;
    timestamp: number;
};
export type ExecutionDebugAttempt = {
    attemptId: string;
    startedAt: number;
    updatedAt: number;
    status: ExecutionDebugStatus;
    /** Promoted to top level for at-a-glance triage when scrolling failed attempts. */
    quoteId?: string;
    /** First / primary order ID once `executeManaged` returns. */
    orderId?: string;
    /** All order IDs in the executed route (for split orders). */
    orderIds?: string[];
    quote?: ExecutionDebugQuoteSnapshot;
    selectedRoute?: unknown;
    bridge?: unknown;
    venueExecution?: unknown;
    rawEvents: ExecutionDebugEvent[];
    normalizedSteps: unknown[];
    errors: ExecutionDebugError[];
    finalStatus?: ExecutionDebugStatus;
};
export type ExecutionDebugEnvironment = {
    appVersion?: string;
    packageVersions?: Record<string, string>;
    url?: string;
    userAgent?: string;
    capturedAt: number;
};
export type ExecutionDebugStore = {
    attempts: ExecutionDebugAttempt[];
    environment: ExecutionDebugEnvironment;
};
export type AppendExecutionDebugAttemptInput = Partial<Pick<ExecutionDebugAttempt, "status" | "quoteId" | "orderId" | "orderIds" | "quote" | "selectedRoute" | "bridge" | "venueExecution">> & {
    attemptId?: string;
};
export type UpdateExecutionDebugAttemptInput = Partial<Pick<ExecutionDebugAttempt, "status" | "quoteId" | "orderId" | "orderIds" | "quote" | "selectedRoute" | "bridge" | "venueExecution" | "finalStatus">>;
/**
 * Pure debug store. The window-scoped collector below is a thin wrapper around
 * an instance of this — but the store itself is environment-agnostic and fully
 * testable in isolation.
 */
export declare const createExecutionDebugStore: (initial?: Partial<Omit<ExecutionDebugEnvironment, "capturedAt">>) => {
    appendAttempt: (input?: AppendExecutionDebugAttemptInput) => ExecutionDebugAttempt;
    updateAttempt: (attemptId: string, patch: UpdateExecutionDebugAttemptInput) => void;
    appendEvent: (attemptId: string, event: Omit<ExecutionDebugEvent, "timestamp"> & {
        timestamp?: number;
    }) => void;
    appendError: (attemptId: string, error: Omit<ExecutionDebugError, "timestamp"> & {
        timestamp?: number;
    }) => void;
    setNormalizedSteps: (attemptId: string, steps: unknown[]) => void;
    getSnapshot: () => ExecutionDebugStore;
    getFailedAttempts: () => ExecutionDebugAttempt[];
    clear: () => void;
};
export type ExecutionDebugStoreInstance = ReturnType<typeof createExecutionDebugStore>;
declare global {
    interface Window {
        executionData?: ExecutionDebugStore;
        getExecutionData?: () => ExecutionDebugStore;
        getFailedExecutionData?: () => {
            attempts: ExecutionDebugAttempt[];
        };
        clearExecutionData?: () => void;
        __aggExecutionDebugStore?: ExecutionDebugStoreInstance;
    }
}
export type InstallExecutionDebugWindowOptions = {
    store: ExecutionDebugStoreInstance;
    /** Override `console` for testing the activation banner and copy logs. */
    consoleImpl?: Pick<Console, "info" | "warn" | "log">;
};
/**
 * Install the `window.executionData` / `window.getExecutionData()` /
 * `window.getFailedExecutionData()` / `window.clearExecutionData()` helpers
 * in the current document. Returns an `uninstall` callback that restores the
 * previous values — handy for cleanup in tests and React effects.
 */
export declare const installExecutionDebugWindow: ({ store, consoleImpl, }: InstallExecutionDebugWindowOptions) => (() => void);
/**
 * Convenience: shared singleton + window-installer used by the React layer.
 * Returns `null` when there is no `window` (SSR). Callers gate this on the
 * `enableDebug` flag from `AggUiConfig` — when that flag is off, this is
 * never invoked and the module has no runtime footprint.
 */
export declare const enableExecutionDebugInBrowser: (initial?: Partial<Omit<ExecutionDebugEnvironment, "capturedAt">>) => ExecutionDebugStoreInstance | null;
