import { EventEmitter } from "../../stencil-public-runtime";
import type { UiScreen } from "../../types/components";
import type { WidgetBranding, WidgetTheme } from "../../utils/branding";
/**
 * Submit event detail - emitted when a form is submitted
 */
export interface SubmitEventDetail {
    /** The current screen configuration */
    screen: UiScreen;
    /** Form field values keyed by component ID */
    data: Record<string, string>;
}
/**
 * Button click event detail - emitted when a non-submit button is clicked
 */
export interface ButtonClickEventDetail {
    /** Component ID */
    id: string;
    /** Component type (e.g., 'SOCIAL', 'BACK_BUTTON') */
    type: string;
    /** Optional value (e.g., connection name for social buttons) */
    value?: string;
}
/**
 * Link click event detail - emitted when a link is clicked
 */
export interface LinkClickEventDetail {
    /** Link ID */
    id?: string;
    /** Link href */
    href: string;
    /** Link text */
    text: string;
}
/**
 * Navigate event detail - emitted when the widget wants to navigate
 */
export interface NavigateEventDetail {
    /** URL to navigate to */
    url: string;
    /** Whether to replace the current history entry */
    replace?: boolean;
}
/**
 * Complete event detail - emitted when auth flow completes
 */
export interface CompleteEventDetail {
    /** Redirect URL (contains code for authorization code flow) */
    redirectUrl?: string;
}
/**
 * Error event detail - emitted on errors
 */
export interface ErrorEventDetail {
    /** Error message */
    message: string;
    /** Error code */
    code?: string;
}
/**
 * Auth params needed for social login and OAuth flows
 */
export interface AuthParams {
    client_id: string;
    redirect_uri?: string;
    scope?: string;
    audience?: string;
    nonce?: string;
    response_type?: string;
    state?: string;
}
/**
 * State persistence mode - where to track state and screen
 */
