// #region Imports
import { ElementValueAccessorBase } from '../../../../../Forms/Accessors/Abstracts/ElementValueAccessorBase';
// #endregion
/**
 * The `SelectElementValueAccessor` class.
 *
 * @public
 */
export class SelectElementValueAccessor extends ElementValueAccessorBase {
    // #region Methods
    /**
     * @public
     */
    hostConnected() {
        this.host.on('input', (e) => this.writeValue(e.target.value));
        this.host.on('change', (e) => this.writeValue(e.target.value));
        this.host.on('selectionChanged', (e) => this.writeValue(e.detail.newValue.value));
        this.host.on('blur', () => this.onTouched());
        // we need to set the value here because the host element may have a value before the accessor is connected
        void this.host.updateComplete.then(() => {
            this.value = this.host.value;
        });
    }
    /**
     * @public
     * @override
     */
    writeValue(value) {
        super.writeValue(value);
        this.host.value = value ?? '';
    }
    /**
     * @public
     * @override
     */
    resetValue() {
        super.resetValue();
        this.host.reset();
    }
}
/**
 * @public
 */
export const selectElementValueAccessor = (host) => new SelectElementValueAccessor(host);
//# sourceMappingURL=SelectElementValueAccessor.js.map