'),svgIcoSoundOn=CreateSVG(''),svgIcoSoundOff=CreateSVG(''),svgIcoNoSound=CreateSVG(' '),svgIcoGamepad=CreateSVG(''),svgIcoKeyboard=CreateSVG(''),svgIcoFullscreen=CreateSVG('');var hSnd=document.getElementById("canvasSndBtn");function simulateKeyEvent(e,t,l,n,c){var o={isTrusted:!0,type:e,bubbles:!0,canceable:!0,char:c,key:c,code:n,keyCode:t,which:t,charCode:l,preventDefault:function(){},defaultPrevented:!1,composed:!0,detail:0,location:0,isComposing:!1,repeat:!1,ctrlKey:!1,metaKey:!1,altKey:!1,shiftKey:!1,currentTarget:window,srcElement:document.body,target:document.body,timeStamp:Date.now(),view:window};if("undefined"!=typeof JSEvents&&JSEvents.eventHandlers&&JSEvents.eventHandlers.length>0)for(var a=0;a{e.addEventListener(t,(e=>{blockEvent(e)}),{capture:!0,passive:!1})}))}function processKeyEvent(e,t){if(e.target.classList.contains("vkey")){e.preventDefault(),e.stopPropagation();var l=e.target,n=l.dataset;if(-1!=Module.keyboardTimeoutId&&n.view){if(t)return;if((s=l.parentElement.parentElement).classList.contains("slide-out")&&!s.classList.contains("slide-in"))return s.classList.add("slide-in"),void doKeyboardTimeout(s);doKeyboardTimeout(s)}var c=parseInt(n.keycode),o=parseInt(n.keychar),a=n.key;if(simulateKeyEvent(t?"keydown":"keyup",c,0,"",a),t)l.classList.add("active"),l.setPointerCapture(e.pointerId);else{var s=document.getElementById("keyboard-container");l.classList.remove("active"),l.releasePointerCapture(e.pointerId),"changeKeyboardView"==n.action&&changeKeyboardView(s)}t&&0!=o&&simulateKeyEvent("keypress",c,o,"",a)}}function initKeyboard(){var e=document.getElementById("keyboard-container");e.querySelectorAll(".keyrow");SetEventBlock(e,["pointerover","touchstart","touchmove","pointermove","gotpointercapture","lostpointercapture","pointerout","touchend","mouseout","mousemove","mousedown","mousepress","mouseup"]),e.dataset.view=3,changeKeyboardView(e)}function initGamePad(e){const t=document,l=document.getElementById(e+"L"),n=document.getElementById(e+"R");n.innerHTML=l.innerHTML,SetEventBlock(l,["pointerover","touchstart","touchmove","pointermove","gotpointercapture","lostpointercapture","pointerout","touchend","mouseout","mousemove","mousedown","mousepress","mouseup"]),SetEventBlock(n,["pointerover","touchstart","touchmove","pointermove","gotpointercapture","lostpointercapture","pointerout","touchend","mouseout","mousemove","mousedown","mousepress","mouseup"]),t.addEventListener("dblclick",(e=>{blockEvent(e)})),t.addEventListener("click",(e=>{blockEvent(e)})),t.addEventListener("contextmenu",(e=>{blockEvent(e)})),t.ondragstart=()=>!1,t.addEventListener("pointerdown",(e=>{processKeyEvent(e,!0)}),{capture:!0,passive:!1}),t.addEventListener("pointerup",(e=>{processKeyEvent(e,!1)}),{capture:!0,passive:!1}),t.addEventListener("pointercancel",(e=>{processKeyEvent(e,!1)}),{capture:!0,passive:!1})}function toggleVolume(e){if(Module.pi8_AudioInit&&e.classList.contains("sound_off")){e.classList.remove("sound_off"),e.classList.add("sound_on"),e.src=svgIcoSoundOn;var t=document.body;t.onpointerdown=t.onclick=t.onkeydown="",Module.HEAP8[Module.pi8_AudioInit]=1,document.querySelectorAll(".AudioItem").forEach((e=>{e.muted=!1}))}else e.classList.contains("sound_mute")?(e.classList.remove("sound_mute"),e.src=svgIcoSoundOn,document.querySelectorAll(".AudioItem").forEach((e=>{e.muted=!1}))):e.classList.contains("sound_on")&&(e.classList.add("sound_mute"),e.src=svgIcoSoundOff,document.querySelectorAll(".AudioItem").forEach((e=>{e.muted=!0})))}function toggleKeyboard(e){var t=document.getElementById("keyboard-container");e.target.classList.toggle("active"),t.classList.toggle("hidden"),Module.Gfx_adjustHeaderSize(),window.setTimeout((function(){Module.Gfx_adjustHeaderSize()}),50)}function changeKeyboardView(e){document.getElementById("keyboard-container");var t=e.dataset,l=2^parseInt(t.view);t.view=l,e.querySelectorAll(".vkey").forEach((e=>{e.style.display=e.dataset.view&l?"":"none"})),e.querySelectorAll(".keyrow").forEach((e=>{e.dataset.view<0?e.style.display=e.dataset.view==-l?"":"none":e.style.display=e.dataset.view&l?"":"none";var t="";1&l&&(t+=" "+e.dataset.grid1),2&l&&(t+=" "+e.dataset.grid2),e.style.gridTemplateColumns=t})),Module.Gfx_adjustHeaderSize()}function toggleGamepad(e){const t=document.getElementById("gamepad-containerL"),l=document.getElementById("gamepad-containerR");e.target.classList.toggle("active"),t.classList.toggle("hidden"),l.classList.toggle("hidden"),Module.Gfx_adjustHeaderSize(),window.setTimeout((function(){Module.Gfx_adjustHeaderSize()}),50)}function doKeyboardTimeout(e){-1!=Module.keyboardTimeoutId&&window.clearTimeout(Module.keyboardTimeoutId),e.classList.remove("slide-out"),Module.keyboardTimeoutId=window.setTimeout((function(){e.classList.remove("slide-in"),e.classList.add("slide-out")}),5e3)}hSnd.src=svgIcoNoSound,document.getElementById("spinico").src=svgIcoFreebasic,document.getElementById("canvasPadBtn").src=svgIcoGamepad,document.getElementById("canvasKeyBtn").src=svgIcoKeyboard,document.getElementById("canvasFulBtn").src=svgIcoFullscreen,document.body.onclick=function(e){toggleVolume(hSnd)},document.body.pointerdown=function(e){toggleVolume(hSnd)},document.body.onkeydown=function(e){toggleVolume(hSnd)};var Module={isFullscreen:!0,keyboardTimeoutId:-1,preRun:[function(){Module.isFullscreen=!0,Module.keyboardTimeoutId=-1,"undefined"!=typeof __fb_rtlib&&(__fb_rtlib.console.open(80,25),null!=__fb_rtlib.console.term&&document.getElementById("termContainer").classList.remove("hidden"));new ResizeObserver((()=>{window.setTimeout((function(){Module.Gfx_adjustHeaderSize()}),50)})).observe(document.getElementById("canvas")),window.onresize=function(){window.setTimeout((function(){Module.Gfx_adjustHeaderSize()}),50)},initGamePad("gamepad-container"),initKeyboard();const e=document.querySelector("title");new MutationObserver((e=>{e.forEach((e=>{if("childList"===e.type){const e=document.getElementById("canvasTitle");e.title=document.title,e.innerText=" "+document.title}}))})).observe(e,{childList:!0})}],postRun:[],print:function(e){arguments.length>1&&(e=Array.prototype.slice.call(arguments).join(" ")),__fb_rtlib.console.write(e)},printErr:function(e){arguments.length>1&&(e=Array.prototype.slice.call(arguments).join(" ")),console.error(e)},canvas:function(){var e=document.getElementById("canvas");return e.addEventListener("webglcontextlost",(function(e){alert("WebGL context lost. You will need to reload the page."),e.preventDefault()}),!1),e}(),setStatus:function(e){if(Module.setStatus.last||(Module.setStatus.last={time:Date.now(),text:""}),e!==Module.setStatus.text){var t=e.match(/([^(]+)\((\d+(\.\d+)?)\/(\d+)\)/),l=Date.now();t&&l-Date.now()<30||(t?(e=t[1],progressElement.value=100*parseInt(t[2]),progressElement.max=100*parseInt(t[4]),progressElement.hidden=!1,spinnerElement.hidden=!1):(progressElement.value=null,progressElement.max=null,progressElement.hidden=!0,e||(spinnerElement.hidden=!0)),statusElement.innerHTML=e)}},leaveFullscreen:function(){var e=document.getElementById("canvasHeader"),t=document.getElementById("canvas");document.getElementById("keyboard-container");e.classList.remove("hidden"),t.style.width="",t.style.height=""},enterFullscreen:function(e){Module.isFullscreen=!0,document.getElementById("canvasHeader").classList.add("hidden"),canvas.style.width="",canvas.style.height="100%",document.getElementById(e).requestFullscreen(),window.screen.orientation.lock("landscape").then((function(){}),(function(){})),console.log("Entered fullscreen")},Gfx_adjustHeaderSize:function(){var e=document.fullscreenElement;Module.isFullscreen&&null==e&&(Module.isFullscreen=!1,Module.leaveFullscreen());var t=document.getElementById("canvasHeader");document.getElementById("hdrFirstBtn");if(!Module.isFullscreen)if(canvas.height+t.clientHeight>window.innerHeight)canvas.style.height=window.innerHeight-t.clientHeight+"px";else if(canvas.clientHeightwindow.innerHeight)&&!(l*canvas.height>240);)l+=1;l*canvas.height+t.clientHeight