// #region Imports
import { ElementValueAccessorBase } from '../../../../../Forms/Accessors/Abstracts/ElementValueAccessorBase';
// #endregion
export class ToggleButtonGroupElementValueAccessor extends ElementValueAccessorBase {
    // #region Methods
    /**
     * @public
     */
    hostConnected() {
        this.host.on('groupChanged', (e) => this.writeValue(e.detail.value ?? null));
        // 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();
        // host implements reset() on the custom element; guard in case of plain HTMLElement
        this.host.reset?.();
    }
}
/**
 * @public
 */
export const toggleButtonGroupElementValueAccessor = (host) => new ToggleButtonGroupElementValueAccessor(host);
//# sourceMappingURL=ToggleButtonGroupElementValueAccessor.js.map