import * as i0 from '@angular/core';
import { OnInit, AfterViewInit, EventEmitter, QueryList, ElementRef, TemplateRef, PipeTransform } from '@angular/core';
import { ControlValueAccessor, ValidatorFn, AsyncValidatorFn } from '@angular/forms';
import { EuiTemplateDirective } from '@eui/components/directives';
import { HttpEvent } from '@angular/common/http';
import { Observable, MonoTypeOperatorFunction, UnaryFunction } from 'rxjs';

interface EuiUploadedFileInterface {
    id?: string | number;
    name?: string;
    url?: string;
    size?: number;
    type?: string;
}

/**
 * @description
 * `eui-file-upload` allows the user to upload a file to a server. It can be use in the classic simple file way or with a drag and drop feature.
 */
declare class EuiFileUploadComponent implements ControlValueAccessor, OnInit, AfterViewInit {
    /**
     * Sets the `data-e2e` attribute for the host element.
     *
     * @default 'eui-file-upload'
     */
    e2eAttr: string;
    /**
     * In combination with `hasProgressBar`. Sets the progress of upload to be displayed by the progress bar.
     *
     * @type {number}
     */
    progress: number;
    /**
     * A comma separated list of extension allowed to be uploaded by the user.
     *
     * @default '*' (all)
     */
    accept: string;
    /**
     * The maximum number of file the user is allowed to upload
     *
     * @type {number}
     * @default null (no maximum)
     */
    maxFiles: number;
    /**
     * Event emitted when a file is drag and dropped in the component.
     */
    fileDrop: EventEmitter<any>;
    /**
     * Event emitted when a choosen file to upload is clicked.
     */
    itemClick: EventEmitter<any>;
    /**
     * Sets the `class` attribute for the host element.
     *
     * @returns A string with all CSS classes applied.
     */
    get cssClasses(): string;
    files: File[];
    filesTotalSize: number;
    /**
     * Random number generated to give an unique id to the field.
     */
    randomNumberId: number;
    /**
     * List of existing files to display in the component.
     *
     * @type {EuiUploadedFileInterface[]}
     */
    uploadedFiles: EuiUploadedFileInterface[];
    dragEntered: boolean;
    /**
     * List of templates passed to the component.
     */
    templates: QueryList<EuiTemplateDirective>;
    fileInputs: QueryList<ElementRef<HTMLInputElement>>;
    uploadedFileTemplate: TemplateRef<{
        $implicit: {
            file: EuiUploadedFileInterface;
            index: number;
            isFileObject: boolean;
        };
    }>;
    browseButtonTemplate: TemplateRef<HTMLElement>;
    resetButtonTemplate: TemplateRef<HTMLElement>;
    progressBarTemplate: TemplateRef<{
        $implicit: {
            progress: number;
        };
    }>;
    /**
     * Wheter multiple files can be choosen.
     *
     * @default true
     */
    isMultiple: boolean;
    /**
     * Wheter a progress bar is displayed to indicate the upload progress.
     *
     * @default true
     */
    hasProgressBar: boolean;
    /**
     * Wheter a preview, image or icon, is displayed for a file to upload.
     *
     * @default true
     */
    hasPreview: boolean;
    /**
     * Wheter a preview is displayed as image.
     *
     * @default true
     */
    hasPreviewAsImage: boolean;
    /**
     * Wheter a preview is displayed as a file format icon.
     *
     * @default false
     */
    hasPreviewAsIcon: boolean;
    /**
     * Wheter the total size that will be uploaded is displayed.
     *
     * @default true
     */
    hasTotalSizeDisplayed: boolean;
    /**
     * Wheter a reset list button is displayed.
     *
     * @default true
     */
    hasResetButton: boolean;
    /**
     * Wheter files can be drag and dropped in the component.
     *
     * @default false
     */
    hasDragArea: boolean;
    /**
     * Wheter items can be clicked. `itemClick` event is emitted.
     *
     * @default false
     */
    isItemsClickable: boolean;
    /**
     * Drag and drop area listener.
     *
     * @param fileList `FileList` containing dropped file and initial file.
     */
    emitFiles(fileList: FileList): void;
    /**
     * Determines whether the reset button should be displayed.
     *
     * @returns {boolean} `true` if the reset button should be shown, otherwise `false`.
     */
    get showResetBtn(): boolean;
    /**
     * Determines whether the drop area should be disabled.
     *
     * @returns {boolean} `true` if the drop area is disabled, otherwise `false`.
     */
    get isDropAreaDisabled(): boolean;
    ngOnInit(): void;
    ngAfterViewInit(): void;
    onDragEnter(): void;
    onDragLeave(): void;
    /**
     * Remove a file from the array of files choosen by the user.
     *
     * @param index Index of the file to remove in the array.
     */
    removeFromList(index: number): void;
    /**
     * Remove a file from the array of files provided to the component as existing values.
     *
     * @param index Index of the file to remove in the array.
     */
    removeFromUploadedList(index: number): void;
    /**
     * Reset the list of files in the component.
     */
    resetList(): void;
    openBrowseWindow(): void;
    /**
     * Click item handler.
     * @param e The item clicked. Will be a `Blob` for a file to be uploaded, `EuiUploadedFileInterface` for an initial file.
     */
    onItemClick(e: Blob | EuiUploadedFileInterface | any): void;
    writeValue(value: any): void;
    registerOnChange(fn: any): void;
    registerOnTouched(fn: any): void;
    private onChange;
    /**
     * Calculates the total size to be uploaded.
     */
    private getTotalSize;
    static ɵfac: i0.ɵɵFactoryDeclaration<EuiFileUploadComponent, never>;
    static ɵcmp: i0.ɵɵComponentDeclaration<EuiFileUploadComponent, "eui-file-upload", never, { "e2eAttr": { "alias": "e2eAttr"; "required": false; }; "progress": { "alias": "progress"; "required": false; }; "accept": { "alias": "accept"; "required": false; }; "maxFiles": { "alias": "maxFiles"; "required": false; }; "isMultiple": { "alias": "isMultiple"; "required": false; }; "hasProgressBar": { "alias": "hasProgressBar"; "required": false; }; "hasPreview": { "alias": "hasPreview"; "required": false; }; "hasPreviewAsImage": { "alias": "hasPreviewAsImage"; "required": false; }; "hasPreviewAsIcon": { "alias": "hasPreviewAsIcon"; "required": false; }; "hasTotalSizeDisplayed": { "alias": "hasTotalSizeDisplayed"; "required": false; }; "hasResetButton": { "alias": "hasResetButton"; "required": false; }; "hasDragArea": { "alias": "hasDragArea"; "required": false; }; "isItemsClickable": { "alias": "isItemsClickable"; "required": false; }; }, { "fileDrop": "fileDrop"; "itemClick": "itemClick"; }, ["templates"], ["*"], true, never>;
    static ngAcceptInputType_isMultiple: unknown;
    static ngAcceptInputType_hasProgressBar: unknown;
    static ngAcceptInputType_hasPreview: unknown;
    static ngAcceptInputType_hasPreviewAsImage: unknown;
    static ngAcceptInputType_hasPreviewAsIcon: unknown;
    static ngAcceptInputType_hasTotalSizeDisplayed: unknown;
    static ngAcceptInputType_hasResetButton: unknown;
    static ngAcceptInputType_hasDragArea: unknown;
    static ngAcceptInputType_isItemsClickable: unknown;
}

