import { p as proxyCustomElement, H, e as createEvent, h } from './p-ae373651.js';
import { S as SyncWithStore } from './p-070aa695.js';
import { e as defaultIconPack, i as useLanguage } from './p-5b3a7f00.js';
import './p-a83ccdbd.js';
import { d as defineCustomElement$3 } from './p-85587a5c.js';
import { d as defineCustomElement$2 } from './p-3e0452c4.js';
import { d as defineCustomElement$1 } from './p-bece0226.js';

const rtkFilePickerButtonCss = ":host{}";
const RtkFilePickerButtonStyle0 = rtkFilePickerButtonCss;

var __decorate = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
        r = Reflect.decorate(decorators, target, key, desc);
    else
        for (var i = decorators.length - 1; i >= 0; i--)
            if (d = decorators[i])
                r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
const RtkFilePickerButton = /*@__PURE__*/ proxyCustomElement(class RtkFilePickerButton extends H {
    constructor() {
        super();
        this.__registerHost();
        this.__attachShadow();
        this.onFileChange = createEvent(this, "fileChange", 7);
        /** Icon */
        this.icon = 'attach';
        /** Icon pack */
        this.iconPack = defaultIconPack;
        /** Language */
        this.t = useLanguage();
        this.uploadFile = () => {
            const input = this.fileInputField;
            input.type = 'file';
            if (this.filter) {
                input.accept = this.filter;
            }
            input.onchange = (e) => {
                const { validity, files: [file], } = e.target;
                if (validity.valid) {
                    this.onFileChange.emit(file);
                }
            };
            input.click();
        };
    }
    connectedCallback() {
        this.fileInputField = document.createElement('input');
    }
    disconnectedCallback() {
        // For GC
        this.fileInputField = undefined;
    }
    render() {
        const label = this.label || this.t('chat.send_file');
        const icon = this.iconPack[this.icon];
        return (h("rtk-tooltip", { key: '329c452b2de6664978946000c6264e823c87830d', label: label }, h("rtk-button", { key: '7b6a275ab946ad2aa751c8e36a6c9701f5fa0dab', variant: "ghost", kind: "icon", onClick: () => this.uploadFile(), title: label }, h("rtk-icon", { key: 'd3306859b107d0988c24f098db21467787b03afc', icon: icon }))));
    }
    static get style() { return RtkFilePickerButtonStyle0; }
}, [1, "rtk-file-picker-button", {
        "filter": [1],
        "label": [1],
        "icon": [1],
        "iconPack": [16],
        "t": [16]
    }]);
__decorate([
    SyncWithStore()
], RtkFilePickerButton.prototype, "iconPack", void 0);
__decorate([
    SyncWithStore()
], RtkFilePickerButton.prototype, "t", void 0);
function defineCustomElement() {
    if (typeof customElements === "undefined") {
        return;
    }
    const components = ["rtk-file-picker-button", "rtk-button", "rtk-icon", "rtk-tooltip"];
    components.forEach(tagName => { switch (tagName) {
        case "rtk-file-picker-button":
            if (!customElements.get(tagName)) {
                customElements.define(tagName, RtkFilePickerButton);
            }
            break;
        case "rtk-button":
            if (!customElements.get(tagName)) {
                defineCustomElement$3();
            }
            break;
        case "rtk-icon":
            if (!customElements.get(tagName)) {
                defineCustomElement$2();
            }
            break;
        case "rtk-tooltip":
            if (!customElements.get(tagName)) {
                defineCustomElement$1();
            }
            break;
    } });
}
defineCustomElement();

export { RtkFilePickerButton as R, defineCustomElement as d };
