import{c as n,i as o}from"./_plugin-vue_export-helper-Bah2QB50.js";import{N as l}from"./Navbar-Fg1INzmv.js";import{R as a}from"./ResourceCard-jHa_I6Bu.js";class t{constructor(e=null,s=null){if(e)this.release=e,this.version=e.tag_name,this.versionName=e.name,this.versionTag=e.tag_tag;else if(s)this.release=null,this.version=s,this.versionName=null,this.versionTag=null;else throw new Error("Either release or version must be provided");this.versionParts=this.parseVersion(this.version),this.versionMajor=this.versionParts?this.versionParts[0]:null,this.versionMinor=this.versionParts?this.versionParts[1]:null,this.versionPatch=this.versionParts?this.versionParts[2]:null}parseVersion(e){if(!e)return null;let s=e;return s.indexOf("v")===0&&(s=s.substring(1)),s.split(".").map(Number)}isGreater(e){let s;if(e instanceof t)s=e.versionParts;else if(typeof e=="string")s=this.parseVersion(e);else throw new Error("Invalid argument: otherVersion must be a SunshineVersion object or a version string");if(!this.versionParts||!s)return!1;for(let r=0;r<Math.min(3,this.versionParts.length,s.length);r++)if(this.versionParts[r]!==s[r])return this.versionParts[r]>s[r];return!1}}console.log("Hello, Sunshine!");let h=n({components:{Navbar:l,ResourceCard:a},data(){return{version:null,githubVersion:null,notifyPreReleases:!1,preReleaseVersion:null,loading:!0,logs:null}},async created(){try{let i=await fetch("./api/config").then(e=>e.json());this.notifyPreReleases=i.notify_pre_releases,this.version=new t(null,i.version),console.log("Version: ",this.version.version),this.githubVersion=new t(await fetch("https://api.github.com/repos/LizardByte/Sunshine/releases/latest").then(e=>e.json()),null),console.log("GitHub Version: ",this.githubVersion.version),this.preReleaseVersion=new t((await fetch("https://api.github.com/repos/LizardByte/Sunshine/releases").then(e=>e.json())).find(e=>e.prerelease),null),console.log("Pre-Release Version: ",this.preReleaseVersion.version)}catch(i){console.error(i)}try{this.logs=await fetch("./api/logs").then(i=>i.text())}catch(i){console.error(i)}this.loading=!1},computed:{installedVersionNotStable(){return!this.githubVersion||!this.version?!1:this.version.isGreater(this.githubVersion)},stableBuildAvailable(){return!this.githubVersion||!this.version?!1:this.githubVersion.isGreater(this.version)},preReleaseBuildAvailable(){return!this.preReleaseVersion||!this.githubVersion||!this.version?!1:this.preReleaseVersion.isGreater(this.version)&&this.preReleaseVersion.isGreater(this.githubVersion)},buildVersionIsDirty(){var i;return((i=this.version.version)==null?void 0:i.split(".").length)===5&&this.version.version.indexOf("dirty")!==-1},fancyLogs(){if(!this.logs)return[];let i=/(\[\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}\.\d{3}]):\s/g,e=this.logs.split(i).splice(1),s=[];for(let r=0;r<e.length;r+=2)s.push({timestamp:e[r],level:e[r+1].split(":")[0],value:e[r+1]});return s}}});o(h);
