import { User, UserDataAdapter } from "@authhero/adapter-interfaces";
import { EnrichedClient } from "./client";
import { Context } from "hono";
import { Bindings, Variables } from "../types";
export declare function getUsersByEmail(userAdapter: UserDataAdapter, tenantId: string, email: string): Promise<User[]>;
interface GetUserByProviderParams {
    userAdapter: UserDataAdapter;
    tenant_id: string;
    username: string;
    provider: string;
}
export declare function getUserByProvider({ userAdapter, tenant_id, username, provider, }: GetUserByProviderParams): Promise<User | null>;
/**
 * Order users by age (oldest first). When account-linking has to choose
 * which of two matching users should remain primary, the older account
 * wins — it has the longer history, accrued sessions, and is most likely
 * the canonical identity the user expects to keep.
 *
 * Falls back to `user_id` so the ordering is fully deterministic when
 * `created_at` is missing or identical (e.g. fixture rows seeded in the
 * same millisecond).
 */
export declare function compareUsersByAge(a: User, b: User): number;
interface GetPrimaryUserByEmailParams {
    userAdapter: UserDataAdapter;
    tenant_id: string;
    email: string;
}
export declare function getPrimaryUserByEmail({ userAdapter, tenant_id, email, }: GetPrimaryUserByEmailParams): Promise<User | undefined>;
interface RepointPrimaryParams {
    userAdapter: UserDataAdapter;
    tenant_id: string;
    formerPrimary: User;
    newPrimaryId: string;
}
/**
 * Demote `formerPrimary` to a secondary of `newPrimaryId`. Any users
 * currently linked to `formerPrimary` are repointed first so the resulting
 * graph remains a single hop deep — `getPrimaryUserByProvider` and similar
 * resolvers only follow one `linked_to` step.
 *
 * Each write is a single-field `linked_to` update so the user-update
 * decorator's fast-path bypasses the pre/post hooks and we don't re-enter
 * the linking logic recursively.
 */
export declare function repointPrimary({ userAdapter, tenant_id, formerPrimary, newPrimaryId, }: RepointPrimaryParams): Promise<void>;
interface GetPrimaryUserByProviderParams {
    userAdapter: UserDataAdapter;
    tenant_id: string;
    username: string;
    provider: string;
}
export declare function getPrimaryUserByProvider({ userAdapter, tenant_id, username, provider, }: GetPrimaryUserByProviderParams): Promise<User | null>;
interface GetOrCreateUserByProviderParams {
    client: EnrichedClient;
    username: string;
    provider: string;
    connection: string;
    userId?: string;
    profileData?: Record<string, unknown>;
    ip?: string;
    isSocial: boolean;
    set_user_root_attributes?: "on_each_login" | "on_first_login" | "never_on_login";
}
/**
 * This function will either fetch an existing user for a provider or create it
 * @param param0
 * @returns
 */
export declare function getOrCreateUserByProvider(ctx: Context<{
    Bindings: Bindings;
    Variables: Variables;
}>, params: GetOrCreateUserByProviderParams): Promise<User>;
export {};
