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

import{serviceSend}from"./settings-gateway-machine.js";import{states,events,productInfo}from"./settings-gateway-constants.js";export const SettingsGatewayStatusHandlerView=Backbone.View.extend({template:_.template(document.getElementById("settings-gateway-status-template").innerHTML),el:"#mainContentData",initialize:function(){let modelid;this.el.innerHTML=this.template(app.config),this.generalTapSvg=this.el.querySelector("#generalTab > svg > use"),this.advancedTapSvg=this.el.querySelector("#advancedTab > svg > use"),this.powerTap=this.el.querySelector("#powerTab"),modelid=app.config.has("devicename")?app.config.get("devicename"):app.config.get("modelid");let pInfo=productInfo[modelid]||productInfo.default;this.generalTapSvg.setAttribute("xlink:href",pInfo.id_sm),this.advancedTapSvg.setAttribute("xlink:href",pInfo.id_settings);const docker=-1!=(app.config.get("runmode")||"").indexOf("docker");"linux-gw"===app.config.get("system")&&!1===docker?this.powerTap.style.display="flex":!0===pInfo.powerOptions&&!1===docker?this.powerTap.style.display="flex":this.powerTap.style.display="none"},events:{"click #generalTab":function(){serviceSend({type:states.GENERAL,activeTab:"#generalTab"})},"click #advancedTab":function(e){e.altKey&&gatewayVersion()>=20559?serviceSend({type:states.DIAGNOSE,activeTab:"#advancedTab"}):serviceSend({type:states.ADVANCED,activeTab:"#advancedTab"})},"click #powerTab":function(){serviceSend({type:states.POWER,activeTab:"#powerTab"})}},render:function(){return this},setTapActive:function(ctx,activity){let tab=activity.activeTab||ctx.activeTab,elem=document.querySelector(tab);elem.parentNode.querySelectorAll("div").forEach(t=>t.classList.remove("active-tab")),elem.classList.add("active-tab")}});