import{I as n,r as i,m as l,u as o,a as d,_ as c,n as p}from"./index-Ms_1iFoB.js";const u={components:{},props:{node:Object,socket:Object},mixins:[n],data(){return{rfRegions:i,rfRegion:null,fwUpdates:[],loading:!1,includePrereleases:!1,showDowngrades:!1}},computed:{...l(o,["controllerNode"]),filteredUpdates(){return this.fwUpdates.filter(s=>!s.downgrade||s.downgrade&&this.showDowngrades)}},mounted(){this.checkUpdates()},methods:{...d(o,["showSnackbar"]),async checkUpdates(){this.loading=!0,this.fwUpdates=[];const s={includePrereleases:this.includePrereleases};this.controllerNode&&this.controllerNode.RFRegion===void 0&&(s.rfRegion=this.rfRegion);const e=await this.app.apiRequest("getAvailableFirmwareUpdates",[this.node.id,s]);if(this.loading=!1,e.success){const{default:t}=await c(async()=>{const{default:a}=await import("./index-Blr6EMNg.js");return{default:a}},[],import.meta.url);for(const a of e.result)a.changelog=t().render(a.changelog);this.fwUpdates=e.result}else this.showSnackbar(`Failed to check for firmware updates: ${e.message}`,"error")},download(s){window.open(s,"_blank")},async updateFirmware(s){if(await this.app.confirm(`OTA ${s.downgrade?"Downgrade":"Upgrade"}`,`<p>Are you sure you want to ${s.downgrade?"downgrade":"upgrade"} node to <b>v${s.version}</b>?</p>
										
					<p><strong>We don't take any responsibility if devices upgraded using Z-Wave JS don't work after an update. Always double-check that the correct update is about to be installed</strong></p>
					
					<p>This will download the desired firmware update from the <a href="https://github.com/zwave-js/firmware-updates/">Z-Wave JS firmware update service</a> and start an over-the-air (OTA) firmware update for the given node.</p>
	
					`,s.downgrade?"error":"warning",{confirmText:`${s.downgrade?"Downgrade":"Upgrade"}`,cancelText:"Cancel",width:"500px"})){const e=await this.app.apiRequest("firmwareUpdateOTA",[this.node.id,s]);await this.app.handleFwUpdateResponse(e)}}}};var v=function(){var e=this,t=e._self._c;return t("v-container",{attrs:{"grid-list-md":""}},[t("v-row",{staticClass:"ml-5"},[t("v-col",{directives:[{name:"show",rawName:"v-show",value:!e.node.firmwareUpdate,expression:"!node.firmwareUpdate"}],attrs:{cols:"12"}},[t("v-row",{staticClass:"mb-2 text-center",attrs:{justify:"center",dense:""}},[t("v-btn",{staticClass:"my-auto",attrs:{disabled:e.loading,outlined:"",color:"green"},on:{click:e.checkUpdates}},[e._v("Check updates")]),t("v-checkbox",{staticClass:"ml-2 my-auto",attrs:{"hide-details":"",dense:"",label:"Include pre-releases"},model:{value:e.includePrereleases,callback:function(a){e.includePrereleases=a},expression:"includePrereleases"}}),t("v-checkbox",{staticClass:"ml-2 my-auto",attrs:{"hide-details":"",dense:"",label:"Show downgrades"},model:{value:e.showDowngrades,callback:function(a){e.showDowngrades=a},expression:"showDowngrades"}}),e.controllerNode&&e.controllerNode.RFRegion===void 0?t("v-select",{staticClass:"ml-2 mb-2",staticStyle:{"max-width":"200px"},attrs:{label:"Rf Region","hide-details":"",items:e.rfRegions},scopedSlots:e._u([{key:"prepend",fn:function(){return[t("v-icon",[e._v("signal_cellular_alt")])]},proxy:!0}],null,!1,2278782249),model:{value:e.rfRegion,callback:function(a){e.rfRegion=a},expression:"rfRegion"}}):e._e()],1)],1),e.filteredUpdates.length>0&&!e.node.firmwareUpdate?e._l(e.filteredUpdates,function(a){return t("v-col",{key:a.version,attrs:{cols:"12",sm:"6",md:"4"}},[t("v-card",{attrs:{dense:"",elevation:"5"}},[t("v-card-title",[t("v-icon",[e._v("mdi-update")]),t("span",{staticClass:"headline"},[t("strong",[e._v("v"+e._s(a.version)+" ["+e._s(a.channel)+"]")])]),t("v-spacer"),t("v-btn",{attrs:{outlined:"",small:"",color:a.downgrade?"warning":"success"},on:{click:function(r){return e.updateFirmware(a)}}},[t("v-icon",{attrs:{small:""}},[e._v(e._s(a.downgrade?"download":"upload"))]),e._v(" "+e._s(a.downgrade?"Downgrade":"Update")+" ")],1)],1),t("v-divider",{staticClass:"mx-4"}),t("v-card-text",[t("v-subheader",{staticClass:"subtitle-1"},[t("strong",[e._v("Changelog")])]),t("p",{staticClass:"text-caption ml-4",domProps:{innerHTML:e._s(a.changelog)}}),e._l(a.files,function(r){return t("v-list-item",{key:r.url,staticStyle:{"border-bottom":"1px solid #e0e0e0"},attrs:{"two-line":"",dense:""}},[t("v-list-item-icon",{staticClass:"my-auto mr-3"},[t("v-icon",{attrs:{color:"primary"}},[e._v("widgets")])],1),t("v-list-item-content",[t("v-list-item-title",[e._v("Target: "+e._s(r.target))]),t("v-list-item-subtitle",[e._v(e._s(r.url))])],1),t("v-list-item-icon",{staticClass:"my-auto"},[t("v-btn",{attrs:{title:"Download",icon:""},on:{click:function(f){return e.download(r.url)}}},[t("v-icon",{attrs:{color:"success"}},[e._v("download")])],1)],1)],1)})],2)],1)],1)}):e.loading||e.node.firmwareUpdate?t("v-col",{staticClass:"text-center"},[t("v-progress-circular",{attrs:{indeterminate:"",color:"primary"}}),t("p",{staticClass:"text-caption"},[e._v(" "+e._s(e.node.firmwareUpdate?"Update in progress...":"Remember to wake up sleeping devices...")+" ")])],1):t("v-col",{staticClass:"text-center"},[t("h1",{staticClass:"title"},[e._v("No updates available")]),t("span",[e._v("This service relies on "),t("a",{attrs:{href:"https://github.com/zwave-js/firmware-updates#readme",target:"_blank"}},[e._v("Z-Wave JS Firmware Update Service")]),e._v(", and may not represent all updates for your device.")]),t("br"),t("span",[e._v("If you know that a firmware update "),t("i",[e._v("does")]),e._v(" exist, you can help the Z-Wave JS community by encouraging your device manufacturer to provide the firmwares. Read more in the link above.")])])],2)],1)},m=[],w=p(u,v,m,!1,null,null);const h=w.exports;export{h as default};
