import type {CapturedResult} from "./CapturedResult";
import type {DecodedBarcodesResult} from "../dbr";
import type {RecognizedTextLinesResult} from "../dlr";
import type {ParsedResult} from "../dcp";
import type {ProcessedDocumentResult} from "../ddn";
import { CaptureVisionRouter } from ".";

/**
 * The CapturedResultReceiver class is designed as a standardized way for retrieving captured results in the Dynamsoft Capture Vision architecture.
 * It adopts an event-driven approach, with events dedicated to various result types,
 * such as the original image, decoded barcodes, recognized text lines, detected quads, normalized images, and parsed results, etc.
 *   <p>Code snippet:</p>
 *
 *   ```
 *   val router: CaptureVisionRouter
 *   router.addResultReceiver({
 *      onDecodedBarcodesReceived: result =>  {
 *          //Handle barcodes. `result` is an instance of DecodedBarcodesResult.
 *      },
 *
 *      onRecognizedTextLinesReceived: result => {
 *          //Handle the result of text recognition. `result` is an instance of RecognizedTextLinesResult.
 *      },
 *   })
 *   ```
 *
 * @see {@link CaptureVisionRouter.addResultReceiver}
 * */
export interface CapturedResultReceiver {
    /**
     * Event triggered when a generic captured result is available, occurring each time an image finishes its processing.
     * This event can be used for any result that does not fit into the specific categories of the other callback events.
     *
     * @see {@link CapturedResult}
     * */
    onCapturedResultReceived?: (result: CapturedResult) => void;

    /**
     * Event triggered when decoded barcodes are available.
     * This event is used to handle barcodes that have been successfully decoded by Dynamsoft Barcode Reader.
     *
     * @see {@link DecodedBarcodesResult}
     * */
    onDecodedBarcodesReceived?: (result: DecodedBarcodesResult) => void;

    /**
     * Event triggered when recognized text lines are available.
     * This event is used to handle the result of text recognition by Dynamsoft Label Recognizer.
     *
     * @see {@link RecognizedTextLinesResult}
     * */
    onRecognizedTextLinesReceived?: (result: RecognizedTextLinesResult) => void;

    /**
     * Event triggered when parsed results are available.
     * This event is used for handling results that have been parsed into a structured format by Dynamsoft Code Parser.
     *
     * @see {@link ParsedResult}
     * */
    onParsedResultsReceived?: (result: ParsedResult) => void;

    /**
     * Event triggered when processed document result are available.
     * This event is used for handling images that have been processed or normalized (e.g., corrected for skew or perspective),
     * by Dynamsoft Document Normalizer.
     *
     * @see {@link ProcessedDocumentResult}
     * */
    onProcessedDocumentResultReceived?: (result: ProcessedDocumentResult) => void;

}
