import {
  DocumentScannerConfiguration,
  BarcodeScannerConfiguration,
  BatchBarcodeScannerConfiguration,
  CroppingConfiguration,
  MrzScannerConfiguration,
  HealthInsuranceCardScannerConfiguration,
  TextDataScannerConfiguration,
  LicensePlateScannerConfiguration,
  MedicalCertificateRecognizerConfiguration,
  GenericDocumentRecognizerConfiguration,
} from './configuration';

export {
  DocumentScannerConfiguration,
  BarcodeScannerConfiguration,
  BatchBarcodeScannerConfiguration,
  CroppingConfiguration,
  MrzScannerConfiguration,
  HealthInsuranceCardScannerConfiguration,
  TextDataScannerConfiguration,
  LicensePlateScannerConfiguration,
  MedicalCertificateRecognizerConfiguration,
};

import {
  DetectBarcodesOnImageArguments,
  DetectBarcodesOnImagesArguments,
  ExtractPagesFromPdfArguments,
  ExtractImagesFromPdfArguments,
  ExtractPagesFromPdfResult,
  ExtractImagesFromPdfResult,
} from './arguments';

export {
  DetectBarcodesOnImageArguments,
  DetectBarcodesOnImagesArguments,
  ExtractPagesFromPdfArguments,
  ExtractImagesFromPdfArguments,
  ExtractPagesFromPdfResult,
  ExtractImagesFromPdfResult,
};

import {
  BarcodeFormat,
  CameraPreviewMode,
  FileEncryptionMode,
  MSIPlesseyChecksumAlgorithm,
} from './configuration';

export {
  BarcodeFormat,
  CameraPreviewMode,
  FileEncryptionMode,
  MSIPlesseyChecksumAlgorithm,
};

import {
  DetectionStatus,
  ImageFilter,
  Status,
  MRZDocumentType,
  CameraImageFormat,
  OCROutputFormat,
  PDFPageSize,
  LicenseStatus,
  TIFFCompression,
} from './enum';

export {
  DetectionStatus,
  ImageFilter,
  Status,
  MRZDocumentType,
  CameraImageFormat,
  OCROutputFormat,
  PDFPageSize,
  LicenseStatus,
  TIFFCompression,
};

import {
  DocumentScannerResult,
  CroppingResult,
  MrzResult,
  BarcodeResult,
  DocumentDetectionResult,
  MrzRecognitionResult,
  HealthInsuranceCardScannerResult,
  TextDataScannerResult,
  LicensePlateScannerResult,
  DetectBarcodesOnImagesResult,
  MedicalCertificateScannerResult,
  GenericDocumentRecognizerResult,
  GenericDocumentField,
} from './result';

export {
  DocumentScannerResult,
  CroppingResult,
  MrzResult,
  BarcodeResult,
  DocumentDetectionResult,
  MrzRecognitionResult,
  HealthInsuranceCardScannerResult,
  TextDataScannerResult,
  LicensePlateScannerResult,
  DetectBarcodesOnImagesResult,
  MedicalCertificateScannerResult,
  GenericDocumentRecognizerResult,
  GenericDocumentField,
};

import {Page, Point, Size, InitializationOptions, LicenseInfo} from './model';
export {Page, Point, Size, InitializationOptions, LicenseInfo};

export interface ScanbotSDKUI {
  startDocumentScanner(
    configuration: DocumentScannerConfiguration,
  ): Promise<DocumentScannerResult>;

  closeDocumentScanner(): Promise<void>;

  startCroppingScreen(
    page: Page,
    configuration: CroppingConfiguration,
  ): Promise<CroppingResult>;

  closeCroppingScreen(): Promise<void>;

  startMrzScanner(configuration: MrzScannerConfiguration): Promise<MrzResult>;

  closeMrzScanner(): Promise<void>;

  startBarcodeScanner(
    configuration: BarcodeScannerConfiguration,
  ): Promise<BarcodeResult>;

  closeBarcodeScanner(): Promise<void>;

  startBatchBarcodeScanner(
    configuration: BatchBarcodeScannerConfiguration,
  ): Promise<BarcodeResult>;

  closeBatchBarcodeScanner(): Promise<void>;

