/*!
 * KoliBri - The accessible HTML-Standard
 */
import { validateHasCounter, validateMaxLength, validatePattern, validatePlaceholder, validateReadOnly, validateRequired, validateVariantClassName, watchString, } from "../../schema";
import { validateAutoComplete } from "../../schema/props/auto-complete";
import { validateMaxLengthBehavior } from "../../schema/props/max-length-behavior";
import { validateVisibilityToggle } from "../../schema/props/visibility-toggle";
import { InputIconController } from "../@deprecated/input/controller-icon";
export class InputPasswordController extends InputIconController {
    constructor(component, name, host) {
        super(component, name, host);
        this.afterSyncCharCounter = () => {
            if (typeof this.component._value === 'string') {
                this.component.state._currentLength = this.component._value.length;
                this.updateCurrentLengthDebounced(this.component._value.length);
            }
        };
        this.component = component;
    }
    validateAutoComplete(value) {
        validateAutoComplete(this.component, value);
    }
    validateHasCounter(value) {
        validateHasCounter(this.component, value);
    }
    validateMaxLengthBehavior(value) {
        validateMaxLengthBehavior(this.component, value);
    }
    validateMaxLength(value) {
        validateMaxLength(this.component, value, {
            hooks: { afterPatch: this.afterSyncCharCounter },
        });
    }
    validatePattern(value) {
        validatePattern(this.component, value);
    }
    validatePlaceholder(value) {
        validatePlaceholder(this.component, value);
    }
    validateReadOnly(value) {
        validateReadOnly(this.component, value);
    }
    validateRequired(value) {
        validateRequired(this.component, value);
    }
    validateValue(value) {
        watchString(this.component, '_value', value, {
            hooks: {
                afterPatch: this.afterSyncCharCounter,
            },
        });
        this.setFormAssociatedValue(this.component.state._value);
    }
    validateVariant(value) {
        validateVariantClassName(this.component, value);
    }
    validateVisibilityToggle(value) {
        validateVisibilityToggle(this.component, value);
    }
    componentWillLoad() {
        super.componentWillLoad();
        this.validateAutoComplete(this.component._autoComplete);
        this.validateHasCounter(this.component._hasCounter);
        this.validateMaxLengthBehavior(this.component._maxLengthBehavior);
        this.validateMaxLength(this.component._maxLength);
        this.validatePattern(this.component._pattern);
        this.validatePlaceholder(this.component._placeholder);
        this.validateReadOnly(this.component._readOnly);
        this.validateRequired(this.component._required);
        this.validateValue(this.component._value);
        this.validateVariant(this.component._variant);
        this.validateVisibilityToggle(this.component._visibilityToggle);
    }
}
//# sourceMappingURL=controller.js.map
