import * as i0 from '@angular/core';
import { Injectable, inject, EventEmitter, Component, ViewChild, Input, Output, HostListener, NgModule } from '@angular/core';
import { DomSanitizer } from '@angular/platform-browser';
import { TranslateService, TranslatePipe } from '@ngx-translate/core';
import * as i1 from '@seniorsistemas/angular-components/common/deprecated-selector';
import { DEPRECATED_CONFIG, DeprecatedSelectorDirective } from '@seniorsistemas/angular-components/common/deprecated-selector';
import { isNullOrUndefined, Breakpoints } from '@seniorsistemas/angular-components/utils';
import moment from 'moment';
import { Subject } from 'rxjs';
import { CustomHttpClient } from '@seniorsistemas/angular-components/common';
import { ButtonComponent } from '@seniorsistemas/angular-components/button';
import { NgTemplateOutlet } from '@angular/common';
import { ProgressBarComponent } from '@seniorsistemas/angular-components/progressbar';
import { Tooltip } from 'primeng/tooltip';

class FilePickerService {
    BASE_URL_FIELD_CUSTOMIZATION = 'platform/field_customization';
    TOKEN = new AbortController();
    async getMetadataCustomField(request) {
        return CustomHttpClient.post(`${this.BASE_URL_FIELD_CUSTOMIZATION}/queries/getFileMetadata`, request, {
            signal: this.TOKEN.signal,
        });
    }
    static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: FilePickerService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
    static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: FilePickerService });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: FilePickerService, decorators: [{
            type: Injectable
        }] });

const ALL_PERMISSIONS = ['add', 'read', 'remove'];

/**
 * @description Componente de upload de arquivos com suporte a seleção múltipla,
 * validação de tipo/tamanho, controle de permissões (adicionar, ler, remover),
 * download e cancelamento de uploads em andamento.
 *
 * @example
 * ```html
 * <s-file-picker
 *   [multiple]="true"
 *   accept="application/pdf"
 *   [maxFileSize]="5242880"
 *   [files]="arquivos"
 *   (uploadHandler)="onUpload($event)"
 *   (removeFile)="onRemove($event)" />
 * ```
 *
 * @category Inputs
 */
