/*! phoscon-app 2024-05-27 */

import{serviceSend}from"./settings-gateway-machine.js";import{states,events,productInfo}from"./settings-gateway-constants.js";import{setViewBox}from"./settings-gateway-functions.js";export const SettingsGatewayHandlerView=Backbone.View.extend({template:_.template(document.getElementById("settings-gateway-template").innerHTML),id:"settingsGwContent",className:"body-content-settings body-content",initialize:function(){let modelid;this.el.innerHTML=this.template(app.config),document.querySelector("body").appendChild(this.el),this.name=this.el.querySelector("#gwName"),this.lgSvgUse=this.el.querySelector("#product_lg_Svg > use"),this.gatewayImageLg=this.el.querySelector("#gatewayImageLg"),this.listenTo(app.config,"change",this.render),modelid=app.config.has("devicename")?app.config.get("devicename"):app.config.get("modelid");let pInfo=productInfo[modelid]||productInfo.default;"ConBee III"===modelid?(this.lgSvgUse.parentElement.style.display="none",this.gatewayImageLg.setAttribute("src","img/generals/conbee3-lg.png"),this.el.querySelector("#gwImageSm").setAttribute("xlink:href",pInfo.id_sm)):(this.gatewayImageLg.style.display="none",this.el.querySelector("#gwImageSm").setAttribute("xlink:href",pInfo.id_sm),this.lgSvgUse.setAttribute("xlink:href",pInfo.id_lg),setViewBox(this.lgSvgUse)),this.dotMenu=this.el.querySelector(".context-menu-box")},events:{"click #resetGatewayBtn":function(){serviceSend(states.RESET),this.dotMenu.classList.remove("show-context")},"click .item-edit.pencil":function(){serviceSend(states.RENAME),this.dotMenu.classList.remove("show-context")}},render:function(){let name=app.config.get("name");return name&&(this.name.textContent=name),this}});