declare class EuiFileUploadProgressComponent {
    /**
     * Sets the progress of upload to be displayed by the progress bar.
     *
     * @type {number}
     */
    progress: number;
    static ɵfac: i0.ɵɵFactoryDeclaration<EuiFileUploadProgressComponent, never>;
    static ɵcmp: i0.ɵɵComponentDeclaration<EuiFileUploadProgressComponent, "eui-file-upload-progress", never, { "progress": { "alias": "progress"; "required": false; }; }, {}, never, never, true, never>;
}

/**
 * @description
 * Internal class used by `eui-file-upload` to display the files to be uploaded.
 */
declare class EuiFilePreviewComponent implements OnInit, AfterViewInit {
    /**
     * The file to use. Will be a `Blob` for a file to be uploaded, `EuiUploadedFileInterface` for an initial file.
     */
    file: Blob | EuiUploadedFileInterface | any;
    /**
     * Template to use in the list of files.
     */
    uploadedFileTemplate: TemplateRef<{
        $implicit: {
            file: EuiUploadedFileInterface;
            index: number;
            isFileObject: boolean;
        };
    }>;
    /**
     * Index of the file in the list.
     */
    index: number;
    /**
     * Object matching extension and icon.
     */
    previewAsIconConfig: {
        avi: string;
        html: string;
        htm: string;
        js: string;
        json: string;
        mp3: string;
        mp4: string;
        pdf: string;
        png: string;
        svg: string;
        txt: string;
        xml: string;
        jpeg: string;
        jpg: string;
        zip: string;
        doc: string;
        docx: string;
        xls: string;
        xlsx: string;
        ppt: string;
        csv: string;
        rtf: string;
    };
    /**
     * Event emitted when the remove button is clicked.
     */
    removeFromList: EventEmitter<number>;
    url: string;
    icon: string;
    fileExtension: string;
    previewData: {
        image: boolean;
        display: string;
    };
    isLoading: boolean;
    typeFromFileExtension: string;
    /**
     * Event emitted when a chosen file to upload is clicked.
     */
    itemClick: EventEmitter<any>;
    /**
     * Whether a preview, image or icon, is displayed for a file to upload.
     *
     * @default true
     */
    hasPreview: boolean;
    /**
     * Whether the filename is displayed.
     *
     * @default true
     */
    isFilenameDisplayed: boolean;
    /**
     * Whether the filesize is displayed.
     *
     * @default true
     */
    isFilesizeDisplayed: boolean;
    /**
     * Whether the file type is displayed.
     *
     * @default true
     */
    isFiletypeDisplayed: boolean;
    /**
     * Whether a preview is displayed as image.
     *
     * @default true
     */
    hasPreviewAsImage: boolean;
    /**
     * Whether a preview is displayed as a file format icon.
     *
     * @default false
     */
    hasPreviewAsIcon: boolean;
    /**
     * Whether items can be clicked. `itemClick` event is emitted.
     *
     * @default false
     */
    isItemsClickable: boolean;
    /**
     * Whether the file is `File` or has been provided by the user as initial value.
     *
     * @default false
     */
    isFileObject: boolean;
    templates: QueryList<EuiTemplateDirective>;
    private cd;
    ngOnInit(): void;
    ngAfterViewInit(): void;
    /**
     * Remove from the list handler.
     */
    onRemoveFromList(): void;
    /**
     * Click item handler.
     * @param e The item clicked.
     */
    onItemClick(e: Event): void;
    /**
     * Method returning a file extension.
     *
     * @param fileName Filename of the file
     * @returns the extension as a string
     */
    private getFileExtension;
    /**
     * Method that returns the preview for a file.
     *
     * @param fileExtension Extension of the file
     * @param imgUrl URL of the file
     * @returns The image URL of valid image otherwise an icon of the extension
     */
    private getPreviewForMime;
    /**
     * Method that return the icon for a MIME type.
     *
     * @param fileExtension Extension of the file
     * @returns An icon string
     */
    private getIconForMime;
    static ɵfac: i0.ɵɵFactoryDeclaration<EuiFilePreviewComponent, never>;
    static ɵcmp: i0.ɵɵComponentDeclaration<EuiFilePreviewComponent, "eui-file-preview", never, { "file": { "alias": "file"; "required": false; }; "uploadedFileTemplate": { "alias": "uploadedFileTemplate"; "required": false; }; "index": { "alias": "index"; "required": false; }; "previewAsIconConfig": { "alias": "previewAsIconConfig"; "required": false; }; "hasPreview": { "alias": "hasPreview"; "required": false; }; "isFilenameDisplayed": { "alias": "isFilenameDisplayed"; "required": false; }; "isFilesizeDisplayed": { "alias": "isFilesizeDisplayed"; "required": false; }; "isFiletypeDisplayed": { "alias": "isFiletypeDisplayed"; "required": false; }; "hasPreviewAsImage": { "alias": "hasPreviewAsImage"; "required": false; }; "hasPreviewAsIcon": { "alias": "hasPreviewAsIcon"; "required": false; }; "isItemsClickable": { "alias": "isItemsClickable"; "required": false; }; "isFileObject": { "alias": "isFileObject"; "required": false; }; }, { "removeFromList": "removeFromList"; "itemClick": "itemClick"; }, ["templates"], never, true, never>;
    static ngAcceptInputType_hasPreview: unknown;
    static ngAcceptInputType_isFilenameDisplayed: unknown;
    static ngAcceptInputType_isFilesizeDisplayed: unknown;
    static ngAcceptInputType_isFiletypeDisplayed: unknown;
    static ngAcceptInputType_hasPreviewAsImage: unknown;
    static ngAcceptInputType_hasPreviewAsIcon: unknown;
    static ngAcceptInputType_isItemsClickable: unknown;
    static ngAcceptInputType_isFileObject: unknown;
}

