/*---------------------------------------------------------------------------------------------
 * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
 * See LICENSE.md in the project root for license terms and full copyright notice.
 *--------------------------------------------------------------------------------------------*/
/** @packageDocumentation
 * @module Backstage
 */
import * as React from "react";
import { UiFramework } from "../UiFramework";
import { InternalBackstageManager } from "./InternalBackstageManager";
/** Controls backstage.
 * @public
 * @deprecated in 4.15.0. Use {@link UiFramework.backstage} instead.
 */
export class BackstageManager {
    constructor() {
        this.internal = new InternalBackstageManager();
    }
    /**
     * Override internal implementation for a mock
     * @internal For tests only.
     */
    mockInternal(internal) {
        this.internal = internal;
    }
    /** Event raised when backstage is opened or closed. */
    get onToggled() {
        return this.internal.onToggled;
    }
    get isOpen() {
        return this.internal.isOpen;
    }
    open() {
        return this.internal.open();
    }
    close() {
        return this.internal.close();
    }
    toggle() {
        return this.internal.toggle();
    }
    // eslint-disable-next-line deprecation/deprecation
    getBackstageToggleCommand(overrideIconSpec) {
        return this.internal.getBackstageToggleCommand(overrideIconSpec);
    }
    /** Get CommandItemDef that will toggle display of Backstage and allow iconSpec to be overridden. */
    // eslint-disable-next-line deprecation/deprecation
    static getBackstageToggleCommand(overrideIconSpec) {
        // eslint-disable-next-line deprecation/deprecation
        return UiFramework.backstage.getBackstageToggleCommand(overrideIconSpec);
    }
}
/** Hook that returns isOpen flag of the backstage.
 * @public
 */
export const useIsBackstageOpen = (manager) => {
    const [isOpen, setIsOpen] = React.useState(manager.isOpen);
    React.useEffect(() => {
        setIsOpen(manager.isOpen);
        return manager.onToggled.addListener((args) => {
            setIsOpen(args.isOpen);
        });
    }, [manager]);
    return isOpen;
};
/** Hook that returns backstage manager.
 * @public
 */
export const useBackstageManager = () => {
    const [manager] = React.useState(UiFramework.backstage);
    return manager;
};
//# sourceMappingURL=BackstageManager.js.map