import { lib as KeetaNetLib } from '@keetanetwork/keetanet-client';
import { getDefaultResolver } from '../../config.js';
import type { UserClient as KeetaNetUserClient } from '@keetanetwork/keetanet-client';
import type { Logger } from '../../lib/log/index.ts';
import Resolver from '../../lib/resolver.js';
import type { ServiceMetadata, ServiceMetadataAuthenticationType, SharedLookupCriteria } from '../../lib/resolver.ts';
import type { BrandedString } from '../../lib/utils/brand.ts';
import type { TransferUsernameOwnershipSignablePayload, KeetaUsernameAnchorUsernameWithAccount, KeetaUsernameAnchorSearchRequestParameters } from './common.js';
import { type KeetaNetAccount, type GloballyIdentifiableUsername } from './common.js';
import type { HTTPSignedField } from '../../lib/http-server/common.js';
export type KeetaUsernameAnchorClientConfig = {
    id?: string;
    logger?: Logger | undefined;
    resolver?: Resolver;
    signer?: InstanceType<typeof KeetaNetLib.Account>;
    account?: InstanceType<typeof KeetaNetLib.Account>;
} & Omit<NonNullable<Parameters<typeof getDefaultResolver>[1]>, 'client'>;
type ProviderID = BrandedString<'UsernameProviderID'>;
type KeetaUsernameAnchorOperations = {
    [operation in keyof NonNullable<ServiceMetadata['services']['username']>[string]['operations']]?: {
        url: (params?: {
            [key: string]: string;
        }) => URL;
        options: {
            authentication: ServiceMetadataAuthenticationType;
        };
    };
};
type KeetaUsernameServiceInfo = {
    operations: {
        [operation in keyof KeetaUsernameAnchorOperations]: Promise<KeetaUsernameAnchorOperations[operation]>;
    };
    usernamePattern?: string;
};
type ClaimUsernameOptions = {
    account?: KeetaNetAccount | undefined;
    transfer?: {
        from: KeetaNetAccount | string;
        signed?: HTTPSignedField;
    };
};
interface KeetaUsernameAnchorBaseConfig {
    client: KeetaNetUserClient;
    logger?: Logger | undefined;
    account?: InstanceType<typeof KeetaNetLib.Account> | undefined;
    signer?: InstanceType<typeof KeetaNetLib.Account> | undefined;
}
declare class KeetaUsernameAnchorBase {
    protected readonly client: KeetaNetUserClient;
    protected readonly logger?: Logger | undefined;
    protected readonly account?: InstanceType<typeof KeetaNetLib.Account> | undefined;
    protected readonly signer?: InstanceType<typeof KeetaNetLib.Account> | undefined;
    constructor(config: KeetaUsernameAnchorBaseConfig);
}
export interface KeetaUsernameAnchorUsernameWithAccountAndProvider extends KeetaUsernameAnchorUsernameWithAccount {
    providerID: ProviderID;
    globallyIdentifiableUsername: GloballyIdentifiableUsername;
}
declare class KeetaUsernameAnchorProvider extends KeetaUsernameAnchorBase {
    #private;
    readonly serviceInfo: KeetaUsernameServiceInfo;
    readonly providerID: ProviderID;
    private readonly parent;
    constructor(serviceInfo: KeetaUsernameServiceInfo, providerID: ProviderID, parent: KeetaUsernameAnchorClient);
    get usernamePattern(): string | undefined;
    /**
     * Check if a username is valid according to the provider's username pattern if set and default validation.
     * @param username The username to check
     * @returns True if the username is valid, false otherwise
     */
    isUsernameValid(username: string): boolean;
    /**
     * Resolve a username for a specific provider
     * @param input The value to lookup, can be a username, PublicKeyString, or an account
     * @returns The resolved account and username, or null if not found
     */
    resolve(input: string | KeetaNetAccount): Promise<KeetaUsernameAnchorUsernameWithAccountAndProvider | null>;
    /**
     * Claim a username for a specific provider
     * @param usernameInput The username to claim
     * @param options The account to claim for, and options related to transfer if applicable
     * @returns True if the claim was successful, false otherwise
     */
    claimUsername(usernameInput: string, options?: ClaimUsernameOptions): Promise<boolean>;
    /**
     * Release a username for a specific provider
     * @param options The account to claim for, and options related to transfer if applicable
     * @returns True if the claim was successful, false otherwise
     */
    releaseUsername(input?: {
        account?: KeetaNetAccount;
    }): Promise<boolean>;
    /**
     * Release a username for a specific provider
     * @param options The account to claim for, and options related to transfer if applicable
     * @returns True if the claim was successful, false otherwise
     */
    search(parameters: KeetaUsernameAnchorSearchRequestParameters): Promise<{
        results: KeetaUsernameAnchorUsernameWithAccountAndProvider[];
    }>;
}
declare class KeetaUsernameAnchorClient extends KeetaUsernameAnchorBase {
    #private;
    readonly resolver: Resolver;
    readonly id: string;
    constructor(client: KeetaNetUserClient, config?: KeetaUsernameAnchorClientConfig);
    getProvider(providerID: string, shared?: SharedLookupCriteria): Promise<KeetaUsernameAnchorProvider | null>;
    /**
     * Resolve a globally identifiable username via the appropriate provider.
     * @param username The globally identifiable username to resolve
     * @param shared Shared resolver lookup criteria
     * @returns The resolution result, or null if not found
     */
    resolve(username: GloballyIdentifiableUsername, shared?: SharedLookupCriteria): ReturnType<KeetaUsernameAnchorProvider['resolve']>;
    /**
     * Resolve against all username providers for the given input.
     * @param input The value to search for, either a globally identifiable username, a username, or an account
     * @param shared Shared lookup criteria
     * @returns A mapping of provider IDs to their resolution results, or null if no providers found a match
     */
    resolveMulti(input: string | KeetaNetAccount | GloballyIdentifiableUsername, shared?: SharedLookupCriteria): Promise<({
        [providerId: ProviderID]: Awaited<ReturnType<KeetaUsernameAnchorProvider['resolve']>>;
    }) | null>;
    /**
     * Resolve against all username providers for the given input.
     * @param input The value to search for, either a globally identifiable username, a username, or an account
     * @param shared Shared lookup criteria
     * @returns A mapping of provider IDs to their resolution results, or null if no providers found a match
     */
    search(parameters: KeetaUsernameAnchorSearchRequestParameters, responseType: 'separate', shared?: SharedLookupCriteria): Promise<({
        [providerId: ProviderID]: Awaited<ReturnType<KeetaUsernameAnchorProvider['search']>>;
    }) | null>;
    search(parameters: KeetaUsernameAnchorSearchRequestParameters, responseType?: 'joined', shared?: SharedLookupCriteria): Promise<Awaited<ReturnType<KeetaUsernameAnchorProvider['search']>> | null>;
    /**
     * Claim a globally identifiable username from the appropriate provider.
     * @param input The globally identifiable username to claim
     * @param options Claim options
     * @returns True if the claim was successful, false otherwise
     */
    claimUsername(input: GloballyIdentifiableUsername, options?: ClaimUsernameOptions, shared?: SharedLookupCriteria): ReturnType<KeetaUsernameAnchorProvider['claimUsername']>;
    signUsernameTransfer(request: Omit<TransferUsernameOwnershipSignablePayload, 'from'>, from?: KeetaNetAccount): Promise<HTTPSignedField>;
}
export default KeetaUsernameAnchorClient;
export { KeetaUsernameAnchorProvider };
//# sourceMappingURL=client.d.ts.map