import {Status} from './enum';
import {Page} from './model';
import {
  BarcodeDocumentFormat,
  BarcodeFormat,
  MSIPlesseyChecksumAlgorithm,
} from './configuration';

interface InternalBarcodeDetectionCommonParameters {
  /**
   * Accepted barcode formats
   */
  barcodeFormats?: BarcodeFormat[];
  /**
   * An optional array of barcode document formats that act as a detection filter.
   * By default all supported document formats will be detected.
   */
  acceptedDocumentFormats?: BarcodeDocumentFormat[];
  /**
   * Optional minimum required text length of the detected barcode.
   * The default is 0 (setting is turned off).
   * NOTE: This feature works on ITF barcodes only.
   */
  minimumTextLength?: number;
  /**
   * Optional maximum required text length of the detected barcode.
   * The default is 0 (setting is turned off).
   * NOTE: This feature works on ITF barcodes only.
   */
  maximumTextLength?: number;
  /**
   * Optional minimum required quiet zone on the barcode.
   * Measured in modules (the size of minimal bar on the barcode).
   * The default is 10.
   * NOTE: This feature works on ITF barcodes only.
   */
  minimum1DBarcodesQuietZone?: number;
  /**
   * With this option enabled, the scanner removes checks digits for UPC, EAN and MSI Plessey codes.
   * Has no effect if both single and double digit MSI Plessey checksums are enabled.
   * The default is `false`
   */
  stripCheckDigits?: boolean;
  /**
   * When set to `true`, the scanner assumes that the barcode can be a GS1 barcode.
   * Turn it off, if you don't want to see decoded FNC1 characters ("]C1" and ASCII char 29).
   * The default value is `true`.
   * NOTE: Currently works for CODE128 barcodes only!
   */
  gs1DecodingEnabled?: boolean;
  /**
   * The checksum algorithm for MSI Plessey barcodes.
   * The default value is Mod10.
   */
  msiPlesseyChecksumAlgorithm?: MSIPlesseyChecksumAlgorithm;
}

export interface DetectBarcodesOnImageArguments
  extends InternalBarcodeDetectionCommonParameters {
  /**
   * The input image file URI
   */
  imageFileUri: string;
}

export interface DetectBarcodesOnImagesArguments
  extends InternalBarcodeDetectionCommonParameters {
  /**
   * The input image files URIs
   */
  imageFileUris: string[];
}

interface PdfExtractorArguments {
  /**
   * The location of the PDF file
   */
  pdfFilePath: string;
  /**
   * The quality that each extracted image should have.
   * This tweaks the compression, affecting the final image file size.
   * (100: maximum quality, 0: minimum quality)
   *
   * Default value is 90
   */
  quality?: number;
  /**
   * Integer scaling factor applied to the PDF media box frame while extracting.
   * Affects the output image quality.
   * In most cases the recommended value is 2 or higher.
   *
   * Default value is 2.
   */
  scaling?: number;
}

export interface ExtractImagesFromPdfArguments extends PdfExtractorArguments {}
export interface ExtractImagesFromPdfResult {
  /**
   * The status of the operation (OK or CANCELED)
   */
  status: Status;
  /**
   * A list containing the file URLs for the extracted images
   */
  imageFilesUrls?: string[];
}

export interface ExtractPagesFromPdfArguments extends PdfExtractorArguments {}
export interface ExtractPagesFromPdfResult {
  /**
   * The status of the operation (OK or CANCELED)
   */
  status: Status;
  /**
   * A list containing the extracted pages
   */
  pages?: Page[];
}