/**
 * A pipe that transforms a file size in bytes into a human-readable format (e.g., KB, MB, GB).
 *
 * @example
 * {{ 1024 | filesize }}  // Outputs: "1.00 KB"
 * {{ 1048576 | filesize:1 }}  // Outputs: "1.0 MB"
 *
 * @param {number} bytes - The file size in bytes.
 * @param {number} [precision=2] - The number of decimal places to include in the output.
 * @returns {string} The formatted file size with the appropriate unit.
 */
declare class EuiFileSizePipe implements PipeTransform {
    private units;
    /**
     * Method used to format a size.
     *
     * @param bytes Bytes to format.
     * @param precision Number of decimal
     * @returns String with formated size and unit.
     */
    transform(bytes?: number, precision?: number): string;
    static ɵfac: i0.ɵɵFactoryDeclaration<EuiFileSizePipe, never>;
    static ɵpipe: i0.ɵɵPipeDeclaration<EuiFileSizePipe, "filesize", true>;
}

declare class EuiFileUploadUtilsService {
    private httpClient;
    /**
     * @description
     * Method that will format data in `FormData` and send them to backend.
     *
     * @example
     * Call the method and log the response in the console.
     *
     * ```
     * this.euiFileUploadUtilsService.sendData(this.form.value, 'http://localhost:3000/api/fake-api').pipe(
     *     this.euiFileUploadUtilsService.uploadProgress((progress) => {
     *         console.log(progress);
     *     }),
     *     this.euiFileUploadUtilsService.toResponseBody(),
     * ).subscribe((response) => {
     *      console.log(response);
     * });
     * ```
     *
     * @param data Data to send to backend
     * @param APIEndPoint Endpoint URL
     * @returns The backend response.
     */
    sendData(data: any, APIEndPoint: string): Observable<any>;
    /**
     * @description
     * Method that will return the upload progress.
     *
     * @example
     * Call the method and log the progress in the console.
     *
     * ```
     * this.euiFileUploadUtilsService.sendData(this.form.value, 'http://localhost:3000/api/fake-api').pipe(
     *     this.euiFileUploadUtilsService.uploadProgress((progress) => {
     *         console.log(progress);
     *     }),
     *     this.euiFileUploadUtilsService.toResponseBody(),
     * ).subscribe((response) => {
     *      console.log(response);
     * });
     * ```
     *
     * @param cb A method to execute on each progress step.
     * @returns A number between 0 and 100.
     */
    uploadProgress<T>(cb: (progress: number) => void): MonoTypeOperatorFunction<HttpEvent<T>>;
    /**
     * @description
     * Method that will return only the body of the backend response.
     *
     * @example
     * Call the method and log the response in the console.
     *
     * ```
     * this.euiFileUploadUtilsService.sendData(this.form.value, 'http://localhost:3000/api/fake-api').pipe(
     *     this.euiFileUploadUtilsService.uploadProgress((progress) => {
     *         console.log(progress);
     *     }),
     *     this.euiFileUploadUtilsService.toResponseBody(),
     * ).subscribe((response) => {
     *      console.log(response);
     * });
     * ```
     *
     * @returns The backend response.
     */
    toResponseBody<T>(): UnaryFunction<Observable<HttpEvent<T>>, Observable<T>>;
    /**
     * @description
     * Return the icon to be used with eui-icon-svg of the given extension or a default file icon
     *
     * @param fileExtension
     * @returns Icon name as string
     */
    getIconForExtension(fileExtension: string): string;
    /**
     * Internal method returning `FormData` object.
     *
     * @param formValue Data to send to form
     * @returns A `FormData` object
     */
    private toFormData;
    static ɵfac: i0.ɵɵFactoryDeclaration<EuiFileUploadUtilsService, never>;
    static ɵprov: i0.ɵɵInjectableDeclaration<EuiFileUploadUtilsService>;
}

