var isShowMobileTips=null,isLandscape=!1,isEnableScroll=!0,scrollingEvent=null,onOrientationChangeEvent=null,touchCount=0,updateScreenDelay=200,dragRatio=1.2,screenRatio={width:16,height:9};function onOrientationChange(e){null!=onOrientationChangeEvent&&(clearTimeout(onOrientationChangeEvent),onOrientationChangeEvent=null),onOrientationChangeEvent=setTimeout(()=>{if(!ScreenUtil.setFullscreen(!0)){let t=e;showMobileTips(isLandscape=90==t||-90==t,!0)}},updateScreenDelay)}function onScrolling(e){isBottomPage(),isTopPage(),onTriggerTips()}function onTriggerTips(){if(1==isLandscape){if(isBottomPage())return void(ScreenUtil.setFullscreen(!0)||showMobileTips(!1,!0));if(isTopPage())return void showMobileTips(!0,!1)}}function onTouchEnd(e){onTriggerTips(),isLandscape&&!isBottomPage()&&isShowMobileTips&&scrollToTop()}function onCheckFirstTime(){scrollToTop(),onOrientationChange(window.orientation),updateLayout()}function isTopPage(){return(void 0!==window.pageYOffset?window.pageYOffset:(document.documentElement||document.body.parentNode||document.body).scrollTop)<=0}function isBottomPage(){return(void 0!==window.pageYOffset?window.pageYOffset:(document.documentElement||document.body.parentNode||document.body).scrollTop)>=document.body.scrollHeight-window.innerHeight}function showMobileTips(e,t=!0){if(isShowMobileTips==e)return void this.updateLayout();if(1==isMobileiOS()&&0==isMobileSafari())return isShowMobileTips=!1,void this.updateLayout();isShowMobileTips=e;let n=document.getElementById("animation-container"),i=document.getElementById("game-container"),o=document.getElementById("mobile-tips"),l=game.scale.displaySize._width,s=game.scale.displaySize._height;l=window.innerWidth,s=window.innerHeight,e?(n&&(n.style.width="100%",n.style.height=s*dragRatio+"px",n.style.display="block"),i&&(i.style.pointerEvents="none"),o&&(o.style.visibility="visible",o.style.display="block",o.style.height=s*dragRatio+"px"),ScreenUtil.setEnableAllInput(!1),this.updateLayout(),1==t&&this.scrollToTop(),this.enableScroll()):(n&&(n.style.width="0px",n.style.height="0px",n.style.display="none"),i&&(i.style.pointerEvents="auto"),o&&(o.style.visibility="hidden",o.style.display="none",o.style.height="0px"),ScreenUtil.setEnableAllInput(!0),this.updateLayout(),1==t&&this.scrollToBottom(),this.disableScroll())}function updateLayout(){let e=document.getElementById("game-container"),t=window.innerWidth,n=window.innerHeight,i=t/screenRatio.width,o=n/screenRatio.height,l=0,s=0;i<=o?(l=t,s=i*screenRatio.height):(l=o*screenRatio.width,s=n);let r=.5*n-.5*s,a=.5*t-.5*l,c=0,u=100;if(isLandscape?isShowMobileTips&&(c+=n*Math.abs(1-dragRatio),u=100*dragRatio):a=0,console.warn(`${r}, ${a}, ${c}`),1==isMobileiOS()){if(console.log("Mobile iOS"),1==isMobileSafari())return console.log("Mobile Safari"),e.style.width=l+"px",e.style.height=s+"px",e.style.marginTop=r+"px",e.style.marginLeft=a+"px",document.body.style.height=u+"vh",void debugStyle();console.log("iOS Other")}else console.log("Other");e.style.width="100%",e.style.height="100%",debugStyle()}function debugStyle(){let e=document.getElementById("game-container");console.log(`game_container : width:${e.style.width} height:${e.style.height}`),console.log(`game_container : marginTop:${e.style.marginTop} marginLeft:${e.style.marginLeft}`)}function scrollToTop(){window.scrollTo(0,0)}function scrollToBottom(){window.scrollTo(0,document.body.scrollHeight+1)}window.addEventListener("orientationchange",(function(e){onOrientationChange(e.target.orientation)})),window.addEventListener("onresize",(function(e){setTimeout(()=>{1==isMobileiOS()&&0==isMobileSafari()||scrollToTop()},updateScreenDelay)})),window.addEventListener("scroll",(function(e){onScrolling(e)})),window.addEventListener("touchstart",(function(e){touchCount=e.touches.length})),window.addEventListener("touchend",(function(e){touchCount=e.touches.length,onTouchEnd(e)}));var keys={37:1,38:1,39:1,40:1};function preventDefault(e){e.preventDefault()}function preventDefaultForScrollKeys(e){if(keys[e.keyCode])return preventDefault(e),!1}var supportsPassive=!1;try{window.addEventListener("test",null,Object.defineProperty({},"passive",{get:function(){supportsPassive=!0}}))}catch(e){}var wheelOpt=!!supportsPassive&&{passive:!1},wheelEvent="onwheel"in document.createElement("div")?"wheel":"mousewheel";function disableScroll(){window.addEventListener("DOMMouseScroll",preventDefault,!1),window.addEventListener(wheelEvent,preventDefault,wheelOpt),window.addEventListener("touchmove",preventDefault,wheelOpt),window.addEventListener("keydown",preventDefaultForScrollKeys,!1),document.body.style.overflow="hidden",document.getElementById("game-container").style.overflow="hidden",isEnableScroll=!1}function enableScroll(){window.removeEventListener("DOMMouseScroll",preventDefault,!1),window.removeEventListener(wheelEvent,preventDefault,wheelOpt),window.removeEventListener("touchmove",preventDefault,wheelOpt),window.removeEventListener("keydown",preventDefaultForScrollKeys,!1),document.body.style.overflow=null,document.getElementById("game-container").style.overflow=null,isEnableScroll=!0}function isMobileiOS(){try{if("iOS"==detect.parse(navigator.userAgent).os.family)return!0}catch{return!1}return!1}function isMobileSafari(){try{if("Mobile Safari"==detect.parse(navigator.userAgent).browser.family){let e=window.navigator.standalone,t=window.navigator.userAgent.toLowerCase(),n=/safari/.test(t);if(/iphone|ipod|ipad/.test(t))if(!e&&n);else if(e&&!n);else if(!e&&!n)return!1;return!0}}catch{return!1}return!1}function isMobileChromeiOS(){try{if("Chrome Mobile iOS"==detect.parse(navigator.userAgent).browser.family)return!0}catch{return!1}return!1}class ScreenUtil{static isMobile(){return!game.device.os.desktop}static isSupportFullscreen(){try{return Helper.getCurrentScene().sys.game.device.fullscreen.available}catch{return!1}}static isFullscreen(){try{let e=Helper.getCurrentScene();return e.sys.game.device.fullscreen.available&&e.scale.isFullscreen}catch{return!1}}static setFullscreen(e){if(Helper.getCurrentScene().sys.game.device.fullscreen.available){console.log("Support fullscreen!");let t=Helper.getCurrentScene();return ScreenUtil.isEnableFullscreen&&e?t.scale.isFullscreen||t.scale.startFullscreen():t.scale.isFullscreen&&t.scale.stopFullscreen(),!0}{console.log("Fullscreen not support.");let t=window.document.documentElement;if(e)if(t.requestFullscreen)t.requestFullscreen();else if(t.mozRequestFullScreen)t.mozRequestFullScreen();else if(t.webkitRequestFullscreen)t.webkitRequestFullscreen();else if(t.webkitEnterFullscreen)t.webkitEnterFullscreen();else{if(!t.msRequestFullscreen)return console.log("Failed to enable fullscreen."),!1;t.msRequestFullscreen()}else if(document.exitFullscreen)document.exitFullscreen();else if(document.mozRequestFullScreen)document.mozCancelFullScreen();else if(document.webkitExitFullscreen)document.webkitExitFullscreen();else{if(!document.msExitFullscreen)return console.log("Failed to disable fullscreen."),!1;document.msExitFullscreen()}return!0}}static setEnableAllInput(e){game&&(game.input.enabled=e)}static getScreenWidth(){let e=window.devicePixelRatio||1;return screen.width*e}static getScreenHeight(){let e=window.devicePixelRatio||1;return screen.height*e}}ScreenUtil.isEnableFullscreen=!0;