/*! phoscon-app 2025-08-29 */

import{serviceSend}from"./settings-gateway-machine.js";import{states,events}from"./settings-gateway-constants.js";import{removeClassFromAll}from"./settings-gateway-functions.js";export const ChangeTimezoneHandlerView=Backbone.View.extend({template:_.template(document.getElementById("change-timezone-template").innerHTML),el:"#changeTimezoneModal",initialize:function(){for(var tz in this.el.innerHTML=this.template(app.config),this.inputTimezone=this.el.querySelector("#inputTimezone"),this.selectTimezone=this.el.querySelector("#selectTimezone"),this.inputTimezoneGlyphicon=this.el.querySelector(".glyphicon-remove"),this.inputTimezoneInfoText=this.el.querySelector('[data-translateid="typing_city"]'),this.prevBtn=this.el.querySelector(".btn-prev"),this.nextBtn=this.el.querySelector(".btn-next"),this.inputListTimezones=this.el.querySelector("#timezones"),this.timezones=moment.tz.names(),this.timezones)screenMax(SCREEN_MAX_WIDTH_TABLET_LANDSCAPE)?this.selectTimezone.insertAdjacentHTML("beforeend","<option>"+this.timezones[tz]+"</option>"):this.inputListTimezones.insertAdjacentHTML("beforeend","<option>"+this.timezones[tz]+"</option>")},events:{"input #inputTimezone":"changeTimezone","input #selectTimezone":"changeTimezone","click .form-control-feedback":"changeTimezone","click .btn-next":function(){serviceSend(events.NEXT_PRESSED)},"click .btn-prev":function(){serviceSend(events.CLOSE_PRESSED)},"click .close":function(){serviceSend(events.CLOSE_PRESSED)}},render:function(){return this},show:function(){screenMax(SCREEN_MAX_WIDTH_TABLET_LANDSCAPE)&&(this.inputTimezone.style.setProperty("display","none","important"),this.inputTimezoneGlyphicon.style.setProperty("display","none","important"),this.inputTimezoneInfoText.style.setProperty("display","none","important"),this.selectTimezone.style.setProperty("display","inline","important")),this.el.classList.add("show")},hide:function(){this.el.classList.remove("show")},changeTimezone:_.debounce(function(){serviceSend(events.TIMEZONE_CHANGED)},200),isValidTimezone:function(){if(screenMax(SCREEN_MAX_WIDTH_TABLET_LANDSCAPE)){if(this.timezones.includes(this.selectTimezone.value)&&this.selectTimezone.value!==app.config.get("timezone"))return!0}else if(this.timezones.includes(this.inputTimezone.value)&&this.inputTimezone.value!==app.config.get("timezone"))return!0},getTimezone:function(){let tz;return tz=screenMax(SCREEN_MAX_WIDTH_TABLET_LANDSCAPE)?this.selectTimezone?this.selectTimezone.value:void 0:this.inputTimezone?this.inputTimezone.value:void 0},page1:function(){let elemList=this.el.querySelectorAll(".page");removeClassFromAll(elemList,"active-page"),this.el.querySelector('[data-page="page1"]').classList.add("active-page"),this.nextBtn.innerText=translate("text_next"),this.prevBtn.innerText=translate("text_back"),app.config.has("timezone")&&(screenMax(SCREEN_MAX_WIDTH_TABLET_LANDSCAPE)?this.selectTimezone.value=app.config.get("timezone"):this.inputTimezone.value=app.config.get("timezone")),this.inputTimezone.focus()},page1Valid:function(){this.nextBtn.classList.remove("disabled")},page1Invalid:function(){this.nextBtn.classList.add("disabled")}});