/g,_=/>/g,m=RegExp(`>|${d}(?:([^\\s"'>=/]+)(${d}*=${d}*(?:[^ \t\n\f\r"'\`<>=]|("|')|))|$)`,"g"),p=/'/g,g=/"/g,$=/^(?:script|style|textarea|title)$/i,y=t=>(i,...s)=>({_$litType$:t,strings:i,values:s}),x=y(1),T=Symbol.for("lit-noChange"),E=Symbol.for("lit-nothing"),A=new WeakMap,C=r$1.createTreeWalker(r$1,129);function P(t,i){if(!a(t)||!t.hasOwnProperty("raw"))throw Error("invalid template strings array");return void 0!==s$2?s$2.createHTML(i):i}const V=(t,i)=>{const s=t.length-1,o=[];let r,l=2===i?"":3===i?"":"",c=f$2;for(let i=0;i"===u[0]?(c=r??f$2,d=-1):void 0===u[1]?d=-2:(d=c.lastIndex-u[2].length,a=u[1],c=void 0===u[3]?m:'"'===u[3]?g:p):c===g||c===p?c=m:c===v||c===_?c=f$2:(c=m,r=void 0);const x=c===m&&t[i+1].startsWith("/>")?" ":"";l+=c===f$2?s+n$1:d>=0?(o.push(a),s.slice(0,d)+e$1+s.slice(d)+h$1+x):s+h$1+(-2===d?i:x)}return[P(t,l+(t[s]||"")+(2===i?"":3===i?"":"")),o]};class N{constructor({strings:t,_$litType$:s},n){let r;this.parts=[];let c=0,a=0;const u=t.length-1,d=this.parts,[f,v]=V(t,s);if(this.el=N.createElement(f,n),C.currentNode=this.el.content,2===s||3===s){const t=this.el.content.firstChild;t.replaceWith(...t.childNodes)}for(;null!==(r=C.nextNode())&&d.length0){r.textContent=i$2?i$2.emptyScript:"";for(let i=0;i2||""!==s[0]||""!==s[1]?(this._$AH=Array(s.length-1).fill(new String),this.strings=s):this._$AH=E}_$AI(t,i=this,s,e){const h=this.strings;let o=!1;if(void 0===h)t=S(this,t,i,0),o=!c$1(t)||t!==this._$AH&&t!==T,o&&(this._$AH=t);else{const e=t;let n,r;for(t=h[0],n=0;n{const e=s?.renderBefore??i;let h=e._$litPart$;if(void 0===h){const t=s?.renderBefore??null;e._$litPart$=h=new R(i.insertBefore(l(),t),t,void 0,s??{})}return h._$AI(t),h /** * @license * Copyright 2017 Google LLC * SPDX-License-Identifier: BSD-3-Clause */};const s$1=globalThis;let i$1=class i extends y$1{constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=void 0}createRenderRoot(){const t=super.createRenderRoot();return this.renderOptions.renderBefore??=t.firstChild,t}update(t){const r=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(t),this._$Do=B(r,this.renderRoot,this.renderOptions)}connectedCallback(){super.connectedCallback(),this._$Do?.setConnected(!0)}disconnectedCallback(){super.disconnectedCallback(),this._$Do?.setConnected(!1)}render(){return T}};i$1._$litElement$=!0,i$1["finalized"]=!0,s$1.litElementHydrateSupport?.({LitElement:i$1});const o$1=s$1.litElementPolyfillSupport;o$1?.({LitElement:i$1});(s$1.litElementVersions??=[]).push("4.2.0"); // Copyright 2023 The Chromium Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. const HIDDEN_CLASS="hidden"; // Copyright 2024 The Chromium Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. const IS_IOS=/CriOS/.test(window.navigator.userAgent);const IS_HIDPI=window.devicePixelRatio>1;const IS_MOBILE=/Android/.test(window.navigator.userAgent)||IS_IOS;const IS_RTL=document.documentElement.dir==="rtl";const FPS=60; // Copyright 2025 The Chromium Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. function getRandomNum(min,max){return Math.floor(Math.random()*(max-min+1))+min}function getTimeStamp(){return IS_IOS?(new Date).getTime():performance.now()}function getRunnerImageSprite(){if("imageSprite"in Runner){return Runner.imageSprite}return null}function getRunnerAltGameImageSprite(){if("altGameImageSprite"in Runner){return Runner.altGameImageSprite}return null}function getRunnerAltCommonImageSprite(){if("altCommonImageSprite"in Runner){return Runner.altCommonImageSprite}return null}function getRunnerOrigImageSprite(){if("origImageSprite"in Runner){return Runner.origImageSprite}return null}function getRunnerSlowdown(){if("slowDown"in Runner&&typeof Runner.slowDown==="boolean"){return Runner.slowDown}return null}function getRunnerAudioCues(){if("audioCues"in Runner&&typeof Runner.audioCues==="boolean"){return Runner.audioCues}return null} // Copyright 2024 The Chromium Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. class DistanceMeter{constructor(canvas,spritePos,canvasWidth){this.canvas=canvas;this.canvasCtx=canvas.getContext("2d");this.image=Runner.imageSprite;this.spritePos=spritePos;this.x=0;this.y=5;this.currentDistance=0;this.maxScore=0;this.highScore="0";this.container=null;this.digits=[];this.achievement=false;this.defaultString="";this.flashTimer=0;this.flashIterations=0;this.invertTrigger=false;this.flashingRafId=null;this.highScoreBounds={};this.highScoreFlashing=false;this.config=DistanceMeter.config;this.maxScoreUnits=this.config.MAX_DISTANCE_UNITS;this.canvasWidth=canvasWidth;this.init(canvasWidth)}init(width){let maxDistanceStr="";this.calcXPos(width);this.maxScore=this.maxScoreUnits;for(let i=0;ithis.maxScore&&this.maxScoreUnits===this.config.MAX_DISTANCE_UNITS){this.maxScoreUnits++;this.maxScore=parseInt(this.maxScore+"9",10)}else{this.distance=0}if(distance>0){if(distance%this.config.ACHIEVEMENT_DISTANCE===0){this.achievement=true;this.flashTimer=0;playSound=true}const distanceStr=(this.defaultString+distance).substr(-this.maxScoreUnits);this.digits=distanceStr.split("")}else{this.digits=this.defaultString.split("")}}else{if(this.flashIterations<=this.config.FLASH_ITERATIONS){this.flashTimer+=deltaTime;if(this.flashTimerthis.config.FLASH_DURATION*2){this.flashTimer=0;this.flashIterations++}}else{this.achievement=false;this.flashIterations=0;this.flashTimer=0}}if(paint){for(let i=this.digits.length-1;i>=0;i--){this.draw(i,parseInt(this.digits[i],10))}}this.drawHighScore();return playSound}drawHighScore(){if(parseInt(this.highScore,10)>0){this.canvasCtx.save();this.canvasCtx.globalAlpha=.8;for(let i=this.highScore.length-1;i>=0;i--){this.draw(i,parseInt(this.highScore[i],10),true)}this.canvasCtx.restore()}}setHighScore(distance){distance=this.getActualDistance(distance);const highScoreStr=(this.defaultString+distance).substr(-this.maxScoreUnits);this.highScore=["10","11",""].concat(highScoreStr.split(""))}hasClickedOnHighScore(e){let x=0;let y=0;if(e.touches){const canvasBounds=this.canvas.getBoundingClientRect();x=e.touches[0].clientX-canvasBounds.left;y=e.touches[0].clientY-canvasBounds.top}else{x=e.offsetX;y=e.offsetY}this.highScoreBounds=this.getHighScoreBounds();return x>=this.highScoreBounds.x&&x<=this.highScoreBounds.x+this.highScoreBounds.width&&y>=this.highScoreBounds.y&&y<=this.highScoreBounds.y+this.highScoreBounds.height}getHighScoreBounds(){return{x:this.x-this.maxScoreUnits*2*DistanceMeter.dimensions.WIDTH-DistanceMeter.config.HIGH_SCORE_HIT_AREA_PADDING,y:this.y,width:DistanceMeter.dimensions.WIDTH*(this.highScore.length+1)+DistanceMeter.config.HIGH_SCORE_HIT_AREA_PADDING,height:DistanceMeter.dimensions.HEIGHT+DistanceMeter.config.HIGH_SCORE_HIT_AREA_PADDING*2}}flashHighScore(){const now=getTimeStamp();const deltaTime=now-(this.frameTimeStamp||now);let paint=true;this.frameTimeStamp=now;if(this.flashIterations>this.config.FLASH_ITERATIONS*2){this.cancelHighScoreFlashing();return}this.flashTimer+=deltaTime;if(this.flashTimerthis.config.FLASH_DURATION*2){this.flashTimer=0;this.flashIterations++}if(paint){this.drawHighScore()}else{this.clearHighScoreBounds()}this.flashingRafId=requestAnimationFrame(this.flashHighScore.bind(this))}clearHighScoreBounds(){this.canvasCtx.save();this.canvasCtx.fillStyle="#fff";this.canvasCtx.rect(this.highScoreBounds.x,this.highScoreBounds.y,this.highScoreBounds.width,this.highScoreBounds.height);this.canvasCtx.fill();this.canvasCtx.restore()}startHighScoreFlashing(){this.highScoreFlashing=true;this.flashHighScore()}isHighScoreFlashing(){return this.highScoreFlashing}cancelHighScoreFlashing(){if(this.flashingRafId){cancelAnimationFrame(this.flashingRafId)}this.flashIterations=0;this.flashTimer=0;this.highScoreFlashing=false;this.clearHighScoreBounds();this.drawHighScore()}resetHighScore(){this.setHighScore(0);this.cancelHighScoreFlashing()}reset(){this.update(0,0);this.achievement=false}}DistanceMeter.dimensions={WIDTH:10,HEIGHT:13,DEST_WIDTH:11};DistanceMeter.yPos=[0,13,27,40,53,67,80,93,107,120];DistanceMeter.config={MAX_DISTANCE_UNITS:5,ACHIEVEMENT_DISTANCE:100,COEFFICIENT:.025,FLASH_DURATION:1e3/4,FLASH_ITERATIONS:3,HIGH_SCORE_HIT_AREA_PADDING:4}; // Copyright 2021 The Chromium Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. const GAME_TYPE=[];function CollisionBox(x,y,w,h){this.x=x;this.y=y;this.width=w;this.height=h}const spriteDefinitionByType={original:{LDPI:{BACKGROUND_EL:{x:86,y:2},CACTUS_LARGE:{x:332,y:2},CACTUS_SMALL:{x:228,y:2},OBSTACLE_2:{x:332,y:2},OBSTACLE:{x:228,y:2},CLOUD:{x:86,y:2},HORIZON:{x:2,y:54},MOON:{x:484,y:2},PTERODACTYL:{x:134,y:2},RESTART:{x:2,y:68},TEXT_SPRITE:{x:655,y:2},TREX:{x:848,y:2},STAR:{x:645,y:2},COLLECTABLE:{x:0,y:0},ALT_GAME_END:{x:32,y:0}},HDPI:{BACKGROUND_EL:{x:166,y:2},CACTUS_LARGE:{x:652,y:2},CACTUS_SMALL:{x:446,y:2},OBSTACLE_2:{x:652,y:2},OBSTACLE:{x:446,y:2},CLOUD:{x:166,y:2},HORIZON:{x:2,y:104},MOON:{x:954,y:2},PTERODACTYL:{x:260,y:2},RESTART:{x:2,y:130},TEXT_SPRITE:{x:1294,y:2},TREX:{x:1678,y:2},STAR:{x:1276,y:2},COLLECTABLE:{x:0,y:0},ALT_GAME_END:{x:64,y:0}},MAX_GAP_COEFFICIENT:1.5,MAX_OBSTACLE_LENGTH:3,HAS_CLOUDS:1,BOTTOM_PAD:10,TREX:{WAITING_1:{x:44,w:44,h:47,xOffset:0},WAITING_2:{x:0,w:44,h:47,xOffset:0},RUNNING_1:{x:88,w:44,h:47,xOffset:0},RUNNING_2:{x:132,w:44,h:47,xOffset:0},JUMPING:{x:0,w:44,h:47,xOffset:0},CRASHED:{x:220,w:44,h:47,xOffset:0},COLLISION_BOXES:[new CollisionBox(22,0,17,16),new CollisionBox(1,18,30,9),new CollisionBox(10,35,14,8),new CollisionBox(1,24,29,5),new CollisionBox(5,30,21,4),new CollisionBox(9,34,15,4)]},OBSTACLES:[{type:"CACTUS_SMALL",width:17,height:35,yPos:105,multipleSpeed:4,minGap:120,minSpeed:0,collisionBoxes:[new CollisionBox(0,7,5,27),new CollisionBox(4,0,6,34),new CollisionBox(10,4,7,14)]},{type:"CACTUS_LARGE",width:25,height:50,yPos:90,multipleSpeed:7,minGap:120,minSpeed:0,collisionBoxes:[new CollisionBox(0,12,7,38),new CollisionBox(8,0,7,49),new CollisionBox(13,10,10,38)]},{type:"PTERODACTYL",width:46,height:40,yPos:[100,75,50],yPosMobile:[100,50],multipleSpeed:999,minSpeed:8.5,minGap:150,collisionBoxes:[new CollisionBox(15,15,16,5),new CollisionBox(18,21,24,6),new CollisionBox(2,14,4,3),new CollisionBox(6,10,4,7),new CollisionBox(10,8,6,9)],numFrames:2,frameRate:1e3/6,speedOffset:.8},{type:"COLLECTABLE",width:31,height:24,yPos:104,multipleSpeed:1e3,minGap:9999,minSpeed:0,collisionBoxes:[new CollisionBox(0,0,32,25)]}],BACKGROUND_EL:{CLOUD:{height:14,maxCloudGap:400,maxSkyLevel:30,minCloudGap:100,minSkyLevel:71,offset:4,width:46,xPos:1,yPos:120}},BACKGROUND_EL_CONFIG:{maxBgEls:1,maxGap:400,minGap:100,pos:0,speed:.5,yPos:125},LINES:[{sourceX:2,sourceY:52,width:600,height:12,yPos:127}],ALT_GAME_OVER_TEXT_CONFIG:{TEXT_X:32,TEXT_Y:0,TEXT_WIDTH:246,TEXT_HEIGHT:17,FLASH_DURATION:1500,FLASHING:false}}}; // Copyright 2024 The Chromium Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. class Trex{constructor(canvas,spritePos){this.canvas=canvas;this.canvasCtx=canvas.getContext("2d");this.spritePos=spritePos;this.xPos=0;this.yPos=0;this.xInitialPos=0;this.groundYPos=0;this.currentFrame=0;this.currentAnimFrames=[];this.blinkDelay=0;this.blinkCount=0;this.animStartTime=0;this.timer=0;this.msPerFrame=1e3/FPS;this.config=Object.assign(Trex.config,Trex.normalJumpConfig);this.status=Trex.status.WAITING;this.jumping=false;this.ducking=false;this.jumpVelocity=0;this.reachedMinHeight=false;this.speedDrop=false;this.jumpCount=0;this.jumpspotX=0;this.altGameModeEnabled=false;this.flashing=false;this.init()}init(){this.groundYPos=Runner.defaultDimensions.height-this.config.HEIGHT-Runner.config.BOTTOM_PAD;this.yPos=this.groundYPos;this.minJumpHeight=this.groundYPos-this.config.MIN_JUMP_HEIGHT;this.draw(0,0);this.update(0,Trex.status.WAITING)}enableSlowConfig(){const jumpConfig=Runner.slowDown?Trex.slowJumpConfig:Trex.normalJumpConfig;Trex.config=Object.assign(Trex.config,jumpConfig);this.adjustAltGameConfigForSlowSpeed()}enableAltGameMode(spritePos){this.altGameModeEnabled=true;this.spritePos=spritePos;const spriteDefinition=Runner.spriteDefinition["TREX"];Trex.animFrames.RUNNING.frames=[spriteDefinition.RUNNING_1.x,spriteDefinition.RUNNING_2.x];Trex.animFrames.CRASHED.frames=[spriteDefinition.CRASHED.x];if(typeof spriteDefinition.JUMPING.x==="object"){Trex.animFrames.JUMPING.frames=spriteDefinition.JUMPING.x}else{Trex.animFrames.JUMPING.frames=[spriteDefinition.JUMPING.x]}Trex.animFrames.DUCKING.frames=[spriteDefinition.DUCKING_1.x,spriteDefinition.DUCKING_2.x];Trex.config.GRAVITY=spriteDefinition.GRAVITY||Trex.config.GRAVITY;Trex.config.HEIGHT=spriteDefinition.RUNNING_1.h,Trex.config.INITIAL_JUMP_VELOCITY=spriteDefinition.INITIAL_JUMP_VELOCITY;Trex.config.MAX_JUMP_HEIGHT=spriteDefinition.MAX_JUMP_HEIGHT;Trex.config.MIN_JUMP_HEIGHT=spriteDefinition.MIN_JUMP_HEIGHT;Trex.config.WIDTH=spriteDefinition.RUNNING_1.w;Trex.config.WIDTH_CRASHED=spriteDefinition.CRASHED.w;Trex.config.WIDTH_JUMP=spriteDefinition.JUMPING.w;Trex.config.INVERT_JUMP=spriteDefinition.INVERT_JUMP;this.adjustAltGameConfigForSlowSpeed(spriteDefinition.GRAVITY);this.config=Trex.config;this.groundYPos=Runner.defaultDimensions.height-this.config.HEIGHT-Runner.spriteDefinition["BOTTOM_PAD"];this.yPos=this.groundYPos;this.reset()}adjustAltGameConfigForSlowSpeed(opt_gravityValue){if(Runner.slowDown){if(opt_gravityValue){Trex.config.GRAVITY=opt_gravityValue/1.5}Trex.config.MIN_JUMP_HEIGHT*=1.5;Trex.config.MAX_JUMP_HEIGHT*=1.5;Trex.config.INITIAL_JUMP_VELOCITY=Trex.config.INITIAL_JUMP_VELOCITY*1.5}}setFlashing(status){this.flashing=status}setJumpVelocity(setting){this.config.INITIAL_JUMP_VELOCITY=-setting;this.config.DROP_VELOCITY=-setting/2}update(deltaTime,opt_status){this.timer+=deltaTime;if(opt_status){this.status=opt_status;this.currentFrame=0;this.msPerFrame=Trex.animFrames[opt_status].msPerFrame;this.currentAnimFrames=Trex.animFrames[opt_status].frames;if(opt_status===Trex.status.WAITING){this.animStartTime=getTimeStamp();this.setBlinkDelay()}}if(this.playingIntro&&this.xPos=this.msPerFrame){this.currentFrame=this.currentFrame===this.currentAnimFrames.length-1?0:this.currentFrame+1;this.timer=0}if(this.speedDrop&&this.yPos===this.groundYPos){this.speedDrop=false;this.setDuck(true)}}draw(x,y){let sourceX=x;let sourceY=y;let sourceWidth=this.ducking&&this.status!==Trex.status.CRASHED?this.config.WIDTH_DUCK:this.config.WIDTH;let sourceHeight=this.config.HEIGHT;const outputHeight=sourceHeight;const outputWidth=this.altGameModeEnabled&&this.status===Trex.status.CRASHED?this.config.WIDTH_CRASHED:this.config.WIDTH;let jumpOffset=Runner.spriteDefinition.TREX.JUMPING.xOffset;if(this.altGameModeEnabled){if(this.jumping&&this.status!==Trex.status.CRASHED){sourceWidth=this.config.WIDTH_JUMP}else if(this.status===Trex.status.CRASHED){sourceWidth=this.config.WIDTH_CRASHED}}if(IS_HIDPI){sourceX*=2;sourceY*=2;sourceWidth*=2;sourceHeight*=2;jumpOffset*=2}sourceX+=this.spritePos.x;sourceY+=this.spritePos.y;if(this.flashing){if(this.timerthis.config.FLASH_OFF){this.timer=0}}if(this.ducking&&this.status!==Trex.status.CRASHED){this.canvasCtx.drawImage(Runner.imageSprite,sourceX,sourceY,sourceWidth,sourceHeight,this.xPos,this.yPos,this.config.WIDTH_DUCK,outputHeight)}else if(this.altGameModeEnabled&&this.jumping&&this.status!==Trex.status.CRASHED){this.canvasCtx.drawImage(Runner.imageSprite,sourceX,sourceY,sourceWidth,sourceHeight,this.xPos-jumpOffset,this.yPos,this.config.WIDTH_JUMP,outputHeight)}else{if(this.ducking&&this.status===Trex.status.CRASHED){this.xPos++}this.canvasCtx.drawImage(Runner.imageSprite,sourceX,sourceY,sourceWidth,sourceHeight,this.xPos,this.yPos,outputWidth,outputHeight)}this.canvasCtx.globalAlpha=1}setBlinkDelay(){this.blinkDelay=Math.ceil(Math.random()*Trex.BLINK_TIMING)}blink(time){const deltaTime=time-this.animStartTime;if(deltaTime>=this.blinkDelay){this.draw(this.currentAnimFrames[this.currentFrame],0);if(this.currentFrame===1){this.setBlinkDelay();this.animStartTime=time;this.blinkCount++}}}startJump(speed){if(!this.jumping){this.update(0,Trex.status.JUMPING);this.jumpVelocity=this.config.INITIAL_JUMP_VELOCITY-speed/10;this.jumping=true;this.reachedMinHeight=false;this.speedDrop=false;if(this.config.INVERT_JUMP){this.minJumpHeight=this.groundYPos+this.config.MIN_JUMP_HEIGHT}}}endJump(){if(this.reachedMinHeight&&this.jumpVelocitythis.minJumpHeight||!this.config.INVERT_JUMP&&this.yPos-this.config.MAX_JUMP_HEIGHT||!this.config.INVERT_JUMP&&this.yPosthis.groundYPos){this.reset();this.jumpCount++;if(Runner.audioCues){Runner.generatedSoundFx.loopFootSteps()}}}setSpeedDrop(){this.speedDrop=true;this.jumpVelocity=1}setDuck(isDucking){if(isDucking&&this.status!==Trex.status.DUCKING){this.update(0,Trex.status.DUCKING);this.ducking=true}else if(this.status===Trex.status.DUCKING){this.update(0,Trex.status.RUNNING);this.ducking=false}}reset(){this.xPos=this.xInitialPos;this.yPos=this.groundYPos;this.jumpVelocity=0;this.jumping=false;this.ducking=false;this.update(0,Trex.status.RUNNING);this.midair=false;this.speedDrop=false;this.jumpCount=0}}Trex.config={DROP_VELOCITY:-5,FLASH_OFF:175,FLASH_ON:100,HEIGHT:47,HEIGHT_DUCK:25,INTRO_DURATION:1500,SPEED_DROP_COEFFICIENT:3,SPRITE_WIDTH:262,START_X_POS:50,WIDTH:44,WIDTH_DUCK:59};Trex.slowJumpConfig={GRAVITY:.25,MAX_JUMP_HEIGHT:50,MIN_JUMP_HEIGHT:45,INITIAL_JUMP_VELOCITY:-20};Trex.normalJumpConfig={GRAVITY:.6,MAX_JUMP_HEIGHT:30,MIN_JUMP_HEIGHT:30,INITIAL_JUMP_VELOCITY:-10};Trex.collisionBoxes={DUCKING:[new CollisionBox(1,18,55,25)],RUNNING:[new CollisionBox(22,0,17,16),new CollisionBox(1,18,30,9),new CollisionBox(10,35,14,8),new CollisionBox(1,24,29,5),new CollisionBox(5,30,21,4),new CollisionBox(9,34,15,4)]};Trex.status={CRASHED:"CRASHED",DUCKING:"DUCKING",JUMPING:"JUMPING",RUNNING:"RUNNING",WAITING:"WAITING"};Trex.BLINK_TIMING=7e3;Trex.animFrames={WAITING:{frames:[44,0],msPerFrame:1e3/3},RUNNING:{frames:[88,132],msPerFrame:1e3/12},CRASHED:{frames:[220],msPerFrame:1e3/60},JUMPING:{frames:[0],msPerFrame:1e3/60},DUCKING:{frames:[264,323],msPerFrame:1e3/8}}; // Copyright 2024 The Chromium Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. class GameOverPanel{constructor(canvas,textImgPos,restartImgPos,dimensions,opt_altGameEndImgPos,opt_altGameActive){this.canvas=canvas;this.canvasCtx=canvas.getContext("2d");this.canvasDimensions=dimensions;this.textImgPos=textImgPos;this.restartImgPos=restartImgPos;this.altGameEndImgPos=opt_altGameEndImgPos;this.altGameModeActive=opt_altGameActive;this.frameTimeStamp=0;this.animTimer=0;this.currentFrame=0;this.gameOverRafId=null;this.flashTimer=0;this.flashCounter=0;this.originalText=true}updateDimensions(width,opt_height){this.canvasDimensions.width=width;if(opt_height){this.canvasDimensions.height=opt_height}this.currentFrame=GameOverPanel.animConfig.frames.length-1}drawGameOverText(dimensions,opt_useAltText){const centerX=this.canvasDimensions.width/2;let textSourceX=dimensions.TEXT_X;let textSourceY=dimensions.TEXT_Y;let textSourceWidth=dimensions.TEXT_WIDTH;let textSourceHeight=dimensions.TEXT_HEIGHT;const textTargetX=Math.round(centerX-dimensions.TEXT_WIDTH/2);const textTargetY=Math.round((this.canvasDimensions.height-25)/3);const textTargetWidth=dimensions.TEXT_WIDTH;const textTargetHeight=dimensions.TEXT_HEIGHT;if(IS_HIDPI){textSourceY*=2;textSourceX*=2;textSourceWidth*=2;textSourceHeight*=2}if(!opt_useAltText){textSourceX+=this.textImgPos.x;textSourceY+=this.textImgPos.y}const spriteSource=opt_useAltText?Runner.altCommonImageSprite:Runner.origImageSprite;this.canvasCtx.save();if(IS_RTL){this.canvasCtx.translate(this.canvasDimensions.width,0);this.canvasCtx.scale(-1,1)}this.canvasCtx.drawImage(spriteSource,textSourceX,textSourceY,textSourceWidth,textSourceHeight,textTargetX,textTargetY,textTargetWidth,textTargetHeight);this.canvasCtx.restore()}drawAltGameElements(tRex){if(this.altGameModeActive&&Runner.spriteDefinition.ALT_GAME_END_CONFIG){const altGameEndConfig=Runner.spriteDefinition.ALT_GAME_END_CONFIG;let altGameEndSourceWidth=altGameEndConfig.WIDTH;let altGameEndSourceHeight=altGameEndConfig.HEIGHT;const altGameEndTargetX=tRex.xPos+altGameEndConfig.X_OFFSET;const altGameEndTargetY=tRex.yPos+altGameEndConfig.Y_OFFSET;if(IS_HIDPI){altGameEndSourceWidth*=2;altGameEndSourceHeight*=2}this.canvasCtx.drawImage(Runner.altCommonImageSprite,this.altGameEndImgPos.x,this.altGameEndImgPos.y,altGameEndSourceWidth,altGameEndSourceHeight,altGameEndTargetX,altGameEndTargetY,altGameEndConfig.WIDTH,altGameEndConfig.HEIGHT)}}drawRestartButton(){const dimensions=GameOverPanel.dimensions;let framePosX=GameOverPanel.animConfig.frames[this.currentFrame];let restartSourceWidth=dimensions.RESTART_WIDTH;let restartSourceHeight=dimensions.RESTART_HEIGHT;const restartTargetX=this.canvasDimensions.width/2-dimensions.RESTART_WIDTH/2;const restartTargetY=this.canvasDimensions.height/2;if(IS_HIDPI){restartSourceWidth*=2;restartSourceHeight*=2;framePosX*=2}this.canvasCtx.save();if(IS_RTL){this.canvasCtx.translate(this.canvasDimensions.width,0);this.canvasCtx.scale(-1,1)}this.canvasCtx.drawImage(Runner.origImageSprite,this.restartImgPos.x+framePosX,this.restartImgPos.y,restartSourceWidth,restartSourceHeight,restartTargetX,restartTargetY,dimensions.RESTART_WIDTH,dimensions.RESTART_HEIGHT);this.canvasCtx.restore()}draw(opt_altGameModeActive,opt_tRex){if(opt_altGameModeActive){this.altGameModeActive=opt_altGameModeActive}this.drawGameOverText(GameOverPanel.dimensions,false);this.drawRestartButton();this.drawAltGameElements(opt_tRex);this.update()}update(){const now=getTimeStamp();const deltaTime=now-(this.frameTimeStamp||now);this.frameTimeStamp=now;this.animTimer+=deltaTime;this.flashTimer+=deltaTime;if(this.currentFrame===0&&this.animTimer>GameOverPanel.LOGO_PAUSE_DURATION){this.animTimer=0;this.currentFrame++;this.drawRestartButton()}else if(this.currentFrame>0&&this.currentFrame=GameOverPanel.animConfig.msPerFrame){this.currentFrame++;this.drawRestartButton()}}else if(!this.altGameModeActive&&this.currentFrame===GameOverPanel.animConfig.frames.length){this.reset();return}if(this.altGameModeActive&&spriteDefinitionByType.original.ALT_GAME_OVER_TEXT_CONFIG){const altTextConfig=spriteDefinitionByType.original.ALT_GAME_OVER_TEXT_CONFIG;if(altTextConfig.FLASHING){if(this.flashCounteraltTextConfig.FLASH_DURATION){this.flashTimer=0;this.originalText=!this.originalText;this.clearGameOverTextBounds();if(this.originalText){this.drawGameOverText(GameOverPanel.dimensions,false);this.flashCounter++}else{this.drawGameOverText(altTextConfig,true)}}else if(this.flashCounter>=GameOverPanel.FLASH_ITERATIONS){this.reset();return}}else{this.clearGameOverTextBounds(altTextConfig);this.drawGameOverText(altTextConfig,true)}}this.gameOverRafId=requestAnimationFrame(this.update.bind(this))}clearGameOverTextBounds(dimensions){this.canvasCtx.save();this.canvasCtx.clearRect(Math.round(this.canvasDimensions.width/2-dimensions.TEXT_WIDTH/2),Math.round((this.canvasDimensions.height-25)/3),dimensions.TEXT_WIDTH,dimensions.TEXT_HEIGHT+4);this.canvasCtx.restore()}reset(){if(this.gameOverRafId){cancelAnimationFrame(this.gameOverRafId);this.gameOverRafId=null}this.animTimer=0;this.frameTimeStamp=0;this.currentFrame=0;this.flashTimer=0;this.flashCounter=0;this.originalText=true}}GameOverPanel.RESTART_ANIM_DURATION=875;GameOverPanel.LOGO_PAUSE_DURATION=875;GameOverPanel.FLASH_ITERATIONS=5;GameOverPanel.animConfig={frames:[0,36,72,108,144,180,216,252],msPerFrame:GameOverPanel.RESTART_ANIM_DURATION/8};GameOverPanel.dimensions={TEXT_X:0,TEXT_Y:13,TEXT_WIDTH:191,TEXT_HEIGHT:11,RESTART_WIDTH:36,RESTART_HEIGHT:32}; // Copyright 2024 The Chromium Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. class GeneratedSoundFx{constructor(){this.context=new AudioContext;if(IS_IOS){this.context.onstatechange=()=>{if(this.context.state!=="running"){this.context.resume()}};this.context.resume()}this.panner=this.context.createStereoPanner?this.context.createStereoPanner():null}context;panner=null;bgSoundIntervalId=null;stopAll(){this.cancelFootSteps()}playNote(frequency,startTime,duration,vol=.01,pan=0){const osc1=this.context.createOscillator();const osc2=this.context.createOscillator();const volume=this.context.createGain();osc1.type="triangle";osc2.type="triangle";volume.gain.value=.1;if(this.panner){this.panner.pan.value=pan;osc1.connect(volume).connect(this.panner);osc2.connect(volume).connect(this.panner);this.panner.connect(this.context.destination)}else{osc1.connect(volume);osc2.connect(volume);volume.connect(this.context.destination)}osc1.frequency.value=frequency+1;osc2.frequency.value=frequency-2;volume.gain.setValueAtTime(vol,startTime+duration-.05);volume.gain.linearRampToValueAtTime(1e-5,startTime+duration);osc1.start(startTime);osc2.start(startTime);osc1.stop(startTime+duration);osc2.stop(startTime+duration)}background(){const now=this.context.currentTime;this.playNote(493.883,now,.116);this.playNote(659.255,now+.116,.232);this.loopFootSteps()}loopFootSteps(){if(!this.bgSoundIntervalId){this.bgSoundIntervalId=setInterval((()=>{this.playNote(73.42,this.context.currentTime,.05,.16);this.playNote(69.3,this.context.currentTime+.116,.116,.16)}),280)}}cancelFootSteps(){if(this.bgSoundIntervalId){clearInterval(this.bgSoundIntervalId);this.bgSoundIntervalId=null;this.playNote(103.83,this.context.currentTime,.232,.02);this.playNote(116.54,this.context.currentTime+.116,.232,.02)}}collect(){this.cancelFootSteps();const now=this.context.currentTime;this.playNote(830.61,now,.116);this.playNote(1318.51,now+.116,.232)}jump(){const now=this.context.currentTime;this.playNote(659.25,now,.116,.3,-.6);this.playNote(880,now+.116,.232,.3,-.6)}} // Copyright 2024 The Chromium Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. function getSpriteConfigForType(type){if("spriteDefinition"in Runner){const spriteDefinition=Runner.spriteDefinition;if(spriteDefinition){if(spriteDefinition.BACKGROUND_EL[type]){return spriteDefinition.BACKGROUND_EL[type]}}}return null}let globalConfig={maxBgEls:0,maxGap:0,minGap:0,msPerFrame:0,pos:0,speed:0,yPos:0};function getGlobalConfig(){return globalConfig}function setGlobalConfig(config){globalConfig=config}class BackgroundEl{gap;xPos;canvas;canvasCtx;spritePos;yPos=0;remove=false;type;animTimer=0;spriteConfig;switchFrames=false;constructor(canvas,spritePos,containerWidth,type){this.canvas=canvas;const canvasContext=this.canvas.getContext("2d");assert(canvasContext);this.canvasCtx=canvasContext;this.spritePos=spritePos;this.xPos=containerWidth;this.type=type;this.gap=getRandomNum(getGlobalConfig().minGap,getGlobalConfig().maxGap);const spriteConfig=getSpriteConfigForType(this.type);assert(spriteConfig);this.spriteConfig=spriteConfig;this.init()}init(){if(this.spriteConfig.fixed){this.xPos=this.spriteConfig.fixedXPos}this.yPos=getGlobalConfig().yPos-this.spriteConfig.height+this.spriteConfig.offset;this.draw()}draw(){this.canvasCtx.save();let sourceWidth=this.spriteConfig.width;let sourceHeight=this.spriteConfig.height;let sourceX=this.spriteConfig.xPos;const outputWidth=sourceWidth;const outputHeight=sourceHeight;const imageSprite=getRunnerImageSprite();assert(imageSprite);if(IS_HIDPI){sourceWidth*=2;sourceHeight*=2;sourceX*=2}this.canvasCtx.drawImage(imageSprite,sourceX,this.spritePos.y,sourceWidth,sourceHeight,this.xPos,this.yPos,outputWidth,outputHeight);this.canvasCtx.restore()}update(speed){if(!this.remove){if(this.spriteConfig.fixed){const globalConfig=getGlobalConfig();assert(globalConfig.msPerFrame);this.animTimer+=speed;if(this.animTimer>globalConfig.msPerFrame){this.animTimer=0;this.switchFrames=!this.switchFrames}if(this.spriteConfig.fixedYPos1&&this.spriteConfig.fixedYPos2){this.yPos=this.switchFrames?this.spriteConfig.fixedYPos1:this.spriteConfig.fixedYPos2}}else{this.xPos-=getGlobalConfig().speed}this.draw();if(!this.isVisible()){this.remove=true}}}isVisible(){return this.xPos+this.spriteConfig.width>0}} // Copyright 2025 The Chromium Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. class Cloud{xPos;yPos=0;canvasCtx;remove=false;spritePos;constructor(canvas,spritePos,containerWidth){const canvasContext=canvas.getContext("2d");assert(canvasContext);this.canvasCtx=canvasContext;this.xPos=containerWidth;this.spritePos=spritePos;this.init()}init(){this.yPos=getRandomNum(Config$1.MAX_SKY_LEVEL,Config$1.MIN_SKY_LEVEL);this.draw()}draw(){const runnerImageSprite=getRunnerImageSprite();assert(runnerImageSprite);this.canvasCtx.save();let sourceWidth=Config$1.WIDTH;let sourceHeight=Config$1.HEIGHT;const outputWidth=sourceWidth;const outputHeight=sourceHeight;if(IS_HIDPI){sourceWidth=sourceWidth*2;sourceHeight=sourceHeight*2}this.canvasCtx.drawImage(runnerImageSprite,this.spritePos.x,this.spritePos.y,sourceWidth,sourceHeight,this.xPos,this.yPos,outputWidth,outputHeight);this.canvasCtx.restore()}update(speed){if(!this.remove){this.xPos-=Math.ceil(speed);this.draw();if(!this.isVisible()){this.remove=true}}}isVisible(){return this.xPos+Config$1.WIDTH>0}}var Config$1;(function(Config){Config[Config["HEIGHT"]=14]="HEIGHT";Config[Config["MAX_CLOUD_GAP"]=400]="MAX_CLOUD_GAP";Config[Config["MAX_SKY_LEVEL"]=30]="MAX_SKY_LEVEL";Config[Config["MIN_CLOUD_GAP"]=100]="MIN_CLOUD_GAP";Config[Config["MIN_SKY_LEVEL"]=71]="MIN_SKY_LEVEL";Config[Config["WIDTH"]=46]="WIDTH"})(Config$1||(Config$1={})); // Copyright 2024 The Chromium Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. class HorizonLine{canvasCtx;xPos;yPos=0;bumpThreshold=.5;sourceXPos;spritePos;sourceDimensions;dimensions;constructor(canvas,lineConfig){let sourceX=lineConfig.sourceX;let sourceY=lineConfig.sourceY;if(IS_HIDPI){sourceX*=2;sourceY*=2}this.spritePos={x:sourceX,y:sourceY};const canvasContext=canvas.getContext("2d");assert(canvasContext);this.canvasCtx=canvasContext;this.dimensions={width:lineConfig.width,height:lineConfig.height};this.sourceXPos=[this.spritePos.x,this.spritePos.x+this.dimensions.width];this.xPos=[0,this.dimensions.width];this.yPos=lineConfig.yPos;this.sourceDimensions={height:lineConfig.height,width:lineConfig.width};if(IS_HIDPI){this.sourceDimensions.width=lineConfig.width*2;this.sourceDimensions.height=lineConfig.height*2}this.draw()}getRandomType(){return Math.random()>this.bumpThreshold?this.dimensions.width:0}draw(){const runnerImageSprite=getRunnerImageSprite();assert(runnerImageSprite);this.canvasCtx.drawImage(runnerImageSprite,this.sourceXPos[0],this.spritePos.y,this.sourceDimensions.width,this.sourceDimensions.height,this.xPos[0],this.yPos,this.dimensions.width,this.dimensions.height);this.canvasCtx.drawImage(runnerImageSprite,this.sourceXPos[1],this.spritePos.y,this.sourceDimensions.width,this.sourceDimensions.height,this.xPos[1],this.yPos,this.dimensions.width,this.dimensions.height)}updatexPos(pos,increment){const line1=pos;const line2=pos===0?1:0;this.xPos[line1]-=increment;this.xPos[line2]=this.xPos[line1]+this.dimensions.width;if(this.xPos[line1]<=-this.dimensions.width){this.xPos[line1]+=this.dimensions.width*2;this.xPos[line2]=this.xPos[line1]-this.dimensions.width;this.sourceXPos[line1]=this.getRandomType()+this.spritePos.x}}update(deltaTime,speed){const increment=Math.floor(speed*(FPS/1e3)*deltaTime);this.updatexPos(this.xPos[0]<=0?0:1,increment);this.draw()}reset(){this.xPos[0]=0;this.xPos[1]=this.dimensions.width}} // Copyright 2024 The Chromium Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. const PHASES=[140,120,100,60,40,20,0];var Config;(function(Config){Config[Config["FADE_SPEED"]=.035]="FADE_SPEED";Config[Config["HEIGHT"]=40]="HEIGHT";Config[Config["MOON_SPEED"]=.25]="MOON_SPEED";Config[Config["NUM_STARS"]=2]="NUM_STARS";Config[Config["STAR_SIZE"]=9]="STAR_SIZE";Config[Config["STAR_SPEED"]=.3]="STAR_SPEED";Config[Config["STAR_MAX_Y"]=70]="STAR_MAX_Y";Config[Config["WIDTH"]=20]="WIDTH"})(Config||(Config={}));class NightMode{spritePos;canvasCtx;xPos=0;yPos=30;currentPhase=0;opacity=0;containerWidth;stars=new Array(Config.NUM_STARS);drawStars=false;constructor(canvas,spritePos,containerWidth){this.spritePos=spritePos;const canvasContext=canvas.getContext("2d");assert(canvasContext);this.canvasCtx=canvasContext;this.containerWidth=containerWidth;this.placeStars()}update(activated){if(activated&&this.opacity===0){this.currentPhase++;if(this.currentPhase>=PHASES.length){this.currentPhase=0}}if(activated&&(this.opacity<1||this.opacity===0)){this.opacity+=Config.FADE_SPEED}else if(this.opacity>0){this.opacity-=Config.FADE_SPEED}if(this.opacity>0){this.xPos=this.updateXpos(this.xPos,Config.MOON_SPEED);if(this.drawStars){for(let i=0;i1&&this.typeConfig.multipleSpeed>speed){this.size=1}this.width=this.typeConfig.width*this.size;if(Array.isArray(this.typeConfig.yPos)){assert(Array.isArray(this.typeConfig.yPosMobile));const yPosConfig=IS_MOBILE?this.typeConfig.yPosMobile:this.typeConfig.yPos;const randomYPos=yPosConfig[getRandomNum(0,yPosConfig.length-1)];assert(randomYPos);this.yPos=randomYPos}else{this.yPos=this.typeConfig.yPos}this.draw();if(this.size>1){assert(this.collisionBoxes.length>=3);this.collisionBoxes[1].width=this.width-this.collisionBoxes[0].width-this.collisionBoxes[2].width;this.collisionBoxes[2].x=this.width-this.collisionBoxes[2].width}if(this.typeConfig.speedOffset){this.speedOffset=Math.random()>.5?this.typeConfig.speedOffset:-this.typeConfig.speedOffset}this.gap=this.getGap(this.gapCoefficient,speed);if(getRunnerAudioCues()){this.gap*=2}}draw(){let sourceWidth=this.typeConfig.width;let sourceHeight=this.typeConfig.height;if(IS_HIDPI){sourceWidth=sourceWidth*2;sourceHeight=sourceHeight*2}let sourceX=sourceWidth*this.size*(.5*(this.size-1))+this.spritePos.x;if(this.currentFrame>0){sourceX+=sourceWidth*this.currentFrame}this.canvasCtx.drawImage(this.imageSprite,sourceX,this.spritePos.y,sourceWidth*this.size,sourceHeight,this.xPos,this.yPos,this.typeConfig.width*this.size,this.typeConfig.height)}update(deltaTime,speed){if(!this.remove){if(this.typeConfig.speedOffset){speed+=this.speedOffset}this.xPos-=Math.floor(speed*FPS/1e3*deltaTime);if(this.typeConfig.numFrames){this.timer+=deltaTime;if(this.timer>=this.typeConfig.frameRate){this.currentFrame=this.currentFrame===this.typeConfig.numFrames-1?0:this.currentFrame+1;this.timer=0}}this.draw();if(!this.isVisible()){this.remove=true}}}getGap(gapCoefficient,speed){const minGap=Math.round(this.width*speed+this.typeConfig.minGap*gapCoefficient);const maxGap=Math.round(minGap*maxGapCoefficient);return getRandomNum(minGap,maxGap)}isVisible(){return this.xPos+this.width>0}cloneCollisionBoxes(){const collisionBoxes=this.typeConfig.collisionBoxes;for(let i=collisionBoxes.length-1;i>=0;i--){this.collisionBoxes[i]=new CollisionBox(collisionBoxes[i].x,collisionBoxes[i].y,collisionBoxes[i].width,collisionBoxes[i].height)}}} // Copyright 2024 The Chromium Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. let obstacleTypes=[];class Horizon{constructor(canvas,spritePos,dimensions,gapCoefficient){this.canvas=canvas;this.canvasCtx=this.canvas.getContext("2d");this.config=Horizon.config;this.dimensions=dimensions;this.gapCoefficient=gapCoefficient;this.obstacles=[];this.obstacleHistory=[];this.horizonOffsets=[0,0];this.cloudFrequency=this.config.CLOUD_FREQUENCY;this.spritePos=spritePos;this.nightMode=null;this.altGameModeActive=false;this.clouds=[];this.cloudSpeed=this.config.BG_CLOUD_SPEED;this.backgroundEls=[];this.lastEl=null;this.backgroundSpeed=this.config.BG_CLOUD_SPEED;this.horizonLine=null;this.horizonLines=[];this.init()}init(){obstacleTypes=spriteDefinitionByType.original.OBSTACLES;this.addCloud();for(let i=0;i=0;i--){bgElArray[i].update(elSpeed)}const lastEl=bgElArray[numElements-1];if(numElementslastEl.gap&&frequency>Math.random()){bgElAddFunction()}}else{bgElAddFunction()}}updateClouds(deltaTime,speed){const elSpeed=this.cloudSpeed/1e3*deltaTime*speed;this.updateBackgroundEl(elSpeed,this.clouds,this.config.MAX_CLOUDS,this.addCloud.bind(this),this.cloudFrequency);this.clouds=this.clouds.filter((obj=>!obj.remove))}updateBackgroundEls(deltaTime,speed){this.updateBackgroundEl(deltaTime,this.backgroundEls,getGlobalConfig().maxBgEls,this.addBackgroundEl.bind(this),this.cloudFrequency);this.backgroundEls=this.backgroundEls.filter((obj=>!obj.remove))}updateObstacles(deltaTime,currentSpeed){const updatedObstacles=this.obstacles.slice(0);for(let i=0;i0){const lastObstacle=this.obstacles[this.obstacles.length-1];if(lastObstacle&&!lastObstacle.followingObstacleCreated&&lastObstacle.isVisible()&&lastObstacle.xPos+lastObstacle.width+lastObstacle.gap0?getRandomNum(0,obstacleCount):0;const obstacleType=obstacleTypes[obstacleTypeIndex];if(obstacleCount>0&&this.duplicateObstacleCheck(obstacleType.type)||currentSpeed1){this.obstacleHistory.splice(Runner.config.MAX_OBSTACLE_DUPLICATION)}}}duplicateObstacleCheck(nextObstacleType){let duplicateCount=0;for(let i=0;i=Runner.config.MAX_OBSTACLE_DUPLICATION}reset(){this.obstacles=[];for(let l=0;l0){let index=getRandomNum(0,backgroundElTypes.length-1);let type=backgroundElTypes[index];while(type===this.lastEl&&backgroundElTypes.length>1){index=getRandomNum(0,backgroundElTypes.length-1);type=backgroundElTypes[index]}this.lastEl=type;this.backgroundEls.push(new BackgroundEl(this.canvas,this.spritePos.BACKGROUND_EL,this.dimensions.WIDTH,type))}}}Horizon.config={BG_CLOUD_SPEED:.2,BUMPY_THRESHOLD:.3,CLOUD_FREQUENCY:.5,HORIZON_HEIGHT:16,MAX_CLOUDS:6}; // Copyright 2014 The Chromium Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. function Runner(outerContainerId,opt_config){if(Runner.instance_){return Runner.instance_}Runner.instance_=this;this.outerContainerEl=document.querySelector(outerContainerId);this.containerEl=null;this.snackbarEl=null;this.touchController=null;this.config=opt_config||Object.assign(Runner.config,Runner.normalConfig);this.dimensions=Runner.defaultDimensions;this.gameType=null;Runner.spriteDefinition=spriteDefinitionByType["original"];this.altGameImageSprite=null;this.altGameModeActive=false;this.altGameModeFlashTimer=null;this.fadeInTimer=0;this.canvas=null;this.canvasCtx=null;this.tRex=null;this.distanceMeter=null;this.distanceRan=0;this.highestScore=0;this.syncHighestScore=false;this.time=0;this.runningTime=0;this.msPerFrame=1e3/FPS;this.currentSpeed=this.config.SPEED;Runner.slowDown=false;this.obstacles=[];this.activated=false;this.playing=false;this.crashed=false;this.paused=false;this.inverted=false;this.invertTimer=0;this.resizeTimerId_=null;this.playCount=0;this.audioBuffer=null;this.soundFx={};this.generatedSoundFx=null;this.audioContext=null;this.images={};this.imagesLoaded=0;this.pollingGamepads=false;this.gamepadIndex=undefined;this.previousGamepad=null;if(this.isDisabled()){this.setupDisabledRunner()}else{if(Runner.isAltGameModeEnabled()){this.initAltGameType();Runner.gameType=this.gameType}this.loadImages();window["initializeEasterEggHighScore"]=this.initializeHighScore.bind(this)}}const DEFAULT_WIDTH=600;const ARCADE_MODE_URL="chrome://dino/";const RESOURCE_POSTFIX="offline-resources-";const A11Y_STRINGS={ariaLabel:"dinoGameA11yAriaLabel",description:"dinoGameA11yDescription",gameOver:"dinoGameA11yGameOver",highScore:"dinoGameA11yHighScore",jump:"dinoGameA11yJump",started:"dinoGameA11yStartGame",speedLabel:"dinoGameA11ySpeedToggle"};Runner.config={AUDIOCUE_PROXIMITY_THRESHOLD:190,AUDIOCUE_PROXIMITY_THRESHOLD_MOBILE_A11Y:250,BG_CLOUD_SPEED:.2,BOTTOM_PAD:10,CANVAS_IN_VIEW_OFFSET:-10,CLEAR_TIME:3e3,CLOUD_FREQUENCY:.5,FADE_DURATION:1,FLASH_DURATION:1e3,GAMEOVER_CLEAR_TIME:1200,INITIAL_JUMP_VELOCITY:12,INVERT_FADE_DURATION:12e3,MAX_BLINK_COUNT:3,MAX_CLOUDS:6,MAX_OBSTACLE_LENGTH:3,MAX_OBSTACLE_DUPLICATION:2,RESOURCE_TEMPLATE_ID:"audio-resources",SPEED:6,SPEED_DROP_COEFFICIENT:3,ARCADE_MODE_INITIAL_TOP_POSITION:35,ARCADE_MODE_TOP_POSITION_PERCENT:.1};Runner.normalConfig={ACCELERATION:.001,AUDIOCUE_PROXIMITY_THRESHOLD:190,AUDIOCUE_PROXIMITY_THRESHOLD_MOBILE_A11Y:250,GAP_COEFFICIENT:.6,INVERT_DISTANCE:700,MAX_SPEED:13,MOBILE_SPEED_COEFFICIENT:1.2,SPEED:6};Runner.slowConfig={ACCELERATION:5e-4,AUDIOCUE_PROXIMITY_THRESHOLD:170,AUDIOCUE_PROXIMITY_THRESHOLD_MOBILE_A11Y:220,GAP_COEFFICIENT:.3,INVERT_DISTANCE:350,MAX_SPEED:9,MOBILE_SPEED_COEFFICIENT:1.5,SPEED:4.2};Runner.defaultDimensions={width:DEFAULT_WIDTH,height:150};Runner.classes={ARCADE_MODE:"arcade-mode",CANVAS:"runner-canvas",CONTAINER:"runner-container",CRASHED:"crashed",ICON:"icon-offline",INVERTED:"inverted",SNACKBAR:"snackbar",SNACKBAR_SHOW:"snackbar-show",TOUCH_CONTROLLER:"controller"};Runner.sounds={BUTTON_PRESS:"offline-sound-press",HIT:"offline-sound-hit",SCORE:"offline-sound-reached"};Runner.keycodes={JUMP:{38:1,32:1},DUCK:{40:1},RESTART:{13:1}};Runner.events={ANIM_END:"webkitAnimationEnd",CLICK:"click",KEYDOWN:"keydown",KEYUP:"keyup",POINTERDOWN:"pointerdown",POINTERUP:"pointerup",RESIZE:"resize",TOUCHEND:"touchend",TOUCHSTART:"touchstart",VISIBILITY:"visibilitychange",BLUR:"blur",FOCUS:"focus",LOAD:"load",GAMEPADCONNECTED:"gamepadconnected"};Runner.prototype={initAltGameType(){if(GAME_TYPE.length>0){this.gameType=loadTimeData&&loadTimeData.valueExists("altGameType")?GAME_TYPE[parseInt(loadTimeData.getValue("altGameType"),10)-1]:""}},isDisabled(){return loadTimeData&&loadTimeData.valueExists("disabledEasterEgg")},setupDisabledRunner(){this.containerEl=document.createElement("div");this.containerEl.className=Runner.classes.SNACKBAR;this.containerEl.textContent=loadTimeData.getValue("disabledEasterEgg");this.outerContainerEl.appendChild(this.containerEl);document.addEventListener(Runner.events.KEYDOWN,function(e){if(Runner.keycodes.JUMP[e.keyCode]){this.containerEl.classList.add(Runner.classes.SNACKBAR_SHOW);document.querySelector(".icon").classList.add("icon-disabled")}}.bind(this))},updateConfigSetting(setting,value){if(setting in this.config&&value!==undefined){this.config[setting]=value;switch(setting){case"GRAVITY":case"MIN_JUMP_HEIGHT":case"SPEED_DROP_COEFFICIENT":this.tRex.config[setting]=value;break;case"INITIAL_JUMP_VELOCITY":this.tRex.setJumpVelocity(value);break;case"SPEED":this.setSpeed(value);break}}},createImageElement(resourceName){const imgSrc=loadTimeData&&loadTimeData.valueExists(resourceName)?loadTimeData.getString(resourceName):null;if(imgSrc){const el=document.createElement("img");el.id=resourceName;el.src=imgSrc;document.getElementById("offline-resources").appendChild(el);return el}return null},loadImages(){let scale="1x";this.spriteDef=Runner.spriteDefinition.LDPI;if(IS_HIDPI){scale="2x";this.spriteDef=Runner.spriteDefinition.HDPI}Runner.imageSprite=document.getElementById(RESOURCE_POSTFIX+scale);if(this.gameType){Runner.altGameImageSprite=this.createImageElement("altGameSpecificImage"+scale);Runner.altCommonImageSprite=this.createImageElement("altGameCommonImage"+scale)}Runner.origImageSprite=Runner.imageSprite;if(!Runner.altGameImageSprite||!Runner.altCommonImageSprite){Runner.isAltGameModeEnabled=()=>false;this.altGameModeActive=false}if(Runner.imageSprite.complete){this.init()}else{Runner.imageSprite.addEventListener(Runner.events.LOAD,this.init.bind(this))}},loadSounds(){if(!IS_IOS){this.audioContext=new AudioContext;const resourceTemplate=document.getElementById(this.config.RESOURCE_TEMPLATE_ID).content;for(const sound in Runner.sounds){let soundSrc=resourceTemplate.getElementById(Runner.sounds[sound]).src;soundSrc=soundSrc.substr(soundSrc.indexOf(",")+1);const buffer=decodeBase64ToArrayBuffer(soundSrc);this.audioContext.decodeAudioData(buffer,function(index,audioData){this.soundFx[index]=audioData}.bind(this,sound))}}},setSpeed(opt_speed){const speed=opt_speed||this.currentSpeed;if(this.dimensions.widthspeed?speed:mobileSpeed}else if(opt_speed){this.currentSpeed=opt_speed}},init(){document.querySelector("."+Runner.classes.ICON).style.visibility="hidden";if(this.isArcadeMode()){document.title=document.title+" - "+getA11yString(A11Y_STRINGS.ariaLabel)}this.adjustDimensions();this.setSpeed();const ariaLabel=getA11yString(A11Y_STRINGS.ariaLabel);this.containerEl=document.createElement("div");this.containerEl.setAttribute("role",IS_MOBILE?"button":"application");this.containerEl.setAttribute("tabindex","0");this.containerEl.setAttribute("title",getA11yString(A11Y_STRINGS.description));this.containerEl.setAttribute("aria-label",ariaLabel);this.containerEl.className=Runner.classes.CONTAINER;this.canvas=createCanvas(this.containerEl,this.dimensions.width,this.dimensions.height);this.a11yStatusEl=document.createElement("span");this.a11yStatusEl.className="offline-runner-live-region";this.a11yStatusEl.setAttribute("aria-live","assertive");this.a11yStatusEl.textContent="";Runner.a11yStatusEl=this.a11yStatusEl;this.slowSpeedCheckboxLabel=document.createElement("label");this.slowSpeedCheckboxLabel.className="slow-speed-option hidden";this.slowSpeedCheckboxLabel.textContent=getA11yString(A11Y_STRINGS.speedLabel);this.slowSpeedCheckbox=document.createElement("input");this.slowSpeedCheckbox.setAttribute("type","checkbox");this.slowSpeedCheckbox.setAttribute("title",getA11yString(A11Y_STRINGS.speedLabel));this.slowSpeedCheckbox.setAttribute("tabindex","0");this.slowSpeedCheckbox.setAttribute("checked","checked");this.slowSpeedToggleEl=document.createElement("span");this.slowSpeedToggleEl.className="slow-speed-toggle";this.slowSpeedCheckboxLabel.appendChild(this.slowSpeedCheckbox);this.slowSpeedCheckboxLabel.appendChild(this.slowSpeedToggleEl);if(IS_IOS){this.outerContainerEl.appendChild(this.a11yStatusEl)}else{this.containerEl.appendChild(this.a11yStatusEl)}this.canvasCtx=this.canvas.getContext("2d");this.canvasCtx.fillStyle="#f7f7f7";this.canvasCtx.fill();Runner.updateCanvasScaling(this.canvas);this.horizon=new Horizon(this.canvas,this.spriteDef,this.dimensions,this.config.GAP_COEFFICIENT);this.distanceMeter=new DistanceMeter(this.canvas,this.spriteDef.TEXT_SPRITE,this.dimensions.width);this.tRex=new Trex(this.canvas,this.spriteDef.TREX);this.outerContainerEl.appendChild(this.containerEl);this.outerContainerEl.appendChild(this.slowSpeedCheckboxLabel);this.startListening();this.update();window.addEventListener(Runner.events.RESIZE,this.debounceResize.bind(this));const darkModeMediaQuery=window.matchMedia("(prefers-color-scheme: dark)");this.isDarkMode=darkModeMediaQuery&&darkModeMediaQuery.matches;darkModeMediaQuery.addListener((e=>{this.isDarkMode=e.matches}))},createTouchController(){this.touchController=document.createElement("div");this.touchController.className=Runner.classes.TOUCH_CONTROLLER;this.touchController.addEventListener(Runner.events.TOUCHSTART,this);this.touchController.addEventListener(Runner.events.TOUCHEND,this);this.outerContainerEl.appendChild(this.touchController)},debounceResize(){if(!this.resizeTimerId_){this.resizeTimerId_=setInterval(this.adjustDimensions.bind(this),250)}},adjustDimensions(){clearInterval(this.resizeTimerId_);this.resizeTimerId_=null;const boxStyles=window.getComputedStyle(this.outerContainerEl);const padding=Number(boxStyles.paddingLeft.substr(0,boxStyles.paddingLeft.length-2));this.dimensions.width=this.outerContainerEl.offsetWidth-padding*2;if(this.isArcadeMode()){this.dimensions.width=Math.min(DEFAULT_WIDTH,this.dimensions.width);if(this.activated){this.setArcadeModeContainerScale()}}if(this.canvas){this.canvas.width=this.dimensions.width;this.canvas.height=this.dimensions.height;Runner.updateCanvasScaling(this.canvas);this.distanceMeter.calcXPos(this.dimensions.width);this.clearCanvas();this.horizon.update(0,0,true);this.tRex.update(0);if(this.playing||this.crashed||this.paused){this.containerEl.style.width=this.dimensions.width+"px";this.containerEl.style.height=this.dimensions.height+"px";this.distanceMeter.update(0,Math.ceil(this.distanceRan));this.stop()}else{this.tRex.draw(0,0)}if(this.crashed&&this.gameOverPanel){this.gameOverPanel.updateDimensions(this.dimensions.width);this.gameOverPanel.draw(this.altGameModeActive,this.tRex)}}},playIntro(){if(!this.activated&&!this.crashed){this.playingIntro=true;this.tRex.playingIntro=true;const keyframes="@-webkit-keyframes intro { "+"from { width:"+Trex.config.WIDTH+"px }"+"to { width: "+this.dimensions.width+"px }"+"}";document.styleSheets[0].insertRule(keyframes,0);this.containerEl.addEventListener(Runner.events.ANIM_END,this.startGame.bind(this));this.containerEl.style.webkitAnimation="intro .4s ease-out 1 both";this.containerEl.style.width=this.dimensions.width+"px";this.setPlayStatus(true);this.activated=true}else if(this.crashed){this.restart()}},startGame(){if(this.isArcadeMode()){this.setArcadeMode()}this.toggleSpeed();this.runningTime=0;this.playingIntro=false;this.tRex.playingIntro=false;this.containerEl.style.webkitAnimation="";this.playCount++;if(Runner.audioCues){this.generatedSoundFx.background();this.containerEl.setAttribute("title",getA11yString(A11Y_STRINGS.jump))}document.addEventListener(Runner.events.VISIBILITY,this.onVisibilityChange.bind(this));window.addEventListener(Runner.events.BLUR,this.onVisibilityChange.bind(this));window.addEventListener(Runner.events.FOCUS,this.onVisibilityChange.bind(this))},clearCanvas(){this.canvasCtx.clearRect(0,0,this.dimensions.width,this.dimensions.height)},isCanvasInView(){return this.containerEl.getBoundingClientRect().top>Runner.config.CANVAS_IN_VIEW_OFFSET},enableAltGameMode(){Runner.imageSprite=Runner.altGameImageSprite;Runner.spriteDefinition=spriteDefinitionByType[Runner.gameType];if(IS_HIDPI){this.spriteDef=Runner.spriteDefinition.HDPI}else{this.spriteDef=Runner.spriteDefinition.LDPI}this.altGameModeActive=true;this.tRex.enableAltGameMode(this.spriteDef.TREX);this.horizon.enableAltGameMode(this.spriteDef);if(Runner.audioCues){this.generatedSoundFx.background()}},update(){this.updatePending=false;const now=getTimeStamp();let deltaTime=now-(this.time||now);if(this.altGameModeFlashTimer<0||this.altGameModeFlashTimer===0){this.altGameModeFlashTimer=null;this.tRex.setFlashing(false);this.enableAltGameMode()}else if(this.altGameModeFlashTimer>0){this.altGameModeFlashTimer-=deltaTime;this.tRex.update(deltaTime);deltaTime=0}this.time=now;if(this.playing){this.clearCanvas();if(this.altGameModeActive&&this.fadeInTimer<=this.config.FADE_DURATION){this.fadeInTimer+=deltaTime/1e3;this.canvasCtx.globalAlpha=this.fadeInTimer}else{this.canvasCtx.globalAlpha=1}if(this.tRex.jumping){this.tRex.updateJump(deltaTime)}this.runningTime+=deltaTime;const hasObstacles=this.runningTime>this.config.CLEAR_TIME;if(this.tRex.jumpCount===1&&!this.playingIntro){this.playIntro()}if(this.playingIntro){this.horizon.update(0,this.currentSpeed,hasObstacles)}else if(!this.crashed){const showNightMode=this.isDarkMode^this.inverted;deltaTime=!this.activated?0:deltaTime;this.horizon.update(deltaTime,this.currentSpeed,hasObstacles,showNightMode)}let collision=hasObstacles&&checkForCollision(this.horizon.obstacles[0],this.tRex);if(Runner.audioCues&&hasObstacles){const jumpObstacle=this.horizon.obstacles[0].typeConfig.type!=="COLLECTABLE";if(!this.horizon.obstacles[0].jumpAlerted){const threshold=Runner.isMobileMouseInput?Runner.config.AUDIOCUE_PROXIMITY_THRESHOLD_MOBILE_A11Y:Runner.config.AUDIOCUE_PROXIMITY_THRESHOLD;const adjProximityThreshold=threshold+threshold*Math.log10(this.currentSpeed/Runner.config.SPEED);if(this.horizon.obstacles[0].xPosthis.config.INVERT_FADE_DURATION){this.invertTimer=0;this.invertTrigger=false;this.invert(false)}else if(this.invertTimer){this.invertTimer+=deltaTime}else{const actualDistance=this.distanceMeter.getActualDistance(Math.ceil(this.distanceRan));if(actualDistance>0){this.invertTrigger=!(actualDistance%this.config.INVERT_DISTANCE);if(this.invertTrigger&&this.invertTimer===0){this.invertTimer+=deltaTime;this.invert(false)}}}}}if(this.playing||!this.activated&&this.tRex.blinkCount=this.config.GAMEOVER_CLEAR_TIME&&Runner.keycodes.JUMP[keyCode])){this.handleGameOverClicks(e)}}else if(this.paused&&isjumpKey){this.tRex.reset();this.play()}},onGamepadConnected(e){if(!this.pollingGamepads){this.pollGamepadState()}},pollGamepadState(){const gamepads=navigator.getGamepads();this.pollActiveGamepad(gamepads);this.pollingGamepads=true;requestAnimationFrame(this.pollGamepadState.bind(this))},pollForActiveGamepad(gamepads){for(let i=0;i0&&gamepads[i].buttons[0].pressed){this.gamepadIndex=i;this.pollActiveGamepad(gamepads);return}}},pollActiveGamepad(gamepads){if(this.gamepadIndex===undefined){this.pollForActiveGamepad(gamepads);return}const gamepad=gamepads[this.gamepadIndex];if(!gamepad){this.gamepadIndex=undefined;this.pollForActiveGamepad(gamepads);return}this.pollGamepadButton(gamepad,0,38);if(gamepad.buttons.length>=2){this.pollGamepadButton(gamepad,1,40)}if(gamepad.buttons.length>=10){this.pollGamepadButton(gamepad,9,13)}this.previousGamepad=gamepad},pollGamepadButton(gamepad,buttonIndex,keyCode){const state=gamepad.buttons[buttonIndex].pressed;let previousState=false;if(this.previousGamepad){previousState=this.previousGamepad.buttons[buttonIndex].pressed}if(state!==previousState){const e=new KeyboardEvent(state?Runner.events.KEYDOWN:Runner.events.KEYUP,{keyCode:keyCode});document.dispatchEvent(e)}},handleGameOverClicks(e){if(e.target!==this.slowSpeedCheckbox){e.preventDefault();if(this.distanceMeter.hasClickedOnHighScore(e)&&this.highestScore){if(this.distanceMeter.isHighScoreFlashing()){this.saveHighScore(0,true);this.distanceMeter.resetHighScore()}else{this.distanceMeter.startHighScoreFlashing()}}else{this.distanceMeter.cancelHighScoreFlashing();this.restart()}}},isLeftClickOnCanvas(e){return e.button!=null&&e.button<2&&e.type===Runner.events.POINTERUP&&(e.target===this.canvas||IS_MOBILE&&Runner.audioCues&&e.target===this.containerEl)},scheduleNextUpdate(){if(!this.updatePending){this.updatePending=true;this.raqId=requestAnimationFrame(this.update.bind(this))}},isRunning(){return!!this.raqId},initializeHighScore(highScore){this.syncHighestScore=true;highScore=Math.ceil(highScore);if(highScorethis.highestScore){this.saveHighScore(this.distanceRan)}this.time=getTimeStamp();if(Runner.audioCues){this.generatedSoundFx.stopAll();announcePhrase(getA11yString(A11Y_STRINGS.gameOver).replace("$1",this.distanceMeter.getActualDistance(this.distanceRan).toString())+" "+getA11yString(A11Y_STRINGS.highScore).replace("$1",this.distanceMeter.getActualDistance(this.highestScore).toString()));this.containerEl.setAttribute("title",getA11yString(A11Y_STRINGS.ariaLabel))}this.showSpeedToggle();this.disableSpeedToggle(false)},stop(){this.setPlayStatus(false);this.paused=true;cancelAnimationFrame(this.raqId);this.raqId=0;if(Runner.audioCues){this.generatedSoundFx.stopAll()}},play(){if(!this.crashed){this.setPlayStatus(true);this.paused=false;this.tRex.update(0,Trex.status.RUNNING);this.time=getTimeStamp();this.update();if(Runner.audioCues){this.generatedSoundFx.background()}}},restart(){if(!this.raqId){this.playCount++;this.runningTime=0;this.setPlayStatus(true);this.toggleSpeed();this.paused=false;this.crashed=false;this.distanceRan=0;this.setSpeed(this.config.SPEED);this.time=getTimeStamp();this.containerEl.classList.remove(Runner.classes.CRASHED);this.clearCanvas();this.distanceMeter.reset();this.horizon.reset();this.tRex.reset();this.playSound(this.soundFx.BUTTON_PRESS);this.invert(true);this.flashTimer=null;this.update();this.gameOverPanel.reset();if(Runner.audioCues){this.generatedSoundFx.background()}this.containerEl.setAttribute("title",getA11yString(A11Y_STRINGS.jump));announcePhrase(getA11yString(A11Y_STRINGS.started))}},setPlayStatus(isPlaying){if(this.touchController){this.touchController.classList.toggle(HIDDEN_CLASS,!isPlaying)}this.playing=isPlaying},isArcadeMode(){return IS_RTL?document.title.indexOf(ARCADE_MODE_URL)===1:document.title===ARCADE_MODE_URL},setArcadeMode(){document.body.classList.add(Runner.classes.ARCADE_MODE);this.setArcadeModeContainerScale()},setArcadeModeContainerScale(){const windowHeight=window.innerHeight;const scaleHeight=windowHeight/this.dimensions.height;const scaleWidth=window.innerWidth/this.dimensions.width;const scale=Math.max(1,Math.min(scaleHeight,scaleWidth));const scaledCanvasHeight=this.dimensions.height*scale;const translateY=Math.ceil(Math.max(0,(windowHeight-scaledCanvasHeight-Runner.config.ARCADE_MODE_INITIAL_TOP_POSITION)*Runner.config.ARCADE_MODE_TOP_POSITION_PERCENT))*window.devicePixelRatio;const cssScale=IS_RTL?-scale+","+scale:scale;this.containerEl.style.transform="scale("+cssScale+") translateY("+translateY+"px)"},onVisibilityChange(e){if(document.hidden||document.webkitHidden||e.type==="blur"||document.visibilityState!=="visible"){this.stop()}else if(!this.crashed){this.tRex.reset();this.play()}},playSound(soundBuffer){if(soundBuffer){const sourceNode=this.audioContext.createBufferSource();sourceNode.buffer=soundBuffer;sourceNode.connect(this.audioContext.destination);sourceNode.start(0)}},invert(reset){const htmlEl=document.firstElementChild;if(reset){htmlEl.classList.toggle(Runner.classes.INVERTED,false);this.invertTimer=0;this.inverted=false}else{this.inverted=htmlEl.classList.toggle(Runner.classes.INVERTED,this.invertTrigger)}}};Runner.updateCanvasScaling=function(canvas,opt_width,opt_height){const context=canvas.getContext("2d");const devicePixelRatio=Math.floor(window.devicePixelRatio)||1;const backingStoreRatio=Math.floor(context.webkitBackingStorePixelRatio)||1;const ratio=devicePixelRatio/backingStoreRatio;if(devicePixelRatio!==backingStoreRatio){const oldWidth=opt_width||canvas.width;const oldHeight=opt_height||canvas.height;canvas.width=oldWidth*ratio;canvas.height=oldHeight*ratio;canvas.style.width=oldWidth+"px";canvas.style.height=oldHeight+"px";context.scale(ratio,ratio);return true}else if(devicePixelRatio===1){canvas.style.width=canvas.width+"px";canvas.style.height=canvas.height+"px"}return false};Runner.isAltGameModeEnabled=function(){return loadTimeData&&loadTimeData.valueExists("enableAltGameMode")};function announcePhrase(phrase){if(Runner.a11yStatusEl){Runner.a11yStatusEl.textContent="";Runner.a11yStatusEl.textContent=phrase}}function getA11yString(stringName){return loadTimeData&&loadTimeData.valueExists(stringName)?loadTimeData.getString(stringName):""}function vibrate(duration){if(IS_MOBILE&&window.navigator.vibrate){window.navigator.vibrate(duration)}}function createCanvas(container,width,height,opt_classname){const canvas=document.createElement("canvas");canvas.className=Runner.classes.CANVAS;canvas.width=width;canvas.height=height;container.appendChild(canvas);return canvas}function decodeBase64ToArrayBuffer(base64String){const len=base64String.length/4*3;const str=atob(base64String);const arrayBuffer=new ArrayBuffer(len);const bytes=new Uint8Array(arrayBuffer);for(let i=0;iobstacleBoxX&&tRexBox.yobstacleBox.y){crashed=true}return crashed} // Copyright 2013 The Chromium Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. let showingDetails=false;let lastData=null;function toggleHelpBox(){showingDetails=!showingDetails;assert(lastData);B(getHtml(lastData,showingDetails),getRequiredElement("content"))}function diagnoseErrors(){if(window.errorPageController){window.errorPageController.diagnoseErrorsButtonClick()}}function portalSignin(){if(window.errorPageController){window.errorPageController.portalSigninButtonClick()}}let isSubFrame=false;if(window.top.location!==window.location){document.documentElement.setAttribute("subframe","");isSubFrame=true}function updateForDnsProbe(newData){onTemplateDataReceived(newData)}function getMainFrameErrorCssClass(showingDetails){return showingDetails?"showing-details":""}function getMainFrameErrorIconCssClass(data){return isSubFrame?"":data.iconClass}function getSubFrameErrorIconCssClass(data){return isSubFrame?data.iconClass:""}function shouldShowSuggestionsSummaryList(data){return!!data.suggestionsSummaryList&&data.suggestionsSummaryList.length>0}function getSuggestionsSummaryItemCssClass(data){assert(data.suggestionsSummaryList);return data.suggestionsSummaryList.length===1?"single-suggestion":""}function reloadButtonClick(e){const url=e.target.dataset["url"];if(window.errorPageController){window.errorPageController.reloadButtonClick()}else{assert(url);window.location.href=url}}function downloadButtonClick(){if(window.errorPageController){window.errorPageController.downloadButtonClick();const downloadButton=getRequiredElement("download-button");downloadButton.disabled=true;downloadButton.textContent=downloadButton.disabledText}}function detailsButtonClick(){if(window.errorPageController){window.errorPageController.detailsButtonClick()}toggleHelpBox()}function setAutoFetchState(scheduled,canSchedule){getRequiredElement("cancel-save-page-button").classList.toggle(HIDDEN_CLASS,!scheduled);getRequiredElement("save-page-for-later-button").classList.toggle(HIDDEN_CLASS,!canSchedule)}function savePageLaterClick(){assert(window.errorPageController);window.errorPageController.savePageForLater()}function cancelSavePageClick(){assert(window.errorPageController);window.errorPageController.cancelSavePage();setAutoFetchState(false,true)}function shouldShowControlButtons(data){const downloadButtonVisible=!!data.downloadButton&&!!data.downloadButton.msg;const reloadButtonVisible=!!data.reloadButton&&!!data.reloadButton.msg;return reloadButtonVisible||downloadButtonVisible}function shouldShowDetailsButton(data){return!!data.suggestionsDetails&&data.suggestionsDetails.length>0}function getDetailsButtonCssClass(data){return shouldShowControlButtons(data)?"":"singular"}function getDetailsButtonText(data,showingDetails){assert(data.details);assert(data.hideDetails);return showingDetails?data.hideDetails:data.details}function getButtonsCssClass(){let primaryControlOnLeft=true;primaryControlOnLeft=false;return primaryControlOnLeft?"suggested-left":"suggested-right"}function onDocumentLoad(){onTemplateDataReceived(window.loadTimeDataRaw)}function onTemplateDataReceived(newData){lastData=newData;B(getHtml(lastData,showingDetails),getRequiredElement("content"));if(!isSubFrame&&newData.iconClass==="icon-offline"){document.documentElement.classList.add("offline");loadTimeData.data=newData;new Runner(".interstitial-wrapper")}}function getHtml(data,showingDetails){return x`

