//!wrt $BSPEC:{"icn":"misc/logo","cpr":"Copyright (C) Windows 96 Team 2023.","dsc":"Windows 96 version history","frn":"Version Browser","ver":1,"ssy":"gui"}

const{WindowParams:WindowParams}=w96,{Theme:Theme,MenuBar:MenuBar}=w96.ui,{ListView:ListView}=w96.ui.components,VMs=[{label:"Version 2.0 [Service Pack 2]",thumb:"/system/resource/app/vm/screenshots/v2sp2.png",url:"https://rel2sp2.windows96.net/",icon:"misc/logo",releaseDate:"29 June 2021"},{label:"Version 2.0 [Service Pack 1]",thumb:"/system/resource/app/vm/screenshots/v2sp1.png",url:"https://rel2sp1.windows96.net/",icon:"misc/logo",releaseDate:"4 April 2021"},{label:"Version 2.0",thumb:"/system/resource/app/vm/screenshots/v2.png",url:"https://rel2.windows96.net/",icon:"misc/logo",releaseDate:"5 February 2021"},{label:"Version 1.0",thumb:"/system/resource/app/vm/screenshots/v1.png",url:"https://rel1.windows96.net/",icon:"misc/logo-ancient",releaseDate:"15 August 2019"},{label:"Version 0.5",thumb:"/system/resource/app/vm/screenshots/v05.png",url:"https://rel05.windows96.net/",icon:"misc/logo-ancient",releaseDate:"7 July 2019"},{label:"Version 0.4",thumb:"/system/resource/app/vm/screenshots/v04.png",url:"https://rel04.windows96.net/",icon:"misc/logo-ancient",releaseDate:"(no exact date)"},{label:"Version 0.3",thumb:"/system/resource/app/vm/screenshots/v03.png",url:"https://rel03.windows96.net/",icon:"misc/logo-ancient",releaseDate:"(no exact date)"},{label:"Version 0.2",thumb:"/system/resource/app/vm/screenshots/v02.png",url:"https://rel02.windows96.net/",icon:"misc/logo-ancient",releaseDate:"1 May 2019"},{label:"Version 0.1",thumb:"/system/resource/app/vm/screenshots/v01.png",url:"https://rel01.windows96.net/",icon:"misc/logo-ancient",releaseDate:"20 April 2019"}];class VMApplication extends WApplication{constructor(){super(),this.selectedIndex=0}async main(e){super.main(e);const s=this.createWindow({title:"Version Browser",initialHeight:361,initialWidth:540,resizable:!0,taskbar:!0,bodyClass:"verbrowser-app",body:`\n                <div class="split-panel">\n                    <div class="listview"></div>\n                    <div class="preview">\n                        <span class="bold-noaa header">Preview</span>\n                        <div class="preview-container">\n                            <img class="img-container" draggable="false">\n                        </div>\n                        <span class="bold-noaa header">Actions</span>\n                        <div class="actions">\n                            <div class="w96-link enlarge">View Screenshot</div>\n                            <div class="w96-link launch">Launch</div>\n                            <div class="w96-link url">Open as URL</div>\n                        </div>\n                    </div>\n                </div>\n                <div class="w96-footer">\n                    <div class="cell">\n                        Current Version: ${await w96.sys.rel.getVersionString()}\n                    </div>\n                </div>\n            `,icon:await Theme.getIconUrl("misc/logo","16x16")},!0),n=s.getBodyContainer(),t=new MenuBar;t.addRoot("File",[{type:"normal",label:"Exit",onclick:()=>this.terminate()}]),t.addRoot("Help",[{type:"normal",label:"About",onclick:()=>{w96.sys.execCmd("about-ui",[])}}]),n.prepend(t.getMenuDiv());const i=new ListView;i.addColumnHeader("Name",80),i.addColumnHeader("Release Date",150),i.addColumnHeader("Standalone URL");for(let e of VMs){const s=i.pushData([e.label,e.releaseDate,e.url],await Theme.getIconUrl(e.icon,"16x16"));s.addEventListener("click",(()=>this.selectVM(VMs.indexOf(e)))),s.addEventListener("dblclick",(()=>this.createVMWindow(VMs.indexOf(e))))}n.querySelector(".listview").replaceWith(i.getElement()),n.querySelector(".enlarge").addEventListener("click",(()=>{w96.urlopen(VMs[this.selectedIndex].thumb)})),n.querySelector(".url").addEventListener("click",(()=>{w96.urlopen(VMs[this.selectedIndex].url)})),n.querySelector(".launch").addEventListener("click",(()=>this.createVMWindow(this.selectedIndex))),s.show(),this.mainwnd=s,i.select(0),this.selectVM(0)}async createVMWindow(e){this.createWindow({title:`[${VMs[e].label}]`,icon:await Theme.getIconUrl(VMs[e].icon,"16x16"),initialHeight:480,initialWidth:640,bodyClass:"if-app",body:`<iframe src="${VMs[e].url}"></iframe>`,taskbar:!0}).show()}selectVM(e){this.selectedIndex=e,this.updatePreview()}updatePreview(){const e=VMs[this.selectedIndex];this.mainwnd.getBodyContainer().querySelector(".img-container").src=e.thumb}}

return await WApplication.execAsync(new VMApplication(), this.boxedEnv.args, this);