import { proxyCustomElement, HTMLElement, h, Host } from '@stencil/core/internal/client';
import { g as getIconPath } from './mer-animated-dots.js';
import 'lit';
import 'lit/directives/when.js';
import 'lit/directives/if-defined.js';
import { L as Locale } from './locale.js';
import { d as defineCustomElement$2 } from './file-item.js';

const fileUploaderCss = ":host{display:grid;block-size:100%}.opacity-0{opacity:0}.gxi-hidden{display:none !important}.align-center{display:flex;align-items:center}.align-end{display:flex;align-items:end}.overflow-auto{overflow:auto}:host(.gx-ide-component){height:100% !important;display:flex !important;flex-direction:column !important}.gx-ide-main-wrapper{color:var(--gx-ide-component-text-color);font-weight:var(--font-style-regular);font-size:var(--font-size-body-m);font-family:var(--font-family-body);height:100%;display:flex;flex-direction:column;flex-grow:1;box-sizing:border-box}.buttons-container{display:flex;gap:var(--spacing-gap-m)}.giu-static-pill-icon-and-text,.giu-static-pill{background-color:var(--elevation-background-color, var(--color-accent-surface-elevation-1));padding-inline:var(--spacing-padding-m);color:var(--color-text-neutral-default);font-size:var(--font-size-body-s);line-height:var(--line-height-relaxed);font-weight:var(--font-style-regular);border-radius:4px;min-block-size:25px;display:inline-grid;align-items:center;pointer-events:none;inline-size:max-content}.giu-static-pill-icon-and-text{display:inline-grid;grid-auto-flow:column;grid-auto-columns:max-content;gap:var(--spacing-gap-m)}.tab-full-width-buttons::part(tab-list block-start),.tab-full-width-buttons::part(tab-list block-end){grid-auto-columns:1fr}.tab-full-width-buttons::part(tab block-start){justify-content:center}.tree-view::part(item__header){--icon__system_warning_warning--disabled:var(\n    --icon__system_warning_warning--enabled\n  )}.tabular-grid{--focus-outline-width:1px}button.button-secondary{border-color:var(--color-border-neutral-default)}:host{display:grid;inline-size:100%;block-size:100%}.file-uploader-dialog{display:grid;grid-template-rows:1fr max-content;block-size:100%;min-block-size:0;position:relative}.file-uploader-dialog .dialog-content{min-block-size:0;overflow:auto}.file-uploader{display:flex;flex-direction:column;inline-size:100%;block-size:100%}.file-uploader__list{display:flex;flex-direction:column;inline-size:100%;block-size:100%}.file-uploader__list-header{position:sticky;top:0;z-index:1;display:flex;justify-content:space-between;align-items:center}.file-uploader__list-content{flex:1;overflow-y:auto;display:flex;flex-direction:column;gap:var(--spacing-gap-l);list-style:none;margin:0;padding:0;padding-block-end:var(--spacing-padding-l)}.file-uploader__list-title-container{display:flex;align-items:center;gap:var(--spacing-gap-xs);white-space:nowrap}.file-uploader__drop-zone{display:flex;flex-direction:column;align-items:center;justify-content:center;inline-size:100%;block-size:100%;border:2px dashed var(--color-border-neutral-default);border-radius:8px;transition:border-color 0.3s ease, background-color 0.3s ease, opacity 0.3s ease}.file-uploader__drop-zone--dragging{border-color:var(--color-accent-primary-default);background:var(--color-accent-primary-hover);opacity:0.7}.file-uploader__drop-zone .text-container{display:flex;flex-direction:column;align-items:center;gap:var(--spacing-gap-xs);margin-block-start:8px}.label-primary-row{display:flex;align-items:center;gap:var(--spacing-gap-m)}";

