import * as i0 from '@angular/core';
import { PipeTransform, OnInit, OnDestroy, EventEmitter, ChangeDetectorRef } from '@angular/core';
import { MatPaginator } from '@angular/material/paginator';
import { SdModal } from '@sdcorejs/angular/components/modal';
import { SdExcelService } from '@sdcorejs/angular/services/excel';
import { SdNotifyService } from '@sdcorejs/angular/services/notify';
import { SdLoadingService } from '@sdcorejs/angular/services/loading';

interface SdImportExcelValidation {
    idx: number;
    errorMessage?: string;
    warningMessage?: string;
}
interface SdImportExcelSheet<T = any> {
    name: string;
    items: T[] | (() => Promise<T[]>);
    headers: {
        value: Extract<keyof T, string>;
        display: string;
    }[];
}
interface SdImportExcelOption<T = any> {
    columns: SdUploadExcelColumn<T>[];
    accept: (items: T[], args: {
        file: File;
    }) => SdImportExcelValidation[] | Promise<SdImportExcelValidation[]>;
    title?: string;
    fileName?: string;
    limit?: number;
    sheets?: SdImportExcelSheet[];
    transform?: (items: SdImportExcelItem<T>[]) => SdImportExcelItem<T>[] | Promise<SdImportExcelItem<T>[]>;
    validateItem?: (item: T, idx: number, items: T[]) => SdImportExcelValidation | Promise<SdImportExcelValidation>;
    validateItems?: (items: T[]) => SdImportExcelValidation[] | Promise<SdImportExcelValidation[]>;
}
type SdUploadExcelColumn<T = any> = SdUploadExcelColumnString<T> | SdUploadExcelColumnNumber<T> | SdUploadExcelColumnBool<T> | SdUploadExcelColumnDate<T> | SdUploadExcelColumnTime<T> | SdUploadExcelColumnDateTime<T> | SdUploadExcelColumnValues<T> | SdUploadExcelColumnStringArray<T>;
interface SdUploadExcelBaseColumn<T = any> {
    field: string;
    title: string;
    required?: boolean;
    width?: string;
    description?: string;
    hidden?: boolean | (() => boolean);
    fontColor?: string;
    fill?: string;
    transform?: (value: any, rowData: T) => string | Promise<string>;
}
interface SdUploadExcelColumnString<T = any> extends SdUploadExcelBaseColumn<T> {
    type: 'string';
    defaultValue?: string;
    pattern?: string;
    minlength?: number;
    maxlength?: number;
}
interface SdUploadExcelColumnNumber<T = any> extends SdUploadExcelBaseColumn<T> {
    type: 'number';
    defaultValue?: number;
    min?: number;
    max?: number;
}
interface SdUploadExcelColumnBool<T = any> extends SdUploadExcelBaseColumn<T> {
    type: 'bool';
    defaultValue?: boolean;
    parseToBool?: boolean;
}
interface SdUploadExcelColumnDate<T = any> extends SdUploadExcelBaseColumn<T> {
    type: 'date';
    format?: 'dd/MM/yyyy';
    defaultValue?: Date;
    minDate?: Date;
    maxDate?: Date;
}
interface SdUploadExcelColumnTime<T = any> extends SdUploadExcelBaseColumn<T> {
    type: 'time';
    format?: 'HH:mm' | 'HH:mm:ss';
    defaultValue?: Date;
    minDate?: Date;
    maxDate?: Date;
}
interface SdUploadExcelColumnDateTime<T = any> extends SdUploadExcelBaseColumn<T> {
    type: 'datetime';
    format?: 'dd/MM/yyyy HH:mm' | 'dd/MM/yyyy';
    defaultValue?: Date;
    minDate?: Date;
    maxDate?: Date;
}
interface SdUploadExcelColumnValues<T = any> extends SdUploadExcelBaseColumn<T> {
    type: 'values' | 'radio';
    defaultValue?: string | number;
    values: (string | number)[];
    checkValueInArray?: boolean;
}
interface SdUploadExcelColumnStringArray<T = any> extends SdUploadExcelBaseColumn<T> {
    type: 'array';
    divideString: string | ';';
    unitString: string | 'items';
    defaultValue?: string;
    minlength?: number;
    maxlength?: number;
}
type SdImportExcelItem<T = any> = {
    data: T;
    meta: {
        excelIndex: number;
        origin: T;
        error: Record<string, string>;
        errorMessages: string[];
        warning: Record<string, string>;
        warningMessages: string[];
    };
};

declare class ColumnHiddenPipe implements PipeTransform {
    constructor();
    transform(column: SdUploadExcelColumn): boolean;
    static ɵfac: i0.ɵɵFactoryDeclaration<ColumnHiddenPipe, never>;
    static ɵpipe: i0.ɵɵPipeDeclaration<ColumnHiddenPipe, "columnHidden", true>;
    static ɵprov: i0.ɵɵInjectableDeclaration<ColumnHiddenPipe>;
}

declare class SdImportExcel implements OnInit, OnDestroy {
    #private;
    private ref;
    private excelService;
    private notifyService;
    private columnHiddenPipe;
    private loadingService;
    option: SdImportExcelOption;
    modal: SdModal;
    excelItems: SdImportExcelItem[];
    hasDescription: boolean;
    showing: 'ALL' | 'SUCCESS' | 'WARNING' | 'ERROR';
    filteredItems: SdImportExcelItem[];
    viewItems: SdImportExcelItem[];
    numberOfSuccess: number;
    numberOfError: number;
    numberOfWarning: number;
    file?: File;
    set paginator(paginator: MatPaginator);
    uploading: boolean;
    isUploaded: boolean;
    isDownloadTemplate: boolean;
    sdClosed: EventEmitter<any>;
    constructor(ref: ChangeDetectorRef, excelService: SdExcelService, notifyService: SdNotifyService, columnHiddenPipe: ColumnHiddenPipe, loadingService: SdLoadingService);
    ngOnInit(): void;
    ngOnDestroy(): void;
    open: () => void;
    close: () => void;
    upload: () => Promise<void>;
    accept: () => void;
    setValidation: (validations: SdImportExcelValidation[]) => void;
    view: (showing?: "ALL" | "SUCCESS" | "WARNING" | "ERROR") => void;
    downloadTemplate: () => Promise<void>;
    export: () => Promise<void>;
    onClosed: () => void;
    static ɵfac: i0.ɵɵFactoryDeclaration<SdImportExcel, never>;
    static ɵcmp: i0.ɵɵComponentDeclaration<SdImportExcel, "sd-import-excel", never, { "option": { "alias": "option"; "required": true; }; }, { "sdClosed": "sdClosed"; }, never, never, true, never>;
}

export { SdImportExcel };
export type { SdImportExcelItem, SdImportExcelOption, SdImportExcelSheet, SdImportExcelValidation, SdUploadExcelBaseColumn, SdUploadExcelColumn, SdUploadExcelColumnBool, SdUploadExcelColumnDate, SdUploadExcelColumnDateTime, SdUploadExcelColumnNumber, SdUploadExcelColumnString, SdUploadExcelColumnStringArray, SdUploadExcelColumnTime, SdUploadExcelColumnValues };
