import "url-search-params-polyfill";
import { Console } from "./console";
import { EventProvider, EventProviderFactory, EventProviderStatus } from "./event";
import { ConsoleAppConfig, ManagerConfig, MapType, UsernamePassword } from "@openremote/model";
import * as Util from "./util";
import Keycloak from 'keycloak-js';
export { Util };
export * from "./asset-mixin";
export * from "./console";
export * from "./event";
export * from "./defaults";
export declare const DEFAULT_ICONSET = "mdi";
export declare const OPENREMOTE_CLIENT_ID = "openremote";
export declare const RESTRICTED_USER_REALM_ROLE = "restricted_user";
export declare type KeycloakPromise<T> = {
    success<TResult1 = T, TResult2 = never>(onfulfilled?: ((value: T) => TResult1 | KeycloakPromise<TResult1>) | undefined | null, onrejected?: ((reason: any) => TResult2 | KeycloakPromise<TResult2>) | undefined | null): KeycloakPromise<TResult1 | TResult2>;
    error<TResult = never>(onrejected?: ((reason: any) => TResult | KeycloakPromise<TResult>) | undefined | null): Promise<T | TResult>;
};
export declare enum ORError {
    MANAGER_FAILED_TO_LOAD = "MANAGER_FAILED_TO_LOAD",
    AUTH_FAILED = "AUTH_FAILED",
    AUTH_TYPE_UNSUPPORTED = "AUTH_TYPE_UNSUPPORTED",
    CONSOLE_ERROR = "CONSOLE_INIT_ERROR",
    EVENTS_CONNECTION_ERROR = "EVENTS_CONNECTION_ERROR",
    TRANSLATION_ERROR = "TRANSLATION_ERROR"
}
export declare enum OREvent {
    ERROR = "ERROR",
    READY = "READY",
    ONLINE = "ONLINE",
    OFFLINE = "OFFLINE",
    CONNECTING = "CONNECTING",
    CONSOLE_INIT = "CONSOLE_INIT",
    CONSOLE_READY = "CONSOLE_READY",
    TRANSLATE_INIT = "TRANSLATE_INIT",
    TRANSLATE_LANGUAGE_CHANGED = "TRANSLATE_LANGUAGE_CHANGED",
    DISPLAY_REALM_CHANGED = "DISPLAY_REALM_CHANGED"
}
export interface LoginOptions {
    redirectUrl?: string;
    action?: string;
    credentials?: UsernamePassword;
}
export interface BasicLoginResult {
    username: string;
    password: string;
    cancel: boolean;
}
export interface Languages {
    [langKey: string]: string;
}
export declare const DEFAULT_LANGUAGES: Languages;
export declare function normaliseConfig(config: ManagerConfig): ManagerConfig;
export interface OrManagerEventDetail {
    event: OREvent;
    error?: ORError;
}
export type EventCallback = (event: OREvent) => void;
export declare class Manager implements EventProviderFactory {
    get username(): string;
    get error(): ORError | undefined;
    get authenticated(): boolean;
    get ready(): boolean;
    get config(): ManagerConfig;
    get roles(): Map<string, string[]>;
    get managerVersion(): string;
    get isManagerAvailable(): boolean | "";
    get managerUrl(): string | undefined;
    get keycloakUrl(): string | undefined;
    get isError(): boolean;
    get connectionStatus(): EventProviderStatus | undefined;
    get console(): Console;
    get consoleAppConfig(): ConsoleAppConfig | undefined;
    get events(): EventProvider | undefined;
    get rest(): import("@openremote/rest").RestApi;
    get language(): string;
    set language(lang: string);
    get displayRealm(): string;
    set displayRealm(realm: string);
    get clientId(): string;
    getEventProvider(): EventProvider | undefined;
    get mapType(): MapType;
    protected static MAX_RECONNECT_DELAY: number;
    private _error?;
    private _config;
    private _authenticated;
    private _ready;
    private _readyCallback?;
    private _name;
    private _username;
    private _keycloak?;
    private _basicIdentity?;
    private _keycloakUpdateTokenInterval?;
    private _managerVersion;
    _authServerUrl: string;
    private _listeners;
    private _console;
    private _consoleAppConfig?;
    private _events?;
    private _disconnected;
    private _reconnectTimer?;
    private _displayRealm?;
    isManagerSameOrigin(): boolean;
    addListener(callback: EventCallback): void;
    removeListener(callback: EventCallback): void;
    init(config: ManagerConfig): Promise<boolean>;
    protected loadManagerInfo(): Promise<boolean>;
    protected doTranslateInit(): Promise<boolean>;
    protected doDescriptorsInit(): Promise<boolean>;
    protected doAuthInit(): Promise<boolean>;
    protected doRestApiInit(): boolean;
    protected doEventsSubscriptionInit(): Promise<boolean>;
    protected _connectEvents(): void;
    protected _onEventProviderStatusChanged(status: EventProviderStatus): void;
    protected doConsoleInit(): Promise<boolean>;
    protected doIconInit(): void;
    protected getConsoleAppConfig(): Promise<boolean>;
    /**
     * Checks the native console to gather the preferred language of the device.
     */
    getConsolePreferredLanguage(orConsole?: Console): Promise<string | undefined>;
    /**
     * Checks the keycloak access token to gather the preferred language of a user.
     */
    getUserPreferredLanguage(keycloak?: Keycloak | undefined): Promise<string | undefined>;
    protected updateKeycloakUserLanguage(lang: string, rest?: import("@openremote/rest").RestApi): Promise<void>;
    logout(redirectUrl?: string): void;
    login(options?: LoginOptions): void;
    protected initialiseBasicAuth(): Promise<boolean>;
    protected doBasicLogin(): Promise<void>;
    isSuperUser(): boolean;
    isRestrictedUser(): boolean;
    getApiBaseUrl(): string;
    getAppName(): string;
    hasRealmRole(role: string): boolean;
    hasRole(role: string, client?: string): boolean;
    getAuthorizationHeader(): string | undefined;
    getKeycloakToken(): string | undefined;
    getBasicToken(): string | undefined;
    getRealm(): string | undefined;
    protected isMobile(): boolean;
    isKeycloak(): boolean;
    protected _onAuthenticated(): void;
    protected loadAndInitialiseKeycloak(): Promise<boolean>;
    protected _createTokenUpdateInterval(): void;
    protected _updateKeycloakAccessToken(): Promise<boolean>;
    protected _getNativeOfflineRefreshToken(): Promise<string | undefined>;
    protected _emitEvent(event: OREvent): void;
    protected _setError(error: ORError): void;
    /** Function that clears the `WebView` history of a console. It will not delete the history on regular browsers. */
    protected _clearWebHistory(): void;
    /**
     * Disconnect can occur when events status changes to offline and/or keycloak token refresh fails
     * we just try to reach keycloak and then get a new token as well as wait for the events status to change
     */
    protected _onDisconnect(): Promise<void>;
    protected _onReconnected(): void;
    /**
     * Checks keycloak is available and token is valid otherwise will redirect to login; also checks if event bus is
     * online.
     */
    reconnect(reattemptDelayMillis?: number): Promise<void>;
    protected isKeycloakReachable(timeoutMillis?: number): Promise<boolean>;
}
export declare const manager: Manager;
export default manager;
//# sourceMappingURL=index.d.ts.map