var __classPrivateFieldGet = (undefined && undefined.__classPrivateFieldGet) || function (receiver, state, kind, f) {
    if (kind === "a" && !f)
        throw new TypeError("Private accessor was defined without a getter");
    if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
        throw new TypeError("Cannot read private member from an object whose class did not declare it");
    return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
};
var __classPrivateFieldSet = (undefined && undefined.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
    if (kind === "m")
        throw new TypeError("Private method is not writable");
    if (kind === "a" && !f)
        throw new TypeError("Private accessor was defined without a setter");
    if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
        throw new TypeError("Cannot write private member to an object whose class did not declare it");
    return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
};
var _FileUploader_instances, _FileUploader__componentLocale, _FileUploader_fileInputEl, _FileUploader_dragCounter, _FileUploader_generateId, _FileUploader_isValidFile, _FileUploader_getValidFiles, _FileUploader_handleDragEnter, _FileUploader_handleDragLeave, _FileUploader_handleDragOver, _FileUploader_handleDrop, _FileUploader_handleFileSelect, _FileUploader_handleFileInput, _FileUploader_handleFiles, _FileUploader_handleNameChange, _FileUploader_handleFileCancel, _FileUploader_handleConfirm, _FileUploader_handleCancel;
const PLUS_ICON = getIconPath({
    category: "system",
    name: "add",
    colorType: "primary"
});
const CSS_BUNDLES = [
    "resets/box-sizing",
    "components/button",
    "components/icon",
    "components/list-box",
    "components/edit",
    "utils/typography",
    "utils/spacing",
    "utils/form",
    "utils/layout",
    "utils/elevation",
    "chameleon/scrollbar"
];
const FileUploader = /*@__PURE__*/ proxyCustomElement(class FileUploader extends HTMLElement {
    constructor() {
        super();
        this.__registerHost();
        this.__attachShadow();
        _FileUploader_instances.add(this);
        _FileUploader__componentLocale.set(this, void 0);
        _FileUploader_fileInputEl.set(this, void 0);
        _FileUploader_dragCounter.set(this, 0);
        /** Generates a unique ID for file identification */
        _FileUploader_generateId.set(this, () => {
            return Math.random().toString(36).substr(2, 9);
        });
        /** Handles drag enter event */
        _FileUploader_handleDragEnter.set(this, (e) => {
            var _a;
            e.preventDefault();
            e.stopPropagation();
            __classPrivateFieldSet(this, _FileUploader_dragCounter, (_a = __classPrivateFieldGet(this, _FileUploader_dragCounter, "f"), _a++, _a), "f");
            this.isDragging = true;
        });
        /** Handles drag leave event */
        _FileUploader_handleDragLeave.set(this, (e) => {
            var _a;
            e.preventDefault();
            e.stopPropagation();
            __classPrivateFieldSet(this, _FileUploader_dragCounter, (_a = __classPrivateFieldGet(this, _FileUploader_dragCounter, "f"), _a--, _a), "f");
            if (__classPrivateFieldGet(this, _FileUploader_dragCounter, "f") === 0) {
                this.isDragging = false;
            }
        });
        /** Handles drag over event */
        _FileUploader_handleDragOver.set(this, (e) => {
            e.preventDefault();
            e.stopPropagation();
        });
        /** Handles drop event */
        _FileUploader_handleDrop.set(this, (e) => {
            var _a;
            e.preventDefault();
            e.stopPropagation();
            this.isDragging = false;
            __classPrivateFieldSet(this, _FileUploader_dragCounter, 0, "f");
            const files = (_a = e.dataTransfer) === null || _a === void 0 ? void 0 : _a.files;
            if (files) {
                __classPrivateFieldGet(this, _FileUploader_handleFiles, "f").call(this, files);
            }
        });
        /** Triggers file input click */
        _FileUploader_handleFileSelect.set(this, () => {
            var _a;
            (_a = __classPrivateFieldGet(this, _FileUploader_fileInputEl, "f")) === null || _a === void 0 ? void 0 : _a.click();
        });
        /** Handles file input change event */
        _FileUploader_handleFileInput.set(this, (e) => {
            const files = e.target.files;
            if (files) {
                __classPrivateFieldGet(this, _FileUploader_handleFiles, "f").call(this, files);
            }
        });
        /** Processes files and starts upload */
        _FileUploader_handleFiles.set(this, (files) => {
            const validFiles = __classPrivateFieldGet(this, _FileUploader_instances, "m", _FileUploader_getValidFiles).call(this, files);
            validFiles.forEach(async (file) => {
                var _a, _b;
                const id = __classPrivateFieldGet(this, _FileUploader_generateId, "f").call(this);
                const fileState = {
                    id,
                    name: file.name,
                    file,
                    pending: true,
                    progress: 0
                };
                if (!this.multiple) {
                    this.fileStates.clear();
                }
                this.fileStates = new Map(this.fileStates.set(id, fileState));
                if (this.uploadFunction) {
                    try {
                        const uploadPromise = this.uploadFunction(file, progress => {
                            const state = this.fileStates.get(id);
                            if (state) {
                                const updatedState = Object.assign(Object.assign({}, state), { progress: progress, pending: progress < 100 });
                                this.fileStates = new Map(this.fileStates.set(id, updatedState));
                            }
                        });
                        // Store the upload promise/object for potential cancellation
                        const stateWithPromise = Object.assign(Object.assign({}, this.fileStates.get(id)), { uploadPromise });
                        this.fileStates = new Map(this.fileStates.set(id, stateWithPromise));
                        const result = await uploadPromise;
                        const state = this.fileStates.get(id);
                        if (state) {
                            if (result.success && result.remoteId) {
                                const updatedState = Object.assign(Object.assign({}, state), { remoteId: result.remoteId, pending: false, progress: 100 });
                                this.fileStates = new Map(this.fileStates.set(id, updatedState));
                                await ((_a = this.fileUploadedCallback) === null || _a === void 0 ? void 0 : _a.call(this, {
                                    name: state.name,
                                    originalName: state.file.name,
                                    remoteId: result.remoteId
                                }));
                            }
                            else {
                                const updatedState = Object.assign(Object.assign({}, state), { error: ((_b = result.errors) === null || _b === void 0 ? void 0 : _b.upload) || "Upload failed", pending: false });
                                this.fileStates = new Map(this.fileStates.set(id, updatedState));
                            }
                        }
                    }
                    catch (error) {
                        const state = this.fileStates.get(id);
                        if (state) {
                            const updatedState = Object.assign(Object.assign({}, state), { error: error instanceof Error
                                    ? error.message
                                    : "Unknown error occurred", pending: false });
                            this.fileStates = new Map(this.fileStates.set(id, updatedState));
                        }
                    }
                }
            });
            if (__classPrivateFieldGet(this, _FileUploader_fileInputEl, "f")) {
                __classPrivateFieldGet(this, _FileUploader_fileInputEl, "f").value = "";
            }
        });
        /** Handles file name change */
        _FileUploader_handleNameChange.set(this, async (event) => {
            var _a;
            const { id, name } = event.detail;
            const file = this.fileStates.get(id);
            if (file) {
                const updatedFile = Object.assign(Object.assign({}, file), { name: name.trim(), isEditing: false });
                this.fileStates = new Map(this.fileStates.set(id, updatedFile));
                await ((_a = this.fileRenamedCallback) === null || _a === void 0 ? void 0 : _a.call(this, { fileId: id, newName: name.trim() }));
            }
        });
        /** Handles individual file cancellation or deletion */
        _FileUploader_handleFileCancel.set(this, async (event) => {
            var _a, _b, _c, _d;
            const id = event.detail;
            const state = this.fileStates.get(id);
            if (state) {
                try {
                    if (state.pending) {
                        // Cancel upload in progress
                        if (state.uploadPromise &&
                            typeof state.uploadPromise.cancel === "function") {
                            state.uploadPromise.cancel();
                        }
                        else if (this.cancelUploadFunction) {
                            await this.cancelUploadFunction(id);
                        }
                        await ((_a = this.uploadCancelledCallback) === null || _a === void 0 ? void 0 : _a.call(this, id));
                        this.fileStates.delete(id);
                        this.fileStates = new Map(this.fileStates);
                    }
                    else {
                        const fileToDelete = {
                            name: state.name,
                            originalName: state.file.name,
                            remoteId: state.remoteId
                        };
                        const shouldDelete = await ((_b = this.onBeforeDelete) === null || _b === void 0 ? void 0 : _b.call(this, fileToDelete));
                        if (shouldDelete) {
                            await ((_c = this.fileDeletedCallback) === null || _c === void 0 ? void 0 : _c.call(this, fileToDelete));
                            this.fileStates.delete(id);
                            this.fileStates = new Map(this.fileStates);
                        }
                    }
                }
                catch (error) {
                    await ((_d = this.fileDeletionErrorCallback) === null || _d === void 0 ? void 0 : _d.call(this, {
                        fileName: state.name,
                        error: error instanceof Error ? error.message : "Unknown error occurred"
                    }));
                }
            }
        });
        /** Handles dialog confirmation */
        _FileUploader_handleConfirm.set(this, async () => {
            var _a;
            // Verificar si hay subidas en progreso
            const hasPendingUploads = Array.from(this.fileStates.values()).some(file => file.pending);
            if (hasPendingUploads) {
                return; // No permitir confirmar si hay subidas en progreso
            }
            // Obtener todos los archivos que están completamente subidos
            const uploadedFiles = Array.from(this.fileStates.values())
                .filter(file => {
                const isValid = !file.pending && file.remoteId && !file.error;
                return isValid;
            })
                .map(file => ({
                name: file.name,
                originalName: file.file.name,
                remoteId: file.remoteId
            }));
            if (uploadedFiles.length > 0) {
                await ((_a = this.dialogConfirmedCallback) === null || _a === void 0 ? void 0 : _a.call(this, uploadedFiles));
            }
            // Clear file states
            this.fileStates.clear();
            this.fileStates = new Map();
            // Reset file input
            if (__classPrivateFieldGet(this, _FileUploader_fileInputEl, "f")) {
                __classPrivateFieldGet(this, _FileUploader_fileInputEl, "f").value = "";
            }
        });
        /** Handles dialog cancellation */
        _FileUploader_handleCancel.set(this, async () => {
            var _a, _b, _c;
            try {
                // Cancelamos todas las subidas en progreso
                for (const [id, state] of this.fileStates.entries()) {
                    if (state.pending && this.cancelUploadFunction) {
                        try {
                            await this.cancelUploadFunction(id);
                            await ((_a = this.uploadCancelledCallback) === null || _a === void 0 ? void 0 : _a.call(this, id));
                        }
                        catch (error) {
                            // Error handling for upload cancellation
                        }
                    }
                }
                // Limpiamos todos los estados
                this.fileStates.clear();
                this.fileStates = new Map();
                if (__classPrivateFieldGet(this, _FileUploader_fileInputEl, "f")) {
                    __classPrivateFieldGet(this, _FileUploader_fileInputEl, "f").value = "";
                }
                await ((_b = this.dialogCanceledCallback) === null || _b === void 0 ? void 0 : _b.call(this));
            }
            catch (error) {
                this.fileStates.clear();
                this.fileStates = new Map();
                await ((_c = this.dialogCanceledCallback) === null || _c === void 0 ? void 0 : _c.call(this));
            }
        });
        this.types = [];
        this.multiple = false;
        this.canEditName = false;
        this.label = undefined;
        this.uploadFunction = undefined;
        this.cancelUploadFunction = undefined;
        this.fileUploadedCallback = undefined;
        this.dialogCanceledCallback = undefined;
        this.dialogConfirmedCallback = undefined;
        this.uploadCancelledCallback = undefined;
        this.fileRenamedCallback = undefined;
        this.fileValidationErrorCallback = undefined;
        this.fileDeletionErrorCallback = undefined;
        this.fileDeletedCallback = undefined;
        this.onBeforeDelete = undefined;
        this.fileStates = new Map();
        this.isDragging = false;
    }
    /** Initializes component with locale strings */
    async componentWillLoad() {
        __classPrivateFieldSet(this, _FileUploader__componentLocale, await Locale.getComponentStrings(this.el), "f");
    }
    /** Clears the current file selection */
    async clear() {
        var _a;
        for (const [id, state] of this.fileStates.entries()) {
            if (state.pending && this.cancelUploadFunction) {
                try {
                    await this.cancelUploadFunction(id);
                    await ((_a = this.uploadCancelledCallback) === null || _a === void 0 ? void 0 : _a.call(this, id));
                }
                catch (error) {
                    // Error handling for upload cancellation
                }
            }
        }
        this.fileStates.clear();
    }
    render() {
        var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
        return (h(Host, { class: "widget" }, h("ch-theme", { model: CSS_BUNDLES }), h("input", { type: "file", hidden: true, multiple: this.multiple, accept: (_a = this.types) === null || _a === void 0 ? void 0 : _a.map(type => (type.startsWith(".") ? type : `.${type}`)).join(","), onChange: __classPrivateFieldGet(this, _FileUploader_handleFileInput, "f"), ref: el => (__classPrivateFieldSet(this, _FileUploader_fileInputEl, el, "f")), "aria-hidden": "true", tabIndex: -1 }), h("div", { class: "file-uploader-dialog" }, h("div", { class: "dialog-content" }, this.isDragging || this.fileStates.size === 0 ? (h("div", { class: {
                "file-uploader__drop-zone elevation-1": true,
                "file-uploader__drop-zone--dragging": this.isDragging
            }, onDragEnter: __classPrivateFieldGet(this, _FileUploader_handleDragEnter, "f"), onDragLeave: __classPrivateFieldGet(this, _FileUploader_handleDragLeave, "f"), onDragOver: __classPrivateFieldGet(this, _FileUploader_handleDragOver, "f"), onDrop: __classPrivateFieldGet(this, _FileUploader_handleDrop, "f") }, h("button", { class: "button-tertiary button-icon-and-text", type: "button", onClick: __classPrivateFieldGet(this, _FileUploader_handleFileSelect, "f") }, h("ch-image", { class: "icon-m", src: PLUS_ICON }), h("label", { class: "label" }, this.multiple
            ? (_b = __classPrivateFieldGet(this, _FileUploader__componentLocale, "f")) === null || _b === void 0 ? void 0 : _b.header.uploadButtonMultiple
            : (_c = __classPrivateFieldGet(this, _FileUploader__componentLocale, "f")) === null || _c === void 0 ? void 0 : _c.header.uploadButtonSingle)), h("div", { class: "text-container" }, h("div", { class: "label-primary-row" }, h("label", { class: "label" }, this.label || ((_d = __classPrivateFieldGet(this, _FileUploader__componentLocale, "f")) === null || _d === void 0 ? void 0 : _d.header.orText)), h("label", { class: "label" }, (_e = __classPrivateFieldGet(this, _FileUploader__componentLocale, "f")) === null || _e === void 0 ? void 0 : _e.header.dragAndDrop)), h("span", { class: "caption" }, this.types && this.types.length > 0
            ? (_f = __classPrivateFieldGet(this, _FileUploader__componentLocale, "f")) === null || _f === void 0 ? void 0 : _f.header.acceptedFiles.replace("{0}", this.types.join(", "))
            : (_g = __classPrivateFieldGet(this, _FileUploader__componentLocale, "f")) === null || _g === void 0 ? void 0 : _g.header.allFilesAccepted)))) : (h("div", { class: "file-uploader__list" }, h("div", { class: "file-uploader__list-header elevation-1 spacing-body-block-end spacing-inline-end" }, h("div", { class: "file-uploader__list-title-container" }, h("label", { class: "label" }, this.label ||
            ((_h = __classPrivateFieldGet(this, _FileUploader__componentLocale, "f")) === null || _h === void 0 ? void 0 : _h.fileList.attachedFiles)), h("span", { class: "caption" }, (_j = __classPrivateFieldGet(this, _FileUploader__componentLocale, "f")) === null || _j === void 0 ? void 0 : _j.fileList.filesCount.replace("{0}", this.fileStates.size.toString()))), this.multiple && (h("button", { class: "button-tertiary button-icon-and-text", type: "button", onClick: __classPrivateFieldGet(this, _FileUploader_handleFileSelect, "f") }, h("ch-image", { class: "icon-m", src: PLUS_ICON }), h("label", { class: "label" }, this.multiple
            ? (_k = __classPrivateFieldGet(this, _FileUploader__componentLocale, "f")) === null || _k === void 0 ? void 0 : _k.header.uploadButtonMultiple
            : (_l = __classPrivateFieldGet(this, _FileUploader__componentLocale, "f")) === null || _l === void 0 ? void 0 : _l.header.uploadButtonSingle)))), h("ul", { class: "file-uploader__list-content scrollable spacing-inline-end spacing-block-end", "aria-live": "polite", "aria-label": (_m = __classPrivateFieldGet(this, _FileUploader__componentLocale, "f")) === null || _m === void 0 ? void 0 : _m.fileList.selectedFilesAriaLabel }, Array.from(this.fileStates.values()).map(file => (h("gx-ide-file-item", { key: file.id, file: file, editable: this.canEditName, componentLocale: __classPrivateFieldGet(this, _FileUploader__componentLocale, "f"), onFileNameChange: __classPrivateFieldGet(this, _FileUploader_handleNameChange, "f"), onFileDelete: __classPrivateFieldGet(this, _FileUploader_handleFileCancel, "f"), onFileCancel: __classPrivateFieldGet(this, _FileUploader_handleFileCancel, "f") }))))))), h("div", { class: {
                "dialog-footer": true,
                "dialog-footer-with-border": this.fileStates.size > 0
            } }, h("div", { class: "buttons-spacer" }, h("button", { class: "button-secondary", type: "button", onClick: __classPrivateFieldGet(this, _FileUploader_handleCancel, "f") }, (_o = __classPrivateFieldGet(this, _FileUploader__componentLocale, "f")) === null || _o === void 0 ? void 0 : _o.buttons.cancel), h("button", { class: "button-primary", type: "button", onClick: __classPrivateFieldGet(this, _FileUploader_handleConfirm, "f"), disabled: this.fileStates.size === 0 ||
                Array.from(this.fileStates.values()).some(file => file.pending) }, (_p = __classPrivateFieldGet(this, _FileUploader__componentLocale, "f")) === null || _p === void 0 ? void 0 : _p.buttons.confirm))))));
    }
    static get assetsDirs() { return ["gx-ide-assets/file-uploader"]; }
    get el() { return this; }
    static get style() { return fileUploaderCss; }
}, [1, "gx-ide-file-uploader", {
        "types": [16],
        "multiple": [4],
        "canEditName": [4, "can-edit-name"],
        "label": [1],
        "uploadFunction": [16],
        "cancelUploadFunction": [16],
        "fileUploadedCallback": [16],
        "dialogCanceledCallback": [16],
        "dialogConfirmedCallback": [16],
        "uploadCancelledCallback": [16],
        "fileRenamedCallback": [16],
        "fileValidationErrorCallback": [16],
        "fileDeletionErrorCallback": [16],
        "fileDeletedCallback": [16],
        "onBeforeDelete": [16],
        "fileStates": [32],
        "isDragging": [32],
        "clear": [64]
    }]);
