/*!
 * Copyright 2017 - 2020 by ChartIQ, Inc.
 * All rights reserved.
 */
/**
 * The Workspace Client manages all calls to load, save, rename, and delete workspaces.
 *
 * The Workspace Client uses the `windowIdentifier` parameter. <a href="tutorial-ComponentTypesAndWindowNames.html">Learn more about them here</a>.
 *
 * See the <a href="tutorial-Workspaces.html">Workspace tutorial</a> for an overview of using the Workspace Client.
 * @module WorkspaceClient
 */
import { RouterResponse } from "./routerClient";
import { StateType, CompleteWindowState } from "../services/workspace/windowStorageManager";
import FinsembleEvent from "../common/events/FinsembleEvent";
import PublicEventManager from "../common/events/PublicEventManager";
import { StandardErrorCallback } from "../types";
import { WorkspaceEventName, Workspace, ActiveWorkspace } from "../services/workspace/types";
export declare type FinsembleEventHandler = (event: FinsembleEvent) => void;
/**
 * @phantom Don't display in Typedoc
 */
export declare class WorkspaceClientController {
    /**
     * List of all workspaces names within the application.
     */
    workspaces: string[];
    /**
     * Utility for managing event listeners - much like EventEmitter
     */
    publicEventManager: PublicEventManager;
    /**
     * Reference to the activeWorkspace object
     */
    activeWorkspace: ActiveWorkspace | undefined;
    constructor();
}
export declare const getControllerInstance: () => WorkspaceClientController;
/**
 * This provides the ability to listen to workspace events.
 * The load-requested event provides a way to merge data into the workspace prior to loading.
 * The close-requested and save-requested event, allow you to perform actions prior to the actual save and close.
 * The rest of the events are informational only.
 * To tell the workspace service to wait, you must call event.wait() in less than one second.
 * To cancel event.cancel() must be called within 10 seconds, otherwise done is assumed.
 * To send data event.done(data) must also be called within 10 seconds, otherwise done with no data is assumed.
 *
 * ```JavaScript
 * // Sync examples:
 * FSBL.Clients.WorkspaceClient.addEventListener("close-requested", (event) => { doSomething(); })
 * FSBL.Clients.WorkspaceClient.addEventListener("load-requested", (event) => { const data = doSomething(); event.done(data); })
 *
 * // Async examples:
 * FSBL.Clients.WorkspaceClient.addEventListener("close-requested", async (event) => { event.wait(); await doSomething(); event.done(); })
 * FSBL.Clients.WorkspaceClient.addEventListener("load-requested", async (event) => { event.wait(); const data = await doSomething(); event.done(data); })
 * ```
 * @param event The workspace event to listen for
 * @param handler A function to handle the event
 */
export declare const addEventListener: (event: WorkspaceEventName, handler: FinsembleEventHandler) => void;
/**
 * Removes an event listener.
 *
 * @param event The workspace event that is listened on
 * @param handler The handler that is in effect
 */
export declare const removeEventListener: (event: WorkspaceEventName, handler: FinsembleEventHandler) => void;
/**
 * Gets the currently active workspace.
 * This function is useful for setting the initial state of a menu or dialog. It is used in the toolbar component to set the initial state.
 *
 * ```JavaScript
 * FSBL.Clients.WorkspaceClient.getActiveWorkspace((err, response) => {
 * 	// do something with the response.
 * });
 * ```
 * @param cb The callback to be invoked after the method completes successfully.
 */
export declare const getActiveWorkspace: (cb?: StandardErrorCallback<{
    data: Workspace;
}> | undefined) => Promise<{
    data: Workspace;
}>;
/**
 * Returns the list of saved workspaces. This function is useful for setting the initial state of a menu or dialog.
 *
 * ```JavaScript
 * FSBL.Clients.WorkspaceClient.getWorkspaces((err, response) => {
 *   //do something with the array of workspace objects
 *   console.log(response)
 * });
 * ```
 * @param cb The callback to be invoked after the method completes successfully.
 */
export declare const getWorkspaces: (cb?: Function | undefined) => Promise<unknown>;
/**
 * Gets workspace actions defined as constants. Allows users to filter
 * updates
 *
 * @param cb The callback to be invoked after the method completes successfully.
 */
export declare const getWorkspaceActions: (cb?: StandardErrorCallback<Record<string, string>> | undefined) => Record<string, string>;
/**
 * Returns a list of workspace names. This function returns the list of all the workspace.</caption>
 *
 * ```JavaScript
 * FSBL.Clients.WorkspaceClient.getWorkspaceNames((err, response) => {
 *   console.log(JSON.stringify(response, null, 2));
 * });
 *
 *
 * Output:
 * [
 *   "Default Workspace",
 *   "Another workspace"
 * ]
 *
 * ```
 * @param cb The callback to be invoked after the method completes successfully.
 */
