"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 State
 */
Object.defineProperty(exports, "__esModule", { value: true });
exports.ConfigurableUiReducer = exports.ConfigurableUiActions = exports.ConfigurableUiActionId = void 0;
const core_frontend_1 = require("@itwin/core-frontend");
const redux_ts_1 = require("../redux/redux-ts");
const ThemeManager_1 = require("../theme/ThemeManager");
// cSpell:ignore configurableui snapmode toolprompt
/** Action Ids used by Redux and to send sync UI components. Typically used to refresh visibility or enable state of control.
 *  Since these are also used as sync ids they should be in lowercase.
 * @public
 */
var ConfigurableUiActionId;
(function (ConfigurableUiActionId) {
    ConfigurableUiActionId["SetSnapMode"] = "configurableui:set_snapmode";
    ConfigurableUiActionId["SetTheme"] = "configurableui:set_theme";
    ConfigurableUiActionId["SetToolPrompt"] = "configurableui:set_toolprompt";
    ConfigurableUiActionId["SetWidgetOpacity"] = "configurableui:set_widget_opacity";
    ConfigurableUiActionId["SetDragInteraction"] = "configurableui:set-drag-interaction";
    ConfigurableUiActionId["SetShowWidgetIcon"] = "configurableui:set-show-widget-icon";
    ConfigurableUiActionId["AutoCollapseUnpinnedPanels"] = "configurableui:set-auto-collapse-unpinned-panels";
    ConfigurableUiActionId["SetViewOverlayDisplay"] = "configurableui:set-view-overlay-display";
    ConfigurableUiActionId["AnimateToolSettings"] = "configurableui:set-animate-tool-settings";
    ConfigurableUiActionId["UseToolAsToolSettingsLabel"] = "configurableui:set-use-tool-as-tool-settings-label";
    ConfigurableUiActionId["SetToolbarOpacity"] = "configurableui:set-toolbar-opacity";
})(ConfigurableUiActionId = exports.ConfigurableUiActionId || (exports.ConfigurableUiActionId = {}));
/** used on first call of ConfigurableUiReducer */
const initialState = {
    snapMode: core_frontend_1.SnapMode.NearestKeypoint,
    toolPrompt: "",
    theme: ThemeManager_1.SYSTEM_PREFERRED_COLOR_THEME,
    widgetOpacity: ThemeManager_1.WIDGET_OPACITY_DEFAULT,
    useDragInteraction: false,
    showWidgetIcon: true,
    autoCollapseUnpinnedPanels: false,
    viewOverlayDisplay: true,
    animateToolSettings: false,
    useToolAsToolSettingsLabel: false,
    toolbarOpacity: ThemeManager_1.TOOLBAR_OPACITY_DEFAULT,
};
/** An object with a function that creates each ConfigurableUiReducer that can be handled by our reducer.
 * @public
 */
exports.ConfigurableUiActions = {
    setSnapMode: (snapMode) => (0, redux_ts_1.createAction)(ConfigurableUiActionId.SetSnapMode, snapMode),
    setTheme: 
    /**
     * Use `UiFramework.setColorTheme` instead which is conveniently typed with available theme union.
     * @param theme ThemeId
     */
    (theme) => (0, redux_ts_1.createAction)(ConfigurableUiActionId.SetTheme, theme),
    setToolPrompt: 
    // istanbul ignore next
    (toolPrompt) => (0, redux_ts_1.createAction)(ConfigurableUiActionId.SetToolPrompt, toolPrompt),
    setWidgetOpacity: 
    // istanbul ignore next
    (opacity) => (0, redux_ts_1.createAction)(ConfigurableUiActionId.SetWidgetOpacity, opacity),
    setDragInteraction: (dragInteraction) => (0, redux_ts_1.createAction)(ConfigurableUiActionId.SetDragInteraction, dragInteraction),
    setShowWidgetIcon: (showWidgetIcon) => (0, redux_ts_1.createAction)(ConfigurableUiActionId.SetShowWidgetIcon, showWidgetIcon),
    setAutoCollapseUnpinnedPanels: (autoCollapse) => (0, redux_ts_1.createAction)(ConfigurableUiActionId.AutoCollapseUnpinnedPanels, autoCollapse),
    setViewOverlayDisplay: (displayViewOverlay) => (0, redux_ts_1.createAction)(ConfigurableUiActionId.SetViewOverlayDisplay, displayViewOverlay),
    setAnimateToolSettings: (animateToolSettings) => (0, redux_ts_1.createAction)(ConfigurableUiActionId.AnimateToolSettings, animateToolSettings),
    setUseToolAsToolSettingsLabel: (useToolAsToolSettingsLabel) => (0, redux_ts_1.createAction)(ConfigurableUiActionId.UseToolAsToolSettingsLabel, useToolAsToolSettingsLabel),
    setToolbarOpacity: (opacity) => (0, redux_ts_1.createAction)(ConfigurableUiActionId.SetToolbarOpacity, opacity),
};
/** Handles actions to update ConfigurableUiState.
 * @public
 */
function ConfigurableUiReducer(state = initialState, action) {
    const outState = state;
    switch (action.type) {
        case ConfigurableUiActionId.SetSnapMode: {
            return { ...state, snapMode: action.payload };
        }
        case ConfigurableUiActionId.SetToolPrompt: {
            return { ...state, toolPrompt: action.payload };
        }
        case ConfigurableUiActionId.SetTheme: {
            return { ...state, theme: action.payload }; // Need to cast because of the (string & {}) trick.
        }
        case ConfigurableUiActionId.SetWidgetOpacity: {
            return { ...state, widgetOpacity: action.payload };
        }
        case ConfigurableUiActionId.SetDragInteraction: {
            return { ...state, useDragInteraction: action.payload };
        }
        case ConfigurableUiActionId.SetShowWidgetIcon: {
            return { ...state, showWidgetIcon: action.payload };
        }
        case ConfigurableUiActionId.AutoCollapseUnpinnedPanels: {
            return { ...state, autoCollapseUnpinnedPanels: action.payload };
        }
        case ConfigurableUiActionId.SetViewOverlayDisplay: {
            return { ...state, viewOverlayDisplay: action.payload };
        }
        case ConfigurableUiActionId.AnimateToolSettings: {
            return { ...state, animateToolSettings: action.payload };
        }
        case ConfigurableUiActionId.UseToolAsToolSettingsLabel: {
            return { ...state, useToolAsToolSettingsLabel: action.payload };
        }
        case ConfigurableUiActionId.SetToolbarOpacity: {
            return { ...state, toolbarOpacity: action.payload };
        }
    }
    return outState;
}
exports.ConfigurableUiReducer = ConfigurableUiReducer;
//# sourceMappingURL=state.js.map