type MimeType = 'image/jpeg' | 'image/png' | 'image/gif' | 'image/webp' | 'image/flif' | 'image/x-xcf' | 'image/x-canon-cr2' | 'image/x-canon-cr3' | 'image/tiff' | 'image/bmp' | 'image/icns' | 'image/vnd.ms-photo' | 'image/vnd.adobe.photoshop' | 'application/x-indesign' | 'application/epub+zip' | 'application/x-xpinstall' | 'application/vnd.oasis.opendocument.text' | 'application/vnd.oasis.opendocument.spreadsheet' | 'application/vnd.oasis.opendocument.presentation' | 'application/vnd.openxmlformats-officedocument.wordprocessingml.document' | 'application/vnd.openxmlformats-officedocument.presentationml.presentation' | 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' | 'application/zip' | 'application/json' | 'application/x-tar' | 'application/x-rar-compressed' | 'application/gzip' | 'application/x-bzip2' | 'application/x-7z-compressed' | 'application/x-apple-diskimage' | 'video/mp4' | 'audio/midi' | 'video/x-matroska' | 'video/webm' | 'video/quicktime' | 'video/vnd.avi' | 'audio/vnd.wave' | 'audio/qcelp' | 'audio/x-ms-asf' | 'video/x-ms-asf' | 'application/vnd.ms-asf' | 'video/mpeg' | 'video/3gpp' | 'audio/mpeg' | 'audio/mp4' | 'audio/opus' | 'video/ogg' | 'audio/ogg' | 'application/ogg' | 'audio/x-flac' | 'audio/ape' | 'audio/wavpack' | 'audio/amr' | 'application/pdf' | 'application/x-elf' | 'application/x-msdownload' | 'application/x-shockwave-flash' | 'application/rtf' | 'application/wasm' | 'font/woff' | 'font/woff2' | 'application/vnd.ms-fontobject' | 'font/ttf' | 'font/otf' | 'image/x-icon' | 'video/x-flv' | 'application/postscript' | 'application/eps' | 'application/x-xz' | 'application/x-sqlite3' | 'application/x-nintendo-nes-rom' | 'application/x-google-chrome-extension' | 'application/vnd.ms-cab-compressed' | 'application/x-deb' | 'application/x-unix-archive' | 'application/x-rpm' | 'application/x-compress' | 'application/x-lzip' | 'application/x-cfb' | 'application/x-mie' | 'application/x-apache-arrow' | 'application/mxf' | 'video/mp2t' | 'application/x-blender' | 'image/bpg' | 'image/j2c' | 'image/jp2' | 'image/jpx' | 'image/jpm' | 'image/mj2' | 'audio/aiff' | 'application/xml' | 'application/x-mobipocket-ebook' | 'image/heif' | 'image/heif-sequence' | 'image/heic' | 'image/heic-sequence' | 'image/ktx' | 'application/dicom' | 'audio/x-musepack' | 'text/calendar' | 'text/vcard' | 'model/gltf-binary' | 'application/vnd.tcpdump.pcap' | 'audio/x-voc' | 'audio/vnd.dolby.dd-raw' | 'audio/x-m4a' | 'image/apng' | 'image/x-olympus-orf' | 'image/x-sony-arw' | 'image/x-adobe-dng' | 'image/x-nikon-nef' | 'image/x-panasonic-rw2' | 'image/x-fujifilm-raf' | 'video/x-m4v' | 'video/3gpp2' | 'application/x-esri-shape' | 'audio/aac' | 'audio/x-it' | 'audio/x-s3m' | 'audio/x-xm' | 'video/MP1S' | 'video/MP2P' | 'application/vnd.sketchup.skp' | 'image/avif' | 'application/x-lzh-compressed' | 'application/pgp-encrypted' | 'application/x-asar' | 'model/stl' | 'application/vnd.ms-htmlhelp' | 'model/3mf' | 'image/jxl' | 'application/zstd' | 'image/jls' | 'application/vnd.ms-outlook' | 'image/vnd.dwg' | 'application/x-parquet' | 'application/java-vm' | 'application/x-arj' | 'application/x-cpio' | 'application/x-ace-compressed' | 'application/avro' | 'application/vnd.iccprofile';
declare const getMimeType: (header: Uint8Array) => MimeType;