export declare const getWorkspaceNames: (cb?: StandardErrorCallback<string[]> | undefined) => Promise<unknown>;
/**
 * Sets the ordering of workspaces (e.g. to control the ordering of workspaces listed in a menu.)
 *
 * @param params
 * @param cb
 * @returns
 * @ignore Keep private until params can be documented
 */
export declare const setWorkspaceOrder: (params: any, cb?: Function | undefined) => Promise<unknown>;
/**
 * Removes a workspace. Either the workspace object or its name must be provided.
 *
 * This example removes 'My Workspace' from the main menu and the default storage tied to the application.
 * ```JavaScript
 * FSBL.Clients.WorkspaceClient.remove({
 * 	name: 'My Workspace'
 * }, function(err, response) {
 * 	//You typically won't do anything here. If you'd like to do something when a workspace change happens, we suggest listening on the `Finsemble.WorkspaceService.update` channel.
 * });
 * ```
 * @param params
 * @param params.workspace The workspace data object.
 * @param params.workspace.name The workspace name removal is requested for.
 * @param params.name The workspace name removal is requested for.
 * @param cb Callback to fire after 'Finsemble.WorkspaceService.update' is transmitted.
 */
export declare const remove: (params: {
    workspace?: {
        name: string;
    };
    name?: string;
}, cb?: Function | undefined) => Promise<unknown>;
/**
 * Renames the workspace with the provided name. Also removes all references in storage to the old workspace's name.
 * This method is used to rename workspaces. It is used in the main Menu component. Note: If you attempt to rename a Workspace to a name that already exists a ({next number}) will be added to the newName.
 *
 * ```JavaScript
 * FSBL.Clients.WorkspaceClient.rename({
 * 	oldName: 'My Workspace',
 * 	newName: 'The best workspace',
 * 	removeOldWorkspace: true,
 * }, function(err, response) {
 * 	//Do something.
 * });
 * ```
 * @param params
 * @param params.oldName Name of workspace to rename.
 * @param params.newName What to rename the workspace to.
 * @param params.removeOldWorkspace Whether to remove references to old workspace after renaming.
 * @param params.overwriteExisting Whether to overwrite an existing workspace.
 * @param cb The callback to be invoked after the method completes successfully.
 */
export declare const rename: (params: {
    oldName: string;
    newName: string;
    removeOldWorkspace?: boolean;
    overwriteExisting?: boolean;
}, cb?: Function | undefined) => Promise<unknown>;
/**
 * Saves the current active workspace.
 *
 * This example persists the currently active workspace.
 * ```JavaScript
 * FSBL.Clients.WorkspaceClient.save(function(err) {
 * 	//Do something.
 * });
 * ```
 * @param cb The callback to be invoked after the method completes successfully.
 */
export declare const save: (cb?: Function | undefined) => Promise<unknown>;
/**
 *
 * Saves the currently active workspace with the provided name.
 *
 * This example persists the currently active workspace with the provided name.
 * ```JavaScript
 * FSBL.Clients.WorkspaceClient.saveAs({
 * 	name: 'My Workspace',
 * }, function(err, response) {
 * 	//Do something.
 * });
 * ```
 * @param params
 * @param params.name The new name you want to save the workspace under.
 * @param params.force Whether to overwrite a workspace already saved with the provided name.
 * @param cb The callback to be invoked after the method completes successfully.
 */
export declare const saveAs: (params: {
    name?: string;
    force?: boolean;
}, cb?: Function | undefined) => Promise<unknown>;
/**
 * Switches to a workspace.
 *
 * This example loads the workspace 'My Workspace' from the storage tied to the application.
 * ```JavaScript
 * FSBL.Clients.WorkspaceClient.switchTo({
 * 	name: 'My Workspace',
 * }, function(err, response) {
 * 	//Do something.
 * });
 * ```
 * @param params
 * @param params.name The name of the workspace you want to switch to.
 * @param cb The callback to be invoked after the method completes successfully.
 */
export declare const switchTo: (params: {
    name: string;
}, cb?: StandardErrorCallback<{
    data: Workspace;
}> | undefined) => Promise<{
    data: Workspace;
}>;
/**
 * Sets the stored state of a given window in the active workspace. `state` may include
 * keys for `windowData`, `componentState`, or both; the state of each key will be completely
 * overwritten by the provided state. If the update results in dirtying change, the active
 * workspace will be marked dirty (or, if auto save is on, persisted directly to storage).
 *
 * @ignore This function is only called by the Window and Assimilation services. It should be
 * moved into workspaceService/workspaceAdminAPI. But, the code uses the locally cached
 * activeWorkspace which may or may not be for legitimate performance reasons. Therefore we're
 * leaving this here until it can be safely refactored.
 */
