"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.StateIsCompleteUC = void 0;
exports.makeStateIsCompleteUC = makeStateIsCompleteUC;
exports.stateIsComplete = stateIsComplete;
const core_1 = require("@vived/core");
const core_2 = require("@vived/core");
const AppDispatcher_1 = require("../Entities/AppDispatcher");
class StateIsCompleteUC extends core_2.AppObjectUC {
    constructor() {
        super(...arguments);
        this.requestType = "ON_STATE_COMPLETED";
    }
}
exports.StateIsCompleteUC = StateIsCompleteUC;
StateIsCompleteUC.type = "StateIsCompleteUC";
StateIsCompleteUC.get = (appObjects) => (0, core_1.getSingletonComponent)(StateIsCompleteUC.type, appObjects);
function makeStateIsCompleteUC(appObject) {
    return new StateIsCompleteUCImp(appObject);
}
function stateIsComplete(appObjects) {
    const uc = StateIsCompleteUC.get(appObjects);
    if (uc) {
        uc.doDispatch();
    }
    else {
        appObjects.submitWarning("stateIsComplete", "Can't find StateIsCompleteUC");
    }
}
class StateIsCompleteUCImp extends StateIsCompleteUC {
    constructor(appObject) {
        super(appObject, StateIsCompleteUC.type);
        this.requestVersion = 1;
        this.doDispatch = () => {
            if (!this.appDispatcher)
                return;
            this.appDispatcher.formRequestAndDispatch(this.requestType, this.requestVersion);
        };
        this.appDispatcher = appObject.getComponent(AppDispatcher_1.AppDispatcher.type);
        if (!this.appDispatcher) {
            this.warn("GoToNextStateUC has been added to an App Object that does not have a AppDispatcher. Add a dispatcher first");
            this.dispose();
        }
    }
}
//# sourceMappingURL=StateIsCompleteUC.js.map