// #region Imports
import { DomServiceLocator } from '../../../../../../Dom/Dom';
import { on } from '@breadstone/mosaik-elements';
import { InputBaseElement } from '../../../../Inputs/Abstracts/InputBase';
// #endregion
/**
 * UpDownBaseElement - A updown represents a control that enables users to select a value from a given minimum and maximum range.
 *
 * @public
 * @abstract
 */
export class UpDownBaseElement extends InputBaseElement {
    // #region Fields
    _inputSubscription;
    // #endregion
    // #region Ctor
    /**
     * Constructs a new instance of the `UpDownBaseElement` class.
     *
     * @protected
     */
    constructor() {
        super();
        this._inputSubscription = null;
    }
    /**
     * Returns the `input` property.
     *
     * @protected
     * @readonly
     */
    get input() {
        const input = this.shadowRoot
            ? DomServiceLocator.current.findDescendant(this.shadowRoot, 'input')
            : null;
        return input;
    }
    // #endregion
    // #region Methods
    disconnectedCallback() {
        super.disconnectedCallback();
        this._inputSubscription?.dispose();
    }
    onApplyTemplate() {
        super.onApplyTemplate();
        if (this.input) {
            this._inputSubscription = on(this.input, 'input', (x) => this.onInputChanged(x));
        }
    }
    /**
     * @protected
     */
    setInputValue(value) {
        if (this.input) {
            this.input.value = value;
            // it muss be dispatched; otherwise the value will not be updated
            this.input.dispatchEvent(new Event('input', { bubbles: true }));
        }
    }
}
//# sourceMappingURL=UpDownBaseElement.js.map