export declare const setWindowState: (params: {
    windowName: string;
    state: Partial<CompleteWindowState>;
}) => Promise<RouterResponse<boolean>>;
/**
 * Checks to see if the workspace is dirty, i.e., if its state has been changed since the last save. If it's already dirty, the window doesn't need to compare its state to the saved state.
 *
 * This example will let you know if the active workspace is dirty.
 * ```JavaScript
 * FSBL.Clients.WorkspaceClient.isWorkspaceDirty(function(err, response) {
 *     if (response.data === true) {
 *         //Do something like prompt the user if they'd like to save the currently loaded workspace before switching.
 *    } else {
 *        //Workspace is clean
 *    }
 * });
 * ```
 * @param cb `cb(err,response)` with response set to true if dirty and false otherwise (when no error).
 */
export declare const isWorkspaceDirty: (cb?: Function | undefined) => Promise<boolean>;
/**
 * Creates a new workspace, returning a promise for the final name of
 * the new workspace as a string. After creation, if "switchAfterCreation" is true,
 * the new workspace becomes the active workspace.
 *
 * If the requested name already exists, a new workspace will be created
 * with the form "[name] (1)" (or "[name] (2)", etc.)
 *
 * This example creates the workspace 'My Workspace'.
 * ```JavaScript
 * FSBL.Clients.WorkspaceClient.createWorkspace("My workspace", {switchAfterCreation:true}),function(err, response) {
 *		if (!err) {}
 *			//Do something, such as notify the user that the workspace has been created.
 *		}
 * });
 * ```
 * @param workspaceName Name for new workspace. If the workspaceName is empty, the workspace is given the name "Untitled." Subsequent creations with empty strings would result in "Untitled1", "Untitled2", etc.
 * @param params Optional params
 * @param params.switchAfterCreation Whether to switch to the new workspace after creating it. Defaults to true.
 * @param cb `cb(err,response)` With response, set to new workspace object if no error.
 */
export declare const createWorkspace: (workspaceName: string, params?: {
    switchAfterCreation?: boolean | undefined;
} | undefined, cb?: (err: any, result: {
    workspaceName: string;
}) => void) => Promise<{
    workspaceName: string;
}>;
/**
 * Gets a workspace definition in JSON form.
 *
 * ```JavaScript
 * FSBL.Clients.WorkspaceClient.export({'workspaceName': 'linker'}, function(err, workspaceDefinition) {
 * 	//do something with the workspace definition
 * });
 * ```
 * @param params
 * @param params.workspaceName The name of the workspace you want to export.
 * @param cb callback(error, workspaceDefinition)
 */
export declare const exportWorkspace: (params: {
    workspaceName: string;
}, cb: Function) => Promise<unknown>;
/**
 * Adds a workspace definition to the list of available workspaces.
 *
 * ```JavaScript
 * FSBL.Clients.WorkspaceClient.import({force: false, workspaceJSONDefinition: workspaceDefinition}, function(err) {
 *		if (!err) console.log("import success.");
 * });
 * ```
 * @param params
 * @param params.workspaceJSONDefinition The JSON for the workspace definition, as exported by the User Preferences menu in Finsemble Connect.
 * @param params.force Whether to overwrite any workspace of the same name that already exists
 * @param cb `cb(err)` where the operation was successful if !err; otherwise, err carries diagnostics
 */
export declare const importWorkspace: (params: {
    workspaceJSONDefinition: Record<string, Workspace | string>;
    force: boolean;
}, cb?: Function | undefined) => Promise<Record<string, string>>;
/**
 * Saves one or more template definitions in a selected file. Note the
 * end user is prompted to identify file location during this save
 * operation. The file can optionally be imported during config
 * initialization (see importConfig) although this requires administration
 * support on the configuration/server side. The file can also be read
 * using readWorkspaceTemplateFromConfigFile();
 *
 * @param params
 * @param params.workspaceTemplateDefinition legal template definition returned by either
 * getWorkspaceTemplateDefinition() or convertWorkspaceDefinitionToTemplate()
 * @ignore This isn't used anywhere. Is it in use by customers?
 */
export declare const exportToFile: (params: {
    workspaceTemplateDefinition: any;
}) => void;
/**
 * Re-export so that typedoc will associate the docs with this module
 */
