"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.DisposeAppBaseUC = void 0;
exports.makeDisposeAppUC = makeDisposeAppUC;
const core_1 = require("@vived/core");
const Entities_1 = require("../Entities");
class DisposeAppBaseUC extends core_1.AppObjectUC {
    constructor() {
        super(...arguments);
        this.requestType = "DISPOSE_APP";
        this.payloadVersion = 1;
    }
}
exports.DisposeAppBaseUC = DisposeAppBaseUC;
DisposeAppBaseUC.type = "DisposeAppBaseUC";
function makeDisposeAppUC(appObject) {
    return new DisposeAppBaseUCImp(appObject);
}
class DisposeAppBaseUCImp extends DisposeAppBaseUC {
    constructor(appObject) {
        super(appObject, DisposeAppBaseUC.type);
        this.action = () => {
            // inject if needed
        };
        this.handleRequest = (version) => {
            if (version === this.payloadVersion) {
                this.action();
            }
            else {
                throw new Entities_1.UnsupportedRequestVersion(this.requestType, version);
            }
        };
        const handler = appObject.getComponent(Entities_1.AppHandlerEntity.type);
        if (!handler) {
            this.warn("DisposeAppBaseUC has been added to an app object that does not have an AppHandlerEntity. Add one first");
            return;
        }
        handler.registerRequestHandler(this);
    }
}
//# sourceMappingURL=DisposeAppUC.js.map