import{i as a,R as t,C as r}from"./index-Bkuhln3H.js";class l extends t{constructor(e){super(e.rid),this.available=!0,this.currentVersion=e.currentVersion,this.version=e.version,this.date=e.date,this.body=e.body,this.rawJson=e.rawJson}async download(e,s){i(s);const d=new r;e&&(d.onmessage=e);const o=await a("plugin:updater|download",{onEvent:d,rid:this.rid,...s});this.downloadedBytes=new t(o)}async install(){if(!this.downloadedBytes)throw new Error("Update.install called before Update.download");await a("plugin:updater|install",{updateRid:this.rid,bytesRid:this.downloadedBytes.rid}),this.downloadedBytes=void 0}async downloadAndInstall(e,s){i(s);const d=new r;e&&(d.onmessage=e),await a("plugin:updater|download_and_install",{onEvent:d,rid:this.rid,...s})}async close(){await this.downloadedBytes?.close(),await super.close()}}async function w(n){i(n);const e=await a("plugin:updater|check",{...n});return e?new l(e):null}function i(n){n?.headers&&(n.headers=Array.from(new Headers(n.headers).entries()))}export{l as Update,w as check};
