/// <reference types="jquery" />
import { AppEventMap, Desktop, ErrorHandler, ErrorInfo, Event, EventEmitter, EventHandler, EventListener, EventMapOf, FontDescriptor, InitModelOf, Locale, Session, SessionModel, Widget } from './index';
export interface AppModel {
    /**
     * Object to configure the session, see {@link Session.init} for the available options.
     */
    session?: SessionModel;
    bootstrap?: AppBootstrapOptions;
    /**
     * True, to check whether the browser fulfills all requirements to run the application. If the check fails, a notification is shown to warn the user about his old browser. Default is true.
     */
    checkBrowserCompatibility?: boolean;
    version?: string;
}
export type JsonErrorResponse = {
    code: number;
    message: string;
};
export interface AppBootstrapOptions {
    /**
     * Fonts that should be preloaded, which means the initialization will not continue until the fonts are loaded.
     * If no fonts are specified, the list of fonts to preload is automatically calculated from the available CSS "@font-face" definitions. This is the default.<br>
     * To disable preloading entirely, set fonts to an empty array.
     */
    fonts?: FontDescriptor[];
    /**
     *  URL or multiple URLs pointing to a resource providing texts that will be available through {@link texts}.
     */
    textsUrl?: string | string[];
    /**
     * URL pointing to a resource providing locale information processed by {@link locales}.
     */
    localesUrl?: string;
    /**
     *  URL pointing to a resource providing codes that will be available through {@link codes}.
     */
    codesUrl?: string;
    /**
     * URL pointing to a resource providing permissions that will be available through {@link access}.
     *
     * @see PermissionCollectionModel
     */
    permissionsUrl?: string;
    /**
     * URL pointing to a resource providing config properties that will be available through {@link config}.
     */
    configUrl?: string | string[];
    /**
     * Custom functions that needs to be executed while bootstrapping.
     * All custom and default bootstrappers need to finish successfully before the app will proceed with the initialization.
     */
    bootstrappers?: (() => JQuery.Promise<void>)[];
}
export declare class App extends EventEmitter {
    static addListener<K extends string & keyof EventMapOf<App>>(type: K, handler: EventHandler<(EventMapOf<App>)[K] & Event<App>>): EventListener;
    /**
     * Adds a function that needs to be executed while bootstrapping.
     * @see AppModel.bootstrappers
     */
    static addBootstrapper(bootstrapper: () => JQuery.Promise<void>): void;
    static get(): App;
    protected static _set(newApp: App): void;
    model: AppModel;
    eventMap: AppEventMap;
    self: App;
    remote: boolean;
    initialized: boolean;
    sessions: Session[];
    errorHandler: ErrorHandler;
    version: string;
    bootstrappers: (() => JQuery.Promise<void>)[];
    protected _loadingTimeoutId: number;
    constructor();
    /**
     * Main initialization function.
     *
     * Calls {@link _prepare}, {@link _bootstrap} and {@link _init}.<br>
     * At the initial phase the essential objects are initialized, those which are required for the next phases like logging and the object factory.<br>
     * During the bootstrap phase additional scripts may get loaded required for a successful session startup.<br>
     * The actual initialization does not get started before these bootstrap scripts are loaded.
     */
    init(options?: InitModelOf<this>): JQuery.Promise<any>;
    /**
     * Initializes the logging framework and the object factory.
     * This happens at the prepare phase because all these things should be available from the beginning.
     */
    protected _prepare(options: AppModel): JQuery.Promise<any>;
    protected _prepareEssentials(options: AppModel): void;
    protected _prepareDone(options: AppModel): void;
    protected _prepareLogging(options: AppModel): JQuery.Promise<JQuery>;
    /**
     * Executes the bootstrappers.
     *
     * The actual session startup begins only when all promises of the bootstrappers are completed.
     * This gives the possibility to dynamically load additional scripts or files which are mandatory for a successful application startup.
     */
    protected _bootstrap(options: AppBootstrapOptions): JQuery.Promise<any>;
    protected _defaultBootstrappers(options: AppBootstrapOptions): (() => JQuery.Promise<void>)[];
    protected _doBootstrap(): JQuery.Promise<any>[];
    protected _bootstrapDone(options: AppBootstrapOptions): void;
    protected _bootstrapFail(options: AppBootstrapOptions, vararg: JQuery.jqXHR | {
        url?: string;
        error?: JsonErrorResponse;
    }, textStatus?: JQuery.Ajax.ErrorTextStatus, errorThrown?: string, requestOptions?: JQuery.AjaxSettings): JQuery.Promise<any> | void;
    protected _isSessionTimeoutStatus(httpStatus: number): boolean;
    protected _handleBootstrapTimeoutError(error: JQuery.jqXHR | JsonErrorResponse, url: string): void;
    /**
     * Initializes a session for each html element with class '.scout' and stores them in scout.sessions.
     */
    protected _init(options: InitModelOf<this>): JQuery.Promise<any>;
    /**
     * Maybe implemented to load data from a server before the desktop is created.
     * @returns promise which is resolved after the loading is complete
     */
    protected _load(options: AppModel): JQuery.Promise<any>;
    protected _checkBrowserCompatibility(options: AppModel): JQuery.Promise<InitModelOf<this>> | null;
    setLoading(loading: boolean): void;
    protected _renderLoading(): void;
    protected _renderLoadingElement($loadingRoot: JQuery, cssClass: string): void;
    protected _removeLoading(): void;
    protected _initVersion(options: AppModel): void;
    protected _prepareDOM(): void;
    protected _installGlobalMouseDownInterceptor(): void;
    protected _installSyntheticActiveStateHandler(): void;
    /**
     * Installs a global error handler.
     *
     * Note: we do not install an error handler on popup-windows because everything is controlled by the main-window
     * so exceptions will also occur in that window. This also means, the fatal message-box will be displayed in the
     * main-window, even when a popup-window is opened and active.
     *
     * Caution: The error.stack doesn't look the same in different browsers. Chrome for instance puts the error message
     * on the first line of the stack. Firefox does only contain the stack lines, without the message, but in return
     * the stack trace is much longer :)
     */
    protected _installErrorHandler(): void;
    protected _createErrorHandler(opts?: InitModelOf<ErrorHandler>): ErrorHandler;
    /**
     * Uses the object returned by {@link _ajaxDefaults} to set up ajax. The values in that object are used as default values for every ajax call.
     */
    protected _ajaxSetup(): void;
    /**
     * Returns the defaults for every ajax call. You may override it to set custom defaults.
     * By default {@link _beforeAjaxCall} is assigned to the beforeSend method.
     *
     * Note: This will affect every ajax call, so use it with care! See also the advice on https://api.jquery.com/jquery.ajaxsetup/.
     */
    protected _ajaxDefaults(): JQuery.AjaxSettings;
    /**
     * Called before every ajax call. Sets the header X-Scout-Correlation-Id.
     *
     * Maybe overridden to set custom headers or to execute other code which should run before an ajax call.
     */
    protected _beforeAjaxCall(request: JQuery.jqXHR, settings: JQuery.AjaxSettings): void;
    protected _loadSessions(options: SessionModel): JQuery.Promise<any>;
    /**
     * @returns promise which is resolved when the session is ready
     */
    protected _loadSession($entryPoint: JQuery, model: Omit<SessionModel, '$entryPoint'>): JQuery.Promise<any>;
    /** @internal */
    _triggerDesktopReady(desktop: Desktop): void;
    /** @internal */
    _triggerSessionReady(session: Session): void;
    protected _createSession(options: InitModelOf<Session>): Session;
    protected _createDesktop(parent: Widget): Desktop;
    /**
     * @returns the locale to be used when no locale is provided as session option. By default, the navigators locale is used.
     */
    protected _loadLocale(): Locale;
    protected _initDone(options: AppModel): void;
    protected _fail(options: AppModel, error: any, ...args: any[]): JQuery.Promise<any>;
    protected _appendStartupError($parent: JQuery, errorInfo: ErrorInfo): void;
    /**
     * Override this method to install extensions to Scout objects. Since the extension feature replaces functions
     * on the prototype of the Scout objects you must apply 'function patches' to Scout framework or other code before
     * the extensions are installed.
     *
     * The default implementation does nothing.
     */
    protected _installExtensions(): void;
    /**
     * @see AppEventMap#installExtensions
     */
    protected _triggerInstallExtensions(): void;
}
//# sourceMappingURL=App.d.ts.map