var k=Object.create;var d=Object.defineProperty;var _=Object.getOwnPropertyDescriptor;var b=Object.getOwnPropertyNames;var N=Object.getPrototypeOf,y=Object.prototype.hasOwnProperty;var D=(t,e)=>{for(var o in e)d(t,o,{get:e[o],enumerable:!0})},f=(t,e,o,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of b(e))!y.call(t,r)&&r!==o&&d(t,r,{get:()=>e[r],enumerable:!(n=_(e,r))||n.enumerable});return t};var g=(t,e,o)=>(o=t!=null?k(N(t)):{},f(e||!t||!t.__esModule?d(o,"default",{value:t,enumerable:!0}):o,t)),V=t=>f(d({},"__esModule",{value:!0}),t);var B={};D(B,{checkVersion:()=>x});module.exports=V(B);var a=require("electron/main"),u=require("electron/common"),s=require("../../common/modules/client"),v=g(require("../../common/modules/l10n")),$=g(require("semver")),m=g(require("@spacingbat3/kolor")),h=require("./error"),c=require("./config");async function x(t){await a.app.whenReady();const e=new v.default().client;if(!a.net.isOnline()){console.debug(e.dialog.ver.updateBadge+" Network is offline, skipping check...");return}const o=s.appInfo.repository.name;let n,r=!1;const i=await(await fetch("https://api.github.com/repos/"+o+"/releases/latest")).json();if(i.tag_name===void 0||i.html_url===void 0)return;switch($.compare(i.tag_name,a.app.getVersion())){case 0:n=e.dialog.ver.recent;break;case 1:r=!0,n=e.dialog.ver.update+" (v"+a.app.getVersion()+" \u2192 v"+i.tag_name.replace(/^v(.+)$/,"$1")+")";break;case-1:(0,s.getBuildInfo)().type==="devel"?n=e.dialog.ver.devel:n=e.dialog.ver.downgrade+" (v"+a.app.getVersion()+" \u2192 v"+i.tag_name.replace(/^v(.+)$/,"$1")+")";break;default:throw new Error("Couldn't compare versions while doing an update")}console.log(m.default.bold(m.default.blue(e.dialog.ver.updateBadge))+" "+n);const l=new Date;l.setDate(l.getDate()+7);const w=c.appConfig.value.update.notification.version===i.tag_name&&new Date(c.appConfig.value.update.notification.till)<l;if(r&&(0,s.getBuildInfo)().features.updateNotifications&&!w){const p=new a.Notification({title:a.app.getName()+": "+e.dialog.ver.updateTitle,icon:s.appInfo.icons.app,body:n});p.on("click",()=>{i.html_url!==void 0&&u.shell.openExternal(i.html_url).catch(h.commonCatches.throw)}),p.on("close",()=>{i.tag_name!==void 0&&(c.appConfig.value={update:{notification:{version:i.tag_name,till:JSON.parse(JSON.stringify(l))}}})}),p.show()}t&&clearInterval(t)}0&&(module.exports={checkVersion});
