vart,n,e;(function(){vart,n;n=classextendsOS.application.BaseService{constructor(t){super("JarvisService",t),this.text=__("Jarvis({0}%)",(0).toString()),this.iconclass="fa fa-android",this.nodes=[{text:__("Status"),id:1},{text:__("Shutdown"),id:3},{text:__("Reboot"),id:4},{text:__("Exit service"),id:2}],this.onchildselect=t=>this.action(t)}init(){vart;returnt=()=>Antunnel.tunnel?(this.tunnel=Antunnel.tunnel,this.sub=newAntunnel.Subscriber("notification"),this.sub.onopen=()=>console.log("Subscribed to notification channel"),this.sub.onerror=t=>this.error(__("Error: {0}",newTextDecoder("utf-8").decode(t.data)),t),this.sub.onmessage=t=>{varn;returnt.data&&(n=JSON.parse(newTextDecoder("utf-8").decode(t.data))),this.text=__("Jarvis({0}%)",Math.round(n.battery_percent).toString()),this.update()},this.sub.onclose=()=>(this.sub=void0,this.notify(__("Unsubscribed to the notification service")),this.quit()),Antunnel.tunnel.subscribe(this.sub)):(this.error(__("The Antunnel service is not started, please start it first")),this._gui.pushService("Antunnel/AntunnelService").catch(t=>this.error(t.toString(),t)),this.quit()),window.Antunnel?t():(console.log("require Antunnel"),this._api.requires("pkg://Antunnel/main.js").then(()=>t()).catch(t=>(this.error(__("Unable to load Antunnel: {0}",t.toString()),t),this.quit())))}action(t){switch(t.data.item.data.id){case1:returnthis._gui.launch("JarvisControl",[]);case2:returnthis.quit();case3:returnthis.execute("poweroff");case4:returnthis.execute("reboot")}}execute(t){varn;if(this.tunnel)return(n=newAntunnel.Subscriber("jarvis_control")).onopen=()=>(console.log("Subscribed to jarvis_control channel. Send the command"),n.send(Antunnel.Msg.DATA,newTextEncoder("utf-8").encode(t)),n.close()),n.onerror=t=>this.error(__("Error: {0}",newTextDecoder("utf-8").decode(t.data)),t),n.onclose=()=>this.notify(__("Unsubscribed to the jarvis_control service")),this.tunnel.subscribe(n)}awake(){}cleanup(){if(this.sub)returnthis.sub.close()}},this.OS.register("JarvisService",n),(t=classextendsthis.OS.application.BaseApplication{constructor(t){super("JarvisControl",t)}main(){vart;returnthis.batterychart=$(this.find("battery-area")).epoch({type:"time.line",axes:["bottom","left","right"],range:[2500,4300],data:[{label:"Battery",values:[]}]}),this.tempchart=$(this.find("temp-area")).epoch({type:"time.line",axes:["bottom","left","right"],range:[0,100],data:[{label:"Temperature",values:[]}]}),this.memchart=$(this.find("mem-area")).epoch({type:"time.gauge",value:0}),this.diskchart=$(this.find("disk-area")).epoch({type:"time.gauge",value:0}),this.cpuchart=$(this.find("cpu-area")).epoch({type:"time.gauge",value:0}),t=()=>Antunnel.tunnel?(this.tunnel=Antunnel.tunnel,this.sub=newAntunnel.Subscriber("notification"),this.sub.onopen=()=>(console.log("Subscribed to notification channel"),this._gui.pushService("JarvisControl/JarvisService")),this.sub.onerror=t=>this.error(__("Error: {0}",newTextDecoder("utf-8").decode(t.data)),t),this.sub.onmessage=t=>{varn;returnt.data&&(n=JSON.parse(newTextDecoder("utf-8").decode(t.data))),this.display(n)},this.sub.onclose=()=>(this.sub=void0,this.notify(__("Unsubscribed to the notification service")),this.quit()),Antunnel.tunnel.subscribe(this.sub)):(this.error(__("The Antunnel service is not started, please start it first")).catch(t=>this.error(t.toString(),t)),this.quit()),this.on("resize",()=>{vart;returnt=this.find("battery-area"),this.batterychart.option("width",$(t).width()),this.batterychart.option("height",$(t).height()),t=this.find("temp-area"),this.tempchart.option("width",$(t).width()),this.tempchart.option("height",$(t).height())}),t()}display(t){varn,e,r;returnr=parseFloat(t.mem.match(/([0-9\.]+)%/)[1]),this.memchart.push(r/100),this.find("mem-text").text=t.mem,e=parseFloat(t.disk.match(/([0-9\.]+)%/)[1]),this.diskchart.push(e/100),this.find("disk-text").text=t.disk,n=parseFloat(t.cpu.match(/([0-9\.]+)$/)[1]),this.cpuchart.push(n/100),this.find("cpu-text").text=t.cpu,this.batterychart.push([{time:(newDate).timestamp(),y:t.battery}]),this.fi