//!wrt $BSPEC:{"icn":"apps/super-player","cpr":"Copyright (C) Windows 96 Team 2023.","dsc":"Super (SWF) Player","frn":"Super Player","ver":1,"ssy":"gui"}

const{WindowParams:WindowParams}=w96,{MsgBoxSimple:MsgBoxSimple,OpenFileDialog:OpenFileDialog,MenuBar:MenuBar,Theme:Theme}=w96.ui;class SuperPlayerApplication extends WApplication{constructor(){super()}async main(e){super.main(e),this._createWindow(e),this.loadedBlobs=[]}async loadSwf(e){if(!await FS.exists(e))return void MsgBoxSimple.error("Error","SWF file does not exist.","OK");const a=URL.createObjectURL(await FS.toBlob(e));this.loadedBlobs.push(a),this.appWindow.setTitle(FSUtil.fname(e)+" - Super Player"),this.appFrame.contentWindow.load(a)}async _createWindow(e){var a=new WindowParams;a.title="Super Player",a.initialWidth=500,a.initialHeight=420;var t=this.createWindow(a,!0);t.registerWindow(),t.registerAppBar(),t.setHtml('<div class="appbar"></div><iframe src="/system/apps/super-player"></iframe>');const o=t.wndObject.querySelector(".window-html-content");o.classList.add("super-player-app"),t.setWindowIcon(await Theme.getIconUrl("apps/super-player","16x16"));const i=new MenuBar;i.addRoot("File",[{type:"normal",label:"Open SWF",onclick:()=>{new OpenFileDialog("c:/user/desktop",["swf","SWF"],(e=>{e&&""!=e.trim()&&this.loadSwf(e)})).show()}},{type:"separator"},{type:"normal",label:"Exit",onclick:()=>{this.mainwnd.close()}}]),i.addRoot("Help",[{type:"normal",label:"Read me please",onclick:()=>{MsgBoxSimple.warning("Read me","Please note: not all games work in Ruffle.","OK")}},{type:"separator"},{type:"normal",label:"About",onclick:()=>{MsgBoxSimple.info("About Super Player",'<span class="bold-noaa">Super Player</span><br>Version 1.0<br><br>Powered by <a href="https://ruffle.rs/">Ruffle</a>',"OK").dlg.setSize(320,140)}}]),o.querySelector(".appbar").replaceWith(i.getMenuDiv());const n=t.wndObject.querySelector("iframe");t.ondarkenelements=()=>{n.style.pointerEvents="none"},t.onlightenelements=()=>{n.style.pointerEvents=""},n.onload=()=>{null!=e[1]&&this.loadSwf(e[1])},this.appFrame=n,this.mainwnd=t,t.show()}ontermination(){super.ontermination();for(let e in this.loadedBlobs)URL.revokeObjectURL(e)}}

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