/*! phoscon-app 2024-02-26 */

import{serviceSend}from"./settings-gateway-machine.js";import{states,events}from"./settings-gateway-constants.js";import{restartOrShutdownGw,unloadListener}from"./settings-gateway-functions.js";const OPTION_RESTART="restart",RESTART_GW_TIME=3e4,RESTART_GW_TIME_FAIL=5e3;export var restartGwViewHandlerFactory=view=>(ctx,activity)=>{let event=activity.type;event===states.RESTART_GW?(view.show(),serviceSend(states.RESTART_GW_PAGE_1)):event===events.CLOSE_PRESSED&&(view.hide(),serviceSend(states.IDLE))};export var restartGwViewPage1HandlerFactory=view=>(ctx,activity)=>{let event=activity.type;event===states.RESTART_GW_PAGE_1?view.page1():event===events.NEXT_PRESSED&&serviceSend(states.RESTART_GW_PAGE_2)};export var restartGwViewPage2HandlerFactory=view=>(ctx,activity)=>{let event=activity.type;event===states.RESTART_GW_PAGE_2?(window.addEventListener("beforeunload",unloadListener),view.page2(),restartOrShutdownGw("restart")):event===events.RESTART_GW_SUCCESS?app.resetGatewayTimer=setTimeout(function(){serviceSend(states.RESTART_GW_PAGE_3)},3e4):event===events.RESTART_GW_FAIL&&(app.resetGatewayTimer=setTimeout(function(){serviceSend(states.RESTART_GW_PAGE_4)},5e3))};export var restartGwViewPage3HandlerFactory=view=>(ctx,activity)=>{activity.type===states.RESTART_GW_PAGE_3&&(window.removeEventListener("beforeunload",unloadListener),view.page3())};export var restartGwViewPage4HandlerFactory=view=>(ctx,activity)=>{activity.type===states.RESTART_GW_PAGE_4&&(window.removeEventListener("beforeunload",unloadListener),view.page4())};