  startEHICScanner(
    configuration: HealthInsuranceCardScannerConfiguration,
  ): Promise<HealthInsuranceCardScannerResult>;

  closeEHICScanner(): Promise<void>;

  startTextDataScanner(
    configuration: TextDataScannerConfiguration,
  ): Promise<TextDataScannerResult>;

  closeTextDataScanner(): Promise<void>;

  startLicensePlateScanner(
    configuration: LicensePlateScannerConfiguration,
  ): Promise<LicensePlateScannerResult>;

  closeLicensePlateScanner(): Promise<void>;

  startMedicalCertificateScanner(
    configuration: MedicalCertificateRecognizerConfiguration,
  ): Promise<MedicalCertificateScannerResult>;

  closeMedicalCertificateScanner(): Promise<void>;

  startGenericDocumentRecognizer(
    configuration: GenericDocumentRecognizerConfiguration,
  ): Promise<GenericDocumentRecognizerResult>;

  closeGenericDocumentRecognizer(): Promise<void>;
}

export interface ScanbotSDKInternal {
  setNativeValidateProperty(result: string): void;
  setNativeProcessProperty(result: string): void;
}

export interface ScanbotSDK {
  UI: ScanbotSDKUI;
  Internal: ScanbotSDKInternal;

  initializeSDK(options: InitializationOptions): Promise<{result: string}>;
  getLicenseInfo(): Promise<LicenseInfo>;

  detectDocument(imageFileUri: string): Promise<DocumentDetectionResult>;

  detectBarcodesOnImage(
    args: DetectBarcodesOnImageArguments,
  ): Promise<BarcodeResult>;
  detectBarcodesOnImages(
    args: DetectBarcodesOnImagesArguments,
  ): Promise<DetectBarcodesOnImagesResult>;

  applyFilter(imageFileUri: string, filter: ImageFilter): Promise<string>;
  getOCRConfigs(): Promise<{
    languageDataPath: string;
    installedLanguages: string[];
  }>;
  performOCR(
    imageFileUris: string[],
    languages: string[],
    options: {
      outputFormat?: OCROutputFormat;
    },
  ): Promise<{
    plainText?: string;
    pdfFileUri?: string;
    jsonData?: any;
  }>;
  createPDF(
    imageFileUris: string[],
    pageSize: PDFPageSize,
  ): Promise<{
    pdfFileUri: string;
  }>;
  writeTIFF(
    imageFileUris: string[],
    options: {
      oneBitEncoded?: boolean;
      dpi?: number;
      compression?: TIFFCompression;
    },
  ): Promise<{
    tiffFileUri: string;
  }>;

  rotateImage(imageFileUri: string, degrees: number): Promise<string>;

  createPage(imageUri: string): Promise<Page>;
  setDocumentImage(page: Page, imageUri: string): Promise<Page>;

  detectDocumentOnPage(page: Page): Promise<Page>;
  estimateBlur(args: {imageFileUri: string}): Promise<{blur: number}>;

  applyImageFilterOnPage(page: Page, filter: ImageFilter): Promise<Page>;
  rotatePage(page: Page, times: number): Promise<Page>;
  getFilteredDocumentPreviewUri(
    page: Page,
    filter: ImageFilter,
  ): Promise<string>;

  recognizeMrz(imageFileUri: string): Promise<MrzRecognitionResult>;

  removePage(page: Page): Promise<void>;
  refreshImageUris(args: {pages: Page[]}): Promise<{pages: Page[]}>;

  cleanup(): Promise<void>;

  getImageData(imageFileUri: string): Promise<{base64ImageData: string}>;

  extractPagesFromPdf(
    args: ExtractPagesFromPdfArguments,
  ): Promise<ExtractPagesFromPdfResult>;
  extractImagesFromPdf(
    args: ExtractImagesFromPdfArguments,
  ): Promise<ExtractImagesFromPdfResult>;
}

declare var ScanbotSDK: ScanbotSDK;

export default ScanbotSDK;

export * from './components/barcode-camera-view/scanbot-barcode-camera-view';
export * from './components/barcode-camera-view/scanbot-barcode-camera-view-types';
