"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.handleManagementApplicationRequests = handleManagementApplicationRequests;
const applicationCommands_1 = require("./applicationCommands");
function handleManagementApplicationRequests(onCommand, dispatch, frontApplet) {
    onCommand(async (commandEvent) => {
        switch (commandEvent.command.type) {
            case applicationCommands_1.ApplicationGetTypeRequest:
                await dispatch({
                    type: applicationCommands_1.ApplicationGetTypeResult,
                    applicationType: await frontApplet.management.app.getType(),
                });
                break;
            case applicationCommands_1.ApplicationGetVersionRequest:
                await dispatch({
                    type: applicationCommands_1.ApplicationGetVersionResult,
                    version: await frontApplet.management.app.getVersion(),
                });
                break;
            case applicationCommands_1.ApplicationUpgradeRequest:
                await dispatch({
                    type: applicationCommands_1.ApplicationUpgradeResult,
                    result: {},
                });
                await frontApplet.management.app.upgrade(commandEvent.command.version, commandEvent.command.baseUrl);
                break;
            default:
        }
    });
}
//# sourceMappingURL=handleApplicationRequests.js.map