import{c as l,i}from"./_plugin-vue_export-helper-5d7c36a3.js";import{N as a}from"./Navbar-ed33a51c.js";const r=l({components:{Navbar:a},data(){return{clients:[],closeAppPressed:!1,closeAppStatus:null,ddResetPressed:!1,ddResetStatus:null,logs:"Loading...",logFilter:null,logInterval:null,restartPressed:!1,showApplyMessage:!1,platform:"",unpairAllPressed:!1,unpairAllStatus:null}},computed:{actualLogs(){if(!this.logFilter)return this.logs;let e=this.logs.split(` `);return e=e.filter(t=>t.indexOf(this.logFilter)!==-1),e.join(` `)}},created(){fetch("/api/config").then(e=>e.json()).then(e=>{this.platform=e.platform}),this.logInterval=setInterval(()=>{this.refreshLogs()},5e3),this.refreshLogs(),this.refreshClients()},beforeDestroy(){clearInterval(this.logInterval)},methods:{refreshLogs(){fetch("./api/logs").then(e=>e.text()).then(e=>{this.logs=e})},closeApp(){this.closeAppPressed=!0,fetch("./api/apps/close",{method:"POST",headers:{"Content-Type":"application/json"}}).then(e=>e.json()).then(e=>{this.closeAppPressed=!1,this.closeAppStatus=e.status,setTimeout(()=>{this.closeAppStatus=null},5e3)})},unpairAll(){this.unpairAllPressed=!0,fetch("./api/clients/unpair-all",{method:"POST",headers:{"Content-Type":"application/json"}}).then(e=>e.json()).then(e=>{this.unpairAllPressed=!1,this.unpairAllStatus=e.status,setTimeout(()=>{this.unpairAllStatus=null},5e3),this.refreshClients()})},unpairSingle(e){fetch("./api/clients/unpair",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({uuid:e})}).then(()=>{this.showApplyMessage=!0,this.refreshClients()})},refreshClients(){fetch("./api/clients/list").then(e=>e.json()).then(e=>{document.querySelector("#client-list"),e.status===!0&&e.named_certs&&e.named_certs.length?this.clients=e.named_certs.sort((t,s)=>t.name.toLowerCase()>s.name.toLowerCase()||t.name===""?1:-1):this.clients=[]})},clickedApplyBanner(){this.showApplyMessage=!1},copyLogs(){navigator.clipboard.writeText(this.actualLogs)},restart(){this.restartPressed=!0,setTimeout(()=>{this.restartPressed=!1},5e3),fetch("./api/restart",{method:"POST",headers:{"Content-Type":"application/json"}})},ddResetPersistence(){this.ddResetPressed=!0,fetch("/api/reset-display-device-persistence",{method:"POST",headers:{"Content-Type":"application/json"}}).then(e=>e.json()).then(e=>{this.ddResetPressed=!1,this.ddResetStatus=e.status,setTimeout(()=>{this.ddResetStatus=null},5e3)})}}});i(r);