/**
 * Types for built-in screens
 */
import { Context } from "hono";
import { UiScreen, Tenant, Theme, Connection, CustomText } from "@authhero/adapter-interfaces";
import { EnrichedClient } from "../../../helpers/client";
import { Bindings, Variables } from "../../../types";
/**
 * Branding information for screen rendering
 */
export interface ScreenBranding {
    logo_url?: string;
    favicon_url?: string;
    powered_by_logo_url?: string;
    colors?: {
        primary?: string;
        page_background?: string | {
            type?: string;
            start?: string;
            end?: string;
            angle_deg?: number;
        };
    };
    font?: {
        url?: string;
    };
}
/**
 * Context passed to screen factories
 */
export interface ScreenContext {
    /** The Hono context */
    ctx: Context<{
        Bindings: Bindings;
        Variables: Variables;
    }>;
    /** The current tenant */
    tenant: Tenant;
    /** The current client application - uses EnrichedClient which has full connection objects */
    client: EnrichedClient;
    /** Theme configuration */
    theme?: Theme;
    /** Branding configuration */
    branding?: ScreenBranding;
    /** Available connections for this client */
    connections: Connection[];
    /** The login state parameter */
    state: string;
    /** Pre-filled values for form fields */
    prefill?: Record<string, string | undefined>;
    /** Error messages to display */
    errors?: Record<string, string>;
    /** Screen-level messages to display (errors, success, info, warnings) */
    messages?: Array<{
        text: string;
        type: "error" | "success" | "info" | "warning";
    }>;
    /** Additional screen-specific data */
    data?: Record<string, unknown>;
    /** Route prefix for universal login routes (e.g., "/u" or "/u2") */
    routePrefix?: string;
    /** Custom texts for the current language */
    customText?: CustomText;
    /** Current language code (e.g., 'en', 'es') */
    language?: string;
    /** Prompt screen ID for custom text namespacing (e.g., 'login-id', 'signup') */
    promptScreen?: string;
    /** Screen name for extracting screen-specific custom text from nested structure */
    screenName?: string;
}
/**
 * Structured WebAuthn ceremony data sent to the widget instead of raw script.
 * The widget validates the shape and performs the ceremony natively.
 */
export interface WebAuthnCeremony {
    type: "webauthn-registration" | "webauthn-authentication" | "webauthn-authentication-conditional";
    options: {
        challenge: string;
        rp?: {
            id: string;
            name: string;
        };
        rpId?: string;
        user?: {
            id: string;
            name: string;
            displayName: string;
        };
        pubKeyCredParams?: Array<{
            alg: number;
            type: string;
        }>;
        timeout?: number;
        attestation?: string;
        authenticatorSelection?: {
            residentKey?: string;
            userVerification?: string;
        };
        excludeCredentials?: Array<{
            id: string;
            type: string;
            transports?: string[];
        }>;
        userVerification?: string;
        allowCredentials?: Array<{
            id: string;
            type: string;
            transports?: string[];
        }>;
    };
    successAction: string;
}
/**
 * Result from a screen factory
 */
export interface ScreenResult {
    /** The screen definition for the widget */
    screen: UiScreen;
    /** Branding to apply */
    branding?: ScreenBranding;
    /** Optional inline script to inject at page level (e.g. WebAuthn ceremony) */
    extraScript?: string;
    /** Structured WebAuthn ceremony data for widget-based flows */
    ceremony?: WebAuthnCeremony;
}
/**
 * A screen factory creates a UiScreen from context
 * Always async for consistency (even if the implementation is sync)
 */
export type ScreenFactory = (context: ScreenContext) => Promise<ScreenResult>;
/**
 * Handler for screen form submissions
 */
export interface ScreenHandler {
    /** Handle GET request - returns the screen (can be sync or async) */
    get: ScreenFactory;
    /** Handle POST request - process form data and return next screen or redirect */
    post?: (context: ScreenContext, data: Record<string, unknown>) => Promise<{
        screen: ScreenResult;
    } | {
        redirect: string;
        cookies?: string[];
    } | {
        error: string;
        screen: ScreenResult;
    } | {
        response: Response;
    }>;
}
/**
 * Screen definition including factory and optional handler
 */
export interface ScreenDefinition {
    /** Unique screen ID (matches route path) */
    id: string;
    /** Human-readable name */
    name: string;
    /** Description */
    description?: string;
    /** The screen handler */
    handler: ScreenHandler;
}
/**
 * Get the correct login path based on the tenant's identifier_first setting.
 * Returns "/u2/login" for password-first or "/u2/login/identifier" for identifier-first.
 */
export declare function getLoginPath(context: ScreenContext): Promise<string>;
