"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.handleManagementPowerRequests = handleManagementPowerRequests;
const powerCommands_1 = require("./powerCommands");
function handleManagementPowerRequests(onCommand, dispatch, frontApplet) {
    onCommand(async (commandEvent) => {
        switch (commandEvent.command.type) {
            case powerCommands_1.PowerSystemRebootRequest:
                await dispatch({
                    type: powerCommands_1.PowerSystemRebootResult,
                    result: {},
                });
                await frontApplet.management.power.systemReboot();
                break;
            case powerCommands_1.PowerAppRestartRequest:
                await dispatch({
                    type: powerCommands_1.PowerAppRestartResult,
                    result: {},
                });
                await frontApplet.management.power.appRestart();
                break;
            case powerCommands_1.ManagementPowerGetTimersRequest:
                await dispatch({
                    type: powerCommands_1.ManagementPowerGetTimersResult,
                    timers: await frontApplet.management.power.getTimers(),
                });
                break;
            case powerCommands_1.ManagementPowerSetTimerRequest:
                await frontApplet.management.power.setTimer(commandEvent.command.timerType, commandEvent.command.timeOn, commandEvent.command.timeOff, commandEvent.command.weekdays, commandEvent.command.volume);
                await dispatch({
                    type: powerCommands_1.ManagementPowerSetTimerResult,
                    result: {},
                });
                break;
            case powerCommands_1.ManagementPowerUnsetTimerRequest:
                await frontApplet.management.power.unsetTimer(commandEvent.command.timerType);
                await dispatch({
                    type: powerCommands_1.ManagementPowerUnsetTimerResult,
                    result: {},
                });
                break;
            case powerCommands_1.ManagementPowerGetProprietaryTimersRequest:
                await dispatch({
                    type: powerCommands_1.ManagementPowerGetProprietaryTimersResult,
                    result: await frontApplet.management.power.getProprietaryTimers(),
                });
                break;
            case powerCommands_1.ManagementPowerSetProprietaryTimerRequest:
                await frontApplet.management.power.setProprietaryTimer(commandEvent.command.timerType, commandEvent.command.timeOn, commandEvent.command.timeOff, commandEvent.command.weekdays, commandEvent.command.keepAppletRunning);
                await dispatch({
                    type: powerCommands_1.ManagementPowerSetProprietaryTimerResult,
                    result: {},
                });
                break;
            case powerCommands_1.ManagementPowerUnsetProprietaryTimerRequest:
                await frontApplet.management.power.unsetProprietaryTimer(commandEvent.command.timerType);
                await dispatch({
                    type: powerCommands_1.ManagementPowerUnsetProprietaryTimerResult,
                    result: {},
                });
                break;
            case powerCommands_1.ManagementPowerClearScheduledRebootsRequest:
                await frontApplet.management.power.clearScheduledReboots();
                await dispatch({
                    type: powerCommands_1.ManagementPowerClearScheduledRebootsResult,
                    result: {},
                });
                break;
            case powerCommands_1.ManagementPowerGetScheduledRebootsRequest:
                await dispatch({
                    type: powerCommands_1.ManagementPowerGetScheduledRebootsResult,
                    result: await frontApplet.management.power.getScheduledReboots(),
                });
                break;
            case powerCommands_1.ManagementPowerRemoveScheduledRebootRequest:
                await frontApplet.management.power.removeScheduledReboot(commandEvent.command.id);
                await dispatch({
                    type: powerCommands_1.ManagementPowerRemoveScheduledRebootResult,
                    result: {},
                });
                break;
            case powerCommands_1.ManagementPowerSetScheduledRebootRequest:
                await frontApplet.management.power.setScheduledReboot(commandEvent.command.weekdays, commandEvent.command.time);
                await dispatch({
                    type: powerCommands_1.ManagementPowerSetScheduledRebootResult,
                    result: {},
                });
                break;
            default:
        }
    });
}
//# sourceMappingURL=handlePowerRequests.js.map