"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 Rendering
 */
Object.defineProperty(exports, "__esModule", { value: true });
exports.FlashSettings = exports.FlashMode = void 0;
const core_bentley_1 = require("@itwin/core-bentley");
/** As part of [[FlashSettings]], describes how geometry is flashed.
 * @public
 * @extensions
 */
var FlashMode;
(function (FlashMode) {
    /** The color of the geometry is mixed with the hilite color. */
    FlashMode[FlashMode["Hilite"] = 0] = "Hilite";
    /** The color of the geometry is brightened. Applicable only to lit geometry - i.e., meshes displayed in a view with [RenderMode.SmoothShade]($common)
     * and lighting enabled.
     */
    FlashMode[FlashMode["Brighten"] = 1] = "Brighten";
})(FlashMode || (exports.FlashMode = FlashMode = {}));
/** Settings that control how geometry is "flashed" when hovered over in a [[Viewport]].
 * When the user hovers the mouse cursor over an element (or other piece of geometry, like a reality mesh), a [[Tool]] visually indicates
 * that it can interact with that geometry by "flashing" it. Flashed geometry changes color in one of the following two ways:
 *  - By mixing the viewport's hilite color as specified by [[Viewport.hilite]] with the geometry's own color; or
 *  - By brightening the geometry's own color (for lit geometry only - i.e., meshes displayed in a view with lighting enabled).
 * The flash effect starts out at an intensity of zero and increases linearly over the period of time specified by [[duration]] until
 * [[maxIntensity]] is reached.
 * @see [[Viewport.flashSettings]] to customize the flash behavior for a viewport.
 * @see [[Viewport.hilite]] to customize the hilite color used by [[FlashMode.Hilite]].
 * @public
 * @extensions
 */
class FlashSettings {
    /** Construct new flash settings.
     * @param options If supplied, overrides specified default values.
     * Example: to change [[duration]] to 1 second and use default [[maxIntensity]] and [[litMode]]:
     * ```ts
     *  const settings = new FlashSettings({ duration: BeDuration.fromSeconds(1) });
     * ```
     */
    constructor(options) {
        this.litMode = options?.litMode === FlashMode.Hilite ? FlashMode.Hilite : FlashMode.Brighten;
        const maxIntensity = options?.maxIntensity ?? 1;
        this.maxIntensity = Math.min(1, Math.max(0, maxIntensity));
        let duration = options?.duration;
        if (duration) {
            const ms = Math.max(0, Math.min(10 * 1000, duration.milliseconds));
            if (ms !== duration.milliseconds)
                duration = core_bentley_1.BeDuration.fromMilliseconds(ms);
        }
        else {
            duration = core_bentley_1.BeDuration.fromSeconds(0.25);
        }
        this.duration = duration;
    }
    /** Create a copy of these settings identical except for properties explicitly specified by `options`.
     * @param options Overrides selected properties of these settings. Any property not supplied will retain its current value. Any property
     * explicitly set to `undefined` will receive its default value.
     * @returns A copy of these settings identical except as specified by `options`.
     */
    clone(options) {
        if (!options)
            return this;
        return new FlashSettings({ ...this, ...options });
    }
}
exports.FlashSettings = FlashSettings;
//# sourceMappingURL=FlashSettings.js.map