/*---------------------------------------------------------------------------------------------
 * 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
 */
import { SnapMode } from "@itwin/core-frontend";
import { createAction } from "../redux/redux-ts";
import { SYSTEM_PREFERRED_COLOR_THEME, TOOLBAR_OPACITY_DEFAULT, WIDGET_OPACITY_DEFAULT, } from "../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
 */
export 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 || (ConfigurableUiActionId = {}));
/** used on first call of ConfigurableUiReducer */
const initialState = {
    snapMode: SnapMode.NearestKeypoint,
    toolPrompt: "",
    theme: SYSTEM_PREFERRED_COLOR_THEME,
    widgetOpacity: WIDGET_OPACITY_DEFAULT,
    useDragInteraction: false,
    showWidgetIcon: true,
    autoCollapseUnpinnedPanels: false,
    viewOverlayDisplay: true,
    animateToolSettings: false,
    useToolAsToolSettingsLabel: false,
    toolbarOpacity: TOOLBAR_OPACITY_DEFAULT,
};
/** An object with a function that creates each ConfigurableUiReducer that can be handled by our reducer.
 * @public
 */
export const ConfigurableUiActions = {
    setSnapMode: (snapMode) => createAction(ConfigurableUiActionId.SetSnapMode, snapMode),
    setTheme: 
    /**
     * Use `UiFramework.setColorTheme` instead which is conveniently typed with available theme union.
     * @param theme ThemeId
     */
    (theme) => createAction(ConfigurableUiActionId.SetTheme, theme),
    setToolPrompt: 
    // istanbul ignore next
    (toolPrompt) => createAction(ConfigurableUiActionId.SetToolPrompt, toolPrompt),
    setWidgetOpacity: 
    // istanbul ignore next
    (opacity) => createAction(ConfigurableUiActionId.SetWidgetOpacity, opacity),
    setDragInteraction: (dragInteraction) => createAction(ConfigurableUiActionId.SetDragInteraction, dragInteraction),
    setShowWidgetIcon: (showWidgetIcon) => createAction(ConfigurableUiActionId.SetShowWidgetIcon, showWidgetIcon),
    setAutoCollapseUnpinnedPanels: (autoCollapse) => createAction(ConfigurableUiActionId.AutoCollapseUnpinnedPanels, autoCollapse),
    setViewOverlayDisplay: (displayViewOverlay) => createAction(ConfigurableUiActionId.SetViewOverlayDisplay, displayViewOverlay),
    setAnimateToolSettings: (animateToolSettings) => createAction(ConfigurableUiActionId.AnimateToolSettings, animateToolSettings),
    setUseToolAsToolSettingsLabel: (useToolAsToolSettingsLabel) => createAction(ConfigurableUiActionId.UseToolAsToolSettingsLabel, useToolAsToolSettingsLabel),
    setToolbarOpacity: (opacity) => createAction(ConfigurableUiActionId.SetToolbarOpacity, opacity),
};
/** Handles actions to update ConfigurableUiState.
 * @public
 */
export 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;
}
//# sourceMappingURL=state.js.map