import * as _siemens_element_translate_ng_translate from '@siemens/element-translate-ng/translate';
import { TranslatableString } from '@siemens/element-translate-ng/translate';
import * as _angular_core from '@angular/core';
import { OnChanges, SimpleChanges } from '@angular/core';
import { HttpHeaders, HttpRequest, HttpEvent, HttpResponse } from '@angular/common/http';
import { Observable, Subscription } from 'rxjs';

/**
 * Copyright (c) Siemens 2016 - 2026
 * SPDX-License-Identifier: MIT
 */

/** */
interface UploadFile {
    status: 'added' | 'invalid' | 'queued' | 'uploading' | 'success' | 'error';
    file: File;
    fileName: string;
    size: string;
    errorText?: TranslatableString;
    progress: number;
}

interface FileUploadError extends UploadFile {
    status: 'invalid';
    errorText: TranslatableString;
}
/**
 * Directive for handling file uploads with validation for file type and size.
 *
 * @example
 * ```html
 * <input
 *   #fileInput
 *   type="file"
 *   class="d-none"
 *   siFileUpload
 *   [accept]="accept()"
 *   [maxFileSize]="maxFileSize()"
 *   [multiple]="true"
 *   (validFiles)="onFilesAdded($event)"
 *   (fileError)="onFileError($event)"
 * />
 * ```
 */
declare class SiFileUploadDirective {
    /**
     * Text or translation key of message title if incorrect file type is dragged / dropped.
     *
     * @defaultValue
     * ```
     * t(() => $localize`:@@SI_FILE_UPLOADER.ERROR_FILE_TYPE:Incorrect file type selected`)
     * ```
     */
    readonly errorTextFileType: _angular_core.InputSignal<TranslatableString>;
    /**
     * Message or translation key if file exceeds the maximum file size limit.
     *
     * @defaultValue
     * ```
     * t(() => $localize`:@@SI_FILE_UPLOADER.ERROR_FILE_SIZE_EXCEEDED:File exceeds allowed maximum size`)
     * ```
     */
    readonly errorTextFileMaxSize: _angular_core.InputSignal<TranslatableString>;
    /**
     * Define which file types are suggested in file browser.
     * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/file#attr-accept
     */
    readonly accept: _angular_core.InputSignal<string | undefined>;
    /**
     * Define maximal allowed file size in bytes.
     */
    readonly maxFileSize: _angular_core.InputSignal<number | undefined>;
    /**
     * Defines whether the file input allows selecting multiple files.
     * When {@link directoryUpload} is enabled, this will have no effect.
     *
     * @defaultValue false
     */
    readonly multiple: _angular_core.InputSignalWithTransform<boolean, unknown>;
    /**
     * Enable directory upload.
     *
     * @defaultValue false
     */
    readonly directoryUpload: _angular_core.InputSignalWithTransform<boolean, unknown>;
    /**
     * Event emitted when valid files are added.
     * Invalid files (due to size or type) will be ignored and instead the {@link fileError} event will be emitted.
     */
    readonly validFiles: _angular_core.OutputEmitterRef<UploadFile[]>;
    /**
     * Event emitted when valid files are added.
     * Also includes invalid files, but with status 'invalid' and an errorText describing why they were ignored.
     */
    readonly filesAdded: _angular_core.OutputEmitterRef<UploadFile[]>;
    /**
     * Event emitted when file validation errors occur, including files that were ignored due to size or type.
     */
    readonly fileError: _angular_core.OutputEmitterRef<FileUploadError>;
    private readonly elementRef;
    private locale;
    private numberFormat;
    protected onInputChange(event: Event): void;
    /**
     * Handle files from input or drag and drop
     */
    handleFiles(files: FileList | null): void;
    /**
     * Handle directory entries for drag and drop
     */
    handleItems(items: DataTransferItemList): void;
    /**
     * Reset the file input value
     */
    reset(): void;
    /**
     * Trigger the file input click
     */
    triggerClick(): void;
    private makeUploadFile;
    private verifyFileSize;
    private verifyFileType;
    fileSizeToString(num: number): string;
    static formatFileSize(num: number, formatter?: Intl.NumberFormat): string;
    static ɵfac: _angular_core.ɵɵFactoryDeclaration<SiFileUploadDirective, never>;
    static ɵdir: _angular_core.ɵɵDirectiveDeclaration<SiFileUploadDirective, "input[type=\"file\"][siFileUpload]", never, { "errorTextFileType": { "alias": "errorTextFileType"; "required": false; "isSignal": true; }; "errorTextFileMaxSize": { "alias": "errorTextFileMaxSize"; "required": false; "isSignal": true; }; "accept": { "alias": "accept"; "required": false; "isSignal": true; }; "maxFileSize": { "alias": "maxFileSize"; "required": false; "isSignal": true; }; "multiple": { "alias": "multiple"; "required": false; "isSignal": true; }; "directoryUpload": { "alias": "directoryUpload"; "required": false; "isSignal": true; }; }, { "validFiles": "validFiles"; "filesAdded": "filesAdded"; "fileError": "fileError"; }, never, never, true, never>;
}