export type StatePersistence = "url" | "session" | "memory";
export declare class AuthheroWidget {
    el: HTMLElement;
    /**
     * The UI screen configuration from the server.
     * Can be passed as a JSON string or object.
     * Follows Auth0 Forms component schema.
     */
    screen?: UiScreen | string;
    /**
     * API endpoint to fetch the initial screen from.
     * If provided, the widget will fetch the screen on load.
     * Can include {screenId} placeholder which will be replaced with the current screen.
     * Example: "/u2/screen/{screenId}" or "https://auth.example.com/u2/screen/{screenId}"
     */
    apiUrl?: string;
    /**
     * Base URL for all API calls. Used when widget is embedded on a different domain.
     * If not provided, relative URLs are used.
     * Example: "https://auth.example.com"
     */
    baseUrl?: string;
    /**
     * Login session state token. Required for social login and maintaining session.
     */
    state?: string;
    /**
     * Current screen ID. Used with apiUrl to fetch screen configuration.
     * When statePersistence is 'url', this is synced with the URL.
     */
    screenId?: string;
    watchScreenId(): void;
    /**
     * OAuth/OIDC parameters for social login redirects.
     * Can be passed as a JSON string or object.
     */
    authParams?: AuthParams | string;
    /**
     * Where to persist state and screen ID.
     * - 'url': Updates URL path/query (default for standalone pages)
     * - 'session': Uses sessionStorage (for embedded widgets)
     * - 'memory': No persistence, state only in memory
     * @default 'memory'
     */
    statePersistence: StatePersistence;
    /**
     * Storage key prefix for session/local storage persistence.
     * @default 'authhero_widget'
     */
    storageKey: string;
    /**
     * Branding configuration from AuthHero API.
     * Controls logo, primary color, and page background.
     * Can be passed as a JSON string or object.
     */
    branding?: WidgetBranding | string;
    /**
     * Theme configuration from AuthHero API.
     * Controls colors, borders, fonts, and layout.
     * Can be passed as a JSON string or object.
     */
    theme?: WidgetTheme | string;
    /**
     * Whether the widget is in a loading state.
     */
    loading: boolean;
    /**
     * Whether the widget should automatically submit forms to the action URL.
     * When false (default), the widget only emits events and the consuming
     * application handles all HTTP requests.
     * When true, the widget handles form submission and screen updates.
     * @default false
     */
    autoSubmit: boolean;
    /**
     * Whether the widget should handle navigation automatically.
     * When true, social login buttons redirect, links navigate, etc.
     * When false, only events are emitted.
     * @default false (same as autoSubmit when not specified)
     */
    autoNavigate?: boolean;
    /**
     * Internal parsed screen state.
     */
    _screen?: UiScreen;
    /**
     * Internal parsed auth params state.
     */
    _authParams?: AuthParams;
    /**
     * Internal parsed branding state.
     */
    _branding?: WidgetBranding;
    /**
     * Internal parsed theme state.
     */
    _theme?: WidgetTheme;
    /**
     * Form data collected from inputs.
     */
    formData: Record<string, string>;
    /**
     * AbortController for an in-flight conditional mediation request.
     * Aborted on screen change or component disconnect.
     */
    private conditionalMediationAbort?;
    /**
     * Emitted when the form is submitted.
     * The consuming application should handle the submission unless autoSubmit is true.
     */
    formSubmit: EventEmitter<SubmitEventDetail>;
    /**
     * Emitted when a non-submit button is clicked (social login, back, etc.).
     * The consuming application decides what to do based on id/type/value.
     */
    buttonClick: EventEmitter<ButtonClickEventDetail>;
    /**
     * Emitted when a link is clicked.
     * The consuming application decides how to handle navigation.
     */
    linkClick: EventEmitter<LinkClickEventDetail>;
    /**
     * Emitted when the widget wants to navigate (e.g., after successful auth).
     * The consuming application decides how to handle navigation.
     */
    navigate: EventEmitter<NavigateEventDetail>;
    /**
     * Emitted when auth flow completes with a redirect URL.
     * The consuming application can redirect or extract the code.
     */
    flowComplete: EventEmitter<CompleteEventDetail>;
    /**
     * Emitted when an error occurs.
     */
    flowError: EventEmitter<ErrorEventDetail>;
    /**
     * Emitted when the screen changes.
     */
    screenChange: EventEmitter<UiScreen>;
    watchScreen(newValue: UiScreen | string | undefined): void;
    /**
     * Initialize formData from component default_value configs.
     * This pre-fills form fields with values resolved on the server
     * (e.g. from user profile context).
     */
    private initFormDataFromDefaults;
    /**
     * Updates the data-screen attribute on the host element and its parent container.
     * This allows external CSS to target different screens using attribute selectors.
     * The parent container (e.g. widget-container div from SSR) is also updated
     * so that page-level CSS selectors work during SPA navigation.
     */
    private updateDataScreenAttribute;
    watchBranding(newValue: WidgetBranding | string | undefined): void;
    watchTheme(newValue: WidgetTheme | string | undefined): void;
    watchAuthParams(newValue: AuthParams | string | undefined): void;
    /**
     * Apply branding and theme as CSS custom properties
     */
    private applyThemeStyles;
    /**
     * Focus the first input field in the form.
     * Called after screen changes to ensure keyboard navigation works properly.
     */
    private focusFirstInput;
    /**
     * Get the effective autoNavigate value (defaults to autoSubmit if not set)
     */
    private get shouldAutoNavigate();
    /**
     * Build the full URL for API calls
     */
    private buildUrl;
    /**
     * Load state from URL or storage based on statePersistence setting
     */
    private loadPersistedState;
    /**
     * Save state to URL or storage based on statePersistence setting
     */
    private persistState;
    private handlePopState;
    connectedCallback(): void;
    disconnectedCallback(): void;
    componentWillLoad(): Promise<void>;
    /**
     * Fetch screen configuration from the API
     * @param screenIdOverride Optional screen ID to fetch (overrides this.screenId)
     * @param nodeId Optional node ID for flow navigation
     */
    fetchScreen(screenIdOverride?: string, nodeId?: string): Promise<boolean>;
    private handleInputChange;
    private handleSubmit;
    /**
     * Override form.submit() so that scripts (e.g. WebAuthn ceremony) that call
     * form.submit() go through the widget's JSON fetch pipeline instead of a
     * native form-urlencoded POST.
     */
    private overrideFormSubmit;
    /**
     * Validate and execute a structured WebAuthn ceremony returned by the server.
     * Instead of injecting arbitrary script content, this parses the ceremony JSON,
     * validates the expected fields, and calls the WebAuthn API natively.
     */
    private performWebAuthnCeremony;
    /**
     * Schema validation for WebAuthn ceremony payloads.
     * Checks required fields and types before invoking browser APIs.
     */
    private isValidWebAuthnCeremony;
    /**
     * Perform the WebAuthn navigator.credentials.create() ceremony and submit
     * the credential result via the form.
     */
    private executeWebAuthnRegistration;
    /**
     * Perform the WebAuthn navigator.credentials.get() ceremony (explicit modal)
     * and submit the credential result via the form.
     */
    private executeWebAuthnAuthentication;
    /**
     * Execute WebAuthn conditional mediation (autofill-assisted passkeys).
     * Runs in the background — the browser shows passkey suggestions in the
     * username field's autofill dropdown. Silently ignored if unsupported.
     */
    private executeWebAuthnConditionalMediation;
    private handleButtonClick;
    /**
     * Handle social login redirect
     */
    private handleSocialLogin;
    /**
     * Handle resend button click (e.g., resend OTP code)
     */
    private handleResend;
    /**
     * Extract screen ID from a u2 link href.
     * Handles patterns like /u2/login/{screenId}?state=... and /u2/{screenId}?state=...
     * Returns the screen ID or null if the href doesn't match a known pattern.
     */
    private extractScreenIdFromHref;
    private handleLinkClick;
    /**
     * Navigate to a screen client-side by fetching it from the API.
     * Updates the widget state and browser URL without a full page reload.
     */
    private navigateToScreen;
    /**
     * Look up the href for a social provider from the current screen's SOCIAL components.
     * Returns the href if found (e.g. for passwordless connections), or null.
     */
    private getProviderHref;
    /**
     * Check if a component is a social button.
     */
    private isSocialComponent;
    /**
     * Check if a component is a divider.
     */
    private isDividerComponent;
    render(): any;
}
