// #region Imports
import { ElementValueAccessorBase } from '../../../../../Forms/Accessors/Abstracts/ElementValueAccessorBase';
// #endregion
/**
 * The `SignaturePadElementValueAccessor` class.
 *
 * @public
 */
export class SignaturePadElementValueAccessor extends ElementValueAccessorBase {
    // #region Methods
    /**
     * @public
     */
    hostConnected() {
        this.host.on('signEnded', (e) => this.value = e.target.toBlob());
        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.value);
        });
    }
    /**
     * @public
     * @override
     */
    writeValue(value) {
        super.writeValue(value);
        // TODO: check how to set a blob to a signature pad
        // this.host.data = value ?? '';
    }
    /**
     * @public
     * @override
     */
    resetValue() {
        super.resetValue();
        this.host.reset();
    }
}
/**
 * @public
 */
export const signaturePadElementValueAccessor = (host) => new SignaturePadElementValueAccessor(host);
//# sourceMappingURL=SignaturePadElementValueAccessor.js.map