import { AnswerHistoryEntry, ExamAnswer, QuestionId } from './ExamAnswer';
export type SaveState = 'initial' | 'saving' | 'saved';
/**
 * CAS status is a state machine with three states.
 *
 * ```
 * +---------+       +--------+      +-------+
 * |forbidden| <---> |allowing| ---> |allowed|
 * +---------+       +--------+      +-------+
 * ```
 *
 * When the user clicks the "Palauta A-osa" button, we start a 60s countdown
 * and transition the state from `'forbidden'` to `'allowing'`. When the timer reaches
 * zero, we transition the state from `'allowing'` to `'allowed'`. Cancelling
 * the countdown transitions the state back from `'allowing'` to `'forbidden'`.
 */
export type CasStatus = InitialCasStatus | 'allowing';
export type InitialCasStatus = 'allowed' | 'forbidden';
export type RestrictedAudioId = number;
export type AudioError = 
/** The user has already accessed this restricted audio */
'already-accessed'
/** There already is an audio file playing */
 | 'already-playing'
/** Permission to use microphone denied */
 | 'permission-denied'
/** Other recording error, e.g. a network issue */
 | 'other-recording-error'
/** Other error, e.g. a network issue */
 | 'other-error';
export type AudioPlaybackResponse = 'ok' | AudioError;
export interface RestrictedAudioPlaybackStats {
    /** An unique identifier for each restricted audio element */
    restrictedAudioId: RestrictedAudioId;
    /** Number of times it has been listened to. */
    times: number;
}
export interface ExamServerAPI {
    /**
     * Setting CAS status to allowed will lock the answers for each section where
     * the use of CAS software is forbidden.
     *
     * All state transitions are not legal (for example, you may not disable CAS
     * software after they have been allowed), so the function returns the CAS
     * status that the server decided upon.
     */
    setCasStatus: (casStatus: CasStatus) => Promise<CasStatus>;
    /** Retrieve the latest answer for each question */
    getAnswers: () => Promise<ExamAnswer[]>;
    /** Retrieve the answer history for one question */
    getAnswerHistory?: (questionId: number) => Promise<AnswerHistoryEntry[]>;
    /** Save a new answer to the server */
    saveAnswer: (answer: ExamAnswer) => Promise<void>;
    /**
     * Play a non-restricted audio file. Right now, this is only used by the
     * audio test. The Promise should be resolved with `'ok'` when playback starts
     * or with an error response if an error occurs.
     */
    playAudio: (src: string) => Promise<AudioPlaybackResponse>;
    /**
     * Play a restricted audio file. The promise should be resolved with `'ok'`
     * when the playback starts or with an error response if an error occurs.
     *
     * @param restrictedAudioId A number that uniquely identifies each restricted audio element.
     * @param playbackTimes How many times this audio has been listened to already.
     */
    playRestrictedAudio: (src: string, restrictedAudioId: number, playbackTimes: number) => Promise<AudioPlaybackResponse>;
    /**
     * Get restricted audio file in a blob. The promise should be resolved with blob
     * when the audio file has be loaded or rejected with an error response if an error occurs.
     *
     * @param restrictedAudioId A number that uniquely identifies each restricted audio element.
     * @param playbackTimes How many times this audio has been listened to already.
     */
    getRestrictedAudio: (src: string, restrictedAudioId: number, playbackTimes: number) => Promise<Blob>;
    /** Select another answer version from answer history. Return undefined to cancel. Optional feature. */
    selectAnswerVersion?: (questionId: QuestionId, questionTitle: string) => Promise<ExamAnswer | undefined>;
    /** Save screenshot to server. Should return the URL to the saved screenshot. */
    saveScreenshot: (questionId: QuestionId, screenshot: Blob) => Promise<string>;
    /** Save audio to server. Should return the URL to the saved audio. */
    saveAudio: (questionId: QuestionId, audio: Blob) => Promise<string>;
    /** Delete audio from server */
    deleteAudio: (audioId: string) => Promise<void>;
    examineExam?: () => void;
    /** Log client activity to server. Message format is free. Optional feature. */
    logActivity?: (message: string) => void;
    /** Called when an irrecoverable error occurs. Exam engine should be shut down gracefully in handler. */
    onFatalError?: (error: unknown) => void;
}
//# sourceMappingURL=ExamServerAPI.d.ts.map