/**
 * @description
 * Validator that requires the maximum length of files that can be uploaded.
 *
 * @example
 * Validate that the user selected maximum 3 files:
 *
 * ```
 * const fileUpload = new FormControl(null, maxFilesValidator(3));
 * console.log(fileUpload.errors); // { maxFiles: 3 }
 * ```
 *
 * @param {MimeType[]} maxFiles - The maximum number of files allowed.
 * @returns A validator function that returns an error map with the
 * `maxFiles` if the validation check fails, otherwise `null`.
 */
declare const maxFilesValidator: (maxFiles: number) => ValidatorFn;
/**
 * @description
 * Validator that requires the maximum size (in bytes) of files that can be uploaded.
 *
 * @example
 * Validate that the user doesn't select a file have a size up to 300Kb:
 *
 * ```
 * const fileUpload = new FormControl(null, maxSizeValidator(300000));
 * console.log(fileUpload.errors); // { maxSize: 300000 }
 * ```
 *
 * @param {MimeType[]} maxFileSize - The maximum filesize allowed.
 * @returns A validator function that returns an error map with the
 * `maxSize` if the validation check fails, otherwise `null`.
 */
declare const maxSizeValidator: (maxSize: number) => ValidatorFn;
/**
 * @description
 * Validator that requires the maximum size (in bytes) per file that can be uploaded.
 *
 * @example
 * Validates that the user doesn't select a file that exceeds the provided size
 *
 * @param {MimeType[]} maxFileSize - The maximum filesize allowed.
 * @returns A validator function that returns an error map with the
 * `maxFileSize` and the `indexes` of the file/files that exceeded the max size if the validation check fails, otherwise `null`.
 */
