"use strict";
/*---------------------------------------------------------------------------------------------
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
* See LICENSE.md in the project root for license terms and full copyright notice.
*--------------------------------------------------------------------------------------------*/
/** @packageDocumentation
 * @module Hooks
 */
Object.defineProperty(exports, "__esModule", { value: true });
exports.FrameworkVersionSwitch = exports.FrameworkVersion = exports.FrameworkVersionContext = exports.useFrameworkVersion = void 0;
const React = require("react");
const react_redux_1 = require("react-redux");
const UiFramework_1 = require("../UiFramework");
/**
 * @deprecated in 3.5. Used to toggle between UI1.0 and UI2.0.
 * @public
 */
function useFrameworkVersion() {
    return React.useContext(exports.FrameworkVersionContext); // eslint-disable-line deprecation/deprecation
}
exports.useFrameworkVersion = useFrameworkVersion;
/**
 * @deprecated in 3.5. Used to toggle between UI1.0 and UI2.0.
 * @public
 */
exports.FrameworkVersionContext = React.createContext("2"); // eslint-disable-line @typescript-eslint/naming-convention, deprecation/deprecation
/** The FrameworkVersion component provides uiVersion context to react component. The
 * component uses the property frameworkState.configurableUiState.frameworkVersion from the redux store
 * to determine the ui version. This version will default to "2" and should only be set to "1" for older
 * iModelApp applications.
 * @deprecated in 3.5. Used to toggle between UI1.0 and UI2.0.
 * @public
 */
function FrameworkVersion(props) {
    const uiVersion = (0, react_redux_1.useSelector)((state) => {
        const frameworkState = state[UiFramework_1.UiFramework.frameworkStateKey];
        return frameworkState ? frameworkState.configurableUiState.frameworkVersion : "2"; // eslint-disable-line deprecation/deprecation
    });
    return React.createElement(exports.FrameworkVersionContext.Provider // eslint-disable-line deprecation/deprecation
    , { children: props.children, value: uiVersion });
}
exports.FrameworkVersion = FrameworkVersion;
/** @internal */
function FrameworkVersionSwitch(props) {
    const version = useFrameworkVersion(); // eslint-disable-line deprecation/deprecation
    switch (version) {
        case "1": {
            return React.createElement(React.Fragment, null, props.v1);
        }
        case "2":
        default: {
            return React.createElement(React.Fragment, null, props.v2);
        }
    }
}
exports.FrameworkVersionSwitch = FrameworkVersionSwitch;
//# sourceMappingURL=useFrameworkVersion.js.map