_FileUploader__componentLocale = new WeakMap(), _FileUploader_fileInputEl = new WeakMap(), _FileUploader_dragCounter = new WeakMap(), _FileUploader_generateId = new WeakMap(), _FileUploader_handleDragEnter = new WeakMap(), _FileUploader_handleDragLeave = new WeakMap(), _FileUploader_handleDragOver = new WeakMap(), _FileUploader_handleDrop = new WeakMap(), _FileUploader_handleFileSelect = new WeakMap(), _FileUploader_handleFileInput = new WeakMap(), _FileUploader_handleFiles = new WeakMap(), _FileUploader_handleNameChange = new WeakMap(), _FileUploader_handleFileCancel = new WeakMap(), _FileUploader_handleConfirm = new WeakMap(), _FileUploader_handleCancel = new WeakMap(), _FileUploader_instances = new WeakSet(), _FileUploader_isValidFile = function _FileUploader_isValidFile(file) {
    var _a, _b;
    // If no types specified, accept any file
    if (!this.types || this.types.length === 0) {
        return { isValid: true };
    }
    for (const type of this.types) {
        // Handle wildcards like 'image/*'
        if (type.includes("/*")) {
            const baseType = type.split("/")[0];
            if (file.type.startsWith(baseType)) {
                return { isValid: true };
            }
        }
        // Handle extensions like '.jpg'
        else if (type.startsWith(".")) {
            if (file.name.toLowerCase().endsWith(type.toLowerCase())) {
                return { isValid: true };
            }
        }
        // Handle specific MIME types
        else if (file.type === type || file.type === `application/${type}`) {
            return { isValid: true };
        }
    }
    return {
        isValid: false,
        error: ((_b = (_a = __classPrivateFieldGet(this, _FileUploader__componentLocale, "f")) === null || _a === void 0 ? void 0 : _a.errors) === null || _b === void 0 ? void 0 : _b.invalidFileType) || "Invalid file type"
    };
}, _FileUploader_getValidFiles = function _FileUploader_getValidFiles(files) {
    const validFiles = [];
    Array.from(files).forEach(file => {
        var _a;
        const validation = __classPrivateFieldGet(this, _FileUploader_instances, "m", _FileUploader_isValidFile).call(this, file);
        if (validation.isValid) {
            validFiles.push(file);
        }
        else {
            (_a = this.fileValidationErrorCallback) === null || _a === void 0 ? void 0 : _a.call(this, {
                fileName: file.name,
                error: validation.error
            });
        }
    });
    return validFiles;
};
function defineCustomElement$1() {
    if (typeof customElements === "undefined") {
        return;
    }
    const components = ["gx-ide-file-uploader", "gx-ide-file-item"];
    components.forEach(tagName => { switch (tagName) {
        case "gx-ide-file-uploader":
            if (!customElements.get(tagName)) {
                customElements.define(tagName, FileUploader);
            }
            break;
        case "gx-ide-file-item":
            if (!customElements.get(tagName)) {
                defineCustomElement$2();
            }
            break;
    } });
}

const GxIdeFileUploader = FileUploader;
const defineCustomElement = defineCustomElement$1;

export { GxIdeFileUploader, defineCustomElement };

//# sourceMappingURL=gx-ide-file-uploader.js.map