import { h } from '../edel-elements.core.js';

import { a as applyInputgroupStyle } from './chunk-69f58b19.js';

class EdelInputPasswordComponent {
    constructor() {
        this.autofocus = false;
    }
    handleChange(event) {
        const keyboardEvent = event;
        this.value = keyboardEvent.target.value;
        this.valueChange.emit(this.value);
    }
    hostData() {
        return {
            class: 'input'
        };
    }
    handleBlur() {
        this.afterEdit.emit(this.value);
    }
    componentDidLoad() {
        this.updateAutoFocus();
        this.updateInGroupDidChange();
        this.updateCss();
    }
    updateAutoFocus() {
        if (this.autofocus) {
            const element = this.hostElement.getElementsByTagName('input').item(0);
            if (element)
                requestAnimationFrame(() => element.focus());
        }
    }
    updateCss() {
        if (this.disabled)
            this.hostElement.classList.add('input--off');
        else
            this.hostElement.classList.remove('input--off');
    }
    render() {
        return (h("input", { value: this.value, type: "password", placeholder: this.placeholder, onInput: this.handleChange.bind(this), onBlur: this.handleBlur.bind(this), autofocus: this.autofocus }));
    }
    updateInGroupDidChange() {
        applyInputgroupStyle(this.inGroup, this.hostElement);
    }
    static get is() { return "edel-input-password"; }
    static get properties() { return {
        "autofocus": {
            "type": Boolean,
            "attr": "autofocus",
            "watchCallbacks": ["updateAutoFocus"]
        },
        "disabled": {
            "type": Boolean,
            "attr": "disabled",
            "watchCallbacks": ["updateCss"]
        },
        "hostElement": {
            "elementRef": true
        },
        "inGroup": {
            "type": Boolean,
            "attr": "in-group",
            "watchCallbacks": ["updateInGroupDidChange"]
        },
        "placeholder": {
            "type": String,
            "attr": "placeholder"
        },
        "value": {
            "type": String,
            "attr": "value",
            "mutable": true
        }
    }; }
    static get events() { return [{
            "name": "valueChange",
            "method": "valueChange",
            "bubbles": true,
            "cancelable": true,
            "composed": true
        }, {
            "name": "afterEdit",
            "method": "afterEdit",
            "bubbles": true,
            "cancelable": true,
            "composed": true
        }]; }
}

export { EdelInputPasswordComponent as EdelInputPassword };
