// #region Imports
import { ElementValueAccessorBase } from '../../../../../Forms/Accessors/Abstracts/ElementValueAccessorBase';
// #endregion
/**
 * The `ColorEditorAlphaSliderElementValueAccessor` class provides form value accessor
 * functionality for the `ColorEditorAlphaSliderElement`, enabling two-way binding
 * between the alpha slider and form controls.
 *
 * @public
 */
export class ColorEditorAlphaSliderElementValueAccessor extends ElementValueAccessorBase {
    // #region Methods
    /**
     * Called when the host element is connected to the DOM.
     * Sets up event listeners for alpha changes.
     *
     * @public
     */
    hostConnected() {
        this.host.on('change', (e) => this.value = e.detail.alpha);
        this.host.on('blur', () => this.onTouched());
        // Sync the initial host value without triggering onChange, because
        // the host element may already have a value before the accessor is connected.
        void this.host.updateComplete.then(() => {
            this.writeValue(this.host.alpha);
        });
    }
    /**
     * Writes a value to the host element.
     *
     * @public
     * @override
     * @param value - The alpha value to write (0-1).
     */
    writeValue(value) {
        super.writeValue(value);
        this.host.alpha = value ?? 1;
    }
    /**
     * Resets the host element to its default value.
     *
     * @public
     * @override
     */
    resetValue() {
        super.resetValue();
        this.host.alpha = 1;
    }
}
/**
 * Factory function to create a `ColorEditorAlphaSliderElementValueAccessor` instance.
 *
 * @public
 */
export const colorEditorAlphaSliderElementValueAccessor = (host) => new ColorEditorAlphaSliderElementValueAccessor(host);
//# sourceMappingURL=ColorEditorAlphaSliderElementValueAccessor.js.map