declare const maxFileSizeValidator: (maxFileSize: number) => ValidatorFn;
/**
 * @description
 * Validator that requires an array of mime type that can be uploaded.
 *
 * @example
 * Validate that the user doesn't select a file having another extension than .jpg or .jpeg:
 * ```
 * const fileUpload = new FormControl(null, mimeTypeExtensionValidator(['image/jpeg'])),
 * console.log(fileUpload.errors); // { invalidFileExtension: ['image/jpeg'] }
 * ```
 *
 * @param {MimeType[]} mimeTypes - The list of allowed MIME types.
 * @returns A validator function that returns an error map with the
 * `invalidFileExtension` if the validation check fails, otherwise `null`.
 */
declare const mimeTypeExtensionValidator: (mimeTypes: string[]) => ValidatorFn;
/**
 * @description
 * Validator that requires an array of mime type that can be uploaded.
 *
 * @example
 * Validate that the user doesn't select a file having another extension than .jpg or .jpeg:
 *
 * ```
 * const fileUpload = new FormControl(null, mimeTypeExtensionValidator(['image/jpeg'])),
 * console.log(fileUpload.errors); // { invalidMimeFileType: ['image/jpeg'] }
 * ```
 * @param {MimeType[]} mimeTypes - The list of allowed MIME types.
 * @returns An Async validator function that returns an error map with the
 * `invalidMimeFileType` if the validation check fails, otherwise `null`.
 */
declare const asyncMimeTypeExtensionValidator: (mimeTypes: MimeType[]) => AsyncValidatorFn;

declare const EUI_FILE_UPLOAD: readonly [typeof EuiFileUploadComponent, typeof EuiFileUploadProgressComponent, typeof EuiFilePreviewComponent, typeof EuiFileSizePipe];

export { EUI_FILE_UPLOAD, EuiFilePreviewComponent, EuiFileSizePipe, EuiFileUploadComponent, EuiFileUploadProgressComponent, EuiFileUploadUtilsService, asyncMimeTypeExtensionValidator, getMimeType, maxFileSizeValidator, maxFilesValidator, maxSizeValidator, mimeTypeExtensionValidator };
export type { EuiUploadedFileInterface, MimeType };
//# sourceMappingURL=eui-components-eui-file-upload.d.ts.map