export { bringAllWindowsToFront as bringWindowsToFront, minimizeAll, autoArrange } from "../common/Desktop";
/**
 * @ignore
 */
export declare const WorkspaceClient: {
    /**
     * For backward compatibility
     * @private
     * @deprecated
     */
    saveWorkspaceTemplateToConfigFile: (params: any) => void;
    /**
     * For backward compatibility
     * @private
     * @deprecated
     */
    addWorkspaceDefinition: (params: any, cb: any) => Promise<Record<string, string>>;
    /**
     * For backward compatibility
     * @private
     * @deprecated
     */
    getWorkspaceDefinition: (params: any, cb: any) => Promise<unknown>;
    /**
     * For backward compatibility
     * @private
     * @deprecated
     */
    createNewWorkspace: (workspaceName: any, params: any, cb: any) => Promise<{
        workspaceName: string;
    }>;
    /**
     * For backward compatibility
     * @private
     * @deprecated
     */
    setWorkspaces: (params: any, cb: any) => Promise<unknown>;
    /**
     * For backward compatibility
     * @private
     * @deprecated
     */
    initialize: () => void;
    /**
     * For backward compatibility
     * @private
     * @deprecated
     */
    onReady: (cb?: any) => void;
    removeWindow: (params: any, cb: any) => void;
    addWindow: (params: any, cb: any) => void;
    readonly workspaces: string[];
    readonly activeWorkspace: Workspace | undefined;
    export: (params: {
        workspaceName: string;
    }, cb: Function) => Promise<unknown>;
    import: (params: {
        workspaceJSONDefinition: Record<string, Workspace | string>;
        force: boolean;
    }, cb?: Function | undefined) => Promise<Record<string, string>>;
    exportToFile: (params: {
        workspaceTemplateDefinition: any;
    }) => void;
    createWorkspace: (workspaceName: string, params?: {
        switchAfterCreation?: boolean | undefined;
    } | undefined, cb?: (err: any, result: {
        workspaceName: string;
    }) => void) => Promise<{
        workspaceName: string;
    }>;
    isWorkspaceDirty: (cb?: Function | undefined) => Promise<boolean>;
    _getWindowState: (params: {
        windowName: string;
        stateVars: StateType[];
    }) => Promise<RouterResponse<Partial<CompleteWindowState>>>;
    _setWindowState: (params: any) => Promise<RouterResponse<boolean>>;
    switchTo: (params: {
        name: string;
    }, cb?: StandardErrorCallback<{
        data: Workspace;
    }> | undefined) => Promise<{
        data: Workspace;
    }>;
    saveAs: (params: {
        name?: string;
        force?: boolean;
    }, cb?: Function | undefined) => Promise<unknown>;
    workspaceExists: (workspaceName: any) => void;
    save: (cb?: Function | undefined) => Promise<unknown>;
    rename: (params: {
        oldName: string;
        newName: string;
        removeOldWorkspace?: boolean;
        overwriteExisting?: boolean;
    }, cb?: Function | undefined) => Promise<unknown>;
    remove: (params: {
        workspace?: {
            name: string;
        };
        name?: string;
    }, cb?: Function | undefined) => Promise<unknown>;
    setWorkspaceOrder: (params: any, cb?: Function | undefined) => Promise<unknown>;
    getWorkspaceNames: (cb?: StandardErrorCallback<string[]> | undefined) => Promise<unknown>;
    getWorkspaceActions: (cb?: StandardErrorCallback<Record<string, string>> | undefined) => Record<string, string>;
    getWorkspaces: (cb?: Function | undefined) => Promise<unknown>;
    getActiveWorkspace: (cb?: StandardErrorCallback<{
        data: Workspace;
    }> | undefined) => Promise<{
        data: Workspace;
    }>;
    bringWindowsToFront: (params?: {
        monitor: string;
        windowIdentifier?: any;
    } | undefined, cb?: StandardErrorCallback<void> | undefined) => import("../types").StandardPromise<void>;
    minimizeAll: (params?: {
        monitor: string;
        windowIdentifier?: any;
    } | undefined, cb?: StandardErrorCallback<void> | undefined) => import("../types").StandardPromise<void>;
    autoArrange: (params: any, cb?: StandardErrorCallback<void> | undefined) => import("../types").StandardPromise<void>;
    addEventListener: (event: WorkspaceEventName, handler: FinsembleEventHandler) => void;
    removeEventListener: (event: WorkspaceEventName, handler: FinsembleEventHandler) => void;
};
/**
 * @ignore
 */
export default WorkspaceClient;
//# sourceMappingURL=workspaceClient.d.ts.map