// #region Imports
import { ElementValueAccessorBase } from '../../../../../Forms/Accessors/Abstracts/ElementValueAccessorBase';
// #endregion
/**
 * The `ChoiceGroupElementValueAccessor` class.
 *
 * @public
 */
export class ChoiceGroupElementValueAccessor extends ElementValueAccessorBase {
    // #region Methods
    /**
     * @public
     */
    hostConnected() {
        this.host.on('choiceChanged', (x) => this.value = x.detail.value ?? null);
        // 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.value);
        });
    }
    /**
     * @public
     * @override
     */
    writeValue(value) {
        super.writeValue(value);
        this.host.value = value;
    }
    /**
     * @public
     * @override
     */
    resetValue() {
        super.resetValue();
        this.host.reset();
    }
}
/**
 * @public
 */
export const choiceGroupElementValueAccessor = (host) => new ChoiceGroupElementValueAccessor(host);
//# sourceMappingURL=ChoiceGroupElementValueAccessor.js.map