declare class SiFileDropzoneComponent {
    /**
     * Text or translation key of the input file selector (is combined with the `uploadTextRest`).
     *
     * @defaultValue
     * ```
     * t(() => $localize`:@@SI_FILE_UPLOADER.FILE_SELECT:click to upload`)
     * ```
     */
    readonly uploadTextFileSelect: _angular_core.InputSignal<_siemens_element_translate_ng_translate.TranslatableString>;
    /**
     * Text or translation key of the drag&drop field (is combined with the `uploadTextFileSelect`).
     *
     * @defaultValue
     * ```
     * t(() => $localize`:@@SI_FILE_UPLOADER.DROP:Drop files here or`)
     * ```
     */
    readonly uploadDropText: _angular_core.InputSignal<_siemens_element_translate_ng_translate.TranslatableString>;
    /**
     * Text or translation key for max file size.
     *
     * @defaultValue
     * ```
     * t(() => $localize`:@@SI_FILE_UPLOADER.MAX_SIZE:Max. {{maxFileSize}} upload size.`)
     * ```
     */
    readonly maxFileSizeText: _angular_core.InputSignal<_siemens_element_translate_ng_translate.TranslatableString>;
    /**
     * Text or translation key for accepted types.
     *
     * @defaultValue
     * ```
     * t(() => $localize`:@@SI_FILE_UPLOADER.ACCEPTED_FILE_TYPES:Accepted file types: {{accept}}.`)
     * ```
     */
    readonly acceptText: _angular_core.InputSignal<_siemens_element_translate_ng_translate.TranslatableString>;
    /**
     * Text or translation key of message title if incorrect file type is dragged / dropped.
     *
     * @defaultValue
     * ```
     * t(() => $localize`:@@SI_FILE_UPLOADER.ERROR_FILE_TYPE:Incorrect file type selected`)
     * ```
     */
    readonly errorTextFileType: _angular_core.InputSignal<_siemens_element_translate_ng_translate.TranslatableString>;
    /**
     * Message or translation key if file exceeds the maximum file size limit.
     *
     * @defaultValue
     * ```
     * t(() => $localize`:@@SI_FILE_UPLOADER.ERROR_FILE_SIZE_EXCEEDED:File exceeds allowed maximum size`)
     * ```
     */
    readonly errorTextFileMaxSize: _angular_core.InputSignal<_siemens_element_translate_ng_translate.TranslatableString>;
    /**
     * Define which file types are suggested in file browser.
     * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/file#attr-accept
     */
    readonly accept: _angular_core.InputSignal<string | undefined>;
    /**
     * Define maximal allowed file size in bytes.
     */
    readonly maxFileSize: _angular_core.InputSignal<number | undefined>;
    /**
     * Defines whether the file input allows selecting multiple files.
     * When {@link directoryUpload} is enabled, this will have no effect.
     *
     * @defaultValue false
     */
    readonly multiple: _angular_core.InputSignalWithTransform<boolean, unknown>;
    /**
     * Event emitted when valid files are added.
     * Invalid files are also included here, but with status 'invalid' and an errorText describing why they were ignored.
     */
    readonly filesAdded: _angular_core.OutputEmitterRef<UploadFile[]>;
    /**
     * Event emitted when file validation errors occur, including files that were ignored due to size or type.
     */
    readonly fileError: _angular_core.OutputEmitterRef<FileUploadError>;
    /**
     * Enable directory upload.
     *
     * @defaultValue false
     */
    readonly directoryUpload: _angular_core.InputSignalWithTransform<boolean, unknown>;
    protected readonly maxFileSizeString: _angular_core.Signal<string>;
    protected readonly icons: Record<"elementUpload", string>;
    protected dragOver: boolean;
    private readonly fileUploadDirective;
    protected dropHandler(event: DragEvent): void;
    protected dragOverHandler(event: DragEvent): void;
    protected inputEnterHandler(): void;
    protected onFilesAdded(files: UploadFile[]): void;
    protected onFileError(error: FileUploadError): void;
    /**
     * Reset all the files inside the native file input (and therefore the dropzone).
     */
    reset(): void;
    static ɵfac: _angular_core.ɵɵFactoryDeclaration<SiFileDropzoneComponent, never>;
    static ɵcmp: _angular_core.ɵɵComponentDeclaration<SiFileDropzoneComponent, "si-file-dropzone", never, { "uploadTextFileSelect": { "alias": "uploadTextFileSelect"; "required": false; "isSignal": true; }; "uploadDropText": { "alias": "uploadDropText"; "required": false; "isSignal": true; }; "maxFileSizeText": { "alias": "maxFileSizeText"; "required": false; "isSignal": true; }; "acceptText": { "alias": "acceptText"; "required": false; "isSignal": true; }; "errorTextFileType": { "alias": "errorTextFileType"; "required": false; "isSignal": true; }; "errorTextFileMaxSize": { "alias": "errorTextFileMaxSize"; "required": false; "isSignal": true; }; "accept": { "alias": "accept"; "required": false; "isSignal": true; }; "maxFileSize": { "alias": "maxFileSize"; "required": false; "isSignal": true; }; "multiple": { "alias": "multiple"; "required": false; "isSignal": true; }; "directoryUpload": { "alias": "directoryUpload"; "required": false; "isSignal": true; }; }, { "filesAdded": "filesAdded"; "fileError": "fileError"; }, never, never, true, never>;
}

