'use strict';

var index = require('./index-p7cvUYAE.js');
var formControlErrorText = require('./form-control-error-text-BO58Y6zF.js');
var parts = require('./parts-BXshb_S-.js');

const FormControlFileV2 = class {
    constructor(hostRef) {
        index.registerInstance(this, hostRef);
        this.formControlInput = index.createEvent(this, "formControlInput", 7);
        this.formControlBlur = index.createEvent(this, "formControlBlur", 7);
        this.errorText = '';
        this.inputHandler = () => { };
        this.disabled = false;
    }
    render() {
        return (index.h(index.Host, { key: '52fee4080e9475313f4043c1a1e116d07881fd72', exportparts: "label,input,input-invalid" }, index.h("div", { key: 'efe6ee7fae0693fad8086e7849fdc03a01525368', class: "form-group d-flex flex-column" }, index.h("div", { key: 'dd224535e329aa82cc86be2f32f40b4a8904e1bc', class: "d-flex align-items-start gap-2" }, index.h("label", { key: '6cee04c50d6eaba123d00ee5ffdad036e46bbf7d', part: "label", class: "form-label", htmlFor: this.name }, this.label), index.h("form-control-tooltip", { key: '30e545c71fa6a5e4eac985ea6073dc5b2ab78629', helpText: this.helpText })), index.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 = "" }), index.h(formControlErrorText.FormControlErrorText, { key: '9ad4526e2937d98d555b325e60d20dc7305ee786', errorText: this.errorText, name: this.name }))));
    }
    get el() { return index.getElement(this); }
};

const FormControlTextarea = class {
    constructor(hostRef) {
        index.registerInstance(this, hostRef);
        this.formControlInput = index.createEvent(this, "formControlInput", 7);
        this.formControlBlur = index.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 parts.inputInvalidAndFocused;
        }
        if (this.errorText) {
            return parts.inputInvalid;
        }
        if (this.isFocused) {
            return parts.inputFocused;
        }
        if (this.disabled) {
            return parts.inputDisabled;
        }
        return parts.input;
    }
    render() {
        return (index.h(index.Host, { key: 'f6c4833f4a582e5b310b89356716acce6ef24f8f' }, index.h("div", { key: 'dc576c3df86ede178fef9dd2975ea2307fd1bd5f', class: "form-group d-flex flex-column" }, index.h("label", { key: '4217d6bbe9fb6331c2ab5e9d043659079a7af1dc', part: parts.label, class: "form-label", htmlFor: this.name }, this.label), index.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 }), index.h("form-control-help-text", { key: 'a1d8a2b674e5faf81c778a07ca270094f77e7281', helpText: this.helpText, name: this.name }), index.h("form-control-error-text", { key: 'a47839b4edc4007b6c9dfc1b6689dd1e1750cc60', errorText: this.errorText, name: this.name }))));
    }
    get el() { return index.getElement(this); }
    static get watchers() { return {
        "defaultValue": ["handleDefaultValueChange"]
    }; }
};

exports.form_control_file_v2 = FormControlFileV2;
exports.form_control_textarea = FormControlTextarea;
