/*---------------------------------------------------------------------------------------------
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
* See LICENSE.md in the project root for license terms and full copyright notice.
*--------------------------------------------------------------------------------------------*/
/** @packageDocumentation
 * @module Item
 */
import { PropsHelper } from "../utils/PropsHelper";
/** The base class for Items.
 * @public
 */
export class ItemDefBase {
    constructor(itemProps) {
        this._label = "";
        this._tooltip = "";
        this._description = "";
        /** @deprecated in 2.x. Use isHidden instead */
        this.isVisible = true;
        /** @deprecated in 2.x. Use isDisabled instead */
        this.isEnabled = true;
        this.isPressed = false;
        this._isActive = false;
        /** @deprecated in 2.x. Use condition instead */
        this.stateSyncIds = [];
        ItemDefBase.initializeDef(this, itemProps);
    }
    get isActive() { return this._isActive; }
    set isActive(v) { this._isActive = v; }
    static initializeDef(me, itemProps) {
        me.isVisible = (itemProps.isVisible !== undefined) ? itemProps.isVisible : true; // eslint-disable-line deprecation/deprecation
        me.isEnabled = (itemProps.isEnabled !== undefined) ? itemProps.isEnabled : true; // eslint-disable-line deprecation/deprecation
        me.isHidden = (itemProps.isHidden === undefined && itemProps.isVisible !== undefined) ? !itemProps.isVisible : itemProps.isHidden; // eslint-disable-line deprecation/deprecation
        me.isDisabled = (itemProps.isDisabled === undefined && itemProps.isEnabled !== undefined) ? !itemProps.isEnabled : itemProps.isDisabled; // eslint-disable-line deprecation/deprecation
        me.isPressed = (itemProps.isPressed !== undefined) ? itemProps.isPressed : false;
        me.isActive = (itemProps.isActive !== undefined) ? itemProps.isActive : false;
        me.badgeType = itemProps.badgeType;
        if (itemProps.applicationData !== undefined)
            me.applicationData = itemProps.applicationData;
        if (itemProps.iconSpec)
            me.iconSpec = itemProps.iconSpec;
        if (itemProps.icon)
            me.iconSpec = itemProps.icon;
        me._label = PropsHelper.getStringSpec(itemProps.label, itemProps.labelKey);
        me._tooltip = PropsHelper.getStringSpec(itemProps.tooltip, itemProps.tooltipKey);
        me._description = PropsHelper.getStringSpec(itemProps.description, itemProps.descriptionKey);
        // deprecated
        if (itemProps.stateFunc) // eslint-disable-line deprecation/deprecation
            me.stateFunc = itemProps.stateFunc; // eslint-disable-line deprecation/deprecation
        // deprecated
        if (itemProps.stateSyncIds) // eslint-disable-line deprecation/deprecation
            me.stateSyncIds = itemProps.stateSyncIds.map((value) => value.toLowerCase()); // eslint-disable-line deprecation/deprecation
    }
    get trayId() { return undefined; }
    /** Get the label string */
    get rawLabel() {
        return this._label;
    }
    /** Get the label string */
    get label() {
        return PropsHelper.getStringFromSpec(this._label);
    }
    /** Set the label.
     * @param v A string or a function to get the string.
     */
    setLabel(v) {
        this._label = v;
    }
    /** Get the tooltip string */
    get tooltip() {
        return PropsHelper.getStringFromSpec(this._tooltip);
    }
    /** Set the tooltip.
     * @param v A string or a function to get the string.
     */
    setTooltip(v) {
        this._tooltip = v;
    }
    /** Get the description string */
    get description() {
        return PropsHelper.getStringFromSpec(this._description);
    }
    /** Set the description.
     * @param v A string or a function to get the string.
     */
    setDescription(v) {
        this._description = v;
    }
}
//# sourceMappingURL=ItemDefBase.js.map