import { Logger } from "../../../clients/logger";
import { RouterClient } from "../../../clients/routerClient";
/**
 * Adds a newly launched window to the current active workspace
 */
export const addWindowReferenceToActiveWorkspace = async (params, cb = null) => {
    const { err, response } = await RouterClient.query("WorkspaceService.addWindow", params, () => { });
    Logger.system.log(`WORKSPACE LIFECYCLE: Window added:WorkspaceClient.addWindow: Name (${params.name})`);
    if (cb)
        cb(err, response);
    // don't throw if the user is using callbacks.
    if (!cb && err) {
        throw err;
    }
    return response;
};
/**
 * Removes window from active workspace (but does not close it).
 *
 * It is called when a window that is using the window manager is closed. That way, the next time the app is loaded, that window is not spawned.
 * ```javascript
 * FSBL.Clients.WorkspaceClient.removeWindow({ name:windowName }, function(err, response) {
 * 	//do something after removing the window.
 * });
 * ```
 * @private
 * @param params
 * @param params.name Window name
 * @param cb The callback to be invoked after the method completes successfully.
 */
export const removeWindowReferenceFromActiveWorkspace = (params, cb = Function.prototype) => {
    RouterClient.query("WorkspaceService.removeWindow", params, (err, response) => {
        if (err) {
            return Logger.system.error(err);
        }
        Logger.system.log(`WORKSPACE LIFECYCLE:WorkspaceClient.removeWindow:Window removed: Name (${params.name})`);
        if (response) {
            cb(err, response.data);
        }
        else {
            cb(err, null);
        }
    });
};
//# sourceMappingURL=workspaceAdminAPI.js.map