import Background from "../domain/Background";
import CompatibilityCheck from "../domain/CompatibilityCheck";
import ConnectionCode from "../domain/ConnectionCode";
import ExplorationEvaluation from "../domain/ExplorationEvaluation";
import Question from "../domain/Question";
import StateForPopup from "../domain/StateForPopup";
import StateForTabScript from "../domain/StateForTabScript";
import Interface4Popup from "./Interface4Popup";
import Interface4TabScript from "./Interface4TabScript";

export default class BackgroundApplication implements Interface4Popup, Interface4TabScript {
	private _background : Background;

	constructor(browserService, aifexService, tabScriptService) {
		this._background = new Background(aifexService, browserService, tabScriptService);
	}


	/************************/
	/* For Popup        */
	/************************/	

	getStateForPopup() : StateForPopup {
		return this._background.getStateForPopup();
	}

	makeCompatibilityCheck(): Promise<CompatibilityCheck> {
		return this._background.makeCompatibilityCheck();
	}

	connect(sessionId: string, modelId: string): Promise<void> {
		const connectionCode = new ConnectionCode(sessionId, modelId);
		return this._background.connect(connectionCode);
	}

	disconnect(): Promise<void> {
		return this._background.disconnect();
	}

	reloadWebsite() : Promise<void> {
		return this._background.reloadWebsite();
	}

	startExploration() : Promise<void> {
		return this._background.startExploration();
	}

	stopExploration(): Promise<void> {
		return this._background.stopExploration();
	}

	changeTesterName(newName : string) : void {
		this._background.changeTesterName(newName);
	}

    setIsTabScriptDisplayingComments(isDisplaying : boolean) : void {
		this._background.setIsTabScriptDisplayingComments(isDisplaying);
	}

	restartExploration(): Promise<void> {
		return this._background.restartExploration();
	}

	removeExploration() : Promise<void> {
		return this._background.removeExploration();
	}

	addCommentToExploration(kind : string , message : string) {
		this._background.addCommentToExploration(kind, message);
	}

	takeScreenShot() {
		return this._background.takeScreenShot();
	}

	drawAttention(): Promise<void> {
		return this._background.drawAttention();
	}

	setRecordMedia(recordMedia: boolean) {
		return this._background.setRecordMedia(recordMedia);
	}



	/************************/
	/* For TabScript        */
	/************************/
	

	getStateForTabScript() : StateForTabScript {
		return this._background.getStateForTabScript();
	}

	getProbabilities(): Promise<{
		state: StateForTabScript;
		probabilityMap: string;
	} | void> {
		return this._background.getProbabilities();
	}

	getComments(): Promise<{
		state: StateForTabScript;
		commentDistributionList: string;
	} | void> {
		return this._background.getComments();
	}

	addActionToExploration(kind: string, value: string): Promise<void> {
		return this._background.addActionToExploration(kind, value);
	}

	addAnswerToExploration(question: Question, value: boolean) {
		this._background.addAnswerToExploration(question, value);
	}

	upComment(kind : string, value : string): void {
		return this._background.upComment(kind, value);
	}

	setPopupCommentPosition(position : {x: string, y: string}) {
		return this._background.setPopupCommentPosition(position);
	}

	getExplorationEvaluation(): Promise<ExplorationEvaluation> {
		return this._background.getExplorationEvaluation();
	}
}