class FilePickerComponent {
    sanitizer = inject(DomSanitizer);
    filePickerService = inject(FilePickerService);
    translate = inject(TranslateService);
    static nextId = 0;
    ADD_PERMISSION = 'add';
    READ_PERMISSION = 'read';
    REMOVE_PERMISSION = 'remove';
    inputUpload = null;
    anchor = null;
    /** @description Identificador do componente no DOM. Gerado automaticamente se não informado. */
    id = `s-file-picker-${FilePickerComponent.nextId++}`;
    /** @description Rótulo do botão de seleção de arquivo. */
    chooseLabel;
    /** @description Rótulo do botão de remoção de arquivo. */
    removeLabel;
    /** @description Rótulo do botão de cancelamento de upload. */
    cancelLabel;
    /** @description Texto do tooltip exibido após upload bem-sucedido. */
    successTooltip;
    /** @description Permite selecionar múltiplos arquivos ao mesmo tempo. */
    multiple;
    /** @description Tipos MIME aceitos pelo seletor de arquivo (ex.: `'application/pdf,image/*'`). */
    accept;
    /** @description Lista de extensões de arquivo aceitas para validação (ex.: `['.pdf', '.docx']`). @default [] */
    supportedExtensions = [];
    /** @description Label ARIA para o nome do arquivo, para leitores de tela. */
    ariaLabelFileName;
    /** @description Tamanho máximo por arquivo em bytes. */
    maxFileSize;
    /** @description Tamanho máximo combinado de todos os arquivos em bytes. */
    maxCombinedFileSize;
    /** @description Número máximo de arquivos que podem ser selecionados. */
    fileLimit;
    /** @description Label ARIA para a barra de progresso do upload. */
    ariaLabelProgress;
    /** @description Label ARIA para o ícone de sucesso. */
    ariaLabelSuccess;
    /** @description Label ARIA para mensagens de erro de validação. */
    ariaLabelError;
    /** @description Label ARIA para o botão de remoção de arquivo. */
    ariaLabelRemove;
    /** @description FormControl externo vinculado ao componente para controle de estado. */
    formControl;
    /** @description Desabilita todas as interações do componente. @default false */
    disabled = false;
    /** @description Exibe a data de upload de cada arquivo. @default false */
    showFileUploadDate = false;
    /** @description Lista de permissões habilitadas no componente: `'add'`, `'read'`, `'remove'`. @default ALL_PERMISSIONS */
    permissions = ALL_PERMISSIONS;
    /**
     * @description Lista de arquivos já enviados a serem exibidos no componente.
     * Ao atribuir, os arquivos são processados e suas URLs são geradas para preview.
     */
    set files(files) {
        if (!files || files?.length === 0) {
            this._files = [];
            return;
        }
        if (this.showFileUploadDate && files[0]?.objectId) {
            this.getUploadDate(files);
        }
        this._files = files.map((file) => {
            file.objectURL = this.sanitizer.bypassSecurityTrustUrl(window.URL.createObjectURL(file));
            return file;
        });
    }
    /** @description Emitido quando o usuário seleciona arquivos válidos para upload. */
    uploadHandler = new EventEmitter();
    /** @description Emitido quando o usuário remove um arquivo da lista. */
    removeFile = new EventEmitter();
    /** @description Emitido quando o usuário cancela um upload em andamento. Emite o índice do arquivo cancelado. */
    cancelUpload = new EventEmitter();
    /** @description Emitido quando o usuário clica para baixar um arquivo. */
    downloadFile = new EventEmitter();
    /** @description Emitido quando um arquivo não passa na validação de tipo, tamanho ou limite. */
    validateErrors = new EventEmitter();
    _files = [];
    ngUsubscribe = new Subject();
    isSmallDevice = false;
    inputValue = '';
    modifiedDate;
    ngOnInit() {
        this.supportedExtensions = this.supportedExtensions.map((extension) => extension.replace('.', '').toLowerCase());
    }
    ngOnDestroy() {
        this.ngUsubscribe.next();
        this.ngUsubscribe.complete();
    }
    ngAfterContentInit() {
        this.update();
    }
    onResize() {
        this.update();
    }
    _onInputFileSelect($event) {
        const eventTargetFiles = $event.target?.files;
        const dataTransferFiles = $event.dataTransfer?.files;
        const files = Array.from(dataTransferFiles ? dataTransferFiles : eventTargetFiles);
        this.onFileSelect(files);
    }
    onFileSelect(files) {
        const newFiles = [];
        if (!this.multiple) {
            this.files = [];
        }
        if (this.isFileLimitExceeded(files)) {
            this.validateErrors.emit({
                files,
                validation: 'maxFileLimit',
            });
            this.clearFileInput();
            return;
        }
        if (this.isFileCombinedSizeExceeded(files)) {
            this.validateErrors.emit({
                files: files,
                validation: 'maxCombinedFileSize',
            });
            this.clearFileInput();
            return;
        }
        for (const file of files) {
            if (this.isUnsupportedFileExtension(file)) {
                this.validateErrors.emit({
                    files: [file],
                    validation: 'unsupportedExtension',
                });
                continue;
            }
            if (this.isFileSizeExceeded(file)) {
                this.validateErrors.emit({
                    files: [file],
                    validation: 'maxFileSize',
                });
                continue;
            }
            newFiles.push(file);
        }
        if (newFiles.length) {
            this.files = this.files.concat(newFiles);
            this.uploadHandler.emit({
                files: newFiles,
            });
        }
        this.clearFileInput();
    }
    onRemoveFile(file) {
        const fileIndex = this.files.indexOf(file);
        const removedFiles = this.files.splice(fileIndex, 1);
        if (removedFiles.length) {
            this.removeFile.emit({ file });
        }
    }
    onCancelUpload(index) {
        const removedFiles = this.files.splice(index, 1);
        if (removedFiles.length) {
            this.cancelUpload.emit(index);
        }
        this.clearFileInput();
    }
    onDowloadFile(index) {
        if (isNullOrUndefined(this.anchor))
            return;
        this.downloadFile.emit({
            index,
            anchor: this.anchor,
        });
    }
    get files() {
        return this._files;
    }
    formatFileSize(size) {
        if (size === 0) {
            return '0 Bytes';
        }
        const k = 1024;
        const sizes = ['bytes', 'KB', 'MB', 'GB', 'TB'];
        const i = Math.floor(Math.log(size) / Math.log(k));
        return parseFloat((size / Math.pow(k, i)).toFixed(2)) + ' ' + sizes[i];
    }
    update() {
        const windowWidth = window.innerWidth;
        this.isSmallDevice = windowWidth <= Breakpoints.SM_MAX;
    }
    isFileLimitExceeded(files) {
        if (!this.fileLimit) {
            return false;
        }
        return this.files.length + files.length > this.fileLimit;
    }
    isFileCombinedSizeExceeded(files) {
        if (!this.maxCombinedFileSize) {
            return false;
        }
        const filesList = [...files, ...this.files];
        const combinedSize = filesList.reduce((combinedSize, file) => combinedSize + file.size, 0);
        return combinedSize > this.maxCombinedFileSize;
    }
    isFileSizeExceeded(file) {
        if (!this.maxFileSize) {
            return false;
        }
        return file.size > this.maxFileSize;
    }
    isUnsupportedFileExtension(file) {
        if (this.supportedExtensions?.length) {
            const extension = file.name.split('.').pop()?.toLowerCase() ?? '';
            return !this.supportedExtensions.includes(extension);
        }
        return false;
    }
    clearFileInput() {
        if (isNullOrUndefined(this.inputUpload?.nativeElement))
            return;
        this.inputUpload.nativeElement.value = null;
    }
    getUploadDate(blobFile) {
        if (!blobFile) {
            return;
        }
        this.filePickerService
            .getMetadataCustomField({ objectId: blobFile[0].objectId ?? '' })
            .then((metadata) => this.setModifiedDate(metadata));
    }
    setModifiedDate(metadata) {
        const hour = moment(metadata.modified).format('HH');
        const minutes = moment(metadata.modified).format('mm');
        const day = moment(metadata.modified).format('DD');
        const month = moment(metadata.modified).format('MM');
        const fullYear = moment(metadata.modified).format('YYYY');
        this.modifiedDate = this.translate.instant('platform.angular_components.date_modified_custom_blob', {
            hour,
            minutes,
            day,
            month,
            fullYear,
        });
    }
    static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: FilePickerComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
    static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "18.2.14", type: FilePickerComponent, isStandalone: true, selector: "s-file-picker, s-file-upload", inputs: { id: "id", chooseLabel: "chooseLabel", removeLabel: "removeLabel", cancelLabel: "cancelLabel", successTooltip: "successTooltip", multiple: "multiple", accept: "accept", supportedExtensions: "supportedExtensions", ariaLabelFileName: "ariaLabelFileName", maxFileSize: "maxFileSize", maxCombinedFileSize: "maxCombinedFileSize", fileLimit: "fileLimit", ariaLabelProgress: "ariaLabelProgress", ariaLabelSuccess: "ariaLabelSuccess", ariaLabelError: "ariaLabelError", ariaLabelRemove: "ariaLabelRemove", formControl: "formControl", disabled: "disabled", showFileUploadDate: "showFileUploadDate", permissions: "permissions", files: "files" }, outputs: { uploadHandler: "uploadHandler", removeFile: "removeFile", cancelUpload: "cancelUpload", downloadFile: "downloadFile", validateErrors: "validateErrors" }, host: { listeners: { "window:resize": "onResize()" } }, providers: [
            {
                provide: DEPRECATED_CONFIG,
                useValue: {
                    oldSelector: 's-file-upload',
                    newSelector: 's-file-picker',
                    removalVersion: '20.0.0',
                },
            },
        ], viewQueries: [{ propertyName: "inputUpload", first: true, predicate: ["inputUpload"], descendants: true }, { propertyName: "anchor", first: true, predicate: ["anchor"], descendants: true }], hostDirectives: [{ directive: i1.DeprecatedSelectorDirective }], ngImport: i0, template: "<div\n    [id]=\"id\"\n    class=\"file-picker\"\n>\n    <div class=\"file-picker-choose\">\n        <input\n            #inputUpload\n            [id]=\"id + 'input-upload'\"\n            type=\"file\"\n            name=\"file\"\n            [accept]=\"accept\"\n            [multiple]=\"multiple\"\n            (change)=\"_onInputFileSelect($event)\"\n        />\n        @if (permissions.includes(ADD_PERMISSION)) {\n            <s-button\n                [id]=\"id + 'upload-button'\"\n                [label]=\"chooseLabel || 'platform.angular_components.attach_files' | translate\"\n                (clicked)=\"inputUpload.click()\"\n                priority=\"primary\"\n                [disabled]=\"disabled || !!formControl?.disabled || fileLimit === files.length\"\n                [auxiliary]=\"false\"\n            >\n            </s-button>\n        }\n    </div>\n\n    @if (files.length) {\n        <section\n            [id]=\"id + 'fileupload-list'\"\n            class=\"file-picker-list\"\n            role=\"grid\"\n        >\n            @for (file of files; track file; let i = $index) {\n                <div\n                    class=\"file-picker-list-file\"\n                    role=\"row\"\n                >\n                    <div\n                        [id]=\"id + '-file-' + i + '-name'\"\n                        class=\"flex flex-grow items-center justify-between overflow-hidden text-ellipsis text-nowrap\"\n                        role=\"gridcell\"\n                    >\n                        <ng-container\n                            *ngTemplateOutlet=\"\n                                (permissions.includes(READ_PERMISSION) && file.savedFile) || file.progress === 100\n                                    ? descriptionUrl\n                                    : description;\n                                context: {\n                                    $implicit: file,\n                                    index: i,\n                                }\n                            \"\n                        >\n                        </ng-container>\n\n                        <span>{{ formatFileSize(file.size) }}</span>\n\n                        @if (modifiedDate) {\n                            <span class=\"file-picker-list-file-name-date\">{{ modifiedDate }}</span>\n                        }\n                    </div>\n                    <div\n                        class=\"file-picker-list-file-status\"\n                        role=\"gridcell\"\n                    >\n                        @if (file.isUploading && !isSmallDevice) {\n                            <div class=\"w-64\">\n                                <s-progressbar\n                                    [value]=\"file.progress ?? 0\"\n                                    [showValue]=\"false\"\n                                    activeColor=\"blue\"\n                                ></s-progressbar>\n                            </div>\n                        }\n\n                        @if (file.isUploading && isSmallDevice) {\n                            <span\n                                [id]=\"id + '-file-' + i + '-spin'\"\n                                class=\"fas fa-circle-notch fa-spin\"\n                                [attr.aria-label]=\"\n                                    ariaLabelProgress || 'platform.angular_components.loading_file' | translate\n                                \"\n                            >\n                            </span>\n                        }\n\n                        @if (!file.isUploading && !file.error && file.progress === 100) {\n                            <span\n                                [id]=\"id + '-file-' + i + '-check'\"\n                                class=\"fas fa-check\"\n                                role=\"alert\"\n                                [attr.aria-label]=\"\n                                    ariaLabelSuccess ||\n                                        successTooltip ||\n                                        'platform.angular_components.file_attached_successfully' | translate\n                                \"\n                                [pTooltip]=\"\n                                    successTooltip || 'platform.angular_components.file_attached_successfully'\n                                        | translate\n                                \"\n                                tooltipPosition=\"top\"\n                                showDelay=\"500\"\n                                [appendTo]=\"'body'\"\n                            >\n                            </span>\n                        }\n\n                        @if (file.error?.message) {\n                            <span\n                                [id]=\"id + '-file-' + i + '-error'\"\n                                class=\"fas fa-times\"\n                                role=\"alert\"\n                                [pTooltip]=\"file.error?.message\"\n                                tooltipPosition=\"top\"\n                                showDelay=\"500\"\n                                [appendTo]=\"'body'\"\n                            >\n                            </span>\n                        }\n                    </div>\n                    <div\n                        class=\"file-picker-list-file-actions\"\n                        role=\"gridcell\"\n                    >\n                        @if (file.isUploading) {\n                            <a\n                                [id]=\"id + '-file-' + i + '-cancel'\"\n                                class=\"file-picker-list-file-actions-action\"\n                                (click)=\"onCancelUpload(i)\"\n                            >\n                                {{ cancelLabel || 'platform.angular_components.cancel' | translate }}\n                            </a>\n                        }\n\n                        @if (\n                            permissions.includes(REMOVE_PERMISSION) &&\n                            !file.isUploading &&\n                            !(disabled || !!formControl?.disabled)\n                        ) {\n                            <a\n                                role=\"button\"\n                                tabindex=\"0\"\n                                [id]=\"id + '-file-' + i + '-remove'\"\n                                class=\"file-picker-list-file-actions-action\"\n                                (click)=\"onRemoveFile(file)\"\n                                [attr.aria-label]=\"\n                                    ariaLabelRemove || removeLabel || 'platform.angular_components.remove' | translate\n                                \"\n                            >\n                                {{ removeLabel || 'platform.angular_components.remove' | translate }}\n                            </a>\n                        }\n                    </div>\n                </div>\n            }\n        </section>\n    }\n</div>\n\n<ng-template\n    #descriptionUrl\n    let-file\n    let-i=\"index\"\n>\n    <div class=\"flex justify-between\">\n        <div>\n            <a\n                [id]=\"id + '-file-' + i + '-name-link'\"\n                tabindex=\"0\"\n                (click)=\"onDowloadFile(i)\"\n                [attr.aria-label]=\"ariaLabelFileName || file.name\"\n                class=\"break-words\"\n                >{{ file.name }}\n            </a>\n            <a\n                style=\"display: none\"\n                [href]=\"file.objectURL\"\n                target=\"_blank\"\n                download\n                #anchor\n            >\n            </a>\n        </div>\n    </div>\n</ng-template>\n\n<ng-template\n    #description\n    let-file\n>\n    <div class=\"flex justify-between\">\n        <span\n            tabindex=\"0\"\n            [attr.aria-label]=\"ariaLabelFileName || file.name\"\n        >\n            {{ file.name }}\n        </span>\n    </div>\n</ng-template>\n\n", styles: [".file-picker .file-picker-choose{position:relative;margin:15px 0;width:max-content}.file-picker input[type=file]{display:none}.file-picker-list{border:1px solid #ccc}.file-picker-list-file:not(:first-child){border-top:1px solid #ccc}.file-picker-list .file-picker-list-file{display:flex;flex-direction:row;flex-wrap:wrap;justify-content:space-between;padding:15px}.file-picker-list .file-picker-list-file .file-picker-list-file-name{display:flex;flex-direction:column;align-self:center;text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.file-picker-list .file-picker-list-file .file-picker-list-file-name .file-picker-list-file-name-date{font-size:.75rem;color:#999}.file-picker-list .file-picker-list-file .file-picker-list-file-name>a{cursor:pointer;text-decoration:none}.file-picker-list .file-picker-list-file .file-picker-list-file-status{align-self:center}.file-picker-list .file-picker-list-file .fas.fa-circle-notch{color:#d8d8d8;font-size:12px}.file-picker-list .file-picker-list-file .fas.fa-check{color:#0c9348;font-size:12px}.file-picker-list .file-picker-list-file .fas.fa-times{color:#c13018;font-size:12px}.file-picker-list .file-picker-list-file .file-picker-list-file-actions{margin-top:15px;align-self:center;width:100%}.file-picker-list .file-picker-list-file .file-picker-list-file-actions a.file-picker-list-file-actions-action{text-decoration:none;color:#428bca}.file-picker-list .file-picker-list-file .file-picker-list-file-actions a.file-picker-list-file-actions-action:hover,.file-picker-list .file-picker-list-file .file-picker-list-file-actions a.file-picker-list-file-actions-action :focus,.file-picker-list .file-picker-list-file .file-picker-list-file-actions a.file-picker-list-file-actions-action :visited{text-decoration:none}@media (min-width: 768px){.file-picker-list .file-picker-list-file{flex-wrap:nowrap}.file-picker-list .file-picker-list-file .file-picker-list-file-name{width:auto;flex-grow:2}.file-picker-list .file-picker-list-file .file-picker-list-file-status{margin:0 15px}.file-picker-list .file-picker-list-file .file-picker-list-file-actions{margin:0;width:auto}}\n"], dependencies: [{ kind: "component", type: ButtonComponent, selector: "s-button", inputs: ["id", "label", "tooltip", "tooltipPosition", "iconClass", "rightIconClass", "caret", "styleClass", "baseZIndex", "disabled", "auxiliary", "type", "priority", "menuOptions", "size", "slide", "animation", "badge", "iconColor", "menuAriaLabel", "ariaLabel"], outputs: ["clicked"] }, { kind: "directive", type: NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "component", type: ProgressBarComponent, selector: "s-progressbar", inputs: ["value", "activeColor", "numberFormatOptions", "targetValue", "label", "targetLabel", "showValue", "mode"] }, { kind: "directive", type: Tooltip, selector: "[pTooltip]", inputs: ["tooltipPosition", "tooltipEvent", "appendTo", "positionStyle", "tooltipStyleClass", "tooltipZIndex", "escape", "showDelay", "hideDelay", "life", "positionTop", "positionLeft", "autoHide", "fitContent", "hideOnEscape", "pTooltip", "tooltipDisabled", "tooltipOptions"] }, { kind: "pipe", type: TranslatePipe, name: "translate" }] });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: FilePickerComponent, decorators: [{
            type: Component,
            args: [{ selector: 's-file-picker, s-file-upload', hostDirectives: [DeprecatedSelectorDirective], providers: [
                        {
                            provide: DEPRECATED_CONFIG,
                            useValue: {
                                oldSelector: 's-file-upload',
                                newSelector: 's-file-picker',
                                removalVersion: '20.0.0',
                            },
                        },
                    ], standalone: true, imports: [ButtonComponent, NgTemplateOutlet, ProgressBarComponent, Tooltip, TranslatePipe], template: "<div\n    [id]=\"id\"\n    class=\"file-picker\"\n>\n    <div class=\"file-picker-choose\">\n        <input\n            #inputUpload\n            [id]=\"id + 'input-upload'\"\n            type=\"file\"\n            name=\"file\"\n            [accept]=\"accept\"\n            [multiple]=\"multiple\"\n            (change)=\"_onInputFileSelect($event)\"\n        />\n        @if (permissions.includes(ADD_PERMISSION)) {\n            <s-button\n                [id]=\"id + 'upload-button'\"\n                [label]=\"chooseLabel || 'platform.angular_components.attach_files' | translate\"\n                (clicked)=\"inputUpload.click()\"\n                priority=\"primary\"\n                [disabled]=\"disabled || !!formControl?.disabled || fileLimit === files.length\"\n                [auxiliary]=\"false\"\n            >\n            </s-button>\n        }\n    </div>\n\n    @if (files.length) {\n        <section\n            [id]=\"id + 'fileupload-list'\"\n            class=\"file-picker-list\"\n            role=\"grid\"\n        >\n            @for (file of files; track file; let i = $index) {\n                <div\n                    class=\"file-picker-list-file\"\n                    role=\"row\"\n                >\n                    <div\n                        [id]=\"id + '-file-' + i + '-name'\"\n                        class=\"flex flex-grow items-center justify-between overflow-hidden text-ellipsis text-nowrap\"\n                        role=\"gridcell\"\n                    >\n                        <ng-container\n                            *ngTemplateOutlet=\"\n                                (permissions.includes(READ_PERMISSION) && file.savedFile) || file.progress === 100\n                                    ? descriptionUrl\n                                    : description;\n                                context: {\n                                    $implicit: file,\n                                    index: i,\n                                }\n                            \"\n                        >\n                        </ng-container>\n\n                        <span>{{ formatFileSize(file.size) }}</span>\n\n                        @if (modifiedDate) {\n                            <span class=\"file-picker-list-file-name-date\">{{ modifiedDate }}</span>\n                        }\n                    </div>\n                    <div\n                        class=\"file-picker-list-file-status\"\n                        role=\"gridcell\"\n                    >\n                        @if (file.isUploading && !isSmallDevice) {\n                            <div class=\"w-64\">\n                                <s-progressbar\n                                    [value]=\"file.progress ?? 0\"\n                                    [showValue]=\"false\"\n                                    activeColor=\"blue\"\n                                ></s-progressbar>\n                            </div>\n                        }\n\n                        @if (file.isUploading && isSmallDevice) {\n                            <span\n                                [id]=\"id + '-file-' + i + '-spin'\"\n                                class=\"fas fa-circle-notch fa-spin\"\n                                [attr.aria-label]=\"\n                                    ariaLabelProgress || 'platform.angular_components.loading_file' | translate\n                                \"\n                            >\n                            </span>\n                        }\n\n                        @if (!file.isUploading && !file.error && file.progress === 100) {\n                            <span\n                                [id]=\"id + '-file-' + i + '-check'\"\n                                class=\"fas fa-check\"\n                                role=\"alert\"\n                                [attr.aria-label]=\"\n                                    ariaLabelSuccess ||\n                                        successTooltip ||\n                                        'platform.angular_components.file_attached_successfully' | translate\n                                \"\n                                [pTooltip]=\"\n                                    successTooltip || 'platform.angular_components.file_attached_successfully'\n                                        | translate\n                                \"\n                                tooltipPosition=\"top\"\n                                showDelay=\"500\"\n                                [appendTo]=\"'body'\"\n                            >\n                            </span>\n                        }\n\n                        @if (file.error?.message) {\n                            <span\n                                [id]=\"id + '-file-' + i + '-error'\"\n                                class=\"fas fa-times\"\n                                role=\"alert\"\n                                [pTooltip]=\"file.error?.message\"\n                                tooltipPosition=\"top\"\n                                showDelay=\"500\"\n                                [appendTo]=\"'body'\"\n                            >\n                            </span>\n                        }\n                    </div>\n                    <div\n                        class=\"file-picker-list-file-actions\"\n                        role=\"gridcell\"\n                    >\n                        @if (file.isUploading) {\n                            <a\n                                [id]=\"id + '-file-' + i + '-cancel'\"\n                                class=\"file-picker-list-file-actions-action\"\n                                (click)=\"onCancelUpload(i)\"\n                            >\n                                {{ cancelLabel || 'platform.angular_components.cancel' | translate }}\n                            </a>\n                        }\n\n                        @if (\n                            permissions.includes(REMOVE_PERMISSION) &&\n                            !file.isUploading &&\n                            !(disabled || !!formControl?.disabled)\n                        ) {\n                            <a\n                                role=\"button\"\n                                tabindex=\"0\"\n                                [id]=\"id + '-file-' + i + '-remove'\"\n                                class=\"file-picker-list-file-actions-action\"\n                                (click)=\"onRemoveFile(file)\"\n                                [attr.aria-label]=\"\n                                    ariaLabelRemove || removeLabel || 'platform.angular_components.remove' | translate\n                                \"\n                            >\n                                {{ removeLabel || 'platform.angular_components.remove' | translate }}\n                            </a>\n                        }\n                    </div>\n                </div>\n            }\n        </section>\n    }\n</div>\n\n<ng-template\n    #descriptionUrl\n    let-file\n    let-i=\"index\"\n>\n    <div class=\"flex justify-between\">\n        <div>\n            <a\n                [id]=\"id + '-file-' + i + '-name-link'\"\n                tabindex=\"0\"\n                (click)=\"onDowloadFile(i)\"\n                [attr.aria-label]=\"ariaLabelFileName || file.name\"\n                class=\"break-words\"\n                >{{ file.name }}\n            </a>\n            <a\n                style=\"display: none\"\n                [href]=\"file.objectURL\"\n                target=\"_blank\"\n                download\n                #anchor\n            >\n            </a>\n        </div>\n    </div>\n</ng-template>\n\n<ng-template\n    #description\n    let-file\n>\n    <div class=\"flex justify-between\">\n        <span\n            tabindex=\"0\"\n            [attr.aria-label]=\"ariaLabelFileName || file.name\"\n        >\n            {{ file.name }}\n        </span>\n    </div>\n</ng-template>\n\n", styles: [".file-picker .file-picker-choose{position:relative;margin:15px 0;width:max-content}.file-picker input[type=file]{display:none}.file-picker-list{border:1px solid #ccc}.file-picker-list-file:not(:first-child){border-top:1px solid #ccc}.file-picker-list .file-picker-list-file{display:flex;flex-direction:row;flex-wrap:wrap;justify-content:space-between;padding:15px}.file-picker-list .file-picker-list-file .file-picker-list-file-name{display:flex;flex-direction:column;align-self:center;text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.file-picker-list .file-picker-list-file .file-picker-list-file-name .file-picker-list-file-name-date{font-size:.75rem;color:#999}.file-picker-list .file-picker-list-file .file-picker-list-file-name>a{cursor:pointer;text-decoration:none}.file-picker-list .file-picker-list-file .file-picker-list-file-status{align-self:center}.file-picker-list .file-picker-list-file .fas.fa-circle-notch{color:#d8d8d8;font-size:12px}.file-picker-list .file-picker-list-file .fas.fa-check{color:#0c9348;font-size:12px}.file-picker-list .file-picker-list-file .fas.fa-times{color:#c13018;font-size:12px}.file-picker-list .file-picker-list-file .file-picker-list-file-actions{margin-top:15px;align-self:center;width:100%}.file-picker-list .file-picker-list-file .file-picker-list-file-actions a.file-picker-list-file-actions-action{text-decoration:none;color:#428bca}.file-picker-list .file-picker-list-file .file-picker-list-file-actions a.file-picker-list-file-actions-action:hover,.file-picker-list .file-picker-list-file .file-picker-list-file-actions a.file-picker-list-file-actions-action :focus,.file-picker-list .file-picker-list-file .file-picker-list-file-actions a.file-picker-list-file-actions-action :visited{text-decoration:none}@media (min-width: 768px){.file-picker-list .file-picker-list-file{flex-wrap:nowrap}.file-picker-list .file-picker-list-file .file-picker-list-file-name{width:auto;flex-grow:2}.file-picker-list .file-picker-list-file .file-picker-list-file-status{margin:0 15px}.file-picker-list .file-picker-list-file .file-picker-list-file-actions{margin:0;width:auto}}\n"] }]
        }], propDecorators: { inputUpload: [{
                type: ViewChild,
                args: ['inputUpload', { static: false }]
            }], anchor: [{
                type: ViewChild,
                args: ['anchor', { static: false }]
            }], id: [{
                type: Input
            }], chooseLabel: [{
                type: Input
            }], removeLabel: [{
                type: Input
            }], cancelLabel: [{
                type: Input
            }], successTooltip: [{
                type: Input
            }], multiple: [{
                type: Input
            }], accept: [{
                type: Input
            }], supportedExtensions: [{
                type: Input
            }], ariaLabelFileName: [{
                type: Input
            }], maxFileSize: [{
                type: Input
            }], maxCombinedFileSize: [{
                type: Input
            }], fileLimit: [{
                type: Input
            }], ariaLabelProgress: [{
                type: Input
            }], ariaLabelSuccess: [{
                type: Input
            }], ariaLabelError: [{
                type: Input
            }], ariaLabelRemove: [{
                type: Input
            }], formControl: [{
                type: Input
            }], disabled: [{
                type: Input
            }], showFileUploadDate: [{
                type: Input
            }], permissions: [{
                type: Input
            }], files: [{
                type: Input
            }], uploadHandler: [{
                type: Output
            }], removeFile: [{
                type: Output
            }], cancelUpload: [{
                type: Output
            }], downloadFile: [{
                type: Output
            }], validateErrors: [{
                type: Output
            }], onResize: [{
                type: HostListener,
                args: ['window:resize']
            }] } });

class FilePickerModule {
    static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: FilePickerModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
    static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "18.2.14", ngImport: i0, type: FilePickerModule, imports: [FilePickerComponent], exports: [FilePickerComponent] });
    static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: FilePickerModule, providers: [FilePickerService], imports: [FilePickerComponent] });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: FilePickerModule, decorators: [{
            type: NgModule,
            args: [{
                    imports: [FilePickerComponent],
                    providers: [FilePickerService],
                    exports: [FilePickerComponent],
                }]
        }] });

/**
 * Generated bundle index. Do not edit.
 */

export { FilePickerComponent, FilePickerModule, FilePickerService };
//# sourceMappingURL=seniorsistemas-angular-components-file-picker.mjs.map
