(()=>{return(e,t)=>{const n={less:-1,equal:0,greater:1,incomparable:NaN};class r{constructor(e){if(!/^[\d\.]+$/.test(e)){throw new Error("Invalid version string")}this.parts=e.split(".").map(e=>parseInt(e));this.versionString=e}compareTo(e){for(let t=0;te.parts[t]){return n.greater}return n.less}if(this.parts.length!==e.parts.length){return n.less}return n.equal}greaterThan(e){return this.compareTo(e)===n.greater}lessThan(e){return this.compareTo(e)===n.less}equals(e){return this.compareTo(e)===n.equal}}async function s(){if(typeof offlineData!=="undefined"||isIframe()){return false}try{let t;try{const n=await Ajax.monkey({url:e.latestVersionLink});t=n.match(/@version[ ]*([\d\.]+)/)[1]}catch(e){t=await Ajax.monkey({url:Resource.cdnRoot||Resource.root+"version.txt"})}const n=new r(t);const s=new r(e.currentVersion);const a=n.greaterThan(s);if(a){const t=`新版本${n.versionString}已发布. 安装查看`;const r=Toast.info(t,"检查更新");SpinQuery.select("#new-version-link").then(e=>e.addEventListener("click",()=>{r&&r.dismiss()}))}return a}catch(e){return false}}return{widget:{content:`\n\n\n`,condition:s,success:()=>{document.querySelector("#new-version-update").addEventListener("click",e=>{if(e.target.nodeName.toLowerCase()!=="a"){document.querySelector("#new-version-update a").click()}});document.querySelector("#new-version-info").addEventListener("click",e=>{if(e.target.nodeName.toLowerCase()!=="a"){document.querySelector("#new-version-info a").click()}})}}}}})();