
import Interface4Background from "./Interface4Background";
import BackgroundService from "../domain/BackgroundService";
import TabScript from "../domain/TabScript";
import Comment from "../domain/Comment";
import State from "../domain/State";
import RuleService from "../domain/RuleService";
import Interface4ViewManager from "./Interface4ViewManager";
import ViewManagerService from "../domain/ViewManagerService";
import ExplorationEvaluation from "../domain/ExplorationEvaluation";
import Question from "../domain/Question";
import Action from "../domain/Action";

export default class TabScriptService implements Interface4Background, Interface4ViewManager {
    private _tabScript : TabScript;

    constructor(backgroundService : BackgroundService, shadowMode : boolean = false) {
        this._tabScript = new TabScript(backgroundService, this, shadowMode);
    }

    synchronizeWithBackground() : Promise<void> {
        return this._tabScript.synchronizeWithBackground();
    }

    getRuleService() : RuleService {
        return this._tabScript.getRuleService();
    }

    explorationStarted() :void{
        this._tabScript.explorationStarted();
    }

    explorationStopped() :void{
        this._tabScript.explorationStopped();
    }

    reload() :void{
        this._tabScript.reload();
    }

    toggleUserView(visible: boolean) :void{
        this._tabScript.toggleUserView(visible);
    }

    getState(): Promise<State> {
        return this._tabScript.getState();
    }

    getCommentList(): Promise<Comment[]> {
        return this._tabScript.getCommentList();
    }

    getActionList(): Action[] {
        return this._tabScript.getActionList();
    }

    getExplorationEvaluation(): Promise<ExplorationEvaluation | null> {
        return this._tabScript.getExplorationEvaluation()
    }

    commentConfirmed(comment: Comment): Promise<void> {
        return this._tabScript.commentConfirmed(comment);
    }

    setUserViewPosition(newPosition : {x : number, y: number}) :void{
        this._tabScript.setUserViewPosition(newPosition);
    }

    pushAnswer(question: Question, value: boolean) :void{
        this._tabScript.pushAnswer(question, value);
    }

}