${data.summary?x`

`:""} ${shouldShowSuggestionsSummaryList(data)?x`

${data.suggestionsSummaryListHeader}

    ${data.suggestionsSummaryList.map((item=>x`
  • `))}
`:""}
${data.errorCode}
${data.savePageLater?x` `:""}
${data.suggestionsDetails?x`
${data.suggestionsDetails.map((item=>x`
`))}
`:""}
${data.summary?x`
`:""} `}Object.assign(window,{diagnoseErrors:diagnoseErrors,portalSignin:portalSignin,toggleHelpBox:toggleHelpBox,updateForDnsProbe:updateForDnsProbe});document.addEventListener("DOMContentLoaded",onDocumentLoad);

This site can’t be reached

werfenweng.skiperformance.com unexpectedly closed the connection.

Try:

ERR_CONNECTION_CLOSED
Check your Internet connection
Check any cables and reboot any routers, modems, or other network devices you may be using.
Allow Chrome to access the network in your firewall or antivirus settings.
If it is already listed as a program allowed to access the network, try removing it from the list and adding it again.
If you use a proxy server…
Go to the Chrome menu > Settings > Show advanced settings… > Change proxy settings… and make sure your configuration is set to "no proxy" or "direct."
werfenweng.skiperformance.com unexpectedly closed the connection.