import { r as registerInstance, c as createEvent, h, H as Host, g as getElement } from './index-CV0Pyo1O.js';
import { F as FormControlErrorText } from './form-control-error-text-Di9QePY5.js';
import { a3 as inputInvalidAndFocused, q as inputInvalid, v as inputFocused, u as inputDisabled, w as input, x as label } from './parts-CPKMvyV_.js';

const FormControlFileV2 = class {
    constructor(hostRef) {
        registerInstance(this, hostRef);
        this.formControlInput = createEvent(this, "formControlInput", 7);
        this.formControlBlur = createEvent(this, "formControlBlur", 7);
        this.errorText = '';
        this.inputHandler = () => { };
        this.disabled = false;
    }
    render() {
        return (h(Host, { key: '52fee4080e9475313f4043c1a1e116d07881fd72', exportparts: "label,input,input-invalid" }, h("div", { key: 'efe6ee7fae0693fad8086e7849fdc03a01525368', class: "form-group d-flex flex-column" }, h("div", { key: 'dd224535e329aa82cc86be2f32f40b4a8904e1bc', class: "d-flex align-items-start gap-2" }, h("label", { key: '6cee04c50d6eaba123d00ee5ffdad036e46bbf7d', part: "label", class: "form-label", htmlFor: this.name }, this.label), h("form-control-tooltip", { key: '30e545c71fa6a5e4eac985ea6073dc5b2ab78629', helpText: this.helpText })), h("input", { key: '3ba7425da1d80314acdd0050c90aa8a795473584', type: "file", name: this.name, part: `input ${this.errorText ? "input-invalid " : ""}${this.disabled ? "input-disabled" : ""}`, class: this.errorText ? "form-control is-invalid" : "form-control", multiple: this.multiple, disabled: this.disabled, onBlur: () => this.formControlBlur.emit(), onChange: () => this.errorText = "" }), h(FormControlErrorText, { key: '9ad4526e2937d98d555b325e60d20dc7305ee786', errorText: this.errorText, name: this.name }))));
    }
    get el() { return getElement(this); }
};

const FormControlTextarea = class {
    constructor(hostRef) {
        registerInstance(this, hostRef);
        this.formControlInput = createEvent(this, "formControlInput", 7);
        this.formControlBlur = createEvent(this, "formControlBlur", 7);
        this.isFocused = false;
        this.helpText = '';
        this.errorText = '';
        this.inputHandler = () => { };
        this.disabled = false;
        this.handleFormControlInput = (event) => {
            const target = event.target;
            const name = target.getAttribute('name');
            this.inputHandler(name, target.value);
            this.formControlInput.emit({ name, value: target.value });
        };
        this.updateInput = (newValue) => {
            const inputElement = this.el.querySelector('textarea');
            if (inputElement) {
                inputElement.value = newValue || '';
            }
        };
    }
    handleDefaultValueChange(newValue) {
        this.updateInput(newValue);
    }
    componentDidLoad() {
        this.updateInput(this.defaultValue);
    }
    get part() {
        if (this.isFocused && this.errorText) {
            return inputInvalidAndFocused;
        }
        if (this.errorText) {
            return inputInvalid;
        }
        if (this.isFocused) {
            return inputFocused;
        }
        if (this.disabled) {
            return inputDisabled;
        }
        return input;
    }
    render() {
        return (h(Host, { key: 'f6c4833f4a582e5b310b89356716acce6ef24f8f' }, h("div", { key: 'dc576c3df86ede178fef9dd2975ea2307fd1bd5f', class: "form-group d-flex flex-column" }, h("label", { key: '4217d6bbe9fb6331c2ab5e9d043659079a7af1dc', part: label, class: "form-label", htmlFor: this.name }, this.label), h("textarea", { key: '42ab7f076431ee0a1e744eb648de1590e39554f7', id: this.name, name: this.name, onFocus: () => this.isFocused = true, onBlur: () => {
                this.isFocused = false;
                this.formControlBlur.emit();
            }, onInput: this.handleFormControlInput, onKeyDown: this.keyDownHandler, onPaste: this.keyDownHandler, maxLength: this.maxLength, part: this.part, class: this.errorText ? 'form-control is-invalid' : 'form-control', disabled: this.disabled }), h("form-control-help-text", { key: 'a1d8a2b674e5faf81c778a07ca270094f77e7281', helpText: this.helpText, name: this.name }), h("form-control-error-text", { key: 'a47839b4edc4007b6c9dfc1b6689dd1e1750cc60', errorText: this.errorText, name: this.name }))));
    }
    get el() { return getElement(this); }
    static get watchers() { return {
        "defaultValue": ["handleDefaultValueChange"]
    }; }
};

export { FormControlFileV2 as form_control_file_v2, FormControlTextarea as form_control_textarea };