/**
 * The FileUploadResult is emitted at completion of the file uploading
 * via the `uploadCompleted` emitter. On success the Http `response` from
 * the backend is provided and on failure, the `error` object is available.
 */
interface FileUploadResult {
    file: string;
    response?: HttpResponse<unknown>;
    error?: Error;
}
interface FileUploadConfig {
    headers: HttpHeaders | string | Record<string, string | number | (string | number)[]> | Headers;
    method: 'POST' | 'PUT' | 'PATCH';
    url: string;
    /** Form field name for the uploaded file. */
    fieldName: string;
    /**
     * Additional form fields added in the HTTP request.
     *
     * @example
     * ```json
     * { upload_user: 'Reiner Zufall', expiry_date: ' 21.12.2012' }
     * ```
     */
    additionalFields?: Record<string, string>;
    /** Specify the server response type */
    responseType?: 'arraybuffer' | 'blob' | 'json' | 'text';
    /** A function to modify the HTTP request sent on the consumer side. */
    handler?: (req: HttpRequest<unknown>) => Observable<HttpEvent<unknown>>;
    /**
     * When `true`, the file will be sent directly w/o the use of `FormData`.
     * You will also need to set the `Content-Type` header when sending binary. See: {@link headers}
     */
    sendBinary?: boolean;
}
interface ExtUploadFile extends UploadFile {
    httpErrorText?: string;
    subscription?: Subscription;
    successResponse?: HttpResponse<unknown>;
    fadeOut?: boolean;
}
declare class SiFileUploaderComponent implements OnChanges {
    /**
     * Text of the link to open the file select dialog (follows `uploadDropText`).
     *
     * @defaultValue
     * ```
     * t(() => $localize`:@@SI_FILE_UPLOADER.FILE_SELECT:click to upload`)
     * ```
     */
    readonly uploadTextFileSelect: _angular_core.InputSignal<_siemens_element_translate_ng_translate.TranslatableString>;
    /**
     * Text instructing a user to drop the files inside the dropzone.
     *
     * @defaultValue
     * ```
     * t(() => $localize`:@@SI_FILE_UPLOADER.DROP:Drop files here or`)
     * ```
     */
    readonly uploadDropText: _angular_core.InputSignal<_siemens_element_translate_ng_translate.TranslatableString>;
    /**
     * Text to describe the maximum file size.
     *
     * @defaultValue
     * ```
     * t(() => $localize`:@@SI_FILE_UPLOADER.MAX_SIZE:Max. {{maxFileSize}} upload size.`)
     * ```
     */
    readonly maxFileSizeText: _angular_core.InputSignal<_siemens_element_translate_ng_translate.TranslatableString>;
    /**
     * Error message shown when the maximum number of files are reached.
     *
     * @defaultValue
     * ```
     * t(() => $localize`:@@SI_FILE_UPLOADER.MAX_FILE_REACHED:Max. {{maxFiles}} files`)
     * ```
     */
    readonly maxFilesReachedText: _angular_core.InputSignal<_siemens_element_translate_ng_translate.TranslatableString>;
    /**
     * Text for the accepted file types.
     *
     * @defaultValue
     * ```
     * t(() => $localize`:@@SI_FILE_UPLOADER.ACCEPTED_FILE_TYPES:Accepted file types: {{accept}}.`)
     * ```
     */
    readonly acceptText: _angular_core.InputSignal<_siemens_element_translate_ng_translate.TranslatableString>;
    /**
     * Text used inside the upload button.
     *
     * @defaultValue
     * ```
     * t(() => $localize`:@@SI_FILE_UPLOADER.UPLOAD:Upload`)
     * ```
     */
    readonly uploadButtonText: _angular_core.InputSignal<_siemens_element_translate_ng_translate.TranslatableString>;
    /**
     * Text used inside the clear button.
     *
     * @defaultValue
     * ```
     * t(() => $localize`:@@SI_FILE_UPLOADER.CLEAR:Clear`)
     * ```
     */
    readonly clearButtonText: _angular_core.InputSignal<_siemens_element_translate_ng_translate.TranslatableString>;
    /**
     * Text shown during the file upload.
     *
     * @defaultValue
     * ```
     * t(() => $localize`:@@SI_FILE_UPLOADER.UPLOADING:Uploading`)
     * ```
     */
    readonly uploadingText: _angular_core.InputSignal<_siemens_element_translate_ng_translate.TranslatableString>;
    /**
     * Text shown to remove a file from the file list. Required for a11y.
     *
     * @defaultValue
     * ```
     * t(() => $localize`:@@SI_FILE_UPLOADER.REMOVE:Remove`)
     * ```
     */
    readonly removeButtonText: _angular_core.InputSignal<_siemens_element_translate_ng_translate.TranslatableString>;
    /**
     * Text of cancel button. Shown during upload. Required for a11y.
     *
     * @defaultValue
     * ```
     * t(() => $localize`:@@SI_FILE_UPLOADER.CANCEL:Cancel`)
     * ```
     */
    readonly cancelButtonText: _angular_core.InputSignal<_siemens_element_translate_ng_translate.TranslatableString>;
    /**
     * Text shown if the upload was successful.
     *
     * @defaultValue
     * ```
     * t(() => $localize`:@@SI_FILE_UPLOADER.UPLOAD_COMPLETED:Upload completed`)
     * ```
     */
    readonly successTextTitle: _angular_core.InputSignal<_siemens_element_translate_ng_translate.TranslatableString>;
    /**
     * Text shown if the upload failed.
     *
     * @defaultValue
     * ```
     * t(() => $localize`:@@SI_FILE_UPLOADER.UPLOAD_FAILED:Upload failed`)
     * ```
     */
    readonly errorUploadFailed: _angular_core.InputSignal<_siemens_element_translate_ng_translate.TranslatableString>;
    /**
     * On failed upload, show the error received from the server.
     *
     * @defaultValue false
     */
    readonly showHttpError: _angular_core.InputSignalWithTransform<boolean, unknown>;
    /**
     * Text shown to indicate that an incorrect file type was added to file list.
     *
     * @defaultValue
     * ```
     * t(() => $localize`:@@SI_FILE_UPLOADER.ERROR_FILE_TYPE:Incorrect file type selected`)
     * ```
     */
    readonly errorTextFileType: _angular_core.InputSignal<_siemens_element_translate_ng_translate.TranslatableString>;
    /**
     * Message or translation key if file exceeds the maximum file size limit.
     *
     * @defaultValue
     * ```
     * t(() => $localize`:@@SI_FILE_UPLOADER.ERROR_FILE_SIZE_EXCEEDED:File exceeds allowed maximum size`)
     * ```
     */
    readonly errorTextFileMaxSize: _angular_core.InputSignal<_siemens_element_translate_ng_translate.TranslatableString>;
    /**
     * Config for HTTP request to upload file.
     *
     * @defaultValue
     * ```
     * {
     *     headers: new HttpHeaders({ 'Accept': 'application/json' }),
     *     method: 'POST',
     *     url: '',
     *     fieldName: 'upload_file',
     *     responseType: 'json'
     *   }
     * ```
     */
    readonly uploadConfig: _angular_core.InputSignal<FileUploadConfig>;
    /**
     * Define which file types are suggested in file browser.
     * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/file#attr-accept
     */
    readonly accept: _angular_core.InputSignal<string | undefined>;
    /**
     * Define maximal allowed file size in bytes.
     *
     * @defaultValue undefined
     */
    readonly maxFileSize: _angular_core.InputSignalWithTransform<number | undefined, unknown>;
    /**
     * Define maximal allowed number of files.
     * When {@link directoryUpload} is enabled, this will have no effect.
     * @defaultValue 10
     */
    readonly maxFiles: _angular_core.InputSignalWithTransform<number, unknown>;
    /**
     * Maximum number of concurrent uploads.
     *
     * @defaultValue 3
     */
    readonly maxConcurrentUploads: _angular_core.InputSignalWithTransform<number, unknown>;
    /**
     * Numbers of retries for failed uploads.
     *
     * @defaultValue 0
     */
    readonly retries: _angular_core.InputSignalWithTransform<number, unknown>;
    /**
     * Auto-upload mode - automatically start upload once files are added.
     *
     * @defaultValue false
     */
    readonly autoUpload: _angular_core.InputSignalWithTransform<boolean, unknown>;
    /**
     * Disable the upload button.
     *
     * @defaultValue false
     */
    readonly disableUpload: _angular_core.InputSignalWithTransform<boolean, unknown>;
    /**
     * Enable directory upload mode.
     * When enabled, the file input will accept directories and upload all files within as a flat list.
     * The hierarchy of the directory will not be preserved.
     * The `maxFiles` property will have no effect when `directoryUpload` is enabled.
     *
     * **Note:** This feature is not yet available for safari (iOS)
     *
     * @defaultValue false
     */
    readonly directoryUpload: _angular_core.InputSignalWithTransform<boolean, unknown>;
    /**
     * Emits when a user press cancel during upload. The event provides the file details.
     */
    readonly uploadCanceled: _angular_core.OutputEmitterRef<UploadFile>;
    /**
     * Output callback event will provide you if upload is finished. If an error
     * occurred it will be emitted.
     */
    readonly uploadCompleted: _angular_core.OutputEmitterRef<FileUploadResult>;
    /**
     * Output which fires whenever new files are added to or removed from the uploader.
     */
    readonly filesChanges: _angular_core.OutputEmitterRef<UploadFile[]>;
    protected readonly icons: Record<"elementCancel" | "elementDelete" | "elementDocument" | "elementRedo", string>;
    protected files: ExtUploadFile[];
    protected pending: number;
    private uploading;
    protected uploadEnabled: boolean;
    protected maxFilesReached: boolean;
    private readonly dropZone;
    private cdRef;
    private http?;
    ngOnChanges(changes: SimpleChanges<this>): void;
    protected handleFiles(files: UploadFile[]): void;
    protected removeFile(index: number): void;
    protected cancelUpload(file: ExtUploadFile): void;
    protected retryUpload(file: UploadFile): void;
    /**
     * Reset the state.
     */
    reset(emit?: boolean): void;
    /**
     * Uploads the file
     */
    fileUpload(doRetry?: boolean): void;
    private doUpload;
    private processQueue;
    private uploadOneFile;
    private isDuplicate;
    private handleUploadEvent;
    private handleUploadError;
    private handleUploadComplete;
    private oneUploadDone;
    private fadeOut;
    private updateStates;
    private countValid;
    static ɵfac: _angular_core.ɵɵFactoryDeclaration<SiFileUploaderComponent, never>;
    static ɵcmp: _angular_core.ɵɵComponentDeclaration<SiFileUploaderComponent, "si-file-uploader", never, { "uploadTextFileSelect": { "alias": "uploadTextFileSelect"; "required": false; "isSignal": true; }; "uploadDropText": { "alias": "uploadDropText"; "required": false; "isSignal": true; }; "maxFileSizeText": { "alias": "maxFileSizeText"; "required": false; "isSignal": true; }; "maxFilesReachedText": { "alias": "maxFilesReachedText"; "required": false; "isSignal": true; }; "acceptText": { "alias": "acceptText"; "required": false; "isSignal": true; }; "uploadButtonText": { "alias": "uploadButtonText"; "required": false; "isSignal": true; }; "clearButtonText": { "alias": "clearButtonText"; "required": false; "isSignal": true; }; "uploadingText": { "alias": "uploadingText"; "required": false; "isSignal": true; }; "removeButtonText": { "alias": "removeButtonText"; "required": false; "isSignal": true; }; "cancelButtonText": { "alias": "cancelButtonText"; "required": false; "isSignal": true; }; "successTextTitle": { "alias": "successTextTitle"; "required": false; "isSignal": true; }; "errorUploadFailed": { "alias": "errorUploadFailed"; "required": false; "isSignal": true; }; "showHttpError": { "alias": "showHttpError"; "required": false; "isSignal": true; }; "errorTextFileType": { "alias": "errorTextFileType"; "required": false; "isSignal": true; }; "errorTextFileMaxSize": { "alias": "errorTextFileMaxSize"; "required": false; "isSignal": true; }; "uploadConfig": { "alias": "uploadConfig"; "required": false; "isSignal": true; }; "accept": { "alias": "accept"; "required": false; "isSignal": true; }; "maxFileSize": { "alias": "maxFileSize"; "required": false; "isSignal": true; }; "maxFiles": { "alias": "maxFiles"; "required": false; "isSignal": true; }; "maxConcurrentUploads": { "alias": "maxConcurrentUploads"; "required": false; "isSignal": true; }; "retries": { "alias": "retries"; "required": false; "isSignal": true; }; "autoUpload": { "alias": "autoUpload"; "required": false; "isSignal": true; }; "disableUpload": { "alias": "disableUpload"; "required": false; "isSignal": true; }; "directoryUpload": { "alias": "directoryUpload"; "required": false; "isSignal": true; }; }, { "uploadCanceled": "uploadCanceled"; "uploadCompleted": "uploadCompleted"; "filesChanges": "filesChanges"; }, never, never, true, never>;
}

declare class SiFileUploaderModule {
    static ɵfac: _angular_core.ɵɵFactoryDeclaration<SiFileUploaderModule, never>;
    static ɵmod: _angular_core.ɵɵNgModuleDeclaration<SiFileUploaderModule, never, [typeof SiFileDropzoneComponent, typeof SiFileUploaderComponent, typeof SiFileUploadDirective], [typeof SiFileDropzoneComponent, typeof SiFileUploaderComponent, typeof SiFileUploadDirective]>;
    static ɵinj: _angular_core.ɵɵInjectorDeclaration<SiFileUploaderModule>;
}

export { SiFileDropzoneComponent, SiFileUploadDirective, SiFileUploaderComponent, SiFileUploaderModule };
export type { FileUploadConfig, FileUploadError, FileUploadResult, UploadFile };
